postgresql/src/include
Tom Lane a0c632c1de Force immediate commit after CREATE DATABASE etc in extended protocol.
We have a few commands that "can't run in a transaction block",
meaning that if they complete their processing but then we fail
to COMMIT, we'll be left with inconsistent on-disk state.
However, the existing defenses for this are only watertight for
simple query protocol.  In extended protocol, we didn't commit
until receiving a Sync message.  Since the client is allowed to
issue another command instead of Sync, we're in trouble if that
command fails or is an explicit ROLLBACK.  In any case, sitting
in an inconsistent state while waiting for a client message
that might not come seems pretty risky.

This case wasn't reachable via libpq before we introduced pipeline
mode, but it's always been an intended aspect of extended query
protocol, and likely there are other clients that could reach it
before.

To fix, set a flag in PreventInTransactionBlock that tells
exec_execute_message to force an immediate commit.  This seems
to be the approach that does least damage to existing working
cases while still preventing the undesirable outcomes.

While here, add some documentation to protocol.sgml that explicitly
says how to use pipelining.  That's latent in the existing docs if
you know what to look for, but it's better to spell it out; and it
provides a place to document this new behavior.

Per bug #17434 from Yugo Nagata.  It's been wrong for ages,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/17434-d9f7a064ce2a88a3@postgresql.org
2022-07-26 13:07:03 -04:00
..
access Force immediate commit after CREATE DATABASE etc in extended protocol. 2022-07-26 13:07:03 -04:00
bootstrap Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
catalog Rename pg_checkpointer predefined role to pg_checkpoint. 2022-07-05 13:31:55 -04:00
commands Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
common Remove PGDLLIMPORT marker from __pg_log_level 2022-05-13 09:39:13 +09:00
datatype Fix overflow hazards in interval input and output conversions. 2022-04-02 16:12:29 -04:00
executor Remove size increase in ExprEvalStep caused by hashed saops 2022-07-06 19:41:09 +12:00
fe_utils Allow db.schema.table patterns, but complain about random garbage. 2022-04-20 11:37:29 -04:00
foreign Update copyright for 2022 2022-01-07 19:04:57 -05:00
jit Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
lib Improve frontend error logging style. 2022-04-08 14:55:14 -04:00
libpq Add some missing PGDLLIMPORT markings 2022-05-12 15:08:45 +09:00
mb Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
nodes Tidy up code in get_cheapest_group_keys_order() 2022-07-13 14:03:24 +12:00
optimizer Fix inconsistent parameter names between prototype and declaration 2022-07-15 15:27:14 +12:00
parser Make STRING an unreserved_keyword. 2022-05-30 14:05:20 -04:00
partitioning Refactor and cleanup runtime partition prune code a little 2022-04-05 11:46:48 +02:00
port windows: msvc: Define STDIN/OUT/ERR_FILENO. 2022-07-18 17:22:35 -07:00
portability Update copyright for 2022 2022-01-07 19:04:57 -05:00
postmaster Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
regex Update copyright for 2022 2022-01-07 19:04:57 -05:00
replication Fix data inconsistency between publisher and subscriber. 2022-06-16 08:45:07 +05:30
rewrite Update copyright for 2022 2022-01-07 19:04:57 -05:00
snowball Update copyright for 2022 2022-01-07 19:04:57 -05:00
statistics Add stxdinherit flag to pg_statistic_ext_data 2022-01-16 13:38:01 +01:00
storage Fix lock assertions in dshash.c. 2022-07-11 16:01:22 +12:00
tcop Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
tsearch Add missing 'extern' to function prototypes. 2022-05-12 12:39:33 -07:00
utils Fix missed corner cases for grantable permissions on GUCs. 2022-07-19 17:22:31 -04:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
fmgr.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
funcapi.h Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
getaddrinfo.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
getopt_long.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
Makefile Build in some knowledge about foreign-key relationships in the catalogs. 2021-02-02 17:11:55 -05:00
miscadmin.h Process session_preload_libraries within InitPostgres's transaction. 2022-07-25 10:27:43 -04:00
pg_config.h.in Simplify configure test 2022-05-04 14:20:36 +02:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Fix old-fd issues using global barriers everywhere. 2022-05-07 16:47:29 +12:00
pg_getopt.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
pg_trace.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pgstat.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
pgtar.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pgtime.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
port.h Invent qsort_interruptible(). 2022-07-12 16:30:36 -04:00
postgres.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
rusagestub.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
windowapi.h Update copyright for 2022 2022-01-07 19:04:57 -05:00