SQL::Statement bug

From: Christopher Huhn (C.Huhn_at_gsi.de)
Date: 04/16/04


Date: 16 Apr 2004 02:38:22 -0700

Hi,

I get the following error when I try to make sql lookups in
amavisd-new work with DBD::CSV.
amavis is preparing a bunch of statements with "WHERE column IN
(?,?,...)" clauses.

This code is working correctly:

   $sql = 'SELECT * FROM whitelist WHERE user_id = ? '.
       'AND from_address IN (?,?)';
   $sth = $dbh->prepare($sql) or die "Cannot prepare: " .
$dbh->errstr();
   $sth->bind_param(1, '1001');
   $sth->bind_param(2, 'email1@other-domain.tld');
   $sth->bind_param(3, 'email2@third-domain.tld');
   $sth->execute() or die "Cannot execute: " . $sth->errstr();
   DBI::dump_results($sth);

while this code (with just one ? more)

   $sql = 'SELECT wb,from_address FROM whitelist WHERE user_id = ? '.
       'AND from_address IN (?,?,?)';
   $sth = $dbh->prepare($sql) or die "Cannot prepare: " .
$dbh->errstr();
   $sth->bind_param(1, '1001');
   $sth->bind_param(2, 'email1@other-domain.tld');
   $sth->bind_param(3, 'email2@third-domain.tld');
   $sth->bind_param(4, 'email3@domain4.tld');
   $sth->execute() or die "Cannot execute: " . $sth->errstr();
   DBI::dump_results($sth);

leads to

   Use of uninitialized value in substitution iterator at
/usr/share/perl5/SQL/Parser.pm line 974.
   SQL ERROR: Bad predicate: ''!

   Use of uninitialized value in string eq at
/usr/share/perl5/SQL/Statement.pm line 1000, <GEN5> line 2.
   Use of uninitialized value in string eq at
/usr/share/perl5/SQL/Statement.pm line 1000, <GEN5> line 2.
...
   Use of uninitialized value in string eq at
/usr/share/perl5/SQL/Statement.pm line 1107, <GEN5> line 4.
   Use of uninitialized value in string eq at
/usr/share/perl5/SQL/Statement.pm line 1108, <GEN5> line 4.

and finally

   'W', 'email1@other-domain.tld'
   1 rows

Adding even more ? leads to the same results.

Note that "SELECT wb,from_address FROM whitelist WHERE from_address IN
(?,?,?)" is working correctly so it seems to be realted to the
conjunction in the WHERE clause.

This is the contents of corresponding CSV file:

FROM_ADDRESS;USER_ID;WB
email1@other-domain.tld;1001;W
email2@third-domain.tld;1001;W
email3@domain4.tld;1001;W

This is my version info (Debian woody):

# dpkg -l libdbd-csv-perl libsql-statement-perl perl
ii libdbd-csv-perl 0.2002-1 perl DBD::CSV
- DBI driver for CSV files
ii libsql-statement-perl 1.005-1 SQL parsing
and processing engine
ii perl 5.6.1-8.6 Larry Wall's
Practical Extraction and Report Language.

Regards,

   Christopher Huhn



Relevant Pages

  • Re: Inconsistency of Export to a CSV file.
    ... A CSV file is a txt file with a different extension. ... >>Public Sub ExportDelim(strTable As String, ... >> Dim varData As Variant ... >> Dim intFileNum As Integer ...
    (microsoft.public.access.externaldata)
  • Re: type conversion error
    ... Take a look to the missing data in your csv file so you can understand why ... ByVal HDR As Boolean) As String ... Dim strFolder As String ... Dim strFileName As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: How to open a .CSV file ?
    ... I'm really having trouble understanding why you feel the need to insult ... I suppose by your reasoning every file is just a big long string and we ... I assume when you said "parse at the comma" you meant string.split. ... If I save the .CSV file to an .XLS file, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How to ignore extra or missing columns?
    ... the best approach would be to parse the CSV file ... Function Make20(Line As String, NFields As Long) As String ... John Nurick [Microsoft Access MVP] ...
    (microsoft.public.access.externaldata)
  • Re: How to open a .CSV file ?
    ... I suppose by your reasoning every file is just a big long string and we should all be using the string manipulation functions to work with them. ... programming possibilites. ... I assume when you said "parse at the comma" you meant string.split. ... If I save the .CSV file to an .XLS file, ...
    (microsoft.public.dotnet.languages.vb)