22 * pg_wait_sampling.c
33 * Track information about wait events.
44 *
5- * Copyright (c) 2015-2025 , Postgres Professional
5+ * Copyright (c) 2015-2026 , Postgres Professional
66 *
77 * IDENTIFICATION
88 * contrib/pg_wait_sampling/pg_wait_sampling.c
@@ -75,9 +75,7 @@ static shmem_request_hook_type prev_shmem_request_hook = NULL;
7575static shmem_startup_hook_type prev_shmem_startup_hook = NULL ;
7676static PGPROC * search_proc (int backendPid );
7777static PlannedStmt * pgws_planner_hook (Query * parse ,
78- #if PG_VERSION_NUM >= 130000
7978 const char * query_string ,
80- #endif
8179 int cursorOptions , ParamListInfo boundParams
8280#if PG_VERSION_NUM >= 190000
8381 , ExplainState * es
@@ -87,26 +85,20 @@ static void pgws_ExecutorStart(QueryDesc *queryDesc, int eflags);
8785static void pgws_ExecutorRun (QueryDesc * queryDesc ,
8886 ScanDirection direction ,
8987 uint64 count
90- #if PG_VERSION_NUM >= 100000 && PG_VERSION_NUM < 180000
88+ #if PG_VERSION_NUM < 180000
9189 ,bool execute_once
9290#endif
9391);
9492static void pgws_ExecutorFinish (QueryDesc * queryDesc );
9593static void pgws_ExecutorEnd (QueryDesc * queryDesc );
9694static void pgws_ProcessUtility (PlannedStmt * pstmt ,
9795 const char * queryString ,
98- #if PG_VERSION_NUM >= 140000
9996 bool readOnlyTree ,
100- #endif
10197 ProcessUtilityContext context ,
10298 ParamListInfo params ,
10399 QueryEnvironment * queryEnv ,
104100 DestReceiver * dest ,
105- #if PG_VERSION_NUM >= 130000
106101 QueryCompletion * qc
107- #else
108- char * completionTag
109- #endif
110102);
111103
112104/*---- GUC variables ----*/
@@ -958,9 +950,7 @@ pg_wait_sampling_get_history(PG_FUNCTION_ARGS)
958950 */
959951static PlannedStmt *
960952pgws_planner_hook (Query * parse ,
961- #if PG_VERSION_NUM >= 130000
962953 const char * query_string ,
963- #endif
964954 int cursorOptions ,
965955 ParamListInfo boundParams
966956#if PG_VERSION_NUM >= 190000
@@ -984,19 +974,15 @@ pgws_planner_hook(Query *parse,
984974 /* Invoke original hook if needed */
985975 if (planner_hook_next )
986976 result = planner_hook_next (parse ,
987- #if PG_VERSION_NUM >= 130000
988977 query_string ,
989- #endif
990978 cursorOptions , boundParams
991979#if PG_VERSION_NUM >= 190000
992980 , es
993981#endif
994982 );
995983 else
996984 result = standard_planner (parse ,
997- #if PG_VERSION_NUM >= 130000
998985 query_string ,
999- #endif
1000986 cursorOptions , boundParams
1001987#if PG_VERSION_NUM >= 190000
1002988 , es
@@ -1042,7 +1028,7 @@ static void
10421028pgws_ExecutorRun (QueryDesc * queryDesc ,
10431029 ScanDirection direction ,
10441030 uint64 count
1045- #if PG_VERSION_NUM >= 100000 && PG_VERSION_NUM < 180000
1031+ #if PG_VERSION_NUM < 180000
10461032 ,bool execute_once
10471033#endif
10481034)
@@ -1054,16 +1040,16 @@ pgws_ExecutorRun(QueryDesc *queryDesc,
10541040 PG_TRY ();
10551041 {
10561042 if (prev_ExecutorRun )
1057- #if PG_VERSION_NUM >= 100000 && PG_VERSION_NUM < 180000
1058- prev_ExecutorRun (queryDesc , direction , count , execute_once );
1059- #else
1043+ #if PG_VERSION_NUM >= 180000
10601044 prev_ExecutorRun (queryDesc , direction , count );
1045+ #else
1046+ prev_ExecutorRun (queryDesc , direction , count , execute_once );
10611047#endif
10621048 else
1063- #if PG_VERSION_NUM >= 100000 && PG_VERSION_NUM < 180000
1064- standard_ExecutorRun (queryDesc , direction , count , execute_once );
1065- #else
1049+ #if PG_VERSION_NUM >= 180000
10661050 standard_ExecutorRun (queryDesc , direction , count );
1051+ #else
1052+ standard_ExecutorRun (queryDesc , direction , count , execute_once );
10671053#endif
10681054 nesting_level -- ;
10691055 if (nesting_level == 0 )
@@ -1131,18 +1117,12 @@ pgws_ExecutorEnd(QueryDesc *queryDesc)
11311117static void
11321118pgws_ProcessUtility (PlannedStmt * pstmt ,
11331119 const char * queryString ,
1134- #if PG_VERSION_NUM >= 140000
11351120 bool readOnlyTree ,
1136- #endif
11371121 ProcessUtilityContext context ,
11381122 ParamListInfo params ,
11391123 QueryEnvironment * queryEnv ,
11401124 DestReceiver * dest ,
1141- #if PG_VERSION_NUM >= 130000
11421125 QueryCompletion * qc
1143- #else
1144- char * completionTag
1145- #endif
11461126)
11471127{
11481128 int i = MyProc - ProcGlobal -> allProcs ;
@@ -1159,30 +1139,16 @@ pgws_ProcessUtility(PlannedStmt *pstmt,
11591139 {
11601140 if (prev_ProcessUtility )
11611141 prev_ProcessUtility (pstmt , queryString ,
1162- #if PG_VERSION_NUM >= 140000
11631142 readOnlyTree ,
1164- #endif
11651143 context , params , queryEnv ,
11661144 dest ,
1167- #if PG_VERSION_NUM >= 130000
1168- qc
1169- #else
1170- completionTag
1171- #endif
1172- );
1145+ qc );
11731146 else
11741147 standard_ProcessUtility (pstmt , queryString ,
1175- #if PG_VERSION_NUM >= 140000
11761148 readOnlyTree ,
1177- #endif
11781149 context , params , queryEnv ,
11791150 dest ,
1180- #if PG_VERSION_NUM >= 130000
1181- qc
1182- #else
1183- completionTag
1184- #endif
1185- );
1151+ qc );
11861152 nesting_level -- ;
11871153 if (nesting_level == 0 )
11881154 pgws_proc_queryids [i ] = UINT64CONST (0 );
0 commit comments