1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Merge all the latest trunk enhancements into the exists-to-join branch.

FossilOrigin-Name: 9084a4c8726a2c7ba1c381886e29c7b86121d531282be0d63d5988d84f6f448d
This commit is contained in:
drh
2024-07-31 23:46:10 +00:00
175 changed files with 1991 additions and 1496 deletions

View File

@ -185,7 +185,8 @@ do_eqp_test autoindex1-500.1 {
QUERY PLAN
|--SEARCH t501 USING INTEGER PRIMARY KEY (rowid=?)
`--LIST SUBQUERY xxxxxx
`--SCAN t502
|--SCAN t502
`--CREATE BLOOM FILTER
}
do_eqp_test autoindex1-501 {
SELECT b FROM t501

View File

@ -112,7 +112,7 @@ proc read_file {zFile} {
set zData {}
if {[file exists $zFile]} {
set fd [open $zFile]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
if {[file size $zFile]<=$::sqlite_pending_byte || $zFile != "test.db"} {
set zData [read $fd]
@ -129,7 +129,7 @@ proc read_file {zFile} {
}
proc write_file {zFile zData} {
set fd [open $zFile w]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
puts -nonewline $fd $zData
close $fd
}

View File

@ -234,6 +234,7 @@ do_test cast-3.1 {
do_test cast-3.2 {
execsql {SELECT CAST(9223372036854774800 AS numeric)}
} 9223372036854774800
breakpoint
do_realnum_test cast-3.3 {
execsql {SELECT CAST(9223372036854774800 AS real)}
} 9.22337203685477e+18

View File

@ -290,7 +290,7 @@ ifcapable oversize_cell_check {
# detecting corruption was not possible at that point, and an assert() failed.
#
set fd [open test.db r+]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
seek $fd [expr 1024+8]
puts -nonewline $fd "\x03\x14"
close $fd

View File

@ -69,7 +69,7 @@ do_test corrupt2-1.3 {
forcedelete corrupt.db-journal
forcecopy test.db corrupt.db
set f [open corrupt.db RDWR]
fconfigure $f -encoding binary
fconfigure $f -translation binary
seek $f 16 start
puts -nonewline $f "\x00\xFF"
close $f
@ -89,7 +89,7 @@ do_test corrupt2-1.4 {
forcedelete corrupt.db-journal
forcecopy test.db corrupt.db
set f [open corrupt.db RDWR]
fconfigure $f -encoding binary
fconfigure $f -translation binary
seek $f 101 start
puts -nonewline $f "\xFF\xFF"
close $f
@ -109,7 +109,7 @@ do_test corrupt2-1.5 {
forcedelete corrupt.db-journal
forcecopy test.db corrupt.db
set f [open corrupt.db RDWR]
fconfigure $f -encoding binary
fconfigure $f -translation binary
seek $f 101 start
puts -nonewline $f "\x00\xC8"
seek $f 200 start
@ -179,7 +179,7 @@ do_test corrupt2-3.1 {
# of the DROP TABLE operation below.
#
set fd [open corrupt.db r+]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd -translation binary
seek $fd [expr 1024*3 + 12]
set zCelloffset [read $fd 2]
binary scan $zCelloffset S iCelloffset
@ -227,7 +227,7 @@ do_test corrupt2-5.1 {
# This block links a page from table t2 into the t1 table structure.
#
set fd [open corrupt.db r+]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd -translation binary
seek $fd [expr 1024 + 12]
set zCelloffset [read $fd 2]
binary scan $zCelloffset S iCelloffset
@ -392,7 +392,7 @@ corruption_test -sqlprep $sqlprep -corrupt {
# 0x0D (interpreted by SQLite as "leaf page of a table B-Tree").
#
set fd [open corrupt.db r+]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
seek $fd [expr 1024*2 + 8]
set zRightChild [read $fd 4]
binary scan $zRightChild I iRightChild
@ -410,7 +410,7 @@ corruption_test -sqlprep $sqlprep -corrupt {
# The corruption is detected as part of an OP_Prev opcode.
#
set fd [open corrupt.db r+]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
seek $fd [expr 1024*2 + 12]
set zCellOffset [read $fd 2]
binary scan $zCellOffset S iCellOffset
@ -431,7 +431,7 @@ corruption_test -sqlprep $sqlprep -corrupt {
# 0x0A (interpreted by SQLite as "leaf page of an index B-Tree").
#
set fd [open corrupt.db r+]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
seek $fd [expr 1024*1 + 8]
set zRightChild [read $fd 4]
binary scan $zRightChild I iRightChild
@ -459,7 +459,7 @@ corruption_test -sqlprep {
CREATE TABLE x6(a, b, c); CREATE TABLE xD(a, b, c); CREATE TABLE xJ(a, b, c);
} -corrupt {
set fd [open corrupt.db r+]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
seek $fd 108
set zRightChild [read $fd 4]
binary scan $zRightChild I iRightChild

View File

@ -122,7 +122,7 @@ proc put4byte {fd offset val} {
# the second rightmost child page number of page 1 to 1.
#
set fd [open test.db r+]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd -translation binary
set nChild [get2byte $fd 103]
set offChild [get2byte $fd [expr 100+12+($nChild-2)*2]]
set pgnoChild [get4byte $fd $offChild]

View File

@ -60,7 +60,7 @@ do_test 1.2 {
sqlite3 db test.db
set fd [db incrblob t1 x 3]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
seek $fd 30
puts -nonewline $fd "\x18"
close $fd
@ -102,7 +102,7 @@ do_test 2.2 {
sqlite3 db test.db
set fd [db incrblob t1 x 5]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
seek $fd 22
puts -nonewline $fd "\x5d"

View File

@ -399,7 +399,7 @@ do_test crash-7.1 {
# Change the checksum value for the master journal name.
set f [open test.db-journal a]
fconfigure $f -encoding binary
fconfigure $f -translation binary
seek $f [expr [file size test.db-journal] - 12]
puts -nonewline $f "\00\00\00\00"
close $f

View File

@ -362,4 +362,22 @@ do_execsql_test 5070 {
SELECT v4.e FROM t3 LEFT JOIN v4 ON true GROUP BY 1;
} NULL
# 2024-06-28 dbsqlfuzz 46343912848a603e32c6072cae792eb056bac897
# Do not call sqlite3ExprToRegister() on an expression that is already
# a register.
#
do_execsql_test 5080 {
CREATE TABLE dual(dummy TEXT);
INSERT INTO dual VALUES('X');
SELECT 11 = (
SELECT b
FROM (
SELECT a AS b
FROM dual
LEFT JOIN (SELECT 22 AS a FROM dual)
)
GROUP BY b, b
);
} 0
finish_test

View File

@ -311,7 +311,8 @@ det 3.3.1 {
QUERY PLAN
|--SCAN t1
`--LIST SUBQUERY xxxxxx
`--SCAN t2
|--SCAN t2
`--CREATE BLOOM FILTER
}
det 3.3.2 {
SELECT * FROM t1 WHERE y IN (SELECT y FROM t2 WHERE t1.x!=t2.x)

View File

@ -41,7 +41,7 @@ sqlite3_soft_heap_limit 0
proc pagerChangeCounter {filename new {fd ""}} {
if {$fd==""} {
set fd [open $filename RDWR]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
set needClose 1
} else {
set needClose 0
@ -70,7 +70,7 @@ proc pagerChangeCounter {filename new {fd ""}} {
proc readPagerChangeCounter {filename} {
set fd [open $filename RDONLY]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
seek $fd 24
foreach {a b c d} [list 0 0 0 0] {}

View File

@ -43,7 +43,7 @@ do_execsql_test func6-100 {
# string.
proc loadhex {file} {
set fd [open $file]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
set data [read $fd]
close $fd
binary encode hex $data

View File

@ -100,13 +100,13 @@ do_execsql_test func7-pg-300 {
SELECT acos(1);
} {0.0}
do_execsql_test func7-pg-301 {
SELECT degrees(acos(0.5));
SELECT format('%f',degrees(acos(0.5)));
} {60.0}
do_execsql_test func7-pg-310 {
SELECT round( asin(1), 7);
} {1.5707963}
do_execsql_test func7-pg-311 {
SELECT degrees( asin(0.5) );
SELECT format('%f',degrees( asin(0.5) ));
} {30.0}
do_execsql_test func7-pg-320 {
SELECT round( atan(1), 7);
@ -139,7 +139,7 @@ do_execsql_test func7-pg-420 {
SELECT round( tan(1), 7);
} {1.5574077}
do_execsql_test func7-pg-421 {
SELECT tan( radians(45) );
SELECT round(tan( radians(45) ),10);
} {1.0}
do_execsql_test func7-pg-500 {
SELECT round( sinh(1), 7);

View File

@ -83,7 +83,7 @@ proc modify_database {iMod} {
set offset [expr {$iMod>>8}]
set fd [open test.db r+]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd -translation binary
seek $fd $offset
set old_blob [read $fd 1]
seek $fd $offset

View File

@ -137,5 +137,61 @@ do_execsql_test 2.1 {
SELECT b FROM t1 WHERE a IN (1,2,3) ORDER BY b ASC NULLS LAST;
} {one three {}}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 3.0 {
CREATE TABLE x1(a);
INSERT INTO x1 VALUES(1), (2), (3);
CREATE TABLE x2(b);
INSERT INTO x2 VALUES(4), (5), (6);
CREATE TABLE t1(u);
INSERT INTO t1 VALUES(1), (2), (3), (4), (5), (6);
CREATE VIEW v1 AS SELECT u FROM t1 WHERE u IN (
SELECT a FROM x1
);
CREATE VIEW v2 AS SELECT u FROM t1 WHERE u IN (
SELECT b FROM x2
);
}
do_execsql_test 3.1 {
SELECT * FROM v1
} {
1 2 3
}
do_execsql_test 3.2 {
SELECT * FROM v2
} {
4 5 6
}
do_execsql_test 3.3 {
SELECT * FROM v2
UNION ALL
SELECT * FROM v1
} {
4 5 6
1 2 3
}
do_execsql_test 3.4 {
WITH w1 AS (
SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3
),
w2 AS (
SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
)
SELECT * FROM v1 WHERE u IN w1
UNION ALL
SELECT * FROM v2 WHERE u IN w2
} {
1 2 3 4 5 6
}
finish_test

View File

@ -50,8 +50,8 @@ proc check_on_disk {} {
set sz [file size test.db]
set fd [open test.db]
set fd2 [open test2.db w]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd2 -encoding binary -translation binary
fconfigure $fd -translation binary
fconfigure $fd2 -translation binary
if {$sz>$::sqlite_pending_byte} {
puts -nonewline $fd2 [read $fd $::sqlite_pending_byte]
seek $fd [expr $::sqlite_pending_byte+512]

View File

@ -225,7 +225,7 @@ if {$tcl_platform(platform)=="unix" && [atomic_batch_write test.db]==0} {
}
forcecopy test2.db-journal test.db-journal
set f [open test.db-journal a]
fconfigure $f -encoding binary
fconfigure $f -translation binary
puts -nonewline $f "hello"
puts -nonewline $f "\x00\x00\x00\x05\x01\x02\x03\x04"
puts -nonewline $f "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7"

View File

@ -117,7 +117,7 @@ foreach locking_mode {normal exclusive} {
# Read the contents of the database file into a Tcl variable.
#
set fd [open test.db]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
set zDatabase [read $fd]
close $fd
@ -138,7 +138,7 @@ foreach locking_mode {normal exclusive} {
#
do_test ioerr5-1.$locking_mode-$iFail.4 {
set fd [open test.db]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
set zDatabase2 [read $fd]
close $fd
expr {$zDatabase eq $zDatabase2}

View File

@ -207,7 +207,7 @@ if {[permutation]!="inmemory_journal"} {
# not commit it.
# 3. Make a copy of the database files on disk.
# 4. Try to read from the copy using unix-dotfile VFS. This fails because
# the dotfile still exists, so SQLite things the database is locked.
# the dotfile still exists, so SQLite thinks the database is locked.
# 5. Remove the dotfile.
# 6. Try to read the db again. This time, the old transaction is rolled
# back and the read permitted.
@ -269,5 +269,3 @@ if {[permutation]!="inmemory_journal"} {
}
finish_test

View File

@ -245,7 +245,7 @@ if {[wal_is_capable]} {
db close
set fd [open test.db]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
set data [read $fd [expr 20*1024]]
close $fd

View File

@ -88,8 +88,8 @@ do_test misc3-2.4 {
execsql {SELECT 2e-25*0.5e250}
} 1e+225
do_test misc3-2.5 {
execsql {SELECT 2.0e-250*0.5e25}
} 1e-225
execsql {SELECT format('%.15e',2.0e-250*0.5e25)}
} {1.0000000000000e-225}
do_test misc3-2.6 {
execsql {SELECT '-2.0e-127' * '-0.5e27'}
} 1e-100

View File

@ -281,6 +281,7 @@ do_test nan-4.14 {
# These tests test some really, really small floating point numbers.
#
load_static_extension db decimal
if {$tcl_platform(platform) != "symbian"} {
# These two are not run on symbian because tcl has trouble converting
# the very small numbers back to text form (probably due to a difference
@ -291,15 +292,15 @@ if {$tcl_platform(platform) != "symbian"} {
set small \
[string repeat 0 10000].[string repeat 0 323][string repeat 9 10000]
db eval "INSERT INTO t1 VALUES($small)"
db eval {SELECT x, typeof(x) FROM t1}
} {9.88131291682493e-324 real}
db eval {SELECT decimal_exp(x), typeof(x) FROM t1}
} {/9\.88131291682493\d*e-324 real/}
do_test nan-4.16 {
db eval {DELETE FROM t1}
set small \
-[string repeat 0 10000].[string repeat 0 323][string repeat 9 10000]
db eval "INSERT INTO t1 VALUES($small)"
db eval {SELECT x, typeof(x) FROM t1}
} {-9.88131291682493e-324 real}
db eval {SELECT decimal_exp(x), typeof(x) FROM t1}
} {/-9\.88131291682493\d*e-324 real/}
}
do_test nan-4.17 {
db eval {DELETE FROM t1}

View File

@ -61,12 +61,12 @@ proc my_db_restore {} {
forcecopy sv_test.db-journal test.db-journal
set fd1 [open sv_test.db r]
fconfigure $fd1 -encoding binary -translation binary
fconfigure $fd1 -translation binary
set data [read $fd1]
close $fd1
set fd1 [open test.db w]
fconfigure $fd1 -encoding binary -translation binary
fconfigure $fd1 -translation binary
puts -nonewline $fd1 $data
close $fd1
}

View File

@ -38,6 +38,23 @@ foreach {in out} {
execsql {SELECT percentile(x,$in) FROM t1}
} $out
}
do_execsql_test percentile-1.1.median {
SELECT median(x) FROM t1;
} 8.0
foreach {in out} {
1.0 11.0
0.5 8.0
0.125 4.0
0.15 4.4
0.2 5.2
0.8 11.0
0.89 11.0
} {
do_test percentile-1.1b-$in {
execsql {SELECT percentile_cont(x,$in) FROM t1}
} $out
}
# Add some NULL values.
#
@ -109,6 +126,9 @@ do_test percentile-1.11 {
do_test percentile-1.12 {
catchsql {SELECT percentile(x,x'3530') FROM t1}
} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
do_test percentile-1.12b {
catchsql {SELECT percentile_cont(x,x'3530') FROM t1}
} {1 {2nd argument to percentile_cont() is not a number between 0.0 and 1.0}}
# Second argument is out of range
#
@ -118,6 +138,9 @@ do_test percentile-1.13 {
do_test percentile-1.14 {
catchsql {SELECT percentile(x,100.0000001) FROM t1}
} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}
do_test percentile-1.14b {
catchsql {SELECT percentile_cont(x,1.0000001) FROM t1}
} {1 {2nd argument to percentile_cont() is not a number between 0.0 and 1.0}}
# First argument is not NULL and is not NUMERIC
#

View File

@ -275,14 +275,13 @@ do_eqp_test 6.1 {
| | `--LIST SUBQUERY xxxxxx
| | |--MATERIALIZE k
| | | `--SCAN 3 CONSTANT ROWS
| | `--SCAN k
| | |--SCAN k
| | `--CREATE BLOOM FILTER
| `--UNION ALL
| |--SEARCH t02 USING INDEX t02x (w=? AND x=? AND y>? AND y<?)
| `--LIST SUBQUERY xxxxxx
| `--SCAN k
| `--REUSE LIST SUBQUERY xxxxxx
|--SEARCH t0
`--LIST SUBQUERY xxxxxx
`--SCAN k
`--REUSE LIST SUBQUERY xxxxxx
}
# ^^^^--- The key feature above is that the SEARCH for each subquery
# uses all three fields of the index w, x, and y. Prior to the push-down
@ -300,18 +299,13 @@ do_eqp_test 6.2 {
| | `--LIST SUBQUERY xxxxxx
| | |--CO-ROUTINE v1
| | | `--SCAN 3 CONSTANT ROWS
| | `--SCAN v1
| | |--SCAN v1
| | `--CREATE BLOOM FILTER
| `--UNION ALL
| |--SEARCH t02 USING INDEX t02x (w=? AND x=? AND y>? AND y<?)
| `--LIST SUBQUERY xxxxxx
| |--CO-ROUTINE v1
| | `--SCAN 3 CONSTANT ROWS
| `--SCAN v1
| `--REUSE LIST SUBQUERY xxxxxx
|--SEARCH t0
`--LIST SUBQUERY xxxxxx
|--CO-ROUTINE v1
| `--SCAN 3 CONSTANT ROWS
`--SCAN v1
`--REUSE LIST SUBQUERY xxxxxx
}
do_eqp_test 6.3 {
SELECT max(z) FROM t0 WHERE w=123 AND x IN k1 AND y BETWEEN 44 AND 55;
@ -322,14 +316,13 @@ do_eqp_test 6.3 {
| |--LEFT-MOST SUBQUERY
| | |--SEARCH t01 USING INDEX t01x (w=? AND x=? AND y>? AND y<?)
| | `--LIST SUBQUERY xxxxxx
| | `--SCAN k1
| | |--SCAN k1
| | `--CREATE BLOOM FILTER
| `--UNION ALL
| |--SEARCH t02 USING INDEX t02x (w=? AND x=? AND y>? AND y<?)
| `--LIST SUBQUERY xxxxxx
| `--SCAN k1
| `--REUSE LIST SUBQUERY xxxxxx
|--SEARCH t0
`--LIST SUBQUERY xxxxxx
`--SCAN k1
`--REUSE LIST SUBQUERY xxxxxx
}
finish_test

View File

@ -15,7 +15,10 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
if {$tcl_platform(platform)=="windows"} finish_test
if {$tcl_platform(platform)=="windows"} {
finish_test
return
}
source $testdir/lock_common.tcl
source $testdir/wal_common.tcl
set ::testprefix readonly

View File

@ -43,7 +43,6 @@ proc compare_dbs {db1 db2} {
proc recover_with_opts {opts} {
set cmd ".recover $opts"
set fd [open [list |$::CLI test.db $cmd]]
fconfigure $fd -encoding binary
fconfigure $fd -translation binary
set sql [read $fd]
close $fd

View File

@ -111,7 +111,7 @@ if {$tcl_platform(platform) == "unix"
]
set iOffset [expr (([file size testA.db-journal] + 511)/512)*512]
set fd [open testA.db-journal a+]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd -translation binary
seek $fd $iOffset
puts -nonewline $fd $zAppend

View File

@ -236,9 +236,11 @@ do_eqp_test 5.1 {
QUERY PLAN
|--SEARCH d2 USING INDEX d2ab (a=? AND b=?)
|--LIST SUBQUERY xxxxxx
| `--SCAN d1
| |--SCAN d1
| `--CREATE BLOOM FILTER
`--LIST SUBQUERY xxxxxx
`--SCAN d1
|--SCAN d1
`--CREATE BLOOM FILTER
}
do_execsql_test 6.0 {

View File

@ -265,7 +265,7 @@ ifcapable trace {
}
proc trace {stmt sql} {
array set A [sqlite3_stmt_scanstatus -flags complex [format %x $stmt] 0]
array set A [sqlite3_stmt_scanstatus -flags complex [format %llx $stmt] 0]
lappend ::trace_explain $A(zExplain)
}
db trace_v2 trace

View File

@ -1059,7 +1059,7 @@ 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} continue
if {$i>=0x80 && ($i<=0x9F || $tcl_version>=9.0)} continue
if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue
if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)=="Linux"} continue
set hex [format %02X $i]

View File

@ -410,7 +410,7 @@ CREATE TABLE t4(a, b);
#
do_test shell5-3.1 {
set fd [open shell5.csv w]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd -translation binary
puts -nonewline $fd "\"test 1\"\x1F,test 2\r\n\x1E"
puts -nonewline $fd "test 3\x1Ftest 4\n"
close $fd

View File

@ -33,7 +33,6 @@ do_execsql_test 1.0 {
foreach {tn l x} [db eval { SELECT tn, length(x) AS l, x FROM f1 }] {
forcedelete shell7_test.bin
set fd [open shell7_test.bin w]
fconfigure $fd -encoding binary
fconfigure $fd -translation binary
puts -nonewline $fd $x
close $fd

View File

@ -166,7 +166,7 @@ do_multiclient_test tn {
proc read_content {file} {
if {[file exists $file]==0} {return ""}
set fd [open $file]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd -translation binary
set content [read $fd]
close $fd
return $content
@ -174,7 +174,7 @@ proc read_content {file} {
proc write_content {file content} {
set fd [open $file w+]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd -translation binary
puts -nonewline $fd $content
close $fd
}

View File

@ -211,7 +211,7 @@ forcedelete test.db test.db2
proc create_db_file {nByte} {
set fd [open test.db w]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
puts -nonewline $fd [string range "xSQLite" 1 $nByte]
close $fd
}

View File

@ -310,66 +310,6 @@ proc do_delete_file {force args} {
}
}
if {$::tcl_platform(platform) eq "windows"} {
proc do_remove_win32_dir {args} {
set nRetry [getFileRetries] ;# Maximum number of retries.
set nDelay [getFileRetryDelay] ;# Delay in ms before retrying.
foreach dirName $args {
# On windows, sometimes even a [remove_win32_dir] can fail just after
# a directory is emptied. The cause is usually "tag-alongs" - programs
# like anti-virus software, automatic backup tools and various explorer
# extensions that keep a file open a little longer than we expect,
# causing the delete to fail.
#
# The solution is to wait a short amount of time before retrying the
# removal.
#
if {$nRetry > 0} {
for {set i 0} {$i < $nRetry} {incr i} {
set rc [catch {
remove_win32_dir $dirName
} msg]
if {$rc == 0} break
if {$nDelay > 0} { after $nDelay }
}
if {$rc} { error $msg }
} else {
remove_win32_dir $dirName
}
}
}
proc do_delete_win32_file {args} {
set nRetry [getFileRetries] ;# Maximum number of retries.
set nDelay [getFileRetryDelay] ;# Delay in ms before retrying.
foreach fileName $args {
# On windows, sometimes even a [delete_win32_file] can fail just after
# a file is closed. The cause is usually "tag-alongs" - programs like
# anti-virus software, automatic backup tools and various explorer
# extensions that keep a file open a little longer than we expect,
# causing the delete to fail.
#
# The solution is to wait a short amount of time before retrying the
# delete.
#
if {$nRetry > 0} {
for {set i 0} {$i < $nRetry} {incr i} {
set rc [catch {
delete_win32_file $fileName
} msg]
if {$rc == 0} break
if {$nDelay > 0} { after $nDelay }
}
if {$rc} { error $msg }
} else {
delete_win32_file $fileName
}
}
}
}
proc execpresql {handle args} {
trace remove execution $handle enter [list execpresql $handle]
if {[info exists ::G(perm:presql)]} {
@ -847,6 +787,9 @@ proc do_test {name cmd expected} {
}
} else {
set ok [expr {[string compare $result $expected]==0}]
if {!$ok} {
set ok [fpnum_compare $result $expected]
}
}
if {!$ok} {
# if {![info exists ::testprefix] || $::testprefix eq ""} {
@ -897,7 +840,7 @@ proc catchsafecmd {db {cmd ""}} {
proc catchcmdex {db {cmd ""}} {
global CLI
set out [open cmds.txt w]
fconfigure $out -encoding binary -translation binary
fconfigure $out -translation binary
puts -nonewline $out $cmd
close $out
set line "exec -keepnewline -- $CLI $db < cmds.txt"
@ -905,7 +848,7 @@ proc catchcmdex {db {cmd ""}} {
foreach chan $chans {
catch {
set modes($chan) [fconfigure $chan]
fconfigure $chan -encoding binary -translation binary -buffering none
fconfigure $chan -translation binary -buffering none
}
}
set rc [catch { eval $line } msg]

View File

@ -399,7 +399,7 @@ if {[llength $argv]==1
}
sqlite3 mydb $TRG(dbname)
mydb timeout 1000
mydb timeout 2000
mydb eval BEGIN
set cmdline [mydb one { SELECT value FROM config WHERE name='cmdline' }]
@ -447,7 +447,7 @@ if {[llength $argv]==1
} job {
display_job [array get job]
}
set nOmit [db one {SELECT count(*) FROM jobs WHERE state='omit'}]
set nOmit [mydb one {SELECT count(*) FROM jobs WHERE state='omit'}]
if {$nOmit} {
puts "$nOmit jobs omitted due to failures"
}
@ -963,6 +963,7 @@ proc add_jobs_from_cmdline {patternlist} {
proc make_new_testset {} {
global TRG
trdb eval {PRAGMA journal_mode=WAL;}
r_write_db {
trdb eval $TRG(schema)
set nJob $TRG(nJob)
@ -1117,7 +1118,7 @@ proc launch_another_job {iJob} {
set fd [open "|$TRG(runcmd) 2>@1" r]
cd $pwd
fconfigure $fd -blocking false
fconfigure $fd -blocking false -translation binary
fileevent $fd readable [list script_input_ready $fd $iJob $job(jobid)]
}

View File

@ -486,7 +486,7 @@ proc make_sh_script {srcdir opts cflags makeOpts configOpts} {
TCLDIR="$tcldir"
if [ ! -f Makefile ] ; then
\$SRCDIR/configure --with-tcl=\$TCL $configOpts
\$SRCDIR/configure --with-tcl=\$TCLDIR $configOpts
fi
$myopts

View File

@ -102,6 +102,7 @@ do_test 3.4 {
set blobs [list]
for {set i 1} {$i<100} {incr i} {
set b [db incrblob -readonly t3 b $i]
fconfigure $b -translation binary
read $b
lappend blobs $b
}

View File

@ -58,7 +58,7 @@ do_test tkt3457-1.1 {
# start of the first journal-header has not been written by SQLite.
# So write it now.
set fd [open bak.db-journal a+]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd -translation binary
seek $fd 0
puts -nonewline $fd "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7"
close $fd

View File

@ -18,10 +18,9 @@ source $testdir/tester.tcl
# A variable with only a string representation comes in as TEXT
do_test types3-1.1 {
set V {}
append V x
set V [format %s xxxxx]
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
} {string text}
} {text}
# A variable with an integer representation comes in as INTEGER
do_test types3-1.2 {

View File

@ -128,10 +128,10 @@ if {$tcl_platform(platform)=="windows"} {
set drive [string range [pwd] 0 1]
set ::env(fstreeDrive) $drive
}
reset_db
register_fs_module db
if {$tcl_platform(platform)!="windows" || \
[regexp -nocase -- {^[A-Z]:} $drive]} {
reset_db
register_fs_module db
do_execsql_test 3.0 {
SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db';
SELECT name FROM fsdir WHERE dir = '.' AND name = '.'

View File

@ -1219,7 +1219,7 @@ foreach {tn pgsz works} {
set framehdr [binary format IIIIII $pg 5 22 23 $c1 $c2]
set fd [open test.db-wal w]
fconfigure $fd -encoding binary -translation binary
fconfigure $fd -translation binary
puts -nonewline $fd $walhdr
puts -nonewline $fd $framehdr
puts -nonewline $fd $framebody

View File

@ -1098,7 +1098,11 @@ if {$::tcl_platform(platform) == "unix"} {
3 00600
4 00755
} {
set effective [format %.5o [expr $permissions & ~$umask]]
if {$tcl_version>=9.0} {
set effective [format %.5d [expr $permissions & ~$umask]]
} else {
set effective [format %.5o [expr $permissions & ~$umask]]
}
do_test wal2-12.2.$tn.1 {
file attributes test.db -permissions $permissions
string map {o 0} [file attributes test.db -permissions]

View File

@ -65,7 +65,6 @@ proc wal_set_walhdr {filename {intlist {}}} {
set fd [open $filename r+]
fconfigure $fd -translation binary
fconfigure $fd -encoding binary
seek $fd 0
puts -nonewline $fd $blob
close $fd
@ -73,7 +72,6 @@ proc wal_set_walhdr {filename {intlist {}}} {
set fd [open $filename]
fconfigure $fd -translation binary
fconfigure $fd -encoding binary
set blob [read $fd 24]
close $fd
@ -89,5 +87,3 @@ proc wal_fix_walindex_cksum {hdrvar} {
lset hdr 10 $c1
lset hdr 11 $c2
}

View File

@ -22,7 +22,6 @@ ifcapable !wal {finish_test ; return }
#
proc readfile {filename} {
set fd [open $filename]
fconfigure $fd -encoding binary
fconfigure $fd -translation binary
set data [read $fd]
close $fd
@ -59,7 +58,6 @@ proc log_checksum_write {filename iFrame endian} {
set bin [binary format II $c1 $c2]
set fd [open $filename r+]
fconfigure $fd -encoding binary
fconfigure $fd -translation binary
seek $fd $offset
puts -nonewline $fd $bin
@ -114,7 +112,6 @@ proc log_checksum_writemagic {filename endian} {
set val [expr {0x377f0682 | ($endian == "big" ? 1 : 0)}]
set bin [binary format I $val]
set fd [open $filename r+]
fconfigure $fd -encoding binary
fconfigure $fd -translation binary
puts -nonewline $fd $bin

View File

@ -109,7 +109,6 @@ foreach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} {
forcecopy test.db-wal test2.db-wal
set fd [open test2.db-wal r+]
fconfigure $fd -encoding binary
fconfigure $fd -translation binary
seek $fd $iOff

View File

@ -49,19 +49,19 @@ set longPath(1) \\\\?\\$path\\[pid]
set uriPath(1a) %5C%5C%3F%5C$path\\[pid]
set uriPath(1b) %5C%5C%3F%5C$rawPath/[pid]
make_win32_dir $longPath(1)
file mkdir $longPath(1)
set longPath(2) $longPath(1)\\[string repeat X 255]
set uriPath(2a) $uriPath(1a)\\[string repeat X 255]
set uriPath(2b) $uriPath(1b)/[string repeat X 255]
make_win32_dir $longPath(2)
file mkdir $longPath(2)
set longPath(3) $longPath(2)\\[string repeat Y 255]
set uriPath(3a) $uriPath(2a)\\[string repeat Y 255]
set uriPath(3b) $uriPath(2b)/[string repeat Y 255]
make_win32_dir $longPath(3)
file mkdir $longPath(3)
set fileName $longPath(3)\\test.db
@ -92,7 +92,6 @@ do_test 1.4 {
} {5 6 7 8}
db3 close
# puts " Database exists \{[exists_win32_path $fileName]\}"
sqlite3 db3 $fileName -vfs win32-longpath
@ -115,7 +114,6 @@ do_test 1.6 {
} {5 6 7 8 9 10 11 12}
db3 close
# puts " Database exists \{[exists_win32_path $fileName]\}"
foreach tn {1a 1b 1c 1d 1e 1f} {
sqlite3 db3 $uri($tn) -vfs win32-longpath -uri 1 -translatefilename 0
@ -129,11 +127,9 @@ foreach tn {1a 1b 1c 1d 1e 1f} {
db3 close
}
do_delete_win32_file $fileName
# puts " Files remaining \{[find_win32_file $longPath(3)\\*]\}"
do_remove_win32_dir $longPath(3)
do_remove_win32_dir $longPath(2)
do_remove_win32_dir $longPath(1)
file delete -force $fileName
file delete -force $longPath(3)
file delete -force $longPath(2)
file delete -force $longPath(1)
finish_test

View File

@ -10,7 +10,10 @@
#***********************************************************************
#
package require Tcl 8.6
if {$tcl_version<8.6} {
puts "Requires TCL 8.6 or later"
return
}
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -30,7 +33,7 @@ if {[catch {load_static_extension db fileio} error]} {
proc readfile {f} {
set fd [open $f]
fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary
set data [read $fd]
close $fd
set data

View File

@ -10,7 +10,10 @@
#***********************************************************************
#
package require Tcl 8.6
if {$tcl_version<8.6} {
puts "Requires TCL 8.6 or later"
return
}
set testdir [file dirname $argv0]
source $testdir/tester.tcl