os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/vtab9.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# 2006 August 29
sl@0
     2
#
sl@0
     3
# The author disclaims copyright to this source code.  In place of
sl@0
     4
# a legal notice, here is a blessing:
sl@0
     5
#
sl@0
     6
#    May you do good and not evil.
sl@0
     7
#    May you find forgiveness for yourself and forgive others.
sl@0
     8
#    May you share freely, never taking more than you give.
sl@0
     9
#
sl@0
    10
#***********************************************************************
sl@0
    11
# This file implements regression tests for SQLite library.  The
sl@0
    12
# focus of this file inserting into virtual tables from a SELECT
sl@0
    13
# statement.
sl@0
    14
#
sl@0
    15
# $Id: vtab9.test,v 1.2 2007/04/16 15:06:26 danielk1977 Exp $
sl@0
    16
sl@0
    17
set testdir [file dirname $argv0]
sl@0
    18
source $testdir/tester.tcl
sl@0
    19
sl@0
    20
ifcapable !vtab {
sl@0
    21
  finish_test
sl@0
    22
  return
sl@0
    23
}
sl@0
    24
sl@0
    25
do_test vtab9-1.1 {
sl@0
    26
  register_echo_module [sqlite3_connection_pointer db]
sl@0
    27
  execsql {
sl@0
    28
    CREATE TABLE t0(a);
sl@0
    29
    CREATE VIRTUAL TABLE t1 USING echo(t0);
sl@0
    30
    INSERT INTO t1 SELECT 'hello';
sl@0
    31
    SELECT rowid, * FROM t1;
sl@0
    32
  }
sl@0
    33
} {1 hello}
sl@0
    34
sl@0
    35
do_test vtab9-1.2 {
sl@0
    36
  execsql {
sl@0
    37
    CREATE TABLE t2(a,b,c);
sl@0
    38
    CREATE VIRTUAL TABLE t3 USING echo(t2);
sl@0
    39
    CREATE TABLE d1(a,b,c);
sl@0
    40
    INSERT INTO d1 VALUES(1,2,3);
sl@0
    41
    INSERT INTO d1 VALUES('a','b','c');
sl@0
    42
    INSERT INTO d1 VALUES(NULL,'x',123.456);
sl@0
    43
    INSERT INTO d1 VALUES(x'6869',123456789,-12345);
sl@0
    44
    INSERT INTO t3(a,b,c) SELECT * FROM d1;
sl@0
    45
    SELECT rowid, * FROM t3;
sl@0
    46
  }
sl@0
    47
} {1 1 2 3 2 a b c 3 {} x 123.456 4 hi 123456789 -12345}
sl@0
    48
sl@0
    49
# do_test vtab9-2.1 {
sl@0
    50
#   execsql {
sl@0
    51
#     CREATE TABLE t4(a);
sl@0
    52
#     CREATE VIRTUAL TABLE t5 USING echo(t4);
sl@0
    53
#     INSERT INTO t4 VALUES('hello');
sl@0
    54
#     SELECT rowid, a FROM t5;
sl@0
    55
#   }
sl@0
    56
# } {1 hello}
sl@0
    57
# do_test vtab9-2.2 {
sl@0
    58
#   execsql {
sl@0
    59
#     INSERT INTO t5(rowid, a) VALUES(1, 'goodbye');
sl@0
    60
#   }
sl@0
    61
# } {1 hello}
sl@0
    62
# do_test vtab9-2.3 {
sl@0
    63
#   execsql {
sl@0
    64
#     REPLACE INTO t5(rowid, a) VALUES(1, 'goodbye');
sl@0
    65
#     SELECT * FROM t5;
sl@0
    66
#   }
sl@0
    67
# } {1 goodbye}
sl@0
    68
sl@0
    69
unset -nocomplain echo_module_begin_fail
sl@0
    70
finish_test