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