Hi, Currently pg_stat_statements replaces constant values with ? characters. I've seen this be a problem on multiple occasions, in particular since it conflicts with the use of ? as an operator.
I'd like to propose changing the replacement character from ? to instead be a parameter (like $1). My main motiviation is to aid external tools that parse pg_stat_statements output (like [0]), and currently have to resort to complex parser patches to distinguish operators from replacement characters. First of all, attached 0001_pgss_additional_regression_tests.v1.patch which increases regression test coverage for a few scenarios relevant to this discussion. Then, there is two variants I've prepared, only one of the two to be committed: A) 0002_pgss_mask_with_incrementing_params.v1.patch: Replace constants with $1, $2, $3 (etc) in the normalized query, whilst respecting any existing params in the counting B) 0003_pgss_mask_with_zero_param.v1.patch: Replace constants with $0 in the normalized query Ideally I'd see A turn into something we can commit, but it involves a bit more computation to get the parameter numbers right. The benefit is that we could use PREPARE/EXECUTE with pg_stat_statements output. B is intentionally simple, and would address the primary issue at hand (distinguishing from the ? operator). I'm also adding this patch to the commitfest starting tomorrow. Best, Lukas [0] https://github.com/lfittl/pg_query#parsing-a-normalized-query -- Lukas Fittl
0001_pgss_additional_regression_tests.v1.patch
Description: Binary data
0002_pgss_mask_with_incrementing_params.v1.patch
Description: Binary data
0003_pgss_mask_with_zero_param.v1.patch
Description: Binary data
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers