vtab8.test 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # 2006 August 29
  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 inserting into virtual tables from a SELECT
  13. # statement.
  14. #
  15. # $Id: vtab8.test,v 1.2 2007/03/02 08:12:23 danielk1977 Exp $
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. ifcapable !vtab {
  19. finish_test
  20. return
  21. }
  22. register_echo_module [sqlite3_connection_pointer db]
  23. # See ticket #2244
  24. #
  25. do_test vtab1.2244-1 {
  26. execsql {
  27. CREATE TABLE t2244(a, b);
  28. CREATE VIRTUAL TABLE t2244e USING echo(t2244);
  29. INSERT INTO t2244 VALUES('AA', 'BB');
  30. INSERT INTO t2244 VALUES('CC', 'DD');
  31. SELECT rowid, * FROM t2244e;
  32. }
  33. } {1 AA BB 2 CC DD}
  34. do_test vtab1.2244-2 {
  35. execsql {
  36. SELECT * FROM t2244e WHERE rowid = 10;
  37. }
  38. } {}
  39. do_test vtab1.2244-3 {
  40. execsql {
  41. UPDATE t2244e SET a = 'hello world' WHERE 0;
  42. SELECT rowid, * FROM t2244e;
  43. }
  44. } {1 AA BB 2 CC DD}
  45. do_test vtab1-2250-2 {
  46. execsql {
  47. CREATE TABLE t2250(a, b);
  48. INSERT INTO t2250 VALUES(10, 20);
  49. CREATE VIRTUAL TABLE t2250e USING echo(t2250);
  50. select max(rowid) from t2250;
  51. select max(rowid) from t2250e;
  52. }
  53. } {1 1}
  54. # See ticket #2260.
  55. #
  56. do_test vtab1.2260-1 {
  57. execsql {
  58. CREATE TABLE t2260a_real(a, b);
  59. CREATE TABLE t2260b_real(a, b);
  60. CREATE INDEX i2260 ON t2260a_real(a);
  61. CREATE INDEX i2260x ON t2260b_real(a);
  62. CREATE VIRTUAL TABLE t2260a USING echo(t2260a_real);
  63. CREATE VIRTUAL TABLE t2260b USING echo(t2260b_real);
  64. SELECT * FROM t2260a, t2260b WHERE t2260a.a = t2260b.a AND t2260a.a > 101;
  65. }
  66. } {}
  67. unset -nocomplain echo_module_begin_fail
  68. finish_test