/* subquery used to convert user ID (eg, datdba) to user name */
static const char *username_subquery;
-/* obsolete as of 7.3: */
-static Oid g_last_builtin_oid; /* value of the last builtin oid */
-
/* The specified names/patterns should to match at least one entity */
static int strict_names = 0;
SimpleStringList *patterns,
SimpleOidList *oids,
bool strict_names);
-static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid);
+static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid);
static void dumpTableData(Archive *fout, TableDataInfo *tdinfo);
static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo);
static void guessConstraintInheritance(TableInfo *tblinfo, int numTables);
const char *proc);
static char *convertOperatorReference(Archive *fout, const char *opr);
static char *convertTSFunction(Archive *fout, Oid funcOid);
-static Oid findLastBuiltinOid_V71(Archive *fout, const char *);
-static Oid findLastBuiltinOid_V70(Archive *fout);
static void selectSourceSchema(Archive *fout, const char *schemaName);
static char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts);
-static char *myFormatType(const char *typname, int32 typmod);
static void getBlobs(Archive *fout);
static void dumpBlob(Archive *fout, BlobInfo *binfo);
static int dumpBlobs(Archive *fout, void *arg);
fout->verbose = g_verbose;
/*
- * We allow the server to be back to 7.0, and up to any minor release of
+ * We allow the server to be back to 8.0, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
- fout->minRemoteVersion = 70000;
+ fout->minRemoteVersion = 80000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
fout->numWorkers = numWorkers;
/* 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 if (fout->remoteVersion >= 70300)
- username_subquery = "SELECT usename FROM pg_catalog.pg_user WHERE usesysid =";
else
- username_subquery = "SELECT usename FROM pg_user WHERE usesysid =";
+ username_subquery = "SELECT usename FROM pg_catalog.pg_user WHERE usesysid =";
/* check the version for the synchronized snapshots feature */
if (numWorkers > 1 && fout->remoteVersion < 90200
exit_horribly(NULL,
"Exported snapshots are not supported by this server version.\n");
- /* Find the last built-in OID, if needed */
- if (fout->remoteVersion < 70300)
- {
- if (fout->remoteVersion >= 70100)
- g_last_builtin_oid = findLastBuiltinOid_V71(fout,
- PQdb(GetConnection(fout)));
- else
- g_last_builtin_oid = findLastBuiltinOid_V70(fout);
- if (g_verbose)
- write_msg(NULL, "last built-in OID is %u\n", g_last_builtin_oid);
- }
-
/* Expand schema selection patterns into OID lists */
if (schema_include_patterns.head != NULL)
{
/*
* Sort the objects into a safe dump order (no forward references).
*
- * In 7.3 or later, we can rely on dependency information to help us
- * determine a safe order, so the initial sort is mostly for cosmetic
- * purposes: we sort by name to ensure that logically identical schemas
- * will dump identically. Before 7.3 we don't have dependencies and we
- * use OID ordering as an (unreliable) guide to creation order.
+ * We rely on dependency information to help us determine a safe order, so
+ * the initial sort is mostly for cosmetic purposes: we sort by name to
+ * ensure that logically identical schemas will dump identically.
*/
- if (fout->remoteVersion >= 70300)
- sortDumpableObjectsByTypeName(dobjs, numObjs);
- else
- sortDumpableObjectsByTypeOid(dobjs, numObjs);
+ sortDumpableObjectsByTypeName(dobjs, numObjs);
/* If we do a parallel dump, we want the largest tables to go first */
if (archiveFormat == archDirectory && numWorkers > 1)
ExecuteSqlStatement(AH, "SET INTERVALSTYLE = POSTGRES");
/*
- * If supported, set extra_float_digits so that we can dump float data
- * exactly (given correctly implemented float I/O code, anyway)
+ * Set extra_float_digits so that we can dump float data exactly (given
+ * correctly implemented float I/O code, anyway)
*/
if (AH->remoteVersion >= 90000)
ExecuteSqlStatement(AH, "SET extra_float_digits TO 3");
- else if (AH->remoteVersion >= 70400)
+ else
ExecuteSqlStatement(AH, "SET extra_float_digits TO 2");
/*
/*
* Disable timeouts if supported.
*/
- if (AH->remoteVersion >= 70300)
- ExecuteSqlStatement(AH, "SET statement_timeout = 0");
+ ExecuteSqlStatement(AH, "SET statement_timeout = 0");
if (AH->remoteVersion >= 90300)
ExecuteSqlStatement(AH, "SET lock_timeout = 0");
if (AH->remoteVersion >= 90600)
"SET TRANSACTION ISOLATION LEVEL "
"REPEATABLE READ, READ ONLY");
}
- else if (AH->remoteVersion >= 70400)
+ else
{
- /* note: comma was not accepted in SET TRANSACTION before 8.0 */
ExecuteSqlStatement(AH,
"SET TRANSACTION ISOLATION LEVEL "
- "SERIALIZABLE READ ONLY");
+ "SERIALIZABLE, READ ONLY");
}
- else
- ExecuteSqlStatement(AH,
- "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
/*
* If user specified a snapshot to use, select that. In a parallel dump
if (patterns->head == NULL)
return; /* nothing to do */
- if (fout->remoteVersion < 70300)
- exit_horribly(NULL, "server version must be at least 7.3 to use schema selection switches\n");
-
query = createPQExpBuffer();
/*
selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name);
/*
- * If possible, specify the column list explicitly so that we have no
- * possibility of retrieving data in the wrong column order. (The default
- * column ordering of COPY will not be what we want in certain corner
- * cases involving ADD COLUMN and inheritance.)
+ * Specify the column list explicitly so that we have no possibility of
+ * retrieving data in the wrong column order. (The default column
+ * ordering of COPY will not be what we want in certain corner cases
+ * involving ADD COLUMN and inheritance.)
*/
- if (fout->remoteVersion >= 70300)
- column_list = fmtCopyColumnList(tbinfo, clistBuf);
- else
- column_list = ""; /* can't select columns in COPY */
+ column_list = fmtCopyColumnList(tbinfo, clistBuf);
if (oids && hasoids)
{
*/
selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name);
- if (fout->remoteVersion >= 70100)
- {
- appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
- "SELECT * FROM ONLY %s",
- fmtQualifiedId(fout->remoteVersion,
- tbinfo->dobj.namespace->dobj.name,
- classname));
- }
- else
- {
- appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
- "SELECT * FROM %s",
- fmtQualifiedId(fout->remoteVersion,
- tbinfo->dobj.namespace->dobj.name,
- classname));
- }
+ appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR "
+ "SELECT * FROM ONLY %s",
+ fmtQualifiedId(fout->remoteVersion,
+ tbinfo->dobj.namespace->dobj.name,
+ classname));
if (tdinfo->filtercond)
appendPQExpBuffer(q, " %s", tdinfo->filtercond);
username_subquery);
appendStringLiteralAH(dbQry, datname, fout);
}
- else if (fout->remoteVersion >= 80000)
+ else
{
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
"(%s datdba) AS dba, "
username_subquery);
appendStringLiteralAH(dbQry, datname, fout);
}
- else if (fout->remoteVersion >= 70100)
- {
- appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
- "(%s datdba) AS dba, "
- "pg_encoding_to_char(encoding) AS encoding, "
- "NULL AS datcollate, NULL AS datctype, "
- "0 AS datfrozenxid, 0 AS datminmxid, "
- "NULL AS tablespace "
- "FROM pg_database "
- "WHERE datname = ",
- username_subquery);
- appendStringLiteralAH(dbQry, datname, fout);
- }
- else
- {
- appendPQExpBuffer(dbQry, "SELECT "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_database') AS tableoid, "
- "oid, "
- "(%s datdba) AS dba, "
- "pg_encoding_to_char(encoding) AS encoding, "
- "NULL AS datcollate, NULL AS datctype, "
- "0 AS datfrozenxid, 0 AS datminmxid, "
- "NULL AS tablespace "
- "FROM pg_database "
- "WHERE datname = ",
- username_subquery);
- appendStringLiteralAH(dbQry, datname, fout);
- }
res = ExecuteSqlQueryForSingleRow(fout, dbQry->data);
"NULL AS initrlomacl "
" FROM pg_largeobject_metadata",
username_subquery);
- else if (fout->remoteVersion >= 70100)
+ 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");
- else
- appendPQExpBufferStr(blobQry,
- "SELECT oid, NULL AS rolname, NULL AS lomacl, "
- "NULL AS rlomacl, NULL AS initlomacl, "
- "NULL AS initrlomacl "
- " FROM pg_class WHERE relkind = 'l'");
res = ExecuteSqlQuery(fout, blobQry->data, PGRES_TUPLES_OK);
*/
if (fout->remoteVersion >= 90000)
blobQry = "DECLARE bloboid CURSOR FOR SELECT oid FROM pg_largeobject_metadata";
- else if (fout->remoteVersion >= 70100)
- blobQry = "DECLARE bloboid CURSOR FOR SELECT DISTINCT loid FROM pg_largeobject";
else
- blobQry = "DECLARE bloboid CURSOR FOR SELECT oid FROM pg_class WHERE relkind = 'l'";
+ blobQry = "DECLARE bloboid CURSOR FOR SELECT DISTINCT loid FROM pg_largeobject";
ExecuteSqlStatement(fout, blobQry);
int i_initnspacl;
int i_initrnspacl;
- /*
- * Before 7.3, there are no real namespaces; create two dummy entries, one
- * for user stuff and one for system stuff.
- */
- if (fout->remoteVersion < 70300)
- {
- nsinfo = (NamespaceInfo *) pg_malloc(2 * sizeof(NamespaceInfo));
-
- nsinfo[0].dobj.objType = DO_NAMESPACE;
- nsinfo[0].dobj.catId.tableoid = 0;
- nsinfo[0].dobj.catId.oid = 0;
- AssignDumpId(&nsinfo[0].dobj);
- nsinfo[0].dobj.name = pg_strdup("public");
- nsinfo[0].rolname = pg_strdup("");
- nsinfo[0].nspacl = pg_strdup("");
- nsinfo[0].rnspacl = pg_strdup("");
- nsinfo[0].initnspacl = pg_strdup("");
- nsinfo[0].initrnspacl = pg_strdup("");
-
- selectDumpableNamespace(&nsinfo[0], fout);
-
- nsinfo[1].dobj.objType = DO_NAMESPACE;
- nsinfo[1].dobj.catId.tableoid = 0;
- nsinfo[1].dobj.catId.oid = 1;
- AssignDumpId(&nsinfo[1].dobj);
- nsinfo[1].dobj.name = pg_strdup("pg_catalog");
- nsinfo[1].rolname = pg_strdup("");
- nsinfo[1].nspacl = pg_strdup("");
- nsinfo[1].rnspacl = pg_strdup("");
- nsinfo[1].initnspacl = pg_strdup("");
- nsinfo[1].initrnspacl = pg_strdup("");
-
- selectDumpableNamespace(&nsinfo[1], fout);
-
- *numNamespaces = 2;
-
- return nsinfo;
- }
-
query = createPQExpBuffer();
/* Make sure we are in proper schema */
/*
* findNamespace:
- * given a namespace OID and an object OID, look up the info read by
- * getNamespaces
- *
- * NB: for pre-7.3 source database, we use object OID to guess whether it's
- * a system object or not. In 7.3 and later there is no guessing, and we
- * don't use objoid at all.
+ * given a namespace OID, look up the info read by getNamespaces
*/
static NamespaceInfo *
-findNamespace(Archive *fout, Oid nsoid, Oid objoid)
+findNamespace(Archive *fout, Oid nsoid)
{
NamespaceInfo *nsinfo;
- if (fout->remoteVersion >= 70300)
- {
- nsinfo = findNamespaceByOid(nsoid);
- }
- else
- {
- /* This code depends on the dummy objects set up by getNamespaces. */
- Oid i;
-
- if (objoid > g_last_builtin_oid)
- i = 0; /* user object */
- else
- i = 1; /* system object */
- nsinfo = findNamespaceByOid(i);
- }
-
+ nsinfo = findNamespaceByOid(nsoid);
if (nsinfo == NULL)
exit_horribly(NULL, "schema with OID %u does not exist\n", nsoid);
-
return nsinfo;
}
"FROM pg_type",
username_subquery);
}
- else if (fout->remoteVersion >= 70300)
+ else
{
appendPQExpBuffer(query, "SELECT tableoid, oid, typname, "
"typnamespace, NULL AS typacl, NULL as rtypacl, "
"FROM pg_type",
username_subquery);
}
- else if (fout->remoteVersion >= 70100)
- {
- appendPQExpBuffer(query, "SELECT tableoid, oid, typname, "
- "0::oid AS typnamespace, NULL AS typacl, NULL as rtypacl, "
- "NULL AS inittypacl, NULL AS initrtypacl, "
- "(%s typowner) AS rolname, "
- "typinput::oid AS typinput, "
- "typoutput::oid AS typoutput, 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);
- }
- else
- {
- appendPQExpBuffer(query, "SELECT "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_type') AS tableoid, "
- "oid, typname, "
- "0::oid AS typnamespace, NULL AS typacl, NULL as rtypacl, "
- "NULL AS inittypacl, NULL AS initrtypacl, "
- "(%s typowner) AS rolname, "
- "typinput::oid AS typinput, "
- "typoutput::oid AS typoutput, 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);
tyinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_typname));
tyinfo[i].dobj.namespace =
findNamespace(fout,
- atooid(PQgetvalue(res, i, i_typnamespace)),
- tyinfo[i].dobj.catId.oid);
+ atooid(PQgetvalue(res, i, i_typnamespace)));
tyinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
tyinfo[i].typacl = pg_strdup(PQgetvalue(res, i, i_typacl));
tyinfo[i].rtypacl = pg_strdup(PQgetvalue(res, i, i_rtypacl));
* this is taken care of while sorting dependencies.
*/
stinfo->dobj.dump = DUMP_COMPONENT_NONE;
-
- /*
- * However, if dumping from pre-7.3, there will be no dependency
- * info so we have to fake it here. We only need to worry about
- * typinput and typoutput since the other functions only exist
- * post-7.3.
- */
- if (fout->remoteVersion < 70300)
- {
- Oid typinput;
- Oid typoutput;
- FuncInfo *funcInfo;
-
- typinput = atooid(PQgetvalue(res, i, i_typinput));
- typoutput = atooid(PQgetvalue(res, i, i_typoutput));
-
- funcInfo = findFuncByOid(typinput);
- if (funcInfo && funcInfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- {
- /* base type depends on function */
- addObjectDependency(&tyinfo[i].dobj,
- funcInfo->dobj.dumpId);
- /* function depends on shell type */
- addObjectDependency(&funcInfo->dobj,
- stinfo->dobj.dumpId);
- /* mark shell type as to be dumped */
- stinfo->dobj.dump = DUMP_COMPONENT_ALL;
- }
-
- funcInfo = findFuncByOid(typoutput);
- if (funcInfo && funcInfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- {
- /* base type depends on function */
- addObjectDependency(&tyinfo[i].dobj,
- funcInfo->dobj.dumpId);
- /* function depends on shell type */
- addObjectDependency(&funcInfo->dobj,
- stinfo->dobj.dumpId);
- /* mark shell type as to be dumped */
- stinfo->dobj.dump = DUMP_COMPONENT_ALL;
- }
- }
}
if (strlen(tyinfo[i].rolname) == 0)
/* Make sure we are in proper schema */
selectSourceSchema(fout, "pg_catalog");
- if (fout->remoteVersion >= 70300)
- {
- appendPQExpBuffer(query, "SELECT tableoid, oid, oprname, "
- "oprnamespace, "
- "(%s oprowner) AS rolname, "
- "oprkind, "
- "oprcode::oid AS oprcode "
- "FROM pg_operator",
- username_subquery);
- }
- else if (fout->remoteVersion >= 70100)
- {
- appendPQExpBuffer(query, "SELECT tableoid, oid, oprname, "
- "0::oid AS oprnamespace, "
- "(%s oprowner) AS rolname, "
- "oprkind, "
- "oprcode::oid AS oprcode "
- "FROM pg_operator",
- username_subquery);
- }
- else
- {
- appendPQExpBuffer(query, "SELECT "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_operator') AS tableoid, "
- "oid, oprname, "
- "0::oid AS oprnamespace, "
- "(%s oprowner) AS rolname, "
- "oprkind, "
- "oprcode::oid AS oprcode "
- "FROM pg_operator",
- username_subquery);
- }
+ appendPQExpBuffer(query, "SELECT tableoid, oid, oprname, "
+ "oprnamespace, "
+ "(%s oprowner) AS rolname, "
+ "oprkind, "
+ "oprcode::oid AS oprcode "
+ "FROM pg_operator",
+ username_subquery);
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
oprinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_oprname));
oprinfo[i].dobj.namespace =
findNamespace(fout,
- atooid(PQgetvalue(res, i, i_oprnamespace)),
- oprinfo[i].dobj.catId.oid);
+ atooid(PQgetvalue(res, i, i_oprnamespace)));
oprinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
oprinfo[i].oprkind = (PQgetvalue(res, i, i_oprkind))[0];
oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode));
collinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_collname));
collinfo[i].dobj.namespace =
findNamespace(fout,
- atooid(PQgetvalue(res, i, i_collnamespace)),
- collinfo[i].dobj.catId.oid);
+ atooid(PQgetvalue(res, i, i_collnamespace)));
collinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
/* Decide whether we want to dump it */
int i_connamespace;
int i_rolname;
- /* Conversions didn't exist pre-7.3 */
- if (fout->remoteVersion < 70300)
- {
- *numConversions = 0;
- return NULL;
- }
-
query = createPQExpBuffer();
/*
convinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_conname));
convinfo[i].dobj.namespace =
findNamespace(fout,
- atooid(PQgetvalue(res, i, i_connamespace)),
- convinfo[i].dobj.catId.oid);
+ atooid(PQgetvalue(res, i, i_connamespace)));
convinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
/* Decide whether we want to dump it */
/* Make sure we are in proper schema */
selectSourceSchema(fout, "pg_catalog");
- if (fout->remoteVersion >= 70300)
- {
- appendPQExpBuffer(query, "SELECT tableoid, oid, opcname, "
- "opcnamespace, "
- "(%s opcowner) AS rolname "
- "FROM pg_opclass",
- username_subquery);
- }
- else if (fout->remoteVersion >= 70100)
- {
- appendPQExpBufferStr(query, "SELECT tableoid, oid, opcname, "
- "0::oid AS opcnamespace, "
- "''::name AS rolname "
- "FROM pg_opclass");
- }
- else
- {
- appendPQExpBufferStr(query, "SELECT "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_opclass') AS tableoid, "
- "oid, opcname, "
- "0::oid AS opcnamespace, "
- "''::name AS rolname "
- "FROM pg_opclass");
- }
+ appendPQExpBuffer(query, "SELECT tableoid, oid, opcname, "
+ "opcnamespace, "
+ "(%s opcowner) AS rolname "
+ "FROM pg_opclass",
+ username_subquery);
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
opcinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_opcname));
opcinfo[i].dobj.namespace =
findNamespace(fout,
- atooid(PQgetvalue(res, i, i_opcnamespace)),
- opcinfo[i].dobj.catId.oid);
+ atooid(PQgetvalue(res, i, i_opcnamespace)));
opcinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
/* Decide whether we want to dump it */
/* Op Classes do not currently have ACLs. */
opcinfo[i].dobj.dump &= ~DUMP_COMPONENT_ACL;
- if (fout->remoteVersion >= 70300)
- {
- if (strlen(opcinfo[i].rolname) == 0)
- write_msg(NULL, "WARNING: owner of operator class \"%s\" appears to be invalid\n",
- opcinfo[i].dobj.name);
- }
+ if (strlen(opcinfo[i].rolname) == 0)
+ write_msg(NULL, "WARNING: owner of operator class \"%s\" appears to be invalid\n",
+ opcinfo[i].dobj.name);
}
PQclear(res);
opfinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_opfname));
opfinfo[i].dobj.namespace =
findNamespace(fout,
- atooid(PQgetvalue(res, i, i_opfnamespace)),
- opfinfo[i].dobj.catId.oid);
+ atooid(PQgetvalue(res, i, i_opfnamespace)));
opfinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
/* Decide whether we want to dump it */
/* Extensions do not currently have ACLs. */
opfinfo[i].dobj.dump &= ~DUMP_COMPONENT_ACL;
- if (fout->remoteVersion >= 70300)
- {
- if (strlen(opfinfo[i].rolname) == 0)
- write_msg(NULL, "WARNING: owner of operator family \"%s\" appears to be invalid\n",
- opfinfo[i].dobj.name);
- }
+ if (strlen(opfinfo[i].rolname) == 0)
+ write_msg(NULL, "WARNING: owner of operator family \"%s\" appears to be invalid\n",
+ opfinfo[i].dobj.name);
}
PQclear(res);
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
}
- else if (fout->remoteVersion >= 70300)
+ else
{
appendPQExpBuffer(query, "SELECT tableoid, oid, proname AS aggname, "
"pronamespace AS aggnamespace, "
"(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog')",
username_subquery);
}
- else if (fout->remoteVersion >= 70100)
- {
- appendPQExpBuffer(query, "SELECT tableoid, oid, aggname, "
- "0::oid AS aggnamespace, "
- "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END AS pronargs, "
- "aggbasetype AS proargtypes, "
- "(%s aggowner) AS rolname, "
- "NULL AS aggacl, "
- "NULL AS raggacl, "
- "NULL AS initaggacl, NULL AS initraggacl "
- "FROM pg_aggregate "
- "where oid > '%u'::oid",
- username_subquery,
- g_last_builtin_oid);
- }
- else
- {
- appendPQExpBuffer(query, "SELECT "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_aggregate') AS tableoid, "
- "oid, aggname, "
- "0::oid AS aggnamespace, "
- "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END AS pronargs, "
- "aggbasetype AS proargtypes, "
- "(%s aggowner) AS rolname, "
- "NULL AS aggacl, "
- "NULL AS raggacl, "
- "NULL AS initaggacl, NULL AS initraggacl "
- "FROM pg_aggregate "
- "where oid > '%u'::oid",
- username_subquery,
- g_last_builtin_oid);
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
agginfo[i].aggfn.dobj.name = pg_strdup(PQgetvalue(res, i, i_aggname));
agginfo[i].aggfn.dobj.namespace =
findNamespace(fout,
- atooid(PQgetvalue(res, i, i_aggnamespace)),
- agginfo[i].aggfn.dobj.catId.oid);
+ atooid(PQgetvalue(res, i, i_aggnamespace)));
agginfo[i].aggfn.rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
if (strlen(agginfo[i].aggfn.rolname) == 0)
write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n",
else
{
agginfo[i].aggfn.argtypes = (Oid *) pg_malloc(agginfo[i].aggfn.nargs * sizeof(Oid));
- if (fout->remoteVersion >= 70300)
- parseOidArray(PQgetvalue(res, i, i_proargtypes),
- agginfo[i].aggfn.argtypes,
- agginfo[i].aggfn.nargs);
- else
- /* it's just aggbasetype */
- agginfo[i].aggfn.argtypes[0] = atooid(PQgetvalue(res, i, i_proargtypes));
+ parseOidArray(PQgetvalue(res, i, i_proargtypes),
+ agginfo[i].aggfn.argtypes,
+ agginfo[i].aggfn.nargs);
}
/* Decide whether we want to dump it */
destroyPQExpBuffer(initacl_subquery);
destroyPQExpBuffer(initracl_subquery);
}
- else if (fout->remoteVersion >= 70300)
+ else
{
appendPQExpBuffer(query,
"SELECT tableoid, oid, proname, prolang, "
"deptype = 'e')");
appendPQExpBufferChar(query, ')');
}
- else if (fout->remoteVersion >= 70100)
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, "
- "NULL AS proacl, "
- "NULL AS rproacl, "
- "NULL as initproacl, NULL AS initrproacl, "
- "0::oid AS pronamespace, "
- "(%s proowner) AS rolname "
- "FROM pg_proc "
- "WHERE pg_proc.oid > '%u'::oid",
- username_subquery,
- g_last_builtin_oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT "
- "(SELECT oid FROM pg_class "
- " WHERE relname = 'pg_proc') AS tableoid, "
- "oid, proname, prolang, "
- "pronargs, proargtypes, prorettype, "
- "NULL AS proacl, "
- "NULL AS rproacl, "
- "NULL as initproacl, NULL AS initrproacl, "
- "0::oid AS pronamespace, "
- "(%s proowner) AS rolname "
- "FROM pg_proc "
- "where pg_proc.oid > '%u'::oid",
- username_subquery,
- g_last_builtin_oid);
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
finfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_proname));
finfo[i].dobj.namespace =
findNamespace(fout,
- atooid(PQgetvalue(res, i, i_pronamespace)),
- finfo[i].dobj.catId.oid);
+ atooid(PQgetvalue(res, i, i_pronamespace)));
finfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang));
finfo[i].prorettype = atooid(PQgetvalue(res, i, i_prorettype));
RELKIND_RELATION, RELKIND_SEQUENCE,
RELKIND_VIEW, RELKIND_COMPOSITE_TYPE);
}
- else if (fout->remoteVersion >= 80000)
+ else
{
/*
* Left join to pick up dependency info linking sequences to their
RELKIND_RELATION, RELKIND_SEQUENCE,
RELKIND_VIEW, RELKIND_COMPOSITE_TYPE);
}
- else if (fout->remoteVersion >= 70300)
- {
- /*
- * Left join to pick up dependency info linking sequences to their
- * owning column, if any
- */
- appendPQExpBuffer(query,
- "SELECT c.tableoid, c.oid, relname, "
- "relacl, NULL as rrelacl, "
- "NULL AS initrelacl, NULL AS initrrelacl, "
- "relkind, relnamespace, "
- "(%s relowner) AS rolname, "
- "relchecks, (reltriggers <> 0) AS relhastriggers, "
- "relhasindex, relhasrules, relhasoids, "
- "'f'::bool AS relrowsecurity, "
- "'f'::bool AS relforcerowsecurity, "
- "0 AS relfrozenxid, 0 AS relminmxid,"
- "0 AS toid, "
- "0 AS tfrozenxid, 0 AS tminmxid,"
- "'p' AS relpersistence, 't' as relispopulated, "
- "'d' AS relreplident, relpages, "
- "NULL AS reloftype, "
- "d.refobjid AS owning_tab, "
- "d.refobjsubid AS owning_col, "
- "NULL AS reltablespace, "
- "NULL AS reloptions, "
- "NULL AS toast_reloptions, "
- "NULL AS changed_acl "
- "FROM pg_class c "
- "LEFT JOIN pg_depend d ON "
- "(c.relkind = '%c' AND "
- "d.classid = c.tableoid AND d.objid = c.oid AND "
- "d.objsubid = 0 AND "
- "d.refclassid = c.tableoid AND d.deptype = 'i') "
- "WHERE relkind IN ('%c', '%c', '%c', '%c') "
- "ORDER BY c.oid",
- username_subquery,
- RELKIND_SEQUENCE,
- RELKIND_RELATION, RELKIND_SEQUENCE,
- RELKIND_VIEW, RELKIND_COMPOSITE_TYPE);
- }
- else if (fout->remoteVersion >= 70200)
- {
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, relname, relacl, "
- "NULL as rrelacl, "
- "NULL AS initrelacl, NULL AS initrrelacl, "
- "relkind, "
- "0::oid AS relnamespace, "
- "(%s relowner) AS rolname, "
- "relchecks, (reltriggers <> 0) AS relhastriggers, "
- "relhasindex, relhasrules, relhasoids, "
- "'f'::bool AS relrowsecurity, "
- "'f'::bool AS relforcerowsecurity, "
- "0 AS relfrozenxid, 0 AS relminmxid,"
- "0 AS toid, "
- "0 AS tfrozenxid, 0 AS tminmxid,"
- "'p' AS relpersistence, 't' as relispopulated, "
- "'d' AS relreplident, relpages, "
- "NULL AS reloftype, "
- "NULL::oid AS owning_tab, "
- "NULL::int4 AS owning_col, "
- "NULL AS reltablespace, "
- "NULL AS reloptions, "
- "NULL AS toast_reloptions, "
- "NULL AS changed_acl "
- "FROM pg_class "
- "WHERE relkind IN ('%c', '%c', '%c') "
- "ORDER BY oid",
- username_subquery,
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
- }
- else if (fout->remoteVersion >= 70100)
- {
- /* all tables have oids in 7.1 */
- appendPQExpBuffer(query,
- "SELECT tableoid, oid, relname, relacl, "
- "NULL as rrelacl, "
- "NULL AS initrelacl, NULL AS initrrelacl, "
- "relkind, "
- "0::oid AS relnamespace, "
- "(%s relowner) AS rolname, "
- "relchecks, (reltriggers <> 0) AS relhastriggers, "
- "relhasindex, relhasrules, "
- "'t'::bool AS relhasoids, "
- "'f'::bool AS relrowsecurity, "
- "'f'::bool AS relforcerowsecurity, "
- "0 AS relfrozenxid, 0 AS relminmxid,"
- "0 AS toid, "
- "0 AS tfrozenxid, 0 AS tminmxid,"
- "'p' AS relpersistence, 't' as relispopulated, "
- "'d' AS relreplident, relpages, "
- "NULL AS reloftype, "
- "NULL::oid AS owning_tab, "
- "NULL::int4 AS owning_col, "
- "NULL AS reltablespace, "
- "NULL AS reloptions, "
- "NULL AS toast_reloptions, "
- "NULL AS changed_acl "
- "FROM pg_class "
- "WHERE relkind IN ('%c', '%c', '%c') "
- "ORDER BY oid",
- username_subquery,
- RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW);
- }
- else
- {
- /*
- * Before 7.1, view relkind was not set to 'v', so we must check if we
- * have a view by looking for a rule in pg_rewrite.
- */
- appendPQExpBuffer(query,
- "SELECT "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, "
- "oid, relname, relacl, NULL as rrelacl, "
- "NULL AS initrelacl, NULL AS initrrelacl, "
- "CASE WHEN relhasrules and relkind = 'r' "
- " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE "
- " r.ev_class = c.oid AND r.ev_type = '1') "
- "THEN '%c'::\"char\" "
- "ELSE relkind END AS relkind,"
- "0::oid AS relnamespace, "
- "(%s relowner) AS rolname, "
- "relchecks, (reltriggers <> 0) AS relhastriggers, "
- "relhasindex, relhasrules, "
- "'t'::bool AS relhasoids, "
- "'f'::bool AS relrowsecurity, "
- "'f'::bool AS relforcerowsecurity, "
- "0 AS relfrozenxid, 0 AS relminmxid,"
- "0 AS toid, "
- "0 AS tfrozenxid, 0 AS tminmxid,"
- "'p' AS relpersistence, 't' as relispopulated, "
- "'d' AS relreplident, 0 AS relpages, "
- "NULL AS reloftype, "
- "NULL::oid AS owning_tab, "
- "NULL::int4 AS owning_col, "
- "NULL AS reltablespace, "
- "NULL AS reloptions, "
- "NULL AS toast_reloptions, "
- "NULL AS changed_acl "
- "FROM pg_class c "
- "WHERE relkind IN ('%c', '%c') "
- "ORDER BY oid",
- RELKIND_VIEW,
- username_subquery,
- RELKIND_RELATION, RELKIND_SEQUENCE);
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
i_reloftype = PQfnumber(res, "reloftype");
i_changed_acl = PQfnumber(res, "changed_acl");
- if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300)
+ if (dopt->lockWaitTimeout)
{
/*
* Arrange to fail instead of waiting forever for a table lock.
tblinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_relname));
tblinfo[i].dobj.namespace =
findNamespace(fout,
- atooid(PQgetvalue(res, i, i_relnamespace)),
- tblinfo[i].dobj.catId.oid);
+ atooid(PQgetvalue(res, i, i_relnamespace)));
tblinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
tblinfo[i].relacl = pg_strdup(PQgetvalue(res, i, i_relacl));
tblinfo[i].rrelacl = pg_strdup(PQgetvalue(res, i, i_rrelacl));
tblinfo[i].dobj.name);
}
- if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300)
+ if (dopt->lockWaitTimeout)
{
ExecuteSqlStatement(fout, "SET statement_timeout = 0");
}
"ORDER BY indexname",
tbinfo->dobj.catId.oid);
}
- else if (fout->remoteVersion >= 80000)
+ else
{
appendPQExpBuffer(query,
"SELECT t.tableoid, t.oid, "
"ORDER BY indexname",
tbinfo->dobj.catId.oid);
}
- else if (fout->remoteVersion >= 70300)
- {
- appendPQExpBuffer(query,
- "SELECT t.tableoid, t.oid, "
- "t.relname AS indexname, "
- "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
- "t.relnatts AS indnkeys, "
- "i.indkey, i.indisclustered, "
- "false AS indisreplident, t.relpages, "
- "c.contype, c.conname, "
- "c.condeferrable, c.condeferred, "
- "c.tableoid AS contableoid, "
- "c.oid AS conoid, "
- "null AS condef, "
- "NULL AS tablespace, "
- "null AS indreloptions "
- "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);
- }
- else if (fout->remoteVersion >= 70100)
- {
- appendPQExpBuffer(query,
- "SELECT t.tableoid, t.oid, "
- "t.relname AS indexname, "
- "pg_get_indexdef(i.indexrelid) AS indexdef, "
- "t.relnatts AS indnkeys, "
- "i.indkey, false AS indisclustered, "
- "false AS indisreplident, t.relpages, "
- "CASE WHEN i.indisprimary THEN 'p'::char "
- "ELSE '0'::char END AS contype, "
- "t.relname AS conname, "
- "false AS condeferrable, "
- "false AS condeferred, "
- "0::oid AS contableoid, "
- "t.oid AS conoid, "
- "null AS condef, "
- "NULL AS tablespace, "
- "null AS indreloptions "
- "FROM pg_index i, pg_class t "
- "WHERE t.oid = i.indexrelid "
- "AND i.indrelid = '%u'::oid "
- "ORDER BY indexname",
- tbinfo->dobj.catId.oid);
- }
- else
- {
- appendPQExpBuffer(query,
- "SELECT "
- "(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, "
- "t.oid, "
- "t.relname AS indexname, "
- "pg_get_indexdef(i.indexrelid) AS indexdef, "
- "t.relnatts AS indnkeys, "
- "i.indkey, false AS indisclustered, "
- "false AS indisreplident, t.relpages, "
- "CASE WHEN i.indisprimary THEN 'p'::char "
- "ELSE '0'::char END AS contype, "
- "t.relname AS conname, "
- "false AS condeferrable, "
- "false AS condeferred, "
- "0::oid AS contableoid, "
- "t.oid AS conoid, "
- "null AS condef, "
- "NULL AS tablespace, "
- "null AS indreloptions "
- "FROM pg_index i, pg_class t "
- "WHERE t.oid = i.indexrelid "
- "AND i.indrelid = '%u'::oid "
- "ORDER BY indexname",
- tbinfo->dobj.catId.oid);
- }
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
indxinfo[j].indnkeys = atoi(PQgetvalue(res, j, i_indnkeys));
indxinfo[j].tablespace = pg_strdup(PQgetvalue(res, j, i_tablespace));
indxinfo[j].indreloptions = pg_strdup(PQgetvalue(res, j, i_indreloptions));
-
- /*
- * In pre-7.4 releases, indkeys may contain more entries than
- * indnkeys says (since indnkeys will be 1 for a functional
- * index). We don't actually care about this case since we don't
- * examine indkeys except for indexes associated with PRIMARY and
- * UNIQUE constraints, which are never functional indexes. But we
- * have to allocate enough space to keep parseOidArray from
- * complaining.
- */
- indxinfo[j].indkeys = (Oid *) pg_malloc(INDEX_MAX_KEYS * sizeof(Oid));
+ indxinfo[j].indkeys = (Oid *) pg_malloc(indxinfo[j].indnkeys * sizeof(Oid));
parseOidArray(PQgetvalue(res, j, i_indkey),
- indxinfo[j].indkeys, INDEX_MAX_KEYS);
+ indxinfo[j].indkeys, indxinfo[j].indnkeys);
indxinfo[j].indisclustered = (PQgetvalue(res, j, i_indisclustered)[0] == 't');
indxinfo[j].indisreplident = (PQgetvalue(res, j, i_indisreplident)[0] == 't');
indxinfo[j].relpages = atoi(PQgetvalue(res, j, i_relpages));
/*
* If we found a constraint matching the index, create an
* entry for it.
- *
- * In a pre-7.3 database, we take this path iff the index was
- * marked indisprimary.
*/
constrinfo[j].dobj.objType = DO_CONSTRAINT;
constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid));
constrinfo[j].separate = true;
indxinfo[j].indexconstraint = constrinfo[j].dobj.dumpId;
-
- /* If pre-7.3 DB, better make sure table comes first */
- addObjectDependency(&constrinfo[j].dobj,
- tbinfo->dobj.dumpId);
}
else
{
i_condef;
int ntups;
- /* pg_constraint was created in 7.3, so nothing to do if older */
- if (fout->remoteVersion < 70300)
- return;
-
query = createPQExpBuffer();
for (i = 0; i < numTables; i++)
i_consrc;
int ntups;
- /* pg_constraint was created in 7.3, so nothing to do if older */
- if (fout->remoteVersion < 70300)
- return;
-
/*
* select appropriate schema to ensure names in constraint are properly
* qualified
"ORDER BY conname",
tyinfo->dobj.catId.oid);
- else if (fout->remoteVersion >= 70400)
- appendPQExpBuffer(query, "SELECT tableoid, oid, conname, "
- "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
- "true as convalidated "
- "FROM pg_catalog.pg_constraint "
- "WHERE contypid = '%u'::pg_catalog.oid "
- "ORDER BY conname",
- tyinfo->dobj.catId.oid);
else
appendPQExpBuffer(query, "SELECT tableoid, oid, conname, "
- "'CHECK (' || consrc || ')' AS consrc, "
+ "pg_catalog.pg_get_constraintdef(oid) AS consrc, "