vtab9.test 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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: vtab9.test,v 1.2 2007/04/16 15:06:26 danielk1977 Exp $
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. ifcapable !vtab {
  19. finish_test
  20. return
  21. }
  22. do_test vtab9-1.1 {
  23. register_echo_module [sqlite3_connection_pointer db]
  24. execsql {
  25. CREATE TABLE t0(a);
  26. CREATE VIRTUAL TABLE t1 USING echo(t0);
  27. INSERT INTO t1 SELECT 'hello';
  28. SELECT rowid, * FROM t1;
  29. }
  30. } {1 hello}
  31. do_test vtab9-1.2 {
  32. execsql {
  33. CREATE TABLE t2(a,b,c);
  34. CREATE VIRTUAL TABLE t3 USING echo(t2);
  35. CREATE TABLE d1(a,b,c);
  36. INSERT INTO d1 VALUES(1,2,3);
  37. INSERT INTO d1 VALUES('a','b','c');
  38. INSERT INTO d1 VALUES(NULL,'x',123.456);
  39. INSERT INTO d1 VALUES(x'6869',123456789,-12345);
  40. INSERT INTO t3(a,b,c) SELECT * FROM d1;
  41. SELECT rowid, * FROM t3;
  42. }
  43. } {1 1 2 3 2 a b c 3 {} x 123.456 4 hi 123456789 -12345}
  44. # do_test vtab9-2.1 {
  45. # execsql {
  46. # CREATE TABLE t4(a);
  47. # CREATE VIRTUAL TABLE t5 USING echo(t4);
  48. # INSERT INTO t4 VALUES('hello');
  49. # SELECT rowid, a FROM t5;
  50. # }
  51. # } {1 hello}
  52. # do_test vtab9-2.2 {
  53. # execsql {
  54. # INSERT INTO t5(rowid, a) VALUES(1, 'goodbye');
  55. # }
  56. # } {1 hello}
  57. # do_test vtab9-2.3 {
  58. # execsql {
  59. # REPLACE INTO t5(rowid, a) VALUES(1, 'goodbye');
  60. # SELECT * FROM t5;
  61. # }
  62. # } {1 goodbye}
  63. unset -nocomplain echo_module_begin_fail
  64. finish_test