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
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c
b/contrib/pg_stat_statements/pg_stat_statements.c
index a2d3ab770cc6..92315627916d 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -1175,6 +1175,7 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char
*queryString,
* For the same reason, we can't risk restoring pstmt->queryId
to its
* former value, which'd otherwise be a good idea.
*/
+ pstmt = NULL;
INSTR_TIME_SET_CURRENT(duration);
INSTR_TIME_SUBTRACT(duration, start);
signature.asc
Description: PGP signature
