summaryrefslogtreecommitdiff
path: root/contrib/oid2name/oid2name.c
diff options
context:
space:
mode:
authorTom Lane2017-03-10 04:36:44 +0000
committerTom Lane2017-03-10 04:36:52 +0000
commit9c2635e26f6f4e34b3b606c0fc79d0e111953a74 (patch)
treea9c715b65b8925d5ca16df366fe1d7cb91778224 /contrib/oid2name/oid2name.c
parentfcd8d25d38b5f42ec4ae77a673813c2dc279ccf7 (diff)
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 'contrib/oid2name/oid2name.c')
-rw-r--r--contrib/oid2name/oid2name.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c
index 5a2aa1dd0e..778e8bad41 100644
--- a/contrib/oid2name/oid2name.c
+++ b/contrib/oid2name/oid2name.c
@@ -9,6 +9,8 @@
*/
#include "postgres_fe.h"
+#include "catalog/pg_class.h"
+
#include "libpq-fe.h"
#include "pg_getopt.h"
@@ -433,11 +435,12 @@ sql_exec_dumpalltables(PGconn *conn, struct options * opts)
snprintf(todo, sizeof(todo),
"SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s "
- "FROM pg_class c "
+ "FROM pg_catalog.pg_class c "
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace "
" LEFT JOIN pg_catalog.pg_database d ON d.datname = pg_catalog.current_database(),"
" pg_catalog.pg_tablespace t "
- "WHERE relkind IN ('r', 'm'%s%s) AND "
+ "WHERE relkind IN (" CppAsString2(RELKIND_RELATION) ","
+ CppAsString2(RELKIND_MATVIEW) "%s%s) AND "
" %s"
" t.oid = CASE"
" WHEN reltablespace <> 0 THEN reltablespace"
@@ -445,8 +448,8 @@ sql_exec_dumpalltables(PGconn *conn, struct options * opts)
" END "
"ORDER BY relname",
opts->extended ? addfields : "",
- opts->indexes ? ", 'i', 'S'" : "",
- opts->systables ? ", 't'" : "",
+ opts->indexes ? "," CppAsString2(RELKIND_INDEX) "," CppAsString2(RELKIND_SEQUENCE) : "",
+ opts->systables ? "," CppAsString2(RELKIND_TOASTVALUE) : "",
opts->systables ? "" : "n.nspname NOT IN ('pg_catalog', 'information_schema') AND n.nspname !~ '^pg_toast' AND");
sql_exec(conn, todo, opts->quiet);
@@ -507,7 +510,11 @@ sql_exec_searchtables(PGconn *conn, struct options * opts)
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace \n"
" LEFT JOIN pg_catalog.pg_database d ON d.datname = pg_catalog.current_database(),\n"
" pg_catalog.pg_tablespace t \n"
- "WHERE relkind IN ('r', 'm', 'i', 'S', 't') AND \n"
+ "WHERE relkind IN (" CppAsString2(RELKIND_RELATION) ","
+ CppAsString2(RELKIND_MATVIEW) ","
+ CppAsString2(RELKIND_INDEX) ","
+ CppAsString2(RELKIND_SEQUENCE) ","
+ CppAsString2(RELKIND_TOASTVALUE) ") AND \n"
" t.oid = CASE\n"
" WHEN reltablespace <> 0 THEN reltablespace\n"
" ELSE dattablespace\n"