Re: [[BUG] pg_stat_statements crashes with var and non-var expressions in IN clause - Mailing list pgsql-hackers

From zengman
Subject Re: [[BUG] pg_stat_statements crashes with var and non-var expressions in IN clause
Date
Msg-id tencent_56D378713B3D126F1B4EE122@qq.com
Whole thread Raw
In response to Re: [[BUG] pg_stat_statements crashes with var and non-var expressions in IN clause  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
> If there is agreement to this fix, I think it should be backpacthed to
> all versions that
> support squashing of IN-lists.
Hi,

Thank you for providing the test case. I happened to have both versions 16 and 19 on hand — it stably triggers the
issueon version 19, while version 16 works perfectly fine.
 
Additionally, I noticed that "ars" in the comment of your patch should be "Vars"  (this seems to be a typo).

```
postgres@zxm-VMware-Virtual-Platform:~/code/postgres$ psql
psql (19devel)
Type "help" for help.

postgres=# SELECT * FROM test_squash a, test_squash b WHERE a.id IN (1, 2, 3,
b.id, b.id + 1);
TRAP: failed Assert("len_to_wrt >= 0"), File: "pg_stat_statements.c", Line: 2906, PID: 52564
postgres: postgres postgres [local] SELECT(ExceptionalCondition+0xbb)[0x59d71bc1d631]
```

```
postgres@zxm-VMware-Virtual-Platform:~$ psql
psql (16.11)
Type "help" for help.

postgres=# SELECT * FROM test_squash a, test_squash b WHERE a.id IN (1, 2, 3,
b.id, b.id + 1);
 id | data | id | data 
----+------+----+------
(0 rows)

postgres=# SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C";
                                 query                                  | calls 
------------------------------------------------------------------------+-------
 SELECT * FROM test_squash a, test_squash b WHERE a.id IN ($1, $2, $3, +|     2
 b.id, b.id + $4)                                                       | 
 SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C" |     1
 select pg_backend_pid()                                                |     1
(3 rows)
```

--
Regards,
Man Zeng
www.openhalo.org

pgsql-hackers by date:

Previous
From: Lukas Fittl
Date:
Subject: Re: Stack-based tracking of per-node WAL/buffer usage
Next
From: Andrey Borodin
Date:
Subject: Re: [PATCH] Teach pg_waldump to extract FPIs from the WAL