Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HasTrait.php « databasetraits « database « src - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 53d2b7230cf786680240ba57773be96026f05c69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
<?php

/**
 * PHPPgAdmin 6.1.2
 */

namespace PHPPgAdmin\Database\Traits;

/**
 * Common trait for flags telling if the driver supports certain attributes/operations.
 */
trait HasTrait
{
    public $conn;

    // The backend platform.  Set to UNKNOWN by default.
    public $platform = 'UNKNOWN';

    /** @var string */

    /**
     * @var float
     */
    public $major_version = 9.6;

    // Max object name length
    public $_maxNameLen = 63;

    // Store the current schema
    public $_schema;

    // Map of database encoding names to HTTP encoding names.  If a
    // database encoding does not appear in this list, then its HTTP
    // encoding name is the same as its database encoding name.
    public $codemap = [
        'BIG5' => 'BIG5',
        'EUC_CN' => 'GB2312',
        'EUC_JP' => 'EUC-JP',
        'EUC_KR' => 'EUC-KR',
        'EUC_TW' => 'EUC-TW',
        'GB18030' => 'GB18030',
        'GBK' => 'GB2312',
        'ISO_8859_5' => 'ISO-8859-5',
        'ISO_8859_6' => 'ISO-8859-6',
        'ISO_8859_7' => 'ISO-8859-7',
        'ISO_8859_8' => 'ISO-8859-8',
        'JOHAB' => 'CP1361',
        'KOI8' => 'KOI8-R',
        'LATIN1' => 'ISO-8859-1',
        'LATIN2' => 'ISO-8859-2',
        'LATIN3' => 'ISO-8859-3',
        'LATIN4' => 'ISO-8859-4',
        'LATIN5' => 'ISO-8859-9',
        'LATIN6' => 'ISO-8859-10',
        'LATIN7' => 'ISO-8859-13',
        'LATIN8' => 'ISO-8859-14',
        'LATIN9' => 'ISO-8859-15',
        'LATIN10' => 'ISO-8859-16',
        'SJIS' => 'SHIFT_JIS',
        'SQL_ASCII' => 'US-ASCII',
        'UHC' => 'WIN949',
        'UTF8' => 'UTF-8',
        'WIN866' => 'CP866',
        'WIN874' => 'CP874',
        'WIN1250' => 'CP1250',
        'WIN1251' => 'CP1251',
        'WIN1252' => 'CP1252',
        'WIN1256' => 'CP1256',
        'WIN1258' => 'CP1258',
    ];

    public $defaultprops = ['', '', ''];

    // Extra "magic" types.  BIGSERIAL was added in PostgreSQL 7.2.
    public $extraTypes = ['SERIAL', 'BIGSERIAL'];

    // Foreign key stuff.  First element MUST be the default.
    public $fkactions = ['NO ACTION', 'RESTRICT', 'CASCADE', 'SET NULL', 'SET DEFAULT'];

    public $fkdeferrable = ['NOT DEFERRABLE', 'DEFERRABLE'];

    public $fkinitial = ['INITIALLY IMMEDIATE', 'INITIALLY DEFERRED'];

    public $fkmatches = ['MATCH SIMPLE', 'MATCH FULL'];

    // Function properties
    public $funcprops = [
        ['', 'VOLATILE', 'IMMUTABLE', 'STABLE'],
        ['', 'CALLED ON NULL INPUT', 'RETURNS NULL ON NULL INPUT'],
        ['', 'SECURITY INVOKER', 'SECURITY DEFINER'],
    ];

    // Default help URL
    public $help_base;

    // Help sub pages
    public $help_page;

    // Name of id column
    public $id = 'oid';

    // Supported join operations for use with view wizard
    public $joinOps = ['INNER JOIN' => 'INNER JOIN', 'LEFT JOIN' => 'LEFT JOIN', 'RIGHT JOIN' => 'RIGHT JOIN', 'FULL JOIN' => 'FULL JOIN'];

    // Map of internal language name to syntax highlighting name
    public $langmap = [
        'sql' => 'SQL',
        'plpgsql' => 'SQL',
        'php' => 'PHP',
        'phpu' => 'PHP',
        'plphp' => 'PHP',
        'plphpu' => 'PHP',
        'perl' => 'Perl',
        'perlu' => 'Perl',
        'plperl' => 'Perl',
        'plperlu' => 'Perl',
        'java' => 'Java',
        'javau' => 'Java',
        'pljava' => 'Java',
        'pljavau' => 'Java',
        'plj' => 'Java',
        'plju' => 'Java',
        'python' => 'Python',
        'pythonu' => 'Python',
        'plpython' => 'Python',
        'plpythonu' => 'Python',
        'ruby' => 'Ruby',
        'rubyu' => 'Ruby',
        'plruby' => 'Ruby',
        'plrubyu' => 'Ruby',
    ];

    // Predefined size types
    public $predefined_size_types = [
        'abstime',
        'aclitem',
        'bigserial',
        'boolean',
        'bytea',
        'cid',
        'cidr',
        'circle',
        'date',
        'float4',
        'float8',
        'gtsvector',
        'inet',
        'int2',
        'int4',
        'int8',
        'macaddr',
        'money',
        'oid',
        'path',
        'polygon',
        'refcursor',
        'regclass',
        'regoper',
        'regoperator',
        'regproc',
        'regprocedure',
        'regtype',
        'reltime',
        'serial',
        'smgr',
        'text',
        'tid',
        'tinterval',
        'tsquery',
        'tsvector',
        'varbit',
        'void',
        'xid',
    ];

    // List of all legal privileges that can be applied to different types
    // of objects.
    public $privlist = [
        'table' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
        'view' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
        'sequence' => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'],
        'database' => ['CREATE', 'TEMPORARY', 'CONNECT', 'ALL PRIVILEGES'],
        'function' => ['EXECUTE', 'ALL PRIVILEGES'],
        'language' => ['USAGE', 'ALL PRIVILEGES'],
        'schema' => ['CREATE', 'USAGE', 'ALL PRIVILEGES'],
        'tablespace' => ['CREATE', 'ALL PRIVILEGES'],
        'column' => ['SELECT', 'INSERT', 'UPDATE', 'REFERENCES', 'ALL PRIVILEGES'],
    ];

    // List of characters in acl lists and the privileges they
    // refer to.
    public $privmap = [
        'r' => 'SELECT',
        'w' => 'UPDATE',
        'a' => 'INSERT',
        'd' => 'DELETE',
        'D' => 'TRUNCATE',
        'R' => 'RULE',
        'x' => 'REFERENCES',
        't' => 'TRIGGER',
        'X' => 'EXECUTE',
        'U' => 'USAGE',
        'C' => 'CREATE',
        'T' => 'TEMPORARY',
        'c' => 'CONNECT',
    ];

    // Rule action types
    public $rule_events = ['SELECT', 'INSERT', 'UPDATE', 'DELETE'];

    // Select operators
    public $selectOps = [
        '=' => 'i',
        '!=' => 'i',
        '<' => 'i',
        '>' => 'i',
        '<=' => 'i',
        '>=' => 'i',
        '<<' => 'i',
        '>>' => 'i',
        '<<=' => 'i',
        '>>=' => 'i',
        'LIKE' => 'i',
        'NOT LIKE' => 'i',
        'ILIKE' => 'i',
        'NOT ILIKE' => 'i',
        'SIMILAR TO' => 'i',
        'NOT SIMILAR TO' => 'i',
        '~' => 'i',
        '!~' => 'i',
        '~*' => 'i',
        '!~*' => 'i',
        'IS NULL' => 'p',
        'IS NOT NULL' => 'p',
        'IN' => 'x',
        'NOT IN' => 'x',
        '@@' => 'i',
        '@@@' => 'i',
        '@>' => 'i',
        '<@' => 'i',
        '@@ to_tsquery' => 't',
        '@@@ to_tsquery' => 't',
        '@> to_tsquery' => 't',
        '<@ to_tsquery' => 't',
        '@@ plainto_tsquery' => 't',
        '@@@ plainto_tsquery' => 't',
        '@> plainto_tsquery' => 't',
        '<@ plainto_tsquery' => 't',
    ];

    // Array of allowed trigger events
    public $triggerEvents = [
        'INSERT',
        'UPDATE',
        'DELETE',
        'INSERT OR UPDATE',
        'INSERT OR DELETE',
        'DELETE OR UPDATE',
        'INSERT OR DELETE OR UPDATE',
    ];

    // When to execute the trigger
    public $triggerExecTimes = ['BEFORE', 'AFTER'];

    // How often to execute the trigger
    public $triggerFrequency = ['ROW', 'STATEMENT'];

    // Array of allowed type alignments
    public $typAligns = ['char', 'int2', 'int4', 'double'];

    // The default type alignment
    public $typAlignDef = 'int4';

    // Default index type
    public $typIndexDef = 'BTREE';

    // Array of allowed index types
    public $typIndexes = ['BTREE', 'RTREE', 'GIST', 'GIN', 'HASH'];

    // Array of allowed type storage attributes
    public $typStorages = ['plain', 'external', 'extended', 'main'];

    // The default type storage
    public $typStorageDef = 'plain';

    /**
     * Determines if it has tablespaces.
     *
     * @return bool true if has tablespaces, False otherwise
     */
    public function hasTablespaces()
    {
        return true;
    }

    /**
     * Determines if it has shared comments.
     *
     * @return bool true if has shared comments, False otherwise
     */
    public function hasSharedComments()
    {
        return true;
    }

    /**
     * Determines if it has roles.
     *
     * @return bool true if has roles, False otherwise
     */
    public function hasRoles()
    {
        return true;
    }

    /**
     * Determines if it has grant option.
     *
     * @return bool true if has grant option, False otherwise
     */
    public function hasGrantOption()
    {
        return true;
    }

    /**
     * Determines if it has create table like with constraints.
     *
     * @return bool true if has create table like with constraints, False otherwise
     */
    public function hasCreateTableLikeWithConstraints()
    {
        return true;
    }

    /**
     * Determines if it has create table like with indexes.
     *
     * @return bool true if has create table like with indexes, False otherwise
     */
    public function hasCreateTableLikeWithIndexes()
    {
        return true;
    }

    /**
     * Determines if it has create field with constraints.
     *
     * @return bool true if has create field with constraints, False otherwise
     */
    public function hasCreateFieldWithConstraints()
    {
        return true;
    }

    /**
     * Determines if it has domain constraints.
     *
     * @return bool true if has domain constraints, False otherwise
     */
    public function hasDomainConstraints()
    {
        return true;
    }

    /**
     * Determines if it has function alter owner.
     *
     * @return bool true if has function alter owner, False otherwise
     */
    public function hasFunctionAlterOwner()
    {
        return true;
    }

    /**
     * Determines if it has function alter schema.
     *
     * @return bool true if has function alter schema, False otherwise
     */
    public function hasFunctionAlterSchema()
    {
        return true;
    }

    /**
     * Determines if it has read only queries.
     *
     * @return bool true if has read only queries, False otherwise
     */
    public function hasReadOnlyQueries()
    {
        return true;
    }

    /**
     * Determines if it has aggregate sort operation.
     *
     * @return bool true if has aggregate sort operation, False otherwise
     */
    public function hasAggregateSortOp()
    {
        return true;
    }

    /**
     * Determines if it has alter aggregate.
     *
     * @return bool true if has alter aggregate, False otherwise
     */
    public function hasAlterAggregate()
    {
        return true;
    }

    /**
     * Determines if it has alter column type.
     *
     * @return bool true if has alter column type, False otherwise
     */
    public function hasAlterColumnType()
    {
        return true;
    }

    /**
     * Determines if it has alter database owner.
     *
     * @return bool true if has alter database owner, False otherwise
     */
    public function hasAlterDatabaseOwner()
    {
        return true;
    }

    /**
     * Determines if it has alter schema.
     *
     * @return bool true if has alter schema, False otherwise
     */
    public function hasAlterSchema()
    {
        return true;
    }

    /**
     * Determines if it has alter schema owner.
     *
     * @return bool true if has alter schema owner, False otherwise
     */
    public function hasAlterSchemaOwner()
    {
        return true;
    }

    /**
     * Determines if it has alter sequence schema.
     *
     * @return bool true if has alter sequence schema, False otherwise
     */
    public function hasAlterSequenceSchema()
    {
        return true;
    }

    /**
     * Determines if it has alter sequence start.
     *
     * @return bool true if has alter sequence start, False otherwise
     */
    public function hasAlterSequenceStart()
    {
        return true;
    }

    /**
     * Determines if it has alter table schema.
     *
     * @return bool true if has alter table schema, False otherwise
     */
    public function hasAlterTableSchema()
    {
        return true;
    }

    /**
     * Determines if it has autovacuum.
     *
     * @return bool true if has autovacuum, False otherwise
     */
    public function hasAutovacuum()
    {
        return true;
    }

    /**
     * Determines if it has create table like.
     *
     * @return bool true if has create table like, False otherwise
     */
    public function hasCreateTableLike()
    {
        return true;
    }

    /**
     * Determines if it has disable triggers.
     *
     * @return bool true if has disable triggers, False otherwise
     */
    public function hasDisableTriggers()
    {
        return true;
    }

    /**
     * Determines if it has alter domains.
     *
     * @return bool true if has alter domains, False otherwise
     */
    public function hasAlterDomains()
    {
        return true;
    }

    /**
     * Determines if it has enum types.
     *
     * @return bool true if has enum types, False otherwise
     */
    public function hasEnumTypes()
    {
        return true;
    }

    /**
     * Determines if it has fts.
     *
     * @return bool true if has fts, False otherwise
     */
    public function hasFTS()
    {
        return true;
    }

    /**
     * Determines if it has function costing.
     *
     * @return bool true if has function costing, False otherwise
     */
    public function hasFunctionCosting()
    {
        return true;
    }

    /**
     * Determines if it has function guc.
     *
     * @return bool true if has function guc, False otherwise
     */
    public function hasFunctionGUC()
    {
        return true;
    }

    /**
     * Determines if it has named parameters.
     *
     * @return bool true if has named parameters, False otherwise
     */
    public function hasNamedParams()
    {
        return true;
    }

    /**
     * Determines if it has prepare.
     *
     * @return bool true if has prepare, False otherwise
     */
    public function hasPrepare()
    {
        return true;
    }

    /**
     * Determines if it has prepared xacts.
     *
     * @return bool true if has prepared xacts, False otherwise
     */
    public function hasPreparedXacts()
    {
        return true;
    }

    /**
     * Determines if it has recluster.
     *
     * @return bool true if has recluster, False otherwise
     */
    public function hasRecluster()
    {
        return true;
    }

    /**
     * Determines if it has server admin funcs.
     *
     * @return bool true if has server admin funcs, False otherwise
     */
    public function hasServerAdminFuncs()
    {
        return true;
    }

    /**
     * Determines if it has query cancel.
     *
     * @return bool true if has query cancel, False otherwise
     */
    public function hasQueryCancel()
    {
        return true;
    }

    /**
     * Determines if it has user rename.
     *
     * @return bool true if has user rename, False otherwise
     */
    public function hasUserRename()
    {
        return true;
    }

    /**
     * Determines if it has user signals.
     *
     * @return bool true if has user signals, False otherwise
     */
    public function hasUserSignals()
    {
        return true;
    }

    /**
     * Determines if it has virtual transaction identifier.
     *
     * @return bool true if has virtual transaction identifier, False otherwise
     */
    public function hasVirtualTransactionId()
    {
        return true;
    }

    /**
     * Determines if it has alter database.
     *
     * @return bool true if has alter database, False otherwise
     */
    public function hasAlterDatabase()
    {
        return $this->hasAlterDatabaseRename();
    }

    /**
     * Determines if it has alter database rename.
     *
     * @return bool true if has alter database rename, False otherwise
     */
    public function hasAlterDatabaseRename()
    {
        return true;
    }

    /**
     * Determines if it has database collation.
     *
     * @return bool true if has database collation, False otherwise
     */
    public function hasDatabaseCollation()
    {
        return true;
    }

    /**
     * Determines if it has magic types.
     *
     * @return bool true if has magic types, False otherwise
     */
    public function hasMagicTypes()
    {
        return true;
    }

    /**
     * Determines if it has query kill.
     *
     * @return bool true if has query kill, False otherwise
     */
    public function hasQueryKill()
    {
        return true;
    }

    /**
     * Determines if it has concurrent index build.
     *
     * @return bool true if has concurrent index build, False otherwise
     */
    public function hasConcurrentIndexBuild()
    {
        return true;
    }

    /**
     * Determines if it has force reindex.
     *
     * @return bool true if has force reindex, False otherwise
     */
    public function hasForceReindex()
    {
        return false;
    }

    /**
     * Determines if it has bytea hexadecimal default.
     *
     * @return bool true if has bytea hexadecimal default, False otherwise
     */
    public function hasByteaHexDefault()
    {
        return true;
    }
}