PostgreSQL Source Code git master
Loading...
Searching...
No Matches
publicationcmds.h File Reference
Include dependency graph for publicationcmds.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAX_RELCACHE_INVAL_MSGS   4096
 

Functions

ObjectAddress CreatePublication (ParseState *pstate, CreatePublicationStmt *stmt)
 
void AlterPublication (ParseState *pstate, AlterPublicationStmt *stmt)
 
void RemovePublicationById (Oid pubid)
 
void RemovePublicationRelById (Oid proid)
 
void RemovePublicationSchemaById (Oid psoid)
 
ObjectAddress AlterPublicationOwner (const char *name, Oid newOwnerId)
 
void AlterPublicationOwner_oid (Oid pubid, Oid newOwnerId)
 
void InvalidatePublicationRels (List *relids)
 
bool pub_rf_contains_invalid_column (Oid pubid, Relation relation, List *ancestors, bool pubviaroot)
 
bool pub_contains_invalid_column (Oid pubid, Relation relation, List *ancestors, bool pubviaroot, char pubgencols_type, bool *invalid_column_list, bool *invalid_gen_col)
 
void InvalidatePubRelSyncCache (Oid pubid, bool puballtables)
 

Macro Definition Documentation

◆ MAX_RELCACHE_INVAL_MSGS

#define MAX_RELCACHE_INVAL_MSGS   4096

Definition at line 23 of file publicationcmds.h.

Function Documentation

◆ AlterPublication()

void AlterPublication ( ParseState pstate,
AlterPublicationStmt stmt 
)
extern

Definition at line 1657 of file publicationcmds.c.

1658{
1659 Relation rel;
1660 HeapTuple tup;
1662
1664
1666 CStringGetDatum(stmt->pubname));
1667
1668 if (!HeapTupleIsValid(tup))
1669 ereport(ERROR,
1671 errmsg("publication \"%s\" does not exist",
1672 stmt->pubname)));
1673
1675
1676 /* must be owner */
1679 stmt->pubname);
1680
1681 if (stmt->options)
1682 AlterPublicationOptions(pstate, stmt, rel, tup);
1683 else
1684 {
1685 List *relations = NIL;
1688 Oid pubid = pubform->oid;
1689
1690 ObjectsInPublicationToOids(stmt->pubobjects, pstate, &relations,
1692
1694
1696
1697 /* Lock the publication so nobody else can do anything with it. */
1700
1701 /*
1702 * It is possible that by the time we acquire the lock on publication,
1703 * concurrent DDL has removed it. We can test this by checking the
1704 * existence of publication. We get the tuple again to avoid the risk
1705 * of any publication option getting changed.
1706 */
1708 if (!HeapTupleIsValid(tup))
1709 ereport(ERROR,
1711 errmsg("publication \"%s\" does not exist",
1712 stmt->pubname));
1713
1714 relations = list_concat(relations, exceptrelations);
1715 AlterPublicationTables(stmt, tup, relations, pstate->p_sourcetext,
1716 schemaidlist != NIL);
1719 }
1720
1721 /* Cleanup. */
1724}
@ ACLCHECK_NOT_OWNER
Definition acl.h:186
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition aclchk.c:2672
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
Definition aclchk.c:4133
int errcode(int sqlerrcode)
Definition elog.c:874
#define ERROR
Definition elog.h:39
#define ereport(elevel,...)
Definition elog.h:150
void heap_freetuple(HeapTuple htup)
Definition heaptuple.c:1384
#define HeapTupleIsValid(tuple)
Definition htup.h:78
static void * GETSTRUCT(const HeapTupleData *tuple)
#define stmt
List * list_concat(List *list1, const List *list2)
Definition list.c:561
void LockDatabaseObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
Definition lmgr.c:1008
#define AccessExclusiveLock
Definition lockdefs.h:43
#define RowExclusiveLock
Definition lockdefs.h:38
Oid GetUserId(void)
Definition miscinit.c:470
static char * errmsg
@ OBJECT_PUBLICATION
#define NIL
Definition pg_list.h:68
END_CATALOG_STRUCT typedef FormData_pg_publication * Form_pg_publication
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:252
static Datum CStringGetDatum(const char *X)
Definition postgres.h:370
unsigned int Oid
static int fb(int x)
static void AlterPublicationSchemas(AlterPublicationStmt *stmt, HeapTuple tup, List *schemaidlist)
static void AlterPublicationAllFlags(AlterPublicationStmt *stmt, Relation rel, HeapTuple tup)
static void CheckAlterPublication(AlterPublicationStmt *stmt, HeapTuple tup, List *tables, List *schemaidlist)
static void ObjectsInPublicationToOids(List *pubobjspec_list, ParseState *pstate, List **rels, List **exceptrels, List **schemas)
static void AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt, Relation rel, HeapTuple tup)
static void AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup, List *tables, const char *queryString, bool publish_schema)
Definition pg_list.h:54
const char * p_sourcetext
Definition parse_node.h:210
#define SearchSysCacheCopy1(cacheId, key1)
Definition syscache.h:91
void table_close(Relation relation, LOCKMODE lockmode)
Definition table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition table.c:40

References AccessExclusiveLock, aclcheck_error(), ACLCHECK_NOT_OWNER, AlterPublicationAllFlags(), AlterPublicationOptions(), AlterPublicationSchemas(), AlterPublicationTables(), CheckAlterPublication(), CStringGetDatum(), ereport, errcode(), errmsg, ERROR, fb(), Form_pg_publication, GETSTRUCT(), GetUserId(), heap_freetuple(), HeapTupleIsValid, list_concat(), LockDatabaseObject(), NIL, object_ownercheck(), OBJECT_PUBLICATION, ObjectIdGetDatum(), ObjectsInPublicationToOids(), ParseState::p_sourcetext, RowExclusiveLock, SearchSysCacheCopy1, stmt, table_close(), and table_open().

Referenced by ProcessUtilitySlow().

◆ AlterPublicationOwner()

ObjectAddress AlterPublicationOwner ( const char name,
Oid  newOwnerId 
)
extern

Definition at line 2230 of file publicationcmds.c.

2231{
2232 Oid pubid;
2233 HeapTuple tup;
2234 Relation rel;
2235 ObjectAddress address;
2237
2239
2241
2242 if (!HeapTupleIsValid(tup))
2243 ereport(ERROR,
2245 errmsg("publication \"%s\" does not exist", name)));
2246
2248 pubid = pubform->oid;
2249
2251
2252 ObjectAddressSet(address, PublicationRelationId, pubid);
2253
2255
2257
2258 return address;
2259}
#define ObjectAddressSet(addr, class_id, object_id)
static void AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
const char * name

References AlterPublicationOwner_internal(), CStringGetDatum(), ereport, errcode(), errmsg, ERROR, fb(), Form_pg_publication, GETSTRUCT(), heap_freetuple(), HeapTupleIsValid, name, ObjectAddressSet, RowExclusiveLock, SearchSysCacheCopy1, table_close(), and table_open().

Referenced by ExecAlterOwnerStmt().

◆ AlterPublicationOwner_oid()

void AlterPublicationOwner_oid ( Oid  pubid,
Oid  newOwnerId 
)
extern

◆ CreatePublication()

ObjectAddress CreatePublication ( ParseState pstate,
CreatePublicationStmt stmt 
)
extern

Definition at line 836 of file publicationcmds.c.

837{
838 Relation rel;
840 Oid puboid;
841 bool nulls[Natts_pg_publication];
844 bool publish_given;
845 PublicationActions pubactions;
851 List *relations = NIL;
854
855 /* must have CREATE privilege on database */
857 if (aclresult != ACLCHECK_OK)
860
861 /* FOR ALL TABLES and FOR ALL SEQUENCES requires superuser */
862 if (!superuser())
863 {
864 if (stmt->for_all_tables || stmt->for_all_sequences)
867 errmsg("must be superuser to create a FOR ALL TABLES or ALL SEQUENCES publication"));
868 }
869
871
872 /* Check if name is used */
874 CStringGetDatum(stmt->pubname));
875 if (OidIsValid(puboid))
878 errmsg("publication \"%s\" already exists",
879 stmt->pubname)));
880
881 /* Form a tuple. */
882 memset(values, 0, sizeof(values));
883 memset(nulls, false, sizeof(nulls));
884
888
890 stmt->options,
891 &publish_given, &pubactions,
896
897 if (stmt->for_all_sequences &&
902 errmsg("publication parameters are not applicable to sequence synchronization and will be ignored for sequences"));
903
908 BoolGetDatum(stmt->for_all_tables);
910 BoolGetDatum(stmt->for_all_sequences);
912 BoolGetDatum(pubactions.pubinsert);
914 BoolGetDatum(pubactions.pubupdate);
916 BoolGetDatum(pubactions.pubdelete);
918 BoolGetDatum(pubactions.pubtruncate);
923
925
926 /* Insert tuple into catalog. */
929
931
933
934 /* Make the changes visible. */
936
937 /* Associate objects with the publication. */
938 ObjectsInPublicationToOids(stmt->pubobjects, pstate, &relations,
940
941 if (stmt->for_all_tables)
942 {
943 /* Process EXCEPT table list */
944 if (exceptrelations != NIL)
945 {
946 List *rels;
947
949 PublicationAddTables(puboid, rels, true, NULL);
950 CloseTableList(rels);
951 }
952
953 /*
954 * Invalidate relcache so that publication info is rebuilt. Sequences
955 * publication doesn't require invalidation, as replica identity
956 * checks don't apply to them.
957 */
959 }
960 else if (!stmt->for_all_sequences)
961 {
962 /* FOR TABLES IN SCHEMA requires superuser */
963 if (schemaidlist != NIL && !superuser())
966 errmsg("must be superuser to create FOR TABLES IN SCHEMA publication"));
967
968 if (relations != NIL)
969 {
970 List *rels;
971
972 rels = OpenTableList(relations);
975
976 CheckPubRelationColumnList(stmt->pubname, rels,
977 schemaidlist != NIL,
979
980 PublicationAddTables(puboid, rels, true, NULL);
981 CloseTableList(rels);
982 }
983
984 if (schemaidlist != NIL)
985 {
986 /*
987 * Schema lock is held until the publication is created to prevent
988 * concurrent schema deletion.
989 */
992 }
993 }
994
996
998
999 /*
1000 * We don't need this warning message when wal_level >= 'replica' since
1001 * logical decoding is automatically enabled up on a logical slot
1002 * creation.
1003 */
1007 errmsg("logical decoding must be enabled to publish logical changes"),
1008 errhint("Before creating subscriptions, ensure that \"wal_level\" is set to \"replica\" or higher.")));
1009
1010 return myself;
1011}
AclResult
Definition acl.h:183
@ ACLCHECK_OK
Definition acl.h:184
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
Definition aclchk.c:3879
static Datum values[MAXATTR]
Definition bootstrap.c:188
#define OidIsValid(objectId)
Definition c.h:860
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition catalog.c:448
int errhint(const char *fmt,...) pg_attribute_printf(1
#define WARNING
Definition elog.h:36
#define NOTICE
Definition elog.h:35
#define DirectFunctionCall1(func, arg1)
Definition fmgr.h:684
Oid MyDatabaseId
Definition globals.c:94
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition heaptuple.c:1037
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition indexing.c:233
void CacheInvalidateRelcacheAll(void)
Definition inval.c:1658
char * get_database_name(Oid dbid)
Definition lsyscache.c:1312
Datum namein(PG_FUNCTION_ARGS)
Definition name.c:48
#define InvokeObjectPostCreateHook(classId, objectId, subId)
@ OBJECT_DATABASE
#define ACL_CREATE
Definition parsenodes.h:85
void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner)
static Datum BoolGetDatum(bool X)
Definition postgres.h:112
uint64_t Datum
Definition postgres.h:70
static Datum CharGetDatum(char X)
Definition postgres.h:132
static void PublicationAddSchemas(Oid pubid, List *schemas, bool if_not_exists, AlterPublicationStmt *stmt)
static void PublicationAddTables(Oid pubid, List *rels, bool if_not_exists, AlterPublicationStmt *stmt)
static void CloseTableList(List *rels)
static void TransformPubWhereClauses(List *tables, const char *queryString, bool pubviaroot)
static List * OpenTableList(List *tables)
static void parse_publication_options(ParseState *pstate, List *options, bool *publish_given, PublicationActions *pubactions, bool *publish_via_partition_root_given, bool *publish_via_partition_root, bool *publish_generated_columns_given, char *publish_generated_columns)
static void CheckPubRelationColumnList(char *pubname, List *tables, bool publish_schema, bool pubviaroot)
static void LockSchemaList(List *schemalist)
#define RelationGetDescr(relation)
Definition rel.h:540
#define ERRCODE_DUPLICATE_OBJECT
Definition streamutil.c:30
bool superuser(void)
Definition superuser.c:47
#define GetSysCacheOid1(cacheId, oidcol, key1)
Definition syscache.h:109
void CommandCounterIncrement(void)
Definition xact.c:1102
int wal_level
Definition xlog.c:135
@ WAL_LEVEL_REPLICA
Definition xlog.h:76

References ACL_CREATE, aclcheck_error(), ACLCHECK_OK, BoolGetDatum(), CacheInvalidateRelcacheAll(), CatalogTupleInsert(), CharGetDatum(), CheckPubRelationColumnList(), CloseTableList(), CommandCounterIncrement(), CStringGetDatum(), DirectFunctionCall1, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errhint(), errmsg, ERROR, fb(), get_database_name(), GetNewOidWithIndex(), GetSysCacheOid1, GetUserId(), heap_form_tuple(), heap_freetuple(), InvokeObjectPostCreateHook, LockSchemaList(), MyDatabaseId, namein(), NIL, NOTICE, object_aclcheck(), OBJECT_DATABASE, ObjectAddressSet, ObjectIdGetDatum(), ObjectsInPublicationToOids(), OidIsValid, OpenTableList(), ParseState::p_sourcetext, parse_publication_options(), PublicationActions::pubdelete, PublicationActions::pubinsert, PublicationAddSchemas(), PublicationAddTables(), PublicationActions::pubtruncate, PublicationActions::pubupdate, recordDependencyOnOwner(), RelationGetDescr, RowExclusiveLock, stmt, superuser(), table_close(), table_open(), TransformPubWhereClauses(), values, wal_level, WAL_LEVEL_REPLICA, and WARNING.

Referenced by ProcessUtilitySlow().

◆ InvalidatePublicationRels()

void InvalidatePublicationRels ( List relids)
extern

Definition at line 1221 of file publicationcmds.c.

1222{
1223 /*
1224 * We don't want to send too many individual messages, at some point it's
1225 * cheaper to just reset whole relcache.
1226 */
1228 {
1229 ListCell *lc;
1230
1231 foreach(lc, relids)
1233 }
1234 else
1236}
void CacheInvalidateRelcacheByRelid(Oid relid)
Definition inval.c:1691
static int list_length(const List *l)
Definition pg_list.h:152
#define lfirst_oid(lc)
Definition pg_list.h:174
#define MAX_RELCACHE_INVAL_MSGS

References CacheInvalidateRelcacheAll(), CacheInvalidateRelcacheByRelid(), fb(), lfirst_oid, list_length(), and MAX_RELCACHE_INVAL_MSGS.

Referenced by AlterPublicationOptions(), publication_add_relation(), publication_add_schema(), RemovePublicationRelById(), and RemovePublicationSchemaById().

◆ InvalidatePubRelSyncCache()

void InvalidatePubRelSyncCache ( Oid  pubid,
bool  puballtables 
)
extern

Definition at line 510 of file publicationcmds.c.

511{
512 if (puballtables)
513 {
515 }
516 else
517 {
518 List *relids = NIL;
520
521 /*
522 * For partitioned tables, we must invalidate all partitions and
523 * itself. WAL records for INSERT/UPDATE/DELETE specify leaf tables as
524 * a target. However, WAL records for TRUNCATE specify both a root and
525 * its leaves.
526 */
527 relids = GetIncludedPublicationRelations(pubid,
531
532 relids = list_concat_unique_oid(relids, schemarelids);
533
534 /* Invalidate the relsyncache */
535 foreach_oid(relid, relids)
537 }
538
539 return;
540}
void CacheInvalidateRelSyncAll(void)
Definition inval.c:1724
void CacheInvalidateRelSync(Oid relid)
Definition inval.c:1712
List * list_concat_unique_oid(List *list1, const List *list2)
Definition list.c:1469
#define foreach_oid(var, lst)
Definition pg_list.h:471
List * GetAllSchemaPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
List * GetIncludedPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
@ PUBLICATION_PART_ALL

References CacheInvalidateRelSync(), CacheInvalidateRelSyncAll(), fb(), foreach_oid, GetAllSchemaPublicationRelations(), GetIncludedPublicationRelations(), list_concat_unique_oid(), NIL, and PUBLICATION_PART_ALL.

Referenced by AlterObjectRename_internal().

◆ pub_contains_invalid_column()

bool pub_contains_invalid_column ( Oid  pubid,
Relation  relation,
List ancestors,
bool  pubviaroot,
char  pubgencols_type,
bool invalid_column_list,
bool invalid_gen_col 
)
extern

Definition at line 366 of file publicationcmds.c.

370{
371 Oid relid = RelationGetRelid(relation);
372 Oid publish_as_relid = RelationGetRelid(relation);
374 Bitmapset *columns = NULL;
375 TupleDesc desc = RelationGetDescr(relation);
376 Publication *pub;
377 int x;
378
379 *invalid_column_list = false;
380 *invalid_gen_col = false;
381
382 /*
383 * For a partition, if pubviaroot is true, find the topmost ancestor that
384 * is published via this publication as we need to use its column list for
385 * the changes.
386 *
387 * Note that even though the column list used is for an ancestor, the
388 * REPLICA IDENTITY used will be for the actual child table.
389 */
390 if (pubviaroot && relation->rd_rel->relispartition)
391 {
392 publish_as_relid = GetTopMostAncestorInPublication(pubid, ancestors, NULL);
393
394 if (!OidIsValid(publish_as_relid))
395 publish_as_relid = relid;
396 }
397
398 /* Fetch the column list */
399 pub = GetPublication(pubid);
400 check_and_fetch_column_list(pub, publish_as_relid, NULL, &columns);
401
402 if (relation->rd_rel->relreplident == REPLICA_IDENTITY_FULL)
403 {
404 /* With REPLICA IDENTITY FULL, no column list is allowed. */
405 *invalid_column_list = (columns != NULL);
406
407 /*
408 * As we don't allow a column list with REPLICA IDENTITY FULL, the
409 * publish_generated_columns option must be set to stored if the table
410 * has any stored generated columns.
411 */
412 if (pubgencols_type != PUBLISH_GENCOLS_STORED &&
413 relation->rd_att->constr &&
415 *invalid_gen_col = true;
416
417 /*
418 * Virtual generated columns are currently not supported for logical
419 * replication at all.
420 */
421 if (relation->rd_att->constr &&
423 *invalid_gen_col = true;
424
426 return true;
427 }
428
429 /* Remember columns that are part of the REPLICA IDENTITY */
432
433 /*
434 * Attnums in the bitmap returned by RelationGetIndexAttrBitmap are offset
435 * (to handle system columns the usual way), while column list does not
436 * use offset, so we can't do bms_is_subset(). Instead, we have to loop
437 * over the idattrs and check all of them are in the list.
438 */
439 x = -1;
440 while ((x = bms_next_member(idattrs, x)) >= 0)
441 {
444
445 if (columns == NULL)
446 {
447 /*
448 * The publish_generated_columns option must be set to stored if
449 * the REPLICA IDENTITY contains any stored generated column.
450 */
451 if (att->attgenerated == ATTRIBUTE_GENERATED_STORED && pubgencols_type != PUBLISH_GENCOLS_STORED)
452 {
453 *invalid_gen_col = true;
454 break;
455 }
456
457 /*
458 * The equivalent setting for virtual generated columns does not
459 * exist yet.
460 */
461 if (att->attgenerated == ATTRIBUTE_GENERATED_VIRTUAL)
462 {
463 *invalid_gen_col = true;
464 break;
465 }
466
467 /* Skip validating the column list since it is not defined */
468 continue;
469 }
470
471 /*
472 * If pubviaroot is true, we are validating the column list of the
473 * parent table, but the bitmap contains the replica identity
474 * information of the child table. The parent/child attnums may not
475 * match, so translate them to the parent - get the attname from the
476 * child, and look it up in the parent.
477 */
478 if (pubviaroot)
479 {
480 /* attribute name in the child table */
481 char *colname = get_attname(relid, attnum, false);
482
483 /*
484 * Determine the attnum for the attribute name in parent (we are
485 * using the column list defined on the parent).
486 */
487 attnum = get_attnum(publish_as_relid, colname);
488 }
489
490 /* replica identity column, not covered by the column list */
492
494 break;
495 }
496
497 bms_free(columns);
499
501}
int16 AttrNumber
Definition attnum.h:21
int bms_next_member(const Bitmapset *a, int prevbit)
Definition bitmapset.c:1290
void bms_free(Bitmapset *a)
Definition bitmapset.c:239
bool bms_is_member(int x, const Bitmapset *a)
Definition bitmapset.c:510
int x
Definition isn.c:75
AttrNumber get_attnum(Oid relid, const char *attname)
Definition lsyscache.c:977
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
Definition lsyscache.c:946
int16 attnum
FormData_pg_attribute * Form_pg_attribute
Oid GetTopMostAncestorInPublication(Oid puboid, List *ancestors, int *ancestor_level)
Publication * GetPublication(Oid pubid)
bool check_and_fetch_column_list(Publication *pub, Oid relid, MemoryContext mcxt, Bitmapset **cols)
#define RelationGetRelid(relation)
Definition rel.h:514
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
Definition relcache.c:5293
@ INDEX_ATTR_BITMAP_IDENTITY_KEY
Definition relcache.h:71
TupleDesc rd_att
Definition rel.h:112
Form_pg_class rd_rel
Definition rel.h:111
bool has_generated_virtual
Definition tupdesc.h:47
bool has_generated_stored
Definition tupdesc.h:46
TupleConstr * constr
Definition tupdesc.h:159
#define FirstLowInvalidHeapAttributeNumber
Definition sysattr.h:27
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:178

References attnum, bms_free(), bms_is_member(), bms_next_member(), check_and_fetch_column_list(), TupleDescData::constr, fb(), FirstLowInvalidHeapAttributeNumber, get_attname(), get_attnum(), GetPublication(), GetTopMostAncestorInPublication(), TupleConstr::has_generated_stored, TupleConstr::has_generated_virtual, INDEX_ATTR_BITMAP_IDENTITY_KEY, OidIsValid, RelationData::rd_att, RelationData::rd_rel, RelationGetDescr, RelationGetIndexAttrBitmap(), RelationGetRelid, TupleDescAttr(), and x.

Referenced by RelationBuildPublicationDesc().

◆ pub_rf_contains_invalid_column()

bool pub_rf_contains_invalid_column ( Oid  pubid,
Relation  relation,
List ancestors,
bool  pubviaroot 
)
extern

Definition at line 280 of file publicationcmds.c.

282{
284 Oid relid = RelationGetRelid(relation);
285 Oid publish_as_relid = RelationGetRelid(relation);
286 bool result = false;
288 bool rfisnull;
289
290 /*
291 * FULL means all columns are in the REPLICA IDENTITY, so all columns are
292 * allowed in the row filter and we can skip the validation.
293 */
294 if (relation->rd_rel->relreplident == REPLICA_IDENTITY_FULL)
295 return false;
296
297 /*
298 * For a partition, if pubviaroot is true, find the topmost ancestor that
299 * is published via this publication as we need to use its row filter
300 * expression to filter the partition's changes.
301 *
302 * Note that even though the row filter used is for an ancestor, the
303 * REPLICA IDENTITY used will be for the actual child table.
304 */
305 if (pubviaroot && relation->rd_rel->relispartition)
306 {
307 publish_as_relid
308 = GetTopMostAncestorInPublication(pubid, ancestors, NULL);
309
310 if (!OidIsValid(publish_as_relid))
311 publish_as_relid = relid;
312 }
313
315 ObjectIdGetDatum(publish_as_relid),
316 ObjectIdGetDatum(pubid));
317
319 return false;
320
323 &rfisnull);
324
325 if (!rfisnull)
326 {
327 rf_context context = {0};
328 Node *rfnode;
329 Bitmapset *bms = NULL;
330
331 context.pubviaroot = pubviaroot;
332 context.parentid = publish_as_relid;
333 context.relid = relid;
334
335 /* Remember columns that are part of the REPLICA IDENTITY */
338
339 context.bms_replident = bms;
341 result = contain_invalid_rfcolumn_walker(rfnode, &context);
342 }
343
345
346 return result;
347}
#define TextDatumGetCString(d)
Definition builtins.h:99
static bool contain_invalid_rfcolumn_walker(Node *node, rf_context *context)
void * stringToNode(const char *str)
Definition read.c:90
Definition nodes.h:135
Bitmapset * bms_replident
void ReleaseSysCache(HeapTuple tuple)
Definition syscache.c:264
HeapTuple SearchSysCache2(SysCacheIdentifier cacheId, Datum key1, Datum key2)
Definition syscache.c:230
Datum SysCacheGetAttr(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition syscache.c:595

References rf_context::bms_replident, contain_invalid_rfcolumn_walker(), fb(), GetTopMostAncestorInPublication(), HeapTupleIsValid, INDEX_ATTR_BITMAP_IDENTITY_KEY, ObjectIdGetDatum(), OidIsValid, rf_context::parentid, rf_context::pubviaroot, RelationData::rd_rel, RelationGetIndexAttrBitmap(), RelationGetRelid, ReleaseSysCache(), rf_context::relid, SearchSysCache2(), stringToNode(), SysCacheGetAttr(), and TextDatumGetCString.

Referenced by RelationBuildPublicationDesc().

◆ RemovePublicationById()

void RemovePublicationById ( Oid  pubid)
extern

Definition at line 1771 of file publicationcmds.c.

1772{
1773 Relation rel;
1774 HeapTuple tup;
1776
1778
1780 if (!HeapTupleIsValid(tup))
1781 elog(ERROR, "cache lookup failed for publication %u", pubid);
1782
1784
1785 /* Invalidate relcache so that publication info is rebuilt. */
1786 if (pubform->puballtables)
1788
1789 CatalogTupleDelete(rel, &tup->t_self);
1790
1792
1794}
#define elog(elevel,...)
Definition elog.h:226
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
Definition indexing.c:365
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Definition syscache.c:220

References CacheInvalidateRelcacheAll(), CatalogTupleDelete(), elog, ERROR, fb(), Form_pg_publication, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), table_close(), and table_open().

Referenced by doDeletion().

◆ RemovePublicationRelById()

void RemovePublicationRelById ( Oid  proid)
extern

Definition at line 1730 of file publicationcmds.c.

1731{
1732 Relation rel;
1733 HeapTuple tup;
1735 List *relids = NIL;
1736
1738
1740
1741 if (!HeapTupleIsValid(tup))
1742 elog(ERROR, "cache lookup failed for publication table %u",
1743 proid);
1744
1746
1747 /*
1748 * Invalidate relcache so that publication info is rebuilt.
1749 *
1750 * For the partitioned tables, we must invalidate all partitions contained
1751 * in the respective partition hierarchies, not just the one explicitly
1752 * mentioned in the publication. This is required because we implicitly
1753 * publish the child tables when the parent table is published.
1754 */
1756 pubrel->prrelid);
1757
1759
1760 CatalogTupleDelete(rel, &tup->t_self);
1761
1763
1765}
List * GetPubPartitionOptionRelations(List *result, PublicationPartOpt pub_partopt, Oid relid)
END_CATALOG_STRUCT typedef FormData_pg_publication_rel * Form_pg_publication_rel
void InvalidatePublicationRels(List *relids)

References CatalogTupleDelete(), elog, ERROR, fb(), Form_pg_publication_rel, GetPubPartitionOptionRelations(), GETSTRUCT(), HeapTupleIsValid, InvalidatePublicationRels(), NIL, ObjectIdGetDatum(), PUBLICATION_PART_ALL, ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), table_close(), and table_open().

Referenced by doDeletion().

◆ RemovePublicationSchemaById()

void RemovePublicationSchemaById ( Oid  psoid)
extern

Definition at line 1800 of file publicationcmds.c.

1801{
1802 Relation rel;
1803 HeapTuple tup;
1804 List *schemaRels = NIL;
1806
1808
1810
1811 if (!HeapTupleIsValid(tup))
1812 elog(ERROR, "cache lookup failed for publication schema %u", psoid);
1813
1815
1816 /*
1817 * Invalidate relcache so that publication info is rebuilt. See
1818 * RemovePublicationRelById for why we need to consider all the
1819 * partitions.
1820 */
1824
1825 CatalogTupleDelete(rel, &tup->t_self);
1826
1828
1830}
List * GetSchemaPublicationRelations(Oid schemaid, PublicationPartOpt pub_partopt)
END_CATALOG_STRUCT typedef FormData_pg_publication_namespace * Form_pg_publication_namespace

References CatalogTupleDelete(), elog, ERROR, fb(), Form_pg_publication_namespace, GetSchemaPublicationRelations(), GETSTRUCT(), HeapTupleIsValid, InvalidatePublicationRels(), NIL, ObjectIdGetDatum(), PUBLICATION_PART_ALL, ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), table_close(), and table_open().

Referenced by doDeletion().