problem using table_info and column_info with DBD::Proxy



I think I've found a problem with DBD::Proxy - table_info and column_info do
not work.

m using DBI 1.50, perl 5.8.6, mysql 4.1.7, Linux kernel 2.6.15
I'm trying to access a mysql database on one machine from a webserver on
another machine. I was able to do simple SELECT queries, but I ran into
difficulties when I tried to retrieve information about the tables and columns
using table_info and column_info. My Google searches found some reports of
difficulties using other databases, but nothing with a solution. So I wrote
some test scripts to isolate the problem:

For the purposes of the tests, I used a single machine, therefore the client
and server versions were the same, and network problems were eliminated.

Example 1
---------------
#!/usr/bin/perl
#
# Testing problem with table_info

use strict;
use warnings;
use Data::Dumper;
use DBI;

#my $dbn= 'DBI:Proxy:hostname=localhost;port=3333;dsn=DBI:mysql:ima';
my $dbn= 'DBI:mysql:ima';
my $charset= 'UTF-8';
my $tds = DBI->connect( $dbn, 'root', '',
{ RaiseError => 1, PrintError => 0 } );

my $sth= $tds->table_info( );
unless ($sth) {
print STDERR "table_info error: ", $tds->errstr, "\n";
exit;
}
print STDERR "table_info OK\n";
print STDERR Dumper($sth);
my $tables = $sth->fetchall_arrayref();
print STDERR "Fetched\n";
print STDERR Dumper($tables);
exit
----------------------------------------------
output:
table_info OK
$VAR1 = bless( {}, 'DBI::st' );
Fetched
$VAR1 = [
[
undef,
undef,
'BaseKit',
'TABLE',
undef
],
.... etc
----------------------------------------------
i.e. It works with a direct database connection. However, if I change $dbn to
point to the same database via Proxy:
my $dbn= 'DBI:Proxy:hostname=localhost;port=3333;dsn=DBI:mysql:ima';
the output is:
DBD::Proxy::db table_info failed: Server returned error: Failed to execute
method CallMethod: Can't call method "execute" without a package or object
reference at /usr/local/lib/perl5/site_perl/5.8.6/i686-linux/DBD/mysql.pm line
251.
----------------------------------------------
The program crashes at $tds->table_info( ), and an error is returned from
mysql.pm on the server.

Similarly, for column_info:

Example2
--------------
#!/usr/bin/perl
#
# Testing problem with LISTFIELDS and column_info

use strict;
use warnings;
use Data::Dumper;
use DBI;

#my $dbn= 'DBI:Proxy:hostname=localhost;port=3333;dsn=DBI:mysql:ima';
my $dbn= 'DBI:mysql:ima';
my $charset= 'UTF-8';
my $tds = DBI->connect( $dbn, 'root', '',
{ RaiseError => 1, PrintError => 0 } );

my $sth = $tds->column_info( undef, undef, 'Product', "%");
my $cnames= $sth->fetchall_hashref( "COLUMN_NAME" );
print STDERR Dumper($cnames), "\n";
exit
----------------------------------------------
output:
$VAR1 = {
'name' => {
'COLUMN_DEF' => undef,
'mysql_values' => undef,
'NUM_PREC_RADIX' => undef,
'COLLATION_CAT' => undef,
'TABLE_SCHEM' => undef,
'DOMAIN_NAME' => undef,
'COLLATION_NAME' => undef,
'REMARKS' => undef,
'mysql_type_name' => 'varchar(60)',
'COLUMN_SIZE' => '60',
.... etc
----------------------------------------------
again, it works with a direct database connection. However, if I change $dbn to
point to the same database via Proxy:
my $dbn= 'DBI:Proxy:hostname=localhost;port=3333;dsn=DBI:mysql:ima';
the output is:
Can't call method "fetchall_hashref" on an undefined value at ./example2.pl
line 17.
----------------------------------------------
A crash does not occur, but $tds->column_info() does not return a statement
handle, and the fetch fails.

Are these known limitations of DBD::Proxy?
Am I doing something wrong?
Is there a workaround or alternative method?

Thanks in advance,
Allan Dyer


--------------------------------------------------------------------
Allan Dyer, CISSP, MHKCS, MIAP | adyer@xxxxxxxxxxxxx
Chief Consultant | http://www.yuikee.com.hk/
Yui Kee Computing Ltd. | +852 28708555

.



Relevant Pages