From: Jeff Davis Date: Wed, 18 Mar 2026 16:58:42 +0000 (-0700) Subject: Fix pg_dump for CREATE FOREIGN DATA WRAPPER ... CONNECTION. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b71bf3b8457027c445b5b3aa4914daa7e6718cf4;p=thirdparty%2Fpostgresql.git Fix pg_dump for CREATE FOREIGN DATA WRAPPER ... CONNECTION. Discussion: https://postgr.es/m/7eb0c03b4312b32cb76d340023b39a751745a1f9.camel@j-davis.com --- diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index ad09677c336..955d2294ec0 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -10530,6 +10530,7 @@ getForeignDataWrappers(Archive *fout) int i_fdwowner; int i_fdwhandler; int i_fdwvalidator; + int i_fdwconnection; int i_fdwacl; int i_acldefault; int i_fdwoptions; @@ -10539,7 +10540,14 @@ getForeignDataWrappers(Archive *fout) appendPQExpBufferStr(query, "SELECT tableoid, oid, fdwname, " "fdwowner, " "fdwhandler::pg_catalog.regproc, " - "fdwvalidator::pg_catalog.regproc, " + "fdwvalidator::pg_catalog.regproc, "); + + if (fout->remoteVersion >= 190000) + appendPQExpBufferStr(query, "fdwconnection::pg_catalog.regproc, "); + else + appendPQExpBufferStr(query, "'-' AS fdwconnection, "); + + appendPQExpBufferStr(query, "fdwacl, " "acldefault('F', fdwowner) AS acldefault, " "array_to_string(ARRAY(" @@ -10562,6 +10570,7 @@ getForeignDataWrappers(Archive *fout) i_fdwowner = PQfnumber(res, "fdwowner"); i_fdwhandler = PQfnumber(res, "fdwhandler"); i_fdwvalidator = PQfnumber(res, "fdwvalidator"); + i_fdwconnection = PQfnumber(res, "fdwconnection"); i_fdwacl = PQfnumber(res, "fdwacl"); i_acldefault = PQfnumber(res, "acldefault"); i_fdwoptions = PQfnumber(res, "fdwoptions"); @@ -10581,6 +10590,7 @@ getForeignDataWrappers(Archive *fout) fdwinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_fdwowner)); fdwinfo[i].fdwhandler = pg_strdup(PQgetvalue(res, i, i_fdwhandler)); fdwinfo[i].fdwvalidator = pg_strdup(PQgetvalue(res, i, i_fdwvalidator)); + fdwinfo[i].fdwconnection = pg_strdup(PQgetvalue(res, i, i_fdwconnection)); fdwinfo[i].fdwoptions = pg_strdup(PQgetvalue(res, i, i_fdwoptions)); /* Decide whether we want to dump it */ @@ -16224,6 +16234,9 @@ dumpForeignDataWrapper(Archive *fout, const FdwInfo *fdwinfo) if (strcmp(fdwinfo->fdwvalidator, "-") != 0) appendPQExpBuffer(q, " VALIDATOR %s", fdwinfo->fdwvalidator); + if (strcmp(fdwinfo->fdwconnection, "-") != 0) + appendPQExpBuffer(q, " CONNECTION %s", fdwinfo->fdwconnection); + if (strlen(fdwinfo->fdwoptions) > 0) appendPQExpBuffer(q, " OPTIONS (\n %s\n)", fdwinfo->fdwoptions); diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 2b9c01b2c0a..5a6726d8b12 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -605,6 +605,7 @@ typedef struct _fdwInfo const char *rolname; char *fdwhandler; char *fdwvalidator; + char *fdwconnection; char *fdwoptions; } FdwInfo;