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. The
12 # focus of this file is syntax errors involving row-values and
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 set ::testprefix rowvalue5
25 proc vtab_command {method args} {
28 return "CREATE TABLE t1(a, b, c, d, expr)"
49 set clist [lindex $args 0]
57 lappend elist "$COL($C(column)) $OP($C(op)) %$i%"
62 lappend ret idxstr [join $elist " AND "]
63 #puts "xBestIndex: $ret"
68 foreach {idxnum idxstr arglist} $args {}
72 if {[string is double $a]==0} {
73 set a "'[string map {' ''} $a]'"
75 set ee [string map [list "%$i%" $a] $ee]
78 set ee [string map [list "'" "''"] $ee]
80 set ret [list sql "SELECT 1, 'a', 'b', 'c', 'd', '$ee'"]
89 register_tcl_module db
91 CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
95 foreach {tn where res} {
98 3 "a=1 AND 4 = b" {{a = 1 AND b = 4}}
99 4 "c>'hello'" {{c > 'hello'}}
100 5 "c<='hel''lo'" {{c <= 'hel''lo'}}
101 6 "(a, b) = (SELECT 9, 10)" {{a = 9 AND b = 10}}
102 7 "(+a, b) = (SELECT 'a', 'b')" {{b = 'b'}}
103 8 "(a, +b) = (SELECT 'a', 'b')" {{a = 'a'}}
104 11 "(+a, b) IN (SELECT 'a', 'b')" {{b = 'b'}}
105 12 "(a, +b) IN (SELECT 'a', 'b')" {{a = 'a'}}
107 13 "(a, b) < ('d', 'e')" {{a <= 'd'}}
108 14 "(a, b) < ('a', 'c')" {{a <= 'a'}}
109 15 "(a, b) <= ('a', 'b')" {{a <= 'a'}}
110 16 "(a, b) < ('a', 'b')" {}
112 do_execsql_test 1.$tn "SELECT expr FROM x1 WHERE $where" $res