pgsql: pg_stat_statements: Set PlannedStmt to NULL after nested utility

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pg_stat_statements: Set PlannedStmt to NULL after nested utility
Date: 2026-05-13 06:48:43
Message-ID: E1wN3Od-000J7N-2D@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pg_stat_statements: Set PlannedStmt to NULL after nested utility execution

As mentioned in 8268e41aca23, pgss_ProcessUtility() may free the
PlannedStmt after an internal ROLLBACK. This commit sets the
PlannedStmt "pstmt" to NULL once it is no longer safe to rely on it,
making bugs similar to the one fixed by the previous commit easier to
detect.

Suggested-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/0A9A8DAC-BC3C-4C7A-9504-2C6050405544@anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/66366217822e23a00251f6ba3743d8e5675fcfc2

Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c | 1 +
1 file changed, 1 insertion(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2026-05-13 11:51:40 pgsql: Fix FOR PORTION OF with non-updatable view columns
Previous Message Michael Paquier 2026-05-13 05:44:34 pgsql: Add more tests for corrupted data with pglz_decompress()