On Thu, Aug 29, 2019 at 3:16 PM Sergei Kornilov <s...@zsrv.org> wrote:

> Hello
>
> > Is there a need for this function for the user?
>
> This was feature request from user. I got such comment:
>
> This function is useful when working with pg_stat_statements. For
> obtaining a databаse name for particular query you need to join pg_database
> relation, but for obtaining an username you just need pg_get_userbyid(). So
> it will be useful not to join extra relation and get a database name using
> the similar function - pg_get_databasebyid().
>
> regards, Sergei
>

Hi,
I think its a user request and don't require to be in the core of
PostgreSQL.
A simple SQL function can fulfill the requirement of the user.

CREATE OR REPLACE FUNCTION pg_get_databasebyid(dboid integer) RETURNS name
AS $$

    SELECT datname from pg_database WHERE oid = dboid;
$$ LANGUAGE SQL;

-- 
Ibrar Ahmed

Reply via email to