delete3.test 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # 2005 August 24
  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
  12. # focus of this script is a test of the DELETE command where a
  13. # large number of rows are deleted.
  14. #
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. # Create a table that contains a large number of rows.
  18. #
  19. do_test delete3-1.1 {
  20. execsql {
  21. CREATE TABLE t1(x integer primary key);
  22. BEGIN;
  23. INSERT INTO t1 VALUES(1);
  24. INSERT INTO t1 VALUES(2);
  25. INSERT INTO t1 SELECT x+2 FROM t1;
  26. INSERT INTO t1 SELECT x+4 FROM t1;
  27. INSERT INTO t1 SELECT x+8 FROM t1;
  28. INSERT INTO t1 SELECT x+16 FROM t1;
  29. INSERT INTO t1 SELECT x+32 FROM t1;
  30. INSERT INTO t1 SELECT x+64 FROM t1;
  31. INSERT INTO t1 SELECT x+128 FROM t1;
  32. INSERT INTO t1 SELECT x+256 FROM t1;
  33. INSERT INTO t1 SELECT x+512 FROM t1;
  34. INSERT INTO t1 SELECT x+1024 FROM t1;
  35. INSERT INTO t1 SELECT x+2048 FROM t1;
  36. INSERT INTO t1 SELECT x+4096 FROM t1;
  37. INSERT INTO t1 SELECT x+8192 FROM t1;
  38. INSERT INTO t1 SELECT x+16384 FROM t1;
  39. INSERT INTO t1 SELECT x+32768 FROM t1;
  40. INSERT INTO t1 SELECT x+65536 FROM t1;
  41. INSERT INTO t1 SELECT x+131072 FROM t1;
  42. INSERT INTO t1 SELECT x+262144 FROM t1;
  43. COMMIT;
  44. SELECT count(*) FROM t1;
  45. }
  46. } {524288}
  47. do_test delete3-1.2 {
  48. execsql {
  49. DELETE FROM t1 WHERE x%2==0;
  50. SELECT count(*) FROM t1;
  51. }
  52. } {262144}
  53. integrity_check delete3-1.3
  54. finish_test