Skip to content

Commit e52fdbb

Browse files
committed
Merge branch 'xtm' of gitlab.postgrespro.ru:pgpro-dev/postgrespro into xtm
2 parents 6096224 + c85a14c commit e52fdbb

16 files changed

+2889
-77
lines changed

contrib/multimaster/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
MODULE_big = multimaster
2-
OBJS = multimaster.o receiver_raw.o decoder_raw.o libdtm.o bytebuf.o bgwpool.o sockhub/sockhub.o
3-
2+
OBJS = multimaster.o libdtm.o bytebuf.o bgwpool.o sockhub/sockhub.o pglogical_output.o pglogical_proto.o pglogical_receiver.o pglogical_apply.o pglogical_hooks.o pglogical_config.o
3+
#OBJS = multimaster.o pglogical_receiver.o decoder_raw.o libdtm.o bytebuf.o bgwpool.o sockhub/sockhub.o
44
EXTENSION = multimaster
55
DATA = multimaster--1.0.sql
66

7-
PG_CPPFLAGS = -I$(libpq_srcdir)
7+
PG_CPPFLAGS = -I$(libpq_srcdir) -DUSE_PGLOGICAL_OUTPUT
88
SHLIB_LINK = $(libpq)
99

1010
ifdef USE_PGXS

contrib/multimaster/Makefile.old

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
MODULE_big = multimaster
2+
OBJS = multimaster.o pglogical_receiver.o decoder_raw.o libdtm.o bytebuf.o bgwpool.o sockhub/sockhub.o
3+
EXTENSION = multimaster
4+
DATA = multimaster--1.0.sql
5+
6+
PG_CPPFLAGS = -I$(libpq_srcdir)
7+
SHLIB_LINK = $(libpq)
8+
9+
ifdef USE_PGXS
10+
PG_CONFIG = pg_config
11+
PGXS := $(shell $(PG_CONFIG) --pgxs)
12+
include $(PGXS)
13+
else
14+
subdir = contrib/multimaster
15+
top_builddir = ../..
16+
include $(top_builddir)/src/Makefile.global
17+
include $(top_srcdir)/contrib/contrib-global.mk
18+
endif
19+

contrib/multimaster/multimaster.c

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "access/xlog.h"
2929
#include "storage/proc.h"
3030
#include "storage/procarray.h"
31-
#include "executor/spi.h"
3231
#include "executor/executor.h"
3332
#include "access/twophase.h"
3433
#include "utils/guc.h"
@@ -104,7 +103,6 @@ static void DtmShmemStartup(void);
104103
static void DtmBackgroundWorker(Datum arg);
105104

106105
static void MMMarkTransAsLocal(TransactionId xid);
107-
static void MMExecutor(int id, void* work, size_t size);
108106
static BgwPool* MMPoolConstructor(void);
109107

110108
static shmem_startup_hook_type prev_shmem_startup_hook;
@@ -1185,48 +1183,7 @@ MMExecutorFinish(QueryDesc *queryDesc)
11851183
{
11861184
standard_ExecutorFinish(queryDesc);
11871185
}
1188-
}
1189-
1190-
static void MMExecutor(int id, void* work, size_t size)
1191-
{
1192-
TransactionId xid = *(TransactionId*)work;
1193-
char* stmts = (char*)work + 4;
1194-
bool finished = false;
1195-
1196-
MMJoinTransaction(xid);
1197-
1198-
SetCurrentStatementStartTimestamp();
1199-
StartTransactionCommand();
1200-
SPI_connect();
1201-
PushActiveSnapshot(GetTransactionSnapshot());
1202-
1203-
PG_TRY();
1204-
{
1205-
int rc = SPI_execute(stmts, false, 0);
1206-
SPI_finish();
1207-
PopActiveSnapshot();
1208-
finished = true;
1209-
if (rc != SPI_OK_INSERT && rc != SPI_OK_UPDATE && rc != SPI_OK_DELETE) {
1210-
ereport(LOG, (errmsg("Executor %d: failed to apply transaction %u",
1211-
id, xid)));
1212-
AbortCurrentTransaction();
1213-
} else {
1214-
CommitTransactionCommand();
1215-
}
1216-
}
1217-
PG_CATCH();
1218-
{
1219-
FlushErrorState();
1220-
if (!finished) {
1221-
SPI_finish();
1222-
if (ActiveSnapshotSet()) {
1223-
PopActiveSnapshot();
1224-
}
1225-
}
1226-
AbortCurrentTransaction();
1227-
}
1228-
PG_END_TRY();
1229-
}
1186+
}
12301187

12311188
extern void MMExecute(void* work, int size)
12321189
{

contrib/multimaster/multimaster.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ extern void MMJoinTransaction(TransactionId xid);
1313
extern bool MMIsLocalTransaction(TransactionId xid);
1414
extern void MMReceiverStarted(void);
1515
extern void MMExecute(void* work, int size);
16+
extern void MMExecutor(int id, void* work, size_t size);
1617

1718
extern char* MMDatabaseName;
1819

0 commit comments

Comments
 (0)