mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Fix squashing algorithm for query texts
The algorithm to squash lists of constants added by commit 62d712ecfd
was a bit too simplistic; we wanted to avoid adding unnecessary
complexity, but cases like direct function calls of typecasting
functions (and others) were missed, and bogus SQL syntax was being shown
in pg_stat_statements normalized query text field. To fix normalization
for those cases, we need the parser to transmit information about were
each list of constant values starts and ends, so add that to a couple of
nodes. Also add a few more test cases to make sure we're doing the
right thing.
The patch initially submitted by Sami added a new private struct in
gram.y to carry the start/end information for A_Expr, but I (Álvaro)
decided that a better fix was to remove the parser indirection via the
in_expr production, and instead create separate components in the a_expr
rule. I'm surprised that this works and doesn't require more changes,
but I assume (without checking) that the grammar used to be more complex
and got simplified at some point.
Bump catversion.
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:
@ -87,6 +87,14 @@ SELECT WHERE (1, 2) IN ((1, 2), (2, 3));
|
||||
SELECT WHERE (3, 4) IN ((5, 6), (8, 7));
|
||||
SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
|
||||
-- with the last element being an explicit function call with an argument, ensure
|
||||
-- the normalization of the squashing interval is correct.
|
||||
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
|
||||
SELECT pg_stat_statements_reset() IS NOT NULL AS t;
|
||||
SELECT WHERE 1 IN (1, int4(1), int4(2));
|
||||
SELECT WHERE 1 = ANY (ARRAY[1, int4(1), int4(2)]);
|
||||
SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
-- queries with locking clauses
|
||||
--
|
||||
|
Reference in New Issue
Block a user