Re: IDENTIFY_SYSTEM

From: bricklen <bricklen(at)gmail(dot)com>
To: Glyn Astill <glynastill(at)yahoo(dot)co(dot)uk>
Cc: Cezariusz Marek <cezariusz(dot)marek(at)comarch(dot)pl>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: IDENTIFY_SYSTEM
Date: 2014-02-05 16:15:48
Message-ID: CAGrpgQ_b8smdAU3sjRrxfTWMtK0EnukQc2LCP71Pd4m=PC26xg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Feb 5, 2014 at 6:51 AM, Glyn Astill <glynastill(at)yahoo(dot)co(dot)uk> wrote:

> >
> > I don't think so no, but you may have better luck finding someone more
> > knowledgable posting to pgsql-general. You could do it by calling
> > pg_controldata via an untrusted procedural language, not so sure how
> happy
> > I'd be with that myself. E.g. with plperlu:
> >
> > CREATE OR REPLACE FUNCTION get_system_identifier_unsafe(text)
> > RETURNS text AS
> > $BODY$
> > my $rv;
> > my $data;
> > my $pg_controldata_bin = $_[0];
> > my $sysid;
> >
> > $rv = spi_exec_query('SHOW data_directory', 1);
> > $data = $rv->{rows}[0]->{data_directory};
> >
> > open(FD,"$pg_controldata_bin $data | ");
> >
> > while(<FD>) {
> > if (/Database system identifier:/) {
> > $sysid = $_;
> > for ($sysid) {
> > s/Database system identifier://;
> > s/[^0-9]//g;
> > }
> > last;
> > }
> > }
> > close (FD);
> > return $sysid;
> >
> > $BODY$
> > LANGUAGE plperlu;
> >
> >
>
> So if I actually ran that:
>
> test=# select get_system_identifier_unsafe('pg_controldata');
> get_system_identifier_unsafe
> ------------------------------
> 5667443312440565226
>

Joe Conway wrote something a few years ago which could probably be brought
up to date and made into a Postgresql extension.
https://github.com/jconway/pg_controldata

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message rawi 2014-02-11 07:54:45 Time AT TIME ZONE: false result using offset instead of time zone name
Previous Message Glyn Astill 2014-02-05 14:51:05 Re: IDENTIFY_SYSTEM