mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Teach pg_dump about the new pg_subscription.subrunasowner option.
Among numerous other oversights, commit 482675987 neglected to fix pg_dump to dump this new subscription option. Since the new default is "false" while the previous behavior corresponds to "true", this would cause legacy subscriptions to silently change behavior during dump/reload or pg_upgrade. That seems like a bad idea. Even if it was intended, failing to preserve the option once set in a new installation is certainly not OK. While here, reorder associated stanzas in pg_dump to match the field order in pg_subscription, in hopes of reducing the impression that all this code was written with the aid of a dartboard. Back-patch to v16 where this new field was added. Philip Warner (cosmetic tweaks by me) Discussion: https://postgr.es/m/20231027042539.01A3A220F0A@thebes.rime.com.au
This commit is contained in:
parent
ab73a37e9e
commit
67738dbf9c
@ -4583,16 +4583,17 @@ getSubscriptions(Archive *fout)
|
|||||||
int i_oid;
|
int i_oid;
|
||||||
int i_subname;
|
int i_subname;
|
||||||
int i_subowner;
|
int i_subowner;
|
||||||
|
int i_subbinary;
|
||||||
int i_substream;
|
int i_substream;
|
||||||
int i_subtwophasestate;
|
int i_subtwophasestate;
|
||||||
int i_subdisableonerr;
|
int i_subdisableonerr;
|
||||||
int i_suborigin;
|
int i_subpasswordrequired;
|
||||||
|
int i_subrunasowner;
|
||||||
int i_subconninfo;
|
int i_subconninfo;
|
||||||
int i_subslotname;
|
int i_subslotname;
|
||||||
int i_subsynccommit;
|
int i_subsynccommit;
|
||||||
int i_subpublications;
|
int i_subpublications;
|
||||||
int i_subbinary;
|
int i_suborigin;
|
||||||
int i_subpasswordrequired;
|
|
||||||
int i,
|
int i,
|
||||||
ntups;
|
ntups;
|
||||||
|
|
||||||
@ -4646,12 +4647,14 @@ getSubscriptions(Archive *fout)
|
|||||||
|
|
||||||
if (fout->remoteVersion >= 160000)
|
if (fout->remoteVersion >= 160000)
|
||||||
appendPQExpBufferStr(query,
|
appendPQExpBufferStr(query,
|
||||||
" s.suborigin,\n"
|
" s.subpasswordrequired,\n"
|
||||||
" s.subpasswordrequired\n");
|
" s.subrunasowner,\n"
|
||||||
|
" s.suborigin\n");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(query,
|
appendPQExpBuffer(query,
|
||||||
" '%s' AS suborigin,\n"
|
" 't' AS subpasswordrequired,\n"
|
||||||
" 't' AS subpasswordrequired\n",
|
" 't' AS subrunasowner,\n"
|
||||||
|
" '%s' AS suborigin\n",
|
||||||
LOGICALREP_ORIGIN_ANY);
|
LOGICALREP_ORIGIN_ANY);
|
||||||
|
|
||||||
appendPQExpBufferStr(query,
|
appendPQExpBufferStr(query,
|
||||||
@ -4671,16 +4674,17 @@ getSubscriptions(Archive *fout)
|
|||||||
i_oid = PQfnumber(res, "oid");
|
i_oid = PQfnumber(res, "oid");
|
||||||
i_subname = PQfnumber(res, "subname");
|
i_subname = PQfnumber(res, "subname");
|
||||||
i_subowner = PQfnumber(res, "subowner");
|
i_subowner = PQfnumber(res, "subowner");
|
||||||
i_subconninfo = PQfnumber(res, "subconninfo");
|
|
||||||
i_subslotname = PQfnumber(res, "subslotname");
|
|
||||||
i_subsynccommit = PQfnumber(res, "subsynccommit");
|
|
||||||
i_subpublications = PQfnumber(res, "subpublications");
|
|
||||||
i_subbinary = PQfnumber(res, "subbinary");
|
i_subbinary = PQfnumber(res, "subbinary");
|
||||||
i_substream = PQfnumber(res, "substream");
|
i_substream = PQfnumber(res, "substream");
|
||||||
i_subtwophasestate = PQfnumber(res, "subtwophasestate");
|
i_subtwophasestate = PQfnumber(res, "subtwophasestate");
|
||||||
i_subdisableonerr = PQfnumber(res, "subdisableonerr");
|
i_subdisableonerr = PQfnumber(res, "subdisableonerr");
|
||||||
i_suborigin = PQfnumber(res, "suborigin");
|
|
||||||
i_subpasswordrequired = PQfnumber(res, "subpasswordrequired");
|
i_subpasswordrequired = PQfnumber(res, "subpasswordrequired");
|
||||||
|
i_subrunasowner = PQfnumber(res, "subrunasowner");
|
||||||
|
i_subconninfo = PQfnumber(res, "subconninfo");
|
||||||
|
i_subslotname = PQfnumber(res, "subslotname");
|
||||||
|
i_subsynccommit = PQfnumber(res, "subsynccommit");
|
||||||
|
i_subpublications = PQfnumber(res, "subpublications");
|
||||||
|
i_suborigin = PQfnumber(res, "suborigin");
|
||||||
|
|
||||||
subinfo = pg_malloc(ntups * sizeof(SubscriptionInfo));
|
subinfo = pg_malloc(ntups * sizeof(SubscriptionInfo));
|
||||||
|
|
||||||
@ -4693,15 +4697,7 @@ getSubscriptions(Archive *fout)
|
|||||||
AssignDumpId(&subinfo[i].dobj);
|
AssignDumpId(&subinfo[i].dobj);
|
||||||
subinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_subname));
|
subinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_subname));
|
||||||
subinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_subowner));
|
subinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_subowner));
|
||||||
subinfo[i].subconninfo = pg_strdup(PQgetvalue(res, i, i_subconninfo));
|
|
||||||
if (PQgetisnull(res, i, i_subslotname))
|
|
||||||
subinfo[i].subslotname = NULL;
|
|
||||||
else
|
|
||||||
subinfo[i].subslotname = pg_strdup(PQgetvalue(res, i, i_subslotname));
|
|
||||||
subinfo[i].subsynccommit =
|
|
||||||
pg_strdup(PQgetvalue(res, i, i_subsynccommit));
|
|
||||||
subinfo[i].subpublications =
|
|
||||||
pg_strdup(PQgetvalue(res, i, i_subpublications));
|
|
||||||
subinfo[i].subbinary =
|
subinfo[i].subbinary =
|
||||||
pg_strdup(PQgetvalue(res, i, i_subbinary));
|
pg_strdup(PQgetvalue(res, i, i_subbinary));
|
||||||
subinfo[i].substream =
|
subinfo[i].substream =
|
||||||
@ -4710,9 +4706,22 @@ getSubscriptions(Archive *fout)
|
|||||||
pg_strdup(PQgetvalue(res, i, i_subtwophasestate));
|
pg_strdup(PQgetvalue(res, i, i_subtwophasestate));
|
||||||
subinfo[i].subdisableonerr =
|
subinfo[i].subdisableonerr =
|
||||||
pg_strdup(PQgetvalue(res, i, i_subdisableonerr));
|
pg_strdup(PQgetvalue(res, i, i_subdisableonerr));
|
||||||
subinfo[i].suborigin = pg_strdup(PQgetvalue(res, i, i_suborigin));
|
|
||||||
subinfo[i].subpasswordrequired =
|
subinfo[i].subpasswordrequired =
|
||||||
pg_strdup(PQgetvalue(res, i, i_subpasswordrequired));
|
pg_strdup(PQgetvalue(res, i, i_subpasswordrequired));
|
||||||
|
subinfo[i].subrunasowner =
|
||||||
|
pg_strdup(PQgetvalue(res, i, i_subrunasowner));
|
||||||
|
subinfo[i].subconninfo =
|
||||||
|
pg_strdup(PQgetvalue(res, i, i_subconninfo));
|
||||||
|
if (PQgetisnull(res, i, i_subslotname))
|
||||||
|
subinfo[i].subslotname = NULL;
|
||||||
|
else
|
||||||
|
subinfo[i].subslotname =
|
||||||
|
pg_strdup(PQgetvalue(res, i, i_subslotname));
|
||||||
|
subinfo[i].subsynccommit =
|
||||||
|
pg_strdup(PQgetvalue(res, i, i_subsynccommit));
|
||||||
|
subinfo[i].subpublications =
|
||||||
|
pg_strdup(PQgetvalue(res, i, i_subpublications));
|
||||||
|
subinfo[i].suborigin = pg_strdup(PQgetvalue(res, i, i_suborigin));
|
||||||
|
|
||||||
/* Decide whether we want to dump it */
|
/* Decide whether we want to dump it */
|
||||||
selectDumpableObject(&(subinfo[i].dobj), fout);
|
selectDumpableObject(&(subinfo[i].dobj), fout);
|
||||||
@ -4788,14 +4797,17 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
|
|||||||
if (strcmp(subinfo->subdisableonerr, "t") == 0)
|
if (strcmp(subinfo->subdisableonerr, "t") == 0)
|
||||||
appendPQExpBufferStr(query, ", disable_on_error = true");
|
appendPQExpBufferStr(query, ", disable_on_error = true");
|
||||||
|
|
||||||
if (pg_strcasecmp(subinfo->suborigin, LOGICALREP_ORIGIN_ANY) != 0)
|
if (strcmp(subinfo->subpasswordrequired, "t") != 0)
|
||||||
appendPQExpBuffer(query, ", origin = %s", subinfo->suborigin);
|
appendPQExpBuffer(query, ", password_required = false");
|
||||||
|
|
||||||
|
if (strcmp(subinfo->subrunasowner, "t") == 0)
|
||||||
|
appendPQExpBufferStr(query, ", run_as_owner = true");
|
||||||
|
|
||||||
if (strcmp(subinfo->subsynccommit, "off") != 0)
|
if (strcmp(subinfo->subsynccommit, "off") != 0)
|
||||||
appendPQExpBuffer(query, ", synchronous_commit = %s", fmtId(subinfo->subsynccommit));
|
appendPQExpBuffer(query, ", synchronous_commit = %s", fmtId(subinfo->subsynccommit));
|
||||||
|
|
||||||
if (strcmp(subinfo->subpasswordrequired, "t") != 0)
|
if (pg_strcasecmp(subinfo->suborigin, LOGICALREP_ORIGIN_ANY) != 0)
|
||||||
appendPQExpBuffer(query, ", password_required = false");
|
appendPQExpBuffer(query, ", origin = %s", subinfo->suborigin);
|
||||||
|
|
||||||
appendPQExpBufferStr(query, ");\n");
|
appendPQExpBufferStr(query, ");\n");
|
||||||
|
|
||||||
|
@ -655,16 +655,17 @@ typedef struct _SubscriptionInfo
|
|||||||
{
|
{
|
||||||
DumpableObject dobj;
|
DumpableObject dobj;
|
||||||
const char *rolname;
|
const char *rolname;
|
||||||
char *subconninfo;
|
|
||||||
char *subslotname;
|
|
||||||
char *subbinary;
|
char *subbinary;
|
||||||
char *substream;
|
char *substream;
|
||||||
char *subtwophasestate;
|
char *subtwophasestate;
|
||||||
char *subdisableonerr;
|
char *subdisableonerr;
|
||||||
char *suborigin;
|
char *subpasswordrequired;
|
||||||
|
char *subrunasowner;
|
||||||
|
char *subconninfo;
|
||||||
|
char *subslotname;
|
||||||
char *subsynccommit;
|
char *subsynccommit;
|
||||||
char *subpublications;
|
char *subpublications;
|
||||||
char *subpasswordrequired;
|
char *suborigin;
|
||||||
} SubscriptionInfo;
|
} SubscriptionInfo;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user