v1-0002-increment-nested-level-utility.patch
text/x-diff
Filename: v1-0002-increment-nested-level-utility.patch
Type: text/x-diff
Part: 1
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v1-0002
| File | + | − |
|---|---|---|
| contrib/pg_stat_statements/pg_stat_statements.c | 21 | 6 |
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 5285c3f7fa..ab3e574b7c 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -1198,14 +1198,29 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
}
else
{
- if (prev_ProcessUtility)
- prev_ProcessUtility(pstmt, queryString, readOnlyTree,
- context, params, queryEnv,
- dest, qc);
- else
- standard_ProcessUtility(pstmt, queryString, readOnlyTree,
+ /*
+ * We need to increase the nesting level to correctly track
+ * the level of nested statements in case track_utility is disabled.
+ */
+ if (PGSS_HANDLED_UTILITY(parsetree))
+ exec_nested_level++;
+ PG_TRY();
+ {
+ if (prev_ProcessUtility)
+ prev_ProcessUtility(pstmt, queryString, readOnlyTree,
context, params, queryEnv,
dest, qc);
+ else
+ standard_ProcessUtility(pstmt, queryString, readOnlyTree,
+ context, params, queryEnv,
+ dest, qc);
+ }
+ PG_FINALLY();
+ {
+ if (PGSS_HANDLED_UTILITY(parsetree))
+ exec_nested_level--;
+ }
+ PG_END_TRY();
}
}