mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Make query jumbling also squash PARAM_EXTERN params
Commit 62d712ecfd
made query jumbling squash lists of Consts as a
single element, but there's no reason not to treat PARAM_EXTERN
parameters the same. For these purposes, these values are indeed
constants for any particular execution of a query.
In particular, this should make list squashing more useful for
applications using extended query protocol, which would use parameters
extensively.
A complication arises: if a query has both external parameters and
squashable lists, then the parameter number used as placeholder for the
squashed list might be inconsistent with regards to the parameter
numbers used by the query literal. To reduce the surprise factor, all
parameters are renumbered starting from 1 in that case.
Author: Sami Imseih <samimseih@gmail.com>
Author: Dmitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAA5RZ0tRXoPG2y6bMgBCWNDt0Tn=unRerbzYM=oW0syi1=C1OA@mail.gmail.com
This commit is contained in:
@ -32,7 +32,7 @@ SELECT WHERE 1 IN (1, int4(1), int4(2), 2);
|
||||
SELECT WHERE 1 = ANY (ARRAY[1, int4(1), int4(2), 2]);
|
||||
SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
|
||||
-- external parameters will not be squashed
|
||||
-- external parameters will be squashed
|
||||
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
|
||||
SELECT * FROM test_squash WHERE id IN ($1, $2, $3, $4, $5) \bind 1 2 3 4 5
|
||||
;
|
||||
@ -40,7 +40,7 @@ SELECT * FROM test_squash WHERE id::text = ANY(ARRAY[$1, $2, $3, $4, $5]) \bind
|
||||
;
|
||||
SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
|
||||
-- neither are prepared statements
|
||||
-- prepared statements will also be squashed
|
||||
-- the IN and ARRAY forms of this statement will have the same queryId
|
||||
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
|
||||
PREPARE p1(int, int, int, int, int) AS
|
||||
|
Reference in New Issue
Block a user