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
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: 466
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".
MIME-Version: 1.0
Subject: why tested in only these versions
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.5.HEAD-11742-1149010919-1287.19604-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
From: brian [...] photoresearchers.com
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 456
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.
MIME-Version: 1.0
In-Reply-To: <rt-3.5.HEAD-11742-1149010919-1287.19604-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.5.HEAD-2040-1149795090-1028.19604-0-0 [...] rt.cpan.org>
References: <rt-3.5.HEAD-11742-1149010919-1287.19604-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 304
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);
X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0 (Apple Message framework v750)
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.5.HEAD-2040-1149795090-1028.19604-5-0 [...] rt.cpan.org>
X-Mailer: Apple Mail (2.750)
Received-SPF: neutral (x1.develooper.com: local policy)
References: <RT-Ticket-19604 [...] rt.cpan.org> <rt-3.5.HEAD-11742-1149010919-1287.19604-5-0 [...] rt.cpan.org> <rt-3.5.HEAD-2040-1149795090-1028.19604-5-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"; format="flowed"
X-RT-Original-Encoding: US-ASCII
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id 037E14D8240 for <cpan-bug+dbd-pg [...] diesel.bestpractical.com>; Thu, 8 Jun 2006 15:40:52 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id B089A4D8229 for <bug-DBD-Pg [...] rt.cpan.org>; Thu, 8 Jun 2006 15:40:51 -0400 (EDT)
Received: (qmail 12289 invoked by alias); 8 Jun 2006 19:40:50 -0000
Received: from mail3.sea5.speakeasy.net (HELO mail3.sea5.speakeasy.net) (69.17.117.5) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Thu, 08 Jun 2006 12:40:05 -0700
Received: (qmail 24077 invoked from network); 8 Jun 2006 19:39:59 -0000
Received: from unknown (HELO [10.11.47.69]) (davidw [...] [64.122.198.69]) (envelope-sender <david [...] kineticode.com>) by mail3.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted SMTP for <bug-DBD-Pg [...] rt.cpan.org>; 8 Jun 2006 19:39:59 -0000
Delivered-To: cpan-bug+dbd-pg [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #19604] ARRAY[] notation no longer supported in INSERT, missing bind parameter
Return-Path: <david [...] kineticode.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+dbd-pg [...] diesel.bestpractical.com
Date: Thu, 8 Jun 2006 12:39:55 -0700
Message-Id: <06DEA73E-53F4-4900-B7CE-2FB11E48102A [...] kineticode.com>
To: bug-DBD-Pg [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: David Wheeler <david [...] kineticode.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.5.HEAD-2043-1149795658-1749.19604-0-0 [...] rt.cpan.org>
Content-Length: 273
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
MIME-Version: 1.0
Subject: oh, if only that were the case
In-Reply-To: <rt-3.5.HEAD-2040-1149795090-1028.19604-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
References: <rt-3.5.HEAD-11742-1149010919-1287.19604-0-0 [...] rt.cpan.org> <rt-3.5.HEAD-2040-1149795090-1028.19604-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.5.HEAD-2046-1149867065-1600.19604-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
From: brian [...] photoresearchers.com
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 1358
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);
X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0 (Apple Message framework v750)
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.5.HEAD-2046-1149867065-1600.19604-5-0 [...] rt.cpan.org>
X-Mailer: Apple Mail (2.750)
Received-SPF: neutral (x1.develooper.com: local policy)
References: <RT-Ticket-19604 [...] rt.cpan.org> <rt-3.5.HEAD-11742-1149010919-1287.19604-5-0 [...] rt.cpan.org> <rt-3.5.HEAD-2040-1149795090-1028.19604-5-0 [...] rt.cpan.org> <rt-3.5.HEAD-2046-1149867065-1600.19604-5-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"; delsp="yes"; format="flowed"
X-RT-Original-Encoding: US-ASCII
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id 02D094D8287 for <cpan-bug+dbd-pg [...] diesel.bestpractical.com>; Fri, 9 Jun 2006 11:41:45 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id CA0C64D8286 for <bug-DBD-Pg [...] rt.cpan.org>; Fri, 9 Jun 2006 11:41:43 -0400 (EDT)
Received: (qmail 30108 invoked by alias); 9 Jun 2006 15:41:42 -0000
Received: from mail3.sea5.speakeasy.net (HELO mail3.sea5.speakeasy.net) (69.17.117.5) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Fri, 09 Jun 2006 08:40:54 -0700
Received: (qmail 2277 invoked from network); 9 Jun 2006 15:40:19 -0000
Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.21]) (davidw [...] [66.93.38.250]) (envelope-sender <david [...] kineticode.com>) by mail3.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted SMTP for <bug-DBD-Pg [...] rt.cpan.org>; 9 Jun 2006 15:40:19 -0000
Delivered-To: cpan-bug+dbd-pg [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #19604] oh, if only that were the case
Return-Path: <david [...] kineticode.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+dbd-pg [...] diesel.bestpractical.com
Date: Fri, 9 Jun 2006 08:40:17 -0700
Message-Id: <CEE3418E-1B4A-4776-BCD7-A4BAEEDDFF7D [...] kineticode.com>
To: bug-DBD-Pg [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: David Wheeler <david [...] kineticode.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.5.HEAD-2040-1149867717-396.19604-0-0 [...] rt.cpan.org>
Content-Length: 281
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.