40
40
#ifdef USE_READLINE
41
41
42
42
#include <ctype.h>
43
+
44
+ #include "catalog/pg_class.h"
45
+
43
46
#include "libpq-fe.h"
44
47
#include "pqexpbuffer.h"
45
48
#include "common.h"
@@ -85,8 +88,9 @@ typedef struct SchemaQuery
85
88
/*
86
89
* Selection condition --- only rows meeting this condition are candidates
87
90
* to display. If catname mentions multiple tables, include the necessary
88
- * join condition here. For example, "c.relkind = 'r'". Write NULL (not
89
- * an empty string) if not needed.
91
+ * join condition here. For example, this might look like "c.relkind = "
92
+ * CppAsString2(RELKIND_RELATION). Write NULL (not an empty string) if
93
+ * not needed.
90
94
*/
91
95
const char * selcondition ;
92
96
@@ -361,7 +365,8 @@ static const SchemaQuery Query_for_list_of_datatypes = {
361
365
"pg_catalog.pg_type t" ,
362
366
/* selcondition --- ignore table rowtypes and array types */
363
367
"(t.typrelid = 0 "
364
- " OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) "
368
+ " OR (SELECT c.relkind = " CppAsString2 (RELKIND_COMPOSITE_TYPE )
369
+ " FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) "
365
370
"AND t.typname !~ '^_'" ,
366
371
/* viscondition */
367
372
"pg_catalog.pg_type_is_visible(t.oid)" ,
@@ -407,7 +412,7 @@ static const SchemaQuery Query_for_list_of_indexes = {
407
412
/* catname */
408
413
"pg_catalog.pg_class c" ,
409
414
/* selcondition */
410
- "c.relkind IN ('i' )" ,
415
+ "c.relkind IN (" CppAsString2 ( RELKIND_INDEX ) " )" ,
411
416
/* viscondition */
412
417
"pg_catalog.pg_table_is_visible(c.oid)" ,
413
418
/* namespace */
@@ -422,7 +427,7 @@ static const SchemaQuery Query_for_list_of_sequences = {
422
427
/* catname */
423
428
"pg_catalog.pg_class c" ,
424
429
/* selcondition */
425
- "c.relkind IN ('S' )" ,
430
+ "c.relkind IN (" CppAsString2 ( RELKIND_SEQUENCE ) " )" ,
426
431
/* viscondition */
427
432
"pg_catalog.pg_table_is_visible(c.oid)" ,
428
433
/* namespace */
@@ -437,7 +442,7 @@ static const SchemaQuery Query_for_list_of_foreign_tables = {
437
442
/* catname */
438
443
"pg_catalog.pg_class c" ,
439
444
/* selcondition */
440
- "c.relkind IN ('f' )" ,
445
+ "c.relkind IN (" CppAsString2 ( RELKIND_FOREIGN_TABLE ) " )" ,
441
446
/* viscondition */
442
447
"pg_catalog.pg_table_is_visible(c.oid)" ,
443
448
/* namespace */
@@ -452,7 +457,8 @@ static const SchemaQuery Query_for_list_of_tables = {
452
457
/* catname */
453
458
"pg_catalog.pg_class c" ,
454
459
/* selcondition */
455
- "c.relkind IN ('r', 'P')" ,
460
+ "c.relkind IN (" CppAsString2 (RELKIND_RELATION ) ", "
461
+ CppAsString2 (RELKIND_PARTITIONED_TABLE ) ")" ,
456
462
/* viscondition */
457
463
"pg_catalog.pg_table_is_visible(c.oid)" ,
458
464
/* namespace */
@@ -467,7 +473,7 @@ static const SchemaQuery Query_for_list_of_partitioned_tables = {
467
473
/* catname */
468
474
"pg_catalog.pg_class c" ,
469
475
/* selcondition */
470
- "c.relkind IN ('P' )" ,
476
+ "c.relkind IN (" CppAsString2 ( RELKIND_PARTITIONED_TABLE ) " )" ,
471
477
/* viscondition */
472
478
"pg_catalog.pg_table_is_visible(c.oid)" ,
473
479
/* namespace */
@@ -498,7 +504,10 @@ static const SchemaQuery Query_for_list_of_updatables = {
498
504
/* catname */
499
505
"pg_catalog.pg_class c" ,
500
506
/* selcondition */
501
- "c.relkind IN ('r', 'f', 'v', 'P')" ,
507
+ "c.relkind IN (" CppAsString2 (RELKIND_RELATION ) ", "
508
+ CppAsString2 (RELKIND_FOREIGN_TABLE ) ", "
509
+ CppAsString2 (RELKIND_VIEW ) ", "
510
+ CppAsString2 (RELKIND_PARTITIONED_TABLE ) ")" ,
502
511
/* viscondition */
503
512
"pg_catalog.pg_table_is_visible(c.oid)" ,
504
513
/* namespace */
@@ -528,7 +537,12 @@ static const SchemaQuery Query_for_list_of_tsvmf = {
528
537
/* catname */
529
538
"pg_catalog.pg_class c" ,
530
539
/* selcondition */
531
- "c.relkind IN ('r', 'S', 'v', 'm', 'f', 'P')" ,
540
+ "c.relkind IN (" CppAsString2 (RELKIND_RELATION ) ", "
541
+ CppAsString2 (RELKIND_SEQUENCE ) ", "
542
+ CppAsString2 (RELKIND_VIEW ) ", "
543
+ CppAsString2 (RELKIND_MATVIEW ) ", "
544
+ CppAsString2 (RELKIND_FOREIGN_TABLE ) ", "
545
+ CppAsString2 (RELKIND_PARTITIONED_TABLE ) ")" ,
532
546
/* viscondition */
533
547
"pg_catalog.pg_table_is_visible(c.oid)" ,
534
548
/* namespace */
@@ -543,7 +557,9 @@ static const SchemaQuery Query_for_list_of_tmf = {
543
557
/* catname */
544
558
"pg_catalog.pg_class c" ,
545
559
/* selcondition */
546
- "c.relkind IN ('r', 'm', 'f')" ,
560
+ "c.relkind IN (" CppAsString2 (RELKIND_RELATION ) ", "
561
+ CppAsString2 (RELKIND_MATVIEW ) ", "
562
+ CppAsString2 (RELKIND_FOREIGN_TABLE ) ")" ,
547
563
/* viscondition */
548
564
"pg_catalog.pg_table_is_visible(c.oid)" ,
549
565
/* namespace */
@@ -558,7 +574,8 @@ static const SchemaQuery Query_for_list_of_tm = {
558
574
/* catname */
559
575
"pg_catalog.pg_class c" ,
560
576
/* selcondition */
561
- "c.relkind IN ('r', 'm')" ,
577
+ "c.relkind IN (" CppAsString2 (RELKIND_RELATION ) ", "
578
+ CppAsString2 (RELKIND_MATVIEW ) ")" ,
562
579
/* viscondition */
563
580
"pg_catalog.pg_table_is_visible(c.oid)" ,
564
581
/* namespace */
@@ -573,7 +590,7 @@ static const SchemaQuery Query_for_list_of_views = {
573
590
/* catname */
574
591
"pg_catalog.pg_class c" ,
575
592
/* selcondition */
576
- "c.relkind IN ('v' )" ,
593
+ "c.relkind IN (" CppAsString2 ( RELKIND_VIEW ) " )" ,
577
594
/* viscondition */
578
595
"pg_catalog.pg_table_is_visible(c.oid)" ,
579
596
/* namespace */
@@ -588,7 +605,7 @@ static const SchemaQuery Query_for_list_of_matviews = {
588
605
/* catname */
589
606
"pg_catalog.pg_class c" ,
590
607
/* selcondition */
591
- "c.relkind IN ('m' )" ,
608
+ "c.relkind IN (" CppAsString2 ( RELKIND_MATVIEW ) " )" ,
592
609
/* viscondition */
593
610
"pg_catalog.pg_table_is_visible(c.oid)" ,
594
611
/* namespace */
0 commit comments