[pgpool-committers: 9183] pgpool: Allow to use multiple statements extensively.
Tatsuo Ishii
ishii at sraoss.co.jp
Wed Feb 15 17:18:31 JST 2023
Allow to use multiple statements extensively.
This commit tries to eliminate pgpool's long standing limitations
regarding multiple statements (multi-statements).
Previously
BEGIN;SELECT;
SAVEPOINT foo;
will fail in streaming replication mode because "BEGIN" was sent to
the primar node, but "SAVEPOINT" will be sent to both the primary and
standbys, and standbys will complain "SAVEPOINT can only be used in
transaction blocks".
Basic idea to solve the problem is, tracking explicit transactions
started by multi-statement queries so that all commands including
PREPARE, EXECUTE, DEALLOCATE, SAVEPOINT and COMMIT/ROLLBACK are sent
to the primary node in streaming replication mode or logical
replication mode. In native replication or snapshot isolation mode,
those queries are sent to all of the backend nodes.
For this purpose new member: is_tx_started_by_multi_statement is added
to session context and also support functions are added.
extern bool is_tx_started_by_multi_statement_query(void);
extern void set_tx_started_by_multi_statement_query(void);
extern void unset_tx_started_by_multi_statement_query(void);
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-February/004287.html
Back-patch-through: 4.2 as backport to 4.1 and before looks difficult
Branch
------
master
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=fd32f5ef996cad36d5b1554e92a33ea7a815419a
Modified Files
--------------
src/context/pool_query_context.c | 31 ++++++++++++++++++--
src/context/pool_session_context.c | 46 +++++++++++++++++++++++++++++-
src/include/context/pool_session_context.h | 14 ++++++++-
src/protocol/CommandComplete.c | 39 ++++++++++++++++++++++++-
src/protocol/pool_process_query.c | 12 ++++++++
src/protocol/pool_proto_modules.c | 5 +++-
6 files changed, 140 insertions(+), 7 deletions(-)
More information about the pgpool-committers
mailing list