/ Check-in [ea03e219]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add rowvalue5.test, which should have been part of the previous commit on this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rowvalue
Files: files | file ages | folders
SHA1:ea03e219ced87777f0c3c6bbb0274078dbb829e2
User & Date: dan 2016-08-09 05:48:40
Context
2016-08-11
12:01
Fix some problems with handling "no such collation sequence" errors. check-in: 8278be06 user: dan tags: rowvalue
2016-08-09
05:48
Add rowvalue5.test, which should have been part of the previous commit on this branch. check-in: ea03e219 user: dan tags: rowvalue
2016-08-08
20:15
Fix some cases involving row values and virtual tables. check-in: 156a41f3 user: dan tags: rowvalue
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/rowvalue5.test.

            1  +# 2016 July 29
            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  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this file is syntax errors involving row-values and
           13  +# virtual tables.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +set ::testprefix rowvalue5
           19  +
           20  +proc vtab_command {method args} {
           21  +  switch -- $method {
           22  +    xConnect {
           23  +      return "CREATE TABLE t1(a, b, c, d, expr)"
           24  +    }
           25  +
           26  +    xBestIndex {
           27  +      set COL(0) a
           28  +      set COL(1) b
           29  +      set COL(2) c
           30  +      set COL(3) d
           31  +      set COL(4) expr
           32  +
           33  +      set OP(eq) =
           34  +      set OP(ne) !=
           35  +      set OP(gt) >
           36  +      set OP(le) <=
           37  +      set OP(lt) <
           38  +      set OP(ge) >=
           39  +      set OP(match) MATCH
           40  +      set OP(like) LIKE
           41  +      set OP(glob) GLOB
           42  +      set OP(regexp) REGEXP
           43  +
           44  +      set clist [lindex $args 0]
           45  +      set ret [list]
           46  +      set elist [list]
           47  +      set i 0
           48  +      foreach c $clist {
           49  +        array set C $c
           50  +        if {$C(usable)} {
           51  +          lappend ret omit $i
           52  +          lappend elist "$COL($C(column)) $OP($C(op)) %$i%"
           53  +        }
           54  +        incr i
           55  +      }
           56  +
           57  +      lappend ret idxstr [join $elist " AND "]
           58  +      #puts "xBestIndex: $ret"
           59  +      return $ret
           60  +    }
           61  +
           62  +    xFilter {
           63  +      foreach {idxnum idxstr arglist} $args {}
           64  +      set i 0
           65  +      set ee $idxstr
           66  +      foreach a $arglist {
           67  +        if {[string is double $a]==0} {
           68  +          set a "'[string map {' ''} $a]'"
           69  +        }
           70  +        set ee [string map [list "%$i%" $a] $ee]
           71  +        incr i
           72  +      }
           73  +      set ee [string map [list "'" "''"] $ee]
           74  +
           75  +      set ret [list sql "SELECT 1, 'a', 'b', 'c', 'd', '$ee'"]
           76  +      #puts "xFilter: $ret"
           77  +      return $ret
           78  +    }
           79  +  }
           80  +
           81  +  return {}
           82  +}
           83  +
           84  +register_tcl_module db
           85  +do_execsql_test 1.0 {
           86  +  CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
           87  +} {}
           88  +
           89  +
           90  +foreach {tn where res} {
           91  +  1 "1"                              {{}}
           92  +  2 "a=1"                            {{a = 1}}
           93  +  3 "a=1 AND 4 = b"                  {{a = 1 AND b = 4}}
           94  +  4 "c>'hello'"                      {{c > 'hello'}}
           95  +  5 "c<='hel''lo'"                   {{c <= 'hel''lo'}}
           96  +  6 "(a, b) = (SELECT 9, 10)"        {{a = 9 AND b = 10}}
           97  +  7 "(+a, b) = (SELECT 'a', 'b')"    {{b = 'b'}}
           98  +  8 "(a, +b) = (SELECT 'a', 'b')"    {{a = 'a'}}
           99  +  10 "(a, b) IN (SELECT 9, 10 UNION SELECT 11, 12)" 
          100  +      {{a = 9 AND b = 10} {a = 11 AND b = 12}}
          101  +  11 "(+a, b) IN (SELECT 'a', 'b')" {{b = 'b'}}
          102  +  12 "(a, +b) IN (SELECT 'a', 'b')" {{a = 'a'}}
          103  +
          104  +  13 "(a, b) < ('d', 'e')"  {{a <= 'd'}}
          105  +  14 "(a, b) < ('a', 'c')"  {{a <= 'a'}}
          106  +  15 "(a, b) <= ('a', 'b')" {{a <= 'a'}}
          107  +  16 "(a, b) < ('a', 'b')"  {}
          108  +} {
          109  +  do_execsql_test 1.$tn "SELECT expr FROM x1 WHERE $where" $res
          110  +}
          111  +
          112  +finish_test
          113  +