2013-08-28 09:49:39 +04:00
|
|
|
# 2013 August 27
|
|
|
|
#
|
|
|
|
# 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 script is testing the file name handling provided
|
|
|
|
# by the "win32-longpath" VFS.
|
|
|
|
#
|
|
|
|
|
|
|
|
if {$tcl_platform(platform)!="windows"} return
|
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
set testprefix win32longpath
|
|
|
|
|
2013-12-10 01:48:49 +04:00
|
|
|
do_test 1.0 {
|
|
|
|
file_control_vfsname db
|
|
|
|
} win32
|
|
|
|
|
2013-08-28 09:49:39 +04:00
|
|
|
db close
|
2020-05-15 04:18:07 +03:00
|
|
|
set rawPath [get_pwd]
|
|
|
|
set path [file nativename $rawPath]
|
2013-08-28 09:49:39 +04:00
|
|
|
sqlite3 db [file join $path test.db] -vfs win32-longpath
|
|
|
|
|
|
|
|
do_test 1.1 {
|
2013-12-10 01:48:49 +04:00
|
|
|
file_control_vfsname db
|
|
|
|
} win32-longpath
|
|
|
|
|
|
|
|
do_test 1.2 {
|
2013-08-28 09:49:39 +04:00
|
|
|
db eval {
|
|
|
|
BEGIN EXCLUSIVE;
|
|
|
|
CREATE TABLE t1(x);
|
|
|
|
INSERT INTO t1 VALUES(1);
|
|
|
|
INSERT INTO t1 VALUES(2);
|
|
|
|
INSERT INTO t1 VALUES(3);
|
|
|
|
INSERT INTO t1 VALUES(4);
|
|
|
|
SELECT x FROM t1 ORDER BY x;
|
|
|
|
COMMIT;
|
|
|
|
}
|
|
|
|
} {1 2 3 4}
|
|
|
|
|
|
|
|
set longPath(1) \\\\?\\$path\\[pid]
|
2020-05-15 04:18:07 +03:00
|
|
|
set uriPath(1a) %5C%5C%3F%5C$path\\[pid]
|
|
|
|
set uriPath(1b) %5C%5C%3F%5C$rawPath/[pid]
|
|
|
|
|
2024-07-31 18:04:37 +03:00
|
|
|
file mkdir $longPath(1)
|
2013-08-28 09:49:39 +04:00
|
|
|
|
|
|
|
set longPath(2) $longPath(1)\\[string repeat X 255]
|
2020-05-15 04:18:07 +03:00
|
|
|
set uriPath(2a) $uriPath(1a)\\[string repeat X 255]
|
|
|
|
set uriPath(2b) $uriPath(1b)/[string repeat X 255]
|
|
|
|
|
2024-07-31 18:04:37 +03:00
|
|
|
file mkdir $longPath(2)
|
2013-08-28 09:49:39 +04:00
|
|
|
|
|
|
|
set longPath(3) $longPath(2)\\[string repeat Y 255]
|
2020-05-15 04:18:07 +03:00
|
|
|
set uriPath(3a) $uriPath(2a)\\[string repeat Y 255]
|
|
|
|
set uriPath(3b) $uriPath(2b)/[string repeat Y 255]
|
|
|
|
|
2024-07-31 18:04:37 +03:00
|
|
|
file mkdir $longPath(3)
|
2013-08-28 09:49:39 +04:00
|
|
|
|
|
|
|
set fileName $longPath(3)\\test.db
|
|
|
|
|
2020-05-15 04:18:07 +03:00
|
|
|
set uri(1a) file:$uriPath(3a)\\test.db
|
|
|
|
set uri(1b) file:$uriPath(3b)/test.db
|
|
|
|
set uri(1c) file:///$uriPath(3a)\\test.db
|
|
|
|
set uri(1d) file:///$uriPath(3b)/test.db
|
|
|
|
set uri(1e) file://localhost/$uriPath(3a)\\test.db
|
|
|
|
set uri(1f) file://localhost/$uriPath(3b)/test.db
|
|
|
|
|
2013-12-10 01:48:49 +04:00
|
|
|
do_test 1.3 {
|
2013-08-28 09:49:39 +04:00
|
|
|
list [catch {sqlite3 db2 [string range $fileName 4 end]} msg] $msg
|
|
|
|
} {1 {unable to open database file}}
|
|
|
|
|
|
|
|
sqlite3 db3 $fileName -vfs win32-longpath
|
|
|
|
|
2013-12-10 01:48:49 +04:00
|
|
|
do_test 1.4 {
|
2013-08-28 09:49:39 +04:00
|
|
|
db3 eval {
|
|
|
|
BEGIN EXCLUSIVE;
|
|
|
|
CREATE TABLE t1(x);
|
|
|
|
INSERT INTO t1 VALUES(5);
|
|
|
|
INSERT INTO t1 VALUES(6);
|
|
|
|
INSERT INTO t1 VALUES(7);
|
|
|
|
INSERT INTO t1 VALUES(8);
|
|
|
|
SELECT x FROM t1 ORDER BY x;
|
|
|
|
COMMIT;
|
|
|
|
}
|
|
|
|
} {5 6 7 8}
|
|
|
|
|
|
|
|
db3 close
|
|
|
|
|
|
|
|
sqlite3 db3 $fileName -vfs win32-longpath
|
|
|
|
|
2013-12-10 01:48:49 +04:00
|
|
|
do_test 1.5 {
|
2013-08-28 11:42:43 +04:00
|
|
|
db3 eval {
|
|
|
|
PRAGMA journal_mode = WAL;
|
|
|
|
}
|
|
|
|
} {wal}
|
|
|
|
|
2013-12-10 01:48:49 +04:00
|
|
|
do_test 1.6 {
|
2013-08-28 09:49:39 +04:00
|
|
|
db3 eval {
|
|
|
|
BEGIN EXCLUSIVE;
|
|
|
|
INSERT INTO t1 VALUES(9);
|
|
|
|
INSERT INTO t1 VALUES(10);
|
|
|
|
INSERT INTO t1 VALUES(11);
|
|
|
|
INSERT INTO t1 VALUES(12);
|
|
|
|
SELECT x FROM t1 ORDER BY x;
|
|
|
|
COMMIT;
|
|
|
|
}
|
|
|
|
} {5 6 7 8 9 10 11 12}
|
|
|
|
|
|
|
|
db3 close
|
|
|
|
|
2020-05-15 04:18:07 +03:00
|
|
|
foreach tn {1a 1b 1c 1d 1e 1f} {
|
|
|
|
sqlite3 db3 $uri($tn) -vfs win32-longpath -uri 1 -translatefilename 0
|
|
|
|
|
|
|
|
do_test 1.7.$tn {
|
|
|
|
db3 eval {
|
|
|
|
SELECT x FROM t1 ORDER BY x;
|
|
|
|
}
|
|
|
|
} {5 6 7 8 9 10 11 12}
|
|
|
|
|
|
|
|
db3 close
|
|
|
|
}
|
|
|
|
|
2024-09-04 16:09:58 +03:00
|
|
|
# These over-length file and directory names are difficult to delete.
|
|
|
|
# The "file delete -force" might not work, depending on the TCL build
|
|
|
|
# being used. So first try to delete using the windows rmdir command.
|
|
|
|
#
|
|
|
|
set fd [open cleanup.bat w]
|
|
|
|
puts $fd "rmdir /q /s $longPath(1)"
|
|
|
|
close $fd
|
|
|
|
if {[catch {exec cleanup.bat} msg]} {
|
|
|
|
puts "Command \[cleanup.bat\] returns $msg"
|
|
|
|
}
|
|
|
|
|
2024-07-31 18:04:37 +03:00
|
|
|
file delete -force $fileName
|
|
|
|
file delete -force $longPath(3)
|
|
|
|
file delete -force $longPath(2)
|
|
|
|
file delete -force $longPath(1)
|
2013-08-28 09:49:39 +04:00
|
|
|
|
|
|
|
finish_test
|