os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/fts2m.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# 2007 April 9
sl@0
     2
#
sl@0
     3
# The author disclaims copyright to this source code.
sl@0
     4
#
sl@0
     5
#*************************************************************************
sl@0
     6
# This file implements regression tests for SQLite library.  fts2
sl@0
     7
# DELETE handling assumed all fields were non-null.  This was not
sl@0
     8
# the intention at all.
sl@0
     9
#
sl@0
    10
# $Id: fts2m.test,v 1.1 2007/04/09 20:45:42 shess Exp $
sl@0
    11
#
sl@0
    12
sl@0
    13
set testdir [file dirname $argv0]
sl@0
    14
source $testdir/tester.tcl
sl@0
    15
sl@0
    16
# If SQLITE_ENABLE_FTS2 is defined, omit this file.
sl@0
    17
ifcapable !fts2 {
sl@0
    18
  finish_test
sl@0
    19
  return
sl@0
    20
}
sl@0
    21
sl@0
    22
db eval {
sl@0
    23
  CREATE VIRTUAL TABLE t1 USING fts2(col_a, col_b);
sl@0
    24
sl@0
    25
  INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing');
sl@0
    26
  INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null);
sl@0
    27
  INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b');
sl@0
    28
  INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null);
sl@0
    29
}
sl@0
    30
sl@0
    31
do_test fts2m-1.0 {
sl@0
    32
  execsql {
sl@0
    33
    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
sl@0
    34
  }
sl@0
    35
} {2 2 4}
sl@0
    36
sl@0
    37
do_test fts2m-1.1 {
sl@0
    38
  execsql {
sl@0
    39
    DELETE FROM t1 WHERE rowid = 1;
sl@0
    40
    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
sl@0
    41
  }
sl@0
    42
} {1 1 3}
sl@0
    43
sl@0
    44
do_test fts2m-1.2 {
sl@0
    45
  execsql {
sl@0
    46
    DELETE FROM t1 WHERE rowid = 2;
sl@0
    47
    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
sl@0
    48
  }
sl@0
    49
} {0 1 2}
sl@0
    50
sl@0
    51
do_test fts2m-1.3 {
sl@0
    52
  execsql {
sl@0
    53
    DELETE FROM t1 WHERE rowid = 3;
sl@0
    54
    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
sl@0
    55
  }
sl@0
    56
} {0 0 1}
sl@0
    57
sl@0
    58
do_test fts2m-1.4 {
sl@0
    59
  execsql {
sl@0
    60
    DELETE FROM t1 WHERE rowid = 4;
sl@0
    61
    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;
sl@0
    62
  }
sl@0
    63
} {0 0 0}
sl@0
    64
sl@0
    65
finish_test