Re: pg_dump versus ancient server versions - Mailing list pgsql-hackers
From | Tom Lane |
---|---|
Subject | Re: pg_dump versus ancient server versions |
Date | |
Msg-id | 22018.1635202338@sss.pgh.pa.us Whole thread Raw |
In response to | Re: pg_dump versus ancient server versions (Andrew Dunstan <andrew@dunslane.net>) |
Responses |
Re: pg_dump versus ancient server versions
|
List | pgsql-hackers |
Anyway, to get back to the original point ... No one has spoken against moving up the cutoff for pg_dump support, so I did a very quick pass to see how much code could be removed. The answer is right about 1000 lines, counting both pg_dump and pg_upgrade, so it seems like it's worth doing independently of the unnest() issue. The attached is just draft-quality, because I don't really want to pursue the point until after committing the pg_dump changes being discussed in the other thread. If I push this first it'll break a lot of those patches. (Admittedly, pushing those first will break this one, but this one is a lot easier to re-do.) BTW, while looking at pg_upgrade I chanced to notice check_for_isn_and_int8_passing_mismatch(), which seems like it's not well thought out at all. It's right that contrib/isn will not upgrade nicely if the target cluster has a different float8_pass_by_value setting from the source. What's wrong is the assumption that no other extension has the same issue. We invented and publicized the "LIKE type" option for CREATE TYPE precisely so that people could build types that act just like isn, so it seems pretty foolish to imagine that no one has done so. I think we should nuke check_for_isn_and_int8_passing_mismatch() and just refuse to upgrade if float8_pass_by_value differs, full stop. I can see little practical need to allow that case. regards, tom lane diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 7682226b99..6e95148d11 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1381,7 +1381,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 8.0 are supported.) + (Currently, servers back to version 9.0 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 20efdd771f..b15fbb44f1 100644 --- a/doc/src/sgml/ref/pgupgrade.sgml +++ b/doc/src/sgml/ref/pgupgrade.sgml @@ -68,7 +68,7 @@ PostgreSQL documentation </para> <para> - pg_upgrade supports upgrades from 8.4.X and later to the current + pg_upgrade supports upgrades from 9.0.X and later to the current major release of <productname>PostgreSQL</productname>, including snapshot and beta releases. </para> </refsect1> diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index ea67e52a3f..e4b04fd491 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -183,10 +183,6 @@ buildACLCommands(const char *name, const char *subname, const char *nspname, appendPQExpBuffer(firstsql, "%s FROM ", name); if (grantee->len == 0) appendPQExpBufferStr(firstsql, "PUBLIC;\n"); - else if (strncmp(grantee->data, "group ", - strlen("group ")) == 0) - appendPQExpBuffer(firstsql, "GROUP %s;\n", - fmtId(grantee->data + strlen("group "))); else appendPQExpBuffer(firstsql, "%s;\n", fmtId(grantee->data)); @@ -194,20 +190,6 @@ buildACLCommands(const char *name, const char *subname, const char *nspname, } } - /* - * We still need some hacking though to cover the case where new default - * public privileges are added in new versions: the REVOKE ALL will revoke - * them, leading to behavior different from what the old version had, - * which is generally not what's wanted. So add back default privs if the - * source database is too old to have had that particular priv. - */ - if (remoteVersion < 80200 && strcmp(type, "DATABASE") == 0) - { - /* database CONNECT priv didn't exist before 8.2 */ - appendPQExpBuffer(firstsql, "%sGRANT CONNECT ON %s %s TO PUBLIC;\n", - prefix, type, name); - } - /* Scan individual ACL items */ for (i = 0; i < naclitems; i++) { @@ -300,10 +282,6 @@ buildACLCommands(const char *name, const char *subname, const char *nspname, appendPQExpBuffer(secondsql, "%s TO ", name); if (grantee->len == 0) appendPQExpBufferStr(secondsql, "PUBLIC;\n"); - else if (strncmp(grantee->data, "group ", - strlen("group ")) == 0) - appendPQExpBuffer(secondsql, "GROUP %s;\n", - fmtId(grantee->data + strlen("group "))); else appendPQExpBuffer(secondsql, "%s;\n", fmtId(grantee->data)); } @@ -316,10 +294,6 @@ buildACLCommands(const char *name, const char *subname, const char *nspname, appendPQExpBuffer(secondsql, "%s TO ", name); if (grantee->len == 0) appendPQExpBufferStr(secondsql, "PUBLIC"); - else if (strncmp(grantee->data, "group ", - strlen("group ")) == 0) - appendPQExpBuffer(secondsql, "GROUP %s", - fmtId(grantee->data + strlen("group "))); else appendPQExpBufferStr(secondsql, fmtId(grantee->data)); appendPQExpBufferStr(secondsql, " WITH GRANT OPTION;\n"); @@ -432,15 +406,12 @@ buildDefaultACLCommands(const char *type, const char *nspname, /* * This will parse an aclitem string, having the general form * username=privilegecodes/grantor - * or - * group groupname=privilegecodes/grantor - * (the "group" case occurs only with servers before 8.1). * * Returns true on success, false on parse error. On success, the components * of the string are returned in the PQExpBuffer parameters. * - * The returned grantee string will be the dequoted username or groupname - * (preceded with "group " in the latter case). Note that a grant to PUBLIC + * The returned grantee string will be the dequoted username. + * Note that a grant to PUBLIC * is represented by an empty grantee string. The returned grantor is the * dequoted grantor name. Privilege characters are translated to GRANT/REVOKE * comma-separated privileges lists. If "privswgo" is non-NULL, the result is @@ -534,8 +505,7 @@ do { \ { CONVERT_PRIV('d', "DELETE"); CONVERT_PRIV('t', "TRIGGER"); - if (remoteVersion >= 80400) - CONVERT_PRIV('D', "TRUNCATE"); + CONVERT_PRIV('D', "TRUNCATE"); } } diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 9b0e699ce8..01ca293b27 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -903,13 +903,10 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te, bool is_parallel) StartTransaction(&AH->public); /* - * If the server version is >= 8.4, make sure we issue - * TRUNCATE with ONLY so that child tables are not - * wiped. + * Issue TRUNCATE with ONLY so that child tables are + * not wiped. */ - ahprintf(AH, "TRUNCATE TABLE %s%s;\n\n", - (PQserverVersion(AH->connection) >= 80400 ? - "ONLY " : ""), + ahprintf(AH, "TRUNCATE TABLE ONLY %s;\n\n", fmtQualifiedId(te->namespace, te->tag)); } diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index e9f68e8986..10b6ca8779 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -96,10 +96,6 @@ static bool dosync = true; /* Issue fsync() to make dump durable on disk. */ /* subquery used to convert user ID (eg, datdba) to user name */ static const char *username_subquery; -/* - * For 8.0 and earlier servers, pulled from pg_database, for 8.1+ we use - * FirstNormalObjectId - 1. - */ static Oid g_last_builtin_oid; /* value of the last builtin oid */ /* The specified names/patterns should to match at least one entity */ @@ -170,7 +166,6 @@ static void expand_table_name_patterns(Archive *fout, static NamespaceInfo *findNamespace(Oid nsoid); static void dumpTableData(Archive *fout, const TableDataInfo *tdinfo); static void refreshMatViewData(Archive *fout, const TableDataInfo *tdinfo); -static void guessConstraintInheritance(TableInfo *tblinfo, int numTables); static void dumpCommentExtended(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, @@ -260,17 +255,11 @@ static void buildMatViewRefreshDependencies(Archive *fout); static void getTableDataFKConstraints(void); static char *format_function_arguments(const FuncInfo *finfo, const char *funcargs, bool is_agg); -static char *format_function_arguments_old(Archive *fout, - const FuncInfo *finfo, int nallargs, - char **allargtypes, - char **argmodes, - char **argnames); static char *format_function_signature(Archive *fout, const FuncInfo *finfo, bool honor_quotes); static char *convertRegProcReference(const char *proc); static char *getFormattedOperatorName(const char *oproid); static char *convertTSFunction(Archive *fout, Oid funcOid); -static Oid findLastBuiltinOid_V71(Archive *fout); static const char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts); static void getBlobs(Archive *fout); static void dumpBlob(Archive *fout, const BlobInfo *binfo); @@ -726,10 +715,10 @@ main(int argc, char **argv) /* - * We allow the server to be back to 8.0, and up to any minor release of + * We allow the server to be back to 9.0, and up to any minor release of * our own major version. (See also version check in pg_dumpall.c.) */ - fout->minRemoteVersion = 80000; + fout->minRemoteVersion = 90000; fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99; fout->numWorkers = numWorkers; @@ -756,10 +745,7 @@ main(int argc, char **argv) dopt.no_unlogged_table_data = true; /* Select the appropriate subquery to convert user IDs to names */ - if (fout->remoteVersion >= 80100) - username_subquery = "SELECT rolname FROM pg_catalog.pg_roles WHERE oid ="; - else - username_subquery = "SELECT usename FROM pg_catalog.pg_user WHERE usesysid ="; + username_subquery = "SELECT rolname FROM pg_catalog.pg_roles WHERE oid ="; /* check the version for the synchronized snapshots feature */ if (numWorkers > 1 && fout->remoteVersion < 90200 @@ -777,10 +763,7 @@ main(int argc, char **argv) * * With 8.1 and above, we can just use FirstNormalObjectId - 1. */ - if (fout->remoteVersion < 80100) - g_last_builtin_oid = findLastBuiltinOid_V71(fout); - else - g_last_builtin_oid = FirstNormalObjectId - 1; + g_last_builtin_oid = FirstNormalObjectId - 1; pg_log_info("last built-in OID is %u", g_last_builtin_oid); @@ -848,9 +831,6 @@ main(int argc, char **argv) */ tblinfo = getSchemaData(fout, &numTables); - if (fout->remoteVersion < 80400) - guessConstraintInheritance(tblinfo, numTables); - if (!dopt.schemaOnly) { getTableData(&dopt, tblinfo, numTables, 0); @@ -1117,7 +1097,7 @@ setup_connection(Archive *AH, const char *dumpencoding, use_role = AH->use_role; /* Set the role if requested */ - if (use_role && AH->remoteVersion >= 80100) + if (use_role) { PQExpBuffer query = createPQExpBuffer(); @@ -1134,8 +1114,7 @@ setup_connection(Archive *AH, const char *dumpencoding, ExecuteSqlStatement(AH, "SET DATESTYLE = ISO"); /* Likewise, avoid using sql_standard intervalstyle */ - if (AH->remoteVersion >= 80400) - ExecuteSqlStatement(AH, "SET INTERVALSTYLE = POSTGRES"); + ExecuteSqlStatement(AH, "SET INTERVALSTYLE = POSTGRES"); /* * Use an explicitly specified extra_float_digits if it has been provided. @@ -1151,17 +1130,14 @@ setup_connection(Archive *AH, const char *dumpencoding, ExecuteSqlStatement(AH, q->data); destroyPQExpBuffer(q); } - else if (AH->remoteVersion >= 90000) - ExecuteSqlStatement(AH, "SET extra_float_digits TO 3"); else - ExecuteSqlStatement(AH, "SET extra_float_digits TO 2"); + ExecuteSqlStatement(AH, "SET extra_float_digits TO 3"); /* - * If synchronized scanning is supported, disable it, to prevent - * unpredictable changes in row ordering across a dump and reload. + * Disable synchronized scanning, to prevent unpredictable changes in row + * ordering across a dump and reload. */ - if (AH->remoteVersion >= 80300) - ExecuteSqlStatement(AH, "SET synchronize_seqscans TO off"); + ExecuteSqlStatement(AH, "SET synchronize_seqscans TO off"); /* * Disable timeouts if supported. @@ -1956,7 +1932,6 @@ dumpTableData_copy(Archive *fout, const void *dcontext) */ if (tdinfo->filtercond || tbinfo->relkind == RELKIND_FOREIGN_TABLE) { - /* Note: this syntax is only supported in 8.2 and up */ appendPQExpBufferStr(q, "COPY (SELECT "); /* klugery to get rid of parens in column list */ if (strlen(column_list) > 2) @@ -2696,81 +2671,6 @@ getTableDataFKConstraints(void) } -/* - * guessConstraintInheritance: - * In pre-8.4 databases, we can't tell for certain which constraints - * are inherited. We assume a CHECK constraint is inherited if its name - * matches the name of any constraint in the parent. Originally this code - * tried to compare the expression texts, but that can fail for various - * reasons --- for example, if the parent and child tables are in different - * schemas, reverse-listing of function calls may produce different text - * (schema-qualified or not) depending on search path. - * - * In 8.4 and up we can rely on the conislocal field to decide which - * constraints must be dumped; much safer. - * - * This function assumes all conislocal flags were initialized to true. - * It clears the flag on anything that seems to be inherited. - */ -static void -guessConstraintInheritance(TableInfo *tblinfo, int numTables) -{ - int i, - j, - k; - - for (i = 0; i < numTables; i++) - { - TableInfo *tbinfo = &(tblinfo[i]); - int numParents; - TableInfo **parents; - TableInfo *parent; - - /* Sequences and views never have parents */ - if (tbinfo->relkind == RELKIND_SEQUENCE || - tbinfo->relkind == RELKIND_VIEW) - continue; - - /* Don't bother computing anything for non-target tables, either */ - if (!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)) - continue; - - numParents = tbinfo->numParents; - parents = tbinfo->parents; - - if (numParents == 0) - continue; /* nothing to see here, move along */ - - /* scan for inherited CHECK constraints */ - for (j = 0; j < tbinfo->ncheck; j++) - { - ConstraintInfo *constr; - - constr = &(tbinfo->checkexprs[j]); - - for (k = 0; k < numParents; k++) - { - int l; - - parent = parents[k]; - for (l = 0; l < parent->ncheck; l++) - { - ConstraintInfo *pconstr = &(parent->checkexprs[l]); - - if (strcmp(pconstr->dobj.name, constr->dobj.name) == 0) - { - constr->conislocal = false; - break; - } - } - if (!constr->conislocal) - break; - } - } - } -} - - /* * dumpDatabase: * dump the database definition @@ -2875,7 +2775,7 @@ dumpDatabase(Archive *fout) "WHERE datname = current_database()", username_subquery); } - else if (fout->remoteVersion >= 80400) + else { appendPQExpBuffer(dbQry, "SELECT tableoid, oid, datname, " "(%s datdba) AS dba, " @@ -2889,33 +2789,6 @@ dumpDatabase(Archive *fout) "WHERE datname = current_database()", username_subquery); } - else if (fout->remoteVersion >= 80200) - { - appendPQExpBuffer(dbQry, "SELECT tableoid, oid, datname, " - "(%s datdba) AS dba, " - "pg_encoding_to_char(encoding) AS encoding, " - "NULL AS datcollate, NULL AS datctype, datfrozenxid, 0 AS datminmxid, " - "datacl, '' as rdatacl, datistemplate, datconnlimit, " - "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, " - "shobj_description(oid, 'pg_database') AS description " - - "FROM pg_database " - "WHERE datname = current_database()", - username_subquery); - } - else - { - appendPQExpBuffer(dbQry, "SELECT tableoid, oid, datname, " - "(%s datdba) AS dba, " - "pg_encoding_to_char(encoding) AS encoding, " - "NULL AS datcollate, NULL AS datctype, datfrozenxid, 0 AS datminmxid, " - "datacl, '' as rdatacl, datistemplate, " - "-1 as datconnlimit, " - "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace " - "FROM pg_database " - "WHERE datname = current_database()", - username_subquery); - } res = ExecuteSqlQueryForSingleRow(fout, dbQry->data); @@ -3016,7 +2889,6 @@ dumpDatabase(Archive *fout) appendPQExpBuffer(labelq, "DATABASE %s", qdatname); /* Dump DB comment if any */ - if (fout->remoteVersion >= 80200) { /* * 8.2 and up keep comments on shared objects in a shared table, so we @@ -3047,11 +2919,6 @@ dumpDatabase(Archive *fout) .nDeps = 1)); } } - else - { - dumpComment(fout, "DATABASE", qdatname, NULL, dba, - dbCatId, 0, dbDumpId); - } /* Dump DB security label, if enabled */ if (!dopt->no_security_labels && fout->remoteVersion >= 90200) @@ -3222,15 +3089,13 @@ dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, /* * First collect database-specific options. Pre-8.4 server versions lack * unnest(), so we do this the hard way by querying once per subscript. + * XXX this could be improved now. */ for (;;) { - if (AH->remoteVersion >= 90000) printfPQExpBuffer(buf, "SELECT setconfig[%d] FROM pg_db_role_setting " "WHERE setrole = 0 AND setdatabase = '%u'::oid", count, dboid); - else - printfPQExpBuffer(buf, "SELECT datconfig[%d] FROM pg_database WHERE oid = '%u'::oid", count, dboid); res = ExecuteSqlQuery(AH, buf->data, PGRES_TUPLES_OK); @@ -3251,9 +3116,6 @@ dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, } /* Now look for role-and-database-specific options */ - if (AH->remoteVersion >= 90000) - { - /* Here we can assume we have unnest() */ printfPQExpBuffer(buf, "SELECT rolname, unnest(setconfig) " "FROM pg_db_role_setting s, pg_roles r " "WHERE setrole = r.oid AND setdatabase = '%u'::oid", @@ -3273,7 +3135,6 @@ dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, } PQclear(res); - } destroyPQExpBuffer(buf); } @@ -3412,7 +3273,7 @@ getBlobs(Archive *fout) pg_log_info("reading large objects"); - /* Fetch BLOB OIDs, and owner/ACL data if >= 9.0 */ + /* Fetch BLOB OIDs and owner/ACL data */ if (fout->remoteVersion >= 90600) { PQExpBuffer acl_subquery = createPQExpBuffer(); @@ -3446,20 +3307,13 @@ getBlobs(Archive *fout) destroyPQExpBuffer(init_acl_subquery); destroyPQExpBuffer(init_racl_subquery); } - else if (fout->remoteVersion >= 90000) + else appendPQExpBuffer(blobQry, "SELECT oid, (%s lomowner) AS rolname, lomacl, " "NULL AS rlomacl, NULL AS initlomacl, " "NULL AS initrlomacl " " FROM pg_largeobject_metadata", username_subquery); - else - appendPQExpBufferStr(blobQry, - "SELECT DISTINCT loid AS oid, " - "NULL::name AS rolname, NULL::oid AS lomacl, " - "NULL::oid AS rlomacl, NULL::oid AS initlomacl, " - "NULL::oid AS initrlomacl " - " FROM pg_largeobject"); res = ExecuteSqlQuery(fout, blobQry->data, PGRES_TUPLES_OK); @@ -3598,14 +3452,9 @@ dumpBlobs(Archive *fout, const void *arg) * Currently, we re-fetch all BLOB OIDs using a cursor. Consider scanning * the already-in-memory dumpable objects instead... */ - if (fout->remoteVersion >= 90000) blobQry = "DECLARE bloboid CURSOR FOR " "SELECT oid FROM pg_largeobject_metadata ORDER BY 1"; - else - blobQry = - "DECLARE bloboid CURSOR FOR " - "SELECT DISTINCT loid FROM pg_largeobject ORDER BY 1"; ExecuteSqlStatement(fout, blobQry); @@ -4593,7 +4442,6 @@ binary_upgrade_set_type_oids_by_type_oid(Archive *fout, "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n", pg_type_oid); - /* we only support old >= 8.3 for binary upgrades */ appendPQExpBuffer(upgrade_query, "SELECT typarray " "FROM pg_catalog.pg_type " @@ -5169,7 +5017,7 @@ getTypes(Archive *fout, int *numTypes) "FROM pg_type", username_subquery); } - else if (fout->remoteVersion >= 80300) + else { appendPQExpBuffer(query, "SELECT tableoid, oid, typname, " "typnamespace, NULL AS typacl, NULL as rtypacl, " @@ -5184,20 +5032,6 @@ getTypes(Archive *fout, int *numTypes) "FROM pg_type", username_subquery); } - else - { - appendPQExpBuffer(query, "SELECT tableoid, oid, typname, " - "typnamespace, NULL AS typacl, NULL as rtypacl, " - "NULL AS inittypacl, NULL AS initrtypacl, " - "(%s typowner) AS rolname, " - "typelem, typrelid, " - "CASE WHEN typrelid = 0 THEN ' '::\"char\" " - "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, " - "typtype, typisdefined, " - "typname[0] = '_' AND typelem != 0 AS isarray " - "FROM pg_type", - username_subquery); - } res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); @@ -5722,13 +5556,6 @@ getOpfamilies(Archive *fout, int *numOpfamilies) int i_opfnamespace; int i_rolname; - /* Before 8.3, there is no separate concept of opfamilies */ - if (fout->remoteVersion < 80300) - { - *numOpfamilies = 0; - return NULL; - } - query = createPQExpBuffer(); /* @@ -5870,7 +5697,7 @@ getAggregates(Archive *fout, int *numAggs) destroyPQExpBuffer(initacl_subquery); destroyPQExpBuffer(initracl_subquery); } - else if (fout->remoteVersion >= 80200) + else { appendPQExpBuffer(query, "SELECT tableoid, oid, proname AS aggname, " "pronamespace AS aggnamespace, " @@ -5894,22 +5721,6 @@ getAggregates(Archive *fout, int *numAggs) "deptype = 'e')"); appendPQExpBufferChar(query, ')'); } - else - { - appendPQExpBuffer(query, "SELECT tableoid, oid, proname AS aggname, " - "pronamespace AS aggnamespace, " - "CASE WHEN proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype THEN 0 ELSE 1 END AS pronargs," - "proargtypes, " - "(%s proowner) AS rolname, " - "proacl AS aggacl, " - "NULL AS raggacl, " - "NULL AS initaggacl, NULL AS initraggacl " - "FROM pg_proc " - "WHERE proisagg " - "AND pronamespace != " - "(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog')", - username_subquery); - } res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); @@ -6286,6 +6097,7 @@ getTables(Archive *fout, int *numTables) "(%s c.relowner) AS rolname, " "c.relchecks, " "c.relhasindex, c.relhasrules, c.relpages, " + "c.relhastriggers, " "d.refobjid AS owning_tab, " "d.refobjsubid AS owning_col, " "tsp.spcname AS reltablespace, ", @@ -6298,13 +6110,6 @@ getTables(Archive *fout, int *numTables) appendPQExpBufferStr(query, "c.relhasoids, "); - if (fout->remoteVersion >= 80400) - appendPQExpBufferStr(query, - "c.relhastriggers, "); - else - appendPQExpBufferStr(query, - "(c.reltriggers <> 0) AS relhastriggers, "); - if (fout->remoteVersion >= 90100) appendPQExpBufferStr(query, "c.relpersistence, "); @@ -6334,14 +6139,9 @@ getTables(Archive *fout, int *numTables) "false AS relrowsecurity, " "false AS relforcerowsecurity, "); - if (fout->remoteVersion >= 80200) - appendPQExpBufferStr(query, - "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, " - "tc.oid AS toid, "); - else - appendPQExpBufferStr(query, - "0 AS relfrozenxid, 0 AS tfrozenxid, " - "0 AS toid, "); + appendPQExpBufferStr(query, + "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, " + "tc.oid AS toid, "); if (fout->remoteVersion >= 90300) appendPQExpBufferStr(query, @@ -6355,26 +6155,15 @@ getTables(Archive *fout, int *numTables) "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 if (fout->remoteVersion >= 80200) - appendPQExpBufferStr(query, - "c.reloptions, NULL AS checkoption, "); else appendPQExpBufferStr(query, - "NULL AS reloptions, NULL AS checkoption, "); + "c.reloptions, NULL AS checkoption, "); - if (fout->remoteVersion >= 80400) - appendPQExpBufferStr(query, - "tc.reloptions AS toast_reloptions, "); - else - appendPQExpBufferStr(query, - "NULL AS toast_reloptions, "); + appendPQExpBufferStr(query, + "tc.reloptions AS toast_reloptions, "); - if (fout->remoteVersion >= 90000) - appendPQExpBufferStr(query, - "CASE WHEN c.reloftype <> 0 THEN c.reloftype::pg_catalog.regtype ELSE NULL END AS reloftype,"); - else - appendPQExpBufferStr(query, - "NULL AS reloftype, "); + appendPQExpBufferStr(query, + "CASE WHEN c.reloftype <> 0 THEN c.reloftype::pg_catalog.regtype ELSE NULL END AS reloftype, "); if (fout->remoteVersion >= 90100) appendPQExpBufferStr(query, @@ -6479,7 +6268,8 @@ getTables(Archive *fout, int *numTables) /* * Left join to pg_depend to pick up dependency info linking sequences to - * their owning column, if any (note this dependency is AUTO as of 8.2). + * their owning column, if any (note this dependency is AUTO except for + * identity sequences, where it's INTERNAL). * Also join to pg_tablespace to collect the spcname. */ appendPQExpBufferStr(query, @@ -6505,15 +6295,12 @@ getTables(Archive *fout, int *numTables) "LEFT JOIN pg_am am ON (c.relam = am.oid)\n"); /* - * We don't need any data from the TOAST table before 8.2. - * * We purposefully ignore toast OIDs for partitioned tables; the reason is * that versions 10 and 11 have them, but later versions do not, so * emitting them causes the upgrade to fail. */ - if (fout->remoteVersion >= 80200) - appendPQExpBufferStr(query, - "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid AND c.relkind <> " CppAsString2(RELKIND_PARTITIONED_TABLE)")\n"); + appendPQExpBufferStr(query, + "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid AND c.relkind <> " CppAsString2(RELKIND_PARTITIONED_TABLE)")\n"); /* * Restrict to interesting relkinds (in particular, not indexes). Not all @@ -7001,7 +6788,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables) "ORDER BY indexname", tbinfo->dobj.catId.oid); } - else if (fout->remoteVersion >= 90000) + else { /* * the test on indisready is necessary in 9.2, and harmless in @@ -7036,73 +6823,6 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables) "ORDER BY indexname", tbinfo->dobj.catId.oid); } - else if (fout->remoteVersion >= 80200) - { - appendPQExpBuffer(query, - "SELECT t.tableoid, t.oid, " - "t.relname AS indexname, " - "0 AS parentidx, " - "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, " - "i.indnatts AS indnkeyatts, " - "i.indnatts AS indnatts, " - "i.indkey, i.indisclustered, " - "false AS indisreplident, " - "c.contype, c.conname, " - "c.condeferrable, c.condeferred, " - "c.tableoid AS contableoid, " - "c.oid AS conoid, " - "null AS condef, " - "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace," - "t.reloptions AS indreloptions, " - "'' AS indstatcols, " - "'' AS indstatvals " - "FROM pg_catalog.pg_index i " - "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) " - "LEFT JOIN pg_catalog.pg_depend d " - "ON (d.classid = t.tableoid " - "AND d.objid = t.oid " - "AND d.deptype = 'i') " - "LEFT JOIN pg_catalog.pg_constraint c " - "ON (d.refclassid = c.tableoid " - "AND d.refobjid = c.oid) " - "WHERE i.indrelid = '%u'::pg_catalog.oid " - "AND i.indisvalid " - "ORDER BY indexname", - tbinfo->dobj.catId.oid); - } - else - { - appendPQExpBuffer(query, - "SELECT t.tableoid, t.oid, " - "t.relname AS indexname, " - "0 AS parentidx, " - "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, " - "t.relnatts AS indnkeyatts, " - "t.relnatts AS indnatts, " - "i.indkey, i.indisclustered, " - "false AS indisreplident, " - "c.contype, c.conname, " - "c.condeferrable, c.condeferred, " - "c.tableoid AS contableoid, " - "c.oid AS conoid, " - "null AS condef, " - "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace," - "null AS indreloptions, " - "'' AS indstatcols, " - "'' AS indstatvals " - "FROM pg_catalog.pg_index i " - "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) " - "LEFT JOIN pg_catalog.pg_depend d " - "ON (d.classid = t.tableoid " - "AND d.objid = t.oid " - "AND d.deptype = 'i') " - "LEFT JOIN pg_catalog.pg_constraint c " - "ON (d.refclassid = c.tableoid " - "AND d.refobjid = c.oid) " - "WHERE i.indrelid = '%u'::pg_catalog.oid " - "ORDER BY indexname", - tbinfo->dobj.catId.oid); - } res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); @@ -7557,24 +7277,12 @@ getRules(Archive *fout, int *numRules) int i_is_instead; int i_ev_enabled; - if (fout->remoteVersion >= 80300) - { - appendPQExpBufferStr(query, "SELECT " - "tableoid, oid, rulename, " - "ev_class AS ruletable, ev_type, is_instead, " - "ev_enabled " - "FROM pg_rewrite " - "ORDER BY oid"); - } - else - { - appendPQExpBufferStr(query, "SELECT " - "tableoid, oid, rulename, " - "ev_class AS ruletable, ev_type, is_instead, " - "'O'::char AS ev_enabled " - "FROM pg_rewrite " - "ORDER BY oid"); - } + appendPQExpBufferStr(query, "SELECT " + "tableoid, oid, rulename, " + "ev_class AS ruletable, ev_type, is_instead, " + "ev_enabled " + "FROM pg_rewrite " + "ORDER BY oid"); res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); @@ -7741,7 +7449,7 @@ getTriggers(Archive *fout, TableInfo tblinfo[], int numTables) tbinfo->ispartition ? " OR t.tgenabled != pt.tgenabled" : ""); } - else if (fout->remoteVersion >= 90000) + else { /* See above about pretty=true in pg_get_triggerdef */ appendPQExpBuffer(query, @@ -7755,48 +7463,6 @@ getTriggers(Archive *fout, TableInfo tblinfo[], int numTables) "AND NOT tgisinternal", tbinfo->dobj.catId.oid); } - else if (fout->remoteVersion >= 80300) - { - /* - * We ignore triggers that are tied to a foreign-key constraint - */ - appendPQExpBuffer(query, - "SELECT tgname, " - "tgfoid::pg_catalog.regproc AS tgfname, " - "tgtype, tgnargs, tgargs, tgenabled, " - "false as tgisinternal, " - "tgisconstraint, tgconstrname, tgdeferrable, " - "tgconstrrelid, tginitdeferred, tableoid, oid, " - "tgconstrrelid::pg_catalog.regclass AS tgconstrrelname " - "FROM pg_catalog.pg_trigger t " - "WHERE tgrelid = '%u'::pg_catalog.oid " - "AND tgconstraint = 0", - tbinfo->dobj.catId.oid); - } - else - { - /* - * We ignore triggers that are tied to a foreign-key constraint, - * but in these versions we have to grovel through pg_constraint - * to find out - */ - appendPQExpBuffer(query, - "SELECT tgname, " - "tgfoid::pg_catalog.regproc AS tgfname, " - "tgtype, tgnargs, tgargs, tgenabled, " - "false as tgisinternal, " - "tgisconstraint, tgconstrname, tgdeferrable, " - "tgconstrrelid, tginitdeferred, tableoid, oid, " - "tgconstrrelid::pg_catalog.regclass AS tgconstrrelname " - "FROM pg_catalog.pg_trigger t " - "WHERE tgrelid = '%u'::pg_catalog.oid " - "AND (NOT tgisconstraint " - " OR NOT EXISTS" - " (SELECT 1 FROM pg_catalog.pg_depend d " - " JOIN pg_catalog.pg_constraint c ON (d.refclassid = c.tableoid AND d.refobjid = c.oid)" - " WHERE d.classid = t.tableoid AND d.objid = t.oid AND d.deptype = 'i' AND c.contype = 'f'))", - tbinfo->dobj.catId.oid); - } res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); @@ -8049,7 +7715,7 @@ getProcLangs(Archive *fout, int *numProcLangs) destroyPQExpBuffer(initacl_subquery); destroyPQExpBuffer(initracl_subquery); } - else if (fout->remoteVersion >= 90000) + else { /* pg_language has a laninline column */ appendPQExpBuffer(query, "SELECT tableoid, oid, " @@ -8062,48 +7728,6 @@ getProcLangs(Archive *fout, int *numProcLangs) "ORDER BY oid", username_subquery); } - else if (fout->remoteVersion >= 80300) - { - /* pg_language has a lanowner column */ - appendPQExpBuffer(query, "SELECT tableoid, oid, " - "lanname, lanpltrusted, lanplcallfoid, " - "0 AS laninline, lanvalidator, lanacl, " - "NULL AS rlanacl, " - "NULL AS initlanacl, NULL AS initrlanacl, " - "(%s lanowner) AS lanowner " - "FROM pg_language " - "WHERE lanispl " - "ORDER BY oid", - username_subquery); - } - else if (fout->remoteVersion >= 80100) - { - /* Languages are owned by the bootstrap superuser, OID 10 */ - appendPQExpBuffer(query, "SELECT tableoid, oid, " - "lanname, lanpltrusted, lanplcallfoid, " - "0 AS laninline, lanvalidator, lanacl, " - "NULL AS rlanacl, " - "NULL AS initlanacl, NULL AS initrlanacl, " - "(%s '10') AS lanowner " - "FROM pg_language " - "WHERE lanispl " - "ORDER BY oid", - username_subquery); - } - else - { - /* Languages are owned by the bootstrap superuser, sysid 1 */ - appendPQExpBuffer(query, "SELECT tableoid, oid, " - "lanname, lanpltrusted, lanplcallfoid, " - "0 AS laninline, lanvalidator, lanacl, " - "NULL AS rlanacl, " - "NULL AS initlanacl, NULL AS initrlanacl, " - "(%s '1') AS lanowner " - "FROM pg_language " - "WHERE lanispl " - "ORDER BY oid", - username_subquery); - } res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); @@ -8199,18 +7823,11 @@ getCasts(Archive *fout, int *numCasts) ") " "ORDER BY 3,4"); } - else if (fout->remoteVersion >= 80400) - { - appendPQExpBufferStr(query, "SELECT tableoid, oid, " - "castsource, casttarget, castfunc, castcontext, " - "castmethod " - "FROM pg_cast ORDER BY 3,4"); - } else { appendPQExpBufferStr(query, "SELECT tableoid, oid, " "castsource, casttarget, castfunc, castcontext, " - "CASE WHEN castfunc = 0 THEN 'b' ELSE 'f' END AS castmethod " + "castmethod " "FROM pg_cast ORDER BY 3,4"); } @@ -8460,14 +8077,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) "a.attlen,\n" "a.attalign,\n" "a.attislocal,\n" - "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n"); - - if (fout->remoteVersion >= 90000) - appendPQExpBufferStr(q, - "array_to_string(a.attoptions, ', ') AS attoptions,\n"); - else - appendPQExpBufferStr(q, - "'' AS attoptions,\n"); + "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n" + "array_to_string(a.attoptions, ', ') AS attoptions,\n"); if (fout->remoteVersion >= 90100) { @@ -8759,7 +8370,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) "ORDER BY conname", tbinfo->dobj.catId.oid); } - else if (fout->remoteVersion >= 80400) + else { /* conislocal is new in 8.4 */ appendPQExpBuffer(q, "SELECT tableoid, oid, conname, " @@ -8771,17 +8382,6 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) "ORDER BY conname", tbinfo->dobj.catId.oid); } - else - { - appendPQExpBuffer(q, "SELECT tableoid, oid, conname, " - "pg_catalog.pg_get_constraintdef(oid) AS consrc, " - "true AS conislocal, true AS convalidated " - "FROM pg_catalog.pg_constraint " - "WHERE conrelid = '%u'::pg_catalog.oid " - " AND contype = 'c' " - "ORDER BY conname", - tbinfo->dobj.catId.oid); - } res = ExecuteSqlQuery(fout, q->data, PGRES_TUPLES_OK); @@ -8907,13 +8507,6 @@ getTSParsers(Archive *fout, int *numTSParsers) int i_prsheadline; int i_prslextype; - /* Before 8.3, there is no built-in text search support */ - if (fout->remoteVersion < 80300) - { - *numTSParsers = 0; - return NULL; - } - query = createPQExpBuffer(); /* @@ -8995,13 +8588,6 @@ getTSDictionaries(Archive *fout, int *numTSDicts) int i_dicttemplate; int i_dictinitoption; - /* Before 8.3, there is no built-in text search support */ - if (fout->remoteVersion < 80300) - { - *numTSDicts = 0; - return NULL; - } - query = createPQExpBuffer(); appendPQExpBuffer(query, "SELECT tableoid, oid, dictname, " @@ -9077,13 +8663,6 @@ getTSTemplates(Archive *fout, int *numTSTemplates) int i_tmplinit; int i_tmpllexize; - /* Before 8.3, there is no built-in text search support */ - if (fout->remoteVersion < 80300) - { - *numTSTemplates = 0; - return NULL; - } - query = createPQExpBuffer(); appendPQExpBufferStr(query, "SELECT tableoid, oid, tmplname, " @@ -9152,13 +8731,6 @@ getTSConfigurations(Archive *fout, int *numTSConfigs) int i_rolname; int i_cfgparser; - /* Before 8.3, there is no built-in text search support */ - if (fout->remoteVersion < 80300) - { - *numTSConfigs = 0; - return NULL; - } - query = createPQExpBuffer(); appendPQExpBuffer(query, "SELECT tableoid, oid, cfgname, " @@ -9234,13 +8806,6 @@ getForeignDataWrappers(Archive *fout, int *numForeignDataWrappers) int i_initrfdwacl; int i_fdwoptions; - /* Before 8.4, there are no foreign-data wrappers */ - if (fout->remoteVersion < 80400) - { - *numForeignDataWrappers = 0; - return NULL; - } - query = createPQExpBuffer(); if (fout->remoteVersion >= 90600) @@ -9401,13 +8966,6 @@ getForeignServers(Archive *fout, int *numForeignServers) int i_initrsrvacl; int i_srvoptions; - /* Before 8.4, there are no foreign servers */ - if (fout->remoteVersion < 80400) - { - *numForeignServers = 0; - return NULL; - } - query = createPQExpBuffer(); if (fout->remoteVersion >= 90600) @@ -9548,12 +9106,6 @@ getDefaultACLs(Archive *fout, int *numDefaultACLs) int i, ntups; - if (fout->remoteVersion < 90000) - { - *numDefaultACLs = 0; - return NULL; - } - query = createPQExpBuffer(); if (fout->remoteVersion >= 90600) @@ -10269,9 +9821,7 @@ dumpNamespace(Archive *fout, const NamespaceInfo *nspinfo) const char *initdb_comment = NULL; if (!nspinfo->create && strcmp(qnspname, "public") == 0) - initdb_comment = (fout->remoteVersion >= 80300 ? - "standard public schema" : - "Standard public schema"); + initdb_comment = "standard public schema"; dumpCommentExtended(fout, "SCHEMA", qnspname, NULL, nspinfo->rolname, nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId, @@ -10845,24 +10395,11 @@ dumpBaseType(Archive *fout, const TypeInfo *tyinfo) "typsend::pg_catalog.oid AS typsendoid, " "typanalyze, " "typanalyze::pg_catalog.oid AS typanalyzeoid, " - "typdelim, typbyval, typalign, typstorage, "); - - if (fout->remoteVersion >= 80300) - appendPQExpBufferStr(query, - "typmodin, typmodout, " - "typmodin::pg_catalog.oid AS typmodinoid, " - "typmodout::pg_catalog.oid AS typmodoutoid, "); - else - appendPQExpBufferStr(query, - "'-' AS typmodin, '-' AS typmodout, " - "0 AS typmodinoid, 0 AS typmodoutoid, "); - - if (fout->remoteVersion >= 80400) - appendPQExpBufferStr(query, - "typcategory, typispreferred, "); - else - appendPQExpBufferStr(query, - "'U' AS typcategory, false AS typispreferred, "); + "typdelim, typbyval, typalign, typstorage, " + "typmodin, typmodout, " + "typmodin::pg_catalog.oid AS typmodinoid, " + "typmodout::pg_catalog.oid AS typmodoutoid, " + "typcategory, typispreferred, "); if (fout->remoteVersion >= 90100) appendPQExpBufferStr(query, "(typcollation <> 0) AS typcollatable, "); @@ -10877,13 +10414,8 @@ dumpBaseType(Archive *fout, const TypeInfo *tyinfo) appendPQExpBufferStr(query, "'-' AS typsubscript, 0 AS typsubscriptoid, "); - /* Before 8.4, pg_get_expr does not allow 0 for its second arg */ - if (fout->remoteVersion >= 80400) - appendPQExpBufferStr(query, - "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault "); - else - appendPQExpBufferStr(query, - "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin,typdefault "); + appendPQExpBufferStr(query, + "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault "); appendPQExpBuffer(query, "FROM pg_catalog.pg_type " "WHERE oid = '%u'::pg_catalog.oid", @@ -11758,82 +11290,11 @@ format_function_arguments(const FuncInfo *finfo, const char *funcargs, bool is_a return fn.data; } -/* - * format_function_arguments_old: generate function name and argument list - * - * The argument type names are qualified if needed. The function name - * is never qualified. - * - * This is used only with pre-8.4 servers, so we aren't expecting to see - * VARIADIC or TABLE arguments, nor are there any defaults for arguments. - * - * Any or all of allargtypes, argmodes, argnames may be NULL. - */ -static char * -format_function_arguments_old(Archive *fout, - const FuncInfo *finfo, int nallargs, - char **allargtypes, - char **argmodes, - char **argnames) -{ - PQExpBufferData fn; - int j; - - initPQExpBuffer(&fn); - appendPQExpBuffer(&fn, "%s(", fmtId(finfo->dobj.name)); - for (j = 0; j < nallargs; j++) - { - Oid typid; - const char *typname; - const char *argmode; - const char *argname; - - typid = allargtypes ? atooid(allargtypes[j]) : finfo->argtypes[j]; - typname = getFormattedTypeName(fout, typid, zeroIsError); - - if (argmodes) - { - switch (argmodes[j][0]) - { - case PROARGMODE_IN: - argmode = ""; - break; - case PROARGMODE_OUT: - argmode = "OUT "; - break; - case PROARGMODE_INOUT: - argmode = "INOUT "; - break; - default: - pg_log_warning("bogus value in proargmodes array"); - argmode = ""; - break; - } - } - else - argmode = ""; - - argname = argnames ? argnames[j] : (char *) NULL; - if (argname && argname[0] == '\0') - argname = NULL; - - appendPQExpBuffer(&fn, "%s%s%s%s%s", - (j > 0) ? ", " : "", - argmode, - argname ? fmtId(argname) : "", - argname ? " " : "", - typname); - } - appendPQExpBufferChar(&fn, ')'); - return fn.data; -} - /* * format_function_signature: generate function name and argument list * - * This is like format_function_arguments_old except that only a minimal - * list of input argument types is generated; this is sufficient to - * reference the function, but not to define it. + * Only a minimal list of input argument types is generated; this is + * sufficient to reference the function, but not to define it. * * If honor_quotes is false then the function name is never quoted. * This is appropriate for use in TOC tags, but not in SQL commands. @@ -11929,40 +11390,13 @@ dumpFunc(Archive *fout, const FuncInfo *finfo) "provolatile,\n" "proisstrict,\n" "prosecdef,\n" - "lanname,\n"); - - if (fout->remoteVersion >= 80300) - appendPQExpBufferStr(query, - "proconfig,\n" - "procost,\n" - "prorows,\n"); - else - appendPQExpBufferStr(query, - "null AS proconfig,\n" - "0 AS procost,\n" - "0 AS prorows,\n"); - - if (fout->remoteVersion >= 80400) - { - /* - * In 8.4 and up we rely on pg_get_function_arguments and - * pg_get_function_result instead of examining proallargtypes etc. - */ - appendPQExpBufferStr(query, - "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"); - } - else if (fout->remoteVersion >= 80100) - appendPQExpBufferStr(query, - "proallargtypes,\n" - "proargmodes,\n" - "proargnames,\n"); - else - appendPQExpBufferStr(query, - "null AS proallargtypes,\n" - "null AS proargmodes,\n" - "proargnames,\n"); + "lanname,\n" + "proconfig,\n" + "procost,\n" + "prorows,\n" + "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"); if (fout->remoteVersion >= 90200) appendPQExpBufferStr(query, @@ -11985,12 +11419,9 @@ dumpFunc(Archive *fout, const FuncInfo *finfo) if (fout->remoteVersion >= 110000) appendPQExpBufferStr(query, "prokind,\n"); - else if (fout->remoteVersion >= 80400) - appendPQExpBufferStr(query, - "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n"); else appendPQExpBufferStr(query, - "'f' AS prokind,\n"); + "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n"); if (fout->remoteVersion >= 120000) appendPQExpBufferStr(query, @@ -12027,20 +11458,10 @@ dumpFunc(Archive *fout, const FuncInfo *finfo) probin = NULL; prosqlbody = PQgetvalue(res, 0, PQfnumber(res, "prosqlbody")); } - if (fout->remoteVersion >= 80400) - { - funcargs = PQgetvalue(res, 0, PQfnumber(res, "funcargs")); - funciargs = PQgetvalue(res, 0, PQfnumber(res, "funciargs")); - funcresult = PQgetvalue(res, 0, PQfnumber(res, "funcresult")); - proallargtypes = proargmodes = proargnames = NULL; - } - else - { - proallargtypes = PQgetvalue(res, 0, PQfnumber(res, "proallargtypes")); - proargmodes = PQgetvalue(res, 0, PQfnumber(res, "proargmodes")); - proargnames = PQgetvalue(res, 0, PQfnumber(res, "proargnames")); - funcargs = funciargs = funcresult = NULL; - } + funcargs = PQgetvalue(res, 0, PQfnumber(res, "funcargs")); + funciargs = PQgetvalue(res, 0, PQfnumber(res, "funciargs")); + funcresult = PQgetvalue(res, 0, PQfnumber(res, "funcresult")); + proallargtypes = proargmodes = proargnames = NULL; if (PQfnumber(res, "protrftypes") != -1) protrftypes = PQgetvalue(res, 0, PQfnumber(res, "protrftypes")); else @@ -12156,17 +11577,8 @@ dumpFunc(Archive *fout, const FuncInfo *finfo) nconfigitems = 0; } - if (funcargs) - { - /* 8.4 or later; we rely on server-side code for most of the work */ - funcfullsig = format_function_arguments(finfo, funcargs, false); - funcsig = format_function_arguments(finfo, funciargs, false); - } - else - /* pre-8.4, do it ourselves */ - funcsig = format_function_arguments_old(fout, - finfo, nallargs, allargtypes, - argmodes, argnames); + funcfullsig = format_function_arguments(finfo, funcargs, false); + funcsig = format_function_arguments(finfo, funciargs, false); funcsig_tag = format_function_signature(fout, finfo, false); @@ -12677,8 +12089,6 @@ dumpOpr(Archive *fout, const OprInfo *oprinfo) oprid = createPQExpBuffer(); details = createPQExpBuffer(); - if (fout->remoteVersion >= 80300) - { appendPQExpBuffer(query, "SELECT oprkind, " "oprcode::pg_catalog.regprocedure, " "oprleft::pg_catalog.regtype, " @@ -12691,23 +12101,6 @@ dumpOpr(Archive *fout, const OprInfo *oprinfo) "FROM pg_catalog.pg_operator " "WHERE oid = '%u'::pg_catalog.oid", oprinfo->dobj.catId.oid); - } - else - { - appendPQExpBuffer(query, "SELECT oprkind, " - "oprcode::pg_catalog.regprocedure, " - "oprleft::pg_catalog.regtype, " - "oprright::pg_catalog.regtype, " - "oprcom, " - "oprnegate, " - "oprrest::pg_catalog.regprocedure, " - "oprjoin::pg_catalog.regprocedure, " - "(oprlsortop != 0) AS oprcanmerge, " - "oprcanhash " - "FROM pg_catalog.pg_operator " - "WHERE oid = '%u'::pg_catalog.oid", - oprinfo->dobj.catId.oid); - } res = ExecuteSqlQueryForSingleRow(fout, query->data); @@ -13031,7 +12424,6 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) int i_opcfamilynsp; int i_amname; int i_amopstrategy; - int i_amopreqcheck; int i_amopopr; int i_sortfamily; int i_sortfamilynsp; @@ -13047,7 +12439,6 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) char *opcfamilynsp; char *amname; char *amopstrategy; - char *amopreqcheck; char *amopopr; char *sortfamily; char *sortfamilynsp; @@ -13068,8 +12459,6 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) nameusing = createPQExpBuffer(); /* Get additional fields from the pg_opclass row */ - if (fout->remoteVersion >= 80300) - { appendPQExpBuffer(query, "SELECT opcintype::pg_catalog.regtype, " "opckeytype::pg_catalog.regtype, " "opcdefault, opcfamily, " @@ -13081,19 +12470,6 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace " "WHERE c.oid = '%u'::pg_catalog.oid", opcinfo->dobj.catId.oid); - } - else - { - appendPQExpBuffer(query, "SELECT opcintype::pg_catalog.regtype, " - "opckeytype::pg_catalog.regtype, " - "opcdefault, NULL AS opcfamily, " - "NULL AS opcfamilyname, " - "NULL AS opcfamilynsp, " - "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcamid) AS amname " - "FROM pg_catalog.pg_opclass " - "WHERE oid = '%u'::pg_catalog.oid", - opcinfo->dobj.catId.oid); - } res = ExecuteSqlQueryForSingleRow(fout, query->data); @@ -13153,18 +12529,12 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) * * Print only those opfamily members that are tied to the opclass by * pg_depend entries. - * - * XXX RECHECK is gone as of 8.4, but we'll still print it if dumping an - * older server's opclass in which it is used. This is to avoid - * hard-to-detect breakage if a newer pg_dump is used to dump from an - * older server and then reload into that old version. This can go away - * once 8.3 is so old as to not be of interest to anyone. */ resetPQExpBuffer(query); if (fout->remoteVersion >= 90100) { - appendPQExpBuffer(query, "SELECT amopstrategy, false AS amopreqcheck, " + appendPQExpBuffer(query, "SELECT amopstrategy, " "amopopr::pg_catalog.regoperator, " "opfname AS sortfamily, " "nspname AS sortfamilynsp " @@ -13179,23 +12549,9 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) opcinfo->dobj.catId.oid, opcfamily); } - else if (fout->remoteVersion >= 80400) - { - appendPQExpBuffer(query, "SELECT amopstrategy, false AS amopreqcheck, " - "amopopr::pg_catalog.regoperator, " - "NULL AS sortfamily, " - "NULL AS sortfamilynsp " - "FROM pg_catalog.pg_amop ao, pg_catalog.pg_depend " - "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass " - "AND refobjid = '%u'::pg_catalog.oid " - "AND classid = 'pg_catalog.pg_amop'::pg_catalog.regclass " - "AND objid = ao.oid " - "ORDER BY amopstrategy", - opcinfo->dobj.catId.oid); - } - else if (fout->remoteVersion >= 80300) + else { - appendPQExpBuffer(query, "SELECT amopstrategy, amopreqcheck, " + appendPQExpBuffer(query, "SELECT amopstrategy, " "amopopr::pg_catalog.regoperator, " "NULL AS sortfamily, " "NULL AS sortfamilynsp " @@ -13207,28 +12563,12 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) "ORDER BY amopstrategy", opcinfo->dobj.catId.oid); } - else - { - /* - * Here, we print all entries since there are no opfamilies and hence - * no loose operators to worry about. - */ - appendPQExpBuffer(query, "SELECT amopstrategy, amopreqcheck, " - "amopopr::pg_catalog.regoperator, " - "NULL AS sortfamily, " - "NULL AS sortfamilynsp " - "FROM pg_catalog.pg_amop " - "WHERE amopclaid = '%u'::pg_catalog.oid " - "ORDER BY amopstrategy", - opcinfo->dobj.catId.oid); - } res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); ntups = PQntuples(res); i_amopstrategy = PQfnumber(res, "amopstrategy"); - i_amopreqcheck = PQfnumber(res, "amopreqcheck"); i_amopopr = PQfnumber(res, "amopopr"); i_sortfamily = PQfnumber(res, "sortfamily"); i_sortfamilynsp = PQfnumber(res, "sortfamilynsp"); @@ -13236,7 +12576,6 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) for (i = 0; i < ntups; i++) { amopstrategy = PQgetvalue(res, i, i_amopstrategy); - amopreqcheck = PQgetvalue(res, i, i_amopreqcheck); amopopr = PQgetvalue(res, i, i_amopopr); sortfamily = PQgetvalue(res, i, i_sortfamily); sortfamilynsp = PQgetvalue(res, i, i_sortfamilynsp); @@ -13254,9 +12593,6 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) appendPQExpBufferStr(q, fmtId(sortfamily)); } - if (strcmp(amopreqcheck, "t") == 0) - appendPQExpBufferStr(q, " RECHECK"); - needComma = true; } @@ -13276,8 +12612,6 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) */ resetPQExpBuffer(query); - if (fout->remoteVersion >= 80300) - { appendPQExpBuffer(query, "SELECT amprocnum, " "amproc::pg_catalog.regprocedure, " "amproclefttype::pg_catalog.regtype, " @@ -13289,18 +12623,6 @@ dumpOpclass(Archive *fout, const OpclassInfo *opcinfo) "AND objid = ap.oid " "ORDER BY amprocnum", opcinfo->dobj.catId.oid); - } - else - { - appendPQExpBuffer(query, "SELECT amprocnum, " - "amproc::pg_catalog.regprocedure, " - "'' AS amproclefttype, " - "'' AS amprocrighttype " - "FROM pg_catalog.pg_amproc " - "WHERE amopclaid = '%u'::pg_catalog.oid " - "ORDER BY amprocnum", - opcinfo->dobj.catId.oid); - } res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); @@ -13399,7 +12721,6 @@ dumpOpfamily(Archive *fout, const OpfamilyInfo *opfinfo) int ntups; int i_amname; int i_amopstrategy; - int i_amopreqcheck; int i_amopopr; int i_sortfamily; int i_sortfamilynsp; @@ -13409,7 +12730,6 @@ dumpOpfamily(Archive *fout, const OpfamilyInfo *opfinfo) int i_amprocrighttype; char *amname; char *amopstrategy; - char *amopreqcheck; char *amopopr; char *sortfamily; char *sortfamilynsp; @@ -13432,16 +12752,10 @@ dumpOpfamily(Archive *fout, const OpfamilyInfo *opfinfo) /* * Fetch only those opfamily members that are tied directly to the * opfamily by pg_depend entries. - * - * XXX RECHECK is gone as of 8.4, but we'll still print it if dumping an - * older server's opclass in which it is used. This is to avoid - * hard-to-detect breakage if a newer pg_dump is used to dump from an - * older server and then reload into that old version. This can go away - * once 8.3 is so old as to not be of interest to anyone. */ if (fout->remoteVersion >= 90100) { - appendPQExpBuffer(query, "SELECT amopstrategy, false AS amopreqcheck, " + appendPQExpBuffer(query, "SELECT amopstrategy, " "amopopr::pg_catalog.regoperator, " "opfname AS sortfamily, " "nspname AS sortfamilynsp " @@ -13456,23 +12770,9 @@ dumpOpfamily(Archive *fout, const OpfamilyInfo *opfinfo) opfinfo->dobj.catId.oid, opfinfo->dobj.catId.oid); } - else if (fout->remoteVersion >= 80400) - { - appendPQExpBuffer(query, "SELECT amopstrategy, false AS amopreqcheck, " - "amopopr::pg_catalog.regoperator, " - "NULL AS sortfamily, " - "NULL AS sortfamilynsp " - "FROM pg_catalog.pg_amop ao, pg_catalog.pg_depend " - "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass " - "AND refobjid = '%u'::pg_catalog.oid " - "AND classid = 'pg_catalog.pg_amop'::pg_catalog.regclass " - "AND objid = ao.oid " - "ORDER BY amopstrategy", - opfinfo->dobj.catId.oid); - } else { - appendPQExpBuffer(query, "SELECT amopstrategy, amopreqcheck, " + appendPQExpBuffer(query, "SELECT amopstrategy, " "amopopr::pg_catalog.regoperator, " "NULL AS sortfamily, " "NULL AS sortfamilynsp " @@ -13548,7 +12848,6 @@ dumpOpfamily(Archive *fout, const OpfamilyInfo *opfinfo) ntups = PQntuples(res_ops); i_amopstrategy = PQfnumber(res_ops, "amopstrategy"); - i_amopreqcheck = PQfnumber(res_ops, "amopreqcheck"); i_amopopr = PQfnumber(res_ops, "amopopr"); i_sortfamily = PQfnumber(res_ops, "sortfamily"); i_sortfamilynsp = PQfnumber(res_ops, "sortfamilynsp"); @@ -13556,7 +12855,6 @@ dumpOpfamily(Archive *fout, const OpfamilyInfo *opfinfo) for (i = 0; i < ntups; i++) { amopstrategy = PQgetvalue(res_ops, i, i_amopstrategy); - amopreqcheck = PQgetvalue(res_ops, i, i_amopreqcheck); amopopr = PQgetvalue(res_ops, i, i_amopopr); sortfamily = PQgetvalue(res_ops, i, i_sortfamily); sortfamilynsp = PQgetvalue(res_ops, i, i_sortfamilynsp); @@ -13574,9 +12872,6 @@ dumpOpfamily(Archive *fout, const OpfamilyInfo *opfinfo) appendPQExpBufferStr(q, fmtId(sortfamily)); } - if (strcmp(amopreqcheck, "t") == 0) - appendPQExpBufferStr(q, " RECHECK"); - needComma = true; } @@ -13980,19 +13275,10 @@ dumpAgg(Archive *fout, const AggInfo *agginfo) "aggtransfn,\n" "aggfinalfn,\n" "aggtranstype::pg_catalog.regtype,\n" - "agginitval,\n"); - - if (fout->remoteVersion >= 80100) - appendPQExpBufferStr(query, - "aggsortop,\n"); - else - appendPQExpBufferStr(query, - "0 AS aggsortop,\n"); - - if (fout->remoteVersion >= 80400) - appendPQExpBufferStr(query, - "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n" - "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"); + "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, @@ -14074,9 +13360,7 @@ dumpAgg(Archive *fout, const AggInfo *agginfo) aggminitval = PQgetvalue(res, 0, i_aggminitval); proparallel = PQgetvalue(res, 0, PQfnumber(res, "proparallel")); - if (fout->remoteVersion >= 80400) { - /* 8.4 or later; we rely on server-side code for most of the work */ char *funcargs; char *funciargs; @@ -14085,9 +13369,6 @@ dumpAgg(Archive *fout, const AggInfo *agginfo) aggfullsig = format_function_arguments(&agginfo->aggfn, funcargs, true); aggsig = format_function_arguments(&agginfo->aggfn, funciargs, true); } - else - /* pre-8.4, do it ourselves */ - aggsig = format_aggregate_signature(agginfo, fout, true); aggsig_tag = format_aggregate_signature(agginfo, fout, false); @@ -15422,7 +14703,7 @@ dumpTable(Archive *fout, const TableInfo *tbinfo) * rather than trying to fetch them during getTableAttrs, so that we won't * miss ACLs on system columns. */ - if (fout->remoteVersion >= 80400 && tbinfo->dobj.dump & DUMP_COMPONENT_ACL) + if (tbinfo->dobj.dump & DUMP_COMPONENT_ACL) { PQExpBuffer query = createPQExpBuffer(); PGresult *res; @@ -17067,29 +16348,6 @@ dumpTableConstraintComment(Archive *fout, const ConstraintInfo *coninfo) free(qtabname); } -/* - * findLastBuiltinOid_V71 - - * - * find the last built in oid - * - * For 7.1 through 8.0, we do this by retrieving datlastsysoid from the - * pg_database entry for the current database. (Note: current_database() - * requires 7.3; pg_dump requires 8.0 now.) - */ -static Oid -findLastBuiltinOid_V71(Archive *fout) -{ - PGresult *res; - Oid last_oid; - - res = ExecuteSqlQueryForSingleRow(fout, - "SELECT datlastsysoid FROM pg_database WHERE datname = current_database()"); - last_oid = atooid(PQgetvalue(res, 0, PQfnumber(res, "datlastsysoid"))); - PQclear(res); - - return last_oid; -} - /* * dumpSequence * write the declaration (not data) of one user-defined sequence @@ -17128,7 +16386,7 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo) "WHERE seqrelid = '%u'::oid", tbinfo->dobj.catId.oid); } - else if (fout->remoteVersion >= 80400) + else { /* * Before PostgreSQL 10, sequence metadata is in the sequence itself. @@ -17142,14 +16400,6 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo) "cache_value, is_cycled FROM %s", fmtQualifiedDumpable(tbinfo)); } - else - { - appendPQExpBuffer(query, - "SELECT 'bigint' AS sequence_type, " - "0 AS start_value, increment_by, max_value, min_value, " - "cache_value, is_cycled FROM %s", - fmtQualifiedDumpable(tbinfo)); - } res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); @@ -17255,8 +16505,7 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo) appendPQExpBuffer(query, " AS %s\n", seqtype); } - if (fout->remoteVersion >= 80400) - appendPQExpBuffer(query, " START WITH %s\n", startv); + appendPQExpBuffer(query, " START WITH %s\n", startv); appendPQExpBuffer(query, " INCREMENT BY %s\n", incby); @@ -18222,13 +17471,7 @@ getDependencies(Archive *fout) * entries will have dependencies on their parent opfamily, which we * should drop since they'd likewise become useless self-dependencies. * (But be sure to keep deps on *other* opfamilies; see amopsortfamily.) - * - * Skip this for pre-8.3 source servers: pg_opfamily doesn't exist there, - * and the (known) cases where it would matter to have these dependencies - * can't arise anyway. */ - if (fout->remoteVersion >= 80300) - { appendPQExpBufferStr(query, "UNION ALL\n" "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype" "FROM pg_depend d, pg_amop o " @@ -18243,7 +17486,6 @@ getDependencies(Archive *fout) "WHERE deptype NOT IN ('p', 'e', 'i') AND " "classid = 'pg_amproc'::regclass AND objid = p.oid " "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n"); - } /* Sort the output for efficiency below */ appendPQExpBufferStr(query, "ORDER BY 1,2"); diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index c29101704a..9c0673271e 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -36,7 +36,6 @@ static void help(void); static void dropRoles(PGconn *conn); static void dumpRoles(PGconn *conn); static void dumpRoleMembership(PGconn *conn); -static void dumpGroups(PGconn *conn); static void dropTablespaces(PGconn *conn); static void dumpTablespaces(PGconn *conn); static void dropDBs(PGconn *conn); @@ -440,8 +439,7 @@ main(int argc, char *argv[]) /* * If there was a database specified on the command line, use that, * otherwise try to connect to database "postgres", and failing that - * "template1". "postgres" is the preferred choice for 8.1 and later - * servers, but it usually will not exist on older ones. + * "template1". */ if (pgdb) { @@ -517,7 +515,7 @@ main(int argc, char *argv[]) std_strings = "off"; /* Set the role if requested */ - if (use_role && server_version >= 80100) + if (use_role) { PQExpBuffer query = createPQExpBuffer(); @@ -581,11 +579,8 @@ main(int argc, char *argv[]) /* Dump roles (users) */ dumpRoles(conn); - /* Dump role memberships --- need different method for pre-8.1 */ - if (server_version >= 80100) - dumpRoleMembership(conn); - else - dumpGroups(conn); + /* Dump role memberships */ + dumpRoleMembership(conn); } /* Dump tablespaces */ @@ -698,19 +693,11 @@ dropRoles(PGconn *conn) "FROM %s " "WHERE rolname !~ '^pg_' " "ORDER BY 1", role_catalog); - else if (server_version >= 80100) + else printfPQExpBuffer(buf, "SELECT rolname " "FROM %s " "ORDER BY 1", role_catalog); - else - printfPQExpBuffer(buf, - "SELECT usename as rolname " - "FROM pg_shadow " - "UNION " - "SELECT groname as rolname " - "FROM pg_group " - "ORDER BY 1"); res = executeQuery(conn, buf->data); @@ -793,7 +780,7 @@ dumpRoles(PGconn *conn) "rolname = current_user AS is_current_user " "FROM %s " "ORDER BY 2", role_catalog, role_catalog); - else if (server_version >= 80200) + else printfPQExpBuffer(buf, "SELECT oid, rolname, rolsuper, rolinherit, " "rolcreaterole, rolcreatedb, " @@ -804,51 +791,6 @@ dumpRoles(PGconn *conn) "rolname = current_user AS is_current_user " "FROM %s " "ORDER BY 2", role_catalog, role_catalog); - else if (server_version >= 80100) - printfPQExpBuffer(buf, - "SELECT oid, rolname, rolsuper, rolinherit, " - "rolcreaterole, rolcreatedb, " - "rolcanlogin, rolconnlimit, rolpassword, " - "rolvaliduntil, false as rolreplication, " - "false as rolbypassrls, " - "null as rolcomment, " - "rolname = current_user AS is_current_user " - "FROM %s " - "ORDER BY 2", role_catalog); - else - printfPQExpBuffer(buf, - "SELECT 0 as oid, usename as rolname, " - "usesuper as rolsuper, " - "true as rolinherit, " - "usesuper as rolcreaterole, " - "usecreatedb as rolcreatedb, " - "true as rolcanlogin, " - "-1 as rolconnlimit, " - "passwd as rolpassword, " - "valuntil as rolvaliduntil, " - "false as rolreplication, " - "false as rolbypassrls, " - "null as rolcomment, " - "usename = current_user AS is_current_user " - "FROM pg_shadow " - "UNION ALL " - "SELECT 0 as oid, groname as rolname, " - "false as rolsuper, " - "true as rolinherit, " - "false as rolcreaterole, " - "false as rolcreatedb, " - "false as rolcanlogin, " - "-1 as rolconnlimit, " - "null::text as rolpassword, " - "null::timestamptz as rolvaliduntil, " - "false as rolreplication, " - "false as rolbypassrls, " - "null as rolcomment, " - "false AS is_current_user " - "FROM pg_group " - "WHERE NOT EXISTS (SELECT 1 FROM pg_shadow " - " WHERE usename = groname) " - "ORDER BY 2"); res = executeQuery(conn, buf->data); @@ -992,7 +934,7 @@ dumpRoles(PGconn *conn) /* - * Dump role memberships. This code is used for 8.1 and later servers. + * Dump role memberships. * * Note: we expect dumpRoles already created all the roles, but there is * no membership yet. @@ -1049,75 +991,6 @@ dumpRoleMembership(PGconn *conn) fprintf(OPF, "\n\n"); } -/* - * Dump group memberships from a pre-8.1 server. It's annoying that we - * can't share any useful amount of code with the post-8.1 case, but - * the catalog representations are too different. - * - * Note: we expect dumpRoles already created all the roles, but there is - * no membership yet. - */ -static void -dumpGroups(PGconn *conn) -{ - PQExpBuffer buf = createPQExpBuffer(); - PGresult *res; - int i; - - res = executeQuery(conn, - "SELECT groname, grolist FROM pg_group ORDER BY 1"); - - if (PQntuples(res) > 0) - fprintf(OPF, "--\n-- Role memberships\n--\n\n"); - - for (i = 0; i < PQntuples(res); i++) - { - char *groname = PQgetvalue(res, i, 0); - char *grolist = PQgetvalue(res, i, 1); - PGresult *res2; - int j; - - /* - * Array representation is {1,2,3} ... convert to (1,2,3) - */ - if (strlen(grolist) < 3) - continue; - - grolist = pg_strdup(grolist); - grolist[0] = '('; - grolist[strlen(grolist) - 1] = ')'; - printfPQExpBuffer(buf, - "SELECT usename FROM pg_shadow " - "WHERE usesysid IN %s ORDER BY 1", - grolist); - free(grolist); - - res2 = executeQuery(conn, buf->data); - - for (j = 0; j < PQntuples(res2); j++) - { - char *usename = PQgetvalue(res2, j, 0); - - /* - * Don't try to grant a role to itself; can happen if old - * installation has identically named user and group. - */ - if (strcmp(groname, usename) == 0) - continue; - - fprintf(OPF, "GRANT %s", fmtId(groname)); - fprintf(OPF, " TO %s;\n", fmtId(usename)); - } - - PQclear(res2); - } - - PQclear(res); - destroyPQExpBuffer(buf); - - fprintf(OPF, "\n\n"); -} - /* * Drop tablespaces. @@ -1220,7 +1093,7 @@ dumpTablespaces(PGconn *conn) "FROM pg_catalog.pg_tablespace " "WHERE spcname !~ '^pg_' " "ORDER BY 1"); - else if (server_version >= 90000) + else res = executeQuery(conn, "SELECT oid, spcname, " "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, " "spclocation, spcacl, '' as rspcacl, " @@ -1229,22 +1102,6 @@ dumpTablespaces(PGconn *conn) "FROM pg_catalog.pg_tablespace " "WHERE spcname !~ '^pg_' " "ORDER BY 1"); - else if (server_version >= 80200) - res = executeQuery(conn, "SELECT oid, spcname, " - "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, " - "spclocation, spcacl, '' as rspcacl, null, " - "pg_catalog.shobj_description(oid, 'pg_tablespace') " - "FROM pg_catalog.pg_tablespace " - "WHERE spcname !~ '^pg_' " - "ORDER BY 1"); - else - res = executeQuery(conn, "SELECT oid, spcname, " - "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, " - "spclocation, spcacl, '' as rspcacl, " - "null, null " - "FROM pg_catalog.pg_tablespace " - "WHERE spcname !~ '^pg_' " - "ORDER BY 1"); if (PQntuples(res) > 0) fprintf(OPF, "--\n-- Tablespaces\n--\n\n"); @@ -1371,17 +1228,11 @@ dumpUserConfig(PGconn *conn, const char *username) { PGresult *res; - if (server_version >= 90000) - printfPQExpBuffer(buf, "SELECT setconfig[%d] FROM pg_db_role_setting WHERE " - "setdatabase = 0 AND setrole = " - "(SELECT oid FROM %s WHERE rolname = ", count, role_catalog); - else if (server_version >= 80100) - printfPQExpBuffer(buf, "SELECT rolconfig[%d] FROM %s WHERE rolname = ", count, role_catalog); - else - printfPQExpBuffer(buf, "SELECT useconfig[%d] FROM pg_shadow WHERE usename = ", count); + printfPQExpBuffer(buf, "SELECT setconfig[%d] FROM pg_db_role_setting WHERE " + "setdatabase = 0 AND setrole = " + "(SELECT oid FROM %s WHERE rolname = ", count, role_catalog); appendStringLiteralConn(buf, username, conn); - if (server_version >= 90000) - appendPQExpBufferChar(buf, ')'); + appendPQExpBufferChar(buf, ')'); res = executeQuery(conn, buf->data); if (PQntuples(res) == 1 && @@ -1816,11 +1667,11 @@ connectDatabase(const char *dbname, const char *connection_string, my_version = PG_VERSION_NUM; /* - * We allow the server to be back to 8.0, and up to any minor release of + * We allow the server to be back to 9.0, and up to any minor release of * our own major version. (See also version check in pg_dump.c.) */ if (my_version != server_version - && (server_version < 80000 || + && (server_version < 90000 || (server_version / 100) > (my_version / 100))) { pg_log_error("server version: %s; %s version: %s", diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index ad5f391995..15c83c4d40 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c @@ -159,10 +159,6 @@ check_and_dump_old_cluster(bool live_check) if (GET_MAJOR_VERSION(old_cluster.major_version) <= 903) old_9_3_check_for_line_data_type_usage(&old_cluster); - /* Pre-PG 9.0 had no large object permissions */ - if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804) - new_9_0_populate_pg_largeobject_metadata(&old_cluster, true); - /* * While not a check option, we do this now because this is the only time * the old server is running. @@ -233,10 +229,6 @@ issue_warnings_and_set_wal_level(void) */ start_postmaster(&new_cluster, true); - /* Create dummy large object permissions for old < PG 9.0? */ - if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804) - new_9_0_populate_pg_largeobject_metadata(&new_cluster, false); - /* 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); @@ -295,8 +287,8 @@ check_cluster_versions(void) * upgrades */ - if (GET_MAJOR_VERSION(old_cluster.major_version) < 804) - pg_fatal("This utility can only upgrade from PostgreSQL version 8.4 and later.\n"); + if (GET_MAJOR_VERSION(old_cluster.major_version) < 900) + pg_fatal("This utility can only upgrade from PostgreSQL version 9.0 and later.\n"); /* Only current PG version is supported as a target */ if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM)) @@ -479,11 +471,6 @@ check_databases_are_compatible(void) * they do, it would cause an error while restoring global objects. * This allows the failure to be detected at check time, rather than * during schema restore. - * - * Note, v8.4 has no tablespace_suffix, which is fine so long as the - * version being upgraded *to* has a suffix, since it's not allowed - * to pg_upgrade from a version to the same version if tablespaces are - * in use. */ static void check_for_new_tablespace_dir(ClusterInfo *new_cluster) @@ -597,11 +584,6 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name) int dbnum; fprintf(script, "\n"); - /* remove PG_VERSION? */ - if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804) - fprintf(script, RM_CMD " %s%cPG_VERSION\n", - fix_path_separator(os_info.old_tablespaces[tblnum]), - PATH_SEPARATOR); for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++) fprintf(script, RMDIR_CMD " %c%s%c%u%c\n", PATH_QUOTE, diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c index 5d9a26cf82..fb8b1dae77 100644 --- a/src/bin/pg_upgrade/info.c +++ b/src/bin/pg_upgrade/info.c @@ -118,15 +118,9 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db, * Verify that rels of same OID have same name. The namespace name * should always match, but the relname might not match for TOAST * tables (and, therefore, their indexes). - * - * TOAST table names initially match the heap pg_class oid, but - * pre-9.0 they can change during certain commands such as CLUSTER, so - * don't insist on a match if old cluster is < 9.0. */ if (strcmp(old_rel->nspname, new_rel->nspname) != 0 || - (strcmp(old_rel->relname, new_rel->relname) != 0 && - (GET_MAJOR_VERSION(old_cluster.major_version) >= 900 || - strcmp(old_rel->nspname, "pg_toast") != 0))) + strcmp(old_rel->relname, new_rel->relname) != 0) { pg_log(PG_WARNING, "Relation names for OID %u in database \"%s\" do not match: " "old name \"%s.%s\", new name \"%s.%s\"\n", diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h index ca0795f68f..5e2fc1d217 100644 --- a/src/bin/pg_upgrade/pg_upgrade.h +++ b/src/bin/pg_upgrade/pg_upgrade.h @@ -447,8 +447,6 @@ bool check_for_data_types_usage(ClusterInfo *cluster, bool check_for_data_type_usage(ClusterInfo *cluster, const char *type_name, const char *output_path); -void new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, - bool check_mode); void old_9_3_check_for_line_data_type_usage(ClusterInfo *cluster); void old_9_6_check_for_unknown_data_type_usage(ClusterInfo *cluster); void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, diff --git a/src/bin/pg_upgrade/tablespace.c b/src/bin/pg_upgrade/tablespace.c index bd49d300db..de26946eb4 100644 --- a/src/bin/pg_upgrade/tablespace.c +++ b/src/bin/pg_upgrade/tablespace.c @@ -105,15 +105,10 @@ get_tablespace_paths(void) static void set_tablespace_directory_suffix(ClusterInfo *cluster) { - if (GET_MAJOR_VERSION(cluster->major_version) <= 804) - cluster->tablespace_suffix = pg_strdup(""); - else - { /* This cluster has a version-specific subdirectory */ /* The leading slash is needed to start a new directory. */ cluster->tablespace_suffix = psprintf("/PG_%s_%d", cluster->major_version_str, cluster->controldata.cat_ver); - } } diff --git a/src/bin/pg_upgrade/test.sh b/src/bin/pg_upgrade/test.sh index 8593488907..e574f2639a 100644 --- a/src/bin/pg_upgrade/test.sh +++ b/src/bin/pg_upgrade/test.sh @@ -183,11 +183,6 @@ if "$MAKE" -C "$oldsrc" installcheck-parallel; then if [ "$newsrc" != "$oldsrc" ]; then fix_sql="" # Get rid of objects not feasible in later versions - case $oldpgversion in - 804??) - fix_sql="DROP FUNCTION public.myfunc(integer);" - ;; - esac # Last appeared in v9.6 if [ $oldpgversion -lt 100000 ]; then @@ -244,9 +239,6 @@ if "$MAKE" -C "$oldsrc" installcheck-parallel; then # update references to old source tree's regress.so etc fix_sql="" case $oldpgversion in - 804??) - fix_sql="UPDATE pg_proc SET probin = replace(probin::text, '$oldsrc', '$newsrc')::bytea WHERE probin LIKE'$oldsrc%';" - ;; *) fix_sql="UPDATE pg_proc SET probin = replace(probin, '$oldsrc', '$newsrc') WHERE probin LIKE '$oldsrc%';" ;; diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c index ccb012657b..82244a93a7 100644 --- a/src/bin/pg_upgrade/version.c +++ b/src/bin/pg_upgrade/version.c @@ -13,88 +13,6 @@ #include "fe_utils/string_utils.h" #include "pg_upgrade.h" -/* - * new_9_0_populate_pg_largeobject_metadata() - * new >= 9.0, old <= 8.4 - * 9.0 has a new pg_largeobject permission table - */ -void -new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode) -{ - int dbnum; - FILE *script = NULL; - bool found = false; - char output_path[MAXPGPATH]; - - prep_status("Checking for large objects"); - - snprintf(output_path, sizeof(output_path), "pg_largeobject.sql"); - - for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++) - { - PGresult *res; - int i_count; - DbInfo *active_db = &cluster->dbarr.dbs[dbnum]; - PGconn *conn = connectToServer(cluster, active_db->db_name); - - /* find if there are any large objects */ - res = executeQueryOrDie(conn, - "SELECT count(*) " - "FROM pg_catalog.pg_largeobject "); - - i_count = PQfnumber(res, "count"); - if (atoi(PQgetvalue(res, 0, i_count)) != 0) - { - found = true; - if (!check_mode) - { - PQExpBufferData connectbuf; - - if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) - pg_fatal("could not open file \"%s\": %s\n", output_path, - strerror(errno)); - - initPQExpBuffer(&connectbuf); - appendPsqlMetaConnect(&connectbuf, active_db->db_name); - fputs(connectbuf.data, script); - termPQExpBuffer(&connectbuf); - - fprintf(script, - "SELECT pg_catalog.lo_create(t.loid)\n" - "FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) AS t;\n"); - } - } - - PQclear(res); - PQfinish(conn); - } - - if (script) - fclose(script); - - if (found) - { - report_status(PG_WARNING, "warning"); - if (check_mode) - pg_log(PG_WARNING, "\n" - "Your installation contains large objects. The new database has an\n" - "additional large object permission table. After upgrading, you will be\n" - "given a command to populate the pg_largeobject_metadata table with\n" - "default permissions.\n\n"); - else - pg_log(PG_WARNING, "\n" - "Your installation contains large objects. The new database has an\n" - "additional large object permission table, so default permissions must be\n" - "defined for all large objects. The file\n" - " %s\n" - "when executed by psql by the database superuser will set the default\n" - "permissions.\n\n", - output_path); - } - else - check_ok(); -} - /* * check_for_data_types_usage()
pgsql-hackers by date: