Subject: | primary_key_info fails on 32bit system for tables where oid is > max value of signed 32bit int |
Date: | Mon, 3 Jun 2013 23:17:27 +0530 (IST) |
To: | bug-DBD-Pg [...] rt.cpan.org |
From: | Rajesh Kumar Mallah <mallah [...] tradeindia.com> |
Dear Admin,
in function primary_key_info of DBD/Pg.pm the result of
below select is stored in a perl integer . In case the value in
c.oid > 2147483647 then info is truncated to that value only. hence the subsequent
sql that is based on oid fails to get any result.
724 my $pri_key_sql = qq{
725 SELECT
726 c.oid
727 , quote_ident(n.nspname)
728 , quote_ident(c.relname)
729 , quote_ident(c2.relname)
730 , i.indkey, quote_ident(t.spcname), quote_ident(t.spclocation)
731 , n.nspname, c.relname, c2.relname
732 FROM
733 pg_catalog.pg_class c
734 JOIN pg_catalog.pg_index i ON (i.indrelid = c.oid)
735 JOIN pg_catalog.pg_class c2 ON (c2.oid = i.indexrelid)
736 LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace)
737 LEFT JOIN $TSJOIN
738 WHERE
739 i.indisprimary IS TRUE
740 $whereclause
741 };
742
743 my $sth = $dbh->prepare($pri_key_sql) or return undef;
744 $sth->execute();
745 my $info = $sth->fetchall_arrayref()->[0];
Subsequent SQL that does not give any result is:
748 # Get the attribute information
749 my $indkey = join ',', split /\s+/, $info->[4];
750 my $sql = qq{
751 SELECT a.attnum, pg_catalog.quote_ident(a.attname) AS colname,
752 pg_catalog.quote_ident(t.typname) AS typename
753 FROM pg_catalog.pg_attribute a, pg_catalog.pg_type t
754 WHERE a.attrelid = '$info->[0]'
755 AND a.atttypid = t.oid
756 AND attnum IN ($indkey);
757 };
A possible solution is probably to cast c.oid to text so that it is
treated as a string by perl. But this needs to be done in all such places
where value of rowid is reused.
Sundry Info:
===============================================================================
# lsb_release -a
Distributor ID: Debian
Description: Debian GNU/Linux 7.0 (wheezy)
Release: 7.0
Codename: wheezy
# uname -a
Linux development2 3.2.0-4-686-pae #1 SMP Debian 3.2.41-2 i686 GNU/Linux
# perl -v | grep version
This is perl 5, version 14, subversion 2 (v5.14.2) built for i486-linux-gnu-thread-multi-64int
psql > select version();
PostgreSQL 9.1.3 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.3.2-1.1) 4.3.2, 64-bit
Regards,
Rajesh Kumar Mallah
Tel. 91-11-46710500 (Ext:303)
Cell +919811255597
Website: http://www.tradeindia.com/
\|/ \|/ \|/ stop printing \|/ \|/ \|/
| | | start planting | | |