mirror of
https://github.com/postgres/postgres.git
synced 2026-07-16 05:02:57 -04:00
Avoid useless calls in pg_get_multixact_stats()
MultiXactOffsetStorageSize() and GetMultiXactInfo() are called to gather the information reported by the function, but were wasteful for the case where a role does not have the privileges of pg_read_all_stats, where we return a set of NULLs. These calls are moved to the code path where their results are used. Author: Ranier Vilela <ranier.vf@gmail.com> Discussion: https://postgr.es/m/CAEudQAonQh7be=wOR-CJFW=bgMBz5wW_bv4t0OFxbgn-794JCQ@mail.gmail.com Backpatch-through: 19
This commit is contained in:
parent
b26e0f6145
commit
9a2c07cbde
1 changed files with 11 additions and 11 deletions
|
|
@ -102,23 +102,12 @@ pg_get_multixact_stats(PG_FUNCTION_ARGS)
|
|||
TupleDesc tupdesc;
|
||||
Datum values[4];
|
||||
bool nulls[4];
|
||||
uint64 members;
|
||||
MultiXactId oldestMultiXactId;
|
||||
uint32 multixacts;
|
||||
MultiXactOffset oldestOffset;
|
||||
MultiXactOffset nextOffset;
|
||||
uint64 membersBytes;
|
||||
|
||||
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("return type must be a row type")));
|
||||
|
||||
GetMultiXactInfo(&multixacts, &nextOffset, &oldestMultiXactId, &oldestOffset);
|
||||
members = nextOffset - oldestOffset;
|
||||
|
||||
membersBytes = MultiXactOffsetStorageSize(nextOffset, oldestOffset);
|
||||
|
||||
if (!has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
|
||||
{
|
||||
/*
|
||||
|
|
@ -129,6 +118,17 @@ pg_get_multixact_stats(PG_FUNCTION_ARGS)
|
|||
}
|
||||
else
|
||||
{
|
||||
uint64 members;
|
||||
MultiXactId oldestMultiXactId;
|
||||
uint32 multixacts;
|
||||
MultiXactOffset oldestOffset;
|
||||
MultiXactOffset nextOffset;
|
||||
uint64 membersBytes;
|
||||
|
||||
GetMultiXactInfo(&multixacts, &nextOffset, &oldestMultiXactId, &oldestOffset);
|
||||
members = nextOffset - oldestOffset;
|
||||
membersBytes = MultiXactOffsetStorageSize(nextOffset, oldestOffset);
|
||||
|
||||
values[0] = UInt32GetDatum(multixacts);
|
||||
values[1] = Int64GetDatum(members);
|
||||
values[2] = Int64GetDatum(membersBytes);
|
||||
|
|
|
|||
Loading…
Reference in a new issue