Re: Refactor query normalization into core query jumbling

From: Lukas Fittl <lukas(at)fittl(dot)com>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, zengman <zengman(at)halodbtech(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Julien Rouhaud <rjuju123(at)gmail(dot)com>
Subject: Re: Refactor query normalization into core query jumbling
Date: 2026-04-01 07:55:28
Message-ID: CAP53Pkx2s7O_fbmLoReKMeOXwp9Z=9e3uW4Tp9RMw99z_dSaiQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 31, 2026 at 7:54 PM Sami Imseih <samimseih(at)gmail(dot)com> wrote:
>
> > I'm +-0 regarding this routine, but I can also see your point about how it's
> > useful to give at least the option to extensions to have a
> > recomputation of the Const lengths, the same way as PGSS. What are
> > the extensions that would use that?
>
> https://github.com/search?q=fill_in_constant_lengths&type=code
>
> A few well-known extensions/tools out there based on a Github search.

See attached a v9 that extracts ComputeConstantLengths from Sami's v7
for easier discussion.

I've done an updated test with pg_stat_monitor [0] and pg_tracing [1]
with that, and that has both extensions passing regressions tests.
I've also looked but not tested a third extension (sql_firewall) and
that looks like it should just work as well.

Its worth noting that pg_tracing had a secondary use case for its
fill_in_constant_lengths function, which is to find the first
non-comment token in a query (to skip over leading comments). Not
having that causes a small regression test difference. The maintainers
will have to decide whether its worth keeping their own function, but
I think that doesn't invalidate the utility of having this in core to
me.

Thanks,
Lukas

[0]: https://github.com/lfittl/pg_stat_monitor/commit/054f347344a380f7a59cb444685db71301669c61
[1]: https://github.com/lfittl/pg_tracing/commit/d48a36c9a2c8fc284cf63ec1161558b90d8b44ef

--
Lukas Fittl

Attachment Content-Type Size
v9-0001-Make-JumbleState-const-in-post_parse_analyze-hook.patch application/octet-stream 17.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-04-01 08:01:56 Re: ALTER TABLE: warn when actions do not recurse to partitions
Previous Message Jim Jones 2026-04-01 07:47:01 Re: WIP - xmlvalidate implementation from TODO list