#include "catalog/pg_default_acl_d.h"
#include "catalog/pg_largeobject_d.h"
#include "catalog/pg_proc_d.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_subscription_d.h"
#include "catalog/pg_type_d.h"
#include "common/connect.h"
#include "common/int.h"
i_oid = PQfnumber(res, "oid");
i_subname = PQfnumber(res, "subname");
i_subowner = PQfnumber(res, "subowner");
+ i_subenabled = PQfnumber(res, "subenabled");
i_subbinary = PQfnumber(res, "subbinary");
i_substream = PQfnumber(res, "substream");
i_subtwophasestate = PQfnumber(res, "subtwophasestate");
i_subdisableonerr = PQfnumber(res, "subdisableonerr");
i_subpasswordrequired = PQfnumber(res, "subpasswordrequired");
i_subrunasowner = PQfnumber(res, "subrunasowner");
+ i_subfailover = PQfnumber(res, "subfailover");
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");
i_suboriginremotelsn = PQfnumber(res, "suboriginremotelsn");
- i_subenabled = PQfnumber(res, "subenabled");
- i_subfailover = PQfnumber(res, "subfailover");
subinfo = pg_malloc(ntups * sizeof(SubscriptionInfo));
subinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_subname));
subinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_subowner));
+ subinfo[i].subenabled =
+ (strcmp(PQgetvalue(res, i, i_subenabled), "t") == 0);
subinfo[i].subbinary =
- pg_strdup(PQgetvalue(res, i, i_subbinary));
- subinfo[i].substream =
- pg_strdup(PQgetvalue(res, i, i_substream));
- subinfo[i].subtwophasestate =
- pg_strdup(PQgetvalue(res, i, i_subtwophasestate));
+ (strcmp(PQgetvalue(res, i, i_subbinary), "t") == 0);
+ subinfo[i].substream = *(PQgetvalue(res, i, i_substream));
+ subinfo[i].subtwophasestate = *(PQgetvalue(res, i, i_subtwophasestate));
subinfo[i].subdisableonerr =
- pg_strdup(PQgetvalue(res, i, i_subdisableonerr));
+ (strcmp(PQgetvalue(res, i, i_subdisableonerr), "t") == 0);
subinfo[i].subpasswordrequired =
- pg_strdup(PQgetvalue(res, i, i_subpasswordrequired));
+ (strcmp(PQgetvalue(res, i, i_subpasswordrequired), "t") == 0);
subinfo[i].subrunasowner =
- pg_strdup(PQgetvalue(res, i, i_subrunasowner));
+ (strcmp(PQgetvalue(res, i, i_subrunasowner), "t") == 0);
+ subinfo[i].subfailover =
+ (strcmp(PQgetvalue(res, i, i_subfailover), "t") == 0);
subinfo[i].subconninfo =
pg_strdup(PQgetvalue(res, i, i_subconninfo));
if (PQgetisnull(res, i, i_subslotname))
else
subinfo[i].suboriginremotelsn =
pg_strdup(PQgetvalue(res, i, i_suboriginremotelsn));
- subinfo[i].subenabled =
- pg_strdup(PQgetvalue(res, i, i_subenabled));
- subinfo[i].subfailover =
- pg_strdup(PQgetvalue(res, i, i_subfailover));
/* Decide whether we want to dump it */
selectDumpableObject(&(subinfo[i].dobj), fout);
char **pubnames = NULL;
int npubnames = 0;
int i;
- char two_phase_disabled[] = {LOGICALREP_TWOPHASE_STATE_DISABLED, '\0'};
/* Do nothing if not dumping schema */
if (!dopt->dumpSchema)
else
appendPQExpBufferStr(query, "NONE");
- if (strcmp(subinfo->subbinary, "t") == 0)
+ if (subinfo->subbinary)
appendPQExpBufferStr(query, ", binary = true");
- if (strcmp(subinfo->substream, "t") == 0)
+ if (subinfo->substream == LOGICALREP_STREAM_ON)
appendPQExpBufferStr(query, ", streaming = on");
- else if (strcmp(subinfo->substream, "p") == 0)
+ else if (subinfo->substream == LOGICALREP_STREAM_PARALLEL)
appendPQExpBufferStr(query, ", streaming = parallel");
else
appendPQExpBufferStr(query, ", streaming = off");
- if (strcmp(subinfo->subtwophasestate, two_phase_disabled) != 0)
+ if (subinfo->subtwophasestate != LOGICALREP_TWOPHASE_STATE_DISABLED)
appendPQExpBufferStr(query, ", two_phase = on");
- if (strcmp(subinfo->subdisableonerr, "t") == 0)
+ if (subinfo->subdisableonerr)
appendPQExpBufferStr(query, ", disable_on_error = true");
- if (strcmp(subinfo->subpasswordrequired, "t") != 0)
+ if (!subinfo->subpasswordrequired)
appendPQExpBuffer(query, ", password_required = false");
- if (strcmp(subinfo->subrunasowner, "t") == 0)
+ if (subinfo->subrunasowner)
appendPQExpBufferStr(query, ", run_as_owner = true");
- if (strcmp(subinfo->subfailover, "t") == 0)
+ if (subinfo->subfailover)
appendPQExpBufferStr(query, ", failover = true");
if (strcmp(subinfo->subsynccommit, "off") != 0)
appendPQExpBuffer(query, ", '%s');\n", subinfo->suboriginremotelsn);
}
- if (strcmp(subinfo->subenabled, "t") == 0)
+ if (subinfo->subenabled)
{
/*
* Enable the subscription to allow the replication to continue
#include "lib/stringinfo.h"
#include "nodes/pg_list.h"
-/*
- * two_phase tri-state values. See comments atop worker.c to know more about
- * these states.
- */
-#define LOGICALREP_TWOPHASE_STATE_DISABLED 'd'
-#define LOGICALREP_TWOPHASE_STATE_PENDING 'p'
-#define LOGICALREP_TWOPHASE_STATE_ENABLED 'e'
-
-/*
- * The subscription will request the publisher to only send changes that do not
- * have any origin.
- */
-#define LOGICALREP_ORIGIN_NONE "none"
-
-/*
- * The subscription will request the publisher to send changes regardless
- * of their origin.
- */
-#define LOGICALREP_ORIGIN_ANY "any"
-
/* ----------------
* pg_subscription definition. cpp turns this into
* typedef struct FormData_pg_subscription
* specified origin */
} Subscription;
+#ifdef EXPOSE_TO_CLIENT_CODE
+
+/*
+ * two_phase tri-state values. See comments atop worker.c to know more about
+ * these states.
+ */
+#define LOGICALREP_TWOPHASE_STATE_DISABLED 'd'
+#define LOGICALREP_TWOPHASE_STATE_PENDING 'p'
+#define LOGICALREP_TWOPHASE_STATE_ENABLED 'e'
+
+/*
+ * The subscription will request the publisher to only send changes that do not
+ * have any origin.
+ */
+#define LOGICALREP_ORIGIN_NONE "none"
+
+/*
+ * The subscription will request the publisher to send changes regardless
+ * of their origin.
+ */
+#define LOGICALREP_ORIGIN_ANY "any"
+
/* Disallow streaming in-progress transactions. */
#define LOGICALREP_STREAM_OFF 'f'
*/
#define LOGICALREP_STREAM_PARALLEL 'p'
+#endif /* EXPOSE_TO_CLIENT_CODE */
+
extern Subscription *GetSubscription(Oid subid, bool missing_ok);
extern void FreeSubscription(Subscription *sub);
extern void DisableSubscription(Oid subid);