Format code

pull/463/head
Artem Gavrilov 2024-06-07 18:14:51 +02:00
parent 91c5683e36
commit ef378f52c8
1 changed files with 46 additions and 45 deletions

View File

@ -868,7 +868,7 @@ pgsm_planner_hook(Query *parse, const char *query_string, int cursorOptions, Par
* top level planner call. * top level planner call.
*/ */
bool enabled; bool enabled;
#if PG_VERSION_NUM >= 170000 #if PG_VERSION_NUM >= 170000
enabled = pgsm_enabled(nesting_level); enabled = pgsm_enabled(nesting_level);
#else #else
@ -920,9 +920,9 @@ pgsm_planner_hook(Query *parse, const char *query_string, int cursorOptions, Par
PG_FINALLY(); PG_FINALLY();
{ {
#if PG_VERSION_NUM >= 170000 #if PG_VERSION_NUM >= 170000
nesting_level--; nesting_level--;
#else #else
plan_nested_level--; plan_nested_level--;
#endif #endif
} }
PG_END_TRY(); PG_END_TRY();
@ -985,9 +985,9 @@ pgsm_planner_hook(Query *parse, const char *query_string, int cursorOptions, Par
PG_FINALLY(); PG_FINALLY();
{ {
#if PG_VERSION_NUM >= 170000 #if PG_VERSION_NUM >= 170000
nesting_level--; nesting_level--;
#else #else
plan_nested_level--; plan_nested_level--;
#endif #endif
} }
PG_END_TRY(); PG_END_TRY();
@ -1028,7 +1028,7 @@ pgsm_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
{ {
Node *parsetree = pstmt->utilityStmt; Node *parsetree = pstmt->utilityStmt;
uint64 queryId = 0; uint64 queryId = 0;
bool enabled = pgsm_track_utility && pgsm_enabled(nesting_level); bool enabled = pgsm_track_utility && pgsm_enabled(nesting_level);
#if PG_VERSION_NUM < 140000 #if PG_VERSION_NUM < 140000
int len = strlen(queryString); int len = strlen(queryString);
@ -1067,7 +1067,7 @@ pgsm_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
*/ */
if (enabled && if (enabled &&
!IsA(parsetree, ExecuteStmt) && !IsA(parsetree, ExecuteStmt) &&
!IsA(parsetree, PrepareStmt) && !IsA(parsetree, PrepareStmt) &&
!IsA(parsetree, DeallocateStmt)) !IsA(parsetree, DeallocateStmt))
{ {
pgsmEntry *entry; pgsmEntry *entry;
@ -1233,10 +1233,10 @@ pgsm_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
* To be absolutely certain we don't mess up the nesting level, * To be absolutely certain we don't mess up the nesting level,
* evaluate the bump_level condition just once. * evaluate the bump_level condition just once.
*/ */
bool bump_level = bool bump_level =
!IsA(parsetree, ExecuteStmt) && !IsA(parsetree, ExecuteStmt) &&
!IsA(parsetree, PrepareStmt) && !IsA(parsetree, PrepareStmt) &&
!IsA(parsetree, DeallocateStmt); !IsA(parsetree, DeallocateStmt);
if (bump_level) if (bump_level)
nesting_level++; nesting_level++;
@ -1244,48 +1244,48 @@ pgsm_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
PG_TRY(); PG_TRY();
{ {
#if PG_VERSION_NUM >= 140000 #if PG_VERSION_NUM >= 140000
if (prev_ProcessUtility) if (prev_ProcessUtility)
prev_ProcessUtility(pstmt, queryString, prev_ProcessUtility(pstmt, queryString,
readOnlyTree,
context, params, queryEnv,
dest,
qc);
else
standard_ProcessUtility(pstmt, queryString,
readOnlyTree, readOnlyTree,
context, params, queryEnv, context, params, queryEnv,
dest, dest,
qc); qc);
else
standard_ProcessUtility(pstmt, queryString,
readOnlyTree,
context, params, queryEnv,
dest,
qc);
#elif PG_VERSION_NUM >= 130000 #elif PG_VERSION_NUM >= 130000
if (prev_ProcessUtility) if (prev_ProcessUtility)
prev_ProcessUtility(pstmt, queryString, prev_ProcessUtility(pstmt, queryString,
context, params, queryEnv,
dest,
qc);
else
standard_ProcessUtility(pstmt, queryString,
context, params, queryEnv, context, params, queryEnv,
dest, dest,
qc); qc);
else
standard_ProcessUtility(pstmt, queryString,
context, params, queryEnv,
dest,
qc);
#else #else
if (prev_ProcessUtility) if (prev_ProcessUtility)
prev_ProcessUtility(pstmt, queryString, prev_ProcessUtility(pstmt, queryString,
context, params, queryEnv,
dest,
completionTag);
else
standard_ProcessUtility(pstmt, queryString,
context, params, queryEnv, context, params, queryEnv,
dest, dest,
completionTag); completionTag);
else
standard_ProcessUtility(pstmt, queryString,
context, params, queryEnv,
dest,
completionTag);
#endif #endif
} }
PG_FINALLY(); PG_FINALLY();
{ {
if (bump_level) if (bump_level)
nesting_level--; nesting_level--;
} }
PG_END_TRY(); PG_END_TRY();
} }
} }
@ -1534,7 +1534,7 @@ pgsm_update_entry(pgsmEntry * entry,
if (nesting_level >= 0 && nesting_level < max_stack_depth) if (nesting_level >= 0 && nesting_level < max_stack_depth)
{ {
int parent_query_len = nested_query_txts[nesting_level - 1] ? int parent_query_len = nested_query_txts[nesting_level - 1] ?
strlen(nested_query_txts[nesting_level - 1]) : 0; strlen(nested_query_txts[nesting_level - 1]) : 0;
e->counters.info.parentid = nested_queryids[nesting_level - 1]; e->counters.info.parentid = nested_queryids[nesting_level - 1];
e->counters.info.parent_query = InvalidDsaPointer; e->counters.info.parent_query = InvalidDsaPointer;
@ -2136,7 +2136,8 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
pgsmEntry *entry; pgsmEntry *entry;
pgsmSharedState *pgsm; pgsmSharedState *pgsm;
int expected_columns; int expected_columns;
switch (api_version) switch (api_version)
{ {
case PGSM_V1_0: case PGSM_V1_0: