Re: Getting my Database name in a C Extension - Mailing list pgsql-general

From Michael Paquier
Subject Re: Getting my Database name in a C Extension
Date
Msg-id CAB7nPqRgmeBhwi3cGcO5UXuFPXax-xThG0KWd3e9sQBXXSk-5w@mail.gmail.com
Whole thread Raw
In response to Re: Getting my Database name in a C Extension  (Albe Laurenz <laurenz.albe@wien.gv.at>)
Responses Re: Getting my Database name in a C Extension  (Cedric Berger <cedric@precidata.com>)
List pgsql-general


On Fri, Oct 3, 2014 at 4:57 PM, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
> Cedric Berger wrote:
>>>> 1) What is the easiest way to get that directly in C?
>>>
>>> The usual locution is "get_database_name(MyDatabaseId)".
>>
>> Ok, but then how do I find "MyDatabaseId" in, say,
>> a BeginForeignScan() or GetForeignRelSize() FDW callback?
>
> It is a global, all you should have to do is
> #include "miscadmin.h"
When looking for a global variable, a command like that is generally useful:
$ git grep MyDatabaseId -- *.h
src/include/access/xact.h:      Oid                     dbId;                   /* MyDatabaseId */
src/include/miscadmin.h:extern PGDLLIMPORT Oid MyDatabaseId;
Regards,
--
Michael

pgsql-general by date:

Previous
From: Albe Laurenz
Date:
Subject: Re: Getting my Database name in a C Extension
Next
From: Andrej Vanek
Date:
Subject: Re: deadlock of lock-waits (on transaction and on tuple) using same update statement