31 #include "utils/fmgroids.h" 58 elog(
ERROR,
"cache lookup failed for subscription %u", subid);
65 sub->
dbid = subform->subdbid;
67 sub->
owner = subform->subowner;
68 sub->
enabled = subform->subenabled;
69 sub->
binary = subform->subbinary;
70 sub->
stream = subform->substream;
75 Anum_pg_subscription_subconninfo,
83 Anum_pg_subscription_subslotname,
93 Anum_pg_subscription_subsynccommit,
101 Anum_pg_subscription_subpublications,
127 Anum_pg_subscription_subdbid,
173 (
errcode(ERRCODE_UNDEFINED_OBJECT),
174 errmsg(
"subscription \"%s\" does not exist", subname)));
196 elog(
ERROR,
"cache lookup failed for subscription %u", subid);
222 TEXTOID, -1,
false, TYPALIGN_INT,
223 &elems, NULL, &nelems);
228 for (i = 0; i < nelems; i++)
243 bool nulls[Natts_pg_subscription_rel];
255 elog(
ERROR,
"subscription table %u in subscription %u already exists",
259 memset(values, 0,
sizeof(values));
260 memset(nulls,
false,
sizeof(nulls));
263 values[Anum_pg_subscription_rel_srsubstate - 1] =
CharGetDatum(state);
265 values[Anum_pg_subscription_rel_srsublsn - 1] =
LSNGetDatum(sublsn);
267 nulls[Anum_pg_subscription_rel_srsublsn - 1] =
true;
289 bool nulls[Natts_pg_subscription_rel];
291 bool replaces[Natts_pg_subscription_rel];
302 elog(
ERROR,
"subscription table %u in subscription %u does not exist",
306 memset(values, 0,
sizeof(values));
307 memset(nulls,
false,
sizeof(nulls));
308 memset(replaces,
false,
sizeof(replaces));
310 replaces[Anum_pg_subscription_rel_srsubstate - 1] =
true;
311 values[Anum_pg_subscription_rel_srsubstate - 1] =
CharGetDatum(state);
313 replaces[Anum_pg_subscription_rel_srsublsn - 1] =
true;
315 values[Anum_pg_subscription_rel_srsublsn - 1] =
LSNGetDatum(sublsn);
317 nulls[Anum_pg_subscription_rel_srsublsn - 1] =
true;
358 return SUBREL_STATE_UNKNOWN;
366 Anum_pg_subscription_rel_srsublsn, &isnull);
398 Anum_pg_subscription_rel_srsubid,
407 Anum_pg_subscription_rel_srrelid,
428 if (!
OidIsValid(subid) && subrel->srsubstate != SUBREL_STATE_READY)
431 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
432 errmsg(
"could not drop relation mapping for subscription \"%s\"",
434 errdetail(
"Table synchronization for relation \"%s\" is in progress and is in state \"%c\".",
440 errhint(
"Use %s to enable subscription if not already enabled or use %s to drop the subscription.",
441 "ALTER SUBSCRIPTION ... ENABLE",
442 "DROP SUBSCRIPTION ...")));
471 Anum_pg_subscription_rel_srsubid,
488 relstate->
relid = subrel->srrelid;
489 relstate->
state = subrel->srsubstate;
491 Anum_pg_subscription_rel_srsublsn, &isnull);
525 Anum_pg_subscription_rel_srsubid,
530 Anum_pg_subscription_rel_srsubstate,
547 relstate->
relid = subrel->srrelid;
548 relstate->
state = subrel->srsubstate;
550 Anum_pg_subscription_rel_srsublsn, &isnull);
Value * makeString(char *str)
#define InvalidXLogRecPtr
void table_close(Relation relation, LOCKMODE lockmode)
int errhint(const char *fmt,...)
void systable_endscan(SysScanDesc sysscan)
void RemoveSubscriptionRel(Oid subid, Oid relid)
TableScanDesc table_beginscan_catalog(Relation relation, int nkeys, struct ScanKeyData *key)
#define RelationGetDescr(relation)
char * pstrdup(const char *in)
int CountDBSubscriptions(Oid dbid)
int errcode(int sqlerrcode)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
FormData_pg_subscription * Form_pg_subscription
void heap_freetuple(HeapTuple htup)
#define OidIsValid(objectId)
void list_free_deep(List *list)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
char * get_subscription_name(Oid subid, bool missing_ok)
Subscription * GetSubscription(Oid subid, bool missing_ok)
HeapTuple systable_getnext(SysScanDesc sysscan)
void pfree(void *pointer)
#define ObjectIdGetDatum(X)
static List * textarray_to_stringlist(ArrayType *textarray)
void AddSubscriptionRelState(Oid subid, Oid relid, char state, XLogRecPtr sublsn)
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
int errdetail(const char *fmt,...)
List * GetSubscriptionRelations(Oid subid)
#define CStringGetDatum(X)
List * lappend(List *list, void *datum)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define TextDatumGetCString(d)
char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn)
void ReleaseSysCache(HeapTuple tuple)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
void UpdateSubscriptionRelState(Oid subid, Oid relid, char state, XLogRecPtr sublsn)
void LockSharedObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
#define ereport(elevel,...)
Oid get_subscription_oid(const char *subname, bool missing_ok)
#define HeapTupleIsValid(tuple)
FormData_pg_subscription_rel * Form_pg_subscription_rel
#define Assert(condition)
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
void FreeSubscription(Subscription *sub)
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
static void table_endscan(TableScanDesc scan)
static Datum values[MAXATTR]
int errmsg(const char *fmt,...)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
#define SearchSysCacheCopy2(cacheId, key1, key2)
Relation table_open(Oid relationId, LOCKMODE lockmode)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, bool *replIsnull, bool *doReplace)
List * GetSubscriptionNotReadyRelations(Oid subid)
char * get_rel_name(Oid relid)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
#define BTEqualStrategyNumber
#define DatumGetArrayTypeP(X)