- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit56083ff
committed
pg_stat_statements: fetch stmt location/length before it disappears.
When executing a utility statement, we must fetch everythingwe need out of the PlannedStmt data structure before callingstandard_ProcessUtility. In certain cases (possibly only ROLLBACKin extended query protocol), that data structure will get freedduring command execution. The situation is probably often harmlessin production builds, but in debug builds we intentionally overwritethe freed memory with garbage, leading to picking up garbage valuesof statement location and length, typically causing an assertionfailure later in pg_stat_statements. In non-debug builds, ifsomething did go wrong it would likely lead to storing garbagefor the query string.Report and fix by zhaoqigui (with cosmetic adjustments by me).It's an old problem, so back-patch to all supported versions.Discussion:https://postgr.es/m/17663-a344fd0675f92128@postgresql.orgDiscussion:https://postgr.es/m/1667307420050.56657@hundsun.com1 parentb02fc7d commit56083ff
1 file changed
+11
-2
lines changedLines changed: 11 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
962 | 962 |
| |
963 | 963 |
| |
964 | 964 |
| |
| 965 | + | |
| 966 | + | |
965 | 967 |
| |
966 | 968 |
| |
967 | 969 |
| |
| |||
1011 | 1013 |
| |
1012 | 1014 |
| |
1013 | 1015 |
| |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
1014 | 1023 |
| |
1015 | 1024 |
| |
1016 | 1025 |
| |
| |||
1049 | 1058 |
| |
1050 | 1059 |
| |
1051 | 1060 |
| |
1052 |
| - | |
1053 |
| - | |
| 1061 | + | |
| 1062 | + | |
1054 | 1063 |
| |
1055 | 1064 |
| |
1056 | 1065 |
| |
|
0 commit comments
Comments
(0)