1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

fixed mixed EOLs and removed redundant blank lines

This commit is contained in:
Kenichi Ishigaki 2019-01-06 05:55:34 +09:00
parent 11c2f4e70f
commit fc55eeb0d7
40 changed files with 867 additions and 975 deletions

View file

@ -28,4 +28,3 @@ ok( $sth->execute, '->execute ok' );
my $names = $sth->{NAME}; my $names = $sth->{NAME};
is( scalar(@$names), 4, 'Got 4 columns' ); is( scalar(@$names), 4, 'Got 4 columns' );
is_deeply( $names, [ 'f1', 'f1', 'f2', 'f3' ], 'Table prepending is disabled by default' ); is_deeply( $names, [ 'f1', 'f1', 'f2', 'f3' ], 'Table prepending is disabled by default' );

View file

@ -88,7 +88,6 @@ foreach my $call_func (@CALL_FUNCS) { for my $flags (@function_flags) {
$result = $dbh->selectall_arrayref( "SELECT newcount() FROM aggr_test GROUP BY field" ); $result = $dbh->selectall_arrayref( "SELECT newcount() FROM aggr_test GROUP BY field" );
ok( @$result == 3 && $result->[0][0] == 1 && $result->[1][0] == 1 ); ok( @$result == 3 && $result->[0][0] == 1 && $result->[1][0] == 1 );
# Test aggregate on empty table # Test aggregate on empty table
$dbh->do( "DROP TABLE aggr_empty_test;" ); $dbh->do( "DROP TABLE aggr_empty_test;" );
$dbh->do( "CREATE TABLE aggr_empty_test ( field )" ); $dbh->do( "CREATE TABLE aggr_empty_test ( field )" );

View file

@ -47,17 +47,13 @@ sub by_num_desc ($$) {
$_[1] <=> $_[0]; $_[1] <=> $_[0];
} }
# collation 'no_accents' will be automatically loaded on demand # collation 'no_accents' will be automatically loaded on demand
$DBD::SQLite::COLLATION{no_accents} = \&no_accents; $DBD::SQLite::COLLATION{no_accents} = \&no_accents;
$" = ", "; # to embed arrays into message strings $" = ", "; # to embed arrays into message strings
my $sql = "SELECT txt from collate_test ORDER BY txt"; my $sql = "SELECT txt from collate_test ORDER BY txt";
# test interaction with the global COLLATION hash ("WriteOnce") # test interaction with the global COLLATION hash ("WriteOnce")
dies (sub {$DBD::SQLite::COLLATION{perl} = sub {}}, dies (sub {$DBD::SQLite::COLLATION{perl} = sub {}},
@ -79,8 +75,6 @@ delete $tied->{foo};
$DBD::SQLite::COLLATION{foo} = \&by_num_desc; # override, no longer dies $DBD::SQLite::COLLATION{foo} = \&by_num_desc; # override, no longer dies
is($DBD::SQLite::COLLATION{foo}, \&by_num_desc, "overridden collation"); is($DBD::SQLite::COLLATION{foo}, \&by_num_desc, "overridden collation");
# now really test the collation functions # now really test the collation functions
foreach my $call_func (@CALL_FUNCS) { foreach my $call_func (@CALL_FUNCS) {
@ -126,7 +120,6 @@ foreach my $call_func (@CALL_FUNCS) {
is_deeply(\@sorted, $db_sorted, is_deeply(\@sorted, $db_sorted,
"collate no_accents (@sorted // @$db_sorted)"); "collate no_accents (@sorted // @$db_sorted)");
# manual addition of a collation for this dbh # manual addition of a collation for this dbh
$dbh->$call_func(by_length => \&by_length, "create_collation"); $dbh->$call_func(by_length => \&by_length, "create_collation");
@sorted = sort by_length @words; @sorted = sort by_length @words;
@ -135,7 +128,3 @@ foreach my $call_func (@CALL_FUNCS) {
"collate by_length (@sorted // @$db_sorted)"); "collate by_length (@sorted // @$db_sorted)");
} }
} }

View file

@ -38,7 +38,6 @@ foreach my $call_func (@CALL_FUNCS) {
# now the progress handler should have been called a number of times # now the progress handler should have been called a number of times
ok($n_callback); ok($n_callback);
# unregister the progress handler, set counter back to zero, do more work # unregister the progress handler, set counter back to zero, do more work
ok($dbh->$call_func( $N_OPCODES, undef, "progress_handler" )); ok($dbh->$call_func( $N_OPCODES, undef, "progress_handler" ));
$n_callback = 0; $n_callback = 0;

View file

@ -110,7 +110,6 @@ SCOPE: {
ok( $sth->finish, '->finish' ); ok( $sth->finish, '->finish' );
} }
# Delete the test row from the table # Delete the test row from the table
ok( $dbh->do('DELETE FROM ONE WHERE id = 2 AND name IS NULL'), 'DELETE' ); ok( $dbh->do('DELETE FROM ONE WHERE id = 2 AND name IS NULL'), 'DELETE' );

View file

@ -74,4 +74,3 @@ sub dumpblob {
} }
if ($ENV{SHOW_BLOBS}) { close(OUT) } if ($ENV{SHOW_BLOBS}) { close(OUT) }
} }

View file

@ -9,9 +9,6 @@ use Test::More tests => 28;
my $warning_count = 0; my $warning_count = 0;
##################################################################### #####################################################################
# Support functions # Support functions
@ -32,10 +29,6 @@ sub rows {
); );
} }
##################################################################### #####################################################################
# Main Tests # Main Tests

View file

@ -51,4 +51,3 @@ isnt $types->[0], 'VARCHAR(2)', '$sth->{TYPE}[0] doesn\'t return a string';
isnt $types->[1], 'CHAR(1)', '$sth->{TYPE}[1] doesn\'t return a string'; isnt $types->[1], 'CHAR(1)', '$sth->{TYPE}[1] doesn\'t return a string';
like $types->[0], qr/^-?\d+$/, '$sth->{TYPE}[0] returns an integer'; like $types->[0], qr/^-?\d+$/, '$sth->{TYPE}[0] returns an integer';
like $types->[1], qr/^-?\d+$/, '$sth->{TYPE}[1] returns an integer'; like $types->[1], qr/^-?\d+$/, '$sth->{TYPE}[1] returns an integer';

View file

@ -98,7 +98,6 @@ foreach my $subdir ( 'longascii', 'adatb
unlink(_path($dbfilex)) if -e _path($dbfilex); unlink(_path($dbfilex)) if -e _path($dbfilex);
} }
# connect to an empty filename - sqlite will create a tempfile # connect to an empty filename - sqlite will create a tempfile
eval { eval {
my $dbh = DBI->connect("dbi:SQLite:dbname=", undef, undef, { my $dbh = DBI->connect("dbi:SQLite:dbname=", undef, undef, {
@ -110,9 +109,6 @@ eval {
is( $@, '', "Could connect to temp database (empty filename)" ); is( $@, '', "Could connect to temp database (empty filename)" );
diag( $@ ) if $@; diag( $@ ) if $@;
sub _path { # copied from DBD::SQLite::connect sub _path { # copied from DBD::SQLite::connect
my $path = shift; my $path = shift;

View file

@ -139,4 +139,3 @@ is_deeply $info, [$table2_info, @systable_info, $table4_info, $table3_info, $tab
#warn 'Schema Names', substr Dumper($dbh->table_info('', '%', '')->fetchall_arrayref), 5; #warn 'Schema Names', substr Dumper($dbh->table_info('', '%', '')->fetchall_arrayref), 5;
#warn 'Table Types', substr Dumper($dbh->table_info('', '', '', '%')->fetchall_arrayref), 5; #warn 'Table Types', substr Dumper($dbh->table_info('', '', '', '%')->fetchall_arrayref), 5;
#warn 'table_info', substr Dumper($info), 5; #warn 'table_info', substr Dumper($info), 5;

View file

@ -122,20 +122,17 @@ foreach my $call_func (@CALL_FUNCS) {
[DBD::SQLite::DELETE, 'hook_test', undef, 'temp', undef], [DBD::SQLite::DELETE, 'hook_test', undef, 'temp', undef],
"args to authorizer (DELETE)"); "args to authorizer (DELETE)");
# unregister the authorizer ... now DELETE should be authorized # unregister the authorizer ... now DELETE should be authorized
$dbh->$call_func(undef, "set_authorizer"); $dbh->$call_func(undef, "set_authorizer");
eval {$dbh->do("DELETE FROM hook_test WHERE foo = 'auth_test'")}; eval {$dbh->do("DELETE FROM hook_test WHERE foo = 'auth_test'")};
ok(!$@, "delete was accepted"); ok(!$@, "delete was accepted");
# sqlite3 did warn in tests above, so avoid complains from Test::Warnings # sqlite3 did warn in tests above, so avoid complains from Test::Warnings
# (would be better to turn off warnings from sqlite3, but I didn't find # (would be better to turn off warnings from sqlite3, but I didn't find
# any way to do that) # any way to do that)
clear_warnings(); clear_warnings();
} }
sub do_transaction { sub do_transaction {
my $dbh = shift; my $dbh = shift;

View file

@ -34,8 +34,6 @@ use locale;
use DBD::SQLite; use DBD::SQLite;
foreach my $call_func (@CALL_FUNCS) { foreach my $call_func (@CALL_FUNCS) {
for my $use_unicode (0, 1) { for my $use_unicode (0, 1) {
@ -85,4 +83,3 @@ foreach my $call_func (@CALL_FUNCS) {
} }
} }
} }

View file

@ -51,13 +51,12 @@ BEGIN {
setlocale(LC_COLLATE, 'en-us'); setlocale(LC_COLLATE, 'en-us');
} }
} }
use locale;
use locale;
sub locale_tokenizer { # see also: Search::Tokenizer sub locale_tokenizer { # see also: Search::Tokenizer
return sub { return sub {
my $string = shift; my $string = shift;
my $regex = qr/\w+/; my $regex = qr/\w+/;
my $term_index = 0; my $term_index = 0;
@ -70,12 +69,8 @@ sub locale_tokenizer { # see also: Search::Tokenizer
}; };
} }
use DBD::SQLite; use DBD::SQLite;
for my $use_unicode (0, 1) { for my $use_unicode (0, 1) {
# connect # connect
@ -83,6 +78,7 @@ for my $use_unicode (0, 1) {
for my $fts (qw/fts3 fts4/) { for my $fts (qw/fts3 fts4/) {
next if $fts eq 'fts4' && !has_sqlite('3.7.4'); next if $fts eq 'fts4' && !has_sqlite('3.7.4');
# create fts table # create fts table
$dbh->do(<<"") or die DBI::errstr; $dbh->do(<<"") or die DBI::errstr;
CREATE VIRTUAL TABLE try_$fts CREATE VIRTUAL TABLE try_$fts
@ -104,7 +100,9 @@ for my $use_unicode (0, 1) {
. "ENABLE_FTS3_PARENTHESIS option", scalar @tests . "ENABLE_FTS3_PARENTHESIS option", scalar @tests
unless DBD::SQLite->can('compile_options') && unless DBD::SQLite->can('compile_options') &&
grep /ENABLE_FTS3_PARENTHESIS/, DBD::SQLite::compile_options(); grep /ENABLE_FTS3_PARENTHESIS/, DBD::SQLite::compile_options();
my $sql = "SELECT docid FROM try_$fts WHERE content MATCH ?"; my $sql = "SELECT docid FROM try_$fts WHERE content MATCH ?";
for my $t (@tests) { for my $t (@tests) {
my ($query, @expected) = @$t; my ($query, @expected) = @$t;
@expected = map {$doc_ids[$_]} @expected; @expected = map {$doc_ids[$_]} @expected;
@ -114,5 +112,3 @@ for my $use_unicode (0, 1) {
} }
} }
} }

View file

@ -52,7 +52,6 @@ CREATE TABLE song(
); );
__EOSQL__ __EOSQL__
plan tests => @sql_statements + 22; plan tests => @sql_statements + 22;
my $dbh = connect_ok( RaiseError => 1, PrintError => 0, AutoCommit => 1 ); my $dbh = connect_ok( RaiseError => 1, PrintError => 0, AutoCommit => 1 );
@ -86,31 +85,26 @@ for ($fk_data->{albumeditor}) {
is($_->{UNIQUE_OR_PRIMARY}, 'PRIMARY', "FK albumeditor, primary"); is($_->{UNIQUE_OR_PRIMARY}, 'PRIMARY', "FK albumeditor, primary");
} }
$sth = $dbh->foreign_key_info(undef, undef, 'artist', $sth = $dbh->foreign_key_info(undef, undef, 'artist',
undef, undef, 'album'); undef, undef, 'album');
$fk_data = $sth->fetchall_hashref('FKCOLUMN_NAME'); $fk_data = $sth->fetchall_hashref('FKCOLUMN_NAME');
is_deeply([keys %$fk_data], ['albumartist'], "FK album with PK, only 1 result"); is_deeply([keys %$fk_data], ['albumartist'], "FK album with PK, only 1 result");
$sth = $dbh->foreign_key_info(undef, undef, 'foobar', $sth = $dbh->foreign_key_info(undef, undef, 'foobar',
undef, undef, 'album'); undef, undef, 'album');
$fk_data = $sth->fetchall_hashref('FKCOLUMN_NAME'); $fk_data = $sth->fetchall_hashref('FKCOLUMN_NAME');
is_deeply([keys %$fk_data], [], "FK album with PK foobar, 0 result"); is_deeply([keys %$fk_data], [], "FK album with PK foobar, 0 result");
$sth = $dbh->foreign_key_info(undef, undef, undef, $sth = $dbh->foreign_key_info(undef, undef, undef,
undef, 'remote', undef); undef, 'remote', undef);
$fk_data = $sth->fetchall_hashref('FKCOLUMN_NAME'); $fk_data = $sth->fetchall_hashref('FKCOLUMN_NAME');
is_deeply([sort keys %$fk_data], [qw/albumartist albumeditor/], "FK remote.*, 2 results"); is_deeply([sort keys %$fk_data], [qw/albumartist albumeditor/], "FK remote.*, 2 results");
$sth = $dbh->foreign_key_info(undef, 'remote', undef, $sth = $dbh->foreign_key_info(undef, 'remote', undef,
undef, undef, undef); undef, undef, undef);
$fk_data = $sth->fetchall_hashref('FKCOLUMN_NAME'); $fk_data = $sth->fetchall_hashref('FKCOLUMN_NAME');
is_deeply([sort keys %$fk_data], [qw/songalbum songartist/], "FK with PK remote.*, 2 results"); is_deeply([sort keys %$fk_data], [qw/songalbum songartist/], "FK with PK remote.*, 2 results");
$sth = $dbh->foreign_key_info(undef, undef, undef, $sth = $dbh->foreign_key_info(undef, undef, undef,
undef, undef, 'song'); undef, undef, 'song');
$fk_data = $sth->fetchall_hashref('FKCOLUMN_NAME'); $fk_data = $sth->fetchall_hashref('FKCOLUMN_NAME');

View file

@ -14,6 +14,7 @@ use SQLiteTest qw/connect_ok @CALL_FUNCS/;
use Test::NoWarnings; use Test::NoWarnings;
plan tests => 16 * @CALL_FUNCS + 1; plan tests => 16 * @CALL_FUNCS + 1;
for my $call_func (@CALL_FUNCS) { for my $call_func (@CALL_FUNCS) {
my $dbh = connect_ok(RaiseError => 1); my $dbh = connect_ok(RaiseError => 1);
$dbh->do('create table foo (id integer primary key autoincrement, "name space", unique_col integer unique)'); $dbh->do('create table foo (id integer primary key autoincrement, "name space", unique_col integer unique)');

View file

@ -40,7 +40,6 @@ CREATE TABLE remote.b (
__EOSQL__ __EOSQL__
plan tests => @sql_statements + 2 + 46 * 2; plan tests => @sql_statements + 2 + 46 * 2;
my $dbh = connect_ok( RaiseError => 1, PrintError => 0, AutoCommit => 1 ); my $dbh = connect_ok( RaiseError => 1, PrintError => 0, AutoCommit => 1 );

View file

@ -45,4 +45,3 @@ foreach my $call_func (@CALL_FUNCS) {
note explain $db_match; note explain $db_match;
} }
} }

View file

@ -50,7 +50,6 @@ for my $query (split m/ ; /xms, $slurp) {
# Then we test the bug. # Then we test the bug.
# #
# We test with both 'DISTINCT(t.name) [..]' and 'DISTINCT t.name [..]' # We test with both 'DISTINCT(t.name) [..]' and 'DISTINCT t.name [..]'
# #
my $query_with_parens = trim(q{ my $query_with_parens = trim(q{

View file

@ -37,10 +37,6 @@ sub fetchrow_1 {
is_deeply( $row, [ 1 ], 'Got row 1' ); is_deeply( $row, [ 1 ], 'Got row 1' );
} }
###################################################################### ######################################################################
# A well-behaved non-cached statement # A well-behaved non-cached statement
@ -74,10 +70,6 @@ SCOPE: {
is( $c, 0, 'No warnings' ); is( $c, 0, 'No warnings' );
} }
###################################################################### ######################################################################
# A badly-behaved regular statement # A badly-behaved regular statement
@ -105,10 +97,6 @@ SCOPE: {
is( $c, 1, 'Got a warning' ); is( $c, 1, 'Got a warning' );
} }
###################################################################### ######################################################################
# A well-behaved cached statement # A well-behaved cached statement
@ -151,10 +139,6 @@ SCOPE: {
is( $c, 1, 'No warnings' ); is( $c, 1, 'No warnings' );
} }
##################################################################### #####################################################################
# Badly-behaved prepare_cached (but still acceptable) # Badly-behaved prepare_cached (but still acceptable)

View file

@ -54,4 +54,3 @@ $sth->execute;
# XXX: Panic occurs here when running under the debugger # XXX: Panic occurs here when running under the debugger
$dbh->commit or die $dbh->errstr; $dbh->commit or die $dbh->errstr;

View file

@ -48,6 +48,7 @@ my $str = "\x{20ac}";
{ {
my $sth = $dbh->prepare('select * from test1 order by id'); my $sth = $dbh->prepare('select * from test1 order by id');
$sth->execute; $sth->execute;
my $expected = [undef, 1, 0, 0, 1, 1, 1]; my $expected = [undef, 1, 0, 0, 1, 1, 1];
@ -58,6 +59,7 @@ my $str = "\x{20ac}";
ok $row && utf8::is_utf8($row->[1]) == $expected->[$_], ok $row && utf8::is_utf8($row->[1]) == $expected->[$_],
"row $_ is ".($expected->[$_] ? "unicode" : "not unicode"); "row $_ is ".($expected->[$_] ? "unicode" : "not unicode");
} }
$sth->finish; $sth->finish;
} }
@ -104,7 +106,6 @@ my $str = "\x{20ac}";
my $expected = [undef, 0, 0, 0, 0, 0, 0]; my $expected = [undef, 0, 0, 0, 0, 0, 0];
for (1..6) { for (1..6) {
$sth->fetch; $sth->fetch;
ok $col1 && $col1 == $_; ok $col1 && $col1 == $_;
ok $col2 && utf8::is_utf8($col2) == $expected->[$_], ok $col2 && utf8::is_utf8($col2) == $expected->[$_],
"row $_ is ".($expected->[$_] ? "unicode" : "not unicode"); "row $_ is ".($expected->[$_] ? "unicode" : "not unicode");

View file

@ -95,7 +95,6 @@ sub unicode_test {
} }
{ # tests for an environment where everything is decoded { # tests for an environment where everything is decoded
my $dbh = connect_ok(sqlite_unicode => 1); my $dbh = connect_ok(sqlite_unicode => 1);
$dbh->do("pragma foreign_keys = on"); $dbh->do("pragma foreign_keys = on");
my $unicode_quoted = $dbh->quote_identifier($unicode); my $unicode_quoted = $dbh->quote_identifier($unicode);

View file

@ -39,7 +39,7 @@ plan tests => 15 + 1;
my $sth = $dbh->primary_key_info(undef, undef, 'foo'); my $sth = $dbh->primary_key_info(undef, undef, 'foo');
my @pk_info; my @pk_info;
while(my $row = $sth->fetchrow_hashref) { push @pk_info, $row }; while(my $row = $sth->fetchrow_hashref) { push @pk_info, $row };
is @pk_info => 2, "found 2 pks"; is @pk_info => 2, "found 2 pks";
is $pk_info[0]{COLUMN_NAME} => 'type', "first pk name is type"; is $pk_info[0]{COLUMN_NAME} => 'type', "first pk name is type";
is $pk_info[1]{COLUMN_NAME} => 'id', "second pk name is id"; is $pk_info[1]{COLUMN_NAME} => 'id', "second pk name is id";
} }

View file

@ -24,7 +24,6 @@ my $dbh = connect_ok(RaiseError => 1, AutoCommit => 1);
my $sql = q{CREATE VIRTUAL TABLE foo USING fts4 (content="", a, b)}; my $sql = q{CREATE VIRTUAL TABLE foo USING fts4 (content="", a, b)};
ok( $dbh->do($sql), 'CREATE TABLE' ); ok( $dbh->do($sql), 'CREATE TABLE' );
ok($dbh->do("INSERT INTO foo(docid, a, b) VALUES(1, 'a', 'b')"), ok($dbh->do("INSERT INTO foo(docid, a, b) VALUES(1, 'a', 'b')"),
"insert without bind"); "insert without bind");
@ -48,4 +47,3 @@ ok($sth->execute(),
ok( $dbh->do("CREATE VIRTUAL TABLE foo_aux USING fts4aux(foo)"), 'FTS4AUX'); ok( $dbh->do("CREATE VIRTUAL TABLE foo_aux USING fts4aux(foo)"), 'FTS4AUX');
my $data = $dbh->selectcol_arrayref("select term from foo_aux where col='*'"); my $data = $dbh->selectcol_arrayref("select term from foo_aux where col='*'");
is_deeply ([sort @$data], [qw/a aa aaa b bb bbb/], "terms properly indexed"); is_deeply ([sort @$data], [qw/a aa aaa b bb bbb/], "terms properly indexed");

View file

@ -20,7 +20,6 @@ is $rows->[0]{rowid}, 5, "rowid column";
is $rows->[0]{foo}, "auto_vivify:0", "foo column"; is $rows->[0]{foo}, "auto_vivify:0", "foo column";
is $rows->[0]{bar}, "auto_vivify:1", "bar column"; is $rows->[0]{bar}, "auto_vivify:1", "bar column";
$sql = "SELECT * FROM foobar "; $sql = "SELECT * FROM foobar ";
$rows = $dbh->selectall_arrayref($sql, {Slice => {}}); $rows = $dbh->selectall_arrayref($sql, {Slice => {}});
is scalar(@$rows), 5, "got 5 rows again"; is scalar(@$rows), 5, "got 5 rows again";
@ -31,7 +30,6 @@ $sql = "SELECT * FROM foobar WHERE foo > -1 and bar < 33";
$rows = $dbh->selectall_arrayref($sql, {Slice => {}}); $rows = $dbh->selectall_arrayref($sql, {Slice => {}});
is scalar(@$rows), 5, "got 5 rows (because of omitted constraints)"; is scalar(@$rows), 5, "got 5 rows (because of omitted constraints)";
package DBD::SQLite::VirtualTable::T; package DBD::SQLite::VirtualTable::T;
use strict; use strict;
use warnings; use warnings;
@ -49,7 +47,6 @@ sub NEW {
return $self; return $self;
} }
sub BEST_INDEX { sub BEST_INDEX {
my ($self, $constraints, $order_by) = @_; my ($self, $constraints, $order_by) = @_;
@ -77,8 +74,6 @@ sub BEST_INDEX {
return $outputs; return $outputs;
} }
package DBD::SQLite::VirtualTable::T::Cursor; package DBD::SQLite::VirtualTable::T::Cursor;
use strict; use strict;
use warnings; use warnings;
@ -99,8 +94,6 @@ sub FILTER {
return; return;
} }
sub EOF { sub EOF {
my $self = shift; my $self = shift;
@ -125,8 +118,4 @@ sub ROWID {
return $self->{row_count}; return $self->{row_count};
} }
1; 1;

View file

@ -52,7 +52,6 @@ my $sth = $dbh->prepare("SELECT * FROM barfoo");
ok !$DBD::SQLite::VirtualTable::T::CREATE_COUNT, "no vtab created"; ok !$DBD::SQLite::VirtualTable::T::CREATE_COUNT, "no vtab created";
is $DBD::SQLite::VirtualTable::T::CONNECT_COUNT, 1, "1 vtab connected"; is $DBD::SQLite::VirtualTable::T::CONNECT_COUNT, 1, "1 vtab connected";
package DBD::SQLite::VirtualTable::T; package DBD::SQLite::VirtualTable::T;
use base 'DBD::SQLite::VirtualTable'; use base 'DBD::SQLite::VirtualTable';
@ -71,4 +70,3 @@ sub DESTROY {$DESTROY_COUNT++}
sub DESTROY_MODULE {$DESTROY_MODULE_COUNT++} sub DESTROY_MODULE {$DESTROY_MODULE_COUNT++}
1; 1;

View file

@ -7,7 +7,6 @@ use Test::NoWarnings;
plan tests => 15; plan tests => 15;
my $dbh = connect_ok( RaiseError => 1, PrintError => 0, AutoCommit => 1 ); my $dbh = connect_ok( RaiseError => 1, PrintError => 0, AutoCommit => 1 );
$dbh->$sqlite_call(create_module => vtab => "DBD::SQLite::VirtualTable::T"); $dbh->$sqlite_call(create_module => vtab => "DBD::SQLite::VirtualTable::T");
@ -50,7 +49,6 @@ is $DBD::SQLite::VirtualTable::T::funcs{abs}{calls}, 1, "abs still 1";
is $DBD::SQLite::VirtualTable::T::funcs{substr}{calls}, 1, "substr still 1"; is $DBD::SQLite::VirtualTable::T::funcs{substr}{calls}, 1, "substr still 1";
is $DBD::SQLite::VirtualTable::T::funcs{trim}{calls}, 1, "trim still 1"; is $DBD::SQLite::VirtualTable::T::funcs{trim}{calls}, 1, "trim still 1";
# new table : should issue new calls to FIND_FUNCTION # new table : should issue new calls to FIND_FUNCTION
ok $dbh->do("CREATE VIRTUAL TABLE barfoo USING vtab(foo INTEGER, bar INTEGER)"), ok $dbh->do("CREATE VIRTUAL TABLE barfoo USING vtab(foo INTEGER, bar INTEGER)"),
"created barfoo"; "created barfoo";
@ -66,7 +64,6 @@ is $DBD::SQLite::VirtualTable::T::funcs{abs}{calls}, 2, "abs now 2";
is $DBD::SQLite::VirtualTable::T::funcs{substr}{calls}, 2, "substr now 2"; is $DBD::SQLite::VirtualTable::T::funcs{substr}{calls}, 2, "substr now 2";
is $DBD::SQLite::VirtualTable::T::funcs{trim}{calls}, 2, "trim now 2"; is $DBD::SQLite::VirtualTable::T::funcs{trim}{calls}, 2, "trim now 2";
# drop table : should free references to functions # drop table : should free references to functions
ok $dbh->do("DROP TABLE foobar"); ok $dbh->do("DROP TABLE foobar");
@ -75,14 +72,11 @@ undef $dbh;
note "done"; note "done";
package DBD::SQLite::VirtualTable::T; package DBD::SQLite::VirtualTable::T;
use strict; use strict;
use warnings; use warnings;
use base 'DBD::SQLite::VirtualTable'; use base 'DBD::SQLite::VirtualTable';
sub BEST_INDEX { sub BEST_INDEX {
my ($self, $constraints, $order_by) = @_; my ($self, $constraints, $order_by) = @_;
@ -106,7 +100,6 @@ sub BEST_INDEX {
our %funcs; our %funcs;
sub FIND_FUNCTION { sub FIND_FUNCTION {
my ($self, $n_arg, $function_name) = @_; my ($self, $n_arg, $function_name) = @_;
@ -115,7 +108,6 @@ sub FIND_FUNCTION {
return $func; return $func;
} }
package DBD::SQLite::VirtualTable::T::Cursor; package DBD::SQLite::VirtualTable::T::Cursor;
use strict; use strict;
use warnings; use warnings;
@ -136,8 +128,6 @@ sub FILTER {
return; return;
} }
sub EOF { sub EOF {
my $self = shift; my $self = shift;
@ -162,8 +152,4 @@ sub ROWID {
return $self->{row_count}; return $self->{row_count};
} }
1; 1;

View file

@ -22,13 +22,11 @@ $dbh->do(<<"");
$dbh->do(<<""); $dbh->do(<<"");
INSERT INTO base VALUES(2, 'foo2', '10_filecontent.t', 'bar2') INSERT INTO base VALUES(2, 'foo2', '10_filecontent.t', 'bar2')
# start tests # start tests
ok $dbh->$sqlite_call(create_module => fs => "DBD::SQLite::VirtualTable::FileContent"), ok $dbh->$sqlite_call(create_module => fs => "DBD::SQLite::VirtualTable::FileContent"),
"create_module"; "create_module";
ok $dbh->do(<<""), "create vtable"; ok $dbh->do(<<""), "create vtable";
CREATE VIRTUAL TABLE vfs USING fs(source = base, CREATE VIRTUAL TABLE vfs USING fs(source = base,
expose = "path, foo, bar", expose = "path, foo, bar",
@ -51,9 +49,7 @@ is_deeply([sort keys %{$rows->[0]}], [qw/bar content foo path/], "col list OK");
is $rows->[0]{bar}, 'bar1', 'got bar1'; is $rows->[0]{bar}, 'bar1', 'got bar1';
is $rows->[1]{bar}, 'bar2', 'got bar2'; is $rows->[1]{bar}, 'bar2', 'got bar2';
# expensive request (reads content from all files in table) ! # expensive request (reads content from all files in table) !
$sql = "SELECT * FROM vfs WHERE content LIKE '%filesys%'"; $sql = "SELECT * FROM vfs WHERE content LIKE '%filesys%'";
$rows = $dbh->selectall_arrayref($sql, {Slice => {}}); $rows = $dbh->selectall_arrayref($sql, {Slice => {}});
is scalar(@$rows), 1, "got 1 row"; is scalar(@$rows), 1, "got 1 row";

View file

@ -66,7 +66,6 @@ $dbh->do("CREATE TABLE files (id INTEGER PRIMARY KEY, path TEXT)");
my $sth = $dbh->prepare("INSERT INTO files(path) VALUES (?)"); my $sth = $dbh->prepare("INSERT INTO files(path) VALUES (?)");
$sth->execute($_) foreach @perl_files; $sth->execute($_) foreach @perl_files;
# create the virtual table # create the virtual table
$dbh->$sqlite_call(create_module => fc => "DBD::SQLite::VirtualTable::FileContent"); $dbh->$sqlite_call(create_module => fc => "DBD::SQLite::VirtualTable::FileContent");
$dbh->do(<<""); $dbh->do(<<"");
@ -92,7 +91,6 @@ foreach my $test (@tests) {
my $remove_path = 'lib/DBD/SQLite/VirtualTable.pm'; my $remove_path = 'lib/DBD/SQLite/VirtualTable.pm';
$dbh->do("DELETE FROM fts WHERE path='$remove_path'"); $dbh->do("DELETE FROM fts WHERE path='$remove_path'");
# test again # test again
foreach my $test (@tests) { foreach my $test (@tests) {
my ($pattern, @expected) = @$test; my ($pattern, @expected) = @$test;
@ -113,4 +111,3 @@ foreach my $test (@tests) {
my $paths = $dbh->selectcol_arrayref($sql, {}, $pattern); my $paths = $dbh->selectcol_arrayref($sql, {}, $pattern);
is_deeply([sort @$paths], \@expected, "search '$pattern' -- after reconnect"); is_deeply([sort @$paths], \@expected, "search '$pattern' -- after reconnect");
} }

View file

@ -39,14 +39,12 @@ is scalar(@$res), 3, "got 3 rows";
is $res->[0]{a}, 1, 'got 1 in a'; is $res->[0]{a}, 1, 'got 1 in a';
is $res->[0]{b}, 2, 'got 2 in b'; is $res->[0]{b}, 2, 'got 2 in b';
$sql = "SELECT * FROM vtb WHERE b < 8 ORDER BY a DESC"; $sql = "SELECT * FROM vtb WHERE b < 8 ORDER BY a DESC";
$res = $dbh->selectall_arrayref($sql, {Slice => {}}); $res = $dbh->selectall_arrayref($sql, {Slice => {}});
is scalar(@$res), 2, "got 2 rows"; is scalar(@$res), 2, "got 2 rows";
is $res->[0]{a}, 4, 'got 4 in first a'; is $res->[0]{a}, 4, 'got 4 in first a';
is $res->[1]{a}, 1, 'got 1 in second a'; is $res->[1]{a}, 1, 'got 1 in second a';
$sql = "SELECT rowid FROM vtb WHERE c = 'six'"; $sql = "SELECT rowid FROM vtb WHERE c = 'six'";
$res = $dbh->selectall_arrayref($sql, {Slice => {}}); $res = $dbh->selectall_arrayref($sql, {Slice => {}});
is_deeply $res, [{rowid => 2}], $sql; is_deeply $res, [{rowid => 2}], $sql;
@ -56,14 +54,12 @@ $sql = "SELECT c FROM vtb WHERE c MATCH 'i' ORDER BY c";
$res = $dbh->selectcol_arrayref($sql); $res = $dbh->selectcol_arrayref($sql);
is_deeply $res, [qw/nine six/], $sql; is_deeply $res, [qw/nine six/], $sql;
$dbh->do("INSERT INTO vtb(a, b, c) VALUES (11, 22, 33)"); $dbh->do("INSERT INTO vtb(a, b, c) VALUES (11, 22, 33)");
my $row_id = $dbh->last_insert_id('', '', '', ''); my $row_id = $dbh->last_insert_id('', '', '', '');
is $row_id, 3, 'new rowid is 3'; is $row_id, 3, 'new rowid is 3';
is scalar(@$perl_rows), 4, 'perl_rows expanded'; is scalar(@$perl_rows), 4, 'perl_rows expanded';
is_deeply $perl_rows->[-1], [11, 22, 33], 'new row is correct'; is_deeply $perl_rows->[-1], [11, 22, 33], 'new row is correct';
#====================================================================== #======================================================================
# test the hashref implementation # test the hashref implementation
#====================================================================== #======================================================================
@ -79,7 +75,6 @@ is scalar(@$res), 2, "got 2 rows";
is $res->[0]{a}, 4, 'got 4 in first a'; is $res->[0]{a}, 4, 'got 4 in first a';
is $res->[1]{a}, 1, 'got 1 in second a'; is $res->[1]{a}, 1, 'got 1 in second a';
#====================================================================== #======================================================================
# test the colref implementation # test the colref implementation
#====================================================================== #======================================================================
@ -104,7 +99,6 @@ $sql = "SELECT a FROM vtb WHERE a IN intarray";
$res = $dbh->selectcol_arrayref($sql); $res = $dbh->selectcol_arrayref($sql);
is_deeply $res, [ 1, 7 ], "IN intarray"; is_deeply $res, [ 1, 7 ], "IN intarray";
# same thing with strings # same thing with strings
our $strings = [qw/one two three/]; our $strings = [qw/one two three/];
ok $dbh->do(<<""), "create vtable strarray"; ok $dbh->do(<<""), "create vtable strarray";

View file

@ -49,7 +49,6 @@ is $res->[0]{block}, $sigma_block, "letter in proper block";
# the following does not work because \b gets escaped as a literal # the following does not work because \b gets escaped as a literal
#$sql = "SELECT * FROM charinfo WHERE script='Greek' AND name MATCH '\\bSIGMA\\b'"; #$sql = "SELECT * FROM charinfo WHERE script='Greek' AND name MATCH '\\bSIGMA\\b'";
# but the following does work because the REGEXP operator is handled # but the following does work because the REGEXP operator is handled
# outside of the BEST_INDEX / FILTER methods # outside of the BEST_INDEX / FILTER methods
$sql = "SELECT * FROM charinfo WHERE script='Greek' AND name REGEXP '\\bSIGMA\\b'"; $sql = "SELECT * FROM charinfo WHERE script='Greek' AND name REGEXP '\\bSIGMA\\b'";

View file

@ -18,7 +18,6 @@ my @interpolation_attempts = (
'$self', '$self',
); );
# sample data # sample data
our $perl_rows = [ our $perl_rows = [
[1, 2, 'three'], [1, 2, 'three'],