mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Merge the latest trunk enhancements into the reuse-schema branch.
FossilOrigin-Name: 93f0febab4b1da711c2238aaff00b4eff276831b516990040e2957a6b91decdc
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
set mxpow [expr {[use_long_double]?100:35}]
|
||||
set mxpow 35
|
||||
expr srand(1)
|
||||
for {set i 1} {$i<20000} {incr i} {
|
||||
set pow [expr {int((rand()-0.5)*$mxpow)}]
|
||||
|
@@ -262,11 +262,9 @@ do_test cast-3.12 {
|
||||
do_realnum_test cast-3.13 {
|
||||
execsql {SELECT CAST('9223372036854774800' AS real)}
|
||||
} 9.22337203685477e+18
|
||||
ifcapable long_double {
|
||||
do_test cast-3.14 {
|
||||
execsql {SELECT CAST(CAST('9223372036854774800' AS real) AS integer)}
|
||||
} 9223372036854774784
|
||||
}
|
||||
do_test cast-3.14 {
|
||||
execsql {SELECT CAST(CAST('9223372036854774800' AS real) AS integer)}
|
||||
} 9223372036854774784
|
||||
do_test cast-3.15 {
|
||||
execsql {SELECT CAST('-9223372036854774800' AS integer)}
|
||||
} -9223372036854774800
|
||||
@@ -276,11 +274,9 @@ do_test cast-3.16 {
|
||||
do_realnum_test cast-3.17 {
|
||||
execsql {SELECT CAST('-9223372036854774800' AS real)}
|
||||
} -9.22337203685477e+18
|
||||
ifcapable long_double {
|
||||
do_test cast-3.18 {
|
||||
execsql {SELECT CAST(CAST('-9223372036854774800' AS real) AS integer)}
|
||||
} -9223372036854774784
|
||||
}
|
||||
do_test cast-3.18 {
|
||||
execsql {SELECT CAST(CAST('-9223372036854774800' AS real) AS integer)}
|
||||
} -9223372036854774784
|
||||
if {[db eval {PRAGMA encoding}]=="UTF-8"} {
|
||||
do_test cast-3.21 {
|
||||
execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS integer)}
|
||||
@@ -291,14 +287,12 @@ if {[db eval {PRAGMA encoding}]=="UTF-8"} {
|
||||
do_realnum_test cast-3.23 {
|
||||
execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS real)}
|
||||
} 9.22337203685477e+18
|
||||
ifcapable long_double {
|
||||
do_test cast-3.24 {
|
||||
execsql {
|
||||
SELECT CAST(CAST(x'39323233333732303336383534373734383030' AS real)
|
||||
AS integer)
|
||||
}
|
||||
} 9223372036854774784
|
||||
}
|
||||
do_test cast-3.24 {
|
||||
execsql {
|
||||
SELECT CAST(CAST(x'39323233333732303336383534373734383030' AS real)
|
||||
AS integer)
|
||||
}
|
||||
} 9223372036854774784
|
||||
}
|
||||
do_test cast-3.31 {
|
||||
execsql {SELECT CAST(NULL AS numeric)}
|
||||
|
@@ -276,4 +276,31 @@ do_catchsql_test 6.3 {
|
||||
UPDATE t1 SET x='hello world' WHERE rowid=1;
|
||||
} {1 {database disk image is malformed}}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
reset_db
|
||||
do_execsql_test 7.0 {
|
||||
BEGIN;
|
||||
CREATE TABLE p1(x PRIMARY KEY);
|
||||
CREATE TABLE c1(y);
|
||||
|
||||
PRAGMA schema_version = 0;
|
||||
PRAGMA writable_schema = RESET;
|
||||
|
||||
INSERT INTO c1 VALUES(1000);
|
||||
ROLLBACK;
|
||||
}
|
||||
|
||||
do_execsql_test 7.1 {
|
||||
PRAGMA table_info = p1;
|
||||
} {0 x {} 0 {} 1}
|
||||
|
||||
do_catchsql_test 7.2 {
|
||||
SELECT * FROM p1;
|
||||
} {1 {database disk image is malformed}}
|
||||
|
||||
do_catchsql_test 7.3 {
|
||||
PRAGMA integrity_check
|
||||
} {1 {database disk image is malformed}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
@@ -12,7 +12,6 @@
|
||||
**
|
||||
** time ./a.out 0 10000000 <-- standard library
|
||||
** time ./a.out 1 10000000 <-- SQLite
|
||||
** time ./a.out 2 10000000 <-- SQLite with long-double disabled
|
||||
*/
|
||||
static double aVal[] = {
|
||||
-1.0163830486285643089e+063,
|
||||
@@ -150,15 +149,6 @@ int main(int argc, char **argv){
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
printf("Doing %d calls to sqlite3_snprintf() without long double\n", cnt);
|
||||
sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, 0);
|
||||
for(i=0; i<cnt; i++){
|
||||
sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.26g", aVal[i%NN]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -261,9 +261,6 @@ ifcapable floatingpoint {
|
||||
catchsql {SELECT round(b,2.0) FROM t1 ORDER BY b}
|
||||
} {0 {-2.0 1.23 2.0}}
|
||||
# Verify some values reported on the mailing list.
|
||||
# Some of these fail on MSVC builds with 64-bit
|
||||
# long doubles, but not on GCC builds with 80-bit
|
||||
# long doubles.
|
||||
for {set i 1} {$i<999} {incr i} {
|
||||
set x1 [expr 40222.5 + $i]
|
||||
set x2 [expr 40223.0 + $i]
|
||||
|
@@ -37,7 +37,7 @@ set highPrecision(3) [expr \
|
||||
{[db eval {SELECT toreal(9007199254740992 + 1);}] eq {{}}}]
|
||||
|
||||
if {!$highPrecision(1) || !$highPrecision(2) || !$highPrecision(3)} {
|
||||
puts "NOTICE: use_long_double: [use_long_double] \
|
||||
puts "NOTICE:\
|
||||
highPrecision: $highPrecision(1) $highPrecision(2) $highPrecision(3)"
|
||||
}
|
||||
|
||||
|
83
test/indexexpr3.test
Normal file
83
test/indexexpr3.test
Normal file
@@ -0,0 +1,83 @@
|
||||
# 2024-10-05
|
||||
#
|
||||
# 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 indexes on expressions.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix indexexpr3
|
||||
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(a, j);
|
||||
INSERT INTO t1 VALUES(1, '{x:"one"}');
|
||||
INSERT INTO t1 VALUES(2, '{x:"two"}');
|
||||
INSERT INTO t1 VALUES(3, '{x:"three"}');
|
||||
|
||||
CREATE INDEX i1 ON t1( json_extract(j, '$.x') );
|
||||
CREATE INDEX i2 ON t1( a, json_extract(j, '$.x') );
|
||||
}
|
||||
|
||||
proc do_hasfunction_test {tn sql res} {
|
||||
set nFunction 0
|
||||
db eval "EXPLAIN $sql" x {
|
||||
if {$x(opcode)=="Function"} {
|
||||
incr nFunction
|
||||
}
|
||||
}
|
||||
|
||||
do_execsql_test $tn "
|
||||
SELECT $nFunction;
|
||||
$sql
|
||||
" $res
|
||||
}
|
||||
|
||||
do_hasfunction_test 1.1 {
|
||||
SELECT json_extract(j, '$.x') FROM t1 ORDER BY 1;
|
||||
} {
|
||||
0 one three two
|
||||
}
|
||||
|
||||
do_hasfunction_test 1.2 {
|
||||
SELECT json_extract(j, '$.x') FROM t1 WHERE a=2
|
||||
} {
|
||||
0 two
|
||||
}
|
||||
|
||||
do_hasfunction_test 1.3 {
|
||||
SELECT coalesce(json_extract(j, '$.x'), 'five') FROM t1 WHERE a=2
|
||||
} {
|
||||
0 two
|
||||
}
|
||||
|
||||
do_hasfunction_test 1.4 {
|
||||
SELECT json_extract(j, '$.x') || '.two' FROM t1 WHERE a=2
|
||||
} {
|
||||
0 two.two
|
||||
}
|
||||
|
||||
do_hasfunction_test 1.5 {
|
||||
SELECT json_insert( '{}', '$.y', json_extract(j, '$.x') ) FROM t1 WHERE a=2
|
||||
} {
|
||||
2 {{"y":"two"}}
|
||||
}
|
||||
|
||||
do_hasfunction_test 1.6 {
|
||||
SELECT json_insert( '{}', '$.y', coalesce( json_extract(j, '$.x'), 'five' ) )
|
||||
FROM t1 WHERE a=2
|
||||
} {
|
||||
2 {{"y":"two"}}
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
||||
|
@@ -731,16 +731,16 @@ ifcapable like_opt&&!icu {
|
||||
}
|
||||
do_test like-9.5.1 {
|
||||
set res [sqlite3_exec_hex db {
|
||||
SELECT x FROM t2 WHERE x LIKE '%fe%25'
|
||||
SELECT 1 FROM t2 WHERE x LIKE '%fe%25'
|
||||
}]
|
||||
} {0 {}}
|
||||
} {0 {1 1}}
|
||||
ifcapable explain {
|
||||
do_test like-9.5.2 {
|
||||
set res [sqlite3_exec_hex db {
|
||||
EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%fe%25'
|
||||
}]
|
||||
regexp {INDEX i2} $res
|
||||
} {1}
|
||||
} {0}
|
||||
}
|
||||
|
||||
# Do an SQL statement. Append the search count to the end of the result.
|
||||
|
@@ -146,6 +146,54 @@ do_test lock5-flock.8 {
|
||||
db2 close
|
||||
} {}
|
||||
|
||||
do_test lock5-flock.9 {
|
||||
sqlite3 db test.db -vfs unix-flock
|
||||
execsql {
|
||||
SELECT * FROM t1
|
||||
}
|
||||
} {1 2}
|
||||
|
||||
do_test lock5-flock.10 {
|
||||
sqlite3 db2 test.db -vfs unix-flock
|
||||
execsql {
|
||||
SELECT * FROM t1
|
||||
} db2
|
||||
} {1 2}
|
||||
|
||||
do_test lock5-flock.10 {
|
||||
execsql {
|
||||
PRAGMA cache_size = 1;
|
||||
BEGIN;
|
||||
WITH s(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000
|
||||
)
|
||||
INSERT INTO t1 SELECT i, i+1 FROM s;
|
||||
}
|
||||
|
||||
catchsql {
|
||||
SELECT * FROM t1
|
||||
} db2
|
||||
} {1 {database is locked}}
|
||||
|
||||
if {[permutation]!="inmemory_journal"} {
|
||||
do_test lock5-flock.11 {
|
||||
forcecopy test.db test.db2
|
||||
forcecopy test.db-journal test.db2-journal
|
||||
db2 close
|
||||
sqlite3 db2 test.db2 -vfs unix-flock
|
||||
catchsql {
|
||||
SELECT * FROM t1
|
||||
} db2
|
||||
} {0 {1 2}}
|
||||
|
||||
do_test lock5-flock.12 {
|
||||
file exists test.db2-journal
|
||||
} 0
|
||||
}
|
||||
|
||||
db close
|
||||
db2 close
|
||||
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
@@ -1063,7 +1063,10 @@ do_test shell1-5.0 {
|
||||
continue
|
||||
}
|
||||
# Tcl 8.7 maps 0x80 through 0x9f into valid UTF8. So skip those tests.
|
||||
if {$i>=0x80 && ($i<=0x9F || $tcl_version>=9.0)} continue
|
||||
if {$i>=0x80} {
|
||||
if {$i<=0x9F || $tcl_version>=9.0} continue
|
||||
if {$tcl_platform(platform)=="windows"} continue
|
||||
}
|
||||
if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue
|
||||
if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)=="Linux"} continue
|
||||
set hex [format %02X $i]
|
||||
|
@@ -96,4 +96,43 @@ do_test 1.8 {
|
||||
list [catch { sqlite3_snapshot_open_blob db3 main $snap } msg] $msg
|
||||
} {1 SQLITE_ERROR_SNAPSHOT}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
reset_db
|
||||
do_execsql_test 2.0 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(a, b);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
} {wal}
|
||||
|
||||
sqlite3 db2 test.db
|
||||
sqlite3 db3 test.db
|
||||
do_execsql_test -db db2 2.0.1 {
|
||||
SELECT * FROM t1
|
||||
} {1 2 3 4}
|
||||
do_execsql_test -db db3 2.0.2 {
|
||||
SELECT * FROM t1
|
||||
} {1 2 3 4}
|
||||
|
||||
do_execsql_test -db db2 2.2 {
|
||||
PRAGMA wal_checkpoint;
|
||||
} {0 4 4}
|
||||
|
||||
do_test 2.1 {
|
||||
db eval { BEGIN }
|
||||
set snap [sqlite3_snapshot_get db main]
|
||||
set {} {}
|
||||
} {}
|
||||
|
||||
do_execsql_test -db db2 2.3 {
|
||||
INSERT INTO t1 VALUES(5, 6);
|
||||
} {}
|
||||
|
||||
do_test 2.2 {
|
||||
execsql { BEGIN } db3
|
||||
sqlite3_snapshot_open db3 main $snap
|
||||
} {}
|
||||
|
||||
sqlite3_snapshot_free $snap
|
||||
|
||||
finish_test
|
||||
|
@@ -21,7 +21,6 @@ static const char zHelp[] =
|
||||
" --memdb Use an in-memory database\n"
|
||||
" --mmap SZ MMAP the first SZ bytes of the database file\n"
|
||||
" --multithread Set multithreaded mode\n"
|
||||
" --nolongdouble Disable the use of long double\n"
|
||||
" --nomemstat Disable memory statistics\n"
|
||||
" --nomutex Open db with SQLITE_OPEN_NOMUTEX\n"
|
||||
" --nosync Set PRAGMA synchronous=OFF\n"
|
||||
@@ -2352,10 +2351,6 @@ int main(int argc, char **argv){
|
||||
ARGC_VALUE_CHECK(1);
|
||||
mmapSize = integerValue(argv[++i]);
|
||||
#endif
|
||||
}else if( strcmp(z,"nolongdouble")==0 ){
|
||||
#ifdef SQLITE_TESTCTRL_USELONGDOUBLE
|
||||
sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, 0);
|
||||
#endif
|
||||
}else if( strcmp(z,"nomutex")==0 ){
|
||||
openFlags |= SQLITE_OPEN_NOMUTEX;
|
||||
}else if( strcmp(z,"nosync")==0 ){
|
||||
|
@@ -215,7 +215,6 @@ namespace eval trd {
|
||||
-DSQLITE_MAX_ATTACHED=125
|
||||
-DSQLITE_MAX_MMAP_SIZE=12884901888
|
||||
-DSQLITE_ENABLE_SORTER_MMAP=1
|
||||
-DLONGDOUBLE_TYPE=double
|
||||
--enable-session
|
||||
}
|
||||
set build(Device-One) {
|
||||
@@ -355,7 +354,6 @@ namespace eval trd {
|
||||
-DSQLITE_ENABLE_FTS4
|
||||
-DSQLITE_ENABLE_RTREE
|
||||
-DSQLITE_ENABLE_HIDDEN_COLUMNS
|
||||
-DLONGDOUBLE_TYPE=double
|
||||
-DCONFIG_SLOWDOWN_FACTOR=8.0
|
||||
}
|
||||
|
||||
|
@@ -95,7 +95,7 @@ proc run_thread_tests {{print_warning 0}} {
|
||||
if {[info commands sqlthread] eq ""} {
|
||||
set zProblem "SQLite build is not threadsafe"
|
||||
}
|
||||
if {![info exists ::tcl_platform(threaded)]} {
|
||||
if {![tcl::pkgconfig get threaded]} {
|
||||
set zProblem "Linked against a non-threadsafe Tcl build"
|
||||
}
|
||||
if {[info exists zProblem]} {
|
||||
@@ -107,4 +107,3 @@ proc run_thread_tests {{print_warning 0}} {
|
||||
}
|
||||
|
||||
return 0
|
||||
|
||||
|
Reference in New Issue
Block a user