Re: How to get the name of the current database in C function/extention inside a trigger? - Mailing list pgsql-general

From David Rowley
Subject Re: How to get the name of the current database in C function/extention inside a trigger?
Date
Msg-id CAApHDvr0uvSiSNt814sm8WDBPC_R+_sh8gRUytWRk9CnAG=--Q@mail.gmail.com
Whole thread Raw
In response to How to get the name of the current database in C function/extention inside a trigger?  (alex m <al-gen@serendipia.email>)
Responses Re: How to get the name of the current database in C function/extention inside a trigger?  (alex m <al-gen@serendipia.email>)
List pgsql-general
On Mon, 3 Aug 2020 at 21:26, alex m <al-gen@serendipia.email> wrote:
> I'm writting a function/extention in C for a trigger. Inside a trigger, in C, I want to get the name of the current
database.However, not via SPI_exec(), SPI_prepare() and the like, but more directly, in a more faster way.
 

You can use MyDatabaseId in miscadmin.h

If you git grep MyDatabaseId in src/contrib you can see some examples.

A good tip for the future would be to just look at the source code of
the built-in function and see how it does it.

David



pgsql-general by date:

Previous
From: "Daniel Westermann (DWE)"
Date:
Subject: Re: Out of memory with "create extension postgis"
Next
From: John Ashmead
Date:
Subject: How can you find out what point logical replication is at?