Skip Menu |

This queue is for tickets about the DBD-Sybase CPAN distribution.

Report information
The Basics
Id: 35383
Status: open
Priority: 0/
Queue: DBD-Sybase

People
Owner: Nobody in particular
Requestors: jason [...] froebe.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.07
Fixed in: 1.07



Subject: DBD::Sybase calls the broken sp_tables stored procedure
Centos 5 Linux dba-dev1 2.6.22.9-default #1 SMP Mon Oct 1 11:26:48 CDT 2007 i686 athlon i386 GNU/Linux Perl v5.8.8 built for i386-linux-thread-multi DBD::Sybase 1.07 but 1.08 also has the problem. Due to Sybase CR 497173, sp_tables can not be relied upon to retrieve table information correctly for ASE 15. (http://froebe.net/blog/2008/04/09/ase-15-stored-procedure-sp_tables-doesnt-work-with-sql-udfs/) We need to query the system tables instead. Obviously, the below code would work in v12.0 and higher. A temp table could probably be used for prior to 12.0 for the TABLE_TYPE to be filled correctly. $ diff ../DBD-Sybase-1.07/Sybase.pm Sybase.pm 218c218 < my $sth = $dbh->prepare("sp_tables $table, $schema, $catalog, $type"); --- Show quoted text
> # my $sth = $dbh->prepare("sp_tables $table, $schema, $catalog,
$type"); 219a220,238 Show quoted text
> my $sth = $dbh->prepare( q{ > select TABLE_QUALIFIER = db_name() > , TABLE_OWNER = u.name > , TABLE_NAME = o.name > , TABLE_TYPE = > case o.type > when "U" then "TABLE" > when "V" then "VIEW" > when "S" then "SYSTEM TABLE" > end > , REMARKS = NULL > from sysobjects o > , sysusers u > where o.type in ('U', 'V', 'S') > and id >99 > and o.uid = u.uid > > }); >
I was trying to use DBIx::Class::Schema::Loader::make_schema_at with Sybase ASE 15.7.0 and views were being defined as tables. So I dug into the problem only to discover that the statement handle returned by DBD::Sybase::db::table_info doesn't contain all of the fields in the DBI docs (https://metacpan.org/pod/DBI#table_info). For the time being I am overriding DBD::Sybase::db::table_info with a sub much like the attached.
Subject: table_info.txt
sub table_info { my $dbh = shift; my $catalog = $dbh->quote(shift); my $schema = $dbh->quote(shift); my $table = $dbh->quote(shift); my $type = $dbh->quote(shift); my $sql = qq{ select null as TABLE_QUALIFIER, u.name as TABLE_OWNER, u.name as TABLE_SCHEM, o.name as TABLE_NAME, CASE o.type WHEN 'U' THEN 'TABLE' WHEN 'S' THEN 'SYSTEM TABLE' WHEN 'V' THEN 'VIEW' END as TABLE_TYPE, null as REMARKS from sysobjects o join sysusers u on o.uid = u.uid and o.type in ('U', 'V', 'S') where u.name = $schema and o.name = $table }; $sql .= " and o.type in ($type)" if (defined $type && $type ne 'NULL'); my $sth = $dbh->prepare($sql); $sth->execute; $sth; }