Skip Menu |

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

Report information
The Basics
Id: 43937
Status: new
Priority: 0/
Queue: DBD-Ingres

People
Owner: Nobody in particular
Requestors: d_roesler [...] agilent.com
Cc:
AdminCc:

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



Subject: Duplicate Statement Handle Names Generated when Prepared
Date: Sat, 7 Mar 2009 23:54:26 -0700
To: <bug-DBD-Ingres [...] rt.cpan.org>
From: <d_roesler [...] agilent.com>
DBD::Ingres version: 0.52 Perl Version: v5.8.8 built for i386-linux-thread-multi OS Version: Linux <hostname> 2.6.18-1.2798.fc6 #1 SMP Mon Oct 16 14:54:20 EDT 2006 i686 Perl Version: v5.8.0 built for PA-RISC1.1-thread-multi OS Version: HP-UX <hostname> B.11.11 U 9000/800 <serial number> unlimited-user license When two different statements that have the same select parameters but different where clauses DBD::Ingres assigns the same name to them. The one prepared last wins when it comes to execution with unexpected results. my $dbh = DBI->connect(....); # <whereClause> and <differentWhereClause> have the same place holders, but $sth2 has additional restrictions my $sth1 = $dbh->prepare(qq{select t1.column1, t2.column2, t2.column3, t3.column4 from table1 t1, table2 t2, table3 t3 where <whereClause>}); my $sth2 = $dbh->prepare(qq{select t1.column1, t2.column2, t2.column3, t3.column4 from table1 t1, table2 t2, table3 t3 where <differentWhereClause>}); $sth1->bind_param(...); $sth1->execute; my $stuff = $sth1->fetchrow_array; The query that gets executed is $sth2. $DBI::lasth->{Statement} will report $sth1, but the results are from executing $sth2. Setting DBI trace will show that when $sth1 and $sth2 are prepared they get the same name assigned to them. In this particular instance column1 only appears in table1 so I could remove the correlation name of table1 from one of the select statements and different names were assigned to the queries when they were prepared. my $sth1 = $dbh->prepare(qq{select column1, t2.column2, t2.column3, t3.column4 from table1 t1, table2 t2, table3 t3 where <whereClause>}); my $sth2 = $dbh->prepare(qq{select t1.column1, t2.column2, t2.column3, t3.column4 from table1 t1, table2 t2, table3 t3 where <differentWhereClause>}); Dennis