Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 34f64ad

Browse files
knizhnikkelvich
authored andcommitted
Fix PGPPRO-717 correctly restore name/schema of local tables
1 parent 1939014 commit 34f64ad

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

multimaster.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,7 @@ MtmCreateLocalTableMap(void)
25232523
return htab;
25242524
}
25252525

2526-
void MtmMakeRelationLocal(Oid relid)
2526+
static void MtmMakeRelationLocal(Oid relid)
25272527
{
25282528
if (OidIsValid(relid)) {
25292529
MtmLock(LW_EXCLUSIVE);
@@ -2533,17 +2533,17 @@ void MtmMakeRelationLocal(Oid relid)
25332533
}
25342534

25352535

2536-
static void MtmMakeTableLocal(char* schema, char* name)
2536+
void MtmMakeTableLocal(char const* schema, char const* name)
25372537
{
2538-
RangeVar* rv = makeRangeVar(schema, name, -1);
2538+
RangeVar* rv = makeRangeVar((char*)schema, (char*)name, -1);
25392539
Oid relid = RangeVarGetRelid(rv, NoLock, true);
25402540
MtmMakeRelationLocal(relid);
25412541
}
25422542

25432543

25442544
typedef struct {
2545-
NameData schema;
2546-
NameData name;
2545+
text schema;
2546+
text name;
25472547
} MtmLocalTablesTuple;
25482548

25492549
static void MtmLoadLocalTables(void)
@@ -2563,7 +2563,7 @@ static void MtmLoadLocalTables(void)
25632563
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
25642564
{
25652565
MtmLocalTablesTuple *t = (MtmLocalTablesTuple*) GETSTRUCT(tuple);
2566-
MtmMakeTableLocal(NameStr(t->schema), NameStr(t->name));
2566+
MtmMakeTableLocal(text_to_cstring(&t->schema), text_to_cstring(&t->name));
25672567
}
25682568

25692569
systable_endscan(scan);

multimaster.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ extern void MtmCheckQuorum(void);
404404
extern bool MtmRecoveryCaughtUp(int nodeId, lsn_t walEndPtr);
405405
extern void MtmCheckRecoveryCaughtUp(int nodeId, lsn_t slotLSN);
406406
extern void MtmRecoveryCompleted(void);
407-
extern void MtmMakeRelationLocal(Oid relid);
407+
extern void MtmMakeTableLocal(char const* schema, char const* name);
408408
extern void MtmHandleApplyError(void);
409409
extern void MtmUpdateLsnMapping(int nodeId, lsn_t endLsn);
410410
extern lsn_t MtmGetFlushPosition(int nodeId);

pglogical_apply.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ process_remote_insert(StringInfo s, Relation rel)
860860
if (strcmp(RelationGetRelationName(rel), MULTIMASTER_LOCAL_TABLES_TABLE) == 0 &&
861861
strcmp(get_namespace_name(RelationGetNamespace(rel)), MULTIMASTER_SCHEMA_NAME) == 0)
862862
{
863-
MtmMakeRelationLocal(RelationGetRelid(rel));
863+
MtmMakeTableLocal(TextDatumGetCString(new_tuple.values[0]), TextDatumGetCString(new_tuple.values[1]));
864864
}
865865

866866
ExecResetTupleTable(estate->es_tupleTable, true);

0 commit comments

Comments
 (0)