Обсуждение: Getting my Database name in a C Extension
Hi, I'm writing an extention (FDW), and I need, in my C code, the name of my database ("contrib_regression_test" for example), and I've two questions: 1) What is the easiest way to get that directly in C? 2) Is there a way to get this information in the SQL extension installation/update scripts (like the @/extschema/@ substitution)? Thanks, -- Cedric Berger Precidata Sarl Maladière 71c 2000 Neuchâtel cedric@precidata.com 032 930 29 62 079 934 11 02
On 10/2/2014 8:11 AM, Cedric Berger wrote:
I'm writing an extention (FDW), and I need, in my C code, the name of
my database ("contrib_regression_test" for example), and I've two
questions:
1) What is the easiest way to get that directly in C?
2) Is there a way to get this information in the SQL extension
installation/update scripts (like the @/extschema/@ substitution)?
you could SELECT CURRENT_CATALOG; using the SPI_ functions from your C, or directly in your SQL extension script... this returns the database name (the name is from the sql standard). see http://www.postgresql.org/docs/current/static/functions-info.html for more info functions like this available in SQL.
-- john r pierce 37N 122W somewhere on the middle of the left coast