Skip Menu |

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

Report information
The Basics
Id: 11743
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: david [...] kineticode.com
jesse [...] bestpractical.com
jv [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.40
Fixed in: 1.41



Date: Thu, 3 Mar 2005 21:40:11 -0500
From: Jesse Vincent <jesse [...] bestpractical.com>
To: bug-dbd-pg [...] rt.cpan.org
Subject: DBD::Pg 1.40 prepare code badly breaks existing apps
When chatting with david wheeler, he mentioned that the only column type that should require explicit typing when bound is BYTEA. DBD::Pg 1.40 seems to go a bit more overboard. Attached is a test-case that fails on 1.40 and passes on 1.32. Thanks, Jesse --

Message body is not shown because sender requested not to inline it.

Date: Thu, 3 Mar 2005 21:47:57 -0500
From: Jesse Vincent <jesse [...] bestpractical.com>
To: DBD-Pg <bug-DBD-Pg [...] rt.cpan.org>
Subject: Re: [cpan #11743] AutoReply: DBD::Pg 1.40 prepare code badly breaks existing apps
RT-Send-Cc:
David, So it looks like an Encode interaction bug? (The DBD::Oracle was a leftover from a previous test script)
CC: bug-dbd-pg [...] rt.cpan.org
From: David Wheeler <david [...] kineticode.com>
Subject: Re: DBD::Pg 1.40 prepare code badly breaks existing apps
Date: Thu, 3 Mar 2005 18:41:41 -0800
To: Jesse Vincent <jesse [...] bestpractical.com>
On Mar 3, 2005, at 6:40 PM, Jesse Vincent wrote: Show quoted text
> When chatting with david wheeler, he mentioned that the only column > type > that should require explicit typing when bound is BYTEA. DBD::Pg 1.40 > seems to go a bit more overboard. Attached is a test-case that fails on > 1.40 and passes on 1.32.
With this diff: --- /Users/david/Desktop/try Thu Mar 3 18:40:05 2005 +++ /Users/david/bin/try Thu Mar 3 18:39:04 2005 @@ -1,6 +1,4 @@ use DBI; -use DBD::Oracle qw(:ora_types); -use Encode; use Test::More qw/no_plan/; # Table setup It works perfectly for me: % prove ~/bin/try /Users/david/bin/try...ok 1 1..1 ok All tests successful. Files=1, Tests=1, 0 wallclock secs ( 0.13 cusr + 0.03 csys = 0.16 CPU) Regards, David
From: David Wheeler <david [...] kineticode.com>
Subject: Re: [cpan #11744] Re: DBD::Pg 1.40 prepare code badly breaks existing apps
Date: Thu, 3 Mar 2005 18:57:19 -0800
To: bug-DBD-Pg [...] rt.cpan.org
RT-Send-Cc:
On Mar 3, 2005, at 6:52 PM, David Wheeler via RT wrote: Show quoted text
> It works perfectly for me:
Scratch that. Bug confirmed when using DBD::Pg with PostgreSQL 7.4.x. $ prove bin/try bin/try...DBD::Pg::st execute failed: ERROR: column "id" is of type integer but expression is of type character varying HINT: You will need to rewrite or cast the expression. bin/try...NOK 1 # Failed test (bin/try at line 19) # Looks like you failed 1 test of 1. bin/try...dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 1 Failed 1/1 tests, 0.00% okay Failed Test Stat Wstat Total Fail Failed List of Failed ------------------------------------------------------------------------ ------- bin/try 1 256 1 1 100.00% 1 Failed 1/1 test scripts, 0.00% okay. 1/1 subtests failed, 0.00% okay. I'll commit a test case shortly.
From: David Wheeler <david [...] kineticode.com>
Subject: Re: [cpan #11744] Re: DBD::Pg 1.40 prepare code badly breaks existing apps
Date: Thu, 3 Mar 2005 19:03:43 -0800
To: bug-DBD-Pg [...] rt.cpan.org
RT-Send-Cc:
On Mar 3, 2005, at 7:00 PM, David Wheeler via RT wrote: Show quoted text
> I'll commit a test case shortly.
Done.
From: kuriyama [...] FreeBSD.org
[david@kineticode.com - Thu Mar 3 22:07:22 2005]: Show quoted text
> > I'll commit a test case shortly.
> > Done.
Is this correct? Inserting same value with placeholder should be different from pre-quoted value insertion... -- Jun Kuriyama <kuriyama@imgsrc.co.jp> // IMG SRC, Inc. <kuriyama@FreeBSD.org> // FreeBSD Project
From: kuriyama [...] FreeBSD.org
I'm not sure this is the correct fix or not, but with this patch, make test works well on my postgresql-7.4.7. Index: dbdimp.c =================================================================== RCS file: /usr/local/cvsroot/dbdpg/dbdpg/dbdimp.c,v retrieving revision 1.98 diff -u -r1.98 dbdimp.c --- dbdimp.c 29 Jan 2005 18:53:52 -0000 1.98 +++ dbdimp.c 6 Mar 2005 12:20:12 -0000 @@ -1251,7 +1251,11 @@ params = imp_sth->numphs; paramTypes = calloc(imp_sth->numphs, sizeof(*paramTypes)); for (x=0,currph=imp_sth->ph; NULL != currph; currph=currph->nextph) { - paramTypes[x++] = currph->bind_type->type_id; + if (BYTEAOID==currph->bind_type->type_id) { + paramTypes[x++] = currph->bind_type->type_id; + } else { + paramTypes[x++] = 0; + } } } result = PQprepare(imp_dbh->conn, imp_sth->prepare_name, statement, params, paramTypes); @@ -1662,7 +1666,11 @@ /* Populate paramTypes */ paramTypes = calloc(imp_sth->numphs, sizeof(*paramTypes)); for (x=0,currph=imp_sth->ph; NULL != currph; currph=currph->nextph) { - paramTypes[x++] = currph->bind_type->type_id; + if (BYTEAOID==currph->bind_type->type_id) { + paramTypes[x++] = currph->bind_type->type_id; + } else { + paramTypes[x++] = 0; + } } if (dbis->debug >= 10) { Index: t/12placeholders.t =================================================================== RCS file: /usr/local/cvsroot/dbdpg/dbdpg/t/12placeholders.t,v retrieving revision 1.15 diff -u -r1.15 12placeholders.t --- t/12placeholders.t 4 Mar 2005 03:03:00 -0000 1.15 +++ t/12placeholders.t 6 Mar 2005 12:20:13 -0000 @@ -40,7 +40,7 @@ checkquote('four'); my $sth = $dbh->prepare(qq{INSERT INTO dbd_pg_test (id,pname) VALUES (?, ?)}); -$sth->execute(100, $quo); +$sth->execute(100, "\\'?:"); my $sql = "SELECT pname FROM dbd_pg_test WHERE pname = $quo"; $sth = $dbh->prepare($sql);
From: hutchinson.chris [...] gmail.com
[david@kineticode.com - Thu Mar 3 22:00:57 2005]: Show quoted text
> On Mar 3, 2005, at 6:52 PM, David Wheeler via RT wrote: >
> > It works perfectly for me:
> > Scratch that. Bug confirmed when using DBD::Pg with PostgreSQL 7.4.x. >
Confirmed bug is a major problem for existing apps with PostgreSQL 8.0.1 by breaking most of our insert code. We applied dbdimp.c patch to work around problem, but are delaying upgrading for clients.
Subject: column type mismatches
Perl 5.8.3, PostgreSQL 7.4.7, DBD::Pg 1.40. I recently upgraded PostgreSQL (from 7.4.6) and DBD::Pg (from 1.31), and now inserting values into tables often lead to errors like: ERROR: column "amount" is of type integer but expression is of type character varying HINT: You will need to rewrite or cast the expression. This used to work in the past. Anything I did wrong?
From: David Wheeler <david [...] kineticode.com>
Subject: Re: [cpan #12126] column type mismatches
Date: Sun, 3 Apr 2005 13:10:28 -0700
To: bug-DBD-Pg [...] rt.cpan.org
RT-Send-Cc:
On Apr 3, 2005, at 1:23 AM, Johan_Vromans via RT wrote: Show quoted text
> ERROR: column "amount" is of type integer but expression is of type > character varying
No, you did nothing wrong. This is a bug in 1.40. Please try 1.40_3, now on CPAN. 1.41 will be released this week. Regards, David