3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
18 ifcapable !vtab||!schema_pragmas {
23 register_schema_module [sqlite3_connection_pointer db]
26 CREATE VIRTUAL TABLE schema USING schema;
30 main schema 0 database {} 0 {} 0 \
31 main schema 1 tablename {} 0 {} 0 \
32 main schema 2 cid {} 0 {} 0 \
33 main schema 3 name {} 0 {} 0 \
34 main schema 4 type {} 0 {} 0 \
35 main schema 5 not_null {} 0 {} 0 \
36 main schema 6 dflt_value {} 0 {} 0 \
37 main schema 7 pk {} 0 {} 0 \
44 SELECT length(tablename) FROM schema GROUP by tablename;
49 SELECT tablename FROM schema GROUP by length(tablename);
54 SELECT length(tablename) FROM schema GROUP by length(tablename);
58 register_tclvar_module [sqlite3_connection_pointer db]
62 CREATE VIRTUAL TABLE vars USING tclvar;
63 SELECT name, arrayname, value FROM vars WHERE name='abc';
71 SELECT name, arrayname, value FROM vars WHERE name='A';
73 } [list A 1 1 A 2 4 A 3 9]
74 unset -nocomplain result
77 foreach var [lsort [info vars tcl_*]] {
78 catch {lappend result $var [set $var]}
82 SELECT name, value FROM vars
83 WHERE name MATCH 'tcl_*' AND arrayname = ''
92 # Make sure we do call Column(), and Rowid() methods of
93 # a virtual table when that table is in a LEFT JOIN.
97 SELECT * FROM schema WHERE dflt_value IS NULL LIMIT 1
99 } {main schema 0 database {} 0 {} 0}
103 FROM schema a LEFT JOIN schema b ON a.dflt_value=b.dflt_value
106 } {main schema 0 database {} 0 {} 0 {} {} {} {} {} {} {} {} {}}
110 FROM schema a LEFT JOIN schema b ON a.dflt_value IS b.dflt_value
111 AND a.dflt_value IS NOT NULL
114 } {main schema 0 database {} 0 {} 0 {} {} {} {} {} {} {} {} {}}
119 CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));
124 INSERT INTO "fkey" VALUES('t1',NULL);
129 execsql { CREATE VIRTUAL TABLE v_col USING schema }
132 execsql { SELECT name FROM v_col WHERE tablename = 't1' AND pk }
137 SET to_col = (SELECT name FROM v_col WHERE tablename = 't1' AND pk);
141 execsql { SELECT * FROM fkey }
144 #-------------------------------------------------------------------------
148 do_execsql_test 5.1 {
149 PRAGMA encoding='UTF16';
153 sqlite3_exec_hex db { CREATE VIRTUAL TABLE %C8 USING fts3 }
157 sqlite3_exec_hex db { CREATE VIRTUAL TABLE %C9 USING s }
158 } {/1 {malformed database schema.* already exists}/}