PostgreSQL Source Code  git master
relation.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  * relation.c
3  * PostgreSQL logical replication
4  *
5  * Copyright (c) 2016-2020, PostgreSQL Global Development Group
6  *
7  * IDENTIFICATION
8  * src/backend/replication/logical/relation.c
9  *
10  * NOTES
11  * This file contains helper functions for logical replication relation
12  * mapping cache.
13  *
14  *-------------------------------------------------------------------------
15  */
16 
17 #include "postgres.h"
18 
19 #include "access/sysattr.h"
20 #include "access/table.h"
21 #include "catalog/namespace.h"
23 #include "executor/executor.h"
24 #include "nodes/makefuncs.h"
27 #include "utils/builtins.h"
28 #include "utils/inval.h"
29 #include "utils/lsyscache.h"
30 #include "utils/memutils.h"
31 #include "utils/syscache.h"
32 
34 
35 static HTAB *LogicalRepRelMap = NULL;
36 static HTAB *LogicalRepTypMap = NULL;
37 
38 /*
39  * Partition map (LogicalRepPartMap)
40  *
41  * When a partitioned table is used as replication target, replicated
42  * operations are actually performed on its leaf partitions, which requires
43  * the partitions to also be mapped to the remote relation. Parent's entry
44  * (LogicalRepRelMapEntry) cannot be used as-is for all partitions, because
45  * individual partitions may have different attribute numbers, which means
46  * attribute mappings to remote relation's attributes must be maintained
47  * separately for each partition.
48  */
50 static HTAB *LogicalRepPartMap = NULL;
51 typedef struct LogicalRepPartMapEntry
52 {
53  Oid partoid; /* LogicalRepPartMap's key */
56 
57 /*
58  * Relcache invalidation callback for our relation map cache.
59  */
60 static void
62 {
63  LogicalRepRelMapEntry *entry;
64 
65  /* Just to be sure. */
66  if (LogicalRepRelMap == NULL)
67  return;
68 
69  if (reloid != InvalidOid)
70  {
72 
73  hash_seq_init(&status, LogicalRepRelMap);
74 
75  /* TODO, use inverse lookup hashtable? */
76  while ((entry = (LogicalRepRelMapEntry *) hash_seq_search(&status)) != NULL)
77  {
78  if (entry->localreloid == reloid)
79  {
80  entry->localreloid = InvalidOid;
81  hash_seq_term(&status);
82  break;
83  }
84  }
85  }
86  else
87  {
88  /* invalidate all cache entries */
90 
91  hash_seq_init(&status, LogicalRepRelMap);
92 
93  while ((entry = (LogicalRepRelMapEntry *) hash_seq_search(&status)) != NULL)
94  entry->localreloid = InvalidOid;
95  }
96 }
97 
98 /*
99  * Initialize the relation map cache.
100  */
101 static void
103 {
104  HASHCTL ctl;
105 
106  if (!LogicalRepRelMapContext)
107  LogicalRepRelMapContext =
109  "LogicalRepRelMapContext",
111 
112  /* Initialize the relation hash table. */
113  MemSet(&ctl, 0, sizeof(ctl));
114  ctl.keysize = sizeof(LogicalRepRelId);
115  ctl.entrysize = sizeof(LogicalRepRelMapEntry);
117 
118  LogicalRepRelMap = hash_create("logicalrep relation map cache", 128, &ctl,
120 
121  /* Initialize the type hash table. */
122  MemSet(&ctl, 0, sizeof(ctl));
123  ctl.keysize = sizeof(Oid);
124  ctl.entrysize = sizeof(LogicalRepTyp);
126 
127  /* This will usually be small. */
128  LogicalRepTypMap = hash_create("logicalrep type map cache", 2, &ctl,
130 
131  /* Watch for invalidation events. */
133  (Datum) 0);
134 }
135 
136 /*
137  * Free the entry of a relation map cache.
138  */
139 static void
141 {
142  LogicalRepRelation *remoterel;
143 
144  remoterel = &entry->remoterel;
145 
146  pfree(remoterel->nspname);
147  pfree(remoterel->relname);
148 
149  if (remoterel->natts > 0)
150  {
151  int i;
152 
153  for (i = 0; i < remoterel->natts; i++)
154  pfree(remoterel->attnames[i]);
155 
156  pfree(remoterel->attnames);
157  pfree(remoterel->atttyps);
158  }
159  bms_free(remoterel->attkeys);
160 
161  if (entry->attrmap)
162  pfree(entry->attrmap);
163 }
164 
165 /*
166  * Add new entry or update existing entry in the relation map cache.
167  *
168  * Called when new relation mapping is sent by the publisher to update
169  * our expected view of incoming data from said publisher.
170  */
171 void
173 {
174  MemoryContext oldctx;
175  LogicalRepRelMapEntry *entry;
176  bool found;
177  int i;
178 
179  if (LogicalRepRelMap == NULL)
181 
182  /*
183  * HASH_ENTER returns the existing entry if present or creates a new one.
184  */
185  entry = hash_search(LogicalRepRelMap, (void *) &remoterel->remoteid,
186  HASH_ENTER, &found);
187 
188  if (found)
190 
191  memset(entry, 0, sizeof(LogicalRepRelMapEntry));
192 
193  /* Make cached copy of the data */
194  oldctx = MemoryContextSwitchTo(LogicalRepRelMapContext);
195  entry->remoterel.remoteid = remoterel->remoteid;
196  entry->remoterel.nspname = pstrdup(remoterel->nspname);
197  entry->remoterel.relname = pstrdup(remoterel->relname);
198  entry->remoterel.natts = remoterel->natts;
199  entry->remoterel.attnames = palloc(remoterel->natts * sizeof(char *));
200  entry->remoterel.atttyps = palloc(remoterel->natts * sizeof(Oid));
201  for (i = 0; i < remoterel->natts; i++)
202  {
203  entry->remoterel.attnames[i] = pstrdup(remoterel->attnames[i]);
204  entry->remoterel.atttyps[i] = remoterel->atttyps[i];
205  }
206  entry->remoterel.replident = remoterel->replident;
207  entry->remoterel.attkeys = bms_copy(remoterel->attkeys);
208  MemoryContextSwitchTo(oldctx);
209 }
210 
211 /*
212  * Find attribute index in TupleDesc struct by attribute name.
213  *
214  * Returns -1 if not found.
215  */
216 static int
218 {
219  int i;
220 
221  for (i = 0; i < remoterel->natts; i++)
222  {
223  if (strcmp(remoterel->attnames[i], attname) == 0)
224  return i;
225  }
226 
227  return -1;
228 }
229 
230 /*
231  * Open the local relation associated with the remote one.
232  *
233  * Optionally rebuilds the Relcache mapping if it was invalidated
234  * by local DDL.
235  */
238 {
239  LogicalRepRelMapEntry *entry;
240  bool found;
241  Oid relid = InvalidOid;
242  LogicalRepRelation *remoterel;
243 
244  if (LogicalRepRelMap == NULL)
246 
247  /* Search for existing entry. */
248  entry = hash_search(LogicalRepRelMap, (void *) &remoteid,
249  HASH_FIND, &found);
250 
251  if (!found)
252  elog(ERROR, "no relation map entry for remote relation ID %u",
253  remoteid);
254 
255  remoterel = &entry->remoterel;
256 
257  /*
258  * When opening and locking a relation, pending invalidation messages are
259  * processed which can invalidate the relation. We need to update the
260  * local cache both when we are first time accessing the relation and when
261  * the relation is invalidated (aka entry->localreloid is set InvalidOid).
262  */
263  if (!OidIsValid(entry->localreloid))
264  {
265  /* Try to find and lock the relation by name. */
266  relid = RangeVarGetRelid(makeRangeVar(remoterel->nspname,
267  remoterel->relname, -1),
268  lockmode, true);
269  if (!OidIsValid(relid))
270  ereport(ERROR,
271  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
272  errmsg("logical replication target relation \"%s.%s\" does not exist",
273  remoterel->nspname, remoterel->relname)));
274  entry->localrel = table_open(relid, NoLock);
275 
276  }
277  else
278  {
279  relid = entry->localreloid;
280  entry->localrel = table_open(entry->localreloid, lockmode);
281  }
282 
283  if (!OidIsValid(entry->localreloid))
284  {
285  int found;
286  Bitmapset *idkey;
287  TupleDesc desc;
288  MemoryContext oldctx;
289  int i;
290 
291  /* Check for supported relkind. */
292  CheckSubscriptionRelkind(entry->localrel->rd_rel->relkind,
293  remoterel->nspname, remoterel->relname);
294 
295  /*
296  * Build the mapping of local attribute numbers to remote attribute
297  * numbers and validate that we don't miss any replicated columns as
298  * that would result in potentially unwanted data loss.
299  */
300  desc = RelationGetDescr(entry->localrel);
301  oldctx = MemoryContextSwitchTo(LogicalRepRelMapContext);
302  entry->attrmap = make_attrmap(desc->natts);
303  MemoryContextSwitchTo(oldctx);
304 
305  found = 0;
306  for (i = 0; i < desc->natts; i++)
307  {
308  int attnum;
309  Form_pg_attribute attr = TupleDescAttr(desc, i);
310 
311  if (attr->attisdropped || attr->attgenerated)
312  {
313  entry->attrmap->attnums[i] = -1;
314  continue;
315  }
316 
317  attnum = logicalrep_rel_att_by_name(remoterel,
318  NameStr(attr->attname));
319 
320  entry->attrmap->attnums[i] = attnum;
321  if (attnum >= 0)
322  found++;
323  }
324 
325  /* TODO, detail message with names of missing columns */
326  if (found < remoterel->natts)
327  ereport(ERROR,
328  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
329  errmsg("logical replication target relation \"%s.%s\" is missing "
330  "some replicated columns",
331  remoterel->nspname, remoterel->relname)));
332 
333  /*
334  * Check that replica identity matches. We allow for stricter replica
335  * identity (fewer columns) on subscriber as that will not stop us
336  * from finding unique tuple. IE, if publisher has identity
337  * (id,timestamp) and subscriber just (id) this will not be a problem,
338  * but in the opposite scenario it will.
339  *
340  * Don't throw any error here just mark the relation entry as not
341  * updatable, as replica identity is only for updates and deletes but
342  * inserts can be replicated even without it.
343  */
344  entry->updatable = true;
345  idkey = RelationGetIndexAttrBitmap(entry->localrel,
347  /* fallback to PK if no replica identity */
348  if (idkey == NULL)
349  {
350  idkey = RelationGetIndexAttrBitmap(entry->localrel,
352 
353  /*
354  * If no replica identity index and no PK, the published table
355  * must have replica identity FULL.
356  */
357  if (idkey == NULL && remoterel->replident != REPLICA_IDENTITY_FULL)
358  entry->updatable = false;
359  }
360 
361  i = -1;
362  while ((i = bms_next_member(idkey, i)) >= 0)
363  {
365 
366  if (!AttrNumberIsForUserDefinedAttr(attnum))
367  ereport(ERROR,
368  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
369  errmsg("logical replication target relation \"%s.%s\" uses "
370  "system columns in REPLICA IDENTITY index",
371  remoterel->nspname, remoterel->relname)));
372 
373  attnum = AttrNumberGetAttrOffset(attnum);
374 
375  if (entry->attrmap->attnums[attnum] < 0 ||
376  !bms_is_member(entry->attrmap->attnums[attnum], remoterel->attkeys))
377  {
378  entry->updatable = false;
379  break;
380  }
381  }
382 
383  entry->localreloid = relid;
384  }
385 
386  if (entry->state != SUBREL_STATE_READY)
388  entry->localreloid,
389  &entry->statelsn,
390  true);
391 
392  return entry;
393 }
394 
395 /*
396  * Close the previously opened logical relation.
397  */
398 void
400 {
401  table_close(rel->localrel, lockmode);
402  rel->localrel = NULL;
403 }
404 
405 /*
406  * Free the type map cache entry data.
407  */
408 static void
410 {
411  pfree(entry->nspname);
412  pfree(entry->typname);
413 }
414 
415 /*
416  * Add new entry or update existing entry in the type map cache.
417  */
418 void
420 {
421  MemoryContext oldctx;
422  LogicalRepTyp *entry;
423  bool found;
424 
425  if (LogicalRepTypMap == NULL)
427 
428  /*
429  * HASH_ENTER returns the existing entry if present or creates a new one.
430  */
431  entry = hash_search(LogicalRepTypMap, (void *) &remotetyp->remoteid,
432  HASH_ENTER, &found);
433 
434  if (found)
436 
437  /* Make cached copy of the data */
438  entry->remoteid = remotetyp->remoteid;
439  oldctx = MemoryContextSwitchTo(LogicalRepRelMapContext);
440  entry->nspname = pstrdup(remotetyp->nspname);
441  entry->typname = pstrdup(remotetyp->typname);
442  MemoryContextSwitchTo(oldctx);
443 }
444 
445 /*
446  * Fetch type name from the cache by remote type OID.
447  *
448  * Return a substitute value if we cannot find the data type; no message is
449  * sent to the log in that case, because this is used by error callback
450  * already.
451  */
452 char *
454 {
455  LogicalRepTyp *entry;
456  bool found;
457 
458  /* Internal types are mapped directly. */
459  if (remoteid < FirstGenbkiObjectId)
460  {
461  if (!get_typisdefined(remoteid))
462  {
463  /*
464  * This can be caused by having a publisher with a higher
465  * PostgreSQL major version than the subscriber.
466  */
467  return psprintf("unrecognized %u", remoteid);
468  }
469 
470  return format_type_be(remoteid);
471  }
472 
473  if (LogicalRepTypMap == NULL)
474  {
475  /*
476  * If the typemap is not initialized yet, we cannot possibly attempt
477  * to search the hash table; but there's no way we know the type
478  * locally yet, since we haven't received a message about this type,
479  * so this is the best we can do.
480  */
481  return psprintf("unrecognized %u", remoteid);
482  }
483 
484  /* search the mapping */
485  entry = hash_search(LogicalRepTypMap, (void *) &remoteid,
486  HASH_FIND, &found);
487  if (!found)
488  return psprintf("unrecognized %u", remoteid);
489 
490  Assert(OidIsValid(entry->remoteid));
491  return psprintf("%s.%s", entry->nspname, entry->typname);
492 }
493 
494 /*
495  * Partition cache: look up partition LogicalRepRelMapEntry's
496  *
497  * Unlike relation map cache, this is keyed by partition OID, not remote
498  * relation OID, because we only have to use this cache in the case where
499  * partitions are not directly mapped to any remote relation, such as when
500  * replication is occurring with one of their ancestors as target.
501  */
502 
503 /*
504  * Relcache invalidation callback
505  */
506 static void
508 {
509  LogicalRepRelMapEntry *entry;
510 
511  /* Just to be sure. */
512  if (LogicalRepPartMap == NULL)
513  return;
514 
515  if (reloid != InvalidOid)
516  {
518 
519  hash_seq_init(&status, LogicalRepPartMap);
520 
521  /* TODO, use inverse lookup hashtable? */
522  while ((entry = (LogicalRepRelMapEntry *) hash_seq_search(&status)) != NULL)
523  {
524  if (entry->localreloid == reloid)
525  {
526  entry->localreloid = InvalidOid;
527  hash_seq_term(&status);
528  break;
529  }
530  }
531  }
532  else
533  {
534  /* invalidate all cache entries */
536 
537  hash_seq_init(&status, LogicalRepPartMap);
538 
539  while ((entry = (LogicalRepRelMapEntry *) hash_seq_search(&status)) != NULL)
540  entry->localreloid = InvalidOid;
541  }
542 }
543 
544 /*
545  * Initialize the partition map cache.
546  */
547 static void
549 {
550  HASHCTL ctl;
551 
552  if (!LogicalRepPartMapContext)
553  LogicalRepPartMapContext =
555  "LogicalRepPartMapContext",
557 
558  /* Initialize the relation hash table. */
559  MemSet(&ctl, 0, sizeof(ctl));
560  ctl.keysize = sizeof(Oid); /* partition OID */
561  ctl.entrysize = sizeof(LogicalRepPartMapEntry);
563 
564  LogicalRepPartMap = hash_create("logicalrep partition map cache", 64, &ctl,
566 
567  /* Watch for invalidation events. */
569  (Datum) 0);
570 }
571 
572 /*
573  * logicalrep_partition_open
574  *
575  * Returned entry reuses most of the values of the root table's entry, save
576  * the attribute map, which can be different for the partition.
577  *
578  * Note there's no logicalrep_partition_close, because the caller closes the
579  * component relation.
580  */
583  Relation partrel, AttrMap *map)
584 {
585  LogicalRepRelMapEntry *entry;
586  LogicalRepPartMapEntry *part_entry;
587  LogicalRepRelation *remoterel = &root->remoterel;
588  Oid partOid = RelationGetRelid(partrel);
589  AttrMap *attrmap = root->attrmap;
590  bool found;
591  int i;
592  MemoryContext oldctx;
593 
594  if (LogicalRepPartMap == NULL)
596 
597  /* Search for existing entry. */
598  part_entry = (LogicalRepPartMapEntry *) hash_search(LogicalRepPartMap,
599  (void *) &partOid,
600  HASH_ENTER, &found);
601 
602  if (found)
603  return &part_entry->relmapentry;
604 
605  memset(part_entry, 0, sizeof(LogicalRepPartMapEntry));
606 
607  /* Switch to longer-lived context. */
608  oldctx = MemoryContextSwitchTo(LogicalRepPartMapContext);
609 
610  part_entry->partoid = partOid;
611 
612  /* Remote relation is used as-is from the root entry. */
613  entry = &part_entry->relmapentry;
614  entry->remoterel.remoteid = remoterel->remoteid;
615  entry->remoterel.nspname = pstrdup(remoterel->nspname);
616  entry->remoterel.relname = pstrdup(remoterel->relname);
617  entry->remoterel.natts = remoterel->natts;
618  entry->remoterel.attnames = palloc(remoterel->natts * sizeof(char *));
619  entry->remoterel.atttyps = palloc(remoterel->natts * sizeof(Oid));
620  for (i = 0; i < remoterel->natts; i++)
621  {
622  entry->remoterel.attnames[i] = pstrdup(remoterel->attnames[i]);
623  entry->remoterel.atttyps[i] = remoterel->atttyps[i];
624  }
625  entry->remoterel.replident = remoterel->replident;
626  entry->remoterel.attkeys = bms_copy(remoterel->attkeys);
627 
628  entry->localrel = partrel;
629  entry->localreloid = partOid;
630 
631  /*
632  * If the partition's attributes don't match the root relation's, we'll
633  * need to make a new attrmap which maps partition attribute numbers to
634  * remoterel's, instead the original which maps root relation's attribute
635  * numbers to remoterel's.
636  *
637  * Note that 'map' which comes from the tuple routing data structure
638  * contains 1-based attribute numbers (of the parent relation). However,
639  * the map in 'entry', a logical replication data structure, contains
640  * 0-based attribute numbers (of the remote relation).
641  */
642  if (map)
643  {
644  AttrNumber attno;
645 
646  entry->attrmap = make_attrmap(map->maplen);
647  for (attno = 0; attno < entry->attrmap->maplen; attno++)
648  {
649  AttrNumber root_attno = map->attnums[attno];
650 
651  entry->attrmap->attnums[attno] = attrmap->attnums[root_attno - 1];
652  }
653  }
654  else
655  entry->attrmap = attrmap;
656 
657  entry->updatable = root->updatable;
658 
659  /* state and statelsn are left set to 0. */
660  MemoryContextSwitchTo(oldctx);
661 
662  return entry;
663 }
Subscription * MySubscription
Definition: worker.c:107
static void logicalrep_relmap_free_entry(LogicalRepRelMapEntry *entry)
Definition: relation.c:140
static void logicalrep_partmap_init(void)
Definition: relation.c:548
#define AllocSetContextCreate
Definition: memutils.h:170
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:133
Bitmapset * bms_copy(const Bitmapset *a)
Definition: bitmapset.c:74
#define HASH_CONTEXT
Definition: hsearch.h:93
char * typname
Definition: logicalproto.h:61
#define HASH_ELEM
Definition: hsearch.h:87
MemoryContext hcxt
Definition: hsearch.h:78
#define RelationGetDescr(relation)
Definition: rel.h:482
int LOCKMODE
Definition: lockdefs.h:26
#define RangeVarGetRelid(relation, lockmode, missing_ok)
Definition: namespace.h:78
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
char * pstrdup(const char *in)
Definition: mcxt.c:1186
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
int bms_next_member(const Bitmapset *a, int prevbit)
Definition: bitmapset.c:1043
struct LogicalRepPartMapEntry LogicalRepPartMapEntry
int maplen
Definition: attmap.h:37
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
Size entrysize
Definition: hsearch.h:73
#define AttrNumberIsForUserDefinedAttr(attributeNumber)
Definition: attnum.h:41
bool get_typisdefined(Oid typid)
Definition: lsyscache.c:2061
int errcode(int sqlerrcode)
Definition: elog.c:610
#define MemSet(start, val, len)
Definition: c.h:971
char * format_type_be(Oid type_oid)
Definition: format_type.c:339
void logicalrep_rel_close(LogicalRepRelMapEntry *rel, LOCKMODE lockmode)
Definition: relation.c:399
#define FirstLowInvalidHeapAttributeNumber
Definition: sysattr.h:27
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:908
Form_pg_class rd_rel
Definition: rel.h:109
unsigned int Oid
Definition: postgres_ext.h:31
static HTAB * LogicalRepTypMap
Definition: relation.c:36
#define OidIsValid(objectId)
Definition: c.h:644
Bitmapset * attkeys
Definition: logicalproto.h:53
Definition: attmap.h:34
LogicalRepRelId remoteid
Definition: logicalproto.h:45
void CacheRegisterRelcacheCallback(RelcacheCallbackFunction func, Datum arg)
Definition: inval.c:1468
void logicalrep_relmap_update(LogicalRepRelation *remoterel)
Definition: relation.c:172
Definition: dynahash.c:210
void pfree(void *pointer)
Definition: mcxt.c:1056
#define ERROR
Definition: elog.h:43
NameData attname
Definition: pg_attribute.h:40
static int logicalrep_rel_att_by_name(LogicalRepRelation *remoterel, const char *attname)
Definition: relation.c:217
LogicalRepRelation remoterel
static HTAB * LogicalRepPartMap
Definition: relation.c:50
static void logicalrep_relmap_invalidate_cb(Datum arg, Oid reloid)
Definition: relation.c:61
LogicalRepRelMapEntry relmapentry
Definition: relation.c:54
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:192
#define AttrNumberGetAttrOffset(attNum)
Definition: attnum.h:51
#define NoLock
Definition: lockdefs.h:34
static MemoryContext LogicalRepRelMapContext
Definition: relation.c:33
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void CheckSubscriptionRelkind(char relkind, const char *nspname, const char *relname)
LogicalRepRelMapEntry * logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
Definition: relation.c:237
struct LogicalRepTyp LogicalRepTyp
#define HASH_BLOBS
Definition: hsearch.h:88
struct LogicalRepRelMapEntry LogicalRepRelMapEntry
HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
Definition: dynahash.c:318
uintptr_t Datum
Definition: postgres.h:367
Size keysize
Definition: hsearch.h:72
#define InvalidOid
Definition: postgres_ext.h:36
LogicalRepRelMapEntry * logicalrep_partition_open(LogicalRepRelMapEntry *root, Relation partrel, AttrMap *map)
Definition: relation.c:582
int16 attnum
Definition: pg_attribute.h:79
#define ereport(elevel,...)
Definition: elog.h:144
void bms_free(Bitmapset *a)
Definition: bitmapset.c:208
#define Assert(condition)
Definition: c.h:738
static void logicalrep_partmap_invalidate_cb(Datum arg, Oid reloid)
Definition: relation.c:507
AttrNumber * attnums
Definition: attmap.h:36
void * hash_seq_search(HASH_SEQ_STATUS *status)
Definition: dynahash.c:1391
char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn, bool missing_ok)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
Definition: dynahash.c:1381
AttrMap * make_attrmap(int maplen)
Definition: attmap.c:41
char * logicalrep_typmap_gettypname(Oid remoteid)
Definition: relation.c:453
static MemoryContext LogicalRepPartMapContext
Definition: relation.c:49
#define FirstGenbkiObjectId
Definition: transam.h:153
void * palloc(Size size)
Definition: mcxt.c:949
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define elog(elevel,...)
Definition: elog.h:214
int i
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
Definition: relcache.c:4937
#define NameStr(name)
Definition: c.h:615
void * arg
static void logicalrep_relmap_init(void)
Definition: relation.c:102
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:225
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:427
int16 AttrNumber
Definition: attnum.h:21
#define RelationGetRelid(relation)
Definition: rel.h:456
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
Definition: makefuncs.c:422
static void logicalrep_typmap_free_entry(LogicalRepTyp *entry)
Definition: relation.c:409
void hash_seq_term(HASH_SEQ_STATUS *status)
Definition: dynahash.c:1467
char * nspname
Definition: logicalproto.h:60
void logicalrep_typmap_update(LogicalRepTyp *remotetyp)
Definition: relation.c:419
static HTAB * LogicalRepRelMap
Definition: relation.c:35
uint32 LogicalRepRelId
Definition: logicalproto.h:39
MemoryContext CacheMemoryContext
Definition: mcxt.c:47