postgresql/src/backend
Michael Paquier b36ee879c5 Add missing query ID reporting in extended query protocol
This commit adds query ID reports for two code paths when processing
extended query protocol messages:
- When receiving a bind message, setting it to the first Query retrieved
from a cached cache.
- When receiving an execute message, setting it to the first PlannedStmt
stored in a portal.

An advantage of this method is that this is able to cover all the types
of portals handled in the extended query protocol, particularly these
two when the report done in ExecutorStart() is not enough (neither is an
addition in ExecutorRun(), actually, for the second point):
- Multiple execute messages, with multiple ExecutorRun().
- Portal with execute/fetch messages, like a query with a RETURNING
clause and a fetch size that stores the tuples in a first execute
message going though ExecutorStart() and ExecuteRun(), followed by one
or more execute messages doing only fetches from the tuplestore created
in the first message.  This corresponds to the case where
execute_is_fetch is set, for example.

Note that the query ID reporting done in ExecutorStart() is still
necessary, as an EXECUTE requires it.  Query ID reporting is optimistic
and more calls to pgstat_report_query_id() don't matter as the first
report takes priority except if the report is forced.  The comment in
ExecutorStart() is adjusted to reflect better the reality with the
extended query protocol.

The test added in pg_stat_statements is a courtesy of Robert Haas.  This
uses psql's \bind metacommand, hence this part is backpatched down to
v16.

Reported-by:  Kaido Vaikla, Erik Wienhold
Author: Sami Imseih
Reviewed-by: Jian He, Andrei Lepikhov, Michael Paquier
Discussion: https://postgr.es/m/CA+427g8DiW3aZ6pOpVgkPbqK97ouBdf18VLiHFesea2jUk3XoQ@mail.gmail.com
Discussion: https://postgr.es/m/CA+TgmoZxtnf_jZ=VqBSyaU8hfUkkwoJCJ6ufy4LGpXaunKrjrg@mail.gmail.com
Discussion: https://postgr.es/m/1391613709.939460.1684777418070@office.mailbox.org
Backpatch-through: 14
2024-09-18 09:59:26 +09:00
..
access Allow _h_indexbuild() to be interrupted. 2024-09-13 16:16:47 -04:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -04:00
catalog Reset relhassubclass upon attaching table as a partition 2024-07-24 12:38:18 +02:00
commands Fix waits of REINDEX CONCURRENTLY for indexes with predicates or expressions 2024-09-09 13:50:16 +09:00
executor Add missing query ID reporting in extended query protocol 2024-09-18 09:59:26 +09:00
foreign Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:23 -07:00
jit Fix illegal attribute propagation in LLVM JIT. 2024-04-10 12:15:07 +12:00
lib Fix lock assertions in dshash.c. 2022-07-11 15:47:12 +12:00
libpq Fix regression in TLS session ticket disabling 2024-08-19 12:55:11 +02:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:38 +09:00
nodes Remove inappropriate raw_expression_tree_walker() code 2023-06-29 10:35:53 +02:00
optimizer Avoid failure to open dropped detached partition 2024-08-19 16:09:10 -04:00
parser Remove incorrect Assert. 2024-09-11 11:42:14 -04:00
partitioning Fix creation of partition descriptor during concurrent detach+drop 2024-08-12 18:17:56 -04:00
po Translation updates 2024-08-05 12:22:08 +02:00
port Close socket in case of errors in setting non-blocking 2024-01-17 11:24:11 +01:00
postmaster Fix bugs in MultiXact truncation 2024-06-26 23:06:12 +03:00
regex Avoid character classification in regex escape parsing. 2023-04-21 08:20:32 -07:00
replication Fix possibility of logical decoding partial transaction changes. 2024-07-11 22:48:13 +09:00
rewrite Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:23 -07:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Fix incorrectly reported stats kind in "can't happen" ERROR 2024-03-05 16:18:42 +13:00
storage Fix lost Windows socket EOF events. 2024-07-13 15:43:43 +12:00
tcop Add missing query ID reporting in extended query protocol 2024-09-18 09:59:26 +09:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Replace usages of xmlXPathCompile() with xmlXPathCtxtCompile(). 2024-09-15 13:33:09 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
nls.mk Translation updates 2021-09-20 16:23:13 +02:00