1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

Small cleanups related to PUBLICATION framework code

Discussion: https://postgr.es/m/202112302021.ca7ihogysgh3@alvherre.pgsql
This commit is contained in:
Alvaro Herrera
2021-12-30 19:24:26 -03:00
parent c7cf73eb7b
commit c9105dd366
6 changed files with 40 additions and 34 deletions

View File

@@ -48,7 +48,7 @@
#include "utils/syscache.h"
#include "utils/varlena.h"
static List *OpenReliIdList(List *relids);
static List *OpenRelIdList(List *relids);
static List *OpenTableList(List *tables);
static void CloseTableList(List *rels);
static void LockSchemaList(List *schemalist);
@@ -169,13 +169,13 @@ ObjectsInPublicationToOids(List *pubobjspec_list, ParseState *pstate,
case PUBLICATIONOBJ_TABLE:
*rels = lappend(*rels, pubobj->pubtable);
break;
case PUBLICATIONOBJ_TABLE_IN_SCHEMA:
case PUBLICATIONOBJ_TABLES_IN_SCHEMA:
schemaid = get_namespace_oid(pubobj->name, false);
/* Filter out duplicates if user specifies "sch1, sch1" */
*schemas = list_append_unique_oid(*schemas, schemaid);
break;
case PUBLICATIONOBJ_TABLE_IN_CUR_SCHEMA:
case PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA:
search_path = fetch_search_path(false);
if (search_path == NIL) /* nothing valid in search_path? */
ereport(ERROR,
@@ -214,7 +214,7 @@ CheckObjSchemaNotAlreadyInPublication(List *rels, List *schemaidlist,
if (list_member_oid(schemaidlist, relSchemaId))
{
if (checkobjtype == PUBLICATIONOBJ_TABLE_IN_SCHEMA)
if (checkobjtype == PUBLICATIONOBJ_TABLES_IN_SCHEMA)
ereport(ERROR,
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot add schema \"%s\" to publication",
@@ -499,8 +499,9 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
Oid pubid = pubform->oid;
/*
* It is quite possible that for the SET case user has not specified any
* tables in which case we need to remove all the existing tables.
* Nothing to do if no objects, except in SET: for that it is quite
* possible that user has not specified any tables in which case we need
* to remove all the existing tables.
*/
if (!tables && stmt->action != DEFELEM_SET)
return;
@@ -593,8 +594,9 @@ AlterPublicationSchemas(AlterPublicationStmt *stmt,
Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
/*
* It is quite possible that for the SET case user has not specified any
* schemas in which case we need to remove all the existing schemas.
* Nothing to do if no objects, except in SET: for that it is quite
* possible that user has not specified any schemas in which case we need
* to remove all the existing schemas.
*/
if (!schemaidlist && stmt->action != DEFELEM_SET)
return;
@@ -610,10 +612,10 @@ AlterPublicationSchemas(AlterPublicationStmt *stmt,
List *reloids;
reloids = GetPublicationRelations(pubform->oid, PUBLICATION_PART_ROOT);
rels = OpenReliIdList(reloids);
rels = OpenRelIdList(reloids);
CheckObjSchemaNotAlreadyInPublication(rels, schemaidlist,
PUBLICATIONOBJ_TABLE_IN_SCHEMA);
PUBLICATIONOBJ_TABLES_IN_SCHEMA);
CloseTableList(rels);
PublicationAddSchemas(pubform->oid, schemaidlist, false, stmt);
@@ -813,7 +815,7 @@ RemovePublicationById(Oid pubid)
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for publication %u", pubid);
pubform = (Form_pg_publication)GETSTRUCT(tup);
pubform = (Form_pg_publication) GETSTRUCT(tup);
/* Invalidate relcache so that publication info is rebuilt. */
if (pubform->puballtables)
@@ -868,7 +870,7 @@ RemovePublicationSchemaById(Oid psoid)
* add them to a publication.
*/
static List *
OpenReliIdList(List *relids)
OpenRelIdList(List *relids)
{
ListCell *lc;
List *rels = NIL;

View File

@@ -40,8 +40,8 @@
#include "catalog/pg_inherits.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
#include "catalog/storage.h"
@@ -15626,7 +15626,6 @@ ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode
else
elog(ERROR, "unexpected identity type %u", stmt->identity_type);
/* Check that the index exists */
indexOid = get_relname_relid(stmt->name, rel->rd_rel->relnamespace);
if (!OidIsValid(indexOid))