@@ -1498,50 +1498,42 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
1498
1498
return (Datum ) 0 ;
1499
1499
}
1500
1500
1501
- Datum
1502
- pg_stat_get_xact_numscans (PG_FUNCTION_ARGS )
1503
- {
1504
- Oid relid = PG_GETARG_OID (0 );
1505
- int64 result ;
1506
- PgStat_TableStatus * tabentry ;
1507
-
1508
- if ((tabentry = find_tabstat_entry (relid )) == NULL )
1509
- result = 0 ;
1510
- else
1511
- result = (int64 ) (tabentry -> counts .numscans );
1512
-
1513
- PG_RETURN_INT64 (result );
1501
+ #define PG_STAT_GET_XACT_RELENTRY_INT64 (stat ) \
1502
+ Datum \
1503
+ CppConcat(pg_stat_get_xact_,stat)(PG_FUNCTION_ARGS) \
1504
+ { \
1505
+ Oid relid = PG_GETARG_OID(0); \
1506
+ int64 result; \
1507
+ PgStat_TableStatus *tabentry; \
1508
+ \
1509
+ if ((tabentry = find_tabstat_entry(relid)) == NULL) \
1510
+ result = 0; \
1511
+ else \
1512
+ result = (int64) (tabentry->counts.stat); \
1513
+ \
1514
+ PG_RETURN_INT64(result); \
1514
1515
}
1515
1516
1516
- Datum
1517
- pg_stat_get_xact_tuples_returned (PG_FUNCTION_ARGS )
1518
- {
1519
- Oid relid = PG_GETARG_OID (0 );
1520
- int64 result ;
1521
- PgStat_TableStatus * tabentry ;
1517
+ /* pg_stat_get_xact_numscans */
1518
+ PG_STAT_GET_XACT_RELENTRY_INT64 (numscans )
1522
1519
1523
- if ((tabentry = find_tabstat_entry (relid )) == NULL )
1524
- result = 0 ;
1525
- else
1526
- result = (int64 ) (tabentry -> counts .tuples_returned );
1520
+ /* pg_stat_get_xact_tuples_returned */
1521
+ PG_STAT_GET_XACT_RELENTRY_INT64 (tuples_returned )
1527
1522
1528
- PG_RETURN_INT64 ( result );
1529
- }
1523
+ /* pg_stat_get_xact_tuples_fetched */
1524
+ PG_STAT_GET_XACT_RELENTRY_INT64 ( tuples_fetched )
1530
1525
1531
- Datum
1532
- pg_stat_get_xact_tuples_fetched (PG_FUNCTION_ARGS )
1533
- {
1534
- Oid relid = PG_GETARG_OID (0 );
1535
- int64 result ;
1536
- PgStat_TableStatus * tabentry ;
1526
+ /* pg_stat_get_xact_tuples_hot_updated */
1527
+ PG_STAT_GET_XACT_RELENTRY_INT64 (tuples_hot_updated )
1537
1528
1538
- if ((tabentry = find_tabstat_entry (relid )) == NULL )
1539
- result = 0 ;
1540
- else
1541
- result = (int64 ) (tabentry -> counts .tuples_fetched );
1529
+ /* pg_stat_get_xact_tuples_newpage_updated */
1530
+ PG_STAT_GET_XACT_RELENTRY_INT64 (tuples_newpage_updated )
1542
1531
1543
- PG_RETURN_INT64 (result );
1544
- }
1532
+ /* pg_stat_get_xact_blocks_fetched */
1533
+ PG_STAT_GET_XACT_RELENTRY_INT64 (blocks_fetched )
1534
+
1535
+ /* pg_stat_get_xact_blocks_hit */
1536
+ PG_STAT_GET_XACT_RELENTRY_INT64 (blocks_hit )
1545
1537
1546
1538
Datum
1547
1539
pg_stat_get_xact_tuples_inserted (PG_FUNCTION_ARGS )
@@ -1606,66 +1598,6 @@ pg_stat_get_xact_tuples_deleted(PG_FUNCTION_ARGS)
1606
1598
PG_RETURN_INT64 (result );
1607
1599
}
1608
1600
1609
- Datum
1610
- pg_stat_get_xact_tuples_hot_updated (PG_FUNCTION_ARGS )
1611
- {
1612
- Oid relid = PG_GETARG_OID (0 );
1613
- int64 result ;
1614
- PgStat_TableStatus * tabentry ;
1615
-
1616
- if ((tabentry = find_tabstat_entry (relid )) == NULL )
1617
- result = 0 ;
1618
- else
1619
- result = (int64 ) (tabentry -> counts .tuples_hot_updated );
1620
-
1621
- PG_RETURN_INT64 (result );
1622
- }
1623
-
1624
- Datum
1625
- pg_stat_get_xact_tuples_newpage_updated (PG_FUNCTION_ARGS )
1626
- {
1627
- Oid relid = PG_GETARG_OID (0 );
1628
- int64 result ;
1629
- PgStat_TableStatus * tabentry ;
1630
-
1631
- if ((tabentry = find_tabstat_entry (relid )) == NULL )
1632
- result = 0 ;
1633
- else
1634
- result = (int64 ) (tabentry -> counts .tuples_newpage_updated );
1635
-
1636
- PG_RETURN_INT64 (result );
1637
- }
1638
-
1639
- Datum
1640
- pg_stat_get_xact_blocks_fetched (PG_FUNCTION_ARGS )
1641
- {
1642
- Oid relid = PG_GETARG_OID (0 );
1643
- int64 result ;
1644
- PgStat_TableStatus * tabentry ;
1645
-
1646
- if ((tabentry = find_tabstat_entry (relid )) == NULL )
1647
- result = 0 ;
1648
- else
1649
- result = (int64 ) (tabentry -> counts .blocks_fetched );
1650
-
1651
- PG_RETURN_INT64 (result );
1652
- }
1653
-
1654
- Datum
1655
- pg_stat_get_xact_blocks_hit (PG_FUNCTION_ARGS )
1656
- {
1657
- Oid relid = PG_GETARG_OID (0 );
1658
- int64 result ;
1659
- PgStat_TableStatus * tabentry ;
1660
-
1661
- if ((tabentry = find_tabstat_entry (relid )) == NULL )
1662
- result = 0 ;
1663
- else
1664
- result = (int64 ) (tabentry -> counts .blocks_hit );
1665
-
1666
- PG_RETURN_INT64 (result );
1667
- }
1668
-
1669
1601
Datum
1670
1602
pg_stat_get_xact_function_calls (PG_FUNCTION_ARGS )
1671
1603
{
0 commit comments