Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 13F0C4767C8 for ; Mon, 9 Dec 2002 18:39:51 -0500 (EST) Received: from lubitsch.akademie.de (ns.akademie.de [62.165.4.3]) by postgresql.org (Postfix) with ESMTP id 9BEC047659F for ; Mon, 9 Dec 2002 18:34:39 -0500 (EST) Received: from pd9eb1466.dip.t-dialin.net ([217.235.20.102] helo=ianb.local) by lubitsch.akademie.de with asmtp (Exim 3.33 #2) id 18LXQ9-0004FY-00; Tue, 10 Dec 2002 00:34:41 +0100 From: Ian Barwick To: Tom Lane Subject: Re: Patch for DBD::Pg pg_relcheck problem Date: Tue, 10 Dec 2002 00:34:31 +0100 X-Mailer: KMail [version 1.4] References: <200212091631.00125.barwick@gmx.net> <8159.1039449832@sss.pgh.pa.us> In-Reply-To: <8159.1039449832@sss.pgh.pa.us> Cc: dbi-dev@perl.org, pgsql-interfaces@postgresql.org MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="------------Boundary-00=_JHLVDF0UAY8OZHEWKHPQ" Message-Id: <200212100034.31936.barwick@gmx.net> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/23 X-Sequence-Number: 3436 --------------Boundary-00=_JHLVDF0UAY8OZHEWKHPQ Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable On Monday 09 December 2002 17:03, Tom Lane wrote: > Ian Barwick writes: > > To avoid voodoo with PostgreSQL version numbers > > a check is made whether pg_relcheck exists and > > the appropriate query (either 7.3 or pre 7.3) > > executed. > > I would think that looking at version number (select version()) > would be a much cleaner approach. Or do you think that direct > examination of pg_class is a version-independent operation? No, but I was hoping it will remain stable for long enough for what is basically a temporary work around until a revised version of=20 DBD::Pg can be produced. It doesn't make any more assumptions=20 about pg_class than are made elsewhere in the current Pg.pm. > This inquiry into pg_relcheck's existence is already arguably wrong > in 7.3 (since it's not taking account of which schema pg_relcheck > might be found in) and it can only go downhill in future versions. Doh. Knew I had to be missing something obvious. (Of course, anyone using current DBD::Pg with 7.3 as is will have to take extra care with system tables and schema namespaces anyway.) So out with the candle wax and pins ;-). Am I right in thinking that the string returned by SELECT version() starts with the word "PostgreSQL" followed by: a space;=20 a single digit indicating the major version number; a full stop / decimal point; a single digit indicating the minor version number; and either "interim release" number (e.g. ".1" in the case of 7.3.1), or "devel", "rc1" etc. ? And that this has been true since 6.x and will continue for the forseeable= =20 future (i.e. far far longer than the intended lifespan of attached patch)? Ian Barwick barwick@gmx.net Attached: revised patch --------------Boundary-00=_JHLVDF0UAY8OZHEWKHPQ Content-Type: text/x-diff; charset="iso-2022-jp"; name="Pg.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Pg.patch" 619c619,629 < my ($constraint) = $dbh->selectrow_array("select rcsrc from pg_relcheck where rcname = '${table}_$col_name'"); --- > # Note: as of PostgreSQL 7.3 pg_relcheck has been replaced > # by pg_constraint. To maintain compatibility, check > # version number and execute appropriate query. > > my ($version) = $dbh->selectrow_array("SELECT version()"); > $version =~ /^PostgreSQL (\d)\.(\d)/; > > my $con_query = $1.$2 < 73 > ? "SELECT rcsrc FROM pg_relcheck WHERE rcname = '${table}_$col_name'" > : "SELECT consrc FROM pg_catalog.pg_constraint WHERE contype = 'c' AND conname = '${table}_$col_name'"; > my ($constraint) = $dbh->selectrow_array($con_query); --------------Boundary-00=_JHLVDF0UAY8OZHEWKHPQ--