mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Generate pg_stat_get_xact*() functions for relations using macros
This change replaces seven functions definitions by macros. This is the same idea as8018ffb
or83a1a1b
, taking advantage of the variable rename done in8089517
for relation entries. Author: Bertrand Drouvot Discussion: https://postgr.es/m/631e3084-c5d9-8463-7540-fcff4674caa5@gmail.com
This commit is contained in:
@ -1498,50 +1498,42 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
|
|||||||
return (Datum) 0;
|
return (Datum) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
#define PG_STAT_GET_XACT_RELENTRY_INT64(stat) \
|
||||||
pg_stat_get_xact_numscans(PG_FUNCTION_ARGS)
|
Datum \
|
||||||
{
|
CppConcat(pg_stat_get_xact_,stat)(PG_FUNCTION_ARGS) \
|
||||||
Oid relid = PG_GETARG_OID(0);
|
{ \
|
||||||
int64 result;
|
Oid relid = PG_GETARG_OID(0); \
|
||||||
PgStat_TableStatus *tabentry;
|
int64 result; \
|
||||||
|
PgStat_TableStatus *tabentry; \
|
||||||
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
\
|
||||||
result = 0;
|
if ((tabentry = find_tabstat_entry(relid)) == NULL) \
|
||||||
else
|
result = 0; \
|
||||||
result = (int64) (tabentry->counts.numscans);
|
else \
|
||||||
|
result = (int64) (tabentry->counts.stat); \
|
||||||
PG_RETURN_INT64(result);
|
\
|
||||||
|
PG_RETURN_INT64(result); \
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
/* pg_stat_get_xact_numscans */
|
||||||
pg_stat_get_xact_tuples_returned(PG_FUNCTION_ARGS)
|
PG_STAT_GET_XACT_RELENTRY_INT64(numscans)
|
||||||
{
|
|
||||||
Oid relid = PG_GETARG_OID(0);
|
|
||||||
int64 result;
|
|
||||||
PgStat_TableStatus *tabentry;
|
|
||||||
|
|
||||||
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
/* pg_stat_get_xact_tuples_returned */
|
||||||
result = 0;
|
PG_STAT_GET_XACT_RELENTRY_INT64(tuples_returned)
|
||||||
else
|
|
||||||
result = (int64) (tabentry->counts.tuples_returned);
|
|
||||||
|
|
||||||
PG_RETURN_INT64(result);
|
/* pg_stat_get_xact_tuples_fetched */
|
||||||
}
|
PG_STAT_GET_XACT_RELENTRY_INT64(tuples_fetched)
|
||||||
|
|
||||||
Datum
|
/* pg_stat_get_xact_tuples_hot_updated */
|
||||||
pg_stat_get_xact_tuples_fetched(PG_FUNCTION_ARGS)
|
PG_STAT_GET_XACT_RELENTRY_INT64(tuples_hot_updated)
|
||||||
{
|
|
||||||
Oid relid = PG_GETARG_OID(0);
|
|
||||||
int64 result;
|
|
||||||
PgStat_TableStatus *tabentry;
|
|
||||||
|
|
||||||
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
/* pg_stat_get_xact_tuples_newpage_updated */
|
||||||
result = 0;
|
PG_STAT_GET_XACT_RELENTRY_INT64(tuples_newpage_updated)
|
||||||
else
|
|
||||||
result = (int64) (tabentry->counts.tuples_fetched);
|
|
||||||
|
|
||||||
PG_RETURN_INT64(result);
|
/* pg_stat_get_xact_blocks_fetched */
|
||||||
}
|
PG_STAT_GET_XACT_RELENTRY_INT64(blocks_fetched)
|
||||||
|
|
||||||
|
/* pg_stat_get_xact_blocks_hit */
|
||||||
|
PG_STAT_GET_XACT_RELENTRY_INT64(blocks_hit)
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
pg_stat_get_xact_tuples_inserted(PG_FUNCTION_ARGS)
|
pg_stat_get_xact_tuples_inserted(PG_FUNCTION_ARGS)
|
||||||
@ -1606,66 +1598,6 @@ pg_stat_get_xact_tuples_deleted(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_INT64(result);
|
PG_RETURN_INT64(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
|
||||||
pg_stat_get_xact_tuples_hot_updated(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
Oid relid = PG_GETARG_OID(0);
|
|
||||||
int64 result;
|
|
||||||
PgStat_TableStatus *tabentry;
|
|
||||||
|
|
||||||
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
||||||
result = 0;
|
|
||||||
else
|
|
||||||
result = (int64) (tabentry->counts.tuples_hot_updated);
|
|
||||||
|
|
||||||
PG_RETURN_INT64(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
Datum
|
|
||||||
pg_stat_get_xact_tuples_newpage_updated(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
Oid relid = PG_GETARG_OID(0);
|
|
||||||
int64 result;
|
|
||||||
PgStat_TableStatus *tabentry;
|
|
||||||
|
|
||||||
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
||||||
result = 0;
|
|
||||||
else
|
|
||||||
result = (int64) (tabentry->counts.tuples_newpage_updated);
|
|
||||||
|
|
||||||
PG_RETURN_INT64(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
Datum
|
|
||||||
pg_stat_get_xact_blocks_fetched(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
Oid relid = PG_GETARG_OID(0);
|
|
||||||
int64 result;
|
|
||||||
PgStat_TableStatus *tabentry;
|
|
||||||
|
|
||||||
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
||||||
result = 0;
|
|
||||||
else
|
|
||||||
result = (int64) (tabentry->counts.blocks_fetched);
|
|
||||||
|
|
||||||
PG_RETURN_INT64(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
Datum
|
|
||||||
pg_stat_get_xact_blocks_hit(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
Oid relid = PG_GETARG_OID(0);
|
|
||||||
int64 result;
|
|
||||||
PgStat_TableStatus *tabentry;
|
|
||||||
|
|
||||||
if ((tabentry = find_tabstat_entry(relid)) == NULL)
|
|
||||||
result = 0;
|
|
||||||
else
|
|
||||||
result = (int64) (tabentry->counts.blocks_hit);
|
|
||||||
|
|
||||||
PG_RETURN_INT64(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
pg_stat_get_xact_function_calls(PG_FUNCTION_ARGS)
|
pg_stat_get_xact_function_calls(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user