#include "catalog/catalog.h"
#include "catalog/pg_authid.h"
+#include "catalog/pg_class.h"
#include "common/file_utils.h"
#include "common/restricted_token.h"
#include "common/username.h"
" SET relacl = (SELECT array_agg(a.acl) FROM "
" (SELECT E'=r/\"$POSTGRES_SUPERUSERNAME\"' as acl "
" UNION SELECT unnest(pg_catalog.acldefault("
- " CASE WHEN relkind = 'S' THEN 's' ELSE 'r' END::\"char\"," CppAsString2(BOOTSTRAP_SUPERUSERID) "::oid))"
+ " CASE WHEN relkind = " CppAsString2(RELKIND_SEQUENCE) " THEN 's' "
+ " ELSE 'r' END::\"char\"," CppAsString2(BOOTSTRAP_SUPERUSERID) "::oid))"
" ) as a) "
- " WHERE relkind IN ('r', 'v', 'm', 'S') AND relacl IS NULL;\n\n",
+ " WHERE relkind IN (" CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_VIEW) ", " CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_SEQUENCE) ")"
+ " AND relacl IS NULL;\n\n",
"GRANT USAGE ON SCHEMA pg_catalog TO PUBLIC;\n\n",
"GRANT CREATE, USAGE ON SCHEMA public TO PUBLIC;\n\n",
"REVOKE ALL ON pg_largeobject FROM PUBLIC;\n\n",
" pg_class"
" WHERE"
" relacl IS NOT NULL"
- " AND relkind IN ('r', 'v', 'm', 'S');",
+ " AND relkind IN (" CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_VIEW) ", " CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_SEQUENCE) ");",
"INSERT INTO pg_init_privs "
" (objoid, classoid, objsubid, initprivs, privtype)"
" SELECT"
" JOIN pg_attribute ON (pg_class.oid = pg_attribute.attrelid)"
" WHERE"
" pg_attribute.attacl IS NOT NULL"
- " AND pg_class.relkind IN ('r', 'v', 'm', 'S');",
+ " AND pg_class.relkind IN (" CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_VIEW) ", " CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_SEQUENCE) ");",
"INSERT INTO pg_init_privs "
" (objoid, classoid, objsubid, initprivs, privtype)"
" SELECT"
#include "pg_backup_utils.h"
#include "pg_dump.h"
+#include "catalog/pg_class.h"
+
/* translator: this is a module name */
static const char *modulename = gettext_noop("sorter");
if (nLoop == 2 &&
loop[0]->objType == DO_TABLE &&
loop[1]->objType == DO_RULE &&
- (((TableInfo *) loop[0])->relkind == 'v' || /* RELKIND_VIEW */
- ((TableInfo *) loop[0])->relkind == 'm') && /* RELKIND_MATVIEW */
+ (((TableInfo *) loop[0])->relkind == RELKIND_VIEW ||
+ ((TableInfo *) loop[0])->relkind == RELKIND_MATVIEW) &&
((RuleInfo *) loop[1])->ev_type == '1' &&
((RuleInfo *) loop[1])->is_instead &&
((RuleInfo *) loop[1])->ruletable == (TableInfo *) loop[0])
if (nLoop == 2 &&
loop[1]->objType == DO_TABLE &&
loop[0]->objType == DO_RULE &&
- (((TableInfo *) loop[1])->relkind == 'v' || /* RELKIND_VIEW */
- ((TableInfo *) loop[1])->relkind == 'm') && /* RELKIND_MATVIEW */
+ (((TableInfo *) loop[1])->relkind == RELKIND_VIEW ||
+ ((TableInfo *) loop[1])->relkind == RELKIND_MATVIEW) &&
((RuleInfo *) loop[0])->ev_type == '1' &&
((RuleInfo *) loop[0])->is_instead &&
((RuleInfo *) loop[0])->ruletable == (TableInfo *) loop[1])
for (i = 0; i < nLoop; i++)
{
if (loop[i]->objType == DO_TABLE &&
- ((TableInfo *) loop[i])->relkind == 'v') /* RELKIND_VIEW */
+ ((TableInfo *) loop[i])->relkind == RELKIND_VIEW)
{
for (j = 0; j < nLoop; j++)
{
for (i = 0; i < nLoop; i++)
{
if (loop[i]->objType == DO_TABLE &&
- ((TableInfo *) loop[i])->relkind == 'm') /* RELKIND_MATVIEW */
+ ((TableInfo *) loop[i])->relkind == RELKIND_MATVIEW)
{
for (j = 0; j < nLoop; j++)
{
#include "pg_upgrade.h"
#include "access/transam.h"
+#include "catalog/pg_class.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
" SELECT c.oid, 0::oid, 0::oid "
" FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
" ON c.relnamespace = n.oid "
- " WHERE relkind IN ('r', 'm') AND "
+ " WHERE relkind IN (" CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ") AND "
/* exclude possible orphaned temp tables */
" ((n.nspname !~ '^pg_temp_' AND "
" n.nspname !~ '^pg_toast_temp_' AND "
#include "postgres_fe.h"
#include "pg_upgrade.h"
+#include "catalog/pg_class.h"
#include "common/restricted_token.h"
#include "fe_utils/string_utils.h"
"UPDATE pg_catalog.pg_class "
"SET relfrozenxid = '%u' "
/* only heap, materialized view, and TOAST are vacuumed */
- "WHERE relkind IN ('r', 'm', 't')",
+ "WHERE relkind IN ("
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_TOASTVALUE) ")",
old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
"UPDATE pg_catalog.pg_class "
"SET relminmxid = '%u' "
/* only heap, materialized view, and TOAST are vacuumed */
- "WHERE relkind IN ('r', 'm', 't')",
+ "WHERE relkind IN ("
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_TOASTVALUE) ")",
old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
#include "postgres_fe.h"
#include "pg_upgrade.h"
+
+#include "catalog/pg_class.h"
#include "fe_utils/string_utils.h"
"WHERE c.oid = a.attrelid AND "
" NOT a.attisdropped AND "
" a.atttypid = 'pg_catalog.unknown'::pg_catalog.regtype AND "
- " c.relkind IN ('r', 'c', 'm') AND "
+ " c.relkind IN ("
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_COMPOSITE_TYPE) ", "
+ CppAsString2(RELKIND_MATVIEW) ") AND "
" c.relnamespace = n.oid AND "
/* exclude possible orphaned temp tables */
" n.nspname !~ '^pg_temp_' AND "
#include <sys/stat.h> /* for stat() */
#endif
+#include "catalog/pg_class.h"
#include "portability/instr_time.h"
#include "libpq-fe.h"
switch (relkind[0])
{
#ifdef NOT_USED
- case 'm':
+ case RELKIND_MATVIEW:
appendPQExpBufferStr(buf, "CREATE OR REPLACE MATERIALIZED VIEW ");
break;
#endif
- case 'v':
+ case RELKIND_VIEW:
appendPQExpBufferStr(buf, "CREATE OR REPLACE VIEW ");
break;
default:
#ifdef USE_READLINE
#include <ctype.h>
+
+#include "catalog/pg_class.h"
+
#include "libpq-fe.h"
#include "pqexpbuffer.h"
#include "common.h"
/*
* Selection condition --- only rows meeting this condition are candidates
* to display. If catname mentions multiple tables, include the necessary
- * join condition here. For example, "c.relkind = 'r'". Write NULL (not
- * an empty string) if not needed.
+ * join condition here. For example, this might look like "c.relkind = "
+ * CppAsString2(RELKIND_RELATION). Write NULL (not an empty string) if
+ * not needed.
*/
const char *selcondition;
"pg_catalog.pg_type t",
/* selcondition --- ignore table rowtypes and array types */
"(t.typrelid = 0 "
- " OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) "
+ " OR (SELECT c.relkind = " CppAsString2(RELKIND_COMPOSITE_TYPE)
+ " FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) "
"AND t.typname !~ '^_'",
/* viscondition */
"pg_catalog.pg_type_is_visible(t.oid)",
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('i')",
+ "c.relkind IN (" CppAsString2(RELKIND_INDEX) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('S')",
+ "c.relkind IN (" CppAsString2(RELKIND_SEQUENCE) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('f')",
+ "c.relkind IN (" CppAsString2(RELKIND_FOREIGN_TABLE) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('r', 'P')",
+ "c.relkind IN (" CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_PARTITIONED_TABLE) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('P')",
+ "c.relkind IN (" CppAsString2(RELKIND_PARTITIONED_TABLE) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('r', 'f', 'v', 'P')",
+ "c.relkind IN (" CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_FOREIGN_TABLE) ", "
+ CppAsString2(RELKIND_VIEW) ", "
+ CppAsString2(RELKIND_PARTITIONED_TABLE) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('r', 'S', 'v', 'm', 'f', 'P')",
+ "c.relkind IN (" CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_SEQUENCE) ", "
+ CppAsString2(RELKIND_VIEW) ", "
+ CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_FOREIGN_TABLE) ", "
+ CppAsString2(RELKIND_PARTITIONED_TABLE) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('r', 'm', 'f')",
+ "c.relkind IN (" CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_FOREIGN_TABLE) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('r', 'm')",
+ "c.relkind IN (" CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('v')",
+ "c.relkind IN (" CppAsString2(RELKIND_VIEW) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
/* catname */
"pg_catalog.pg_class c",
/* selcondition */
- "c.relkind IN ('m')",
+ "c.relkind IN (" CppAsString2(RELKIND_MATVIEW) ")",
/* viscondition */
"pg_catalog.pg_table_is_visible(c.oid)",
/* namespace */
#include <sys/select.h>
#endif
+#include "catalog/pg_class.h"
+
#include "common.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
initPQExpBuffer(&buf);
res = executeQuery(conn,
- "SELECT c.relname, ns.nspname FROM pg_class c, pg_namespace ns\n"
- " WHERE relkind IN (\'r\', \'m\') AND c.relnamespace = ns.oid\n"
+ "SELECT c.relname, ns.nspname"
+ " FROM pg_class c, pg_namespace ns\n"
+ " WHERE relkind IN ("
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ")"
+ " AND c.relnamespace = ns.oid\n"
" ORDER BY c.relpages DESC;",
progname, echo);