Merge all recent enhancements and fixes from trunk.

FossilOrigin-Name: 0546d1cd1a3402890edade7970c269cc3f17bc98
This commit is contained in:
drh
2015-11-02 18:57:26 +00:00
9 changed files with 229 additions and 45 deletions
+15
View File
@@ -62,6 +62,21 @@ do_execsql_test index3-2.2eqp {
EXPLAIN QUERY PLAN
SELECT a FROM t1 WHERE b='ab005xy' COLLATE nocase;
} {/USING INDEX/}
do_execsql_test index3-2.3 {
SELECT name FROM sqlite_master WHERE tbl_name='t1' ORDER BY name
} {sqlite_autoindex_t1_1 sqlite_autoindex_t1_2 t1 t1c t1d}
do_execsql_test index3-2.4 {
CREATE TABLE t2a(a integer, b, PRIMARY KEY(a));
CREATE TABLE t2b("a" integer, b, PRIMARY KEY("a"));
CREATE TABLE t2c([a] integer, b, PRIMARY KEY([a]));
CREATE TABLE t2d('a' integer, b, PRIMARY KEY('a'));
}
do_execsql_test index3-2.5 {
SELECT name FROM sqlite_master WHERE tbl_name LIKE 't2_' ORDER BY name
} {t2a t2b t2c t2d}
# This test corrupts the database file so it must be the last test
+3 -1
View File
@@ -93,7 +93,9 @@ do_test 1.4.1 {
list [catch { sqlite3 dbh /root/test.db } msg] $msg
} {1 {unable to open database file}}
do_re_test 1.4.2 { lindex $::log 0 } {^os_unix.c:\d*: \(\d+\) open\(.*test.db\) - }
do_re_test 1.4.2 {
lindex $::log 0
} {^os_unix.c:\d*: \(\d+\) (open|readlink)\(.*test.db\) - }
#--------------------------------------------------------------------------
# Tests oserror-1.* test failures in the unlink() system call.
+119
View File
@@ -0,0 +1,119 @@
# 2015 October 31
#
# 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 that SQLite can follow symbolic links.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix symlink
# This only runs on unix.
if {$::tcl_platform(platform)!="unix"} {
finish_test
return
}
# Ensure that test.db has been created.
#
do_execsql_test 1.0 {
CREATE TABLE t1(x, y);
}
# Test that SQLite follows symlinks when opening files.
#
forcedelete test.db2
do_test 1.1 {
file link test.db2 test.db
sqlite3 db2 test.db2
sqlite3_db_filename db2 main
} [file join [pwd] test.db]
# Test that if the symlink points to a file that does not exists, it is
# created when it is opened.
#
do_test 1.2.1 {
db2 close
db close
forcedelete test.db
file exists test.db
} 0
do_test 1.2.2 {
sqlite3 db2 test.db2
file exists test.db
} 1
do_test 1.2.3 {
sqlite3_db_filename db2 main
} [file join [pwd] test.db]
db2 close
# Test that a loop of symlinks cannot be opened.
#
do_test 1.3 {
forcedelete test.db
# Note: Tcl [file link] command is too smart to create loops of symlinks.
exec ln -s test.db2 test.db
list [catch { sqlite3 db test.db } msg] $msg
} {1 {unable to open database file}}
# Test that overly large paths cannot be opened.
#
do_test 1.4 {
set name "test.db[string repeat x 502]"
list [catch { sqlite3 db $name } msg] $msg
} {1 {unable to open database file}}
do_test 1.5 {
set r [expr 510 - [string length test.db] - [string length [pwd]]]
set name "test.db[string repeat x $r]"
list [catch { sqlite3 db $name } msg] $msg
} {1 {unable to open database file}}
#-------------------------------------------------------------------------
# Test that journal and wal files are created next to the real file,
# not the symlink.
#
do_test 2.0 {
catch { db close }
catch { db2 close }
forcedelete test.db test.db2
sqlite3 db test.db
execsql { CREATE TABLE t1(x) }
file link test.db2 test.db
sqlite3 db2 test.db2
file exists test.db-journal
} 0
do_test 2.1 {
execsql {
BEGIN;
INSERT INTO t1 VALUES(1);
} db2
file exists test.db-journal
} 1
do_test 2.2 {
file exists test.db2-journal
} 0
do_test 2.3 {
execsql {
COMMIT;
PRAGMA journal_mode = wal;
INSERT INTO t1 VALUES(2);
} db2
file exists test.db-wal
} 1
do_test 2.4 {
file exists test.db2-wal
} 0
do_execsql_test 2.5 {
SELECT * FROM t1;
} {1 2}
finish_test
+1 -1
View File
@@ -61,7 +61,7 @@ foreach s {
fcntl read pread write pwrite fchmod fallocate
pread64 pwrite64 unlink openDirectory mkdir rmdir
statvfs fchown umask mmap munmap mremap
getpagesize
getpagesize readlink
} {
if {[test_syscall exists $s]} {lappend syscall_list $s}
}