Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: stephen_tu [...] berkeley.edu
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: 2.10.0



Subject: DBD-Pg "do" does not handle multiple prepare statements even with pg_server_prepare set to 0
Date: Wed, 20 Aug 2008 13:12:46 -0700
To: bug-DBD-Pg [...] rt.cpan.org
From: Stephen Tu <stephen_tu [...] berkeley.edu>
Hello DBD-Pg team: I have encountered a slight issue with the DBD-Pg driver when trying to do multiple prepare statements. I am not exactly sure if this is exactly a bug per se, or a result of a design decision, but I'd like to be able to see this functionality. Anyways, let me provide you with some background information first of all: $ uname -a FreeBSD [domain-name] 6.2-RELEASE-p10 FreeBSD 6.2-RELEASE-p10 #2: Thu Jan 17 04:34:12 PST 2008 $ pkg_info | grep -i db [only showing relevant ones] p5-DBD-Pg-2.9.0 Provides access to PostgreSQL databases through the DBI p5-DBI-1.60.4 The perl5 Database Interface. Required for DBD::* modules $ pkg_info | grep postgres postgresql-client-8.2.5_1 PostgreSQL database (client) postgresql-server-8.2.5_2 The most advanced open-source database available anywhere $ perl -v This is perl, v5.8.8 built for i386-freebsd-64int ----------- Here is a very simple, trivial script that i put together that demonstrates the issue: dbi_test.pl #!/usr/bin/perl use strict; use warnings; use DBI; my $dbh = DBI->connect( 'dbi:Pg:dbname=databasename', 'user', 'password', { AutoCommit => 0 } ); $dbh->{pg_server_prepare} = 0; #according to DBD::Pg docs, this is how you get multi-prepared statements to work my $sql = <<SQL; UPDATE test SET description = 'this is my trivial test' WHERE id = ?; SELECT * FROM test WHERE id = ?; SQL my @values = (1,1); # this segment will work my $sth = $dbh->prepare($sql); $sth->execute(@values); my $rows = $sth->rows; print "number of rows = $rows\n"; # these two segments will not work $dbh->do($sql,undef,@values); $dbh->do($sql,{ pg_server_prepare => 0 },@values); # i even tried to pass in the explicit attribute $dbh->commit; and here is the output: $ ./dbi_test.pl number of rows = 1 DBD::Pg::db do failed: ERROR: cannot insert multiple commands into a prepared statement at ./dbi_test.pl line 27. DBD::Pg::db do failed: ERROR: cannot insert multiple commands into a prepared statement at ./dbi_test.pl line 28. like i said before, i'm not sure if this is really a "bug", but it'd be a feature that would be fairly useful. i'm actually not sure why this doesn't work, since according to DBI.pm, the implementation of "do" is "logically" similar to what i did the first time around w/ "prepare" and "execute", but i guess the actual implementation does some optimization that makes it not work? i hope that this is clear and concise enough to you, and at the same time descriptive. please let me know if there are any further questions Regards, Stephen Tu
Proposed fix in r11673 if you would like to test.
Subject: Re: [rt.cpan.org #38623] DBD-Pg "do" does not handle multiple prepare statements even with pg_server_prepare set to 0
Date: Tue, 02 Sep 2008 10:14:29 -0700
To: bug-DBD-Pg [...] rt.cpan.org
From: Stephen Tu <stephen_tu [...] berkeley.edu>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Greg, This fix works perfectly. Thanks! - -Stephen Tu -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQEVAwUBSL10c6HQULQmc2Y6AQi33Af9GYPULOAzUQ7t6Tap3Cm4j8zbIVSHVGEL J7rH6a7rQ9jllBtjadsg4zysgeh9YJFFA/gAK7/qRIOnZ8sOacf6r9Ds5GIr8rwY oluwHqXJfBBlar2tvqFin97zAIuhAW5vl4ErlYWWKRTElsM20P8h2og9KjYsIXUB zOxiUVaa/8yBFOa4bL4lp/z9EsceAXMXg/FmsWnakBOvlXEBi/b/T0WVxvV39zJP qscaXB87VPpR6YFPtuvz9wdEE1rh0TomXV9Ft50o+syR/GvLTfOLZPxNZz3c7FwB 98QBclwG7CgKa3JVZ1ecyd1vrfkMEclm3pMS5GhS3DajpyrUIPhf2w== =iitZ -----END PGP SIGNATURE-----