Skip Menu |

This queue is for tickets about the SQL-Statement CPAN distribution.

Report information
The Basics
Id: 99349
Status: resolved
Priority: 0/
Queue: SQL-Statement

People
Owner: Nobody in particular
Requestors: vulpeculus [...] gmx.de
Cc:
AdminCc:

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



Subject: bind variables are not bound to placeholders in the correct order
Date: Tue, 07 Oct 2014 17:15:14 +0200
To: bug-DBD-CSV [...] rt.cpan.org
From: vulpeculus [...] gmx.de
It seems that bind variables are not bound in the correct order to the placeholders in a 'where'-clause of a SQL statement, if some parts of the clause need not to be executed (e.g. OR after a true condition). The attached program demonstrates the problem: Assume a csv databasea (called abc.csv) with one row A=1, B=2, C=3: A,B,C 1,2,3 The search for (A=1 OR B=1) AND C=3 should return the only row in abc.csv, but returns nothing prepare('select * from abc where (a=? or b=?) and c=?') execute(1,1,3) The search for (A=1 OR B=3) AND C=99 should return no result, but returns the one row in abc.csv same prepare as befor execute(1,3,99) Tested on Ubuntu (Linux xxx 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux) and Solaris (SunOS xxx 5.10 Generic_150401-15 i86pc i386 i86pc), with perl 5.18.2 and 5.10.0 and use DBI 1.631; use DBD::CSV 0.44; use SQL::Statement 1.405;

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

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

From: vulpeculus [...] gmx.de
After looking deeper into the code, I found that the problem is not in DBD::CSV, but in SQL::Statement. I will resend the bug report there, together with a proposed patch
Very likely the issue is in S::S
On Wed Oct 08 06:26:09 2014, vulpeculus@gmx.de wrote: Show quoted text
> After looking deeper into the code, I found that the problem is not in > DBD::CSV, but in SQL::Statement. > > I will resend the bug report there, together with a proposed patch
Don't resend - we can move tickets ;) Do you have the option to patch your local installation? I'm a bit busy at the moment with qw/list of many OSS and CPAN distributions, pkgsrc and Yocto/ and SQL-Statement repository is in a desolate state because of trouble around DBI::Test. I might not be able to release soon because $me_is_an_idiot.
Subject: bind variables are not bound to placeholders in the correct order Date
It seems that bind variables are not bound in the correct order to the placeholders in a 'where'-clause of a SQL statement, if some parts of the clause need not to be executed (e.g. OR after a true condition). The attached program demonstrates the problem: Assume a csv databasea (called abc.csv) with one row A=1, B=2, C=3: A,B,C 1,2,3 The search for (A=1 OR B=1) AND C=3 should return the only row in abc.csv, but returns nothing prepare('select * from abc where (a=? or b=?) and c=?') execute(1,1,3) The search for (A=1 OR B=3) AND C=99 should return no result, but returns the one row in abc.csv same prepare as befor execute(1,3,99) Tested on Ubuntu (Linux xxx 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux) and Solaris (SunOS xxx 5.10 Generic_150401-15 i86pc i386 i86pc), with perl 5.18.2 and 5.10.0 and use DBI 1.631; use DBD::CSV 0.44; use SQL::Statement 1.405; ------------------------------------------------------------- The problems is probably in SQL::Statement::Operation::And and ...::Or (File Operation.pm). The attached patch fixes it, although it is more time consuming (because it evaluates both operands of AND and OR, regardless of the value of the left one)
Subject: patch
Download patch
application/octet-stream 1k

Message body not shown because it is not plain text.

From: vulpeculus [...] gmx.de
Am Mi 08. Okt 2014, 06:43:47, REHSACK schrieb: Show quoted text
> Do you have the option to patch your local installation? I'm a bit > busy at the moment with qw/list of many OSS and CPAN distributions,
Yes, I can easily patch my local distribution.
On Wed Oct 08 06:49:07 2014, vulpeculus@gmx.de wrote: Show quoted text
> Am Mi 08. Okt 2014, 06:43:47, REHSACK schrieb: >
> > Do you have the option to patch your local installation? I'm a bit > > busy at the moment with qw/list of many OSS and CPAN distributions,
> > Yes, I can easily patch my local distribution.
Cool. I'll try to make SQL-Statement repository sane as soon as possible. You're patch reminds me about preprocessor issues in C and ensure evaluating once. BTW: Real fix would be to rewrite the parser and associate the placeholder with an id which can be addressed everytime accessing the placeholder list ... On TODO ^^ So - even with your patch applied, I will not mark the issue as resolved.
Pushed fix to github to let travis work
Patch is included in uploaded 1.409. Thanks for reporting.