agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedbump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
21+ messages / 5 participants
[nested] [flat]
* bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-04-08 15:47 Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-04-08 15:47 UTC (permalink / raw)
To: pgsql-hackers
(This is for v20.)
I've brought this up a couple times in the past ~year, so here's a patch.
Supporting versions as old as v9.2 has become quite cumbersome, requiring
various version-specific branches and hacks. I believe our current policy
is that we support at least 10 previous major versions [0]. For reference,
we last bumped the minimum to v9.2 in 2021 (commits 30e7c175b81,
e469f0aaf3, and cf0cab868a).
From "git show --stat":
16 files changed, 569 insertions(+), 1836 deletions(-)
Thoughts?
[0] https://postgr.es/m/d0316012-ece7-7b7e-2d36-9c38cb77cb3b%40enterprisedb.com
--
nathan
From b21edbb59a6a5abb6cefdd2e0a84dfec06010300 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Wed, 8 Apr 2026 10:40:38 -0500
Subject: [PATCH v1 1/1] remove pg_dump, pg_dumpall, and pg_upgrade support for
pre-10 servers
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_dump/pg_dump.c | 792 ++++++++---------------------
src/bin/pg_dump/pg_dumpall.c | 4 +-
src/bin/pg_upgrade/check.c | 175 +------
src/bin/pg_upgrade/controldata.c | 97 +---
src/bin/pg_upgrade/exec.c | 20 +-
src/bin/pg_upgrade/file.c | 164 ------
src/bin/pg_upgrade/pg_upgrade.c | 92 +---
src/bin/pg_upgrade/pg_upgrade.h | 30 --
src/bin/pg_upgrade/relfilenumber.c | 87 ++--
src/bin/pg_upgrade/server.c | 4 +-
src/bin/pg_upgrade/version.c | 127 -----
src/bin/psql/command.c | 48 +-
src/bin/psql/describe.c | 703 +++++++++----------------
src/bin/psql/tab-complete.in.c | 46 +-
16 files changed, 569 insertions(+), 1836 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index ae1bc14d2f2..64a3447e445 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1718,7 +1706,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index 38ca09b423c..c4ed75211db 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d34240073bb..70174715d2d 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,10 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
- }
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1942,12 +1933,9 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
addObjectDependency(dobj, ext->dobj.dumpId);
/*
- * In 9.6 and above, mark the member object to have any non-initial ACLs
- * dumped. (Any initial ACLs will be removed later, using data from
- * pg_init_privs, so that we'll dump only the delta from the extension's
- * initial setup.)
- *
- * Prior to 9.6, we do not include any extension member components.
+ * Mark the member object to have any non-initial ACLs dumped. (Any
+ * initial ACLs will be removed later, using data from pg_init_privs, so
+ * that we'll dump only the delta from the extension's initial setup.)
*
* In binary upgrades, we still dump all components of the members
* individually, since the idea is to exactly reproduce the database
@@ -1964,12 +1952,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -2000,8 +1983,7 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
* In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
@@ -2213,8 +2195,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2212,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3097,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3324,11 +3294,7 @@ dumpDatabase(Archive *fout)
"pg_encoding_to_char(encoding) AS encoding, "
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
- "datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
- appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
+ "datistemplate, datconnlimit, datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3636,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4203,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4315,12 +4271,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
pg_log_info("reading row-level security policies");
printfPQExpBuffer(query,
- "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
- appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
- appendPQExpBuffer(query,
+ "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, pol.polpermissive, "
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
"pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
@@ -4534,7 +4485,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4848,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5138,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,26 +6626,10 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
- /*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
- */
- appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
- appendPQExpBufferStr(query, "FROM pg_am");
+ /* Select all access methods from pg_am table. */
+ appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler "
+ "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6879,67 +6814,41 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7022,6 +6931,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7044,93 +6954,49 @@ getFuncs(Archive *fout)
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7379,64 +7245,14 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
-
- if (fout->remoteVersion >= 90400)
- appendPQExpBufferStr(query,
- "c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
-
- if (fout->remoteVersion >= 90300)
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
-
- if (fout->remoteVersion >= 90300)
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
-
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
-
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
-
- if (fout->remoteVersion >= 100000)
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, c.relreplident, c.relrowsecurity, "
+ "c.relforcerowsecurity, c.relminmxid, tc.relminmxid AS tminmxid, "
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, "
+ "am.amname, (d.deptype = 'i') IS TRUE AS is_identity_sequence, "
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,12 +7269,9 @@ getTables(Archive *fout, int *numTables)
"d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
- /*
- * In 9.6 and up, left join to pg_am to pick up the amname.
- */
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ /* left join to pg_am to pick up the amname. */
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -8026,15 +7839,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
" WHERE attrelid = i.indexrelid) "
"ELSE NULL END AS indattnames, "
"(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
- "t.reloptions AS indreloptions, ");
-
-
- if (fout->remoteVersion >= 90400)
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
+ "t.reloptions AS indreloptions, i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8319,10 +8124,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8989,10 +8790,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9259,10 +9056,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9490,12 +9283,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10898,76 +10687,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
}
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11140,16 +10926,6 @@ fetchAttributeStats(Archive *fout)
PGresult *res = NULL;
static TocEntry *te;
static bool restarted;
- int max_rels = MAX_ATTR_STATS_RELS;
-
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
/* If we're just starting, set our TOC pointer. */
if (!te)
@@ -11179,7 +10955,7 @@ fetchAttributeStats(Archive *fout)
* This is perhaps not the sturdiest assumption, so we verify it matches
* reality in dumpRelationStats_dumper().
*/
- for (; te != AH->toc && count < max_rels; te = te->next)
+ for (; te != AH->toc && count < MAX_ATTR_STATS_RELS; te = te->next)
{
if ((te->reqs & REQ_STATS) == 0 ||
strcmp(te->desc, "STATISTICS DATA") != 0)
@@ -11321,16 +11097,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For pre-v18 servers, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11338,7 +11109,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11346,12 +11117,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13671,21 +13436,9 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
- "proleakproof,\n");
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
-
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
+ "proleakproof,\n"
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15173,16 +14926,7 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
qcollname = pg_strdup(fmtId(collinfo->dobj.name));
/* Get collation-specific details */
- appendPQExpBufferStr(query, "SELECT ");
-
- if (fout->remoteVersion >= 100000)
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
+ appendPQExpBufferStr(query, "SELECT collprovider, collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15587,45 +15331,21 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"agginitval,\n"
"aggsortop,\n"
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
- "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
-
- if (fout->remoteVersion >= 90400)
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
-
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
+ "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n"
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17081,47 +16801,33 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
if (!fout->is_prepared[PREPQUERY_GETCOLUMNACLS])
{
- /* Set up query for column ACLs */
+ /*
+ * Set up query for column ACLs.
+ *
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
appendPQExpBufferStr(query,
- "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
-
- if (fout->remoteVersion >= 90600)
- {
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
+ "PREPARE getColumnACLs(pg_catalog.oid) AS\n"
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19411,17 +19117,11 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ if (fout->remoteVersion < 180000 ||
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19478,59 +19178,19 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
- Assert(sequences);
-
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
+ Assert(sequences);
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19709,8 +19369,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 20cdd2d92f0..69f21a1fb86 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -693,11 +693,11 @@ main(int argc, char *argv[])
fout->verbose = verbose;
/*
- * We allow the server to be back to 9.2, and up to any minor release
+ * We allow the server to be back to 10, and up to any minor release
* of our own major version. (See also version check in
* pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = 1;
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 06134cf5d2e..22812b38ed5 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1567,19 +1473,13 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
appendPQExpBufferStr(&old_polymorphics,
"'array_append(anyarray,anyelement)'"
", 'array_cat(anyarray,anyarray)'"
- ", 'array_prepend(anyelement,anyarray)'");
-
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
-
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ ", 'array_prepend(anyelement,anyarray)'"
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'"
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
@@ -1870,63 +1770,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index e18687226ae..a563efcb6d3 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -42,9 +42,6 @@ get_control_data(ClusterInfo *cluster)
char bufin[MAX_STRING];
FILE *output;
char *p;
- bool got_tli = false;
- bool got_log_id = false;
- bool got_log_seg = false;
bool got_xid = false;
bool got_oid = false;
bool got_multi = false;
@@ -75,10 +72,6 @@ get_control_data(ClusterInfo *cluster)
char *language = NULL;
char *lc_all = NULL;
char *lc_messages = NULL;
- uint32 tli = 0;
- uint32 logid = 0;
- uint32 segno = 0;
- char *resetwal_bin;
int rc;
bool live_check = (cluster == &old_cluster && user_opts.live_check);
@@ -189,27 +182,15 @@ get_control_data(ClusterInfo *cluster)
}
}
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- resetwal_bin = "pg_resetxlog\" -n";
- else
- resetwal_bin = "pg_resetwal\" -n";
snprintf(cmd, sizeof(cmd), "\"%s/%s \"%s\"",
cluster->bindir,
- live_check ? "pg_controldata\"" : resetwal_bin,
+ live_check ? "pg_controldata\"" : "pg_resetwal\" -n",
cluster->pgdata);
fflush(NULL);
if ((output = popen(cmd, "r")) == NULL)
pg_fatal("could not get control data using %s: %m", cmd);
- /* Only in <= 9.2 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
- {
- cluster->controldata.data_checksum_version = PG_DATA_CHECKSUM_OFF;
- got_data_checksum_version = true;
- }
-
/* we have the result of cmd in "output". so parse it line by line now */
while (fgets(bufin, sizeof(bufin), output))
{
@@ -237,39 +218,6 @@ get_control_data(ClusterInfo *cluster)
p++; /* remove ':' char */
cluster->controldata.cat_ver = str2uint(p);
}
- else if ((p = strstr(bufin, "Latest checkpoint's TimeLineID:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- tli = str2uint(p);
- got_tli = true;
- }
- else if ((p = strstr(bufin, "First log file ID after reset:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- logid = str2uint(p);
- got_log_id = true;
- }
- else if ((p = strstr(bufin, "First log file segment after reset:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- segno = str2uint(p);
- got_log_seg = true;
- }
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
p = strchr(p, ':');
@@ -280,23 +228,12 @@ get_control_data(ClusterInfo *cluster)
p++; /* remove ':' char */
cluster->controldata.chkpnt_nxtepoch = str2uint(p);
- /*
- * Delimiter changed from '/' to ':' in 9.6. We don't test for
- * the catalog version of the change because the catalog version
- * is pulled from pg_controldata too, and it isn't worth adding an
- * order dependency for this --- we just check the string.
- */
- if (strchr(p, '/') != NULL)
- p = strchr(p, '/');
- else if (GET_MAJOR_VERSION(cluster->major_version) >= 906)
- p = strchr(p, ':');
- else
- p = NULL;
+ p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
- p++; /* remove '/' or ':' char */
+ p++; /* remove ':' char */
cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
@@ -568,22 +505,6 @@ get_control_data(ClusterInfo *cluster)
pg_free(lc_all);
pg_free(lc_messages);
- /*
- * Before 9.3, pg_resetwal reported the xlogid and segno of the first log
- * file after reset as separate lines. Starting with 9.3, it reports the
- * WAL file name. If the old cluster is older than 9.3, we construct the
- * WAL file name from the xlogid and segno.
- */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
- {
- if (got_tli && got_log_id && got_log_seg)
- {
- snprintf(cluster->controldata.nextxlogfile, 25, "%08X%08X%08X",
- tli, logid, segno);
- got_nextxlogfile = true;
- }
- }
-
/*
* Pre-v18 database clusters don't have the default char signedness
* information. We use the char signedness of the platform where
@@ -602,14 +523,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +549,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +588,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index e1de61f36ee..beb255a5152 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -353,18 +353,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
- check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -404,11 +394,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..48e6f8e52a8 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -64,7 +64,7 @@ static void prepare_new_cluster(void);
static void prepare_new_globals(void);
static void create_new_objects(void);
static void copy_xact_xlog_xid(void);
-static void set_frozenxids(bool minmxid_only);
+static void set_frozenxids(void);
static void make_outputdirs(char *pgdata);
static void setup(char *argv0);
static void create_logical_replication_slots(void);
@@ -576,7 +576,7 @@ prepare_new_globals(void)
/*
* Before we restore anything, set frozenxids of initdb-created tables.
*/
- set_frozenxids(false);
+ set_frozenxids();
/*
* Now restore global objects (roles and tablespaces).
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -773,14 +766,8 @@ copy_subdir_files(const char *old_subdir, const char *new_subdir)
static void
copy_xact_xlog_xid(void)
{
- /*
- * Copy old commit logs to new data dir. pg_clog has been renamed to
- * pg_xact in post-10 clusters.
- */
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ /* Copy old commit logs to new data dir. */
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +796,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +830,8 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
@@ -914,18 +883,10 @@ copy_xact_xlog_xid(void)
*
* As we create user tables later, their relfrozenxid/relminmxid fields will
* be restored properly by the binary-upgrade restore script. Likewise for
- * user-database datfrozenxid/datminmxid. However, if we're upgrading from a
- * pre-9.3 database, which does not store per-table or per-DB minmxid, then
- * the relminmxid/datminmxid values filled in by the restore script will just
- * be zeroes.
- *
- * Hence, with a pre-9.3 source database, a second call occurs after
- * everything is restored, with minmxid_only = true. This pass will
- * initialize all tables and databases, both those made by initdb and user
- * objects, with the desired minmxid value. frozenxid values are left alone.
+ * user-database datfrozenxid/datminmxid.
*/
static void
-set_frozenxids(bool minmxid_only)
+set_frozenxids(void)
{
int dbnum;
PGconn *conn,
@@ -935,19 +896,15 @@ set_frozenxids(bool minmxid_only)
int i_datname;
int i_datallowconn;
- if (!minmxid_only)
- prep_status("Setting frozenxid and minmxid counters in new cluster");
- else
- prep_status("Setting minmxid counter in new cluster");
+ prep_status("Setting frozenxid and minmxid counters in new cluster");
conn_template1 = connectToServer(&new_cluster, "template1");
- if (!minmxid_only)
- /* set pg_database.datfrozenxid */
- PQclear(executeQueryOrDie(conn_template1,
- "UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ /* set pg_database.datfrozenxid */
+ PQclear(executeQueryOrDie(conn_template1,
+ "UPDATE pg_catalog.pg_database "
+ "SET datfrozenxid = '%u'",
+ old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
@@ -983,17 +940,16 @@ set_frozenxids(bool minmxid_only)
conn = connectToServer(&new_cluster, datname);
- if (!minmxid_only)
- /* set pg_class.relfrozenxid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
- /* only heap, materialized view, and TOAST are vacuumed */
- "WHERE relkind IN ("
- CppAsString2(RELKIND_RELATION) ", "
- CppAsString2(RELKIND_MATVIEW) ", "
- CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ /* set pg_class.relfrozenxid */
+ PQclear(executeQueryOrDie(conn,
+ "UPDATE pg_catalog.pg_class "
+ "SET relfrozenxid = '%u' "
+ /* only heap, materialized view, and TOAST are vacuumed */
+ "WHERE relkind IN ("
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_TOASTVALUE) ")",
+ old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 1d767bbda2d..16cf7d924fd 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,11 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
-
void report_extension_updates(ClusterInfo *cluster);
/* multixact_rewrite.c */
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,40 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
+ switch (user_opts.transfer_mode)
{
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
}
- else
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
}
}
diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c
index 1eb8bc97c05..abaa59f090c 100644
--- a/src/bin/pg_upgrade/server.c
+++ b/src/bin/pg_upgrade/server.c
@@ -185,9 +185,7 @@ start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error)
if (cluster->sockdir)
snprintf(socket_string + strlen(socket_string),
sizeof(socket_string) - strlen(socket_string),
- " -c %s='%s'",
- (GET_MAJOR_VERSION(cluster->major_version) <= 902) ?
- "unix_socket_directory" : "unix_socket_directories",
+ " -c unix_socket_directories='%s'",
cluster->sockdir);
#endif
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 493400f9090..e5fb3595598 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6272,38 +6272,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 4e8ff00394a..662df2d5448 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,20 +387,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,70 +1086,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,53 +1675,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2459,12 +2324,8 @@ describeOneTableDetails(const char *schemaname,
"contype IN (" CppAsString2(CONSTRAINT_PRIMARY) ","
CppAsString2(CONSTRAINT_UNIQUE) ","
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
- "condeferred) AS condeferred,\n");
-
- if (pset.sversion >= 90400)
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
+ "condeferred) AS condeferred,\n"
+ "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2568,11 +2429,8 @@ describeOneTableDetails(const char *schemaname,
"i.indisclustered, i.indisvalid, "
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
- "contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
- appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
+ "contype, condeferrable, condeferred, "
+ "i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,88 +2681,78 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBuffer(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBuffer(&buf, "SELECT pol.polname, pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
}
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2855,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,118 +3021,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
{
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
}
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3551,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3561,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3963,12 +3800,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
appendPQExpBufferStr(&buf, "\n, pg_catalog.shobj_description(r.oid, 'pg_authid') AS description");
ncols++;
}
- appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
+ appendPQExpBufferStr(&buf, "\n, r.rolreplication, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,9 +3855,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -4514,19 +4345,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4852,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4921,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,19 +5150,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6481,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6618,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6868,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index 9990f818942..abf0bf3b8dc 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -1208,6 +1208,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC"
" FROM pg_catalog.pg_timezone_names() "\
" WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')"
+#define Query_for_list_of_publications \
+" SELECT pubname "\
+" FROM pg_catalog.pg_publication "\
+" WHERE pubname LIKE '%s'"
+
+#define Query_for_list_of_subscriptions \
+" SELECT s.subname "\
+" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d "\
+" WHERE s.subname LIKE '%s' "\
+" AND d.datname = pg_catalog.current_database() "\
+" AND s.subdbid = d.oid"
+
/* Privilege options shared between GRANT and REVOKE */
#define Privilege_options_of_grant_and_revoke \
"SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \
@@ -1242,32 +1254,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \
#define Copy_to_options \
Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY"
-/*
- * These object types were introduced later than our support cutoff of
- * server version 9.2. We use the VersionedQuery infrastructure so that
- * we don't send certain-to-fail queries to older servers.
- */
-
-static const VersionedQuery Query_for_list_of_publications[] = {
- {100000,
- " SELECT pubname "
- " FROM pg_catalog.pg_publication "
- " WHERE pubname LIKE '%s'"
- },
- {0, NULL}
-};
-
-static const VersionedQuery Query_for_list_of_subscriptions[] = {
- {100000,
- " SELECT s.subname "
- " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d "
- " WHERE s.subname LIKE '%s' "
- " AND d.datname = pg_catalog.current_database() "
- " AND s.subdbid = d.oid"
- },
- {0, NULL}
-};
-
/* Known command-starting keywords. */
static const char *const sql_commands[] = {
"ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER",
@@ -1345,7 +1331,7 @@ static const pgsql_thing_t words_after_create[] = {
{"POLICY", NULL, NULL, NULL},
{"PROCEDURE", NULL, NULL, Query_for_list_of_procedures},
{"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs},
- {"PUBLICATION", NULL, Query_for_list_of_publications},
+ {"PUBLICATION", Query_for_list_of_publications},
{"ROLE", Query_for_list_of_roles},
{"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE},
{"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"},
@@ -1353,7 +1339,7 @@ static const pgsql_thing_t words_after_create[] = {
{"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences},
{"SERVER", Query_for_list_of_servers},
{"STATISTICS", NULL, NULL, &Query_for_list_of_statistics},
- {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions},
+ {"SUBSCRIPTION", Query_for_list_of_subscriptions},
{"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
{"TABLE", NULL, NULL, &Query_for_list_of_tables},
{"TABLESPACE", Query_for_list_of_tablespaces},
@@ -5672,9 +5658,9 @@ match_previous_words(int pattern_id,
else if (TailMatchesCS("\\dP*"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations);
else if (TailMatchesCS("\\dRp*"))
- COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications);
+ COMPLETE_WITH_QUERY(Query_for_list_of_publications);
else if (TailMatchesCS("\\dRs*"))
- COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions);
+ COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions);
else if (TailMatchesCS("\\ds*"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences);
else if (TailMatchesCS("\\dt*"))
--
2.50.1 (Apple Git-155)
Attachments:
[text/plain] v1-0001-remove-pg_dump-pg_dumpall-and-pg_upgrade-support-.patch (125.3K, ../../adZ4j88Dq9r8y9_9@nathan/2-v1-0001-remove-pg_dump-pg_dumpall-and-pg_upgrade-support-.patch)
download | inline diff:
From b21edbb59a6a5abb6cefdd2e0a84dfec06010300 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Wed, 8 Apr 2026 10:40:38 -0500
Subject: [PATCH v1 1/1] remove pg_dump, pg_dumpall, and pg_upgrade support for
pre-10 servers
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_dump/pg_dump.c | 792 ++++++++---------------------
src/bin/pg_dump/pg_dumpall.c | 4 +-
src/bin/pg_upgrade/check.c | 175 +------
src/bin/pg_upgrade/controldata.c | 97 +---
src/bin/pg_upgrade/exec.c | 20 +-
src/bin/pg_upgrade/file.c | 164 ------
src/bin/pg_upgrade/pg_upgrade.c | 92 +---
src/bin/pg_upgrade/pg_upgrade.h | 30 --
src/bin/pg_upgrade/relfilenumber.c | 87 ++--
src/bin/pg_upgrade/server.c | 4 +-
src/bin/pg_upgrade/version.c | 127 -----
src/bin/psql/command.c | 48 +-
src/bin/psql/describe.c | 703 +++++++++----------------
src/bin/psql/tab-complete.in.c | 46 +-
16 files changed, 569 insertions(+), 1836 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index ae1bc14d2f2..64a3447e445 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1718,7 +1706,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index 38ca09b423c..c4ed75211db 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d34240073bb..70174715d2d 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,10 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
- }
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1942,12 +1933,9 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
addObjectDependency(dobj, ext->dobj.dumpId);
/*
- * In 9.6 and above, mark the member object to have any non-initial ACLs
- * dumped. (Any initial ACLs will be removed later, using data from
- * pg_init_privs, so that we'll dump only the delta from the extension's
- * initial setup.)
- *
- * Prior to 9.6, we do not include any extension member components.
+ * Mark the member object to have any non-initial ACLs dumped. (Any
+ * initial ACLs will be removed later, using data from pg_init_privs, so
+ * that we'll dump only the delta from the extension's initial setup.)
*
* In binary upgrades, we still dump all components of the members
* individually, since the idea is to exactly reproduce the database
@@ -1964,12 +1952,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -2000,8 +1983,7 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
* In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
@@ -2213,8 +2195,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2212,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3097,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3324,11 +3294,7 @@ dumpDatabase(Archive *fout)
"pg_encoding_to_char(encoding) AS encoding, "
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
- "datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
- appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
+ "datistemplate, datconnlimit, datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3636,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4203,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4315,12 +4271,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
pg_log_info("reading row-level security policies");
printfPQExpBuffer(query,
- "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
- appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
- appendPQExpBuffer(query,
+ "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, pol.polpermissive, "
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
"pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
@@ -4534,7 +4485,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4848,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5138,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,26 +6626,10 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
- /*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
- */
- appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
- appendPQExpBufferStr(query, "FROM pg_am");
+ /* Select all access methods from pg_am table. */
+ appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler "
+ "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6879,67 +6814,41 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7022,6 +6931,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7044,93 +6954,49 @@ getFuncs(Archive *fout)
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7379,64 +7245,14 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
-
- if (fout->remoteVersion >= 90400)
- appendPQExpBufferStr(query,
- "c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
-
- if (fout->remoteVersion >= 90300)
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
-
- if (fout->remoteVersion >= 90300)
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
-
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
-
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
-
- if (fout->remoteVersion >= 100000)
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, c.relreplident, c.relrowsecurity, "
+ "c.relforcerowsecurity, c.relminmxid, tc.relminmxid AS tminmxid, "
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, "
+ "am.amname, (d.deptype = 'i') IS TRUE AS is_identity_sequence, "
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,12 +7269,9 @@ getTables(Archive *fout, int *numTables)
"d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
- /*
- * In 9.6 and up, left join to pg_am to pick up the amname.
- */
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ /* left join to pg_am to pick up the amname. */
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -8026,15 +7839,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
" WHERE attrelid = i.indexrelid) "
"ELSE NULL END AS indattnames, "
"(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
- "t.reloptions AS indreloptions, ");
-
-
- if (fout->remoteVersion >= 90400)
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
+ "t.reloptions AS indreloptions, i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8319,10 +8124,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8989,10 +8790,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9259,10 +9056,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9490,12 +9283,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10898,76 +10687,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
}
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11140,16 +10926,6 @@ fetchAttributeStats(Archive *fout)
PGresult *res = NULL;
static TocEntry *te;
static bool restarted;
- int max_rels = MAX_ATTR_STATS_RELS;
-
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
/* If we're just starting, set our TOC pointer. */
if (!te)
@@ -11179,7 +10955,7 @@ fetchAttributeStats(Archive *fout)
* This is perhaps not the sturdiest assumption, so we verify it matches
* reality in dumpRelationStats_dumper().
*/
- for (; te != AH->toc && count < max_rels; te = te->next)
+ for (; te != AH->toc && count < MAX_ATTR_STATS_RELS; te = te->next)
{
if ((te->reqs & REQ_STATS) == 0 ||
strcmp(te->desc, "STATISTICS DATA") != 0)
@@ -11321,16 +11097,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For pre-v18 servers, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11338,7 +11109,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11346,12 +11117,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13671,21 +13436,9 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
- "proleakproof,\n");
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
-
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
+ "proleakproof,\n"
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15173,16 +14926,7 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
qcollname = pg_strdup(fmtId(collinfo->dobj.name));
/* Get collation-specific details */
- appendPQExpBufferStr(query, "SELECT ");
-
- if (fout->remoteVersion >= 100000)
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
+ appendPQExpBufferStr(query, "SELECT collprovider, collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15587,45 +15331,21 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"agginitval,\n"
"aggsortop,\n"
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
- "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
-
- if (fout->remoteVersion >= 90400)
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
-
- if (fout->remoteVersion >= 90600)
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
+ "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n"
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17081,47 +16801,33 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
if (!fout->is_prepared[PREPQUERY_GETCOLUMNACLS])
{
- /* Set up query for column ACLs */
+ /*
+ * Set up query for column ACLs.
+ *
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
appendPQExpBufferStr(query,
- "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
-
- if (fout->remoteVersion >= 90600)
- {
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
+ "PREPARE getColumnACLs(pg_catalog.oid) AS\n"
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19411,17 +19117,11 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ if (fout->remoteVersion < 180000 ||
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19478,59 +19178,19 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
- Assert(sequences);
-
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
+ Assert(sequences);
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19709,8 +19369,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 20cdd2d92f0..69f21a1fb86 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -693,11 +693,11 @@ main(int argc, char *argv[])
fout->verbose = verbose;
/*
- * We allow the server to be back to 9.2, and up to any minor release
+ * We allow the server to be back to 10, and up to any minor release
* of our own major version. (See also version check in
* pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = 1;
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 06134cf5d2e..22812b38ed5 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1567,19 +1473,13 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
appendPQExpBufferStr(&old_polymorphics,
"'array_append(anyarray,anyelement)'"
", 'array_cat(anyarray,anyarray)'"
- ", 'array_prepend(anyelement,anyarray)'");
-
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
-
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ ", 'array_prepend(anyelement,anyarray)'"
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'"
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
@@ -1870,63 +1770,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index e18687226ae..a563efcb6d3 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -42,9 +42,6 @@ get_control_data(ClusterInfo *cluster)
char bufin[MAX_STRING];
FILE *output;
char *p;
- bool got_tli = false;
- bool got_log_id = false;
- bool got_log_seg = false;
bool got_xid = false;
bool got_oid = false;
bool got_multi = false;
@@ -75,10 +72,6 @@ get_control_data(ClusterInfo *cluster)
char *language = NULL;
char *lc_all = NULL;
char *lc_messages = NULL;
- uint32 tli = 0;
- uint32 logid = 0;
- uint32 segno = 0;
- char *resetwal_bin;
int rc;
bool live_check = (cluster == &old_cluster && user_opts.live_check);
@@ -189,27 +182,15 @@ get_control_data(ClusterInfo *cluster)
}
}
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- resetwal_bin = "pg_resetxlog\" -n";
- else
- resetwal_bin = "pg_resetwal\" -n";
snprintf(cmd, sizeof(cmd), "\"%s/%s \"%s\"",
cluster->bindir,
- live_check ? "pg_controldata\"" : resetwal_bin,
+ live_check ? "pg_controldata\"" : "pg_resetwal\" -n",
cluster->pgdata);
fflush(NULL);
if ((output = popen(cmd, "r")) == NULL)
pg_fatal("could not get control data using %s: %m", cmd);
- /* Only in <= 9.2 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
- {
- cluster->controldata.data_checksum_version = PG_DATA_CHECKSUM_OFF;
- got_data_checksum_version = true;
- }
-
/* we have the result of cmd in "output". so parse it line by line now */
while (fgets(bufin, sizeof(bufin), output))
{
@@ -237,39 +218,6 @@ get_control_data(ClusterInfo *cluster)
p++; /* remove ':' char */
cluster->controldata.cat_ver = str2uint(p);
}
- else if ((p = strstr(bufin, "Latest checkpoint's TimeLineID:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- tli = str2uint(p);
- got_tli = true;
- }
- else if ((p = strstr(bufin, "First log file ID after reset:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- logid = str2uint(p);
- got_log_id = true;
- }
- else if ((p = strstr(bufin, "First log file segment after reset:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- segno = str2uint(p);
- got_log_seg = true;
- }
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
p = strchr(p, ':');
@@ -280,23 +228,12 @@ get_control_data(ClusterInfo *cluster)
p++; /* remove ':' char */
cluster->controldata.chkpnt_nxtepoch = str2uint(p);
- /*
- * Delimiter changed from '/' to ':' in 9.6. We don't test for
- * the catalog version of the change because the catalog version
- * is pulled from pg_controldata too, and it isn't worth adding an
- * order dependency for this --- we just check the string.
- */
- if (strchr(p, '/') != NULL)
- p = strchr(p, '/');
- else if (GET_MAJOR_VERSION(cluster->major_version) >= 906)
- p = strchr(p, ':');
- else
- p = NULL;
+ p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
- p++; /* remove '/' or ':' char */
+ p++; /* remove ':' char */
cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
@@ -568,22 +505,6 @@ get_control_data(ClusterInfo *cluster)
pg_free(lc_all);
pg_free(lc_messages);
- /*
- * Before 9.3, pg_resetwal reported the xlogid and segno of the first log
- * file after reset as separate lines. Starting with 9.3, it reports the
- * WAL file name. If the old cluster is older than 9.3, we construct the
- * WAL file name from the xlogid and segno.
- */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
- {
- if (got_tli && got_log_id && got_log_seg)
- {
- snprintf(cluster->controldata.nextxlogfile, 25, "%08X%08X%08X",
- tli, logid, segno);
- got_nextxlogfile = true;
- }
- }
-
/*
* Pre-v18 database clusters don't have the default char signedness
* information. We use the char signedness of the platform where
@@ -602,14 +523,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +549,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +588,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index e1de61f36ee..beb255a5152 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -353,18 +353,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
- check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -404,11 +394,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..48e6f8e52a8 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -64,7 +64,7 @@ static void prepare_new_cluster(void);
static void prepare_new_globals(void);
static void create_new_objects(void);
static void copy_xact_xlog_xid(void);
-static void set_frozenxids(bool minmxid_only);
+static void set_frozenxids(void);
static void make_outputdirs(char *pgdata);
static void setup(char *argv0);
static void create_logical_replication_slots(void);
@@ -576,7 +576,7 @@ prepare_new_globals(void)
/*
* Before we restore anything, set frozenxids of initdb-created tables.
*/
- set_frozenxids(false);
+ set_frozenxids();
/*
* Now restore global objects (roles and tablespaces).
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -773,14 +766,8 @@ copy_subdir_files(const char *old_subdir, const char *new_subdir)
static void
copy_xact_xlog_xid(void)
{
- /*
- * Copy old commit logs to new data dir. pg_clog has been renamed to
- * pg_xact in post-10 clusters.
- */
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ /* Copy old commit logs to new data dir. */
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +796,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +830,8 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
@@ -914,18 +883,10 @@ copy_xact_xlog_xid(void)
*
* As we create user tables later, their relfrozenxid/relminmxid fields will
* be restored properly by the binary-upgrade restore script. Likewise for
- * user-database datfrozenxid/datminmxid. However, if we're upgrading from a
- * pre-9.3 database, which does not store per-table or per-DB minmxid, then
- * the relminmxid/datminmxid values filled in by the restore script will just
- * be zeroes.
- *
- * Hence, with a pre-9.3 source database, a second call occurs after
- * everything is restored, with minmxid_only = true. This pass will
- * initialize all tables and databases, both those made by initdb and user
- * objects, with the desired minmxid value. frozenxid values are left alone.
+ * user-database datfrozenxid/datminmxid.
*/
static void
-set_frozenxids(bool minmxid_only)
+set_frozenxids(void)
{
int dbnum;
PGconn *conn,
@@ -935,19 +896,15 @@ set_frozenxids(bool minmxid_only)
int i_datname;
int i_datallowconn;
- if (!minmxid_only)
- prep_status("Setting frozenxid and minmxid counters in new cluster");
- else
- prep_status("Setting minmxid counter in new cluster");
+ prep_status("Setting frozenxid and minmxid counters in new cluster");
conn_template1 = connectToServer(&new_cluster, "template1");
- if (!minmxid_only)
- /* set pg_database.datfrozenxid */
- PQclear(executeQueryOrDie(conn_template1,
- "UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ /* set pg_database.datfrozenxid */
+ PQclear(executeQueryOrDie(conn_template1,
+ "UPDATE pg_catalog.pg_database "
+ "SET datfrozenxid = '%u'",
+ old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
@@ -983,17 +940,16 @@ set_frozenxids(bool minmxid_only)
conn = connectToServer(&new_cluster, datname);
- if (!minmxid_only)
- /* set pg_class.relfrozenxid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
- /* only heap, materialized view, and TOAST are vacuumed */
- "WHERE relkind IN ("
- CppAsString2(RELKIND_RELATION) ", "
- CppAsString2(RELKIND_MATVIEW) ", "
- CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ /* set pg_class.relfrozenxid */
+ PQclear(executeQueryOrDie(conn,
+ "UPDATE pg_catalog.pg_class "
+ "SET relfrozenxid = '%u' "
+ /* only heap, materialized view, and TOAST are vacuumed */
+ "WHERE relkind IN ("
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_TOASTVALUE) ")",
+ old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 1d767bbda2d..16cf7d924fd 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,11 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
-
void report_extension_updates(ClusterInfo *cluster);
/* multixact_rewrite.c */
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,40 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
+ switch (user_opts.transfer_mode)
{
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
}
- else
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
}
}
diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c
index 1eb8bc97c05..abaa59f090c 100644
--- a/src/bin/pg_upgrade/server.c
+++ b/src/bin/pg_upgrade/server.c
@@ -185,9 +185,7 @@ start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error)
if (cluster->sockdir)
snprintf(socket_string + strlen(socket_string),
sizeof(socket_string) - strlen(socket_string),
- " -c %s='%s'",
- (GET_MAJOR_VERSION(cluster->major_version) <= 902) ?
- "unix_socket_directory" : "unix_socket_directories",
+ " -c unix_socket_directories='%s'",
cluster->sockdir);
#endif
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 493400f9090..e5fb3595598 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6272,38 +6272,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 4e8ff00394a..662df2d5448 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,20 +387,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,70 +1086,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,53 +1675,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2459,12 +2324,8 @@ describeOneTableDetails(const char *schemaname,
"contype IN (" CppAsString2(CONSTRAINT_PRIMARY) ","
CppAsString2(CONSTRAINT_UNIQUE) ","
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
- "condeferred) AS condeferred,\n");
-
- if (pset.sversion >= 90400)
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
+ "condeferred) AS condeferred,\n"
+ "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2568,11 +2429,8 @@ describeOneTableDetails(const char *schemaname,
"i.indisclustered, i.indisvalid, "
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
- "contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
- appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
+ "contype, condeferrable, condeferred, "
+ "i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,88 +2681,78 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBuffer(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBuffer(&buf, "SELECT pol.polname, pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
}
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2855,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,118 +3021,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
{
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
}
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3551,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3561,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3963,12 +3800,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
appendPQExpBufferStr(&buf, "\n, pg_catalog.shobj_description(r.oid, 'pg_authid') AS description");
ncols++;
}
- appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
+ appendPQExpBufferStr(&buf, "\n, r.rolreplication, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,9 +3855,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -4514,19 +4345,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4852,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4921,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,19 +5150,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6481,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6618,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6868,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index 9990f818942..abf0bf3b8dc 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -1208,6 +1208,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC"
" FROM pg_catalog.pg_timezone_names() "\
" WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')"
+#define Query_for_list_of_publications \
+" SELECT pubname "\
+" FROM pg_catalog.pg_publication "\
+" WHERE pubname LIKE '%s'"
+
+#define Query_for_list_of_subscriptions \
+" SELECT s.subname "\
+" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d "\
+" WHERE s.subname LIKE '%s' "\
+" AND d.datname = pg_catalog.current_database() "\
+" AND s.subdbid = d.oid"
+
/* Privilege options shared between GRANT and REVOKE */
#define Privilege_options_of_grant_and_revoke \
"SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \
@@ -1242,32 +1254,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \
#define Copy_to_options \
Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY"
-/*
- * These object types were introduced later than our support cutoff of
- * server version 9.2. We use the VersionedQuery infrastructure so that
- * we don't send certain-to-fail queries to older servers.
- */
-
-static const VersionedQuery Query_for_list_of_publications[] = {
- {100000,
- " SELECT pubname "
- " FROM pg_catalog.pg_publication "
- " WHERE pubname LIKE '%s'"
- },
- {0, NULL}
-};
-
-static const VersionedQuery Query_for_list_of_subscriptions[] = {
- {100000,
- " SELECT s.subname "
- " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d "
- " WHERE s.subname LIKE '%s' "
- " AND d.datname = pg_catalog.current_database() "
- " AND s.subdbid = d.oid"
- },
- {0, NULL}
-};
-
/* Known command-starting keywords. */
static const char *const sql_commands[] = {
"ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER",
@@ -1345,7 +1331,7 @@ static const pgsql_thing_t words_after_create[] = {
{"POLICY", NULL, NULL, NULL},
{"PROCEDURE", NULL, NULL, Query_for_list_of_procedures},
{"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs},
- {"PUBLICATION", NULL, Query_for_list_of_publications},
+ {"PUBLICATION", Query_for_list_of_publications},
{"ROLE", Query_for_list_of_roles},
{"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE},
{"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"},
@@ -1353,7 +1339,7 @@ static const pgsql_thing_t words_after_create[] = {
{"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences},
{"SERVER", Query_for_list_of_servers},
{"STATISTICS", NULL, NULL, &Query_for_list_of_statistics},
- {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions},
+ {"SUBSCRIPTION", Query_for_list_of_subscriptions},
{"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
{"TABLE", NULL, NULL, &Query_for_list_of_tables},
{"TABLESPACE", Query_for_list_of_tablespaces},
@@ -5672,9 +5658,9 @@ match_previous_words(int pattern_id,
else if (TailMatchesCS("\\dP*"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations);
else if (TailMatchesCS("\\dRp*"))
- COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications);
+ COMPLETE_WITH_QUERY(Query_for_list_of_publications);
else if (TailMatchesCS("\\dRs*"))
- COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions);
+ COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions);
else if (TailMatchesCS("\\ds*"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences);
else if (TailMatchesCS("\\dt*"))
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-04-08 16:23 Tom Lane <tgl@sss.pgh.pa.us>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Tom Lane @ 2026-04-08 16:23 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: pgsql-hackers
Nathan Bossart <nathandbossart@gmail.com> writes:
> I've brought this up a couple times in the past ~year, so here's a patch.
> Supporting versions as old as v9.2 has become quite cumbersome, requiring
> various version-specific branches and hacks. I believe our current policy
> is that we support at least 10 previous major versions [0]. For reference,
> we last bumped the minimum to v9.2 in 2021 (commits 30e7c175b 81,
> e469f0aaf3, and cf0cab868a).
I'm on board with this for v20, but as a matter of reviewing the
patch: it'd be easier if you separated it into two steps, one that
does the actual changes but doesn't reindent anything, and then a
separate application of pgindent. As this diff stands, there's an
awful lot of noise resulting from outdenting no-longer-conditional
code, which has to be reviewed by hand but it could be checked
mechanically if you left it to a "this just applies pgindent" step.
Looking at the commit log, I was struck by my comment in 30e7c175b:
(As in previous changes of
this sort, we aren't removing pg_restore's ability to read older
archive files ... though it's fair to wonder how that might be
tested nowadays.)
I wonder whether we ought to sunset some of that code too, and
if so how to draw the line on minimum archive version to support.
BTW, see also 492046fa9.
regards, tom lane
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-04-08 16:42 Andrew Dunstan <andrew@dunslane.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 21+ messages in thread
From: Andrew Dunstan @ 2026-04-08 16:42 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Nathan Bossart <nathandbossart@gmail.com>; +Cc: pgsql-hackers
On 2026-04-08 We 12:23 PM, Tom Lane wrote:
> Nathan Bossart <nathandbossart@gmail.com> writes:
>> I've brought this up a couple times in the past ~year, so here's a patch.
>> Supporting versions as old as v9.2 has become quite cumbersome, requiring
>> various version-specific branches and hacks. I believe our current policy
>> is that we support at least 10 previous major versions [0]. For reference,
>> we last bumped the minimum to v9.2 in 2021 (commits 30e7c175b 81,
>> e469f0aaf3, and cf0cab868a).
> I'm on board with this for v20, but as a matter of reviewing the
> patch: it'd be easier if you separated it into two steps, one that
> does the actual changes but doesn't reindent anything, and then a
> separate application of pgindent. As this diff stands, there's an
> awful lot of noise resulting from outdenting no-longer-conditional
> code, which has to be reviewed by hand but it could be checked
> mechanically if you left it to a "this just applies pgindent" step.
>
> Looking at the commit log, I was struck by my comment in 30e7c175b:
>
> (As in previous changes of
> this sort, we aren't removing pg_restore's ability to read older
> archive files ... though it's fair to wonder how that might be
> tested nowadays.)
>
> I wonder whether we ought to sunset some of that code too, and
> if so how to draw the line on minimum archive version to support.
>
> BTW, see also 492046fa9.
>
>
I'm on board, if for no other reason than that it will shorten some of
my animals' buildfarm runs. I guess people wanting to upgrade from
ancient versions can do it in multiple hops. At the same time, I
wouldn't want to do this every year. It's been 5 years since he last
time we did this, and that seems about the right interval.
I guess I'll have to teach the buildfarm's cross-version upgrade module
what old versions are supported by which release.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-04-08 17:24 Corey Huinker <corey.huinker@gmail.com>
parent: Andrew Dunstan <andrew@dunslane.net>
1 sibling, 1 reply; 21+ messages in thread
From: Corey Huinker @ 2026-04-08 17:24 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
>
> > I wonder whether we ought to sunset some of that code too, and
> > if so how to draw the line on minimum archive version to support.
>
I'm assuming that the need to restore such very old dumpfiles is forensic
or compliance in nature, so we'd want to give people some recourse for
those files going forward.
> I guess people wanting to upgrade from
> ancient versions can do it in multiple hops.
+1
It would help if we provided some small documentation on how to do that. It
could be as simple as a docbook table mapping various postgres versions to
the highest version a) a live database can be pg_upgraded to and b) a
dumpfile can be pg_restored to. But it could also include a script to
re-dump an old dumpfile to a newer dump version. I'd be happy to take a
swing at that if nobody else is interested.
> At the same time, I
> wouldn't want to do this every year. It's been 5 years since he last
> time we did this, and that seems about the right interval.
>
+1 to a 5 year cadence.
> I guess I'll have to teach the buildfarm's cross-version upgrade module
> what old versions are supported by which release.
>
Which is a second use for that table I just proposed.
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-04-08 17:31 Nathan Bossart <nathandbossart@gmail.com>
parent: Andrew Dunstan <andrew@dunslane.net>
1 sibling, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-04-08 17:31 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
On Wed, Apr 08, 2026 at 12:42:21PM -0400, Andrew Dunstan wrote:
> On 2026-04-08 We 12:23 PM, Tom Lane wrote:
>> I'm on board with this for v20, but as a matter of reviewing the
>> patch: it'd be easier if you separated it into two steps, one that
>> does the actual changes but doesn't reindent anything, and then a
>> separate application of pgindent. As this diff stands, there's an
>> awful lot of noise resulting from outdenting no-longer-conditional
>> code, which has to be reviewed by hand but it could be checked
>> mechanically if you left it to a "this just applies pgindent" step.
Will do. There's also various code consolidation throughout, so I suspect
this will become ~3 patches in the end.
>> Looking at the commit log, I was struck by my comment in 30e7c175b:
>>
>> (As in previous changes of
>> this sort, we aren't removing pg_restore's ability to read older
>> archive files ... though it's fair to wonder how that might be
>> tested nowadays.)
>>
>> I wonder whether we ought to sunset some of that code too, and
>> if so how to draw the line on minimum archive version to support.
K_VERS_1_12 was added in 2010 for v9.0, and K_VERS_1_13 was added in 2018
for v11. The latter is within our 10 release window for pg_dump, etc., and
the former is well beyond it. So, K_VERS_1_12 is probably the latest we
could bump it to. I suspect that'd be fine, but we might still want to
consider choosing an earlier version out of an abundance of caution.
Perhaps our policy could be something like past-15-major-releases for
pg_restore.
>> BTW, see also 492046fa9.
Noted.
> I'm on board, if for no other reason than that it will shorten some of my
> animals' buildfarm runs. I guess people wanting to upgrade from ancient
> versions can do it in multiple hops. At the same time, I wouldn't want to do
> this every year. It's been 5 years since he last time we did this, and that
> seems about the right interval.
Yeah, I think this is where we ultimately landed in a previous discussion
on Discord.
--
nathan
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-04-08 17:55 Tom Lane <tgl@sss.pgh.pa.us>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 0 replies; 21+ messages in thread
From: Tom Lane @ 2026-04-08 17:55 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Corey Huinker <corey.huinker@gmail.com>; Andrew Dunstan <andrew@dunslane.net>; pgsql-hackers
Nathan Bossart <nathandbossart@gmail.com> writes:
> On Wed, Apr 08, 2026 at 12:42:21PM -0400, Andrew Dunstan wrote:
>> On 2026-04-08 We 12:23 PM, Tom Lane wrote:
>>> Looking at the commit log, I was struck by my comment in 30e7c175b:
>>> (As in previous changes of
>>> this sort, we aren't removing pg_restore's ability to read older
>>> archive files ... though it's fair to wonder how that might be
>>> tested nowadays.)
>>> I wonder whether we ought to sunset some of that code too, and
>>> if so how to draw the line on minimum archive version to support.
> K_VERS_1_12 was added in 2010 for v9.0, and K_VERS_1_13 was added in 2018
> for v11. The latter is within our 10 release window for pg_dump, etc., and
> the former is well beyond it. So, K_VERS_1_12 is probably the latest we
> could bump it to. I suspect that'd be fine, but we might still want to
> consider choosing an earlier version out of an abundance of caution.
> Perhaps our policy could be something like past-15-major-releases for
> pg_restore.
Yeah. In 64f3524e2 I said
I did not remove the ability for pg_restore to read custom-format archives
generated by these old versions (and light testing says that that does
still work). If you have an old server, you probably also have a pg_dump
that will work with it; but you have an old custom-format backup file,
that might be all you have.
That reasoning still holds, so we ought to be a bit more reluctant to
remove archive-version support than server-version support. However,
carrying ancient code we can't test anymore isn't attractive either.
BTW, I think this is actually more complicated than just looking for
code that's conditional on K_VERS_x; there's not that much of that
anyway, if memory serves. What could get rid of more code is looking
for places that support TOC entry types we no longer generate, or work
around bugs we no longer have. Finding such places is tricky though.
A starting point might be to examine the code coverage report for
unexercised stanzas in pg_restore.
Another related point, which doesn't really concern this code-ectomy
project but is relevant to Corey's idea of making a table of supported
upgrade paths, is that we've also made server-side changes that affect
dump/restore compatibility. The ones I found in a quick search
were v13's e58a59975, 84eca14bc, bb03010b9, but there are probably
more.
regards, tom lane
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-04-08 18:04 Nathan Bossart <nathandbossart@gmail.com>
parent: Corey Huinker <corey.huinker@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-04-08 18:04 UTC (permalink / raw)
To: Corey Huinker <corey.huinker@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
On Wed, Apr 08, 2026 at 01:24:29PM -0400, Corey Huinker wrote:
> It would help if we provided some small documentation on how to do that. It
> could be as simple as a docbook table mapping various postgres versions to
> the highest version a) a live database can be pg_upgraded to and b) a
> dumpfile can be pg_restored to. But it could also include a script to
> re-dump an old dumpfile to a newer dump version. I'd be happy to take a
> swing at that if nobody else is interested.
I like these ideas. IMHO this helps us be reasonably aggressive about
removing support for ancient versions while still providing a lifeboat when
folks using those ancient versions decide to upgrade.
--
nathan
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-05-01 20:10 Nathan Bossart <nathandbossart@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-05-01 20:10 UTC (permalink / raw)
To: Corey Huinker <corey.huinker@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
I wrote a new set of patches on a plane a couple of weeks ago, but I forgot
to post them. I'm not yet 100% positive I've got the changes to
rewrite_multixacts() in the pg_upgrade patch correct, but otherwise it's
pretty mechanical and straightforward.
--
nathan
From 83e5bd021dc3f41b4aa36633873881efb6dea2b0 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 10:15:38 -0700
Subject: [PATCH v2 1/4] pg_dump/pg_dumpall: bump minimum supported version to
v10
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/runtime.sgml | 2 +-
src/bin/pg_dump/pg_dump.c | 330 ++--------------------------------
src/bin/pg_dump/pg_dumpall.c | 32 +---
4 files changed, 22 insertions(+), 356 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index ae1bc14d2f2..64a3447e445 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1718,7 +1706,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index b01e74638c4..3fa6cdf3a5e 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1776,7 +1776,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
version of
<productname>PostgreSQL</productname>, to take advantage of enhancements
that might have been made in these programs. Current releases of the
- dump programs can read data from any server version back to 9.2.
+ dump programs can read data from any server version back to 10.
</para>
<para>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d56dcc701ce..eed9aaeb7c1 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,9 +1491,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security = on");
else
ExecuteSqlStatement(AH, "SET row_security = off");
- }
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1964,12 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
return true;
}
@@ -2000,11 +1986,10 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
+ * We dump out any ACLs defined in pg_catalog, if
* they are interesting (and not the original ACLs which were set at
* initdb time, see pg_init_privs).
*/
@@ -2213,8 +2198,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2215,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3100,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3325,10 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid IN (%u, %u, %u, %u);\n",
LargeObjectRelationId, LargeObjectLOidPNIndexId,
LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4207,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4316,10 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -4534,7 +4491,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4854,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5144,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,24 +6632,12 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
/*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
+ * Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"amtype, "
"amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6878,15 +6823,12 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
: "p.proisagg");
@@ -6916,29 +6858,6 @@ getAggregates(Archive *fout)
"refclassid = 'pg_extension'::regclass AND "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7021,6 +6940,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7039,14 +6959,10 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, in 9.6 and up, include functions in
+ * they are built-in. Also, include functions in
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
: "NOT p.proisagg");
@@ -7090,46 +7006,6 @@ getFuncs(Archive *fout)
appendPQExpBufferStr(query,
"\n OR p.proacl IS DISTINCT FROM pip.initprivs");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7378,64 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
"CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
"WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,9 +7296,8 @@ getTables(Archive *fout, int *numTables)
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
/*
- * In 9.6 and up, left join to pg_am to pick up the amname.
+ * Left join to pg_am to pick up the amname.
*/
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
@@ -8028,12 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8318,10 +8156,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8988,10 +8822,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9258,10 +9088,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9489,12 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(q,
"a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10897,8 +10719,6 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
printfPQExpBuffer(query,
"SELECT objoid, classoid, objsubid, privtype, initprivs "
"FROM pg_init_privs");
@@ -10966,7 +10786,6 @@ getAdditionalACLs(Archive *fout)
}
}
PQclear(res);
- }
destroyPQExpBuffer(query);
}
@@ -11141,15 +10960,6 @@ fetchAttributeStats(Archive *fout)
static bool restarted;
int max_rels = MAX_ATTR_STATS_RELS;
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
-
/* If we're just starting, set our TOC pointer. */
if (!te)
te = AH->toc->next;
@@ -11320,16 +11130,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For versions before 19, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11337,7 +11142,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11345,12 +11150,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13672,19 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15174,14 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"collprovider, "
"collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15588,7 +15374,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"aggkind,\n"
"aggmtransfn,\n"
@@ -15600,31 +15385,12 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"aggtransspace,\n"
"aggmtransspace,\n"
"aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"aggcombinefn,\n"
"aggserialfn,\n"
"aggdeserialfn,\n"
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17084,8 +16850,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- if (fout->remoteVersion >= 90600)
- {
/*
* In principle we should call acldefault('c', relowner) to
* get the default ACL for a column. However, we don't
@@ -17110,17 +16874,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
"ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
ExecuteSqlStatement(fout, query->data);
@@ -19410,16 +19163,10 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
+ if (fout->remoteVersion < 180000 ||
(!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
@@ -19477,59 +19224,20 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
+ * The sequence information is gathered in a sorted
* table before any calls to dumpSequence(). See collectSequences() for
* more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
Assert(sequences);
key.oid = tbinfo->dobj.catId.oid;
seq = bsearch(&key, sequences, nsequences,
sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
-
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19708,8 +19416,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index c1f43113c53..5b10f7122b7 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -693,11 +693,11 @@ main(int argc, char *argv[])
fout->verbose = verbose;
/*
- * We allow the server to be back to 9.2, and up to any minor release
+ * We allow the server to be back to 10, and up to any minor release
* of our own major version. (See also version check in
* pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = 1;
@@ -954,17 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT rolname "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 1", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1041,7 +1035,6 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT oid, rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, "
@@ -1052,27 +1045,6 @@ dumpRoles(PGconn *conn)
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 2", role_catalog);
- else if (server_version >= 90500)
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, "
- "false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
--
2.50.1 (Apple Git-155)
From f647a1f77856bff05dcb5eab91d02c6829c9e1e5 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:20:18 -0700
Subject: [PATCH v2 2/4] pg_upgrade: bump minimum supported version to v10
---
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_upgrade/check.c | 157 +----------------------
src/bin/pg_upgrade/controldata.c | 12 +-
src/bin/pg_upgrade/exec.c | 23 ----
src/bin/pg_upgrade/file.c | 164 -------------------------
src/bin/pg_upgrade/multixact_rewrite.c | 11 +-
src/bin/pg_upgrade/pg_upgrade.c | 31 +----
src/bin/pg_upgrade/pg_upgrade.h | 29 -----
src/bin/pg_upgrade/relfilenumber.c | 37 +-----
src/bin/pg_upgrade/version.c | 127 -------------------
10 files changed, 16 insertions(+), 577 deletions(-)
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index 38ca09b423c..c4ed75211db 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 5a7afe62eab..0813cef2729 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 10)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1569,12 +1475,10 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
appendPQExpBufferStr(&old_polymorphics,
", 'array_remove(anyarray,anyelement)'"
", 'array_replace(anyarray,anyelement,anyelement)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
appendPQExpBufferStr(&old_polymorphics,
", 'array_position(anyarray,anyelement)'"
", 'array_position(anyarray,anyelement,integer)'"
@@ -1870,63 +1774,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index cffcd4b0eba..8188355240f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -602,14 +602,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +628,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +667,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index e1de61f36ee..479557abdcc 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,16 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- if (v1 < 10)
- {
- /* old style, e.g. 9.6.1 */
- cluster->bin_version = v1 * 10000 + v2 * 100;
- }
- else
- {
- /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
- }
}
@@ -353,17 +344,7 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
check_single_dir(pg_data, "pg_xact");
}
@@ -404,10 +385,6 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index 823984ec8f3..c45b3183684 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -25,10 +25,7 @@ static void RecordMultiXactMembers(SlruSegState *members_writer,
* 32-bit offsets to the current format.
*
* Multixids in the range [from_multi, to_multi) are read from the old
- * cluster, and written in the new format. An important edge case is that if
- * from_multi == to_multi, this initializes the new pg_multixact files in the
- * new format without trying to open any old files. (We rely on that when
- * upgrading from PostgreSQL version 9.2 or below.)
+ * cluster, and written in the new format.
*
* Returns the new nextOffset value; the caller should set it in the new
* control file. The new members always start from offset 1, regardless of
@@ -42,6 +39,7 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
SlruSegState *members_writer;
char dir[MAXPGPATH] = {0};
bool prev_multixid_valid = false;
+ OldMultiXactReader *old_reader;
/*
* The range of valid multi XIDs is unchanged by the conversion (they are
@@ -63,10 +61,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- if (to_multi != from_multi)
- {
- OldMultiXactReader *old_reader;
-
old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
old_cluster.controldata.chkpnt_nxtmulti,
old_cluster.controldata.chkpnt_nxtmxoff);
@@ -113,7 +107,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
}
FreeOldMultiXactReader(old_reader);
- }
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..e5d7920c1b1 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -777,10 +770,7 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +799,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 1d767bbda2d..5a0d2045be5 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,10 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
void report_extension_updates(ClusterInfo *cluster);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..ec2ff7acb21 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,14 +587,6 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
- {
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
- }
- else
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
--
2.50.1 (Apple Git-155)
From 3880d0ba99dbc3c5979afb1782c38187de90105d Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:34:35 -0700
Subject: [PATCH v2 3/4] psql: bump minimum supported version to v10
---
doc/src/sgml/ref/psql-ref.sgml | 2 +-
src/bin/psql/command.c | 23 +--
src/bin/psql/describe.c | 255 +--------------------------------
3 files changed, 11 insertions(+), 269 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 7c05afd4719..56c2692e618 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
or an older major version. Backslash commands are particularly likely
to fail if the server is of a newer version than <application>psql</application>
itself. However, backslash commands of the <literal>\d</literal> family should
- work with servers of versions back to 9.2, though not necessarily with
+ work with servers of versions back to 10, though not necessarily with
servers newer than <application>psql</application> itself. The general
functionality of running SQL commands and displaying query results
should also work with servers of a newer major version, but this cannot
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 493400f9090..c9573d4b765 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
+ * Views may have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
+ * separately. Materialized views may have
* arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
@@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index e1449654f96..76d299fb55c 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Result data type"),
gettext_noop("Argument data types"));
- if (pset.sversion >= 110000)
appendPQExpBuffer(&buf,
" pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
"FROM pg_catalog.pg_proc p\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
"WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n",
gettext_noop("Description"));
- else
- appendPQExpBuffer(&buf,
- " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
- "FROM pg_catalog.pg_proc p\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
- "WHERE p.proisagg\n",
- gettext_noop("Description"));
if (!showSystem && !pattern)
appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n"
@@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
appendPQExpBuffer(&buf,
",\n CASE\n"
" WHEN p.proparallel = "
@@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
myopt.translate_columns = translate_columns;
myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT polname\n"
@@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname,
"FROM pg_catalog.pg_sequence\n"
"WHERE seqrelid = '%s';",
oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname,
if (tableinfo.relkind == RELKIND_INDEX ||
tableinfo.relkind == RELKIND_PARTITIONED_INDEX)
{
- if (pset.sversion >= 110000)
- {
appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key",
oid,
gettext_noop("yes"),
gettext_noop("no"));
isindexkey_col = cols++;
- }
appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef");
indexdef_col = cols++;
}
@@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
appendPQExpBuffer(&buf,
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
@@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
if (pset.sversion >= 150000)
@@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Bypass RLS"));
@@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
" CASE c.collprovider "
"WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
@@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
"WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
"END AS \"%s\",\n",
gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6475,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6612,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
--
2.50.1 (Apple Git-155)
From 9c32a105a321c4f1e8478286464c3becd12f68ea Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 1 May 2026 14:38:37 -0500
Subject: [PATCH v2 4/4] run pgindent
---
src/bin/pg_dump/pg_dump.c | 457 ++++++++++++-----------
src/bin/pg_dump/pg_dumpall.c | 30 +-
src/bin/pg_upgrade/check.c | 16 +-
src/bin/pg_upgrade/exec.c | 8 +-
src/bin/pg_upgrade/multixact_rewrite.c | 80 ++--
src/bin/pg_upgrade/pg_upgrade.c | 2 +-
src/bin/pg_upgrade/relfilenumber.c | 54 +--
src/bin/psql/command.c | 29 +-
src/bin/psql/describe.c | 483 ++++++++++++-------------
9 files changed, 578 insertions(+), 581 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index eed9aaeb7c1..c05623b1889 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1491,8 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1505,10 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1955,7 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -1989,9 +1989,9 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * We dump out any ACLs defined in pg_catalog, if
- * they are interesting (and not the original ACLs which were set at
- * initdb time, see pg_init_privs).
+ * We dump out any ACLs defined in pg_catalog, if they are interesting
+ * (and not the original ACLs which were set at initdb time, see
+ * pg_init_privs).
*/
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL;
}
@@ -3298,7 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- appendPQExpBufferStr(dbQry, "datminmxid, ");
+ appendPQExpBufferStr(dbQry, "datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3640,11 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- appendPQExpBufferStr(query, "pol.polpermissive, ");
+ appendPQExpBufferStr(query, "pol.polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -6635,9 +6635,9 @@ getAccessMethods(Archive *fout)
* Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
+ appendPQExpBufferStr(query,
+ "amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6829,35 +6829,35 @@ getAggregates(Archive *fout)
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6959,53 +6959,53 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, include functions in
- * pg_catalog if they have an ACL different from what's shown in
- * pg_init_privs (so we have to join to pg_init_privs; annoying).
+ * they are built-in. Also, include functions in pg_catalog if they have
+ * an ACL different from what's shown in pg_init_privs (so we have to join
+ * to pg_init_privs; annoying).
*/
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7254,31 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, ");
- appendPQExpBufferStr(query,
- "c.relreplident, ");
+ appendPQExpBufferStr(query,
+ "c.relreplident, ");
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
+ appendPQExpBufferStr(query,
+ "c.relrowsecurity, c.relforcerowsecurity, ");
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
+ appendPQExpBufferStr(query,
+ "c.relminmxid, tc.relminmxid AS tminmxid, ");
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
+ appendPQExpBufferStr(query,
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- appendPQExpBufferStr(query,
- "am.amname, ");
+ appendPQExpBufferStr(query,
+ "am.amname, ");
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
+ appendPQExpBufferStr(query,
+ "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7298,8 +7298,8 @@ getTables(Archive *fout, int *numTables)
/*
* Left join to pg_am to pick up the amname.
*/
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -7870,8 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
+ appendPQExpBufferStr(query,
+ "i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -9315,8 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10719,73 +10719,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
+ }
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11130,8 +11130,8 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For versions before 19, the redundant filter clause on s.tablename =
- * ANY(...) seems sufficient to convince the planner to use
+ * For versions before 19, the redundant filter clause on s.tablename
+ * = ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
@@ -13471,11 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ appendPQExpBufferStr(query,
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- appendPQExpBufferStr(query,
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -14965,9 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
+ appendPQExpBufferStr(query,
+ "collprovider, "
+ "collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15374,23 +15374,23 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
+ appendPQExpBufferStr(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -16850,30 +16850,30 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ /*
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
+ appendPQExpBufferStr(query,
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19167,7 +19167,7 @@ collectSequences(Archive *fout)
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19229,15 +19229,14 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * The sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- Assert(sequences);
+ Assert(sequences);
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 5b10f7122b7..3f61196671c 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -954,11 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1035,16 +1035,16 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 2", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT oid, rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, rolreplication, rolbypassrls, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 0813cef2729..5f63e2114c8 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1475,15 +1475,15 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 479557abdcc..9a675929e17 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,7 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- cluster->bin_version = v1 * 10000;
+ cluster->bin_version = v1 * 10000;
}
@@ -344,8 +344,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
- check_single_dir(pg_data, "pg_wal");
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -385,7 +385,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index c45b3183684..c7a1416494d 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -61,52 +61,52 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_nxtmxoff);
+ old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
+ old_cluster.controldata.chkpnt_nxtmulti,
+ old_cluster.controldata.chkpnt_nxtmxoff);
- for (MultiXactId multi = from_multi; multi != to_multi;)
- {
- MultiXactMember member;
- bool multixid_valid;
-
- /*
- * Read this multixid's members.
- *
- * Locking-only XIDs that may be part of multi-xids don't matter
- * after upgrade, as there can be no transactions running across
- * upgrade. So as a small optimization, we only read one member
- * from each multixid: the one updating one, or if there was no
- * update, arbitrarily the first locking xid.
- */
- multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
+ for (MultiXactId multi = from_multi; multi != to_multi;)
+ {
+ MultiXactMember member;
+ bool multixid_valid;
- /*
- * Write the new offset to pg_multixact/offsets.
- *
- * Even if this multixid is invalid, we still need to write its
- * offset if the *previous* multixid was valid. That's because
- * when reading a multixid, the number of members is calculated
- * from the difference between the two offsets.
- */
- RecordMultiXactOffset(offsets_writer, multi,
- (multixid_valid || prev_multixid_valid) ? next_offset : 0);
+ /*
+ * Read this multixid's members.
+ *
+ * Locking-only XIDs that may be part of multi-xids don't matter after
+ * upgrade, as there can be no transactions running across upgrade. So
+ * as a small optimization, we only read one member from each
+ * multixid: the one updating one, or if there was no update,
+ * arbitrarily the first locking xid.
+ */
+ multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
- /* Write the members */
- if (multixid_valid)
- {
- RecordMultiXactMembers(members_writer, next_offset, 1, &member);
- next_offset += 1;
- }
+ /*
+ * Write the new offset to pg_multixact/offsets.
+ *
+ * Even if this multixid is invalid, we still need to write its offset
+ * if the *previous* multixid was valid. That's because when reading
+ * a multixid, the number of members is calculated from the difference
+ * between the two offsets.
+ */
+ RecordMultiXactOffset(offsets_writer, multi,
+ (multixid_valid || prev_multixid_valid) ? next_offset : 0);
- /* Advance to next multixid, handling wraparound */
- multi++;
- if (multi < FirstMultiXactId)
- multi = FirstMultiXactId;
- prev_multixid_valid = multixid_valid;
+ /* Write the members */
+ if (multixid_valid)
+ {
+ RecordMultiXactMembers(members_writer, next_offset, 1, &member);
+ next_offset += 1;
}
- FreeOldMultiXactReader(old_reader);
+ /* Advance to next multixid, handling wraparound */
+ multi++;
+ if (multi < FirstMultiXactId)
+ multi = FirstMultiXactId;
+ prev_multixid_valid = multixid_valid;
+ }
+
+ FreeOldMultiXactReader(old_reader);
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5d7920c1b1..d8e1b680f5a 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -833,7 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index ec2ff7acb21..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -587,32 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix)
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
+ }
}
}
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index c9573d4b765..e5fb3595598 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6272,23 +6272,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 76d299fb55c..389c4dce367 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -98,12 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Result data type"),
gettext_noop("Argument data types"));
- appendPQExpBuffer(&buf,
- " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
- "FROM pg_catalog.pg_proc p\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
- "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n",
- gettext_noop("Description"));
+ appendPQExpBuffer(&buf,
+ " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
+ "FROM pg_catalog.pg_proc p\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
+ "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n",
+ gettext_noop("Description"));
if (!showSystem && !pattern)
appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n"
@@ -379,19 +379,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -591,8 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1078,38 +1078,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1667,27 +1667,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -1905,7 +1905,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -1916,11 +1916,11 @@ describeOneTableDetails(const char *schemaname,
if (tableinfo.relkind == RELKIND_INDEX ||
tableinfo.relkind == RELKIND_PARTITIONED_INDEX)
{
- appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key",
- oid,
- gettext_noop("yes"),
- gettext_noop("no"));
- isindexkey_col = cols++;
+ appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key",
+ oid,
+ gettext_noop("yes"),
+ gettext_noop("no"));
+ isindexkey_col = cols++;
appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef");
indexdef_col = cols++;
}
@@ -2315,7 +2315,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
+ appendPQExpBufferStr(&buf, "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2420,7 +2420,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- appendPQExpBufferStr(&buf, ", i.indisreplident");
+ appendPQExpBufferStr(&buf, ", i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2671,81 +2671,80 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBufferStr(&buf, "SELECT pol.polname,");
+ appendPQExpBufferStr(&buf,
+ " pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3014,115 +3013,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Included in publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Included in publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3794,7 +3793,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
+ appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -3849,8 +3848,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -5144,14 +5143,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
--
2.50.1 (Apple Git-155)
Attachments:
[text/plain] v2-0001-pg_dump-pg_dumpall-bump-minimum-supported-version.patch (30.0K, ../../afUIy181HqDMzaQU@nathan/2-v2-0001-pg_dump-pg_dumpall-bump-minimum-supported-version.patch)
download | inline diff:
From 83e5bd021dc3f41b4aa36633873881efb6dea2b0 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 10:15:38 -0700
Subject: [PATCH v2 1/4] pg_dump/pg_dumpall: bump minimum supported version to
v10
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/runtime.sgml | 2 +-
src/bin/pg_dump/pg_dump.c | 330 ++--------------------------------
src/bin/pg_dump/pg_dumpall.c | 32 +---
4 files changed, 22 insertions(+), 356 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index ae1bc14d2f2..64a3447e445 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1718,7 +1706,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index b01e74638c4..3fa6cdf3a5e 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1776,7 +1776,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
version of
<productname>PostgreSQL</productname>, to take advantage of enhancements
that might have been made in these programs. Current releases of the
- dump programs can read data from any server version back to 9.2.
+ dump programs can read data from any server version back to 10.
</para>
<para>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d56dcc701ce..eed9aaeb7c1 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,9 +1491,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security = on");
else
ExecuteSqlStatement(AH, "SET row_security = off");
- }
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1964,12 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
return true;
}
@@ -2000,11 +1986,10 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
+ * We dump out any ACLs defined in pg_catalog, if
* they are interesting (and not the original ACLs which were set at
* initdb time, see pg_init_privs).
*/
@@ -2213,8 +2198,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2215,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3100,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3325,10 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid IN (%u, %u, %u, %u);\n",
LargeObjectRelationId, LargeObjectLOidPNIndexId,
LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4207,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4316,10 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -4534,7 +4491,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4854,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5144,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,24 +6632,12 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
/*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
+ * Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"amtype, "
"amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6878,15 +6823,12 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
: "p.proisagg");
@@ -6916,29 +6858,6 @@ getAggregates(Archive *fout)
"refclassid = 'pg_extension'::regclass AND "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7021,6 +6940,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7039,14 +6959,10 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, in 9.6 and up, include functions in
+ * they are built-in. Also, include functions in
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
: "NOT p.proisagg");
@@ -7090,46 +7006,6 @@ getFuncs(Archive *fout)
appendPQExpBufferStr(query,
"\n OR p.proacl IS DISTINCT FROM pip.initprivs");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7378,64 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
"CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
"WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,9 +7296,8 @@ getTables(Archive *fout, int *numTables)
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
/*
- * In 9.6 and up, left join to pg_am to pick up the amname.
+ * Left join to pg_am to pick up the amname.
*/
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
@@ -8028,12 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8318,10 +8156,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8988,10 +8822,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9258,10 +9088,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9489,12 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(q,
"a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10897,8 +10719,6 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
printfPQExpBuffer(query,
"SELECT objoid, classoid, objsubid, privtype, initprivs "
"FROM pg_init_privs");
@@ -10966,7 +10786,6 @@ getAdditionalACLs(Archive *fout)
}
}
PQclear(res);
- }
destroyPQExpBuffer(query);
}
@@ -11141,15 +10960,6 @@ fetchAttributeStats(Archive *fout)
static bool restarted;
int max_rels = MAX_ATTR_STATS_RELS;
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
-
/* If we're just starting, set our TOC pointer. */
if (!te)
te = AH->toc->next;
@@ -11320,16 +11130,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For versions before 19, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11337,7 +11142,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11345,12 +11150,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13672,19 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15174,14 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"collprovider, "
"collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15588,7 +15374,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"aggkind,\n"
"aggmtransfn,\n"
@@ -15600,31 +15385,12 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"aggtransspace,\n"
"aggmtransspace,\n"
"aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"aggcombinefn,\n"
"aggserialfn,\n"
"aggdeserialfn,\n"
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17084,8 +16850,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- if (fout->remoteVersion >= 90600)
- {
/*
* In principle we should call acldefault('c', relowner) to
* get the default ACL for a column. However, we don't
@@ -17110,17 +16874,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
"ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
ExecuteSqlStatement(fout, query->data);
@@ -19410,16 +19163,10 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
+ if (fout->remoteVersion < 180000 ||
(!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
@@ -19477,59 +19224,20 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
+ * The sequence information is gathered in a sorted
* table before any calls to dumpSequence(). See collectSequences() for
* more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
Assert(sequences);
key.oid = tbinfo->dobj.catId.oid;
seq = bsearch(&key, sequences, nsequences,
sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
-
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19708,8 +19416,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index c1f43113c53..5b10f7122b7 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -693,11 +693,11 @@ main(int argc, char *argv[])
fout->verbose = verbose;
/*
- * We allow the server to be back to 9.2, and up to any minor release
+ * We allow the server to be back to 10, and up to any minor release
* of our own major version. (See also version check in
* pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = 1;
@@ -954,17 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT rolname "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 1", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1041,7 +1035,6 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT oid, rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, "
@@ -1052,27 +1045,6 @@ dumpRoles(PGconn *conn)
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 2", role_catalog);
- else if (server_version >= 90500)
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, "
- "false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
--
2.50.1 (Apple Git-155)
[text/plain] v2-0002-pg_upgrade-bump-minimum-supported-version-to-v10.patch (32.6K, ../../afUIy181HqDMzaQU@nathan/3-v2-0002-pg_upgrade-bump-minimum-supported-version-to-v10.patch)
download | inline diff:
From f647a1f77856bff05dcb5eab91d02c6829c9e1e5 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:20:18 -0700
Subject: [PATCH v2 2/4] pg_upgrade: bump minimum supported version to v10
---
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_upgrade/check.c | 157 +----------------------
src/bin/pg_upgrade/controldata.c | 12 +-
src/bin/pg_upgrade/exec.c | 23 ----
src/bin/pg_upgrade/file.c | 164 -------------------------
src/bin/pg_upgrade/multixact_rewrite.c | 11 +-
src/bin/pg_upgrade/pg_upgrade.c | 31 +----
src/bin/pg_upgrade/pg_upgrade.h | 29 -----
src/bin/pg_upgrade/relfilenumber.c | 37 +-----
src/bin/pg_upgrade/version.c | 127 -------------------
10 files changed, 16 insertions(+), 577 deletions(-)
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index 38ca09b423c..c4ed75211db 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 5a7afe62eab..0813cef2729 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 10)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1569,12 +1475,10 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
appendPQExpBufferStr(&old_polymorphics,
", 'array_remove(anyarray,anyelement)'"
", 'array_replace(anyarray,anyelement,anyelement)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
appendPQExpBufferStr(&old_polymorphics,
", 'array_position(anyarray,anyelement)'"
", 'array_position(anyarray,anyelement,integer)'"
@@ -1870,63 +1774,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index cffcd4b0eba..8188355240f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -602,14 +602,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +628,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +667,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index e1de61f36ee..479557abdcc 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,16 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- if (v1 < 10)
- {
- /* old style, e.g. 9.6.1 */
- cluster->bin_version = v1 * 10000 + v2 * 100;
- }
- else
- {
- /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
- }
}
@@ -353,17 +344,7 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
check_single_dir(pg_data, "pg_xact");
}
@@ -404,10 +385,6 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index 823984ec8f3..c45b3183684 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -25,10 +25,7 @@ static void RecordMultiXactMembers(SlruSegState *members_writer,
* 32-bit offsets to the current format.
*
* Multixids in the range [from_multi, to_multi) are read from the old
- * cluster, and written in the new format. An important edge case is that if
- * from_multi == to_multi, this initializes the new pg_multixact files in the
- * new format without trying to open any old files. (We rely on that when
- * upgrading from PostgreSQL version 9.2 or below.)
+ * cluster, and written in the new format.
*
* Returns the new nextOffset value; the caller should set it in the new
* control file. The new members always start from offset 1, regardless of
@@ -42,6 +39,7 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
SlruSegState *members_writer;
char dir[MAXPGPATH] = {0};
bool prev_multixid_valid = false;
+ OldMultiXactReader *old_reader;
/*
* The range of valid multi XIDs is unchanged by the conversion (they are
@@ -63,10 +61,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- if (to_multi != from_multi)
- {
- OldMultiXactReader *old_reader;
-
old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
old_cluster.controldata.chkpnt_nxtmulti,
old_cluster.controldata.chkpnt_nxtmxoff);
@@ -113,7 +107,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
}
FreeOldMultiXactReader(old_reader);
- }
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..e5d7920c1b1 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -777,10 +770,7 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +799,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 1d767bbda2d..5a0d2045be5 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,10 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
void report_extension_updates(ClusterInfo *cluster);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..ec2ff7acb21 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,14 +587,6 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
- {
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
- }
- else
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
--
2.50.1 (Apple Git-155)
[text/plain] v2-0003-psql-bump-minimum-supported-version-to-v10.patch (22.4K, ../../afUIy181HqDMzaQU@nathan/4-v2-0003-psql-bump-minimum-supported-version-to-v10.patch)
download | inline diff:
From 3880d0ba99dbc3c5979afb1782c38187de90105d Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:34:35 -0700
Subject: [PATCH v2 3/4] psql: bump minimum supported version to v10
---
doc/src/sgml/ref/psql-ref.sgml | 2 +-
src/bin/psql/command.c | 23 +--
src/bin/psql/describe.c | 255 +--------------------------------
3 files changed, 11 insertions(+), 269 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 7c05afd4719..56c2692e618 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
or an older major version. Backslash commands are particularly likely
to fail if the server is of a newer version than <application>psql</application>
itself. However, backslash commands of the <literal>\d</literal> family should
- work with servers of versions back to 9.2, though not necessarily with
+ work with servers of versions back to 10, though not necessarily with
servers newer than <application>psql</application> itself. The general
functionality of running SQL commands and displaying query results
should also work with servers of a newer major version, but this cannot
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 493400f9090..c9573d4b765 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
+ * Views may have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
+ * separately. Materialized views may have
* arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
@@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index e1449654f96..76d299fb55c 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Result data type"),
gettext_noop("Argument data types"));
- if (pset.sversion >= 110000)
appendPQExpBuffer(&buf,
" pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
"FROM pg_catalog.pg_proc p\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
"WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n",
gettext_noop("Description"));
- else
- appendPQExpBuffer(&buf,
- " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
- "FROM pg_catalog.pg_proc p\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
- "WHERE p.proisagg\n",
- gettext_noop("Description"));
if (!showSystem && !pattern)
appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n"
@@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
appendPQExpBuffer(&buf,
",\n CASE\n"
" WHEN p.proparallel = "
@@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
myopt.translate_columns = translate_columns;
myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT polname\n"
@@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname,
"FROM pg_catalog.pg_sequence\n"
"WHERE seqrelid = '%s';",
oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname,
if (tableinfo.relkind == RELKIND_INDEX ||
tableinfo.relkind == RELKIND_PARTITIONED_INDEX)
{
- if (pset.sversion >= 110000)
- {
appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key",
oid,
gettext_noop("yes"),
gettext_noop("no"));
isindexkey_col = cols++;
- }
appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef");
indexdef_col = cols++;
}
@@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
appendPQExpBuffer(&buf,
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
@@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
if (pset.sversion >= 150000)
@@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Bypass RLS"));
@@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
" CASE c.collprovider "
"WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
@@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
"WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
"END AS \"%s\",\n",
gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6475,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6612,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
--
2.50.1 (Apple Git-155)
[text/plain] v2-0004-run-pgindent.patch (61.4K, ../../afUIy181HqDMzaQU@nathan/5-v2-0004-run-pgindent.patch)
download | inline diff:
From 9c32a105a321c4f1e8478286464c3becd12f68ea Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 1 May 2026 14:38:37 -0500
Subject: [PATCH v2 4/4] run pgindent
---
src/bin/pg_dump/pg_dump.c | 457 ++++++++++++-----------
src/bin/pg_dump/pg_dumpall.c | 30 +-
src/bin/pg_upgrade/check.c | 16 +-
src/bin/pg_upgrade/exec.c | 8 +-
src/bin/pg_upgrade/multixact_rewrite.c | 80 ++--
src/bin/pg_upgrade/pg_upgrade.c | 2 +-
src/bin/pg_upgrade/relfilenumber.c | 54 +--
src/bin/psql/command.c | 29 +-
src/bin/psql/describe.c | 483 ++++++++++++-------------
9 files changed, 578 insertions(+), 581 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index eed9aaeb7c1..c05623b1889 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1491,8 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1505,10 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1955,7 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -1989,9 +1989,9 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * We dump out any ACLs defined in pg_catalog, if
- * they are interesting (and not the original ACLs which were set at
- * initdb time, see pg_init_privs).
+ * We dump out any ACLs defined in pg_catalog, if they are interesting
+ * (and not the original ACLs which were set at initdb time, see
+ * pg_init_privs).
*/
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL;
}
@@ -3298,7 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- appendPQExpBufferStr(dbQry, "datminmxid, ");
+ appendPQExpBufferStr(dbQry, "datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3640,11 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- appendPQExpBufferStr(query, "pol.polpermissive, ");
+ appendPQExpBufferStr(query, "pol.polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -6635,9 +6635,9 @@ getAccessMethods(Archive *fout)
* Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
+ appendPQExpBufferStr(query,
+ "amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6829,35 +6829,35 @@ getAggregates(Archive *fout)
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6959,53 +6959,53 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, include functions in
- * pg_catalog if they have an ACL different from what's shown in
- * pg_init_privs (so we have to join to pg_init_privs; annoying).
+ * they are built-in. Also, include functions in pg_catalog if they have
+ * an ACL different from what's shown in pg_init_privs (so we have to join
+ * to pg_init_privs; annoying).
*/
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7254,31 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, ");
- appendPQExpBufferStr(query,
- "c.relreplident, ");
+ appendPQExpBufferStr(query,
+ "c.relreplident, ");
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
+ appendPQExpBufferStr(query,
+ "c.relrowsecurity, c.relforcerowsecurity, ");
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
+ appendPQExpBufferStr(query,
+ "c.relminmxid, tc.relminmxid AS tminmxid, ");
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
+ appendPQExpBufferStr(query,
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- appendPQExpBufferStr(query,
- "am.amname, ");
+ appendPQExpBufferStr(query,
+ "am.amname, ");
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
+ appendPQExpBufferStr(query,
+ "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7298,8 +7298,8 @@ getTables(Archive *fout, int *numTables)
/*
* Left join to pg_am to pick up the amname.
*/
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -7870,8 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
+ appendPQExpBufferStr(query,
+ "i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -9315,8 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10719,73 +10719,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
+ }
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11130,8 +11130,8 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For versions before 19, the redundant filter clause on s.tablename =
- * ANY(...) seems sufficient to convince the planner to use
+ * For versions before 19, the redundant filter clause on s.tablename
+ * = ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
@@ -13471,11 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ appendPQExpBufferStr(query,
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- appendPQExpBufferStr(query,
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -14965,9 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
+ appendPQExpBufferStr(query,
+ "collprovider, "
+ "collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15374,23 +15374,23 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
+ appendPQExpBufferStr(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -16850,30 +16850,30 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ /*
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
+ appendPQExpBufferStr(query,
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19167,7 +19167,7 @@ collectSequences(Archive *fout)
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19229,15 +19229,14 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * The sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- Assert(sequences);
+ Assert(sequences);
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 5b10f7122b7..3f61196671c 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -954,11 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1035,16 +1035,16 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 2", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT oid, rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, rolreplication, rolbypassrls, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 0813cef2729..5f63e2114c8 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1475,15 +1475,15 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 479557abdcc..9a675929e17 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,7 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- cluster->bin_version = v1 * 10000;
+ cluster->bin_version = v1 * 10000;
}
@@ -344,8 +344,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
- check_single_dir(pg_data, "pg_wal");
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -385,7 +385,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index c45b3183684..c7a1416494d 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -61,52 +61,52 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_nxtmxoff);
+ old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
+ old_cluster.controldata.chkpnt_nxtmulti,
+ old_cluster.controldata.chkpnt_nxtmxoff);
- for (MultiXactId multi = from_multi; multi != to_multi;)
- {
- MultiXactMember member;
- bool multixid_valid;
-
- /*
- * Read this multixid's members.
- *
- * Locking-only XIDs that may be part of multi-xids don't matter
- * after upgrade, as there can be no transactions running across
- * upgrade. So as a small optimization, we only read one member
- * from each multixid: the one updating one, or if there was no
- * update, arbitrarily the first locking xid.
- */
- multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
+ for (MultiXactId multi = from_multi; multi != to_multi;)
+ {
+ MultiXactMember member;
+ bool multixid_valid;
- /*
- * Write the new offset to pg_multixact/offsets.
- *
- * Even if this multixid is invalid, we still need to write its
- * offset if the *previous* multixid was valid. That's because
- * when reading a multixid, the number of members is calculated
- * from the difference between the two offsets.
- */
- RecordMultiXactOffset(offsets_writer, multi,
- (multixid_valid || prev_multixid_valid) ? next_offset : 0);
+ /*
+ * Read this multixid's members.
+ *
+ * Locking-only XIDs that may be part of multi-xids don't matter after
+ * upgrade, as there can be no transactions running across upgrade. So
+ * as a small optimization, we only read one member from each
+ * multixid: the one updating one, or if there was no update,
+ * arbitrarily the first locking xid.
+ */
+ multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
- /* Write the members */
- if (multixid_valid)
- {
- RecordMultiXactMembers(members_writer, next_offset, 1, &member);
- next_offset += 1;
- }
+ /*
+ * Write the new offset to pg_multixact/offsets.
+ *
+ * Even if this multixid is invalid, we still need to write its offset
+ * if the *previous* multixid was valid. That's because when reading
+ * a multixid, the number of members is calculated from the difference
+ * between the two offsets.
+ */
+ RecordMultiXactOffset(offsets_writer, multi,
+ (multixid_valid || prev_multixid_valid) ? next_offset : 0);
- /* Advance to next multixid, handling wraparound */
- multi++;
- if (multi < FirstMultiXactId)
- multi = FirstMultiXactId;
- prev_multixid_valid = multixid_valid;
+ /* Write the members */
+ if (multixid_valid)
+ {
+ RecordMultiXactMembers(members_writer, next_offset, 1, &member);
+ next_offset += 1;
}
- FreeOldMultiXactReader(old_reader);
+ /* Advance to next multixid, handling wraparound */
+ multi++;
+ if (multi < FirstMultiXactId)
+ multi = FirstMultiXactId;
+ prev_multixid_valid = multixid_valid;
+ }
+
+ FreeOldMultiXactReader(old_reader);
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5d7920c1b1..d8e1b680f5a 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -833,7 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index ec2ff7acb21..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -587,32 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix)
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
+ }
}
}
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index c9573d4b765..e5fb3595598 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6272,23 +6272,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 76d299fb55c..389c4dce367 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -98,12 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Result data type"),
gettext_noop("Argument data types"));
- appendPQExpBuffer(&buf,
- " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
- "FROM pg_catalog.pg_proc p\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
- "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n",
- gettext_noop("Description"));
+ appendPQExpBuffer(&buf,
+ " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
+ "FROM pg_catalog.pg_proc p\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
+ "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n",
+ gettext_noop("Description"));
if (!showSystem && !pattern)
appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n"
@@ -379,19 +379,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -591,8 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1078,38 +1078,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1667,27 +1667,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -1905,7 +1905,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -1916,11 +1916,11 @@ describeOneTableDetails(const char *schemaname,
if (tableinfo.relkind == RELKIND_INDEX ||
tableinfo.relkind == RELKIND_PARTITIONED_INDEX)
{
- appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key",
- oid,
- gettext_noop("yes"),
- gettext_noop("no"));
- isindexkey_col = cols++;
+ appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key",
+ oid,
+ gettext_noop("yes"),
+ gettext_noop("no"));
+ isindexkey_col = cols++;
appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef");
indexdef_col = cols++;
}
@@ -2315,7 +2315,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
+ appendPQExpBufferStr(&buf, "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2420,7 +2420,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- appendPQExpBufferStr(&buf, ", i.indisreplident");
+ appendPQExpBufferStr(&buf, ", i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2671,81 +2671,80 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBufferStr(&buf, "SELECT pol.polname,");
+ appendPQExpBufferStr(&buf,
+ " pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3014,115 +3013,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Included in publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Included in publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3794,7 +3793,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
+ appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -3849,8 +3848,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -5144,14 +5143,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-05-06 21:47 Nathan Bossart <nathandbossart@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-05-06 21:47 UTC (permalink / raw)
To: Corey Huinker <corey.huinker@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
On Fri, May 01, 2026 at 03:10:51PM -0500, Nathan Bossart wrote:
> I wrote a new set of patches on a plane a couple of weeks ago, but I forgot
> to post them. I'm not yet 100% positive I've got the changes to
> rewrite_multixacts() in the pg_upgrade patch correct, but otherwise it's
> pretty mechanical and straightforward.
Best I can tell, the rewrite_multixacts() changes are fine. I also noticed
a couple of accidental removals of v11 stuff in the psql patch, which
should be fixed in the attached.
--
nathan
From 1cebf4c897662dc5a58e69dc63ec59bef40b2871 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 10:15:38 -0700
Subject: [PATCH v3 1/4] pg_dump/pg_dumpall: bump minimum supported version to
v10
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/runtime.sgml | 2 +-
src/bin/pg_dump/pg_dump.c | 330 ++--------------------------------
src/bin/pg_dump/pg_dumpall.c | 32 +---
4 files changed, 22 insertions(+), 356 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index ae1bc14d2f2..64a3447e445 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1718,7 +1706,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index dfa292c2c3a..d9984910cc4 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1776,7 +1776,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
version of
<productname>PostgreSQL</productname>, to take advantage of enhancements
that might have been made in these programs. Current releases of the
- dump programs can read data from any server version back to 9.2.
+ dump programs can read data from any server version back to 10.
</para>
<para>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d56dcc701ce..eed9aaeb7c1 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,9 +1491,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security = on");
else
ExecuteSqlStatement(AH, "SET row_security = off");
- }
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1964,12 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
return true;
}
@@ -2000,11 +1986,10 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
+ * We dump out any ACLs defined in pg_catalog, if
* they are interesting (and not the original ACLs which were set at
* initdb time, see pg_init_privs).
*/
@@ -2213,8 +2198,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2215,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3100,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3325,10 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid IN (%u, %u, %u, %u);\n",
LargeObjectRelationId, LargeObjectLOidPNIndexId,
LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4207,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4316,10 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -4534,7 +4491,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4854,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5144,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,24 +6632,12 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
/*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
+ * Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"amtype, "
"amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6878,15 +6823,12 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
: "p.proisagg");
@@ -6916,29 +6858,6 @@ getAggregates(Archive *fout)
"refclassid = 'pg_extension'::regclass AND "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7021,6 +6940,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7039,14 +6959,10 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, in 9.6 and up, include functions in
+ * they are built-in. Also, include functions in
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
: "NOT p.proisagg");
@@ -7090,46 +7006,6 @@ getFuncs(Archive *fout)
appendPQExpBufferStr(query,
"\n OR p.proacl IS DISTINCT FROM pip.initprivs");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7378,64 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
"CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
"WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,9 +7296,8 @@ getTables(Archive *fout, int *numTables)
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
/*
- * In 9.6 and up, left join to pg_am to pick up the amname.
+ * Left join to pg_am to pick up the amname.
*/
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
@@ -8028,12 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8318,10 +8156,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8988,10 +8822,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9258,10 +9088,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9489,12 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(q,
"a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10897,8 +10719,6 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
printfPQExpBuffer(query,
"SELECT objoid, classoid, objsubid, privtype, initprivs "
"FROM pg_init_privs");
@@ -10966,7 +10786,6 @@ getAdditionalACLs(Archive *fout)
}
}
PQclear(res);
- }
destroyPQExpBuffer(query);
}
@@ -11141,15 +10960,6 @@ fetchAttributeStats(Archive *fout)
static bool restarted;
int max_rels = MAX_ATTR_STATS_RELS;
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
-
/* If we're just starting, set our TOC pointer. */
if (!te)
te = AH->toc->next;
@@ -11320,16 +11130,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For versions before 19, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11337,7 +11142,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11345,12 +11150,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13672,19 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15174,14 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"collprovider, "
"collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15588,7 +15374,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"aggkind,\n"
"aggmtransfn,\n"
@@ -15600,31 +15385,12 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"aggtransspace,\n"
"aggmtransspace,\n"
"aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"aggcombinefn,\n"
"aggserialfn,\n"
"aggdeserialfn,\n"
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17084,8 +16850,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- if (fout->remoteVersion >= 90600)
- {
/*
* In principle we should call acldefault('c', relowner) to
* get the default ACL for a column. However, we don't
@@ -17110,17 +16874,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
"ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
ExecuteSqlStatement(fout, query->data);
@@ -19410,16 +19163,10 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
+ if (fout->remoteVersion < 180000 ||
(!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
@@ -19477,59 +19224,20 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
+ * The sequence information is gathered in a sorted
* table before any calls to dumpSequence(). See collectSequences() for
* more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
Assert(sequences);
key.oid = tbinfo->dobj.catId.oid;
seq = bsearch(&key, sequences, nsequences,
sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
-
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19708,8 +19416,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index c1f43113c53..5b10f7122b7 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -693,11 +693,11 @@ main(int argc, char *argv[])
fout->verbose = verbose;
/*
- * We allow the server to be back to 9.2, and up to any minor release
+ * We allow the server to be back to 10, and up to any minor release
* of our own major version. (See also version check in
* pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = 1;
@@ -954,17 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT rolname "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 1", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1041,7 +1035,6 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT oid, rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, "
@@ -1052,27 +1045,6 @@ dumpRoles(PGconn *conn)
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 2", role_catalog);
- else if (server_version >= 90500)
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, "
- "false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
--
2.50.1 (Apple Git-155)
From b479d176d9e4d7405e9dd79209573a9d3cc683ad Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:20:18 -0700
Subject: [PATCH v3 2/4] pg_upgrade: bump minimum supported version to v10
---
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_upgrade/check.c | 157 +----------------------
src/bin/pg_upgrade/controldata.c | 12 +-
src/bin/pg_upgrade/exec.c | 23 ----
src/bin/pg_upgrade/file.c | 164 -------------------------
src/bin/pg_upgrade/multixact_rewrite.c | 11 +-
src/bin/pg_upgrade/pg_upgrade.c | 31 +----
src/bin/pg_upgrade/pg_upgrade.h | 29 -----
src/bin/pg_upgrade/relfilenumber.c | 37 +-----
src/bin/pg_upgrade/version.c | 127 -------------------
10 files changed, 16 insertions(+), 577 deletions(-)
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index 38ca09b423c..c4ed75211db 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 5a7afe62eab..0813cef2729 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 10)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1569,12 +1475,10 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
appendPQExpBufferStr(&old_polymorphics,
", 'array_remove(anyarray,anyelement)'"
", 'array_replace(anyarray,anyelement,anyelement)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
appendPQExpBufferStr(&old_polymorphics,
", 'array_position(anyarray,anyelement)'"
", 'array_position(anyarray,anyelement,integer)'"
@@ -1870,63 +1774,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index cffcd4b0eba..8188355240f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -602,14 +602,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +628,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +667,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index e1de61f36ee..479557abdcc 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,16 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- if (v1 < 10)
- {
- /* old style, e.g. 9.6.1 */
- cluster->bin_version = v1 * 10000 + v2 * 100;
- }
- else
- {
- /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
- }
}
@@ -353,17 +344,7 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
check_single_dir(pg_data, "pg_xact");
}
@@ -404,10 +385,6 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index 823984ec8f3..c45b3183684 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -25,10 +25,7 @@ static void RecordMultiXactMembers(SlruSegState *members_writer,
* 32-bit offsets to the current format.
*
* Multixids in the range [from_multi, to_multi) are read from the old
- * cluster, and written in the new format. An important edge case is that if
- * from_multi == to_multi, this initializes the new pg_multixact files in the
- * new format without trying to open any old files. (We rely on that when
- * upgrading from PostgreSQL version 9.2 or below.)
+ * cluster, and written in the new format.
*
* Returns the new nextOffset value; the caller should set it in the new
* control file. The new members always start from offset 1, regardless of
@@ -42,6 +39,7 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
SlruSegState *members_writer;
char dir[MAXPGPATH] = {0};
bool prev_multixid_valid = false;
+ OldMultiXactReader *old_reader;
/*
* The range of valid multi XIDs is unchanged by the conversion (they are
@@ -63,10 +61,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- if (to_multi != from_multi)
- {
- OldMultiXactReader *old_reader;
-
old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
old_cluster.controldata.chkpnt_nxtmulti,
old_cluster.controldata.chkpnt_nxtmxoff);
@@ -113,7 +107,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
}
FreeOldMultiXactReader(old_reader);
- }
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..e5d7920c1b1 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -777,10 +770,7 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +799,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 1d767bbda2d..5a0d2045be5 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,10 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
void report_extension_updates(ClusterInfo *cluster);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..ec2ff7acb21 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,14 +587,6 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
- {
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
- }
- else
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
--
2.50.1 (Apple Git-155)
From 726c02a3d0931825060fcf21a2c36a0c3ee91e93 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:34:35 -0700
Subject: [PATCH v3 3/4] psql: bump minimum supported version to v10
---
doc/src/sgml/ref/psql-ref.sgml | 2 +-
src/bin/psql/command.c | 23 +---
src/bin/psql/describe.c | 244 +--------------------------------
3 files changed, 11 insertions(+), 258 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 7c05afd4719..56c2692e618 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
or an older major version. Backslash commands are particularly likely
to fail if the server is of a newer version than <application>psql</application>
itself. However, backslash commands of the <literal>\d</literal> family should
- work with servers of versions back to 9.2, though not necessarily with
+ work with servers of versions back to 10, though not necessarily with
servers newer than <application>psql</application> itself. The general
functionality of running SQL commands and displaying query results
should also work with servers of a newer major version, but this cannot
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 493400f9090..c9573d4b765 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
+ * Views may have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
+ * separately. Materialized views may have
* arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
@@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index e1449654f96..9f26ed928cb 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
appendPQExpBuffer(&buf,
",\n CASE\n"
" WHEN p.proparallel = "
@@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
myopt.translate_columns = translate_columns;
myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT polname\n"
@@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname,
"FROM pg_catalog.pg_sequence\n"
"WHERE seqrelid = '%s';",
oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
appendPQExpBuffer(&buf,
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
@@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
if (pset.sversion >= 150000)
@@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Bypass RLS"));
@@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
" CASE c.collprovider "
"WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
@@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
"WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
"END AS \"%s\",\n",
gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6486,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6623,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
--
2.50.1 (Apple Git-155)
From b72b2c25cf568b83fefa9ea3e43d51b56b17c822 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Wed, 6 May 2026 16:43:06 -0500
Subject: [PATCH v3 4/4] run pgindent
---
src/bin/pg_dump/pg_dump.c | 457 ++++++++++++------------
src/bin/pg_dump/pg_dumpall.c | 30 +-
src/bin/pg_upgrade/check.c | 16 +-
src/bin/pg_upgrade/exec.c | 8 +-
src/bin/pg_upgrade/multixact_rewrite.c | 80 ++---
src/bin/pg_upgrade/pg_upgrade.c | 2 +-
src/bin/pg_upgrade/relfilenumber.c | 54 +--
src/bin/psql/command.c | 29 +-
src/bin/psql/describe.c | 461 ++++++++++++-------------
9 files changed, 567 insertions(+), 570 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index eed9aaeb7c1..c05623b1889 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1491,8 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1505,10 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1955,7 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -1989,9 +1989,9 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * We dump out any ACLs defined in pg_catalog, if
- * they are interesting (and not the original ACLs which were set at
- * initdb time, see pg_init_privs).
+ * We dump out any ACLs defined in pg_catalog, if they are interesting
+ * (and not the original ACLs which were set at initdb time, see
+ * pg_init_privs).
*/
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL;
}
@@ -3298,7 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- appendPQExpBufferStr(dbQry, "datminmxid, ");
+ appendPQExpBufferStr(dbQry, "datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3640,11 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- appendPQExpBufferStr(query, "pol.polpermissive, ");
+ appendPQExpBufferStr(query, "pol.polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -6635,9 +6635,9 @@ getAccessMethods(Archive *fout)
* Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
+ appendPQExpBufferStr(query,
+ "amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6829,35 +6829,35 @@ getAggregates(Archive *fout)
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6959,53 +6959,53 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, include functions in
- * pg_catalog if they have an ACL different from what's shown in
- * pg_init_privs (so we have to join to pg_init_privs; annoying).
+ * they are built-in. Also, include functions in pg_catalog if they have
+ * an ACL different from what's shown in pg_init_privs (so we have to join
+ * to pg_init_privs; annoying).
*/
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7254,31 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, ");
- appendPQExpBufferStr(query,
- "c.relreplident, ");
+ appendPQExpBufferStr(query,
+ "c.relreplident, ");
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
+ appendPQExpBufferStr(query,
+ "c.relrowsecurity, c.relforcerowsecurity, ");
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
+ appendPQExpBufferStr(query,
+ "c.relminmxid, tc.relminmxid AS tminmxid, ");
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
+ appendPQExpBufferStr(query,
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- appendPQExpBufferStr(query,
- "am.amname, ");
+ appendPQExpBufferStr(query,
+ "am.amname, ");
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
+ appendPQExpBufferStr(query,
+ "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7298,8 +7298,8 @@ getTables(Archive *fout, int *numTables)
/*
* Left join to pg_am to pick up the amname.
*/
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -7870,8 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
+ appendPQExpBufferStr(query,
+ "i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -9315,8 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10719,73 +10719,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
+ }
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11130,8 +11130,8 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For versions before 19, the redundant filter clause on s.tablename =
- * ANY(...) seems sufficient to convince the planner to use
+ * For versions before 19, the redundant filter clause on s.tablename
+ * = ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
@@ -13471,11 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ appendPQExpBufferStr(query,
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- appendPQExpBufferStr(query,
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -14965,9 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
+ appendPQExpBufferStr(query,
+ "collprovider, "
+ "collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15374,23 +15374,23 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
+ appendPQExpBufferStr(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -16850,30 +16850,30 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ /*
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
+ appendPQExpBufferStr(query,
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19167,7 +19167,7 @@ collectSequences(Archive *fout)
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19229,15 +19229,14 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * The sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- Assert(sequences);
+ Assert(sequences);
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 5b10f7122b7..3f61196671c 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -954,11 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1035,16 +1035,16 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 2", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT oid, rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, rolreplication, rolbypassrls, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 0813cef2729..5f63e2114c8 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1475,15 +1475,15 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 479557abdcc..9a675929e17 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,7 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- cluster->bin_version = v1 * 10000;
+ cluster->bin_version = v1 * 10000;
}
@@ -344,8 +344,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
- check_single_dir(pg_data, "pg_wal");
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -385,7 +385,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index c45b3183684..c7a1416494d 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -61,52 +61,52 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_nxtmxoff);
+ old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
+ old_cluster.controldata.chkpnt_nxtmulti,
+ old_cluster.controldata.chkpnt_nxtmxoff);
- for (MultiXactId multi = from_multi; multi != to_multi;)
- {
- MultiXactMember member;
- bool multixid_valid;
-
- /*
- * Read this multixid's members.
- *
- * Locking-only XIDs that may be part of multi-xids don't matter
- * after upgrade, as there can be no transactions running across
- * upgrade. So as a small optimization, we only read one member
- * from each multixid: the one updating one, or if there was no
- * update, arbitrarily the first locking xid.
- */
- multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
+ for (MultiXactId multi = from_multi; multi != to_multi;)
+ {
+ MultiXactMember member;
+ bool multixid_valid;
- /*
- * Write the new offset to pg_multixact/offsets.
- *
- * Even if this multixid is invalid, we still need to write its
- * offset if the *previous* multixid was valid. That's because
- * when reading a multixid, the number of members is calculated
- * from the difference between the two offsets.
- */
- RecordMultiXactOffset(offsets_writer, multi,
- (multixid_valid || prev_multixid_valid) ? next_offset : 0);
+ /*
+ * Read this multixid's members.
+ *
+ * Locking-only XIDs that may be part of multi-xids don't matter after
+ * upgrade, as there can be no transactions running across upgrade. So
+ * as a small optimization, we only read one member from each
+ * multixid: the one updating one, or if there was no update,
+ * arbitrarily the first locking xid.
+ */
+ multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
- /* Write the members */
- if (multixid_valid)
- {
- RecordMultiXactMembers(members_writer, next_offset, 1, &member);
- next_offset += 1;
- }
+ /*
+ * Write the new offset to pg_multixact/offsets.
+ *
+ * Even if this multixid is invalid, we still need to write its offset
+ * if the *previous* multixid was valid. That's because when reading
+ * a multixid, the number of members is calculated from the difference
+ * between the two offsets.
+ */
+ RecordMultiXactOffset(offsets_writer, multi,
+ (multixid_valid || prev_multixid_valid) ? next_offset : 0);
- /* Advance to next multixid, handling wraparound */
- multi++;
- if (multi < FirstMultiXactId)
- multi = FirstMultiXactId;
- prev_multixid_valid = multixid_valid;
+ /* Write the members */
+ if (multixid_valid)
+ {
+ RecordMultiXactMembers(members_writer, next_offset, 1, &member);
+ next_offset += 1;
}
- FreeOldMultiXactReader(old_reader);
+ /* Advance to next multixid, handling wraparound */
+ multi++;
+ if (multi < FirstMultiXactId)
+ multi = FirstMultiXactId;
+ prev_multixid_valid = multixid_valid;
+ }
+
+ FreeOldMultiXactReader(old_reader);
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5d7920c1b1..d8e1b680f5a 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -833,7 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index ec2ff7acb21..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -587,32 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix)
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
+ }
}
}
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index c9573d4b765..e5fb3595598 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6272,23 +6272,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 9f26ed928cb..9731c0079c8 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -387,19 +387,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -599,8 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1086,38 +1086,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1675,27 +1675,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -1913,7 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2326,7 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
+ appendPQExpBufferStr(&buf, "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2431,7 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- appendPQExpBufferStr(&buf, ", i.indisreplident");
+ appendPQExpBufferStr(&buf, ", i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2682,81 +2682,80 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBufferStr(&buf, "SELECT pol.polname,");
+ appendPQExpBufferStr(&buf,
+ " pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3025,115 +3024,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Included in publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Included in publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3805,7 +3804,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
+ appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -3860,8 +3859,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -5155,14 +5154,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
--
2.50.1 (Apple Git-155)
Attachments:
[text/plain] v3-0001-pg_dump-pg_dumpall-bump-minimum-supported-version.patch (30.0K, ../../afu248qSjSvL7XAT@nathan/2-v3-0001-pg_dump-pg_dumpall-bump-minimum-supported-version.patch)
download | inline diff:
From 1cebf4c897662dc5a58e69dc63ec59bef40b2871 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 10:15:38 -0700
Subject: [PATCH v3 1/4] pg_dump/pg_dumpall: bump minimum supported version to
v10
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/runtime.sgml | 2 +-
src/bin/pg_dump/pg_dump.c | 330 ++--------------------------------
src/bin/pg_dump/pg_dumpall.c | 32 +---
4 files changed, 22 insertions(+), 356 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index ae1bc14d2f2..64a3447e445 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1718,7 +1706,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index dfa292c2c3a..d9984910cc4 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1776,7 +1776,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
version of
<productname>PostgreSQL</productname>, to take advantage of enhancements
that might have been made in these programs. Current releases of the
- dump programs can read data from any server version back to 9.2.
+ dump programs can read data from any server version back to 10.
</para>
<para>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d56dcc701ce..eed9aaeb7c1 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,9 +1491,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security = on");
else
ExecuteSqlStatement(AH, "SET row_security = off");
- }
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1964,12 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
return true;
}
@@ -2000,11 +1986,10 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
+ * We dump out any ACLs defined in pg_catalog, if
* they are interesting (and not the original ACLs which were set at
* initdb time, see pg_init_privs).
*/
@@ -2213,8 +2198,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2215,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3100,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3325,10 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid IN (%u, %u, %u, %u);\n",
LargeObjectRelationId, LargeObjectLOidPNIndexId,
LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4207,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4316,10 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -4534,7 +4491,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4854,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5144,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,24 +6632,12 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
/*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
+ * Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"amtype, "
"amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6878,15 +6823,12 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
: "p.proisagg");
@@ -6916,29 +6858,6 @@ getAggregates(Archive *fout)
"refclassid = 'pg_extension'::regclass AND "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7021,6 +6940,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7039,14 +6959,10 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, in 9.6 and up, include functions in
+ * they are built-in. Also, include functions in
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
: "NOT p.proisagg");
@@ -7090,46 +7006,6 @@ getFuncs(Archive *fout)
appendPQExpBufferStr(query,
"\n OR p.proacl IS DISTINCT FROM pip.initprivs");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7378,64 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
"CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
"WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,9 +7296,8 @@ getTables(Archive *fout, int *numTables)
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
/*
- * In 9.6 and up, left join to pg_am to pick up the amname.
+ * Left join to pg_am to pick up the amname.
*/
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
@@ -8028,12 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8318,10 +8156,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8988,10 +8822,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9258,10 +9088,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9489,12 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(q,
"a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10897,8 +10719,6 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
printfPQExpBuffer(query,
"SELECT objoid, classoid, objsubid, privtype, initprivs "
"FROM pg_init_privs");
@@ -10966,7 +10786,6 @@ getAdditionalACLs(Archive *fout)
}
}
PQclear(res);
- }
destroyPQExpBuffer(query);
}
@@ -11141,15 +10960,6 @@ fetchAttributeStats(Archive *fout)
static bool restarted;
int max_rels = MAX_ATTR_STATS_RELS;
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
-
/* If we're just starting, set our TOC pointer. */
if (!te)
te = AH->toc->next;
@@ -11320,16 +11130,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For versions before 19, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11337,7 +11142,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11345,12 +11150,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13672,19 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15174,14 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"collprovider, "
"collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15588,7 +15374,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"aggkind,\n"
"aggmtransfn,\n"
@@ -15600,31 +15385,12 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"aggtransspace,\n"
"aggmtransspace,\n"
"aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"aggcombinefn,\n"
"aggserialfn,\n"
"aggdeserialfn,\n"
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17084,8 +16850,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- if (fout->remoteVersion >= 90600)
- {
/*
* In principle we should call acldefault('c', relowner) to
* get the default ACL for a column. However, we don't
@@ -17110,17 +16874,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
"ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
ExecuteSqlStatement(fout, query->data);
@@ -19410,16 +19163,10 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
+ if (fout->remoteVersion < 180000 ||
(!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
@@ -19477,59 +19224,20 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
+ * The sequence information is gathered in a sorted
* table before any calls to dumpSequence(). See collectSequences() for
* more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
Assert(sequences);
key.oid = tbinfo->dobj.catId.oid;
seq = bsearch(&key, sequences, nsequences,
sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
-
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19708,8 +19416,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index c1f43113c53..5b10f7122b7 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -693,11 +693,11 @@ main(int argc, char *argv[])
fout->verbose = verbose;
/*
- * We allow the server to be back to 9.2, and up to any minor release
+ * We allow the server to be back to 10, and up to any minor release
* of our own major version. (See also version check in
* pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = 1;
@@ -954,17 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT rolname "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 1", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1041,7 +1035,6 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT oid, rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, "
@@ -1052,27 +1045,6 @@ dumpRoles(PGconn *conn)
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 2", role_catalog);
- else if (server_version >= 90500)
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, "
- "false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
--
2.50.1 (Apple Git-155)
[text/plain] v3-0002-pg_upgrade-bump-minimum-supported-version-to-v10.patch (32.6K, ../../afu248qSjSvL7XAT@nathan/3-v3-0002-pg_upgrade-bump-minimum-supported-version-to-v10.patch)
download | inline diff:
From b479d176d9e4d7405e9dd79209573a9d3cc683ad Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:20:18 -0700
Subject: [PATCH v3 2/4] pg_upgrade: bump minimum supported version to v10
---
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_upgrade/check.c | 157 +----------------------
src/bin/pg_upgrade/controldata.c | 12 +-
src/bin/pg_upgrade/exec.c | 23 ----
src/bin/pg_upgrade/file.c | 164 -------------------------
src/bin/pg_upgrade/multixact_rewrite.c | 11 +-
src/bin/pg_upgrade/pg_upgrade.c | 31 +----
src/bin/pg_upgrade/pg_upgrade.h | 29 -----
src/bin/pg_upgrade/relfilenumber.c | 37 +-----
src/bin/pg_upgrade/version.c | 127 -------------------
10 files changed, 16 insertions(+), 577 deletions(-)
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index 38ca09b423c..c4ed75211db 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 5a7afe62eab..0813cef2729 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 10)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1569,12 +1475,10 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
appendPQExpBufferStr(&old_polymorphics,
", 'array_remove(anyarray,anyelement)'"
", 'array_replace(anyarray,anyelement,anyelement)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
appendPQExpBufferStr(&old_polymorphics,
", 'array_position(anyarray,anyelement)'"
", 'array_position(anyarray,anyelement,integer)'"
@@ -1870,63 +1774,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index cffcd4b0eba..8188355240f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -602,14 +602,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +628,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +667,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index e1de61f36ee..479557abdcc 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,16 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- if (v1 < 10)
- {
- /* old style, e.g. 9.6.1 */
- cluster->bin_version = v1 * 10000 + v2 * 100;
- }
- else
- {
- /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
- }
}
@@ -353,17 +344,7 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
check_single_dir(pg_data, "pg_xact");
}
@@ -404,10 +385,6 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index 823984ec8f3..c45b3183684 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -25,10 +25,7 @@ static void RecordMultiXactMembers(SlruSegState *members_writer,
* 32-bit offsets to the current format.
*
* Multixids in the range [from_multi, to_multi) are read from the old
- * cluster, and written in the new format. An important edge case is that if
- * from_multi == to_multi, this initializes the new pg_multixact files in the
- * new format without trying to open any old files. (We rely on that when
- * upgrading from PostgreSQL version 9.2 or below.)
+ * cluster, and written in the new format.
*
* Returns the new nextOffset value; the caller should set it in the new
* control file. The new members always start from offset 1, regardless of
@@ -42,6 +39,7 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
SlruSegState *members_writer;
char dir[MAXPGPATH] = {0};
bool prev_multixid_valid = false;
+ OldMultiXactReader *old_reader;
/*
* The range of valid multi XIDs is unchanged by the conversion (they are
@@ -63,10 +61,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- if (to_multi != from_multi)
- {
- OldMultiXactReader *old_reader;
-
old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
old_cluster.controldata.chkpnt_nxtmulti,
old_cluster.controldata.chkpnt_nxtmxoff);
@@ -113,7 +107,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
}
FreeOldMultiXactReader(old_reader);
- }
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..e5d7920c1b1 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -777,10 +770,7 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +799,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 1d767bbda2d..5a0d2045be5 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,10 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
void report_extension_updates(ClusterInfo *cluster);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..ec2ff7acb21 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,14 +587,6 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
- {
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
- }
- else
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
--
2.50.1 (Apple Git-155)
[text/plain] v3-0003-psql-bump-minimum-supported-version-to-v10.patch (20.9K, ../../afu248qSjSvL7XAT@nathan/4-v3-0003-psql-bump-minimum-supported-version-to-v10.patch)
download | inline diff:
From 726c02a3d0931825060fcf21a2c36a0c3ee91e93 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:34:35 -0700
Subject: [PATCH v3 3/4] psql: bump minimum supported version to v10
---
doc/src/sgml/ref/psql-ref.sgml | 2 +-
src/bin/psql/command.c | 23 +---
src/bin/psql/describe.c | 244 +--------------------------------
3 files changed, 11 insertions(+), 258 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 7c05afd4719..56c2692e618 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
or an older major version. Backslash commands are particularly likely
to fail if the server is of a newer version than <application>psql</application>
itself. However, backslash commands of the <literal>\d</literal> family should
- work with servers of versions back to 9.2, though not necessarily with
+ work with servers of versions back to 10, though not necessarily with
servers newer than <application>psql</application> itself. The general
functionality of running SQL commands and displaying query results
should also work with servers of a newer major version, but this cannot
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 493400f9090..c9573d4b765 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
+ * Views may have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
+ * separately. Materialized views may have
* arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
@@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index e1449654f96..9f26ed928cb 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
appendPQExpBuffer(&buf,
",\n CASE\n"
" WHEN p.proparallel = "
@@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
myopt.translate_columns = translate_columns;
myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT polname\n"
@@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname,
"FROM pg_catalog.pg_sequence\n"
"WHERE seqrelid = '%s';",
oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
appendPQExpBuffer(&buf,
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
@@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
if (pset.sversion >= 150000)
@@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Bypass RLS"));
@@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
" CASE c.collprovider "
"WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
@@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
"WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
"END AS \"%s\",\n",
gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6486,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6623,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
--
2.50.1 (Apple Git-155)
[text/plain] v3-0004-run-pgindent.patch (59.6K, ../../afu248qSjSvL7XAT@nathan/5-v3-0004-run-pgindent.patch)
download | inline diff:
From b72b2c25cf568b83fefa9ea3e43d51b56b17c822 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Wed, 6 May 2026 16:43:06 -0500
Subject: [PATCH v3 4/4] run pgindent
---
src/bin/pg_dump/pg_dump.c | 457 ++++++++++++------------
src/bin/pg_dump/pg_dumpall.c | 30 +-
src/bin/pg_upgrade/check.c | 16 +-
src/bin/pg_upgrade/exec.c | 8 +-
src/bin/pg_upgrade/multixact_rewrite.c | 80 ++---
src/bin/pg_upgrade/pg_upgrade.c | 2 +-
src/bin/pg_upgrade/relfilenumber.c | 54 +--
src/bin/psql/command.c | 29 +-
src/bin/psql/describe.c | 461 ++++++++++++-------------
9 files changed, 567 insertions(+), 570 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index eed9aaeb7c1..c05623b1889 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1491,8 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1505,10 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1955,7 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -1989,9 +1989,9 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * We dump out any ACLs defined in pg_catalog, if
- * they are interesting (and not the original ACLs which were set at
- * initdb time, see pg_init_privs).
+ * We dump out any ACLs defined in pg_catalog, if they are interesting
+ * (and not the original ACLs which were set at initdb time, see
+ * pg_init_privs).
*/
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL;
}
@@ -3298,7 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- appendPQExpBufferStr(dbQry, "datminmxid, ");
+ appendPQExpBufferStr(dbQry, "datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3640,11 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- appendPQExpBufferStr(query, "pol.polpermissive, ");
+ appendPQExpBufferStr(query, "pol.polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -6635,9 +6635,9 @@ getAccessMethods(Archive *fout)
* Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
+ appendPQExpBufferStr(query,
+ "amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6829,35 +6829,35 @@ getAggregates(Archive *fout)
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6959,53 +6959,53 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, include functions in
- * pg_catalog if they have an ACL different from what's shown in
- * pg_init_privs (so we have to join to pg_init_privs; annoying).
+ * they are built-in. Also, include functions in pg_catalog if they have
+ * an ACL different from what's shown in pg_init_privs (so we have to join
+ * to pg_init_privs; annoying).
*/
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7254,31 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, ");
- appendPQExpBufferStr(query,
- "c.relreplident, ");
+ appendPQExpBufferStr(query,
+ "c.relreplident, ");
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
+ appendPQExpBufferStr(query,
+ "c.relrowsecurity, c.relforcerowsecurity, ");
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
+ appendPQExpBufferStr(query,
+ "c.relminmxid, tc.relminmxid AS tminmxid, ");
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
+ appendPQExpBufferStr(query,
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- appendPQExpBufferStr(query,
- "am.amname, ");
+ appendPQExpBufferStr(query,
+ "am.amname, ");
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
+ appendPQExpBufferStr(query,
+ "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7298,8 +7298,8 @@ getTables(Archive *fout, int *numTables)
/*
* Left join to pg_am to pick up the amname.
*/
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -7870,8 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
+ appendPQExpBufferStr(query,
+ "i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -9315,8 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10719,73 +10719,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
+ }
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11130,8 +11130,8 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For versions before 19, the redundant filter clause on s.tablename =
- * ANY(...) seems sufficient to convince the planner to use
+ * For versions before 19, the redundant filter clause on s.tablename
+ * = ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
@@ -13471,11 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ appendPQExpBufferStr(query,
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- appendPQExpBufferStr(query,
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -14965,9 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
+ appendPQExpBufferStr(query,
+ "collprovider, "
+ "collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15374,23 +15374,23 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
+ appendPQExpBufferStr(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -16850,30 +16850,30 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ /*
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
+ appendPQExpBufferStr(query,
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19167,7 +19167,7 @@ collectSequences(Archive *fout)
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19229,15 +19229,14 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * The sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- Assert(sequences);
+ Assert(sequences);
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 5b10f7122b7..3f61196671c 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -954,11 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1035,16 +1035,16 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 2", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT oid, rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, rolreplication, rolbypassrls, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 0813cef2729..5f63e2114c8 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1475,15 +1475,15 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 479557abdcc..9a675929e17 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,7 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- cluster->bin_version = v1 * 10000;
+ cluster->bin_version = v1 * 10000;
}
@@ -344,8 +344,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
- check_single_dir(pg_data, "pg_wal");
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -385,7 +385,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index c45b3183684..c7a1416494d 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -61,52 +61,52 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_nxtmxoff);
+ old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
+ old_cluster.controldata.chkpnt_nxtmulti,
+ old_cluster.controldata.chkpnt_nxtmxoff);
- for (MultiXactId multi = from_multi; multi != to_multi;)
- {
- MultiXactMember member;
- bool multixid_valid;
-
- /*
- * Read this multixid's members.
- *
- * Locking-only XIDs that may be part of multi-xids don't matter
- * after upgrade, as there can be no transactions running across
- * upgrade. So as a small optimization, we only read one member
- * from each multixid: the one updating one, or if there was no
- * update, arbitrarily the first locking xid.
- */
- multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
+ for (MultiXactId multi = from_multi; multi != to_multi;)
+ {
+ MultiXactMember member;
+ bool multixid_valid;
- /*
- * Write the new offset to pg_multixact/offsets.
- *
- * Even if this multixid is invalid, we still need to write its
- * offset if the *previous* multixid was valid. That's because
- * when reading a multixid, the number of members is calculated
- * from the difference between the two offsets.
- */
- RecordMultiXactOffset(offsets_writer, multi,
- (multixid_valid || prev_multixid_valid) ? next_offset : 0);
+ /*
+ * Read this multixid's members.
+ *
+ * Locking-only XIDs that may be part of multi-xids don't matter after
+ * upgrade, as there can be no transactions running across upgrade. So
+ * as a small optimization, we only read one member from each
+ * multixid: the one updating one, or if there was no update,
+ * arbitrarily the first locking xid.
+ */
+ multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
- /* Write the members */
- if (multixid_valid)
- {
- RecordMultiXactMembers(members_writer, next_offset, 1, &member);
- next_offset += 1;
- }
+ /*
+ * Write the new offset to pg_multixact/offsets.
+ *
+ * Even if this multixid is invalid, we still need to write its offset
+ * if the *previous* multixid was valid. That's because when reading
+ * a multixid, the number of members is calculated from the difference
+ * between the two offsets.
+ */
+ RecordMultiXactOffset(offsets_writer, multi,
+ (multixid_valid || prev_multixid_valid) ? next_offset : 0);
- /* Advance to next multixid, handling wraparound */
- multi++;
- if (multi < FirstMultiXactId)
- multi = FirstMultiXactId;
- prev_multixid_valid = multixid_valid;
+ /* Write the members */
+ if (multixid_valid)
+ {
+ RecordMultiXactMembers(members_writer, next_offset, 1, &member);
+ next_offset += 1;
}
- FreeOldMultiXactReader(old_reader);
+ /* Advance to next multixid, handling wraparound */
+ multi++;
+ if (multi < FirstMultiXactId)
+ multi = FirstMultiXactId;
+ prev_multixid_valid = multixid_valid;
+ }
+
+ FreeOldMultiXactReader(old_reader);
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5d7920c1b1..d8e1b680f5a 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -833,7 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index ec2ff7acb21..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -587,32 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix)
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
+ }
}
}
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index c9573d4b765..e5fb3595598 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6272,23 +6272,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 9f26ed928cb..9731c0079c8 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -387,19 +387,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -599,8 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1086,38 +1086,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1675,27 +1675,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -1913,7 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2326,7 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
+ appendPQExpBufferStr(&buf, "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2431,7 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- appendPQExpBufferStr(&buf, ", i.indisreplident");
+ appendPQExpBufferStr(&buf, ", i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2682,81 +2682,80 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBufferStr(&buf, "SELECT pol.polname,");
+ appendPQExpBufferStr(&buf,
+ " pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3025,115 +3024,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Included in publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Included in publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3805,7 +3804,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
+ appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -3860,8 +3859,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -5155,14 +5154,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-05-16 12:00 Andrew Dunstan <andrew@dunslane.net>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Andrew Dunstan @ 2026-05-16 12:00 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; Corey Huinker <corey.huinker@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers
On 2026-05-06 We 5:47 PM, Nathan Bossart wrote:
> On Fri, May 01, 2026 at 03:10:51PM -0500, Nathan Bossart wrote:
>> I wrote a new set of patches on a plane a couple of weeks ago, but I forgot
>> to post them. I'm not yet 100% positive I've got the changes to
>> rewrite_multixacts() in the pg_upgrade patch correct, but otherwise it's
>> pretty mechanical and straightforward.
> Best I can tell, the rewrite_multixacts() changes are fine. I also noticed
> a couple of accidental removals of v11 stuff in the psql patch, which
> should be fixed in the attached.
Have we made a definite decision on this? If so, I will push the
buildfarm change I have ready for it, so when we pull the trigger we
don't get breakage.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-05-16 13:42 Tom Lane <tgl@sss.pgh.pa.us>
parent: Andrew Dunstan <andrew@dunslane.net>
0 siblings, 1 reply; 21+ messages in thread
From: Tom Lane @ 2026-05-16 13:42 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> Have we made a definite decision on this? If so, I will push the
> buildfarm change I have ready for it, so when we pull the trigger we
> don't get breakage.
I think we've agreed to do this for v20. (I've not reviewed the
proposed patch, so that's not an endorsement of the patch details.)
Getting out ahead of that in the buildfarm would be a good thing.
regards, tom lane
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-05-16 13:44 Nathan Bossart <nathandbossart@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-05-16 13:44 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
On Sat, May 16, 2026 at 09:42:47AM -0400, Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
>> Have we made a definite decision on this? If so, I will push the
>> buildfarm change I have ready for it, so when we pull the trigger we
>> don't get breakage.
>
> I think we've agreed to do this for v20. (I've not reviewed the
> proposed patch, so that's not an endorsement of the patch details.)
> Getting out ahead of that in the buildfarm would be a good thing.
+1
--
nathan
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-05-16 17:51 Andrew Dunstan <andrew@dunslane.net>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Andrew Dunstan @ 2026-05-16 17:51 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
On 2026-05-16 Sa 9:44 AM, Nathan Bossart wrote:
> On Sat, May 16, 2026 at 09:42:47AM -0400, Tom Lane wrote:
>> Andrew Dunstan <andrew@dunslane.net> writes:
>>> Have we made a definite decision on this? If so, I will push the
>>> buildfarm change I have ready for it, so when we pull the trigger we
>>> don't get breakage.
>> I think we've agreed to do this for v20. (I've not reviewed the
>> proposed patch, so that's not an endorsement of the patch details.)
>> Getting out ahead of that in the buildfarm would be a good thing.
> +1
>
OK, I have pushed that. See
<https://github.com/PGBuildFarm/client-code/commit/4c3ed0c37bbcaf427e61384bb351364ecae9b4d9;
crake will be immediately affected on HEAD. I'll make a new release when
we branch the tree.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-06-11 14:21 Nathan Bossart <nathandbossart@gmail.com>
parent: Andrew Dunstan <andrew@dunslane.net>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-06-11 14:21 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
rebased
--
nathan
From 65f93e2739cb4d714b5442b08b3c4582e5474122 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 10:15:38 -0700
Subject: [PATCH v4 1/4] pg_dump/pg_dumpall: bump minimum supported version to
v10
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/runtime.sgml | 2 +-
src/bin/pg_dump/pg_dump.c | 330 ++--------------------------------
src/bin/pg_dump/pg_dumpall.c | 32 +---
4 files changed, 22 insertions(+), 356 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index ae1bc14d2f2..64a3447e445 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1718,7 +1706,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index dfa292c2c3a..d9984910cc4 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1776,7 +1776,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
version of
<productname>PostgreSQL</productname>, to take advantage of enhancements
that might have been made in these programs. Current releases of the
- dump programs can read data from any server version back to 9.2.
+ dump programs can read data from any server version back to 10.
</para>
<para>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index a0f7f8e2168..75c27a08540 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,9 +1491,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security = on");
else
ExecuteSqlStatement(AH, "SET row_security = off");
- }
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1964,12 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
return true;
}
@@ -2000,11 +1986,10 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
+ * We dump out any ACLs defined in pg_catalog, if
* they are interesting (and not the original ACLs which were set at
* initdb time, see pg_init_privs).
*/
@@ -2213,8 +2198,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2215,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3100,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3325,10 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid IN (%u, %u, %u, %u);\n",
LargeObjectRelationId, LargeObjectLOidPNIndexId,
LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4207,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4316,10 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -4534,7 +4491,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4854,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5144,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,24 +6632,12 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
/*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
+ * Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"amtype, "
"amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6878,15 +6823,12 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
: "p.proisagg");
@@ -6916,29 +6858,6 @@ getAggregates(Archive *fout)
"refclassid = 'pg_extension'::regclass AND "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7021,6 +6940,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7039,14 +6959,10 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, in 9.6 and up, include functions in
+ * they are built-in. Also, include functions in
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
: "NOT p.proisagg");
@@ -7090,46 +7006,6 @@ getFuncs(Archive *fout)
appendPQExpBufferStr(query,
"\n OR p.proacl IS DISTINCT FROM pip.initprivs");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7378,64 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
"CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
"WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,9 +7296,8 @@ getTables(Archive *fout, int *numTables)
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
/*
- * In 9.6 and up, left join to pg_am to pick up the amname.
+ * Left join to pg_am to pick up the amname.
*/
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
@@ -8028,12 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8318,10 +8156,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8988,10 +8822,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9258,10 +9088,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9489,12 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(q,
"a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10897,8 +10719,6 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
printfPQExpBuffer(query,
"SELECT objoid, classoid, objsubid, privtype, initprivs "
"FROM pg_init_privs");
@@ -10966,7 +10786,6 @@ getAdditionalACLs(Archive *fout)
}
}
PQclear(res);
- }
destroyPQExpBuffer(query);
}
@@ -11141,15 +10960,6 @@ fetchAttributeStats(Archive *fout)
static bool restarted;
int max_rels = MAX_ATTR_STATS_RELS;
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
-
/* If we're just starting, set our TOC pointer. */
if (!te)
te = AH->toc->next;
@@ -11320,16 +11130,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For versions before 19, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11337,7 +11142,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11345,12 +11150,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13672,19 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15174,14 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"collprovider, "
"collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15588,7 +15374,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"aggkind,\n"
"aggmtransfn,\n"
@@ -15600,31 +15385,12 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"aggtransspace,\n"
"aggmtransspace,\n"
"aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"aggcombinefn,\n"
"aggserialfn,\n"
"aggdeserialfn,\n"
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17084,8 +16850,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- if (fout->remoteVersion >= 90600)
- {
/*
* In principle we should call acldefault('c', relowner) to
* get the default ACL for a column. However, we don't
@@ -17110,17 +16874,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
"ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
ExecuteSqlStatement(fout, query->data);
@@ -19410,16 +19163,10 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
+ if (fout->remoteVersion < 180000 ||
(!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
@@ -19477,59 +19224,20 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
+ * The sequence information is gathered in a sorted
* table before any calls to dumpSequence(). See collectSequences() for
* more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
Assert(sequences);
key.oid = tbinfo->dobj.catId.oid;
seq = bsearch(&key, sequences, nsequences,
sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
-
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19708,8 +19416,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index c1f43113c53..5b10f7122b7 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -693,11 +693,11 @@ main(int argc, char *argv[])
fout->verbose = verbose;
/*
- * We allow the server to be back to 9.2, and up to any minor release
+ * We allow the server to be back to 10, and up to any minor release
* of our own major version. (See also version check in
* pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = 1;
@@ -954,17 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT rolname "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 1", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1041,7 +1035,6 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT oid, rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, "
@@ -1052,27 +1045,6 @@ dumpRoles(PGconn *conn)
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 2", role_catalog);
- else if (server_version >= 90500)
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, "
- "false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
--
2.50.1 (Apple Git-155)
From 06bb9d59133582ffb7ff4cd265c244f24db3c46f Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:20:18 -0700
Subject: [PATCH v4 2/4] pg_upgrade: bump minimum supported version to v10
---
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_upgrade/check.c | 157 +----------------------
src/bin/pg_upgrade/controldata.c | 12 +-
src/bin/pg_upgrade/exec.c | 23 ----
src/bin/pg_upgrade/file.c | 164 -------------------------
src/bin/pg_upgrade/multixact_rewrite.c | 11 +-
src/bin/pg_upgrade/pg_upgrade.c | 31 +----
src/bin/pg_upgrade/pg_upgrade.h | 29 -----
src/bin/pg_upgrade/relfilenumber.c | 37 +-----
src/bin/pg_upgrade/version.c | 127 -------------------
10 files changed, 16 insertions(+), 577 deletions(-)
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index 38ca09b423c..c4ed75211db 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index f5c93e611d2..f1e35a6af47 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 10)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1569,12 +1475,10 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
appendPQExpBufferStr(&old_polymorphics,
", 'array_remove(anyarray,anyelement)'"
", 'array_replace(anyarray,anyelement,anyelement)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
appendPQExpBufferStr(&old_polymorphics,
", 'array_position(anyarray,anyelement)'"
", 'array_position(anyarray,anyelement,integer)'"
@@ -1870,63 +1774,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index cffcd4b0eba..8188355240f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -602,14 +602,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +628,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +667,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 563b4a6b5fa..44355feea30 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,16 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- if (v1 < 10)
- {
- /* old style, e.g. 9.6.1 */
- cluster->bin_version = v1 * 10000 + v2 * 100;
- }
- else
- {
- /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
- }
}
@@ -353,17 +344,7 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
check_single_dir(pg_data, "pg_xact");
}
@@ -404,10 +385,6 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index 823984ec8f3..c45b3183684 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -25,10 +25,7 @@ static void RecordMultiXactMembers(SlruSegState *members_writer,
* 32-bit offsets to the current format.
*
* Multixids in the range [from_multi, to_multi) are read from the old
- * cluster, and written in the new format. An important edge case is that if
- * from_multi == to_multi, this initializes the new pg_multixact files in the
- * new format without trying to open any old files. (We rely on that when
- * upgrading from PostgreSQL version 9.2 or below.)
+ * cluster, and written in the new format.
*
* Returns the new nextOffset value; the caller should set it in the new
* control file. The new members always start from offset 1, regardless of
@@ -42,6 +39,7 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
SlruSegState *members_writer;
char dir[MAXPGPATH] = {0};
bool prev_multixid_valid = false;
+ OldMultiXactReader *old_reader;
/*
* The range of valid multi XIDs is unchanged by the conversion (they are
@@ -63,10 +61,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- if (to_multi != from_multi)
- {
- OldMultiXactReader *old_reader;
-
old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
old_cluster.controldata.chkpnt_nxtmulti,
old_cluster.controldata.chkpnt_nxtmxoff);
@@ -113,7 +107,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
}
FreeOldMultiXactReader(old_reader);
- }
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..e5d7920c1b1 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -777,10 +770,7 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +799,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index ccd1ac0d013..d6e5bca5792 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,10 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
void report_extension_updates(ClusterInfo *cluster);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..ec2ff7acb21 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,14 +587,6 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
- {
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
- }
- else
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
--
2.50.1 (Apple Git-155)
From f732e91730714aa08735e91520339921837b9098 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:34:35 -0700
Subject: [PATCH v4 3/4] psql: bump minimum supported version to v10
---
doc/src/sgml/ref/psql-ref.sgml | 2 +-
src/bin/psql/command.c | 23 +---
src/bin/psql/describe.c | 244 +--------------------------------
3 files changed, 11 insertions(+), 258 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 7c05afd4719..56c2692e618 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
or an older major version. Backslash commands are particularly likely
to fail if the server is of a newer version than <application>psql</application>
itself. However, backslash commands of the <literal>\d</literal> family should
- work with servers of versions back to 9.2, though not necessarily with
+ work with servers of versions back to 10, though not necessarily with
servers newer than <application>psql</application> itself. The general
functionality of running SQL commands and displaying query results
should also work with servers of a newer major version, but this cannot
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 01b8f11aadd..44ef11d980e 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
+ * Views may have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
+ * separately. Materialized views may have
* arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
@@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 7f9b2b71a36..ec9c61ee924 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
appendPQExpBuffer(&buf,
",\n CASE\n"
" WHEN p.proparallel = "
@@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
myopt.translate_columns = translate_columns;
myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT polname\n"
@@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname,
"FROM pg_catalog.pg_sequence\n"
"WHERE seqrelid = '%s';",
oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
appendPQExpBuffer(&buf,
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
@@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
if (pset.sversion >= 150000)
@@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Bypass RLS"));
@@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
" CASE c.collprovider "
"WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
@@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
"WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
"END AS \"%s\",\n",
gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6486,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6623,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
--
2.50.1 (Apple Git-155)
From b779c7376f5300d71a4e74ff7c96e83c895b2707 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Thu, 11 Jun 2026 09:15:56 -0500
Subject: [PATCH v4 4/4] run pgindent
---
src/bin/pg_dump/pg_dump.c | 457 ++++++++++++------------
src/bin/pg_dump/pg_dumpall.c | 30 +-
src/bin/pg_upgrade/check.c | 16 +-
src/bin/pg_upgrade/exec.c | 8 +-
src/bin/pg_upgrade/multixact_rewrite.c | 80 ++---
src/bin/pg_upgrade/pg_upgrade.c | 2 +-
src/bin/pg_upgrade/relfilenumber.c | 54 +--
src/bin/psql/command.c | 29 +-
src/bin/psql/describe.c | 461 ++++++++++++-------------
9 files changed, 567 insertions(+), 570 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 75c27a08540..67a8ebdd3f5 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1491,8 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1505,10 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1955,7 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -1989,9 +1989,9 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * We dump out any ACLs defined in pg_catalog, if
- * they are interesting (and not the original ACLs which were set at
- * initdb time, see pg_init_privs).
+ * We dump out any ACLs defined in pg_catalog, if they are interesting
+ * (and not the original ACLs which were set at initdb time, see
+ * pg_init_privs).
*/
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL;
}
@@ -3298,7 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- appendPQExpBufferStr(dbQry, "datminmxid, ");
+ appendPQExpBufferStr(dbQry, "datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3640,11 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- appendPQExpBufferStr(query, "pol.polpermissive, ");
+ appendPQExpBufferStr(query, "pol.polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -6635,9 +6635,9 @@ getAccessMethods(Archive *fout)
* Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
+ appendPQExpBufferStr(query,
+ "amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6829,35 +6829,35 @@ getAggregates(Archive *fout)
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6959,53 +6959,53 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, include functions in
- * pg_catalog if they have an ACL different from what's shown in
- * pg_init_privs (so we have to join to pg_init_privs; annoying).
+ * they are built-in. Also, include functions in pg_catalog if they have
+ * an ACL different from what's shown in pg_init_privs (so we have to join
+ * to pg_init_privs; annoying).
*/
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7254,31 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, ");
- appendPQExpBufferStr(query,
- "c.relreplident, ");
+ appendPQExpBufferStr(query,
+ "c.relreplident, ");
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
+ appendPQExpBufferStr(query,
+ "c.relrowsecurity, c.relforcerowsecurity, ");
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
+ appendPQExpBufferStr(query,
+ "c.relminmxid, tc.relminmxid AS tminmxid, ");
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
+ appendPQExpBufferStr(query,
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- appendPQExpBufferStr(query,
- "am.amname, ");
+ appendPQExpBufferStr(query,
+ "am.amname, ");
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
+ appendPQExpBufferStr(query,
+ "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7298,8 +7298,8 @@ getTables(Archive *fout, int *numTables)
/*
* Left join to pg_am to pick up the amname.
*/
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -7870,8 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
+ appendPQExpBufferStr(query,
+ "i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -9315,8 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10719,73 +10719,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
+ }
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11130,8 +11130,8 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For versions before 19, the redundant filter clause on s.tablename =
- * ANY(...) seems sufficient to convince the planner to use
+ * For versions before 19, the redundant filter clause on s.tablename
+ * = ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
@@ -13471,11 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ appendPQExpBufferStr(query,
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- appendPQExpBufferStr(query,
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -14965,9 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
+ appendPQExpBufferStr(query,
+ "collprovider, "
+ "collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15374,23 +15374,23 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
+ appendPQExpBufferStr(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -16850,30 +16850,30 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ /*
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
+ appendPQExpBufferStr(query,
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19167,7 +19167,7 @@ collectSequences(Archive *fout)
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19229,15 +19229,14 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * The sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- Assert(sequences);
+ Assert(sequences);
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 5b10f7122b7..3f61196671c 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -954,11 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1035,16 +1035,16 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 2", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT oid, rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, rolreplication, rolbypassrls, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index f1e35a6af47..a2f9b683c59 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1475,15 +1475,15 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 44355feea30..a1bdbf373e3 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,7 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- cluster->bin_version = v1 * 10000;
+ cluster->bin_version = v1 * 10000;
}
@@ -344,8 +344,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
- check_single_dir(pg_data, "pg_wal");
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -385,7 +385,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index c45b3183684..c7a1416494d 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -61,52 +61,52 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_nxtmxoff);
+ old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
+ old_cluster.controldata.chkpnt_nxtmulti,
+ old_cluster.controldata.chkpnt_nxtmxoff);
- for (MultiXactId multi = from_multi; multi != to_multi;)
- {
- MultiXactMember member;
- bool multixid_valid;
-
- /*
- * Read this multixid's members.
- *
- * Locking-only XIDs that may be part of multi-xids don't matter
- * after upgrade, as there can be no transactions running across
- * upgrade. So as a small optimization, we only read one member
- * from each multixid: the one updating one, or if there was no
- * update, arbitrarily the first locking xid.
- */
- multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
+ for (MultiXactId multi = from_multi; multi != to_multi;)
+ {
+ MultiXactMember member;
+ bool multixid_valid;
- /*
- * Write the new offset to pg_multixact/offsets.
- *
- * Even if this multixid is invalid, we still need to write its
- * offset if the *previous* multixid was valid. That's because
- * when reading a multixid, the number of members is calculated
- * from the difference between the two offsets.
- */
- RecordMultiXactOffset(offsets_writer, multi,
- (multixid_valid || prev_multixid_valid) ? next_offset : 0);
+ /*
+ * Read this multixid's members.
+ *
+ * Locking-only XIDs that may be part of multi-xids don't matter after
+ * upgrade, as there can be no transactions running across upgrade. So
+ * as a small optimization, we only read one member from each
+ * multixid: the one updating one, or if there was no update,
+ * arbitrarily the first locking xid.
+ */
+ multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
- /* Write the members */
- if (multixid_valid)
- {
- RecordMultiXactMembers(members_writer, next_offset, 1, &member);
- next_offset += 1;
- }
+ /*
+ * Write the new offset to pg_multixact/offsets.
+ *
+ * Even if this multixid is invalid, we still need to write its offset
+ * if the *previous* multixid was valid. That's because when reading
+ * a multixid, the number of members is calculated from the difference
+ * between the two offsets.
+ */
+ RecordMultiXactOffset(offsets_writer, multi,
+ (multixid_valid || prev_multixid_valid) ? next_offset : 0);
- /* Advance to next multixid, handling wraparound */
- multi++;
- if (multi < FirstMultiXactId)
- multi = FirstMultiXactId;
- prev_multixid_valid = multixid_valid;
+ /* Write the members */
+ if (multixid_valid)
+ {
+ RecordMultiXactMembers(members_writer, next_offset, 1, &member);
+ next_offset += 1;
}
- FreeOldMultiXactReader(old_reader);
+ /* Advance to next multixid, handling wraparound */
+ multi++;
+ if (multi < FirstMultiXactId)
+ multi = FirstMultiXactId;
+ prev_multixid_valid = multixid_valid;
+ }
+
+ FreeOldMultiXactReader(old_reader);
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5d7920c1b1..d8e1b680f5a 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -833,7 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index ec2ff7acb21..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -587,32 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix)
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
+ }
}
}
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 44ef11d980e..c90bf8bbde2 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6278,23 +6278,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index ec9c61ee924..87dfe702050 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -387,19 +387,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -599,8 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1086,38 +1086,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1675,27 +1675,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -1913,7 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2326,7 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
+ appendPQExpBufferStr(&buf, "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2431,7 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- appendPQExpBufferStr(&buf, ", i.indisreplident");
+ appendPQExpBufferStr(&buf, ", i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2682,81 +2682,80 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBufferStr(&buf, "SELECT pol.polname,");
+ appendPQExpBufferStr(&buf,
+ " pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3025,115 +3024,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT pg_catalog.string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT pg_catalog.string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Included in publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Included in publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3805,7 +3804,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
+ appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -3860,8 +3859,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -5155,14 +5154,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
--
2.50.1 (Apple Git-155)
Attachments:
[text/plain] v4-0001-pg_dump-pg_dumpall-bump-minimum-supported-version.patch (30.0K, ../../airEaHxsisyb14ih@nathan/2-v4-0001-pg_dump-pg_dumpall-bump-minimum-supported-version.patch)
download | inline diff:
From 65f93e2739cb4d714b5442b08b3c4582e5474122 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 10:15:38 -0700
Subject: [PATCH v4 1/4] pg_dump/pg_dumpall: bump minimum supported version to
v10
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/runtime.sgml | 2 +-
src/bin/pg_dump/pg_dump.c | 330 ++--------------------------------
src/bin/pg_dump/pg_dumpall.c | 32 +---
4 files changed, 22 insertions(+), 356 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index ae1bc14d2f2..64a3447e445 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1718,7 +1706,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index dfa292c2c3a..d9984910cc4 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1776,7 +1776,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
version of
<productname>PostgreSQL</productname>, to take advantage of enhancements
that might have been made in these programs. Current releases of the
- dump programs can read data from any server version back to 9.2.
+ dump programs can read data from any server version back to 10.
</para>
<para>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index a0f7f8e2168..75c27a08540 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,9 +1491,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security = on");
else
ExecuteSqlStatement(AH, "SET row_security = off");
- }
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1964,12 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
return true;
}
@@ -2000,11 +1986,10 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
+ * We dump out any ACLs defined in pg_catalog, if
* they are interesting (and not the original ACLs which were set at
* initdb time, see pg_init_privs).
*/
@@ -2213,8 +2198,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2215,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3100,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3325,10 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid IN (%u, %u, %u, %u);\n",
LargeObjectRelationId, LargeObjectLOidPNIndexId,
LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4207,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4316,10 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -4534,7 +4491,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4854,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5144,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,24 +6632,12 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
/*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
+ * Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"amtype, "
"amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6878,15 +6823,12 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
: "p.proisagg");
@@ -6916,29 +6858,6 @@ getAggregates(Archive *fout)
"refclassid = 'pg_extension'::regclass AND "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7021,6 +6940,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7039,14 +6959,10 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, in 9.6 and up, include functions in
+ * they are built-in. Also, include functions in
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
: "NOT p.proisagg");
@@ -7090,46 +7006,6 @@ getFuncs(Archive *fout)
appendPQExpBufferStr(query,
"\n OR p.proacl IS DISTINCT FROM pip.initprivs");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7378,64 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
"CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
"WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,9 +7296,8 @@ getTables(Archive *fout, int *numTables)
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
/*
- * In 9.6 and up, left join to pg_am to pick up the amname.
+ * Left join to pg_am to pick up the amname.
*/
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
@@ -8028,12 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8318,10 +8156,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8988,10 +8822,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9258,10 +9088,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9489,12 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(q,
"a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10897,8 +10719,6 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
printfPQExpBuffer(query,
"SELECT objoid, classoid, objsubid, privtype, initprivs "
"FROM pg_init_privs");
@@ -10966,7 +10786,6 @@ getAdditionalACLs(Archive *fout)
}
}
PQclear(res);
- }
destroyPQExpBuffer(query);
}
@@ -11141,15 +10960,6 @@ fetchAttributeStats(Archive *fout)
static bool restarted;
int max_rels = MAX_ATTR_STATS_RELS;
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
-
/* If we're just starting, set our TOC pointer. */
if (!te)
te = AH->toc->next;
@@ -11320,16 +11130,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For versions before 19, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11337,7 +11142,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11345,12 +11150,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13672,19 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15174,14 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"collprovider, "
"collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15588,7 +15374,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"aggkind,\n"
"aggmtransfn,\n"
@@ -15600,31 +15385,12 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"aggtransspace,\n"
"aggmtransspace,\n"
"aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"aggcombinefn,\n"
"aggserialfn,\n"
"aggdeserialfn,\n"
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17084,8 +16850,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- if (fout->remoteVersion >= 90600)
- {
/*
* In principle we should call acldefault('c', relowner) to
* get the default ACL for a column. However, we don't
@@ -17110,17 +16874,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
"ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
ExecuteSqlStatement(fout, query->data);
@@ -19410,16 +19163,10 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
+ if (fout->remoteVersion < 180000 ||
(!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
@@ -19477,59 +19224,20 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
+ * The sequence information is gathered in a sorted
* table before any calls to dumpSequence(). See collectSequences() for
* more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
Assert(sequences);
key.oid = tbinfo->dobj.catId.oid;
seq = bsearch(&key, sequences, nsequences,
sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
-
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19708,8 +19416,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index c1f43113c53..5b10f7122b7 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -693,11 +693,11 @@ main(int argc, char *argv[])
fout->verbose = verbose;
/*
- * We allow the server to be back to 9.2, and up to any minor release
+ * We allow the server to be back to 10, and up to any minor release
* of our own major version. (See also version check in
* pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = 1;
@@ -954,17 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT rolname "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 1", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1041,7 +1035,6 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT oid, rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, "
@@ -1052,27 +1045,6 @@ dumpRoles(PGconn *conn)
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 2", role_catalog);
- else if (server_version >= 90500)
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, "
- "false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
--
2.50.1 (Apple Git-155)
[text/plain] v4-0002-pg_upgrade-bump-minimum-supported-version-to-v10.patch (32.6K, ../../airEaHxsisyb14ih@nathan/3-v4-0002-pg_upgrade-bump-minimum-supported-version-to-v10.patch)
download | inline diff:
From 06bb9d59133582ffb7ff4cd265c244f24db3c46f Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:20:18 -0700
Subject: [PATCH v4 2/4] pg_upgrade: bump minimum supported version to v10
---
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_upgrade/check.c | 157 +----------------------
src/bin/pg_upgrade/controldata.c | 12 +-
src/bin/pg_upgrade/exec.c | 23 ----
src/bin/pg_upgrade/file.c | 164 -------------------------
src/bin/pg_upgrade/multixact_rewrite.c | 11 +-
src/bin/pg_upgrade/pg_upgrade.c | 31 +----
src/bin/pg_upgrade/pg_upgrade.h | 29 -----
src/bin/pg_upgrade/relfilenumber.c | 37 +-----
src/bin/pg_upgrade/version.c | 127 -------------------
10 files changed, 16 insertions(+), 577 deletions(-)
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index 38ca09b423c..c4ed75211db 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index f5c93e611d2..f1e35a6af47 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 10)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1569,12 +1475,10 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
appendPQExpBufferStr(&old_polymorphics,
", 'array_remove(anyarray,anyelement)'"
", 'array_replace(anyarray,anyelement,anyelement)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
appendPQExpBufferStr(&old_polymorphics,
", 'array_position(anyarray,anyelement)'"
", 'array_position(anyarray,anyelement,integer)'"
@@ -1870,63 +1774,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index cffcd4b0eba..8188355240f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -602,14 +602,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +628,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +667,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 563b4a6b5fa..44355feea30 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,16 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- if (v1 < 10)
- {
- /* old style, e.g. 9.6.1 */
- cluster->bin_version = v1 * 10000 + v2 * 100;
- }
- else
- {
- /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
- }
}
@@ -353,17 +344,7 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
check_single_dir(pg_data, "pg_xact");
}
@@ -404,10 +385,6 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index 823984ec8f3..c45b3183684 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -25,10 +25,7 @@ static void RecordMultiXactMembers(SlruSegState *members_writer,
* 32-bit offsets to the current format.
*
* Multixids in the range [from_multi, to_multi) are read from the old
- * cluster, and written in the new format. An important edge case is that if
- * from_multi == to_multi, this initializes the new pg_multixact files in the
- * new format without trying to open any old files. (We rely on that when
- * upgrading from PostgreSQL version 9.2 or below.)
+ * cluster, and written in the new format.
*
* Returns the new nextOffset value; the caller should set it in the new
* control file. The new members always start from offset 1, regardless of
@@ -42,6 +39,7 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
SlruSegState *members_writer;
char dir[MAXPGPATH] = {0};
bool prev_multixid_valid = false;
+ OldMultiXactReader *old_reader;
/*
* The range of valid multi XIDs is unchanged by the conversion (they are
@@ -63,10 +61,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- if (to_multi != from_multi)
- {
- OldMultiXactReader *old_reader;
-
old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
old_cluster.controldata.chkpnt_nxtmulti,
old_cluster.controldata.chkpnt_nxtmxoff);
@@ -113,7 +107,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
}
FreeOldMultiXactReader(old_reader);
- }
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..e5d7920c1b1 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -777,10 +770,7 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +799,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index ccd1ac0d013..d6e5bca5792 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,10 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
void report_extension_updates(ClusterInfo *cluster);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..ec2ff7acb21 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,14 +587,6 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
- {
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
- }
- else
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
--
2.50.1 (Apple Git-155)
[text/plain] v4-0003-psql-bump-minimum-supported-version-to-v10.patch (20.9K, ../../airEaHxsisyb14ih@nathan/4-v4-0003-psql-bump-minimum-supported-version-to-v10.patch)
download | inline diff:
From f732e91730714aa08735e91520339921837b9098 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:34:35 -0700
Subject: [PATCH v4 3/4] psql: bump minimum supported version to v10
---
doc/src/sgml/ref/psql-ref.sgml | 2 +-
src/bin/psql/command.c | 23 +---
src/bin/psql/describe.c | 244 +--------------------------------
3 files changed, 11 insertions(+), 258 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 7c05afd4719..56c2692e618 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
or an older major version. Backslash commands are particularly likely
to fail if the server is of a newer version than <application>psql</application>
itself. However, backslash commands of the <literal>\d</literal> family should
- work with servers of versions back to 9.2, though not necessarily with
+ work with servers of versions back to 10, though not necessarily with
servers newer than <application>psql</application> itself. The general
functionality of running SQL commands and displaying query results
should also work with servers of a newer major version, but this cannot
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 01b8f11aadd..44ef11d980e 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
+ * Views may have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
+ * separately. Materialized views may have
* arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
@@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 7f9b2b71a36..ec9c61ee924 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
appendPQExpBuffer(&buf,
",\n CASE\n"
" WHEN p.proparallel = "
@@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
myopt.translate_columns = translate_columns;
myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT polname\n"
@@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname,
"FROM pg_catalog.pg_sequence\n"
"WHERE seqrelid = '%s';",
oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
appendPQExpBuffer(&buf,
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
@@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
if (pset.sversion >= 150000)
@@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Bypass RLS"));
@@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
" CASE c.collprovider "
"WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
@@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
"WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
"END AS \"%s\",\n",
gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6486,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6623,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
--
2.50.1 (Apple Git-155)
[text/plain] v4-0004-run-pgindent.patch (59.7K, ../../airEaHxsisyb14ih@nathan/5-v4-0004-run-pgindent.patch)
download | inline diff:
From b779c7376f5300d71a4e74ff7c96e83c895b2707 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Thu, 11 Jun 2026 09:15:56 -0500
Subject: [PATCH v4 4/4] run pgindent
---
src/bin/pg_dump/pg_dump.c | 457 ++++++++++++------------
src/bin/pg_dump/pg_dumpall.c | 30 +-
src/bin/pg_upgrade/check.c | 16 +-
src/bin/pg_upgrade/exec.c | 8 +-
src/bin/pg_upgrade/multixact_rewrite.c | 80 ++---
src/bin/pg_upgrade/pg_upgrade.c | 2 +-
src/bin/pg_upgrade/relfilenumber.c | 54 +--
src/bin/psql/command.c | 29 +-
src/bin/psql/describe.c | 461 ++++++++++++-------------
9 files changed, 567 insertions(+), 570 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 75c27a08540..67a8ebdd3f5 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1491,8 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1505,10 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1955,7 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -1989,9 +1989,9 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * We dump out any ACLs defined in pg_catalog, if
- * they are interesting (and not the original ACLs which were set at
- * initdb time, see pg_init_privs).
+ * We dump out any ACLs defined in pg_catalog, if they are interesting
+ * (and not the original ACLs which were set at initdb time, see
+ * pg_init_privs).
*/
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL;
}
@@ -3298,7 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- appendPQExpBufferStr(dbQry, "datminmxid, ");
+ appendPQExpBufferStr(dbQry, "datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3640,11 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- appendPQExpBufferStr(query, "pol.polpermissive, ");
+ appendPQExpBufferStr(query, "pol.polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -6635,9 +6635,9 @@ getAccessMethods(Archive *fout)
* Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
+ appendPQExpBufferStr(query,
+ "amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6829,35 +6829,35 @@ getAggregates(Archive *fout)
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6959,53 +6959,53 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, include functions in
- * pg_catalog if they have an ACL different from what's shown in
- * pg_init_privs (so we have to join to pg_init_privs; annoying).
+ * they are built-in. Also, include functions in pg_catalog if they have
+ * an ACL different from what's shown in pg_init_privs (so we have to join
+ * to pg_init_privs; annoying).
*/
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7254,31 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, ");
- appendPQExpBufferStr(query,
- "c.relreplident, ");
+ appendPQExpBufferStr(query,
+ "c.relreplident, ");
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
+ appendPQExpBufferStr(query,
+ "c.relrowsecurity, c.relforcerowsecurity, ");
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
+ appendPQExpBufferStr(query,
+ "c.relminmxid, tc.relminmxid AS tminmxid, ");
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
+ appendPQExpBufferStr(query,
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- appendPQExpBufferStr(query,
- "am.amname, ");
+ appendPQExpBufferStr(query,
+ "am.amname, ");
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
+ appendPQExpBufferStr(query,
+ "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7298,8 +7298,8 @@ getTables(Archive *fout, int *numTables)
/*
* Left join to pg_am to pick up the amname.
*/
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -7870,8 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
+ appendPQExpBufferStr(query,
+ "i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -9315,8 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10719,73 +10719,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
+ }
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11130,8 +11130,8 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For versions before 19, the redundant filter clause on s.tablename =
- * ANY(...) seems sufficient to convince the planner to use
+ * For versions before 19, the redundant filter clause on s.tablename
+ * = ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
@@ -13471,11 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ appendPQExpBufferStr(query,
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- appendPQExpBufferStr(query,
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -14965,9 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
+ appendPQExpBufferStr(query,
+ "collprovider, "
+ "collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15374,23 +15374,23 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
+ appendPQExpBufferStr(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -16850,30 +16850,30 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ /*
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
+ appendPQExpBufferStr(query,
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19167,7 +19167,7 @@ collectSequences(Archive *fout)
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19229,15 +19229,14 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * The sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- Assert(sequences);
+ Assert(sequences);
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 5b10f7122b7..3f61196671c 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -954,11 +954,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -1035,16 +1035,16 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 2", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT oid, rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, rolreplication, rolbypassrls, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index f1e35a6af47..a2f9b683c59 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1475,15 +1475,15 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 44355feea30..a1bdbf373e3 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,7 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- cluster->bin_version = v1 * 10000;
+ cluster->bin_version = v1 * 10000;
}
@@ -344,8 +344,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
- check_single_dir(pg_data, "pg_wal");
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -385,7 +385,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index c45b3183684..c7a1416494d 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -61,52 +61,52 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_nxtmxoff);
+ old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
+ old_cluster.controldata.chkpnt_nxtmulti,
+ old_cluster.controldata.chkpnt_nxtmxoff);
- for (MultiXactId multi = from_multi; multi != to_multi;)
- {
- MultiXactMember member;
- bool multixid_valid;
-
- /*
- * Read this multixid's members.
- *
- * Locking-only XIDs that may be part of multi-xids don't matter
- * after upgrade, as there can be no transactions running across
- * upgrade. So as a small optimization, we only read one member
- * from each multixid: the one updating one, or if there was no
- * update, arbitrarily the first locking xid.
- */
- multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
+ for (MultiXactId multi = from_multi; multi != to_multi;)
+ {
+ MultiXactMember member;
+ bool multixid_valid;
- /*
- * Write the new offset to pg_multixact/offsets.
- *
- * Even if this multixid is invalid, we still need to write its
- * offset if the *previous* multixid was valid. That's because
- * when reading a multixid, the number of members is calculated
- * from the difference between the two offsets.
- */
- RecordMultiXactOffset(offsets_writer, multi,
- (multixid_valid || prev_multixid_valid) ? next_offset : 0);
+ /*
+ * Read this multixid's members.
+ *
+ * Locking-only XIDs that may be part of multi-xids don't matter after
+ * upgrade, as there can be no transactions running across upgrade. So
+ * as a small optimization, we only read one member from each
+ * multixid: the one updating one, or if there was no update,
+ * arbitrarily the first locking xid.
+ */
+ multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
- /* Write the members */
- if (multixid_valid)
- {
- RecordMultiXactMembers(members_writer, next_offset, 1, &member);
- next_offset += 1;
- }
+ /*
+ * Write the new offset to pg_multixact/offsets.
+ *
+ * Even if this multixid is invalid, we still need to write its offset
+ * if the *previous* multixid was valid. That's because when reading
+ * a multixid, the number of members is calculated from the difference
+ * between the two offsets.
+ */
+ RecordMultiXactOffset(offsets_writer, multi,
+ (multixid_valid || prev_multixid_valid) ? next_offset : 0);
- /* Advance to next multixid, handling wraparound */
- multi++;
- if (multi < FirstMultiXactId)
- multi = FirstMultiXactId;
- prev_multixid_valid = multixid_valid;
+ /* Write the members */
+ if (multixid_valid)
+ {
+ RecordMultiXactMembers(members_writer, next_offset, 1, &member);
+ next_offset += 1;
}
- FreeOldMultiXactReader(old_reader);
+ /* Advance to next multixid, handling wraparound */
+ multi++;
+ if (multi < FirstMultiXactId)
+ multi = FirstMultiXactId;
+ prev_multixid_valid = multixid_valid;
+ }
+
+ FreeOldMultiXactReader(old_reader);
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5d7920c1b1..d8e1b680f5a 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -833,7 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index ec2ff7acb21..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -587,32 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix)
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
+ }
}
}
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 44ef11d980e..c90bf8bbde2 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6278,23 +6278,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index ec9c61ee924..87dfe702050 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -387,19 +387,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -599,8 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1086,38 +1086,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1675,27 +1675,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -1913,7 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2326,7 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
+ appendPQExpBufferStr(&buf, "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2431,7 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- appendPQExpBufferStr(&buf, ", i.indisreplident");
+ appendPQExpBufferStr(&buf, ", i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2682,81 +2682,80 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBufferStr(&buf, "SELECT pol.polname,");
+ appendPQExpBufferStr(&buf,
+ " pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3025,115 +3024,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT pg_catalog.string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT pg_catalog.string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Included in publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Included in publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3805,7 +3804,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
+ appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -3860,8 +3859,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -5155,14 +5154,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-06-29 15:16 Nathan Bossart <nathandbossart@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-06-29 15:16 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
rebased
--
nathan
From a584eb33d83cb4483fe08263c2eeec1926de4603 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 10:15:38 -0700
Subject: [PATCH v5 1/4] pg_dump/pg_dumpall: bump minimum supported version to
v10
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/runtime.sgml | 2 +-
src/bin/pg_dump/pg_dump.c | 330 ++--------------------------------
src/bin/pg_dump/pg_dumpall.c | 28 ---
4 files changed, 20 insertions(+), 354 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 0e0d53926af..774be23b4f9 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1717,7 +1705,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index dfa292c2c3a..d9984910cc4 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1776,7 +1776,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
version of
<productname>PostgreSQL</productname>, to take advantage of enhancements
that might have been made in these programs. Current releases of the
- dump programs can read data from any server version back to 9.2.
+ dump programs can read data from any server version back to 10.
</para>
<para>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index c56437d6057..17ad8eeb838 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,9 +1491,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security = on");
else
ExecuteSqlStatement(AH, "SET row_security = off");
- }
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1964,12 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
return true;
}
@@ -2000,11 +1986,10 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
+ * We dump out any ACLs defined in pg_catalog, if
* they are interesting (and not the original ACLs which were set at
* initdb time, see pg_init_privs).
*/
@@ -2213,8 +2198,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2215,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3100,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3325,10 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid IN (%u, %u, %u, %u);\n",
LargeObjectRelationId, LargeObjectLOidPNIndexId,
LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4207,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4316,10 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -4534,7 +4491,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4854,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5144,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,24 +6632,12 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
/*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
+ * Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"amtype, "
"amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6878,15 +6823,12 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
: "p.proisagg");
@@ -6916,29 +6858,6 @@ getAggregates(Archive *fout)
"refclassid = 'pg_extension'::regclass AND "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7021,6 +6940,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7039,14 +6959,10 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, in 9.6 and up, include functions in
+ * they are built-in. Also, include functions in
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
: "NOT p.proisagg");
@@ -7090,46 +7006,6 @@ getFuncs(Archive *fout)
appendPQExpBufferStr(query,
"\n OR p.proacl IS DISTINCT FROM pip.initprivs");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7378,64 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
"CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
"WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,9 +7296,8 @@ getTables(Archive *fout, int *numTables)
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
/*
- * In 9.6 and up, left join to pg_am to pick up the amname.
+ * Left join to pg_am to pick up the amname.
*/
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
@@ -8028,12 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8318,10 +8156,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8988,10 +8822,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9258,10 +9088,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9489,12 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(q,
"a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10897,8 +10719,6 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
printfPQExpBuffer(query,
"SELECT objoid, classoid, objsubid, privtype, initprivs "
"FROM pg_init_privs");
@@ -10966,7 +10786,6 @@ getAdditionalACLs(Archive *fout)
}
}
PQclear(res);
- }
destroyPQExpBuffer(query);
}
@@ -11141,15 +10960,6 @@ fetchAttributeStats(Archive *fout)
static bool restarted;
int max_rels = MAX_ATTR_STATS_RELS;
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
-
/* If we're just starting, set our TOC pointer. */
if (!te)
te = AH->toc->next;
@@ -11320,16 +11130,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For versions before 19, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11337,7 +11142,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11345,12 +11150,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13672,19 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15174,14 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"collprovider, "
"collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15588,7 +15374,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"aggkind,\n"
"aggmtransfn,\n"
@@ -15600,31 +15385,12 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"aggtransspace,\n"
"aggmtransspace,\n"
"aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"aggcombinefn,\n"
"aggserialfn,\n"
"aggdeserialfn,\n"
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17084,8 +16850,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- if (fout->remoteVersion >= 90600)
- {
/*
* In principle we should call acldefault('c', relowner) to
* get the default ACL for a column. However, we don't
@@ -17110,17 +16874,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
"ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
ExecuteSqlStatement(fout, query->data);
@@ -19410,16 +19163,10 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
+ if (fout->remoteVersion < 180000 ||
(!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
@@ -19477,59 +19224,20 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
+ * The sequence information is gathered in a sorted
* table before any calls to dumpSequence(). See collectSequences() for
* more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
Assert(sequences);
key.oid = tbinfo->dobj.catId.oid;
seq = bsearch(&key, sequences, nsequences,
sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
-
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19708,8 +19416,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index b9653f0aefe..e68937c9934 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -785,17 +785,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT rolname "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 1", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -849,7 +843,6 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT oid, rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, "
@@ -860,27 +853,6 @@ dumpRoles(PGconn *conn)
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 2", role_catalog);
- else if (server_version >= 90500)
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, "
- "false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
--
2.50.1 (Apple Git-155)
From 1191a09db71d32738a0812d97623ad65186a08ba Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:20:18 -0700
Subject: [PATCH v5 2/4] pg_upgrade: bump minimum supported version to v10
---
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_upgrade/check.c | 157 +----------------------
src/bin/pg_upgrade/controldata.c | 12 +-
src/bin/pg_upgrade/exec.c | 23 ----
src/bin/pg_upgrade/file.c | 164 -------------------------
src/bin/pg_upgrade/multixact_rewrite.c | 11 +-
src/bin/pg_upgrade/pg_upgrade.c | 31 +----
src/bin/pg_upgrade/pg_upgrade.h | 29 -----
src/bin/pg_upgrade/relfilenumber.c | 37 +-----
src/bin/pg_upgrade/version.c | 127 -------------------
10 files changed, 16 insertions(+), 577 deletions(-)
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index cc44983a9a8..e4e8c02e6d6 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index f8f31382835..01b354e3c44 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 10)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1569,12 +1475,10 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
appendPQExpBufferStr(&old_polymorphics,
", 'array_remove(anyarray,anyelement)'"
", 'array_replace(anyarray,anyelement,anyelement)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
appendPQExpBufferStr(&old_polymorphics,
", 'array_position(anyarray,anyelement)'"
", 'array_position(anyarray,anyelement,integer)'"
@@ -1870,63 +1774,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index cffcd4b0eba..8188355240f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -602,14 +602,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +628,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +667,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 563b4a6b5fa..44355feea30 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,16 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- if (v1 < 10)
- {
- /* old style, e.g. 9.6.1 */
- cluster->bin_version = v1 * 10000 + v2 * 100;
- }
- else
- {
- /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
- }
}
@@ -353,17 +344,7 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
check_single_dir(pg_data, "pg_xact");
}
@@ -404,10 +385,6 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index 823984ec8f3..c45b3183684 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -25,10 +25,7 @@ static void RecordMultiXactMembers(SlruSegState *members_writer,
* 32-bit offsets to the current format.
*
* Multixids in the range [from_multi, to_multi) are read from the old
- * cluster, and written in the new format. An important edge case is that if
- * from_multi == to_multi, this initializes the new pg_multixact files in the
- * new format without trying to open any old files. (We rely on that when
- * upgrading from PostgreSQL version 9.2 or below.)
+ * cluster, and written in the new format.
*
* Returns the new nextOffset value; the caller should set it in the new
* control file. The new members always start from offset 1, regardless of
@@ -42,6 +39,7 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
SlruSegState *members_writer;
char dir[MAXPGPATH] = {0};
bool prev_multixid_valid = false;
+ OldMultiXactReader *old_reader;
/*
* The range of valid multi XIDs is unchanged by the conversion (they are
@@ -63,10 +61,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- if (to_multi != from_multi)
- {
- OldMultiXactReader *old_reader;
-
old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
old_cluster.controldata.chkpnt_nxtmulti,
old_cluster.controldata.chkpnt_nxtmxoff);
@@ -113,7 +107,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
}
FreeOldMultiXactReader(old_reader);
- }
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..e5d7920c1b1 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -777,10 +770,7 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +799,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index ccd1ac0d013..d6e5bca5792 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,10 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
void report_extension_updates(ClusterInfo *cluster);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..ec2ff7acb21 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,14 +587,6 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
- {
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
- }
- else
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
--
2.50.1 (Apple Git-155)
From 83789792970535565491a46b88fd467ccd0d4eca Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:34:35 -0700
Subject: [PATCH v5 3/4] psql: bump minimum supported version to v10
---
doc/src/sgml/ref/psql-ref.sgml | 2 +-
src/bin/psql/command.c | 23 +---
src/bin/psql/describe.c | 244 +--------------------------------
3 files changed, 11 insertions(+), 258 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 7c05afd4719..56c2692e618 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
or an older major version. Backslash commands are particularly likely
to fail if the server is of a newer version than <application>psql</application>
itself. However, backslash commands of the <literal>\d</literal> family should
- work with servers of versions back to 9.2, though not necessarily with
+ work with servers of versions back to 10, though not necessarily with
servers newer than <application>psql</application> itself. The general
functionality of running SQL commands and displaying query results
should also work with servers of a newer major version, but this cannot
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 01b8f11aadd..44ef11d980e 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
+ * Views may have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
+ * separately. Materialized views may have
* arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
@@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index af3935b0078..ce99137c613 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
appendPQExpBuffer(&buf,
",\n CASE\n"
" WHEN p.proparallel = "
@@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
myopt.translate_columns = translate_columns;
myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT polname\n"
@@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname,
"FROM pg_catalog.pg_sequence\n"
"WHERE seqrelid = '%s';",
oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
appendPQExpBuffer(&buf,
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
@@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
if (pset.sversion >= 150000)
@@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Bypass RLS"));
@@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
" CASE c.collprovider "
"WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
@@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
"WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
"END AS \"%s\",\n",
gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6486,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6623,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
--
2.50.1 (Apple Git-155)
From 63644da2b316128a3b04b40875da2316ffc8b246 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Mon, 29 Jun 2026 09:56:17 -0500
Subject: [PATCH v5 4/4] run pgindent
---
src/bin/pg_dump/pg_dump.c | 457 ++++++++++++------------
src/bin/pg_dump/pg_dumpall.c | 30 +-
src/bin/pg_upgrade/check.c | 16 +-
src/bin/pg_upgrade/exec.c | 8 +-
src/bin/pg_upgrade/multixact_rewrite.c | 80 ++---
src/bin/pg_upgrade/pg_upgrade.c | 2 +-
src/bin/pg_upgrade/relfilenumber.c | 54 +--
src/bin/psql/command.c | 29 +-
src/bin/psql/describe.c | 461 ++++++++++++-------------
9 files changed, 567 insertions(+), 570 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 17ad8eeb838..33786f976e3 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1491,8 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1505,10 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1955,7 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -1989,9 +1989,9 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * We dump out any ACLs defined in pg_catalog, if
- * they are interesting (and not the original ACLs which were set at
- * initdb time, see pg_init_privs).
+ * We dump out any ACLs defined in pg_catalog, if they are interesting
+ * (and not the original ACLs which were set at initdb time, see
+ * pg_init_privs).
*/
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL;
}
@@ -3298,7 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- appendPQExpBufferStr(dbQry, "datminmxid, ");
+ appendPQExpBufferStr(dbQry, "datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3640,11 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- appendPQExpBufferStr(query, "pol.polpermissive, ");
+ appendPQExpBufferStr(query, "pol.polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -6635,9 +6635,9 @@ getAccessMethods(Archive *fout)
* Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
+ appendPQExpBufferStr(query,
+ "amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6829,35 +6829,35 @@ getAggregates(Archive *fout)
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6959,53 +6959,53 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, include functions in
- * pg_catalog if they have an ACL different from what's shown in
- * pg_init_privs (so we have to join to pg_init_privs; annoying).
+ * they are built-in. Also, include functions in pg_catalog if they have
+ * an ACL different from what's shown in pg_init_privs (so we have to join
+ * to pg_init_privs; annoying).
*/
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7254,31 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, ");
- appendPQExpBufferStr(query,
- "c.relreplident, ");
+ appendPQExpBufferStr(query,
+ "c.relreplident, ");
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
+ appendPQExpBufferStr(query,
+ "c.relrowsecurity, c.relforcerowsecurity, ");
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
+ appendPQExpBufferStr(query,
+ "c.relminmxid, tc.relminmxid AS tminmxid, ");
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
+ appendPQExpBufferStr(query,
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- appendPQExpBufferStr(query,
- "am.amname, ");
+ appendPQExpBufferStr(query,
+ "am.amname, ");
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
+ appendPQExpBufferStr(query,
+ "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7298,8 +7298,8 @@ getTables(Archive *fout, int *numTables)
/*
* Left join to pg_am to pick up the amname.
*/
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -7870,8 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
+ appendPQExpBufferStr(query,
+ "i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -9315,8 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10719,73 +10719,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
+ }
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11130,8 +11130,8 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For versions before 19, the redundant filter clause on s.tablename =
- * ANY(...) seems sufficient to convince the planner to use
+ * For versions before 19, the redundant filter clause on s.tablename
+ * = ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
@@ -13471,11 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ appendPQExpBufferStr(query,
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- appendPQExpBufferStr(query,
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -14965,9 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
+ appendPQExpBufferStr(query,
+ "collprovider, "
+ "collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15374,23 +15374,23 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
+ appendPQExpBufferStr(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -16850,30 +16850,30 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ /*
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
+ appendPQExpBufferStr(query,
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19167,7 +19167,7 @@ collectSequences(Archive *fout)
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19229,15 +19229,14 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * The sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- Assert(sequences);
+ Assert(sequences);
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index e68937c9934..afcd9a218d8 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -785,11 +785,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -843,16 +843,16 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 2", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT oid, rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, rolreplication, rolbypassrls, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 01b354e3c44..7629f8cab02 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1475,15 +1475,15 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 44355feea30..a1bdbf373e3 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,7 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- cluster->bin_version = v1 * 10000;
+ cluster->bin_version = v1 * 10000;
}
@@ -344,8 +344,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
- check_single_dir(pg_data, "pg_wal");
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -385,7 +385,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index c45b3183684..c7a1416494d 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -61,52 +61,52 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_nxtmxoff);
+ old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
+ old_cluster.controldata.chkpnt_nxtmulti,
+ old_cluster.controldata.chkpnt_nxtmxoff);
- for (MultiXactId multi = from_multi; multi != to_multi;)
- {
- MultiXactMember member;
- bool multixid_valid;
-
- /*
- * Read this multixid's members.
- *
- * Locking-only XIDs that may be part of multi-xids don't matter
- * after upgrade, as there can be no transactions running across
- * upgrade. So as a small optimization, we only read one member
- * from each multixid: the one updating one, or if there was no
- * update, arbitrarily the first locking xid.
- */
- multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
+ for (MultiXactId multi = from_multi; multi != to_multi;)
+ {
+ MultiXactMember member;
+ bool multixid_valid;
- /*
- * Write the new offset to pg_multixact/offsets.
- *
- * Even if this multixid is invalid, we still need to write its
- * offset if the *previous* multixid was valid. That's because
- * when reading a multixid, the number of members is calculated
- * from the difference between the two offsets.
- */
- RecordMultiXactOffset(offsets_writer, multi,
- (multixid_valid || prev_multixid_valid) ? next_offset : 0);
+ /*
+ * Read this multixid's members.
+ *
+ * Locking-only XIDs that may be part of multi-xids don't matter after
+ * upgrade, as there can be no transactions running across upgrade. So
+ * as a small optimization, we only read one member from each
+ * multixid: the one updating one, or if there was no update,
+ * arbitrarily the first locking xid.
+ */
+ multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
- /* Write the members */
- if (multixid_valid)
- {
- RecordMultiXactMembers(members_writer, next_offset, 1, &member);
- next_offset += 1;
- }
+ /*
+ * Write the new offset to pg_multixact/offsets.
+ *
+ * Even if this multixid is invalid, we still need to write its offset
+ * if the *previous* multixid was valid. That's because when reading
+ * a multixid, the number of members is calculated from the difference
+ * between the two offsets.
+ */
+ RecordMultiXactOffset(offsets_writer, multi,
+ (multixid_valid || prev_multixid_valid) ? next_offset : 0);
- /* Advance to next multixid, handling wraparound */
- multi++;
- if (multi < FirstMultiXactId)
- multi = FirstMultiXactId;
- prev_multixid_valid = multixid_valid;
+ /* Write the members */
+ if (multixid_valid)
+ {
+ RecordMultiXactMembers(members_writer, next_offset, 1, &member);
+ next_offset += 1;
}
- FreeOldMultiXactReader(old_reader);
+ /* Advance to next multixid, handling wraparound */
+ multi++;
+ if (multi < FirstMultiXactId)
+ multi = FirstMultiXactId;
+ prev_multixid_valid = multixid_valid;
+ }
+
+ FreeOldMultiXactReader(old_reader);
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5d7920c1b1..d8e1b680f5a 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -833,7 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index ec2ff7acb21..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -587,32 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix)
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
+ }
}
}
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 44ef11d980e..c90bf8bbde2 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6278,23 +6278,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index ce99137c613..ac0c55e7aa5 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -387,19 +387,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -599,8 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1086,38 +1086,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1675,27 +1675,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -1913,7 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2326,7 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
+ appendPQExpBufferStr(&buf, "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2431,7 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- appendPQExpBufferStr(&buf, ", i.indisreplident");
+ appendPQExpBufferStr(&buf, ", i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2682,81 +2682,80 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBufferStr(&buf, "SELECT pol.polname,");
+ appendPQExpBufferStr(&buf,
+ " pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3025,115 +3024,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT pg_catalog.string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT pg_catalog.string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Included in publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Included in publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3805,7 +3804,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
+ appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -3860,8 +3859,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -5155,14 +5154,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
--
2.50.1 (Apple Git-155)
Attachments:
[text/plain] v5-0001-pg_dump-pg_dumpall-bump-minimum-supported-version.patch (29.5K, ../../akKMWBN8nSjVohcs@nathan/2-v5-0001-pg_dump-pg_dumpall-bump-minimum-supported-version.patch)
download | inline diff:
From a584eb33d83cb4483fe08263c2eeec1926de4603 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 10:15:38 -0700
Subject: [PATCH v5 1/4] pg_dump/pg_dumpall: bump minimum supported version to
v10
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/runtime.sgml | 2 +-
src/bin/pg_dump/pg_dump.c | 330 ++--------------------------------
src/bin/pg_dump/pg_dumpall.c | 28 ---
4 files changed, 20 insertions(+), 354 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 0e0d53926af..774be23b4f9 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1717,7 +1705,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index dfa292c2c3a..d9984910cc4 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1776,7 +1776,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
version of
<productname>PostgreSQL</productname>, to take advantage of enhancements
that might have been made in these programs. Current releases of the
- dump programs can read data from any server version back to 9.2.
+ dump programs can read data from any server version back to 10.
</para>
<para>
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index c56437d6057..17ad8eeb838 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,9 +1491,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security = on");
else
ExecuteSqlStatement(AH, "SET row_security = off");
- }
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1964,12 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
return true;
}
@@ -2000,11 +1986,10 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
+ * We dump out any ACLs defined in pg_catalog, if
* they are interesting (and not the original ACLs which were set at
* initdb time, see pg_init_privs).
*/
@@ -2213,8 +2198,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2215,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3100,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3325,10 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid IN (%u, %u, %u, %u);\n",
LargeObjectRelationId, LargeObjectLOidPNIndexId,
LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4207,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4316,10 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -4534,7 +4491,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4854,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5144,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,24 +6632,12 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
/*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
+ * Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"amtype, "
"amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6878,15 +6823,12 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
: "p.proisagg");
@@ -6916,29 +6858,6 @@ getAggregates(Archive *fout)
"refclassid = 'pg_extension'::regclass AND "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7021,6 +6940,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7039,14 +6959,10 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, in 9.6 and up, include functions in
+ * they are built-in. Also, include functions in
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
: "NOT p.proisagg");
@@ -7090,46 +7006,6 @@ getFuncs(Archive *fout)
appendPQExpBufferStr(query,
"\n OR p.proacl IS DISTINCT FROM pip.initprivs");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7378,64 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
"CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
"WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,9 +7296,8 @@ getTables(Archive *fout, int *numTables)
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
/*
- * In 9.6 and up, left join to pg_am to pick up the amname.
+ * Left join to pg_am to pick up the amname.
*/
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
@@ -8028,12 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8318,10 +8156,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8988,10 +8822,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9258,10 +9088,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9489,12 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(q,
"a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10897,8 +10719,6 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
printfPQExpBuffer(query,
"SELECT objoid, classoid, objsubid, privtype, initprivs "
"FROM pg_init_privs");
@@ -10966,7 +10786,6 @@ getAdditionalACLs(Archive *fout)
}
}
PQclear(res);
- }
destroyPQExpBuffer(query);
}
@@ -11141,15 +10960,6 @@ fetchAttributeStats(Archive *fout)
static bool restarted;
int max_rels = MAX_ATTR_STATS_RELS;
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
-
/* If we're just starting, set our TOC pointer. */
if (!te)
te = AH->toc->next;
@@ -11320,16 +11130,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For versions before 19, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11337,7 +11142,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11345,12 +11150,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13672,19 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15174,14 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"collprovider, "
"collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15588,7 +15374,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"aggkind,\n"
"aggmtransfn,\n"
@@ -15600,31 +15385,12 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"aggtransspace,\n"
"aggmtransspace,\n"
"aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"aggcombinefn,\n"
"aggserialfn,\n"
"aggdeserialfn,\n"
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17084,8 +16850,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- if (fout->remoteVersion >= 90600)
- {
/*
* In principle we should call acldefault('c', relowner) to
* get the default ACL for a column. However, we don't
@@ -17110,17 +16874,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
"ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
ExecuteSqlStatement(fout, query->data);
@@ -19410,16 +19163,10 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
+ if (fout->remoteVersion < 180000 ||
(!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
@@ -19477,59 +19224,20 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
+ * The sequence information is gathered in a sorted
* table before any calls to dumpSequence(). See collectSequences() for
* more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
Assert(sequences);
key.oid = tbinfo->dobj.catId.oid;
seq = bsearch(&key, sequences, nsequences,
sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
-
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19708,8 +19416,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index b9653f0aefe..e68937c9934 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -785,17 +785,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT rolname "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 1", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -849,7 +843,6 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT oid, rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, "
@@ -860,27 +853,6 @@ dumpRoles(PGconn *conn)
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 2", role_catalog);
- else if (server_version >= 90500)
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, "
- "false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
--
2.50.1 (Apple Git-155)
[text/plain] v5-0002-pg_upgrade-bump-minimum-supported-version-to-v10.patch (32.6K, ../../akKMWBN8nSjVohcs@nathan/3-v5-0002-pg_upgrade-bump-minimum-supported-version-to-v10.patch)
download | inline diff:
From 1191a09db71d32738a0812d97623ad65186a08ba Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:20:18 -0700
Subject: [PATCH v5 2/4] pg_upgrade: bump minimum supported version to v10
---
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_upgrade/check.c | 157 +----------------------
src/bin/pg_upgrade/controldata.c | 12 +-
src/bin/pg_upgrade/exec.c | 23 ----
src/bin/pg_upgrade/file.c | 164 -------------------------
src/bin/pg_upgrade/multixact_rewrite.c | 11 +-
src/bin/pg_upgrade/pg_upgrade.c | 31 +----
src/bin/pg_upgrade/pg_upgrade.h | 29 -----
src/bin/pg_upgrade/relfilenumber.c | 37 +-----
src/bin/pg_upgrade/version.c | 127 -------------------
10 files changed, 16 insertions(+), 577 deletions(-)
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index cc44983a9a8..e4e8c02e6d6 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index f8f31382835..01b354e3c44 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 10)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1569,12 +1475,10 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
appendPQExpBufferStr(&old_polymorphics,
", 'array_remove(anyarray,anyelement)'"
", 'array_replace(anyarray,anyelement,anyelement)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
appendPQExpBufferStr(&old_polymorphics,
", 'array_position(anyarray,anyelement)'"
", 'array_position(anyarray,anyelement,integer)'"
@@ -1870,63 +1774,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index cffcd4b0eba..8188355240f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -602,14 +602,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +628,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +667,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 563b4a6b5fa..44355feea30 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,16 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- if (v1 < 10)
- {
- /* old style, e.g. 9.6.1 */
- cluster->bin_version = v1 * 10000 + v2 * 100;
- }
- else
- {
- /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
- }
}
@@ -353,17 +344,7 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
check_single_dir(pg_data, "pg_xact");
}
@@ -404,10 +385,6 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index 823984ec8f3..c45b3183684 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -25,10 +25,7 @@ static void RecordMultiXactMembers(SlruSegState *members_writer,
* 32-bit offsets to the current format.
*
* Multixids in the range [from_multi, to_multi) are read from the old
- * cluster, and written in the new format. An important edge case is that if
- * from_multi == to_multi, this initializes the new pg_multixact files in the
- * new format without trying to open any old files. (We rely on that when
- * upgrading from PostgreSQL version 9.2 or below.)
+ * cluster, and written in the new format.
*
* Returns the new nextOffset value; the caller should set it in the new
* control file. The new members always start from offset 1, regardless of
@@ -42,6 +39,7 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
SlruSegState *members_writer;
char dir[MAXPGPATH] = {0};
bool prev_multixid_valid = false;
+ OldMultiXactReader *old_reader;
/*
* The range of valid multi XIDs is unchanged by the conversion (they are
@@ -63,10 +61,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- if (to_multi != from_multi)
- {
- OldMultiXactReader *old_reader;
-
old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
old_cluster.controldata.chkpnt_nxtmulti,
old_cluster.controldata.chkpnt_nxtmxoff);
@@ -113,7 +107,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
}
FreeOldMultiXactReader(old_reader);
- }
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..e5d7920c1b1 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -777,10 +770,7 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +799,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index ccd1ac0d013..d6e5bca5792 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,10 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
void report_extension_updates(ClusterInfo *cluster);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..ec2ff7acb21 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,14 +587,6 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
- {
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
- }
- else
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
--
2.50.1 (Apple Git-155)
[text/plain] v5-0003-psql-bump-minimum-supported-version-to-v10.patch (20.9K, ../../akKMWBN8nSjVohcs@nathan/4-v5-0003-psql-bump-minimum-supported-version-to-v10.patch)
download | inline diff:
From 83789792970535565491a46b88fd467ccd0d4eca Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:34:35 -0700
Subject: [PATCH v5 3/4] psql: bump minimum supported version to v10
---
doc/src/sgml/ref/psql-ref.sgml | 2 +-
src/bin/psql/command.c | 23 +---
src/bin/psql/describe.c | 244 +--------------------------------
3 files changed, 11 insertions(+), 258 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 7c05afd4719..56c2692e618 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
or an older major version. Backslash commands are particularly likely
to fail if the server is of a newer version than <application>psql</application>
itself. However, backslash commands of the <literal>\d</literal> family should
- work with servers of versions back to 9.2, though not necessarily with
+ work with servers of versions back to 10, though not necessarily with
servers newer than <application>psql</application> itself. The general
functionality of running SQL commands and displaying query results
should also work with servers of a newer major version, but this cannot
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 01b8f11aadd..44ef11d980e 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
+ * Views may have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
+ * separately. Materialized views may have
* arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
@@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index af3935b0078..ce99137c613 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
appendPQExpBuffer(&buf,
",\n CASE\n"
" WHEN p.proparallel = "
@@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
myopt.translate_columns = translate_columns;
myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT polname\n"
@@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname,
"FROM pg_catalog.pg_sequence\n"
"WHERE seqrelid = '%s';",
oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
appendPQExpBuffer(&buf,
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
@@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
if (pset.sversion >= 150000)
@@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Bypass RLS"));
@@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
" CASE c.collprovider "
"WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
@@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
"WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
"END AS \"%s\",\n",
gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6486,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6623,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
--
2.50.1 (Apple Git-155)
[text/plain] v5-0004-run-pgindent.patch (59.7K, ../../akKMWBN8nSjVohcs@nathan/5-v5-0004-run-pgindent.patch)
download | inline diff:
From 63644da2b316128a3b04b40875da2316ffc8b246 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Mon, 29 Jun 2026 09:56:17 -0500
Subject: [PATCH v5 4/4] run pgindent
---
src/bin/pg_dump/pg_dump.c | 457 ++++++++++++------------
src/bin/pg_dump/pg_dumpall.c | 30 +-
src/bin/pg_upgrade/check.c | 16 +-
src/bin/pg_upgrade/exec.c | 8 +-
src/bin/pg_upgrade/multixact_rewrite.c | 80 ++---
src/bin/pg_upgrade/pg_upgrade.c | 2 +-
src/bin/pg_upgrade/relfilenumber.c | 54 +--
src/bin/psql/command.c | 29 +-
src/bin/psql/describe.c | 461 ++++++++++++-------------
9 files changed, 567 insertions(+), 570 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 17ad8eeb838..33786f976e3 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1491,8 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1505,10 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1955,7 +1955,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -1989,9 +1989,9 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * We dump out any ACLs defined in pg_catalog, if
- * they are interesting (and not the original ACLs which were set at
- * initdb time, see pg_init_privs).
+ * We dump out any ACLs defined in pg_catalog, if they are interesting
+ * (and not the original ACLs which were set at initdb time, see
+ * pg_init_privs).
*/
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL;
}
@@ -3298,7 +3298,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- appendPQExpBufferStr(dbQry, "datminmxid, ");
+ appendPQExpBufferStr(dbQry, "datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3640,11 +3640,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- appendPQExpBufferStr(query, "pol.polpermissive, ");
+ appendPQExpBufferStr(query, "pol.polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -6635,9 +6635,9 @@ getAccessMethods(Archive *fout)
* Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
+ appendPQExpBufferStr(query,
+ "amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6829,35 +6829,35 @@ getAggregates(Archive *fout)
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6959,53 +6959,53 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, include functions in
- * pg_catalog if they have an ACL different from what's shown in
- * pg_init_privs (so we have to join to pg_init_privs; annoying).
+ * they are built-in. Also, include functions in pg_catalog if they have
+ * an ACL different from what's shown in pg_init_privs (so we have to join
+ * to pg_init_privs; annoying).
*/
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7254,31 +7254,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, ");
- appendPQExpBufferStr(query,
- "c.relreplident, ");
+ appendPQExpBufferStr(query,
+ "c.relreplident, ");
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
+ appendPQExpBufferStr(query,
+ "c.relrowsecurity, c.relforcerowsecurity, ");
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
+ appendPQExpBufferStr(query,
+ "c.relminmxid, tc.relminmxid AS tminmxid, ");
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
+ appendPQExpBufferStr(query,
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- appendPQExpBufferStr(query,
- "am.amname, ");
+ appendPQExpBufferStr(query,
+ "am.amname, ");
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
+ appendPQExpBufferStr(query,
+ "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7298,8 +7298,8 @@ getTables(Archive *fout, int *numTables)
/*
* Left join to pg_am to pick up the amname.
*/
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -7870,8 +7870,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
+ appendPQExpBufferStr(query,
+ "i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -9315,8 +9315,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10719,73 +10719,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
+ }
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11130,8 +11130,8 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For versions before 19, the redundant filter clause on s.tablename =
- * ANY(...) seems sufficient to convince the planner to use
+ * For versions before 19, the redundant filter clause on s.tablename
+ * = ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
@@ -13471,11 +13471,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ appendPQExpBufferStr(query,
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- appendPQExpBufferStr(query,
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -14965,9 +14965,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
+ appendPQExpBufferStr(query,
+ "collprovider, "
+ "collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15374,23 +15374,23 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
+ appendPQExpBufferStr(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -16850,30 +16850,30 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ /*
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
+ appendPQExpBufferStr(query,
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19167,7 +19167,7 @@ collectSequences(Archive *fout)
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19229,15 +19229,14 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * The sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- Assert(sequences);
+ Assert(sequences);
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index e68937c9934..afcd9a218d8 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -785,11 +785,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -843,16 +843,16 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 2", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT oid, rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, rolreplication, rolbypassrls, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 01b354e3c44..7629f8cab02 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1475,15 +1475,15 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 44355feea30..a1bdbf373e3 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,7 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- cluster->bin_version = v1 * 10000;
+ cluster->bin_version = v1 * 10000;
}
@@ -344,8 +344,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
- check_single_dir(pg_data, "pg_wal");
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -385,7 +385,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index c45b3183684..c7a1416494d 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -61,52 +61,52 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_nxtmxoff);
+ old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
+ old_cluster.controldata.chkpnt_nxtmulti,
+ old_cluster.controldata.chkpnt_nxtmxoff);
- for (MultiXactId multi = from_multi; multi != to_multi;)
- {
- MultiXactMember member;
- bool multixid_valid;
-
- /*
- * Read this multixid's members.
- *
- * Locking-only XIDs that may be part of multi-xids don't matter
- * after upgrade, as there can be no transactions running across
- * upgrade. So as a small optimization, we only read one member
- * from each multixid: the one updating one, or if there was no
- * update, arbitrarily the first locking xid.
- */
- multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
+ for (MultiXactId multi = from_multi; multi != to_multi;)
+ {
+ MultiXactMember member;
+ bool multixid_valid;
- /*
- * Write the new offset to pg_multixact/offsets.
- *
- * Even if this multixid is invalid, we still need to write its
- * offset if the *previous* multixid was valid. That's because
- * when reading a multixid, the number of members is calculated
- * from the difference between the two offsets.
- */
- RecordMultiXactOffset(offsets_writer, multi,
- (multixid_valid || prev_multixid_valid) ? next_offset : 0);
+ /*
+ * Read this multixid's members.
+ *
+ * Locking-only XIDs that may be part of multi-xids don't matter after
+ * upgrade, as there can be no transactions running across upgrade. So
+ * as a small optimization, we only read one member from each
+ * multixid: the one updating one, or if there was no update,
+ * arbitrarily the first locking xid.
+ */
+ multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
- /* Write the members */
- if (multixid_valid)
- {
- RecordMultiXactMembers(members_writer, next_offset, 1, &member);
- next_offset += 1;
- }
+ /*
+ * Write the new offset to pg_multixact/offsets.
+ *
+ * Even if this multixid is invalid, we still need to write its offset
+ * if the *previous* multixid was valid. That's because when reading
+ * a multixid, the number of members is calculated from the difference
+ * between the two offsets.
+ */
+ RecordMultiXactOffset(offsets_writer, multi,
+ (multixid_valid || prev_multixid_valid) ? next_offset : 0);
- /* Advance to next multixid, handling wraparound */
- multi++;
- if (multi < FirstMultiXactId)
- multi = FirstMultiXactId;
- prev_multixid_valid = multixid_valid;
+ /* Write the members */
+ if (multixid_valid)
+ {
+ RecordMultiXactMembers(members_writer, next_offset, 1, &member);
+ next_offset += 1;
}
- FreeOldMultiXactReader(old_reader);
+ /* Advance to next multixid, handling wraparound */
+ multi++;
+ if (multi < FirstMultiXactId)
+ multi = FirstMultiXactId;
+ prev_multixid_valid = multixid_valid;
+ }
+
+ FreeOldMultiXactReader(old_reader);
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5d7920c1b1..d8e1b680f5a 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -833,7 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index ec2ff7acb21..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -587,32 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix)
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
+ }
}
}
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 44ef11d980e..c90bf8bbde2 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6278,23 +6278,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index ce99137c613..ac0c55e7aa5 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -387,19 +387,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -599,8 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1086,38 +1086,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1675,27 +1675,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -1913,7 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2326,7 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
+ appendPQExpBufferStr(&buf, "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2431,7 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- appendPQExpBufferStr(&buf, ", i.indisreplident");
+ appendPQExpBufferStr(&buf, ", i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2682,81 +2682,80 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBufferStr(&buf, "SELECT pol.polname,");
+ appendPQExpBufferStr(&buf,
+ " pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3025,115 +3024,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT pg_catalog.string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT pg_catalog.string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Included in publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Included in publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3805,7 +3804,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
+ appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -3860,8 +3859,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -5155,14 +5154,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-06-30 03:36 Fujii Masao <masao.fujii@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Fujii Masao @ 2026-06-30 03:36 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
On Tue, Jun 30, 2026 at 12:16 AM Nathan Bossart
<nathandbossart@gmail.com> wrote:
>
> rebased
Thanks for updating the patches!
Regarding 0001 patch:
Wouldn't it make sense to document the minimum supported server
version also in the pg_dumpall docs?
/*
* We allow the server to be back to 9.2, and up to any minor release of
* our own major version. (See also version check in pg_dump.c.)
*/
if (my_version != server_version_temp
&& (server_version_temp < 90200 ||
(server_version_temp / 100) > (my_version / 100)))
Shouldn't this be updated as well?
Regarding 0002 patch:
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 10)
Shouldn't this be "< 1000" instead of "< 10"?
According to the following git grep results, there still seem to be
several code paths for pre-v10 support. Should those also be updated or
removed?
$ git grep -E "GET_MAJOR_VERSION.* 9"
src/bin/pg_upgrade/controldata.c: if
(GET_MAJOR_VERSION(cluster->bin_version) <= 906)
src/bin/pg_upgrade/controldata.c: if
(GET_MAJOR_VERSION(cluster->major_version) <= 902)
src/bin/pg_upgrade/controldata.c: else if
(GET_MAJOR_VERSION(cluster->major_version) >= 906)
src/bin/pg_upgrade/controldata.c: if
(GET_MAJOR_VERSION(cluster->major_version) <= 902)
src/bin/pg_upgrade/server.c:
(GET_MAJOR_VERSION(cluster->major_version) <= 902) ?
# --swap can't be used to upgrade from versions older than 10, so just skip
# the test if the old cluster version is too old.
if ($old->pg_version < 10 && $mode eq "--swap")
In pg_upgrade/t/006_transfer_modes.pl, shouldn't this simply be
"if ($old->pg_version < 10)" so that the test is skipped whenever
the old cluster is pre-v10?
Regarding 0003 patch:
/*
* These object types were introduced later than our support cutoff of
* server version 9.2. We use the VersionedQuery infrastructure so that
* we don't send certain-to-fail queries to older servers.
*/
In psql/tab-complete.in.c, shouldn't this comment be updated as well?
Overall, the following git grep results seem to suggest that there are several
comments referring to pre-v10 support that may also need updating:
$ git grep " 9\.[0-6]" | grep -E "pg_dump|pg_upgrade|psql" | grep -v "\.po:"
Regards,
--
Fujii Masao
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-06-30 20:18 Nathan Bossart <nathandbossart@gmail.com>
parent: Fujii Masao <masao.fujii@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-06-30 20:18 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
On Tue, Jun 30, 2026 at 12:36:39PM +0900, Fujii Masao wrote:
> Thanks for updating the patches!
Appreciate the review.
> Regarding 0001 patch:
>
> Wouldn't it make sense to document the minimum supported server
> version also in the pg_dumpall docs?
Yes, I think so. However, since that's an additive change and not directly
related to $subject, I'd like to tackle it separately. Folks might have
preferences on the wording.
> /*
> * We allow the server to be back to 9.2, and up to any minor release of
> * our own major version. (See also version check in pg_dump.c.)
> */
> if (my_version != server_version_temp
> && (server_version_temp < 90200 ||
> (server_version_temp / 100) > (my_version / 100)))
>
> Shouldn't this be updated as well?
Oops, yes.
> Regarding 0002 patch:
>
> - if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
> + if (GET_MAJOR_VERSION(old_cluster.major_version) < 10)
>
> Shouldn't this be "< 1000" instead of "< 10"?
Yes.
> According to the following git grep results, there still seem to be
> several code paths for pre-v10 support. Should those also be updated or
> removed?
>
> $ git grep -E "GET_MAJOR_VERSION.* 9"
> src/bin/pg_upgrade/controldata.c: if
> (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
> src/bin/pg_upgrade/controldata.c: if
> (GET_MAJOR_VERSION(cluster->major_version) <= 902)
> src/bin/pg_upgrade/controldata.c: else if
> (GET_MAJOR_VERSION(cluster->major_version) >= 906)
> src/bin/pg_upgrade/controldata.c: if
> (GET_MAJOR_VERSION(cluster->major_version) <= 902)
> src/bin/pg_upgrade/server.c:
> (GET_MAJOR_VERSION(cluster->major_version) <= 902) ?
Fixed. I thought I had handled these, but apparently they got lost
somewhere.
> # --swap can't be used to upgrade from versions older than 10, so just skip
> # the test if the old cluster version is too old.
> if ($old->pg_version < 10 && $mode eq "--swap")
>
> In pg_upgrade/t/006_transfer_modes.pl, shouldn't this simply be
> "if ($old->pg_version < 10)" so that the test is skipped whenever
> the old cluster is pre-v10?
I think we can remove it entirely. We don't block for <v9.2 today, so I
see no need to make it robust against invalid test setups.
> Regarding 0003 patch:
>
> /*
> * These object types were introduced later than our support cutoff of
> * server version 9.2. We use the VersionedQuery infrastructure so that
> * we don't send certain-to-fail queries to older servers.
> */
>
> In psql/tab-complete.in.c, shouldn't this comment be updated as well?
This also got lost along the way. Fixed.
> Overall, the following git grep results seem to suggest that there are several
> comments referring to pre-v10 support that may also need updating:
>
> $ git grep " 9\.[0-6]" | grep -E "pg_dump|pg_upgrade|psql" | grep -v "\.po:"
I didn't see anything else that I thought obviously needed to be changed.
Please let me know if you feel otherwise.
--
nathan
From 39e79ecc0aaf2c70159f34c94053269f874d23e6 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 10:15:38 -0700
Subject: [PATCH v6 1/4] pg_dump/pg_dumpall: bump minimum supported version to
v10
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/runtime.sgml | 2 +-
src/bin/pg_dump/connectdb.c | 4 +-
src/bin/pg_dump/pg_dump.c | 334 ++--------------------------------
src/bin/pg_dump/pg_dumpall.c | 28 ---
5 files changed, 23 insertions(+), 359 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 0e0d53926af..774be23b4f9 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1717,7 +1705,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index dfa292c2c3a..d9984910cc4 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1776,7 +1776,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
version of
<productname>PostgreSQL</productname>, to take advantage of enhancements
that might have been made in these programs. Current releases of the
- dump programs can read data from any server version back to 9.2.
+ dump programs can read data from any server version back to 10.
</para>
<para>
diff --git a/src/bin/pg_dump/connectdb.c b/src/bin/pg_dump/connectdb.c
index f3ce8b1cfb1..d145308dccf 100644
--- a/src/bin/pg_dump/connectdb.c
+++ b/src/bin/pg_dump/connectdb.c
@@ -212,11 +212,11 @@ ConnectDatabase(const char *dbname, const char *connection_string,
my_version = PG_VERSION_NUM;
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dump.c.)
*/
if (my_version != server_version_temp
- && (server_version_temp < 90200 ||
+ && (server_version_temp < 100000 ||
(server_version_temp / 100) > (my_version / 100)))
{
pg_log_error("aborting because of server version mismatch");
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index c56437d6057..65bd15ebfd2 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,9 +1491,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security = on");
else
ExecuteSqlStatement(AH, "SET row_security = off");
- }
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1942,13 +1933,11 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
addObjectDependency(dobj, ext->dobj.dumpId);
/*
- * In 9.6 and above, mark the member object to have any non-initial ACLs
+ * Mark the member object to have any non-initial ACLs
* dumped. (Any initial ACLs will be removed later, using data from
* pg_init_privs, so that we'll dump only the delta from the extension's
* initial setup.)
*
- * Prior to 9.6, we do not include any extension member components.
- *
* In binary upgrades, we still dump all components of the members
* individually, since the idea is to exactly reproduce the database
* contents rather than replace the extension contents with something
@@ -1964,12 +1953,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
return true;
}
@@ -2000,11 +1984,10 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
+ * We dump out any ACLs defined in pg_catalog, if
* they are interesting (and not the original ACLs which were set at
* initdb time, see pg_init_privs).
*/
@@ -2213,8 +2196,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2213,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3098,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3325,10 +3296,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3638,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid IN (%u, %u, %u, %u);\n",
LargeObjectRelationId, LargeObjectLOidPNIndexId,
LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4205,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4316,10 +4274,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -4534,7 +4489,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4852,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5142,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,24 +6630,12 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
/*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
+ * Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"amtype, "
"amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6878,15 +6821,12 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
: "p.proisagg");
@@ -6916,29 +6856,6 @@ getAggregates(Archive *fout)
"refclassid = 'pg_extension'::regclass AND "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7021,6 +6938,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7039,14 +6957,10 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, in 9.6 and up, include functions in
+ * they are built-in. Also, include functions in
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
: "NOT p.proisagg");
@@ -7090,46 +7004,6 @@ getFuncs(Archive *fout)
appendPQExpBufferStr(query,
"\n OR p.proacl IS DISTINCT FROM pip.initprivs");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7378,64 +7252,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
"CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
"WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,9 +7294,8 @@ getTables(Archive *fout, int *numTables)
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
/*
- * In 9.6 and up, left join to pg_am to pick up the amname.
+ * Left join to pg_am to pick up the amname.
*/
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
@@ -8028,12 +7868,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8318,10 +8154,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8988,10 +8820,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9258,10 +9086,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9489,12 +9313,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(q,
"a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10897,8 +10717,6 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
printfPQExpBuffer(query,
"SELECT objoid, classoid, objsubid, privtype, initprivs "
"FROM pg_init_privs");
@@ -10966,7 +10784,6 @@ getAdditionalACLs(Archive *fout)
}
}
PQclear(res);
- }
destroyPQExpBuffer(query);
}
@@ -11141,15 +10958,6 @@ fetchAttributeStats(Archive *fout)
static bool restarted;
int max_rels = MAX_ATTR_STATS_RELS;
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
-
/* If we're just starting, set our TOC pointer. */
if (!te)
te = AH->toc->next;
@@ -11320,16 +11128,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For versions before 19, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11337,7 +11140,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11345,12 +11148,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13672,19 +13469,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15174,14 +14963,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"collprovider, "
"collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15588,7 +15372,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"aggkind,\n"
"aggmtransfn,\n"
@@ -15600,31 +15383,12 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"aggtransspace,\n"
"aggmtransspace,\n"
"aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"aggcombinefn,\n"
"aggserialfn,\n"
"aggdeserialfn,\n"
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17084,8 +16848,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- if (fout->remoteVersion >= 90600)
- {
/*
* In principle we should call acldefault('c', relowner) to
* get the default ACL for a column. However, we don't
@@ -17110,17 +16872,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
"ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
ExecuteSqlStatement(fout, query->data);
@@ -19410,16 +19161,10 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
+ if (fout->remoteVersion < 180000 ||
(!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
@@ -19477,59 +19222,20 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
+ * The sequence information is gathered in a sorted
* table before any calls to dumpSequence(). See collectSequences() for
* more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
Assert(sequences);
key.oid = tbinfo->dobj.catId.oid;
seq = bsearch(&key, sequences, nsequences,
sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
-
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19708,8 +19414,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index b9653f0aefe..e68937c9934 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -785,17 +785,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT rolname "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 1", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -849,7 +843,6 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT oid, rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, "
@@ -860,27 +853,6 @@ dumpRoles(PGconn *conn)
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 2", role_catalog);
- else if (server_version >= 90500)
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, "
- "false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
--
2.50.1 (Apple Git-155)
From 397131270606dec009ecd76b787b35b8a83c5d11 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:20:18 -0700
Subject: [PATCH v6 2/4] pg_upgrade: bump minimum supported version to v10
---
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_upgrade/check.c | 157 +-------------------
src/bin/pg_upgrade/controldata.c | 98 +-----------
src/bin/pg_upgrade/exec.c | 23 ---
src/bin/pg_upgrade/file.c | 164 ---------------------
src/bin/pg_upgrade/multixact_rewrite.c | 11 +-
src/bin/pg_upgrade/pg_upgrade.c | 56 +------
src/bin/pg_upgrade/pg_upgrade.h | 29 ----
src/bin/pg_upgrade/relfilenumber.c | 37 +----
src/bin/pg_upgrade/server.c | 3 +-
src/bin/pg_upgrade/t/006_transfer_modes.pl | 20 ---
src/bin/pg_upgrade/version.c | 127 ----------------
12 files changed, 26 insertions(+), 701 deletions(-)
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index cc44983a9a8..e4e8c02e6d6 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index f8f31382835..786c1474829 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1569,12 +1475,10 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
appendPQExpBufferStr(&old_polymorphics,
", 'array_remove(anyarray,anyelement)'"
", 'array_replace(anyarray,anyelement,anyelement)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
appendPQExpBufferStr(&old_polymorphics,
", 'array_position(anyarray,anyelement)'"
", 'array_position(anyarray,anyelement,integer)'"
@@ -1870,63 +1774,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index cffcd4b0eba..8f81c9e9582 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -42,9 +42,6 @@ get_control_data(ClusterInfo *cluster)
char bufin[MAX_STRING];
FILE *output;
char *p;
- bool got_tli = false;
- bool got_log_id = false;
- bool got_log_seg = false;
bool got_xid = false;
bool got_oid = false;
bool got_multi = false;
@@ -75,10 +72,6 @@ get_control_data(ClusterInfo *cluster)
char *language = NULL;
char *lc_all = NULL;
char *lc_messages = NULL;
- uint32 tli = 0;
- uint32 logid = 0;
- uint32 segno = 0;
- char *resetwal_bin;
int rc;
bool live_check = (cluster == &old_cluster && user_opts.live_check);
@@ -189,27 +182,15 @@ get_control_data(ClusterInfo *cluster)
}
}
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- resetwal_bin = "pg_resetxlog\" -n";
- else
- resetwal_bin = "pg_resetwal\" -n";
snprintf(cmd, sizeof(cmd), "\"%s/%s \"%s\"",
cluster->bindir,
- live_check ? "pg_controldata\"" : resetwal_bin,
+ live_check ? "pg_controldata\"" : "pg_resetwal\" -n",
cluster->pgdata);
fflush(NULL);
if ((output = popen(cmd, "r")) == NULL)
pg_fatal("could not get control data using %s: %m", cmd);
- /* Only in <= 9.2 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
- {
- cluster->controldata.data_checksum_version = PG_DATA_CHECKSUM_OFF;
- got_data_checksum_version = true;
- }
-
/* we have the result of cmd in "output". so parse it line by line now */
while (fgets(bufin, sizeof(bufin), output))
{
@@ -237,39 +218,6 @@ get_control_data(ClusterInfo *cluster)
p++; /* remove ':' char */
cluster->controldata.cat_ver = str2uint(p);
}
- else if ((p = strstr(bufin, "Latest checkpoint's TimeLineID:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- tli = str2uint(p);
- got_tli = true;
- }
- else if ((p = strstr(bufin, "First log file ID after reset:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- logid = str2uint(p);
- got_log_id = true;
- }
- else if ((p = strstr(bufin, "First log file segment after reset:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- segno = str2uint(p);
- got_log_seg = true;
- }
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
p = strchr(p, ':');
@@ -280,23 +228,12 @@ get_control_data(ClusterInfo *cluster)
p++; /* remove ':' char */
cluster->controldata.chkpnt_nxtepoch = str2uint(p);
- /*
- * Delimiter changed from '/' to ':' in 9.6. We don't test for
- * the catalog version of the change because the catalog version
- * is pulled from pg_controldata too, and it isn't worth adding an
- * order dependency for this --- we just check the string.
- */
- if (strchr(p, '/') != NULL)
- p = strchr(p, '/');
- else if (GET_MAJOR_VERSION(cluster->major_version) >= 906)
p = strchr(p, ':');
- else
- p = NULL;
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
- p++; /* remove '/' or ':' char */
+ p++; /* remove ':' char */
cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
@@ -568,22 +505,6 @@ get_control_data(ClusterInfo *cluster)
pg_free(lc_all);
pg_free(lc_messages);
- /*
- * Before 9.3, pg_resetwal reported the xlogid and segno of the first log
- * file after reset as separate lines. Starting with 9.3, it reports the
- * WAL file name. If the old cluster is older than 9.3, we construct the
- * WAL file name from the xlogid and segno.
- */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
- {
- if (got_tli && got_log_id && got_log_seg)
- {
- snprintf(cluster->controldata.nextxlogfile, 25, "%08X%08X%08X",
- tli, logid, segno);
- got_nextxlogfile = true;
- }
- }
-
/*
* Pre-v18 database clusters don't have the default char signedness
* information. We use the char signedness of the platform where
@@ -602,14 +523,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +549,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +588,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
@@ -724,8 +641,7 @@ check_control_data(ControlData *oldctrl,
if (oldctrl->toast == 0 || oldctrl->toast != newctrl->toast)
pg_fatal("old and new pg_controldata maximum TOAST chunk sizes are invalid or do not match");
- /* large_object added in 9.5, so it might not exist in the old cluster */
- if (oldctrl->large_object != 0 &&
+ if (oldctrl->large_object == 0 ||
oldctrl->large_object != newctrl->large_object)
pg_fatal("old and new pg_controldata large-object chunk sizes are invalid or do not match");
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 563b4a6b5fa..44355feea30 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,16 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- if (v1 < 10)
- {
- /* old style, e.g. 9.6.1 */
- cluster->bin_version = v1 * 10000 + v2 * 100;
- }
- else
- {
- /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
- }
}
@@ -353,17 +344,7 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
check_single_dir(pg_data, "pg_xact");
}
@@ -404,10 +385,6 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index 823984ec8f3..c45b3183684 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -25,10 +25,7 @@ static void RecordMultiXactMembers(SlruSegState *members_writer,
* 32-bit offsets to the current format.
*
* Multixids in the range [from_multi, to_multi) are read from the old
- * cluster, and written in the new format. An important edge case is that if
- * from_multi == to_multi, this initializes the new pg_multixact files in the
- * new format without trying to open any old files. (We rely on that when
- * upgrading from PostgreSQL version 9.2 or below.)
+ * cluster, and written in the new format.
*
* Returns the new nextOffset value; the caller should set it in the new
* control file. The new members always start from offset 1, regardless of
@@ -42,6 +39,7 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
SlruSegState *members_writer;
char dir[MAXPGPATH] = {0};
bool prev_multixid_valid = false;
+ OldMultiXactReader *old_reader;
/*
* The range of valid multi XIDs is unchanged by the conversion (they are
@@ -63,10 +61,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- if (to_multi != from_multi)
- {
- OldMultiXactReader *old_reader;
-
old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
old_cluster.controldata.chkpnt_nxtmulti,
old_cluster.controldata.chkpnt_nxtmxoff);
@@ -113,7 +107,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
}
FreeOldMultiXactReader(old_reader);
- }
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..c6af9035665 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -64,7 +64,7 @@ static void prepare_new_cluster(void);
static void prepare_new_globals(void);
static void create_new_objects(void);
static void copy_xact_xlog_xid(void);
-static void set_frozenxids(bool minmxid_only);
+static void set_frozenxids(void);
static void make_outputdirs(char *pgdata);
static void setup(char *argv0);
static void create_logical_replication_slots(void);
@@ -576,7 +576,7 @@ prepare_new_globals(void)
/*
* Before we restore anything, set frozenxids of initdb-created tables.
*/
- set_frozenxids(false);
+ set_frozenxids();
/*
* Now restore global objects (roles and tablespaces).
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -777,10 +770,7 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +799,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
@@ -906,26 +877,18 @@ copy_xact_xlog_xid(void)
/*
* set_frozenxids()
*
- * This is called on the new cluster before we restore anything, with
- * minmxid_only = false. Its purpose is to ensure that all initdb-created
+ * This is called on the new cluster before we restore anything.
+ * Its purpose is to ensure that all initdb-created
* vacuumable tables have relfrozenxid/relminmxid matching the old cluster's
* xid/mxid counters. We also initialize the datfrozenxid/datminmxid of the
* built-in databases to match.
*
* As we create user tables later, their relfrozenxid/relminmxid fields will
* be restored properly by the binary-upgrade restore script. Likewise for
- * user-database datfrozenxid/datminmxid. However, if we're upgrading from a
- * pre-9.3 database, which does not store per-table or per-DB minmxid, then
- * the relminmxid/datminmxid values filled in by the restore script will just
- * be zeroes.
- *
- * Hence, with a pre-9.3 source database, a second call occurs after
- * everything is restored, with minmxid_only = true. This pass will
- * initialize all tables and databases, both those made by initdb and user
- * objects, with the desired minmxid value. frozenxid values are left alone.
+ * user-database datfrozenxid/datminmxid.
*/
static void
-set_frozenxids(bool minmxid_only)
+set_frozenxids(void)
{
int dbnum;
PGconn *conn,
@@ -935,14 +898,10 @@ set_frozenxids(bool minmxid_only)
int i_datname;
int i_datallowconn;
- if (!minmxid_only)
prep_status("Setting frozenxid and minmxid counters in new cluster");
- else
- prep_status("Setting minmxid counter in new cluster");
conn_template1 = connectToServer(&new_cluster, "template1");
- if (!minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
@@ -983,7 +942,6 @@ set_frozenxids(bool minmxid_only)
conn = connectToServer(&new_cluster, datname);
- if (!minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index ccd1ac0d013..d6e5bca5792 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,10 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
void report_extension_updates(ClusterInfo *cluster);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..ec2ff7acb21 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,14 +587,6 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
- {
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
- }
- else
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c
index 5d81e4e95b8..7da9dffe585 100644
--- a/src/bin/pg_upgrade/server.c
+++ b/src/bin/pg_upgrade/server.c
@@ -186,8 +186,7 @@ start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error)
snprintf(socket_string + strlen(socket_string),
sizeof(socket_string) - strlen(socket_string),
" -c %s='%s'",
- (GET_MAJOR_VERSION(cluster->major_version) <= 902) ?
- "unix_socket_directory" : "unix_socket_directories",
+ "unix_socket_directories",
cluster->sockdir);
#endif
diff --git a/src/bin/pg_upgrade/t/006_transfer_modes.pl b/src/bin/pg_upgrade/t/006_transfer_modes.pl
index 6b7ab9f29a2..9efa5dc863c 100644
--- a/src/bin/pg_upgrade/t/006_transfer_modes.pl
+++ b/src/bin/pg_upgrade/t/006_transfer_modes.pl
@@ -17,15 +17,6 @@ sub test_mode
PostgreSQL::Test::Cluster->new('old', install_path => $ENV{oldinstall});
my $new = PostgreSQL::Test::Cluster->new('new');
- # --swap can't be used to upgrade from versions older than 10, so just skip
- # the test if the old cluster version is too old.
- if ($old->pg_version < 10 && $mode eq "--swap")
- {
- $old->clean_node();
- $new->clean_node();
- return;
- }
-
if (defined($ENV{oldinstall}))
{
# Checksums are now enabled by default, but weren't before 18, so pass
@@ -38,14 +29,10 @@ sub test_mode
}
$new->init();
- # allow_in_place_tablespaces is available as far back as v10.
- if ($old->pg_version >= 10)
- {
$new->append_conf('postgresql.conf',
"allow_in_place_tablespaces = true");
$old->append_conf('postgresql.conf',
"allow_in_place_tablespaces = true");
- }
# We can only test security labels if both the old and new installations
# have dummy_seclabel.
@@ -89,9 +76,6 @@ sub test_mode
"CREATE TABLE test4 AS SELECT generate_series(400, 502)");
}
- # If the old cluster is >= v10, we can test in-place tablespaces.
- if ($old->pg_version >= 10)
- {
$old->safe_psql('postgres',
"CREATE TABLESPACE inplc_tblspc LOCATION ''");
$old->safe_psql('postgres',
@@ -101,7 +85,6 @@ sub test_mode
);
$old->safe_psql('testdb3',
"CREATE TABLE test6 AS SELECT generate_series(607, 711)");
- }
# While we are here, test handling of large objects.
$old->safe_psql(
@@ -169,15 +152,12 @@ sub test_mode
}
# Tests for in-place tablespaces.
- if ($old->pg_version >= 10)
- {
$result =
$new->safe_psql('postgres', "SELECT COUNT(*) FROM test5");
is($result, '104', "test5 data after pg_upgrade $mode");
$result =
$new->safe_psql('testdb3', "SELECT COUNT(*) FROM test6");
is($result, '105', "test6 data after pg_upgrade $mode");
- }
# Tests for large objects
$result = $new->safe_psql('postgres', "SELECT lo_get(4532)");
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
--
2.50.1 (Apple Git-155)
From 680cc0d8d67c2151e870d81bc78337746249b7a8 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:34:35 -0700
Subject: [PATCH v6 3/4] psql: bump minimum supported version to v10
---
doc/src/sgml/ref/psql-ref.sgml | 2 +-
src/bin/psql/command.c | 23 +---
src/bin/psql/describe.c | 244 +--------------------------------
src/bin/psql/tab-complete.in.c | 46 +++----
4 files changed, 27 insertions(+), 288 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 7c05afd4719..56c2692e618 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
or an older major version. Backslash commands are particularly likely
to fail if the server is of a newer version than <application>psql</application>
itself. However, backslash commands of the <literal>\d</literal> family should
- work with servers of versions back to 9.2, though not necessarily with
+ work with servers of versions back to 10, though not necessarily with
servers newer than <application>psql</application> itself. The general
functionality of running SQL commands and displaying query results
should also work with servers of a newer major version, but this cannot
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 01b8f11aadd..44ef11d980e 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
+ * Views may have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
+ * separately. Materialized views may have
* arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
@@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index af3935b0078..ce99137c613 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
appendPQExpBuffer(&buf,
",\n CASE\n"
" WHEN p.proparallel = "
@@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
myopt.translate_columns = translate_columns;
myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT polname\n"
@@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname,
"FROM pg_catalog.pg_sequence\n"
"WHERE seqrelid = '%s';",
oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
appendPQExpBuffer(&buf,
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
@@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
if (pset.sversion >= 150000)
@@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Bypass RLS"));
@@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
" CASE c.collprovider "
"WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
@@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
"WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
"END AS \"%s\",\n",
gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6486,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6623,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index 46b9add0604..f4d842966bf 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC"
" FROM pg_catalog.pg_timezone_names() "\
" WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')"
+#define Query_for_list_of_publications \
+"SELECT pubname "\
+" FROM pg_catalog.pg_publication "\
+" WHERE pubname LIKE '%s'"
+
+#define Query_for_list_of_subscriptions \
+"SELECT s.subname "\
+" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\
+" WHERE s.subname LIKE '%s' "\
+" AND d.datname = pg_catalog.current_database() "\
+" AND s.subdbid = d.oid"
+
/* Privilege options shared between GRANT and REVOKE */
#define Privilege_options_of_grant_and_revoke \
"SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \
@@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \
#define Copy_to_options \
Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY"
-/*
- * These object types were introduced later than our support cutoff of
- * server version 9.2. We use the VersionedQuery infrastructure so that
- * we don't send certain-to-fail queries to older servers.
- */
-
-static const VersionedQuery Query_for_list_of_publications[] = {
- {100000,
- " SELECT pubname "
- " FROM pg_catalog.pg_publication "
- " WHERE pubname LIKE '%s'"
- },
- {0, NULL}
-};
-
-static const VersionedQuery Query_for_list_of_subscriptions[] = {
- {100000,
- " SELECT s.subname "
- " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d "
- " WHERE s.subname LIKE '%s' "
- " AND d.datname = pg_catalog.current_database() "
- " AND s.subdbid = d.oid"
- },
- {0, NULL}
-};
-
/* Known command-starting keywords. */
static const char *const sql_commands[] = {
"ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER",
@@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = {
{"POLICY", NULL, NULL, NULL},
{"PROCEDURE", NULL, NULL, Query_for_list_of_procedures},
{"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs},
- {"PUBLICATION", NULL, Query_for_list_of_publications},
+ {"PUBLICATION", Query_for_list_of_publications},
{"ROLE", Query_for_list_of_roles},
{"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE},
{"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"},
@@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = {
{"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences},
{"SERVER", Query_for_list_of_servers},
{"STATISTICS", NULL, NULL, &Query_for_list_of_statistics},
- {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions},
+ {"SUBSCRIPTION", Query_for_list_of_subscriptions},
{"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
{"TABLE", NULL, NULL, &Query_for_list_of_tables},
{"TABLESPACE", Query_for_list_of_tablespaces},
@@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id,
else if (TailMatchesCS("\\dP*"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations);
else if (TailMatchesCS("\\dRp*"))
- COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications);
+ COMPLETE_WITH_QUERY(Query_for_list_of_publications);
else if (TailMatchesCS("\\dRs*"))
- COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions);
+ COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions);
else if (TailMatchesCS("\\ds*"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences);
else if (TailMatchesCS("\\dt*"))
--
2.50.1 (Apple Git-155)
From 0c9782c349a9999649977a1cee041ca1c3d561ee Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Tue, 30 Jun 2026 13:24:59 -0500
Subject: [PATCH v6 4/4] run pgindent and pgperltidy
---
src/bin/pg_dump/pg_dump.c | 464 ++++++++++-----------
src/bin/pg_dump/pg_dumpall.c | 30 +-
src/bin/pg_upgrade/check.c | 16 +-
src/bin/pg_upgrade/controldata.c | 2 +-
src/bin/pg_upgrade/exec.c | 8 +-
src/bin/pg_upgrade/multixact_rewrite.c | 80 ++--
src/bin/pg_upgrade/pg_upgrade.c | 34 +-
src/bin/pg_upgrade/relfilenumber.c | 54 +--
src/bin/pg_upgrade/t/006_transfer_modes.pl | 33 +-
src/bin/psql/command.c | 29 +-
src/bin/psql/describe.c | 461 ++++++++++----------
11 files changed, 601 insertions(+), 610 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 65bd15ebfd2..5673268b467 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1491,8 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1505,10 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1933,10 +1933,9 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
addObjectDependency(dobj, ext->dobj.dumpId);
/*
- * Mark the member object to have any non-initial ACLs
- * dumped. (Any initial ACLs will be removed later, using data from
- * pg_init_privs, so that we'll dump only the delta from the extension's
- * initial setup.)
+ * Mark the member object to have any non-initial ACLs dumped. (Any
+ * initial ACLs will be removed later, using data from pg_init_privs, so
+ * that we'll dump only the delta from the extension's initial setup.)
*
* In binary upgrades, we still dump all components of the members
* individually, since the idea is to exactly reproduce the database
@@ -1953,7 +1952,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -1987,9 +1986,9 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * We dump out any ACLs defined in pg_catalog, if
- * they are interesting (and not the original ACLs which were set at
- * initdb time, see pg_init_privs).
+ * We dump out any ACLs defined in pg_catalog, if they are interesting
+ * (and not the original ACLs which were set at initdb time, see
+ * pg_init_privs).
*/
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL;
}
@@ -3296,7 +3295,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- appendPQExpBufferStr(dbQry, "datminmxid, ");
+ appendPQExpBufferStr(dbQry, "datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3638,11 +3637,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4274,7 +4273,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- appendPQExpBufferStr(query, "pol.polpermissive, ");
+ appendPQExpBufferStr(query, "pol.polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -6633,9 +6632,9 @@ getAccessMethods(Archive *fout)
* Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
+ appendPQExpBufferStr(query,
+ "amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6827,35 +6826,35 @@ getAggregates(Archive *fout)
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6957,53 +6956,53 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, include functions in
- * pg_catalog if they have an ACL different from what's shown in
- * pg_init_privs (so we have to join to pg_init_privs; annoying).
+ * they are built-in. Also, include functions in pg_catalog if they have
+ * an ACL different from what's shown in pg_init_privs (so we have to join
+ * to pg_init_privs; annoying).
*/
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7252,31 +7251,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, ");
- appendPQExpBufferStr(query,
- "c.relreplident, ");
+ appendPQExpBufferStr(query,
+ "c.relreplident, ");
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
+ appendPQExpBufferStr(query,
+ "c.relrowsecurity, c.relforcerowsecurity, ");
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
+ appendPQExpBufferStr(query,
+ "c.relminmxid, tc.relminmxid AS tminmxid, ");
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
+ appendPQExpBufferStr(query,
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- appendPQExpBufferStr(query,
- "am.amname, ");
+ appendPQExpBufferStr(query,
+ "am.amname, ");
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
+ appendPQExpBufferStr(query,
+ "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7296,8 +7295,8 @@ getTables(Archive *fout, int *numTables)
/*
* Left join to pg_am to pick up the amname.
*/
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -7868,8 +7867,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
+ appendPQExpBufferStr(query,
+ "i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -9313,8 +9312,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10717,73 +10716,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
+ }
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11128,8 +11127,8 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For versions before 19, the redundant filter clause on s.tablename =
- * ANY(...) seems sufficient to convince the planner to use
+ * For versions before 19, the redundant filter clause on s.tablename
+ * = ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
@@ -13469,11 +13468,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ appendPQExpBufferStr(query,
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- appendPQExpBufferStr(query,
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -14963,9 +14962,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
+ appendPQExpBufferStr(query,
+ "collprovider, "
+ "collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15372,23 +15371,23 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
+ appendPQExpBufferStr(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -16848,30 +16847,30 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ /*
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
+ appendPQExpBufferStr(query,
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19165,7 +19164,7 @@ collectSequences(Archive *fout)
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19227,15 +19226,14 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * The sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- Assert(sequences);
+ Assert(sequences);
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index e68937c9934..afcd9a218d8 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -785,11 +785,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -843,16 +843,16 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 2", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT oid, rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, rolreplication, rolbypassrls, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 786c1474829..f725f5ee3e2 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1475,15 +1475,15 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 8f81c9e9582..02ea02df60f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -228,7 +228,7 @@ get_control_data(ClusterInfo *cluster)
p++; /* remove ':' char */
cluster->controldata.chkpnt_nxtepoch = str2uint(p);
- p = strchr(p, ':');
+ p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 44355feea30..a1bdbf373e3 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,7 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- cluster->bin_version = v1 * 10000;
+ cluster->bin_version = v1 * 10000;
}
@@ -344,8 +344,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
- check_single_dir(pg_data, "pg_wal");
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -385,7 +385,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index c45b3183684..c7a1416494d 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -61,52 +61,52 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_nxtmxoff);
+ old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
+ old_cluster.controldata.chkpnt_nxtmulti,
+ old_cluster.controldata.chkpnt_nxtmxoff);
- for (MultiXactId multi = from_multi; multi != to_multi;)
- {
- MultiXactMember member;
- bool multixid_valid;
-
- /*
- * Read this multixid's members.
- *
- * Locking-only XIDs that may be part of multi-xids don't matter
- * after upgrade, as there can be no transactions running across
- * upgrade. So as a small optimization, we only read one member
- * from each multixid: the one updating one, or if there was no
- * update, arbitrarily the first locking xid.
- */
- multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
+ for (MultiXactId multi = from_multi; multi != to_multi;)
+ {
+ MultiXactMember member;
+ bool multixid_valid;
- /*
- * Write the new offset to pg_multixact/offsets.
- *
- * Even if this multixid is invalid, we still need to write its
- * offset if the *previous* multixid was valid. That's because
- * when reading a multixid, the number of members is calculated
- * from the difference between the two offsets.
- */
- RecordMultiXactOffset(offsets_writer, multi,
- (multixid_valid || prev_multixid_valid) ? next_offset : 0);
+ /*
+ * Read this multixid's members.
+ *
+ * Locking-only XIDs that may be part of multi-xids don't matter after
+ * upgrade, as there can be no transactions running across upgrade. So
+ * as a small optimization, we only read one member from each
+ * multixid: the one updating one, or if there was no update,
+ * arbitrarily the first locking xid.
+ */
+ multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
- /* Write the members */
- if (multixid_valid)
- {
- RecordMultiXactMembers(members_writer, next_offset, 1, &member);
- next_offset += 1;
- }
+ /*
+ * Write the new offset to pg_multixact/offsets.
+ *
+ * Even if this multixid is invalid, we still need to write its offset
+ * if the *previous* multixid was valid. That's because when reading
+ * a multixid, the number of members is calculated from the difference
+ * between the two offsets.
+ */
+ RecordMultiXactOffset(offsets_writer, multi,
+ (multixid_valid || prev_multixid_valid) ? next_offset : 0);
- /* Advance to next multixid, handling wraparound */
- multi++;
- if (multi < FirstMultiXactId)
- multi = FirstMultiXactId;
- prev_multixid_valid = multixid_valid;
+ /* Write the members */
+ if (multixid_valid)
+ {
+ RecordMultiXactMembers(members_writer, next_offset, 1, &member);
+ next_offset += 1;
}
- FreeOldMultiXactReader(old_reader);
+ /* Advance to next multixid, handling wraparound */
+ multi++;
+ if (multi < FirstMultiXactId)
+ multi = FirstMultiXactId;
+ prev_multixid_valid = multixid_valid;
+ }
+
+ FreeOldMultiXactReader(old_reader);
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index c6af9035665..7366fd4627c 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -833,7 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
@@ -898,15 +898,15 @@ set_frozenxids(void)
int i_datname;
int i_datallowconn;
- prep_status("Setting frozenxid and minmxid counters in new cluster");
+ prep_status("Setting frozenxid and minmxid counters in new cluster");
conn_template1 = connectToServer(&new_cluster, "template1");
- /* set pg_database.datfrozenxid */
- PQclear(executeQueryOrDie(conn_template1,
- "UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ /* set pg_database.datfrozenxid */
+ PQclear(executeQueryOrDie(conn_template1,
+ "UPDATE pg_catalog.pg_database "
+ "SET datfrozenxid = '%u'",
+ old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
@@ -942,16 +942,16 @@ set_frozenxids(void)
conn = connectToServer(&new_cluster, datname);
- /* set pg_class.relfrozenxid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
- /* only heap, materialized view, and TOAST are vacuumed */
- "WHERE relkind IN ("
- CppAsString2(RELKIND_RELATION) ", "
- CppAsString2(RELKIND_MATVIEW) ", "
- CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ /* set pg_class.relfrozenxid */
+ PQclear(executeQueryOrDie(conn,
+ "UPDATE pg_catalog.pg_class "
+ "SET relfrozenxid = '%u' "
+ /* only heap, materialized view, and TOAST are vacuumed */
+ "WHERE relkind IN ("
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_TOASTVALUE) ")",
+ old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index ec2ff7acb21..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -587,32 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix)
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
+ }
}
}
diff --git a/src/bin/pg_upgrade/t/006_transfer_modes.pl b/src/bin/pg_upgrade/t/006_transfer_modes.pl
index 9efa5dc863c..360d05c4b68 100644
--- a/src/bin/pg_upgrade/t/006_transfer_modes.pl
+++ b/src/bin/pg_upgrade/t/006_transfer_modes.pl
@@ -29,10 +29,8 @@ sub test_mode
}
$new->init();
- $new->append_conf('postgresql.conf',
- "allow_in_place_tablespaces = true");
- $old->append_conf('postgresql.conf',
- "allow_in_place_tablespaces = true");
+ $new->append_conf('postgresql.conf', "allow_in_place_tablespaces = true");
+ $old->append_conf('postgresql.conf', "allow_in_place_tablespaces = true");
# We can only test security labels if both the old and new installations
# have dummy_seclabel.
@@ -76,15 +74,14 @@ sub test_mode
"CREATE TABLE test4 AS SELECT generate_series(400, 502)");
}
- $old->safe_psql('postgres',
- "CREATE TABLESPACE inplc_tblspc LOCATION ''");
- $old->safe_psql('postgres',
- "CREATE DATABASE testdb3 TABLESPACE inplc_tblspc");
- $old->safe_psql('postgres',
- "CREATE TABLE test5 TABLESPACE inplc_tblspc AS SELECT generate_series(503, 606)"
- );
- $old->safe_psql('testdb3',
- "CREATE TABLE test6 AS SELECT generate_series(607, 711)");
+ $old->safe_psql('postgres', "CREATE TABLESPACE inplc_tblspc LOCATION ''");
+ $old->safe_psql('postgres',
+ "CREATE DATABASE testdb3 TABLESPACE inplc_tblspc");
+ $old->safe_psql('postgres',
+ "CREATE TABLE test5 TABLESPACE inplc_tblspc AS SELECT generate_series(503, 606)"
+ );
+ $old->safe_psql('testdb3',
+ "CREATE TABLE test6 AS SELECT generate_series(607, 711)");
# While we are here, test handling of large objects.
$old->safe_psql(
@@ -152,12 +149,10 @@ sub test_mode
}
# Tests for in-place tablespaces.
- $result =
- $new->safe_psql('postgres', "SELECT COUNT(*) FROM test5");
- is($result, '104', "test5 data after pg_upgrade $mode");
- $result =
- $new->safe_psql('testdb3', "SELECT COUNT(*) FROM test6");
- is($result, '105', "test6 data after pg_upgrade $mode");
+ $result = $new->safe_psql('postgres', "SELECT COUNT(*) FROM test5");
+ is($result, '104', "test5 data after pg_upgrade $mode");
+ $result = $new->safe_psql('testdb3', "SELECT COUNT(*) FROM test6");
+ is($result, '105', "test6 data after pg_upgrade $mode");
# Tests for large objects
$result = $new->safe_psql('postgres', "SELECT lo_get(4532)");
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 44ef11d980e..c90bf8bbde2 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6278,23 +6278,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index ce99137c613..ac0c55e7aa5 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -387,19 +387,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -599,8 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1086,38 +1086,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1675,27 +1675,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -1913,7 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2326,7 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
+ appendPQExpBufferStr(&buf, "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2431,7 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- appendPQExpBufferStr(&buf, ", i.indisreplident");
+ appendPQExpBufferStr(&buf, ", i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2682,81 +2682,80 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBufferStr(&buf, "SELECT pol.polname,");
+ appendPQExpBufferStr(&buf,
+ " pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3025,115 +3024,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT pg_catalog.string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT pg_catalog.string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Included in publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Included in publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3805,7 +3804,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
+ appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -3860,8 +3859,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -5155,14 +5154,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
--
2.50.1 (Apple Git-155)
Attachments:
[text/plain] v6-0001-pg_dump-pg_dumpall-bump-minimum-supported-version.patch (31.0K, ../../akQkqy1P8vw-1qC9@nathan/2-v6-0001-pg_dump-pg_dumpall-bump-minimum-supported-version.patch)
download | inline diff:
From 39e79ecc0aaf2c70159f34c94053269f874d23e6 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 10:15:38 -0700
Subject: [PATCH v6 1/4] pg_dump/pg_dumpall: bump minimum supported version to
v10
---
doc/src/sgml/ref/pg_dump.sgml | 14 +-
doc/src/sgml/runtime.sgml | 2 +-
src/bin/pg_dump/connectdb.c | 4 +-
src/bin/pg_dump/pg_dump.c | 334 ++--------------------------------
src/bin/pg_dump/pg_dumpall.c | 28 ---
5 files changed, 23 insertions(+), 359 deletions(-)
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 0e0d53926af..774be23b4f9 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -407,18 +407,6 @@ PostgreSQL documentation
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</para>
- <para>
- To perform a parallel dump, the database server needs to support
- synchronized snapshots, a feature that was introduced in
- <productname>PostgreSQL</productname> 9.2 for primary servers and 10
- for standbys. With this feature, database clients can ensure they see
- the same data set even though they use different connections.
- <command>pg_dump -j</command> uses multiple database connections; it
- connects to the database once with the leader process and once again
- for each worker job. Without the synchronized snapshot feature, the
- different worker jobs wouldn't be guaranteed to see the same data in
- each connection, which could lead to an inconsistent backup.
- </para>
</listitem>
</varlistentry>
@@ -1717,7 +1705,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<productname>PostgreSQL</productname> server versions newer than
<application>pg_dump</application>'s version. <application>pg_dump</application> can also
dump from <productname>PostgreSQL</productname> servers older than its own version.
- (Currently, servers back to version 9.2 are supported.)
+ (Currently, servers back to version 10 are supported.)
However, <application>pg_dump</application> cannot dump from
<productname>PostgreSQL</productname> servers newer than its own major version;
it will refuse to even try, rather than risk making an invalid dump.
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index dfa292c2c3a..d9984910cc4 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1776,7 +1776,7 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
version of
<productname>PostgreSQL</productname>, to take advantage of enhancements
that might have been made in these programs. Current releases of the
- dump programs can read data from any server version back to 9.2.
+ dump programs can read data from any server version back to 10.
</para>
<para>
diff --git a/src/bin/pg_dump/connectdb.c b/src/bin/pg_dump/connectdb.c
index f3ce8b1cfb1..d145308dccf 100644
--- a/src/bin/pg_dump/connectdb.c
+++ b/src/bin/pg_dump/connectdb.c
@@ -212,11 +212,11 @@ ConnectDatabase(const char *dbname, const char *connection_string,
my_version = PG_VERSION_NUM;
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dump.c.)
*/
if (my_version != server_version_temp
- && (server_version_temp < 90200 ||
+ && (server_version_temp < 100000 ||
(server_version_temp / 100) > (my_version / 100)))
{
pg_log_error("aborting because of server version mismatch");
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index c56437d6057..65bd15ebfd2 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -977,10 +977,10 @@ main(int argc, char **argv)
/*
- * We allow the server to be back to 9.2, and up to any minor release of
+ * We allow the server to be back to 10, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 90200;
+ fout->minRemoteVersion = 100000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
@@ -1491,9 +1491,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- if (AH->remoteVersion >= 90600)
ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1507,13 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (AH->remoteVersion >= 90500)
- {
if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security = on");
else
ExecuteSqlStatement(AH, "SET row_security = off");
- }
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1568,11 +1563,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
destroyPQExpBuffer(query);
}
else if (AH->numWorkers > 1)
- {
- if (AH->isStandby && AH->remoteVersion < 100000)
- pg_fatal("parallel dumps from standby servers are not supported by this server version");
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
- }
}
/* Set up connection for a parallel worker process */
@@ -1942,13 +1933,11 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
addObjectDependency(dobj, ext->dobj.dumpId);
/*
- * In 9.6 and above, mark the member object to have any non-initial ACLs
+ * Mark the member object to have any non-initial ACLs
* dumped. (Any initial ACLs will be removed later, using data from
* pg_init_privs, so that we'll dump only the delta from the extension's
* initial setup.)
*
- * Prior to 9.6, we do not include any extension member components.
- *
* In binary upgrades, we still dump all components of the members
* individually, since the idea is to exactly reproduce the database
* contents rather than replace the extension contents with something
@@ -1964,12 +1953,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- {
- if (fout->remoteVersion < 90600)
- dobj->dump = DUMP_COMPONENT_NONE;
- else
dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
- }
return true;
}
@@ -2000,11 +1984,10 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
- else if (fout->remoteVersion >= 90600 &&
- strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
+ else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * In 9.6 and above, we dump out any ACLs defined in pg_catalog, if
+ * We dump out any ACLs defined in pg_catalog, if
* they are interesting (and not the original ACLs which were set at
* initdb time, see pg_init_privs).
*/
@@ -2213,8 +2196,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
else
{
if (plang->dobj.catId.oid <= g_last_builtin_oid)
- plang->dobj.dump = fout->remoteVersion < 90600 ?
- DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
+ plang->dobj.dump = DUMP_COMPONENT_ACL;
else
plang->dobj.dump = DUMP_COMPONENT_ALL;
}
@@ -2231,13 +2213,6 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void
selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
{
- /* see getAccessMethods() comment about v9.6. */
- if (fout->remoteVersion < 90600)
- {
- method->dobj.dump = DUMP_COMPONENT_NONE;
- return;
- }
-
if (checkExtensionMembership(&method->dobj, fout))
return; /* extension membership overrides all else */
@@ -3123,10 +3098,6 @@ buildMatViewRefreshDependencies(Archive *fout)
i_objid,
i_refobjid;
- /* No Mat Views before 9.3. */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "WITH RECURSIVE w AS "
@@ -3325,10 +3296,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(dbQry, "datminmxid, ");
- else
- appendPQExpBufferStr(dbQry, "0 AS datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3670,17 +3638,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- if (fout->remoteVersion >= 90300)
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid IN (%u, %u, %u, %u);\n",
LargeObjectRelationId, LargeObjectLOidPNIndexId,
LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
- else
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4243,10 +4205,6 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- /* No policies before 9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
/* Skip if --no-policies was specified */
if (dopt->no_policies)
return;
@@ -4316,10 +4274,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query, "pol.polpermissive, ");
- else
- appendPQExpBufferStr(query, "'t' as polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -4534,7 +4489,7 @@ getPublications(Archive *fout)
int i,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -4897,7 +4852,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
j,
ntups;
- if (dopt->no_publications || fout->remoteVersion < 100000)
+ if (dopt->no_publications)
return;
query = createPQExpBuffer();
@@ -5187,7 +5142,7 @@ getSubscriptions(Archive *fout)
int i,
ntups;
- if (dopt->no_subscriptions || fout->remoteVersion < 100000)
+ if (dopt->no_subscriptions)
return;
if (!is_superuser(fout))
@@ -6675,24 +6630,12 @@ getAccessMethods(Archive *fout)
query = createPQExpBuffer();
/*
- * Select all access methods from pg_am table. v9.6 introduced CREATE
- * ACCESS METHOD, so earlier versions usually have only built-in access
- * methods. v9.6 also changed the access method API, replacing dozens of
- * pg_am columns with amhandler. Even if a user created an access method
- * by "INSERT INTO pg_am", we have no way to translate pre-v9.6 pg_am
- * columns to a v9.6+ CREATE ACCESS METHOD. Hence, before v9.6, read
- * pg_am just to facilitate findAccessMethodByOid() providing the
- * OID-to-name mapping.
+ * Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"amtype, "
"amhandler::pg_catalog.regproc AS amhandler ");
- else
- appendPQExpBufferStr(query,
- "'i'::pg_catalog.\"char\" AS amtype, "
- "'-'::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6878,15 +6821,12 @@ getAggregates(Archive *fout)
int i_proowner;
int i_aggacl;
int i_acldefault;
+ const char *agg_check;
/*
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *agg_check;
-
agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
: "p.proisagg");
@@ -6916,29 +6856,6 @@ getAggregates(Archive *fout)
"refclassid = 'pg_extension'::regclass AND "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, proname AS aggname, "
- "pronamespace AS aggnamespace, "
- "pronargs, proargtypes, "
- "proowner, "
- "proacl AS aggacl, "
- "acldefault('f', proowner) AS acldefault "
- "FROM pg_proc p "
- "WHERE proisagg AND ("
- "pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')");
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7021,6 +6938,7 @@ getFuncs(Archive *fout)
int i_prorettype;
int i_proacl;
int i_acldefault;
+ const char *not_agg_check;
/*
* Find all interesting functions. This is a bit complicated:
@@ -7039,14 +6957,10 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, in 9.6 and up, include functions in
+ * they are built-in. Also, include functions in
* pg_catalog if they have an ACL different from what's shown in
* pg_init_privs (so we have to join to pg_init_privs; annoying).
*/
- if (fout->remoteVersion >= 90600)
- {
- const char *not_agg_check;
-
not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
: "NOT p.proisagg");
@@ -7090,46 +7004,6 @@ getFuncs(Archive *fout)
appendPQExpBufferStr(query,
"\n OR p.proacl IS DISTINCT FROM pip.initprivs");
appendPQExpBufferChar(query, ')');
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, proacl, "
- "acldefault('f', proowner) AS acldefault, "
- "pronamespace, "
- "proowner "
- "FROM pg_proc p "
- "WHERE NOT proisagg"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
-
- if (fout->remoteVersion >= 90500)
- appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
-
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7378,64 +7252,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relispopulated, ");
- else
- appendPQExpBufferStr(query,
- "'t' as relispopulated, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"c.relreplident, ");
- else
- appendPQExpBufferStr(query,
- "'d' AS relreplident, ");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"c.relrowsecurity, c.relforcerowsecurity, ");
- else
- appendPQExpBufferStr(query,
- "false AS relrowsecurity, "
- "false AS relforcerowsecurity, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"c.relminmxid, tc.relminmxid AS tminmxid, ");
- else
- appendPQExpBufferStr(query,
- "0 AS relminmxid, 0 AS tminmxid, ");
- if (fout->remoteVersion >= 90300)
appendPQExpBufferStr(query,
"array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
"CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
"WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- else
- appendPQExpBufferStr(query,
- "c.reloptions, NULL AS checkoption, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"am.amname, ");
- else
- appendPQExpBufferStr(query,
- "NULL AS amname, ");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- else
- appendPQExpBufferStr(query,
- "false AS is_identity_sequence, ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"c.relispartition AS ispartition ");
- else
- appendPQExpBufferStr(query,
- "false AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7453,9 +7294,8 @@ getTables(Archive *fout, int *numTables)
"LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
/*
- * In 9.6 and up, left join to pg_am to pick up the amname.
+ * Left join to pg_am to pick up the amname.
*/
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
@@ -8028,12 +7868,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"i.indisreplident, ");
- else
- appendPQExpBufferStr(query,
- "false AS indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -8318,10 +8154,6 @@ getExtendedStatistics(Archive *fout)
int i_stattarget;
int i;
- /* Extended statistics were new in v10 */
- if (fout->remoteVersion < 100000)
- return;
-
query = createPQExpBuffer();
if (fout->remoteVersion < 130000)
@@ -8988,10 +8820,6 @@ getEventTriggers(Archive *fout)
i_evtenabled;
int ntups;
- /* Before 9.3, there are no event triggers */
- if (fout->remoteVersion < 90300)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query,
@@ -9258,10 +9086,6 @@ getTransforms(Archive *fout)
int i_trffromsql;
int i_trftosql;
- /* Transforms didn't exist pre-9.5 */
- if (fout->remoteVersion < 90500)
- return;
-
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
@@ -9489,12 +9313,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(q,
"a.attidentity,\n");
- else
- appendPQExpBufferStr(q,
- "'' AS attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10897,8 +10717,6 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- if (fout->remoteVersion >= 90600)
- {
printfPQExpBuffer(query,
"SELECT objoid, classoid, objsubid, privtype, initprivs "
"FROM pg_init_privs");
@@ -10966,7 +10784,6 @@ getAdditionalACLs(Archive *fout)
}
}
PQclear(res);
- }
destroyPQExpBuffer(query);
}
@@ -11141,15 +10958,6 @@ fetchAttributeStats(Archive *fout)
static bool restarted;
int max_rels = MAX_ATTR_STATS_RELS;
- /*
- * Our query for retrieving statistics for multiple relations uses WITH
- * ORDINALITY and multi-argument UNNEST(), both of which were introduced
- * in v9.4. For older versions, we resort to gathering statistics for a
- * single relation at a time.
- */
- if (fout->remoteVersion < 90400)
- max_rels = 1;
-
/* If we're just starting, set our TOC pointer. */
if (!te)
te = AH->toc->next;
@@ -11320,16 +11128,11 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For v9.4 through v18, the redundant filter clause on s.tablename =
+ * For versions before 19, the redundant filter clause on s.tablename =
* ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
- *
- * Our query for retrieving statistics for multiple relations uses
- * WITH ORDINALITY and multi-argument UNNEST(), both of which were
- * introduced in v9.4. For older versions, we resort to gathering
- * statistics for a single relation at a time.
*/
if (fout->remoteVersion >= 190000)
appendPQExpBufferStr(query,
@@ -11337,7 +11140,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
"ON s.tableid = u.tableid "
"ORDER BY u.ord, s.attname, s.inherited");
- else if (fout->remoteVersion >= 90400)
+ else
appendPQExpBufferStr(query,
"FROM pg_catalog.pg_stats s "
"JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
@@ -11345,12 +11148,6 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
"AND s.tablename = u.tablename "
"WHERE s.tablename = ANY($2) "
"ORDER BY u.ord, s.attname, s.inherited");
- else
- appendPQExpBufferStr(query,
- "FROM pg_catalog.pg_stats s "
- "WHERE s.schemaname = $1[1] "
- "AND s.tablename = $2[1] "
- "ORDER BY s.attname, s.inherited");
ExecuteSqlStatement(fout, query->data);
@@ -13672,19 +13469,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
- else
- appendPQExpBufferStr(query,
- "NULL AS protrftypes,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -15174,14 +14963,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- if (fout->remoteVersion >= 100000)
appendPQExpBufferStr(query,
"collprovider, "
"collversion, ");
- else
- appendPQExpBufferStr(query,
- "'c' AS collprovider, "
- "NULL AS collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15588,7 +15372,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- if (fout->remoteVersion >= 90400)
appendPQExpBufferStr(query,
"aggkind,\n"
"aggmtransfn,\n"
@@ -15600,31 +15383,12 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"aggtransspace,\n"
"aggmtransspace,\n"
"aggminitval,\n");
- else
- appendPQExpBufferStr(query,
- "'n' AS aggkind,\n"
- "'-' AS aggmtransfn,\n"
- "'-' AS aggminvtransfn,\n"
- "'-' AS aggmfinalfn,\n"
- "0 AS aggmtranstype,\n"
- "false AS aggfinalextra,\n"
- "false AS aggmfinalextra,\n"
- "0 AS aggtransspace,\n"
- "0 AS aggmtransspace,\n"
- "NULL AS aggminitval,\n");
- if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
"aggcombinefn,\n"
"aggserialfn,\n"
"aggdeserialfn,\n"
"proparallel,\n");
- else
- appendPQExpBufferStr(query,
- "'-' AS aggcombinefn,\n"
- "'-' AS aggserialfn,\n"
- "'-' AS aggdeserialfn,\n"
- "'u' AS proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -17084,8 +16848,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- if (fout->remoteVersion >= 90600)
- {
/*
* In principle we should call acldefault('c', relowner) to
* get the default ACL for a column. However, we don't
@@ -17110,17 +16872,6 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
"NOT at.attisdropped "
"AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
"ORDER BY at.attnum");
- }
- else
- {
- appendPQExpBufferStr(query,
- "SELECT attname, attacl, '{}' AS acldefault, "
- "NULL AS privtype, NULL AS initprivs "
- "FROM pg_catalog.pg_attribute "
- "WHERE attrelid = $1 AND NOT attisdropped "
- "AND attacl IS NOT NULL "
- "ORDER BY attnum");
- }
ExecuteSqlStatement(fout, query->data);
@@ -19410,16 +19161,10 @@ collectSequences(Archive *fout)
const char *query;
/*
- * Before Postgres 10, sequence metadata is in the sequence itself. With
- * some extra effort, we might be able to use the sorted table for those
- * versions, but for now it seems unlikely to be worth it.
- *
* Since version 18, we can gather the sequence data in this query with
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
- if (fout->remoteVersion < 100000)
- return;
- else if (fout->remoteVersion < 180000 ||
+ if (fout->remoteVersion < 180000 ||
(!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
@@ -19477,59 +19222,20 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
PQExpBuffer delqry = createPQExpBuffer();
char *qseqname;
TableInfo *owning_tab = NULL;
+ SequenceItem key = {0};
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * For versions >= 10, the sequence information is gathered in a sorted
+ * The sequence information is gathered in a sorted
* table before any calls to dumpSequence(). See collectSequences() for
* more information.
*/
- if (fout->remoteVersion >= 100000)
- {
- SequenceItem key = {0};
-
Assert(sequences);
key.oid = tbinfo->dobj.catId.oid;
seq = bsearch(&key, sequences, nsequences,
sizeof(SequenceItem), SequenceItemCmp);
- }
- else
- {
- PGresult *res;
-
- /*
- * Before PostgreSQL 10, sequence metadata is in the sequence itself.
- *
- * Note: it might seem that 'bigint' potentially needs to be
- * schema-qualified, but actually that's a keyword.
- */
- appendPQExpBuffer(query,
- "SELECT 'bigint' AS sequence_type, "
- "start_value, increment_by, max_value, min_value, "
- "cache_value, is_cycled FROM %s",
- fmtQualifiedDumpable(tbinfo));
-
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
-
- if (PQntuples(res) != 1)
- pg_fatal(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)",
- "query to get data of sequence \"%s\" returned %d rows (expected 1)",
- PQntuples(res)),
- tbinfo->dobj.name, PQntuples(res));
-
- seq = pg_malloc0_object(SequenceItem);
- seq->seqtype = parse_sequence_type(PQgetvalue(res, 0, 0));
- seq->startv = strtoi64(PQgetvalue(res, 0, 1), NULL, 10);
- seq->incby = strtoi64(PQgetvalue(res, 0, 2), NULL, 10);
- seq->maxv = strtoi64(PQgetvalue(res, 0, 3), NULL, 10);
- seq->minv = strtoi64(PQgetvalue(res, 0, 4), NULL, 10);
- seq->cache = strtoi64(PQgetvalue(res, 0, 5), NULL, 10);
- seq->cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
-
- PQclear(res);
- }
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
@@ -19708,8 +19414,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
- if (fout->remoteVersion < 100000)
- pg_free(seq);
destroyPQExpBuffer(query);
destroyPQExpBuffer(delqry);
free(qseqname);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index b9653f0aefe..e68937c9934 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -785,17 +785,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT rolname "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 1", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -849,7 +843,6 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- if (server_version >= 90600)
printfPQExpBuffer(buf,
"SELECT oid, rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, "
@@ -860,27 +853,6 @@ dumpRoles(PGconn *conn)
"FROM %s "
"WHERE rolname !~ '^pg_' "
"ORDER BY 2", role_catalog);
- else if (server_version >= 90500)
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
- else
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, "
- "false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
--
2.50.1 (Apple Git-155)
[text/plain] v6-0002-pg_upgrade-bump-minimum-supported-version-to-v10.patch (42.8K, ../../akQkqy1P8vw-1qC9@nathan/3-v6-0002-pg_upgrade-bump-minimum-supported-version-to-v10.patch)
download | inline diff:
From 397131270606dec009ecd76b787b35b8a83c5d11 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:20:18 -0700
Subject: [PATCH v6 2/4] pg_upgrade: bump minimum supported version to v10
---
doc/src/sgml/ref/pgupgrade.sgml | 2 +-
src/bin/pg_upgrade/check.c | 157 +-------------------
src/bin/pg_upgrade/controldata.c | 98 +-----------
src/bin/pg_upgrade/exec.c | 23 ---
src/bin/pg_upgrade/file.c | 164 ---------------------
src/bin/pg_upgrade/multixact_rewrite.c | 11 +-
src/bin/pg_upgrade/pg_upgrade.c | 56 +------
src/bin/pg_upgrade/pg_upgrade.h | 29 ----
src/bin/pg_upgrade/relfilenumber.c | 37 +----
src/bin/pg_upgrade/server.c | 3 +-
src/bin/pg_upgrade/t/006_transfer_modes.pl | 20 ---
src/bin/pg_upgrade/version.c | 127 ----------------
12 files changed, 26 insertions(+), 701 deletions(-)
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index cc44983a9a8..e4e8c02e6d6 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
</para>
<para>
- <application>pg_upgrade</application> supports upgrades from 9.2.X and later to the current
+ <application>pg_upgrade</application> supports upgrades from 10.X and later to the current
major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
</para>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index f8f31382835..786c1474829 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -28,7 +28,6 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
static void check_for_tables_with_oids(ClusterInfo *cluster);
static void check_for_not_null_inheritance(ClusterInfo *cluster);
static void check_for_gist_inet_ops(ClusterInfo *cluster);
-static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(void);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static void check_for_unicode_update(ClusterInfo *cluster);
@@ -128,26 +127,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = ALL_VERSIONS
},
- /*
- * 9.3 -> 9.4 Fully implement the 'line' data type in 9.4, which
- * previously returned "not enabled" by default and was only functionally
- * enabled with a compile-time switch; as of 9.4 "line" has a different
- * on-disk representation format.
- */
- {
- .status = gettext_noop("Checking for incompatible \"line\" data type"),
- .report_filename = "tables_using_line.txt",
- .base_query =
- "SELECT 'pg_catalog.line'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"line\" data type in user tables.\n"
- "This data type changed its internal and input/output format\n"
- "between your old and new versions so this\n"
- "cluster cannot currently be upgraded. You can\n"
- "drop the problem columns and restart the upgrade.\n"),
- .threshold_version = 903
- },
-
/*
* pg_upgrade only preserves these system values: pg_class.oid pg_type.oid
* pg_enum.oid
@@ -209,30 +188,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1500
},
- /*
- * It's no longer allowed to create tables or views with "unknown"-type
- * columns. We do not complain about views with such columns, because
- * they should get silently converted to "text" columns during the DDL
- * dump and reload; it seems unlikely to be worth making users do that by
- * hand. However, if there's a table with such a column, the DDL reload
- * will fail, so we should pre-detect that rather than failing
- * mid-upgrade. Worse, if there's a matview with such a column, the DDL
- * reload will silently change it to "text" which won't match the on-disk
- * storage (which is like "cstring"). So we *must* reject that.
- */
- {
- .status = gettext_noop("Checking for invalid \"unknown\" user columns"),
- .report_filename = "tables_using_unknown.txt",
- .base_query =
- "SELECT 'pg_catalog.unknown'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"unknown\" data type in user tables.\n"
- "This data type is no longer allowed in tables, so this cluster\n"
- "cannot currently be upgraded. You can drop the problem columns\n"
- "and restart the upgrade.\n"),
- .threshold_version = 906
- },
-
/*
* PG 12 changed the 'sql_identifier' type storage to be based on name,
* not varchar, which breaks on-disk format for existing data. So we need
@@ -255,23 +210,6 @@ static DataTypesUsageChecks data_types_usage_checks[] =
.threshold_version = 1100
},
- /*
- * JSONB changed its storage format during 9.4 beta, so check for it.
- */
- {
- .status = gettext_noop("Checking for incompatible \"jsonb\" data type in user tables"),
- .report_filename = "tables_using_jsonb.txt",
- .base_query =
- "SELECT 'pg_catalog.jsonb'::pg_catalog.regtype AS oid",
- .report_text =
- gettext_noop("Your installation contains the \"jsonb\" data type in user tables.\n"
- "The internal format of \"jsonb\" changed during 9.4 beta so this\n"
- "cluster cannot currently be upgraded. You can drop the problem \n"
- "columns and restart the upgrade.\n"),
- .threshold_version = MANUAL_CHECK,
- .version_hook = jsonb_9_4_check_applicable
- },
-
/*
* PG 12 removed types abstime, reltime, tinterval.
*/
@@ -712,20 +650,6 @@ check_and_dump_old_cluster(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1800)
check_for_gist_inet_ops(&old_cluster);
- /*
- * Pre-PG 10 allowed tables with 'unknown' type columns and non WAL logged
- * hash indexes
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- {
- if (user_opts.check)
- old_9_6_invalidate_hash_indexes(&old_cluster, true);
- }
-
- /* 9.5 and below should not have roles starting with pg_ */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 905)
- check_for_pg_role_prefix(&old_cluster);
-
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -772,20 +696,6 @@ check_new_cluster(void)
* system boundaries.
*/
check_hard_link(TRANSFER_MODE_SWAP);
-
- /*
- * There are a few known issues with using --swap to upgrade from
- * versions older than 10. For example, the sequence tuple format
- * changed in v10, and the visibility map format changed in 9.6.
- * While such problems are not insurmountable (and we may have to
- * deal with similar problems in the future, anyway), it doesn't
- * seem worth the effort to support swap mode for upgrades from
- * long-unsupported versions.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
- pg_fatal("Swap mode can only upgrade clusters from PostgreSQL version %s and later.",
- "10");
-
break;
}
@@ -831,10 +741,6 @@ issue_warnings_and_set_wal_level(void)
*/
start_postmaster(&new_cluster, true);
- /* Reindex hash indexes for old < 10.0 */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
- old_9_6_invalidate_hash_indexes(&new_cluster, false);
-
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -892,9 +798,9 @@ check_cluster_versions(void)
* upgrades
*/
- if (GET_MAJOR_VERSION(old_cluster.major_version) < 902)
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 1000)
pg_fatal("This utility can only upgrade from PostgreSQL version %s and later.",
- "9.2");
+ "10");
/* Only current PG version is supported as a target */
if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
@@ -1569,12 +1475,10 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 903)
appendPQExpBufferStr(&old_polymorphics,
", 'array_remove(anyarray,anyelement)'"
", 'array_replace(anyarray,anyelement,anyelement)'");
- if (GET_MAJOR_VERSION(cluster->major_version) >= 905)
appendPQExpBufferStr(&old_polymorphics,
", 'array_position(anyarray,anyelement)'"
", 'array_position(anyarray,anyelement,integer)'"
@@ -1870,63 +1774,6 @@ check_for_gist_inet_ops(ClusterInfo *cluster)
check_ok();
}
-/*
- * check_for_pg_role_prefix()
- *
- * Versions older than 9.6 should not have any pg_* roles
- */
-static void
-check_for_pg_role_prefix(ClusterInfo *cluster)
-{
- PGresult *res;
- PGconn *conn = connectToServer(cluster, "template1");
- int ntups;
- int i_roloid;
- int i_rolname;
- FILE *script = NULL;
- char output_path[MAXPGPATH];
-
- prep_status("Checking for roles starting with \"pg_\"");
-
- snprintf(output_path, sizeof(output_path), "%s/%s",
- log_opts.basedir,
- "pg_role_prefix.txt");
-
- res = executeQueryOrDie(conn,
- "SELECT oid AS roloid, rolname "
- "FROM pg_catalog.pg_roles "
- "WHERE rolname ~ '^pg_'");
-
- ntups = PQntuples(res);
- i_roloid = PQfnumber(res, "roloid");
- i_rolname = PQfnumber(res, "rolname");
- for (int rowno = 0; rowno < ntups; rowno++)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- fprintf(script, "%s (oid=%s)\n",
- PQgetvalue(res, rowno, i_rolname),
- PQgetvalue(res, rowno, i_roloid));
- }
-
- PQclear(res);
-
- PQfinish(conn);
-
- if (script)
- {
- fclose(script);
- pg_log(PG_REPORT, "fatal");
- pg_fatal("Your installation contains roles starting with \"pg_\".\n"
- "\"pg_\" is a reserved prefix for system roles. The cluster\n"
- "cannot be upgraded until these roles are renamed.\n"
- "A list of roles starting with \"pg_\" is in the file:\n"
- " %s", output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* check_for_user_defined_encoding_conversions()'s UpgradeTask. If the query
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index cffcd4b0eba..8f81c9e9582 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -42,9 +42,6 @@ get_control_data(ClusterInfo *cluster)
char bufin[MAX_STRING];
FILE *output;
char *p;
- bool got_tli = false;
- bool got_log_id = false;
- bool got_log_seg = false;
bool got_xid = false;
bool got_oid = false;
bool got_multi = false;
@@ -75,10 +72,6 @@ get_control_data(ClusterInfo *cluster)
char *language = NULL;
char *lc_all = NULL;
char *lc_messages = NULL;
- uint32 tli = 0;
- uint32 logid = 0;
- uint32 segno = 0;
- char *resetwal_bin;
int rc;
bool live_check = (cluster == &old_cluster && user_opts.live_check);
@@ -189,27 +182,15 @@ get_control_data(ClusterInfo *cluster)
}
}
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- resetwal_bin = "pg_resetxlog\" -n";
- else
- resetwal_bin = "pg_resetwal\" -n";
snprintf(cmd, sizeof(cmd), "\"%s/%s \"%s\"",
cluster->bindir,
- live_check ? "pg_controldata\"" : resetwal_bin,
+ live_check ? "pg_controldata\"" : "pg_resetwal\" -n",
cluster->pgdata);
fflush(NULL);
if ((output = popen(cmd, "r")) == NULL)
pg_fatal("could not get control data using %s: %m", cmd);
- /* Only in <= 9.2 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
- {
- cluster->controldata.data_checksum_version = PG_DATA_CHECKSUM_OFF;
- got_data_checksum_version = true;
- }
-
/* we have the result of cmd in "output". so parse it line by line now */
while (fgets(bufin, sizeof(bufin), output))
{
@@ -237,39 +218,6 @@ get_control_data(ClusterInfo *cluster)
p++; /* remove ':' char */
cluster->controldata.cat_ver = str2uint(p);
}
- else if ((p = strstr(bufin, "Latest checkpoint's TimeLineID:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- tli = str2uint(p);
- got_tli = true;
- }
- else if ((p = strstr(bufin, "First log file ID after reset:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- logid = str2uint(p);
- got_log_id = true;
- }
- else if ((p = strstr(bufin, "First log file segment after reset:")) != NULL)
- {
- p = strchr(p, ':');
-
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
-
- p++; /* remove ':' char */
- segno = str2uint(p);
- got_log_seg = true;
- }
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
p = strchr(p, ':');
@@ -280,23 +228,12 @@ get_control_data(ClusterInfo *cluster)
p++; /* remove ':' char */
cluster->controldata.chkpnt_nxtepoch = str2uint(p);
- /*
- * Delimiter changed from '/' to ':' in 9.6. We don't test for
- * the catalog version of the change because the catalog version
- * is pulled from pg_controldata too, and it isn't worth adding an
- * order dependency for this --- we just check the string.
- */
- if (strchr(p, '/') != NULL)
- p = strchr(p, '/');
- else if (GET_MAJOR_VERSION(cluster->major_version) >= 906)
p = strchr(p, ':');
- else
- p = NULL;
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
- p++; /* remove '/' or ':' char */
+ p++; /* remove ':' char */
cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
@@ -568,22 +505,6 @@ get_control_data(ClusterInfo *cluster)
pg_free(lc_all);
pg_free(lc_messages);
- /*
- * Before 9.3, pg_resetwal reported the xlogid and segno of the first log
- * file after reset as separate lines. Starting with 9.3, it reports the
- * WAL file name. If the old cluster is older than 9.3, we construct the
- * WAL file name from the xlogid and segno.
- */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 902)
- {
- if (got_tli && got_log_id && got_log_seg)
- {
- snprintf(cluster->controldata.nextxlogfile, 25, "%08X%08X%08X",
- tli, logid, segno);
- got_nextxlogfile = true;
- }
- }
-
/*
* Pre-v18 database clusters don't have the default char signedness
* information. We use the char signedness of the platform where
@@ -602,14 +523,12 @@ get_control_data(ClusterInfo *cluster)
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
!got_multi || !got_oldestxid ||
- (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER) ||
+ !got_oldestmulti ||
!got_mxoff || (!live_check && !got_nextxlogfile) ||
!got_float8_pass_by_value || !got_align || !got_blocksz ||
!got_largesz || !got_walsz || !got_walseg || !got_ident ||
!got_index || !got_toast ||
- (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER) ||
+ !got_large_object ||
!got_date_is_int || !got_data_checksum_version ||
(!got_default_char_signedness &&
cluster->controldata.cat_ver >= DEFAULT_CHAR_SIGNEDNESS_CAT_VER))
@@ -630,8 +549,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_multi)
pg_log(PG_REPORT, " latest checkpoint next MultiXactId");
- if (!got_oldestmulti &&
- cluster->controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
+ if (!got_oldestmulti)
pg_log(PG_REPORT, " latest checkpoint oldest MultiXactId");
if (!got_oldestxid)
@@ -670,8 +588,7 @@ get_control_data(ClusterInfo *cluster)
if (!got_toast)
pg_log(PG_REPORT, " maximum TOAST chunk size");
- if (!got_large_object &&
- cluster->controldata.ctrl_ver >= LARGE_OBJECT_SIZE_PG_CONTROL_VER)
+ if (!got_large_object)
pg_log(PG_REPORT, " large-object chunk size");
if (!got_date_is_int)
@@ -724,8 +641,7 @@ check_control_data(ControlData *oldctrl,
if (oldctrl->toast == 0 || oldctrl->toast != newctrl->toast)
pg_fatal("old and new pg_controldata maximum TOAST chunk sizes are invalid or do not match");
- /* large_object added in 9.5, so it might not exist in the old cluster */
- if (oldctrl->large_object != 0 &&
+ if (oldctrl->large_object == 0 ||
oldctrl->large_object != newctrl->large_object)
pg_fatal("old and new pg_controldata large-object chunk sizes are invalid or do not match");
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 563b4a6b5fa..44355feea30 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,16 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- if (v1 < 10)
- {
- /* old style, e.g. 9.6.1 */
- cluster->bin_version = v1 * 10000 + v2 * 100;
- }
- else
- {
- /* new style, e.g. 10.1 */
cluster->bin_version = v1 * 10000;
- }
}
@@ -353,17 +344,7 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
-
- /* pg_xlog has been renamed to pg_wal in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_xlog");
- else
check_single_dir(pg_data, "pg_wal");
-
- /* pg_clog has been renamed to pg_xact in v10 */
- if (GET_MAJOR_VERSION(cluster->major_version) <= 906)
- check_single_dir(pg_data, "pg_clog");
- else
check_single_dir(pg_data, "pg_xact");
}
@@ -404,10 +385,6 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- /* pg_resetxlog has been renamed to pg_resetwal in version 10 */
- if (GET_MAJOR_VERSION(cluster->bin_version) <= 906)
- check_exec(cluster->bindir, "pg_resetxlog", check_versions);
- else
check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 5b276008614..af82c0de490 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -20,12 +20,8 @@
#include <linux/fs.h>
#endif
-#include "access/visibilitymapdefs.h"
#include "common/file_perm.h"
#include "pg_upgrade.h"
-#include "storage/bufpage.h"
-#include "storage/checksum.h"
-#include "storage/checksum_impl.h"
/*
@@ -196,166 +192,6 @@ linkFile(const char *src, const char *dst,
}
-/*
- * rewriteVisibilityMap()
- *
- * Transform a visibility map file, copying from src to dst.
- * schemaName/relName are relation's SQL name (used for error messages only).
- *
- * In versions of PostgreSQL prior to catversion 201603011, PostgreSQL's
- * visibility map included one bit per heap page; it now includes two.
- * When upgrading a cluster from before that time to a current PostgreSQL
- * version, we could refuse to copy visibility maps from the old cluster
- * to the new cluster; the next VACUUM would recreate them, but at the
- * price of scanning the entire table. So, instead, we rewrite the old
- * visibility maps in the new format. That way, the all-visible bits
- * remain set for the pages for which they were set previously. The
- * all-frozen bits are never set by this conversion; we leave that to VACUUM.
- */
-void
-rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
-{
- int src_fd;
- int dst_fd;
- PGIOAlignedBlock buffer;
- PGIOAlignedBlock new_vmbuf;
- ssize_t totalBytesRead = 0;
- ssize_t src_filesize;
- int rewriteVmBytesPerPage;
- BlockNumber new_blkno = 0;
- struct stat statbuf;
-
- /* Compute number of old-format bytes per new page */
- rewriteVmBytesPerPage = (BLCKSZ - SizeOfPageHeaderData) / 2;
-
- if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if (fstat(src_fd, &statbuf) != 0)
- pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %m",
- schemaName, relName, fromfile);
-
- if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
- pg_file_create_mode)) < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %m",
- schemaName, relName, tofile);
-
- /* Save old file size */
- src_filesize = statbuf.st_size;
-
- /*
- * Turn each visibility map page into 2 pages one by one. Each new page
- * has the same page header as the old one. If the last section of the
- * last page is empty, we skip it, mostly to avoid turning one-page
- * visibility maps for small relations into two pages needlessly.
- */
- while (totalBytesRead < src_filesize)
- {
- ssize_t bytesRead;
- char *old_cur;
- char *old_break;
- char *old_blkend;
- PageHeaderData pageheader;
- bool old_lastblk;
-
- if ((bytesRead = read(src_fd, buffer.data, BLCKSZ)) != BLCKSZ)
- {
- if (bytesRead < 0)
- pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %m",
- schemaName, relName, fromfile);
- else
- pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
- schemaName, relName, fromfile);
- }
-
- totalBytesRead += BLCKSZ;
- old_lastblk = (totalBytesRead == src_filesize);
-
- /* Save the page header data */
- memcpy(&pageheader, buffer.data, SizeOfPageHeaderData);
-
- /*
- * These old_* variables point to old visibility map page. old_cur
- * points to current position on old page. old_blkend points to end of
- * old block. old_break is the end+1 position on the old page for the
- * data that will be transferred to the current new page.
- */
- old_cur = buffer.data + SizeOfPageHeaderData;
- old_blkend = buffer.data + bytesRead;
- old_break = old_cur + rewriteVmBytesPerPage;
-
- while (old_break <= old_blkend)
- {
- char *new_cur;
- bool empty = true;
- bool old_lastpart;
-
- /* First, copy old page header to new page */
- memcpy(new_vmbuf.data, &pageheader, SizeOfPageHeaderData);
-
- /* Rewriting the last part of the last old page? */
- old_lastpart = old_lastblk && (old_break == old_blkend);
-
- new_cur = new_vmbuf.data + SizeOfPageHeaderData;
-
- /* Process old page bytes one by one, and turn it into new page. */
- while (old_cur < old_break)
- {
- uint8 byte = *(uint8 *) old_cur;
- uint16 new_vmbits = 0;
- int i;
-
- /* Generate new format bits while keeping old information */
- for (i = 0; i < BITS_PER_BYTE; i++)
- {
- if (byte & (1 << i))
- {
- empty = false;
- new_vmbits |=
- VISIBILITYMAP_ALL_VISIBLE << (BITS_PER_HEAPBLOCK * i);
- }
- }
-
- /* Copy new visibility map bytes to new-format page */
- new_cur[0] = (char) (new_vmbits & 0xFF);
- new_cur[1] = (char) (new_vmbits >> 8);
-
- old_cur++;
- new_cur += BITS_PER_HEAPBLOCK;
- }
-
- /* If the last part of the last page is empty, skip writing it */
- if (old_lastpart && empty)
- break;
-
- /* Set new checksum for visibility map page, if enabled */
- if (new_cluster.controldata.data_checksum_version != PG_DATA_CHECKSUM_OFF)
- ((PageHeader) new_vmbuf.data)->pd_checksum =
- pg_checksum_page(new_vmbuf.data, new_blkno);
-
- errno = 0;
- if (write(dst_fd, new_vmbuf.data, BLCKSZ) != BLCKSZ)
- {
- /* if write didn't set errno, assume problem is no disk space */
- if (errno == 0)
- errno = ENOSPC;
- pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %m",
- schemaName, relName, tofile);
- }
-
- /* Advance for next new page */
- old_break += rewriteVmBytesPerPage;
- new_blkno++;
- }
- }
-
- /* Clean up */
- close(dst_fd);
- close(src_fd);
-}
-
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index 823984ec8f3..c45b3183684 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -25,10 +25,7 @@ static void RecordMultiXactMembers(SlruSegState *members_writer,
* 32-bit offsets to the current format.
*
* Multixids in the range [from_multi, to_multi) are read from the old
- * cluster, and written in the new format. An important edge case is that if
- * from_multi == to_multi, this initializes the new pg_multixact files in the
- * new format without trying to open any old files. (We rely on that when
- * upgrading from PostgreSQL version 9.2 or below.)
+ * cluster, and written in the new format.
*
* Returns the new nextOffset value; the caller should set it in the new
* control file. The new members always start from offset 1, regardless of
@@ -42,6 +39,7 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
SlruSegState *members_writer;
char dir[MAXPGPATH] = {0};
bool prev_multixid_valid = false;
+ OldMultiXactReader *old_reader;
/*
* The range of valid multi XIDs is unchanged by the conversion (they are
@@ -63,10 +61,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- if (to_multi != from_multi)
- {
- OldMultiXactReader *old_reader;
-
old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
old_cluster.controldata.chkpnt_nxtmulti,
old_cluster.controldata.chkpnt_nxtmxoff);
@@ -113,7 +107,6 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
}
FreeOldMultiXactReader(old_reader);
- }
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 2127d297bfe..c6af9035665 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -64,7 +64,7 @@ static void prepare_new_cluster(void);
static void prepare_new_globals(void);
static void create_new_objects(void);
static void copy_xact_xlog_xid(void);
-static void set_frozenxids(bool minmxid_only);
+static void set_frozenxids(void);
static void make_outputdirs(char *pgdata);
static void setup(char *argv0);
static void create_logical_replication_slots(void);
@@ -576,7 +576,7 @@ prepare_new_globals(void)
/*
* Before we restore anything, set frozenxids of initdb-created tables.
*/
- set_frozenxids(false);
+ set_frozenxids();
/*
* Now restore global objects (roles and tablespaces).
@@ -714,13 +714,6 @@ create_new_objects(void)
end_progress_output();
check_ok();
- /*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
- */
- if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
- set_frozenxids(true);
-
/* update new_cluster info now that we have objects in the databases */
get_db_rel_and_slot_infos(&new_cluster);
}
@@ -777,10 +770,7 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files("pg_xact", "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -809,7 +799,6 @@ copy_xact_xlog_xid(void)
check_ok();
/* Copy or convert pg_multixact files */
- Assert(new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER);
Assert(new_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER);
if (old_cluster.controldata.cat_ver >= MULTIXACTOFFSET_FORMATCHANGE_CAT_VER)
{
@@ -844,25 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
- {
- /* Versions 9.3 - 18: convert all multixids */
oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
- }
- else
- {
- /*
- * In PostgreSQL 9.2 and below, multitransactions were only used
- * for row locking, and as such don't need to be preserved during
- * upgrade. In that case, we utilize rewrite_multixacts() just to
- * initialize new, empty files in the new format.
- *
- * It's important that the oldest multi is set to the latest value
- * used by the old system, so that multixact.c returns the empty
- * set for multis that might be present on disk.
- */
- oldstMulti = nxtmulti;
- }
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
@@ -906,26 +877,18 @@ copy_xact_xlog_xid(void)
/*
* set_frozenxids()
*
- * This is called on the new cluster before we restore anything, with
- * minmxid_only = false. Its purpose is to ensure that all initdb-created
+ * This is called on the new cluster before we restore anything.
+ * Its purpose is to ensure that all initdb-created
* vacuumable tables have relfrozenxid/relminmxid matching the old cluster's
* xid/mxid counters. We also initialize the datfrozenxid/datminmxid of the
* built-in databases to match.
*
* As we create user tables later, their relfrozenxid/relminmxid fields will
* be restored properly by the binary-upgrade restore script. Likewise for
- * user-database datfrozenxid/datminmxid. However, if we're upgrading from a
- * pre-9.3 database, which does not store per-table or per-DB minmxid, then
- * the relminmxid/datminmxid values filled in by the restore script will just
- * be zeroes.
- *
- * Hence, with a pre-9.3 source database, a second call occurs after
- * everything is restored, with minmxid_only = true. This pass will
- * initialize all tables and databases, both those made by initdb and user
- * objects, with the desired minmxid value. frozenxid values are left alone.
+ * user-database datfrozenxid/datminmxid.
*/
static void
-set_frozenxids(bool minmxid_only)
+set_frozenxids(void)
{
int dbnum;
PGconn *conn,
@@ -935,14 +898,10 @@ set_frozenxids(bool minmxid_only)
int i_datname;
int i_datallowconn;
- if (!minmxid_only)
prep_status("Setting frozenxid and minmxid counters in new cluster");
- else
- prep_status("Setting minmxid counter in new cluster");
conn_template1 = connectToServer(&new_cluster, "template1");
- if (!minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
@@ -983,7 +942,6 @@ set_frozenxids(bool minmxid_only)
conn = connectToServer(&new_cluster, datname);
- if (!minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index ccd1ac0d013..d6e5bca5792 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -101,19 +101,6 @@ extern char *output_files[];
#endif
-/*
- * The format of visibility map was changed with this 9.6 commit.
- */
-#define VISIBILITY_MAP_FROZEN_BIT_CAT_VER 201603011
-
-/*
- * pg_multixact format changed in 9.3 commit 0ac5ad5134f2769ccbaefec73844f85,
- * ("Improve concurrency of foreign key locking") which also updated catalog
- * version to this value. pg_upgrade behavior depends on whether old and new
- * server versions are both newer than this, or only the new one is.
- */
-#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
-
/*
* MultiXactOffset was changed from 32-bit to 64-bit in version 19, at this
* catalog version. pg_multixact files need to be converted when upgrading
@@ -121,17 +108,6 @@ extern char *output_files[];
*/
#define MULTIXACTOFFSET_FORMATCHANGE_CAT_VER 202512091
-/*
- * large object chunk size added to pg_controldata,
- * commit 5f93c37805e7485488480916b4585e098d3cc883
- */
-#define LARGE_OBJECT_SIZE_PG_CONTROL_VER 942
-
-/*
- * change in JSONB format during 9.4 beta
- */
-#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
-
/*
* The control file was changed to have the default char signedness,
* commit 44fe30fdab6746a287163e7cc093fd36cda8eb92
@@ -429,8 +405,6 @@ void copyFileByRange(const char *src, const char *dst,
const char *schemaName, const char *relName);
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
-void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
void check_file_clone(void);
void check_copy_file_range(void);
void check_hard_link(transferMode transfer_mode);
@@ -500,10 +474,7 @@ unsigned int str2uint(const char *str);
/* version.c */
-bool jsonb_9_4_check_applicable(ClusterInfo *cluster);
bool protocol_negotiation_supported(const ClusterInfo *cluster);
-void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
- bool check_mode);
void report_extension_updates(ClusterInfo *cluster);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index d5088447e0d..ec2ff7acb21 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -18,7 +18,7 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace, char *new_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix);
/*
* The following set of sync_queue_* functions are used for --swap to reduce
@@ -496,25 +496,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
char *old_tablespace, char *new_tablespace)
{
int mapnum;
- bool vm_must_add_frozenbit = false;
-
- /*
- * Do we need to rewrite visibilitymap?
- */
- if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_FROZEN_BIT_CAT_VER &&
- new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
- vm_must_add_frozenbit = true;
/* --swap has its own subroutine */
if (user_opts.transfer_mode == TRANSFER_MODE_SWAP)
{
- /*
- * We don't support --swap to upgrade from versions that require
- * rewriting the visibility map. We should've failed already if
- * someone tries to do that.
- */
- Assert(!vm_must_add_frozenbit);
-
do_swap(maps, size, old_tablespace, new_tablespace);
return;
}
@@ -525,13 +510,13 @@ transfer_single_new_db(FileNameMap *maps, int size,
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "");
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm");
+ transfer_relfile(&maps[mapnum], "_vm");
}
}
}
@@ -540,12 +525,10 @@ transfer_single_new_db(FileNameMap *maps, int size,
/*
* transfer_relfile()
*
- * Copy or link file from old cluster to new one. If vm_must_add_frozenbit
- * is true, visibility map forks are converted and rewritten, even in link
- * mode.
+ * Copy or link file from old cluster to new one.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -604,14 +587,6 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- if (vm_must_add_frozenbit && strcmp(type_suffix, "_vm") == 0)
- {
- /* Need to rewrite visibility map format */
- pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
- old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
- }
- else
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c
index 5d81e4e95b8..7da9dffe585 100644
--- a/src/bin/pg_upgrade/server.c
+++ b/src/bin/pg_upgrade/server.c
@@ -186,8 +186,7 @@ start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error)
snprintf(socket_string + strlen(socket_string),
sizeof(socket_string) - strlen(socket_string),
" -c %s='%s'",
- (GET_MAJOR_VERSION(cluster->major_version) <= 902) ?
- "unix_socket_directory" : "unix_socket_directories",
+ "unix_socket_directories",
cluster->sockdir);
#endif
diff --git a/src/bin/pg_upgrade/t/006_transfer_modes.pl b/src/bin/pg_upgrade/t/006_transfer_modes.pl
index 6b7ab9f29a2..9efa5dc863c 100644
--- a/src/bin/pg_upgrade/t/006_transfer_modes.pl
+++ b/src/bin/pg_upgrade/t/006_transfer_modes.pl
@@ -17,15 +17,6 @@ sub test_mode
PostgreSQL::Test::Cluster->new('old', install_path => $ENV{oldinstall});
my $new = PostgreSQL::Test::Cluster->new('new');
- # --swap can't be used to upgrade from versions older than 10, so just skip
- # the test if the old cluster version is too old.
- if ($old->pg_version < 10 && $mode eq "--swap")
- {
- $old->clean_node();
- $new->clean_node();
- return;
- }
-
if (defined($ENV{oldinstall}))
{
# Checksums are now enabled by default, but weren't before 18, so pass
@@ -38,14 +29,10 @@ sub test_mode
}
$new->init();
- # allow_in_place_tablespaces is available as far back as v10.
- if ($old->pg_version >= 10)
- {
$new->append_conf('postgresql.conf',
"allow_in_place_tablespaces = true");
$old->append_conf('postgresql.conf',
"allow_in_place_tablespaces = true");
- }
# We can only test security labels if both the old and new installations
# have dummy_seclabel.
@@ -89,9 +76,6 @@ sub test_mode
"CREATE TABLE test4 AS SELECT generate_series(400, 502)");
}
- # If the old cluster is >= v10, we can test in-place tablespaces.
- if ($old->pg_version >= 10)
- {
$old->safe_psql('postgres',
"CREATE TABLESPACE inplc_tblspc LOCATION ''");
$old->safe_psql('postgres',
@@ -101,7 +85,6 @@ sub test_mode
);
$old->safe_psql('testdb3',
"CREATE TABLE test6 AS SELECT generate_series(607, 711)");
- }
# While we are here, test handling of large objects.
$old->safe_psql(
@@ -169,15 +152,12 @@ sub test_mode
}
# Tests for in-place tablespaces.
- if ($old->pg_version >= 10)
- {
$result =
$new->safe_psql('postgres', "SELECT COUNT(*) FROM test5");
is($result, '104', "test5 data after pg_upgrade $mode");
$result =
$new->safe_psql('testdb3', "SELECT COUNT(*) FROM test6");
is($result, '105', "test6 data after pg_upgrade $mode");
- }
# Tests for large objects
$result = $new->safe_psql('postgres', "SELECT lo_get(4532)");
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index 047670d4acb..9e83d4659be 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -12,22 +12,6 @@
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
-/*
- * version_hook functions for check_for_data_types_usage in order to determine
- * whether a data type check should be executed for the cluster in question or
- * not.
- */
-bool
-jsonb_9_4_check_applicable(ClusterInfo *cluster)
-{
- /* JSONB changed its storage format during 9.4 beta */
- if (GET_MAJOR_VERSION(cluster->major_version) == 904 &&
- cluster->controldata.cat_ver < JSONB_FORMAT_CHANGE_CAT_VER)
- return true;
-
- return false;
-}
-
/*
* Older servers can't support newer protocol versions, so their connection
* strings will need to lock max_protocol_version to 3.0.
@@ -46,117 +30,6 @@ protocol_negotiation_supported(const ClusterInfo *cluster)
return (GET_MAJOR_VERSION(cluster->major_version) >= 1100);
}
-/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
- */
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
-{
- int dbnum;
- FILE *script = NULL;
- bool found = false;
- char *output_path = "reindex_hash.sql";
-
- prep_status("Checking for hash indexes");
-
- for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
- {
- PGresult *res;
- bool db_used = false;
- int ntups;
- int rowno;
- int i_nspname,
- i_relname;
- DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(cluster, active_db->db_name);
-
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_index i, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
-
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (!check_mode)
- {
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %m", output_path);
- if (!db_used)
- {
- PQExpBufferData connectbuf;
-
- initPQExpBuffer(&connectbuf);
- appendPsqlMetaConnect(&connectbuf, active_db->db_name);
- fputs(connectbuf.data, script);
- termPQExpBuffer(&connectbuf);
- db_used = true;
- }
- fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
- }
- }
-
- PQclear(res);
-
- if (!check_mode && db_used)
- {
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_index i "
- "SET indisvalid = false "
- "FROM pg_catalog.pg_class c, "
- " pg_catalog.pg_am a, "
- " pg_catalog.pg_namespace n "
- "WHERE i.indexrelid = c.oid AND "
- " c.relam = a.oid AND "
- " c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
- }
-
- PQfinish(conn);
- }
-
- if (script)
- fclose(script);
-
- if (found)
- {
- report_status(PG_WARNING, "warning");
- if (check_mode)
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
- else
- pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
- "internal formats between your old and new clusters, so they must be\n"
- "reindexed with the REINDEX command. The file\n"
- " %s\n"
- "when executed by psql by the database superuser will recreate all invalid\n"
- "indexes; until then, none of these indexes will be used.",
- output_path);
- }
- else
- check_ok();
-}
-
/*
* Callback function for processing results of query for
* report_extension_updates()'s UpgradeTask. If the query returned any rows,
--
2.50.1 (Apple Git-155)
[text/plain] v6-0003-psql-bump-minimum-supported-version-to-v10.patch (24.6K, ../../akQkqy1P8vw-1qC9@nathan/4-v6-0003-psql-bump-minimum-supported-version-to-v10.patch)
download | inline diff:
From 680cc0d8d67c2151e870d81bc78337746249b7a8 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 17 Apr 2026 11:34:35 -0700
Subject: [PATCH v6 3/4] psql: bump minimum supported version to v10
---
doc/src/sgml/ref/psql-ref.sgml | 2 +-
src/bin/psql/command.c | 23 +---
src/bin/psql/describe.c | 244 +--------------------------------
src/bin/psql/tab-complete.in.c | 46 +++----
4 files changed, 27 insertions(+), 288 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 7c05afd4719..56c2692e618 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
or an older major version. Backslash commands are particularly likely
to fail if the server is of a newer version than <application>psql</application>
itself. However, backslash commands of the <literal>\d</literal> family should
- work with servers of versions back to 9.2, though not necessarily with
+ work with servers of versions back to 10, though not necessarily with
servers newer than <application>psql</application> itself. The general
functionality of running SQL commands and displaying query results
should also work with servers of a newer major version, but this cannot
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 01b8f11aadd..44ef11d980e 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup)
/*
* Warn if server's major version is newer than ours, or if server
- * predates our support cutoff (currently 9.2).
+ * predates our support cutoff (currently 10).
*/
if (pset.sversion / 100 > client_ver / 100 ||
- pset.sversion < 90200)
+ pset.sversion < 100000)
printf(_("WARNING: %s major version %s, server major version %s.\n"
" Some psql features might not work.\n"),
pset.progname,
@@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED]
+ * Views may have WITH [LOCAL|CASCADED]
* CHECK OPTION. These are not part of the view definition
* returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views (introduced in 9.3) may have
+ * separately. Materialized views may have
* arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- if (pset.sversion >= 90400)
- {
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "
@@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
"LEFT JOIN pg_catalog.pg_namespace n "
"ON c.relnamespace = n.oid WHERE c.oid = %u",
oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "c.reloptions AS reloptions, "
- "NULL AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
- }
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index af3935b0078..ce99137c613 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,9 +3,9 @@
*
* Support for the various \d ("describe") commands. Note that the current
* expectation is that all functions in this file will succeed when working
- * with servers of versions 9.2 and up. It's okay to omit irrelevant
+ * with servers of versions 10 and up. It's okay to omit irrelevant
* information for an old server, but not to fail outright. (But failing
- * against a pre-9.2 server is allowed.)
+ * against a pre-10 server is allowed.)
*
* Copyright (c) 2000-2026, PostgreSQL Global Development Group
*
@@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, true, false, false};
- if (pset.sversion < 90600)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support access methods.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
@@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false};
- /* No "Parallel" column before 9.6 */
- static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
-
if (strlen(functypes) != strspn(functypes, df_options))
{
pg_log_error("\\df only takes [%s] as options", df_options);
@@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- if (pset.sversion >= 90600)
appendPQExpBuffer(&buf,
",\n CASE\n"
" WHEN p.proparallel = "
@@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- if (pset.sversion >= 90600)
- {
myopt.translate_columns = translate_columns;
myopt.n_translate_columns = lengthof(translate_columns);
- }
- else
- {
- myopt.translate_columns = translate_columns_pre_96;
- myopt.n_translate_columns = lengthof(translate_columns_pre_96);
- }
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- if (pset.sversion >= 90500 && pset.sversion < 100000)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
-
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT polname\n"
@@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 100000)
+ else
{
appendPQExpBuffer(&buf,
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname,
: "''"),
oid);
}
- else if (pset.sversion >= 90500)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
- "c.relhasoids, false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else if (pset.sversion >= 90400)
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence, c.relreplident\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
- "c.relhastriggers, false, false, c.relhasoids, "
- "false as relispartition, %s, c.reltablespace, "
- "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
- "c.relpersistence\n"
- "FROM pg_catalog.pg_class c\n "
- "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
- "WHERE c.oid = '%s';",
- (verbose ?
- "pg_catalog.array_to_string(c.reloptions || "
- "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
- : "''"),
- oid);
- }
res = PSQLexec(buf.data);
if (!res)
@@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname,
tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ?
pg_strdup(PQgetvalue(res, 0, 11)) : NULL;
tableinfo.relpersistence = *(PQgetvalue(res, 0, 12));
- tableinfo.relreplident = (pset.sversion >= 90400) ?
- *(PQgetvalue(res, 0, 13)) : 'd';
+ tableinfo.relreplident = *(PQgetvalue(res, 0, 13));
if (pset.sversion >= 120000)
tableinfo.relam = PQgetisnull(res, 0, 14) ?
NULL : pg_strdup(PQgetvalue(res, 0, 14));
@@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- if (pset.sversion >= 100000)
- {
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname,
"FROM pg_catalog.pg_sequence\n"
"WHERE seqrelid = '%s';",
oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "SELECT 'bigint' AS \"%s\",\n"
- " start_value AS \"%s\",\n"
- " min_value AS \"%s\",\n"
- " max_value AS \"%s\",\n"
- " increment_by AS \"%s\",\n"
- " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " cache_value AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname));
- /* must be separate because fmtId isn't reentrant */
- appendPQExpBuffer(&buf, ".%s;", fmtId(relationname));
- }
res = PSQLexec(buf.data);
if (!res)
@@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf, ",\n a.attidentity");
- else
- appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
- else
- appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- if (pset.sversion >= 90400)
appendPQExpBufferStr(&buf, ", i.indisreplident");
- else
- appendPQExpBufferStr(&buf, ", false AS indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- if (pset.sversion >= 90500)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- if (pset.sversion >= 100000)
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
- else
- appendPQExpBufferStr(&buf,
- " 't' as polpermissive,\n");
appendPQExpBuffer(&buf,
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
@@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname,
}
PQclear(result);
}
- else if (pset.sversion >= 100000)
+ else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
@@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- if (pset.sversion >= 100000)
- {
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
if (pset.sversion >= 150000)
@@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddFooter(&cont, buf.data);
}
PQclear(result);
- }
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else if (pset.sversion >= 100000)
+ else
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
" false AS inhdetachpending,"
@@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname,
"ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT',"
" c.oid::pg_catalog.regclass::pg_catalog.text;",
oid);
- else
- appendPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, c.relkind,"
- " false AS inhdetachpending, NULL\n"
- "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
- "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n"
- "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;",
- oid);
result = PSQLexec(buf.data);
if (!result)
@@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
-
- if (pset.sversion >= 90500)
- {
appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
- }
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (pset.sversion >= 90500)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Bypass RLS"));
@@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
const char *tabletitle;
bool mixed_output = false;
- /*
- * Note: Declarative table partitioning is only supported as of Pg 10.0.
- */
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support declarative table partitioning.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
/* If no relation kind was selected, show them all */
if (!showTables && !showIndexes)
showTables = showIndexes = true;
@@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose)
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
- if (pset.sversion < 90300)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support event triggers.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
@@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose)
PGresult *res;
printQueryOpt myopt = pset.popt;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support extended statistics.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
@@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- if (pset.sversion >= 100000)
appendPQExpBuffer(&buf,
" CASE c.collprovider "
"WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
@@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
"WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
"END AS \"%s\",\n",
gettext_noop("Provider"));
- else
- appendPQExpBuffer(&buf,
- " 'libc' AS \"%s\",\n",
- gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
@@ -6688,16 +6486,6 @@ listPublications(const char *pattern)
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
@@ -6835,16 +6623,6 @@ describePublications(const char *pattern)
PQExpBufferData title;
printTableContent cont;
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support publications.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
has_pubsequence = (pset.sversion >= 190000);
has_pubtruncate = (pset.sversion >= 110000);
has_pubgencols = (pset.sversion >= 180000);
@@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose)
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false};
- if (pset.sversion < 100000)
- {
- char sverbuf[32];
-
- pg_log_error("The server (version %s) does not support subscriptions.",
- formatPGVersionNumber(pset.sversion, false,
- sverbuf, sizeof(sverbuf)));
- return true;
- }
-
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index 46b9add0604..f4d842966bf 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC"
" FROM pg_catalog.pg_timezone_names() "\
" WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')"
+#define Query_for_list_of_publications \
+"SELECT pubname "\
+" FROM pg_catalog.pg_publication "\
+" WHERE pubname LIKE '%s'"
+
+#define Query_for_list_of_subscriptions \
+"SELECT s.subname "\
+" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\
+" WHERE s.subname LIKE '%s' "\
+" AND d.datname = pg_catalog.current_database() "\
+" AND s.subdbid = d.oid"
+
/* Privilege options shared between GRANT and REVOKE */
#define Privilege_options_of_grant_and_revoke \
"SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \
@@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \
#define Copy_to_options \
Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY"
-/*
- * These object types were introduced later than our support cutoff of
- * server version 9.2. We use the VersionedQuery infrastructure so that
- * we don't send certain-to-fail queries to older servers.
- */
-
-static const VersionedQuery Query_for_list_of_publications[] = {
- {100000,
- " SELECT pubname "
- " FROM pg_catalog.pg_publication "
- " WHERE pubname LIKE '%s'"
- },
- {0, NULL}
-};
-
-static const VersionedQuery Query_for_list_of_subscriptions[] = {
- {100000,
- " SELECT s.subname "
- " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d "
- " WHERE s.subname LIKE '%s' "
- " AND d.datname = pg_catalog.current_database() "
- " AND s.subdbid = d.oid"
- },
- {0, NULL}
-};
-
/* Known command-starting keywords. */
static const char *const sql_commands[] = {
"ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER",
@@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = {
{"POLICY", NULL, NULL, NULL},
{"PROCEDURE", NULL, NULL, Query_for_list_of_procedures},
{"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs},
- {"PUBLICATION", NULL, Query_for_list_of_publications},
+ {"PUBLICATION", Query_for_list_of_publications},
{"ROLE", Query_for_list_of_roles},
{"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE},
{"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"},
@@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = {
{"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences},
{"SERVER", Query_for_list_of_servers},
{"STATISTICS", NULL, NULL, &Query_for_list_of_statistics},
- {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions},
+ {"SUBSCRIPTION", Query_for_list_of_subscriptions},
{"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
{"TABLE", NULL, NULL, &Query_for_list_of_tables},
{"TABLESPACE", Query_for_list_of_tablespaces},
@@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id,
else if (TailMatchesCS("\\dP*"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations);
else if (TailMatchesCS("\\dRp*"))
- COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications);
+ COMPLETE_WITH_QUERY(Query_for_list_of_publications);
else if (TailMatchesCS("\\dRs*"))
- COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions);
+ COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions);
else if (TailMatchesCS("\\ds*"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences);
else if (TailMatchesCS("\\dt*"))
--
2.50.1 (Apple Git-155)
[text/plain] v6-0004-run-pgindent-and-pgperltidy.patch (65.1K, ../../akQkqy1P8vw-1qC9@nathan/5-v6-0004-run-pgindent-and-pgperltidy.patch)
download | inline diff:
From 0c9782c349a9999649977a1cee041ca1c3d561ee Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Tue, 30 Jun 2026 13:24:59 -0500
Subject: [PATCH v6 4/4] run pgindent and pgperltidy
---
src/bin/pg_dump/pg_dump.c | 464 ++++++++++-----------
src/bin/pg_dump/pg_dumpall.c | 30 +-
src/bin/pg_upgrade/check.c | 16 +-
src/bin/pg_upgrade/controldata.c | 2 +-
src/bin/pg_upgrade/exec.c | 8 +-
src/bin/pg_upgrade/multixact_rewrite.c | 80 ++--
src/bin/pg_upgrade/pg_upgrade.c | 34 +-
src/bin/pg_upgrade/relfilenumber.c | 54 +--
src/bin/pg_upgrade/t/006_transfer_modes.pl | 33 +-
src/bin/psql/command.c | 29 +-
src/bin/psql/describe.c | 461 ++++++++++----------
11 files changed, 601 insertions(+), 610 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 65bd15ebfd2..5673268b467 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1491,8 +1491,8 @@ setup_connection(Archive *AH, const char *dumpencoding,
* Disable timeouts if supported.
*/
ExecuteSqlStatement(AH, "SET statement_timeout = 0");
- ExecuteSqlStatement(AH, "SET lock_timeout = 0");
- ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
+ ExecuteSqlStatement(AH, "SET lock_timeout = 0");
+ ExecuteSqlStatement(AH, "SET idle_in_transaction_session_timeout = 0");
if (AH->remoteVersion >= 170000)
ExecuteSqlStatement(AH, "SET transaction_timeout = 0");
@@ -1505,10 +1505,10 @@ setup_connection(Archive *AH, const char *dumpencoding,
/*
* Adjust row-security mode, if supported.
*/
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security = on");
- else
- ExecuteSqlStatement(AH, "SET row_security = off");
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
/*
* For security reasons, we restrict the expansion of non-system views and
@@ -1933,10 +1933,9 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
addObjectDependency(dobj, ext->dobj.dumpId);
/*
- * Mark the member object to have any non-initial ACLs
- * dumped. (Any initial ACLs will be removed later, using data from
- * pg_init_privs, so that we'll dump only the delta from the extension's
- * initial setup.)
+ * Mark the member object to have any non-initial ACLs dumped. (Any
+ * initial ACLs will be removed later, using data from pg_init_privs, so
+ * that we'll dump only the delta from the extension's initial setup.)
*
* In binary upgrades, we still dump all components of the members
* individually, since the idea is to exactly reproduce the database
@@ -1953,7 +1952,7 @@ checkExtensionMembership(DumpableObject *dobj, Archive *fout)
if (fout->dopt->binary_upgrade)
dobj->dump = ext->dobj.dump;
else
- dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
+ dobj->dump = ext->dobj.dump_contains & (DUMP_COMPONENT_ACL);
return true;
}
@@ -1987,9 +1986,9 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
else if (strcmp(nsinfo->dobj.name, "pg_catalog") == 0)
{
/*
- * We dump out any ACLs defined in pg_catalog, if
- * they are interesting (and not the original ACLs which were set at
- * initdb time, see pg_init_privs).
+ * We dump out any ACLs defined in pg_catalog, if they are interesting
+ * (and not the original ACLs which were set at initdb time, see
+ * pg_init_privs).
*/
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ACL;
}
@@ -3296,7 +3295,7 @@ dumpDatabase(Archive *fout)
"datcollate, datctype, datfrozenxid, "
"datacl, acldefault('d', datdba) AS acldefault, "
"datistemplate, datconnlimit, ");
- appendPQExpBufferStr(dbQry, "datminmxid, ");
+ appendPQExpBufferStr(dbQry, "datminmxid, ");
if (fout->remoteVersion >= 170000)
appendPQExpBufferStr(dbQry, "datlocprovider, datlocale, datcollversion, ");
else if (fout->remoteVersion >= 150000)
@@ -3638,11 +3637,11 @@ dumpDatabase(Archive *fout)
ii_oid,
ii_relminmxid;
- appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
- "FROM pg_catalog.pg_class\n"
- "WHERE oid IN (%u, %u, %u, %u);\n",
- LargeObjectRelationId, LargeObjectLOidPNIndexId,
- LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
+ appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
+ "FROM pg_catalog.pg_class\n"
+ "WHERE oid IN (%u, %u, %u, %u);\n",
+ LargeObjectRelationId, LargeObjectLOidPNIndexId,
+ LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
lo_res = ExecuteSqlQuery(fout, loFrozenQry->data, PGRES_TUPLES_OK);
@@ -4274,7 +4273,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
printfPQExpBuffer(query,
"SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
- appendPQExpBufferStr(query, "pol.polpermissive, ");
+ appendPQExpBufferStr(query, "pol.polpermissive, ");
appendPQExpBuffer(query,
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
@@ -6633,9 +6632,9 @@ getAccessMethods(Archive *fout)
* Select all access methods from pg_am table.
*/
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, ");
- appendPQExpBufferStr(query,
- "amtype, "
- "amhandler::pg_catalog.regproc AS amhandler ");
+ appendPQExpBufferStr(query,
+ "amtype, "
+ "amhandler::pg_catalog.regproc AS amhandler ");
appendPQExpBufferStr(query, "FROM pg_am");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6827,35 +6826,35 @@ getAggregates(Archive *fout)
* Find all interesting aggregates. See comment in getFuncs() for the
* rationale behind the filtering logic.
*/
- agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
- : "p.proisagg");
+ agg_check = (fout->remoteVersion >= 110000 ? "p.prokind = 'a'"
+ : "p.proisagg");
- appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
- "p.proname AS aggname, "
- "p.pronamespace AS aggnamespace, "
- "p.pronargs, p.proargtypes, "
- "p.proowner, "
- "p.proacl AS aggacl, "
- "acldefault('f', p.proowner) AS acldefault "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s AND ("
- "p.pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog') OR "
- "p.proacl IS DISTINCT FROM pip.initprivs",
- agg_check);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
- appendPQExpBufferChar(query, ')');
+ appendPQExpBuffer(query, "SELECT p.tableoid, p.oid, "
+ "p.proname AS aggname, "
+ "p.pronamespace AS aggnamespace, "
+ "p.pronargs, p.proargtypes, "
+ "p.proowner, "
+ "p.proacl AS aggacl, "
+ "acldefault('f', p.proowner) AS acldefault "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s AND ("
+ "p.pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog') OR "
+ "p.proacl IS DISTINCT FROM pip.initprivs",
+ agg_check);
+ if (dopt->binary_upgrade)
+ appendPQExpBufferStr(query,
+ " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6957,53 +6956,53 @@ getFuncs(Archive *fout)
* include them, since we want to dump extension members individually in
* that mode. Also, if they are used by casts or transforms then we need
* to gather the information about them, though they won't be dumped if
- * they are built-in. Also, include functions in
- * pg_catalog if they have an ACL different from what's shown in
- * pg_init_privs (so we have to join to pg_init_privs; annoying).
+ * they are built-in. Also, include functions in pg_catalog if they have
+ * an ACL different from what's shown in pg_init_privs (so we have to join
+ * to pg_init_privs; annoying).
*/
- not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
- : "NOT p.proisagg");
+ not_agg_check = (fout->remoteVersion >= 110000 ? "p.prokind <> 'a'"
+ : "NOT p.proisagg");
- appendPQExpBuffer(query,
- "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
- "p.pronargs, p.proargtypes, p.prorettype, "
- "p.proacl, "
- "acldefault('f', p.proowner) AS acldefault, "
- "p.pronamespace, "
- "p.proowner "
- "FROM pg_proc p "
- "LEFT JOIN pg_init_privs pip ON "
- "(p.oid = pip.objoid "
- "AND pip.classoid = 'pg_proc'::regclass "
- "AND pip.objsubid = 0) "
- "WHERE %s"
- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
- "WHERE classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND deptype = 'i')"
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > %u "
- "\n AND p.oid = pg_cast.castfunc)"
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > %u AND "
- "\n (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- not_agg_check,
- g_last_builtin_oid,
- g_last_builtin_oid);
- if (dopt->binary_upgrade)
- appendPQExpBufferStr(query,
- "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
- "classid = 'pg_proc'::regclass AND "
- "objid = p.oid AND "
- "refclassid = 'pg_extension'::regclass AND "
- "deptype = 'e')");
+ appendPQExpBuffer(query,
+ "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
+ "p.pronargs, p.proargtypes, p.prorettype, "
+ "p.proacl, "
+ "acldefault('f', p.proowner) AS acldefault, "
+ "p.pronamespace, "
+ "p.proowner "
+ "FROM pg_proc p "
+ "LEFT JOIN pg_init_privs pip ON "
+ "(p.oid = pip.objoid "
+ "AND pip.classoid = 'pg_proc'::regclass "
+ "AND pip.objsubid = 0) "
+ "WHERE %s"
+ "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
+ "WHERE classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND deptype = 'i')"
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > %u "
+ "\n AND p.oid = pg_cast.castfunc)"
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > %u AND "
+ "\n (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ not_agg_check,
+ g_last_builtin_oid,
+ g_last_builtin_oid);
+ if (dopt->binary_upgrade)
appendPQExpBufferStr(query,
- "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
- appendPQExpBufferChar(query, ')');
+ "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
+ "classid = 'pg_proc'::regclass AND "
+ "objid = p.oid AND "
+ "refclassid = 'pg_extension'::regclass AND "
+ "deptype = 'e')");
+ appendPQExpBufferStr(query,
+ "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
+ appendPQExpBufferChar(query, ')');
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -7252,31 +7251,31 @@ getTables(Archive *fout, int *numTables)
appendPQExpBufferStr(query,
"c.relhasoids, ");
- appendPQExpBufferStr(query,
- "c.relispopulated, ");
+ appendPQExpBufferStr(query,
+ "c.relispopulated, ");
- appendPQExpBufferStr(query,
- "c.relreplident, ");
+ appendPQExpBufferStr(query,
+ "c.relreplident, ");
- appendPQExpBufferStr(query,
- "c.relrowsecurity, c.relforcerowsecurity, ");
+ appendPQExpBufferStr(query,
+ "c.relrowsecurity, c.relforcerowsecurity, ");
- appendPQExpBufferStr(query,
- "c.relminmxid, tc.relminmxid AS tminmxid, ");
+ appendPQExpBufferStr(query,
+ "c.relminmxid, tc.relminmxid AS tminmxid, ");
- appendPQExpBufferStr(query,
- "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
+ appendPQExpBufferStr(query,
+ "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
- appendPQExpBufferStr(query,
- "am.amname, ");
+ appendPQExpBufferStr(query,
+ "am.amname, ");
- appendPQExpBufferStr(query,
- "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
+ appendPQExpBufferStr(query,
+ "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
- appendPQExpBufferStr(query,
- "c.relispartition AS ispartition ");
+ appendPQExpBufferStr(query,
+ "c.relispartition AS ispartition ");
/*
* Left join to pg_depend to pick up dependency info linking sequences to
@@ -7296,8 +7295,8 @@ getTables(Archive *fout, int *numTables)
/*
* Left join to pg_am to pick up the amname.
*/
- appendPQExpBufferStr(query,
- "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
+ appendPQExpBufferStr(query,
+ "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
/*
* We purposefully ignore toast OIDs for partitioned tables; the reason is
@@ -7868,8 +7867,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
"t.reloptions AS indreloptions, ");
- appendPQExpBufferStr(query,
- "i.indisreplident, ");
+ appendPQExpBufferStr(query,
+ "i.indisreplident, ");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -9313,8 +9312,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBufferStr(q,
"'' AS attcompression,\n");
- appendPQExpBufferStr(q,
- "a.attidentity,\n");
+ appendPQExpBufferStr(q,
+ "a.attidentity,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(q,
@@ -10717,73 +10716,73 @@ getAdditionalACLs(Archive *fout)
PQclear(res);
/* Fetch initial-privileges data */
- printfPQExpBuffer(query,
- "SELECT objoid, classoid, objsubid, privtype, initprivs "
- "FROM pg_init_privs");
+ printfPQExpBuffer(query,
+ "SELECT objoid, classoid, objsubid, privtype, initprivs "
+ "FROM pg_init_privs");
- res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
+ res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- ntups = PQntuples(res);
- for (i = 0; i < ntups; i++)
- {
- Oid objoid = atooid(PQgetvalue(res, i, 0));
- Oid classoid = atooid(PQgetvalue(res, i, 1));
- int objsubid = atoi(PQgetvalue(res, i, 2));
- char privtype = *(PQgetvalue(res, i, 3));
- char *initprivs = PQgetvalue(res, i, 4);
- CatalogId objId;
- DumpableObject *dobj;
+ ntups = PQntuples(res);
+ for (i = 0; i < ntups; i++)
+ {
+ Oid objoid = atooid(PQgetvalue(res, i, 0));
+ Oid classoid = atooid(PQgetvalue(res, i, 1));
+ int objsubid = atoi(PQgetvalue(res, i, 2));
+ char privtype = *(PQgetvalue(res, i, 3));
+ char *initprivs = PQgetvalue(res, i, 4);
+ CatalogId objId;
+ DumpableObject *dobj;
- objId.tableoid = classoid;
- objId.oid = objoid;
- dobj = findObjectByCatalogId(objId);
- /* OK to ignore entries we haven't got a DumpableObject for */
- if (dobj)
+ objId.tableoid = classoid;
+ objId.oid = objoid;
+ dobj = findObjectByCatalogId(objId);
+ /* OK to ignore entries we haven't got a DumpableObject for */
+ if (dobj)
+ {
+ /* Cope with sub-object initprivs */
+ if (objsubid != 0)
{
- /* Cope with sub-object initprivs */
- if (objsubid != 0)
- {
- if (dobj->objType == DO_TABLE)
- {
- /* For a column initprivs, set the table's ACL flags */
- dobj->components |= DUMP_COMPONENT_ACL;
- ((TableInfo *) dobj)->hascolumnACLs = true;
- }
- else
- pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
- classoid, objoid, objsubid);
- continue;
- }
-
- /*
- * We ignore any pg_init_privs.initprivs entry for the public
- * schema, as explained in getNamespaces().
- */
- if (dobj->objType == DO_NAMESPACE &&
- strcmp(dobj->name, "public") == 0)
- continue;
-
- /* Else it had better be of a type we think has ACLs */
- if (dobj->objType == DO_NAMESPACE ||
- dobj->objType == DO_TYPE ||
- dobj->objType == DO_FUNC ||
- dobj->objType == DO_AGG ||
- dobj->objType == DO_TABLE ||
- dobj->objType == DO_PROCLANG ||
- dobj->objType == DO_FDW ||
- dobj->objType == DO_FOREIGN_SERVER)
+ if (dobj->objType == DO_TABLE)
{
- DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
-
- daobj->dacl.privtype = privtype;
- daobj->dacl.initprivs = pstrdup(initprivs);
+ /* For a column initprivs, set the table's ACL flags */
+ dobj->components |= DUMP_COMPONENT_ACL;
+ ((TableInfo *) dobj)->hascolumnACLs = true;
}
else
pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
classoid, objoid, objsubid);
+ continue;
+ }
+
+ /*
+ * We ignore any pg_init_privs.initprivs entry for the public
+ * schema, as explained in getNamespaces().
+ */
+ if (dobj->objType == DO_NAMESPACE &&
+ strcmp(dobj->name, "public") == 0)
+ continue;
+
+ /* Else it had better be of a type we think has ACLs */
+ if (dobj->objType == DO_NAMESPACE ||
+ dobj->objType == DO_TYPE ||
+ dobj->objType == DO_FUNC ||
+ dobj->objType == DO_AGG ||
+ dobj->objType == DO_TABLE ||
+ dobj->objType == DO_PROCLANG ||
+ dobj->objType == DO_FDW ||
+ dobj->objType == DO_FOREIGN_SERVER)
+ {
+ DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj;
+
+ daobj->dacl.privtype = privtype;
+ daobj->dacl.initprivs = pstrdup(initprivs);
}
+ else
+ pg_log_warning("unsupported pg_init_privs entry: %u %u %d",
+ classoid, objoid, objsubid);
}
- PQclear(res);
+ }
+ PQclear(res);
destroyPQExpBuffer(query);
}
@@ -11128,8 +11127,8 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
* The results must be in the order of the relations supplied in the
* parameters to ensure we remain in sync as we walk through the TOC.
*
- * For versions before 19, the redundant filter clause on s.tablename =
- * ANY(...) seems sufficient to convince the planner to use
+ * For versions before 19, the redundant filter clause on s.tablename
+ * = ANY(...) seems sufficient to convince the planner to use
* pg_class_relname_nsp_index, which avoids a full scan of pg_stats.
* In newer versions, pg_stats returns the table OIDs, eliminating the
* need for that hack.
@@ -13469,11 +13468,11 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
"pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
"proleakproof,\n");
- appendPQExpBufferStr(query,
- "array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ appendPQExpBufferStr(query,
+ "array_to_string(protrftypes, ' ') AS protrftypes,\n");
- appendPQExpBufferStr(query,
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -14963,9 +14962,9 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
/* Get collation-specific details */
appendPQExpBufferStr(query, "SELECT ");
- appendPQExpBufferStr(query,
- "collprovider, "
- "collversion, ");
+ appendPQExpBufferStr(query,
+ "collprovider, "
+ "collversion, ");
if (fout->remoteVersion >= 120000)
appendPQExpBufferStr(query,
@@ -15372,23 +15371,23 @@ dumpAgg(Archive *fout, const AggInfo *agginfo)
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
- appendPQExpBufferStr(query,
- "aggkind,\n"
- "aggmtransfn,\n"
- "aggminvtransfn,\n"
- "aggmfinalfn,\n"
- "aggmtranstype::pg_catalog.regtype,\n"
- "aggfinalextra,\n"
- "aggmfinalextra,\n"
- "aggtransspace,\n"
- "aggmtransspace,\n"
- "aggminitval,\n");
+ appendPQExpBufferStr(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+ "aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
- appendPQExpBufferStr(query,
- "aggcombinefn,\n"
- "aggserialfn,\n"
- "aggdeserialfn,\n"
- "proparallel,\n");
+ appendPQExpBufferStr(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
if (fout->remoteVersion >= 110000)
appendPQExpBufferStr(query,
@@ -16848,30 +16847,30 @@ dumpTable(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query,
"PREPARE getColumnACLs(pg_catalog.oid) AS\n");
- /*
- * In principle we should call acldefault('c', relowner) to
- * get the default ACL for a column. However, we don't
- * currently store the numeric OID of the relowner in
- * TableInfo. We could convert the owner name using regrole,
- * but that creates a risk of failure due to concurrent role
- * renames. Given that the default ACL for columns is empty
- * and is likely to stay that way, it's not worth extra cycles
- * and risk to avoid hard-wiring that knowledge here.
- */
- appendPQExpBufferStr(query,
- "SELECT at.attname, "
- "at.attacl, "
- "'{}' AS acldefault, "
- "pip.privtype, pip.initprivs "
- "FROM pg_catalog.pg_attribute at "
- "LEFT JOIN pg_catalog.pg_init_privs pip ON "
- "(at.attrelid = pip.objoid "
- "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
- "AND at.attnum = pip.objsubid) "
- "WHERE at.attrelid = $1 AND "
- "NOT at.attisdropped "
- "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
- "ORDER BY at.attnum");
+ /*
+ * In principle we should call acldefault('c', relowner) to get
+ * the default ACL for a column. However, we don't currently
+ * store the numeric OID of the relowner in TableInfo. We could
+ * convert the owner name using regrole, but that creates a risk
+ * of failure due to concurrent role renames. Given that the
+ * default ACL for columns is empty and is likely to stay that
+ * way, it's not worth extra cycles and risk to avoid hard-wiring
+ * that knowledge here.
+ */
+ appendPQExpBufferStr(query,
+ "SELECT at.attname, "
+ "at.attacl, "
+ "'{}' AS acldefault, "
+ "pip.privtype, pip.initprivs "
+ "FROM pg_catalog.pg_attribute at "
+ "LEFT JOIN pg_catalog.pg_init_privs pip ON "
+ "(at.attrelid = pip.objoid "
+ "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
+ "AND at.attnum = pip.objsubid) "
+ "WHERE at.attrelid = $1 AND "
+ "NOT at.attisdropped "
+ "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
+ "ORDER BY at.attnum");
ExecuteSqlStatement(fout, query->data);
@@ -19165,7 +19164,7 @@ collectSequences(Archive *fout)
* pg_get_sequence_data(), but we only do so for non-schema-only dumps.
*/
if (fout->remoteVersion < 180000 ||
- (!fout->dopt->dumpData && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
@@ -19227,15 +19226,14 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
qseqname = pg_strdup(fmtId(tbinfo->dobj.name));
/*
- * The sequence information is gathered in a sorted
- * table before any calls to dumpSequence(). See collectSequences() for
- * more information.
+ * The sequence information is gathered in a sorted table before any calls
+ * to dumpSequence(). See collectSequences() for more information.
*/
- Assert(sequences);
+ Assert(sequences);
- key.oid = tbinfo->dobj.catId.oid;
- seq = bsearch(&key, sequences, nsequences,
- sizeof(SequenceItem), SequenceItemCmp);
+ key.oid = tbinfo->dobj.catId.oid;
+ seq = bsearch(&key, sequences, nsequences,
+ sizeof(SequenceItem), SequenceItemCmp);
/* Calculate default limits for a sequence of this type */
is_ascending = (seq->incby >= 0);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index e68937c9934..afcd9a218d8 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -785,11 +785,11 @@ dropRoles(PGconn *conn)
int i_rolname;
int i;
- printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
res = executeQuery(conn, buf->data);
@@ -843,16 +843,16 @@ dumpRoles(PGconn *conn)
* Notes: rolconfig is dumped later, and pg_authid must be used for
* extracting rolcomment regardless of role_catalog.
*/
- printfPQExpBuffer(buf,
- "SELECT oid, rolname, rolsuper, rolinherit, "
- "rolcreaterole, rolcreatedb, "
- "rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
- "rolname = current_user AS is_current_user "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 2", role_catalog);
+ printfPQExpBuffer(buf,
+ "SELECT oid, rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, rolreplication, rolbypassrls, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
+ "rolname = current_user AS is_current_user "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 2", role_catalog);
res = executeQuery(conn, buf->data);
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 786c1474829..f725f5ee3e2 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1475,15 +1475,15 @@ check_for_incompatible_polymorphics(ClusterInfo *cluster)
", 'array_cat(anyarray,anyarray)'"
", 'array_prepend(anyelement,anyarray)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_remove(anyarray,anyelement)'"
- ", 'array_replace(anyarray,anyelement,anyelement)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_remove(anyarray,anyelement)'"
+ ", 'array_replace(anyarray,anyelement,anyelement)'");
- appendPQExpBufferStr(&old_polymorphics,
- ", 'array_position(anyarray,anyelement)'"
- ", 'array_position(anyarray,anyelement,integer)'"
- ", 'array_positions(anyarray,anyelement)'"
- ", 'width_bucket(anyelement,anyarray)'");
+ appendPQExpBufferStr(&old_polymorphics,
+ ", 'array_position(anyarray,anyelement)'"
+ ", 'array_position(anyarray,anyelement,integer)'"
+ ", 'array_positions(anyarray,anyelement)'"
+ ", 'width_bucket(anyelement,anyarray)'");
/*
* The query below hardcodes FirstNormalObjectId as 16384 rather than
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 8f81c9e9582..02ea02df60f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -228,7 +228,7 @@ get_control_data(ClusterInfo *cluster)
p++; /* remove ':' char */
cluster->controldata.chkpnt_nxtepoch = str2uint(p);
- p = strchr(p, ':');
+ p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 44355feea30..a1bdbf373e3 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -55,7 +55,7 @@ get_bin_version(ClusterInfo *cluster)
if (sscanf(cmd_output, "%*s %*s %d.%d", &v1, &v2) < 1)
pg_fatal("could not get pg_ctl version output from %s", cmd);
- cluster->bin_version = v1 * 10000;
+ cluster->bin_version = v1 * 10000;
}
@@ -344,8 +344,8 @@ check_data_dir(ClusterInfo *cluster)
check_single_dir(pg_data, "pg_subtrans");
check_single_dir(pg_data, PG_TBLSPC_DIR);
check_single_dir(pg_data, "pg_twophase");
- check_single_dir(pg_data, "pg_wal");
- check_single_dir(pg_data, "pg_xact");
+ check_single_dir(pg_data, "pg_wal");
+ check_single_dir(pg_data, "pg_xact");
}
@@ -385,7 +385,7 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions)
*/
get_bin_version(cluster);
- check_exec(cluster->bindir, "pg_resetwal", check_versions);
+ check_exec(cluster->bindir, "pg_resetwal", check_versions);
if (cluster == &new_cluster)
{
diff --git a/src/bin/pg_upgrade/multixact_rewrite.c b/src/bin/pg_upgrade/multixact_rewrite.c
index c45b3183684..c7a1416494d 100644
--- a/src/bin/pg_upgrade/multixact_rewrite.c
+++ b/src/bin/pg_upgrade/multixact_rewrite.c
@@ -61,52 +61,52 @@ rewrite_multixacts(MultiXactId from_multi, MultiXactId to_multi)
* Convert old multixids, if needed, by reading them one-by-one from the
* old cluster.
*/
- old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_nxtmxoff);
+ old_reader = AllocOldMultiXactRead(old_cluster.pgdata,
+ old_cluster.controldata.chkpnt_nxtmulti,
+ old_cluster.controldata.chkpnt_nxtmxoff);
- for (MultiXactId multi = from_multi; multi != to_multi;)
- {
- MultiXactMember member;
- bool multixid_valid;
-
- /*
- * Read this multixid's members.
- *
- * Locking-only XIDs that may be part of multi-xids don't matter
- * after upgrade, as there can be no transactions running across
- * upgrade. So as a small optimization, we only read one member
- * from each multixid: the one updating one, or if there was no
- * update, arbitrarily the first locking xid.
- */
- multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
+ for (MultiXactId multi = from_multi; multi != to_multi;)
+ {
+ MultiXactMember member;
+ bool multixid_valid;
- /*
- * Write the new offset to pg_multixact/offsets.
- *
- * Even if this multixid is invalid, we still need to write its
- * offset if the *previous* multixid was valid. That's because
- * when reading a multixid, the number of members is calculated
- * from the difference between the two offsets.
- */
- RecordMultiXactOffset(offsets_writer, multi,
- (multixid_valid || prev_multixid_valid) ? next_offset : 0);
+ /*
+ * Read this multixid's members.
+ *
+ * Locking-only XIDs that may be part of multi-xids don't matter after
+ * upgrade, as there can be no transactions running across upgrade. So
+ * as a small optimization, we only read one member from each
+ * multixid: the one updating one, or if there was no update,
+ * arbitrarily the first locking xid.
+ */
+ multixid_valid = GetOldMultiXactIdSingleMember(old_reader, multi, &member);
- /* Write the members */
- if (multixid_valid)
- {
- RecordMultiXactMembers(members_writer, next_offset, 1, &member);
- next_offset += 1;
- }
+ /*
+ * Write the new offset to pg_multixact/offsets.
+ *
+ * Even if this multixid is invalid, we still need to write its offset
+ * if the *previous* multixid was valid. That's because when reading
+ * a multixid, the number of members is calculated from the difference
+ * between the two offsets.
+ */
+ RecordMultiXactOffset(offsets_writer, multi,
+ (multixid_valid || prev_multixid_valid) ? next_offset : 0);
- /* Advance to next multixid, handling wraparound */
- multi++;
- if (multi < FirstMultiXactId)
- multi = FirstMultiXactId;
- prev_multixid_valid = multixid_valid;
+ /* Write the members */
+ if (multixid_valid)
+ {
+ RecordMultiXactMembers(members_writer, next_offset, 1, &member);
+ next_offset += 1;
}
- FreeOldMultiXactReader(old_reader);
+ /* Advance to next multixid, handling wraparound */
+ multi++;
+ if (multi < FirstMultiXactId)
+ multi = FirstMultiXactId;
+ prev_multixid_valid = multixid_valid;
+ }
+
+ FreeOldMultiXactReader(old_reader);
/* Write the final 'next' offset to the last SLRU page */
RecordMultiXactOffset(offsets_writer, to_multi,
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index c6af9035665..7366fd4627c 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -833,7 +833,7 @@ copy_xact_xlog_xid(void)
* Determine the range of multixacts to convert.
*/
nxtmulti = old_cluster.controldata.chkpnt_nxtmulti;
- oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
+ oldstMulti = old_cluster.controldata.chkpnt_oldstMulti;
/* handle wraparound */
if (nxtmulti < FirstMultiXactId)
nxtmulti = FirstMultiXactId;
@@ -898,15 +898,15 @@ set_frozenxids(void)
int i_datname;
int i_datallowconn;
- prep_status("Setting frozenxid and minmxid counters in new cluster");
+ prep_status("Setting frozenxid and minmxid counters in new cluster");
conn_template1 = connectToServer(&new_cluster, "template1");
- /* set pg_database.datfrozenxid */
- PQclear(executeQueryOrDie(conn_template1,
- "UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ /* set pg_database.datfrozenxid */
+ PQclear(executeQueryOrDie(conn_template1,
+ "UPDATE pg_catalog.pg_database "
+ "SET datfrozenxid = '%u'",
+ old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
@@ -942,16 +942,16 @@ set_frozenxids(void)
conn = connectToServer(&new_cluster, datname);
- /* set pg_class.relfrozenxid */
- PQclear(executeQueryOrDie(conn,
- "UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
- /* only heap, materialized view, and TOAST are vacuumed */
- "WHERE relkind IN ("
- CppAsString2(RELKIND_RELATION) ", "
- CppAsString2(RELKIND_MATVIEW) ", "
- CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ /* set pg_class.relfrozenxid */
+ PQclear(executeQueryOrDie(conn,
+ "UPDATE pg_catalog.pg_class "
+ "SET relfrozenxid = '%u' "
+ /* only heap, materialized view, and TOAST are vacuumed */
+ "WHERE relkind IN ("
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) ", "
+ CppAsString2(RELKIND_TOASTVALUE) ")",
+ old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index ec2ff7acb21..6c467bdc8a5 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -587,32 +587,32 @@ transfer_relfile(FileNameMap *map, const char *type_suffix)
/* Copying files might take some time, so give feedback. */
pg_log(PG_STATUS, "%s", old_file);
- switch (user_opts.transfer_mode)
- {
- case TRANSFER_MODE_CLONE:
- pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
- old_file, new_file);
- cloneFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
- old_file, new_file);
- copyFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_COPY_FILE_RANGE:
- pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
- old_file, new_file);
- copyFileByRange(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_LINK:
- pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
- old_file, new_file);
- linkFile(old_file, new_file, map->nspname, map->relname);
- break;
- case TRANSFER_MODE_SWAP:
- /* swap mode is handled in its own code path */
- pg_fatal("should never happen");
- break;
- }
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_COPY_FILE_RANGE:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\" with copy_file_range",
+ old_file, new_file);
+ copyFileByRange(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, map->nspname, map->relname);
+ break;
+ case TRANSFER_MODE_SWAP:
+ /* swap mode is handled in its own code path */
+ pg_fatal("should never happen");
+ break;
+ }
}
}
diff --git a/src/bin/pg_upgrade/t/006_transfer_modes.pl b/src/bin/pg_upgrade/t/006_transfer_modes.pl
index 9efa5dc863c..360d05c4b68 100644
--- a/src/bin/pg_upgrade/t/006_transfer_modes.pl
+++ b/src/bin/pg_upgrade/t/006_transfer_modes.pl
@@ -29,10 +29,8 @@ sub test_mode
}
$new->init();
- $new->append_conf('postgresql.conf',
- "allow_in_place_tablespaces = true");
- $old->append_conf('postgresql.conf',
- "allow_in_place_tablespaces = true");
+ $new->append_conf('postgresql.conf', "allow_in_place_tablespaces = true");
+ $old->append_conf('postgresql.conf', "allow_in_place_tablespaces = true");
# We can only test security labels if both the old and new installations
# have dummy_seclabel.
@@ -76,15 +74,14 @@ sub test_mode
"CREATE TABLE test4 AS SELECT generate_series(400, 502)");
}
- $old->safe_psql('postgres',
- "CREATE TABLESPACE inplc_tblspc LOCATION ''");
- $old->safe_psql('postgres',
- "CREATE DATABASE testdb3 TABLESPACE inplc_tblspc");
- $old->safe_psql('postgres',
- "CREATE TABLE test5 TABLESPACE inplc_tblspc AS SELECT generate_series(503, 606)"
- );
- $old->safe_psql('testdb3',
- "CREATE TABLE test6 AS SELECT generate_series(607, 711)");
+ $old->safe_psql('postgres', "CREATE TABLESPACE inplc_tblspc LOCATION ''");
+ $old->safe_psql('postgres',
+ "CREATE DATABASE testdb3 TABLESPACE inplc_tblspc");
+ $old->safe_psql('postgres',
+ "CREATE TABLE test5 TABLESPACE inplc_tblspc AS SELECT generate_series(503, 606)"
+ );
+ $old->safe_psql('testdb3',
+ "CREATE TABLE test6 AS SELECT generate_series(607, 711)");
# While we are here, test handling of large objects.
$old->safe_psql(
@@ -152,12 +149,10 @@ sub test_mode
}
# Tests for in-place tablespaces.
- $result =
- $new->safe_psql('postgres', "SELECT COUNT(*) FROM test5");
- is($result, '104', "test5 data after pg_upgrade $mode");
- $result =
- $new->safe_psql('testdb3', "SELECT COUNT(*) FROM test6");
- is($result, '105', "test6 data after pg_upgrade $mode");
+ $result = $new->safe_psql('postgres', "SELECT COUNT(*) FROM test5");
+ is($result, '104', "test5 data after pg_upgrade $mode");
+ $result = $new->safe_psql('testdb3', "SELECT COUNT(*) FROM test6");
+ is($result, '105', "test6 data after pg_upgrade $mode");
# Tests for large objects
$result = $new->safe_psql('postgres', "SELECT lo_get(4532)");
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 44ef11d980e..c90bf8bbde2 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -6278,23 +6278,22 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* ensure the right view gets replaced. Also, check relation kind
* to be sure it's a view.
*
- * Views may have WITH [LOCAL|CASCADED]
- * CHECK OPTION. These are not part of the view definition
- * returned by pg_get_viewdef() and so need to be retrieved
- * separately. Materialized views may have
- * arbitrary storage parameter reloptions.
+ * Views may have WITH [LOCAL|CASCADED] CHECK OPTION. These are
+ * not part of the view definition returned by pg_get_viewdef()
+ * and so need to be retrieved separately. Materialized views may
+ * have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
- appendPQExpBuffer(query,
- "SELECT nspname, relname, relkind, "
- "pg_catalog.pg_get_viewdef(c.oid, true), "
- "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
- "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
- "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
- "FROM pg_catalog.pg_class c "
- "LEFT JOIN pg_catalog.pg_namespace n "
- "ON c.relnamespace = n.oid WHERE c.oid = %u",
- oid);
+ appendPQExpBuffer(query,
+ "SELECT nspname, relname, relkind, "
+ "pg_catalog.pg_get_viewdef(c.oid, true), "
+ "pg_catalog.array_remove(pg_catalog.array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
+ "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
+ "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption "
+ "FROM pg_catalog.pg_class c "
+ "LEFT JOIN pg_catalog.pg_namespace n "
+ "ON c.relnamespace = n.oid WHERE c.oid = %u",
+ oid);
break;
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index ce99137c613..ac0c55e7aa5 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -387,19 +387,19 @@ describeFunctions(const char *functypes, const char *func_pattern,
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"));
- appendPQExpBuffer(&buf,
- ",\n CASE\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
- " WHEN p.proparallel = "
- CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
- " END as \"%s\"",
- gettext_noop("restricted"),
- gettext_noop("safe"),
- gettext_noop("unsafe"),
- gettext_noop("Parallel"));
+ appendPQExpBuffer(&buf,
+ ",\n CASE\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_RESTRICTED) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_SAFE) " THEN '%s'\n"
+ " WHEN p.proparallel = "
+ CppAsString2(PROPARALLEL_UNSAFE) " THEN '%s'\n"
+ " END as \"%s\"",
+ gettext_noop("restricted"),
+ gettext_noop("safe"),
+ gettext_noop("unsafe"),
+ gettext_noop("Parallel"));
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\""
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
@@ -599,8 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern,
myopt.title = _("List of functions");
myopt.translate_header = true;
- myopt.translate_columns = translate_columns;
- myopt.n_translate_columns = lengthof(translate_columns);
+ myopt.translate_columns = translate_columns;
+ myopt.n_translate_columns = lengthof(translate_columns);
printQuery(res, &myopt, pset.queryFout, false, pset.logfile);
@@ -1086,38 +1086,38 @@ permissionsList(const char *pattern, bool showSystem)
" ), E'\\n') AS \"%s\"",
gettext_noop("Column privileges"));
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.array_to_string(ARRAY(\n"
- " SELECT polname\n"
- " || CASE WHEN NOT polpermissive THEN\n"
- " E' (RESTRICTIVE)'\n"
- " ELSE '' END\n"
- " || CASE WHEN polcmd != '*' THEN\n"
- " E' (' || polcmd::pg_catalog.text || E'):'\n"
- " ELSE E':'\n"
- " END\n"
- " || CASE WHEN polqual IS NOT NULL THEN\n"
- " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
- " ELSE E''\n"
- " END\n"
- " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
- " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
- " ELSE E''\n"
- " END"
- " || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
- " ARRAY(\n"
- " SELECT rolname\n"
- " FROM pg_catalog.pg_roles\n"
- " WHERE oid = ANY (polroles)\n"
- " ORDER BY 1\n"
- " ), E', ')\n"
- " ELSE E''\n"
- " END\n"
- " FROM pg_catalog.pg_policy pol\n"
- " WHERE polrelid = c.oid), E'\\n')\n"
- " AS \"%s\"",
- gettext_noop("Policies"));
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.array_to_string(ARRAY(\n"
+ " SELECT polname\n"
+ " || CASE WHEN NOT polpermissive THEN\n"
+ " E' (RESTRICTIVE)'\n"
+ " ELSE '' END\n"
+ " || CASE WHEN polcmd != '*' THEN\n"
+ " E' (' || polcmd::pg_catalog.text || E'):'\n"
+ " ELSE E':'\n"
+ " END\n"
+ " || CASE WHEN polqual IS NOT NULL THEN\n"
+ " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n"
+ " ELSE E''\n"
+ " END\n"
+ " || CASE WHEN polwithcheck IS NOT NULL THEN\n"
+ " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n"
+ " ELSE E''\n"
+ " END"
+ " || CASE WHEN polroles <> '{0}' THEN\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " ARRAY(\n"
+ " SELECT rolname\n"
+ " FROM pg_catalog.pg_roles\n"
+ " WHERE oid = ANY (polroles)\n"
+ " ORDER BY 1\n"
+ " ), E', ')\n"
+ " ELSE E''\n"
+ " END\n"
+ " FROM pg_catalog.pg_policy pol\n"
+ " WHERE polrelid = c.oid), E'\\n')\n"
+ " AS \"%s\"",
+ gettext_noop("Policies"));
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
@@ -1675,27 +1675,27 @@ describeOneTableDetails(const char *schemaname,
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
- appendPQExpBuffer(&buf,
- "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
- " seqstart AS \"%s\",\n"
- " seqmin AS \"%s\",\n"
- " seqmax AS \"%s\",\n"
- " seqincrement AS \"%s\",\n"
- " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
- " seqcache AS \"%s\"\n",
- gettext_noop("Type"),
- gettext_noop("Start"),
- gettext_noop("Minimum"),
- gettext_noop("Maximum"),
- gettext_noop("Increment"),
- gettext_noop("yes"),
- gettext_noop("no"),
- gettext_noop("Cycles?"),
- gettext_noop("Cache"));
- appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_sequence\n"
- "WHERE seqrelid = '%s';",
- oid);
+ appendPQExpBuffer(&buf,
+ "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
+ " seqstart AS \"%s\",\n"
+ " seqmin AS \"%s\",\n"
+ " seqmax AS \"%s\",\n"
+ " seqincrement AS \"%s\",\n"
+ " CASE WHEN seqcycle THEN '%s' ELSE '%s' END AS \"%s\",\n"
+ " seqcache AS \"%s\"\n",
+ gettext_noop("Type"),
+ gettext_noop("Start"),
+ gettext_noop("Minimum"),
+ gettext_noop("Maximum"),
+ gettext_noop("Increment"),
+ gettext_noop("yes"),
+ gettext_noop("no"),
+ gettext_noop("Cycles?"),
+ gettext_noop("Cache"));
+ appendPQExpBuffer(&buf,
+ "FROM pg_catalog.pg_sequence\n"
+ "WHERE seqrelid = '%s';",
+ oid);
res = PSQLexec(buf.data);
if (!res)
@@ -1913,7 +1913,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n"
" WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation");
attcoll_col = cols++;
- appendPQExpBufferStr(&buf, ",\n a.attidentity");
+ appendPQExpBufferStr(&buf, ",\n a.attidentity");
attidentity_col = cols++;
if (pset.sversion >= 120000)
appendPQExpBufferStr(&buf, ",\n a.attgenerated");
@@ -2326,7 +2326,7 @@ describeOneTableDetails(const char *schemaname,
CppAsString2(CONSTRAINT_EXCLUSION) ") AND "
"condeferred) AS condeferred,\n");
- appendPQExpBufferStr(&buf, "i.indisreplident,\n");
+ appendPQExpBufferStr(&buf, "i.indisreplident,\n");
if (pset.sversion >= 150000)
appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n");
@@ -2431,7 +2431,7 @@ describeOneTableDetails(const char *schemaname,
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n "
"pg_catalog.pg_get_constraintdef(con.oid, true), "
"contype, condeferrable, condeferred");
- appendPQExpBufferStr(&buf, ", i.indisreplident");
+ appendPQExpBufferStr(&buf, ", i.indisreplident");
appendPQExpBufferStr(&buf, ", c2.reltablespace");
if (pset.sversion >= 180000)
appendPQExpBufferStr(&buf, ", con.conperiod");
@@ -2682,81 +2682,80 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get row-level policies for this table"));
- appendPQExpBufferStr(&buf, "SELECT pol.polname,");
- appendPQExpBufferStr(&buf,
- " pol.polpermissive,\n");
- appendPQExpBuffer(&buf,
- " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- " CASE pol.polcmd\n"
- " WHEN 'r' THEN 'SELECT'\n"
- " WHEN 'a' THEN 'INSERT'\n"
- " WHEN 'w' THEN 'UPDATE'\n"
- " WHEN 'd' THEN 'DELETE'\n"
- " END AS cmd\n"
- "FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
- oid);
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get row-level policies for this table"));
+ appendPQExpBufferStr(&buf, "SELECT pol.polname,");
+ appendPQExpBufferStr(&buf,
+ " pol.polpermissive,\n");
+ appendPQExpBuffer(&buf,
+ " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ " pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ " CASE pol.polcmd\n"
+ " WHEN 'r' THEN 'SELECT'\n"
+ " WHEN 'a' THEN 'INSERT'\n"
+ " WHEN 'w' THEN 'UPDATE'\n"
+ " WHEN 'd' THEN 'DELETE'\n"
+ " END AS cmd\n"
+ "FROM pg_catalog.pg_policy pol\n"
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ oid);
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- /*
- * Handle cases where RLS is enabled and there are policies, or
- * there aren't policies, or RLS isn't enabled but there are
- * policies
- */
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies:"));
+ /*
+ * Handle cases where RLS is enabled and there are policies, or there
+ * aren't policies, or RLS isn't enabled but there are policies
+ */
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies:"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled):"));
- if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
+ if (tableinfo.rowsecurity && !tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (row security enabled): (none)"));
- if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
- printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
+ if (tableinfo.rowsecurity && tableinfo.forcerowsecurity && tuples == 0)
+ printTableAddFooter(&cont, _("Policies (forced row security enabled): (none)"));
- if (!tableinfo.rowsecurity && tuples > 0)
- printTableAddFooter(&cont, _("Policies (row security disabled):"));
+ if (!tableinfo.rowsecurity && tuples > 0)
+ printTableAddFooter(&cont, _("Policies (row security disabled):"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " POLICY \"%s\"",
+ PQgetvalue(result, i, 0));
- if (*(PQgetvalue(result, i, 1)) == 'f')
- appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
+ if (*(PQgetvalue(result, i, 1)) == 'f')
+ appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
- if (!PQgetisnull(result, i, 5))
- appendPQExpBuffer(&buf, " FOR %s",
- PQgetvalue(result, i, 5));
+ if (!PQgetisnull(result, i, 5))
+ appendPQExpBuffer(&buf, " FOR %s",
+ PQgetvalue(result, i, 5));
- if (!PQgetisnull(result, i, 2))
- {
- appendPQExpBuffer(&buf, "\n TO %s",
- PQgetvalue(result, i, 2));
- }
+ if (!PQgetisnull(result, i, 2))
+ {
+ appendPQExpBuffer(&buf, "\n TO %s",
+ PQgetvalue(result, i, 2));
+ }
- if (!PQgetisnull(result, i, 3))
- appendPQExpBuffer(&buf, "\n USING (%s)",
- PQgetvalue(result, i, 3));
+ if (!PQgetisnull(result, i, 3))
+ appendPQExpBuffer(&buf, "\n USING (%s)",
+ PQgetvalue(result, i, 3));
- if (!PQgetisnull(result, i, 4))
- appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
- PQgetvalue(result, i, 4));
+ if (!PQgetisnull(result, i, 4))
+ appendPQExpBuffer(&buf, "\n WITH CHECK (%s)",
+ PQgetvalue(result, i, 4));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* print any extended statistics */
if (pset.sversion >= 140000)
@@ -3025,115 +3024,115 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
- printfPQExpBuffer(&buf, "/* %s */\n",
- _("Get publications that publish this table"));
- if (pset.sversion >= 150000)
+ printfPQExpBuffer(&buf, "/* %s */\n",
+ _("Get publications that publish this table"));
+ if (pset.sversion >= 150000)
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
+ " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
+ "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
+ "UNION\n"
+ "SELECT pubname\n"
+ " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
+ " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
+ " (SELECT pg_catalog.string_agg(attname, ', ')\n"
+ " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
+ " pg_catalog.pg_attribute\n"
+ " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
+ " ELSE NULL END) "
+ "FROM pg_catalog.pg_publication p\n"
+ " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
+ "WHERE pr.prrelid = '%s'\n",
+ oid, oid, oid);
+
+ if (pset.sversion >= 190000)
{
+ /*
+ * Skip entries where this relation appears in the
+ * publication's EXCEPT list.
+ */
appendPQExpBuffer(&buf,
+ " AND NOT pr.prexcept\n"
+ "UNION\n"
"SELECT pubname\n"
" , NULL\n"
" , NULL\n"
"FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid\n"
- " JOIN pg_catalog.pg_class pc ON pc.relnamespace = pn.pnnspid\n"
- "WHERE pc.oid ='%s' and pg_catalog.pg_relation_is_publishable('%s')\n"
- "UNION\n"
- "SELECT pubname\n"
- " , pg_catalog.pg_get_expr(pr.prqual, c.oid)\n"
- " , (CASE WHEN pr.prattrs IS NOT NULL THEN\n"
- " (SELECT pg_catalog.string_agg(attname, ', ')\n"
- " FROM pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
- " pg_catalog.pg_attribute\n"
- " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
- " ELSE NULL END) "
- "FROM pg_catalog.pg_publication p\n"
- " JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- " JOIN pg_catalog.pg_class c ON c.oid = pr.prrelid\n"
- "WHERE pr.prrelid = '%s'\n",
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ " AND NOT EXISTS (\n"
+ " SELECT 1\n"
+ " FROM pg_catalog.pg_publication_rel pr\n"
+ " WHERE pr.prpubid = p.oid AND\n"
+ " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
+ "ORDER BY 1;",
oid, oid, oid);
-
- if (pset.sversion >= 190000)
- {
- /*
- * Skip entries where this relation appears in the
- * publication's EXCEPT list.
- */
- appendPQExpBuffer(&buf,
- " AND NOT pr.prexcept\n"
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- " AND NOT EXISTS (\n"
- " SELECT 1\n"
- " FROM pg_catalog.pg_publication_rel pr\n"
- " WHERE pr.prpubid = p.oid AND\n"
- " (pr.prrelid = '%s' OR pr.prrelid = pg_catalog.pg_partition_root('%s')))\n"
- "ORDER BY 1;",
- oid, oid, oid);
- }
- else
- {
- appendPQExpBuffer(&buf,
- "UNION\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
- "ORDER BY 1;",
- oid);
- }
}
else
{
appendPQExpBuffer(&buf,
+ "UNION\n"
"SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
- "FROM pg_catalog.pg_publication p\n"
- "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
- "WHERE pr.prrelid = '%s'\n"
- "UNION ALL\n"
- "SELECT pubname\n"
- " , NULL\n"
- " , NULL\n"
+ " , NULL\n"
+ " , NULL\n"
"FROM pg_catalog.pg_publication p\n"
"WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
"ORDER BY 1;",
- oid, oid);
+ oid);
}
+ }
+ else
+ {
+ appendPQExpBuffer(&buf,
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "JOIN pg_catalog.pg_publication_rel pr ON p.oid = pr.prpubid\n"
+ "WHERE pr.prrelid = '%s'\n"
+ "UNION ALL\n"
+ "SELECT pubname\n"
+ " , NULL\n"
+ " , NULL\n"
+ "FROM pg_catalog.pg_publication p\n"
+ "WHERE p.puballtables AND pg_catalog.pg_relation_is_publishable('%s')\n"
+ "ORDER BY 1;",
+ oid, oid);
+ }
- result = PSQLexec(buf.data);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
- printTableAddFooter(&cont, _("Included in publications:"));
+ if (tuples > 0)
+ printTableAddFooter(&cont, _("Included in publications:"));
- /* Might be an empty set - that's ok */
- for (i = 0; i < tuples; i++)
- {
- printfPQExpBuffer(&buf, " \"%s\"",
- PQgetvalue(result, i, 0));
+ /* Might be an empty set - that's ok */
+ for (i = 0; i < tuples; i++)
+ {
+ printfPQExpBuffer(&buf, " \"%s\"",
+ PQgetvalue(result, i, 0));
- /* column list (if any) */
- if (!PQgetisnull(result, i, 2))
- appendPQExpBuffer(&buf, " (%s)",
- PQgetvalue(result, i, 2));
+ /* column list (if any) */
+ if (!PQgetisnull(result, i, 2))
+ appendPQExpBuffer(&buf, " (%s)",
+ PQgetvalue(result, i, 2));
- /* row filter (if any) */
- if (!PQgetisnull(result, i, 1))
- appendPQExpBuffer(&buf, " WHERE %s",
- PQgetvalue(result, i, 1));
+ /* row filter (if any) */
+ if (!PQgetisnull(result, i, 1))
+ appendPQExpBuffer(&buf, " WHERE %s",
+ PQgetvalue(result, i, 1));
- printTableAddFooter(&cont, buf.data);
- }
- PQclear(result);
+ printTableAddFooter(&cont, buf.data);
+ }
+ PQclear(result);
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
@@ -3805,7 +3804,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
ncols++;
}
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
- appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
+ appendPQExpBufferStr(&buf, "\n, r.rolbypassrls");
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
@@ -3860,8 +3859,8 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
- if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
- add_role_attribute(&buf, _("Bypass RLS"));
+ if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
+ add_role_attribute(&buf, _("Bypass RLS"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
@@ -5155,14 +5154,14 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
gettext_noop("Schema"),
gettext_noop("Name"));
- appendPQExpBuffer(&buf,
- " CASE c.collprovider "
- "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
- "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
- "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
- "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
- "END AS \"%s\",\n",
- gettext_noop("Provider"));
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider "
+ "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' "
+ "WHEN " CppAsString2(COLLPROVIDER_BUILTIN) " THEN 'builtin' "
+ "WHEN " CppAsString2(COLLPROVIDER_LIBC) " THEN 'libc' "
+ "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' "
+ "END AS \"%s\",\n",
+ gettext_noop("Provider"));
appendPQExpBuffer(&buf,
" c.collcollate AS \"%s\",\n"
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-07-01 15:55 Nathan Bossart <nathandbossart@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-07-01 15:55 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
On Tue, Jun 30, 2026 at 03:18:51PM -0500, Nathan Bossart wrote:
> I didn't see anything else that I thought obviously needed to be changed.
> Please let me know if you feel otherwise.
FTR I'm planning to commit this tomorrow.
--
nathan
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-07-02 18:11 Nathan Bossart <nathandbossart@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-07-02 18:11 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
On Wed, Jul 01, 2026 at 10:55:01AM -0500, Nathan Bossart wrote:
> FTR I'm planning to commit this tomorrow.
Committed.
--
nathan
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-07-08 21:43 Nathan Bossart <nathandbossart@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Nathan Bossart @ 2026-07-08 21:43 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
I just noticed that I forgot to update AdjustUpgrade.pm accordingly.
Here's a patch.
--
nathan
From bb49350cf783e10f2f79ed894e53c06f4da82f45 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Wed, 8 Jul 2026 16:39:17 -0500
Subject: [PATCH v1 1/1] clean up AdjustUpgrade.pm after pg_upgrade min version
bump
---
.../perl/PostgreSQL/Test/AdjustUpgrade.pm | 207 +-----------------
1 file changed, 5 insertions(+), 202 deletions(-)
diff --git a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
index 878fcc16a9e..04844298ab3 100644
--- a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
+++ b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
@@ -199,15 +199,10 @@ sub adjust_database_contents
'drop operator if exists #@%# (bigint,NONE)');
# get rid of dblink's dependencies on regress.so
- my $regrdb =
- $old_version le '9.4'
- ? 'contrib_regression'
- : 'contrib_regression_dblink';
-
- if ($dbnames{$regrdb})
+ if ($dbnames{'contrib_regression_dblink'})
{
_add_st(
- $result, $regrdb,
+ $result, 'contrib_regression_dblink',
'drop function if exists public.putenv(text)',
'drop function if exists public.wait_pid(integer)');
}
@@ -250,7 +245,7 @@ sub adjust_database_contents
}
# this table had OIDs too, but we'll just drop it
- if ($old_version >= 10 && $dbnames{'contrib_regression_postgres_fdw'})
+ if ($dbnames{'contrib_regression_postgres_fdw'})
{
_add_st(
$result,
@@ -276,43 +271,13 @@ sub adjust_database_contents
'drop function if exists public.funny_dup17()');
}
- # version-0 C functions are no longer supported
- if ($old_version < 10)
- {
- _add_st($result, 'regression',
- 'drop function oldstyle_length(integer, text)');
- }
-
- if ($old_version lt '9.5')
- {
- # cope with changes of underlying functions
- _add_st(
- $result,
- 'regression',
- 'drop operator @#@ (NONE, bigint)',
- 'CREATE OPERATOR @#@ ('
- . 'PROCEDURE = factorial, RIGHTARG = bigint )',
- 'drop aggregate public.array_cat_accum(anyarray)',
- 'CREATE AGGREGATE array_larger_accum (anyarray) ' . ' ( '
- . ' sfunc = array_larger, '
- . ' stype = anyarray, '
- . ' initcond = $${}$$ ' . ' ) ');
-
- # "=>" is no longer valid as an operator name
- _add_st($result, 'regression',
- 'drop operator if exists public.=> (bigint, NONE)');
- }
-
# Version 19 changed the output format of pg_lsn. To avoid output
# differences, set all pg_lsn columns to NULL if the old version is
# older than 19.
if ($old_version < 19)
{
- if ($old_version >= '9.5')
- {
- _add_st($result, 'regression',
- "update brintest set lsncol = NULL");
- }
+ _add_st($result, 'regression',
+ "update brintest set lsncol = NULL");
if ($old_version >= 12)
{
@@ -426,107 +391,6 @@ sub adjust_old_dumpfile
/$1 EXECUTE FUNCTION/mgx;
}
- # During pg_upgrade, we reindex hash indexes if the source is pre-v10.
- # This may change their tables' relallvisible values, so don't compare
- # those.
- if ($old_version < 10)
- {
- $dump =~ s/
- (^SELECT\s\*\sFROM\spg_catalog\.pg_restore_relation_stats\(
- [^;]*'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass,
- [^;]*'relallvisible',)\s'\d+'::integer
- /$1 ''::integer/mgx;
- }
-
- if ($old_version lt '9.6')
- {
- # adjust some places where we don't print so many parens anymore
-
- my $prefix =
- "'New York'\tnew & york | big & apple | nyc\t'new' & 'york'\t";
- my $orig = "( 'new' & 'york' | 'big' & 'appl' ) | 'nyc'";
- my $repl = "'new' & 'york' | 'big' & 'appl' | 'nyc'";
- $dump =~ s/(?<=^\Q$prefix\E)\Q$orig\E/$repl/mg;
-
- $prefix =
- "'Sanct Peter'\tPeterburg | peter | 'Sanct Peterburg'\t'sanct' & 'peter'\t";
- $orig = "( 'peterburg' | 'peter' ) | 'sanct' & 'peterburg'";
- $repl = "'peterburg' | 'peter' | 'sanct' & 'peterburg'";
- $dump =~ s/(?<=^\Q$prefix\E)\Q$orig\E/$repl/mg;
- }
-
- if ($old_version lt '9.5')
- {
- # adjust some places where we don't print so many parens anymore
-
- my $prefix = "CONSTRAINT (?:sequence|copy)_con CHECK [(][(]";
- my $orig = "((x > 3) AND (y <> 'check failed'::text))";
- my $repl = "(x > 3) AND (y <> 'check failed'::text)";
- $dump =~ s/($prefix)\Q$orig\E/$1$repl/mg;
-
- $prefix = "CONSTRAINT insert_con CHECK [(][(]";
- $orig = "((x >= 3) AND (y <> 'check failed'::text))";
- $repl = "(x >= 3) AND (y <> 'check failed'::text)";
- $dump =~ s/($prefix)\Q$orig\E/$1$repl/mg;
-
- $orig = "DEFAULT ((-1) * currval('public.insert_seq'::regclass))";
- $repl =
- "DEFAULT ('-1'::integer * currval('public.insert_seq'::regclass))";
- $dump =~ s/\Q$orig\E/$repl/mg;
-
- my $expr =
- "(rsl.sl_color = rsh.slcolor) AND (rsl.sl_len_cm >= rsh.slminlen_cm)";
- $dump =~ s/WHERE \(\(\Q$expr\E\)/WHERE ($expr/g;
-
- $expr =
- "(rule_and_refint_t3.id3a = new.id3a) AND (rule_and_refint_t3.id3b = new.id3b)";
- $dump =~ s/WHERE \(\(\Q$expr\E\)/WHERE ($expr/g;
-
- $expr =
- "(rule_and_refint_t3_1.id3a = new.id3a) AND (rule_and_refint_t3_1.id3b = new.id3b)";
- $dump =~ s/WHERE \(\(\Q$expr\E\)/WHERE ($expr/g;
- }
-
- if ($old_version lt '9.3')
- {
- # CREATE VIEW/RULE statements were not pretty-printed before 9.3.
- # To cope, reduce all whitespace sequences within them to one space.
- # This must be done on both old and new dumps.
- $dump = _mash_view_whitespace($dump);
-
- # _mash_view_whitespace doesn't handle multi-command rules;
- # rather than trying to fix that, just hack the exceptions manually.
-
- my $prefix =
- "CREATE RULE rtest_sys_del AS ON DELETE TO public.rtest_system DO (DELETE FROM public.rtest_interface WHERE (rtest_interface.sysname = old.sysname);";
- my $line2 = " DELETE FROM public.rtest_admin";
- my $line3 = " WHERE (rtest_admin.sysname = old.sysname);";
- $dump =~
- s/(?<=\Q$prefix\E)\Q$line2$line3\E \);/\n$line2\n $line3\n);/mg;
-
- $prefix =
- "CREATE RULE rtest_sys_upd AS ON UPDATE TO public.rtest_system DO (UPDATE public.rtest_interface SET sysname = new.sysname WHERE (rtest_interface.sysname = old.sysname);";
- $line2 = " UPDATE public.rtest_admin SET sysname = new.sysname";
- $line3 = " WHERE (rtest_admin.sysname = old.sysname);";
- $dump =~
- s/(?<=\Q$prefix\E)\Q$line2$line3\E \);/\n$line2\n $line3\n);/mg;
-
- # and there's one place where pre-9.3 uses a different table alias
- $dump =~ s {^(CREATE\sRULE\srule_and_refint_t3_ins\sAS\s
- ON\sINSERT\sTO\spublic\.rule_and_refint_t3\s
- WHERE\s\(EXISTS\s\(SELECT\s1\sFROM\spublic\.rule_and_refint_t3)\s
- (WHERE\s\(\(rule_and_refint_t3)
- (\.id3a\s=\snew\.id3a\)\sAND\s\(rule_and_refint_t3)
- (\.id3b\s=\snew\.id3b\)\sAND\s\(rule_and_refint_t3)}
- {$1 rule_and_refint_t3_1 $2_1$3_1$4_1}mx;
-
- # Also fix old use of NATURAL JOIN syntax
- $dump =~ s {NATURAL JOIN public\.credit_card r}
- {JOIN public.credit_card r USING (cid)}mg;
- $dump =~ s {NATURAL JOIN public\.credit_usage r}
- {JOIN public.credit_usage r USING (cid)}mg;
- }
-
# Suppress blank lines, as some places in pg_dump emit more or fewer.
$dump =~ s/\n\n+/\n/g;
@@ -661,37 +525,6 @@ sub _mash_view_qualifiers
return $dump;
}
-
-# Internal subroutine to mangle whitespace within view/rule commands.
-# Any consecutive sequence of whitespace is reduced to one space.
-sub _mash_view_whitespace
-{
- my ($dump) = @_;
-
- foreach my $leader ('CREATE VIEW', 'CREATE RULE')
- {
- my @splitchunks = split $leader, $dump;
-
- $dump = shift(@splitchunks);
- foreach my $chunk (@splitchunks)
- {
- my @thischunks = split /;/, $chunk, 2;
- my $stmt = shift(@thischunks);
-
- # now $stmt is just the body of the CREATE VIEW/RULE
- $stmt =~ s/\s+/ /sg;
- # we also need to smash these forms for sub-selects and rules
- $stmt =~ s/\( SELECT/(SELECT/g;
- $stmt =~ s/\( INSERT/(INSERT/g;
- $stmt =~ s/\( UPDATE/(UPDATE/g;
- $stmt =~ s/\( DELETE/(DELETE/g;
-
- $dump .= $leader . $stmt . ';' . $thischunks[0];
- }
- }
- return $dump;
-}
-
=pod
=item adjust_new_dumpfile($old_version, $dump)
@@ -779,36 +612,6 @@ sub adjust_new_dumpfile
$dump =~ s/^SET default_table_access_method = heap;\n//mg;
}
- # During pg_upgrade, we reindex hash indexes if the source is pre-v10.
- # This may change their tables' relallvisible values, so don't compare
- # those.
- if ($old_version < 10)
- {
- $dump =~ s/
- (^SELECT\s\*\sFROM\spg_catalog\.pg_restore_relation_stats\(
- [^;]*'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass,
- [^;]*'relallvisible',)\s'\d+'::integer
- /$1 ''::integer/mgx;
- }
-
- # dumps from pre-9.6 dblink may include redundant ACL settings
- if ($old_version lt '9.6')
- {
- my $comment =
- "-- Name: FUNCTION dblink_connect_u\(.*?\); Type: ACL; Schema: public; Owner: .*";
- my $sql =
- "REVOKE ALL ON FUNCTION public\.dblink_connect_u\(.*?\) FROM PUBLIC;";
- $dump =~ s/^--\n$comment\n--\n+$sql\n+//mg;
- }
-
- if ($old_version lt '9.3')
- {
- # CREATE VIEW/RULE statements were not pretty-printed before 9.3.
- # To cope, reduce all whitespace sequences within them to one space.
- # This must be done on both old and new dumps.
- $dump = _mash_view_whitespace($dump);
- }
-
# Suppress blank lines, as some places in pg_dump emit more or fewer.
$dump =~ s/\n\n+/\n/g;
--
2.50.1 (Apple Git-155)
Attachments:
[text/plain] v1-0001-clean-up-AdjustUpgrade.pm-after-pg_upgrade-min-ve.patch (9.0K, ../../ak7Ekv2-L-G55-YD@nathan/2-v1-0001-clean-up-AdjustUpgrade.pm-after-pg_upgrade-min-ve.patch)
download | inline diff:
From bb49350cf783e10f2f79ed894e53c06f4da82f45 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Wed, 8 Jul 2026 16:39:17 -0500
Subject: [PATCH v1 1/1] clean up AdjustUpgrade.pm after pg_upgrade min version
bump
---
.../perl/PostgreSQL/Test/AdjustUpgrade.pm | 207 +-----------------
1 file changed, 5 insertions(+), 202 deletions(-)
diff --git a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
index 878fcc16a9e..04844298ab3 100644
--- a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
+++ b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
@@ -199,15 +199,10 @@ sub adjust_database_contents
'drop operator if exists #@%# (bigint,NONE)');
# get rid of dblink's dependencies on regress.so
- my $regrdb =
- $old_version le '9.4'
- ? 'contrib_regression'
- : 'contrib_regression_dblink';
-
- if ($dbnames{$regrdb})
+ if ($dbnames{'contrib_regression_dblink'})
{
_add_st(
- $result, $regrdb,
+ $result, 'contrib_regression_dblink',
'drop function if exists public.putenv(text)',
'drop function if exists public.wait_pid(integer)');
}
@@ -250,7 +245,7 @@ sub adjust_database_contents
}
# this table had OIDs too, but we'll just drop it
- if ($old_version >= 10 && $dbnames{'contrib_regression_postgres_fdw'})
+ if ($dbnames{'contrib_regression_postgres_fdw'})
{
_add_st(
$result,
@@ -276,43 +271,13 @@ sub adjust_database_contents
'drop function if exists public.funny_dup17()');
}
- # version-0 C functions are no longer supported
- if ($old_version < 10)
- {
- _add_st($result, 'regression',
- 'drop function oldstyle_length(integer, text)');
- }
-
- if ($old_version lt '9.5')
- {
- # cope with changes of underlying functions
- _add_st(
- $result,
- 'regression',
- 'drop operator @#@ (NONE, bigint)',
- 'CREATE OPERATOR @#@ ('
- . 'PROCEDURE = factorial, RIGHTARG = bigint )',
- 'drop aggregate public.array_cat_accum(anyarray)',
- 'CREATE AGGREGATE array_larger_accum (anyarray) ' . ' ( '
- . ' sfunc = array_larger, '
- . ' stype = anyarray, '
- . ' initcond = $${}$$ ' . ' ) ');
-
- # "=>" is no longer valid as an operator name
- _add_st($result, 'regression',
- 'drop operator if exists public.=> (bigint, NONE)');
- }
-
# Version 19 changed the output format of pg_lsn. To avoid output
# differences, set all pg_lsn columns to NULL if the old version is
# older than 19.
if ($old_version < 19)
{
- if ($old_version >= '9.5')
- {
- _add_st($result, 'regression',
- "update brintest set lsncol = NULL");
- }
+ _add_st($result, 'regression',
+ "update brintest set lsncol = NULL");
if ($old_version >= 12)
{
@@ -426,107 +391,6 @@ sub adjust_old_dumpfile
/$1 EXECUTE FUNCTION/mgx;
}
- # During pg_upgrade, we reindex hash indexes if the source is pre-v10.
- # This may change their tables' relallvisible values, so don't compare
- # those.
- if ($old_version < 10)
- {
- $dump =~ s/
- (^SELECT\s\*\sFROM\spg_catalog\.pg_restore_relation_stats\(
- [^;]*'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass,
- [^;]*'relallvisible',)\s'\d+'::integer
- /$1 ''::integer/mgx;
- }
-
- if ($old_version lt '9.6')
- {
- # adjust some places where we don't print so many parens anymore
-
- my $prefix =
- "'New York'\tnew & york | big & apple | nyc\t'new' & 'york'\t";
- my $orig = "( 'new' & 'york' | 'big' & 'appl' ) | 'nyc'";
- my $repl = "'new' & 'york' | 'big' & 'appl' | 'nyc'";
- $dump =~ s/(?<=^\Q$prefix\E)\Q$orig\E/$repl/mg;
-
- $prefix =
- "'Sanct Peter'\tPeterburg | peter | 'Sanct Peterburg'\t'sanct' & 'peter'\t";
- $orig = "( 'peterburg' | 'peter' ) | 'sanct' & 'peterburg'";
- $repl = "'peterburg' | 'peter' | 'sanct' & 'peterburg'";
- $dump =~ s/(?<=^\Q$prefix\E)\Q$orig\E/$repl/mg;
- }
-
- if ($old_version lt '9.5')
- {
- # adjust some places where we don't print so many parens anymore
-
- my $prefix = "CONSTRAINT (?:sequence|copy)_con CHECK [(][(]";
- my $orig = "((x > 3) AND (y <> 'check failed'::text))";
- my $repl = "(x > 3) AND (y <> 'check failed'::text)";
- $dump =~ s/($prefix)\Q$orig\E/$1$repl/mg;
-
- $prefix = "CONSTRAINT insert_con CHECK [(][(]";
- $orig = "((x >= 3) AND (y <> 'check failed'::text))";
- $repl = "(x >= 3) AND (y <> 'check failed'::text)";
- $dump =~ s/($prefix)\Q$orig\E/$1$repl/mg;
-
- $orig = "DEFAULT ((-1) * currval('public.insert_seq'::regclass))";
- $repl =
- "DEFAULT ('-1'::integer * currval('public.insert_seq'::regclass))";
- $dump =~ s/\Q$orig\E/$repl/mg;
-
- my $expr =
- "(rsl.sl_color = rsh.slcolor) AND (rsl.sl_len_cm >= rsh.slminlen_cm)";
- $dump =~ s/WHERE \(\(\Q$expr\E\)/WHERE ($expr/g;
-
- $expr =
- "(rule_and_refint_t3.id3a = new.id3a) AND (rule_and_refint_t3.id3b = new.id3b)";
- $dump =~ s/WHERE \(\(\Q$expr\E\)/WHERE ($expr/g;
-
- $expr =
- "(rule_and_refint_t3_1.id3a = new.id3a) AND (rule_and_refint_t3_1.id3b = new.id3b)";
- $dump =~ s/WHERE \(\(\Q$expr\E\)/WHERE ($expr/g;
- }
-
- if ($old_version lt '9.3')
- {
- # CREATE VIEW/RULE statements were not pretty-printed before 9.3.
- # To cope, reduce all whitespace sequences within them to one space.
- # This must be done on both old and new dumps.
- $dump = _mash_view_whitespace($dump);
-
- # _mash_view_whitespace doesn't handle multi-command rules;
- # rather than trying to fix that, just hack the exceptions manually.
-
- my $prefix =
- "CREATE RULE rtest_sys_del AS ON DELETE TO public.rtest_system DO (DELETE FROM public.rtest_interface WHERE (rtest_interface.sysname = old.sysname);";
- my $line2 = " DELETE FROM public.rtest_admin";
- my $line3 = " WHERE (rtest_admin.sysname = old.sysname);";
- $dump =~
- s/(?<=\Q$prefix\E)\Q$line2$line3\E \);/\n$line2\n $line3\n);/mg;
-
- $prefix =
- "CREATE RULE rtest_sys_upd AS ON UPDATE TO public.rtest_system DO (UPDATE public.rtest_interface SET sysname = new.sysname WHERE (rtest_interface.sysname = old.sysname);";
- $line2 = " UPDATE public.rtest_admin SET sysname = new.sysname";
- $line3 = " WHERE (rtest_admin.sysname = old.sysname);";
- $dump =~
- s/(?<=\Q$prefix\E)\Q$line2$line3\E \);/\n$line2\n $line3\n);/mg;
-
- # and there's one place where pre-9.3 uses a different table alias
- $dump =~ s {^(CREATE\sRULE\srule_and_refint_t3_ins\sAS\s
- ON\sINSERT\sTO\spublic\.rule_and_refint_t3\s
- WHERE\s\(EXISTS\s\(SELECT\s1\sFROM\spublic\.rule_and_refint_t3)\s
- (WHERE\s\(\(rule_and_refint_t3)
- (\.id3a\s=\snew\.id3a\)\sAND\s\(rule_and_refint_t3)
- (\.id3b\s=\snew\.id3b\)\sAND\s\(rule_and_refint_t3)}
- {$1 rule_and_refint_t3_1 $2_1$3_1$4_1}mx;
-
- # Also fix old use of NATURAL JOIN syntax
- $dump =~ s {NATURAL JOIN public\.credit_card r}
- {JOIN public.credit_card r USING (cid)}mg;
- $dump =~ s {NATURAL JOIN public\.credit_usage r}
- {JOIN public.credit_usage r USING (cid)}mg;
- }
-
# Suppress blank lines, as some places in pg_dump emit more or fewer.
$dump =~ s/\n\n+/\n/g;
@@ -661,37 +525,6 @@ sub _mash_view_qualifiers
return $dump;
}
-
-# Internal subroutine to mangle whitespace within view/rule commands.
-# Any consecutive sequence of whitespace is reduced to one space.
-sub _mash_view_whitespace
-{
- my ($dump) = @_;
-
- foreach my $leader ('CREATE VIEW', 'CREATE RULE')
- {
- my @splitchunks = split $leader, $dump;
-
- $dump = shift(@splitchunks);
- foreach my $chunk (@splitchunks)
- {
- my @thischunks = split /;/, $chunk, 2;
- my $stmt = shift(@thischunks);
-
- # now $stmt is just the body of the CREATE VIEW/RULE
- $stmt =~ s/\s+/ /sg;
- # we also need to smash these forms for sub-selects and rules
- $stmt =~ s/\( SELECT/(SELECT/g;
- $stmt =~ s/\( INSERT/(INSERT/g;
- $stmt =~ s/\( UPDATE/(UPDATE/g;
- $stmt =~ s/\( DELETE/(DELETE/g;
-
- $dump .= $leader . $stmt . ';' . $thischunks[0];
- }
- }
- return $dump;
-}
-
=pod
=item adjust_new_dumpfile($old_version, $dump)
@@ -779,36 +612,6 @@ sub adjust_new_dumpfile
$dump =~ s/^SET default_table_access_method = heap;\n//mg;
}
- # During pg_upgrade, we reindex hash indexes if the source is pre-v10.
- # This may change their tables' relallvisible values, so don't compare
- # those.
- if ($old_version < 10)
- {
- $dump =~ s/
- (^SELECT\s\*\sFROM\spg_catalog\.pg_restore_relation_stats\(
- [^;]*'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass,
- [^;]*'relallvisible',)\s'\d+'::integer
- /$1 ''::integer/mgx;
- }
-
- # dumps from pre-9.6 dblink may include redundant ACL settings
- if ($old_version lt '9.6')
- {
- my $comment =
- "-- Name: FUNCTION dblink_connect_u\(.*?\); Type: ACL; Schema: public; Owner: .*";
- my $sql =
- "REVOKE ALL ON FUNCTION public\.dblink_connect_u\(.*?\) FROM PUBLIC;";
- $dump =~ s/^--\n$comment\n--\n+$sql\n+//mg;
- }
-
- if ($old_version lt '9.3')
- {
- # CREATE VIEW/RULE statements were not pretty-printed before 9.3.
- # To cope, reduce all whitespace sequences within them to one space.
- # This must be done on both old and new dumps.
- $dump = _mash_view_whitespace($dump);
- }
-
# Suppress blank lines, as some places in pg_dump emit more or fewer.
$dump =~ s/\n\n+/\n/g;
--
2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10
@ 2026-07-31 15:01 Nathan Bossart <nathandbossart@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 0 replies; 21+ messages in thread
From: Nathan Bossart @ 2026-07-31 15:01 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Corey Huinker <corey.huinker@gmail.com>; pgsql-hackers
On Wed, Jul 08, 2026 at 04:43:46PM -0500, Nathan Bossart wrote:
> I just noticed that I forgot to update AdjustUpgrade.pm accordingly.
> Here's a patch.
Committed.
--
nathan
^ permalink raw reply [nested|flat] 21+ messages in thread
end of thread, other threads:[~2026-07-31 15:01 UTC | newest]
Thread overview: 21+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-04-08 15:47 bump minimum supported version of psql and pg_{dump,dumpall,upgrade} to v10 Nathan Bossart <nathandbossart@gmail.com>
2026-04-08 16:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2026-04-08 16:42 ` Andrew Dunstan <andrew@dunslane.net>
2026-04-08 17:24 ` Corey Huinker <corey.huinker@gmail.com>
2026-04-08 18:04 ` Nathan Bossart <nathandbossart@gmail.com>
2026-05-01 20:10 ` Nathan Bossart <nathandbossart@gmail.com>
2026-05-06 21:47 ` Nathan Bossart <nathandbossart@gmail.com>
2026-05-16 12:00 ` Andrew Dunstan <andrew@dunslane.net>
2026-05-16 13:42 ` Tom Lane <tgl@sss.pgh.pa.us>
2026-05-16 13:44 ` Nathan Bossart <nathandbossart@gmail.com>
2026-05-16 17:51 ` Andrew Dunstan <andrew@dunslane.net>
2026-06-11 14:21 ` Nathan Bossart <nathandbossart@gmail.com>
2026-06-29 15:16 ` Nathan Bossart <nathandbossart@gmail.com>
2026-06-30 03:36 ` Fujii Masao <masao.fujii@gmail.com>
2026-06-30 20:18 ` Nathan Bossart <nathandbossart@gmail.com>
2026-07-01 15:55 ` Nathan Bossart <nathandbossart@gmail.com>
2026-07-02 18:11 ` Nathan Bossart <nathandbossart@gmail.com>
2026-07-08 21:43 ` Nathan Bossart <nathandbossart@gmail.com>
2026-07-31 15:01 ` Nathan Bossart <nathandbossart@gmail.com>
2026-04-08 17:31 ` Nathan Bossart <nathandbossart@gmail.com>
2026-04-08 17:55 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox