Skip Menu |
 

This queue is for tickets about the Class-DBI-Pg CPAN distribution.

Report information
The Basics
Id: 30344
Status: new
Priority: 0/
Queue: Class-DBI-Pg

People
Owner: Nobody in particular
Requestors: kilpatds [...] oppositelock.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.08
Fixed in: (no value)



Subject: RFE: Support Postgres schemas
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1722
Download (untitled) / with headers
text/plain 1.6k
in set_up_table, the queries do not support namespaces/schemas. A couple of queries will break if tables of the same name exist in different namespaces. I hacked up my personal copy, but it doesn't support older versions of postgres. I'll provide the relevant bits here anyway... [ .. no changes until after $catalog is initialized ] my $schema = 'public'; if ($table =~ m|[.]|) { ($schema,$table) = split(/[.]/,$table,2); } # find primary key my $sth = $dbh->prepare(<<"SQL"); SELECT indkey FROM ${catalog}pg_index as I join ${catalog}pg_class as C on (I.indrelid = C.oid) join ${catalog}pg_namespace as N on (C.relowner = N.nspowner) WHERE I.indisprimary = true and C.relname = ? and N.nspname = ? SQL $sth->execute($table,$schema); my %prinum = map { $_ => 1 } split ' ', $sth->fetchrow_array; $sth->finish; # find all columns $sth = $dbh->prepare(<<"SQL"); SELECT a.attname, a.attnum FROM pg_class c, pg_attribute a, pg_namespace n WHERE c.relname = ? AND n.nspname = ? AND c.relowner = n.nspowner AND a.attnum > 0 AND a.attrelid = c.oid ORDER BY a.attnum SQL $sth->execute($table,$schema); my $columns = $sth->fetchall_arrayref; $sth->finish; # find SERIAL type. # nextval('"table_id_seq"'::text) $sth = $dbh->prepare(<<"SQL"); SELECT adsrc FROM ${catalog}pg_attrdef as A JOIN ${catalog}pg_class as C on (A.adrelid = C.oid) JOIN ${catalog}pg_namespace as N on (C.relowner = N.nspowner) WHERE c.relname = ? AND n.nspname = ? SQL $sth->execute($table,$schema); my ($nextval_str) = $sth->fetchrow_array; $sth->finish; [... no changes for the rest of the method]


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.