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 focus
12 # of this file is testing the interaction of SQLite manifest types
13 # with Tcl dual-representations.
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
19 # A variable with only a string representation comes in as TEXT
23 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
26 # A variable with an integer representation comes in as INTEGER
28 set V [expr {int(1+2)}]
29 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
31 set V [expr {1+12345678012345}]
32 if {[tcl_variable_type V]=="wideInt"} {
34 set V [expr {1+123456789012345}]
35 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
39 set V [expr {1+123456789012345}]
40 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
44 # A double variable comes in as REAL
47 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
50 # A byte-array variable comes in a BLOB if it has no string representation
51 # or as TEXT if there is a string representation.
54 set V [binary format a3 abc]
55 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
60 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
63 # Check to make sure return values are of the right types.
67 set V [db one {SELECT x'616263'}]
72 set V [db one {SELECT 123}]
75 set Vx [expr {1+wide(123456789123456)}]
77 set V [db one {SELECT 1234567890123456}]
79 } [tcl_variable_type Vx]
80 do_test types3-2.4.1 {
81 set V [db one {SELECT 1234567890123456.1}]
84 do_test types3-2.4.2 {
85 set V [db one {SELECT 1234567890123.456}]
89 set V [db one {SELECT '1234567890123456.0'}]
93 set V [db one {SELECT NULL}]
97 # See https://sqlite.org/forum/forumpost/3776b48e71
99 # On a text-affinity comparison of two values where one of
100 # the values has both MEM_Str and a numeric type like MEM_Int,
101 # make sure that only the MEM_Str representation is used.
103 sqlite3_create_function db
104 do_execsql_test types3-3.1 {
105 DROP TABLE IF EXISTS t1;
106 CREATE TABLE t1(x TEXT PRIMARY KEY);
107 INSERT INTO t1 VALUES('1');
108 SELECT * FROM t1 WHERE NOT x=upper(1);
110 do_execsql_test types3-3.2 {
111 SELECT * FROM t1 WHERE NOT x=add_text_type(1);
113 do_execsql_test types3-3.3 {
114 SELECT * FROM t1 WHERE NOT x=add_int_type('1');
116 do_execsql_test types3-3.4 {
118 INSERT INTO t1 VALUES(1.25);
119 SELECT * FROM t1 WHERE NOT x=add_real_type('1.25');
121 do_execsql_test types3-3.5 {
122 SELECT * FROM t1 WHERE NOT x=add_text_type(1.25);