mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
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
This commit is contained in:
@ -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 ");");
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user