AryaWu/sqlite
0
1# 2015-11-052#3# The author disclaims copyright to this source code. In place of4# 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 tests for indexes on large numeric values.12#13 14set testdir [file dirname $argv0]15source $testdir/tester.tcl16 17 18# Test cases from Zsbán Ambrus:19#20do_execsql_test numindex1-1.1 {21 CREATE TABLE t1(a INTEGER PRIMARY KEY, b);22 CREATE INDEX t1b ON t1(b);23 INSERT INTO t1(a,b) VALUES(100, 356282677878746339);24 INSERT INTO t1(a,b) VALUES(50, 356282677878746339.0);25 INSERT INTO t1(a,b) VALUES(0, 356282677878746340);26 DELETE FROM t1 WHERE a=50;27 PRAGMA integrity_check;28} {ok}29 30do_execsql_test numindex1-1.2 {31 CREATE TABLE t2(a,b);32 INSERT INTO t2(a,b) VALUES('b', 1<<58),33 ('c', (1<<58)+1e-7), ('d', (1<<58)+1);34 SELECT a, b, typeof(b), '|' FROM t2 ORDER BY +a;35} {b 288230376151711744 integer | c 2.88230376151712e+17 real | d 288230376151711745 integer |}36 37do_execsql_test numindex1-1.3 {38 SELECT x.a || CASE WHEN x.b==y.b THEN '==' ELSE '<>' END || y.a39 FROM t2 AS x, t2 AS y40 ORDER BY +x.a, +x.b;41} {b==b b==c b<>d c==b c==c c<>d d<>b d<>c d==d}42 43# New test cases44#45do_execsql_test numindex1-2.1 {46 DROP TABLE IF EXISTS t1;47 CREATE TABLE t1(a INTEGER PRIMARY KEY,b);48 CREATE INDEX t1b ON t1(b);49 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)50 INSERT INTO t1(a,b) SELECT x, 10000000000000004.0 FROM c51 WHERE x NOT IN (23,37);52 INSERT INTO t1(a,b) VALUES(23,10000000000000005);53 INSERT INTO t1(a,b) VALUES(37,10000000000000003);54 DELETE FROM t1 WHERE a NOT IN (23,37);55 PRAGMA integrity_check;56} {ok}57 58do_execsql_test numindex1-3.1 {59 DROP TABLE IF EXISTS t1;60 CREATE TABLE t1(a INTEGER PRIMARY KEY,b);61 CREATE INDEX t1b ON t1(b);62 WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<20)63 INSERT INTO t1(a,b) SELECT x, 100000000000000005.064 FROM c WHERE x NOT IN (3,5,7,11,13,17,19);65 INSERT INTO t1(a,b) VALUES(3,100000000000000005);66 INSERT INTO t1(a,b) VALUES(5,100000000000000000);67 INSERT INTO t1(a,b) VALUES(7,100000000000000008);68 INSERT INTO t1(a,b) VALUES(11,100000000000000006);69 INSERT INTO t1(a,b) VALUES(13,100000000000000001);70 INSERT INTO t1(a,b) VALUES(17,100000000000000004);71 INSERT INTO t1(a,b) VALUES(19,100000000000000003);72 PRAGMA integrity_check;73} {ok}74 75do_execsql_test numindex1-3.2 {76 SELECT a FROM t1 ORDER BY b;77} {1 2 4 5 6 8 9 10 12 14 15 16 18 20 13 19 17 3 11 7}78 79finish_test80 