summaryrefslogtreecommitdiff
path: root/src/tools/findoidjoins
diff options
context:
space:
mode:
authorTom Lane2017-03-10 04:36:44 +0000
committerTom Lane2017-03-10 04:36:52 +0000
commit9c2635e26f6f4e34b3b606c0fc79d0e111953a74 (patch)
treea9c715b65b8925d5ca16df366fe1d7cb91778224 /src/tools/findoidjoins
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 'src/tools/findoidjoins')
-rw-r--r--src/tools/findoidjoins/findoidjoins.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/tools/findoidjoins/findoidjoins.c b/src/tools/findoidjoins/findoidjoins.c
index 9fe0379f63e..267107ddaeb 100644
--- a/src/tools/findoidjoins/findoidjoins.c
+++ b/src/tools/findoidjoins/findoidjoins.c
@@ -7,6 +7,8 @@
*/
#include "postgres_fe.h"
+#include "catalog/pg_class.h"
+
#include "libpq-fe.h"
#include "pqexpbuffer.h"
@@ -51,8 +53,8 @@ main(int argc, char **argv)
"SELECT c.relname, (SELECT nspname FROM "
"pg_catalog.pg_namespace n WHERE n.oid = c.relnamespace) AS nspname "
"FROM pg_catalog.pg_class c "
- "WHERE c.relkind = 'r' "
- "AND c.relhasoids "
+ "WHERE c.relkind = " CppAsString2(RELKIND_RELATION)
+ " AND c.relhasoids "
"ORDER BY nspname, c.relname"
);
@@ -71,9 +73,10 @@ main(int argc, char **argv)
"(SELECT nspname FROM pg_catalog.pg_namespace n WHERE n.oid = c.relnamespace) AS nspname, "
"a.attname "
"FROM pg_catalog.pg_class c, pg_catalog.pg_attribute a "
- "WHERE a.attnum > 0 AND c.relkind = 'r' "
- "AND a.attrelid = c.oid "
- "AND a.atttypid IN ('pg_catalog.oid'::regtype, "
+ "WHERE a.attnum > 0"
+ " AND c.relkind = " CppAsString2(RELKIND_RELATION)
+ " AND a.attrelid = c.oid"
+ " AND a.atttypid IN ('pg_catalog.oid'::regtype, "
" 'pg_catalog.regclass'::regtype, "
" 'pg_catalog.regoper'::regtype, "
" 'pg_catalog.regoperator'::regtype, "
@@ -146,9 +149,10 @@ main(int argc, char **argv)
"(SELECT nspname FROM pg_catalog.pg_namespace n WHERE n.oid = c.relnamespace) AS nspname, "
"a.attname "
"FROM pg_catalog.pg_class c, pg_catalog.pg_attribute a "
- "WHERE a.attnum > 0 AND c.relkind = 'r' "
- "AND a.attrelid = c.oid "
- "AND a.atttypid IN ('pg_catalog.oid[]'::regtype, "
+ "WHERE a.attnum > 0"
+ " AND c.relkind = " CppAsString2(RELKIND_RELATION)
+ " AND a.attrelid = c.oid"
+ " AND a.atttypid IN ('pg_catalog.oid[]'::regtype, "
" 'pg_catalog.regclass[]'::regtype, "
" 'pg_catalog.regoper[]'::regtype, "
" 'pg_catalog.regoperator[]'::regtype, "