Make query jumbling also squash PARAM_EXTERN params
authorÁlvaro Herrera <alvherre@kurilemu.de>
Tue, 24 Jun 2025 17:36:32 +0000 (19:36 +0200)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Tue, 24 Jun 2025 17:36:32 +0000 (19:36 +0200)
commitc2da1a5d6325a92d834c9cb036f65d362e4bfc3e
treed87b107d5097549a18677b1558354582fadd9d13
parentdebad29d22152d7fe4c4e671090e20238647c460
Make query jumbling also squash PARAM_EXTERN params

Commit 62d712ecfd94 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
contrib/pg_stat_statements/expected/extended.out
contrib/pg_stat_statements/expected/squashing.out
contrib/pg_stat_statements/pg_stat_statements.c
contrib/pg_stat_statements/sql/extended.sql
contrib/pg_stat_statements/sql/squashing.sql
src/backend/nodes/queryjumblefuncs.c
src/include/nodes/primnodes.h
src/include/nodes/queryjumble.h