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 hdl [lindex $args 0]
50 set clist [$hdl constraints]
59 lappend elist "$COL($C(column)) $OP($C(op)) %$i%"
64 lappend ret idxstr [join $elist " AND "]
65 #puts "xBestIndex: $ret"
70 foreach {idxnum idxstr arglist} $args {}
74 if {[string is double $a]==0} {
75 set a "'[string map {' ''} $a]'"
77 set ee [string map [list "%$i%" $a] $ee]
80 set ee [string map [list "'" "''"] $ee]
82 set ret [list sql "SELECT 1, 'a', 'b', 'c', 'd', '$ee'"]
91 register_tcl_module db
93 CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
97 foreach {tn where res} {
100 3 "a=1 AND 4 = b" {{a = 1 AND b = 4}}
101 4 "c>'hello'" {{c > 'hello'}}
102 5 "c<='hel''lo'" {{c <= 'hel''lo'}}
103 6 "(a, b) = (SELECT 9, 10)" {{a = 9 AND b = 10}}
104 7 "(+a, b) = (SELECT 'a', 'b')" {{b = 'b'}}
105 8 "(a, +b) = (SELECT 'a', 'b')" {{a = 'a'}}
106 11 "(+a, b) IN (SELECT 'a', 'b')" {{b = 'b'}}
107 12 "(a, +b) IN (SELECT 'a', 'b')" {{a = 'a'}}
109 13 "(a, b) < ('d', 'e')" {{a <= 'd'}}
110 14 "(a, b) < ('a', 'c')" {{a <= 'a'}}
111 15 "(a, b) <= ('a', 'b')" {{a <= 'a'}}
112 16 "(a, b) < ('a', 'b')" {}
114 do_execsql_test 1.$tn "SELECT expr FROM x1 WHERE $where" $res