50
50
#include "catalog/pg_default_acl_d.h"
51
51
#include "catalog/pg_largeobject_d.h"
52
52
#include "catalog/pg_proc_d.h"
53
- #include "catalog/pg_subscription .h"
53
+ #include "catalog/pg_subscription_d .h"
54
54
#include "catalog/pg_type_d.h"
55
55
#include "common/connect.h"
56
56
#include "common/int.h"
@@ -4968,20 +4968,20 @@ getSubscriptions(Archive *fout)
4968
4968
i_oid = PQfnumber(res, "oid");
4969
4969
i_subname = PQfnumber(res, "subname");
4970
4970
i_subowner = PQfnumber(res, "subowner");
4971
+ i_subenabled = PQfnumber(res, "subenabled");
4971
4972
i_subbinary = PQfnumber(res, "subbinary");
4972
4973
i_substream = PQfnumber(res, "substream");
4973
4974
i_subtwophasestate = PQfnumber(res, "subtwophasestate");
4974
4975
i_subdisableonerr = PQfnumber(res, "subdisableonerr");
4975
4976
i_subpasswordrequired = PQfnumber(res, "subpasswordrequired");
4976
4977
i_subrunasowner = PQfnumber(res, "subrunasowner");
4978
+ i_subfailover = PQfnumber(res, "subfailover");
4977
4979
i_subconninfo = PQfnumber(res, "subconninfo");
4978
4980
i_subslotname = PQfnumber(res, "subslotname");
4979
4981
i_subsynccommit = PQfnumber(res, "subsynccommit");
4980
4982
i_subpublications = PQfnumber(res, "subpublications");
4981
4983
i_suborigin = PQfnumber(res, "suborigin");
4982
4984
i_suboriginremotelsn = PQfnumber(res, "suboriginremotelsn");
4983
- i_subenabled = PQfnumber(res, "subenabled");
4984
- i_subfailover = PQfnumber(res, "subfailover");
4985
4985
4986
4986
subinfo = pg_malloc(ntups * sizeof(SubscriptionInfo));
4987
4987
@@ -4995,18 +4995,20 @@ getSubscriptions(Archive *fout)
4995
4995
subinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_subname));
4996
4996
subinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_subowner));
4997
4997
4998
+ subinfo[i].subenabled =
4999
+ (strcmp(PQgetvalue(res, i, i_subenabled), "t") == 0);
4998
5000
subinfo[i].subbinary =
4999
- pg_strdup(PQgetvalue(res, i, i_subbinary));
5000
- subinfo[i].substream =
5001
- pg_strdup(PQgetvalue(res, i, i_substream));
5002
- subinfo[i].subtwophasestate =
5003
- pg_strdup(PQgetvalue(res, i, i_subtwophasestate));
5001
+ (strcmp(PQgetvalue(res, i, i_subbinary), "t") == 0);
5002
+ subinfo[i].substream = *(PQgetvalue(res, i, i_substream));
5003
+ subinfo[i].subtwophasestate = *(PQgetvalue(res, i, i_subtwophasestate));
5004
5004
subinfo[i].subdisableonerr =
5005
- pg_strdup( PQgetvalue(res, i, i_subdisableonerr));
5005
+ (strcmp( PQgetvalue(res, i, i_subdisableonerr), "t") == 0 );
5006
5006
subinfo[i].subpasswordrequired =
5007
- pg_strdup( PQgetvalue(res, i, i_subpasswordrequired));
5007
+ (strcmp( PQgetvalue(res, i, i_subpasswordrequired), "t") == 0 );
5008
5008
subinfo[i].subrunasowner =
5009
- pg_strdup(PQgetvalue(res, i, i_subrunasowner));
5009
+ (strcmp(PQgetvalue(res, i, i_subrunasowner), "t") == 0);
5010
+ subinfo[i].subfailover =
5011
+ (strcmp(PQgetvalue(res, i, i_subfailover), "t") == 0);
5010
5012
subinfo[i].subconninfo =
5011
5013
pg_strdup(PQgetvalue(res, i, i_subconninfo));
5012
5014
if (PQgetisnull(res, i, i_subslotname))
@@ -5024,10 +5026,6 @@ getSubscriptions(Archive *fout)
5024
5026
else
5025
5027
subinfo[i].suboriginremotelsn =
5026
5028
pg_strdup(PQgetvalue(res, i, i_suboriginremotelsn));
5027
- subinfo[i].subenabled =
5028
- pg_strdup(PQgetvalue(res, i, i_subenabled));
5029
- subinfo[i].subfailover =
5030
- pg_strdup(PQgetvalue(res, i, i_subfailover));
5031
5029
5032
5030
/* Decide whether we want to dump it */
5033
5031
selectDumpableObject(&(subinfo[i].dobj), fout);
@@ -5208,7 +5206,6 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
5208
5206
char **pubnames = NULL;
5209
5207
int npubnames = 0;
5210
5208
int i;
5211
- char two_phase_disabled[] = {LOGICALREP_TWOPHASE_STATE_DISABLED, '\0'};
5212
5209
5213
5210
/* Do nothing if not dumping schema */
5214
5211
if (!dopt->dumpSchema)
@@ -5245,29 +5242,29 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
5245
5242
else
5246
5243
appendPQExpBufferStr(query, "NONE");
5247
5244
5248
- if (strcmp( subinfo->subbinary, "t") == 0 )
5245
+ if (subinfo->subbinary)
5249
5246
appendPQExpBufferStr(query, ", binary = true");
5250
5247
5251
- if (strcmp( subinfo->substream, "t") == 0 )
5248
+ if (subinfo->substream == LOGICALREP_STREAM_ON )
5252
5249
appendPQExpBufferStr(query, ", streaming = on");
5253
- else if (strcmp( subinfo->substream, "p") == 0 )
5250
+ else if (subinfo->substream == LOGICALREP_STREAM_PARALLEL )
5254
5251
appendPQExpBufferStr(query, ", streaming = parallel");
5255
5252
else
5256
5253
appendPQExpBufferStr(query, ", streaming = off");
5257
5254
5258
- if (strcmp( subinfo->subtwophasestate, two_phase_disabled) != 0 )
5255
+ if (subinfo->subtwophasestate != LOGICALREP_TWOPHASE_STATE_DISABLED )
5259
5256
appendPQExpBufferStr(query, ", two_phase = on");
5260
5257
5261
- if (strcmp( subinfo->subdisableonerr, "t") == 0 )
5258
+ if (subinfo->subdisableonerr)
5262
5259
appendPQExpBufferStr(query, ", disable_on_error = true");
5263
5260
5264
- if (strcmp( subinfo->subpasswordrequired, "t") != 0 )
5261
+ if (! subinfo->subpasswordrequired)
5265
5262
appendPQExpBuffer(query, ", password_required = false");
5266
5263
5267
- if (strcmp( subinfo->subrunasowner, "t") == 0 )
5264
+ if (subinfo->subrunasowner)
5268
5265
appendPQExpBufferStr(query, ", run_as_owner = true");
5269
5266
5270
- if (strcmp( subinfo->subfailover, "t") == 0 )
5267
+ if (subinfo->subfailover)
5271
5268
appendPQExpBufferStr(query, ", failover = true");
5272
5269
5273
5270
if (strcmp(subinfo->subsynccommit, "off") != 0)
@@ -5303,7 +5300,7 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
5303
5300
appendPQExpBuffer(query, ", '%s');\n", subinfo->suboriginremotelsn);
5304
5301
}
5305
5302
5306
- if (strcmp( subinfo->subenabled, "t") == 0 )
5303
+ if (subinfo->subenabled)
5307
5304
{
5308
5305
/*
5309
5306
* Enable the subscription to allow the replication to continue
0 commit comments