Re: Fix unsafe PlannedStmt access in pg_stat_statements
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org, Chao Li <li.evan.chao@gmail.com>
Date: 2026-05-13T04:26:36Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
pg_stat_statements: Set PlannedStmt to NULL after nested utility execution
- 66366217822e 19 (unreleased) landed
-
pg_stat_statements: Fix potential use-after-free of PlannedStmt
- 8268e41aca23 19 (unreleased) landed
-
pg_stat_statements: Add counters for generic and custom plans
- 3357471cf9f5 19 (unreleased) cited
Attachments
- pgss-pstmt.patch (text/plain) patch
On Tue, May 12, 2026 at 11:00:16AM +0200, Andres Freund wrote: > Seems like the code should make this clearer, by simply unsetting > pstmt at the point it becomes unsafe to use? Sure, we could do that as well and crash hard if something decides to do the same mistake. Like the simple patch attached for example? I am not sure if we need to update the comment. It's pretty clear what the intention is, at least to me. -- Michael