48 if (LogicalRepRelMap == NULL)
88 if (!LogicalRepRelMapContext)
89 LogicalRepRelMapContext =
91 "LogicalRepRelMapContext",
95 MemSet(&ctl, 0,
sizeof(ctl));
100 LogicalRepRelMap =
hash_create(
"logicalrep relation map cache", 128, &ctl,
104 MemSet(&ctl, 0,
sizeof(ctl));
110 LogicalRepTypMap =
hash_create(
"logicalrep type map cache", 2, &ctl,
131 if (remoterel->
natts > 0)
135 for (i = 0; i < remoterel->
natts; i++)
161 if (LogicalRepRelMap == NULL)
183 for (i = 0; i < remoterel->
natts; i++)
203 for (i = 0; i < remoterel->
natts; i++)
205 if (strcmp(remoterel->
attnames[i], attname) == 0)
224 if (LogicalRepRelMap == NULL)
228 entry =
hash_search(LogicalRepRelMap, (
void *) &remoteid,
232 elog(
ERROR,
"no relation map entry for remote relation ID %u",
254 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
255 errmsg(
"logical replication target relation \"%s.%s\" does not exist",
274 for (i = 0; i < desc->
natts; i++)
279 if (attr->attisdropped)
294 if (found < remoterel->natts)
296 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
297 errmsg(
"logical replication target relation \"%s.%s\" is missing " 298 "some replicated columns",
325 if (idkey == NULL && remoterel->
replident != REPLICA_IDENTITY_FULL)
336 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
337 errmsg(
"logical replication target relation \"%s.%s\" uses " 338 "system columns in REPLICA IDENTITY index",
355 if (entry->
state != SUBREL_STATE_READY)
394 if (LogicalRepTypMap == NULL)
436 return psprintf(
"unrecognized %u", remoteid);
442 if (LogicalRepTypMap == NULL)
450 return psprintf(
"unrecognized %u", remoteid);
454 entry =
hash_search(LogicalRepTypMap, (
void *) &remoteid,
457 return psprintf(
"unrecognized %u", remoteid);
Subscription * MySubscription
static void logicalrep_relmap_free_entry(LogicalRepRelMapEntry *entry)
Bitmapset * bms_copy(const Bitmapset *a)
#define RelationGetDescr(relation)
#define RangeVarGetRelid(relation, lockmode, missing_ok)
#define TupleDescAttr(tupdesc, i)
char * pstrdup(const char *in)
char * psprintf(const char *fmt,...)
int bms_next_member(const Bitmapset *a, int prevbit)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define AttrNumberIsForUserDefinedAttr(attributeNumber)
bool get_typisdefined(Oid typid)
int errcode(int sqlerrcode)
#define MemSet(start, val, len)
void logicalrep_rel_close(LogicalRepRelMapEntry *rel, LOCKMODE lockmode)
#define FirstLowInvalidHeapAttributeNumber
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
static HTAB * LogicalRepTypMap
#define OidIsValid(objectId)
#define FirstNormalObjectId
void CacheRegisterRelcacheCallback(RelcacheCallbackFunction func, Datum arg)
void logicalrep_relmap_update(LogicalRepRelation *remoterel)
void pfree(void *pointer)
static int logicalrep_rel_att_by_name(LogicalRepRelation *remoterel, const char *attname)
LogicalRepRelation remoterel
static void logicalrep_relmap_invalidate_cb(Datum arg, Oid reloid)
#define ALLOCSET_DEFAULT_SIZES
#define AttrNumberGetAttrOffset(attNum)
static MemoryContext LogicalRepRelMapContext
FormData_pg_attribute * Form_pg_attribute
void CheckSubscriptionRelkind(char relkind, const char *nspname, const char *relname)
LogicalRepRelMapEntry * logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
#define ereport(elevel, rest)
struct LogicalRepTyp LogicalRepTyp
#define AllocSetContextCreate(parent, name, allocparams)
struct LogicalRepRelMapEntry LogicalRepRelMapEntry
HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
Relation heap_open(Oid relationId, LOCKMODE lockmode)
void bms_free(Bitmapset *a)
#define Assert(condition)
void * hash_seq_search(HASH_SEQ_STATUS *status)
char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn, bool missing_ok)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
char * logicalrep_typmap_gettypname(Oid remoteid)
int errmsg(const char *fmt,...)
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
static void logicalrep_relmap_init(void)
static void static void status(const char *fmt,...) pg_attribute_printf(1
bool bms_is_member(int x, const Bitmapset *a)
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
static void logicalrep_typmap_free_entry(LogicalRepTyp *entry)
void hash_seq_term(HASH_SEQ_STATUS *status)
void logicalrep_typmap_update(LogicalRepTyp *remotetyp)
static HTAB * LogicalRepRelMap
MemoryContext CacheMemoryContext