@@ -113,6 +113,7 @@ typedef enum pgssVersion
113
113
PGSS_V1_9 ,
114
114
PGSS_V1_10 ,
115
115
PGSS_V1_11 ,
116
+ PGSS_V1_12 ,
116
117
} pgssVersion ;
117
118
118
119
typedef enum pgssStoreKind
@@ -204,6 +205,10 @@ typedef struct Counters
204
205
int64 jit_emission_count ; /* number of times emission time has been
205
206
* > 0 */
206
207
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 */
207
212
} Counters ;
208
213
209
214
/*
@@ -317,6 +322,7 @@ PG_FUNCTION_INFO_V1(pg_stat_statements_1_8);
317
322
PG_FUNCTION_INFO_V1 (pg_stat_statements_1_9 );
318
323
PG_FUNCTION_INFO_V1 (pg_stat_statements_1_10 );
319
324
PG_FUNCTION_INFO_V1 (pg_stat_statements_1_11 );
325
+ PG_FUNCTION_INFO_V1 (pg_stat_statements_1_12 );
320
326
PG_FUNCTION_INFO_V1 (pg_stat_statements );
321
327
PG_FUNCTION_INFO_V1 (pg_stat_statements_info );
322
328
@@ -347,7 +353,9 @@ static void pgss_store(const char *query, uint64 queryId,
347
353
const BufferUsage * bufusage ,
348
354
const WalUsage * walusage ,
349
355
const struct JitInstrumentation * jitusage ,
350
- JumbleState * jstate );
356
+ JumbleState * jstate ,
357
+ int parallel_workers_to_launch ,
358
+ int parallel_workers_launched );
351
359
static void pg_stat_statements_internal (FunctionCallInfo fcinfo ,
352
360
pgssVersion api_version ,
353
361
bool showtext );
@@ -867,7 +875,9 @@ pgss_post_parse_analyze(ParseState *pstate, Query *query, JumbleState *jstate)
867
875
NULL ,
868
876
NULL ,
869
877
NULL ,
870
- jstate );
878
+ jstate ,
879
+ 0 ,
880
+ 0 );
871
881
}
872
882
873
883
/*
@@ -945,7 +955,9 @@ pgss_planner(Query *parse,
945
955
& bufusage ,
946
956
& walusage ,
947
957
NULL ,
948
- NULL );
958
+ NULL ,
959
+ 0 ,
960
+ 0 );
949
961
}
950
962
else
951
963
{
@@ -1078,7 +1090,9 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
1078
1090
& queryDesc -> totaltime -> bufusage ,
1079
1091
& queryDesc -> totaltime -> walusage ,
1080
1092
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 );
1082
1096
}
1083
1097
1084
1098
if (prev_ExecutorEnd )
@@ -1209,7 +1223,9 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
1209
1223
& bufusage ,
1210
1224
& walusage ,
1211
1225
NULL ,
1212
- NULL );
1226
+ NULL ,
1227
+ 0 ,
1228
+ 0 );
1213
1229
}
1214
1230
else
1215
1231
{
@@ -1270,7 +1286,9 @@ pgss_store(const char *query, uint64 queryId,
1270
1286
const BufferUsage * bufusage ,
1271
1287
const WalUsage * walusage ,
1272
1288
const struct JitInstrumentation * jitusage ,
1273
- JumbleState * jstate )
1289
+ JumbleState * jstate ,
1290
+ int parallel_workers_to_launch ,
1291
+ int parallel_workers_launched )
1274
1292
{
1275
1293
pgssHashKey key ;
1276
1294
pgssEntry * entry ;
@@ -1473,6 +1491,10 @@ pgss_store(const char *query, uint64 queryId,
1473
1491
entry -> counters .jit_emission_time += INSTR_TIME_GET_MILLISEC (jitusage -> emission_counter );
1474
1492
}
1475
1493
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
+
1476
1498
SpinLockRelease (& entry -> mutex );
1477
1499
}
1478
1500
@@ -1539,7 +1561,8 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS)
1539
1561
#define PG_STAT_STATEMENTS_COLS_V1_9 33
1540
1562
#define PG_STAT_STATEMENTS_COLS_V1_10 43
1541
1563
#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 */
1543
1566
1544
1567
/*
1545
1568
* Retrieve statement statistics.
@@ -1551,6 +1574,16 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS)
1551
1574
* expected API version is identified by embedding it in the C name of the
1552
1575
* function. Unfortunately we weren't bright enough to do that for 1.1.
1553
1576
*/
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
+
1554
1587
Datum
1555
1588
pg_stat_statements_1_11 (PG_FUNCTION_ARGS )
1556
1589
{
@@ -1695,6 +1728,10 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
1695
1728
if (api_version != PGSS_V1_11 )
1696
1729
elog (ERROR , "incorrect number of output arguments" );
1697
1730
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 ;
1698
1735
default :
1699
1736
elog (ERROR , "incorrect number of output arguments" );
1700
1737
}
@@ -1932,6 +1969,14 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
1932
1969
{
1933
1970
values [i ++ ] = Int64GetDatumFast (tmp .jit_deform_count );
1934
1971
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
+ {
1935
1980
values [i ++ ] = TimestampTzGetDatum (stats_since );
1936
1981
values [i ++ ] = TimestampTzGetDatum (minmax_stats_since );
1937
1982
}
@@ -1944,6 +1989,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
1944
1989
api_version == PGSS_V1_9 ? PG_STAT_STATEMENTS_COLS_V1_9 :
1945
1990
api_version == PGSS_V1_10 ? PG_STAT_STATEMENTS_COLS_V1_10 :
1946
1991
api_version == PGSS_V1_11 ? PG_STAT_STATEMENTS_COLS_V1_11 :
1992
+ api_version == PGSS_V1_12 ? PG_STAT_STATEMENTS_COLS_V1_12 :
1947
1993
-1 /* fail if you forget to update this assert */ ));
1948
1994
1949
1995
tuplestore_putvalues (rsinfo -> setResult , rsinfo -> setDesc , values , nulls );
0 commit comments