Skip to content

Commit fbeac1b

Browse files
knizhnikkelvich
authored andcommitted
Fix make_table_local
1 parent 768f076 commit fbeac1b

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

multimaster--1.0.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,5 @@ CREATE FUNCTION mtm.check_deadlock(xid bigint) RETURNS boolean
8383
AS 'MODULE_PATHNAME','mtm_check_deadlock'
8484
LANGUAGE C;
8585

86-
-- CREATE TABLE IF NOT EXISTS public.ddl_log (issued timestamp with time zone not null, query text);
87-
88-
-- CREATE TABLE IF NOT EXISTS mtm.local_tables(rel_schema text, rel_name text, primary key(rel_schema, rel_name));
86+
CREATE TABLE IF NOT EXISTS mtm.local_tables(rel_schema text, rel_name text, primary key(rel_schema, rel_name));
8987

multimaster.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,7 @@ MtmCreateLocalTableMap(void)
23312331
return htab;
23322332
}
23332333

2334-
static void MtmMakeRelationLocal(Oid relid)
2334+
void MtmMakeRelationLocal(Oid relid)
23352335
{
23362336
if (OidIsValid(relid)) {
23372337
MtmLock(LW_EXCLUSIVE);
@@ -2341,7 +2341,7 @@ static void MtmMakeRelationLocal(Oid relid)
23412341
}
23422342

23432343

2344-
void MtmMakeTableLocal(char* schema, char* name)
2344+
static void MtmMakeTableLocal(char* schema, char* name)
23452345
{
23462346
RangeVar* rv = makeRangeVar(schema, name, -1);
23472347
Oid relid = RangeVarGetRelid(rv, NoLock, true);
@@ -4179,7 +4179,7 @@ mtm_get_cluster_info(PG_FUNCTION_ARGS)
41794179

41804180
Datum mtm_make_table_local(PG_FUNCTION_ARGS)
41814181
{
4182-
Oid reloid = PG_GETARG_OID(1);
4182+
Oid reloid = PG_GETARG_OID(0);
41834183
RangeVar *rv;
41844184
Relation rel;
41854185
TupleDesc tupDesc;
@@ -4192,8 +4192,8 @@ Datum mtm_make_table_local(PG_FUNCTION_ARGS)
41924192
rv = makeRangeVar(MULTIMASTER_SCHEMA_NAME, MULTIMASTER_LOCAL_TABLES_TABLE, -1);
41934193
rel = heap_openrv(rv, RowExclusiveLock);
41944194
if (rel != NULL) {
4195-
char* tableName = get_rel_name(reloid);
4196-
Oid schemaid = get_rel_namespace(reloid);
4195+
char* tableName = RelationGetRelationName(rel);
4196+
Oid schemaid = RelationGetNamespace(rel);
41974197
char* schemaName = get_namespace_name(schemaid);
41984198

41994199
tupDesc = RelationGetDescr(rel);

multimaster.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ extern void MtmCheckQuorum(void);
396396
extern bool MtmRecoveryCaughtUp(int nodeId, lsn_t walEndPtr);
397397
extern void MtmCheckRecoveryCaughtUp(int nodeId, lsn_t slotLSN);
398398
extern void MtmRecoveryCompleted(void);
399-
extern void MtmMakeTableLocal(char* schema, char* name);
399+
extern void MtmMakeRelationLocal(Oid relid);
400400
extern void MtmHandleApplyError(void);
401401
extern void MtmUpdateLsnMapping(int nodeId, lsn_t endLsn);
402402
extern lsn_t MtmGetFlushPosition(int nodeId);

pglogical_apply.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,10 +818,16 @@ process_remote_insert(StringInfo s, Relation rel)
818818
if (ActiveSnapshotSet())
819819
PopActiveSnapshot();
820820

821+
if (strcmp(RelationGetRelationName(rel), MULTIMASTER_LOCAL_TABLES_TABLE) == 0 &&
822+
strcmp(get_namespace_name(RelationGetNamespace(rel)), MULTIMASTER_SCHEMA_NAME) == 0)
823+
{
824+
MtmMakeRelationLocal(RelationGetRelid(rel));
825+
}
826+
821827
heap_close(rel, NoLock);
822828
ExecResetTupleTable(estate->es_tupleTable, true);
823829
FreeExecutorState(estate);
824-
830+
825831
CommandCounterIncrement();
826832
}
827833

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy