Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 39267475FB9 for ; Mon, 9 Dec 2002 10:40:03 -0500 (EST) Received: from post.webmailer.de (natsmtp01.webmailer.de [192.67.198.81]) by postgresql.org (Postfix) with ESMTP id 9742D475ECE for ; Mon, 9 Dec 2002 10:31:12 -0500 (EST) Received: from ianb.local (pD9EB1466.dip.t-dialin.net [217.235.20.102]) by post.webmailer.de (8.9.3/8.8.7) with ESMTP id QAA08256; Mon, 9 Dec 2002 16:31:06 +0100 (MET) From: Ian Barwick To: dbi-dev@perl.org, pgsql-interfaces@postgresql.org Subject: Patch for DBD::Pg pg_relcheck problem Date: Mon, 9 Dec 2002 16:31:00 +0100 X-Mailer: KMail [version 1.4] MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="------------Boundary-00=_O3ZUXV9RA1USVWXYW0X6" Message-Id: <200212091631.00125.barwick@gmx.net> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/21 X-Sequence-Number: 3434 --------------Boundary-00=_O3ZUXV9RA1USVWXYW0X6 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Attached is a patch against DBD::Pg 1.20 which fixes the driver-specific function 'table_attributes' for use with PostgreSQL 7.3 while maintaining backwards compatibility with older PostgreSQL versions. 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. Tested with 7.3 and 7.1.3. This is hopefully a one off problem requiring this kind of check. I haven't had a chance to look at every function in Pg.pm, but it seems this is the only one "broken" by 7.3. Comments, corrections etc. welcome! Ian Barwick barwick@gmx.net --------------Boundary-00=_O3ZUXV9RA1USVWXYW0X6 Content-Type: text/x-diff; charset="us-ascii"; name="Pg.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Pg.patch" 619c619,627 < 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 whether > # pg_relcheck exists and execute the appropriate query. > > my ($pre73) = $dbh->selectrow_array("SELECT 1 FROM pg_class WHERE relname='pg_relcheck'") || 0; > my $con_query = $pre73 > ? "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=_O3ZUXV9RA1USVWXYW0X6--