Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ba4cc3

Browse files
committed
Teach pg_dump about the new pg_subscription.subrunasowner option.
Among numerous other oversights, commit4826759 neglected to fixpg_dump to dump this new subscription option. Since the new defaultis "false" while the previous behavior corresponds to "true", thiswould cause legacy subscriptions to silently change behavior duringdump/reload or pg_upgrade. That seems like a bad idea. Even if itwas intended, failing to preserve the option once set in a newinstallation is certainly not OK.While here, reorder associated stanzas in pg_dump to match thefield order in pg_subscription, in hopes of reducing the impressionthat 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
1 parentb2d5544 commit5ba4cc3

File tree

2 files changed

+43
-30
lines changed

2 files changed

+43
-30
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4596,16 +4596,17 @@ getSubscriptions(Archive *fout)
45964596
inti_oid;
45974597
inti_subname;
45984598
inti_subowner;
4599+
inti_subbinary;
45994600
inti_substream;
46004601
inti_subtwophasestate;
46014602
inti_subdisableonerr;
4602-
inti_suborigin;
4603+
inti_subpasswordrequired;
4604+
inti_subrunasowner;
46034605
inti_subconninfo;
46044606
inti_subslotname;
46054607
inti_subsynccommit;
46064608
inti_subpublications;
4607-
inti_subbinary;
4608-
inti_subpasswordrequired;
4609+
inti_suborigin;
46094610
inti,
46104611
ntups;
46114612

@@ -4659,12 +4660,14 @@ getSubscriptions(Archive *fout)
46594660

46604661
if (fout->remoteVersion >= 160000)
46614662
appendPQExpBufferStr(query,
4662-
" s.suborigin,\n"
4663-
" s.subpasswordrequired\n");
4663+
" s.subpasswordrequired,\n"
4664+
" s.subrunasowner,\n"
4665+
" s.suborigin\n");
46644666
else
46654667
appendPQExpBuffer(query,
4666-
" '%s' AS suborigin,\n"
4667-
" 't' AS subpasswordrequired\n",
4668+
" 't' AS subpasswordrequired,\n"
4669+
" 't' AS subrunasowner,\n"
4670+
" '%s' AS suborigin\n",
46684671
LOGICALREP_ORIGIN_ANY);
46694672

46704673
appendPQExpBufferStr(query,
@@ -4684,16 +4687,17 @@ getSubscriptions(Archive *fout)
46844687
i_oid = PQfnumber(res, "oid");
46854688
i_subname = PQfnumber(res, "subname");
46864689
i_subowner = PQfnumber(res, "subowner");
4687-
i_subconninfo = PQfnumber(res, "subconninfo");
4688-
i_subslotname = PQfnumber(res, "subslotname");
4689-
i_subsynccommit = PQfnumber(res, "subsynccommit");
4690-
i_subpublications = PQfnumber(res, "subpublications");
46914690
i_subbinary = PQfnumber(res, "subbinary");
46924691
i_substream = PQfnumber(res, "substream");
46934692
i_subtwophasestate = PQfnumber(res, "subtwophasestate");
46944693
i_subdisableonerr = PQfnumber(res, "subdisableonerr");
4695-
i_suborigin = PQfnumber(res, "suborigin");
46964694
i_subpasswordrequired = PQfnumber(res, "subpasswordrequired");
4695+
i_subrunasowner = PQfnumber(res, "subrunasowner");
4696+
i_subconninfo = PQfnumber(res, "subconninfo");
4697+
i_subslotname = PQfnumber(res, "subslotname");
4698+
i_subsynccommit = PQfnumber(res, "subsynccommit");
4699+
i_subpublications = PQfnumber(res, "subpublications");
4700+
i_suborigin = PQfnumber(res, "suborigin");
46974701

46984702
subinfo = pg_malloc(ntups * sizeof(SubscriptionInfo));
46994703

@@ -4706,15 +4710,7 @@ getSubscriptions(Archive *fout)
47064710
AssignDumpId(&subinfo[i].dobj);
47074711
subinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_subname));
47084712
subinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_subowner));
4709-
subinfo[i].subconninfo = pg_strdup(PQgetvalue(res, i, i_subconninfo));
4710-
if (PQgetisnull(res, i, i_subslotname))
4711-
subinfo[i].subslotname = NULL;
4712-
else
4713-
subinfo[i].subslotname = pg_strdup(PQgetvalue(res, i, i_subslotname));
4714-
subinfo[i].subsynccommit =
4715-
pg_strdup(PQgetvalue(res, i, i_subsynccommit));
4716-
subinfo[i].subpublications =
4717-
pg_strdup(PQgetvalue(res, i, i_subpublications));
4713+
47184714
subinfo[i].subbinary =
47194715
pg_strdup(PQgetvalue(res, i, i_subbinary));
47204716
subinfo[i].substream =
@@ -4723,9 +4719,22 @@ getSubscriptions(Archive *fout)
47234719
pg_strdup(PQgetvalue(res, i, i_subtwophasestate));
47244720
subinfo[i].subdisableonerr =
47254721
pg_strdup(PQgetvalue(res, i, i_subdisableonerr));
4726-
subinfo[i].suborigin = pg_strdup(PQgetvalue(res, i, i_suborigin));
47274722
subinfo[i].subpasswordrequired =
47284723
pg_strdup(PQgetvalue(res, i, i_subpasswordrequired));
4724+
subinfo[i].subrunasowner =
4725+
pg_strdup(PQgetvalue(res, i, i_subrunasowner));
4726+
subinfo[i].subconninfo =
4727+
pg_strdup(PQgetvalue(res, i, i_subconninfo));
4728+
if (PQgetisnull(res, i, i_subslotname))
4729+
subinfo[i].subslotname = NULL;
4730+
else
4731+
subinfo[i].subslotname =
4732+
pg_strdup(PQgetvalue(res, i, i_subslotname));
4733+
subinfo[i].subsynccommit =
4734+
pg_strdup(PQgetvalue(res, i, i_subsynccommit));
4735+
subinfo[i].subpublications =
4736+
pg_strdup(PQgetvalue(res, i, i_subpublications));
4737+
subinfo[i].suborigin = pg_strdup(PQgetvalue(res, i, i_suborigin));
47294738

47304739
/* Decide whether we want to dump it */
47314740
selectDumpableObject(&(subinfo[i].dobj), fout);
@@ -4801,14 +4810,17 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
48014810
if (strcmp(subinfo->subdisableonerr, "t") == 0)
48024811
appendPQExpBufferStr(query, ", disable_on_error = true");
48034812

4804-
if (pg_strcasecmp(subinfo->suborigin, LOGICALREP_ORIGIN_ANY) != 0)
4805-
appendPQExpBuffer(query, ", origin = %s", subinfo->suborigin);
4813+
if (strcmp(subinfo->subpasswordrequired, "t") != 0)
4814+
appendPQExpBuffer(query, ", password_required = false");
4815+
4816+
if (strcmp(subinfo->subrunasowner, "t") == 0)
4817+
appendPQExpBufferStr(query, ", run_as_owner = true");
48064818

48074819
if (strcmp(subinfo->subsynccommit, "off") != 0)
48084820
appendPQExpBuffer(query, ", synchronous_commit = %s", fmtId(subinfo->subsynccommit));
48094821

4810-
if (strcmp(subinfo->subpasswordrequired, "t") != 0)
4811-
appendPQExpBuffer(query, ",password_required =false");
4822+
if (pg_strcasecmp(subinfo->suborigin, LOGICALREP_ORIGIN_ANY) != 0)
4823+
appendPQExpBuffer(query, ",origin =%s", subinfo->suborigin);
48124824

48134825
appendPQExpBufferStr(query, ");\n");
48144826

‎src/bin/pg_dump/pg_dump.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,16 +660,17 @@ typedef struct _SubscriptionInfo
660660
{
661661
DumpableObjectdobj;
662662
constchar*rolname;
663-
char*subconninfo;
664-
char*subslotname;
665663
char*subbinary;
666664
char*substream;
667665
char*subtwophasestate;
668666
char*subdisableonerr;
669-
char*suborigin;
667+
char*subpasswordrequired;
668+
char*subrunasowner;
669+
char*subconninfo;
670+
char*subslotname;
670671
char*subsynccommit;
671672
char*subpublications;
672-
char*subpasswordrequired;
673+
char*suborigin;
673674
}SubscriptionInfo;
674675

675676
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp