PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
publicationcmds.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * publicationcmds.c
4  * publication manipulation
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * IDENTIFICATION
10  * publicationcmds.c
11  *
12  *-------------------------------------------------------------------------
13  */
14 
15 #include "postgres.h"
16 
17 #include "funcapi.h"
18 #include "miscadmin.h"
19 
20 #include "access/genam.h"
21 #include "access/hash.h"
22 #include "access/heapam.h"
23 #include "access/htup_details.h"
24 #include "access/xact.h"
25 
26 #include "catalog/catalog.h"
27 #include "catalog/indexing.h"
28 #include "catalog/namespace.h"
29 #include "catalog/objectaccess.h"
30 #include "catalog/objectaddress.h"
31 #include "catalog/pg_inherits_fn.h"
32 #include "catalog/pg_type.h"
33 #include "catalog/pg_publication.h"
35 
36 #include "commands/dbcommands.h"
37 #include "commands/defrem.h"
38 #include "commands/event_trigger.h"
40 
41 #include "utils/array.h"
42 #include "utils/builtins.h"
43 #include "utils/catcache.h"
44 #include "utils/fmgroids.h"
45 #include "utils/inval.h"
46 #include "utils/lsyscache.h"
47 #include "utils/rel.h"
48 #include "utils/syscache.h"
49 #include "utils/varlena.h"
50 
51 /* Same as MAXNUMMESSAGES in sinvaladt.c */
52 #define MAX_RELCACHE_INVAL_MSGS 4096
53 
54 static List *OpenTableList(List *tables);
55 static void CloseTableList(List *rels);
56 static void PublicationAddTables(Oid pubid, List *rels, bool if_not_exists,
58 static void PublicationDropTables(Oid pubid, List *rels, bool missing_ok);
59 
60 static void
62  bool *publish_given,
63  bool *publish_insert,
64  bool *publish_update,
65  bool *publish_delete)
66 {
67  ListCell *lc;
68 
69  *publish_given = false;
70 
71  /* Defaults are true */
72  *publish_insert = true;
73  *publish_update = true;
74  *publish_delete = true;
75 
76  /* Parse options */
77  foreach(lc, options)
78  {
79  DefElem *defel = (DefElem *) lfirst(lc);
80 
81  if (strcmp(defel->defname, "publish") == 0)
82  {
83  char *publish;
84  List *publish_list;
85  ListCell *lc;
86 
87  if (*publish_given)
88  ereport(ERROR,
89  (errcode(ERRCODE_SYNTAX_ERROR),
90  errmsg("conflicting or redundant options")));
91 
92  /*
93  * If publish option was given only the explicitly listed actions
94  * should be published.
95  */
96  *publish_insert = false;
97  *publish_update = false;
98  *publish_delete = false;
99 
100  *publish_given = true;
101  publish = defGetString(defel);
102 
103  if (!SplitIdentifierString(publish, ',', &publish_list))
104  ereport(ERROR,
105  (errcode(ERRCODE_SYNTAX_ERROR),
106  errmsg("invalid publish list")));
107 
108  /* Process the option list. */
109  foreach(lc, publish_list)
110  {
111  char *publish_opt = (char *) lfirst(lc);
112 
113  if (strcmp(publish_opt, "insert") == 0)
114  *publish_insert = true;
115  else if (strcmp(publish_opt, "update") == 0)
116  *publish_update = true;
117  else if (strcmp(publish_opt, "delete") == 0)
118  *publish_delete = true;
119  else
120  ereport(ERROR,
121  (errcode(ERRCODE_SYNTAX_ERROR),
122  errmsg("unrecognized \"publish\" value: \"%s\"", publish_opt)));
123  }
124  }
125  else
126  ereport(ERROR,
127  (errcode(ERRCODE_SYNTAX_ERROR),
128  errmsg("unrecognized publication parameter: %s", defel->defname)));
129  }
130 }
131 
132 /*
133  * Create new publication.
134  */
137 {
138  Relation rel;
139  ObjectAddress myself;
140  Oid puboid;
141  bool nulls[Natts_pg_publication];
143  HeapTuple tup;
144  bool publish_given;
145  bool publish_insert;
146  bool publish_update;
147  bool publish_delete;
148  AclResult aclresult;
149 
150  /* must have CREATE privilege on database */
152  if (aclresult != ACLCHECK_OK)
155 
156  /* FOR ALL TABLES requires superuser */
157  if (stmt->for_all_tables && !superuser())
158  ereport(ERROR,
159  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
160  (errmsg("must be superuser to create FOR ALL TABLES publication"))));
161 
163 
164  /* Check if name is used */
166  if (OidIsValid(puboid))
167  {
168  ereport(ERROR,
170  errmsg("publication \"%s\" already exists",
171  stmt->pubname)));
172  }
173 
174  /* Form a tuple. */
175  memset(values, 0, sizeof(values));
176  memset(nulls, false, sizeof(nulls));
177 
178  values[Anum_pg_publication_pubname - 1] =
181 
183  &publish_given, &publish_insert,
184  &publish_update, &publish_delete);
185 
188  values[Anum_pg_publication_pubinsert - 1] =
189  BoolGetDatum(publish_insert);
190  values[Anum_pg_publication_pubupdate - 1] =
191  BoolGetDatum(publish_update);
192  values[Anum_pg_publication_pubdelete - 1] =
193  BoolGetDatum(publish_delete);
194 
195  tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
196 
197  /* Insert tuple into catalog. */
198  puboid = CatalogTupleInsert(rel, tup);
199  heap_freetuple(tup);
200 
202 
203  ObjectAddressSet(myself, PublicationRelationId, puboid);
204 
205  /* Make the changes visible. */
207 
208  if (stmt->tables)
209  {
210  List *rels;
211 
212  Assert(list_length(stmt->tables) > 0);
213 
214  rels = OpenTableList(stmt->tables);
215  PublicationAddTables(puboid, rels, true, NULL);
216  CloseTableList(rels);
217  }
218 
220 
222 
223  return myself;
224 }
225 
226 /*
227  * Change options of a publication.
228  */
229 static void
231  HeapTuple tup)
232 {
233  bool nulls[Natts_pg_publication];
234  bool replaces[Natts_pg_publication];
236  bool publish_given;
237  bool publish_insert;
238  bool publish_update;
239  bool publish_delete;
240  ObjectAddress obj;
241 
243  &publish_given, &publish_insert,
244  &publish_update, &publish_delete);
245 
246  /* Everything ok, form a new tuple. */
247  memset(values, 0, sizeof(values));
248  memset(nulls, false, sizeof(nulls));
249  memset(replaces, false, sizeof(replaces));
250 
251  if (publish_given)
252  {
253  values[Anum_pg_publication_pubinsert - 1] = BoolGetDatum(publish_insert);
254  replaces[Anum_pg_publication_pubinsert - 1] = true;
255 
256  values[Anum_pg_publication_pubupdate - 1] = BoolGetDatum(publish_update);
257  replaces[Anum_pg_publication_pubupdate - 1] = true;
258 
259  values[Anum_pg_publication_pubdelete - 1] = BoolGetDatum(publish_delete);
260  replaces[Anum_pg_publication_pubdelete - 1] = true;
261  }
262 
263  tup = heap_modify_tuple(tup, RelationGetDescr(rel), values, nulls,
264  replaces);
265 
266  /* Update the catalog. */
267  CatalogTupleUpdate(rel, &tup->t_self, tup);
268 
270 
271  /* Invalidate the relcache. */
272  if (((Form_pg_publication) GETSTRUCT(tup))->puballtables)
273  {
275  }
276  else
277  {
279 
280  /*
281  * We don't want to send too many individual messages, at some point
282  * it's cheaper to just reset whole relcache.
283  */
284  if (list_length(relids) < MAX_RELCACHE_INVAL_MSGS)
285  {
286  ListCell *lc;
287 
288  foreach(lc, relids)
289  {
290  Oid relid = lfirst_oid(lc);
291 
293  }
294  }
295  else
297  }
298 
301  (Node *) stmt);
302 
304 }
305 
306 /*
307  * Add or remove table to/from publication.
308  */
309 static void
311  HeapTuple tup)
312 {
313  Oid pubid = HeapTupleGetOid(tup);
314  List *rels = NIL;
316 
317  /* Check that user is allowed to manipulate the publication tables. */
318  if (pubform->puballtables)
319  ereport(ERROR,
320  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
321  errmsg("publication \"%s\" is defined as FOR ALL TABLES",
322  NameStr(pubform->pubname)),
323  errdetail("Tables cannot be added to or dropped from FOR ALL TABLES publications.")));
324 
325  Assert(list_length(stmt->tables) > 0);
326 
327  rels = OpenTableList(stmt->tables);
328 
329  if (stmt->tableAction == DEFELEM_ADD)
330  PublicationAddTables(pubid, rels, false, stmt);
331  else if (stmt->tableAction == DEFELEM_DROP)
332  PublicationDropTables(pubid, rels, false);
333  else /* DEFELEM_SET */
334  {
335  List *oldrelids = GetPublicationRelations(pubid);
336  List *delrels = NIL;
337  ListCell *oldlc;
338 
339  /* Calculate which relations to drop. */
340  foreach(oldlc, oldrelids)
341  {
342  Oid oldrelid = lfirst_oid(oldlc);
343  ListCell *newlc;
344  bool found = false;
345 
346  foreach(newlc, rels)
347  {
348  Relation newrel = (Relation) lfirst(newlc);
349 
350  if (RelationGetRelid(newrel) == oldrelid)
351  {
352  found = true;
353  break;
354  }
355  }
356 
357  if (!found)
358  {
359  Relation oldrel = heap_open(oldrelid,
361 
362  delrels = lappend(delrels, oldrel);
363  }
364  }
365 
366  /* And drop them. */
367  PublicationDropTables(pubid, delrels, true);
368 
369  /*
370  * Don't bother calculating the difference for adding, we'll catch and
371  * skip existing ones when doing catalog update.
372  */
373  PublicationAddTables(pubid, rels, true, stmt);
374 
375  CloseTableList(delrels);
376  }
377 
378  CloseTableList(rels);
379 }
380 
381 /*
382  * Alter the existing publication.
383  *
384  * This is dispatcher function for AlterPublicationOptions and
385  * AlterPublicationTables.
386  */
387 void
389 {
390  Relation rel;
391  HeapTuple tup;
392 
394 
396  CStringGetDatum(stmt->pubname));
397 
398  if (!HeapTupleIsValid(tup))
399  ereport(ERROR,
400  (errcode(ERRCODE_UNDEFINED_OBJECT),
401  errmsg("publication \"%s\" does not exist",
402  stmt->pubname)));
403 
404  /* must be owner */
407  stmt->pubname);
408 
409  if (stmt->options)
410  AlterPublicationOptions(stmt, rel, tup);
411  else
412  AlterPublicationTables(stmt, rel, tup);
413 
414  /* Cleanup. */
415  heap_freetuple(tup);
417 }
418 
419 /*
420  * Drop publication by OID
421  */
422 void
424 {
425  Relation rel;
426  HeapTuple tup;
427 
429 
431 
432  if (!HeapTupleIsValid(tup))
433  elog(ERROR, "cache lookup failed for publication %u", pubid);
434 
435  CatalogTupleDelete(rel, &tup->t_self);
436 
437  ReleaseSysCache(tup);
438 
440 }
441 
442 /*
443  * Remove relation from publication by mapping OID.
444  */
445 void
447 {
448  Relation rel;
449  HeapTuple tup;
451 
453 
455 
456  if (!HeapTupleIsValid(tup))
457  elog(ERROR, "cache lookup failed for publication table %u",
458  proid);
459 
460  pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
461 
462  /* Invalidate relcache so that publication info is rebuilt. */
463  CacheInvalidateRelcacheByRelid(pubrel->prrelid);
464 
465  CatalogTupleDelete(rel, &tup->t_self);
466 
467  ReleaseSysCache(tup);
468 
470 }
471 
472 /*
473  * Open relations based on provided by RangeVar list.
474  * The returned tables are locked in ShareUpdateExclusiveLock mode.
475  */
476 static List *
478 {
479  List *relids = NIL;
480  List *rels = NIL;
481  ListCell *lc;
482 
483  /*
484  * Open, share-lock, and check all the explicitly-specified relations
485  */
486  foreach(lc, tables)
487  {
488  RangeVar *rv = lfirst(lc);
489  Relation rel;
490  bool recurse = rv->inh;
491  Oid myrelid;
492 
494 
496  myrelid = RelationGetRelid(rel);
497 
498  /*
499  * Filter out duplicates if user specifies "foo, foo".
500  *
501  * Note that this algorithm is known to not be very efficient (O(N^2))
502  * but given that it only works on list of tables given to us by user
503  * it's deemed acceptable.
504  */
505  if (list_member_oid(relids, myrelid))
506  {
508  continue;
509  }
510  rels = lappend(rels, rel);
511  relids = lappend_oid(relids, myrelid);
512 
513  if (recurse)
514  {
515  ListCell *child;
516  List *children;
517 
518  children = find_all_inheritors(myrelid, ShareUpdateExclusiveLock,
519  NULL);
520 
521  foreach(child, children)
522  {
523  Oid childrelid = lfirst_oid(child);
524 
525  if (list_member_oid(relids, childrelid))
526  continue;
527 
528  /*
529  * Skip duplicates if user specified both parent and child
530  * tables.
531  */
532  if (list_member_oid(relids, childrelid))
533  {
535  continue;
536  }
537 
538  /* find_all_inheritors already got lock */
539  rel = heap_open(childrelid, NoLock);
540  rels = lappend(rels, rel);
541  relids = lappend_oid(relids, childrelid);
542  }
543  }
544  }
545 
546  list_free(relids);
547 
548  return rels;
549 }
550 
551 /*
552  * Close all relations in the list.
553  */
554 static void
556 {
557  ListCell *lc;
558 
559  foreach(lc, rels)
560  {
561  Relation rel = (Relation) lfirst(lc);
562 
563  heap_close(rel, NoLock);
564  }
565 }
566 
567 /*
568  * Add listed tables to the publication.
569  */
570 static void
571 PublicationAddTables(Oid pubid, List *rels, bool if_not_exists,
573 {
574  ListCell *lc;
575 
576  Assert(!stmt || !stmt->for_all_tables);
577 
578  foreach(lc, rels)
579  {
580  Relation rel = (Relation) lfirst(lc);
581  ObjectAddress obj;
582 
583  /* Must be owner of the table or superuser. */
587 
588  obj = publication_add_relation(pubid, rel, if_not_exists);
589  if (stmt)
590  {
592  (Node *) stmt);
593 
595  obj.objectId, 0);
596  }
597  }
598 }
599 
600 /*
601  * Remove listed tables from the publication.
602  */
603 static void
604 PublicationDropTables(Oid pubid, List *rels, bool missing_ok)
605 {
606  ObjectAddress obj;
607  ListCell *lc;
608  Oid prid;
609 
610  foreach(lc, rels)
611  {
612  Relation rel = (Relation) lfirst(lc);
613  Oid relid = RelationGetRelid(rel);
614 
616  ObjectIdGetDatum(pubid));
617  if (!OidIsValid(prid))
618  {
619  if (missing_ok)
620  continue;
621 
622  ereport(ERROR,
623  (errcode(ERRCODE_UNDEFINED_OBJECT),
624  errmsg("relation \"%s\" is not part of the publication",
625  RelationGetRelationName(rel))));
626  }
627 
629  performDeletion(&obj, DROP_CASCADE, 0);
630  }
631 }
632 
633 /*
634  * Internal workhorse for changing a publication owner
635  */
636 static void
638 {
639  Form_pg_publication form;
640 
641  form = (Form_pg_publication) GETSTRUCT(tup);
642 
643  if (form->pubowner == newOwnerId)
644  return;
645 
646  if (!superuser())
647  {
648  AclResult aclresult;
649 
650  /* Must be owner */
653  NameStr(form->pubname));
654 
655  /* Must be able to become new owner */
656  check_is_member_of_role(GetUserId(), newOwnerId);
657 
658  /* New owner must have CREATE privilege on database */
659  aclresult = pg_database_aclcheck(MyDatabaseId, newOwnerId, ACL_CREATE);
660  if (aclresult != ACLCHECK_OK)
663 
664  if (form->puballtables && !superuser_arg(newOwnerId))
665  ereport(ERROR,
666  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
667  errmsg("permission denied to change owner of publication \"%s\"",
668  NameStr(form->pubname)),
669  errhint("The owner of a FOR ALL TABLES publication must be a superuser.")));
670  }
671 
672  form->pubowner = newOwnerId;
673  CatalogTupleUpdate(rel, &tup->t_self, tup);
674 
675  /* Update owner dependency reference */
677  HeapTupleGetOid(tup),
678  newOwnerId);
679 
681  HeapTupleGetOid(tup), 0);
682 }
683 
684 /*
685  * Change publication owner -- by name
686  */
688 AlterPublicationOwner(const char *name, Oid newOwnerId)
689 {
690  Oid subid;
691  HeapTuple tup;
692  Relation rel;
693  ObjectAddress address;
694 
696 
698 
699  if (!HeapTupleIsValid(tup))
700  ereport(ERROR,
701  (errcode(ERRCODE_UNDEFINED_OBJECT),
702  errmsg("publication \"%s\" does not exist", name)));
703 
704  subid = HeapTupleGetOid(tup);
705 
706  AlterPublicationOwner_internal(rel, tup, newOwnerId);
707 
708  ObjectAddressSet(address, PublicationRelationId, subid);
709 
710  heap_freetuple(tup);
711 
713 
714  return address;
715 }
716 
717 /*
718  * Change publication owner -- by OID
719  */
720 void
722 {
723  HeapTuple tup;
724  Relation rel;
725 
727 
729 
730  if (!HeapTupleIsValid(tup))
731  ereport(ERROR,
732  (errcode(ERRCODE_UNDEFINED_OBJECT),
733  errmsg("publication with OID %u does not exist", subid)));
734 
735  AlterPublicationOwner_internal(rel, tup, newOwnerId);
736 
737  heap_freetuple(tup);
738 
740 }
#define NIL
Definition: pg_list.h:69
#define Natts_pg_publication
static void AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel, HeapTuple tup)
static void PublicationAddTables(Oid pubid, List *rels, bool if_not_exists, AlterPublicationStmt *stmt)
Datum namein(PG_FUNCTION_ARGS)
Definition: name.c:46
int errhint(const char *fmt,...)
Definition: elog.c:987
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define InvokeObjectPostCreateHook(classId, objectId, subId)
Definition: objectaccess.h:145
#define RelationGetDescr(relation)
Definition: rel.h:429
ObjectAddress CreatePublication(CreatePublicationStmt *stmt)
Oid GetUserId(void)
Definition: miscinit.c:283
static void PublicationDropTables(Oid pubid, List *rels, bool missing_ok)
bool pg_publication_ownercheck(Oid pub_oid, Oid roleid)
Definition: aclchk.c:5084
Definition: nodes.h:509
int errcode(int sqlerrcode)
Definition: elog.c:575
bool superuser(void)
Definition: superuser.c:47
#define PublicationRelationId
void RemovePublicationById(Oid pubid)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
Definition: indexing.c:255
void RemovePublicationRelById(Oid proid)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:692
#define heap_close(r, l)
Definition: heapam.h:97
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:584
void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner)
Definition: pg_shdepend.c:159
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1372
unsigned int Oid
Definition: postgres_ext.h:31
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
#define OidIsValid(objectId)
Definition: c.h:538
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:156
#define Anum_pg_publication_pubowner
#define GetSysCacheOid2(cacheId, key1, key2)
Definition: syscache.h:185
#define PublicationRelRelationId
#define GetSysCacheOid1(cacheId, key1)
Definition: syscache.h:183
static void CloseTableList(List *rels)
void changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId)
Definition: pg_shdepend.c:304
#define MAX_RELCACHE_INVAL_MSGS
struct RelationData * Relation
Definition: relcache.h:21
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ACL_CREATE
Definition: parsenodes.h:82
Oid CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition: indexing.c:162
char * defGetString(DefElem *def)
Definition: define.c:49
ItemPointerData t_self
Definition: htup.h:65
char * get_database_name(Oid dbid)
Definition: dbcommands.c:2056
#define Anum_pg_publication_pubupdate
#define NoLock
Definition: lockdefs.h:34
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3247
void aclcheck_error(AclResult aclerr, AclObjectKind objectkind, const char *objectname)
Definition: aclchk.c:3399
#define RowExclusiveLock
Definition: lockdefs.h:38
struct statement * stmt
Definition: extern.h:74
int errdetail(const char *fmt,...)
Definition: elog.c:873
#define CStringGetDatum(X)
Definition: postgres.h:584
void performDeletion(const ObjectAddress *object, DropBehavior behavior, int flags)
Definition: dependency.c:303
void CacheInvalidateRelcacheByRelid(Oid relid)
Definition: inval.c:1292
#define RelationGetRelationName(relation)
Definition: rel.h:437
void check_is_member_of_role(Oid member, Oid role)
Definition: acl.c:4859
#define Anum_pg_publication_pubdelete
#define ereport(elevel, rest)
Definition: elog.h:122
#define InvokeObjectPostAlterHook(classId, objectId, subId)
Definition: objectaccess.h:163
static void AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
bool superuser_arg(Oid roleid)
Definition: superuser.c:57
bool inh
Definition: primnodes.h:69
List * lappend(List *list, void *datum)
Definition: list.c:128
static void AlterPublicationTables(AlterPublicationStmt *stmt, Relation rel, HeapTuple tup)
void CacheInvalidateRelcacheAll(void)
Definition: inval.c:1257
AclResult
Definition: acl.h:170
uintptr_t Datum
Definition: postgres.h:372
void CommandCounterIncrement(void)
Definition: xact.c:922
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1117
#define Anum_pg_publication_pubinsert
Oid MyDatabaseId
Definition: globals.c:76
ObjectAddress AlterPublicationOwner(const char *name, Oid newOwnerId)
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1284
#define BoolGetDatum(X)
Definition: postgres.h:408
Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
Definition: heapam.c:1312
DefElemAction tableAction
Definition: parsenodes.h:3368
#define ShareUpdateExclusiveLock
Definition: lockdefs.h:39
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:505
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
AclResult pg_database_aclcheck(Oid db_oid, Oid roleid, AclMode mode)
Definition: aclchk.c:4434
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
#define lfirst(lc)
Definition: pg_list.h:106
bool pg_class_ownercheck(Oid class_oid, Oid roleid)
Definition: aclchk.c:4546
List * GetPublicationRelations(Oid pubid)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
Definition: indexing.c:210
static int list_length(const List *l)
Definition: pg_list.h:89
const char * name
Definition: encode.c:521
#define ObjectAddressSet(addr, class_id, object_id)
Definition: objectaddress.h:40
static Datum values[MAXATTR]
Definition: bootstrap.c:163
#define SearchSysCacheCopy1(cacheId, key1)
Definition: syscache.h:165
List * find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents)
Definition: pg_inherits.c:167
const ObjectAddress InvalidObjectAddress
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define Anum_pg_publication_puballtables
void list_free(List *list)
Definition: list.c:1133
FormData_pg_publication_rel * Form_pg_publication_rel
#define NameStr(name)
Definition: c.h:499
char * defname
Definition: parsenodes.h:720
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:97
ObjectAddress publication_add_relation(Oid pubid, Relation targetrel, bool if_not_exists)
void AlterPublicationOwner_oid(Oid subid, Oid newOwnerId)
#define elog
Definition: elog.h:219
void EventTriggerCollectSimpleCommand(ObjectAddress address, ObjectAddress secondaryObject, Node *parsetree)
#define Anum_pg_publication_pubname
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
static void parse_publication_options(List *options, bool *publish_given, bool *publish_insert, bool *publish_update, bool *publish_delete)
FormData_pg_publication * Form_pg_publication
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, bool *replIsnull, bool *doReplace)
Definition: heaptuple.c:791
#define ERRCODE_DUPLICATE_OBJECT
Definition: streamutil.c:31
Definition: pg_list.h:45
#define RelationGetRelid(relation)
Definition: rel.h:417
static List * OpenTableList(List *tables)
#define lfirst_oid(lc)
Definition: pg_list.h:108
void AlterPublication(AlterPublicationStmt *stmt)