Update the Makefile for LSM1 so that the LSMOPTS can be set prior to
[sqlite.git] / test / csv01.test
blob8151c477146664d8ac6c07e6241c5facb7a95c1e
1 # 2016-06-02
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
12 # Test cases for CSV virtual table.
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 set testprefix csv01
18 ifcapable !vtab||!cte { finish_test ; return }
20 load_static_extension db csv
22 do_execsql_test 1.0 {
23   CREATE VIRTUAL TABLE temp.t1 USING csv(
24     data=
25 '1,2,3,4
26 5,6,7,8
27 9,10,11,12
28 13,14,15,16
30     columns=4
31   );
32   SELECT * FROM t1 WHERE c1=10;
33 } {9 10 11 12}
34 do_execsql_test 1.1 {
35   SELECT * FROM t1 WHERE c1='10';
36 } {9 10 11 12}
37 do_execsql_test 1.2 {
38   SELECT rowid FROM t1;
39 } {1 2 3 4}
41 do_execsql_test 2.0 {
42   DROP TABLE t1;
43   CREATE VIRTUAL TABLE temp.t2 USING csv(
44     data=
45 '1,2,3,4
46 5,6,7,8
47 9,10,11,12
48 13,14,15,16
50     columns=4,
51     schema='CREATE TABLE t2(a INT, b TEXT, c REAL, d BLOB)'
52   );
53   SELECT * FROM t2 WHERE a=9;
54 } {9 10 11 12}
55 do_execsql_test 2.1 {
56   SELECT * FROM t2 WHERE b=10;
57 } {9 10 11 12}
58 do_execsql_test 2.2 {
59   SELECT * FROM t2 WHERE c=11;
60 } {9 10 11 12}
61 do_execsql_test 2.3 {
62   SELECT * FROM t2 WHERE d=12;
63 } {}
64 do_execsql_test 2.4 {
65   SELECT * FROM t2 WHERE d='12';
66 } {9 10 11 12}
67 do_execsql_test 2.5 {
68   SELECT * FROM t2 WHERE a='9';
69 } {9 10 11 12}
71 do_execsql_test 3.0 {
72   DROP TABLE t2;
73   CREATE VIRTUAL TABLE temp.t3 USING csv(
74     data=
75 '1,2,3,4
76 5,6,7,8
77 9,10,11,12
78 13,14,15,16
80     columns=4,
81     schema=
82       'CREATE TABLE t3(a PRIMARY KEY,b TEXT,c TEXT,d TEXT) WITHOUT ROWID',
83     testflags=1
84   );
85   SELECT a FROM t3 WHERE b=6 OR c=7 OR d=12 ORDER BY +a;
86 } {5 9}
87 do_execsql_test 3.1 {
88   SELECT a FROM t3 WHERE +b=6 OR c=7 OR d=12 ORDER BY +a;
89 } {5 9}
91 # The rowid column is not visible on a WITHOUT ROWID virtual table
92 do_catchsql_test 3.2 {
93   SELECT rowid, a FROM t3;
94 } {1 {no such column: rowid}}
96 do_catchsql_test 4.0 {
97   DROP TABLE t3;
98   CREATE VIRTUAL TABLE temp.t4 USING csv_wr(
99     data=
100 '1,2,3,4
101 5,6,7,8
102 9,10,11,12
103 13,14,15,16
105     columns=4,
106     schema=
107       'CREATE TABLE t3(a PRIMARY KEY,b TEXT,c TEXT,d TEXT) WITHOUT ROWID',
108     testflags=1
109   );
110 } {1 {vtable constructor failed: t4}}
112 finish_test