interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / test / vtabL.test

75 lines · 1670 bytes Raw Blame History
1# 2024-03-26
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#
12
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15set testprefix vtabL
16
17ifcapable !vtab {
18 finish_test
19 return
20}
21
22register_tcl_module db
23
24proc vtab_command {method args} {
25 switch -- $method {
26 xConnect {
27 return $::create_table_sql
28 }
29 }
30
31 return {}
32}
33
34foreach {tn cts} {
35 1 {SELECT 123}
36 2 {SELECT 123, 456}
37 3 {INSERT INTO t1 VALUES(5, 6)}
38 4 {CREATE INDEX i1 ON t1(a)}
39 5 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END;}
40 6 {DROP TABLE nosuchtable}
41 7 {DROP TABLE x1}
42 8 {DROP TABLE t1}
43} {
44 set ::create_table_sql $cts
45 do_catchsql_test 1.$tn {
46 CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
47 } {1 {declare_vtab: syntax error}}
48}
49
50foreach {tn cts} {
51 9 {CREATE TABLE xyz AS SELECT * FROM sqlite_schema}
52 10 {CREATE TABLE xyz AS SELECT 1 AS 'col'}
53} {
54 set ::create_table_sql $cts
55 do_catchsql_test 1.$tn {
56 CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
57 } {1 {declare_vtab: SQL logic error}}
58}
59
60foreach {tn cts} {
61 1 {CREATE TABLE IF NOT EXISTS t1(a, b)}
62 2 {CREATE TABLE ""(a, b PRIMARY KEY) WITHOUT ROWID}
63} {
64 set ::create_table_sql $cts
65 execsql { DROP TABLE IF EXISTS x1 }
66 do_execsql_test 2.$tn.1 {
67 CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
68 }
69 do_execsql_test 2.$tn.2 {
70 SELECT a, b FROM x1
71 }
72}
73
74finish_test
75