Re: Database system identifier via SELECT?

Lists: pgsql-general
From: Chris Redekop <chris(at)replicon(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Database system identifier via SELECT?
Date: 2011-12-08 18:08:31
Message-ID: CAC2SuRJLMtKyvCs6DbxdyUrHy+WKe-94cBuGnwCXAg914cwG7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Is there any way to get the database system identifier via a select
statement? I have a primary/secondary async replication setup, and I'd
like be able to verify from the client side that the provided primary and
secondary connection strings do in fact refer to the same data set...


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Chris Redekop <chris(at)replicon(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database system identifier via SELECT?
Date: 2011-12-08 20:57:24
Message-ID: 201112082057.pB8KvOU19242@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Chris Redekop wrote:
> Is there any way to get the database system identifier via a select
> statement? I have a primary/secondary async replication setup, and I'd
> like be able to verify from the client side that the provided primary and
> secondary connection strings do in fact refer to the same data set...

Wow, that is a reasonable thing to want available via SQL, but I can't
see a way to get to it.

The only method I can suggest is to write a server-side C function that
calls GetSystemIdentifier().

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Chris Redekop <chris(at)replicon(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database system identifier via SELECT?
Date: 2011-12-08 21:11:19
Message-ID: 4EE127F7.8090908@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


On 12/08/2011 12:57 PM, Bruce Momjian wrote:
>
> Chris Redekop wrote:
>> Is there any way to get the database system identifier via a select
>> statement? I have a primary/secondary async replication setup, and I'd
>> like be able to verify from the client side that the provided primary and
>> secondary connection strings do in fact refer to the same data set...
>
> Wow, that is a reasonable thing to want available via SQL, but I can't
> see a way to get to it.
>
> The only method I can suggest is to write a server-side C function that
> calls GetSystemIdentifier().

This seems like something we should have in core, don't you think?

JD

>

--
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Support, Training, Professional Services and Development
The PostgreSQL Conference - http://www.postgresqlconference.org/
@cmdpromptinc - @postgresconf - 509-416-6579


From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Bruce Momjian'" <bruce(at)momjian(dot)us>, "'Chris Redekop'" <chris(at)replicon(dot)com>
Cc: "'pgsql-general'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database system identifier via SELECT?
Date: 2011-12-08 21:15:58
Message-ID: 058001ccb5ee$956722f0$c03568d0$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Bruce Momjian
Sent: Thursday, December 08, 2011 3:57 PM
To: Chris Redekop
Cc: pgsql-general
Subject: Re: [GENERAL] Database system identifier via SELECT?

Chris Redekop wrote:
> Is there any way to get the database system identifier via a select
> statement? I have a primary/secondary async replication setup, and
> I'd like be able to verify from the client side that the provided
> primary and secondary connection strings do in fact refer to the same data
set...

Wow, that is a reasonable thing to want available via SQL, but I can't see a
way to get to it.

The only method I can suggest is to write a server-side C function that
calls GetSystemIdentifier().

---------------------------------------------------

Maybe I mis-understand the question but how about:

SHOW listen_addresses; (of the functional equivalent)

You just need to make sure each server is listening to a specific IP and/or
Port and just tag off of that.

David J.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Chris Redekop <chris(at)replicon(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database system identifier via SELECT?
Date: 2011-12-08 21:27:15
Message-ID: 201112082127.pB8LRF323502@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Joshua D. Drake wrote:
>
> On 12/08/2011 12:57 PM, Bruce Momjian wrote:
> >
> > Chris Redekop wrote:
> >> Is there any way to get the database system identifier via a select
> >> statement? I have a primary/secondary async replication setup, and I'd
> >> like be able to verify from the client side that the provided primary and
> >> secondary connection strings do in fact refer to the same data set...
> >
> > Wow, that is a reasonable thing to want available via SQL, but I can't
> > see a way to get to it.
> >
> > The only method I can suggest is to write a server-side C function that
> > calls GetSystemIdentifier().
>
> This seems like something we should have in core, don't you think?

Yeah, kind of, except this is the first request we ever got for this.
The identifier is passed as part of streaming replication, so maybe it
will be needed more in the future.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Scott Mead <scottm(at)openscg(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Chris Redekop <chris(at)replicon(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database system identifier via SELECT?
Date: 2011-12-08 21:57:58
Message-ID: CAKq0gvKjDqO=5FLxo3uGCHJqMJHCrFErYV+EmDmo64kntj4bBg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, Dec 8, 2011 at 4:27 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:

> Joshua D. Drake wrote:
> >
> > On 12/08/2011 12:57 PM, Bruce Momjian wrote:
> > >
> > > Chris Redekop wrote:
> > >> Is there any way to get the database system identifier via a select
> > >> statement? I have a primary/secondary async replication setup, and
> I'd
> > >> like be able to verify from the client side that the provided primary
> and
> > >> secondary connection strings do in fact refer to the same data set...
> > >
> > > Wow, that is a reasonable thing to want available via SQL, but I can't
> > > see a way to get to it.
> > >
> > > The only method I can suggest is to write a server-side C function that
> > > calls GetSystemIdentifier().
>

select inet_server_addr()?

--Scott

> >
> > This seems like something we should have in core, don't you think?
>
> Yeah, kind of, except this is the first request we ever got for this.
> The identifier is passed as part of streaming replication, so maybe it
> will be needed more in the future.
>
> --
> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
> EnterpriseDB http://enterprisedb.com
>
> + It's impossible for everything to be true. +
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>


From: Safari Code <safaricode(at)gmail(dot)com>
To: Scott Mead <scottm(at)openscg(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Chris Redekop <chris(at)replicon(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database system identifier via SELECT?
Date: 2011-12-08 22:09:07
Message-ID: CANO3SPhUUVKd-gQDoSSbmqOSmvsg-e_nAkg7iv20bYjDJFaG=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

You can get the database system identifier from the OS shell as part of the
control data:
pg_controldata /Library/PostgreSQL/9.1/data

Here, '/Library/PostgreSQL/9.1/data' is my data directory on os x; replace
it with your own data directory.
>From there, you can isolate the database system identifier with grep:
pg_controldata /Library/PostgreSQL/9.1/data | grep "system identifier"

This is not the same as calling a function within a SELECT statement, but
using the shell command above, one could easily write a function that
returns the database system identifier as a string in a SQL query.

I hope this solves the problem.

On Thu, Dec 8, 2011 at 4:57 PM, Scott Mead <scottm(at)openscg(dot)com> wrote:

>
> On Thu, Dec 8, 2011 at 4:27 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>
>> Joshua D. Drake wrote:
>> >
>> > On 12/08/2011 12:57 PM, Bruce Momjian wrote:
>> > >
>> > > Chris Redekop wrote:
>> > >> Is there any way to get the database system identifier via a select
>> > >> statement? I have a primary/secondary async replication setup, and
>> I'd
>> > >> like be able to verify from the client side that the provided
>> primary and
>> > >> secondary connection strings do in fact refer to the same data set...
>> > >
>> > > Wow, that is a reasonable thing to want available via SQL, but I can't
>> > > see a way to get to it.
>> > >
>> > > The only method I can suggest is to write a server-side C function
>> that
>> > > calls GetSystemIdentifier().
>>
>
> select inet_server_addr()?
>
> --Scott
>
>
>
>
>> >
>> > This seems like something we should have in core, don't you think?
>>
>> Yeah, kind of, except this is the first request we ever got for this.
>> The identifier is passed as part of streaming replication, so maybe it
>> will be needed more in the future.
>>
>> --
>> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
>> EnterpriseDB http://enterprisedb.com
>>
>> + It's impossible for everything to be true. +
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>>
>
>


From: Chris Redekop <chris(at)replicon(dot)com>
To: Safari Code <safaricode(at)gmail(dot)com>
Cc: Scott Mead <scottm(at)openscg(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database system identifier via SELECT?
Date: 2011-12-09 14:16:39
Message-ID: CAC2SuR+p+QGGkWtCaoyGHKUGDmaEUY4ymZuCVz0BPBAVwMm_RQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Yeah, it would be easy enough to write a custom extension to do it. I was
hoping for something built-in so I wouldn't require a pre-req extension be
installed on all servers by the superuser....sysadmins tend to resist
making such changes. But oh well what you gotta do you gotta do....thanks
guys.

FYI this isn't the first time it's been asked for...
http://archives.postgresql.org/pgsql-sql/2007-07/msg00045.php ...first time
in 4 years tho :P

On Thu, Dec 8, 2011 at 3:09 PM, Safari Code <safaricode(at)gmail(dot)com> wrote:

> You can get the database system identifier from the OS shell as part of
> the control data:
> pg_controldata /Library/PostgreSQL/9.1/data
>
> Here, '/Library/PostgreSQL/9.1/data' is my data directory on os x; replace
> it with your own data directory.
> From there, you can isolate the database system identifier with grep:
> pg_controldata /Library/PostgreSQL/9.1/data | grep "system identifier"
>
> This is not the same as calling a function within a SELECT statement, but
> using the shell command above, one could easily write a function that
> returns the database system identifier as a string in a SQL query.
>
> I hope this solves the problem.
>
> On Thu, Dec 8, 2011 at 4:57 PM, Scott Mead <scottm(at)openscg(dot)com> wrote:
>
>>
>> On Thu, Dec 8, 2011 at 4:27 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>>
>>> Joshua D. Drake wrote:
>>> >
>>> > On 12/08/2011 12:57 PM, Bruce Momjian wrote:
>>> > >
>>> > > Chris Redekop wrote:
>>> > >> Is there any way to get the database system identifier via a select
>>> > >> statement? I have a primary/secondary async replication setup, and
>>> I'd
>>> > >> like be able to verify from the client side that the provided
>>> primary and
>>> > >> secondary connection strings do in fact refer to the same data
>>> set...
>>> > >
>>> > > Wow, that is a reasonable thing to want available via SQL, but I
>>> can't
>>> > > see a way to get to it.
>>> > >
>>> > > The only method I can suggest is to write a server-side C function
>>> that
>>> > > calls GetSystemIdentifier().
>>>
>>
>> select inet_server_addr()?
>>
>> --Scott
>>
>>
>>
>>
>>> >
>>> > This seems like something we should have in core, don't you think?
>>>
>>> Yeah, kind of, except this is the first request we ever got for this.
>>> The identifier is passed as part of streaming replication, so maybe it
>>> will be needed more in the future.
>>>
>>> --
>>> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
>>> EnterpriseDB http://enterprisedb.com
>>>
>>> + It's impossible for everything to be true. +
>>>
>>> --
>>> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgsql-general
>>>
>>
>>
>