diff options
Diffstat (limited to 'src/bin/pg_dump/pg_dump.c')
-rw-r--r-- | src/bin/pg_dump/pg_dump.c | 131 |
1 files changed, 66 insertions, 65 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index e8ce719a0a6..38a01758a14 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -135,7 +135,7 @@ static const CatalogId nilCatalogId = {0, 0}; /* override for standard extra_float_digits setting */ static bool have_extra_float_digits = false; -static int extra_float_digits; +static int extra_float_digits; /* * The default number of rows per INSERT when @@ -601,7 +601,7 @@ main(int argc, char **argv) errno == ERANGE) { pg_log_error("rows-per-insert must be in range %d..%d", - 1, INT_MAX); + 1, INT_MAX); exit_nicely(1); } dopt.dump_inserts = (int) rowsPerInsert; @@ -1112,13 +1112,14 @@ setup_connection(Archive *AH, const char *dumpencoding, ExecuteSqlStatement(AH, "SET INTERVALSTYLE = POSTGRES"); /* - * Use an explicitly specified extra_float_digits if it has been - * provided. Otherwise, set extra_float_digits so that we can dump float - * data exactly (given correctly implemented float I/O code, anyway). + * Use an explicitly specified extra_float_digits if it has been provided. + * Otherwise, set extra_float_digits so that we can dump float data + * exactly (given correctly implemented float I/O code, anyway). */ if (have_extra_float_digits) { PQExpBuffer q = createPQExpBuffer(); + appendPQExpBuffer(q, "SET extra_float_digits TO %d", extra_float_digits); ExecuteSqlStatement(AH, q->data); @@ -1921,7 +1922,7 @@ dumpTableData_copy(Archive *fout, void *dcontext) /* Do this to ensure we've pumped libpq back to idle state */ if (PQgetResult(conn) != NULL) pg_log_warning("unexpected extra results during COPY of table \"%s\"", - classname); + classname); destroyPQExpBuffer(q); return 1; @@ -3468,7 +3469,7 @@ dumpBlobs(Archive *fout, void *arg) loFd = lo_open(conn, blobOid, INV_READ); if (loFd == -1) fatal("could not open large object %u: %s", - blobOid, PQerrorMessage(conn)); + blobOid, PQerrorMessage(conn)); StartBlob(fout, blobOid); @@ -3478,7 +3479,7 @@ dumpBlobs(Archive *fout, void *arg) cnt = lo_read(conn, loFd, buf, LOBBUFSIZE); if (cnt < 0) fatal("error reading large object %u: %s", - blobOid, PQerrorMessage(conn)); + blobOid, PQerrorMessage(conn)); WriteData(fout, buf, cnt); } while (cnt > 0); @@ -3711,7 +3712,7 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo) else { pg_log_error("unexpected policy command type: %c", - polinfo->polcmd); + polinfo->polcmd); exit_nicely(1); } @@ -3838,7 +3839,7 @@ getPublications(Archive *fout) if (strlen(pubinfo[i].rolname) == 0) pg_log_warning("owner of publication \"%s\" appears to be invalid", - pubinfo[i].dobj.name); + pubinfo[i].dobj.name); /* Decide whether we want to dump it */ selectDumpableObject(&(pubinfo[i].dobj), fout); @@ -4172,7 +4173,7 @@ getSubscriptions(Archive *fout) if (strlen(subinfo[i].rolname) == 0) pg_log_warning("owner of subscription \"%s\" appears to be invalid", - subinfo[i].dobj.name); + subinfo[i].dobj.name); /* Decide whether we want to dump it */ selectDumpableObject(&(subinfo[i].dobj), fout); @@ -4488,7 +4489,7 @@ binary_upgrade_extension_member(PQExpBuffer upgrade_buffer, } if (extobj == NULL) fatal("could not find parent extension for %s %s", - objtype, objname); + objtype, objname); appendPQExpBufferStr(upgrade_buffer, "\n-- For binary upgrade, handle extension membership the hard way\n"); @@ -4620,7 +4621,7 @@ getNamespaces(Archive *fout, int *numNamespaces) if (strlen(nsinfo[i].rolname) == 0) pg_log_warning("owner of schema \"%s\" appears to be invalid", - nsinfo[i].dobj.name); + nsinfo[i].dobj.name); } PQclear(res); @@ -4968,7 +4969,7 @@ getTypes(Archive *fout, int *numTypes) if (strlen(tyinfo[i].rolname) == 0) pg_log_warning("owner of data type \"%s\" appears to be invalid", - tyinfo[i].dobj.name); + tyinfo[i].dobj.name); } *numTypes = ntups; @@ -5053,7 +5054,7 @@ getOperators(Archive *fout, int *numOprs) if (strlen(oprinfo[i].rolname) == 0) pg_log_warning("owner of operator \"%s\" appears to be invalid", - oprinfo[i].dobj.name); + oprinfo[i].dobj.name); } PQclear(res); @@ -5355,7 +5356,7 @@ getOpclasses(Archive *fout, int *numOpclasses) if (strlen(opcinfo[i].rolname) == 0) pg_log_warning("owner of operator class \"%s\" appears to be invalid", - opcinfo[i].dobj.name); + opcinfo[i].dobj.name); } PQclear(res); @@ -5439,7 +5440,7 @@ getOpfamilies(Archive *fout, int *numOpfamilies) if (strlen(opfinfo[i].rolname) == 0) pg_log_warning("owner of operator family \"%s\" appears to be invalid", - opfinfo[i].dobj.name); + opfinfo[i].dobj.name); } PQclear(res); @@ -5608,7 +5609,7 @@ getAggregates(Archive *fout, int *numAggs) agginfo[i].aggfn.rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); if (strlen(agginfo[i].aggfn.rolname) == 0) pg_log_warning("owner of aggregate function \"%s\" appears to be invalid", - agginfo[i].aggfn.dobj.name); + agginfo[i].aggfn.dobj.name); agginfo[i].aggfn.lang = InvalidOid; /* not currently interesting */ agginfo[i].aggfn.prorettype = InvalidOid; /* not saved */ agginfo[i].aggfn.proacl = pg_strdup(PQgetvalue(res, i, i_aggacl)); @@ -5868,7 +5869,7 @@ getFuncs(Archive *fout, int *numFuncs) if (strlen(finfo[i].rolname) == 0) pg_log_warning("owner of function \"%s\" appears to be invalid", - finfo[i].dobj.name); + finfo[i].dobj.name); } PQclear(res); @@ -6664,7 +6665,7 @@ getTables(Archive *fout, int *numTables) /* Emit notice if join for owner failed */ if (strlen(tblinfo[i].rolname) == 0) pg_log_warning("owner of table \"%s\" appears to be invalid", - tblinfo[i].dobj.name); + tblinfo[i].dobj.name); } if (dopt->lockWaitTimeout) @@ -6706,7 +6707,7 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables) owning_tab = findTableByOid(seqinfo->owning_tab); if (owning_tab == NULL) fatal("failed sanity check, parent table with OID %u of sequence with OID %u not found", - seqinfo->owning_tab, seqinfo->dobj.catId.oid); + seqinfo->owning_tab, seqinfo->dobj.catId.oid); /* * Only dump identity sequences if we're going to dump the table that @@ -7470,7 +7471,7 @@ getRules(Archive *fout, int *numRules) ruleinfo[i].ruletable = findTableByOid(ruletableoid); if (ruleinfo[i].ruletable == NULL) fatal("failed sanity check, parent table with OID %u of pg_rewrite entry with OID %u not found", - ruletableoid, ruleinfo[i].dobj.catId.oid); + ruletableoid, ruleinfo[i].dobj.catId.oid); ruleinfo[i].dobj.namespace = ruleinfo[i].ruletable->dobj.namespace; ruleinfo[i].dobj.dump = ruleinfo[i].ruletable->dobj.dump; ruleinfo[i].ev_type = *(PQgetvalue(res, i, i_ev_type)); @@ -7686,9 +7687,9 @@ getTriggers(Archive *fout, TableInfo tblinfo[], int numTables) { if (PQgetisnull(res, j, i_tgconstrrelname)) fatal("query produced null referenced table name for foreign key trigger \"%s\" on table \"%s\" (OID of table: %u)", - tginfo[j].dobj.name, - tbinfo->dobj.name, - tginfo[j].tgconstrrelid); + tginfo[j].dobj.name, + tbinfo->dobj.name, + tginfo[j].tgconstrrelid); tginfo[j].tgconstrrelname = pg_strdup(PQgetvalue(res, j, i_tgconstrrelname)); } else @@ -8377,7 +8378,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) { if (j + 1 != atoi(PQgetvalue(res, j, i_attnum))) fatal("invalid column numbering in table \"%s\"", - tbinfo->dobj.name); + tbinfo->dobj.name); tbinfo->attnames[j] = pg_strdup(PQgetvalue(res, j, i_attname)); tbinfo->atttypnames[j] = pg_strdup(PQgetvalue(res, j, i_atttypname)); tbinfo->atttypmod[j] = atoi(PQgetvalue(res, j, i_atttypmod)); @@ -8436,7 +8437,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) if (adnum <= 0 || adnum > ntups) fatal("invalid adnum value %d for table \"%s\"", - adnum, tbinfo->dobj.name); + adnum, tbinfo->dobj.name); /* * dropped columns shouldn't have defaults, but just in case, @@ -8552,7 +8553,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) pg_log_error(ngettext("expected %d check constraint on table \"%s\" but found %d", "expected %d check constraints on table \"%s\" but found %d", tbinfo->ncheck), - tbinfo->ncheck, tbinfo->dobj.name, numConstrs); + tbinfo->ncheck, tbinfo->dobj.name, numConstrs); pg_log_error("(The system catalogs might be corrupted.)"); exit_nicely(1); } @@ -10130,7 +10131,7 @@ dumpType(Archive *fout, TypeInfo *tyinfo) dumpUndefinedType(fout, tyinfo); else pg_log_warning("typtype of data type \"%s\" appears to be invalid", - tyinfo->dobj.name); + tyinfo->dobj.name); } /* @@ -11977,7 +11978,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) appendPQExpBufferStr(q, " STABLE"); else if (provolatile[0] != PROVOLATILE_VOLATILE) fatal("unrecognized provolatile value for function \"%s\"", - finfo->dobj.name); + finfo->dobj.name); } if (proisstrict[0] == 't') @@ -12027,7 +12028,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) appendPQExpBufferStr(q, " PARALLEL RESTRICTED"); else if (proparallel[0] != PROPARALLEL_UNSAFE) fatal("unrecognized proparallel value for function \"%s\"", - finfo->dobj.name); + finfo->dobj.name); } for (i = 0; i < nconfigitems; i++) @@ -12160,7 +12161,7 @@ dumpCast(Archive *fout, CastInfo *cast) funcInfo = findFuncByOid(cast->castfunc); if (funcInfo == NULL) fatal("could not find function definition for function with OID %u", - cast->castfunc); + cast->castfunc); } defqry = createPQExpBuffer(); @@ -12269,14 +12270,14 @@ dumpTransform(Archive *fout, TransformInfo *transform) fromsqlFuncInfo = findFuncByOid(transform->trffromsql); if (fromsqlFuncInfo == NULL) fatal("could not find function definition for function with OID %u", - transform->trffromsql); + transform->trffromsql); } if (OidIsValid(transform->trftosql)) { tosqlFuncInfo = findFuncByOid(transform->trftosql); if (tosqlFuncInfo == NULL) fatal("could not find function definition for function with OID %u", - transform->trftosql); + transform->trftosql); } defqry = createPQExpBuffer(); @@ -12649,7 +12650,7 @@ getFormattedOperatorName(Archive *fout, const char *oproid) if (oprInfo == NULL) { pg_log_warning("could not find operator with OID %s", - oproid); + oproid); return NULL; } @@ -12717,7 +12718,7 @@ dumpAccessMethod(Archive *fout, AccessMethodInfo *aminfo) break; default: pg_log_warning("invalid type \"%c\" of access method \"%s\"", - aminfo->amtype, qamname); + aminfo->amtype, qamname); destroyPQExpBuffer(q); destroyPQExpBuffer(delq); free(qamname); @@ -13471,7 +13472,7 @@ dumpCollation(Archive *fout, CollInfo *collinfo) appendPQExpBufferStr(q, "default"); else fatal("unrecognized collation provider: %s\n", - collprovider); + collprovider); if (strcmp(PQgetvalue(res, 0, i_collisdeterministic), "f") == 0) appendPQExpBufferStr(q, ", deterministic = false"); @@ -13943,7 +13944,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) if (!convertok) { pg_log_warning("aggregate function %s could not be dumped correctly for this database version; ignored", - aggsig); + aggsig); if (aggfullsig) free(aggfullsig); @@ -13998,7 +13999,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) break; default: fatal("unrecognized aggfinalmodify value for aggregate \"%s\"", - agginfo->aggfn.dobj.name); + agginfo->aggfn.dobj.name); break; } } @@ -14054,7 +14055,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) break; default: fatal("unrecognized aggmfinalmodify value for aggregate \"%s\"", - agginfo->aggfn.dobj.name); + agginfo->aggfn.dobj.name); break; } } @@ -14079,7 +14080,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) appendPQExpBufferStr(details, ",\n PARALLEL = restricted"); else if (proparallel[0] != PROPARALLEL_UNSAFE) fatal("unrecognized proparallel value for function \"%s\"", - agginfo->aggfn.dobj.name); + agginfo->aggfn.dobj.name); } appendPQExpBuffer(delq, "DROP AGGREGATE %s.%s;\n", @@ -14776,7 +14777,7 @@ dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo) default: /* shouldn't get here */ fatal("unrecognized object type in default privileges: %d", - (int) daclinfo->defaclobjtype); + (int) daclinfo->defaclobjtype); type = ""; /* keep compiler quiet */ } @@ -14794,7 +14795,7 @@ dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo) fout->remoteVersion, q)) fatal("could not parse default ACL list (%s)", - daclinfo->defaclacl); + daclinfo->defaclacl); if (daclinfo->dobj.dump & DUMP_COMPONENT_ACL) ArchiveEntry(fout, daclinfo->dobj.catId, daclinfo->dobj.dumpId, @@ -14874,7 +14875,7 @@ dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId, initacls, initracls, owner, "", fout->remoteVersion, sql)) fatal("could not parse initial GRANT ACL list (%s) or initial REVOKE ACL list (%s) for object \"%s\" (%s)", - initacls, initracls, name, type); + initacls, initracls, name, type); appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n"); } @@ -14882,7 +14883,7 @@ dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId, acls, racls, owner, "", fout->remoteVersion, sql)) fatal("could not parse GRANT ACL list (%s) or REVOKE ACL list (%s) for object \"%s\" (%s)", - acls, racls, name, type); + acls, racls, name, type); if (sql->len > 0) { @@ -15381,17 +15382,17 @@ createViewAsClause(Archive *fout, TableInfo *tbinfo) { if (PQntuples(res) < 1) fatal("query to obtain definition of view \"%s\" returned no data", - tbinfo->dobj.name); + tbinfo->dobj.name); else fatal("query to obtain definition of view \"%s\" returned more than one definition", - tbinfo->dobj.name); + tbinfo->dobj.name); } len = PQgetlength(res, 0, 0); if (len == 0) fatal("definition of view \"%s\" appears to be empty (length zero)", - tbinfo->dobj.name); + tbinfo->dobj.name); /* Strip off the trailing semicolon so that other things may follow. */ Assert(PQgetvalue(res, 0, 0)[len - 1] == ';'); @@ -15473,7 +15474,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) if (tbinfo->hasoids) pg_log_warning("WITH OIDS is not supported anymore (table \"%s\")", - qrelname); + qrelname); if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_rel_oid(fout, q, @@ -15600,7 +15601,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) */ if (tbinfo->numParents != 1) fatal("invalid number of parents %d for table \"%s\"", - tbinfo->numParents, tbinfo->dobj.name); + tbinfo->numParents, tbinfo->dobj.name); appendPQExpBuffer(q, " PARTITION OF %s", fmtQualifiedDumpable(parentRel)); @@ -16157,7 +16158,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION) { - char *tableam = NULL; + char *tableam = NULL; if (tbinfo->relkind == RELKIND_RELATION || tbinfo->relkind == RELKIND_MATVIEW) @@ -16287,7 +16288,7 @@ getAttrName(int attrnum, TableInfo *tblInfo) return "tableoid"; } fatal("invalid column number %d for table \"%s\"", - attrnum, tblInfo->dobj.name); + attrnum, tblInfo->dobj.name); return NULL; /* keep compiler quiet */ } @@ -16549,7 +16550,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) if (indxinfo == NULL) fatal("missing index for constraint \"%s\"", - coninfo->dobj.name); + coninfo->dobj.name); if (dopt->binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, @@ -16769,7 +16770,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) else { fatal("unrecognized constraint type: %c", - coninfo->contype); + coninfo->contype); } /* Dump Constraint Comments --- only works for table constraints */ @@ -16902,8 +16903,8 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) { pg_log_error(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)", "query to get data of sequence \"%s\" returned %d rows (expected 1)", - PQntuples(res)), - tbinfo->dobj.name, PQntuples(res)); + PQntuples(res)), + tbinfo->dobj.name, PQntuples(res)); exit_nicely(1); } @@ -17056,7 +17057,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) if (owning_tab == NULL) fatal("failed sanity check, parent table with OID %u of sequence with OID %u not found", - tbinfo->owning_tab, tbinfo->dobj.catId.oid); + tbinfo->owning_tab, tbinfo->dobj.catId.oid); if (owning_tab->dobj.dump & DUMP_COMPONENT_DEFINITION) { @@ -17122,8 +17123,8 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo) { pg_log_error(ngettext("query to get data of sequence \"%s\" returned %d row (expected 1)", "query to get data of sequence \"%s\" returned %d rows (expected 1)", - PQntuples(res)), - tbinfo->dobj.name, PQntuples(res)); + PQntuples(res)), + tbinfo->dobj.name, PQntuples(res)); exit_nicely(1); } @@ -17291,9 +17292,9 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) { /* hm, not found before end of bytea value... */ pg_log_error("invalid argument string (%s) for trigger \"%s\" on table \"%s\"", - tginfo->tgargs, - tginfo->dobj.name, - tbinfo->dobj.name); + tginfo->tgargs, + tginfo->dobj.name, + tbinfo->dobj.name); exit_nicely(1); } @@ -17520,7 +17521,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo) if (PQntuples(res) != 1) { pg_log_error("query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned", - rinfo->dobj.name, tbinfo->dobj.name); + rinfo->dobj.name, tbinfo->dobj.name); exit_nicely(1); } @@ -17949,7 +17950,7 @@ getDependencies(Archive *fout) { #ifdef NOT_USED pg_log_warning("no referencing object %u %u", - objId.tableoid, objId.oid); + objId.tableoid, objId.oid); #endif continue; } @@ -17960,7 +17961,7 @@ getDependencies(Archive *fout) { #ifdef NOT_USED pg_log_warning("no referenced object %u %u", - refobjId.tableoid, refobjId.oid); + refobjId.tableoid, refobjId.oid); #endif continue; } |