diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-03-09 23:36:44 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-03-09 23:36:52 -0500 |
commit | 9c2635e26f6f4e34b3b606c0fc79d0e111953a74 (patch) | |
tree | a9c715b65b8925d5ca16df366fe1d7cb91778224 /src/backend/utils/adt/xml.c | |
parent | fcd8d25d38b5f42ec4ae77a673813c2dc279ccf7 (diff) | |
download | postgresql-9c2635e26f6f4e34b3b606c0fc79d0e111953a74.tar.gz postgresql-9c2635e26f6f4e34b3b606c0fc79d0e111953a74.zip |
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
Diffstat (limited to 'src/backend/utils/adt/xml.c')
-rw-r--r-- | src/backend/utils/adt/xml.c | 17 |
1 files changed, 15 insertions, 2 deletions
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 ");"); } |