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 # Tests to exercise the MEM_IntReal representation of Mem objects.
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 set ::testprefix intreal
17 sqlite3_create_function db
22 SELECT intreal(5)=5, 6=intreal(6);
25 SELECT intreal(7)=7.0, 8.0=intreal(8);
28 SELECT typeof(intreal(9));
31 SELECT 'a'||intreal(11)||'z';
35 SELECT max(1.0,intreal(2),3.0), max(1,intreal(2),3);
38 SELECT max(1.0,intreal(4),3.0), max(1,intreal(4),3);
41 SELECT max(1.0,intreal(2),intreal(3),4.0),
42 max(1,intreal(2),intreal(3),4);
45 SELECT max(1.0,intreal(5),intreal(3),4.0),
46 max(1,intreal(5),intreal(3),4);
49 #-------------------------------------------------------------------------
51 CREATE TABLE t2(a REAL);
52 INSERT INTO t2 VALUES( 836627109860825358 );
53 SELECT substr(a,1,4) FROM t2 WHERE a = CAST(836627109860825358 AS REAL);
57 CREATE INDEX i2 ON t2(a);
58 SELECT substr(a,1,4) FROM t2 WHERE a = CAST(836627109860825358 AS REAL);
63 CREATE TABLE t1 (c1 REAL);
64 INSERT INTO t1(c1) VALUES (8366271098608253588);
65 INSERT INTO t0(c0) VALUES ('a');
67 set D [db one {SELECT c1 FROM t1}]
70 SELECT * FROM t1 WHERE (t1.c1 = CAST(8366271098608253588 AS REAL));
74 SELECT * FROM t0, t1 WHERE (t1.c1 = CAST(8366271098608253588 AS REAL));
80 t1.c1 >= CAST(8366271098608253588 AS REAL)
81 AND t1.c1 <= CAST(8366271098608253588 AS REAL)
85 # 2019-07-29 ticket ba2f4585cf495231
90 CREATE TABLE t0 (c0 REAL, c1);
91 CREATE UNIQUE INDEX i0 ON t0(c1, 0 | c0);
92 INSERT INTO t0(c0) VALUES (4750228396194493326), (0);
93 UPDATE OR REPLACE t0 SET c0 = 'a', c1 = '';
94 SELECT * FROM t0 ORDER BY t0.c1;
95 PRAGMA integrity_check;
100 do_execsql_test 4.0 {
101 CREATE TABLE t1(a REAL, b AS ('expr') );
103 do_execsql_test 4.1 {
104 INSERT INTO t1 VALUES( REPLACE(0, '', 'expr') );
106 do_execsql_test 4.2 {
107 INSERT INTO t1 SELECT REPLACE(4, '', 'expr');
109 do_execsql_test 4.3 {
110 SELECT typeof(a), a FROM t1;