PostgreSQL Source Code  git master
pg_publication.h File Reference
#include "catalog/genbki.h"
#include "catalog/pg_publication_d.h"
#include "catalog/objectaddress.h"
Include dependency graph for pg_publication.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PublicationActions
 
struct  Publication
 

Typedefs

typedef FormData_pg_publicationForm_pg_publication
 
typedef struct PublicationActions PublicationActions
 
typedef struct Publication Publication
 

Functions

 CATALOG (pg_publication, 6104, PublicationRelationId)
 
PublicationGetPublication (Oid pubid)
 
PublicationGetPublicationByName (const char *pubname, bool missing_ok)
 
ListGetRelationPublications (Oid relid)
 
ListGetPublicationRelations (Oid pubid)
 
ListGetAllTablesPublications (void)
 
ListGetAllTablesPublicationRelations (void)
 
bool is_publishable_relation (Relation rel)
 
ObjectAddress publication_add_relation (Oid pubid, Relation targetrel, bool if_not_exists)
 
Oid get_publication_oid (const char *pubname, bool missing_ok)
 
char * get_publication_name (Oid pubid)
 
Datum pg_get_publication_tables (PG_FUNCTION_ARGS)
 

Variables

 FormData_pg_publication
 

Typedef Documentation

◆ Form_pg_publication

◆ Publication

◆ PublicationActions

Function Documentation

◆ CATALOG()

CATALOG ( pg_publication  ,
6104  ,
PublicationRelationId   
)

Definition at line 30 of file pg_publication.h.

31 {
32  NameData pubname; /* name of the publication */
33 
34  Oid pubowner; /* publication owner */
35 
36  /*
37  * indicates that this is special publication which should encompass all
38  * tables in the database (except for the unlogged and temp ones)
39  */
40  bool puballtables;
41 
42  /* true if inserts are published */
43  bool pubinsert;
44 
45  /* true if updates are published */
46  bool pubupdate;
47 
48  /* true if deletes are published */
49  bool pubdelete;
50 
51  /* true if truncates are published */
52  bool pubtruncate;
53 
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_publication
Definition: c.h:570

◆ get_publication_name()

char* get_publication_name ( Oid  pubid)

Definition at line 432 of file pg_publication.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, pstrdup(), PUBLICATIONOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by getObjectDescription(), and getObjectIdentityParts().

433 {
434  HeapTuple tup;
435  char *pubname;
436  Form_pg_publication pubform;
437 
439 
440  if (!HeapTupleIsValid(tup))
441  elog(ERROR, "cache lookup failed for publication %u", pubid);
442 
443  pubform = (Form_pg_publication) GETSTRUCT(tup);
444  pubname = pstrdup(NameStr(pubform->pubname));
445 
446  ReleaseSysCache(tup);
447 
448  return pubname;
449 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:673
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define ObjectIdGetDatum(X)
Definition: postgres.h:490
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:576
#define elog
Definition: elog.h:219
FormData_pg_publication * Form_pg_publication

◆ get_publication_oid()

Oid get_publication_oid ( const char *  pubname,
bool  missing_ok 
)

Definition at line 416 of file pg_publication.c.

References CStringGetDatum, ereport, errcode(), errmsg(), ERROR, GetSysCacheOid1, OidIsValid, and PUBLICATIONNAME.

Referenced by get_object_address_unqualified().

417 {
418  Oid oid;
419 
421  if (!OidIsValid(oid) && !missing_ok)
422  ereport(ERROR,
423  (errcode(ERRCODE_UNDEFINED_OBJECT),
424  errmsg("publication \"%s\" does not exist", pubname)));
425  return oid;
426 }
int errcode(int sqlerrcode)
Definition: elog.c:575
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:605
#define GetSysCacheOid1(cacheId, key1)
Definition: syscache.h:191
#define ERROR
Definition: elog.h:43
#define CStringGetDatum(X)
Definition: postgres.h:561
#define ereport(elevel, rest)
Definition: elog.h:122
int errmsg(const char *fmt,...)
Definition: elog.c:797

◆ GetAllTablesPublicationRelations()

List* GetAllTablesPublicationRelations ( void  )

Definition at line 321 of file pg_publication.c.

References AccessShareLock, BTEqualStrategyNumber, CharGetDatum, ForwardScanDirection, GETSTRUCT, heap_beginscan_catalog(), heap_close, heap_endscan(), heap_getnext(), heap_open(), HeapTupleGetOid, is_publishable_class(), lappend_oid(), NIL, and ScanKeyInit().

Referenced by pg_get_publication_tables().

322 {
323  Relation classRel;
324  ScanKeyData key[1];
325  HeapScanDesc scan;
326  HeapTuple tuple;
327  List *result = NIL;
328 
329  classRel = heap_open(RelationRelationId, AccessShareLock);
330 
331  ScanKeyInit(&key[0],
332  Anum_pg_class_relkind,
333  BTEqualStrategyNumber, F_CHAREQ,
334  CharGetDatum(RELKIND_RELATION));
335 
336  scan = heap_beginscan_catalog(classRel, 1, key);
337 
338  while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
339  {
340  Oid relid = HeapTupleGetOid(tuple);
341  Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
342 
343  if (is_publishable_class(relid, relForm))
344  result = lappend_oid(result, relid);
345  }
346 
347  heap_endscan(scan);
348  heap_close(classRel, AccessShareLock);
349 
350  return result;
351 }
#define NIL
Definition: pg_list.h:69
#define GETSTRUCT(TUP)
Definition: htup_details.h:673
void heap_endscan(HeapScanDesc scan)
Definition: heapam.c:1572
#define AccessShareLock
Definition: lockdefs.h:36
#define heap_close(r, l)
Definition: heapam.h:97
unsigned int Oid
Definition: postgres_ext.h:31
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
HeapScanDesc heap_beginscan_catalog(Relation relation, int nkeys, ScanKey key)
Definition: heapam.c:1412
HeapTuple heap_getnext(HeapScanDesc scan, ScanDirection direction)
Definition: heapam.c:1835
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1294
#define CharGetDatum(X)
Definition: postgres.h:399
FormData_pg_class * Form_pg_class
Definition: pg_class.h:92
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition: scankey.c:76
static bool is_publishable_class(Oid relid, Form_pg_class reltuple)
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:712
Definition: pg_list.h:45
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ GetAllTablesPublications()

List* GetAllTablesPublications ( void  )

Definition at line 288 of file pg_publication.c.

References AccessShareLock, BoolGetDatum, BTEqualStrategyNumber, heap_close, heap_open(), HeapTupleGetOid, HeapTupleIsValid, InvalidOid, lappend_oid(), NIL, ScanKeyInit(), systable_beginscan(), systable_endscan(), and systable_getnext().

Referenced by GetRelationPublicationActions().

289 {
290  List *result;
291  Relation rel;
292  ScanKeyData scankey;
293  SysScanDesc scan;
294  HeapTuple tup;
295 
296  /* Find all publications that are marked as for all tables. */
297  rel = heap_open(PublicationRelationId, AccessShareLock);
298 
299  ScanKeyInit(&scankey,
300  Anum_pg_publication_puballtables,
301  BTEqualStrategyNumber, F_BOOLEQ,
302  BoolGetDatum(true));
303 
304  scan = systable_beginscan(rel, InvalidOid, false,
305  NULL, 1, &scankey);
306 
307  result = NIL;
308  while (HeapTupleIsValid(tup = systable_getnext(scan)))
309  result = lappend_oid(result, HeapTupleGetOid(tup));
310 
311  systable_endscan(scan);
313 
314  return result;
315 }
#define NIL
Definition: pg_list.h:69
void systable_endscan(SysScanDesc sysscan)
Definition: genam.c:502
#define AccessShareLock
Definition: lockdefs.h:36
#define heap_close(r, l)
Definition: heapam.h:97
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition: genam.c:331
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition: genam.c:419
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1294
#define BoolGetDatum(X)
Definition: postgres.h:385
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition: scankey.c:76
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:712
Definition: pg_list.h:45
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ GetPublication()

Publication* GetPublication ( Oid  pubid)

Definition at line 359 of file pg_publication.c.

References Publication::alltables, elog, ERROR, GETSTRUCT, HeapTupleIsValid, Publication::name, NameStr, ObjectIdGetDatum, Publication::oid, palloc(), pstrdup(), Publication::pubactions, PublicationActions::pubdelete, PublicationActions::pubinsert, PUBLICATIONOID, PublicationActions::pubtruncate, PublicationActions::pubupdate, ReleaseSysCache(), and SearchSysCache1().

Referenced by GetPublicationByName(), and publication_add_relation().

360 {
361  HeapTuple tup;
362  Publication *pub;
363  Form_pg_publication pubform;
364 
366 
367  if (!HeapTupleIsValid(tup))
368  elog(ERROR, "cache lookup failed for publication %u", pubid);
369 
370  pubform = (Form_pg_publication) GETSTRUCT(tup);
371 
372  pub = (Publication *) palloc(sizeof(Publication));
373  pub->oid = pubid;
374  pub->name = pstrdup(NameStr(pubform->pubname));
375  pub->alltables = pubform->puballtables;
376  pub->pubactions.pubinsert = pubform->pubinsert;
377  pub->pubactions.pubupdate = pubform->pubupdate;
378  pub->pubactions.pubdelete = pubform->pubdelete;
379  pub->pubactions.pubtruncate = pubform->pubtruncate;
380 
381  ReleaseSysCache(tup);
382 
383  return pub;
384 }
PublicationActions pubactions
#define GETSTRUCT(TUP)
Definition: htup_details.h:673
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define ObjectIdGetDatum(X)
Definition: postgres.h:490
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
void * palloc(Size size)
Definition: mcxt.c:924
#define NameStr(name)
Definition: c.h:576
#define elog
Definition: elog.h:219
FormData_pg_publication * Form_pg_publication

◆ GetPublicationByName()

Publication* GetPublicationByName ( const char *  pubname,
bool  missing_ok 
)

Definition at line 391 of file pg_publication.c.

References CStringGetDatum, ereport, errcode(), errmsg(), ERROR, GetPublication(), GetSysCacheOid1, OidIsValid, and PUBLICATIONNAME.

Referenced by get_object_address_publication_rel(), LoadPublications(), and pg_get_publication_tables().

392 {
393  Oid oid;
394 
396  if (!OidIsValid(oid))
397  {
398  if (missing_ok)
399  return NULL;
400 
401  ereport(ERROR,
402  (errcode(ERRCODE_UNDEFINED_OBJECT),
403  errmsg("publication \"%s\" does not exist", pubname)));
404  }
405 
406  return GetPublication(oid);
407 }
int errcode(int sqlerrcode)
Definition: elog.c:575
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:605
#define GetSysCacheOid1(cacheId, key1)
Definition: syscache.h:191
Publication * GetPublication(Oid pubid)
#define ERROR
Definition: elog.h:43
#define CStringGetDatum(X)
Definition: postgres.h:561
#define ereport(elevel, rest)
Definition: elog.h:122
int errmsg(const char *fmt,...)
Definition: elog.c:797

◆ GetPublicationRelations()

List* GetPublicationRelations ( Oid  pubid)

Definition at line 249 of file pg_publication.c.

References AccessShareLock, BTEqualStrategyNumber, GETSTRUCT, heap_close, heap_open(), HeapTupleIsValid, lappend_oid(), NIL, ObjectIdGetDatum, PublicationRelPrrelidPrpubidIndexId, ScanKeyInit(), systable_beginscan(), systable_endscan(), and systable_getnext().

Referenced by AlterPublicationOptions(), AlterPublicationTables(), and pg_get_publication_tables().

250 {
251  List *result;
252  Relation pubrelsrel;
253  ScanKeyData scankey;
254  SysScanDesc scan;
255  HeapTuple tup;
256 
257  /* Find all publications associated with the relation. */
258  pubrelsrel = heap_open(PublicationRelRelationId, AccessShareLock);
259 
260  ScanKeyInit(&scankey,
261  Anum_pg_publication_rel_prpubid,
262  BTEqualStrategyNumber, F_OIDEQ,
263  ObjectIdGetDatum(pubid));
264 
266  true, NULL, 1, &scankey);
267 
268  result = NIL;
269  while (HeapTupleIsValid(tup = systable_getnext(scan)))
270  {
272 
273  pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
274 
275  result = lappend_oid(result, pubrel->prrelid);
276  }
277 
278  systable_endscan(scan);
279  heap_close(pubrelsrel, AccessShareLock);
280 
281  return result;
282 }
#define NIL
Definition: pg_list.h:69
void systable_endscan(SysScanDesc sysscan)
Definition: genam.c:502
#define GETSTRUCT(TUP)
Definition: htup_details.h:673
#define AccessShareLock
Definition: lockdefs.h:36
#define heap_close(r, l)
Definition: heapam.h:97
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition: genam.c:331
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition: genam.c:419
#define ObjectIdGetDatum(X)
Definition: postgres.h:490
#define PublicationRelPrrelidPrpubidIndexId
Definition: indexing.h:353
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1294
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_publication_rel * Form_pg_publication_rel
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition: scankey.c:76
Definition: pg_list.h:45
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ GetRelationPublications()

List* GetRelationPublications ( Oid  relid)

Definition at line 220 of file pg_publication.c.

References GETSTRUCT, i, lappend_oid(), catclist::members, catclist::n_members, NIL, ObjectIdGetDatum, PUBLICATIONRELMAP, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by ATPrepChangePersistence(), get_rel_sync_entry(), and GetRelationPublicationActions().

221 {
222  List *result = NIL;
223  CatCList *pubrellist;
224  int i;
225 
226  /* Find all publications associated with the relation. */
228  ObjectIdGetDatum(relid));
229  for (i = 0; i < pubrellist->n_members; i++)
230  {
231  HeapTuple tup = &pubrellist->members[i]->tuple;
232  Oid pubid = ((Form_pg_publication_rel) GETSTRUCT(tup))->prpubid;
233 
234  result = lappend_oid(result, pubid);
235  }
236 
237  ReleaseSysCacheList(pubrellist);
238 
239  return result;
240 }
#define NIL
Definition: pg_list.h:69
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:673
unsigned int Oid
Definition: postgres_ext.h:31
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:490
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:209
#define ReleaseSysCacheList(x)
Definition: syscache.h:216
FormData_pg_publication_rel * Form_pg_publication_rel
int i
HeapTupleData tuple
Definition: catcache.h:121
Definition: pg_list.h:45

◆ is_publishable_relation()

bool is_publishable_relation ( Relation  rel)

Definition at line 112 of file pg_publication.c.

References is_publishable_class(), RelationData::rd_rel, and RelationGetRelid.

Referenced by pgoutput_change(), and pgoutput_truncate().

113 {
114  return is_publishable_class(RelationGetRelid(rel), rel->rd_rel);
115 }
Form_pg_class rd_rel
Definition: rel.h:84
static bool is_publishable_class(Oid relid, Form_pg_class reltuple)
#define RelationGetRelid(relation)
Definition: rel.h:407

◆ pg_get_publication_tables()

Datum pg_get_publication_tables ( PG_FUNCTION_ARGS  )

Definition at line 455 of file pg_publication.c.

References Publication::alltables, GetAllTablesPublicationRelations(), GetPublicationByName(), GetPublicationRelations(), lfirst_oid, list_head(), lnext, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, ObjectIdGetDatum, Publication::oid, palloc(), PG_GETARG_TEXT_PP, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, text_to_cstring(), and FuncCallContext::user_fctx.

456 {
457  FuncCallContext *funcctx;
458  char *pubname = text_to_cstring(PG_GETARG_TEXT_PP(0));
459  Publication *publication;
460  List *tables;
461  ListCell **lcp;
462 
463  /* stuff done only on the first call of the function */
464  if (SRF_IS_FIRSTCALL())
465  {
466  MemoryContext oldcontext;
467 
468  /* create a function context for cross-call persistence */
469  funcctx = SRF_FIRSTCALL_INIT();
470 
471  /* switch to memory context appropriate for multiple function calls */
472  oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
473 
474  publication = GetPublicationByName(pubname, false);
475  if (publication->alltables)
477  else
478  tables = GetPublicationRelations(publication->oid);
479  lcp = (ListCell **) palloc(sizeof(ListCell *));
480  *lcp = list_head(tables);
481  funcctx->user_fctx = (void *) lcp;
482 
483  MemoryContextSwitchTo(oldcontext);
484  }
485 
486  /* stuff done on every call of the function */
487  funcctx = SRF_PERCALL_SETUP();
488  lcp = (ListCell **) funcctx->user_fctx;
489 
490  while (*lcp != NULL)
491  {
492  Oid relid = lfirst_oid(*lcp);
493 
494  *lcp = lnext(*lcp);
495  SRF_RETURN_NEXT(funcctx, ObjectIdGetDatum(relid));
496  }
497 
498  SRF_RETURN_DONE(funcctx);
499 }
List * GetAllTablesPublicationRelations(void)
#define SRF_IS_FIRSTCALL()
Definition: funcapi.h:294
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
unsigned int Oid
Definition: postgres_ext.h:31
#define SRF_PERCALL_SETUP()
Definition: funcapi.h:298
Publication * GetPublicationByName(const char *pubname, bool missing_ok)
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:278
#define SRF_RETURN_NEXT(_funcctx, _result)
Definition: funcapi.h:300
#define ObjectIdGetDatum(X)
Definition: postgres.h:490
static ListCell * list_head(const List *l)
Definition: pg_list.h:77
#define lnext(lc)
Definition: pg_list.h:105
List * GetPublicationRelations(Oid pubid)
MemoryContext multi_call_memory_ctx
Definition: funcapi.h:110
char * text_to_cstring(const text *t)
Definition: varlena.c:182
void * user_fctx
Definition: funcapi.h:91
void * palloc(Size size)
Definition: mcxt.c:924
Definition: pg_list.h:45
#define lfirst_oid(lc)
Definition: pg_list.h:108
#define SRF_RETURN_DONE(_funcctx)
Definition: funcapi.h:318
#define SRF_FIRSTCALL_INIT()
Definition: funcapi.h:296

◆ publication_add_relation()

ObjectAddress publication_add_relation ( Oid  pubid,
Relation  targetrel,
bool  if_not_exists 
)

Definition at line 145 of file pg_publication.c.

References CacheInvalidateRelcache(), CatalogTupleInsert(), check_publication_add_relation(), DEPENDENCY_AUTO, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, GetPublication(), heap_close, heap_form_tuple(), heap_freetuple(), heap_open(), InvalidObjectAddress, Publication::name, ObjectAddressSet, ObjectIdGetDatum, PUBLICATIONRELMAP, recordDependencyOn(), RelationGetDescr, RelationGetRelationName, RelationGetRelid, RowExclusiveLock, SearchSysCacheExists2, and values.

Referenced by PublicationAddTables().

147 {
148  Relation rel;
149  HeapTuple tup;
150  Datum values[Natts_pg_publication_rel];
151  bool nulls[Natts_pg_publication_rel];
152  Oid relid = RelationGetRelid(targetrel);
153  Oid prrelid;
154  Publication *pub = GetPublication(pubid);
155  ObjectAddress myself,
156  referenced;
157 
158  rel = heap_open(PublicationRelRelationId, RowExclusiveLock);
159 
160  /*
161  * Check for duplicates. Note that this does not really prevent
162  * duplicates, it's here just to provide nicer error message in common
163  * case. The real protection is the unique key on the catalog.
164  */
166  ObjectIdGetDatum(pubid)))
167  {
169 
170  if (if_not_exists)
171  return InvalidObjectAddress;
172 
173  ereport(ERROR,
175  errmsg("relation \"%s\" is already member of publication \"%s\"",
176  RelationGetRelationName(targetrel), pub->name)));
177  }
178 
180 
181  /* Form a tuple. */
182  memset(values, 0, sizeof(values));
183  memset(nulls, false, sizeof(nulls));
184 
185  values[Anum_pg_publication_rel_prpubid - 1] =
186  ObjectIdGetDatum(pubid);
187  values[Anum_pg_publication_rel_prrelid - 1] =
188  ObjectIdGetDatum(relid);
189 
190  tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
191 
192  /* Insert tuple into catalog. */
193  prrelid = CatalogTupleInsert(rel, tup);
194  heap_freetuple(tup);
195 
196  ObjectAddressSet(myself, PublicationRelRelationId, prrelid);
197 
198  /* Add dependency on the publication */
199  ObjectAddressSet(referenced, PublicationRelationId, pubid);
200  recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO);
201 
202  /* Add dependency on the relation */
203  ObjectAddressSet(referenced, RelationRelationId, relid);
204  recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO);
205 
206  /* Close the table. */
208 
209  /* Invalidate relcache so that publication info is rebuilt. */
210  CacheInvalidateRelcache(targetrel);
211 
212  return myself;
213 }
#define RelationGetDescr(relation)
Definition: rel.h:433
int errcode(int sqlerrcode)
Definition: elog.c:575
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
Definition: pg_depend.c:44
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1074
#define heap_close(r, l)
Definition: heapam.h:97
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1773
unsigned int Oid
Definition: postgres_ext.h:31
Publication * GetPublication(Oid pubid)
#define ObjectIdGetDatum(X)
Definition: postgres.h:490
#define ERROR
Definition: elog.h:43
Oid CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition: indexing.c:163
static void check_publication_add_relation(Relation targetrel)
#define RowExclusiveLock
Definition: lockdefs.h:38
#define RelationGetRelationName(relation)
Definition: rel.h:441
#define ereport(elevel, rest)
Definition: elog.h:122
uintptr_t Datum
Definition: postgres.h:365
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1294
#define SearchSysCacheExists2(cacheId, key1, key2)
Definition: syscache.h:184
#define ObjectAddressSet(addr, class_id, object_id)
Definition: objectaddress.h:40
void CacheInvalidateRelcache(Relation relation)
Definition: inval.c:1233
static Datum values[MAXATTR]
Definition: bootstrap.c:164
const ObjectAddress InvalidObjectAddress
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define ERRCODE_DUPLICATE_OBJECT
Definition: streamutil.c:32
#define RelationGetRelid(relation)
Definition: rel.h:407

Variable Documentation

◆ FormData_pg_publication

FormData_pg_publication

Definition at line 54 of file pg_publication.h.