summaryrefslogtreecommitdiff
path: root/src/bin/pg_upgrade/version.c
diff options
context:
space:
mode:
authorDavid Rowley2020-10-15 07:35:17 +0000
committerDavid Rowley2020-10-15 07:35:17 +0000
commit110d81728a0a006abcf654543fc15346f8043dc0 (patch)
treeeb0caef08d002a3bc627bcb8de2e5b1d65925abc /src/bin/pg_upgrade/version.c
parent73c381cee71e7dd8a78a394731958b0bbb4d8991 (diff)
Fixup some appendStringInfo and appendPQExpBuffer calls
A number of places were using appendStringInfo() when they could have been using appendStringInfoString() instead. While there's no functionality change there, it's just more efficient to use appendStringInfoString() when no formatting is required. Likewise for some appendStringInfoString() calls which were just appending a single char. We can just use appendStringInfoChar() for that. Additionally, many places were using appendPQExpBuffer() when they could have used appendPQExpBufferStr(). Change those too. Patch by Zhijie Hou, but further searching by me found significantly more places that deserved the same treatment. Author: Zhijie Hou, David Rowley Discussion: https://postgr.es/m/cb172cf4361e4c7ba7167429070979d4@G08CNEXMBPEKD05.g08.fujitsu.local
Diffstat (limited to 'src/bin/pg_upgrade/version.c')
-rw-r--r--src/bin/pg_upgrade/version.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 4e5d27f76eb..db1934124ee 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -158,33 +158,33 @@ check_for_data_type_usage(ClusterInfo *cluster, const char *typename,
/* Ranges were introduced in 9.2 */
if (GET_MAJOR_VERSION(cluster->major_version) >= 902)
- appendPQExpBuffer(&querybuf,
- " UNION ALL "
+ appendPQExpBufferStr(&querybuf,
+ " UNION ALL "
/* ranges containing any type selected so far */
- " SELECT t.oid FROM pg_catalog.pg_type t, pg_catalog.pg_range r, x "
- " WHERE t.typtype = 'r' AND r.rngtypid = t.oid AND r.rngsubtype = x.oid");
+ " SELECT t.oid FROM pg_catalog.pg_type t, pg_catalog.pg_range r, x "
+ " WHERE t.typtype = 'r' AND r.rngtypid = t.oid AND r.rngsubtype = x.oid");
- appendPQExpBuffer(&querybuf,
- " ) foo "
- ") "
+ appendPQExpBufferStr(&querybuf,
+ " ) foo "
+ ") "
/* now look for stored columns of any such type */
- "SELECT n.nspname, c.relname, a.attname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_namespace n, "
- " pg_catalog.pg_attribute a "
- "WHERE c.oid = a.attrelid AND "
- " NOT a.attisdropped AND "
- " a.atttypid IN (SELECT oid FROM oids) AND "
- " c.relkind IN ("
- CppAsString2(RELKIND_RELATION) ", "
- CppAsString2(RELKIND_MATVIEW) ", "
- CppAsString2(RELKIND_INDEX) ") AND "
- " c.relnamespace = n.oid AND "
+ "SELECT n.nspname, c.relname, a.attname "
+ "FROM pg_catalog.pg_class c, "
+ " pg_catalog.pg_namespace n, "
+ " pg_catalog.pg_attribute a "
+ "WHERE c.oid = a.attrelid AND "
+ " NOT a.attisdropped AND "
+ " a.atttypid IN (SELECT oid FROM oids) AND "
+ " c.relkind IN ("
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_INDEX) ") AND "
+ " c.relnamespace = n.oid AND "
/* exclude possible orphaned temp tables */
- " n.nspname !~ '^pg_temp_' AND "
- " n.nspname !~ '^pg_toast_temp_' AND "
+ " n.nspname !~ '^pg_temp_' AND "
+ " n.nspname !~ '^pg_toast_temp_' AND "
/* exclude system catalogs, too */
- " n.nspname NOT IN ('pg_catalog', 'information_schema')");
+ " n.nspname NOT IN ('pg_catalog', 'information_schema')");
res = executeQueryOrDie(conn, "%s", querybuf.data);