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/188/head
Diego Fronza 2022-01-21 13:35:14 -03:00 committed by Hamid Akhtar
parent cb5aab89b3
commit 79e0a86e4b
1 changed files with 2 additions and 1 deletions

View File

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