4040#ifdef USE_READLINE
4141
4242#include <ctype.h>
43+
44+ #include "catalog/pg_class.h"
45+
4346#include "libpq-fe.h"
4447#include "pqexpbuffer.h"
4548#include "common.h"
@@ -85,8 +88,9 @@ typedef struct SchemaQuery
8588/*
8689 * Selection condition --- only rows meeting this condition are candidates
8790 * 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.
9094 */
9195const char * selcondition ;
9296
@@ -361,7 +365,8 @@ static const SchemaQuery Query_for_list_of_datatypes = {
361365"pg_catalog.pg_type t" ,
362366/* selcondition --- ignore table rowtypes and array types */
363367"(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)) "
365370"AND t.typname !~ '^_'" ,
366371/* viscondition */
367372"pg_catalog.pg_type_is_visible(t.oid)" ,
@@ -407,7 +412,7 @@ static const SchemaQuery Query_for_list_of_indexes = {
407412/* catname */
408413"pg_catalog.pg_class c" ,
409414/* selcondition */
410- "c.relkind IN ('i' )" ,
415+ "c.relkind IN (" CppAsString2 ( RELKIND_INDEX ) " )" ,
411416/* viscondition */
412417"pg_catalog.pg_table_is_visible(c.oid)" ,
413418/* namespace */
@@ -422,7 +427,7 @@ static const SchemaQuery Query_for_list_of_sequences = {
422427/* catname */
423428"pg_catalog.pg_class c" ,
424429/* selcondition */
425- "c.relkind IN ('S' )" ,
430+ "c.relkind IN (" CppAsString2 ( RELKIND_SEQUENCE ) " )" ,
426431/* viscondition */
427432"pg_catalog.pg_table_is_visible(c.oid)" ,
428433/* namespace */
@@ -437,7 +442,7 @@ static const SchemaQuery Query_for_list_of_foreign_tables = {
437442/* catname */
438443"pg_catalog.pg_class c" ,
439444/* selcondition */
440- "c.relkind IN ('f' )" ,
445+ "c.relkind IN (" CppAsString2 ( RELKIND_FOREIGN_TABLE ) " )" ,
441446/* viscondition */
442447"pg_catalog.pg_table_is_visible(c.oid)" ,
443448/* namespace */
@@ -452,7 +457,8 @@ static const SchemaQuery Query_for_list_of_tables = {
452457/* catname */
453458"pg_catalog.pg_class c" ,
454459/* selcondition */
455- "c.relkind IN ('r', 'P')" ,
460+ "c.relkind IN (" CppAsString2 (RELKIND_RELATION )", "
461+ CppAsString2 (RELKIND_PARTITIONED_TABLE )")" ,
456462/* viscondition */
457463"pg_catalog.pg_table_is_visible(c.oid)" ,
458464/* namespace */
@@ -467,7 +473,7 @@ static const SchemaQuery Query_for_list_of_partitioned_tables = {
467473/* catname */
468474"pg_catalog.pg_class c" ,
469475/* selcondition */
470- "c.relkind IN ('P' )" ,
476+ "c.relkind IN (" CppAsString2 ( RELKIND_PARTITIONED_TABLE ) " )" ,
471477/* viscondition */
472478"pg_catalog.pg_table_is_visible(c.oid)" ,
473479/* namespace */
@@ -498,7 +504,10 @@ static const SchemaQuery Query_for_list_of_updatables = {
498504/* catname */
499505"pg_catalog.pg_class c" ,
500506/* 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 )")" ,
502511/* viscondition */
503512"pg_catalog.pg_table_is_visible(c.oid)" ,
504513/* namespace */
@@ -528,7 +537,12 @@ static const SchemaQuery Query_for_list_of_tsvmf = {
528537/* catname */
529538"pg_catalog.pg_class c" ,
530539/* 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 )")" ,
532546/* viscondition */
533547"pg_catalog.pg_table_is_visible(c.oid)" ,
534548/* namespace */
@@ -543,7 +557,9 @@ static const SchemaQuery Query_for_list_of_tmf = {
543557/* catname */
544558"pg_catalog.pg_class c" ,
545559/* selcondition */
546- "c.relkind IN ('r', 'm', 'f')" ,
560+ "c.relkind IN (" CppAsString2 (RELKIND_RELATION )", "
561+ CppAsString2 (RELKIND_MATVIEW )", "
562+ CppAsString2 (RELKIND_FOREIGN_TABLE )")" ,
547563/* viscondition */
548564"pg_catalog.pg_table_is_visible(c.oid)" ,
549565/* namespace */
@@ -558,7 +574,8 @@ static const SchemaQuery Query_for_list_of_tm = {
558574/* catname */
559575"pg_catalog.pg_class c" ,
560576/* selcondition */
561- "c.relkind IN ('r', 'm')" ,
577+ "c.relkind IN (" CppAsString2 (RELKIND_RELATION )", "
578+ CppAsString2 (RELKIND_MATVIEW )")" ,
562579/* viscondition */
563580"pg_catalog.pg_table_is_visible(c.oid)" ,
564581/* namespace */
@@ -573,7 +590,7 @@ static const SchemaQuery Query_for_list_of_views = {
573590/* catname */
574591"pg_catalog.pg_class c" ,
575592/* selcondition */
576- "c.relkind IN ('v' )" ,
593+ "c.relkind IN (" CppAsString2 ( RELKIND_VIEW ) " )" ,
577594/* viscondition */
578595"pg_catalog.pg_table_is_visible(c.oid)" ,
579596/* namespace */
@@ -588,7 +605,7 @@ static const SchemaQuery Query_for_list_of_matviews = {
588605/* catname */
589606"pg_catalog.pg_class c" ,
590607/* selcondition */
591- "c.relkind IN ('m' )" ,
608+ "c.relkind IN (" CppAsString2 ( RELKIND_MATVIEW ) " )" ,
592609/* viscondition */
593610"pg_catalog.pg_table_is_visible(c.oid)" ,
594611/* namespace */