From 9c2635e26f6f4e34b3b606c0fc79d0e111953a74 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 9 Mar 2017 23:36:44 -0500 Subject: Fix hard-coded relkind constants in assorted other files. Although it's reasonable to expect that most of these constants will never change, that does not make it good programming style to hard-code the value rather than using the RELKIND_FOO macros. I think I've now gotten all the hard-coded references in C code. Unfortunately there's no equally convenient way to parameterize SQL files ... Discussion: https://postgr.es/m/11145.1488931324@sss.pgh.pa.us --- src/backend/utils/adt/xml.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/backend/utils/adt/xml.c') diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index 04aeb7178e9..f81cf489d26 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -69,6 +69,7 @@ #include "access/htup_details.h" #include "catalog/namespace.h" +#include "catalog/pg_class.h" #include "catalog/pg_type.h" #include "commands/dbcommands.h" #include "executor/executor.h" @@ -2344,7 +2345,13 @@ schema_get_xml_visible_tables(Oid nspid) StringInfoData query; initStringInfo(&query); - appendStringInfo(&query, "SELECT oid FROM pg_catalog.pg_class WHERE relnamespace = %u AND relkind IN ('r', 'm', 'v') AND pg_catalog.has_table_privilege (oid, 'SELECT') ORDER BY relname;", nspid); + appendStringInfo(&query, "SELECT oid FROM pg_catalog.pg_class" + " WHERE relnamespace = %u AND relkind IN (" + CppAsString2(RELKIND_RELATION) "," + CppAsString2(RELKIND_MATVIEW) "," + CppAsString2(RELKIND_VIEW) ")" + " AND pg_catalog.has_table_privilege (oid, 'SELECT')" + " ORDER BY relname;", nspid); return query_to_oid_list(query.data); } @@ -2370,7 +2377,13 @@ static List * database_get_xml_visible_tables(void) { /* At the moment there is no order required here. */ - return query_to_oid_list("SELECT oid FROM pg_catalog.pg_class WHERE relkind IN ('r', 'm', 'v') AND pg_catalog.has_table_privilege (pg_class.oid, 'SELECT') AND relnamespace IN (" XML_VISIBLE_SCHEMAS ");"); + return query_to_oid_list("SELECT oid FROM pg_catalog.pg_class" + " WHERE relkind IN (" + CppAsString2(RELKIND_RELATION) "," + CppAsString2(RELKIND_MATVIEW) "," + CppAsString2(RELKIND_VIEW) ")" + " AND pg_catalog.has_table_privilege(pg_class.oid, 'SELECT')" + " AND relnamespace IN (" XML_VISIBLE_SCHEMAS ");"); } -- cgit v1.2.3