29#include "utils/fmgroids.h"
48 foreach(lc, publications)
87 elog(
ERROR,
"cache lookup failed for subscription %u", subid);
94 sub->
dbid = subform->subdbid;
95 sub->
skiplsn = subform->subskiplsn;
97 sub->
owner = subform->subowner;
98 sub->
enabled = subform->subenabled;
99 sub->
binary = subform->subbinary;
100 sub->
stream = subform->substream;
105 sub->
failover = subform->subfailover;
110 Anum_pg_subscription_subconninfo);
116 Anum_pg_subscription_subslotname,
126 Anum_pg_subscription_subsynccommit);
132 Anum_pg_subscription_subpublications);
138 Anum_pg_subscription_suborigin);
165 Anum_pg_subscription_subdbid,
203 bool nulls[Natts_pg_subscription];
204 bool replaces[Natts_pg_subscription];
213 elog(
ERROR,
"cache lookup failed for subscription %u", subid);
219 memset(nulls,
false,
sizeof(nulls));
220 memset(replaces,
false,
sizeof(replaces));
224 replaces[Anum_pg_subscription_subenabled - 1] =
true;
253 for (
i = 0;
i < nelems;
i++)
272 bool nulls[Natts_pg_subscription_rel];
284 elog(
ERROR,
"subscription table %u in subscription %u already exists",
289 memset(nulls,
false,
sizeof(nulls));
296 nulls[Anum_pg_subscription_rel_srsublsn - 1] =
true;
326 bool nulls[Natts_pg_subscription_rel];
328 bool replaces[Natts_pg_subscription_rel];
339 elog(
ERROR,
"subscription table %u in subscription %u does not exist",
344 memset(nulls,
false,
sizeof(nulls));
345 memset(replaces,
false,
sizeof(replaces));
347 replaces[Anum_pg_subscription_rel_srsubstate - 1] =
true;
350 replaces[Anum_pg_subscription_rel_srsublsn - 1] =
true;
354 nulls[Anum_pg_subscription_rel_srsublsn - 1] =
true;
395 return SUBREL_STATE_UNKNOWN;
403 Anum_pg_subscription_rel_srsublsn, &isnull);
435 Anum_pg_subscription_rel_srsubid,
444 Anum_pg_subscription_rel_srrelid,
465 if (!
OidIsValid(subid) && subrel->srsubstate != SUBREL_STATE_READY)
468 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
469 errmsg(
"could not drop relation mapping for subscription \"%s\"",
471 errdetail(
"Table synchronization for relation \"%s\" is in progress and is in state \"%c\".",
478 errhint(
"Use %s to enable subscription if not already enabled or use %s to drop the subscription.",
479 "ALTER SUBSCRIPTION ... ENABLE",
480 "DROP SUBSCRIPTION ...")));
507 Anum_pg_subscription_rel_srsubid,
544 Anum_pg_subscription_rel_srsubid,
550 Anum_pg_subscription_rel_srsubstate,
567 relstate->
relid = subrel->srrelid;
568 relstate->
state = subrel->srsubstate;
570 Anum_pg_subscription_rel_srsublsn, &isnull);
#define DatumGetArrayTypeP(X)
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
static Datum values[MAXATTR]
#define TextDatumGetCString(d)
#define Assert(condition)
#define OidIsValid(objectId)
static void PGresult * res
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
List * lappend(List *list, void *datum)
void list_free_deep(List *list)
void LockSharedObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
void UnlockSharedObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
char * get_rel_name(Oid relid)
char * get_subscription_name(Oid subid, bool missing_ok)
char * pstrdup(const char *in)
void pfree(void *pointer)
static Datum LSNGetDatum(XLogRecPtr X)
static XLogRecPtr DatumGetLSN(Datum X)
List * GetSubscriptionRelations(Oid subid, bool not_ready)
int CountDBSubscriptions(Oid dbid)
void FreeSubscription(Subscription *sub)
void DisableSubscription(Oid subid)
void RemoveSubscriptionRel(Oid subid, Oid relid)
char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn)
void GetPublicationsStr(List *publications, StringInfo dest, bool quote_literal)
void AddSubscriptionRelState(Oid subid, Oid relid, char state, XLogRecPtr sublsn, bool retain_lock)
void UpdateSubscriptionRelState(Oid subid, Oid relid, char state, XLogRecPtr sublsn)
static List * textarray_to_stringlist(ArrayType *textarray)
bool HasSubscriptionRelations(Oid subid)
Subscription * GetSubscription(Oid subid, bool missing_ok)
FormData_pg_subscription * Form_pg_subscription
FormData_pg_subscription_rel * Form_pg_subscription_rel
static Name DatumGetName(Datum X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Datum CharGetDatum(char X)
char * quote_literal_cstr(const char *rawstr)
Datum quote_literal(PG_FUNCTION_ARGS)
#define RelationGetDescr(relation)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
#define BTEqualStrategyNumber
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
bool superuser_arg(Oid roleid)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
#define SearchSysCacheCopy1(cacheId, key1)
#define SearchSysCacheCopy2(cacheId, key1, key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TableScanDesc table_beginscan_catalog(Relation relation, int nkeys, struct ScanKeyData *key)
static void table_endscan(TableScanDesc scan)
String * makeString(char *str)
#define InvalidXLogRecPtr