Subject: | unknown data types do not default to SQL_VARCHAR in DBD::Pg 1.42 |
Distribution name and version: DBD-Pg-1.42
Perl version: This is perl, v5.8.6 built for i686-linux
Operating System vendor and version: Linux 2.6.9-5.0.5.106.unsupportedsmp #1 SMP Tue May 10 01:19:44 CDT 2005 i686 athlon i386 GNU/Linux
Here's a simplified test case:
#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect("dbi:Pg:dbname=template1", 'postgres', '');
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $sth = $dbh->prepare('SELECT ? AS test');
$sth->execute('It works');
my $arrayref = $sth->fetchrow_arrayref;
undef $sth;
print $arrayref->[0] . "\n";
$dbh->commit;
$dbh->disconnect;
Running the above program gives the following result:
DBD::Pg::st execute failed: ERROR: could not determine data type of parameter $1
DBD::Pg::st execute failed: ERROR: could not determine data type of parameter $1
Issuing rollback() for database handle being DESTROY'd without explicit disconnect().
However, if I change the program to the following:
#!/usr/local/bin/perl -w
use strict;
use DBI qw(:sql_types);
my $dbh = DBI->connect("dbi:Pg:dbname=template1", 'postgres', '');
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $sth = $dbh->prepare('SELECT ? AS test');
$sth->bind_param(1,undef,SQL_VARCHAR);
$sth->execute('It works');
my $arrayref = $sth->fetchrow_arrayref;
undef $sth;
print $arrayref->[0] . "\n";
$dbh->commit;
$dbh->disconnect;
...then it works fine with the following output:
It works