Re: Database system identifier from SQL

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Database system identifier from SQL
Date: 2007-07-10 18:06:10
Message-ID: 200707102006.11643.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > Is there a way to query the database system identifier that
> > pg_controldata outputs from SQL?
>
> Don't think so. Do you have a use-case for providing a function to
> return that?

I'd like to find out whether two connections are really to the same
server.

This is in the context of an installation routine for a database
application which pulls the connection parameters for several databases
from a configuration file and creates various things there. It should,
however, only create roles once if the connection parameters point to
the same server (if the user only expects a small installation, say).

A workaround is to compare inet_server_addr() and inet_server_port(),
but that is not 100% safe because it doesn't cover Unix-domain sockets
using different paths.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2007-07-10 18:15:20 Re: Database system identifier from SQL
Previous Message Tom Lane 2007-07-10 17:24:24 Re: Index working, but not inside function