Thread: pgsql: Make query jumbling also squash PARAM_EXTERN params

pgsql: Make query jumbling also squash PARAM_EXTERN params

From
Álvaro Herrera
Date:
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c2da1a5d6325a92d834c9cb036f65d362e4bfc3e

Modified Files
--------------
contrib/pg_stat_statements/expected/extended.out  |  60 ++++++--
contrib/pg_stat_statements/expected/squashing.out |  26 ++--
contrib/pg_stat_statements/pg_stat_statements.c   |  10 ++
contrib/pg_stat_statements/sql/extended.sql       |  11 +-
contrib/pg_stat_statements/sql/squashing.sql      |   4 +-
src/backend/nodes/queryjumblefuncs.c              | 160 +++++++++++++---------
src/include/nodes/primnodes.h                     |   6 +-
src/include/nodes/queryjumble.h                   |  19 ++-
8 files changed, 198 insertions(+), 98 deletions(-)