tkt-f777251dc7a.test 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # 2009 October 16
  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. #
  13. # This file implements tests to verify that ticket [f777251dc7a] has been
  14. # fixed.
  15. #
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. ifcapable !compound {
  19. finish_test
  20. return
  21. }
  22. do_test tkt-f7772-1.1 {
  23. execsql {
  24. CREATE TEMP TABLE t1(x UNIQUE);
  25. INSERT INTO t1 VALUES(1);
  26. CREATE TABLE t2(x, y);
  27. INSERT INTO t2 VALUES(1, 2);
  28. CREATE TEMP TABLE t3(w, z);
  29. }
  30. } {}
  31. proc force_rollback {} {
  32. catch {db eval {INSERT OR ROLLBACK INTO t1 VALUES(1)}}
  33. }
  34. db function force_rollback force_rollback
  35. do_test tkt-f7772-1.2 {
  36. catchsql {
  37. BEGIN IMMEDIATE;
  38. SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2;
  39. }
  40. } {1 {abort due to ROLLBACK}}
  41. do_test tkt-f7772-1.3 {
  42. sqlite3_get_autocommit db
  43. } {1}
  44. do_test tkt-f7772-2.1 {
  45. execsql {
  46. DROP TABLE IF EXISTS t1;
  47. DROP TABLE IF EXISTS t2;
  48. DROP TABLE IF EXISTS t3;
  49. CREATE TEMP TABLE t1(x UNIQUE);
  50. INSERT INTO t1 VALUES(1);
  51. CREATE TABLE t2(x, y);
  52. INSERT INTO t2 VALUES(1, 2);
  53. }
  54. } {}
  55. do_test tkt-f7772-2.2 {
  56. execsql {
  57. BEGIN IMMEDIATE;
  58. CREATE TEMP TABLE t3(w, z);
  59. }
  60. catchsql {
  61. SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2
  62. }
  63. } {1 {callback requested query abort}}
  64. do_test tkt-f7772-2.3 {
  65. sqlite3_get_autocommit db
  66. } {1}
  67. do_test tkt-f7772-3.1 {
  68. execsql {
  69. DROP TABLE IF EXISTS t1;
  70. DROP TABLE IF EXISTS t2;
  71. DROP TABLE IF EXISTS t3;
  72. CREATE TEMP TABLE t1(x);
  73. CREATE TABLE t2(x);
  74. CREATE TABLE t3(x);
  75. INSERT INTO t1 VALUES(1);
  76. INSERT INTO t1 VALUES(2);
  77. INSERT INTO t2 VALUES(1);
  78. INSERT INTO t2 VALUES(2);
  79. }
  80. } {}
  81. proc ins {} { db eval {INSERT INTO t3 VALUES('hello')} }
  82. db function ins ins
  83. do_test tkt-f7772-3.2 {
  84. execsql {
  85. SELECT ins() AS x FROM t2 UNION ALL SELECT ins() AS x FROM t1
  86. }
  87. } {{} {} {} {}}
  88. do_test tkt-f7772-3.3 {
  89. execsql { SELECT * FROM t3 }
  90. } {hello hello hello hello}
  91. finish_test