@@ -101,7 +101,9 @@ typedef enum pgspVersion
101
101
{
102
102
PGSP_V1_5 = 0 ,
103
103
PGSP_V1_6 ,
104
- PGSP_V1_7
104
+ PGSP_V1_7 ,
105
+ /* PGSP_V1_7 interface is used for v1.8 */
106
+ PGSP_V1_9
105
107
} pgspVersion ;
106
108
107
109
/*
@@ -142,8 +144,19 @@ typedef struct Counters
142
144
int64 local_blks_written ; /* # of local disk blocks written */
143
145
int64 temp_blks_read ; /* # of temp blocks read */
144
146
int64 temp_blks_written ; /* # of temp blocks written */
147
+ #if PG_VERSION_NUM >= 170000
148
+ double shared_blk_read_time ; /* time spent reading shared bloks,
149
+ in msec */
150
+ double shared_blk_write_time ; /* time spent writing shared blocks,
151
+ in msec */
152
+ double local_blk_read_time ; /* time spent reading local blocks,
153
+ in msec */
154
+ double local_blk_write_time ; /* time spent writing local blocks,
155
+ in msec */
156
+ #else
145
157
double blk_read_time ; /* time spent reading, in msec */
146
158
double blk_write_time ; /* time spent writing, in msec */
159
+ #endif
147
160
double temp_blk_read_time ; /* time spent reading temp blocks,
148
161
in msec */
149
162
double temp_blk_write_time ;/* time spent writing temp blocks,
@@ -321,6 +334,7 @@ PG_FUNCTION_INFO_V1(pg_store_plans_hash_query);
321
334
PG_FUNCTION_INFO_V1 (pg_store_plans );
322
335
PG_FUNCTION_INFO_V1 (pg_store_plans_1_6 );
323
336
PG_FUNCTION_INFO_V1 (pg_store_plans_1_7 );
337
+ PG_FUNCTION_INFO_V1 (pg_store_plans_1_9 );
324
338
PG_FUNCTION_INFO_V1 (pg_store_plans_shorten );
325
339
PG_FUNCTION_INFO_V1 (pg_store_plans_normalize );
326
340
PG_FUNCTION_INFO_V1 (pg_store_plans_jsonplan );
@@ -1356,9 +1370,22 @@ pgsp_store(char *plan, queryid_t queryId,
1356
1370
e -> counters .temp_blks_read += bufusage -> temp_blks_read ;
1357
1371
e -> counters .temp_blks_written += bufusage -> temp_blks_written ;
1358
1372
1359
- e -> counters .blk_read_time += INSTR_TIME_GET_MILLISEC (bufusage -> blk_read_time );
1360
- e -> counters .blk_write_time += INSTR_TIME_GET_MILLISEC (bufusage -> blk_write_time );
1361
-
1373
+ #if PG_VERSION_NUM >= 170000
1374
+ e -> counters .shared_blk_read_time +=
1375
+ INSTR_TIME_GET_MILLISEC (bufusage -> shared_blk_read_time );
1376
+ e -> counters .shared_blk_write_time +=
1377
+ INSTR_TIME_GET_MILLISEC (bufusage -> shared_blk_write_time );
1378
+ e -> counters .local_blk_read_time +=
1379
+ INSTR_TIME_GET_MILLISEC (bufusage -> local_blk_read_time );
1380
+ e -> counters .local_blk_write_time +=
1381
+ INSTR_TIME_GET_MILLISEC (bufusage -> local_blk_write_time );
1382
+ #else
1383
+ e -> counters .blk_read_time +=
1384
+ INSTR_TIME_GET_MILLISEC (bufusage -> blk_read_time );
1385
+ e -> counters .blk_write_time +=
1386
+ INSTR_TIME_GET_MILLISEC (bufusage -> blk_write_time );
1387
+ #endif
1388
+
1362
1389
#if PG_VERSION_NUM >= 150000
1363
1390
e -> counters .temp_blk_read_time += INSTR_TIME_GET_MILLISEC (bufusage -> temp_blk_read_time );
1364
1391
e -> counters .temp_blk_write_time += INSTR_TIME_GET_MILLISEC (bufusage -> temp_blk_write_time );
@@ -1395,11 +1422,20 @@ pg_store_plans_reset(PG_FUNCTION_ARGS)
1395
1422
#define PG_STORE_PLANS_COLS_V1_5 27
1396
1423
#define PG_STORE_PLANS_COLS_V1_6 26
1397
1424
#define PG_STORE_PLANS_COLS_V1_7 28
1398
- #define PG_STORE_PLANS_COLS 28 /* maximum of above */
1425
+ #define PG_STORE_PLANS_COLS_V1_9 30
1426
+ #define PG_STORE_PLANS_COLS 30 /* maximum of above */
1399
1427
1400
1428
/*
1401
1429
* Retrieve statement statistics.
1402
1430
*/
1431
+ Datum
1432
+ pg_store_plans_1_9 (PG_FUNCTION_ARGS )
1433
+ {
1434
+ pg_store_plans_internal (fcinfo , PGSP_V1_9 );
1435
+
1436
+ return (Datum ) 0 ;
1437
+ }
1438
+
1403
1439
Datum
1404
1440
pg_store_plans_1_7 (PG_FUNCTION_ARGS )
1405
1441
{
@@ -1658,8 +1694,14 @@ pg_store_plans_internal(FunctionCallInfo fcinfo,
1658
1694
values [i ++ ] = Int64GetDatumFast (tmp .local_blks_written );
1659
1695
values [i ++ ] = Int64GetDatumFast (tmp .temp_blks_read );
1660
1696
values [i ++ ] = Int64GetDatumFast (tmp .temp_blks_written );
1661
- values [i ++ ] = Float8GetDatumFast (tmp .blk_read_time );
1662
- values [i ++ ] = Float8GetDatumFast (tmp .blk_write_time );
1697
+ values [i ++ ] = Float8GetDatumFast (tmp .shared_blk_read_time );
1698
+ values [i ++ ] = Float8GetDatumFast (tmp .shared_blk_write_time );
1699
+
1700
+ if (api_version >= PGSP_V1_9 )
1701
+ {
1702
+ values [i ++ ] = Float8GetDatumFast (tmp .local_blk_read_time );
1703
+ values [i ++ ] = Float8GetDatumFast (tmp .local_blk_write_time );
1704
+ }
1663
1705
1664
1706
if (api_version >= PGSP_V1_7 )
1665
1707
{
@@ -1673,15 +1715,18 @@ pg_store_plans_internal(FunctionCallInfo fcinfo,
1673
1715
Assert (i == (api_version == PGSP_V1_5 ? PG_STORE_PLANS_COLS_V1_5 :
1674
1716
api_version == PGSP_V1_6 ? PG_STORE_PLANS_COLS_V1_6 :
1675
1717
api_version == PGSP_V1_7 ? PG_STORE_PLANS_COLS_V1_7 :
1718
+ api_version == PGSP_V1_9 ? PG_STORE_PLANS_COLS_V1_9 :
1676
1719
-1 /* fail if you forget to update this assert */ ));
1677
1720
1678
1721
tuplestore_putvalues (tupstore , tupdesc , values , nulls );
1679
1722
}
1680
1723
1681
1724
LWLockRelease (shared_state -> lock );
1682
1725
1726
+ #if PG_VERSION_NUM < 170000
1683
1727
/* clean up and return the tuplestore */
1684
1728
tuplestore_donestoring (tupstore );
1729
+ #endif
1685
1730
}
1686
1731
1687
1732
/* Number of output arguments (columns) for pg_stat_statements_info */
0 commit comments