xref: /sqlite-3.40.0/test/vtab9.test (revision 16ed8a64)
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.1 2006/08/29 18:46:14 drh Exp $
16
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
20ifcapable !vtab {
21  finish_test
22  return
23}
24
25do_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
35do_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
49unset -nocomplain echo_module_begin_fail
50finish_test
51