[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    Re: [SQL] IDENTIFY_SYSTEM
From:       bricklen <bricklen () gmail ! com>
Date:       2014-02-05 16:15:48
Message-ID: CAGrpgQ_b8smdAU3sjRrxfTWMtK0EnukQc2LCP71Pd4m=PC26xg () mail ! gmail ! com
[Download RAW message or body]

On Wed, Feb 5, 2014 at 6:51 AM, Glyn Astill <glynastill@yahoo.co.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

[Attachment #3 (text/html)]

<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 5, \
2014 at 6:51 AM, Glyn Astill <span dir="ltr">&lt;<a \
href="mailto:glynastill@yahoo.co.uk" \
target="_blank">glynastill@yahoo.co.uk</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div><div class="h5"> &gt;<br>
&gt; I don&#39;t think so no, but you may have better luck finding someone more<br>
&gt; knowledgable posting to pgsql-general.   You could do it by calling<br>
&gt; pg_controldata via an untrusted procedural language, not so sure how happy<br>
&gt; I&#39;d be with that myself.   E.g. with plperlu:<br>
&gt;<br>
&gt; CREATE OR REPLACE FUNCTION get_system_identifier_unsafe(text)<br>
&gt; RETURNS text AS<br>
&gt; $BODY$<br>
&gt;        my $rv;<br>
&gt;        my $data;<br>
&gt;        my $pg_controldata_bin = $_[0];<br>
&gt;        my $sysid;<br>
&gt;       <br>
&gt;        $rv = spi_exec_query(&#39;SHOW data_directory&#39;, 1);<br>
&gt;        $data = $rv-&gt;{rows}[0]-&gt;{data_directory};<br>
&gt;       <br>
&gt;        open(FD,&quot;$pg_controldata_bin $data | &quot;);<br>
&gt;       <br>
&gt;        while(&lt;FD&gt;) {<br>
&gt;               if (/Database system identifier:/) {<br>
&gt;                      $sysid = $_;<br>
&gt;                      for ($sysid) {<br>
&gt;                             s/Database system identifier://;<br>
&gt;                             s/[^0-9]//g;<br>
&gt;                      }<br>
&gt;                      last;<br>
&gt;               }<br>
&gt;        }<br>
&gt;        close (FD);<br>
&gt;        return $sysid;      <br>
&gt;<br>
&gt; $BODY$<br>
&gt; LANGUAGE plperlu;<br>
&gt;<br>
&gt;<br>
<br>
</div></div>So if I actually ran that:<br>
<br>
test=# select get_system_identifier_unsafe(&#39;pg_controldata&#39;);<br>
  get_system_identifier_unsafe<br>
------------------------------<br>
  5667443312440565226<br></blockquote></div><br><br></div><div \
class="gmail_extra">Joe Conway wrote something a few years ago which could probably \
be brought up to date and made into a Postgresql extension. <a \
href="https://github.com/jconway/pg_controldata">https://github.com/jconway/pg_controldata</a><br>
 </div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic