| From: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com> |
|---|---|
| To: | Sami Imseih <samimseih(at)gmail(dot)com> |
| Cc: | Konstantin Knizhnik <knizhnik(at)garret(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Bug in pg_stat_statements |
| Date: | 2025-10-24 14:33:41 |
| Message-ID: | 637jlyhmvrwmzlpzj2xo47phvek7le36epdujv4oxvd4ujb6x2@n3mh2lapgdhd |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Fri, Oct 24, 2025 at 09:17:22AM -0500, Sami Imseih wrote:
> > Having said
> > that it seems that another solution would be to check for duplicated constants
> > in fill_in_constant_length
>
> Yes, I started thinking along these lines as well, where we check for
> duplicates
> in fill_in_constant_length; or after jumbling, we de-duplicate locations if we
> have a squashable list, which is what I have attached with updated test cases.
>
> This means we do need to scan the locations one extra time during jumbling,
> but I don't see that as a problem. Maybe there is another better way?
Why? What I hand in mind is something like this, after a quick test it seems to
be able to address both the original case and the one you've discovered.
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index f2187167..f17a2b79 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -3008,11 +3008,17 @@ fill_in_constant_lengths(JumbleState *jstate, const char *query,
Assert(loc >= 0);
- if (locs[i].squashed)
- continue; /* squashable list, ignore */
-
if (loc <= last_loc)
+ {
+ locs[i].length = -1;
continue; /* Duplicate constant, ignore */
+ }
+
+ if (locs[i].squashed)
+ {
+ last_loc = loc;
+ continue; /* squashable list, ignore */
+ }
/* Lex tokens until we find the desired constant */
for (;;)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Greg Sabino Mullane | 2025-10-24 14:54:57 | Re: display hot standby state in psql prompt |
| Previous Message | Ivan Bykov | 2025-10-24 14:33:22 | Re: IPC/MultixactCreation on the Standby server |