Sent this originally about 10 days ago, didn't see any response. Is this a
bug, or am I doing something wrong?
------
This looks like a bug to me. I'm using
$db->func('table_name', 'table_attributes')
under DBD::Pg to retrieve and process the primary keys of a table, but
I've found a case where the primary key has two columns, and the returned
list of attributes only identifies one of the columns as a primary key.
Here's the output of pg_dump for the table:
----start of block----
$ pg_dump -s -t stat_site
--
-- Selected TOC Entries:
--
\connect - nexcerpt
--
-- TOC Entry ID 2 (OID 26547)
--
-- Name: stat_site Type: TABLE Owner: nexcerpt
--
CREATE TABLE "stat_site" (
"site_name" text NOT NULL,
"hit_date" date DEFAULT 'today' NOT NULL,
"hits_header" integer DEFAULT 0,
"hits_full" integer DEFAULT 0,
"hits_failed" integer DEFAULT 0,
"hits_db" integer DEFAULT 0,
Constraint "stat_site_pkey" Primary Key ("site_name", "hit_date")
);
--
-- TOC Entry ID 3 (OID 26547)
--
-- Name: stat_site Type: ACL Owner:
--
REVOKE ALL on "stat_site" from PUBLIC;
GRANT ALL on "stat_site" to "nexcerpt";
GRANT INSERT,UPDATE,DELETE,SELECT on "stat_site" to GROUP
"nexcerpt_staff";
----end of block----
Here's a code fragment that retrieves table_attributes:
----start of block----
#!/usr/bin/perl -w
use strict;
use Nexcerpt::DBConnection;
use Data::Dumper;
my $db = Nexcerpt::DBConnection->new( );
my $attrs = $db->func('stat_site', 'table_attributes');
print Dumper( $attrs ), "\n";
----end of block----
and here's the output of this:
(the columns that should be primary keys are the first and last in the
listing)
----start of block----
$ perl testattr.pl
$VAR1 = [
{
'PRIMARY_KEY' => 1,
'SIZE' => '-1',
'TYPE' => 'text',
'CONSTRAINT' => '',
'NAME' => 'site_name',
'NOTNULL' => '1',
'DEFAULT' => ''
},
{
'PRIMARY_KEY' => 0,
'SIZE' => '4',
'TYPE' => 'int4',
'CONSTRAINT' => '',
'NAME' => 'hits_header',
'NOTNULL' => '0',
'DEFAULT' => ''
},
{
'PRIMARY_KEY' => 0,
'SIZE' => '4',
'TYPE' => 'int4',
'CONSTRAINT' => '',
'NAME' => 'hits_full',
'NOTNULL' => '0',
'DEFAULT' => ''
},
{
'PRIMARY_KEY' => 0,
'SIZE' => '4',
'TYPE' => 'int4',
'CONSTRAINT' => '',
'NAME' => 'hits_failed',
'NOTNULL' => '0',
'DEFAULT' => ''
},
{
'PRIMARY_KEY' => 0,
'SIZE' => '4',
'TYPE' => 'int4',
'CONSTRAINT' => '',
'NAME' => 'hits_db',
'NOTNULL' => '0',
'DEFAULT' => ''
},
{
'PRIMARY_KEY' => 0,
'SIZE' => '4',
'TYPE' => 'date',
'CONSTRAINT' => '',
'NAME' => 'hit_date',
'NOTNULL' => '1',
'DEFAULT' => ''
}
];
----end of block----
--
Jeff Boes vox 616.226.9550
Database Engineer fax 616.349.9076
Nexcerpt, Inc. [EMAIL PROTECTED]