PG-338: Fix query call count (utilities).

There was a missing increment/decrement to exec_nested_level in
pgss_ProcessUtility hook, due to this, some utility statements could
end up being processed more than once, as PostgreSQL may recurse into
this hook for sub-statements or when processing a query string
containing multiple semicolon-separated statements.
pull/175/head
Diego Fronza 2022-01-21 13:35:14 -03:00
parent 26000f40b6
commit 2c14e1dc08
1 changed files with 2 additions and 1 deletions

View File

@ -986,6 +986,7 @@ static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
WalUsage walusage_start = pgWalUsage; WalUsage walusage_start = pgWalUsage;
#endif #endif
INSTR_TIME_SET_CURRENT(start); INSTR_TIME_SET_CURRENT(start);
exec_nested_level++;
PG_TRY(); PG_TRY();
{ {
#if PG_VERSION_NUM >= 140000 #if PG_VERSION_NUM >= 140000
@ -1024,12 +1025,12 @@ static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
dest, dest,
completionTag); completionTag);
#endif #endif
exec_nested_level--;
} }
PG_CATCH(); PG_CATCH();
{ {
exec_nested_level--; exec_nested_level--;
PG_RE_THROW(); PG_RE_THROW();
} }
PG_END_TRY(); PG_END_TRY();