vtabB.test 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # 2008 April 10
  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 file is is verifying that a virtual table in the
  13. # TEMP database that is created and dropped within a transaction
  14. # is handled correctly. Ticket #2994.
  15. #
  16. # Also make sure a virtual table on the right-hand side of an IN operator
  17. # is materialized rather than being used directly. Ticket #3082.
  18. #
  19. #
  20. # $Id: vtabB.test,v 1.2 2008/04/25 12:10:15 drh Exp $
  21. set testdir [file dirname $argv0]
  22. source $testdir/tester.tcl
  23. ifcapable !vtab {
  24. finish_test
  25. return
  26. }
  27. do_test vtabB-1.1 {
  28. register_echo_module [sqlite3_connection_pointer db]
  29. execsql {
  30. CREATE TABLE t1(x);
  31. BEGIN;
  32. CREATE VIRTUAL TABLE temp.echo_test1 USING echo(t1);
  33. DROP TABLE echo_test1;
  34. ROLLBACK;
  35. }
  36. } {}
  37. do_test vtabB-2.1 {
  38. execsql {
  39. INSERT INTO t1 VALUES(2);
  40. INSERT INTO t1 VALUES(3);
  41. CREATE TABLE t2(y);
  42. INSERT INTO t2 VALUES(1);
  43. INSERT INTO t2 VALUES(2);
  44. CREATE VIRTUAL TABLE echo_t2 USING echo(t2);
  45. SELECT * FROM t1 WHERE x IN (SELECT rowid FROM t2);
  46. }
  47. } {2}
  48. do_test vtab8-2.2 {
  49. execsql {
  50. SELECT rowid FROM echo_t2
  51. }
  52. } {1 2}
  53. do_test vtabB-2.3 {
  54. execsql {
  55. SELECT * FROM t1 WHERE x IN (SELECT rowid FROM t2);
  56. }
  57. } {2}
  58. do_test vtabB-2.4 {
  59. execsql {
  60. SELECT * FROM t1 WHERE x IN (SELECT rowid FROM echo_t2);
  61. }
  62. } {2}
  63. do_test vtabB-2.5 {
  64. execsql {
  65. SELECT * FROM t1 WHERE x IN (SELECT y FROM t2);
  66. }
  67. } {2}
  68. do_test vtabB-2.6 {
  69. execsql {
  70. SELECT * FROM t1 WHERE x IN (SELECT y FROM echo_t2);
  71. }
  72. } {2}
  73. finish_test