1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list

provided by Andrew.
This commit is contained in:
Bruce Momjian
2009-06-11 14:49:15 +00:00
parent 4e86efb4e5
commit d747140279
654 changed files with 11900 additions and 11387 deletions

View File

@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.538 2009/05/27 20:42:29 tgl Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.539 2009/06/11 14:49:07 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -158,8 +158,8 @@ static void dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo);
static void dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo);
static void dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo);
static void dumpUserMappings(Archive *fout, const char *target,
const char *servername, const char *namespace,
const char *owner, CatalogId catalogId, DumpId dumpId);
const char *servername, const char *namespace,
const char *owner, CatalogId catalogId, DumpId dumpId);
static void dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
@@ -172,9 +172,9 @@ static void getTableData(TableInfo *tblinfo, int numTables, bool oids);
static void getTableDataFKConstraints(void);
static char *format_function_arguments(FuncInfo *finfo, char *funcargs);
static char *format_function_arguments_old(FuncInfo *finfo, int nallargs,
char **allargtypes,
char **argmodes,
char **argnames);
char **allargtypes,
char **argmodes,
char **argnames);
static char *format_function_signature(FuncInfo *finfo, bool honor_quotes);
static const char *convertRegProcReference(const char *proc);
static const char *convertOperatorReference(const char *opr);
@@ -230,7 +230,7 @@ main(int argc, char **argv)
RestoreOptions *ropt;
static int disable_triggers = 0;
static int outputNoTablespaces = 0;
static int outputNoTablespaces = 0;
static int use_setsessauth = 0;
struct option long_options[] = {
@@ -539,8 +539,8 @@ main(int argc, char **argv)
}
/*
* We allow the server to be back to 7.0, and up to any minor release
* of our own major version. (See also version check in pg_dumpall.c.)
* We allow the server to be back to 7.0, and up to any minor release of
* our own major version. (See also version check in pg_dumpall.c.)
*/
g_fout->minRemoteVersion = 70000;
g_fout->maxRemoteVersion = (my_version / 100) * 100 + 99;
@@ -809,7 +809,7 @@ help(const char *progname)
printf(_(" -N, --exclude-schema=SCHEMA do NOT dump the named schema(s)\n"));
printf(_(" -o, --oids include OIDs in dump\n"));
printf(_(" -O, --no-owner skip restoration of object ownership in\n"
" plain-text format\n"));
" plain-text format\n"));
printf(_(" -s, --schema-only dump only the schema, no data\n"));
printf(_(" -S, --superuser=NAME superuser user name to use in plain-text format\n"));
printf(_(" -t, --table=TABLE dump the named table(s) only\n"));
@@ -823,8 +823,8 @@ help(const char *progname)
printf(_(" --no-tablespaces do not dump tablespace assignments\n"));
printf(_(" --role=ROLENAME do SET ROLE before dump\n"));
printf(_(" --use-set-session-authorization\n"
" use SET SESSION AUTHORIZATION commands instead of\n"
" ALTER OWNER commands to set ownership\n"));
" use SET SESSION AUTHORIZATION commands instead of\n"
" ALTER OWNER commands to set ownership\n"));
printf(_("\nConnection options:\n"));
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
@@ -1010,7 +1010,7 @@ selectDumpableTable(TableInfo *tbinfo)
* Mark a type as to be dumped or not
*
* If it's a table's rowtype or an autogenerated array type, we also apply a
* special type code to facilitate sorting into the desired order. (We don't
* special type code to facilitate sorting into the desired order. (We don't
* want to consider those to be ordinary types because that would bring tables
* up into the datatype part of the dump order.) Those tests should be made
* first to ensure the objType change is applied regardless of namespace etc.
@@ -1465,7 +1465,7 @@ getTableDataFKConstraints(void)
if (dobjs[i]->objType == DO_FK_CONSTRAINT)
{
ConstraintInfo *cinfo = (ConstraintInfo *) dobjs[i];
TableInfo *ftable;
TableInfo *ftable;
/* Not interesting unless both tables are to be dumped */
if (cinfo->contable == NULL ||
@@ -1475,9 +1475,10 @@ getTableDataFKConstraints(void)
if (ftable == NULL ||
ftable->dataObj == NULL)
continue;
/*
* Okay, make referencing table's TABLE_DATA object depend on
* the referenced table's TABLE_DATA object.
* Okay, make referencing table's TABLE_DATA object depend on the
* referenced table's TABLE_DATA object.
*/
addObjectDependency(&cinfo->contable->dataObj->dobj,
ftable->dataObj->dobj.dumpId);
@@ -1490,7 +1491,7 @@ 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
* 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
@@ -1620,7 +1621,7 @@ dumpDatabase(Archive *AH)
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
"(%s datdba) AS dba, "
"pg_encoding_to_char(encoding) AS encoding, "
"NULL AS datcollate, NULL AS datctype, datfrozenxid, "
"NULL AS datcollate, NULL AS datctype, datfrozenxid, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
"shobj_description(oid, 'pg_database') AS description "
@@ -1634,7 +1635,7 @@ dumpDatabase(Archive *AH)
appendPQExpBuffer(dbQry, "SELECT tableoid, oid, "
"(%s datdba) AS dba, "
"pg_encoding_to_char(encoding) AS encoding, "
"NULL AS datcollate, NULL AS datctype, datfrozenxid, "
"NULL AS datcollate, NULL AS datctype, datfrozenxid, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace "
"FROM pg_database "
"WHERE datname = ",
@@ -1733,13 +1734,13 @@ dumpDatabase(Archive *AH)
{
appendPQExpBuffer(creaQry, "\n-- For binary upgrade, set datfrozenxid.\n");
appendPQExpBuffer(creaQry, "UPDATE pg_database\n"
"SET datfrozenxid = '%u'\n"
"WHERE datname = ",
frozenxid);
"SET datfrozenxid = '%u'\n"
"WHERE datname = ",
frozenxid);
appendStringLiteralAH(creaQry, datname, AH);
appendPQExpBuffer(creaQry, ";\n");
}
appendPQExpBuffer(delQry, "DROP DATABASE %s;\n",
fmtId(datname));
@@ -1754,7 +1755,7 @@ dumpDatabase(Archive *AH)
dba, /* Owner */
false, /* with oids */
"DATABASE", /* Desc */
SECTION_PRE_DATA, /* Section */
SECTION_PRE_DATA, /* Section */
creaQry->data, /* Create */
delQry->data, /* Del */
NULL, /* Copy */
@@ -1775,7 +1776,11 @@ dumpDatabase(Archive *AH)
if (comment && strlen(comment))
{
resetPQExpBuffer(dbQry);
/* Generates warning when loaded into a differently-named database.*/
/*
* Generates warning when loaded into a differently-named
* database.
*/
appendPQExpBuffer(dbQry, "COMMENT ON DATABASE %s IS ", fmtId(datname));
appendStringLiteralAH(dbQry, comment, AH);
appendPQExpBuffer(dbQry, ";\n");
@@ -1995,26 +2000,26 @@ dumpBlobComments(Archive *AH, void *arg)
/* Cursor to get all BLOB comments */
if (AH->remoteVersion >= 70300)
blobQry = "DECLARE blobcmt CURSOR FOR SELECT loid, "
"obj_description(loid, 'pg_largeobject') "
"FROM (SELECT DISTINCT loid FROM "
"pg_description d JOIN pg_largeobject l ON (objoid = loid) "
"WHERE classoid = 'pg_largeobject'::regclass) ss";
"obj_description(loid, 'pg_largeobject') "
"FROM (SELECT DISTINCT loid FROM "
"pg_description d JOIN pg_largeobject l ON (objoid = loid) "
"WHERE classoid = 'pg_largeobject'::regclass) ss";
else if (AH->remoteVersion >= 70200)
blobQry = "DECLARE blobcmt CURSOR FOR SELECT loid, "
"obj_description(loid, 'pg_largeobject') "
"FROM (SELECT DISTINCT loid FROM pg_largeobject) ss";
"obj_description(loid, 'pg_largeobject') "
"FROM (SELECT DISTINCT loid FROM pg_largeobject) ss";
else if (AH->remoteVersion >= 70100)
blobQry = "DECLARE blobcmt CURSOR FOR SELECT loid, "
"obj_description(loid) "
"FROM (SELECT DISTINCT loid FROM pg_largeobject) ss";
"obj_description(loid) "
"FROM (SELECT DISTINCT loid FROM pg_largeobject) ss";
else
blobQry = "DECLARE blobcmt CURSOR FOR SELECT oid, "
" ( "
" SELECT description "
" FROM pg_description pd "
" WHERE pd.objoid=pc.oid "
" ) "
"FROM pg_class pc WHERE relkind = 'l'";
" ( "
" SELECT description "
" FROM pg_description pd "
" WHERE pd.objoid=pc.oid "
" ) "
"FROM pg_class pc WHERE relkind = 'l'";
res = PQexec(g_conn, blobQry);
check_sql_result(res, g_conn, blobQry, PGRES_COMMAND_OK);
@@ -3178,7 +3183,7 @@ getTables(int *numTables)
"d.refobjid AS owning_tab, "
"d.refobjsubid AS owning_col, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
"array_to_string(c.reloptions, ', ') AS reloptions, "
"array_to_string(c.reloptions, ', ') AS reloptions, "
"array_to_string(array(SELECT 'toast.' || x FROM unnest(tc.reloptions) x), ', ') AS toast_reloptions "
"FROM pg_class c "
"LEFT JOIN pg_depend d ON "
@@ -3186,7 +3191,7 @@ getTables(int *numTables)
"d.classid = c.tableoid AND d.objid = c.oid AND "
"d.objsubid = 0 AND "
"d.refclassid = c.tableoid AND d.deptype = 'a') "
"LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid) "
"LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid) "
"WHERE c.relkind in ('%c', '%c', '%c', '%c') "
"ORDER BY c.oid",
username_subquery,
@@ -3210,7 +3215,7 @@ getTables(int *numTables)
"d.refobjid AS owning_tab, "
"d.refobjsubid AS owning_col, "
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
"array_to_string(c.reloptions, ', ') AS reloptions, "
"array_to_string(c.reloptions, ', ') AS reloptions, "
"NULL AS toast_reloptions "
"FROM pg_class c "
"LEFT JOIN pg_depend d ON "
@@ -3405,9 +3410,9 @@ getTables(int *numTables)
/*
* Arrange to fail instead of waiting forever for a table lock.
*
* NB: this coding assumes that the only queries issued within
* the following loop are LOCK TABLEs; else the timeout may be
* undesirably applied to other things too.
* NB: this coding assumes that the only queries issued within the
* following loop are LOCK TABLEs; else the timeout may be undesirably
* applied to other things too.
*/
resetPQExpBuffer(query);
appendPQExpBuffer(query, "SET statement_timeout = ");
@@ -4528,7 +4533,7 @@ getCasts(int *numCasts)
{
appendPQExpBuffer(query, "SELECT tableoid, oid, "
"castsource, casttarget, castfunc, castcontext, "
"CASE WHEN castfunc = 0 THEN 'b' ELSE 'f' END AS castmethod "
"CASE WHEN castfunc = 0 THEN 'b' ELSE 'f' END AS castmethod "
"FROM pg_cast ORDER BY 3,4");
}
else
@@ -4686,9 +4691,9 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
{
/* need left join here to not fail on dropped columns ... */
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, "
"a.attstattarget, a.attstorage, t.typstorage, "
"a.attnotnull, a.atthasdef, a.attisdropped, "
"a.attlen, a.attalign, a.attislocal, "
"a.attstattarget, a.attstorage, t.typstorage, "
"a.attnotnull, a.atthasdef, a.attisdropped, "
"a.attlen, a.attalign, a.attislocal, "
"pg_catalog.format_type(t.oid,a.atttypmod) AS atttypname "
"FROM pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_type t "
"ON a.atttypid = t.oid "
@@ -4705,7 +4710,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
* explicitly set or was just a default.
*/
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, "
"a.atttypmod, -1 AS attstattarget, a.attstorage, "
"a.atttypmod, -1 AS attstattarget, a.attstorage, "
"t.typstorage, a.attnotnull, a.atthasdef, "
"false AS attisdropped, 0 AS attlen, "
"' ' AS attalign, false AS attislocal, "
@@ -4725,7 +4730,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
"attstorage AS typstorage, "
"attnotnull, atthasdef, false AS attisdropped, "
"0 AS attlen, ' ' AS attalign, "
"false AS attislocal, "
"false AS attislocal, "
"(SELECT typname FROM pg_type WHERE oid = atttypid) AS atttypname "
"FROM pg_attribute a "
"WHERE attrelid = '%u'::oid "
@@ -4803,9 +4808,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
/*
* ALTER TABLE DROP COLUMN clears pg_attribute.atttypid, so we
* set the column data type to 'TEXT; we will later drop the
* column.
* ALTER TABLE DROP COLUMN clears pg_attribute.atttypid, so we set the
* column data type to 'TEXT; we will later drop the column.
*/
if (binary_upgrade)
{
@@ -4815,7 +4819,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
tbinfo->atttypnames[j] = strdup("TEXT");
}
}
/*
* Get info about column defaults
*/
@@ -4935,7 +4939,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (g_fout->remoteVersion >= 80400)
{
appendPQExpBuffer(q, "SELECT tableoid, oid, conname, "
"pg_catalog.pg_get_constraintdef(oid) AS consrc, "
"pg_catalog.pg_get_constraintdef(oid) AS consrc, "
"conislocal "
"FROM pg_catalog.pg_constraint "
"WHERE conrelid = '%u'::pg_catalog.oid "
@@ -4946,7 +4950,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
else if (g_fout->remoteVersion >= 70400)
{
appendPQExpBuffer(q, "SELECT tableoid, oid, conname, "
"pg_catalog.pg_get_constraintdef(oid) AS consrc, "
"pg_catalog.pg_get_constraintdef(oid) AS consrc, "
"true AS conislocal "
"FROM pg_catalog.pg_constraint "
"WHERE conrelid = '%u'::pg_catalog.oid "
@@ -5048,8 +5052,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
constrs[j].dobj.dumpId);
/*
* If the constraint is inherited, this will be detected
* later (in pre-8.4 databases). We also detect later if the
* If the constraint is inherited, this will be detected later
* (in pre-8.4 databases). We also detect later if the
* constraint must be split out from the table definition.
*/
}
@@ -5395,7 +5399,7 @@ getForeignDataWrappers(int *numForeignDataWrappers)
int ntups;
int i;
PQExpBuffer query = createPQExpBuffer();
FdwInfo *fdwinfo;
FdwInfo *fdwinfo;
int i_oid;
int i_fdwname;
int i_rolname;
@@ -5414,10 +5418,10 @@ getForeignDataWrappers(int *numForeignDataWrappers)
selectSourceSchema("pg_catalog");
appendPQExpBuffer(query, "SELECT oid, fdwname, "
"(%s fdwowner) AS rolname, fdwvalidator::pg_catalog.regproc, fdwacl,"
"(%s fdwowner) AS rolname, fdwvalidator::pg_catalog.regproc, fdwacl,"
"array_to_string(ARRAY("
" SELECT option_name || ' ' || quote_literal(option_value) "
" FROM pg_options_to_table(fdwoptions)), ', ') AS fdwoptions "
" SELECT option_name || ' ' || quote_literal(option_value) "
" FROM pg_options_to_table(fdwoptions)), ', ') AS fdwoptions "
"FROM pg_foreign_data_wrapper",
username_subquery);
@@ -5498,8 +5502,8 @@ getForeignServers(int *numForeignServers)
"(%s srvowner) AS rolname, "
"srvfdw, srvtype, srvversion, srvacl,"
"array_to_string(ARRAY("
" SELECT option_name || ' ' || quote_literal(option_value) "
" FROM pg_options_to_table(srvoptions)), ', ') AS srvoptions "
" SELECT option_name || ' ' || quote_literal(option_value) "
" FROM pg_options_to_table(srvoptions)), ', ') AS srvoptions "
"FROM pg_foreign_server",
username_subquery);
@@ -5598,9 +5602,9 @@ dumpComment(Archive *fout, const char *target,
appendPQExpBuffer(query, ";\n");
/*
* We mark comments as SECTION_NONE because they really belong
* in the same section as their parent, whether that is
* pre-data or post-data.
* We mark comments as SECTION_NONE because they really belong in the
* same section as their parent, whether that is pre-data or
* post-data.
*/
ArchiveEntry(fout, nilCatalogId, createDumpId(),
target, namespace, NULL, owner,
@@ -6343,7 +6347,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -6542,7 +6546,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -6905,7 +6909,8 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
* This is used when we can rely on pg_get_function_arguments to format
* the argument list.
*/
static char *format_function_arguments(FuncInfo *finfo, char *funcargs)
static char *
format_function_arguments(FuncInfo *finfo, char *funcargs)
{
PQExpBufferData fn;
@@ -7033,8 +7038,8 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
PQExpBuffer delqry;
PQExpBuffer asPart;
PGresult *res;
char *funcsig; /* identity signature */
char *funcfullsig; /* full signature */
char *funcsig; /* identity signature */
char *funcfullsig; /* full signature */
char *funcsig_tag;
int ntups;
char *proretset;
@@ -7084,9 +7089,9 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
*/
appendPQExpBuffer(query,
"SELECT proretset, prosrc, probin, "
"pg_catalog.pg_get_function_arguments(oid) AS funcargs, "
"pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs, "
"pg_catalog.pg_get_function_result(oid) AS funcresult, "
"pg_catalog.pg_get_function_arguments(oid) AS funcargs, "
"pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs, "
"pg_catalog.pg_get_function_result(oid) AS funcresult, "
"proiswindow, provolatile, proisstrict, prosecdef, "
"proconfig, procost, prorows, "
"(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) AS lanname "
@@ -7193,7 +7198,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -7552,7 +7557,7 @@ dumpCast(Archive *fout, CastInfo *cast)
getFormattedTypeName(cast->castsource, zeroAsNone),
getFormattedTypeName(cast->casttarget, zeroAsNone));
switch(cast->castmethod)
switch (cast->castmethod)
{
case COERCION_METHOD_BINARY:
appendPQExpBuffer(defqry, "WITHOUT FUNCTION");
@@ -7561,6 +7566,7 @@ dumpCast(Archive *fout, CastInfo *cast)
appendPQExpBuffer(defqry, "WITH INOUT");
break;
case COERCION_METHOD_FUNCTION:
/*
* Always qualify the function name, in case it is not in
* pg_catalog schema (format_function_signature won't qualify it).
@@ -7730,7 +7736,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -7980,7 +7986,7 @@ convertTSFunction(Oid funcOid)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query);
exit_nicely();
@@ -8086,7 +8092,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -8160,9 +8166,9 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
*
* 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.
* 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.
*/
appendPQExpBuffer(query, "SELECT amopstrategy, false AS amopreqcheck, "
"amopopr::pg_catalog.regoperator "
@@ -8373,31 +8379,31 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
/*
* 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.
* 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.
*/
appendPQExpBuffer(query, "SELECT amopstrategy, false AS amopreqcheck, "
"amopopr::pg_catalog.regoperator "
"FROM pg_catalog.pg_amop ao, pg_catalog.pg_depend "
"amopopr::pg_catalog.regoperator "
"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 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);
"AND objid = ao.oid "
"ORDER BY amopstrategy",
opfinfo->dobj.catId.oid);
}
else
{
appendPQExpBuffer(query, "SELECT amopstrategy, amopreqcheck, "
"amopopr::pg_catalog.regoperator "
"FROM pg_catalog.pg_amop ao, pg_catalog.pg_depend "
"amopopr::pg_catalog.regoperator "
"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 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);
"AND objid = ao.oid "
"ORDER BY amopstrategy",
opfinfo->dobj.catId.oid);
}
res_ops = PQexec(g_conn, query->data);
@@ -8471,7 +8477,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -8647,7 +8653,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -8844,7 +8850,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -9071,7 +9077,7 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -9226,7 +9232,7 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -9412,7 +9418,7 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();
@@ -9467,7 +9473,7 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
dumpUserMappings(fout, q->data,
srvinfo->dobj.name, NULL,
srvinfo->rolname,
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
destroyPQExpBuffer(q);
destroyPQExpBuffer(delq);
@@ -9482,9 +9488,9 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
*/
static void
dumpUserMappings(Archive *fout, const char *target,
const char *servername, const char *namespace,
const char *owner,
CatalogId catalogId, DumpId dumpId)
const char *servername, const char *namespace,
const char *owner,
CatalogId catalogId, DumpId dumpId)
{
PQExpBuffer q;
PQExpBuffer delq;
@@ -9519,7 +9525,7 @@ dumpUserMappings(Archive *fout, const char *target,
for (i = 0; i < ntups; i++)
{
char *umuser;
char *umoptions;
char *umoptions;
umuser = PQgetvalue(res, i, i_umuser);
umoptions = PQgetvalue(res, i, i_umoptions);
@@ -9615,7 +9621,7 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
{
if (tbinfo->dobj.dump)
{
char *namecopy;
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
dumpSequence(fout, tbinfo);
@@ -9631,18 +9637,18 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
tbinfo->relacl);
/*
* Handle column ACLs, if any. Note: we pull these with a separate
* Handle column ACLs, if any. Note: we pull these with a separate
* query rather than trying to fetch them during getTableAttrs, so
* that we won't miss ACLs on system columns.
*/
if (g_fout->remoteVersion >= 80400)
{
PQExpBuffer query = createPQExpBuffer();
PGresult *res;
int i;
PGresult *res;
int i;
appendPQExpBuffer(query,
"SELECT attname, attacl FROM pg_catalog.pg_attribute "
"SELECT attname, attacl FROM pg_catalog.pg_attribute "
"WHERE attrelid = '%u' AND NOT attisdropped AND attacl IS NOT NULL "
"ORDER BY attnum",
tbinfo->dobj.catId.oid);
@@ -9651,10 +9657,10 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
for (i = 0; i < PQntuples(res); i++)
{
char *attname = PQgetvalue(res, i, 0);
char *attacl = PQgetvalue(res, i, 1);
char *attnamecopy;
char *acltag;
char *attname = PQgetvalue(res, i, 0);
char *attacl = PQgetvalue(res, i, 1);
char *attnamecopy;
char *acltag;
attnamecopy = strdup(fmtId(attname));
acltag = malloc(strlen(tbinfo->dobj.name) + strlen(attname) + 2);
@@ -9865,9 +9871,9 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
}
if ((tbinfo->reloptions && strlen(tbinfo->reloptions) > 0) ||
(tbinfo->toast_reloptions && strlen(tbinfo->toast_reloptions) > 0))
(tbinfo->toast_reloptions && strlen(tbinfo->toast_reloptions) > 0))
{
bool addcomma = false;
bool addcomma = false;
appendPQExpBuffer(q, "\nWITH (");
if (tbinfo->reloptions && strlen(tbinfo->reloptions) > 0)
@@ -9886,8 +9892,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
appendPQExpBuffer(q, ";\n");
/*
* For binary-compatible heap files, we create dropped columns
* above and drop them here.
* For binary-compatible heap files, we create dropped columns above
* and drop them here.
*/
if (binary_upgrade)
{
@@ -9901,46 +9907,46 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
fmtId(tbinfo->attnames[j]));
/*
* ALTER TABLE DROP COLUMN clears pg_attribute.atttypid,
* so we have to set pg_attribute.attlen and
* pg_attribute.attalign values because that is what
* is used to skip over dropped columns in the heap tuples.
* We have atttypmod, but it seems impossible to know the
* correct data type that will yield pg_attribute values
* that match the old installation.
* See comment in backend/catalog/heap.c::RemoveAttributeById()
* ALTER TABLE DROP COLUMN clears pg_attribute.atttypid,
* so we have to set pg_attribute.attlen and
* pg_attribute.attalign values because that is what is
* used to skip over dropped columns in the heap tuples.
* We have atttypmod, but it seems impossible to know the
* correct data type that will yield pg_attribute values
* that match the old installation. See comment in
* backend/catalog/heap.c::RemoveAttributeById()
*/
appendPQExpBuffer(q, "\n-- For binary upgrade, recreate dropped column's length and alignment.\n");
appendPQExpBuffer(q, "UPDATE pg_attribute\n"
"SET attlen = %d, "
"attalign = '%c'\n"
"WHERE attname = '%s'\n"
" AND attrelid = \n"
" (\n"
" SELECT oid\n"
" FROM pg_class\n"
" WHERE relnamespace = "
"(SELECT oid FROM pg_namespace "
"WHERE nspname = CURRENT_SCHEMA)\n"
" AND relname = ",
tbinfo->attlen[j],
tbinfo->attalign[j],
tbinfo->attnames[j]);
"SET attlen = %d, "
"attalign = '%c'\n"
"WHERE attname = '%s'\n"
" AND attrelid = \n"
" (\n"
" SELECT oid\n"
" FROM pg_class\n"
" WHERE relnamespace = "
"(SELECT oid FROM pg_namespace "
"WHERE nspname = CURRENT_SCHEMA)\n"
" AND relname = ",
tbinfo->attlen[j],
tbinfo->attalign[j],
tbinfo->attnames[j]);
appendStringLiteralAH(q, tbinfo->dobj.name, fout);
appendPQExpBuffer(q, "\n );\n");
}
}
appendPQExpBuffer(q, "\n-- For binary upgrade, set relfrozenxid.\n");
appendPQExpBuffer(q, "UPDATE pg_class\n"
"SET relfrozenxid = '%u'\n"
"WHERE relname = ",
tbinfo->frozenxid);
"SET relfrozenxid = '%u'\n"
"WHERE relname = ",
tbinfo->frozenxid);
appendStringLiteralAH(q, tbinfo->dobj.name, fout);
appendPQExpBuffer(q, "\n AND relnamespace = "
"(SELECT oid FROM pg_namespace "
"WHERE nspname = CURRENT_SCHEMA);\n");
"(SELECT oid FROM pg_namespace "
"WHERE nspname = CURRENT_SCHEMA);\n");
}
/* Loop dumping statistics and storage statements */
for (j = 0; j < tbinfo->numatts; j++)
{
@@ -10522,36 +10528,36 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
if (g_fout->remoteVersion >= 80400)
{
appendPQExpBuffer(query,
"SELECT sequence_name, "
"start_value, last_value, increment_by, "
"CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
" WHEN increment_by < 0 AND max_value = -1 THEN NULL "
" ELSE max_value "
"END AS max_value, "
"CASE WHEN increment_by > 0 AND min_value = 1 THEN NULL "
" WHEN increment_by < 0 AND min_value = %s THEN NULL "
" ELSE min_value "
"END AS min_value, "
"cache_value, is_cycled, is_called from %s",
bufx, bufm,
fmtId(tbinfo->dobj.name));
"SELECT sequence_name, "
"start_value, last_value, increment_by, "
"CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
" WHEN increment_by < 0 AND max_value = -1 THEN NULL "
" ELSE max_value "
"END AS max_value, "
"CASE WHEN increment_by > 0 AND min_value = 1 THEN NULL "
" WHEN increment_by < 0 AND min_value = %s THEN NULL "
" ELSE min_value "
"END AS min_value, "
"cache_value, is_cycled, is_called from %s",
bufx, bufm,
fmtId(tbinfo->dobj.name));
}
else
{
appendPQExpBuffer(query,
"SELECT sequence_name, "
"0 AS start_value, last_value, increment_by, "
"CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
" WHEN increment_by < 0 AND max_value = -1 THEN NULL "
" ELSE max_value "
"END AS max_value, "
"CASE WHEN increment_by > 0 AND min_value = 1 THEN NULL "
" WHEN increment_by < 0 AND min_value = %s THEN NULL "
" ELSE min_value "
"END AS min_value, "
"cache_value, is_cycled, is_called from %s",
bufx, bufm,
fmtId(tbinfo->dobj.name));
"SELECT sequence_name, "
"0 AS start_value, last_value, increment_by, "
"CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
" WHEN increment_by < 0 AND max_value = -1 THEN NULL "
" ELSE max_value "
"END AS max_value, "
"CASE WHEN increment_by > 0 AND min_value = 1 THEN NULL "
" WHEN increment_by < 0 AND min_value = %s THEN NULL "
" ELSE min_value "
"END AS min_value, "
"cache_value, is_cycled, is_called from %s",
bufx, bufm,
fmtId(tbinfo->dobj.name));
}
res = PQexec(g_conn, query->data);
@@ -10622,7 +10628,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
/*
* Versions before 8.4 did not remember the true start value. If
* is_called is false then the sequence has never been incremented
* so we can use last_val. Otherwise punt and let it default.
* so we can use last_val. Otherwise punt and let it default.
*/
if (!called)
appendPQExpBuffer(query, " START WITH %s\n", last);
@@ -11268,7 +11274,7 @@ getFormattedTypeName(Oid oid, OidOptions opts)
if (ntups != 1)
{
write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
"query returned %d rows instead of one: %s\n",
ntups),
ntups, query->data);
exit_nicely();