diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 287d485d5f..2d6ea13c45 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -685,7 +685,7 @@ AddAcl(PQExpBuffer aclbuf, const char *keyword, const char *subname) * keep this file free of assumptions about how to deal with SQL errors.) */ void -buildShSecLabelQuery(PGconn *conn, const char *catalog_name, Oid objectId, +buildShSecLabelQuery(const char *catalog_name, Oid objectId, PQExpBuffer sql) { appendPQExpBuffer(sql, diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h index cb1d98d873..d35d9d34d2 100644 --- a/src/bin/pg_dump/dumputils.h +++ b/src/bin/pg_dump/dumputils.h @@ -46,7 +46,7 @@ extern bool buildDefaultACLCommands(const char *type, const char *nspname, const char *owner, int remoteVersion, PQExpBuffer sql); -extern void buildShSecLabelQuery(PGconn *conn, const char *catalog_name, +extern void buildShSecLabelQuery(const char *catalog_name, Oid objectId, PQExpBuffer sql); extern void emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer, const char *objtype, const char *objname); diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 178b61d6cb..bc47578294 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -70,8 +70,7 @@ typedef struct _parallelReadyList static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt, const int compression, bool dosync, ArchiveMode mode, SetupWorkerPtrType setupWorkerPtr); -static void _getObjectDescription(PQExpBuffer buf, TocEntry *te, - ArchiveHandle *AH); +static void _getObjectDescription(PQExpBuffer buf, TocEntry *te); static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData); static char *sanitize_line(const char *str, bool want_hyphen); static void _doSetFixedOutputState(ArchiveHandle *AH); @@ -91,7 +90,7 @@ static bool _tocEntryIsACL(TocEntry *te); static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te); static void _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te); static void buildTocEntryArrays(ArchiveHandle *AH); -static void _moveBefore(ArchiveHandle *AH, TocEntry *pos, TocEntry *te); +static void _moveBefore(TocEntry *pos, TocEntry *te); static int _discoverArchiveFormat(ArchiveHandle *AH); static int RestoringToDB(ArchiveHandle *AH); @@ -121,8 +120,7 @@ static int TocEntrySizeCompare(const void *p1, const void *p2); static void move_to_ready_list(TocEntry *pending_list, ParallelReadyList *ready_list, RestorePass pass); -static TocEntry *pop_next_work_item(ArchiveHandle *AH, - ParallelReadyList *ready_list, +static TocEntry *pop_next_work_item(ParallelReadyList *ready_list, ParallelState *pstate); static void mark_dump_job_done(ArchiveHandle *AH, TocEntry *te, @@ -1442,7 +1440,7 @@ SortTocFromFile(Archive *AHX) * side-effects on the order in which restorable items actually get * restored. */ - _moveBefore(AH, AH->toc, te); + _moveBefore(AH->toc, te); } if (fclose(fh) != 0) @@ -1804,7 +1802,7 @@ _moveAfter(ArchiveHandle *AH, TocEntry *pos, TocEntry *te) #endif static void -_moveBefore(ArchiveHandle *AH, TocEntry *pos, TocEntry *te) +_moveBefore(TocEntry *pos, TocEntry *te) { /* Unlink te from list */ te->prev->next = te->next; @@ -3465,7 +3463,7 @@ _selectTableAccessMethod(ArchiveHandle *AH, const char *tableam) * This is used for ALTER ... OWNER TO. */ static void -_getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH) +_getObjectDescription(PQExpBuffer buf, TocEntry *te) { const char *type = te->desc; @@ -3674,7 +3672,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData) PQExpBuffer temp = createPQExpBuffer(); appendPQExpBufferStr(temp, "ALTER "); - _getObjectDescription(temp, te, AH); + _getObjectDescription(temp, te); appendPQExpBuffer(temp, " OWNER TO %s;", fmtId(te->owner)); ahprintf(AH, "%s\n\n", temp->data); destroyPQExpBuffer(temp); @@ -4078,7 +4076,7 @@ restore_toc_entries_parallel(ArchiveHandle *AH, ParallelState *pstate, for (;;) { /* Look for an item ready to be dispatched to a worker */ - next_work_item = pop_next_work_item(AH, &ready_list, pstate); + next_work_item = pop_next_work_item(&ready_list, pstate); if (next_work_item != NULL) { /* If not to be restored, don't waste time launching a worker */ @@ -4384,7 +4382,7 @@ move_to_ready_list(TocEntry *pending_list, * no remaining dependencies, but we have to check for lock conflicts. */ static TocEntry * -pop_next_work_item(ArchiveHandle *AH, ParallelReadyList *ready_list, +pop_next_work_item(ParallelReadyList *ready_list, ParallelState *pstate) { /* diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c index c601ec0701..54e708875c 100644 --- a/src/bin/pg_dump/pg_backup_tar.c +++ b/src/bin/pg_dump/pg_backup_tar.c @@ -107,7 +107,7 @@ static void tarClose(ArchiveHandle *AH, TAR_MEMBER *TH); #ifdef __NOT_USED__ static char *tarGets(char *buf, size_t len, TAR_MEMBER *th); #endif -static int tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...) pg_attribute_printf(3, 4); +static int tarPrintf(TAR_MEMBER *th, const char *fmt,...) pg_attribute_printf(2, 3); static void _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th); static TAR_MEMBER *_tarPositionTo(ArchiveHandle *AH, const char *filename); @@ -851,7 +851,7 @@ _CloseArchive(ArchiveHandle *AH) */ th = tarOpen(AH, "restore.sql", 'w'); - tarPrintf(AH, th, "--\n" + tarPrintf(th, "--\n" "-- NOTE:\n" "--\n" "-- File paths need to be edited. Search for $$PATH$$ and\n" @@ -964,7 +964,7 @@ _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid) sprintf(fname, "blob_%u.dat%s", oid, sfx); - tarPrintf(AH, ctx->blobToc, "%u %s\n", oid, fname); + tarPrintf(ctx->blobToc, "%u %s\n", oid, fname); tctx->TH = tarOpen(AH, fname, 'w'); } @@ -1008,7 +1008,7 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te) */ static int -tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...) +tarPrintf(TAR_MEMBER *th, const char *fmt,...) { int save_errno = errno; char *p; diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index dce6af09c9..f021bb72f4 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -157,7 +157,7 @@ static void expand_table_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names); -static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid); +static NamespaceInfo *findNamespace(Oid nsoid); static void dumpTableData(Archive *fout, TableDataInfo *tdinfo); static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo); static void guessConstraintInheritance(TableInfo *tblinfo, int numTables); @@ -250,9 +250,8 @@ static char *format_function_arguments_old(Archive *fout, char **argnames); static char *format_function_signature(Archive *fout, FuncInfo *finfo, bool honor_quotes); -static char *convertRegProcReference(Archive *fout, - const char *proc); -static char *getFormattedOperatorName(Archive *fout, const char *oproid); +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 char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts); @@ -2974,7 +2973,7 @@ dumpDatabase(Archive *fout) seclabelQry = createPQExpBuffer(); - buildShSecLabelQuery(conn, "pg_database", dbCatId.oid, seclabelQry); + buildShSecLabelQuery("pg_database", dbCatId.oid, seclabelQry); shres = ExecuteSqlQuery(fout, seclabelQry->data, PGRES_TUPLES_OK); resetPQExpBuffer(seclabelQry); emitShSecLabels(conn, shres, seclabelQry, "DATABASE", datname); @@ -4811,7 +4810,7 @@ getNamespaces(Archive *fout, int *numNamespaces) * given a namespace OID, look up the info read by getNamespaces */ static NamespaceInfo * -findNamespace(Archive *fout, Oid nsoid) +findNamespace(Oid nsoid) { NamespaceInfo *nsinfo; @@ -5069,8 +5068,7 @@ getTypes(Archive *fout, int *numTypes) AssignDumpId(&tyinfo[i].dobj); tyinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_typname)); tyinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_typnamespace))); + findNamespace(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)); @@ -5214,8 +5212,7 @@ getOperators(Archive *fout, int *numOprs) AssignDumpId(&oprinfo[i].dobj); oprinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_oprname)); oprinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_oprnamespace))); + findNamespace(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)); @@ -5300,8 +5297,7 @@ getCollations(Archive *fout, int *numCollations) AssignDumpId(&collinfo[i].dobj); collinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_collname)); collinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_collnamespace))); + findNamespace(atooid(PQgetvalue(res, i, i_collnamespace))); collinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); /* Decide whether we want to dump it */ @@ -5373,8 +5369,7 @@ getConversions(Archive *fout, int *numConversions) AssignDumpId(&convinfo[i].dobj); convinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_conname)); convinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_connamespace))); + findNamespace(atooid(PQgetvalue(res, i, i_connamespace))); convinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); /* Decide whether we want to dump it */ @@ -5518,8 +5513,7 @@ getOpclasses(Archive *fout, int *numOpclasses) AssignDumpId(&opcinfo[i].dobj); opcinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_opcname)); opcinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_opcnamespace))); + findNamespace(atooid(PQgetvalue(res, i, i_opcnamespace))); opcinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); /* Decide whether we want to dump it */ @@ -5602,8 +5596,7 @@ getOpfamilies(Archive *fout, int *numOpfamilies) AssignDumpId(&opfinfo[i].dobj); opfinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_opfname)); opfinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_opfnamespace))); + findNamespace(atooid(PQgetvalue(res, i, i_opfnamespace))); opfinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); /* Decide whether we want to dump it */ @@ -5778,8 +5771,7 @@ getAggregates(Archive *fout, int *numAggs) AssignDumpId(&agginfo[i].aggfn.dobj); 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))); + findNamespace(atooid(PQgetvalue(res, i, i_aggnamespace))); 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", @@ -6013,8 +6005,7 @@ getFuncs(Archive *fout, int *numFuncs) AssignDumpId(&finfo[i].dobj); finfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_proname)); finfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_pronamespace))); + findNamespace(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)); @@ -6751,8 +6742,7 @@ getTables(Archive *fout, int *numTables) AssignDumpId(&tblinfo[i].dobj); tblinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_relname)); tblinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_relnamespace))); + findNamespace(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)); @@ -7413,8 +7403,7 @@ getExtendedStatistics(Archive *fout) AssignDumpId(&statsextinfo[i].dobj); statsextinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_stxname)); statsextinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_stxnamespace))); + findNamespace(atooid(PQgetvalue(res, i, i_stxnamespace))); statsextinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); statsextinfo[i].stattarget = atoi(PQgetvalue(res, i, i_stattarget)); @@ -8952,8 +8941,7 @@ getTSParsers(Archive *fout, int *numTSParsers) AssignDumpId(&prsinfo[i].dobj); prsinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_prsname)); prsinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_prsnamespace))); + findNamespace(atooid(PQgetvalue(res, i, i_prsnamespace))); prsinfo[i].prsstart = atooid(PQgetvalue(res, i, i_prsstart)); prsinfo[i].prstoken = atooid(PQgetvalue(res, i, i_prstoken)); prsinfo[i].prsend = atooid(PQgetvalue(res, i, i_prsend)); @@ -9035,8 +9023,7 @@ getTSDictionaries(Archive *fout, int *numTSDicts) AssignDumpId(&dictinfo[i].dobj); dictinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_dictname)); dictinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_dictnamespace))); + findNamespace(atooid(PQgetvalue(res, i, i_dictnamespace))); dictinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); dictinfo[i].dicttemplate = atooid(PQgetvalue(res, i, i_dicttemplate)); if (PQgetisnull(res, i, i_dictinitoption)) @@ -9115,8 +9102,7 @@ getTSTemplates(Archive *fout, int *numTSTemplates) AssignDumpId(&tmplinfo[i].dobj); tmplinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_tmplname)); tmplinfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_tmplnamespace))); + findNamespace(atooid(PQgetvalue(res, i, i_tmplnamespace))); tmplinfo[i].tmplinit = atooid(PQgetvalue(res, i, i_tmplinit)); tmplinfo[i].tmpllexize = atooid(PQgetvalue(res, i, i_tmpllexize)); @@ -9192,8 +9178,7 @@ getTSConfigurations(Archive *fout, int *numTSConfigs) AssignDumpId(&cfginfo[i].dobj); cfginfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_cfgname)); cfginfo[i].dobj.namespace = - findNamespace(fout, - atooid(PQgetvalue(res, i, i_cfgnamespace))); + findNamespace(atooid(PQgetvalue(res, i, i_cfgnamespace))); cfginfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); cfginfo[i].cfgparser = atooid(PQgetvalue(res, i, i_cfgparser)); @@ -9640,7 +9625,7 @@ getDefaultACLs(Archive *fout, int *numDefaultACLs) daclinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_defaclobjtype)); if (nspid != InvalidOid) - daclinfo[i].dobj.namespace = findNamespace(fout, nspid); + daclinfo[i].dobj.namespace = findNamespace(nspid); else daclinfo[i].dobj.namespace = NULL; @@ -12655,7 +12640,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) pg_log_warning("postfix operators are not supported anymore (operator \"%s\")", oprcode); - oprregproc = convertRegProcReference(fout, oprcode); + oprregproc = convertRegProcReference(oprcode); if (oprregproc) { appendPQExpBuffer(details, " FUNCTION = %s", oprregproc); @@ -12688,14 +12673,14 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) else appendPQExpBufferStr(oprid, ", NONE)"); - oprref = getFormattedOperatorName(fout, oprcom); + oprref = getFormattedOperatorName(oprcom); if (oprref) { appendPQExpBuffer(details, ",\n COMMUTATOR = %s", oprref); free(oprref); } - oprref = getFormattedOperatorName(fout, oprnegate); + oprref = getFormattedOperatorName(oprnegate); if (oprref) { appendPQExpBuffer(details, ",\n NEGATOR = %s", oprref); @@ -12708,14 +12693,14 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) if (strcmp(oprcanhash, "t") == 0) appendPQExpBufferStr(details, ",\n HASHES"); - oprregproc = convertRegProcReference(fout, oprrest); + oprregproc = convertRegProcReference(oprrest); if (oprregproc) { appendPQExpBuffer(details, ",\n RESTRICT = %s", oprregproc); free(oprregproc); } - oprregproc = convertRegProcReference(fout, oprjoin); + oprregproc = convertRegProcReference(oprjoin); if (oprregproc) { appendPQExpBuffer(details, ",\n JOIN = %s", oprregproc); @@ -12770,7 +12755,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) * part. */ static char * -convertRegProcReference(Archive *fout, const char *proc) +convertRegProcReference(const char *proc) { char *name; char *paren; @@ -12811,7 +12796,7 @@ convertRegProcReference(Archive *fout, const char *proc) * are in different schemas. */ static char * -getFormattedOperatorName(Archive *fout, const char *oproid) +getFormattedOperatorName(const char *oproid) { OprInfo *oprInfo; @@ -14121,7 +14106,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) } } - aggsortconvop = getFormattedOperatorName(fout, aggsortop); + aggsortconvop = getFormattedOperatorName(aggsortop); if (aggsortconvop) { appendPQExpBuffer(details, ",\n SORTOP = %s", diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 219ca963c3..2fa11745cc 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -1614,7 +1614,7 @@ buildShSecLabels(PGconn *conn, const char *catalog_name, Oid objectId, PQExpBuffer sql = createPQExpBuffer(); PGresult *res; - buildShSecLabelQuery(conn, catalog_name, objectId, sql); + buildShSecLabelQuery(catalog_name, objectId, sql); res = executeQuery(conn, sql->data); emitShSecLabels(conn, res, buffer, objtype, objname);