Merge trunk changes into the fts4-incr-merge branch.

FossilOrigin-Name: f61d5fb0281381228eb1a12a233bacaeb26b12a3
This commit is contained in:
drh
2012-03-20 17:04:17 +00:00
42 changed files with 318 additions and 172 deletions
+3 -3
View File
@@ -69,7 +69,7 @@ do_test bigfile-1.1 {
# large files. So skip all of the remaining tests in this file.
#
db close
if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} {
if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} {
puts "**** Unable to create a file larger than 4096 MB. *****"
finish_test
return
@@ -109,7 +109,7 @@ do_test bigfile-1.4 {
} $::MAGIC_SUM
db close
if {[catch {fake_big_file 8192 [pwd]/test.db}]} {
if {[catch {fake_big_file 8192 [get_pwd]/test.db}]} {
puts "**** Unable to create a file larger than 8192 MB. *****"
finish_test
return
@@ -148,7 +148,7 @@ do_test bigfile-1.9 {
} $::MAGIC_SUM
db close
if {[catch {fake_big_file 16384 [pwd]/test.db}]} {
if {[catch {fake_big_file 16384 [get_pwd]/test.db}]} {
puts "**** Unable to create a file larger than 16384 MB. *****"
finish_test
return
+1 -1
View File
@@ -29,7 +29,7 @@ do_execsql_test 1.1 {
# are actually in use and new pages will be appended to the file.
#
db close
if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} {
if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} {
puts "**** Unable to create a file larger than 4096 MB. *****"
finish_test
return
+2 -2
View File
@@ -47,7 +47,7 @@ for {set ii 0} {$ii < 10} {incr ii} {
do_test crash5-$ii.$jj.1 {
crashsql -delay 1 -file test.db-journal -seed $ii -tclbody [join [list \
[list set iFail $jj] {
sqlite3_crashparams 0 [file join [pwd] test.db-journal]
sqlite3_crashparams 0 [file join [get_pwd] test.db-journal]
# Begin a transaction and evaluate a "CREATE INDEX" statement
# with the iFail'th malloc() set to fail. This operation will
@@ -89,7 +89,7 @@ for {set ii 0} {$ii < 10} {incr ii} {
# by writing page 4 out to the db file. If it crashes later on,
# before syncing the journal... Corruption!
#
sqlite3_crashparams 1 [file join [pwd] test.db-journal]
sqlite3_crashparams 1 [file join [get_pwd] test.db-journal]
sqlite3_release_memory 8092
}]] {}
expr 1
+15 -1
View File
@@ -50,7 +50,7 @@ proc do_insert_tests {args} {
uplevel do_select_tests $args
}
# EVIDENCE-OF: R-55375-41353 -- syntax diagram insert-stmt
# EVIDENCE-OF: R-21350-31508 -- syntax diagram insert-stmt
#
do_insert_tests e_insert-0 {
1 "INSERT INTO a1 DEFAULT VALUES" {}
@@ -123,6 +123,20 @@ do_insert_tests e_insert-0 {
68 "INSERT OR IGNORE INTO a1 (b, a) SELECT c, b FROM a2" {}
69 "REPLACE INTO a1 (b, a) SELECT c, b FROM a2" {}
70 "REPLACE INTO main.a1 (b, a) SELECT c, b FROM a2" {}
71 "INSERT INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
72 "INSERT INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
73 "INSERT OR ROLLBACK INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
74 "INSERT OR ROLLBACK INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
75 "INSERT OR ABORT INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
76 "INSERT OR ABORT INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
77 "INSERT OR REPLACE INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
78 "INSERT OR REPLACE INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
79 "INSERT OR FAIL INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
80 "INSERT OR FAIL INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
81 "INSERT OR FAIL INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
82 "INSERT OR IGNORE INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
83 "REPLACE INTO a1 (b, a) VALUES(1, 2),(3,4)" {}
84 "REPLACE INTO main.a1 (b, a) VALUES(1, 2),(3,4)" {}
}
delete_all_data
+8 -8
View File
@@ -131,10 +131,10 @@ sqlite3_config_uri 1
if {$tcl_platform(platform) == "unix"} {
set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]
foreach {tn uri error} "
1 {file://localhost[pwd]/test.db} {not an error}
2 {file://[pwd]/test.db} {not an error}
3 {file://x[pwd]/test.db} {invalid uri authority: x}
4 {file://invalid[pwd]/test.db} {invalid uri authority: invalid}
1 {file://localhost[get_pwd]/test.db} {not an error}
2 {file://[get_pwd]/test.db} {not an error}
3 {file://x[get_pwd]/test.db} {invalid uri authority: x}
4 {file://invalid[get_pwd]/test.db} {invalid uri authority: invalid}
" {
do_test 2.$tn {
set DB [sqlite3_open_v2 $uri $flags ""]
@@ -153,9 +153,9 @@ if {$tcl_platform(platform) == "unix"} {
# parameters passed through to the VFS xOpen() methods.
#
foreach {tn uri parse} "
1 {file:test.db#abc} {[pwd]/test.db {}}
2 {file:test.db?a=b#abc} {[pwd]/test.db {a b}}
3 {file:test.db?a=b#?c=d} {[pwd]/test.db {a b}}
1 {file:test.db#abc} {[get_pwd]/test.db {}}
2 {file:test.db?a=b#abc} {[get_pwd]/test.db {a b}}
3 {file:test.db?a=b#?c=d} {[get_pwd]/test.db {a b}}
" {
do_filepath_test 3.$tn { parse_uri $uri } $parse
}
@@ -171,7 +171,7 @@ foreach {tn uri parse} "
# path is interpreted as a relative path.
#
foreach {tn uri parse} "
1 {file:test.db} {[pwd]/test.db {}}
1 {file:test.db} {[get_pwd]/test.db {}}
2 {file:/test.db} {/test.db {}}
3 {file:///test.db} {/test.db {}}
4 {file://localhost/test.db} {/test.db {}}
+1 -1
View File
@@ -34,7 +34,7 @@ do_test filectrl-1.4 {
do_test filectrl-1.5 {
db close
sqlite3 db test_control_lockproxy.db
file_control_lockproxy_test db [pwd]
file_control_lockproxy_test db [get_pwd]
} {}
db close
forcedelete .test_control_lockproxy.db-conch test.proxy
-2
View File
@@ -482,6 +482,4 @@ foreach lid [list 4 [expr 1<<30]] {
SELECT count(*) FROM t6_segments;
} {4 4}
}
finish_test
+1 -1
View File
@@ -130,7 +130,7 @@ do_test ioerr2-5 {
}
} msg]
list $rc $msg
} {1 {callback requested query abort}}
} {1 {abort due to ROLLBACK}}
if {$::tcl_platform(platform) == "unix"} {
# Cause the call to xAccess used by [pragma temp_store_directory] to
+1 -1
View File
@@ -483,7 +483,7 @@ do_test misc7-20.1 {
# Try to open a really long file name.
#
do_test misc7-21.1 {
set zFile [file join [pwd] "[string repeat abcde 104].db"]
set zFile [file join [get_pwd] "[string repeat abcde 104].db"]
set rc [catch {sqlite3 db2 $zFile} msg]
list $rc $msg
} {1 {unable to open database file}}
+21 -3
View File
@@ -535,7 +535,7 @@ proc copy_on_mj_delete {method filename args} {
return SQLITE_OK
}
set pwd [pwd]
set pwd [get_pwd]
foreach {tn1 tcl} {
1 { set prefix "test.db" }
2 {
@@ -887,6 +887,24 @@ do_test pager1.4.7.3 {
delete_file test.db-journal
file exists test.db-journal
} {0}
do_test pager1.4.8.1 {
catch {file attributes test.db -permissions r--------}
catch {file attributes test.db -readonly 1}
sqlite3 db test.db
db eval { SELECT * FROM t1 }
sqlite3_db_readonly db main
} {1}
do_test pager1.4.8.2 {
sqlite3_db_readonly db xyz
} {-1}
do_test pager1.4.8.3 {
db close
catch {file attributes test.db -readonly 0}
catch {file attributes test.db -permissions rw-rw-rw-} msg
sqlite3 db test.db
db eval { SELECT * FROM t1 }
sqlite3_db_readonly db main
} {0}
#-------------------------------------------------------------------------
# The following tests deal with multi-file commits.
@@ -1001,7 +1019,7 @@ do_test pager1-5.4.1 {
# the master-journal name encoded as utf-8 with no nul term.
#
set mj_pointer [expr {
20 + [string length [pwd]] + [string length "/test.db-mjXXXXXX9XX"]
20 + [string length [get_pwd]] + [string length "/test.db-mjXXXXXX9XX"]
}]
expr {$::max_journal==(512+2*(1024+8)+$mj_pointer)}
} 1
@@ -1020,7 +1038,7 @@ do_test pager1-5.4.2 {
# written starting at the next (in this case 512 byte) sector boundary.
#
set mj_pointer [expr {
20 + [string length [pwd]] + [string length "/test.db-mjXXXXXX9XX"]
20 + [string length [get_pwd]] + [string length "/test.db-mjXXXXXX9XX"]
}]
expr {$::max_journal==(((512+2*(1024+8)+511)/512)*512 + $mj_pointer)}
} 1
+2 -2
View File
@@ -990,7 +990,7 @@ do_test pragma-9.4 {
} {}
ifcapable wsd {
do_test pragma-9.5 {
set pwd [string map {' ''} [file nativename [pwd]]]
set pwd [string map {' ''} [file nativename [get_pwd]]]
execsql "
PRAGMA temp_store_directory='$pwd';
"
@@ -999,7 +999,7 @@ ifcapable wsd {
execsql {
PRAGMA temp_store_directory;
}
} [list [file nativename [pwd]]]
} [list [file nativename [get_pwd]]]
do_test pragma-9.7 {
catchsql {
PRAGMA temp_store_directory='/NON/EXISTENT/PATH/FOOBAR';
+1 -1
View File
@@ -221,7 +221,7 @@ do_test quota-3.3.1 {
execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a
execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b
set ::quota
} [list [file join [pwd] test.db] 5120]
} [list [file join [get_pwd] test.db] 5120]
do_test quota-3.2.X {
foreach db {db1a db2a db2b db1b} { catch { $db close } }
+1 -1
View File
@@ -28,7 +28,7 @@ foreach dir {quota2a quota2a/x1 quota2a/x2 quota2b quota2c} {
# that is the same across platforms.
#
unset -nocomplain ::quota_pwd ::quota_mapping
set ::quota_pwd [string map {\\ /} [pwd]]
set ::quota_pwd [string map {\\ /} [get_pwd]]
set ::quota_mapping [list $::quota_pwd PWD]
proc standard_path {x} {
set x [string map {\\ /} $x]
+20 -1
View File
@@ -19,6 +19,7 @@
#
# Commands to manipulate the db and the file-system at a high level:
#
# get_pwd
# copy_file FROM TO
# delete_file FILENAME
# drop_all_tables ?DB?
@@ -148,6 +149,24 @@ proc getFileRetryDelay {} {
return $::G(file-retry-delay)
}
# Return the string representing the name of the current directory. On
# Windows, the result is "normalized" to whatever our parent command shell
# is using to prevent case-mismatch issues.
#
proc get_pwd {} {
if {$::tcl_platform(platform) eq "windows"} {
#
# NOTE: Cannot use [file normalize] here because it would alter the
# case of the result to what Tcl considers canonical, which would
# defeat the purpose of this procedure.
#
return [string map [list \\ /] \
[string trim [exec -- $::env(ComSpec) /c echo %CD%]]]
} else {
return [pwd]
}
}
# Copy file $from into $to. This is used because some versions of
# TCL for windows (notably the 8.4.1 binary package shipped with the
# current mingw release) have a broken "file copy" command.
@@ -984,7 +1003,7 @@ proc crashsql {args} {
# $crashfile gets compared to the native filename in
# cfSync(), which can be different then what TCL uses by
# default, so here we force it to the "nativename" format.
set cfile [string map {\\ \\\\} [file nativename [file join [pwd] $crashfile]]]
set cfile [string map {\\ \\\\} [file nativename [file join [get_pwd] $crashfile]]]
set f [open crash.tcl w]
puts $f "sqlite3_crash_enable 1"
+1 -1
View File
@@ -27,7 +27,7 @@ do_test tkt-94c94-1.1 {
# Grow the file to larger than 4096MB (2^32 bytes)
db close
if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} {
if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} {
puts "**** Unable to create a file larger than 4096 MB. *****"
finish_test
return
+3 -2
View File
@@ -134,18 +134,19 @@ ifcapable fts3 {
"-- REPLACE INTO 'main'.'x1_stat' VALUES(0,?)"
"-- SELECT (SELECT max(idx) FROM 'main'.'x1_segdir' WHERE level = ?) + 1"
"-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)"
"-- INSERT INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)"
"-- REPLACE INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)"
}
do_trace_test 2.3 {
INSERT INTO x1(x1) VALUES('optimize');
} {
"INSERT INTO x1(x1) VALUES('optimize');"
"-- SELECT DISTINCT level / (1024 * ?) FROM 'main'.'x1_segdir'"
"-- SELECT idx, start_block, leaves_end_block, end_block, root FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?ORDER BY level DESC, idx ASC"
"-- SELECT max(level) FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?"
"-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)"
"-- DELETE FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?"
"-- INSERT INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)"
"-- REPLACE INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)"
}
}
+4 -4
View File
@@ -54,9 +54,9 @@ foreach {tn uri file} {
if {$tcl_platform(platform)=="windows"} {
if {$tn>14} break
set uri [string map [list PWD /[pwd]] $uri]
set uri [string map [list PWD /[get_pwd]] $uri]
} else {
set uri [string map [list PWD [pwd]] $uri]
set uri [string map [list PWD [get_pwd]] $uri]
}
if {[file isdir $file]} {error "$file is a directory"}
@@ -274,9 +274,9 @@ foreach {tn uri res} {
} {
if {$tcl_platform(platform)=="windows"} {
set uri [string map [list PWD [string range [pwd] 3 end]] $uri]
set uri [string map [list PWD [string range [get_pwd] 3 end]] $uri]
} else {
set uri [string map [list PWD [string range [pwd] 1 end]] $uri]
set uri [string map [list PWD [string range [get_pwd] 1 end]] $uri]
}
do_test 6.$tn {
+1 -1
View File
@@ -1477,7 +1477,7 @@ foreach pgsz {512 1024 2048 4096 8192 16384 32768 65536} {
# Test that when 1 or more pages are recovered from a WAL file,
# sqlite3_log() is invoked to report this to the user.
#
set walfile [file nativename [file join [pwd] test.db-wal]]
set walfile [file nativename [file join [get_pwd] test.db-wal]]
catch {db close}
forcedelete test.db
do_test wal-23.1 {
+1 -1
View File
@@ -52,7 +52,7 @@ do_test walbig-1.0 {
} {wal}
db close
if {[catch {fake_big_file 5000 [pwd]/test.db}]} {
if {[catch {fake_big_file 5000 [get_pwd]/test.db}]} {
puts "**** Unable to create a file larger than 5000 MB. *****"
finish_test
return
+1 -1
View File
@@ -23339,7 +23339,7 @@ do_execsql_test where7-3.1 {
OR t301.c8 = 1407424651264000)
ORDER BY t302.c5 LIMIT 200;
} {
0 0 1 {SEARCH TABLE t301 USING COVERING INDEX t301_c4 (c4=?) (~5 rows)}
0 0 1 {SEARCH TABLE t301 USING COVERING INDEX t301_c4 (c4=?) (~10 rows)}
0 0 1 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
0 1 0 {SEARCH TABLE t302 USING INDEX t302_c8_c3 (c8=? AND c3>?) (~2 rows)}
0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+24 -4
View File
@@ -364,7 +364,7 @@ ifcapable explain {
} {
0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?) (~2 rows)}
0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~5 rows)}
0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~10 rows)}
}
do_execsql_test where9-3.2 {
EXPLAIN QUERY PLAN
@@ -374,7 +374,7 @@ ifcapable explain {
} {
0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}
0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?) (~2 rows)}
0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~5 rows)}
0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~10 rows)}
}
}
@@ -453,8 +453,8 @@ ifcapable explain {
do_execsql_test where9-5.1 {
EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c=31031 OR d IS NULL)
} {
0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?) (~2 rows)}
0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?) (~2 rows)}
0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?) (~3 rows)}
0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?) (~3 rows)}
}
# In contrast, b=1000 is preferred over any OR-clause.
@@ -856,5 +856,25 @@ do_test where9-7.3.2 {
}
} {79 81}
# Fix for ticket [b7c8682cc17f32903f03a610bd0d35ffd3c1e6e4]
# "Incorrect result from LEFT JOIN with OR in the WHERE clause"
#
do_test where9-8.1 {
db eval {
CREATE TABLE t81(a INTEGER PRIMARY KEY, b, c, d);
CREATE TABLE t82(x INTEGER PRIMARY KEY, y);
CREATE TABLE t83(p INTEGER PRIMARY KEY, q);
INSERT INTO t81 VALUES(2,3,4,5);
INSERT INTO t81 VALUES(3,4,5,6);
INSERT INTO t82 VALUES(2,4);
INSERT INTO t83 VALUES(5,55);
SELECT *
FROM t81 LEFT JOIN t82 ON y=b JOIN t83
WHERE c==p OR d==p
ORDER BY +a;
}
} {2 3 4 5 {} {} 5 55 3 4 5 6 2 4 5 55}
finish_test