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
+12 -11
View File
@@ -1,5 +1,5 @@
C Merge\sall\sthe\slatest\senhancements\sfrom\strunk.
D 2015-10-30T16:50:00.513
C Merge\sall\srecent\senhancements\sand\sfixes\sfrom\strunk.
D 2015-11-02T18:57:26.691
F Makefile.in 3229179cfbc7d1378aba248dcbdf5213fff6214a
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 2ed14817d36a6c26cb146e53b9c8a7318ba5bdd4
@@ -305,7 +305,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
F src/btree.c 77343aac89c50bb5e06cbca3ace8c057c14de57c
F src/btree.h b512723e4f27d7ba16b4b985cdecdb82c0f6d0c0
F src/btreeInt.h 8177c9ab90d772d6d2c6c517e05bed774b7c92c0
F src/build.c d6162335d690396dfc5c4bd59e8b2b0c14ba6285
F src/build.c ca574d33ffb1763cfd2979383f4d507095bfbe19
F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f
F src/ctime.c 509ef9c64d1321f42448f111da86400b1799218a
@@ -344,7 +344,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8
F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
F src/os_unix.c fc93d55f96bb978f0b0168c6ea7d6fc60b0e172c
F src/os_unix.c cf72e06e15839ebe7121e01d3eebf256c039b0ca
F src/os_win.c 1716291e5ec2dbfc5a1fe0b32182030f1f7d8acf
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
F src/pager.c 9c1eec0d88133484b165fa0b5284a411c24b964c
@@ -372,7 +372,7 @@ F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e
F src/tclsqlite.c e2344bee0d192397f555a24ef3fab26f2ed93bcc
F src/test1.c 9ac5cbfe3c859ab7518edc5109a2959d6bf7b059
F src/test2.c 577961fe48961b2f2e5c8b56ee50c3f459d3359d
F src/test3.c f7ae1d6a4aa07aac257de18a43800c1199b513fc
F src/test3.c a8887dabbbee3059af338f20d290084a63ed1b0f
F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e
F src/test5.c 5a34feec76d9b3a86aab30fd4f6cc9c48cbab4c1
F src/test6.c 41cacf3b0dd180823919bf9e1fbab287c9266723
@@ -804,7 +804,7 @@ F test/incrvacuum3.test 75256fb1377e7c39ef2de62bfc42bbff67be295a
F test/incrvacuum_ioerr.test 6ae2f783424e47a0033304808fe27789cf93e635
F test/index.test fe3c7a1aad82af92623747e9c3f3aa94ccd51238
F test/index2.test f835d5e13ca163bd78c4459ca15fd2e4ed487407
F test/index3.test fa3e49bbaa4f38091c9c742e36a1abe67c4ef1fc
F test/index3.test 81bc47890b8abfb181bc35f8d10b56c069803386
F test/index4.test ab92e736d5946840236cd61ac3191f91a7856bf6
F test/index5.test 8621491915800ec274609e42e02a97d67e9b13e7
F test/index6.test 7102ec371414c42dfb1d5ca37eb4519aa9edc23a
@@ -933,7 +933,7 @@ F test/orderby6.test 8b38138ab0972588240b3fca0985d2e400432859
F test/orderby7.test 3d1383d52ade5b9eb3a173b3147fdd296f0202da
F test/orderby8.test 23ef1a5d72bd3adcc2f65561c654295d1b8047bd
F test/orderby9.test 87fb9548debcc2cd141c5299002dd94672fa76a3
F test/oserror.test 14fec2796c2b6fe431c7823750e8a18a761176d7
F test/oserror.test 361346396ae18462c7393c1ac5c3f17237bd89b2
F test/ovfl.test 4f7ca651cba5c059a12d8c67dddd49bec5747799
F test/pager1.test 1acbdb14c5952a72dd43129cabdbf69aaa3ed1fa
F test/pager2.test 67b8f40ae98112bcdba1f2b2d03ea83266418c71
@@ -1067,8 +1067,9 @@ F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4
F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a
F test/subtype1.test 7fe09496352f97053af1437150751be2d0a0cae8
F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2
F test/symlink.test 2513f7c030df0f435c6415687ba8b739f3d312df
F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85
F test/syscall.test d2fdaad713f103ac611fe7ef9b724c7b69f8149c
F test/syscall.test fba9ebdc6905d05bba6a835e691f20ed9ea2cc88
F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6
F test/tabfunc01.test 03c4ad422c6ab596cff6dcaf86dd061a9f039525
F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f
@@ -1418,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 2bbb9595ccc4fdd854bf16a1efcddbc42a7ff14e 7565b046ff939e8310631397a4526fbd98b99aaf
R 01665c5c372c0e12761e9c423a71cfd1
P 395a153ff7b3c7a72f3d02b6fe76d72383f4e480 6d5ce3ede4c7038c19a77268a5a7b9d5650933c2
R 108cce56953c38f03dac9fc0349473c4
U drh
Z b4b0651f582925800ad2e9fdf5ebff65
Z a9e0c02c1ba22a50e60adc1f82d63108
+1 -1
View File
@@ -1 +1 @@
395a153ff7b3c7a72f3d02b6fe76d72383f4e480
0546d1cd1a3402890edade7970c269cc3f17bc98
+25 -24
View File
@@ -1271,6 +1271,30 @@ void sqlite3AddDefaultValue(Parse *pParse, ExprSpan *pSpan){
sqlite3ExprDelete(db, pSpan->pExpr);
}
/*
** Backwards Compatibility Hack:
**
** Historical versions of SQLite accepted strings as column names in
** indexes and PRIMARY KEY constraints and in UNIQUE constraints. Example:
**
** CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim)
** CREATE INDEX abc ON xyz('c','d' DESC,'e' COLLATE nocase DESC);
**
** This is goofy. But to preserve backwards compatibility we continue to
** accept it. This routine does the necessary conversion. It converts
** the expression given in its argument from a TK_STRING into a TK_ID
** if the expression is just a TK_STRING with an optional COLLATE clause.
** If the epxression is anything other than TK_STRING, the expression is
** unchanged.
*/
static void sqlite3StringToId(Expr *p){
if( p->op==TK_STRING ){
p->op = TK_ID;
}else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){
p->pLeft->op = TK_ID;
}
}
/*
** Designate the PRIMARY KEY for the table. pList is a list of names
** of columns that form the primary key. If pList is NULL, then the
@@ -1317,6 +1341,7 @@ void sqlite3AddPrimaryKey(
for(i=0; i<nTerm; i++){
Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);
assert( pCExpr!=0 );
sqlite3StringToId(pCExpr);
if( pCExpr->op==TK_ID ){
const char *zCName = pCExpr->u.zToken;
for(iCol=0; iCol<pTab->nCol; iCol++){
@@ -2855,30 +2880,6 @@ Index *sqlite3AllocateIndexObject(
return p;
}
/*
** Backwards Compatibility Hack:
**
** Historical versions of SQLite accepted strings as column names in
** indexes and PRIMARY KEY constraints and in UNIQUE constraints. Example:
**
** CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim)
** CREATE INDEX abc ON xyz('c','d' DESC,'e' COLLATE nocase DESC);
**
** This is goofy. But to preserve backwards compatibility we continue to
** accept it. This routine does the necessary conversion. It converts
** the expression given in its argument from a TK_STRING into a TK_ID
** if the expression is just a TK_STRING with an optional COLLATE clause.
** If the epxression is anything other than TK_STRING, the expression is
** unchanged.
*/
static void sqlite3StringToId(Expr *p){
if( p->op==TK_STRING ){
p->op = TK_ID;
}else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){
p->pLeft->op = TK_ID;
}
}
/*
** Create a new index for an SQL table. pName1.pName2 is the name of the index
** and pTblList is the name of the table that is to be indexed. Both will
+47 -7
View File
@@ -464,6 +464,9 @@ static struct unix_syscall {
{ "getpagesize", (sqlite3_syscall_ptr)unixGetpagesize, 0 },
#define osGetpagesize ((int(*)(void))aSyscall[24].pCurrent)
{ "readlink", (sqlite3_syscall_ptr)readlink, 0 },
#define osReadlink ((ssize_t(*)(const char*,char*,size_t))aSyscall[25].pCurrent)
#endif
}; /* End of the overrideable system calls */
@@ -6026,6 +6029,7 @@ static int unixFullPathname(
int nOut, /* Size of output buffer in bytes */
char *zOut /* Output buffer */
){
int nByte;
/* It's odd to simulate an io-error here, but really this is just
** using the io-error infrastructure to test that SQLite handles this
@@ -6037,17 +6041,53 @@ static int unixFullPathname(
assert( pVfs->mxPathname==MAX_PATHNAME );
UNUSED_PARAMETER(pVfs);
zOut[nOut-1] = '\0';
if( zPath[0]=='/' ){
sqlite3_snprintf(nOut, zOut, "%s", zPath);
/* Attempt to resolve the path as if it were a symbolic link. If it is
** a symbolic link, the resolved path is stored in buffer zOut[]. Or, if
** the identified file is not a symbolic link or does not exist, then
** zPath is copied directly into zOut. Either way, nByte is left set to
** the size of the string copied into zOut[] in bytes. */
nByte = osReadlink(zPath, zOut, nOut-1);
if( nByte<0 ){
if( errno!=EINVAL && errno!=ENOENT ){
return unixLogError(SQLITE_CANTOPEN_BKPT, "readlink", zPath);
}
zOut[nOut-1] = '\0';
sqlite3_snprintf(nOut-1, zOut, "%s", zPath);
nByte = sqlite3Strlen30(zOut);
}else{
zOut[nByte] = '\0';
}
/* If buffer zOut[] now contains an absolute path there is nothing more
** to do. If it contains a relative path, do the following:
**
** * move the relative path string so that it is at the end of th
** zOut[] buffer.
** * Call getcwd() to read the path of the current working directory
** into the start of the zOut[] buffer.
** * Append a '/' character to the cwd string and move the
** relative path back within the buffer so that it immediately
** follows the '/'.
**
** This code is written so that if the combination of the CWD and relative
** path are larger than the allocated size of zOut[] the CWD is silently
** truncated to make it fit. This is Ok, as SQLite refuses to open any
** file for which this function returns a full path larger than (nOut-8)
** bytes in size. */
if( zOut[0]!='/' ){
int nCwd;
if( osGetcwd(zOut, nOut-1)==0 ){
int nRem = nOut-nByte-1;
memmove(&zOut[nRem], zOut, nByte+1);
zOut[nRem-1] = '\0';
if( osGetcwd(zOut, nRem-1)==0 ){
return unixLogError(SQLITE_CANTOPEN_BKPT, "getcwd", zPath);
}
nCwd = (int)strlen(zOut);
sqlite3_snprintf(nOut-nCwd, &zOut[nCwd], "/%s", zPath);
nCwd = sqlite3Strlen30(zOut);
assert( nCwd<=nRem-1 );
zOut[nCwd] = '/';
memmove(&zOut[nCwd+1], &zOut[nRem], nByte+1);
}
return SQLITE_OK;
}
@@ -7542,7 +7582,7 @@ int sqlite3_os_init(void){
/* Double-check that the aSyscall[] array has been constructed
** correctly. See ticket [bb3a86e890c8e96ab] */
assert( ArraySize(aSyscall)==25 );
assert( ArraySize(aSyscall)==26 );
/* Register all VFSes defined in the aVfs[] array */
for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
+6
View File
@@ -217,6 +217,7 @@ static int btree_cursor(
if( wrFlag ) wrFlag = BTREE_WRCSR;
pCur = (BtCursor *)ckalloc(sqlite3BtreeCursorSize());
memset(pCur, 0, sqlite3BtreeCursorSize());
sqlite3_mutex_enter(pBt->db->mutex);
sqlite3BtreeEnter(pBt);
#ifndef SQLITE_OMIT_SHARED_CACHE
rc = sqlite3BtreeLockTable(pBt, iTable, !!wrFlag);
@@ -225,6 +226,7 @@ static int btree_cursor(
rc = sqlite3BtreeCursor(pBt, iTable, wrFlag, 0, pCur);
}
sqlite3BtreeLeave(pBt);
sqlite3_mutex_leave(pBt->db->mutex);
if( rc ){
ckfree((char *)pCur);
Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
@@ -257,9 +259,11 @@ static int btree_close_cursor(
}
pCur = sqlite3TestTextToPtr(argv[1]);
pBt = pCur->pBtree;
sqlite3_mutex_enter(pBt->db->mutex);
sqlite3BtreeEnter(pBt);
rc = sqlite3BtreeCloseCursor(pCur);
sqlite3BtreeLeave(pBt);
sqlite3_mutex_leave(pBt->db->mutex);
ckfree((char *)pCur);
if( rc ){
Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);
@@ -630,9 +634,11 @@ static int btree_insert(
}
pCur = (BtCursor*)sqlite3TestTextToPtr(Tcl_GetString(objv[1]));
sqlite3_mutex_enter(pCur->pBtree->db->mutex);
sqlite3BtreeEnter(pCur->pBtree);
rc = sqlite3BtreeInsert(pCur, pKey, nKey, pData, nData, 0, 0, 0);
sqlite3BtreeLeave(pCur->pBtree);
sqlite3_mutex_leave(pCur->pBtree->db->mutex);
Tcl_ResetResult(interp);
if( rc ){
+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}
}