where8m.test 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # 2008 December 23
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  6. # May you do good and not evil.
  7. # May you find forgiveness for yourself and forgive others.
  8. # May you share freely, never taking more than you give.
  9. #
  10. #***********************************************************************
  11. # This file implements regression tests for SQLite library. The focus
  12. # is testing of where.c. More specifically, the focus is the optimization
  13. # of WHERE clauses that feature the OR operator.
  14. #
  15. # $Id: where8m.test,v 1.3 2009/06/05 17:09:12 drh Exp $
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. source $testdir/malloc_common.tcl
  19. do_malloc_test where8m-1 -sqlprep {
  20. CREATE TABLE t1(a, b, c);
  21. CREATE INDEX i1 ON t1(a);
  22. CREATE INDEX i2 ON t1(b);
  23. } -sqlbody {
  24. SELECT c FROM t1
  25. WHERE
  26. a = 2 OR b = 'three' OR a = 4 OR b = 'five' OR a = 6 OR
  27. b = 'seven' OR a = 8 OR b = 'nine' OR a = 10
  28. ORDER BY rowid;
  29. SELECT c FROM t1 WHERE
  30. a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6;
  31. SELECT c FROM t1 WHERE
  32. a BETWEEN 1 AND 3 AND b < 5 AND b > 2 AND c = 4;
  33. }
  34. do_malloc_test where8m-2 -tclprep {
  35. db eval {
  36. BEGIN;
  37. CREATE TABLE t1(a, b, c);
  38. CREATE INDEX i1 ON t1(a);
  39. CREATE INDEX i2 ON t1(b);
  40. }
  41. for {set i 0} {$i < 1000} {incr i} {
  42. set ii [expr $i*$i]
  43. set iii [expr $i*$i]
  44. db eval { INSERT INTO t1 VALUES($i, $ii, $iii) }
  45. }
  46. db eval COMMIT
  47. } -sqlbody {
  48. SELECT count(*) FROM t1 WHERE a BETWEEN 5 AND 995 OR b BETWEEN 5 AND 900000;
  49. }
  50. finish_test