Skip Menu |
 

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

Report information
The Basics
Id: 19604
Status: rejected
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: brian [...] photoresearchers.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 1.31
  • 1.43
Fixed in: (no value)



Subject: ARRAY[] notation no longer supported in INSERT, missing bind parameter
Download (untitled) / with headers
text/plain 466b
Inserting of array values using the ARRAY[?,?] notation no longer works. The only alternative is to use a single bind paramter and insert the array using the VARCHAR notation '{"",""}'. Once upon a time this worked, but alas, no longer. The error message indicates that the question marks inside the array brackets are skipped as bind parameters altogether, prompting and error message like "failed: called with N bind parameters when N-arraysize are needed".
Subject: why tested in only these versions
From: brian [...] photoresearchers.com
Download (untitled) / with headers
text/plain 456b
I'd have tested this in a later version, but this is on a RHEL production system where I need it to work with the RedHat-provided version of DBI (1.40), and thus 1.43 is the latest version that works (prior to the "'DBIcf_PrintWarn' undeclared" bug #18260). Maybe I'll get around to testing it in later versions at some point, but in the mean time if anyone else can discover whether this problem exists in later versions they can add comments below.
Download (untitled) / with headers
text/plain 304b
The problem does not seem to exist in newer versions, but I cannot tell for sure without seeing the exact SQL you are using. However, this works as expected: $SQL = "INSERT INTO mytable(a,b) VALUES (ARRAY[?,?],?)"; $sth = $dbh->prepare($SQL); $sth->bind_param(1,1,SQL_INTEGER); $sth->execute(1,2,3);
Subject: Re: [rt.cpan.org #19604] ARRAY[] notation no longer supported in INSERT, missing bind parameter
Date: Thu, 8 Jun 2006 12:39:55 -0700
To: bug-DBD-Pg [...] rt.cpan.org
From: David Wheeler <david [...] kineticode.com>
Download (untitled) / with headers
text/plain 273b
On Jun 8, 2006, at 12:31, Guest via RT wrote: Show quoted text
> $SQL = "INSERT INTO mytable(a,b) VALUES (ARRAY[?,?],?)"; > $sth = $dbh->prepare($SQL); > $sth->bind_param(1,1,SQL_INTEGER); > $sth->execute(1,2,3);
I see that the explicit bind_param is required. Why is that? Best, David
Subject: oh, if only that were the case
From: brian [...] photoresearchers.com
Download (untitled) / with headers
text/plain 1.3k
On Thu Jun 08 15:31:31 2006, guest wrote: Show quoted text
> The problem does not seem to exist in newer versions, but I cannot tell > for sure without seeing the exact SQL you are using. However, this works > as expected:
Hmm, maybe for you, but not for me: [example]$ /path/to/perl-5.8.5/bin/perl -MDBI -e ' use DBI qw(:sql_types); my $dbh = DBI->connect("dbi:Pg:dbname=mytestdb","user","pass", {RaiseError => 1, PrintError => 0, AutoCommit => 1}); warn "DBI version is $DBI::VERSION \n"; warn "DBD::Pg version is $DBD::Pg::VERSION\n"; $dbh->do("CREATE TEMP TABLE arytst ( a INTEGER[], b INTEGER ) WITHOUT OIDS;"); my $sql = "INSERT INTO arytst(a,b) VALUES (ARRAY[?,?],?)"; my $sth = $dbh->prepare($sql); $sth->bind_param(1,1,SQL_INTEGER); $sth->execute(1,2,3); ' DBI version is 1.40 DBD::Pg version is 1.43 DBD::Pg::st execute failed: called with 3 bind variables when 1 are needed at -e line 1. *** Alternately, adding: $sth->bind_param(2,1,SQL_INTEGER); $sth->bind_param(3,1,SQL_INTEGER); yields: Cannot bind unknown placeholder 2 (2) at -e line 1. Are there not three bind parameters?! The following change is required to get this to work properly: my $sql = "INSERT INTO arytst(a,b) VALUES (?,?)"; my $sth = $dbh->prepare($sql); # $sth->bind_param(2,1,SQL_INTEGER); # not required, David $sth->execute("{1,2}",3);
Subject: Re: [rt.cpan.org #19604] oh, if only that were the case
Date: Fri, 9 Jun 2006 08:40:17 -0700
To: bug-DBD-Pg [...] rt.cpan.org
From: David Wheeler <david [...] kineticode.com>
Download (untitled) / with headers
text/plain 281b
On Jun 9, 2006, at 08:31, Guest via RT wrote: Show quoted text
> DBI version is 1.40 > DBD::Pg version is 1.43 > DBD::Pg::st execute failed: called with 3 bind variables when 1 are > needed at -e line 1.
It works for me with: DBI version is 1.51 DBD::Pg version is 1.49 Best, David


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.