mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
Add a regression test for RT-124227
This commit is contained in:
parent
4738b4c3b4
commit
849d2ac9ad
2 changed files with 75 additions and 0 deletions
1
MANIFEST
1
MANIFEST
|
@ -92,6 +92,7 @@ t/lib/SQLiteTest.pm
|
|||
t/rt_106151_outermost_savepoint.t
|
||||
t/rt_106950_extra_warnings_with_savepoints.t
|
||||
t/rt_115465_column_info_with_spaces.t
|
||||
t/rt_124227_index_regression.t
|
||||
t/rt_15186_prepcached.t
|
||||
t/rt_21406_auto_finish.t
|
||||
t/rt_25371_asymmetric_unicode.t
|
||||
|
|
74
t/rt_124227_index_regression.t
Normal file
74
t/rt_124227_index_regression.t
Normal file
|
@ -0,0 +1,74 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use lib "t/lib";
|
||||
use SQLiteTest;
|
||||
use Test::More;
|
||||
use Test::NoWarnings;
|
||||
|
||||
plan tests => 5;
|
||||
|
||||
my $sql_in_question = <<'EOS';
|
||||
SELECT cdid
|
||||
FROM cd me
|
||||
WHERE 2 > (
|
||||
SELECT COUNT( * )
|
||||
FROM cd rownum__emulation
|
||||
WHERE
|
||||
(
|
||||
me.genreid IS NOT NULL
|
||||
AND
|
||||
rownum__emulation.genreid IS NULL
|
||||
)
|
||||
OR
|
||||
(
|
||||
me.genreid IS NOT NULL
|
||||
AND
|
||||
rownum__emulation.genreid IS NOT NULL
|
||||
AND
|
||||
rownum__emulation.genreid < me.genreid
|
||||
)
|
||||
OR
|
||||
(
|
||||
( me.genreid = rownum__emulation.genreid OR ( me.genreid IS NULL AND rownum__emulation.genreid IS NULL ) )
|
||||
AND
|
||||
rownum__emulation.cdid > me.cdid
|
||||
)
|
||||
)
|
||||
EOS
|
||||
|
||||
{ # With an index
|
||||
my $dbh = connect_ok();
|
||||
$dbh->do($_) for (
|
||||
'CREATE TABLE cd ( cdid INTEGER PRIMARY KEY NOT NULL, genreid integer )',
|
||||
'CREATE INDEX cd_idx_genreid ON cd (genreid)',
|
||||
'INSERT INTO cd ( cdid, genreid ) VALUES
|
||||
( 1, 1 ),
|
||||
( 2, NULL ),
|
||||
( 3, NULL ),
|
||||
( 4, NULL ),
|
||||
( 5, NULL )
|
||||
',
|
||||
);
|
||||
|
||||
my $res = $dbh->selectall_arrayref($sql_in_question);
|
||||
|
||||
is_deeply $res => [[4], [5]], "got the expected result with the index" or note explain $res;
|
||||
}
|
||||
|
||||
{ # Without the index
|
||||
my $dbh = connect_ok();
|
||||
$dbh->do($_) for (
|
||||
'CREATE TABLE cd ( cdid INTEGER PRIMARY KEY NOT NULL, genreid integer )',
|
||||
'INSERT INTO cd ( cdid, genreid ) VALUES
|
||||
( 1, 1 ),
|
||||
( 2, NULL ),
|
||||
( 3, NULL ),
|
||||
( 4, NULL ),
|
||||
( 5, NULL )
|
||||
',
|
||||
);
|
||||
|
||||
my $res = $dbh->selectall_arrayref($sql_in_question);
|
||||
|
||||
is_deeply $res => [[4], [5]], "got the expected result without the index" or note explain $res;
|
||||
}
|
Loading…
Add table
Reference in a new issue