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

Commit e2424b9

Browse files
knizhnikkelvich
authored andcommitted
Create fake portal
1 parent f2afd06 commit e2424b9

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

bgwpool.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ static void BgwPoolMainLoop(BgwPool* pool)
2020
{
2121
int size;
2222
void* work;
23+
static PortalData fakePortal;
2324

2425
MtmIsLogicalReceiver = true;
2526

2627
BackgroundWorkerUnblockSignals();
2728
BackgroundWorkerInitializeConnection(pool->dbname, pool->dbuser);
28-
ActivePortal = CreatePortal("", true, true);
29+
ActivePortal = &fakePortal;
2930
ActivePortal->status = PORTAL_ACTIVE;
3031
ActivePortal->sourceText = "";
3132

multimaster.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ extern int MtmReplicationNodeId;
288288
extern int MtmNodes;
289289
extern int MtmArbiterPort;
290290
extern char* MtmDatabaseName;
291+
extern char* MtmDatabaseUser;
291292
extern int MtmConnectTimeout;
292293
extern int MtmReconnectTimeout;
293294
extern int MtmRaftPollDelay;

pglogical_apply.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ process_remote_transactional_message(StringInfo s)
371371
}
372372

373373
MTM_LOG1("%d: Executing utility statement %s", MyProcPid, stmt);
374-
SPI_connect();
374+
SPI_connect();
375+
ActivePortal->sourceText = stmt;
375376
rc = SPI_execute(stmt, false, 0);
376377
SPI_finish();
377378
if (rc < 0)
@@ -971,8 +972,8 @@ void MtmExecutor(void* work, size_t size)
971972
StringInfoData s;
972973
Relation rel = NULL;
973974
int spill_file = -1;
974-
int save_cursor;
975-
int save_len;
975+
int save_cursor = 0;
976+
int save_len = 0;
976977
s.data = work;
977978
s.len = size;
978979
s.maxlen = -1;

pglogical_receiver.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include "utils/memutils.h"
3636
#include "executor/spi.h"
3737
#include "replication/origin.h"
38+
#include "utils/portal.h"
39+
#include "tcop/pquery.h"
3840

3941
#include "multimaster.h"
4042
#include "spill.h"
@@ -218,6 +220,8 @@ pglogical_receiver_main(Datum main_arg)
218220
StringInfoData spill_info;
219221
char *slotName;
220222
char* connString = psprintf("replication=database %s", Mtm->nodes[nodeId-1].con.connStr);
223+
static PortalData fakePortal;
224+
221225
slotName = psprintf(MULTIMASTER_SLOT_PATTERN, MtmNodeId);
222226

223227
MtmIsLogicalReceiver = true;
@@ -239,7 +243,10 @@ pglogical_receiver_main(Datum main_arg)
239243
BackgroundWorkerUnblockSignals();
240244

241245
/* Connect to a database */
242-
BackgroundWorkerInitializeConnection(MtmDatabaseName, NULL);
246+
BackgroundWorkerInitializeConnection(MtmDatabaseName, MtmDatabaseUser);
247+
ActivePortal = &fakePortal;
248+
ActivePortal->status = PORTAL_ACTIVE;
249+
ActivePortal->sourceText = "";
243250

244251
/* This is main loop of logical replication.
245252
* In case of errors we will try to reestablish connection.

0 commit comments

Comments
 (0)