[HACKERS] [PATCH] Use $ parameters as replacement characters for pg_stat_statements - Mailing list pgsql-hackers

From Lukas Fittl
Subject [HACKERS] [PATCH] Use $ parameters as replacement characters for pg_stat_statements
Date
Msg-id CAP53PkxeaCuwYmF-A4J5z2-qk5fYFo5_NH3gpXGJJBxv1DMwEw@mail.gmail.com
Whole thread Raw
Responses Re: [HACKERS] [PATCH] Use $ parameters as replacement characters forpg_stat_statements  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
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


--
Lukas Fittl
Attachment

pgsql-hackers by date:

Previous
From: Rahila Syed
Date:
Subject: [HACKERS] Adding support for Default partition in partitioning
Next
From: Amit Langote
Date:
Subject: Re: [HACKERS] Declarative partitioning optimization for large amountof partitions