PostgreSQL Source Code git master
|
#include "postgres.h"
#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/objectaddress.h"
#include "catalog/pg_database.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_publication.h"
#include "catalog/pg_publication_namespace.h"
#include "catalog/pg_publication_rel.h"
#include "commands/dbcommands.h"
#include "commands/defrem.h"
#include "commands/event_trigger.h"
#include "commands/publicationcmds.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "parser/parse_clause.h"
#include "parser/parse_collate.h"
#include "parser/parse_relation.h"
#include "storage/lmgr.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/syscache.h"
#include "utils/varlena.h"
Go to the source code of this file.
Data Structures | |
struct | rf_context |
Typedefs | |
typedef struct rf_context | rf_context |
Functions | |
static List * | OpenTableList (List *tables) |
static void | CloseTableList (List *rels) |
static void | LockSchemaList (List *schemalist) |
static void | PublicationAddTables (Oid pubid, List *rels, bool if_not_exists, AlterPublicationStmt *stmt) |
static void | PublicationDropTables (Oid pubid, List *rels, bool missing_ok) |
static void | PublicationAddSchemas (Oid pubid, List *schemas, bool if_not_exists, AlterPublicationStmt *stmt) |
static void | PublicationDropSchemas (Oid pubid, List *schemas, bool missing_ok) |
static char | defGetGeneratedColsOption (DefElem *def) |
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 | ObjectsInPublicationToOids (List *pubobjspec_list, ParseState *pstate, List **rels, List **schemas) |
static bool | contain_invalid_rfcolumn_walker (Node *node, rf_context *context) |
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) |
static bool | contain_mutable_or_user_functions_checker (Oid func_id, void *context) |
static bool | check_simple_rowfilter_expr_walker (Node *node, ParseState *pstate) |
static bool | check_simple_rowfilter_expr (Node *node, ParseState *pstate) |
static void | TransformPubWhereClauses (List *tables, const char *queryString, bool pubviaroot) |
static void | CheckPubRelationColumnList (char *pubname, List *tables, bool publish_schema, bool pubviaroot) |
ObjectAddress | CreatePublication (ParseState *pstate, CreatePublicationStmt *stmt) |
static void | AlterPublicationOptions (ParseState *pstate, AlterPublicationStmt *stmt, Relation rel, HeapTuple tup) |
void | InvalidatePublicationRels (List *relids) |
static void | AlterPublicationTables (AlterPublicationStmt *stmt, HeapTuple tup, List *tables, const char *queryString, bool publish_schema) |
static void | AlterPublicationSchemas (AlterPublicationStmt *stmt, HeapTuple tup, List *schemaidlist) |
static void | CheckAlterPublication (AlterPublicationStmt *stmt, HeapTuple tup, List *tables, List *schemaidlist) |
void | AlterPublication (ParseState *pstate, AlterPublicationStmt *stmt) |
void | RemovePublicationRelById (Oid proid) |
void | RemovePublicationById (Oid pubid) |
void | RemovePublicationSchemaById (Oid psoid) |
static void | AlterPublicationOwner_internal (Relation rel, HeapTuple tup, Oid newOwnerId) |
ObjectAddress | AlterPublicationOwner (const char *name, Oid newOwnerId) |
void | AlterPublicationOwner_oid (Oid subid, Oid newOwnerId) |
typedef struct rf_context rf_context |
void AlterPublication | ( | ParseState * | pstate, |
AlterPublicationStmt * | stmt | ||
) |
Definition at line 1418 of file publicationcmds.c.
References AccessExclusiveLock, aclcheck_error(), ACLCHECK_NOT_OWNER, AlterPublicationOptions(), AlterPublicationSchemas(), AlterPublicationTables(), CheckAlterPublication(), CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, GETSTRUCT(), GetUserId(), heap_freetuple(), HeapTupleIsValid, LockDatabaseObject(), NIL, object_ownercheck(), OBJECT_PUBLICATION, ObjectIdGetDatum(), ObjectsInPublicationToOids(), ParseState::p_sourcetext, RowExclusiveLock, SearchSysCacheCopy1, stmt, table_close(), and table_open().
Referenced by ProcessUtilitySlow().
|
static |
Definition at line 916 of file publicationcmds.c.
References AccessShareLock, Assert, BoolGetDatum(), CacheInvalidateRelcacheAll(), CatalogTupleUpdate(), CharGetDatum(), CommandCounterIncrement(), ereport, errcode(), errdetail(), errmsg(), ERROR, EventTriggerCollectSimpleCommand(), get_rel_name(), get_rel_relkind(), GetAllSchemaPublicationRelations(), GetPublicationRelations(), GetPubPartitionOptionRelations(), GETSTRUCT(), heap_attisnull(), heap_modify_tuple(), HeapTupleIsValid, InvalidatePublicationRels(), InvalidObjectAddress, InvokeObjectPostAlterHook, lfirst_oid, list_concat_unique_oid(), LockDatabaseObject(), NIL, ObjectAddressSet, ObjectIdGetDatum(), parse_publication_options(), PublicationActions::pubdelete, PublicationActions::pubinsert, PUBLICATION_PART_ALL, PUBLICATION_PART_ROOT, PublicationActions::pubtruncate, PublicationActions::pubupdate, RelationGetDescr, ReleaseSysCache(), relname, SearchSysCache2(), stmt, HeapTupleData::t_self, and values.
Referenced by AlterPublication().
ObjectAddress AlterPublicationOwner | ( | const char * | name, |
Oid | newOwnerId | ||
) |
Definition at line 1993 of file publicationcmds.c.
References AlterPublicationOwner_internal(), CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, GETSTRUCT(), heap_freetuple(), HeapTupleIsValid, name, ObjectAddressSet, RowExclusiveLock, SearchSysCacheCopy1, table_close(), and table_open().
Referenced by ExecAlterOwnerStmt().
Definition at line 1935 of file publicationcmds.c.
References ACL_CREATE, aclcheck_error(), ACLCHECK_NOT_OWNER, ACLCHECK_OK, CatalogTupleUpdate(), changeDependencyOnOwner(), check_can_set_role(), ereport, errcode(), errhint(), errmsg(), ERROR, get_database_name(), GETSTRUCT(), GetUserId(), InvokeObjectPostAlterHook, is_schema_publication(), MyDatabaseId, NameStr, object_aclcheck(), OBJECT_DATABASE, object_ownercheck(), OBJECT_PUBLICATION, superuser(), superuser_arg(), and HeapTupleData::t_self.
Referenced by AlterPublicationOwner(), and AlterPublicationOwner_oid().
Definition at line 2028 of file publicationcmds.c.
References AlterPublicationOwner_internal(), ereport, errcode(), errmsg(), ERROR, heap_freetuple(), HeapTupleIsValid, ObjectIdGetDatum(), RowExclusiveLock, SearchSysCacheCopy1, table_close(), and table_open().
Referenced by shdepReassignOwned_Owner().
|
static |
Definition at line 1296 of file publicationcmds.c.
References AP_AddObjects, AP_DropObjects, AP_SetObjects, ereport, errcode(), errdetail(), errmsg(), ERROR, GetPublicationRelations(), GetPublicationSchemas(), GETSTRUCT(), heap_attisnull(), HeapTupleIsValid, lfirst_oid, list_difference_oid(), LockSchemaList(), NIL, ObjectIdGetDatum(), PUBLICATION_PART_ROOT, PublicationAddSchemas(), PublicationDropSchemas(), ReleaseSysCache(), SearchSysCache2(), and stmt.
Referenced by AlterPublication().
|
static |
Definition at line 1134 of file publicationcmds.c.
References AP_AddObjects, AP_DropObjects, AP_SetObjects, bms_equal(), CheckPubRelationColumnList(), CloseTableList(), PublicationRelInfo::columns, equal(), GetPublicationRelations(), GETSTRUCT(), HeapTupleIsValid, is_schema_publication(), lappend(), lfirst, lfirst_oid, NIL, ObjectIdGetDatum(), OpenTableList(), palloc(), pub_collist_to_bitmapset(), pub_collist_validate(), PUBLICATION_PART_ROOT, PublicationAddTables(), PublicationDropTables(), PublicationRelInfo::relation, RelationGetRelid, ReleaseSysCache(), SearchSysCache2(), ShareUpdateExclusiveLock, stmt, stringToNode(), SysCacheGetAttr(), table_open(), TextDatumGetCString, TransformPubWhereClauses(), and PublicationRelInfo::whereClause.
Referenced by AlterPublication().
|
static |
Definition at line 629 of file publicationcmds.c.
References check_simple_rowfilter_expr_walker().
Referenced by TransformPubWhereClauses().
|
static |
Definition at line 522 of file publicationcmds.c.
References _, check_functions_in_node(), check_simple_rowfilter_expr_walker(), contain_mutable_or_user_functions_checker(), ereport, errcode(), errdetail_internal(), errmsg(), ERROR, exprCollation(), expression_tree_walker, exprInputCollation(), exprLocation(), exprType(), FirstNormalObjectId, InvalidAttrNumber, IsA, lfirst_oid, nodeTag, and parser_errposition().
Referenced by check_simple_rowfilter_expr(), and check_simple_rowfilter_expr_walker().
|
static |
Definition at line 1380 of file publicationcmds.c.
References AP_AddObjects, AP_SetObjects, ereport, errcode(), errdetail(), errmsg(), ERROR, GETSTRUCT(), NameStr, stmt, and superuser().
Referenced by AlterPublication().
|
static |
Definition at line 716 of file publicationcmds.c.
References PublicationRelInfo::columns, ereport, errcode(), errdetail(), errmsg(), ERROR, get_namespace_name(), lfirst, NIL, RelationData::rd_rel, PublicationRelInfo::relation, RelationGetNamespace, and RelationGetRelationName.
Referenced by AlterPublicationTables(), and CreatePublication().
|
static |
Definition at line 1746 of file publicationcmds.c.
References lfirst, list_free_deep(), NoLock, PublicationRelInfo::relation, and table_close().
Referenced by AlterPublicationTables(), and CreatePublication().
|
static |
Definition at line 231 of file publicationcmds.c.
References attnum, bms_is_member(), rf_context::bms_replident, contain_invalid_rfcolumn_walker(), expression_tree_walker, FirstLowInvalidHeapAttributeNumber, get_attname(), get_attnum(), IsA, rf_context::parentid, rf_context::pubviaroot, rf_context::relid, and Var::varattno.
Referenced by contain_invalid_rfcolumn_walker(), and pub_rf_contains_invalid_column().
|
static |
Definition at line 477 of file publicationcmds.c.
References FirstNormalObjectId, and func_volatile().
Referenced by check_simple_rowfilter_expr_walker().
ObjectAddress CreatePublication | ( | ParseState * | pstate, |
CreatePublicationStmt * | stmt | ||
) |
Definition at line 767 of file publicationcmds.c.
References ACL_CREATE, aclcheck_error(), ACLCHECK_OK, BoolGetDatum(), CacheInvalidateRelcacheAll(), CatalogTupleInsert(), CharGetDatum(), CheckPubRelationColumnList(), CloseTableList(), CommandCounterIncrement(), CStringGetDatum(), DirectFunctionCall1, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errhint(), errmsg(), ERROR, get_database_name(), GetNewOidWithIndex(), GetSysCacheOid1, GetUserId(), heap_form_tuple(), heap_freetuple(), InvokeObjectPostCreateHook, LockSchemaList(), MyDatabaseId, namein(), NIL, 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_LOGICAL, and WARNING.
Referenced by ProcessUtilitySlow().
|
static |
Definition at line 2054 of file publicationcmds.c.
References DefElem::arg, defGetString(), DefElem::defname, ereport, errcode(), errmsg(), ERROR, and pg_strcasecmp().
Referenced by parse_publication_options().
void InvalidatePublicationRels | ( | List * | relids | ) |
Definition at line 1113 of file publicationcmds.c.
References CacheInvalidateRelcacheAll(), CacheInvalidateRelcacheByRelid(), lfirst_oid, list_length(), and MAX_RELCACHE_INVAL_MSGS.
Referenced by AlterPublicationOptions(), publication_add_relation(), publication_add_schema(), RemovePublicationRelById(), and RemovePublicationSchemaById().
|
static |
Definition at line 1766 of file publicationcmds.c.
References AccessShareLock, CHECK_FOR_INTERRUPTS, ereport, errcode(), errmsg(), ERROR, lfirst_oid, LockDatabaseObject(), ObjectIdGetDatum(), and SearchSysCacheExists1.
Referenced by AlterPublicationSchemas(), and CreatePublication().
|
static |
Definition at line 178 of file publicationcmds.c.
References elog, ereport, errcode(), errmsg(), ERROR, fetch_search_path(), get_namespace_oid(), lappend(), lfirst, linitial_oid, list_append_unique_oid(), list_free(), PublicationObjSpec::name, NIL, PUBLICATIONOBJ_TABLE, PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA, PUBLICATIONOBJ_TABLES_IN_SCHEMA, PublicationObjSpec::pubobjtype, and PublicationObjSpec::pubtable.
Referenced by AlterPublication(), and CreatePublication().
Definition at line 1596 of file publicationcmds.c.
References CHECK_FOR_INTERRUPTS, PublicationRelInfo::columns, PublicationTable::columns, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, find_all_inheritors(), RangeVar::inh, lappend(), lappend_oid(), lfirst_node, lfirst_oid, list_free(), list_member_oid(), NIL, NoLock, palloc(), RelationData::rd_rel, PublicationRelInfo::relation, PublicationTable::relation, RelationGetRelationName, RelationGetRelid, ShareUpdateExclusiveLock, table_close(), table_open(), table_openrv(), PublicationRelInfo::whereClause, and PublicationTable::whereClause.
Referenced by AlterPublicationTables(), and CreatePublication().
|
static |
Definition at line 77 of file publicationcmds.c.
References defGetBoolean(), defGetGeneratedColsOption(), defGetString(), DefElem::defname, ereport, errcode(), errmsg(), ERROR, errorConflictingDefElem(), if(), lfirst, PublicationActions::pubdelete, PublicationActions::pubinsert, PublicationActions::pubtruncate, PublicationActions::pubupdate, and SplitIdentifierString().
Referenced by AlterPublicationOptions(), and CreatePublication().
bool pub_contains_invalid_column | ( | Oid | pubid, |
Relation | relation, | ||
List * | ancestors, | ||
bool | pubviaroot, | ||
char | pubgencols_type, | ||
bool * | invalid_column_list, | ||
bool * | invalid_gen_col | ||
) |
Definition at line 356 of file publicationcmds.c.
References attnum, bms_free(), bms_is_member(), bms_next_member(), check_and_fetch_column_list(), TupleDescData::constr, FirstLowInvalidHeapAttributeNumber, get_attname(), get_attnum(), GetPublication(), GetTopMostAncestorInPublication(), TupleConstr::has_generated_stored, INDEX_ATTR_BITMAP_IDENTITY_KEY, OidIsValid, RelationData::rd_att, RelationData::rd_rel, RelationGetDescr, RelationGetIndexAttrBitmap(), RelationGetRelid, TupleDescAttr(), and x.
Referenced by RelationBuildPublicationDesc().
bool pub_rf_contains_invalid_column | ( | Oid | pubid, |
Relation | relation, | ||
List * | ancestors, | ||
bool | pubviaroot | ||
) |
Definition at line 270 of file publicationcmds.c.
References rf_context::bms_replident, contain_invalid_rfcolumn_walker(), 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().
|
static |
Definition at line 1873 of file publicationcmds.c.
References Assert, EventTriggerCollectSimpleCommand(), InvalidObjectAddress, InvokeObjectPostCreateHook, lfirst_oid, ObjectAddress::objectId, publication_add_schema(), and stmt.
Referenced by AlterPublicationSchemas(), and CreatePublication().
|
static |
Definition at line 1794 of file publicationcmds.c.
References aclcheck_error(), ACLCHECK_NOT_OWNER, Assert, EventTriggerCollectSimpleCommand(), get_relkind_objtype(), GetUserId(), InvalidObjectAddress, InvokeObjectPostCreateHook, lfirst, object_ownercheck(), ObjectAddress::objectId, publication_add_relation(), RelationData::rd_rel, PublicationRelInfo::relation, RelationGetRelationName, RelationGetRelid, and stmt.
Referenced by AlterPublicationTables(), and CreatePublication().
Definition at line 1901 of file publicationcmds.c.
References DROP_CASCADE, ereport, errcode(), errmsg(), ERROR, get_namespace_name(), GetSysCacheOid2, lfirst_oid, ObjectAddressSet, ObjectIdGetDatum(), OidIsValid, and performDeletion().
Referenced by AlterPublicationSchemas().
Definition at line 1828 of file publicationcmds.c.
References PublicationRelInfo::columns, DROP_CASCADE, ereport, errcode(), errmsg(), ERROR, GetSysCacheOid2, lfirst, ObjectAddressSet, ObjectIdGetDatum(), OidIsValid, performDeletion(), PublicationRelInfo::relation, RelationGetRelationName, RelationGetRelid, and PublicationRelInfo::whereClause.
Referenced by AlterPublicationTables().
void RemovePublicationById | ( | Oid | pubid | ) |
Definition at line 1529 of file publicationcmds.c.
References CacheInvalidateRelcacheAll(), CatalogTupleDelete(), elog, ERROR, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by doDeletion().
void RemovePublicationRelById | ( | Oid | proid | ) |
Definition at line 1488 of file publicationcmds.c.
References CatalogTupleDelete(), elog, ERROR, GetPubPartitionOptionRelations(), GETSTRUCT(), HeapTupleIsValid, InvalidatePublicationRels(), NIL, ObjectIdGetDatum(), PUBLICATION_PART_ALL, ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by doDeletion().
void RemovePublicationSchemaById | ( | Oid | psoid | ) |
Definition at line 1558 of file publicationcmds.c.
References CatalogTupleDelete(), elog, ERROR, GetSchemaPublicationRelations(), GETSTRUCT(), HeapTupleIsValid, InvalidatePublicationRels(), NIL, ObjectIdGetDatum(), PUBLICATION_PART_ALL, ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by doDeletion().
|
static |
Definition at line 644 of file publicationcmds.c.
References AccessShareLock, addNSItemToQuery(), addRangeTableEntryForRelation(), assign_expr_collations(), check_simple_rowfilter_expr(), copyObject, ereport, errcode(), errdetail(), errmsg(), ERROR, EXPR_KIND_WHERE, free_parsestate(), lfirst, make_parsestate(), ParseState::p_sourcetext, RelationData::rd_rel, PublicationRelInfo::relation, RelationGetRelationName, transformWhereClause(), and PublicationRelInfo::whereClause.
Referenced by AlterPublicationTables(), and CreatePublication().