pg_stat_statements: remove redundant function call in pg_stat_statements_internal

From: Dong Wook Lee <sh95119(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: pg_stat_statements: remove redundant function call in pg_stat_statements_internal
Date: 2022-02-27 11:45:13
Message-ID: CAAcBya+szDd1Y6dJU4_dbH_Ye3=G=8O1oQGG01kv3Tpie7wELQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I found some redundant function calls in
pg_stat_statements.c/pg_stat_statements_internal(),
There is no need to call GetUserId() again because the value was
previously obtained.
so I propose a patch to fix it.

--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -1508,7 +1508,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
pgssEntry *entry;

/* Superusers or members of pg_read_all_stats members are allowed */
- is_allowed_role = is_member_of_role(GetUserId(),
ROLE_PG_READ_ALL_STATS);
+ is_allowed_role = is_member_of_role(userid, ROLE_PG_READ_ALL_STATS);

/* hash table must exist already */
if (!pgss || !pgss_hash)

Regards,
Lee Dong Wook.

Attachment Content-Type Size
v1_tiny_improvement_pg_stat_statements.patch application/octet-stream 638 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2022-02-27 11:55:26 Re: pg_stat_statements: remove redundant function call in pg_stat_statements_internal
Previous Message Dean Rasheed 2022-02-27 11:23:27 Re: Some optimisations for numeric division