Subject: | Accepting bad SQL "select 'eek" |
While developing, I gave DBD::SQLite a bad SQL statement like "select 'eek" (quoted string not terminated). It worked and gave a weird answer. Is that something I should be expecting? Some oddity of SQLite?
The following test script was run
#!/usr/bin/perl
use DBI;
use DBD::SQLite;
use Test::More tests => 5;
diag("\$DBI::VERSION: $DBI::VERSION, \$DBD::SQLite::VERSION: $DBD::SQLite::VERSION\n");
my $dbh = DBI->connect('dbi:SQLite:dbname=t.db');
ok($dbh, 'defined $dbh');
# this is bad SQL
my $sql = "select 'eek";
my $sth = $dbh->prepare($sql);
ok($sth, "defined \$sth (SQL: $sql) ?!");
ok($sth->execute, "execute ok ?!");
my @row = $sth->fetchrow_array;
is(scalar @row, 1, 'one column fetched');
is($row[0], 'eekk', 'returning "eekk", arghh!');
and gave the output
$ perl bug.pl
1..5
# $DBI::VERSION: 1.48, $DBD::SQLite::VERSION: 1.09
ok 1 - defined $dbh
ok 2 - defined $sth (SQL: select 'eek) ?!
ok 3 - execute ok ?!
ok 4 - one column fetched
ok 5 - returning "eekk", arghh!
$ perl -v
This is perl, v5.8.7 built for cygwin-thread-multi-64int
$ uname -a
CYGWIN_NT-5.0 INF-020 1.5.18(0.132/4/2) 2005-07-02 20:30 i686 unknown unknown Cygwin