@@ -113,6 +113,7 @@ typedef enum pgssVersion
113113 PGSS_V1_9 ,
114114 PGSS_V1_10 ,
115115 PGSS_V1_11 ,
116+ PGSS_V1_12 ,
116117} pgssVersion ;
117118
118119typedef enum pgssStoreKind
@@ -204,6 +205,10 @@ typedef struct Counters
204205 int64 jit_emission_count ; /* number of times emission time has been
205206 * > 0 */
206207 double jit_emission_time ; /* total time to emit jit code */
208+ int64 parallel_workers_to_launch ; /* # of parallel workers planned
209+ * to be launched */
210+ int64 parallel_workers_launched ; /* # of parallel workers actually
211+ * launched */
207212} Counters ;
208213
209214/*
@@ -317,6 +322,7 @@ PG_FUNCTION_INFO_V1(pg_stat_statements_1_8);
317322PG_FUNCTION_INFO_V1 (pg_stat_statements_1_9 );
318323PG_FUNCTION_INFO_V1 (pg_stat_statements_1_10 );
319324PG_FUNCTION_INFO_V1 (pg_stat_statements_1_11 );
325+ PG_FUNCTION_INFO_V1 (pg_stat_statements_1_12 );
320326PG_FUNCTION_INFO_V1 (pg_stat_statements );
321327PG_FUNCTION_INFO_V1 (pg_stat_statements_info );
322328
@@ -347,7 +353,9 @@ static void pgss_store(const char *query, uint64 queryId,
347353 const BufferUsage * bufusage ,
348354 const WalUsage * walusage ,
349355 const struct JitInstrumentation * jitusage ,
350- JumbleState * jstate );
356+ JumbleState * jstate ,
357+ int parallel_workers_to_launch ,
358+ int parallel_workers_launched );
351359static void pg_stat_statements_internal (FunctionCallInfo fcinfo ,
352360 pgssVersion api_version ,
353361 bool showtext );
@@ -867,7 +875,9 @@ pgss_post_parse_analyze(ParseState *pstate, Query *query, JumbleState *jstate)
867875 NULL ,
868876 NULL ,
869877 NULL ,
870- jstate );
878+ jstate ,
879+ 0 ,
880+ 0 );
871881}
872882
873883/*
@@ -945,7 +955,9 @@ pgss_planner(Query *parse,
945955 & bufusage ,
946956 & walusage ,
947957 NULL ,
948- NULL );
958+ NULL ,
959+ 0 ,
960+ 0 );
949961 }
950962 else
951963 {
@@ -1078,7 +1090,9 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
10781090 & queryDesc -> totaltime -> bufusage ,
10791091 & queryDesc -> totaltime -> walusage ,
10801092 queryDesc -> estate -> es_jit ? & queryDesc -> estate -> es_jit -> instr : NULL ,
1081- NULL );
1093+ NULL ,
1094+ queryDesc -> estate -> es_parallel_workers_to_launch ,
1095+ queryDesc -> estate -> es_parallel_workers_launched );
10821096 }
10831097
10841098 if (prev_ExecutorEnd )
@@ -1209,7 +1223,9 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
12091223 & bufusage ,
12101224 & walusage ,
12111225 NULL ,
1212- NULL );
1226+ NULL ,
1227+ 0 ,
1228+ 0 );
12131229 }
12141230 else
12151231 {
@@ -1270,7 +1286,9 @@ pgss_store(const char *query, uint64 queryId,
12701286 const BufferUsage * bufusage ,
12711287 const WalUsage * walusage ,
12721288 const struct JitInstrumentation * jitusage ,
1273- JumbleState * jstate )
1289+ JumbleState * jstate ,
1290+ int parallel_workers_to_launch ,
1291+ int parallel_workers_launched )
12741292{
12751293 pgssHashKey key ;
12761294 pgssEntry * entry ;
@@ -1473,6 +1491,10 @@ pgss_store(const char *query, uint64 queryId,
14731491 entry -> counters .jit_emission_time += INSTR_TIME_GET_MILLISEC (jitusage -> emission_counter );
14741492 }
14751493
1494+ /* parallel worker counters */
1495+ entry -> counters .parallel_workers_to_launch += parallel_workers_to_launch ;
1496+ entry -> counters .parallel_workers_launched += parallel_workers_launched ;
1497+
14761498 SpinLockRelease (& entry -> mutex );
14771499 }
14781500
@@ -1539,7 +1561,8 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS)
15391561#define PG_STAT_STATEMENTS_COLS_V1_9 33
15401562#define PG_STAT_STATEMENTS_COLS_V1_10 43
15411563#define PG_STAT_STATEMENTS_COLS_V1_11 49
1542- #define PG_STAT_STATEMENTS_COLS 49 /* maximum of above */
1564+ #define PG_STAT_STATEMENTS_COLS_V1_12 51
1565+ #define PG_STAT_STATEMENTS_COLS 51 /* maximum of above */
15431566
15441567/*
15451568 * Retrieve statement statistics.
@@ -1551,6 +1574,16 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS)
15511574 * expected API version is identified by embedding it in the C name of the
15521575 * function. Unfortunately we weren't bright enough to do that for 1.1.
15531576 */
1577+ Datum
1578+ pg_stat_statements_1_12 (PG_FUNCTION_ARGS )
1579+ {
1580+ bool showtext = PG_GETARG_BOOL (0 );
1581+
1582+ pg_stat_statements_internal (fcinfo , PGSS_V1_12 , showtext );
1583+
1584+ return (Datum ) 0 ;
1585+ }
1586+
15541587Datum
15551588pg_stat_statements_1_11 (PG_FUNCTION_ARGS )
15561589{
@@ -1695,6 +1728,10 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
16951728 if (api_version != PGSS_V1_11 )
16961729 elog (ERROR , "incorrect number of output arguments" );
16971730 break ;
1731+ case PG_STAT_STATEMENTS_COLS_V1_12 :
1732+ if (api_version != PGSS_V1_12 )
1733+ elog (ERROR , "incorrect number of output arguments" );
1734+ break ;
16981735 default :
16991736 elog (ERROR , "incorrect number of output arguments" );
17001737 }
@@ -1932,6 +1969,14 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
19321969 {
19331970 values [i ++ ] = Int64GetDatumFast (tmp .jit_deform_count );
19341971 values [i ++ ] = Float8GetDatumFast (tmp .jit_deform_time );
1972+ }
1973+ if (api_version >= PGSS_V1_12 )
1974+ {
1975+ values [i ++ ] = Int64GetDatumFast (tmp .parallel_workers_to_launch );
1976+ values [i ++ ] = Int64GetDatumFast (tmp .parallel_workers_launched );
1977+ }
1978+ if (api_version >= PGSS_V1_11 )
1979+ {
19351980 values [i ++ ] = TimestampTzGetDatum (stats_since );
19361981 values [i ++ ] = TimestampTzGetDatum (minmax_stats_since );
19371982 }
@@ -1944,6 +1989,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
19441989 api_version == PGSS_V1_9 ? PG_STAT_STATEMENTS_COLS_V1_9 :
19451990 api_version == PGSS_V1_10 ? PG_STAT_STATEMENTS_COLS_V1_10 :
19461991 api_version == PGSS_V1_11 ? PG_STAT_STATEMENTS_COLS_V1_11 :
1992+ api_version == PGSS_V1_12 ? PG_STAT_STATEMENTS_COLS_V1_12 :
19471993 -1 /* fail if you forget to update this assert */ ));
19481994
19491995 tuplestore_putvalues (rsinfo -> setResult , rsinfo -> setDesc , values , nulls );
0 commit comments