Re: Determining current database programmatically

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fran Fabrizio <ffabrizio(at)mmrd(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Determining current database programmatically
Date: 2001-12-03 15:46:31
Message-ID: 13368.1007394391@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Fran Fabrizio <ffabrizio(at)mmrd(dot)com> writes:
> I am writing a stored procedure that should ideally alter its behavior
> depending on the database that it is in. (If it's being used in the test
> database it should do one thing, and in production it should do another
> - it uses pgMail to send email alerts and I don't want to be sending
> the support folks emails from my own testing). I want to keep the
> procedure generic, so is there a way to figure out the name of the
> current database programmatically?

I don't think there is anything available at the SQL or plpgsql level
that tells that. While it wouldn't be hard to add, ISTM that wiring a
dependency on database name into your procedures is going to be a
mistake in the long run. Why don't you set up a "configuration" table
in each database that tells the procedure what to do?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Campano, Troy 2001-12-03 16:22:23 Should I use CAST?
Previous Message Tom Lane 2001-12-03 15:40:45 Re: Problem (bug?) with like