tkt3201.test 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # 2008 July 4
  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.
  12. # Specifically, it tests that bug #3201 has been fixed.
  13. #
  14. # $Id: tkt3201.test,v 1.3 2008/07/12 14:52:21 drh Exp $
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. do_test tkt3201-1 {
  18. execsql {
  19. CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
  20. INSERT INTO t1 VALUES(1, 'one');
  21. INSERT INTO t1 VALUES(2, 'two');
  22. }
  23. } {}
  24. do_test tkt3201-2 {
  25. execsql {
  26. SELECT l.a, r.a FROM t1 AS l, t1 AS r WHERE l.a < r.a;
  27. }
  28. } {1 2}
  29. do_test tkt3201-3 {
  30. execsql {
  31. CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);
  32. INSERT INTO t2 VALUES(2, 'two');
  33. }
  34. execsql {
  35. SELECT l.a, r.a FROM t1 AS l, t2 AS r WHERE l.a < r.a;
  36. }
  37. } {1 2}
  38. do_test tkt3201-4 {
  39. execsql {
  40. DELETE FROM t1 WHERE a = 2;
  41. }
  42. execsql {
  43. SELECT l.a, r.a FROM t1 AS l, t2 AS r WHERE l.a < r.a;
  44. }
  45. } {1 2}
  46. do_test tkt3201-5 {
  47. execsql {
  48. DELETE FROM t1 WHERE a = 2;
  49. }
  50. execsql {
  51. SELECT t1.a, t1.b, t2.a, t2.b FROM t1, t2;
  52. }
  53. } {1 one 2 two}
  54. do_test tkt3201-6 {
  55. execsql {
  56. CREATE TABLE t3(c INTEGER PRIMARY KEY, d TEXT);
  57. INSERT INTO t3 VALUES(2, 'two');
  58. }
  59. execsql { SELECT a, b, c, d FROM t1, t3 }
  60. } {1 one 2 two}
  61. do_test tkt3201-7 {
  62. execsql { SELECT a, b, c, d FROM t1, t3 WHERE a < c }
  63. } {1 one 2 two}
  64. # Ticket [efc02f977919]
  65. #
  66. ifcapable trigger {
  67. do_test tkt3201-4.0 {
  68. db eval {
  69. CREATE TABLE t4(x);
  70. CREATE TABLE t4_log(x);
  71. CREATE TRIGGER r4_1 AFTER INSERT ON t4 WHEN new.x=1 BEGIN
  72. INSERT INTO t4_log(x) VALUES(new.x);
  73. END;
  74. CREATE TRIGGER r4_2 AFTER INSERT ON t4 WHEN new.x=2 BEGIN
  75. INSERT INTO t4_log(x) VALUES(new.x);
  76. END;
  77. CREATE TRIGGER r4_3 AFTER INSERT ON t4 WHEN new.x=3 BEGIN
  78. INSERT INTO t4_log(x) VALUES(new.x);
  79. END;
  80. CREATE TRIGGER r4_4 AFTER INSERT ON t4 WHEN new.x=4 BEGIN
  81. INSERT INTO t4_log(x) VALUES(new.x);
  82. END;
  83. INSERT INTO t4 VALUES(1);
  84. INSERT INTO t4 VALUES(2);
  85. INSERT INTO t4 VALUES(3);
  86. INSERT INTO t4 VALUES(4);
  87. SELECT * FROM t4_log;
  88. }
  89. } {1 2 3 4}
  90. }
  91. finish_test