Merge experimental into trunk: Refactor the text-to-numeric conversion
routines to work without zero-terminators and in UTF16 as well as UTF8. Avoid invalidating strings with doing affinity conversions. FossilOrigin-Name: 07ee080ec4527fd2191f41231208da66b3f6b955
This commit is contained in:
+1
-1
@@ -84,7 +84,7 @@ for {set i 0} {$i<1000} {incr i} {
|
||||
datetest 2.3 {date('2003-10-22','weekday 0')} 2003-10-26
|
||||
datetest 2.4 {date('2003-10-22','weekday 1')} 2003-10-27
|
||||
datetest 2.4a {date('2003-10-22','weekday 1')} 2003-10-27
|
||||
datetest 2.4b {date('2003-10-22','weekday 1x')} 2003-10-27
|
||||
datetest 2.4b {date('2003-10-22','weekday 1x')} NULL
|
||||
datetest 2.4c {date('2003-10-22','weekday -1')} NULL
|
||||
datetest 2.4d {date('2003-10-22','weakday 1x')} NULL
|
||||
datetest 2.4e {date('2003-10-22','weekday ')} NULL
|
||||
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
# 2010 Sept 29
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library. The focus of
|
||||
# this file is testing the SQLite routines used for converting between the
|
||||
# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
|
||||
# UTF-16be).
|
||||
#
|
||||
# $Id: enc4.test,v 1.0 2010/09/29 08:29:32 shaneh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If UTF16 support is disabled, ignore the tests in this file
|
||||
#
|
||||
ifcapable {!utf16} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
db close
|
||||
|
||||
# The three unicode encodings understood by SQLite.
|
||||
set encodings [list UTF-8 UTF-16le UTF-16be]
|
||||
|
||||
# initial value to use in SELECT
|
||||
set inits [list 1 1.0 1. 1e0]
|
||||
|
||||
# vals
|
||||
set vals [list\
|
||||
"922337203685477580792233720368547758079223372036854775807"\
|
||||
"100000000000000000000000000000000000000000000000000000000"\
|
||||
"1.0000000000000000000000000000000000000000000000000000000"\
|
||||
]
|
||||
|
||||
set i 1
|
||||
foreach enc $encodings {
|
||||
|
||||
file delete -force test.db
|
||||
sqlite3 db test.db
|
||||
db eval "PRAGMA encoding = \"$enc\""
|
||||
|
||||
do_test enc4-$i.1 {
|
||||
db eval {PRAGMA encoding}
|
||||
} $enc
|
||||
|
||||
set j 1
|
||||
foreach init $inits {
|
||||
|
||||
do_test enc4-$i.$j.2 {
|
||||
set S [sqlite3_prepare_v2 db "SELECT $init+?" -1 dummy]
|
||||
sqlite3_expired $S
|
||||
} {0}
|
||||
|
||||
set k 1
|
||||
foreach val $vals {
|
||||
for {set x 1} {$x<18} {incr x} {
|
||||
set part [expr $init + [string range $val 0 [expr $x-1]]]
|
||||
regsub {e\+0} $part {e+} part
|
||||
regsub {^1e} $part {1.0e} part
|
||||
|
||||
do_test enc4-$i.$j.$k.3.$x {
|
||||
sqlite3_reset $S
|
||||
sqlite3_bind_text $S 1 $val $x
|
||||
sqlite3_step $S
|
||||
sqlite3_column_text $S 0
|
||||
} [list $part]
|
||||
|
||||
do_test enc4-$i.$j.$k.4.$x {
|
||||
sqlite3_reset $S
|
||||
sqlite3_bind_text16 $S 1 [encoding convertto unicode $val] [expr $x*2]
|
||||
sqlite3_step $S
|
||||
sqlite3_column_text $S 0
|
||||
} [list $part]
|
||||
}
|
||||
|
||||
incr k
|
||||
}
|
||||
|
||||
do_test enc4-$i.$j.5 {
|
||||
sqlite3_finalize $S
|
||||
} {SQLITE_OK}
|
||||
|
||||
incr j
|
||||
}
|
||||
|
||||
db close
|
||||
incr i
|
||||
}
|
||||
|
||||
file delete -force test.db
|
||||
sqlite3 db test.db
|
||||
|
||||
do_test enc4-4.1 {
|
||||
db eval "select 1+1."
|
||||
} {2.0}
|
||||
|
||||
do_test enc4-4.2.1 {
|
||||
set S [sqlite3_prepare_v2 db "SELECT 1+1." -1 dummy]
|
||||
sqlite3_step $S
|
||||
sqlite3_column_text $S 0
|
||||
} {2.0}
|
||||
|
||||
do_test enc4-4.2.2 {
|
||||
sqlite3_finalize $S
|
||||
} {SQLITE_OK}
|
||||
|
||||
do_test enc4-4.3.1 {
|
||||
set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
|
||||
sqlite3_bind_text $S 1 "1." 2
|
||||
sqlite3_step $S
|
||||
sqlite3_column_text $S 0
|
||||
} {2.0}
|
||||
|
||||
do_test enc4-4.3.2 {
|
||||
sqlite3_finalize $S
|
||||
} {SQLITE_OK}
|
||||
|
||||
do_test enc4-4.4.1 {
|
||||
set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
|
||||
sqlite3_bind_text $S 1 "1.0" 2
|
||||
sqlite3_step $S
|
||||
sqlite3_column_text $S 0
|
||||
} {2.0}
|
||||
|
||||
do_test enc4-4.4.2 {
|
||||
sqlite3_finalize $S
|
||||
} {SQLITE_OK}
|
||||
|
||||
db close
|
||||
|
||||
finish_test
|
||||
+1
-1
@@ -290,7 +290,7 @@ ifcapable floatingpoint {
|
||||
test_expr expr-4.14 {r1='abc', r2='Bbc'} {r1>r2} 1
|
||||
test_expr expr-4.15 {r1='0', r2='0.0'} {r1==r2} 1
|
||||
test_expr expr-4.16 {r1='0.000', r2='0.0'} {r1==r2} 1
|
||||
test_expr expr-4.17 {r1=' 0.000', r2=' 0.0'} {r1==r2} 0
|
||||
test_expr expr-4.17 {r1=' 0.000', r2=' 0.0'} {r1==r2} 1
|
||||
test_expr expr-4.18 {r1='0.0', r2='abc'} {r1<r2} 1
|
||||
test_expr expr-4.19 {r1='0.0', r2='abc'} {r1==r2} 0
|
||||
test_expr expr-4.20 {r1='0.0', r2='abc'} {r1>r2} 0
|
||||
|
||||
+12
-3
@@ -532,10 +532,19 @@ do_test index-15.2 {
|
||||
INSERT INTO t1 VALUES('+',9);
|
||||
INSERT INTO t1 VALUES('+12347.E+02',10);
|
||||
INSERT INTO t1 VALUES('+12347E+02',11);
|
||||
SELECT b FROM t1 ORDER BY a;
|
||||
INSERT INTO t1 VALUES('+.125E+04',12);
|
||||
INSERT INTO t1 VALUES('-.125E+04',13);
|
||||
INSERT INTO t1 VALUES('.125E+0',14);
|
||||
INSERT INTO t1 VALUES('.125',15);
|
||||
SELECT b FROM t1 ORDER BY a, b;
|
||||
}
|
||||
} {8 5 2 1 3 6 11 9 10 4 7}
|
||||
integrity_check index-15.1
|
||||
} {13 14 15 12 8 5 2 1 3 6 10 11 9 4 7}
|
||||
do_test index-15.3 {
|
||||
execsql {
|
||||
SELECT b FROM t1 WHERE typeof(a) IN ('integer','real') ORDER BY b;
|
||||
}
|
||||
} {1 2 3 5 6 8 10 11 12 13 14 15}
|
||||
integrity_check index-15.4
|
||||
|
||||
# The following tests - index-16.* - test that when a table definition
|
||||
# includes qualifications that specify the same constraint twice only a
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# 2010 September 30
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# This file implements regression tests for SQLite library. Specifically,
|
||||
# it tests that ticket [3998683a16a7076e08f5585c1f4816414c8c653a] where in
|
||||
# floating point values with a decimal point at the beginning or end
|
||||
# of the mantissa are used.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
do_test tkt-3998683a16.1 {
|
||||
db eval {
|
||||
CREATE TABLE t1(x, y REAL);
|
||||
INSERT INTO t1 VALUES(1, '1.0');
|
||||
INSERT INTO t1 VALUES(2, '.125');
|
||||
INSERT INTO t1 VALUES(3, '123.');
|
||||
INSERT INTO t1 VALUES(4, '123.e+2');
|
||||
INSERT INTO t1 VALUES(5, '.125e+3');
|
||||
INSERT INTO t1 VALUES(6, '123e4');
|
||||
INSERT INTO t1 VALUES(11, ' 1.0');
|
||||
INSERT INTO t1 VALUES(12, ' .125');
|
||||
INSERT INTO t1 VALUES(13, ' 123.');
|
||||
INSERT INTO t1 VALUES(14, ' 123.e+2');
|
||||
INSERT INTO t1 VALUES(15, ' .125e+3');
|
||||
INSERT INTO t1 VALUES(16, ' 123e4');
|
||||
INSERT INTO t1 VALUES(21, '1.0 ');
|
||||
INSERT INTO t1 VALUES(22, '.125 ');
|
||||
INSERT INTO t1 VALUES(23, '123. ');
|
||||
INSERT INTO t1 VALUES(24, '123.e+2 ');
|
||||
INSERT INTO t1 VALUES(25, '.125e+3 ');
|
||||
INSERT INTO t1 VALUES(26, '123e4 ');
|
||||
SELECT x FROM t1 WHERE typeof(y)=='real' ORDER BY x;
|
||||
}
|
||||
} {1 2 3 4 5 6 11 12 13 14 15 16 21 22 23 24 25 26}
|
||||
|
||||
finish_test
|
||||
@@ -0,0 +1,67 @@
|
||||
# 2010 September 30
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# This file implements regression tests for SQLite library. Specifically,
|
||||
# it tests that ticket [8454a207b9fd2243c4c6b7a73f67ea0315717c1a]. Verify
|
||||
# that a negative default value on an added text column actually comes
|
||||
# out negative.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
do_test tkt-8454a207b9.1 {
|
||||
db eval {
|
||||
CREATE TABLE t1(a);
|
||||
INSERT INTO t1 VALUES(1);
|
||||
ALTER TABLE t1 ADD COLUMN b TEXT DEFAULT -123.0;
|
||||
SELECT b, typeof(b) FROM t1;
|
||||
}
|
||||
} {-123.0 text}
|
||||
do_test tkt-8454a207b9.2 {
|
||||
db eval {
|
||||
ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT -123.5;
|
||||
SELECT c, typeof(c) FROM t1;
|
||||
}
|
||||
} {-123.5 text}
|
||||
do_test tkt-8454a207b9.3 {
|
||||
db eval {
|
||||
ALTER TABLE t1 ADD COLUMN d TEXT DEFAULT -'hello';
|
||||
SELECT d, typeof(d) FROM t1;
|
||||
}
|
||||
} {0 text}
|
||||
do_test tkt-8454a207b9.4 {
|
||||
db eval {
|
||||
ALTER TABLE t1 ADD COLUMN e DEFAULT -123.0;
|
||||
SELECT e, typeof(e) FROM t1;
|
||||
}
|
||||
} {-123 integer}
|
||||
do_test tkt-8454a207b9.5 {
|
||||
db eval {
|
||||
ALTER TABLE t1 ADD COLUMN f DEFAULT -123.5;
|
||||
SELECT f, typeof(f) FROM t1;
|
||||
}
|
||||
} {-123.5 real}
|
||||
do_test tkt-8454a207b9.6 {
|
||||
db eval {
|
||||
ALTER TABLE t1 ADD COLUMN g DEFAULT -9223372036854775808;
|
||||
SELECT g, typeof(g) FROM t1;
|
||||
}
|
||||
} {-9223372036854775808 integer}
|
||||
do_test tkt-8454a207b9.7 {
|
||||
db eval {
|
||||
ALTER TABLE t1 ADD COLUMN h DEFAULT 9223372036854775807;
|
||||
SELECT h, typeof(h) FROM t1;
|
||||
}
|
||||
} {9223372036854775807 integer}
|
||||
|
||||
|
||||
finish_test
|
||||
Reference in New Issue
Block a user