0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-12-01 17:23:42 +01:00
sqlite/test/fts1l.test
shess 6b6ab13353 Fix crash in delete when existing row has null fields. Previous code
assumed that the row had values in all columns, sigh.  Fixes bug
http://www.sqlite.org/cvstrac/tktview?tn=2289 . (CVS 3833)

FossilOrigin-Name: 81be7290a4db7b74a533aaf95c7389eb4bde6a88
2007-04-09 20:45:40 +00:00

66 lines
1.5 KiB
Plaintext

# 2007 April 9
#
# The author disclaims copyright to this source code.
#
#*************************************************************************
# This file implements regression tests for SQLite library. fts1
# DELETE handling assumed all fields were non-null. This was not
# the intention at all.
#
# $Id: fts1l.test,v 1.1 2007/04/09 20:45:42 shess Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS1 is defined, omit this file.
ifcapable !fts1 {
finish_test
return
}
db eval {
CREATE VIRTUAL TABLE t1 USING fts1(col_a, col_b);
INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing');
INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null);
INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b');
INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null);
}
do_test fts1m-1.0 {
execsql {
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {2 2 4}
do_test fts1m-1.1 {
execsql {
DELETE FROM t1 WHERE rowid = 1;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {1 1 3}
do_test fts1m-1.2 {
execsql {
DELETE FROM t1 WHERE rowid = 2;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {0 1 2}
do_test fts1m-1.3 {
execsql {
DELETE FROM t1 WHERE rowid = 3;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {0 0 1}
do_test fts1m-1.4 {
execsql {
DELETE FROM t1 WHERE rowid = 4;
SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
}
} {0 0 0}
finish_test