Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WB3oo-0006Rm-SQ for pgsql-sql@arkaria.postgresql.org; Wed, 05 Feb 2014 14:51:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WB3oo-0006J8-CQ for pgsql-sql@arkaria.postgresql.org; Wed, 05 Feb 2014 14:51:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WB3on-0006J2-Mw for pgsql-sql@postgresql.org; Wed, 05 Feb 2014 14:51:13 +0000 Received: from nm22.bullet.mail.ir2.yahoo.com ([212.82.96.46]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WB3og-0002d2-PE for pgsql-sql@postgresql.org; Wed, 05 Feb 2014 14:51:13 +0000 Received: from [212.82.98.58] by nm22.bullet.mail.ir2.yahoo.com with NNFMP; 05 Feb 2014 14:51:05 -0000 Received: from [212.82.98.110] by tm11.bullet.mail.ir2.yahoo.com with NNFMP; 05 Feb 2014 14:51:05 -0000 Received: from [127.0.0.1] by omp1047.mail.ir2.yahoo.com with NNFMP; 05 Feb 2014 14:51:05 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 538671.62986.bm@omp1047.mail.ir2.yahoo.com Received: (qmail 24879 invoked by uid 60001); 5 Feb 2014 14:51:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1391611865; bh=6pemb+bTYoif1ph5dEG0xu28SFvef11EC9XNT+hWPWs=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=r8sKLVv1EskKXlijaUsJ1BBTbJoNLX5OUBW5AYo4CxFoN1ekFo/y3uAS6jOvv1TPjf5mVXEMdwn196T26+5NjZ9a1M0cU2tlioiyDf51Gtw/uq6T4DHZYFPtVEN/AqxecEM3J3fRrQm4E5kOkwJ68RDS4XLPg91Z1rLSOdKemGY= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=KjVEeKUvBHm1mQZt+d0QcK6hws719kt1ypQeTr2vXYAf4Pg6kDjHPgTZoIrfuhP33AccEhrLbJUdZC1h2KhonACp1CmacMFOre4iVoSPFy+0dSIWqoGEr2oeznjp7bGzvt+WQt8go6HowDzUSXLyRwHVR5EIaS/ZGIeuQcusBV0=; X-YMail-OSG: 4QOxGPkVM1kKcpS5f9C0j3IJiT.80o4bUFIz3z6MKH_ceUi ddLftsijNb4pggOFgqcz5SxBx1GQDoaQU51Fy0Moa3XUMGGmtV0ohg8zm.WI f2BMz5RYflKS47RR0tKIgvU8r9Zum3GaSCpCOqpdrOfz1fg53Oh93wztmrdW .IshB3gYDZVbGn7yipHa7KZoPHWqPbqA_lCZ8YwRLfAPK26Lx686CvVXcAze mhaAW8IpRvGgvwX9k5.biX2zpRBdfVmn8udQRGQrtTiKaQ48z_VOarmS4A5C aKH6UJ1AvWK5unczUtNVUVGlP_c3Quk1_a7URgVts_Xun_l4c5MXCNrNcCPc otGTvKW9TTfN74g9KDQetLMvtsDmBQBV8i1ll.ji8I7KDFuF_aNOWKiAuvK4 qv92hiNnMC2g42F1ppMVzaeMqwWrbiLkHu2EdxuMNgOcOSVfoOp959DmGO_2 CKDUaJS8n_poTqRDmmPUCSUY5nJNlx0oWIJo6DeUpuVS77rRnOC9mMmQQryf 0XUQIsVXzVNAn5ypq6Dk_F11u5smpBnk6cfsgFmR__hdAMO99gHnEBdDUW2q x Received: from [194.168.202.210] by web133202.mail.ir2.yahoo.com via HTTP; Wed, 05 Feb 2014 14:51:05 GMT X-Rocket-MIMEInfo: 002.001, LS0tLS0gT3JpZ2luYWwgTWVzc2FnZSAtLS0tLQoKPiBGcm9tOiBHbHluIEFzdGlsbCA8Z2x5bmFzdGlsbEB5YWhvby5jby51az4KPiBUbzogQ2V6YXJpdXN6IE1hcmVrIDxjZXphcml1c3oubWFyZWtAY29tYXJjaC5wbD47ICJwZ3NxbC1zcWxAcG9zdGdyZXNxbC5vcmciIDxwZ3NxbC1zcWxAcG9zdGdyZXNxbC5vcmc.Cj4gQ2M6IAo.IFNlbnQ6IFdlZG5lc2RheSwgNSBGZWJydWFyeSAyMDE0LCAxNDo0NQo.IFN1YmplY3Q6IFJlOiBbU1FMXSBJREVOVElGWV9TWVNURU0KPiAKPiAtLS0tLSBPcmlnaW5hbCBNZXMBMAEBAQE- X-Mailer: YahooMailWebService/0.8.175.631 References: <08af01cf20ba$d5f0aec0$81d20c40$@comarch.pl> <1391600088.5800.YahooMailNeo@web133204.mail.ir2.yahoo.com> <0aa401cf226a$12eb9320$38c2b960$@comarch.pl> <1391611541.96644.YahooMailNeo@web133205.mail.ir2.yahoo.com> Message-ID: <1391611865.95042.YahooMailNeo@web133202.mail.ir2.yahoo.com> Date: Wed, 5 Feb 2014 14:51:05 +0000 (GMT) From: Glyn Astill Reply-To: Glyn Astill Subject: Re: IDENTIFY_SYSTEM To: Cezariusz Marek , "pgsql-sql@postgresql.org" In-Reply-To: <1391611541.96644.YahooMailNeo@web133205.mail.ir2.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org ----- Original Message ----- > From: Glyn Astill > To: Cezariusz Marek ; "pgsql-sql@postgresql.o= rg" > Cc:=20 > Sent: Wednesday, 5 February 2014, 14:45 > Subject: Re: [SQL] IDENTIFY_SYSTEM >=20 > ----- Original Message ----- >=20 >> From: Cezariusz Marek >> To: pgsql-sql@postgresql.org >> Cc:=20 >> Sent: Wednesday, 5 February 2014, 12:01 >> Subject: Re: [SQL] IDENTIFY_SYSTEM >>=20 >>> =A0 That's part of the streaming replication protocol >>>=20 >>> =A0 http://www.postgresql.org/docs/9.3/static/protocol-replication.html >>> =A0 As long as you're using wal_level >=3D archive and the=20 > replication=20 >> connection is enabled you can retrieve it via psql >>=20 >> Yes, I know, but there is no way to get the systemid value from a funct= ion=20 > using=20 >> just SQL or plpgsql? >>=20 >=20 > I don't think so no, but you may have better luck finding someone more=20 > knowledgable posting to pgsql-general.=A0 You could do it by calling=20 > pg_controldata via an untrusted procedural language, not so sure how happ= y=20 > I'd be with that myself.=A0 E.g. with plperlu: >=20 > CREATE OR REPLACE FUNCTION get_system_identifier_unsafe(text)=20 > RETURNS text AS=20 > $BODY$ > =A0=A0=A0 my $rv; > =A0=A0=A0 my $data; > =A0=A0=A0 my $pg_controldata_bin =3D $_[0]; > =A0=A0=A0 my $sysid; > =A0=A0=A0=20 > =A0=A0=A0 $rv =3D spi_exec_query('SHOW data_directory', 1); > =A0=A0=A0 $data =3D $rv->{rows}[0]->{data_directory}; > =A0=A0=A0=20 > =A0=A0=A0 open(FD,"$pg_controldata_bin $data | "); > =A0=A0=A0=20 > =A0=A0=A0 while() { > =A0=A0=A0 =A0=A0=A0 if (/Database system identifier:/) { > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 $sysid =3D $_; > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 for ($sysid) { > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 s/Database system identifier://; > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 s/[^0-9]//g; > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 } > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 last; > =A0=A0=A0 =A0=A0=A0 } > =A0=A0=A0 } > =A0=A0=A0 close (FD); > =A0=A0=A0 return $sysid;=A0=A0=A0=20 >=20 > $BODY$ > LANGUAGE plperlu; >=20 >=20 So if I actually ran that: test=3D# select get_system_identifier_unsafe('pg_controldata'); =A0get_system_identifier_unsafe ------------------------------ =A05667443312440565226 >=20 >>> =A0 If it's just for licencing perhaps inet_server_addr() or a plperl=20 >> function to grab the mac address of the machine might suffice? >>=20 >> I have to license each database, not just the whole machine. And the=20 > systemid is=20 >> the only unique database identifier I've found. >=20 > Is it each database or each postgresql instance / cluster?=A0=A0 How exac= tly do you=20 > want your licencing to work? There may be a better way. > --=20 Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql