Re: Fix unsafe PlannedStmt access in pg_stat_statements
Chao Li <li.evan.chao@gmail.com>
From: Chao Li <li.evan.chao@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Andres Freund <andres@anarazel.de>,
pgsql-hackers@lists.postgresql.org
Date: 2026-05-13T05:31:01Z
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
> On May 13, 2026, at 12:26, Michael Paquier <michael@paquier.xyz> wrote: > > 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 > <pgss-pstmt.patch> Yeah, this is the exactly same change I was about to reply. And I agree the current comment is clear enough, no more needed to add. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/