From 3be8b1a4f7848c1d67324893f4ac9cace8c06eb0 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 21 Oct 2017 12:59:27 +0000 Subject: [PATCH 001/190] Initial implementation of the appendvfs extension. Untested. FossilOrigin-Name: 063a03a3779e8c032dd006712facaaa6d60964425701ea10c753ff981a8f2bd9 --- ext/misc/appendvfs.c | 453 +++++++++++++++++++++++++++++++++++++++++++ manifest | 17 +- manifest.uuid | 2 +- 3 files changed, 464 insertions(+), 8 deletions(-) create mode 100644 ext/misc/appendvfs.c diff --git a/ext/misc/appendvfs.c b/ext/misc/appendvfs.c new file mode 100644 index 0000000000..b650b80be3 --- /dev/null +++ b/ext/misc/appendvfs.c @@ -0,0 +1,453 @@ +/* +** 2017-10-20 +** +** 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 a VFS shim that allows an SQLite database to be +** appended onto the end of some other file, such as an executable. +** +** A special record must appear at the end of the file that identifies the +** file as an appended database and provides an offset to page 1. For +** best performance page 1 should be located at a disk page boundary, though +** that is not required. +** +** An appended database is considered immutable. It is read-only and no +** locks are ever taken. +** +** If the file being opened is not an appended database, then this shim is +** a pass-through into the default underlying VFS. +**/ +#include +SQLITE_EXTENSION_INIT1 +#include +#include + +/* The append mark at the end of the database is: +** +** Start-Of-SQLite3-NNNNNNNN +** 123456789 123456789 12345 +** +** The NNNNNNNN represents a 64-bit big-endian unsigned integer which is +** the offset to page 1. +*/ +#define APND_MARK_PREFIX "Start-Of-SQLite3-" +#define APND_MARK_PREFIX_SZ 17 +#define APND_MARK_SIZE 25 + +/* +** Forward declaration of objects used by this utility +*/ +typedef struct sqlite3_vfs ApndVfs; +typedef struct ApndFile ApndFile; + +/* Access to a lower-level VFS that (might) implement dynamic loading, +** access to randomness, etc. +*/ +#define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData)) +#define ORIGFILE(p) ((sqlite3_file*)(((ApndFile*)(p))+1)) + +/* An open file */ +struct ApndFile { + sqlite3_file base; /* IO methods */ + sqlite3_int64 iPgOne; /* File offset to page 1 */ +}; + +/* +** Methods for ApndFile +*/ +static int apndClose(sqlite3_file*); +static int apndRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); +static int apndWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst); +static int apndTruncate(sqlite3_file*, sqlite3_int64 size); +static int apndSync(sqlite3_file*, int flags); +static int apndFileSize(sqlite3_file*, sqlite3_int64 *pSize); +static int apndLock(sqlite3_file*, int); +static int apndUnlock(sqlite3_file*, int); +static int apndCheckReservedLock(sqlite3_file*, int *pResOut); +static int apndFileControl(sqlite3_file*, int op, void *pArg); +static int apndSectorSize(sqlite3_file*); +static int apndDeviceCharacteristics(sqlite3_file*); +static int apndShmMap(sqlite3_file*, int iPg, int pgsz, int, void volatile**); +static int apndShmLock(sqlite3_file*, int offset, int n, int flags); +static void apndShmBarrier(sqlite3_file*); +static int apndShmUnmap(sqlite3_file*, int deleteFlag); +static int apndFetch(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp); +static int apndUnfetch(sqlite3_file*, sqlite3_int64 iOfst, void *p); + +/* +** Methods for ApndVfs +*/ +static int apndOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *); +static int apndDelete(sqlite3_vfs*, const char *zName, int syncDir); +static int apndAccess(sqlite3_vfs*, const char *zName, int flags, int *); +static int apndFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut); +static void *apndDlOpen(sqlite3_vfs*, const char *zFilename); +static void apndDlError(sqlite3_vfs*, int nByte, char *zErrMsg); +static void (*apndDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void); +static void apndDlClose(sqlite3_vfs*, void*); +static int apndRandomness(sqlite3_vfs*, int nByte, char *zOut); +static int apndSleep(sqlite3_vfs*, int microseconds); +static int apndCurrentTime(sqlite3_vfs*, double*); +static int apndGetLastError(sqlite3_vfs*, int, char *); +static int apndCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*); +static int apndSetSystemCall(sqlite3_vfs*, const char*,sqlite3_syscall_ptr); +static sqlite3_syscall_ptr apndGetSystemCall(sqlite3_vfs*, const char *z); +static const char *apndNextSystemCall(sqlite3_vfs*, const char *zName); + +static sqlite3_vfs apnd_vfs = { + 3, /* iVersion (set when registered) */ + 0, /* szOsFile (set when registered) */ + 1024, /* mxPathname */ + 0, /* pNext */ + "apndvfs", /* zName */ + 0, /* pAppData (set when registered) */ + apndOpen, /* xOpen */ + apndDelete, /* xDelete */ + apndAccess, /* xAccess */ + apndFullPathname, /* xFullPathname */ + apndDlOpen, /* xDlOpen */ + apndDlError, /* xDlError */ + apndDlSym, /* xDlSym */ + apndDlClose, /* xDlClose */ + apndRandomness, /* xRandomness */ + apndSleep, /* xSleep */ + apndCurrentTime, /* xCurrentTime */ + apndGetLastError, /* xGetLastError */ + apndCurrentTimeInt64, /* xCurrentTimeInt64 */ + apndSetSystemCall, /* xSetSystemCall */ + apndGetSystemCall, /* xGetSystemCall */ + apndNextSystemCall /* xNextSystemCall */ +}; + +static const sqlite3_io_methods apnd_io_methods = { + 3, /* iVersion */ + apndClose, /* xClose */ + apndRead, /* xRead */ + apndWrite, /* xWrite */ + apndTruncate, /* xTruncate */ + apndSync, /* xSync */ + apndFileSize, /* xFileSize */ + apndLock, /* xLock */ + apndUnlock, /* xUnlock */ + apndCheckReservedLock, /* xCheckReservedLock */ + apndFileControl, /* xFileControl */ + apndSectorSize, /* xSectorSize */ + apndDeviceCharacteristics, /* xDeviceCharacteristics */ + apndShmMap, /* xShmMap */ + apndShmLock, /* xShmLock */ + apndShmBarrier, /* xShmBarrier */ + apndShmUnmap, /* xShmUnmap */ + apndFetch, /* xFetch */ + apndUnfetch /* xUnfetch */ +}; + + + +/* +** Close an apnd-file. +*/ +static int apndClose(sqlite3_file *pFile){ + pFile = ORIGFILE(pFile); + return pFile->pMethods->xClose(pFile); +} + +/* +** Read data from an apnd-file. +*/ +static int apndRead( + sqlite3_file *pFile, + void *zBuf, + int iAmt, + sqlite_int64 iOfst +){ + ApndFile *p = (ApndFile *)pFile; + pFile = ORIGFILE(pFile); + return pFile->pMethods->xRead(pFile, zBuf, iAmt, iOfst+p->iPgOne); +} + +/* +** Write data to an apnd-file. +*/ +static int apndWrite( + sqlite3_file *pFile, + const void *z, + int iAmt, + sqlite_int64 iOfst +){ + return SQLITE_READONLY; +} + +/* +** Truncate an apnd-file. +*/ +static int apndTruncate(sqlite3_file *pFile, sqlite_int64 size){ + return SQLITE_READONLY; +} + +/* +** Sync an apnd-file. +*/ +static int apndSync(sqlite3_file *pFile, int flags){ + return SQLITE_READONLY; +} + +/* +** Return the current file-size of an apnd-file. +*/ +static int apndFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ + ApndFile *p = (ApndFile*)pFile; + int rc; + pFile = ORIGFILE(p); + rc = pFile->pMethods->xFileSize(pFile, pSize); + if( rc==SQLITE_OK && p->iPgOne ){ + *pSize -= p->iPgOne + APND_MARK_SIZE; + } + return rc; +} + +/* +** Lock an apnd-file. +*/ +static int apndLock(sqlite3_file *pFile, int eLock){ + return SQLITE_READONLY; +} + +/* +** Unlock an apnd-file. +*/ +static int apndUnlock(sqlite3_file *pFile, int eLock){ + return SQLITE_OK; +} + +/* +** Check if another file-handle holds a RESERVED lock on an apnd-file. +*/ +static int apndCheckReservedLock(sqlite3_file *pFile, int *pResOut){ + *pResOut = 0; + return SQLITE_OK; +} + +/* +** File control method. For custom operations on an apnd-file. +*/ +static int apndFileControl(sqlite3_file *pFile, int op, void *pArg){ + ApndFile *p = (ApndFile *)pFile; + int rc; + pFile = ORIGFILE(pFile); + rc = pFile->pMethods->xFileControl(pFile, op, pArg); + if( rc==SQLITE_OK && op==SQLITE_FCNTL_VFSNAME ){ + *(char**)pArg = sqlite3_mprintf("apnd(%lld)/%z", p->iPgOne, *(char**)pArg); + } + return rc; +} + +/* +** Return the sector-size in bytes for an apnd-file. +*/ +static int apndSectorSize(sqlite3_file *pFile){ + pFile = ORIGFILE(pFile); + return pFile->pMethods->xSectorSize(pFile); +} + +/* +** Return the device characteristic flags supported by an apnd-file. +*/ +static int apndDeviceCharacteristics(sqlite3_file *pFile){ + pFile = ORIGFILE(pFile); + return SQLITE_IOCAP_IMMUTABLE | + pFile->pMethods->xDeviceCharacteristics(pFile); +} + +/* Create a shared memory file mapping */ +static int apndShmMap( + sqlite3_file *pFile, + int iPg, + int pgsz, + int bExtend, + void volatile **pp +){ + return SQLITE_READONLY; +} + +/* Perform locking on a shared-memory segment */ +static int apndShmLock(sqlite3_file *pFile, int offset, int n, int flags){ + return SQLITE_READONLY; +} + +/* Memory barrier operation on shared memory */ +static void apndShmBarrier(sqlite3_file *pFile){ + return; +} + +/* Unmap a shared memory segment */ +static int apndShmUnmap(sqlite3_file *pFile, int deleteFlag){ + return SQLITE_OK; +} + +/* Fetch a page of a memory-mapped file */ +static int apndFetch( + sqlite3_file *pFile, + sqlite3_int64 iOfst, + int iAmt, + void **pp +){ + ApndFile *p = (ApndFile *)pFile; + pFile = ORIGFILE(pFile); + return pFile->pMethods->xFetch(pFile, iOfst+p->iPgOne, iAmt, pp); +} + +/* Release a memory-mapped page */ +static int apndUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ + ApndFile *p = (ApndFile *)pFile; + pFile = ORIGFILE(pFile); + return pFile->pMethods->xUnfetch(pFile, iOfst+p->iPgOne, pPage); +} + +/* +** Open an apnd file handle. +*/ +static int apndOpen( + sqlite3_vfs *pVfs, + const char *zName, + sqlite3_file *pFile, + int flags, + int *pOutFlags +){ + ApndFile *p; + int rc; + sqlite3_int64 sz; + pVfs = ORIGVFS(pVfs); + if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){ + return pVfs->xOpen(pVfs, zName, pFile, flags, pOutFlags); + } + p = (ApndFile*)pFile; + memset(p, 0, sizeof(*p)); + p->base.pMethods = &apnd_io_methods; + pFile = ORIGFILE(pFile); + flags &= ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE); + flags |= SQLITE_OPEN_READONLY; + rc = pVfs->xOpen(pVfs, zName, pFile, flags, pOutFlags); + if( rc ) return rc; + rc = pFile->pMethods->xFileSize(pFile, &sz); + if( rc==SQLITE_OK && sz>512 ){ + unsigned char a[APND_MARK_SIZE]; + rc = pFile->pMethods->xRead(pFile, a, APND_MARK_SIZE, sz-APND_MARK_SIZE); + if( rc==SQLITE_OK + && memcmp(a, APND_MARK_PREFIX, APND_MARK_PREFIX_SZ)==0 + ){ + p->iPgOne = + ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ]<<56) + + ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+1]<<48) + + ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+2]<<40) + + ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+3]<<32) + + ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+4]<<24) + + ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+5]<<16) + + ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+6]<<8) + + ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+7]); + } + } + return SQLITE_OK; +} + +/* +** All other VFS methods are pass-thrus. +*/ +static int apndDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ + return ORIGVFS(pVfs)->xDelete(ORIGVFS(pVfs), zPath, dirSync); +} +static int apndAccess( + sqlite3_vfs *pVfs, + const char *zPath, + int flags, + int *pResOut +){ + return ORIGVFS(pVfs)->xAccess(ORIGVFS(pVfs), zPath, flags, pResOut); +} +static int apndFullPathname( + sqlite3_vfs *pVfs, + const char *zPath, + int nOut, + char *zOut +){ + return ORIGVFS(pVfs)->xFullPathname(ORIGVFS(pVfs),zPath,nOut,zOut); +} +static void *apndDlOpen(sqlite3_vfs *pVfs, const char *zPath){ + return ORIGVFS(pVfs)->xDlOpen(ORIGVFS(pVfs), zPath); +} +static void apndDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){ + ORIGVFS(pVfs)->xDlError(ORIGVFS(pVfs), nByte, zErrMsg); +} +static void (*apndDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){ + return ORIGVFS(pVfs)->xDlSym(ORIGVFS(pVfs), p, zSym); +} +static void apndDlClose(sqlite3_vfs *pVfs, void *pHandle){ + ORIGVFS(pVfs)->xDlClose(ORIGVFS(pVfs), pHandle); +} +static int apndRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ + return ORIGVFS(pVfs)->xRandomness(ORIGVFS(pVfs), nByte, zBufOut); +} +static int apndSleep(sqlite3_vfs *pVfs, int nMicro){ + return ORIGVFS(pVfs)->xSleep(ORIGVFS(pVfs), nMicro); +} +static int apndCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ + return ORIGVFS(pVfs)->xCurrentTime(ORIGVFS(pVfs), pTimeOut); +} +static int apndGetLastError(sqlite3_vfs *pVfs, int a, char *b){ + return ORIGVFS(pVfs)->xGetLastError(ORIGVFS(pVfs), a, b); +} +static int apndCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){ + return ORIGVFS(pVfs)->xCurrentTimeInt64(ORIGVFS(pVfs), p); +} +static int apndSetSystemCall( + sqlite3_vfs *pVfs, + const char *zName, + sqlite3_syscall_ptr pCall +){ + return ORIGVFS(pVfs)->xSetSystemCall(ORIGVFS(pVfs),zName,pCall); +} +static sqlite3_syscall_ptr apndGetSystemCall( + sqlite3_vfs *pVfs, + const char *zName +){ + return ORIGVFS(pVfs)->xGetSystemCall(ORIGVFS(pVfs),zName); +} +static const char *apndNextSystemCall(sqlite3_vfs *pVfs, const char *zName){ + return ORIGVFS(pVfs)->xNextSystemCall(ORIGVFS(pVfs), zName); +} + + +#ifdef _WIN32 +__declspec(dllexport) +#endif +/* +** This routine is called when the extension is loaded. +** Register the new VFS. +*/ +int sqlite3_appendvfs_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ + int rc = SQLITE_OK; + sqlite3_vfs *pOrig; + SQLITE_EXTENSION_INIT2(pApi); + pOrig = sqlite3_vfs_find(0); + apnd_vfs.iVersion = pOrig->iVersion; + apnd_vfs.pAppData = pOrig; + apnd_vfs.szOsFile = sizeof(ApndFile); + rc = sqlite3_vfs_register(&apnd_vfs, 1); +#ifdef APPENDVFS_TEST + if( rc==SQLITE_OK ){ + rc = sqlite3_auto_extension((void(*)(void))apndvfsRegister); + } +#endif + if( rc==SQLITE_OK ) rc = SQLITE_OK_LOAD_PERMANENTLY; + return rc; +} diff --git a/manifest b/manifest index 5c8ae4d13c..e9413c8f80 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Take\sextra\scare\sto\savoid\san\sOOB\sread\scaused\sby\sa\scorrupt\sb-tree\spage. -D 2017-10-19T15:17:38.752 +C Initial\simplementation\sof\sthe\sappendvfs\sextension.\s\sUntested. +D 2017-10-21T12:59:27.233 F Makefile.in e016061b23e60ac9ec27c65cb577292b6bde0307ca55abd874ab3487b3b1beb2 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 37740aba9c4bb359c627eadccf1cfd7be4f5f847078723777ea7763969e533b1 @@ -258,6 +258,7 @@ F ext/lsm1/test/lsm1_simple.test ca949efefa102f4644231dcd9291d8cda7699a4ce1006b2 F ext/misc/README.md 8e008c8d2b02e09096b31dfba033253ac27c6c06a18aa5826e299fa7601d90b2 F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb +F ext/misc/appendvfs.c 487a5db4427d118413346780c4c90d0256315e8de3fb528ee54daef3bb73276f F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/completion.c 52c3f01523e3e387eb321b4739a89d1fe47cbe6025aa1f2d8d3685e9e365df0f @@ -1664,8 +1665,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cd0471ca9f75e7c8be74536ff4ec85b5d70f0d7994b680ed5f45b9f12a46cf46 -R 14641e8822b464d39bf472f899e19240 -T +closed 9dd591ef24b302a5fe2af0619d0cda6733348bacc541b3c0a134ac25981d4b2a -U dan -Z 576e55698c218b4128bbad5de39dc1b0 +P 04925dee41a21ffca9a9f9df27d8165431668c42c2b33d08b077fdb28011170b +R b5d8b4b601b02e4902be4e639107c749 +T *branch * appendvfs +T *sym-appendvfs * +T -sym-trunk * +U drh +Z 11816656e34dd3c798cb5d3f2287708a diff --git a/manifest.uuid b/manifest.uuid index 26a2375f60..69ef83190d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -04925dee41a21ffca9a9f9df27d8165431668c42c2b33d08b077fdb28011170b \ No newline at end of file +063a03a3779e8c032dd006712facaaa6d60964425701ea10c753ff981a8f2bd9 \ No newline at end of file From 72afc3c5de1a4c125b919fe086f83dfe27a43e03 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 5 Dec 2017 18:32:40 +0000 Subject: [PATCH 002/190] If SQLITE_HAVE_ZLIB is defined at build-time, include the functions in ext/misc/compress.c in the shell. FossilOrigin-Name: 0296286a9963bbaab60ee30d8700703f5ccb382380c9bfc0eb12c4bcb6f2accd --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/shell.c.in | 6 ++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index f5ffa7a07d..d6e9390bd0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scompilation\sproblem\swhen\sboth\sSQLITE_ENABLE_MULTITHREADED_CHECKS\sand\nSQLITE_ENABLE_API_ARMOUR\sare\sdefined. -D 2017-12-05T14:58:59.468 +C If\sSQLITE_HAVE_ZLIB\sis\sdefined\sat\sbuild-time,\sinclude\sthe\sfunctions\sin\next/misc/compress.c\sin\sthe\sshell. +D 2017-12-05T18:32:40.201 F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e5d7606238f55816da99f719969598df5b091aa2e9a6935c9412fcae8f53fc44 @@ -472,7 +472,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in 6ffed0c589f5aff180789a8c8abf5b2d3e2eea7470c86b30e797887cb0c9d0e5 +F src/shell.c.in ab727c09b4c87c0c1db32d2fe0a910c0a8e468a0209233328753f5526d6c6c73 F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1679,7 +1679,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5771b1d611b3562ea6c040f3f893073c4d0ee58c35b37ae211520d9aee8ed547 -R 926398ae5d668c18adb3c9f09b2dd707 +P 0342ce510d2063a63839399a2cfa25b7fc02f4fde17764082676b332d6136241 +R eddb6c6e05812e7a9afe7b2909e80007 +T *branch * sqlar-shell-support +T *sym-sqlar-shell-support * +T -sym-trunk * U dan -Z 60a10472a4a400f76cfacb5adca001dc +Z e3b1a40cd391e9a775fce7f501c26e90 diff --git a/manifest.uuid b/manifest.uuid index 3ccf62c280..6f484dbf3c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0342ce510d2063a63839399a2cfa25b7fc02f4fde17764082676b332d6136241 \ No newline at end of file +0296286a9963bbaab60ee30d8700703f5ccb382380c9bfc0eb12c4bcb6f2accd \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 062f76e475..edd75b078c 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -796,6 +796,9 @@ static void shellAddSchemaName( INCLUDE ../ext/misc/shathree.c INCLUDE ../ext/misc/fileio.c INCLUDE ../ext/misc/completion.c +#ifdef SQLITE_HAVE_ZLIB +INCLUDE ../ext/misc/compress.c +#endif #if defined(SQLITE_ENABLE_SESSION) /* @@ -2897,6 +2900,9 @@ static void open_db(ShellState *p, int keepAlive){ sqlite3_fileio_init(p->db, 0, 0); sqlite3_shathree_init(p->db, 0, 0); sqlite3_completion_init(p->db, 0, 0); +#ifdef SQLITE_HAVE_ZLIB + sqlite3_compress_init(p->db, 0, 0); +#endif sqlite3_create_function(p->db, "shell_add_schema", 2, SQLITE_UTF8, 0, shellAddSchemaName, 0, 0); } From cb6acda902b5a1ad02fa888d7b95884ba1bc94d1 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 5 Dec 2017 18:54:12 +0000 Subject: [PATCH 003/190] Add support for including zlib in the shell when compiling with MSVC. FossilOrigin-Name: e1838cee3847301ef491467dc75d9c4e1e3b12599596c058bdb14319a52fd8a0 --- .fossil-settings/empty-dirs | 1 + .fossil-settings/ignore-glob | 1 + Makefile.msc | 83 +++++++++++++++++++++++++++++++++--- autoconf/Makefile.msc | 1 + manifest | 21 +++++---- manifest.uuid | 2 +- 6 files changed, 92 insertions(+), 17 deletions(-) create mode 100644 .fossil-settings/empty-dirs create mode 100644 .fossil-settings/ignore-glob diff --git a/.fossil-settings/empty-dirs b/.fossil-settings/empty-dirs new file mode 100644 index 0000000000..64fb6839df --- /dev/null +++ b/.fossil-settings/empty-dirs @@ -0,0 +1 @@ +compat diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob new file mode 100644 index 0000000000..5282ca9c3d --- /dev/null +++ b/.fossil-settings/ignore-glob @@ -0,0 +1 @@ +compat/* diff --git a/Makefile.msc b/Makefile.msc index b16f08adee..e924db395a 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -92,6 +92,20 @@ SPLIT_AMALGAMATION = 0 !ENDIF # <> +# Set this non-0 to use zlib, possibly compiling it from source code. +# +!IFNDEF USE_ZLIB +USE_ZLIB = 0 +!ENDIF + +# Set this non-0 to build zlib from source code. This is enabled by +# default and in that case it will be assumed that the ZLIBDIR macro +# points to the top-level source code directory for zlib. +# +!IFNDEF BUILD_ZLIB +BUILD_ZLIB = 1 +!ENDIF + # Set this non-0 to use the International Components for Unicode (ICU). # !IFNDEF USE_ICU @@ -612,6 +626,14 @@ SHELL_CORE_DEP = !ENDIF !ENDIF +# <> +# If zlib support is enabled, add the shell dependency for it. +# +!IF $(USE_ZLIB)!=0 && $(BUILD_ZLIB)!=0 +SHELL_CORE_DEP = zlib $(SHELL_CORE_DEP) +!ENDIF +# <> + # This is the core library that the shell executable should link with. # !IFNDEF SHELL_CORE_LIB @@ -802,12 +824,16 @@ RCC = $(RCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1 # prior to running nmake in order to match the actual installed location and # version on this machine. # +!IFNDEF TCLDIR +TCLDIR = c:\tcl +!ENDIF + !IFNDEF TCLINCDIR -TCLINCDIR = c:\tcl\include +TCLINCDIR = $(TCLDIR)\include !ENDIF !IFNDEF TCLLIBDIR -TCLLIBDIR = c:\tcl\lib +TCLLIBDIR = $(TCLDIR)\lib !ENDIF !IFNDEF LIBTCL @@ -819,7 +845,32 @@ LIBTCLSTUB = tclstub86.lib !ENDIF !IFNDEF LIBTCLPATH -LIBTCLPATH = c:\tcl\bin +LIBTCLPATH = $(TCLDIR)\bin +!ENDIF + +# The locations of the zlib header and library files. These variables +# (ZLIBINCDIR, ZLIBLIBDIR, and ZLIBLIB) may be overridden via the environment +# prior to running nmake in order to match the actual installed (or source +# code) location on this machine. +# +!IFNDEF ZLIBDIR +ZLIBDIR = $(TOP)\compat\zlib +!ENDIF + +!IFNDEF ZLIBINCDIR +ZLIBINCDIR = $(ZLIBDIR) +!ENDIF + +!IFNDEF ZLIBLIBDIR +ZLIBLIBDIR = $(ZLIBDIR) +!ENDIF + +!IFNDEF ZLIBLIB +!IF $(DYNAMIC_SHELL)!=0 +ZLIBLIB = zdll.lib +!ELSE +ZLIBLIB = zlib.lib +!ENDIF !ENDIF # The locations of the ICU header and library files. These variables @@ -827,12 +878,16 @@ LIBTCLPATH = c:\tcl\bin # prior to running nmake in order to match the actual installed location on # this machine. # +!IFNDEF ICUDIR +ICUDIR = C:\icu +!ENDIF + !IFNDEF ICUINCDIR -ICUINCDIR = c:\icu\include +ICUINCDIR = $(ICUDIR)\include !ENDIF !IFNDEF ICULIBDIR -ICULIBDIR = c:\icu\lib +ICULIBDIR = $(ICUDIR)\lib !ENDIF !IFNDEF LIBICU @@ -951,6 +1006,15 @@ BCC = $(BCC) -Zi !ENDIF # <> +# If zlib support is enabled, add the compiler options for it. +# +!IF $(USE_ZLIB)!=0 +TCC = $(TCC) -DSQLITE_HAVE_ZLIB=1 +RCC = $(RCC) -DSQLITE_HAVE_ZLIB=1 +TCC = $(TCC) -I$(ZLIBINCDIR) +RCC = $(RCC) -I$(ZLIBINCDIR) +!ENDIF + # If ICU support is enabled, add the compiler options for it. # !IF $(USE_ICU)!=0 @@ -1075,6 +1139,13 @@ LTLIBPATHS = /LIBPATH:$(TCLLIBDIR) LTLIBS = $(LTLIBS) $(LIBTCL) !ENDIF +# If zlib support is enabled, add the linker options for it. +# +!IF $(USE_ZLIB)!=0 +LTLIBPATHS = $(LTLIBPATHS) /LIBPATH:$(ZLIBLIBDIR) +LTLIBS = $(LTLIBS) $(ZLIBLIB) +!ENDIF + # If ICU support is enabled, add the linker options for it. # !IF $(USE_ICU)!=0 @@ -1987,6 +2058,8 @@ SHELL_SRC = \ shell.c: $(SHELL_SRC) $(TOP)\tool\mkshellc.tcl $(TCLSH_CMD) $(TOP)\tool\mkshellc.tcl > shell.c +zlib: + pushd $(ZLIBDIR) && $(MAKE) /f win32\Makefile.msc $(ZLIBLIB) && popd # Rules to build the extension objects. # diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index 199af21ea9..5b5133c8b9 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -561,6 +561,7 @@ SHELL_CORE_DEP = !ENDIF !ENDIF + # This is the core library that the shell executable should link with. # !IFNDEF SHELL_CORE_LIB diff --git a/manifest b/manifest index d6e9390bd0..f406bec75d 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,10 @@ -C If\sSQLITE_HAVE_ZLIB\sis\sdefined\sat\sbuild-time,\sinclude\sthe\sfunctions\sin\next/misc/compress.c\sin\sthe\sshell. -D 2017-12-05T18:32:40.201 +C Add\ssupport\sfor\sincluding\szlib\sin\sthe\sshell\swhen\scompiling\swith\sMSVC. +D 2017-12-05T18:54:12.861 +F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 +F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc e5d7606238f55816da99f719969598df5b091aa2e9a6935c9412fcae8f53fc44 +F Makefile.msc 2cc781176ca1a58bfb7c2741a192726e2f08db0b473daba3d6c3388d44698470 F README.md f5c87359573c4d255425e588a56554b50fdcc2afba4e017a2e02a43701456afd F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -11,7 +13,7 @@ F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am 66c0befa511f0d95ba229e180067cf0357a9ebf8b3201b06d683c5ba6220fb39 -F autoconf/Makefile.msc b88a70dee8453cc353e5d6df172d60a11a0af905710a24b1e6be80f8fea6e96b +F autoconf/Makefile.msc 2b4b5e5ff7e7a9806ebdd4b441f8fb54695a3628701a97ae53860e67e872acc3 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 F autoconf/configure.ac 8dd08ca564279fff091c9bfdd2599d8f992c9f1f70c5396de2126ad2bd1b3bed @@ -1679,10 +1681,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0342ce510d2063a63839399a2cfa25b7fc02f4fde17764082676b332d6136241 -R eddb6c6e05812e7a9afe7b2909e80007 -T *branch * sqlar-shell-support -T *sym-sqlar-shell-support * -T -sym-trunk * -U dan -Z e3b1a40cd391e9a775fce7f501c26e90 +P 0296286a9963bbaab60ee30d8700703f5ccb382380c9bfc0eb12c4bcb6f2accd +R 8fbbfa59bd11832619e2c9584cf54899 +U mistachkin +Z 4e0794167698ff60a9b30c96ee6b24e0 diff --git a/manifest.uuid b/manifest.uuid index 6f484dbf3c..c2f98dfc4d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0296286a9963bbaab60ee30d8700703f5ccb382380c9bfc0eb12c4bcb6f2accd \ No newline at end of file +e1838cee3847301ef491467dc75d9c4e1e3b12599596c058bdb14319a52fd8a0 \ No newline at end of file From a0fcafe7623efb2bbef52e15b8dbc6ae82e71c0c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 5 Dec 2017 19:07:30 +0000 Subject: [PATCH 004/190] For MSVC, simplify default locations for Tcl and ICU by using directories inside 'compat'. FossilOrigin-Name: 8155b5ac850327ea76aba2adf624132f3e05024c973afd218b12f186fc7630e8 --- Makefile.msc | 17 +++++++++++++++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index e924db395a..c40d195404 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -92,6 +92,15 @@ SPLIT_AMALGAMATION = 0 !ENDIF # <> +# Set this non-0 to have this makefile assume the Tcl shell executable +# (tclsh*.exe) is available in the PATH. By default, this is enabled +# for compatibility with older build environments. This setting only +# applies if TCLSH_CMD is not set manually. +# +!IFNDEF USE_TCLSH_IN_PATH +USE_TCLSH_IN_PATH = 1 +!ENDIF + # Set this non-0 to use zlib, possibly compiling it from source code. # !IFNDEF USE_ZLIB @@ -825,7 +834,7 @@ RCC = $(RCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1 # version on this machine. # !IFNDEF TCLDIR -TCLDIR = c:\tcl +TCLDIR = $(TOP)\compat\tcl !ENDIF !IFNDEF TCLINCDIR @@ -879,7 +888,7 @@ ZLIBLIB = zlib.lib # this machine. # !IFNDEF ICUDIR -ICUDIR = C:\icu +ICUDIR = $(TOP)\compat\icu !ENDIF !IFNDEF ICUINCDIR @@ -900,7 +909,11 @@ LIBICU = icuuc.lib icuin.lib # specific Tcl shell to use. # !IFNDEF TCLSH_CMD +!IF $(USE_TCLSH_IN_PATH)!=0 TCLSH_CMD = tclsh +!ELSE +TCLSH_CMD = $(TCLDIR)\bin\tclsh.exe +!ENDIF !ENDIF # <> diff --git a/manifest b/manifest index f406bec75d..3e24dc86b3 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Add\ssupport\sfor\sincluding\szlib\sin\sthe\sshell\swhen\scompiling\swith\sMSVC. -D 2017-12-05T18:54:12.861 +C For\sMSVC,\ssimplify\sdefault\slocations\sfor\sTcl\sand\sICU\sby\susing\sdirectories\sinside\s'compat'. +D 2017-12-05T19:07:30.651 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 2cc781176ca1a58bfb7c2741a192726e2f08db0b473daba3d6c3388d44698470 +F Makefile.msc 2eb985916ed36fb4ba73033d030090fbf22d4d972e06caee19e7d89fb305a8ab F README.md f5c87359573c4d255425e588a56554b50fdcc2afba4e017a2e02a43701456afd F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1681,7 +1681,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0296286a9963bbaab60ee30d8700703f5ccb382380c9bfc0eb12c4bcb6f2accd -R 8fbbfa59bd11832619e2c9584cf54899 +P e1838cee3847301ef491467dc75d9c4e1e3b12599596c058bdb14319a52fd8a0 +R a792968384e617f4a37df83169716b24 U mistachkin -Z 4e0794167698ff60a9b30c96ee6b24e0 +Z 06008f15f266edb3571035a6d698db2a diff --git a/manifest.uuid b/manifest.uuid index c2f98dfc4d..b50deeb9bc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1838cee3847301ef491467dc75d9c4e1e3b12599596c058bdb14319a52fd8a0 \ No newline at end of file +8155b5ac850327ea76aba2adf624132f3e05024c973afd218b12f186fc7630e8 \ No newline at end of file From fd0245d771542a60f17fb7aa5c1ab13990d0a92f Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Dec 2017 15:44:29 +0000 Subject: [PATCH 005/190] Begin adding support for the sqlar archive format to shell.c. There is no "extract" command so far, only "create". FossilOrigin-Name: c9827a01a6e107f38f85c2b2c1c7a599e443067b106217e965b6936441ca619d --- ext/misc/fileio.c | 403 ++++++++++++++++++++++++++++++++++++++++++++-- manifest | 16 +- manifest.uuid | 2 +- src/shell.c.in | 215 +++++++++++++++++++++++++ 4 files changed, 611 insertions(+), 25 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 2c00ad971d..475f3713ce 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -12,11 +12,46 @@ ** ** This SQLite extension implements SQL functions readfile() and ** writefile(). +** +** Also, an eponymous virtual table type "fsdir". Used as follows: +** +** SELECT * FROM fsdir($dirname); +** +** Returns one row for each entry in the directory $dirname. No row is +** returned for "." or "..". Row columns are as follows: +** +** name: Name of directory entry. +** mode: Value of stat.st_mode for directory entry. +** mtime: Value of stat.st_mtime for directory entry. +** data: For a regular file, a blob containing the file data. For a +** symlink, a text value containing the text of the link. For a +** directory, NULL. */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #include +#define FSDIR_SCHEMA "CREATE TABLE x(name,mode,mtime,data,dir HIDDEN)" + +static void readFileContents(sqlite3_context *ctx, const char *zName){ + FILE *in; + long nIn; + void *pBuf; + + in = fopen(zName, "rb"); + if( in==0 ) return; + fseek(in, 0, SEEK_END); + nIn = ftell(in); + rewind(in); + pBuf = sqlite3_malloc( nIn ); + if( pBuf && 1==fread(pBuf, nIn, 1, in) ){ + sqlite3_result_blob(ctx, pBuf, nIn, sqlite3_free); + }else{ + sqlite3_free(pBuf); + } + fclose(in); +} + /* ** Implementation of the "readfile(X)" SQL function. The entire content ** of the file named X is read and returned as a BLOB. NULL is returned @@ -28,25 +63,10 @@ static void readfileFunc( sqlite3_value **argv ){ const char *zName; - FILE *in; - long nIn; - void *pBuf; - (void)(argc); /* Unused parameter */ zName = (const char*)sqlite3_value_text(argv[0]); if( zName==0 ) return; - in = fopen(zName, "rb"); - if( in==0 ) return; - fseek(in, 0, SEEK_END); - nIn = ftell(in); - rewind(in); - pBuf = sqlite3_malloc( nIn ); - if( pBuf && 1==fread(pBuf, nIn, 1, in) ){ - sqlite3_result_blob(context, pBuf, nIn, sqlite3_free); - }else{ - sqlite3_free(pBuf); - } - fclose(in); + readFileContents(context, zName); } /* @@ -80,6 +100,354 @@ static void writefileFunc( sqlite3_result_int64(context, rc); } +#ifndef SQLITE_OMIT_VIRTUALTABLE + +#include +#include +#include +#include + +/* +*/ +typedef struct fsdir_cursor fsdir_cursor; +struct fsdir_cursor { + sqlite3_vtab_cursor base; /* Base class - must be first */ + int eType; /* One of FSDIR_DIR or FSDIR_ENTRY */ + DIR *pDir; /* From opendir() */ + struct stat sStat; /* Current lstat() results */ + char *zDir; /* Directory to read */ + int nDir; /* Value of strlen(zDir) */ + char *zPath; /* Path to current entry */ + int bEof; + sqlite3_int64 iRowid; /* Current rowid */ +}; + +typedef struct fsdir_tab fsdir_tab; +struct fsdir_tab { + sqlite3_vtab base; /* Base class - must be first */ + int eType; /* One of FSDIR_DIR or FSDIR_ENTRY */ +}; + +#define FSDIR_DIR 0 +#define FSDIR_ENTRY 1 + +/* +** Construct a new fsdir virtual table object. +*/ +static int fsdirConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + fsdir_tab *pNew = 0; + int rc; + + rc = sqlite3_declare_vtab(db, FSDIR_SCHEMA); + if( rc==SQLITE_OK ){ + pNew = (fsdir_tab*)sqlite3_malloc( sizeof(*pNew) ); + if( pNew==0 ) return SQLITE_NOMEM; + memset(pNew, 0, sizeof(*pNew)); + pNew->eType = (pAux==0 ? FSDIR_DIR : FSDIR_ENTRY); + } + *ppVtab = (sqlite3_vtab*)pNew; + return rc; +} + +/* +** This method is the destructor for fsdir vtab objects. +*/ +static int fsdirDisconnect(sqlite3_vtab *pVtab){ + sqlite3_free(pVtab); + return SQLITE_OK; +} + +/* +** Constructor for a new fsdir_cursor object. +*/ +static int fsdirOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ + fsdir_cursor *pCur; + pCur = sqlite3_malloc( sizeof(*pCur) ); + if( pCur==0 ) return SQLITE_NOMEM; + memset(pCur, 0, sizeof(*pCur)); + pCur->eType = ((fsdir_tab*)p)->eType; + *ppCursor = &pCur->base; + return SQLITE_OK; +} + +/* +** Destructor for an fsdir_cursor. +*/ +static int fsdirClose(sqlite3_vtab_cursor *cur){ + fsdir_cursor *pCur = (fsdir_cursor*)cur; + if( pCur->pDir ) closedir(pCur->pDir); + sqlite3_free(pCur->zDir); + sqlite3_free(pCur->zPath); + sqlite3_free(pCur); + return SQLITE_OK; +} + +/* +** Advance an fsdir_cursor to its next row of output. +*/ +static int fsdirNext(sqlite3_vtab_cursor *cur){ + fsdir_cursor *pCur = (fsdir_cursor*)cur; + struct dirent *pEntry; + + if( pCur->eType==FSDIR_ENTRY ){ + pCur->bEof = 1; + return SQLITE_OK; + } + + sqlite3_free(pCur->zPath); + pCur->zPath = 0; + + while( 1 ){ + pEntry = readdir(pCur->pDir); + if( pEntry ){ + if( strcmp(pEntry->d_name, ".") + && strcmp(pEntry->d_name, "..") + ){ + pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zDir, pEntry->d_name); + if( pCur->zPath==0 ) return SQLITE_NOMEM; + lstat(pCur->zPath, &pCur->sStat); + break; + } + }else{ + pCur->bEof = 1; + break; + } + } + + pCur->iRowid++; + return SQLITE_OK; +} + +/* +** Return values of columns for the row at which the series_cursor +** is currently pointing. +*/ +static int fsdirColumn( + sqlite3_vtab_cursor *cur, /* The cursor */ + sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ + int i /* Which column to return */ +){ + fsdir_cursor *pCur = (fsdir_cursor*)cur; + switch( i ){ + case 0: { /* name */ + const char *zName; + if( pCur->eType==FSDIR_DIR ){ + zName = &pCur->zPath[pCur->nDir+1]; + }else{ + zName = pCur->zPath; + } + sqlite3_result_text(ctx, zName, -1, SQLITE_TRANSIENT); + break; + } + + case 1: /* mode */ + sqlite3_result_int64(ctx, pCur->sStat.st_mode); + break; + + case 2: /* mode */ + sqlite3_result_int64(ctx, pCur->sStat.st_mtime); + break; + + case 3: { + mode_t m = pCur->sStat.st_mode; + if( S_ISDIR(m) ){ + sqlite3_result_null(ctx); + }else if( S_ISLNK(m) ){ + char aStatic[64]; + char *aBuf = aStatic; + int nBuf = 64; + int n; + + while( 1 ){ + n = readlink(pCur->zPath, aBuf, nBuf); + if( nzPath); + } + } + } + return SQLITE_OK; +} + +/* +** Return the rowid for the current row. In this implementation, the +** first row returned is assigned rowid value 1, and each subsequent +** row a value 1 more than that of the previous. +*/ +static int fsdirRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + fsdir_cursor *pCur = (fsdir_cursor*)cur; + *pRowid = pCur->iRowid; + return SQLITE_OK; +} + +/* +** Return TRUE if the cursor has been moved off of the last +** row of output. +*/ +static int fsdirEof(sqlite3_vtab_cursor *cur){ + fsdir_cursor *pCur = (fsdir_cursor*)cur; + return pCur->bEof; +} + +static void fsdirSetErrmsg(fsdir_cursor *pCur, const char *zFmt, ...){ + va_list ap; + va_start(ap, zFmt); + pCur->base.pVtab->zErrMsg = sqlite3_vmprintf(zFmt, ap); + va_end(ap); +} + +/* +** xFilter callback. +*/ +static int fsdirFilter( + sqlite3_vtab_cursor *cur, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + const char *zDir = 0; + fsdir_cursor *pCur = (fsdir_cursor*)cur; + + sqlite3_free(pCur->zDir); + pCur->iRowid = 0; + pCur->zDir = 0; + pCur->bEof = 0; + if( pCur->pDir ){ + closedir(pCur->pDir); + pCur->pDir = 0; + } + + if( idxNum==0 ){ + fsdirSetErrmsg(pCur, "table function fsdir requires an argument"); + return SQLITE_ERROR; + } + + assert( argc==1 ); + zDir = (const char*)sqlite3_value_text(argv[0]); + if( zDir==0 ){ + fsdirSetErrmsg(pCur, "table function fsdir requires a non-NULL argument"); + return SQLITE_ERROR; + } + + pCur->zDir = sqlite3_mprintf("%s", zDir); + if( pCur->zDir==0 ){ + return SQLITE_NOMEM; + } + + if( pCur->eType==FSDIR_ENTRY ){ + int rc = lstat(pCur->zDir, &pCur->sStat); + if( rc ){ + fsdirSetErrmsg(pCur, "cannot stat file: %s", pCur->zDir); + }else{ + pCur->zPath = sqlite3_mprintf("%s", pCur->zDir); + if( pCur->zPath==0 ) return SQLITE_NOMEM; + } + return SQLITE_OK; + }else{ + pCur->nDir = strlen(pCur->zDir); + pCur->pDir = opendir(zDir); + if( pCur->pDir==0 ){ + fsdirSetErrmsg(pCur, "error in opendir(\"%s\")", zDir); + return SQLITE_ERROR; + } + + return fsdirNext(cur); + } +} + +/* +** SQLite will invoke this method one or more times while planning a query +** that uses the generate_series virtual table. This routine needs to create +** a query plan for each invocation and compute an estimated cost for that +** plan. +** +** In this implementation idxNum is used to represent the +** query plan. idxStr is unused. +** +** The query plan is represented by bits in idxNum: +** +** (1) start = $value -- constraint exists +** (2) stop = $value -- constraint exists +** (4) step = $value -- constraint exists +** (8) output in descending order +*/ +static int fsdirBestIndex( + sqlite3_vtab *tab, + sqlite3_index_info *pIdxInfo +){ + int i; /* Loop over constraints */ + + const struct sqlite3_index_constraint *pConstraint; + pConstraint = pIdxInfo->aConstraint; + for(i=0; inConstraint; i++, pConstraint++){ + if( pConstraint->usable==0 ) continue; + if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; + if( pConstraint->iColumn!=4 ) continue; + break; + } + + if( inConstraint ){ + pIdxInfo->aConstraintUsage[i].omit = 1; + pIdxInfo->aConstraintUsage[i].argvIndex = 1; + pIdxInfo->idxNum = 1; + pIdxInfo->estimatedCost = 10.0; + }else{ + pIdxInfo->idxNum = 0; + pIdxInfo->estimatedCost = (double)(((sqlite3_int64)1) << 50); + } + + return SQLITE_OK; +} + +static int fsdirRegister(sqlite3 *db){ + static sqlite3_module fsdirModule = { + 0, /* iVersion */ + 0, /* xCreate */ + fsdirConnect, /* xConnect */ + fsdirBestIndex, /* xBestIndex */ + fsdirDisconnect, /* xDisconnect */ + 0, /* xDestroy */ + fsdirOpen, /* xOpen - open a cursor */ + fsdirClose, /* xClose - close a cursor */ + fsdirFilter, /* xFilter - configure scan constraints */ + fsdirNext, /* xNext - advance a cursor */ + fsdirEof, /* xEof - check for end of scan */ + fsdirColumn, /* xColumn - read data */ + fsdirRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ + }; + + int rc = sqlite3_create_module(db, "fsdir", &fsdirModule, 0); + if( rc==SQLITE_OK ){ + rc = sqlite3_create_module(db, "fsentry", &fsdirModule, (void*)1); + } + return rc; +} +#else /* SQLITE_OMIT_VIRTUALTABLE */ +# define fsdirRegister(x) SQLITE_OK +#endif #ifdef _WIN32 __declspec(dllexport) @@ -98,5 +466,8 @@ int sqlite3_fileio_init( rc = sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0, writefileFunc, 0, 0); } + if( rc==SQLITE_OK ){ + rc = fsdirRegister(db); + } return rc; } diff --git a/manifest b/manifest index 3e24dc86b3..dc93367667 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sMSVC,\ssimplify\sdefault\slocations\sfor\sTcl\sand\sICU\sby\susing\sdirectories\sinside\s'compat'. -D 2017-12-05T19:07:30.651 +C Begin\sadding\ssupport\sfor\sthe\ssqlar\sarchive\sformat\sto\sshell.c.\sThere\sis\sno\n"extract"\scommand\sso\sfar,\sonly\s"create". +D 2017-12-07T15:44:29.604 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -269,7 +269,7 @@ F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c b1aa06c0f1dac277695d4529e5e976c65ab5678dcbb53a0304deaa8adc44b332 +F ext/misc/fileio.c bd2dd9bd22a509f972a4658be18bbfef80aec3cbc3e18948c5e8c5e29ece9939 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -474,7 +474,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in ab727c09b4c87c0c1db32d2fe0a910c0a8e468a0209233328753f5526d6c6c73 +F src/shell.c.in 56c4c091c74af2c7858f2d8af962caa632889596435b17bffbc308058fb305cc F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1681,7 +1681,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e1838cee3847301ef491467dc75d9c4e1e3b12599596c058bdb14319a52fd8a0 -R a792968384e617f4a37df83169716b24 -U mistachkin -Z 06008f15f266edb3571035a6d698db2a +P 8155b5ac850327ea76aba2adf624132f3e05024c973afd218b12f186fc7630e8 +R 1ffe38726fc0bf4dcb6cd1bf88405c9b +U dan +Z f98960131c8a51264c03e5b1a40bd1b7 diff --git a/manifest.uuid b/manifest.uuid index b50deeb9bc..3b745e1dd5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8155b5ac850327ea76aba2adf624132f3e05024c973afd218b12f186fc7630e8 \ No newline at end of file +c9827a01a6e107f38f85c2b2c1c7a599e443067b106217e965b6936441ca619d \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index edd75b078c..9015a4330a 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4074,6 +4074,214 @@ static int lintDotCommand( return SQLITE_ERROR; } +static void shellPrepare( + ShellState *p, + int *pRc, + const char *zSql, + sqlite3_stmt **ppStmt +){ + *ppStmt = 0; + if( *pRc==SQLITE_OK ){ + int rc = sqlite3_prepare_v2(p->db, zSql, -1, ppStmt, 0); + if( rc!=SQLITE_OK ){ + raw_printf(stderr, "sql error: %s (%d)\n", + sqlite3_errmsg(p->db), sqlite3_errcode(p->db) + ); + *pRc = rc; + } + } +} + +static void shellFinalize( + int *pRc, + sqlite3_stmt *pStmt +){ + int rc = sqlite3_finalize(pStmt); + if( *pRc==SQLITE_OK ) *pRc = rc; +} + +static void shellReset( + int *pRc, + sqlite3_stmt *pStmt +){ + int rc = sqlite3_reset(pStmt); + if( *pRc==SQLITE_OK ) *pRc = rc; +} + +/* +** Implementation of .ar "eXtract" command. +*/ +static int arExtractCommand(ShellState *p, int bVerbose){ + const char *zSql = + "SELECT name, mode, mtime, sz, data FROM sqlar"; + sqlite3_stmt *pSql = 0; + int rc = SQLITE_OK; + + shellPrepare(p, &rc, zSql, &pSql); + while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ + } + + shellFinalize(&rc, pSql); + return rc; +} + +/* +** Implementation of .ar "Create" command. +** +** Create the "sqlar" table in the database if it does not already exist. +** Then add each file in the azFile[] array to the archive. Directories +** are added recursively. If argument bVerbose is non-zero, a message is +** printed on stdout for each file archived. +*/ +static int arCreateCommand( + ShellState *p, /* Shell state pointer */ + char **azFile, /* Array of files to add to archive */ + int nFile, /* Number of entries in azFile[] */ + int bVerbose /* True to be verbose on stdout */ +){ + const char *zSql = + "WITH f(n, m, t, d) AS (" + " SELECT name, mode, mtime, data FROM fsentry(:1) UNION ALL " + " SELECT n || '/' || name, mode, mtime, data " + " FROM f, fsdir(n) WHERE (m&?)" + ") SELECT * FROM f"; + + const char *zSqlar = + "CREATE TABLE IF NOT EXISTS sqlar(" + "name TEXT PRIMARY KEY, -- name of the file\n" + "mode INT, -- access permissions\n" + "mtime INT, -- last modification time\n" + "sz INT, -- original file size\n" + "data BLOB -- compressed content\n" + ")"; + + const char *zInsert = "REPLACE INTO sqlar VALUES(?, ?, ?, ?, ?)"; + + sqlite3_stmt *pStmt = 0; /* Directory traverser */ + sqlite3_stmt *pInsert = 0; /* Compilation of zInsert */ + int i; /* For iterating through azFile[] */ + int rc; /* Return code */ + + Bytef *aCompress = 0; /* Compression buffer */ + int nCompress = 0; /* Size of compression buffer */ + + rc = sqlite3_exec(p->db, "SAVEPOINT ar;", 0, 0, 0); + if( rc!=SQLITE_OK ) return rc; + + rc = sqlite3_exec(p->db, zSqlar, 0, 0, 0); + shellPrepare(p, &rc, zInsert, &pInsert); + shellPrepare(p, &rc, zSql, &pStmt); + + for(i=0; inCompress ){ + Bytef *aNew = sqlite3_realloc(aCompress, nReq); + if( aNew==0 ){ + rc = SQLITE_NOMEM; + }else{ + aCompress = aNew; + nCompress = nReq; + } + } + + if( Z_OK!=compress(aCompress, &nReq, pData, sz) ){ + rc = SQLITE_ERROR; + } + if( nReqdb, "ROLLBACK TO ar; RELEASE ar;", 0, 0, 0); + }else{ + rc = sqlite3_exec(p->db, "RELEASE ar;", 0, 0, 0); + } + shellFinalize(&rc, pStmt); + shellFinalize(&rc, pInsert); + sqlite3_free(aCompress); + return rc; +} + +/* +** Implementation of ".ar" dot command. +*/ +static int arDotCommand( + ShellState *pState, /* Current shell tool state */ + char **azArg, /* Array of arguments passed to dot command */ + int nArg /* Number of entries in azArg[] */ +){ + int bVerbose = 0; + char cmd = 0; + int i; + int n1; + if( nArg<=1 ) goto usage; + + n1 = strlen(azArg[1]); + for(i=0; i=3 && strncmp(azArg[0], "backup", n)==0) || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0) ){ From 25c1218e73b918d27af79245136c9efe17c6f5f9 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 7 Dec 2017 21:03:33 +0000 Subject: [PATCH 006/190] Add the ".ar x" command to the shell. For extracting the contents of sqlar archives. FossilOrigin-Name: 0cc699d14adfe8c7b7be50c180186562861806c47425c80c935bce43ee5c5c12 --- ext/misc/fileio.c | 104 ++++++++++++++++++++++++++++++++++++---------- manifest | 14 +++---- manifest.uuid | 2 +- src/shell.c.in | 46 ++++++++++++++++---- 4 files changed, 128 insertions(+), 38 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 475f3713ce..db69357008 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -30,6 +30,17 @@ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + #define FSDIR_SCHEMA "CREATE TABLE x(name,mode,mtime,data,dir HIDDEN)" @@ -69,44 +80,91 @@ static void readfileFunc( readFileContents(context, zName); } +static void ctxErrorMsg(sqlite3_context *ctx, const char *zFmt, ...){ + char *zMsg = 0; + va_list ap; + va_start(ap, zFmt); + zMsg = sqlite3_vmprintf(zFmt, ap); + sqlite3_result_error(ctx, zMsg, -1); + sqlite3_free(zMsg); + va_end(ap); +} + /* -** Implementation of the "writefile(X,Y)" SQL function. The argument Y -** is written into file X. The number of bytes written is returned. Or -** NULL is returned if something goes wrong, such as being unable to open -** file X for writing. +** Implementation of the "writefile(W,X[,Y]])" SQL function. +** +** The argument X is written into file W. The number of bytes written is +** returned. Or NULL is returned if something goes wrong, such as being unable +** to open file X for writing. */ static void writefileFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ - FILE *out; - const char *z; - sqlite3_int64 rc; const char *zFile; + mode_t mode = 0; + + if( argc<2 || argc>3 ){ + sqlite3_result_error(context, + "wrong number of arguments to function writefile()", -1 + ); + return; + } - (void)(argc); /* Unused parameter */ zFile = (const char*)sqlite3_value_text(argv[0]); if( zFile==0 ) return; - out = fopen(zFile, "wb"); - if( out==0 ) return; - z = (const char*)sqlite3_value_blob(argv[1]); - if( z==0 ){ - rc = 0; - }else{ - rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out); + if( argc>=3 ){ + sqlite3_result_int(context, 0); + mode = sqlite3_value_int(argv[2]); + } + + if( S_ISLNK(mode) ){ + const char *zTo = (const char*)sqlite3_value_text(argv[1]); + if( symlink(zTo, zFile)<0 ){ + ctxErrorMsg(context, "failed to create symlink: %s", zFile); + return; + } + }else{ + if( S_ISDIR(mode) ){ + if( mkdir(zFile, mode) ){ + ctxErrorMsg(context, "failed to create directory: %s", zFile); + return; + } + }else{ + sqlite3_int64 nWrite = 0; + const char *z; + int rc = 0; + FILE *out = fopen(zFile, "wb"); + if( out==0 ){ + if( argc>2 ){ + ctxErrorMsg(context, "failed to open file for writing: %s", zFile); + } + return; + } + z = (const char*)sqlite3_value_blob(argv[1]); + if( z ){ + sqlite3_int64 n = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out); + nWrite = sqlite3_value_bytes(argv[1]); + if( nWrite!=n ){ + ctxErrorMsg(context, "failed to write file: %s", zFile); + rc = 1; + } + } + fclose(out); + if( rc ) return; + sqlite3_result_int64(context, nWrite); + } + + if( argc>2 && chmod(zFile, mode & 0777) ){ + ctxErrorMsg(context, "failed to chmod file: %s", zFile); + return; + } } - fclose(out); - sqlite3_result_int64(context, rc); } #ifndef SQLITE_OMIT_VIRTUALTABLE -#include -#include -#include -#include - /* */ typedef struct fsdir_cursor fsdir_cursor; @@ -463,7 +521,7 @@ int sqlite3_fileio_init( rc = sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0, readfileFunc, 0, 0); if( rc==SQLITE_OK ){ - rc = sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0, + rc = sqlite3_create_function(db, "writefile", -1, SQLITE_UTF8, 0, writefileFunc, 0, 0); } if( rc==SQLITE_OK ){ diff --git a/manifest b/manifest index dc93367667..ab01f7195c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Begin\sadding\ssupport\sfor\sthe\ssqlar\sarchive\sformat\sto\sshell.c.\sThere\sis\sno\n"extract"\scommand\sso\sfar,\sonly\s"create". -D 2017-12-07T15:44:29.604 +C Add\sthe\s".ar\sx"\scommand\sto\sthe\sshell.\sFor\sextracting\sthe\scontents\sof\ssqlar\narchives. +D 2017-12-07T21:03:33.903 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -269,7 +269,7 @@ F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c bd2dd9bd22a509f972a4658be18bbfef80aec3cbc3e18948c5e8c5e29ece9939 +F ext/misc/fileio.c c84ec9c399657bd95914e7c4e9aefcc148cb86fe3ab7f2102e9557c861dd0d51 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -474,7 +474,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in 56c4c091c74af2c7858f2d8af962caa632889596435b17bffbc308058fb305cc +F src/shell.c.in 2f9ae0bee09bdd35922ab7ed264d88e1d7fb34d39d37fc633e6a3a1af60036be F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1681,7 +1681,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8155b5ac850327ea76aba2adf624132f3e05024c973afd218b12f186fc7630e8 -R 1ffe38726fc0bf4dcb6cd1bf88405c9b +P c9827a01a6e107f38f85c2b2c1c7a599e443067b106217e965b6936441ca619d +R 4b2bb930e9456062f8914cba7a04cf63 U dan -Z f98960131c8a51264c03e5b1a40bd1b7 +Z 4726613d4458219c808274490c55a044 diff --git a/manifest.uuid b/manifest.uuid index 3b745e1dd5..245ee49a8f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c9827a01a6e107f38f85c2b2c1c7a599e443067b106217e965b6936441ca619d \ No newline at end of file +0cc699d14adfe8c7b7be50c180186562861806c47425c80c935bce43ee5c5c12 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 9015a4330a..fe58460fe1 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4096,8 +4096,16 @@ static void shellFinalize( int *pRc, sqlite3_stmt *pStmt ){ - int rc = sqlite3_finalize(pStmt); - if( *pRc==SQLITE_OK ) *pRc = rc; + if( pStmt ){ + sqlite3 *db = sqlite3_db_handle(pStmt); + int rc = sqlite3_finalize(pStmt); + if( *pRc==SQLITE_OK ){ + if( rc!=SQLITE_OK ){ + raw_printf(stderr, "SQL error: %s\n", sqlite3_errmsg(db)); + } + *pRc = rc; + } + } } static void shellReset( @@ -4112,16 +4120,40 @@ static void shellReset( ** Implementation of .ar "eXtract" command. */ static int arExtractCommand(ShellState *p, int bVerbose){ - const char *zSql = - "SELECT name, mode, mtime, sz, data FROM sqlar"; + const char *zSql1 = + "SELECT name, writefile(name, " + "CASE WHEN (data AND sz>=0 AND sz!=length(data)) THEN uncompress(data) " + " ELSE data END, " + "mode) FROM sqlar"; + const char *zSql2 = "SELECT name, mtime FROM sqlar"; + + struct timespec times[2]; sqlite3_stmt *pSql = 0; int rc = SQLITE_OK; - shellPrepare(p, &rc, zSql, &pSql); - while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ - } + memset(times, 0, sizeof(times)); + times[0].tv_sec = time(0); + shellPrepare(p, &rc, zSql1, &pSql); + while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ + if( bVerbose ){ + raw_printf(stdout, "%s\n", sqlite3_column_text(pSql, 0)); + } + } shellFinalize(&rc, pSql); + + shellPrepare(p, &rc, zSql2, &pSql); + while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ + const char *zPath = (const char*)sqlite3_column_text(pSql, 0); + times[1].tv_sec = (time_t)sqlite3_column_int64(pSql, 1); + if( utimensat(AT_FDCWD, zPath, times, AT_SYMLINK_NOFOLLOW) ){ + raw_printf(stderr, "failed to set timestamp for %s\n", zPath); + rc = SQLITE_ERROR; + break; + } + } + shellFinalize(&rc, pSql); + return rc; } From 88be0209168e1625ef5a5b0ef7f33f14e8895b1b Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 9 Dec 2017 17:58:02 +0000 Subject: [PATCH 007/190] Improve parsing of ".ar" commands. Add new test file for the same. FossilOrigin-Name: 840401cc8ce3a09e0663b46973ecd2856d9607be71d2d1e9b21f7df7a82dcbe5 --- manifest | 13 ++-- manifest.uuid | 2 +- src/shell.c.in | 177 +++++++++++++++++++++++++++++++++++++---------- test/shell8.test | 83 ++++++++++++++++++++++ 4 files changed, 232 insertions(+), 43 deletions(-) create mode 100644 test/shell8.test diff --git a/manifest b/manifest index ab01f7195c..98adac2007 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s".ar\sx"\scommand\sto\sthe\sshell.\sFor\sextracting\sthe\scontents\sof\ssqlar\narchives. -D 2017-12-07T21:03:33.903 +C Improve\sparsing\sof\s".ar"\scommands.\sAdd\snew\stest\sfile\sfor\sthe\ssame. +D 2017-12-09T17:58:02.648 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -474,7 +474,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in 2f9ae0bee09bdd35922ab7ed264d88e1d7fb34d39d37fc633e6a3a1af60036be +F src/shell.c.in 907661eeab82949420270b24f5989a399242cb8721e6140f73b3a46939fc4820 F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1214,6 +1214,7 @@ F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f +F test/shell8.test 98b1d7b218060e557b3a789f3396635a0c03873ea652b3154c7f3f238d4a1a8f F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1681,7 +1682,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c9827a01a6e107f38f85c2b2c1c7a599e443067b106217e965b6936441ca619d -R 4b2bb930e9456062f8914cba7a04cf63 +P 0cc699d14adfe8c7b7be50c180186562861806c47425c80c935bce43ee5c5c12 +R 0b3e6167ae82d64c1e021b537a83d40a U dan -Z 4726613d4458219c808274490c55a044 +Z 9b95380c27ad603c463b4469d523a6d2 diff --git a/manifest.uuid b/manifest.uuid index 245ee49a8f..d1e1c772f3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0cc699d14adfe8c7b7be50c180186562861806c47425c80c935bce43ee5c5c12 \ No newline at end of file +840401cc8ce3a09e0663b46973ecd2856d9607be71d2d1e9b21f7df7a82dcbe5 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index fe58460fe1..b8471fea9f 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4116,10 +4116,124 @@ static void shellReset( if( *pRc==SQLITE_OK ) *pRc = rc; } +/* +** Structure representing a single ".ar" command. +*/ +typedef struct ArCommand ArCommand; +struct ArCommand { + int eCmd; /* An AR_CMD_* value */ + const char *zFile; /* --file argument, or NULL */ + const char *zDir; /* --directory argument, or NULL */ + int bVerbose; /* True if --verbose */ + int nArg; /* Number of command arguments */ + char **azArg; /* Array of command arguments */ +}; + +/* +** Print a usage message for the .ar command to stderr and return SQLITE_ERROR. +*/ +static int arUsage(void){ + /* todo */ + raw_printf(stderr, "error in .ar command line\n"); + return SQLITE_ERROR; +} + +/* +** Values for ArCommand.eCmd. +*/ +#define AR_CMD_CREATE 1 +#define AR_CMD_EXTRACT 2 +#define AR_CMD_LIST 3 +#define AR_CMD_UPDATE 4 + +/* +** Parse the command line for an ".ar" command. The results are written into +** structure (*pAr). SQLITE_OK is returned if the command line is parsed +** successfully, otherwise an error message is written to stderr and +** SQLITE_ERROR returned. +*/ +static int arParseCommand( + char **azArg, /* Array of arguments passed to dot command */ + int nArg, /* Number of entries in azArg[] */ + ArCommand *pAr /* Populate this object */ +){ + if( nArg<=1 ){ + return arUsage(); + }else{ + char *z = azArg[1]; + memset(pAr, 0, sizeof(ArCommand)); + + if( z[0]!='-' ){ + /* Traditional style [tar] invocation */ + int i; + int iArg = 2; + for(i=0; z[i]; i++){ + switch( z[i] ){ + case 'c': + if( pAr->eCmd ) return arUsage(); + pAr->eCmd = AR_CMD_CREATE; + break; + case 'x': + if( pAr->eCmd ) return arUsage(); + pAr->eCmd = AR_CMD_EXTRACT; + break; + case 't': + if( pAr->eCmd ) return arUsage(); + pAr->eCmd = AR_CMD_LIST; + break; + case 'u': + if( pAr->eCmd ) return arUsage(); + pAr->eCmd = AR_CMD_UPDATE; + break; + + case 'v': + pAr->bVerbose = 1; + break; + case 'f': + if( iArg>=nArg ) return arUsage(); + pAr->zFile = azArg[iArg++]; + break; + case 'C': + if( iArg>=nArg ) return arUsage(); + pAr->zDir = azArg[iArg++]; + break; + + default: + return arUsage(); + } + } + + pAr->nArg = nArg-iArg; + if( pAr->nArg>0 ){ + pAr->azArg = &azArg[iArg]; + } + } + } + + return SQLITE_OK; +} + +/* +** Implementation of .ar "Update" command. +*/ +static int arUpdateCmd(ShellState *p, ArCommand *pAr){ + raw_printf(stderr, "todo...\n"); + return SQLITE_OK; +} + +/* +** Implementation of .ar "lisT" command. +*/ +static int arListCommand(ShellState *p, ArCommand *pAr){ + raw_printf(stderr, "todo...\n"); + return SQLITE_OK; +} + + /* ** Implementation of .ar "eXtract" command. */ -static int arExtractCommand(ShellState *p, int bVerbose){ +static int arExtractCommand(ShellState *p, ArCommand *pAr){ const char *zSql1 = "SELECT name, writefile(name, " "CASE WHEN (data AND sz>=0 AND sz!=length(data)) THEN uncompress(data) " @@ -4136,7 +4250,7 @@ static int arExtractCommand(ShellState *p, int bVerbose){ shellPrepare(p, &rc, zSql1, &pSql); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ - if( bVerbose ){ + if( pAr->bVerbose ){ raw_printf(stdout, "%s\n", sqlite3_column_text(pSql, 0)); } } @@ -4167,9 +4281,7 @@ static int arExtractCommand(ShellState *p, int bVerbose){ */ static int arCreateCommand( ShellState *p, /* Shell state pointer */ - char **azFile, /* Array of files to add to archive */ - int nFile, /* Number of entries in azFile[] */ - int bVerbose /* True to be verbose on stdout */ + ArCommand *pAr /* Command arguments and options */ ){ const char *zSql = "WITH f(n, m, t, d) AS (" @@ -4204,8 +4316,8 @@ static int arCreateCommand( shellPrepare(p, &rc, zInsert, &pInsert); shellPrepare(p, &rc, zSql, &pStmt); - for(i=0; inArg && rc==SQLITE_OK; i++){ + sqlite3_bind_text(pStmt, 1, pAr->azArg[i], -1, SQLITE_STATIC); sqlite3_bind_int(pStmt, 2, S_IFDIR); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ int sz; @@ -4213,7 +4325,7 @@ static int arCreateCommand( int mode = sqlite3_column_int(pStmt, 1); unsigned int mtime = sqlite3_column_int(pStmt, 2); - if( bVerbose ){ + if( pAr->bVerbose ){ raw_printf(stdout, "%s\n", zName); } @@ -4280,38 +4392,31 @@ static int arDotCommand( char **azArg, /* Array of arguments passed to dot command */ int nArg /* Number of entries in azArg[] */ ){ - int bVerbose = 0; - char cmd = 0; - int i; - int n1; - if( nArg<=1 ) goto usage; + ArCommand cmd; + int rc; + rc = arParseCommand(azArg, nArg, &cmd); + if( rc==SQLITE_OK ){ + switch( cmd.eCmd ){ + case AR_CMD_CREATE: + rc = arCreateCommand(pState, &cmd); + break; - n1 = strlen(azArg[1]); - for(i=0; i Date: Sat, 9 Dec 2017 18:28:22 +0000 Subject: [PATCH 008/190] Add support for -C to ".ar x". FossilOrigin-Name: 8cd70960c5ddf0d0b2c40b8b6af4ce6b0277ffdaf04f33fcb33227d2b99ad515 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 18 ++++++++++++++++-- test/shell8.test | 13 +++++++++++-- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 98adac2007..1916921b89 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sparsing\sof\s".ar"\scommands.\sAdd\snew\stest\sfile\sfor\sthe\ssame. -D 2017-12-09T17:58:02.648 +C Add\ssupport\sfor\s-C\sto\s".ar\sx". +D 2017-12-09T18:28:22.916 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -474,7 +474,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in 907661eeab82949420270b24f5989a399242cb8721e6140f73b3a46939fc4820 +F src/shell.c.in 8e57abbd26d7d2344ba752be0f86b2cbf93ad73ca28c651786392fbfd3b512ba F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1214,7 +1214,7 @@ F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f -F test/shell8.test 98b1d7b218060e557b3a789f3396635a0c03873ea652b3154c7f3f238d4a1a8f +F test/shell8.test 0e8e064da50c92df8eb514202dcfd0020f71762250066bf41ed098e0ff5f0e3d F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1682,7 +1682,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0cc699d14adfe8c7b7be50c180186562861806c47425c80c935bce43ee5c5c12 -R 0b3e6167ae82d64c1e021b537a83d40a +P 840401cc8ce3a09e0663b46973ecd2856d9607be71d2d1e9b21f7df7a82dcbe5 +R e8ce05071b1dec8c5193e0b4d7b226fe U dan -Z 9b95380c27ad603c463b4469d523a6d2 +Z f3cf78b2d0eddbe511b3f9a244339aaa diff --git a/manifest.uuid b/manifest.uuid index d1e1c772f3..b240d7b3d5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -840401cc8ce3a09e0663b46973ecd2856d9607be71d2d1e9b21f7df7a82dcbe5 \ No newline at end of file +8cd70960c5ddf0d0b2c40b8b6af4ce6b0277ffdaf04f33fcb33227d2b99ad515 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index b8471fea9f..431329579e 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4235,20 +4235,30 @@ static int arListCommand(ShellState *p, ArCommand *pAr){ */ static int arExtractCommand(ShellState *p, ArCommand *pAr){ const char *zSql1 = - "SELECT name, writefile(name, " + "SELECT :1 || name, writefile(:1 || name, " "CASE WHEN (data AND sz>=0 AND sz!=length(data)) THEN uncompress(data) " " ELSE data END, " "mode) FROM sqlar"; - const char *zSql2 = "SELECT name, mtime FROM sqlar"; + const char *zSql2 = "SELECT :1 || name, mtime FROM sqlar"; struct timespec times[2]; sqlite3_stmt *pSql = 0; int rc = SQLITE_OK; + char *zDir = 0; + + if( pAr->zDir ){ + zDir = sqlite3_mprintf("%s/", pAr->zDir); + }else{ + zDir = sqlite3_mprintf(""); + } memset(times, 0, sizeof(times)); times[0].tv_sec = time(0); shellPrepare(p, &rc, zSql1, &pSql); + if( rc==SQLITE_OK ){ + sqlite3_bind_text(pSql, 1, zDir, -1, SQLITE_STATIC); + } while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ if( pAr->bVerbose ){ raw_printf(stdout, "%s\n", sqlite3_column_text(pSql, 0)); @@ -4257,6 +4267,9 @@ static int arExtractCommand(ShellState *p, ArCommand *pAr){ shellFinalize(&rc, pSql); shellPrepare(p, &rc, zSql2, &pSql); + if( rc==SQLITE_OK ){ + sqlite3_bind_text(pSql, 1, zDir, -1, SQLITE_STATIC); + } while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ const char *zPath = (const char*)sqlite3_column_text(pSql, 0); times[1].tv_sec = (time_t)sqlite3_column_int64(pSql, 1); @@ -4268,6 +4281,7 @@ static int arExtractCommand(ShellState *p, ArCommand *pAr){ } shellFinalize(&rc, pSql); + sqlite3_free(zDir); return rc; } diff --git a/test/shell8.test b/test/shell8.test index 4c412b41dc..2d2fc7b94d 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -34,12 +34,14 @@ proc populate_dir {dirname spec} { } } -proc dir_to_list {dirname} { +proc dir_to_list {dirname {n -1}} { + if {$n<0} {set n [llength [file split $dirname]]} + set res [list] foreach f [glob -nocomplain $dirname/*] { set mtime [file mtime $f] set perm [file attributes $f -perm] - set relpath [file join {*}[lrange [file split $f] 1 end]] + set relpath [file join {*}[lrange [file split $f] $n end]] lappend res if {[file isdirectory $f]} { lappend res [list $relpath / $mtime $perm] @@ -78,6 +80,13 @@ do_test 1.1 { dir_to_list ar1 } $expected +do_test 1.2 { + file delete -force ar3 + file mkdir ar3 + catchcmd test_ar.db ".ar xvC ar3" + dir_to_list ar3/ar1 +} $expected + finish_test From 1ad3f61b810e48ad8d6f0b59152689fc10bdfb28 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 11 Dec 2017 20:22:02 +0000 Subject: [PATCH 009/190] Enhance virtual table "fsdir" in ext/misc/fileio.c. Add support for "-C" to the shell command's ".ar c" command. FossilOrigin-Name: 0394889afed2479773af594e2d9659cf58b8959004ebcdeaff8e08e5dae684ef --- ext/misc/fileio.c | 230 +++++++++++++++++++++++++++------------------- manifest | 16 ++-- manifest.uuid | 2 +- src/shell.c.in | 11 +-- test/shell8.test | 10 ++ 5 files changed, 158 insertions(+), 111 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index db69357008..d3c00b4b1f 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -42,7 +42,7 @@ SQLITE_EXTENSION_INIT1 #include -#define FSDIR_SCHEMA "CREATE TABLE x(name,mode,mtime,data,dir HIDDEN)" +#define FSDIR_SCHEMA "(name,mode,mtime,data,path HIDDEN,dir HIDDEN)" static void readFileContents(sqlite3_context *ctx, const char *zName){ FILE *in; @@ -166,29 +166,36 @@ static void writefileFunc( #ifndef SQLITE_OMIT_VIRTUALTABLE /* +** Cursor type for recursively iterating through a directory structure. */ typedef struct fsdir_cursor fsdir_cursor; +typedef struct FsdirLevel FsdirLevel; + +struct FsdirLevel { + DIR *pDir; /* From opendir() */ + char *zDir; /* Name of directory (nul-terminated) */ +}; + struct fsdir_cursor { sqlite3_vtab_cursor base; /* Base class - must be first */ - int eType; /* One of FSDIR_DIR or FSDIR_ENTRY */ - DIR *pDir; /* From opendir() */ + + int nLvl; /* Number of entries in aLvl[] array */ + int iLvl; /* Index of current entry */ + FsdirLevel *aLvl; /* Hierarchy of directories being traversed */ + + const char *zBase; + int nBase; + struct stat sStat; /* Current lstat() results */ - char *zDir; /* Directory to read */ - int nDir; /* Value of strlen(zDir) */ char *zPath; /* Path to current entry */ - int bEof; sqlite3_int64 iRowid; /* Current rowid */ }; typedef struct fsdir_tab fsdir_tab; struct fsdir_tab { sqlite3_vtab base; /* Base class - must be first */ - int eType; /* One of FSDIR_DIR or FSDIR_ENTRY */ }; -#define FSDIR_DIR 0 -#define FSDIR_ENTRY 1 - /* ** Construct a new fsdir virtual table object. */ @@ -202,12 +209,11 @@ static int fsdirConnect( fsdir_tab *pNew = 0; int rc; - rc = sqlite3_declare_vtab(db, FSDIR_SCHEMA); + rc = sqlite3_declare_vtab(db, "CREATE TABLE x" FSDIR_SCHEMA); if( rc==SQLITE_OK ){ pNew = (fsdir_tab*)sqlite3_malloc( sizeof(*pNew) ); if( pNew==0 ) return SQLITE_NOMEM; memset(pNew, 0, sizeof(*pNew)); - pNew->eType = (pAux==0 ? FSDIR_DIR : FSDIR_ENTRY); } *ppVtab = (sqlite3_vtab*)pNew; return rc; @@ -229,56 +235,107 @@ static int fsdirOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ pCur = sqlite3_malloc( sizeof(*pCur) ); if( pCur==0 ) return SQLITE_NOMEM; memset(pCur, 0, sizeof(*pCur)); - pCur->eType = ((fsdir_tab*)p)->eType; + pCur->iLvl = -1; *ppCursor = &pCur->base; return SQLITE_OK; } +static void fsdirResetCursor(fsdir_cursor *pCur){ + int i; + for(i=0; i<=pCur->iLvl; i++){ + FsdirLevel *pLvl = &pCur->aLvl[i]; + if( pLvl->pDir ) closedir(pLvl->pDir); + sqlite3_free(pLvl->zDir); + } + sqlite3_free(pCur->zPath); + pCur->aLvl = 0; + pCur->zPath = 0; + pCur->zBase = 0; + pCur->nBase = 0; + pCur->iLvl = -1; + pCur->iRowid = 1; +} + /* ** Destructor for an fsdir_cursor. */ static int fsdirClose(sqlite3_vtab_cursor *cur){ fsdir_cursor *pCur = (fsdir_cursor*)cur; - if( pCur->pDir ) closedir(pCur->pDir); - sqlite3_free(pCur->zDir); - sqlite3_free(pCur->zPath); + + fsdirResetCursor(pCur); + sqlite3_free(pCur->aLvl); sqlite3_free(pCur); return SQLITE_OK; } +static void fsdirSetErrmsg(fsdir_cursor *pCur, const char *zFmt, ...){ + va_list ap; + va_start(ap, zFmt); + pCur->base.pVtab->zErrMsg = sqlite3_vmprintf(zFmt, ap); + va_end(ap); +} + + /* ** Advance an fsdir_cursor to its next row of output. */ static int fsdirNext(sqlite3_vtab_cursor *cur){ fsdir_cursor *pCur = (fsdir_cursor*)cur; - struct dirent *pEntry; + mode_t m = pCur->sStat.st_mode; - if( pCur->eType==FSDIR_ENTRY ){ - pCur->bEof = 1; - return SQLITE_OK; - } - - sqlite3_free(pCur->zPath); - pCur->zPath = 0; - - while( 1 ){ - pEntry = readdir(pCur->pDir); - if( pEntry ){ - if( strcmp(pEntry->d_name, ".") - && strcmp(pEntry->d_name, "..") - ){ - pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zDir, pEntry->d_name); - if( pCur->zPath==0 ) return SQLITE_NOMEM; - lstat(pCur->zPath, &pCur->sStat); - break; - } - }else{ - pCur->bEof = 1; - break; + pCur->iRowid++; + if( S_ISDIR(m) ){ + /* Descend into this directory */ + int iNew = pCur->iLvl + 1; + FsdirLevel *pLvl; + if( iNew>=pCur->nLvl ){ + int nNew = iNew+1; + int nByte = nNew*sizeof(FsdirLevel); + FsdirLevel *aNew = (FsdirLevel*)sqlite3_realloc(pCur->aLvl, nByte); + if( aNew==0 ) return SQLITE_NOMEM; + memset(&aNew[pCur->nLvl], 0, sizeof(FsdirLevel)*(nNew-pCur->nLvl)); + pCur->aLvl = aNew; + pCur->nLvl = nNew; + } + pCur->iLvl = iNew; + pLvl = &pCur->aLvl[iNew]; + + pLvl->zDir = pCur->zPath; + pCur->zPath = 0; + pLvl->pDir = opendir(pLvl->zDir); + if( pLvl->pDir==0 ){ + fsdirSetErrmsg(pCur, "cannot read directory: %s", pCur->zPath); + return SQLITE_ERROR; } } - pCur->iRowid++; + while( pCur->iLvl>=0 ){ + FsdirLevel *pLvl = &pCur->aLvl[pCur->iLvl]; + struct dirent *pEntry = readdir(pLvl->pDir); + if( pEntry ){ + if( pEntry->d_name[0]=='.' ){ + if( pEntry->d_name[1]=='.' && pEntry->d_name[2]=='\0' ) continue; + if( pEntry->d_name[1]=='\0' ) continue; + } + sqlite3_free(pCur->zPath); + pCur->zPath = sqlite3_mprintf("%s/%s", pLvl->zDir, pEntry->d_name); + if( pCur->zPath==0 ) return SQLITE_NOMEM; + if( lstat(pCur->zPath, &pCur->sStat) ){ + fsdirSetErrmsg(pCur, "cannot stat file: %s", pCur->zPath); + return SQLITE_ERROR; + } + return SQLITE_OK; + } + closedir(pLvl->pDir); + sqlite3_free(pLvl->zDir); + pLvl->pDir = 0; + pLvl->zDir = 0; + pCur->iLvl--; + } + + /* EOF */ + sqlite3_free(pCur->zPath); + pCur->zPath = 0; return SQLITE_OK; } @@ -294,13 +351,7 @@ static int fsdirColumn( fsdir_cursor *pCur = (fsdir_cursor*)cur; switch( i ){ case 0: { /* name */ - const char *zName; - if( pCur->eType==FSDIR_DIR ){ - zName = &pCur->zPath[pCur->nDir+1]; - }else{ - zName = pCur->zPath; - } - sqlite3_result_text(ctx, zName, -1, SQLITE_TRANSIENT); + sqlite3_result_text(ctx, &pCur->zPath[pCur->nBase], -1, SQLITE_TRANSIENT); break; } @@ -308,11 +359,11 @@ static int fsdirColumn( sqlite3_result_int64(ctx, pCur->sStat.st_mode); break; - case 2: /* mode */ + case 2: /* mtime */ sqlite3_result_int64(ctx, pCur->sStat.st_mtime); break; - case 3: { + case 3: { /* data */ mode_t m = pCur->sStat.st_mode; if( S_ISDIR(m) ){ sqlite3_result_null(ctx); @@ -361,14 +412,7 @@ static int fsdirRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ */ static int fsdirEof(sqlite3_vtab_cursor *cur){ fsdir_cursor *pCur = (fsdir_cursor*)cur; - return pCur->bEof; -} - -static void fsdirSetErrmsg(fsdir_cursor *pCur, const char *zFmt, ...){ - va_list ap; - va_start(ap, zFmt); - pCur->base.pVtab->zErrMsg = sqlite3_vmprintf(zFmt, ap); - va_end(ap); + return (pCur->zPath==0); } /* @@ -382,51 +426,38 @@ static int fsdirFilter( const char *zDir = 0; fsdir_cursor *pCur = (fsdir_cursor*)cur; - sqlite3_free(pCur->zDir); - pCur->iRowid = 0; - pCur->zDir = 0; - pCur->bEof = 0; - if( pCur->pDir ){ - closedir(pCur->pDir); - pCur->pDir = 0; - } + fsdirResetCursor(pCur); if( idxNum==0 ){ fsdirSetErrmsg(pCur, "table function fsdir requires an argument"); return SQLITE_ERROR; } - assert( argc==1 ); + assert( argc==idxNum && (argc==1 || argc==2) ); zDir = (const char*)sqlite3_value_text(argv[0]); if( zDir==0 ){ fsdirSetErrmsg(pCur, "table function fsdir requires a non-NULL argument"); return SQLITE_ERROR; } + if( argc==2 ){ + pCur->zBase = (const char*)sqlite3_value_text(argv[1]); + } + if( pCur->zBase ){ + pCur->nBase = strlen(pCur->zBase)+1; + pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zBase, zDir); + }else{ + pCur->zPath = sqlite3_mprintf("%s", zDir); + } - pCur->zDir = sqlite3_mprintf("%s", zDir); - if( pCur->zDir==0 ){ + if( pCur->zPath==0 ){ return SQLITE_NOMEM; } - - if( pCur->eType==FSDIR_ENTRY ){ - int rc = lstat(pCur->zDir, &pCur->sStat); - if( rc ){ - fsdirSetErrmsg(pCur, "cannot stat file: %s", pCur->zDir); - }else{ - pCur->zPath = sqlite3_mprintf("%s", pCur->zDir); - if( pCur->zPath==0 ) return SQLITE_NOMEM; - } - return SQLITE_OK; - }else{ - pCur->nDir = strlen(pCur->zDir); - pCur->pDir = opendir(zDir); - if( pCur->pDir==0 ){ - fsdirSetErrmsg(pCur, "error in opendir(\"%s\")", zDir); - return SQLITE_ERROR; - } - - return fsdirNext(cur); + if( lstat(pCur->zPath, &pCur->sStat) ){ + fsdirSetErrmsg(pCur, "cannot stat file: %s", pCur->zPath); + return SQLITE_ERROR; } + + return SQLITE_OK; } /* @@ -450,24 +481,33 @@ static int fsdirBestIndex( sqlite3_index_info *pIdxInfo ){ int i; /* Loop over constraints */ + int idx4 = -1; + int idx5 = -1; const struct sqlite3_index_constraint *pConstraint; pConstraint = pIdxInfo->aConstraint; for(i=0; inConstraint; i++, pConstraint++){ if( pConstraint->usable==0 ) continue; if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; - if( pConstraint->iColumn!=4 ) continue; - break; + if( pConstraint->iColumn==4 ) idx4 = i; + if( pConstraint->iColumn==5 ) idx5 = i; } - if( inConstraint ){ - pIdxInfo->aConstraintUsage[i].omit = 1; - pIdxInfo->aConstraintUsage[i].argvIndex = 1; - pIdxInfo->idxNum = 1; - pIdxInfo->estimatedCost = 10.0; - }else{ + if( idx4<0 ){ pIdxInfo->idxNum = 0; pIdxInfo->estimatedCost = (double)(((sqlite3_int64)1) << 50); + }else{ + pIdxInfo->aConstraintUsage[idx4].omit = 1; + pIdxInfo->aConstraintUsage[idx4].argvIndex = 1; + if( idx5>=0 ){ + pIdxInfo->aConstraintUsage[idx5].omit = 1; + pIdxInfo->aConstraintUsage[idx5].argvIndex = 2; + pIdxInfo->idxNum = 2; + pIdxInfo->estimatedCost = 10.0; + }else{ + pIdxInfo->idxNum = 1; + pIdxInfo->estimatedCost = 100.0; + } } return SQLITE_OK; diff --git a/manifest b/manifest index 1916921b89..d95b1b4be9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\s-C\sto\s".ar\sx". -D 2017-12-09T18:28:22.916 +C Enhance\svirtual\stable\s"fsdir"\sin\sext/misc/fileio.c.\sAdd\ssupport\sfor\s"-C"\sto\nthe\sshell\scommand's\s".ar\sc"\scommand. +D 2017-12-11T20:22:02.045 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -269,7 +269,7 @@ F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c c84ec9c399657bd95914e7c4e9aefcc148cb86fe3ab7f2102e9557c861dd0d51 +F ext/misc/fileio.c 238d0c65a14bda99748285527543273e0248bc428c01c3955ec45acb8738db3b F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -474,7 +474,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in 8e57abbd26d7d2344ba752be0f86b2cbf93ad73ca28c651786392fbfd3b512ba +F src/shell.c.in 4c7a2c1226216dfad7978642c958143f0fdfee4f09aef2add1e73e3601dd7d33 F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1214,7 +1214,7 @@ F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f -F test/shell8.test 0e8e064da50c92df8eb514202dcfd0020f71762250066bf41ed098e0ff5f0e3d +F test/shell8.test d04773f4e8cdad62d42a1b13bf4c1182109880441689a2f5d5001e190ec04831 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1682,7 +1682,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 840401cc8ce3a09e0663b46973ecd2856d9607be71d2d1e9b21f7df7a82dcbe5 -R e8ce05071b1dec8c5193e0b4d7b226fe +P 8cd70960c5ddf0d0b2c40b8b6af4ce6b0277ffdaf04f33fcb33227d2b99ad515 +R ddf59f7efc51e054de53889e9f879e48 U dan -Z f3cf78b2d0eddbe511b3f9a244339aaa +Z c8a2667de38f55deb8cffcf1545f4d0c diff --git a/manifest.uuid b/manifest.uuid index b240d7b3d5..1e0e922cc2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8cd70960c5ddf0d0b2c40b8b6af4ce6b0277ffdaf04f33fcb33227d2b99ad515 \ No newline at end of file +0394889afed2479773af594e2d9659cf58b8959004ebcdeaff8e08e5dae684ef \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 431329579e..0e32cbe1e2 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4285,6 +4285,7 @@ static int arExtractCommand(ShellState *p, ArCommand *pAr){ return rc; } + /* ** Implementation of .ar "Create" command. ** @@ -4298,11 +4299,7 @@ static int arCreateCommand( ArCommand *pAr /* Command arguments and options */ ){ const char *zSql = - "WITH f(n, m, t, d) AS (" - " SELECT name, mode, mtime, data FROM fsentry(:1) UNION ALL " - " SELECT n || '/' || name, mode, mtime, data " - " FROM f, fsdir(n) WHERE (m&?)" - ") SELECT * FROM f"; + "SELECT name, mode, mtime, data FROM fsdir(?, ?)"; const char *zSqlar = "CREATE TABLE IF NOT EXISTS sqlar(" @@ -4322,17 +4319,17 @@ static int arCreateCommand( Bytef *aCompress = 0; /* Compression buffer */ int nCompress = 0; /* Size of compression buffer */ - + rc = sqlite3_exec(p->db, "SAVEPOINT ar;", 0, 0, 0); if( rc!=SQLITE_OK ) return rc; rc = sqlite3_exec(p->db, zSqlar, 0, 0, 0); shellPrepare(p, &rc, zInsert, &pInsert); shellPrepare(p, &rc, zSql, &pStmt); + sqlite3_bind_text(pStmt, 2, pAr->zDir, -1, SQLITE_STATIC); for(i=0; inArg && rc==SQLITE_OK; i++){ sqlite3_bind_text(pStmt, 1, pAr->azArg[i], -1, SQLITE_STATIC); - sqlite3_bind_int(pStmt, 2, S_IFDIR); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ int sz; const char *zName = (const char*)sqlite3_column_text(pStmt, 0); diff --git a/test/shell8.test b/test/shell8.test index 2d2fc7b94d..b3189d4215 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -87,6 +87,16 @@ do_test 1.2 { dir_to_list ar3/ar1 } $expected +do_test 1.3 { + file delete -force ar3 + file mkdir ar3 + + forcedelete test_ar.db + catchcmd test_ar.db ".ar cC ar1 file1 file2 dir1" + catchcmd test_ar.db ".ar xC ar3" + dir_to_list ar3 +} $expected + finish_test From d4b56e59017d3f57afdc7c5f3d0b84904eca920d Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Dec 2017 20:04:59 +0000 Subject: [PATCH 010/190] Add support for parsing options in non-traditional tar form to the ".ar" command. Have writefile() attempt to create any missing path components. And not to throw an exception if it is called to create a directory that already exists. FossilOrigin-Name: 38dbeb1e777aa7ec742aa27002ad4dcee28af520dc43de96e5c56c39f16574ff --- ext/misc/fileio.c | 149 ++++++++++++++++++++-------- manifest | 16 +-- manifest.uuid | 2 +- src/shell.c.in | 244 ++++++++++++++++++++++++++++++++++------------ test/shell8.test | 91 +++++++++++------ 5 files changed, 362 insertions(+), 140 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index d3c00b4b1f..2320173997 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -40,6 +40,7 @@ SQLITE_EXTENSION_INIT1 #include #include #include +#include #define FSDIR_SCHEMA "(name,mode,mtime,data,path HIDDEN,dir HIDDEN)" @@ -90,6 +91,103 @@ static void ctxErrorMsg(sqlite3_context *ctx, const char *zFmt, ...){ va_end(ap); } +/* +** Argument zFile is the name of a file that will be created and/or written +** by SQL function writefile(). This function ensures that the directory +** zFile will be written to exists, creating it if required. The permissions +** for any path components created by this function are set to (mode&0777). +** +** If an OOM condition is encountered, SQLITE_NOMEM is returned. Otherwise, +** SQLITE_OK is returned if the directory is successfully created, or +** SQLITE_ERROR otherwise. +*/ +static int makeDirectory( + const char *zFile, + mode_t mode +){ + char *zCopy = sqlite3_mprintf("%s", zFile); + int rc = SQLITE_OK; + + if( zCopy==0 ){ + rc = SQLITE_NOMEM; + }else{ + int nCopy = strlen(zCopy); + int i = 1; + + while( rc==SQLITE_OK ){ + struct stat sStat; + int rc; + + for(; zCopy[i]!='/' && i3 ){ sqlite3_result_error(context, @@ -119,46 +218,20 @@ static void writefileFunc( mode = sqlite3_value_int(argv[2]); } - if( S_ISLNK(mode) ){ - const char *zTo = (const char*)sqlite3_value_text(argv[1]); - if( symlink(zTo, zFile)<0 ){ - ctxErrorMsg(context, "failed to create symlink: %s", zFile); - return; - } - }else{ - if( S_ISDIR(mode) ){ - if( mkdir(zFile, mode) ){ - ctxErrorMsg(context, "failed to create directory: %s", zFile); - return; - } - }else{ - sqlite3_int64 nWrite = 0; - const char *z; - int rc = 0; - FILE *out = fopen(zFile, "wb"); - if( out==0 ){ - if( argc>2 ){ - ctxErrorMsg(context, "failed to open file for writing: %s", zFile); - } - return; - } - z = (const char*)sqlite3_value_blob(argv[1]); - if( z ){ - sqlite3_int64 n = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out); - nWrite = sqlite3_value_bytes(argv[1]); - if( nWrite!=n ){ - ctxErrorMsg(context, "failed to write file: %s", zFile); - rc = 1; - } - } - fclose(out); - if( rc ) return; - sqlite3_result_int64(context, nWrite); + res = writeFile(context, zFile, mode, argv[1]); + if( res==1 && errno==ENOENT ){ + if( makeDirectory(zFile, mode)==SQLITE_OK ){ + res = writeFile(context, zFile, mode, argv[1]); } + } - if( argc>2 && chmod(zFile, mode & 0777) ){ - ctxErrorMsg(context, "failed to chmod file: %s", zFile); - return; + if( res!=0 ){ + if( S_ISLNK(mode) ){ + ctxErrorMsg(context, "failed to create symlink: %s", zFile); + }else if( S_ISDIR(mode) ){ + ctxErrorMsg(context, "failed to create directory: %s", zFile); + }else{ + ctxErrorMsg(context, "failed to write file: %s", zFile); } } } diff --git a/manifest b/manifest index d95b1b4be9..af08ef11da 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\svirtual\stable\s"fsdir"\sin\sext/misc/fileio.c.\sAdd\ssupport\sfor\s"-C"\sto\nthe\sshell\scommand's\s".ar\sc"\scommand. -D 2017-12-11T20:22:02.045 +C Add\ssupport\sfor\sparsing\soptions\sin\snon-traditional\star\sform\sto\sthe\s".ar"\ncommand.\sHave\swritefile()\sattempt\sto\screate\sany\smissing\spath\scomponents.\sAnd\nnot\sto\sthrow\san\sexception\sif\sit\sis\scalled\sto\screate\sa\sdirectory\sthat\salready\nexists. +D 2017-12-12T20:04:59.331 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -269,7 +269,7 @@ F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 238d0c65a14bda99748285527543273e0248bc428c01c3955ec45acb8738db3b +F ext/misc/fileio.c 29b7fc94752fff6245cf4a81455f98cf6778ec1102ca7e67bf693d41a7db4307 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -474,7 +474,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in 4c7a2c1226216dfad7978642c958143f0fdfee4f09aef2add1e73e3601dd7d33 +F src/shell.c.in 0ab6e3c1fa09e420e643628d55929422867ca053f05df67a4cae4a67e2a6cfc5 F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1214,7 +1214,7 @@ F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f -F test/shell8.test d04773f4e8cdad62d42a1b13bf4c1182109880441689a2f5d5001e190ec04831 +F test/shell8.test 5c5a9d100d34b125e0f46d259ea76cf074ac60719b722b2a2c63d759c63fc113 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1682,7 +1682,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8cd70960c5ddf0d0b2c40b8b6af4ce6b0277ffdaf04f33fcb33227d2b99ad515 -R ddf59f7efc51e054de53889e9f879e48 +P 0394889afed2479773af594e2d9659cf58b8959004ebcdeaff8e08e5dae684ef +R e0d6dbcefc8608142fe03f9ef6d2dee7 U dan -Z c8a2667de38f55deb8cffcf1545f4d0c +Z 5813e7d404a813775aab77275468b917 diff --git a/manifest.uuid b/manifest.uuid index 1e0e922cc2..9e345298fb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0394889afed2479773af594e2d9659cf58b8959004ebcdeaff8e08e5dae684ef \ No newline at end of file +38dbeb1e777aa7ec742aa27002ad4dcee28af520dc43de96e5c56c39f16574ff \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 0e32cbe1e2..fd8659297c 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4075,17 +4075,17 @@ static int lintDotCommand( } static void shellPrepare( - ShellState *p, + sqlite3 *db, int *pRc, const char *zSql, sqlite3_stmt **ppStmt ){ *ppStmt = 0; if( *pRc==SQLITE_OK ){ - int rc = sqlite3_prepare_v2(p->db, zSql, -1, ppStmt, 0); + int rc = sqlite3_prepare_v2(db, zSql, -1, ppStmt, 0); if( rc!=SQLITE_OK ){ raw_printf(stderr, "sql error: %s (%d)\n", - sqlite3_errmsg(p->db), sqlite3_errcode(p->db) + sqlite3_errmsg(db), sqlite3_errcode(db) ); *pRc = rc; } @@ -4141,10 +4141,42 @@ static int arUsage(void){ /* ** Values for ArCommand.eCmd. */ -#define AR_CMD_CREATE 1 -#define AR_CMD_EXTRACT 2 -#define AR_CMD_LIST 3 -#define AR_CMD_UPDATE 4 +#define AR_CMD_CREATE 1 +#define AR_CMD_EXTRACT 2 +#define AR_CMD_LIST 3 +#define AR_CMD_UPDATE 4 + +/* +** Other (non-command) switches. +*/ +#define AR_SWITCH_VERBOSE 5 +#define AR_SWITCH_FILE 6 +#define AR_SWITCH_DIRECTORY 7 + +static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ + switch( eSwitch ){ + case AR_CMD_CREATE: + case AR_CMD_EXTRACT: + case AR_CMD_LIST: + case AR_CMD_UPDATE: + if( pAr->eCmd ) return arUsage(); + pAr->eCmd = eSwitch; + break; + + case AR_SWITCH_VERBOSE: + pAr->bVerbose = 1; + break; + + case AR_SWITCH_FILE: + pAr->zFile = zArg; + break; + case AR_SWITCH_DIRECTORY: + pAr->zDir = zArg; + break; + } + + return SQLITE_OK; +} /* ** Parse the command line for an ".ar" command. The results are written into @@ -4157,6 +4189,23 @@ static int arParseCommand( int nArg, /* Number of entries in azArg[] */ ArCommand *pAr /* Populate this object */ ){ + struct ArSwitch { + char cShort; + const char *zLong; + int eSwitch; + int bArg; + } aSwitch[] = { + { 'c', "create", AR_CMD_CREATE, 0 }, + { 'x', "extract", AR_CMD_EXTRACT, 0 }, + { 't', "list", AR_CMD_LIST, 0 }, + { 'u', "update", AR_CMD_UPDATE, 0 }, + { 'v', "verbose", AR_SWITCH_VERBOSE, 0 }, + { 'f', "file", AR_SWITCH_FILE, 1 }, + { 'C', "directory", AR_SWITCH_DIRECTORY, 1 } + }; + int nSwitch = sizeof(aSwitch) / sizeof(struct ArSwitch); + struct ArSwitch *pEnd = &aSwitch[nSwitch]; + if( nArg<=1 ){ return arUsage(); }else{ @@ -4168,45 +4217,91 @@ static int arParseCommand( int i; int iArg = 2; for(i=0; z[i]; i++){ - switch( z[i] ){ - case 'c': - if( pAr->eCmd ) return arUsage(); - pAr->eCmd = AR_CMD_CREATE; - break; - case 'x': - if( pAr->eCmd ) return arUsage(); - pAr->eCmd = AR_CMD_EXTRACT; - break; - case 't': - if( pAr->eCmd ) return arUsage(); - pAr->eCmd = AR_CMD_LIST; - break; - case 'u': - if( pAr->eCmd ) return arUsage(); - pAr->eCmd = AR_CMD_UPDATE; - break; - - case 'v': - pAr->bVerbose = 1; - break; - case 'f': - if( iArg>=nArg ) return arUsage(); - pAr->zFile = azArg[iArg++]; - break; - case 'C': - if( iArg>=nArg ) return arUsage(); - pAr->zDir = azArg[iArg++]; - break; - - default: - return arUsage(); + const char *zArg = 0; + struct ArSwitch *pOpt; + for(pOpt=&aSwitch[0]; pOptcShort ) break; } + if( pOpt==pEnd ) return arUsage(); + if( pOpt->bArg ){ + if( iArg>=nArg ) return arUsage(); + zArg = azArg[iArg++]; + } + if( arProcessSwitch(pAr, pOpt->eSwitch, zArg) ) return SQLITE_ERROR; } - pAr->nArg = nArg-iArg; if( pAr->nArg>0 ){ pAr->azArg = &azArg[iArg]; } + }else{ + /* Non-traditional invocation */ + int iArg; + for(iArg=1; iArgazArg = &azArg[iArg]; + pAr->nArg = nArg-iArg; + break; + } + n = strlen(z); + + if( z[1]!='-' ){ + int i; + /* One or more short options */ + for(i=1; icShort ) break; + } + if( pOpt==pEnd ) return arUsage(); + if( pOpt->bArg ){ + if( i<(n-1) ){ + zArg = &z[i+1]; + i = n; + }else{ + if( iArg>=(nArg-1) ) return arUsage(); + zArg = azArg[++iArg]; + } + } + if( arProcessSwitch(pAr, pOpt->eSwitch, zArg) ) return SQLITE_ERROR; + } + }else if( z[2]=='\0' ){ + /* A -- option, indicating that all remaining command line words + ** are command arguments. */ + pAr->azArg = &azArg[iArg+1]; + pAr->nArg = nArg-iArg-1; + break; + }else{ + /* A long option */ + const char *zArg = 0; /* Argument for option, if any */ + struct ArSwitch *pMatch = 0; /* Matching option */ + struct ArSwitch *pOpt; /* Iterator */ + for(pOpt=&aSwitch[0]; pOptzLong; + if( (n-2)<=strlen(zLong) && 0==memcmp(&z[2], zLong, n-2) ){ + if( pMatch ){ + /* ambiguous option */ + return arUsage(); + }else{ + pMatch = pOpt; + } + } + } + + if( pMatch==0 ){ + /* no such option. */ + return arUsage(); + } + if( pMatch->bArg ){ + if( iArg>=(nArg-1) ) return arUsage(); + zArg = azArg[++iArg]; + } + if( arProcessSwitch(pAr, pMatch->eSwitch, zArg) ) return SQLITE_ERROR; + } + } } } @@ -4216,7 +4311,7 @@ static int arParseCommand( /* ** Implementation of .ar "Update" command. */ -static int arUpdateCmd(ShellState *p, ArCommand *pAr){ +static int arUpdateCmd(ShellState *p, sqlite3 *db, ArCommand *pAr){ raw_printf(stderr, "todo...\n"); return SQLITE_OK; } @@ -4224,7 +4319,7 @@ static int arUpdateCmd(ShellState *p, ArCommand *pAr){ /* ** Implementation of .ar "lisT" command. */ -static int arListCommand(ShellState *p, ArCommand *pAr){ +static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ raw_printf(stderr, "todo...\n"); return SQLITE_OK; } @@ -4233,7 +4328,7 @@ static int arListCommand(ShellState *p, ArCommand *pAr){ /* ** Implementation of .ar "eXtract" command. */ -static int arExtractCommand(ShellState *p, ArCommand *pAr){ +static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ const char *zSql1 = "SELECT :1 || name, writefile(:1 || name, " "CASE WHEN (data AND sz>=0 AND sz!=length(data)) THEN uncompress(data) " @@ -4255,7 +4350,7 @@ static int arExtractCommand(ShellState *p, ArCommand *pAr){ memset(times, 0, sizeof(times)); times[0].tv_sec = time(0); - shellPrepare(p, &rc, zSql1, &pSql); + shellPrepare(db, &rc, zSql1, &pSql); if( rc==SQLITE_OK ){ sqlite3_bind_text(pSql, 1, zDir, -1, SQLITE_STATIC); } @@ -4266,7 +4361,7 @@ static int arExtractCommand(ShellState *p, ArCommand *pAr){ } shellFinalize(&rc, pSql); - shellPrepare(p, &rc, zSql2, &pSql); + shellPrepare(db, &rc, zSql2, &pSql); if( rc==SQLITE_OK ){ sqlite3_bind_text(pSql, 1, zDir, -1, SQLITE_STATIC); } @@ -4296,20 +4391,19 @@ static int arExtractCommand(ShellState *p, ArCommand *pAr){ */ static int arCreateCommand( ShellState *p, /* Shell state pointer */ + sqlite3 *db, ArCommand *pAr /* Command arguments and options */ ){ - const char *zSql = - "SELECT name, mode, mtime, data FROM fsdir(?, ?)"; - - const char *zSqlar = + const char *zSql = "SELECT name, mode, mtime, data FROM fsdir(?, ?)"; + const char *zCreate = "CREATE TABLE IF NOT EXISTS sqlar(" "name TEXT PRIMARY KEY, -- name of the file\n" "mode INT, -- access permissions\n" "mtime INT, -- last modification time\n" "sz INT, -- original file size\n" "data BLOB -- compressed content\n" - ")"; - + ")"; + const char *zDrop = "DROP TABLE IF EXISTS sqlar"; const char *zInsert = "REPLACE INTO sqlar VALUES(?, ?, ?, ?, ?)"; sqlite3_stmt *pStmt = 0; /* Directory traverser */ @@ -4320,12 +4414,15 @@ static int arCreateCommand( Bytef *aCompress = 0; /* Compression buffer */ int nCompress = 0; /* Size of compression buffer */ - rc = sqlite3_exec(p->db, "SAVEPOINT ar;", 0, 0, 0); + rc = sqlite3_exec(db, "SAVEPOINT ar;", 0, 0, 0); if( rc!=SQLITE_OK ) return rc; - rc = sqlite3_exec(p->db, zSqlar, 0, 0, 0); - shellPrepare(p, &rc, zInsert, &pInsert); - shellPrepare(p, &rc, zSql, &pStmt); + rc = sqlite3_exec(db, zDrop, 0, 0, 0); + if( rc!=SQLITE_OK ) return rc; + + rc = sqlite3_exec(db, zCreate, 0, 0, 0); + shellPrepare(db, &rc, zInsert, &pInsert); + shellPrepare(db, &rc, zSql, &pStmt); sqlite3_bind_text(pStmt, 2, pAr->zDir, -1, SQLITE_STATIC); for(i=0; inArg && rc==SQLITE_OK; i++){ @@ -4385,9 +4482,9 @@ static int arCreateCommand( } if( rc!=SQLITE_OK ){ - sqlite3_exec(p->db, "ROLLBACK TO ar; RELEASE ar;", 0, 0, 0); + sqlite3_exec(db, "ROLLBACK TO ar; RELEASE ar;", 0, 0, 0); }else{ - rc = sqlite3_exec(p->db, "RELEASE ar;", 0, 0, 0); + rc = sqlite3_exec(db, "RELEASE ar;", 0, 0, 0); } shellFinalize(&rc, pStmt); shellFinalize(&rc, pInsert); @@ -4407,24 +4504,49 @@ static int arDotCommand( int rc; rc = arParseCommand(azArg, nArg, &cmd); if( rc==SQLITE_OK ){ + sqlite3 *db = 0; /* Database handle to use as archive */ + + if( cmd.zFile ){ + int flags; + if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_UPDATE ){ + flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE; + }else{ + flags = SQLITE_OPEN_READONLY; + } + rc = sqlite3_open_v2(cmd.zFile, &db, flags, 0); + if( rc!=SQLITE_OK ){ + raw_printf(stderr, "cannot open file: %s (%s)\n", + cmd.zFile, sqlite3_errmsg(db) + ); + sqlite3_close(db); + return rc; + } + }else{ + db = pState->db; + } + switch( cmd.eCmd ){ case AR_CMD_CREATE: - rc = arCreateCommand(pState, &cmd); + rc = arCreateCommand(pState, db, &cmd); break; case AR_CMD_EXTRACT: - rc = arExtractCommand(pState, &cmd); + rc = arExtractCommand(pState, db, &cmd); break; case AR_CMD_LIST: - rc = arListCommand(pState, &cmd); + rc = arListCommand(pState, db, &cmd); break; default: assert( cmd.eCmd==AR_CMD_UPDATE ); - rc = arUpdateCmd(pState, &cmd); + rc = arUpdateCmd(pState, db, &cmd); break; } + + if( cmd.zFile ){ + sqlite3_close(db); + } } return rc; diff --git a/test/shell8.test b/test/shell8.test index b3189d4215..577452511a 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -62,41 +62,68 @@ proc dir_compare {d1 d2} { string compare $l1 $l2 } -populate_dir ar1 { - file1 "abcd" - file2 "efgh" - dir1/file3 "ijkl" +foreach {tn tcl} { + 1 { + set c1 ".ar c ar1" + set x1 ".ar x" + + set c2 ".ar cC ar1 ." + set x2 ".ar Cx ar3" + } + + 2 { + set c1 ".ar -c ar1" + set x1 ".ar -x" + + set c2 ".ar -cC ar1 ." + set x2 ".ar -xC ar3" + } + + 3 { + set c1 ".ar --create ar1" + set x1 ".ar --extract" + + set c2 ".ar --directory ar1 --create ." + set x2 ".ar --extract --dir ar3" + } + + 4 { + set c1 ".ar --cr ar1" + set x1 ".ar --e" + + set c2 ".ar -C ar1 -c ." + set x2 ".ar -x -C ar3" + } +} { + eval $tcl + + # Populate directory "ar1" with some files. + # + populate_dir ar1 { + file1 "abcd" + file2 "efgh" + dir1/file3 "ijkl" + } + set expected [dir_to_list ar1] + + do_test 1.$tn.1 { + catchcmd test_ar.db $c1 + file delete -force ar1 + catchcmd test_ar.db $x1 + dir_to_list ar1 + } $expected + + do_test 1.$tn.2 { + file delete -force ar3 + catchcmd test_ar.db $c2 + catchcmd test_ar.db $x2 + dir_to_list ar3 + } $expected } -set expected [dir_to_list ar1] -# puts "# $expected" -do_test 1.1 { - forcedelete test_ar.db - - catchcmd test_ar.db ".ar c ar1" - file delete -force ar1 - catchcmd test_ar.db ".ar x" - - dir_to_list ar1 -} $expected - -do_test 1.2 { - file delete -force ar3 - file mkdir ar3 - catchcmd test_ar.db ".ar xvC ar3" - dir_to_list ar3/ar1 -} $expected - -do_test 1.3 { - file delete -force ar3 - file mkdir ar3 - - forcedelete test_ar.db - catchcmd test_ar.db ".ar cC ar1 file1 file2 dir1" - catchcmd test_ar.db ".ar xC ar3" - dir_to_list ar3 -} $expected +finish_test finish_test + From ece4b0c17201699beb3df4e073fda7b6287cde64 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Dec 2017 20:28:36 +0000 Subject: [PATCH 011/190] Add tests and fixes for the shell ".ar" command -f option. FossilOrigin-Name: 1a9867973c9d6675fa5254fdd74f36004707a98a91593a188033cf5a49cc7a0b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 2 ++ test/shell8.test | 20 ++++++++++++++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index af08ef11da..61046afc09 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\sparsing\soptions\sin\snon-traditional\star\sform\sto\sthe\s".ar"\ncommand.\sHave\swritefile()\sattempt\sto\screate\sany\smissing\spath\scomponents.\sAnd\nnot\sto\sthrow\san\sexception\sif\sit\sis\scalled\sto\screate\sa\sdirectory\sthat\salready\nexists. -D 2017-12-12T20:04:59.331 +C Add\stests\sand\sfixes\sfor\sthe\sshell\s".ar"\scommand\s-f\soption. +D 2017-12-12T20:28:36.588 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -474,7 +474,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in 0ab6e3c1fa09e420e643628d55929422867ca053f05df67a4cae4a67e2a6cfc5 +F src/shell.c.in a09773c80a647f6ba4ef8dd9ce88840d52dbede5a9fa318333843deb8c8548b7 F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1214,7 +1214,7 @@ F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f -F test/shell8.test 5c5a9d100d34b125e0f46d259ea76cf074ac60719b722b2a2c63d759c63fc113 +F test/shell8.test 0f7dfc5b33bde7143df8e37cbb4ae6ccc7e91f87232dc8e5e02be03117cdebb8 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1682,7 +1682,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0394889afed2479773af594e2d9659cf58b8959004ebcdeaff8e08e5dae684ef -R e0d6dbcefc8608142fe03f9ef6d2dee7 +P 38dbeb1e777aa7ec742aa27002ad4dcee28af520dc43de96e5c56c39f16574ff +R e6fcdae437270c2329ef751955f65f0e U dan -Z 5813e7d404a813775aab77275468b917 +Z 1b5cf819c180e1535b22a7c0cf2ece4d diff --git a/manifest.uuid b/manifest.uuid index 9e345298fb..7640d02900 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38dbeb1e777aa7ec742aa27002ad4dcee28af520dc43de96e5c56c39f16574ff \ No newline at end of file +1a9867973c9d6675fa5254fdd74f36004707a98a91593a188033cf5a49cc7a0b \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index fd8659297c..ee9ccd6e76 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4521,6 +4521,8 @@ static int arDotCommand( sqlite3_close(db); return rc; } + sqlite3_fileio_init(db, 0, 0); + sqlite3_compress_init(db, 0, 0); }else{ db = pState->db; } diff --git a/test/shell8.test b/test/shell8.test index 577452511a..07065b56bd 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -69,6 +69,9 @@ foreach {tn tcl} { set c2 ".ar cC ar1 ." set x2 ".ar Cx ar3" + + set c3 ".ar cCf ar1 test_xyz.db ." + set x3 ".ar Cfx ar3 test_xyz.db" } 2 { @@ -77,6 +80,9 @@ foreach {tn tcl} { set c2 ".ar -cC ar1 ." set x2 ".ar -xC ar3" + + set c3 ".ar -cCar1 -ftest_xyz.db ." + set x3 ".ar -x -C ar3 -f test_xyz.db" } 3 { @@ -85,6 +91,9 @@ foreach {tn tcl} { set c2 ".ar --directory ar1 --create ." set x2 ".ar --extract --dir ar3" + + set c3 ".ar --creat --dir ar1 --file test_xyz.db ." + set x3 ".ar --e --d ar3 --f test_xyz.db" } 4 { @@ -93,6 +102,9 @@ foreach {tn tcl} { set c2 ".ar -C ar1 -c ." set x2 ".ar -x -C ar3" + + set c3 ".ar -c --directory ar1 --file test_xyz.db ." + set x3 ".ar -x --directory ar3 --file test_xyz.db" } } { eval $tcl @@ -119,6 +131,14 @@ foreach {tn tcl} { catchcmd test_ar.db $x2 dir_to_list ar3 } $expected + + do_test 1.$tn.3 { + file delete -force ar3 + file delete -force test_xyz.db + catchcmd ":memory:" $c3 + catchcmd ":memory:" $x3 + dir_to_list ar3 + } $expected } finish_test From 3f67ddf8f22cae016c577dff9295b2fe523031c9 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Dec 2017 20:04:53 +0000 Subject: [PATCH 012/190] Add support for the "--list" command. And for arguments to the "--extract" command. FossilOrigin-Name: 32c4fa2552bb0fa7d7d143108457efae7a756d6cb14b1d59312e56efac3b2656 --- manifest | 12 ++--- manifest.uuid | 2 +- src/shell.c.in | 138 +++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 135 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 61046afc09..8be2f2242c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sand\sfixes\sfor\sthe\sshell\s".ar"\scommand\s-f\soption. -D 2017-12-12T20:28:36.588 +C Add\ssupport\sfor\sthe\s"--list"\scommand.\sAnd\sfor\sarguments\sto\sthe\s"--extract"\ncommand. +D 2017-12-13T20:04:53.034 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -474,7 +474,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in a09773c80a647f6ba4ef8dd9ce88840d52dbede5a9fa318333843deb8c8548b7 +F src/shell.c.in b53eddcb293a9d35c0673c1d3bf2cf120b55e6660b436f65d689776a56391562 F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1682,7 +1682,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 38dbeb1e777aa7ec742aa27002ad4dcee28af520dc43de96e5c56c39f16574ff -R e6fcdae437270c2329ef751955f65f0e +P 1a9867973c9d6675fa5254fdd74f36004707a98a91593a188033cf5a49cc7a0b +R c505f9c0d154ac54b6761fcc5d07e027 U dan -Z 1b5cf819c180e1535b22a7c0cf2ece4d +Z dcb23b384070f4f2014f2150f41e157a diff --git a/manifest.uuid b/manifest.uuid index 7640d02900..71ba76fdc3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1a9867973c9d6675fa5254fdd74f36004707a98a91593a188033cf5a49cc7a0b \ No newline at end of file +32c4fa2552bb0fa7d7d143108457efae7a756d6cb14b1d59312e56efac3b2656 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index ee9ccd6e76..0230e5f4d7 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4092,6 +4092,26 @@ static void shellPrepare( } } +static void shellPrepare2( + sqlite3 *db, + int *pRc, + const char *zSql, + const char *zTail, + sqlite3_stmt **ppStmt +){ + if( *pRc==SQLITE_OK && zTail ){ + char *z = sqlite3_mprintf("%s %s", zSql, zTail); + if( z==0 ){ + *pRc = SQLITE_NOMEM; + }else{ + shellPrepare(db, pRc, z, ppStmt); + sqlite3_free(z); + } + }else{ + shellPrepare(db, pRc, zSql, ppStmt); + } +} + static void shellFinalize( int *pRc, sqlite3_stmt *pStmt @@ -4316,12 +4336,96 @@ static int arUpdateCmd(ShellState *p, sqlite3 *db, ArCommand *pAr){ return SQLITE_OK; } +/* +** This function assumes that all arguments within the ArCommand.azArg[] +** array refer to archive members, as for the --extract or --list commands. +** It checks that each of them are present. If any specified file is not +** present in the archive, an error is printed to stderr and an error +** code returned. Otherwise, if all specified arguments are present in +** the archive, SQLITE_OK is returned. +** +** This function strips any trailing '/' characters from each argument. +** This is consistent with the way the [tar] command seems to work on +** Linux. +*/ +static int arCheckEntries(sqlite3 *db, ArCommand *pAr){ + int rc = SQLITE_OK; + if( pAr->nArg ){ + int i; + sqlite3_stmt *pTest = 0; + + shellPrepare(db, &rc, "SELECT name FROM sqlar WHERE name=?", &pTest); + for(i=0; inArg && rc==SQLITE_OK; i++){ + char *z = pAr->azArg[i]; + int n = strlen(z); + int bOk = 0; + while( n>0 && z[n-1]=='/' ) n--; + z[n] = '\0'; + sqlite3_bind_text(pTest, 1, z, -1, SQLITE_STATIC); + if( SQLITE_ROW==sqlite3_step(pTest) ){ + bOk = 1; + } + shellReset(&rc, pTest); + if( rc==SQLITE_OK && bOk==0 ){ + raw_printf(stderr, "not found in archive: %s\n", z); + rc = SQLITE_ERROR; + } + } + shellFinalize(&rc, pTest); + } + + return rc; +} + +/* +** Format a WHERE clause that can be used against the "sqlar" table to +** identify all archive members that match the command arguments held +** in (*pAr). Leave this WHERE clause in (*pzWhere) before returning. +** The caller is responsible for eventually calling sqlite3_free() on +** any non-NULL (*pzWhere) value. +*/ +static void arWhereClause( + int *pRc, + ArCommand *pAr, + char **pzWhere /* OUT: New WHERE clause (or NULL) */ +){ + char *zWhere = 0; + if( *pRc==SQLITE_OK ){ + int i; + const char *zSep = "WHERE "; + for(i=0; inArg; i++){ + const char *z = pAr->azArg[i]; + zWhere = sqlite3_mprintf( + "%z%s name = '%q' OR name BETWEEN '%q/' AND '%q0'", + zWhere, zSep, z, z, z + ); + if( zWhere==0 ){ + *pRc = SQLITE_NOMEM; + break; + } + zSep = " OR "; + } + } + *pzWhere = zWhere; +} + /* ** Implementation of .ar "lisT" command. */ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ - raw_printf(stderr, "todo...\n"); - return SQLITE_OK; + const char *zSql = "SELECT name FROM sqlar"; + char *zWhere = 0; + sqlite3_stmt *pSql = 0; + int rc; + + rc = arCheckEntries(db, pAr); + arWhereClause(&rc, pAr, &zWhere); + + shellPrepare2(db, &rc, zSql, zWhere, &pSql); + while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ + raw_printf(p->out, "%s\n", sqlite3_column_text(pSql, 0)); + } + return rc; } @@ -4331,8 +4435,11 @@ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ const char *zSql1 = "SELECT :1 || name, writefile(:1 || name, " - "CASE WHEN (data AND sz>=0 AND sz!=length(data)) THEN uncompress(data) " - " ELSE data END, " + "CASE WHEN (data AND sz>=0 AND sz!=length(data)) THEN " + " uncompress(data) " + "ELSE" + " data " + "END, " "mode) FROM sqlar"; const char *zSql2 = "SELECT :1 || name, mtime FROM sqlar"; @@ -4340,17 +4447,27 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ sqlite3_stmt *pSql = 0; int rc = SQLITE_OK; char *zDir = 0; + char *zWhere = 0; - if( pAr->zDir ){ - zDir = sqlite3_mprintf("%s/", pAr->zDir); - }else{ - zDir = sqlite3_mprintf(""); + /* If arguments are specified, check that they actually exist within + ** the archive before proceeding. And formulate a WHERE clause to + ** match them. */ + rc = arCheckEntries(db, pAr); + arWhereClause(&rc, pAr, &zWhere); + + if( rc==SQLITE_OK ){ + if( pAr->zDir ){ + zDir = sqlite3_mprintf("%s/", pAr->zDir); + }else{ + zDir = sqlite3_mprintf(""); + } + if( zDir==0 ) rc = SQLITE_NOMEM; } memset(times, 0, sizeof(times)); times[0].tv_sec = time(0); - shellPrepare(db, &rc, zSql1, &pSql); + shellPrepare2(db, &rc, zSql1, zWhere, &pSql); if( rc==SQLITE_OK ){ sqlite3_bind_text(pSql, 1, zDir, -1, SQLITE_STATIC); } @@ -4361,7 +4478,7 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ } shellFinalize(&rc, pSql); - shellPrepare(db, &rc, zSql2, &pSql); + shellPrepare2(db, &rc, zSql2, zWhere, &pSql); if( rc==SQLITE_OK ){ sqlite3_bind_text(pSql, 1, zDir, -1, SQLITE_STATIC); } @@ -4377,6 +4494,7 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ shellFinalize(&rc, pSql); sqlite3_free(zDir); + sqlite3_free(zWhere); return rc; } From 06741a3c9b7bfb10c6d22ae74706b40af46ecd4a Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Dec 2017 20:17:18 +0000 Subject: [PATCH 013/190] Add the shell tool ".ar --update" command. FossilOrigin-Name: 825e3c037b03fc09d581aeda0193ff1d4062404414c7354cb649f99aa9022d25 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 48 +++++++++++++++++++++++++++++++++++------------- 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 8be2f2242c..c7890a8a98 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\sthe\s"--list"\scommand.\sAnd\sfor\sarguments\sto\sthe\s"--extract"\ncommand. -D 2017-12-13T20:04:53.034 +C Add\sthe\sshell\stool\s".ar\s--update"\scommand. +D 2017-12-13T20:17:18.759 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -474,7 +474,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in b53eddcb293a9d35c0673c1d3bf2cf120b55e6660b436f65d689776a56391562 +F src/shell.c.in 12313c0500b9b1958507d3a432c192f73f86da112f0f37467636530696d13152 F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1682,7 +1682,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1a9867973c9d6675fa5254fdd74f36004707a98a91593a188033cf5a49cc7a0b -R c505f9c0d154ac54b6761fcc5d07e027 +P 32c4fa2552bb0fa7d7d143108457efae7a756d6cb14b1d59312e56efac3b2656 +R 656e4fd0036ab859f27379daf7289767 U dan -Z dcb23b384070f4f2014f2150f41e157a +Z 57a0e73a5198163aa720919c6750aab2 diff --git a/manifest.uuid b/manifest.uuid index 71ba76fdc3..937d78b439 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -32c4fa2552bb0fa7d7d143108457efae7a756d6cb14b1d59312e56efac3b2656 \ No newline at end of file +825e3c037b03fc09d581aeda0193ff1d4062404414c7354cb649f99aa9022d25 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 0230e5f4d7..e9a01ed779 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4328,14 +4328,6 @@ static int arParseCommand( return SQLITE_OK; } -/* -** Implementation of .ar "Update" command. -*/ -static int arUpdateCmd(ShellState *p, sqlite3 *db, ArCommand *pAr){ - raw_printf(stderr, "todo...\n"); - return SQLITE_OK; -} - /* ** This function assumes that all arguments within the ArCommand.azArg[] ** array refer to archive members, as for the --extract or --list commands. @@ -4500,17 +4492,21 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ /* -** Implementation of .ar "Create" command. +** Implementation of .ar "create" and "update" commands. ** ** Create the "sqlar" table in the database if it does not already exist. ** Then add each file in the azFile[] array to the archive. Directories ** are added recursively. If argument bVerbose is non-zero, a message is ** printed on stdout for each file archived. +** +** The create command is the same as update, except that it drops +** any existing "sqlar" table before beginning. */ -static int arCreateCommand( +static int arCreateUpdate( ShellState *p, /* Shell state pointer */ sqlite3 *db, - ArCommand *pAr /* Command arguments and options */ + ArCommand *pAr, /* Command arguments and options */ + int bUpdate ){ const char *zSql = "SELECT name, mode, mtime, data FROM fsdir(?, ?)"; const char *zCreate = @@ -4535,8 +4531,10 @@ static int arCreateCommand( rc = sqlite3_exec(db, "SAVEPOINT ar;", 0, 0, 0); if( rc!=SQLITE_OK ) return rc; - rc = sqlite3_exec(db, zDrop, 0, 0, 0); - if( rc!=SQLITE_OK ) return rc; + if( bUpdate==0 ){ + rc = sqlite3_exec(db, zDrop, 0, 0, 0); + if( rc!=SQLITE_OK ) return rc; + } rc = sqlite3_exec(db, zCreate, 0, 0, 0); shellPrepare(db, &rc, zInsert, &pInsert); @@ -4610,6 +4608,30 @@ static int arCreateCommand( return rc; } +/* +** Implementation of .ar "Create" command. +** +** Create the "sqlar" table in the database if it does not already exist. +** Then add each file in the azFile[] array to the archive. Directories +** are added recursively. If argument bVerbose is non-zero, a message is +** printed on stdout for each file archived. +*/ +static int arCreateCommand( + ShellState *p, /* Shell state pointer */ + sqlite3 *db, + ArCommand *pAr /* Command arguments and options */ +){ + return arCreateUpdate(p, db, pAr, 0); +} + +/* +** Implementation of .ar "Update" command. +*/ +static int arUpdateCmd(ShellState *p, sqlite3 *db, ArCommand *pAr){ + return arCreateUpdate(p, db, pAr, 1); +} + + /* ** Implementation of ".ar" dot command. */ From 0d0547fec67e1ef00b68fdfd648709f7f5477719 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 14 Dec 2017 15:40:42 +0000 Subject: [PATCH 014/190] Improve error and usage messages output by the shell ".ar" command. FossilOrigin-Name: b9d2d5d97291bf3d1392232e3705cca89dc7b918db2b08067b2b013ea39320e0 --- manifest | 12 +++---- manifest.uuid | 2 +- src/shell.c.in | 92 +++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 80 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index d58279c9ae..dda85f8287 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\slatest\strunk\schanges\sinto\sthis\sbranch. -D 2017-12-14T13:55:01.572 +C Improve\serror\sand\susage\smessages\soutput\sby\sthe\sshell\s".ar"\scommand. +D 2017-12-14T15:40:42.931 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -475,7 +475,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in 12313c0500b9b1958507d3a432c192f73f86da112f0f37467636530696d13152 +F src/shell.c.in 4bdd2efe722005180365698f2a3de51e22ae1e9bb61c868006bc8f2c5e02eb98 F src/sqlite.h.in 364515dd186285f3c01f5cab42e7db7edc47c70e87b6a25de389a2e6b8c413fd F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1683,7 +1683,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 825e3c037b03fc09d581aeda0193ff1d4062404414c7354cb649f99aa9022d25 3765aaf712998af5ffb6bc680a0c1419f2b5deb47ecbc1835ba5879127c4dbe3 -R bf083f80c8163c105f680457377723eb +P 803156cba8b056a1cb8d1bb186a57454afe72341abe7de1dfe529234c3415cd2 +R 69895ee1194373ab4ba11578d798fe26 U dan -Z 36133c008e2dcaa09c3c6c120c31dee9 +Z 5ea750b0cf239f9442948a3eda934166 diff --git a/manifest.uuid b/manifest.uuid index 4a8f53dbe3..ce1ae1dcb3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -803156cba8b056a1cb8d1bb186a57454afe72341abe7de1dfe529234c3415cd2 \ No newline at end of file +b9d2d5d97291bf3d1392232e3705cca89dc7b918db2b08067b2b013ea39320e0 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index e9a01ed779..2a0f9fde9e 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4152,9 +4152,46 @@ struct ArCommand { /* ** Print a usage message for the .ar command to stderr and return SQLITE_ERROR. */ -static int arUsage(void){ - /* todo */ - raw_printf(stderr, "error in .ar command line\n"); +static int arUsage(FILE *f){ + raw_printf(f, +"\n" +"Usage: .ar [OPTION...] [FILE...]\n" +"The .ar command manages sqlar archives.\n" +"\n" +"Examples:\n" +" .ar -cf archive.sar foo bar # Create archive.sar from files foo and bar\n" +" .ar -tf archive.sar # List members of archive.sar\n" +" .ar -xvf archive.sar # Verbosely extract files from archive.sar\n" +"\n" +"Each command line must feature exactly one command option:\n" +" -c, --create Create a new archive\n" +" -u, --update Update or add files to an existing archive\n" +" -t, --list List contents of archive\n" +" -x, --extract Extract files from archive\n" +"\n" +"And zero or more optional options:\n" +" -v, --verbose Print each filename as it is processed\n" +" -f FILE, --file FILE Operate on archive FILE (default is current db)\n" +" -C DIR, --directory DIR Change to directory DIR to read/extract files\n" +"\n" +"See also: http://sqlite.org/cli.html#sqlar_archive_support\n" +"\n" +); + return SQLITE_ERROR; +} + +/* +** Print an error message for the .ar command to stderr and return +** SQLITE_ERROR. +*/ +static int arErrorMsg(const char *zFmt, ...){ + va_list ap; + char *z; + va_start(ap, zFmt); + z = sqlite3_vmprintf(zFmt, ap); + va_end(ap); + raw_printf(stderr, "Error: %s (try \".ar --help\")\n", z); + sqlite3_free(z); return SQLITE_ERROR; } @@ -4165,13 +4202,14 @@ static int arUsage(void){ #define AR_CMD_EXTRACT 2 #define AR_CMD_LIST 3 #define AR_CMD_UPDATE 4 +#define AR_CMD_HELP 5 /* ** Other (non-command) switches. */ -#define AR_SWITCH_VERBOSE 5 -#define AR_SWITCH_FILE 6 -#define AR_SWITCH_DIRECTORY 7 +#define AR_SWITCH_VERBOSE 6 +#define AR_SWITCH_FILE 7 +#define AR_SWITCH_DIRECTORY 8 static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ switch( eSwitch ){ @@ -4179,7 +4217,10 @@ static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ case AR_CMD_EXTRACT: case AR_CMD_LIST: case AR_CMD_UPDATE: - if( pAr->eCmd ) return arUsage(); + case AR_CMD_HELP: + if( pAr->eCmd ){ + return arErrorMsg("multiple command options"); + } pAr->eCmd = eSwitch; break; @@ -4219,6 +4260,7 @@ static int arParseCommand( { 'x', "extract", AR_CMD_EXTRACT, 0 }, { 't', "list", AR_CMD_LIST, 0 }, { 'u', "update", AR_CMD_UPDATE, 0 }, + { 'h', "help", AR_CMD_HELP, 0 }, { 'v', "verbose", AR_SWITCH_VERBOSE, 0 }, { 'f', "file", AR_SWITCH_FILE, 1 }, { 'C', "directory", AR_SWITCH_DIRECTORY, 1 } @@ -4227,7 +4269,7 @@ static int arParseCommand( struct ArSwitch *pEnd = &aSwitch[nSwitch]; if( nArg<=1 ){ - return arUsage(); + return arUsage(stderr); }else{ char *z = azArg[1]; memset(pAr, 0, sizeof(ArCommand)); @@ -4242,9 +4284,13 @@ static int arParseCommand( for(pOpt=&aSwitch[0]; pOptcShort ) break; } - if( pOpt==pEnd ) return arUsage(); + if( pOpt==pEnd ){ + return arErrorMsg("unrecognized option: %c", z[i]); + } if( pOpt->bArg ){ - if( iArg>=nArg ) return arUsage(); + if( iArg>=nArg ){ + return arErrorMsg("option requires an argument: %c",z[i]); + } zArg = azArg[iArg++]; } if( arProcessSwitch(pAr, pOpt->eSwitch, zArg) ) return SQLITE_ERROR; @@ -4276,13 +4322,17 @@ static int arParseCommand( for(pOpt=&aSwitch[0]; pOptcShort ) break; } - if( pOpt==pEnd ) return arUsage(); + if( pOpt==pEnd ){ + return arErrorMsg("unrecognized option: %c\n", z[i]); + } if( pOpt->bArg ){ if( i<(n-1) ){ zArg = &z[i+1]; i = n; }else{ - if( iArg>=(nArg-1) ) return arUsage(); + if( iArg>=(nArg-1) ){ + return arErrorMsg("option requires an argument: %c\n",z[i]); + } zArg = azArg[++iArg]; } } @@ -4303,8 +4353,7 @@ static int arParseCommand( const char *zLong = pOpt->zLong; if( (n-2)<=strlen(zLong) && 0==memcmp(&z[2], zLong, n-2) ){ if( pMatch ){ - /* ambiguous option */ - return arUsage(); + return arErrorMsg("ambiguous option: %s",z); }else{ pMatch = pOpt; } @@ -4312,11 +4361,12 @@ static int arParseCommand( } if( pMatch==0 ){ - /* no such option. */ - return arUsage(); + return arErrorMsg("unrecognized option: %s", z); } if( pMatch->bArg ){ - if( iArg>=(nArg-1) ) return arUsage(); + if( iArg>=(nArg-1) ){ + return arErrorMsg("option requires an argument: %s", z); + } zArg = azArg[++iArg]; } if( arProcessSwitch(pAr, pMatch->eSwitch, zArg) ) return SQLITE_ERROR; @@ -4465,7 +4515,7 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ } while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ if( pAr->bVerbose ){ - raw_printf(stdout, "%s\n", sqlite3_column_text(pSql, 0)); + raw_printf(p->out, "%s\n", sqlite3_column_text(pSql, 0)); } } shellFinalize(&rc, pSql); @@ -4550,7 +4600,7 @@ static int arCreateUpdate( unsigned int mtime = sqlite3_column_int(pStmt, 2); if( pAr->bVerbose ){ - raw_printf(stdout, "%s\n", zName); + raw_printf(p->out, "%s\n", zName); } sqlite3_bind_text(pInsert, 1, zName, -1, SQLITE_STATIC); @@ -4680,6 +4730,10 @@ static int arDotCommand( rc = arListCommand(pState, db, &cmd); break; + case AR_CMD_HELP: + arUsage(pState->out); + break; + default: assert( cmd.eCmd==AR_CMD_UPDATE ); rc = arUpdateCmd(pState, db, &cmd); From e483d349ab20b49cf704423f3d15e30d722f25e2 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Dec 2017 16:28:27 +0000 Subject: [PATCH 015/190] Add the ability to write to an appended database. This check-in compiles but is otherwise untested. FossilOrigin-Name: e343c63cbd754f37c33c939cd0b6f1ecc6202e60c6e66cd65c23cc8d571a994e --- ext/misc/appendvfs.c | 187 ++++++++++++++++++++++++++++++++++--------- manifest | 12 +-- manifest.uuid | 2 +- 3 files changed, 155 insertions(+), 46 deletions(-) diff --git a/ext/misc/appendvfs.c b/ext/misc/appendvfs.c index b650b80be3..d0096f1224 100644 --- a/ext/misc/appendvfs.c +++ b/ext/misc/appendvfs.c @@ -18,8 +18,31 @@ ** best performance page 1 should be located at a disk page boundary, though ** that is not required. ** -** An appended database is considered immutable. It is read-only and no -** locks are ever taken. +** When opening a database using this VFS, the connection might treat +** the file as an ordinary SQLite database, or it might treat is as a +** database appended onto some other file. Here are the rules: +** +** (1) When opening a new empty file, that file is treated as an ordinary +** database. +** +** (2) When opening a file that begins with the standard SQLite prefix +** string "SQLite format 3", that file is treated as an ordinary +** database. +** +** (3) When opening a file that ends with the appendvfs trailer string +** "Start-Of-SQLite3-NNNNNNNN" that file is treated as an appended +** database. +** +** (4) If none of the above apply and the SQLITE_OPEN_CREATE flag is +** set, then a new database is appended to the already existing file. +** +** (5) Otherwise, SQLITE_CANTOPEN is returned. +** +** To avoid unnecessary complications with the PENDING_BYTE, the size of +** the file containing the database is limited to 1GB. This VFS will refuse +** to read or write past the 1GB mark. This restriction might be lifted in +** future versions. For now, if you need a large database, then keep the +** database in a separate file. ** ** If the file being opened is not an appended database, then this shim is ** a pass-through into the default underlying VFS. @@ -41,6 +64,12 @@ SQLITE_EXTENSION_INIT1 #define APND_MARK_PREFIX_SZ 17 #define APND_MARK_SIZE 25 +/* +** Maximum size of the combined prefix + database + append-mark. This +** must be less than 0x40000000 to avoid locking issues on Windows. +*/ +#define APND_MAX_SIZE (65536*15259) + /* ** Forward declaration of objects used by this utility */ @@ -57,6 +86,7 @@ typedef struct ApndFile ApndFile; struct ApndFile { sqlite3_file base; /* IO methods */ sqlite3_int64 iPgOne; /* File offset to page 1 */ + sqlite3_int64 iMark; /* Start of the append-mark */ }; /* @@ -172,37 +202,75 @@ static int apndRead( return pFile->pMethods->xRead(pFile, zBuf, iAmt, iOfst+p->iPgOne); } +/* +** Add the append-mark onto the end of the file. +*/ +static int apndWriteMark(ApndFile *p, sqlite3_file *pFile){ + int i; + unsigned char a[APND_MARK_SIZE]; + memcpy(a, APND_MARK_PREFIX, APND_MARK_PREFIX_SZ); + for(i=0; i<8; i++){ + a[APND_MARK_PREFIX_SZ+i] = (p->iPgOne >> (56 - i*8)) & 0xff; + } + return pFile->pMethods->xWrite(pFile, a, APND_MARK_PREFIX_SZ, p->iMark); +} + /* ** Write data to an apnd-file. */ static int apndWrite( sqlite3_file *pFile, - const void *z, + const void *zBuf, int iAmt, sqlite_int64 iOfst ){ - return SQLITE_READONLY; + int rc; + ApndFile *p = (ApndFile *)pFile; + pFile = ORIGFILE(pFile); + if( iOfst+iAmt>=APND_MAX_SIZE ) return SQLITE_FULL; + rc = pFile->pMethods->xWrite(pFile, zBuf, iAmt, iOfst+p->iPgOne); + if( rc==SQLITE_OK && iOfst + iAmt + p->iPgOne > p->iMark ){ + sqlite3_int64 sz = 0; + rc = pFile->pMethods->xFileSize(pFile, &sz); + if( rc==SQLITE_OK ){ + p->iMark = sz - APND_MARK_SIZE; + if( iOfst + iAmt + p->iPgOne > p->iMark ){ + p->iMark = p->iPgOne + iOfst + iAmt; + rc = apndWriteMark(p, pFile); + } + } + } + return rc; } /* ** Truncate an apnd-file. */ static int apndTruncate(sqlite3_file *pFile, sqlite_int64 size){ - return SQLITE_READONLY; + int rc; + ApndFile *p = (ApndFile *)pFile; + pFile = ORIGFILE(pFile); + rc = pFile->pMethods->xTruncate(pFile, size+p->iPgOne+APND_MARK_SIZE); + if( rc==SQLITE_OK ){ + p->iMark = p->iPgOne+size; + rc = apndWriteMark(p, pFile); + } + return rc; } /* ** Sync an apnd-file. */ static int apndSync(sqlite3_file *pFile, int flags){ - return SQLITE_READONLY; + pFile = ORIGFILE(pFile); + return pFile->pMethods->xSync(pFile, flags); } /* ** Return the current file-size of an apnd-file. */ static int apndFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ - ApndFile *p = (ApndFile*)pFile; + ApndFile *p = (ApndFile *)pFile; int rc; pFile = ORIGFILE(p); rc = pFile->pMethods->xFileSize(pFile, pSize); @@ -216,22 +284,24 @@ static int apndFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ ** Lock an apnd-file. */ static int apndLock(sqlite3_file *pFile, int eLock){ - return SQLITE_READONLY; + pFile = ORIGFILE(pFile); + return pFile->pMethods->xLock(pFile, eLock); } /* ** Unlock an apnd-file. */ static int apndUnlock(sqlite3_file *pFile, int eLock){ - return SQLITE_OK; + pFile = ORIGFILE(pFile); + return pFile->pMethods->xUnlock(pFile, eLock); } /* ** Check if another file-handle holds a RESERVED lock on an apnd-file. */ static int apndCheckReservedLock(sqlite3_file *pFile, int *pResOut){ - *pResOut = 0; - return SQLITE_OK; + pFile = ORIGFILE(pFile); + return pFile->pMethods->xCheckReservedLock(pFile, pResOut); } /* @@ -273,22 +343,26 @@ static int apndShmMap( int bExtend, void volatile **pp ){ - return SQLITE_READONLY; + pFile = ORIGFILE(pFile); + return pFile->pMethods->xShmMap(pFile,iPg,pgsz,bExtend,pp); } /* Perform locking on a shared-memory segment */ static int apndShmLock(sqlite3_file *pFile, int offset, int n, int flags){ - return SQLITE_READONLY; + pFile = ORIGFILE(pFile); + return pFile->pMethods->xShmLock(pFile,offset,n,flags); } /* Memory barrier operation on shared memory */ static void apndShmBarrier(sqlite3_file *pFile){ - return; + pFile = ORIGFILE(pFile); + pFile->pMethods->xShmBarrier(pFile); } /* Unmap a shared memory segment */ static int apndShmUnmap(sqlite3_file *pFile, int deleteFlag){ - return SQLITE_OK; + pFile = ORIGFILE(pFile); + return pFile->pMethods->xShmUnmap(pFile,deleteFlag); } /* Fetch a page of a memory-mapped file */ @@ -310,6 +384,40 @@ static int apndUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){ return pFile->pMethods->xUnfetch(pFile, iOfst+p->iPgOne, pPage); } +/* +** Check to see if the file is an ordinary SQLite database file. +*/ +static int apndIsOrdinaryDatabaseFile(sqlite3_int64 sz, sqlite3_file *pFile){ + int rc; + char zHdr[16]; + static const char aSqliteHdr[] = "SQLite format 3"; + if( sz<512 ) return 0; + rc = pFile->pMethods->xRead(pFile, zHdr, sizeof(zHdr), 0); + if( rc ) return 0; + return memcmp(zHdr, aSqliteHdr, sizeof(zHdr))==0; +} + +/* +** Try to read the append-mark off the end of a file. Return the +** start of the appended database if the append-mark is present. If +** there is no append-mark, return -1; +*/ +static sqlite3_int64 apndReadMark(sqlite3_int64 sz, sqlite3_file *pFile){ + int rc, i; + sqlite3_int64 iMark; + unsigned char a[APND_MARK_SIZE]; + + if( sz<=APND_MARK_SIZE ) return -1; + rc = pFile->pMethods->xRead(pFile, a, APND_MARK_SIZE, sz-APND_MARK_SIZE); + if( rc ) return -1; + if( memcmp(a, APND_MARK_PREFIX, APND_MARK_PREFIX_SZ)!=0 ) return -1; + iMark = ((sqlite3_int64)(a[APND_MARK_PREFIX_SZ]&0x7f))<<56; + for(i=1; i<8; i++){ + iMark += (sqlite3_int64)a[APND_MARK_PREFIX_SZ+i]<<(56-8*i); + } + return iMark; +} + /* ** Open an apnd file handle. */ @@ -321,38 +429,39 @@ static int apndOpen( int *pOutFlags ){ ApndFile *p; + sqlite3_file *pSubFile; + sqlite3_vfs *pSubVfs; int rc; sqlite3_int64 sz; - pVfs = ORIGVFS(pVfs); + pSubVfs = ORIGVFS(pVfs); if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){ - return pVfs->xOpen(pVfs, zName, pFile, flags, pOutFlags); + return pSubVfs->xOpen(pSubVfs, zName, pFile, flags, pOutFlags); } p = (ApndFile*)pFile; memset(p, 0, sizeof(*p)); p->base.pMethods = &apnd_io_methods; - pFile = ORIGFILE(pFile); - flags &= ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE); - flags |= SQLITE_OPEN_READONLY; - rc = pVfs->xOpen(pVfs, zName, pFile, flags, pOutFlags); + pSubFile = ORIGFILE(pFile); + rc = pSubVfs->xOpen(pSubVfs, zName, pSubFile, flags, pOutFlags); if( rc ) return rc; - rc = pFile->pMethods->xFileSize(pFile, &sz); - if( rc==SQLITE_OK && sz>512 ){ - unsigned char a[APND_MARK_SIZE]; - rc = pFile->pMethods->xRead(pFile, a, APND_MARK_SIZE, sz-APND_MARK_SIZE); - if( rc==SQLITE_OK - && memcmp(a, APND_MARK_PREFIX, APND_MARK_PREFIX_SZ)==0 - ){ - p->iPgOne = - ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ]<<56) + - ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+1]<<48) + - ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+2]<<40) + - ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+3]<<32) + - ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+4]<<24) + - ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+5]<<16) + - ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+6]<<8) + - ((sqlite3_uint64)a[APND_MARK_PREFIX_SZ+7]); - } + rc = pSubFile->pMethods->xFileSize(pSubFile, &sz); + if( rc ){ + pSubFile->pMethods->xClose(pSubFile); + return rc; } + if( apndIsOrdinaryDatabaseFile(sz, pSubFile) ){ + memmove(pFile, pSubFile, pSubVfs->szOsFile); + return SQLITE_OK; + } + p->iMark = 0; + p->iPgOne = apndReadMark(sz, pFile); + if( p->iPgOne>0 ){ + return SQLITE_OK; + } + if( (flags & SQLITE_OPEN_CREATE)==0 ){ + pSubFile->pMethods->xClose(pSubFile); + return SQLITE_CANTOPEN; + } + p->iPgOne = (sz+0xfff) & ~(sqlite3_int64)0xfff; return SQLITE_OK; } @@ -442,7 +551,7 @@ int sqlite3_appendvfs_init( apnd_vfs.iVersion = pOrig->iVersion; apnd_vfs.pAppData = pOrig; apnd_vfs.szOsFile = sizeof(ApndFile); - rc = sqlite3_vfs_register(&apnd_vfs, 1); + rc = sqlite3_vfs_register(&apnd_vfs, 0); #ifdef APPENDVFS_TEST if( rc==SQLITE_OK ){ rc = sqlite3_auto_extension((void(*)(void))apndvfsRegister); diff --git a/manifest b/manifest index 1b36095a3f..4ddbb0d1d5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bring\sin\sthe\slatest\strunk\schanges. -D 2017-12-14T14:50:49.020 +C Add\sthe\sability\sto\swrite\sto\san\sappended\sdatabase.\s\sThis\scheck-in\scompiles\nbut\sis\sotherwise\suntested. +D 2017-12-14T16:28:27.146 F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc a2492b29176edc3c754aa7a2f7daa20cd3fa20a56e3ee64e376092836177c42a @@ -260,7 +260,7 @@ F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f607 F ext/misc/README.md 8e008c8d2b02e09096b31dfba033253ac27c6c06a18aa5826e299fa7601d90b2 F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb -F ext/misc/appendvfs.c 487a5db4427d118413346780c4c90d0256315e8de3fb528ee54daef3bb73276f +F ext/misc/appendvfs.c c8b18caae0d22762080a9c48a4e46933f48625bac7fde2af9ef8ec2a23755ac9 F ext/misc/btreeinfo.c d7fd9a2fe2fa33ba28488e2fce703ebecc759219ea9e0bb3b254784866c0a676 F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 @@ -1681,7 +1681,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1a1a73b821eb1a22ca335f582a0aea31c71ca9f5b09d54f26409691c90e38c4a 3765aaf712998af5ffb6bc680a0c1419f2b5deb47ecbc1835ba5879127c4dbe3 -R 29a07f33957881a5b837419ff7f21683 +P 75d8517703f7efa33437079108e2c4ef0de1a118bbe1f4a86afdc34da09d3008 +R 15eddfa7673da0a2579cc83183e243e0 U drh -Z d18bd4436a6dfca865f7b12ca3ce5865 +Z 4e88658420f57b7b81dd23d0961f71ee diff --git a/manifest.uuid b/manifest.uuid index 29cb2dde87..026378badf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -75d8517703f7efa33437079108e2c4ef0de1a118bbe1f4a86afdc34da09d3008 \ No newline at end of file +e343c63cbd754f37c33c939cd0b6f1ecc6202e60c6e66cd65c23cc8d571a994e \ No newline at end of file From 233ff96ec5beae1301731a3c0893f8cf358c86f0 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Dec 2017 16:57:11 +0000 Subject: [PATCH 016/190] The "apndvfs" VFS shim now appears to be working for both reads and writes. FossilOrigin-Name: 7f7b72d83633922e2b5dbf0d3455d0fea72cc6b8925ffcb78dfbad7b3c4b26e9 --- ext/misc/appendvfs.c | 7 +++---- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ext/misc/appendvfs.c b/ext/misc/appendvfs.c index d0096f1224..bd1f37509e 100644 --- a/ext/misc/appendvfs.c +++ b/ext/misc/appendvfs.c @@ -212,7 +212,7 @@ static int apndWriteMark(ApndFile *p, sqlite3_file *pFile){ for(i=0; i<8; i++){ a[APND_MARK_PREFIX_SZ+i] = (p->iPgOne >> (56 - i*8)) & 0xff; } - return pFile->pMethods->xWrite(pFile, a, APND_MARK_PREFIX_SZ, p->iMark); + return pFile->pMethods->xWrite(pFile, a, APND_MARK_SIZE, p->iMark); } /* @@ -331,8 +331,7 @@ static int apndSectorSize(sqlite3_file *pFile){ */ static int apndDeviceCharacteristics(sqlite3_file *pFile){ pFile = ORIGFILE(pFile); - return SQLITE_IOCAP_IMMUTABLE | - pFile->pMethods->xDeviceCharacteristics(pFile); + return pFile->pMethods->xDeviceCharacteristics(pFile); } /* Create a shared memory file mapping */ @@ -550,7 +549,7 @@ int sqlite3_appendvfs_init( pOrig = sqlite3_vfs_find(0); apnd_vfs.iVersion = pOrig->iVersion; apnd_vfs.pAppData = pOrig; - apnd_vfs.szOsFile = sizeof(ApndFile); + apnd_vfs.szOsFile = pOrig->szOsFile + sizeof(ApndFile); rc = sqlite3_vfs_register(&apnd_vfs, 0); #ifdef APPENDVFS_TEST if( rc==SQLITE_OK ){ diff --git a/manifest b/manifest index 4ddbb0d1d5..c5da940c02 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sability\sto\swrite\sto\san\sappended\sdatabase.\s\sThis\scheck-in\scompiles\nbut\sis\sotherwise\suntested. -D 2017-12-14T16:28:27.146 +C The\s"apndvfs"\sVFS\sshim\snow\sappears\sto\sbe\sworking\sfor\sboth\sreads\sand\swrites. +D 2017-12-14T16:57:11.644 F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc a2492b29176edc3c754aa7a2f7daa20cd3fa20a56e3ee64e376092836177c42a @@ -260,7 +260,7 @@ F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f607 F ext/misc/README.md 8e008c8d2b02e09096b31dfba033253ac27c6c06a18aa5826e299fa7601d90b2 F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb -F ext/misc/appendvfs.c c8b18caae0d22762080a9c48a4e46933f48625bac7fde2af9ef8ec2a23755ac9 +F ext/misc/appendvfs.c ee71fbc918ab4c526a5935a3153c1cc4e0b601c081da8f9a549e0e9d01bdbca5 F ext/misc/btreeinfo.c d7fd9a2fe2fa33ba28488e2fce703ebecc759219ea9e0bb3b254784866c0a676 F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 @@ -1681,7 +1681,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 75d8517703f7efa33437079108e2c4ef0de1a118bbe1f4a86afdc34da09d3008 -R 15eddfa7673da0a2579cc83183e243e0 +P e343c63cbd754f37c33c939cd0b6f1ecc6202e60c6e66cd65c23cc8d571a994e +R 427fca803286f3061d4cdb1346b5bd46 U drh -Z 4e88658420f57b7b81dd23d0961f71ee +Z 919006b84ebd33ef7833311db2cf1160 diff --git a/manifest.uuid b/manifest.uuid index 026378badf..566e5b932a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e343c63cbd754f37c33c939cd0b6f1ecc6202e60c6e66cd65c23cc8d571a994e \ No newline at end of file +7f7b72d83633922e2b5dbf0d3455d0fea72cc6b8925ffcb78dfbad7b3c4b26e9 \ No newline at end of file From ac15e2d7ccfb706d020d4a42fc4d809f6ca1cca8 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 14 Dec 2017 19:15:07 +0000 Subject: [PATCH 017/190] Have the writefile() function optionally set the modification-time of the files it writes or creates. And many small fixes to the new code on this branch. FossilOrigin-Name: 7b51269caebe1492885fe9b965892f49a3f8bdb1d666b0203d594c30f9e83938 --- ext/misc/fileio.c | 136 ++++++++++++++++++++++++++++++++++++---------- manifest | 16 +++--- manifest.uuid | 2 +- src/shell.c.in | 91 ++++++++++++++++--------------- test/shell8.test | 15 +++++ 5 files changed, 177 insertions(+), 83 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 2320173997..7dbac4043f 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -11,21 +11,67 @@ ****************************************************************************** ** ** This SQLite extension implements SQL functions readfile() and -** writefile(). +** writefile(), and eponymous virtual type "fsdir". ** -** Also, an eponymous virtual table type "fsdir". Used as follows: +** WRITEFILE(FILE, DATA [, MODE [, MTIME]]): ** -** SELECT * FROM fsdir($dirname); +** If neither of the optional arguments is present, then this UDF +** function writes blob DATA to file FILE. If successful, the number +** of bytes written is returned. If an error occurs, NULL is returned. ** -** Returns one row for each entry in the directory $dirname. No row is -** returned for "." or "..". Row columns are as follows: +** If the first option argument - MODE - is present, then it must +** be passed an integer value that corresponds to a POSIX mode +** value (file type + permissions, as returned in the stat.st_mode +** field by the stat() system call). Three types of files may +** be written/created: ** -** name: Name of directory entry. -** mode: Value of stat.st_mode for directory entry. -** mtime: Value of stat.st_mtime for directory entry. -** data: For a regular file, a blob containing the file data. For a -** symlink, a text value containing the text of the link. For a -** directory, NULL. +** regular files: (mode & 0170000)==0100000 +** symbolic links: (mode & 0170000)==0120000 +** directories: (mode & 0170000)==0040000 +** +** For a directory, the DATA is ignored. For a symbolic link, it is +** interpreted as text and used as the target of the link. For a +** regular file, it is interpreted as a blob and written into the +** named file. Regardless of the type of file, its permissions are +** set to (mode & 0777) before returning. +** +** If the optional MTIME argument is present, then it is interpreted +** as an integer - the number of seconds since the unix epoch. The +** modification-time of the target file is set to this value before +** returning. +** +** If three or more arguments are passed to this function and an +** error is encountered, an exception is raised. +** +** READFILE(FILE): +** +** Read and return the contents of file FILE (type blob) from disk. +** +** FSDIR: +** +** Used as follows: +** +** SELECT * FROM fsdir($path [, $dir]); +** +** Parameter $path is an absolute or relative pathname. If the file that it +** refers to does not exist, it is an error. If the path refers to a regular +** file or symbolic link, it returns a single row. Or, if the path refers +** to a directory, it returns one row for the directory, and one row for each +** file within the hierarchy rooted at $path. +** +** Each row has the following columns: +** +** name: Path to file or directory (text value). +** mode: Value of stat.st_mode for directory entry (an integer). +** mtime: Value of stat.st_mtime for directory entry (an integer). +** data: For a regular file, a blob containing the file data. For a +** symlink, a text value containing the text of the link. For a +** directory, NULL. +** +** If a non-NULL value is specified for the optional $dir parameter and +** $path is a relative path, then $path is interpreted relative to $dir. +** And the paths returned in the "name" column of the table are also +** relative to directory $dir. */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 @@ -45,6 +91,10 @@ SQLITE_EXTENSION_INIT1 #define FSDIR_SCHEMA "(name,mode,mtime,data,path HIDDEN,dir HIDDEN)" +/* +** Set the result stored by context ctx to a blob containing the +** contents of file zName. +*/ static void readFileContents(sqlite3_context *ctx, const char *zName){ FILE *in; long nIn; @@ -81,6 +131,10 @@ static void readfileFunc( readFileContents(context, zName); } +/* +** Set the error message contained in context ctx to the results of +** vprintf(zFmt, ...). +*/ static void ctxErrorMsg(sqlite3_context *ctx, const char *zFmt, ...){ char *zMsg = 0; va_list ap; @@ -138,11 +192,16 @@ static int makeDirectory( return rc; } +/* +** This function does the work for the writefile() UDF. Refer to +** header comments at the top of this file for details. +*/ static int writeFile( - sqlite3_context *pCtx, - const char *zFile, - mode_t mode, - sqlite3_value *pData + sqlite3_context *pCtx, /* Context to return bytes written in */ + const char *zFile, /* File to write */ + sqlite3_value *pData, /* Data to write */ + mode_t mode, /* MODE parameter passed to writefile() */ + sqlite3_int64 mtime /* MTIME parameter (or -1 to not set time) */ ){ if( S_ISLNK(mode) ){ const char *zTo = (const char*)sqlite3_value_text(pData); @@ -178,22 +237,30 @@ static int writeFile( } } fclose(out); - if( rc==0 && chmod(zFile, mode & 0777) ){ + if( rc==0 && mode && chmod(zFile, mode & 0777) ){ rc = 1; } if( rc ) return 2; sqlite3_result_int64(pCtx, nWrite); } } + + if( mtime>=0 ){ + struct timespec times[2]; + times[0].tv_nsec = times[1].tv_nsec = 0; + times[0].tv_sec = time(0); + times[1].tv_sec = mtime; + if( utimensat(AT_FDCWD, zFile, times, AT_SYMLINK_NOFOLLOW) ){ + return 1; + } + } + return 0; } /* -** Implementation of the "writefile(W,X[,Y]])" SQL function. -** -** The argument X is written into file W. The number of bytes written is -** returned. Or NULL is returned if something goes wrong, such as being unable -** to open file X for writing. +** Implementation of the "writefile(W,X[,Y[,Z]]])" SQL function. +** Refer to header comments at the top of this file for details. */ static void writefileFunc( sqlite3_context *context, @@ -203,8 +270,9 @@ static void writefileFunc( const char *zFile; mode_t mode = 0; int res; + sqlite3_int64 mtime = -1; - if( argc<2 || argc>3 ){ + if( argc<2 || argc>4 ){ sqlite3_result_error(context, "wrong number of arguments to function writefile()", -1 ); @@ -214,18 +282,20 @@ static void writefileFunc( zFile = (const char*)sqlite3_value_text(argv[0]); if( zFile==0 ) return; if( argc>=3 ){ - sqlite3_result_int(context, 0); mode = sqlite3_value_int(argv[2]); } + if( argc==4 ){ + mtime = sqlite3_value_int64(argv[3]); + } - res = writeFile(context, zFile, mode, argv[1]); + res = writeFile(context, zFile, argv[1], mode, mtime); if( res==1 && errno==ENOENT ){ if( makeDirectory(zFile, mode)==SQLITE_OK ){ - res = writeFile(context, zFile, mode, argv[1]); + res = writeFile(context, zFile, argv[1], mode, mtime); } } - if( res!=0 ){ + if( argc>2 && res!=0 ){ if( S_ISLNK(mode) ){ ctxErrorMsg(context, "failed to create symlink: %s", zFile); }else if( S_ISDIR(mode) ){ @@ -313,6 +383,10 @@ static int fsdirOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ return SQLITE_OK; } +/* +** Reset a cursor back to the state it was in when first returned +** by fsdirOpen(). +*/ static void fsdirResetCursor(fsdir_cursor *pCur){ int i; for(i=0; i<=pCur->iLvl; i++){ @@ -341,6 +415,10 @@ static int fsdirClose(sqlite3_vtab_cursor *cur){ return SQLITE_OK; } +/* +** Set the error message for the virtual table associated with cursor +** pCur to the results of vprintf(zFmt, ...). +*/ static void fsdirSetErrmsg(fsdir_cursor *pCur, const char *zFmt, ...){ va_list ap; va_start(ap, zFmt); @@ -586,6 +664,9 @@ static int fsdirBestIndex( return SQLITE_OK; } +/* +** Register the "fsdir" virtual table. +*/ static int fsdirRegister(sqlite3 *db){ static sqlite3_module fsdirModule = { 0, /* iVersion */ @@ -611,9 +692,6 @@ static int fsdirRegister(sqlite3 *db){ }; int rc = sqlite3_create_module(db, "fsdir", &fsdirModule, 0); - if( rc==SQLITE_OK ){ - rc = sqlite3_create_module(db, "fsentry", &fsdirModule, (void*)1); - } return rc; } #else /* SQLITE_OMIT_VIRTUALTABLE */ diff --git a/manifest b/manifest index dda85f8287..2ee47c023e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\serror\sand\susage\smessages\soutput\sby\sthe\sshell\s".ar"\scommand. -D 2017-12-14T15:40:42.931 +C Have\sthe\swritefile()\sfunction\soptionally\sset\sthe\smodification-time\sof\sthe\nfiles\sit\swrites\sor\screates.\sAnd\smany\ssmall\sfixes\sto\sthe\snew\scode\son\sthis\nbranch. +D 2017-12-14T19:15:07.381 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -270,7 +270,7 @@ F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 29b7fc94752fff6245cf4a81455f98cf6778ec1102ca7e67bf693d41a7db4307 +F ext/misc/fileio.c 014152d4133e7b29eab8eb39d0c640659c23a6d23d882b4778f487ae7d1a457b F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -475,7 +475,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in 4bdd2efe722005180365698f2a3de51e22ae1e9bb61c868006bc8f2c5e02eb98 +F src/shell.c.in 074b2129559a0aa712a367317f7e7daf4740925ec2c123b529800628eb10dc73 F src/sqlite.h.in 364515dd186285f3c01f5cab42e7db7edc47c70e87b6a25de389a2e6b8c413fd F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1215,7 +1215,7 @@ F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f -F test/shell8.test 0f7dfc5b33bde7143df8e37cbb4ae6ccc7e91f87232dc8e5e02be03117cdebb8 +F test/shell8.test 96f35965fe84d633fb2338696f5cbc1bcf6bdbdd79677244bc617a8452851dc7 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1683,7 +1683,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 803156cba8b056a1cb8d1bb186a57454afe72341abe7de1dfe529234c3415cd2 -R 69895ee1194373ab4ba11578d798fe26 +P b9d2d5d97291bf3d1392232e3705cca89dc7b918db2b08067b2b013ea39320e0 +R 975f9981c88e18e3ddfa1fe4bb6e7fae U dan -Z 5ea750b0cf239f9442948a3eda934166 +Z 1e84576de6ef44efce8abf1d868c1119 diff --git a/manifest.uuid b/manifest.uuid index ce1ae1dcb3..31073ba115 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b9d2d5d97291bf3d1392232e3705cca89dc7b918db2b08067b2b013ea39320e0 \ No newline at end of file +7b51269caebe1492885fe9b965892f49a3f8bdb1d666b0203d594c30f9e83938 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 2a0f9fde9e..8b16082add 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4092,23 +4092,25 @@ static void shellPrepare( } } -static void shellPrepare2( +static void shellPreparePrintf( sqlite3 *db, int *pRc, - const char *zSql, - const char *zTail, - sqlite3_stmt **ppStmt + sqlite3_stmt **ppStmt, + const char *zFmt, + ... ){ - if( *pRc==SQLITE_OK && zTail ){ - char *z = sqlite3_mprintf("%s %s", zSql, zTail); + *ppStmt = 0; + if( *pRc==SQLITE_OK ){ + va_list ap; + char *z; + va_start(ap, zFmt); + z = sqlite3_vmprintf(zFmt, ap); if( z==0 ){ *pRc = SQLITE_NOMEM; }else{ shellPrepare(db, pRc, z, ppStmt); sqlite3_free(z); } - }else{ - shellPrepare(db, pRc, zSql, ppStmt); } } @@ -4429,23 +4431,27 @@ static int arCheckEntries(sqlite3 *db, ArCommand *pAr){ static void arWhereClause( int *pRc, ArCommand *pAr, - char **pzWhere /* OUT: New WHERE clause (or NULL) */ + char **pzWhere /* OUT: New WHERE clause */ ){ char *zWhere = 0; if( *pRc==SQLITE_OK ){ - int i; - const char *zSep = "WHERE "; - for(i=0; inArg; i++){ - const char *z = pAr->azArg[i]; - zWhere = sqlite3_mprintf( - "%z%s name = '%q' OR name BETWEEN '%q/' AND '%q0'", - zWhere, zSep, z, z, z - ); - if( zWhere==0 ){ - *pRc = SQLITE_NOMEM; - break; + if( pAr->nArg==0 ){ + zWhere = sqlite3_mprintf("1"); + }else{ + int i; + const char *zSep = ""; + for(i=0; inArg; i++){ + const char *z = pAr->azArg[i]; + zWhere = sqlite3_mprintf( + "%z%s name = '%q' OR name BETWEEN '%q/' AND '%q0'", + zWhere, zSep, z, z, z + ); + if( zWhere==0 ){ + *pRc = SQLITE_NOMEM; + break; + } + zSep = " OR "; } - zSep = " OR "; } } *pzWhere = zWhere; @@ -4455,7 +4461,7 @@ static void arWhereClause( ** Implementation of .ar "lisT" command. */ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ - const char *zSql = "SELECT name FROM sqlar"; + const char *zSql = "SELECT name FROM sqlar WHERE %s"; char *zWhere = 0; sqlite3_stmt *pSql = 0; int rc; @@ -4463,7 +4469,7 @@ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ rc = arCheckEntries(db, pAr); arWhereClause(&rc, pAr, &zWhere); - shellPrepare2(db, &rc, zSql, zWhere, &pSql); + shellPreparePrintf(db, &rc, &pSql, zSql, zWhere); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ raw_printf(p->out, "%s\n", sqlite3_column_text(pSql, 0)); } @@ -4482,14 +4488,14 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ "ELSE" " data " "END, " - "mode) FROM sqlar"; - const char *zSql2 = "SELECT :1 || name, mtime FROM sqlar"; + "mode, mtime) FROM sqlar WHERE (%s) AND (data IS NULL OR :2 = 0)"; struct timespec times[2]; sqlite3_stmt *pSql = 0; int rc = SQLITE_OK; char *zDir = 0; char *zWhere = 0; + int i; /* If arguments are specified, check that they actually exist within ** the archive before proceeding. And formulate a WHERE clause to @@ -4509,31 +4515,26 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ memset(times, 0, sizeof(times)); times[0].tv_sec = time(0); - shellPrepare2(db, &rc, zSql1, zWhere, &pSql); + shellPreparePrintf(db, &rc, &pSql, zSql1, zWhere); if( rc==SQLITE_OK ){ sqlite3_bind_text(pSql, 1, zDir, -1, SQLITE_STATIC); - } - while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ - if( pAr->bVerbose ){ - raw_printf(p->out, "%s\n", sqlite3_column_text(pSql, 0)); - } - } - shellFinalize(&rc, pSql); - shellPrepare2(db, &rc, zSql2, zWhere, &pSql); - if( rc==SQLITE_OK ){ - sqlite3_bind_text(pSql, 1, zDir, -1, SQLITE_STATIC); - } - while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ - const char *zPath = (const char*)sqlite3_column_text(pSql, 0); - times[1].tv_sec = (time_t)sqlite3_column_int64(pSql, 1); - if( utimensat(AT_FDCWD, zPath, times, AT_SYMLINK_NOFOLLOW) ){ - raw_printf(stderr, "failed to set timestamp for %s\n", zPath); - rc = SQLITE_ERROR; - break; + /* Run the SELECT statement twice. The first time, writefile() is called + ** for all archive members that should be extracted. The second time, + ** only for the directories. This is because the timestamps for + ** extracted directories must be reset after they are populated (as + ** populating them changes the timestamp). */ + for(i=0; i<2; i++){ + sqlite3_bind_int(pSql, 2, i); + while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ + if( i==0 && pAr->bVerbose ){ + raw_printf(p->out, "%s\n", sqlite3_column_text(pSql, 0)); + } + } + shellReset(&rc, pSql); } + shellFinalize(&rc, pSql); } - shellFinalize(&rc, pSql); sqlite3_free(zDir); sqlite3_free(zWhere); diff --git a/test/shell8.test b/test/shell8.test index 07065b56bd..14980a84a5 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -139,6 +139,21 @@ foreach {tn tcl} { catchcmd ":memory:" $x3 dir_to_list ar3 } $expected + + # This is a repeat of test 1.$tn.1, except that there is a 2 second + # pause between creating the archive and extracting its contents. + # This is to test that timestamps are set correctly. + # + # Because it is slow, only do this for $tn==1. + if {$tn==1} { + do_test 1.$tn.1 { + catchcmd test_ar.db $c1 + file delete -force ar1 + after 2000 + catchcmd test_ar.db $x1 + dir_to_list ar1 + } $expected + } } finish_test From dd2a43a225a69a53bbdfe17eec319bbb85e674f9 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 14 Dec 2017 19:24:00 +0000 Subject: [PATCH 018/190] Fixes to the appendvfs.c extension. Add the "sqltclsh" application that uses appendvfs.c to find its scripts. FossilOrigin-Name: ee248b529c2396c5480fb99b0a1dc31032627ec8241eca4a8c0fff257bb4a088 --- Makefile.in | 9 +++++- ext/misc/appendvfs.c | 3 ++ main.mk | 9 +++++- manifest | 18 ++++++------ manifest.uuid | 2 +- tool/sqltclsh.c.in | 42 ++++++++++++++++++++++++++++ tool/sqltclsh.tcl | 66 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 138 insertions(+), 11 deletions(-) create mode 100644 tool/sqltclsh.c.in create mode 100644 tool/sqltclsh.tcl diff --git a/Makefile.in b/Makefile.in index 4883c1ac6b..5d377174f8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -556,7 +556,8 @@ TESTPROGS = \ sqlite3$(TEXE) \ sqlite3_analyzer$(TEXE) \ sqldiff$(TEXE) \ - dbhash$(TEXE) + dbhash$(TEXE) \ + sqltclsh$(TEXE) # Databases containing fuzzer test cases # @@ -1190,6 +1191,12 @@ sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $ sqlite3_analyzer$(TEXE): sqlite3_analyzer.c $(LTLINK) sqlite3_analyzer.c -o $@ $(LIBTCL) $(TLIBS) +sqltclsh.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/sqltclsh.tcl $(TOP)/ext/misc/appendvfs.c $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in + $(TCLSH_CMD) $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in >sqltclsh.c + +sqltclsh$(TEXE): sqltclsh.c + $(LTLINK) sqltclsh.c -o $@ $(LIBTCL) $(TLIBS) + CHECKER_DEPS =\ $(TOP)/tool/mkccode.tcl \ sqlite3.c \ diff --git a/ext/misc/appendvfs.c b/ext/misc/appendvfs.c index bd1f37509e..c6e9e0d58b 100644 --- a/ext/misc/appendvfs.c +++ b/ext/misc/appendvfs.c @@ -47,7 +47,9 @@ ** If the file being opened is not an appended database, then this shim is ** a pass-through into the default underlying VFS. **/ +#if !defined(SQLITEINT_H) #include +#endif SQLITE_EXTENSION_INIT1 #include #include @@ -458,6 +460,7 @@ static int apndOpen( } if( (flags & SQLITE_OPEN_CREATE)==0 ){ pSubFile->pMethods->xClose(pSubFile); + pFile->pMethods = 0; return SQLITE_CANTOPEN; } p->iPgOne = (sz+0xfff) & ~(sqlite3_int64)0xfff; diff --git a/main.mk b/main.mk index e978b23a58..bc4e404020 100644 --- a/main.mk +++ b/main.mk @@ -484,7 +484,8 @@ TESTPROGS = \ sqlite3_analyzer$(EXE) \ sqlite3_checker$(EXE) \ sqldiff$(EXE) \ - dbhash$(EXE) + dbhash$(EXE) \ + sqltclsh$(EXE) # Databases containing fuzzer test cases # @@ -809,6 +810,12 @@ sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $ sqlite3_analyzer$(EXE): sqlite3_analyzer.c $(TCCX) $(TCL_FLAGS) sqlite3_analyzer.c -o $@ $(LIBTCL) $(THREADLIB) +sqltclsh.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/sqltclsh.tcl $(TOP)/ext/misc/appendvfs.c $(TOP)/tool/mkccode.tcl + tclsh $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in >sqltclsh.c + +sqltclsh$(EXE): sqltclsh.c + $(TCCX) $(TCL_FLAGS) sqltclsh.c -o $@ $(LIBTCL) $(THREADLIB) + CHECKER_DEPS =\ $(TOP)/tool/mkccode.tcl \ sqlite3.c \ diff --git a/manifest b/manifest index c5da940c02..743670d293 100644 --- a/manifest +++ b/manifest @@ -1,6 +1,6 @@ -C The\s"apndvfs"\sVFS\sshim\snow\sappears\sto\sbe\sworking\sfor\sboth\sreads\sand\swrites. -D 2017-12-14T16:57:11.644 -F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 +C Fixes\sto\sthe\sappendvfs.c\sextension.\s\sAdd\sthe\s"sqltclsh"\sapplication\sthat\nuses\sappendvfs.c\sto\sfind\sits\sscripts. +D 2017-12-14T19:24:00.444 +F Makefile.in 053284f237e955fba2f386fd9f87020199e6dbcbce9f48bc02cf431458afbe07 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc a2492b29176edc3c754aa7a2f7daa20cd3fa20a56e3ee64e376092836177c42a F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 @@ -260,7 +260,7 @@ F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f607 F ext/misc/README.md 8e008c8d2b02e09096b31dfba033253ac27c6c06a18aa5826e299fa7601d90b2 F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb -F ext/misc/appendvfs.c ee71fbc918ab4c526a5935a3153c1cc4e0b601c081da8f9a549e0e9d01bdbca5 +F ext/misc/appendvfs.c 8cc3ae6633e7d97ca9c3c9a48c647e9ba23f8d24f3d5f5f596272a81dc50c398 F ext/misc/btreeinfo.c d7fd9a2fe2fa33ba28488e2fce703ebecc759219ea9e0bb3b254784866c0a676 F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 @@ -396,7 +396,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 6123b0b2db806ddb482c24786ad6603a289df720382a3bce8f532d76a94c84b1 +F main.mk d0278b8833203dc60ed81eed12412d90559fcd3470e0fd5d509d41ef74a3d64b F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1650,6 +1650,8 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl 3efcd4240b738f6bb2b5af0aea7e1e0ef9bc1c61654f645076cec883030b710c F tool/sqldiff.c 30879bbc8de686df4624e86adce2d8981f500904c1cfb55b5d1eea2ffd9341eb F tool/sqlite3_analyzer.c.in 7eeaae8b0d7577662acaabbb11107af0659d1b41bc1dfdd4d91422de27127968 +F tool/sqltclsh.c.in e1f48150f755bfbe0194478cba50aa9f2f5183bb1efbdd6456532cce3cd2e18d +F tool/sqltclsh.tcl 71bdb62c8f6b37c05b2d377e870c3dd13ee96cc4fee5b5ae5215ae9a0aca088d F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d @@ -1681,7 +1683,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e343c63cbd754f37c33c939cd0b6f1ecc6202e60c6e66cd65c23cc8d571a994e -R 427fca803286f3061d4cdb1346b5bd46 +P 7f7b72d83633922e2b5dbf0d3455d0fea72cc6b8925ffcb78dfbad7b3c4b26e9 +R 4666f6f48678fbbcc815c221172efa48 U drh -Z 919006b84ebd33ef7833311db2cf1160 +Z 47302a3d5371e2c5e325f342d15c1218 diff --git a/manifest.uuid b/manifest.uuid index 566e5b932a..dcab13a743 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7f7b72d83633922e2b5dbf0d3455d0fea72cc6b8925ffcb78dfbad7b3c4b26e9 \ No newline at end of file +ee248b529c2396c5480fb99b0a1dc31032627ec8241eca4a8c0fff257bb4a088 \ No newline at end of file diff --git a/tool/sqltclsh.c.in b/tool/sqltclsh.c.in new file mode 100644 index 0000000000..bdfac7dd00 --- /dev/null +++ b/tool/sqltclsh.c.in @@ -0,0 +1,42 @@ +/* +** This is the source code to a "tclsh" that has SQLite built-in. +** +** The startup script is located as follows: +** +** (1) Open the executable as an appended SQLite database and try to +** read the startup script out of that database. +** +** (2) If the first argument is a readable file, try to open that file +** as an SQLite database and read the startup script out of that +** database. +** +** (3) If the first argument is a readable file with a ".tcl" extension, +** then try to run that script directly. +** +** If none of the above steps work, then the program runs as an interactive +** tclsh. +*/ +#define TCLSH_INIT_PROC sqlite3_tclapp_init_proc +#define SQLITE_ENABLE_DBSTAT_VTAB 1 +#undef SQLITE_THREADSAFE +#define SQLITE_THREADSAFE 0 +#undef SQLITE_ENABLE_COLUMN_METADATA +#define SQLITE_OMIT_DECLTYPE 1 +#define SQLITE_OMIT_DEPRECATED 1 +#define SQLITE_OMIT_PROGRESS_CALLBACK 1 +#define SQLITE_OMIT_SHARED_CACHE 1 +#define SQLITE_DEFAULT_MEMSTATUS 0 +#define SQLITE_MAX_EXPR_DEPTH 0 +INCLUDE sqlite3.c +INCLUDE $ROOT/ext/misc/appendvfs.c +INCLUDE $ROOT/src/tclsqlite.c + +const char *sqlite3_tclapp_init_proc(Tcl_Interp *interp){ + (void)interp; + sqlite3_appendvfs_init(0,0,0); + return +BEGIN_STRING +INCLUDE $ROOT/tool/sqltclsh.tcl +END_STRING +; +} diff --git a/tool/sqltclsh.tcl b/tool/sqltclsh.tcl new file mode 100644 index 0000000000..999f166ccb --- /dev/null +++ b/tool/sqltclsh.tcl @@ -0,0 +1,66 @@ +# Try to open the executable as a database and read the "scripts.data" +# field where "scripts.name" is 'main.tcl' +# +catch { + sqlite3 db $argv0 -vfs apndvfs -create 0 + set mainscript [db one {SELECT data FROM scripts WHERE name='main.tcl'}] +} +if {[info exists mainscript]} { + eval $mainscript + return +} else { + catch {db close} +} + +# Try to open file named in the first argument as a database and +# read the "scripts.data" field where "scripts.name" is 'main.tcl' +# +if {[llength $argv]>0 && [file readable [lindex $argv 0]]} { + catch { + sqlite3 db [lindex $argv 0] -vfs apndvfs -create 0 + set mainscript [db one {SELECT data FROM scripts WHERE name='main.tcl'}] + set argv0 [lindex $argv 0] + set argv [lrange $argv 1 end] + } + if {[info exists mainscript]} { + eval $mainscript + return + } else { + catch {db close} + } + if {[string match *.tcl [lindex $argv 0]]} { + set fd [open [lindex $argv 0] rb] + set mainscript [read $fd] + close $fd + unset fd + set argv0 [lindex $argv 0] + set argv [lrange $argv 1 end] + } + if {[info exists mainscript]} { + eval $mainscript + return + } +} + +# If all else fails, do an interactive loop +# +set line {} +while {![eof stdin]} { + if {$line!=""} { + puts -nonewline "> " + } else { + puts -nonewline "% " + } + flush stdout + append line [gets stdin] + if {[info complete $line]} { + if {[catch {uplevel #0 $line} result]} { + puts stderr "Error: $result" + } elseif {$result!=""} { + puts $result + } + set line {} + } else { + append line \\n" + } +} From d1b51d49551d03ac2d47f3164df4096e4b8c6efb Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 16 Dec 2017 19:11:26 +0000 Subject: [PATCH 019/190] Do not use the compress() and uncompress() functions in ext/misc/compress.c - they are not quite compatible with the spec. Instead use new functions in ext/misc/sqlar.c. FossilOrigin-Name: 7652b3c2374084047b6c1da3e525e0cac34fe220597f81e793bc4fd9f33358da --- ext/misc/sqlar.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++ main.mk | 3 +- manifest | 15 ++++--- manifest.uuid | 2 +- src/shell.c.in | 58 +++++++----------------- 5 files changed, 139 insertions(+), 52 deletions(-) create mode 100644 ext/misc/sqlar.c diff --git a/ext/misc/sqlar.c b/ext/misc/sqlar.c new file mode 100644 index 0000000000..17d0875938 --- /dev/null +++ b/ext/misc/sqlar.c @@ -0,0 +1,113 @@ +/* +** 2017-12-17 +** +** 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. +** +****************************************************************************** +** +** Utility functions sqlar_compress() and sqlar_uncompress(). Useful +** for working with sqlar archives and used by the shell tool's built-in +** sqlar support. +*/ +#include "sqlite3ext.h" +SQLITE_EXTENSION_INIT1 +#include + +/* +** Implementation of the "sqlar_compress(X)" SQL function. +** +** If the type of X is SQLITE_BLOB, and compressing that blob using +** zlib utility function compress() yields a smaller blob, return the +** compressed blob. Otherwise, return a copy of X. +*/ +static void sqlarCompressFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + assert( argc==1 ); + if( sqlite3_value_type(argv[0])==SQLITE_BLOB ){ + const Bytef *pData = sqlite3_value_blob(argv[0]); + uLong nData = sqlite3_value_bytes(argv[0]); + uLongf nOut = compressBound(nData); + Bytef *pOut; + + pOut = (Bytef*)sqlite3_malloc(nOut); + if( pOut==0 ){ + sqlite3_result_error_nomem(context); + return; + }else{ + if( Z_OK!=compress(pOut, &nOut, pData, nData) ){ + sqlite3_result_error(context, "error in compress()", -1); + }else if( nOutshell.c diff --git a/manifest b/manifest index 2ee47c023e..bbdf7f6ae0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sthe\swritefile()\sfunction\soptionally\sset\sthe\smodification-time\sof\sthe\nfiles\sit\swrites\sor\screates.\sAnd\smany\ssmall\sfixes\sto\sthe\snew\scode\son\sthis\nbranch. -D 2017-12-14T19:15:07.381 +C Do\snot\suse\sthe\scompress()\sand\suncompress()\sfunctions\sin\sext/misc/compress.c\s-\nthey\sare\snot\squite\scompatible\swith\sthe\sspec.\sInstead\suse\snew\sfunctions\sin\next/misc/sqlar.c. +D 2017-12-16T19:11:26.054 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -287,6 +287,7 @@ F ext/misc/sha1.c 0b9e9b855354910d3ca467bf39099d570e73db56 F ext/misc/shathree.c fa185d7aee0ad0aca5e091b4a2db7baff11796170e5793b5de99e511a13af448 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c 41cf26c6b89fcaa8798ae10ae64d39c1f1d9d6995152e545bd491c13058b8fac +F ext/misc/sqlar.c d355cd8b6e7280d2f61d4737672922acb512a2ab1cee52399ffb88980476e31c F ext/misc/stmt.c 6f16443abb3551e3f5813bb13ba19a30e7032830015b0f92fe0c0453045c0a11 F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/unionvtab.c 1e0ebc5078e1a916db191bcd88f87e94ea7ba4aa563ee30ff706261cb4b39461 @@ -397,7 +398,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 6123b0b2db806ddb482c24786ad6603a289df720382a3bce8f532d76a94c84b1 +F main.mk f5f8e5e6bdd9ab3dabd94c6cf929813a601d5dbf312197fe463190c7d927c27c F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -475,7 +476,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in 074b2129559a0aa712a367317f7e7daf4740925ec2c123b529800628eb10dc73 +F src/shell.c.in ad8c13b9dee606d1ef11226f90d8e4e084d75986f96e6852e8e5b1c54aa4f0aa F src/sqlite.h.in 364515dd186285f3c01f5cab42e7db7edc47c70e87b6a25de389a2e6b8c413fd F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1683,7 +1684,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b9d2d5d97291bf3d1392232e3705cca89dc7b918db2b08067b2b013ea39320e0 -R 975f9981c88e18e3ddfa1fe4bb6e7fae +P 7b51269caebe1492885fe9b965892f49a3f8bdb1d666b0203d594c30f9e83938 +R 6fdfedcd54ee170b8eb014864253aebf U dan -Z 1e84576de6ef44efce8abf1d868c1119 +Z 7252a7eb50ba8ff9515237c2fa79b757 diff --git a/manifest.uuid b/manifest.uuid index 31073ba115..4125d09f9b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7b51269caebe1492885fe9b965892f49a3f8bdb1d666b0203d594c30f9e83938 \ No newline at end of file +7652b3c2374084047b6c1da3e525e0cac34fe220597f81e793bc4fd9f33358da \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 8b16082add..adfbaa96d1 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -797,7 +797,7 @@ INCLUDE ../ext/misc/shathree.c INCLUDE ../ext/misc/fileio.c INCLUDE ../ext/misc/completion.c #ifdef SQLITE_HAVE_ZLIB -INCLUDE ../ext/misc/compress.c +INCLUDE ../ext/misc/sqlar.c #endif #if defined(SQLITE_ENABLE_SESSION) @@ -2901,7 +2901,7 @@ static void open_db(ShellState *p, int keepAlive){ sqlite3_shathree_init(p->db, 0, 0); sqlite3_completion_init(p->db, 0, 0); #ifdef SQLITE_HAVE_ZLIB - sqlite3_compress_init(p->db, 0, 0); + sqlite3_sqlar_init(p->db, 0, 0); #endif sqlite3_create_function(p->db, "shell_add_schema", 2, SQLITE_UTF8, 0, shellAddSchemaName, 0, 0); @@ -4482,13 +4482,10 @@ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ */ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ const char *zSql1 = - "SELECT :1 || name, writefile(:1 || name, " - "CASE WHEN (data AND sz>=0 AND sz!=length(data)) THEN " - " uncompress(data) " - "ELSE" - " data " - "END, " - "mode, mtime) FROM sqlar WHERE (%s) AND (data IS NULL OR :2 = 0)"; + "SELECT " + " :1 || name, " + " writefile(:1 || name, sqlar_uncompress(data, sz), mode, mtime) " + "FROM sqlar WHERE (%s) AND (data IS NULL OR :2 = 0)"; struct timespec times[2]; sqlite3_stmt *pSql = 0; @@ -4569,16 +4566,13 @@ static int arCreateUpdate( "data BLOB -- compressed content\n" ")"; const char *zDrop = "DROP TABLE IF EXISTS sqlar"; - const char *zInsert = "REPLACE INTO sqlar VALUES(?, ?, ?, ?, ?)"; + const char *zInsert = "REPLACE INTO sqlar VALUES(?,?,?,?,sqlar_compress(?))"; sqlite3_stmt *pStmt = 0; /* Directory traverser */ sqlite3_stmt *pInsert = 0; /* Compilation of zInsert */ int i; /* For iterating through azFile[] */ int rc; /* Return code */ - Bytef *aCompress = 0; /* Compression buffer */ - int nCompress = 0; /* Size of compression buffer */ - rc = sqlite3_exec(db, "SAVEPOINT ar;", 0, 0, 0); if( rc!=SQLITE_OK ) return rc; @@ -4611,39 +4605,18 @@ static int arCreateUpdate( if( S_ISDIR(mode) ){ sz = 0; sqlite3_bind_null(pInsert, 5); - }else if( S_ISLNK(mode) ){ - sz = -1; - sqlite3_bind_value(pInsert, 5, sqlite3_column_value(pStmt, 3)); }else{ - uLongf nReq; /* Required size of compression buffer */ - const Bytef *pData = (const Bytef*)sqlite3_column_blob(pStmt, 3); - sz = sqlite3_column_bytes(pStmt, 3); - nReq = compressBound(sz); - if( aCompress==0 || nReq>nCompress ){ - Bytef *aNew = sqlite3_realloc(aCompress, nReq); - if( aNew==0 ){ - rc = SQLITE_NOMEM; - }else{ - aCompress = aNew; - nCompress = nReq; - } - } - - if( Z_OK!=compress(aCompress, &nReq, pData, sz) ){ - rc = SQLITE_ERROR; - } - if( nReqdb; } From 9ebfaad25db43869ccfae50c02e0fd3310a95e9b Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 26 Dec 2017 20:39:58 +0000 Subject: [PATCH 020/190] Add new file ext/misc/zipfile.c, containing a virtual table for read-only access to simple zip archives. FossilOrigin-Name: 8e366b99b13d765d8bf000a7ec5919e582702e51dc07c27a746b6002898a2302 --- ext/misc/zipfile.c | 696 +++++++++++++++++++++++++++++++++++++++++++++ main.mk | 3 +- manifest | 17 +- manifest.uuid | 2 +- src/shell.c.in | 2 + 5 files changed, 710 insertions(+), 10 deletions(-) create mode 100644 ext/misc/zipfile.c diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c new file mode 100644 index 0000000000..bcee873044 --- /dev/null +++ b/ext/misc/zipfile.c @@ -0,0 +1,696 @@ +/* +** 2017-12-26 +** +** 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. +** +****************************************************************************** +** +*/ +#include "sqlite3ext.h" +SQLITE_EXTENSION_INIT1 +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef SQLITE_OMIT_VIRTUALTABLE + +#ifndef SQLITE_AMALGAMATION +typedef sqlite3_int64 i64; +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned long u32; +#define MIN(a,b) ((a)<(b) ? (a) : (b)) +#endif + +#define ZIPFILE_SCHEMA "CREATE TABLE y(" \ + "name, /* Name of file in zip archive */" \ + "mode, /* POSIX mode for file */" \ + "mtime, /* Last modification time in seconds since epoch */" \ + "sz, /* Size of object */" \ + "data, /* Data stored in zip file (possibly compressed) */" \ + "method, /* Compression method (integer) */" \ + "f HIDDEN /* Name of zip file */" \ +");" + +#define ZIPFILE_F_COLUMN_IDX 6 /* Index of column "f" in the above */ + +#define ZIPFILE_BUFFER_SIZE (64*1024) + +/* +** Set the error message contained in context ctx to the results of +** vprintf(zFmt, ...). +*/ +static void zipfileCtxErrorMsg(sqlite3_context *ctx, const char *zFmt, ...){ + char *zMsg = 0; + va_list ap; + va_start(ap, zFmt); + zMsg = sqlite3_vmprintf(zFmt, ap); + sqlite3_result_error(ctx, zMsg, -1); + sqlite3_free(zMsg); + va_end(ap); +} + + +/* +*** 4.3.16 End of central directory record: +*** +*** end of central dir signature 4 bytes (0x06054b50) +*** number of this disk 2 bytes +*** number of the disk with the +*** start of the central directory 2 bytes +*** total number of entries in the +*** central directory on this disk 2 bytes +*** total number of entries in +*** the central directory 2 bytes +*** size of the central directory 4 bytes +*** offset of start of central +*** directory with respect to +*** the starting disk number 4 bytes +*** .ZIP file comment length 2 bytes +*** .ZIP file comment (variable size) +*/ +typedef struct ZipfileEOCD ZipfileEOCD; +struct ZipfileEOCD { + u16 iDisk; + u16 iFirstDisk; + u16 nEntry; + u16 nEntryTotal; + u32 nSize; + u32 iOffset; +}; + +/* +*** 4.3.12 Central directory structure: +*** +*** ... +*** +*** central file header signature 4 bytes (0x02014b50) +*** version made by 2 bytes +*** version needed to extract 2 bytes +*** general purpose bit flag 2 bytes +*** compression method 2 bytes +*** last mod file time 2 bytes +*** last mod file date 2 bytes +*** crc-32 4 bytes +*** compressed size 4 bytes +*** uncompressed size 4 bytes +*** file name length 2 bytes +*** extra field length 2 bytes +*** file comment length 2 bytes +*** disk number start 2 bytes +*** internal file attributes 2 bytes +*** external file attributes 4 bytes +*** relative offset of local header 4 bytes +*/ +typedef struct ZipfileCDS ZipfileCDS; +struct ZipfileCDS { + u16 iVersionMadeBy; + u16 iVersionExtract; + u16 flags; + u16 iCompression; + u16 mTime; + u16 mDate; + u32 crc32; + u32 szCompressed; + u32 szUncompressed; + u16 nFile; + u16 nExtra; + u16 nComment; + u16 iDiskStart; + u16 iInternalAttr; + u32 iExternalAttr; + u32 iOffset; + char *zFile; /* Filename (sqlite3_malloc()) */ +}; + +/* +*** 4.3.7 Local file header: +*** +*** local file header signature 4 bytes (0x04034b50) +*** version needed to extract 2 bytes +*** general purpose bit flag 2 bytes +*** compression method 2 bytes +*** last mod file time 2 bytes +*** last mod file date 2 bytes +*** crc-32 4 bytes +*** compressed size 4 bytes +*** uncompressed size 4 bytes +*** file name length 2 bytes +*** extra field length 2 bytes +*** +*/ +typedef struct ZipfileLFH ZipfileLFH; +struct ZipfileLFH { + u16 iVersionExtract; + u16 flags; + u16 iCompression; + u16 mTime; + u16 mDate; + u32 crc32; + u32 szCompressed; + u32 szUncompressed; + u16 nFile; + u16 nExtra; +}; + +/* +** Cursor type for recursively iterating through a directory structure. +*/ +typedef struct ZipfileCsr ZipfileCsr; + +struct ZipfileCsr { + sqlite3_vtab_cursor base; /* Base class - must be first */ + i64 iRowid; /* Rowid for current row */ + FILE *pFile; /* Zip file */ + i64 nByte; /* Size of zip file on disk */ + int bEof; /* True when at EOF */ + i64 iNextOff; /* Offset of next record in central directory */ + ZipfileEOCD eocd; /* Parse of central directory record */ + ZipfileCDS cds; /* Central Directory Structure */ + ZipfileLFH lfh; /* Local File Header for current entry */ + i64 iDataOff; /* Offset in zipfile to data */ + u32 mTime; /* Extended mtime value */ + int flags; + u8 *aBuffer; /* Buffer used for various tasks */ +}; + +#define ZIPFILE_MTIME_VALID 0x0001 + +typedef struct ZipfileTab ZipfileTab; +struct ZipfileTab { + sqlite3_vtab base; /* Base class - must be first */ +}; + +/* +** Construct a new ZipfileTab virtual table object. +*/ +static int zipfileConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + ZipfileTab *pNew = 0; + int rc; + + rc = sqlite3_declare_vtab(db, ZIPFILE_SCHEMA); + if( rc==SQLITE_OK ){ + pNew = (ZipfileTab*)sqlite3_malloc( sizeof(*pNew) ); + if( pNew==0 ) return SQLITE_NOMEM; + memset(pNew, 0, sizeof(*pNew)); + } + *ppVtab = (sqlite3_vtab*)pNew; + return rc; +} + +/* +** This method is the destructor for zipfile vtab objects. +*/ +static int zipfileDisconnect(sqlite3_vtab *pVtab){ + sqlite3_free(pVtab); + return SQLITE_OK; +} + +/* +** Constructor for a new ZipfileCsr object. +*/ +static int zipfileOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){ + ZipfileCsr *pCsr; + pCsr = sqlite3_malloc( sizeof(*pCsr) + ZIPFILE_BUFFER_SIZE); + if( pCsr==0 ) return SQLITE_NOMEM; + memset(pCsr, 0, sizeof(*pCsr)); + pCsr->aBuffer = (u8*)&pCsr[1]; + *ppCsr = &pCsr->base; + return SQLITE_OK; +} + +/* +** Reset a cursor back to the state it was in when first returned +** by zipfileOpen(). +*/ +static void zipfileResetCursor(ZipfileCsr *pCsr){ + pCsr->iRowid = 0; + pCsr->bEof = 0; + if( pCsr->pFile ){ + fclose(pCsr->pFile); + pCsr->pFile = 0; + } +} + +/* +** Destructor for an ZipfileCsr. +*/ +static int zipfileClose(sqlite3_vtab_cursor *cur){ + ZipfileCsr *pCsr = (ZipfileCsr*)cur; + zipfileResetCursor(pCsr); + sqlite3_free(pCsr); + return SQLITE_OK; +} + +/* +** Set the error message for the virtual table associated with cursor +** pCsr to the results of vprintf(zFmt, ...). +*/ +static void zipfileSetErrmsg(ZipfileCsr *pCsr, const char *zFmt, ...){ + va_list ap; + va_start(ap, zFmt); + pCsr->base.pVtab->zErrMsg = sqlite3_vmprintf(zFmt, ap); + va_end(ap); +} + +static int zipfileReadData(ZipfileCsr *pCsr, u8 *aRead, int nRead, i64 iOff){ + size_t n; + fseek(pCsr->pFile, iOff, SEEK_SET); + n = fread(aRead, 1, nRead, pCsr->pFile); + if( n!=nRead ){ + zipfileSetErrmsg(pCsr, "error in fread()"); + return SQLITE_ERROR; + } + return SQLITE_OK; +} + +static u16 zipfileGetU16(const u8 *aBuf){ + return (aBuf[1] << 8) + aBuf[0]; +} +static u32 zipfileGetU32(const u8 *aBuf){ + return ((u32)(aBuf[3]) << 24) + + ((u32)(aBuf[2]) << 16) + + ((u32)(aBuf[1]) << 8) + + ((u32)(aBuf[0]) << 0); +} + +#define zipfileRead32(aBuf) ( aBuf+=4, zipfileGetU32(aBuf-4) ) +#define zipfileRead16(aBuf) ( aBuf+=2, zipfileGetU16(aBuf-2) ) + +static int zipfileReadCDS(ZipfileCsr *pCsr){ + static const int szFix = 46; /* Size of fixed-size part of CDS */ + u8 *aRead = pCsr->aBuffer; + int rc; + + rc = zipfileReadData(pCsr, aRead, szFix, pCsr->iNextOff); + if( rc==SQLITE_OK ){ + u32 sig = zipfileRead32(aRead); + if( sig!=0x02014b50 ){ + zipfileSetErrmsg(pCsr,"failed to read CDS at offset %lld",pCsr->iNextOff); + rc = SQLITE_ERROR; + }else{ + int nRead; + pCsr->cds.iVersionMadeBy = zipfileRead16(aRead); + pCsr->cds.iVersionExtract = zipfileRead16(aRead); + pCsr->cds.flags = zipfileRead16(aRead); + pCsr->cds.iCompression = zipfileRead16(aRead); + pCsr->cds.mTime = zipfileRead16(aRead); + pCsr->cds.mDate = zipfileRead16(aRead); + pCsr->cds.crc32 = zipfileRead32(aRead); + pCsr->cds.szCompressed = zipfileRead32(aRead); + pCsr->cds.szUncompressed = zipfileRead32(aRead); + pCsr->cds.nFile = zipfileRead16(aRead); + pCsr->cds.nExtra = zipfileRead16(aRead); + pCsr->cds.nComment = zipfileRead16(aRead); + pCsr->cds.iDiskStart = zipfileRead16(aRead); + pCsr->cds.iInternalAttr = zipfileRead16(aRead); + pCsr->cds.iExternalAttr = zipfileRead32(aRead); + pCsr->cds.iOffset = zipfileRead32(aRead); + + assert( aRead==&pCsr->aBuffer[szFix] ); + + nRead = pCsr->cds.nFile + pCsr->cds.nExtra; + aRead = pCsr->aBuffer; + rc = zipfileReadData(pCsr, aRead, nRead, pCsr->iNextOff+szFix); + + if( rc==SQLITE_OK ){ + pCsr->cds.zFile = sqlite3_mprintf("%.*s", (int)pCsr->cds.nFile, aRead); + pCsr->iNextOff += szFix; + pCsr->iNextOff += pCsr->cds.nFile; + pCsr->iNextOff += pCsr->cds.nExtra; + pCsr->iNextOff += pCsr->cds.nComment; + } + + /* Scan the "extra" fields */ + if( rc==SQLITE_OK ){ + u8 *p = &aRead[pCsr->cds.nFile]; + u8 *pEnd = &p[pCsr->cds.nExtra]; + + while( p modtime is present */ + pCsr->mTime = zipfileGetU32(&p[1]); + pCsr->flags |= ZIPFILE_MTIME_VALID; + } + break; + } + + case 0x7875: /* Info-ZIP Unix (new) */ + break; + } + + p += nByte; + } + } + } + } + + return rc; +} + +static int zipfileReadLFH(ZipfileCsr *pCsr){ + static const int szFix = 30; /* Size of fixed-size part of LFH */ + u8 *aRead = pCsr->aBuffer; + int rc; + + rc = zipfileReadData(pCsr, aRead, szFix, pCsr->cds.iOffset); + if( rc==SQLITE_OK ){ + u32 sig = zipfileRead32(aRead); + if( sig!=0x04034b50 ){ + zipfileSetErrmsg(pCsr, "failed to read LFH at offset %d", + (int)pCsr->cds.iOffset + ); + rc = SQLITE_ERROR; + }else{ + pCsr->lfh.iVersionExtract = zipfileRead16(aRead); + pCsr->lfh.flags = zipfileRead16(aRead); + pCsr->lfh.iCompression = zipfileRead16(aRead); + pCsr->lfh.mTime = zipfileRead16(aRead); + pCsr->lfh.mDate = zipfileRead16(aRead); + pCsr->lfh.crc32 = zipfileRead32(aRead); + pCsr->lfh.szCompressed = zipfileRead32(aRead); + pCsr->lfh.szUncompressed = zipfileRead32(aRead); + pCsr->lfh.nFile = zipfileRead16(aRead); + pCsr->lfh.nExtra = zipfileRead16(aRead); + assert( aRead==&pCsr->aBuffer[szFix] ); + pCsr->iDataOff = pCsr->cds.iOffset+szFix+pCsr->lfh.nFile+pCsr->lfh.nExtra; + } + } + + return rc; +} + + +/* +** Advance an ZipfileCsr to its next row of output. +*/ +static int zipfileNext(sqlite3_vtab_cursor *cur){ + ZipfileCsr *pCsr = (ZipfileCsr*)cur; + i64 iEof = pCsr->eocd.iOffset + pCsr->eocd.nSize; + int rc = SQLITE_OK; + + if( pCsr->iNextOff>=iEof ){ + pCsr->bEof = 1; + }else{ + pCsr->iRowid++; + pCsr->flags = 0; + rc = zipfileReadCDS(pCsr); + if( rc==SQLITE_OK ){ + rc = zipfileReadLFH(pCsr); + } + } + return rc; +} + +/* +** "Standard" MS-DOS time format: +** +** File modification time: +** Bits 00-04: seconds divided by 2 +** Bits 05-10: minute +** Bits 11-15: hour +** File modification date: +** Bits 00-04: day +** Bits 05-08: month (1-12) +** Bits 09-15: years from 1980 +*/ +static time_t zipfileMtime(ZipfileCsr *pCsr){ + struct tm t; + memset(&t, 0, sizeof(t)); + t.tm_sec = (pCsr->cds.mTime & 0x1F)*2; + t.tm_min = (pCsr->cds.mTime >> 5) & 0x2F; + t.tm_hour = (pCsr->cds.mTime >> 11) & 0x1F; + + t.tm_mday = (pCsr->cds.mDate & 0x1F); + t.tm_mon = ((pCsr->cds.mDate >> 5) & 0x0F) - 1; + t.tm_year = 80 + ((pCsr->cds.mDate >> 9) & 0x7F); + + return mktime(&t); +} + +/* +** Return values of columns for the row at which the series_cursor +** is currently pointing. +*/ +static int zipfileColumn( + sqlite3_vtab_cursor *cur, /* The cursor */ + sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ + int i /* Which column to return */ +){ + ZipfileCsr *pCsr = (ZipfileCsr*)cur; + int rc = SQLITE_OK; + switch( i ){ + case 0: /* name */ + sqlite3_result_text(ctx, pCsr->cds.zFile, -1, SQLITE_TRANSIENT); + break; + case 1: /* mode */ + /* TODO: Whether or not the following is correct surely depends on + ** the platform on which the archive was created. */ + sqlite3_result_int(ctx, pCsr->cds.iExternalAttr >> 16); + break; + case 2: { /* mtime */ + if( pCsr->flags & ZIPFILE_MTIME_VALID ){ + sqlite3_result_int64(ctx, pCsr->mTime); + }else{ + sqlite3_result_int64(ctx, zipfileMtime(pCsr)); + } + break; + } + case 3: { /* sz */ + sqlite3_result_int64(ctx, pCsr->cds.szUncompressed); + break; + } + case 4: { /* data */ + int sz = pCsr->cds.szCompressed; + if( sz>0 ){ + u8 *aBuf = sqlite3_malloc(sz); + if( aBuf==0 ){ + rc = SQLITE_NOMEM; + }else{ + rc = zipfileReadData(pCsr, aBuf, sz, pCsr->iDataOff); + } + if( rc==SQLITE_OK ){ + sqlite3_result_blob(ctx, aBuf, sz, SQLITE_TRANSIENT); + sqlite3_free(aBuf); + } + } + break; + } + case 5: /* method */ + sqlite3_result_int(ctx, pCsr->cds.iCompression); + break; + } + + return SQLITE_OK; +} + +/* +** Return the rowid for the current row. In this implementation, the +** first row returned is assigned rowid value 1, and each subsequent +** row a value 1 more than that of the previous. +*/ +static int zipfileRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + ZipfileCsr *pCsr = (ZipfileCsr*)cur; + *pRowid = pCsr->iRowid; + return SQLITE_OK; +} + +/* +** Return TRUE if the cursor has been moved off of the last +** row of output. +*/ +static int zipfileEof(sqlite3_vtab_cursor *cur){ + ZipfileCsr *pCsr = (ZipfileCsr*)cur; + return pCsr->bEof; +} + +/* +** The zip file has been successfully opened (so pCsr->pFile is valid). +** This function attempts to locate and read the End of central +** directory record from the file. +** +*/ +static int zipfileReadEOCD(ZipfileCsr *pCsr, ZipfileEOCD *pEOCD){ + u8 *aRead = pCsr->aBuffer; + int nRead = (int)(MIN(pCsr->nByte, ZIPFILE_BUFFER_SIZE)); + i64 iOff = pCsr->nByte - nRead; + + int rc = zipfileReadData(pCsr, aRead, nRead, iOff); + if( rc==SQLITE_OK ){ + int i; + + /* Scan backwards looking for the signature bytes */ + for(i=nRead-20; i>=0; i--){ + if( aRead[i]==0x50 && aRead[i+1]==0x4b + && aRead[i+2]==0x05 && aRead[i+3]==0x06 + ){ + break; + } + } + if( i<0 ){ + zipfileSetErrmsg(pCsr, "cannot find end of central directory record"); + return SQLITE_ERROR; + } + + aRead += i+4; + pEOCD->iDisk = zipfileRead16(aRead); + pEOCD->iFirstDisk = zipfileRead16(aRead); + pEOCD->nEntry = zipfileRead16(aRead); + pEOCD->nEntryTotal = zipfileRead16(aRead); + pEOCD->nSize = zipfileRead32(aRead); + pEOCD->iOffset = zipfileRead32(aRead); + +#if 0 + printf("iDisk=%d iFirstDisk=%d nEntry=%d " + "nEntryTotal=%d nSize=%d iOffset=%d", + (int)pEOCD->iDisk, (int)pEOCD->iFirstDisk, (int)pEOCD->nEntry, + (int)pEOCD->nEntryTotal, (int)pEOCD->nSize, (int)pEOCD->iOffset + ); +#endif + } + + return SQLITE_OK; +} + +/* +** xFilter callback. +*/ +static int zipfileFilter( + sqlite3_vtab_cursor *cur, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + ZipfileCsr *pCsr = (ZipfileCsr*)cur; + const char *zFile; /* Zip file to scan */ + int rc = SQLITE_OK; /* Return Code */ + + zipfileResetCursor(pCsr); + + assert( idxNum==argc && (idxNum==0 || idxNum==1) ); + if( idxNum==0 ){ + /* Error. User did not supply a file name. */ + zipfileSetErrmsg(pCsr, "table function zipfile() requires an argument"); + return SQLITE_ERROR; + } + + zFile = sqlite3_value_text(argv[0]); + pCsr->pFile = fopen(zFile, "rb"); + if( pCsr->pFile==0 ){ + zipfileSetErrmsg(pCsr, "cannot open file: %s", zFile); + rc = SQLITE_ERROR; + }else{ + fseek(pCsr->pFile, 0, SEEK_END); + pCsr->nByte = (i64)ftell(pCsr->pFile); + rc = zipfileReadEOCD(pCsr, &pCsr->eocd); + if( rc==SQLITE_OK ){ + pCsr->iNextOff = pCsr->eocd.iOffset; + rc = zipfileNext(cur); + } + } + + return rc; +} + +/* +** xBestIndex callback. +*/ +static int zipfileBestIndex( + sqlite3_vtab *tab, + sqlite3_index_info *pIdxInfo +){ + int i; + + for(i=0; inConstraint; i++){ + const struct sqlite3_index_constraint *pCons = &pIdxInfo->aConstraint[i]; + if( pCons->usable==0 ) continue; + if( pCons->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; + if( pCons->iColumn!=ZIPFILE_F_COLUMN_IDX ) continue; + break; + } + + if( inConstraint ){ + pIdxInfo->aConstraintUsage[i].argvIndex = 1; + pIdxInfo->aConstraintUsage[i].omit = 1; + pIdxInfo->estimatedCost = 1000.0; + pIdxInfo->idxNum = 1; + }else{ + pIdxInfo->estimatedCost = (double)(((sqlite3_int64)1) << 50); + pIdxInfo->idxNum = 0; + } + + return SQLITE_OK; +} + +/* +** Register the "zipfile" virtual table. +*/ +static int zipfileRegister(sqlite3 *db){ + static sqlite3_module zipfileModule = { + 0, /* iVersion */ + 0, /* xCreate */ + zipfileConnect, /* xConnect */ + zipfileBestIndex, /* xBestIndex */ + zipfileDisconnect, /* xDisconnect */ + 0, /* xDestroy */ + zipfileOpen, /* xOpen - open a cursor */ + zipfileClose, /* xClose - close a cursor */ + zipfileFilter, /* xFilter - configure scan constraints */ + zipfileNext, /* xNext - advance a cursor */ + zipfileEof, /* xEof - check for end of scan */ + zipfileColumn, /* xColumn - read data */ + zipfileRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindMethod */ + 0, /* xRename */ + }; + + int rc = sqlite3_create_module(db, "zipfile" , &zipfileModule, 0); + return rc; +} +#else /* SQLITE_OMIT_VIRTUALTABLE */ +# define zipfileRegister(x) SQLITE_OK +#endif + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int sqlite3_zipfile_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ + int rc = SQLITE_OK; + SQLITE_EXTENSION_INIT2(pApi); + (void)pzErrMsg; /* Unused parameter */ + return zipfileRegister(db); +} + diff --git a/main.mk b/main.mk index ea0ff8bc2e..ff379da861 100644 --- a/main.mk +++ b/main.mk @@ -695,7 +695,8 @@ SHELL_SRC = \ $(TOP)/ext/misc/completion.c \ $(TOP)/ext/misc/sqlar.c \ $(TOP)/ext/expert/sqlite3expert.c \ - $(TOP)/ext/expert/sqlite3expert.h + $(TOP)/ext/expert/sqlite3expert.h \ + $(TOP)/ext/misc/zipfile.c shell.c: $(SHELL_SRC) $(TOP)/tool/mkshellc.tcl tclsh $(TOP)/tool/mkshellc.tcl >shell.c diff --git a/manifest b/manifest index 0293660ba4..a788cbbd26 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\senhancements\sfrom\strunk. -D 2017-12-23T18:34:49.545 +C Add\snew\sfile\sext/misc/zipfile.c,\scontaining\sa\svirtual\stable\sfor\sread-only\naccess\sto\ssimple\szip\sarchives. +D 2017-12-26T20:39:58.777 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in ceb40bfcb30ebba8e1202b34c56ff7e13e112f9809e2381d99be32c2726058f5 @@ -302,6 +302,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 +F ext/misc/zipfile.c 9736694a5eb029397e769f06517250be8b8e3836f4869246bfb60942a4047227 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -404,7 +405,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk eef9a9918485b5df70d7a69ed3d0e1dd182bf714740122a144905a59d42da5c6 +F main.mk fc13303745f7a06e2eac69406ee0e7ba481f6df37a528ceb6ebacc03e310a020 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -482,7 +483,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in e739db2809b9ad38ac389a89bead6986542a679ca33b153aef5850856998b525 +F src/shell.c.in 1c927f9407fa4e58ed114577971525209ea12a293d25fe689d1973d9fef17f74 F src/sqlite.h.in 2126192945019d4cdce335cb236b440a05ec75c93e4cd94c9c6d6e7fcc654cc4 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1691,7 +1692,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7652b3c2374084047b6c1da3e525e0cac34fe220597f81e793bc4fd9f33358da 07c773148d8db185fa54991df09298b64f4fef28879e6c9395759265e8183977 -R 0cdaf396f246262d8fd00807c02fe094 -U drh -Z d44ebee6c3c37877974b2b88daec7bfe +P 150f07fec1e6d1fc0601820d717d8712fc513fe0d4bed67c8679eb51bca30d53 +R ab04bfd243997fb0b46867b0347c7799 +U dan +Z 06eecfc1ea586319973b447240342e1d diff --git a/manifest.uuid b/manifest.uuid index 3fe37939e4..85c9e9cdf5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -150f07fec1e6d1fc0601820d717d8712fc513fe0d4bed67c8679eb51bca30d53 \ No newline at end of file +8e366b99b13d765d8bf000a7ec5919e582702e51dc07c27a746b6002898a2302 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 444df58899..b3ef375c0b 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -797,6 +797,7 @@ INCLUDE ../ext/misc/shathree.c INCLUDE ../ext/misc/fileio.c INCLUDE ../ext/misc/completion.c #ifdef SQLITE_HAVE_ZLIB +INCLUDE ../ext/misc/zipfile.c INCLUDE ../ext/misc/sqlar.c #endif INCLUDE ../ext/expert/sqlite3expert.h @@ -3002,6 +3003,7 @@ static void open_db(ShellState *p, int keepAlive){ sqlite3_shathree_init(p->db, 0, 0); sqlite3_completion_init(p->db, 0, 0); #ifdef SQLITE_HAVE_ZLIB + sqlite3_zipfile_init(p->db, 0, 0); sqlite3_sqlar_init(p->db, 0, 0); #endif sqlite3_create_function(p->db, "shell_add_schema", 2, SQLITE_UTF8, 0, From 5a78b81b1b5b8ab70ab61feeac7407379e3efeee Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 27 Dec 2017 18:54:11 +0000 Subject: [PATCH 021/190] Have the shell tool ".ar --list" and ".ar --extract" commands support zip files. Currently the "-zip" switch is required. FossilOrigin-Name: a532a0f6fd59e81086d46f09151ba7fb26725198231d902c71d0f95cb01dbe91 --- ext/misc/zipfile.c | 52 ++++++++++++++++++++++++++++++++++ manifest | 14 +++++----- manifest.uuid | 2 +- src/shell.c.in | 70 ++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 121 insertions(+), 17 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index bcee873044..cf9666a7ae 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -680,6 +680,54 @@ static int zipfileRegister(sqlite3 *db){ # define zipfileRegister(x) SQLITE_OK #endif +#include + +/* +** zipfile_uncompress(DATA, SZ, METHOD) +*/ +static void zipfileUncompressFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + int iMethod; + + iMethod = sqlite3_value_int(argv[2]); + if( iMethod==0 ){ + sqlite3_result_value(context, argv[0]); + }else if( iMethod==8 ){ + Byte *res; + int sz = sqlite3_value_int(argv[1]); + z_stream str; + memset(&str, 0, sizeof(str)); + str.next_in = (Byte*)sqlite3_value_blob(argv[0]); + str.avail_in = sqlite3_value_bytes(argv[0]); + res = str.next_out = (Byte*)sqlite3_malloc(sz); + if( res==0 ){ + sqlite3_result_error_nomem(context); + }else{ + int err; + str.avail_out = sz; + + err = inflateInit2(&str, -15); + if( err!=Z_OK ){ + zipfileCtxErrorMsg(context, "inflateInit2() failed (%d)", err); + }else{ + err = inflate(&str, Z_NO_FLUSH); + if( err!=Z_STREAM_END ){ + zipfileCtxErrorMsg(context, "inflate() failed (%d)", err); + }else{ + sqlite3_result_blob(context, res, sz, SQLITE_TRANSIENT); + } + } + sqlite3_free(res); + inflateEnd(&str); + } + }else{ + zipfileCtxErrorMsg(context, "unrecognized compression method: %d", iMethod); + } +} + #ifdef _WIN32 __declspec(dllexport) #endif @@ -691,6 +739,10 @@ int sqlite3_zipfile_init( int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi); (void)pzErrMsg; /* Unused parameter */ + rc = sqlite3_create_function(db, "zipfile_uncompress", 3, + SQLITE_UTF8, 0, zipfileUncompressFunc, 0, 0 + ); + if( rc!=SQLITE_OK ) return rc; return zipfileRegister(db); } diff --git a/manifest b/manifest index a788cbbd26..0cc3ca2bdd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\sfile\sext/misc/zipfile.c,\scontaining\sa\svirtual\stable\sfor\sread-only\naccess\sto\ssimple\szip\sarchives. -D 2017-12-26T20:39:58.777 +C Have\sthe\sshell\stool\s".ar\s--list"\sand\s".ar\s--extract"\scommands\ssupport\szip\nfiles.\sCurrently\sthe\s"-zip"\sswitch\sis\srequired. +D 2017-12-27T18:54:11.166 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in ceb40bfcb30ebba8e1202b34c56ff7e13e112f9809e2381d99be32c2726058f5 @@ -302,7 +302,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 9736694a5eb029397e769f06517250be8b8e3836f4869246bfb60942a4047227 +F ext/misc/zipfile.c 96148b78b56664fe82f774e50dcdf6c83d693a1449b88011eba00cd6c697fedf F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -483,7 +483,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 1c927f9407fa4e58ed114577971525209ea12a293d25fe689d1973d9fef17f74 +F src/shell.c.in d1be3030ee7afbbfb67972e4614b6d08dcae2e76460114d6b200fd28d0f008fb F src/sqlite.h.in 2126192945019d4cdce335cb236b440a05ec75c93e4cd94c9c6d6e7fcc654cc4 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1692,7 +1692,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 150f07fec1e6d1fc0601820d717d8712fc513fe0d4bed67c8679eb51bca30d53 -R ab04bfd243997fb0b46867b0347c7799 +P 8e366b99b13d765d8bf000a7ec5919e582702e51dc07c27a746b6002898a2302 +R 0d0cb33644ad535bd9f83812fd2ec78d U dan -Z 06eecfc1ea586319973b447240342e1d +Z 54715bdb695d1dc399a9b1cd512f6d24 diff --git a/manifest.uuid b/manifest.uuid index 85c9e9cdf5..6167e93eb4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e366b99b13d765d8bf000a7ec5919e582702e51dc07c27a746b6002898a2302 \ No newline at end of file +a532a0f6fd59e81086d46f09151ba7fb26725198231d902c71d0f95cb01dbe91 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index b3ef375c0b..15a018bb9c 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4238,7 +4238,13 @@ static void shellReset( sqlite3_stmt *pStmt ){ int rc = sqlite3_reset(pStmt); - if( *pRc==SQLITE_OK ) *pRc = rc; + if( *pRc==SQLITE_OK ){ + if( rc!=SQLITE_OK ){ + sqlite3 *db = sqlite3_db_handle(pStmt); + raw_printf(stderr, "SQL error: %s\n", sqlite3_errmsg(db)); + } + *pRc = rc; + } } /* @@ -4250,6 +4256,7 @@ struct ArCommand { const char *zFile; /* --file argument, or NULL */ const char *zDir; /* --directory argument, or NULL */ int bVerbose; /* True if --verbose */ + int bZip; /* True if --zip */ int nArg; /* Number of command arguments */ char **azArg; /* Array of command arguments */ }; @@ -4315,6 +4322,7 @@ static int arErrorMsg(const char *zFmt, ...){ #define AR_SWITCH_VERBOSE 6 #define AR_SWITCH_FILE 7 #define AR_SWITCH_DIRECTORY 8 +#define AR_SWITCH_ZIP 9 static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ switch( eSwitch ){ @@ -4332,6 +4340,9 @@ static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ case AR_SWITCH_VERBOSE: pAr->bVerbose = 1; break; + case AR_SWITCH_ZIP: + pAr->bZip = 1; + break; case AR_SWITCH_FILE: pAr->zFile = zArg; @@ -4368,7 +4379,8 @@ static int arParseCommand( { 'h', "help", AR_CMD_HELP, 0 }, { 'v', "verbose", AR_SWITCH_VERBOSE, 0 }, { 'f', "file", AR_SWITCH_FILE, 1 }, - { 'C', "directory", AR_SWITCH_DIRECTORY, 1 } + { 'C', "directory", AR_SWITCH_DIRECTORY, 1 }, + { 'z', "zip", AR_SWITCH_ZIP, 0 } }; int nSwitch = sizeof(aSwitch) / sizeof(struct ArSwitch); struct ArSwitch *pEnd = &aSwitch[nSwitch]; @@ -4501,7 +4513,12 @@ static int arCheckEntries(sqlite3 *db, ArCommand *pAr){ int i; sqlite3_stmt *pTest = 0; - shellPrepare(db, &rc, "SELECT name FROM sqlar WHERE name=?", &pTest); + shellPreparePrintf(db, &rc, &pTest, "SELECT name FROM %s WHERE name=?1", + pAr->bZip ? "zipfile(?2)" : "sqlar" + ); + if( rc==SQLITE_OK && pAr->bZip ){ + sqlite3_bind_text(pTest, 2, pAr->zFile, -1, SQLITE_TRANSIENT); + } for(i=0; inArg && rc==SQLITE_OK; i++){ char *z = pAr->azArg[i]; int n = strlen(z); @@ -4564,7 +4581,9 @@ static void arWhereClause( ** Implementation of .ar "lisT" command. */ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ - const char *zSql = "SELECT name FROM sqlar WHERE %s"; + const char *zSql = "SELECT name FROM %s WHERE %s"; + const char *zTbl = (pAr->bZip ? "zipfile(?)" : "sqlar"); + char *zWhere = 0; sqlite3_stmt *pSql = 0; int rc; @@ -4572,10 +4591,15 @@ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ rc = arCheckEntries(db, pAr); arWhereClause(&rc, pAr, &zWhere); - shellPreparePrintf(db, &rc, &pSql, zSql, zWhere); + shellPreparePrintf(db, &rc, &pSql, zSql, zTbl, zWhere); + if( rc==SQLITE_OK && pAr->bZip ){ + sqlite3_bind_text(pSql, 1, pAr->zFile, -1, SQLITE_TRANSIENT); + } while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ raw_printf(p->out, "%s\n", sqlite3_column_text(pSql, 0)); } + + shellFinalize(&rc, pSql); return rc; } @@ -4587,8 +4611,18 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ const char *zSql1 = "SELECT " " :1 || name, " - " writefile(:1 || name, sqlar_uncompress(data, sz), mode, mtime) " - "FROM sqlar WHERE (%s) AND (data IS NULL OR :2 = 0)"; + " writefile(?1 || name, %s, mode, mtime) " + "FROM %s WHERE (%s) AND (data IS NULL OR ?2 = 0)"; + + const char *azExtraArg[] = { + "sqlar_uncompress(data, sz)", + "zipfile_uncompress(data, sz, method)" + }; + const char *azSource[] = { + "sqlar", "zipfile(?3)" + }; + + struct timespec times[2]; sqlite3_stmt *pSql = 0; @@ -4615,9 +4649,15 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ memset(times, 0, sizeof(times)); times[0].tv_sec = time(0); - shellPreparePrintf(db, &rc, &pSql, zSql1, zWhere); + shellPreparePrintf(db, &rc, &pSql, zSql1, + azExtraArg[pAr->bZip], azSource[pAr->bZip], zWhere + ); + if( rc==SQLITE_OK ){ sqlite3_bind_text(pSql, 1, zDir, -1, SQLITE_STATIC); + if( pAr->bZip ){ + sqlite3_bind_text(pSql, 3, pAr->zFile, -1, SQLITE_STATIC); + } /* Run the SELECT statement twice. The first time, writefile() is called ** for all archive members that should be extracted. The second time, @@ -4676,6 +4716,8 @@ static int arCreateUpdate( int i; /* For iterating through azFile[] */ int rc; /* Return code */ + assert( pAr->bZip==0 ); + rc = sqlite3_exec(db, "SAVEPOINT ar;", 0, 0, 0); if( rc!=SQLITE_OK ) return rc; @@ -4772,7 +4814,17 @@ static int arDotCommand( if( rc==SQLITE_OK ){ sqlite3 *db = 0; /* Database handle to use as archive */ - if( cmd.zFile ){ + if( cmd.bZip ){ + if( cmd.zFile==0 ){ + raw_printf(stderr, "zip format requires a --file switch\n"); + return SQLITE_ERROR; + }else + if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_UPDATE ){ + raw_printf(stderr, "zip archives are read-only\n"); + return SQLITE_ERROR; + } + db = pState->db; + }else if( cmd.zFile ){ int flags; if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_UPDATE ){ flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE; From b5090e489784941c91e559cc23e5cbe497dab52c Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 27 Dec 2017 21:13:21 +0000 Subject: [PATCH 022/190] Improve the shell tool ".ar --list --verbose" command. FossilOrigin-Name: b64681a644c419bb98d00980a6cb56ef5a0aff5ef5321955631f0b4c88aac283 --- ext/misc/zipfile.c | 17 +++++++++++----- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 48 +++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index cf9666a7ae..188d4fc2ea 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -50,6 +50,9 @@ typedef unsigned long u32; #define ZIPFILE_BUFFER_SIZE (64*1024) + +#define ZIPFILE_EXTRA_TIMESTAMP 0x5455 + /* ** Set the error message contained in context ctx to the results of ** vprintf(zFmt, ...). @@ -341,7 +344,14 @@ static int zipfileReadCDS(ZipfileCsr *pCsr){ pCsr->iNextOff += pCsr->cds.nComment; } - /* Scan the "extra" fields */ + /* Scan the cds.nExtra bytes of "extra" fields for any that can + ** be interpreted. The general format of an extra field is: + ** + ** Header ID 2 bytes + ** Data Size 2 bytes + ** Data N bytes + ** + */ if( rc==SQLITE_OK ){ u8 *p = &aRead[pCsr->cds.nFile]; u8 *pEnd = &p[pCsr->cds.nExtra]; @@ -351,7 +361,7 @@ static int zipfileReadCDS(ZipfileCsr *pCsr){ u16 nByte = zipfileRead16(p); switch( id ){ - case 0x5455: { /* Extended timestamp */ + case ZIPFILE_EXTRA_TIMESTAMP: { u8 b = p[0]; if( b & 0x01 ){ /* 0x01 -> modtime is present */ pCsr->mTime = zipfileGetU32(&p[1]); @@ -359,9 +369,6 @@ static int zipfileReadCDS(ZipfileCsr *pCsr){ } break; } - - case 0x7875: /* Info-ZIP Unix (new) */ - break; } p += nByte; diff --git a/manifest b/manifest index 0cc3ca2bdd..d6c9a543e5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sthe\sshell\stool\s".ar\s--list"\sand\s".ar\s--extract"\scommands\ssupport\szip\nfiles.\sCurrently\sthe\s"-zip"\sswitch\sis\srequired. -D 2017-12-27T18:54:11.166 +C Improve\sthe\sshell\stool\s".ar\s--list\s--verbose"\scommand. +D 2017-12-27T21:13:21.423 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in ceb40bfcb30ebba8e1202b34c56ff7e13e112f9809e2381d99be32c2726058f5 @@ -302,7 +302,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 96148b78b56664fe82f774e50dcdf6c83d693a1449b88011eba00cd6c697fedf +F ext/misc/zipfile.c ced1aa768904cf8182c3da93d42df4e3cf30fe7a2e66c9216f6bc64a8df4fd5b F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -483,7 +483,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in d1be3030ee7afbbfb67972e4614b6d08dcae2e76460114d6b200fd28d0f008fb +F src/shell.c.in 9177b6cc706b1dd1ed81b05344641597d7ed8bba97a8fc31192309189846fab7 F src/sqlite.h.in 2126192945019d4cdce335cb236b440a05ec75c93e4cd94c9c6d6e7fcc654cc4 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1692,7 +1692,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8e366b99b13d765d8bf000a7ec5919e582702e51dc07c27a746b6002898a2302 -R 0d0cb33644ad535bd9f83812fd2ec78d +P a532a0f6fd59e81086d46f09151ba7fb26725198231d902c71d0f95cb01dbe91 +R 7075030d907b0ffe212621eb709bb967 U dan -Z 54715bdb695d1dc399a9b1cd512f6d24 +Z 1c430e112380037cc2bfad44bf8be92e diff --git a/manifest.uuid b/manifest.uuid index 6167e93eb4..aaba04f0ec 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a532a0f6fd59e81086d46f09151ba7fb26725198231d902c71d0f95cb01dbe91 \ No newline at end of file +b64681a644c419bb98d00980a6cb56ef5a0aff5ef5321955631f0b4c88aac283 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 15a018bb9c..f7edb53f06 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4577,12 +4577,43 @@ static void arWhereClause( *pzWhere = zWhere; } +/* +** Argument zMode must point to a buffer at least 11 bytes in size. This +** function populates this buffer with the string interpretation of +** the unix file mode passed as the second argument (e.g. "drwxr-xr-x"). +*/ +static void shellModeToString(char *zMode, int mode){ + int i; + + /* Magic numbers copied from [man 2 stat] */ + if( mode & 0040000 ){ + zMode[0] = 'd'; + }else if( (mode & 0120000)==0120000 ){ + zMode[0] = 'l'; + }else{ + zMode[0] = '-'; + } + + for(i=0; i<3; i++){ + int m = (mode >> ((2-i)*3)); + char *a = &zMode[1 + i*3]; + a[0] = (m & 0x4) ? 'r' : '-'; + a[1] = (m & 0x2) ? 'w' : '-'; + a[2] = (m & 0x1) ? 'x' : '-'; + } + zMode[10] = '\0'; +} + /* ** Implementation of .ar "lisT" command. */ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ - const char *zSql = "SELECT name FROM %s WHERE %s"; + const char *zSql = "SELECT %s FROM %s WHERE %s"; const char *zTbl = (pAr->bZip ? "zipfile(?)" : "sqlar"); + const char *azCols[] = { + "name", + "mode, sz, datetime(mtime, 'unixepoch'), name" + }; char *zWhere = 0; sqlite3_stmt *pSql = 0; @@ -4591,12 +4622,23 @@ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ rc = arCheckEntries(db, pAr); arWhereClause(&rc, pAr, &zWhere); - shellPreparePrintf(db, &rc, &pSql, zSql, zTbl, zWhere); + shellPreparePrintf(db, &rc, &pSql, zSql, azCols[pAr->bVerbose], zTbl, zWhere); if( rc==SQLITE_OK && pAr->bZip ){ sqlite3_bind_text(pSql, 1, pAr->zFile, -1, SQLITE_TRANSIENT); } while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ - raw_printf(p->out, "%s\n", sqlite3_column_text(pSql, 0)); + if( pAr->bVerbose ){ + char zMode[11]; + shellModeToString(zMode, sqlite3_column_int(pSql, 0)); + + raw_printf(p->out, "%s % 10d %s %s\n", zMode, + sqlite3_column_int(pSql, 1), + sqlite3_column_text(pSql, 2), + sqlite3_column_text(pSql, 3) + ); + }else{ + raw_printf(p->out, "%s\n", sqlite3_column_text(pSql, 0)); + } } shellFinalize(&rc, pSql); From 373dc3bb3f00c19e84fab3a997194c7316f4f0e5 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 29 Dec 2017 20:19:03 +0000 Subject: [PATCH 023/190] Update ext/misc/zipfile.c to support creating and adding entries to existing zip archives. FossilOrigin-Name: 2dec2dec592c0726ebe87b841b9c8d493dea7074a99f278eb1bf0b744d658a9d --- ext/misc/zipfile.c | 670 +++++++++++++++++++++++++++++++++++++++++---- main.mk | 1 + manifest | 17 +- manifest.uuid | 2 +- src/test1.c | 2 + test/zipfile.test | 60 ++++ 6 files changed, 689 insertions(+), 63 deletions(-) create mode 100644 test/zipfile.test diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 188d4fc2ea..5824965032 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -26,6 +26,8 @@ SQLITE_EXTENSION_INIT1 #include #include +#include + #ifndef SQLITE_OMIT_VIRTUALTABLE #ifndef SQLITE_AMALGAMATION @@ -47,11 +49,40 @@ typedef unsigned long u32; ");" #define ZIPFILE_F_COLUMN_IDX 6 /* Index of column "f" in the above */ - #define ZIPFILE_BUFFER_SIZE (64*1024) -#define ZIPFILE_EXTRA_TIMESTAMP 0x5455 +/* +** Magic numbers used to read and write zip files. +** +** ZIPFILE_NEWENTRY_MADEBY: +** Use this value for the "version-made-by" field in new zip file +** entries. The upper byte indicates "unix", and the lower byte +** indicates that the zip file matches pkzip specification 3.0. +** This is what info-zip seems to do. +** +** ZIPFILE_NEWENTRY_REQUIRED: +** Value for "version-required-to-extract" field of new entries. +** Version 2.0 is required to support folders and deflate compression. +** +** ZIPFILE_NEWENTRY_FLAGS: +** Value for "general-purpose-bit-flags" field of new entries. Bit +** 11 means "utf-8 filename and comment". +** +** ZIPFILE_SIGNATURE_CDS: +** First 4 bytes of a valid CDS record. +** +** ZIPFILE_SIGNATURE_LFH: +** First 4 bytes of a valid LFH record. +*/ +#define ZIPFILE_EXTRA_TIMESTAMP 0x5455 +#define ZIPFILE_NEWENTRY_MADEBY ((3<<8) + 30) +#define ZIPFILE_NEWENTRY_REQUIRED 20 +#define ZIPFILE_NEWENTRY_FLAGS 0x800 +#define ZIPFILE_SIGNATURE_CDS 0x02014b50 +#define ZIPFILE_SIGNATURE_LFH 0x04034b50 +#define ZIPFILE_SIGNATURE_EOCD 0x06054b50 +#define ZIPFILE_LFH_FIXED_SZ 30 /* ** Set the error message contained in context ctx to the results of @@ -188,18 +219,58 @@ struct ZipfileCsr { i64 iDataOff; /* Offset in zipfile to data */ u32 mTime; /* Extended mtime value */ int flags; - u8 *aBuffer; /* Buffer used for various tasks */ }; +/* +** Values for ZipfileCsr.flags. +*/ #define ZIPFILE_MTIME_VALID 0x0001 +typedef struct ZipfileEntry ZipfileEntry; +struct ZipfileEntry { + char *zPath; /* Path of zipfile entry */ + u8 *aCdsEntry; /* Buffer containing entire CDS entry */ + int nCdsEntry; /* Size of buffer aCdsEntry[] in bytes */ + ZipfileEntry *pNext; +}; + typedef struct ZipfileTab ZipfileTab; struct ZipfileTab { sqlite3_vtab base; /* Base class - must be first */ + char *zFile; /* Zip file this table accesses (may be NULL) */ + u8 *aBuffer; /* Temporary buffer used for various tasks */ + + /* The following are used by write transactions only */ + ZipfileEntry *pEntry; /* Linked list of all files (if pWriteFd!=0) */ + FILE *pWriteFd; /* File handle open on zip archive */ + i64 szCurrent; /* Current size of zip archive */ + i64 szOrig; /* Size of archive at start of transaction */ }; +static void zipfileDequote(char *zIn){ + char q = zIn[0]; + if( q=='"' || q=='\'' || q=='`' || q=='[' ){ + char c; + int iIn = 1; + int iOut = 0; + if( q=='[' ) q = ']'; + while( (c = zIn[iIn++]) ){ + if( c==q ){ + if( zIn[iIn++]!=q ) break; + } + zIn[iOut++] = c; + } + zIn[iOut] = '\0'; + } +} + /* ** Construct a new ZipfileTab virtual table object. +** +** argv[0] -> module name ("zipfile") +** argv[1] -> database name +** argv[2] -> table name +** argv[...] -> "column name" and other module argument fields. */ static int zipfileConnect( sqlite3 *db, @@ -208,14 +279,28 @@ static int zipfileConnect( sqlite3_vtab **ppVtab, char **pzErr ){ + int nByte = sizeof(ZipfileTab) + ZIPFILE_BUFFER_SIZE; + int nFile = 0; + const char *zFile = 0; ZipfileTab *pNew = 0; int rc; + if( argc>3 ){ + zFile = argv[3]; + nFile = strlen(zFile)+1; + } + rc = sqlite3_declare_vtab(db, ZIPFILE_SCHEMA); if( rc==SQLITE_OK ){ - pNew = (ZipfileTab*)sqlite3_malloc( sizeof(*pNew) ); + pNew = (ZipfileTab*)sqlite3_malloc(nByte+nFile); if( pNew==0 ) return SQLITE_NOMEM; - memset(pNew, 0, sizeof(*pNew)); + memset(pNew, 0, nByte+nFile); + pNew->aBuffer = (u8*)&pNew[1]; + if( zFile ){ + pNew->zFile = (char*)&pNew->aBuffer[ZIPFILE_BUFFER_SIZE]; + memcpy(pNew->zFile, zFile, nFile); + zipfileDequote(pNew->zFile); + } } *ppVtab = (sqlite3_vtab*)pNew; return rc; @@ -234,11 +319,12 @@ static int zipfileDisconnect(sqlite3_vtab *pVtab){ */ static int zipfileOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){ ZipfileCsr *pCsr; - pCsr = sqlite3_malloc( sizeof(*pCsr) + ZIPFILE_BUFFER_SIZE); - if( pCsr==0 ) return SQLITE_NOMEM; + pCsr = sqlite3_malloc(sizeof(*pCsr)); + *ppCsr = (sqlite3_vtab_cursor*)pCsr; + if( pCsr==0 ){ + return SQLITE_NOMEM; + } memset(pCsr, 0, sizeof(*pCsr)); - pCsr->aBuffer = (u8*)&pCsr[1]; - *ppCsr = &pCsr->base; return SQLITE_OK; } @@ -247,6 +333,8 @@ static int zipfileOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){ ** by zipfileOpen(). */ static void zipfileResetCursor(ZipfileCsr *pCsr){ + sqlite3_free(pCsr->cds.zFile); + pCsr->cds.zFile = 0; pCsr->iRowid = 0; pCsr->bEof = 0; if( pCsr->pFile ){ @@ -276,17 +364,39 @@ static void zipfileSetErrmsg(ZipfileCsr *pCsr, const char *zFmt, ...){ va_end(ap); } -static int zipfileReadData(ZipfileCsr *pCsr, u8 *aRead, int nRead, i64 iOff){ +static int zipfileReadData( + FILE *pFile, /* Read from this file */ + u8 *aRead, /* Read into this buffer */ + int nRead, /* Number of bytes to read */ + i64 iOff, /* Offset to read from */ + char **pzErrmsg /* OUT: Error message (from sqlite3_malloc) */ +){ size_t n; - fseek(pCsr->pFile, iOff, SEEK_SET); - n = fread(aRead, 1, nRead, pCsr->pFile); + fseek(pFile, iOff, SEEK_SET); + n = fread(aRead, 1, nRead, pFile); if( n!=nRead ){ - zipfileSetErrmsg(pCsr, "error in fread()"); + *pzErrmsg = sqlite3_mprintf("error in fread()"); return SQLITE_ERROR; } return SQLITE_OK; } +static int zipfileAppendData( + ZipfileTab *pTab, + const u8 *aWrite, + int nWrite +){ + size_t n; + fseek(pTab->pWriteFd, pTab->szCurrent, SEEK_SET); + n = fwrite(aWrite, 1, nWrite, pTab->pWriteFd); + if( n!=nWrite ){ + pTab->base.zErrMsg = sqlite3_mprintf("error in fwrite()"); + return SQLITE_ERROR; + } + pTab->szCurrent += nWrite; + return SQLITE_OK; +} + static u16 zipfileGetU16(const u8 *aBuf){ return (aBuf[1] << 8) + aBuf[0]; } @@ -297,18 +407,47 @@ static u32 zipfileGetU32(const u8 *aBuf){ + ((u32)(aBuf[0]) << 0); } +static void zipfilePutU16(u8 *aBuf, u16 val){ + aBuf[0] = val & 0xFF; + aBuf[1] = (val>>8) & 0xFF; +} +static void zipfilePutU32(u8 *aBuf, u32 val){ + aBuf[0] = val & 0xFF; + aBuf[1] = (val>>8) & 0xFF; + aBuf[2] = (val>>16) & 0xFF; + aBuf[3] = (val>>24) & 0xFF; +} + #define zipfileRead32(aBuf) ( aBuf+=4, zipfileGetU32(aBuf-4) ) #define zipfileRead16(aBuf) ( aBuf+=2, zipfileGetU16(aBuf-2) ) +#define zipfileWrite32(aBuf,val) { zipfilePutU32(aBuf,val); aBuf+=4; } +#define zipfileWrite16(aBuf,val) { zipfilePutU16(aBuf,val); aBuf+=2; } + +static u8* zipfileCsrBuffer(ZipfileCsr *pCsr){ + return ((ZipfileTab*)(pCsr->base.pVtab))->aBuffer; +} + +/* +** Magic numbers used to read CDS records. +*/ +#define ZIPFILE_CDS_FIXED_SZ 46 +#define ZIPFILE_CDS_NFILE_OFF 28 + static int zipfileReadCDS(ZipfileCsr *pCsr){ - static const int szFix = 46; /* Size of fixed-size part of CDS */ - u8 *aRead = pCsr->aBuffer; + char **pzErr = &pCsr->base.pVtab->zErrMsg; + u8 *aRead = zipfileCsrBuffer(pCsr); int rc; - rc = zipfileReadData(pCsr, aRead, szFix, pCsr->iNextOff); + sqlite3_free(pCsr->cds.zFile); + pCsr->cds.zFile = 0; + + rc = zipfileReadData( + pCsr->pFile, aRead, ZIPFILE_CDS_FIXED_SZ, pCsr->iNextOff, pzErr + ); if( rc==SQLITE_OK ){ u32 sig = zipfileRead32(aRead); - if( sig!=0x02014b50 ){ + if( sig!=ZIPFILE_SIGNATURE_CDS ){ zipfileSetErrmsg(pCsr,"failed to read CDS at offset %lld",pCsr->iNextOff); rc = SQLITE_ERROR; }else{ @@ -322,6 +461,7 @@ static int zipfileReadCDS(ZipfileCsr *pCsr){ pCsr->cds.crc32 = zipfileRead32(aRead); pCsr->cds.szCompressed = zipfileRead32(aRead); pCsr->cds.szUncompressed = zipfileRead32(aRead); + assert( aRead==zipfileCsrBuffer(pCsr)+ZIPFILE_CDS_NFILE_OFF ); pCsr->cds.nFile = zipfileRead16(aRead); pCsr->cds.nExtra = zipfileRead16(aRead); pCsr->cds.nComment = zipfileRead16(aRead); @@ -330,15 +470,15 @@ static int zipfileReadCDS(ZipfileCsr *pCsr){ pCsr->cds.iExternalAttr = zipfileRead32(aRead); pCsr->cds.iOffset = zipfileRead32(aRead); - assert( aRead==&pCsr->aBuffer[szFix] ); + assert( aRead==zipfileCsrBuffer(pCsr)+ZIPFILE_CDS_FIXED_SZ ); nRead = pCsr->cds.nFile + pCsr->cds.nExtra; - aRead = pCsr->aBuffer; - rc = zipfileReadData(pCsr, aRead, nRead, pCsr->iNextOff+szFix); + aRead = zipfileCsrBuffer(pCsr); + pCsr->iNextOff += ZIPFILE_CDS_FIXED_SZ; + rc = zipfileReadData(pCsr->pFile, aRead, nRead, pCsr->iNextOff, pzErr); if( rc==SQLITE_OK ){ pCsr->cds.zFile = sqlite3_mprintf("%.*s", (int)pCsr->cds.nFile, aRead); - pCsr->iNextOff += szFix; pCsr->iNextOff += pCsr->cds.nFile; pCsr->iNextOff += pCsr->cds.nExtra; pCsr->iNextOff += pCsr->cds.nComment; @@ -381,14 +521,15 @@ static int zipfileReadCDS(ZipfileCsr *pCsr){ } static int zipfileReadLFH(ZipfileCsr *pCsr){ - static const int szFix = 30; /* Size of fixed-size part of LFH */ - u8 *aRead = pCsr->aBuffer; + char **pzErr = &pCsr->base.pVtab->zErrMsg; + static const int szFix = ZIPFILE_LFH_FIXED_SZ; + u8 *aRead = zipfileCsrBuffer(pCsr); int rc; - rc = zipfileReadData(pCsr, aRead, szFix, pCsr->cds.iOffset); + rc = zipfileReadData(pCsr->pFile, aRead, szFix, pCsr->cds.iOffset, pzErr); if( rc==SQLITE_OK ){ u32 sig = zipfileRead32(aRead); - if( sig!=0x04034b50 ){ + if( sig!=ZIPFILE_SIGNATURE_LFH ){ zipfileSetErrmsg(pCsr, "failed to read LFH at offset %d", (int)pCsr->cds.iOffset ); @@ -404,7 +545,7 @@ static int zipfileReadLFH(ZipfileCsr *pCsr){ pCsr->lfh.szUncompressed = zipfileRead32(aRead); pCsr->lfh.nFile = zipfileRead16(aRead); pCsr->lfh.nExtra = zipfileRead16(aRead); - assert( aRead==&pCsr->aBuffer[szFix] ); + assert( aRead==zipfileCsrBuffer(pCsr)+szFix ); pCsr->iDataOff = pCsr->cds.iOffset+szFix+pCsr->lfh.nFile+pCsr->lfh.nExtra; } } @@ -460,6 +601,22 @@ static time_t zipfileMtime(ZipfileCsr *pCsr){ return mktime(&t); } +static void zipfileMtimeToDos(ZipfileCDS *pCds, u32 mTime){ + time_t t = (time_t)mTime; + struct tm res; + localtime_r(&t, &res); + + pCds->mTime = + (res.tm_sec / 2) + + (res.tm_min << 5) + + (res.tm_hour << 11); + + pCds->mDate = + (res.tm_mday-1) + + ((res.tm_mon+1) << 5) + + ((res.tm_year-80) << 9); +} + /* ** Return values of columns for the row at which the series_cursor ** is currently pointing. @@ -499,7 +656,9 @@ static int zipfileColumn( if( aBuf==0 ){ rc = SQLITE_NOMEM; }else{ - rc = zipfileReadData(pCsr, aBuf, sz, pCsr->iDataOff); + rc = zipfileReadData(pCsr->pFile, aBuf, sz, pCsr->iDataOff, + &pCsr->base.pVtab->zErrMsg + ); } if( rc==SQLITE_OK ){ sqlite3_result_blob(ctx, aBuf, sz, SQLITE_TRANSIENT); @@ -537,17 +696,26 @@ static int zipfileEof(sqlite3_vtab_cursor *cur){ } /* -** The zip file has been successfully opened (so pCsr->pFile is valid). -** This function attempts to locate and read the End of central -** directory record from the file. -** */ -static int zipfileReadEOCD(ZipfileCsr *pCsr, ZipfileEOCD *pEOCD){ - u8 *aRead = pCsr->aBuffer; - int nRead = (int)(MIN(pCsr->nByte, ZIPFILE_BUFFER_SIZE)); - i64 iOff = pCsr->nByte - nRead; +static int zipfileReadEOCD( + ZipfileTab *pTab, /* Return errors here */ + FILE *pFile, /* Read from this file */ + ZipfileEOCD *pEOCD /* Object to populate */ +){ + u8 *aRead = pTab->aBuffer; /* Temporary buffer */ + i64 szFile; /* Total size of file in bytes */ + int nRead; /* Bytes to read from file */ + i64 iOff; /* Offset to read from */ - int rc = zipfileReadData(pCsr, aRead, nRead, iOff); + fseek(pFile, 0, SEEK_END); + szFile = (i64)ftell(pFile); + if( szFile==0 ){ + return SQLITE_EMPTY; + } + nRead = (int)(MIN(szFile, ZIPFILE_BUFFER_SIZE)); + iOff = szFile - nRead; + + int rc = zipfileReadData(pFile, aRead, nRead, iOff, &pTab->base.zErrMsg); if( rc==SQLITE_OK ){ int i; @@ -560,7 +728,9 @@ static int zipfileReadEOCD(ZipfileCsr *pCsr, ZipfileEOCD *pEOCD){ } } if( i<0 ){ - zipfileSetErrmsg(pCsr, "cannot find end of central directory record"); + pTab->base.zErrMsg = sqlite3_mprintf( + "cannot find end of central directory record" + ); return SQLITE_ERROR; } @@ -592,6 +762,7 @@ static int zipfileFilter( int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ + ZipfileTab *pTab = (ZipfileTab*)cur->pVtab; ZipfileCsr *pCsr = (ZipfileCsr*)cur; const char *zFile; /* Zip file to scan */ int rc = SQLITE_OK; /* Return Code */ @@ -600,23 +771,29 @@ static int zipfileFilter( assert( idxNum==argc && (idxNum==0 || idxNum==1) ); if( idxNum==0 ){ - /* Error. User did not supply a file name. */ - zipfileSetErrmsg(pCsr, "table function zipfile() requires an argument"); - return SQLITE_ERROR; + ZipfileTab *pTab = (ZipfileTab*)cur->pVtab; + zFile = pTab->zFile; + if( zFile==0 ){ + /* Error. This is an eponymous virtual table and the user has not + ** supplied a file name. */ + zipfileSetErrmsg(pCsr, "table function zipfile() requires an argument"); + return SQLITE_ERROR; + } + }else{ + zFile = (const char*)sqlite3_value_text(argv[0]); } - - zFile = sqlite3_value_text(argv[0]); pCsr->pFile = fopen(zFile, "rb"); if( pCsr->pFile==0 ){ zipfileSetErrmsg(pCsr, "cannot open file: %s", zFile); rc = SQLITE_ERROR; }else{ - fseek(pCsr->pFile, 0, SEEK_END); - pCsr->nByte = (i64)ftell(pCsr->pFile); - rc = zipfileReadEOCD(pCsr, &pCsr->eocd); + rc = zipfileReadEOCD(pTab, pCsr->pFile, &pCsr->eocd); if( rc==SQLITE_OK ){ pCsr->iNextOff = pCsr->eocd.iOffset; rc = zipfileNext(cur); + }else if( rc==SQLITE_EMPTY ){ + rc = SQLITE_OK; + pCsr->bEof = 1; } } @@ -653,17 +830,404 @@ static int zipfileBestIndex( return SQLITE_OK; } +static int zipfileLoadDirectory(ZipfileTab *pTab){ + ZipfileEOCD eocd; + int rc; + + rc = zipfileReadEOCD(pTab, pTab->pWriteFd, &eocd); + if( rc==SQLITE_OK ){ + int i; + int iOff = 0; + u8 *aBuf = sqlite3_malloc(eocd.nSize); + if( aBuf==0 ){ + rc = SQLITE_NOMEM; + }else{ + rc = zipfileReadData( + pTab->pWriteFd, aBuf, eocd.nSize, eocd.iOffset, &pTab->base.zErrMsg + ); + } + + for(i=0; rc==SQLITE_OK && izPath = (char*)&pNew[1]; + memcpy(pNew->zPath, &aBuf[ZIPFILE_CDS_FIXED_SZ], nFile); + pNew->zPath[nFile] = '\0'; + pNew->aCdsEntry = (u8*)&pNew->zPath[nFile+1]; + pNew->nCdsEntry = ZIPFILE_CDS_FIXED_SZ+nFile+nExtra+nComment; + memcpy(pNew->aCdsEntry, aRec, pNew->nCdsEntry); + + pNew->pNext = pTab->pEntry; + pTab->pEntry = pNew; + } + + iOff += ZIPFILE_CDS_FIXED_SZ+nFile+nExtra+nComment; + } + + sqlite3_free(aBuf); + }else if( rc==SQLITE_EMPTY ){ + rc = SQLITE_OK; + } + + return rc; +} + +static ZipfileEntry *zipfileNewEntry( + ZipfileCDS *pCds, /* Values for fixed size part of CDS */ + const char *zPath, /* Path for new entry */ + int nPath, /* strlen(zPath) */ + u32 mTime /* Modification time (or 0) */ +){ + u8 *aWrite; + ZipfileEntry *pNew; + pCds->nFile = nPath; + pCds->nExtra = mTime ? 9 : 0; + pNew = (ZipfileEntry*)sqlite3_malloc( + sizeof(ZipfileEntry) + + nPath+1 + + ZIPFILE_CDS_FIXED_SZ + nPath + pCds->nExtra + ); + + if( pNew ){ + pNew->zPath = (char*)&pNew[1]; + pNew->aCdsEntry = (u8*)&pNew->zPath[nPath+1]; + pNew->nCdsEntry = ZIPFILE_CDS_FIXED_SZ + nPath + pCds->nExtra; + memcpy(pNew->zPath, zPath, nPath+1); + + aWrite = pNew->aCdsEntry; + zipfileWrite32(aWrite, ZIPFILE_SIGNATURE_CDS); + zipfileWrite16(aWrite, pCds->iVersionMadeBy); + zipfileWrite16(aWrite, pCds->iVersionExtract); + zipfileWrite16(aWrite, pCds->flags); + zipfileWrite16(aWrite, pCds->iCompression); + zipfileWrite16(aWrite, pCds->mTime); + zipfileWrite16(aWrite, pCds->mDate); + zipfileWrite32(aWrite, pCds->crc32); + zipfileWrite32(aWrite, pCds->szCompressed); + zipfileWrite32(aWrite, pCds->szUncompressed); + zipfileWrite16(aWrite, pCds->nFile); + zipfileWrite16(aWrite, pCds->nExtra); + zipfileWrite16(aWrite, pCds->nComment); assert( pCds->nComment==0 ); + zipfileWrite16(aWrite, pCds->iDiskStart); + zipfileWrite16(aWrite, pCds->iInternalAttr); + zipfileWrite32(aWrite, pCds->iExternalAttr); + zipfileWrite32(aWrite, pCds->iOffset); + assert( aWrite==&pNew->aCdsEntry[ZIPFILE_CDS_FIXED_SZ] ); + memcpy(aWrite, zPath, nPath); + if( pCds->nExtra ){ + aWrite += nPath; + zipfileWrite16(aWrite, ZIPFILE_EXTRA_TIMESTAMP); + zipfileWrite16(aWrite, 5); + *aWrite++ = 0x01; + zipfileWrite32(aWrite, mTime); + } + } + + return pNew; +} + +static int zipfileAppendEntry( + ZipfileTab *pTab, + ZipfileCDS *pCds, + const char *zPath, /* Path for new entry */ + int nPath, /* strlen(zPath) */ + const u8 *pData, + int nData, + u32 mTime +){ + u8 *aBuf = pTab->aBuffer; + int rc; + + zipfileWrite32(aBuf, ZIPFILE_SIGNATURE_LFH); + zipfileWrite16(aBuf, pCds->iVersionExtract); + zipfileWrite16(aBuf, pCds->flags); + zipfileWrite16(aBuf, pCds->iCompression); + zipfileWrite16(aBuf, pCds->mTime); + zipfileWrite16(aBuf, pCds->mDate); + zipfileWrite32(aBuf, pCds->crc32); + zipfileWrite32(aBuf, pCds->szCompressed); + zipfileWrite32(aBuf, pCds->szUncompressed); + zipfileWrite16(aBuf, nPath); + zipfileWrite16(aBuf, pCds->nExtra); + assert( aBuf==&pTab->aBuffer[ZIPFILE_LFH_FIXED_SZ] ); + rc = zipfileAppendData(pTab, pTab->aBuffer, aBuf - pTab->aBuffer); + if( rc==SQLITE_OK ){ + rc = zipfileAppendData(pTab, (const u8*)zPath, nPath); + } + + if( rc==SQLITE_OK && pCds->nExtra ){ + aBuf = pTab->aBuffer; + zipfileWrite16(aBuf, ZIPFILE_EXTRA_TIMESTAMP); + zipfileWrite16(aBuf, 5); + *aBuf++ = 0x01; + zipfileWrite32(aBuf, mTime); + rc = zipfileAppendData(pTab, pTab->aBuffer, 9); + } + + if( rc==SQLITE_OK ){ + rc = zipfileAppendData(pTab, pData, nData); + } + + return rc; +} + +static int zipfileGetMode(ZipfileTab *pTab, sqlite3_value *pVal, int *pMode){ + const char *z = (const char*)sqlite3_value_text(pVal); + int mode = 0; + if( z==0 || (z[0]>=0 && z[0]<=9) ){ + mode = sqlite3_value_int(pVal); + }else{ + const char zTemplate[10] = "-rwxrwxrwx"; + int i; + if( strlen(z)!=10 ) goto parse_error; + switch( z[0] ){ + case '-': mode |= S_IFREG; break; + case 'd': mode |= S_IFDIR; break; + case 'l': mode |= S_IFLNK; break; + default: goto parse_error; + } + for(i=1; i<10; i++){ + if( z[i]==zTemplate[i] ) mode |= 1 << (9-i); + else if( z[i]!='-' ) goto parse_error; + } + } + *pMode = mode; + return SQLITE_OK; + + parse_error: + pTab->base.zErrMsg = sqlite3_mprintf("zipfile: parse error in mode: %s", z); + return SQLITE_ERROR; +} + +/* +** xUpdate method. +*/ +static int zipfileUpdate( + sqlite3_vtab *pVtab, + int nVal, + sqlite3_value **apVal, + sqlite_int64 *pRowid +){ + ZipfileTab *pTab = (ZipfileTab*)pVtab; + int rc = SQLITE_OK; /* Return Code */ + ZipfileEntry *pNew = 0; /* New in-memory CDS entry */ + + int mode; /* Mode for new entry */ + i64 mTime; /* Modification time for new entry */ + i64 sz; /* Uncompressed size */ + const char *zPath; /* Path for new entry */ + int nPath; /* strlen(zPath) */ + const u8 *pData; /* Pointer to buffer containing content */ + int nData; /* Size of pData buffer in bytes */ + int iMethod = 0; /* Compression method for new entry */ + u8 *pFree = 0; /* Free this */ + ZipfileCDS cds; /* New Central Directory Structure entry */ + + if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){ + pTab->base.zErrMsg = sqlite3_mprintf( + "zipfile: UPDATE/DELETE not yet supported" + ); + return SQLITE_ERROR; + } + + /* This table is only writable if a default archive path was specified + ** as part of the CREATE VIRTUAL TABLE statement. */ + if( pTab->zFile==0 ){ + pTab->base.zErrMsg = sqlite3_mprintf( + "zipfile: writing requires a default archive" + ); + return SQLITE_ERROR; + } + + /* Open a write fd on the file. Also load the entire central directory + ** structure into memory. During the transaction any new file data is + ** appended to the archive file, but the central directory is accumulated + ** in main-memory until the transaction is committed. */ + if( pTab->pWriteFd==0 ){ + pTab->pWriteFd = fopen(pTab->zFile, "ab+"); + if( pTab->pWriteFd==0 ){ + pTab->base.zErrMsg = sqlite3_mprintf( + "zipfile: failed to open file %s for writing", pTab->zFile + ); + return SQLITE_ERROR; + } + fseek(pTab->pWriteFd, 0, SEEK_END); + pTab->szCurrent = pTab->szOrig = (i64)ftell(pTab->pWriteFd); + rc = zipfileLoadDirectory(pTab); + if( rc!=SQLITE_OK ) return rc; + } + + zPath = (const char*)sqlite3_value_text(apVal[2]); + nPath = strlen(zPath); + rc = zipfileGetMode(pTab, apVal[3], &mode); + if( rc!=SQLITE_OK ) return rc; + mTime = sqlite3_value_int64(apVal[4]); + sz = sqlite3_value_int(apVal[5]); + pData = sqlite3_value_blob(apVal[6]); + nData = sqlite3_value_bytes(apVal[6]); + + /* If a NULL value is inserted into the 'method' column, do automatic + ** compression. */ + if( nData>0 && sqlite3_value_type(apVal[7])==SQLITE_NULL ){ + pFree = (u8*)sqlite3_malloc(nData); + if( pFree==0 ){ + rc = SQLITE_NOMEM; + }else{ + int res; + z_stream str; + memset(&str, 0, sizeof(str)); + str.next_in = (z_const Bytef*)pData; + str.avail_in = nData; + str.next_out = pFree; + str.avail_out = nData; + deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY); + res = deflate(&str, Z_FINISH); + if( res==Z_STREAM_END ){ + pData = pFree; + nData = str.total_out; + iMethod = 8; + }else if( res!=Z_OK ){ + pTab->base.zErrMsg = sqlite3_mprintf("zipfile: deflate() error"); + rc = SQLITE_ERROR; + } + deflateEnd(&str); + } + }else{ + iMethod = sqlite3_value_int(apVal[7]); + if( iMethod<0 || iMethod>65535 ){ + pTab->base.zErrMsg = sqlite3_mprintf( + "zipfile: invalid compression method: %d", iMethod + ); + rc = SQLITE_ERROR; + } + } + + if( rc==SQLITE_OK ){ + /* Create the new CDS record. */ + memset(&cds, 0, sizeof(cds)); + cds.iVersionMadeBy = ZIPFILE_NEWENTRY_MADEBY; + cds.iVersionExtract = ZIPFILE_NEWENTRY_REQUIRED; + cds.flags = ZIPFILE_NEWENTRY_FLAGS; + cds.iCompression = iMethod; + zipfileMtimeToDos(&cds, (u32)mTime); + cds.crc32 = crc32(0, pData, nData); + cds.szCompressed = nData; + cds.szUncompressed = sz; + cds.iExternalAttr = (mode<<16); + cds.iOffset = pTab->szCurrent; + pNew = zipfileNewEntry(&cds, zPath, nPath, (u32)mTime); + if( pNew==0 ){ + rc = SQLITE_NOMEM; + }else{ + pNew->pNext = pTab->pEntry; + pTab->pEntry = pNew; + } + } + + /* Append the new header+file to the archive */ + if( rc==SQLITE_OK ){ + rc = zipfileAppendEntry(pTab, &cds, zPath, nPath, pData, nData, (u32)mTime); + } + + sqlite3_free(pFree); + return rc; +} + +static int zipfileAppendEOCD(ZipfileTab *pTab, ZipfileEOCD *p){ + u8 *aBuf = pTab->aBuffer; + + zipfileWrite32(aBuf, ZIPFILE_SIGNATURE_EOCD); + zipfileWrite16(aBuf, p->iDisk); + zipfileWrite16(aBuf, p->iFirstDisk); + zipfileWrite16(aBuf, p->nEntry); + zipfileWrite16(aBuf, p->nEntryTotal); + zipfileWrite32(aBuf, p->nSize); + zipfileWrite32(aBuf, p->iOffset); + zipfileWrite16(aBuf, 0); /* Size of trailing comment in bytes*/ + + assert( (aBuf-pTab->aBuffer)==22 ); + return zipfileAppendData(pTab, pTab->aBuffer, aBuf - pTab->aBuffer); +} + +static void zipfileCleanupTransaction(ZipfileTab *pTab){ + ZipfileEntry *pEntry; + ZipfileEntry *pNext; + + for(pEntry=pTab->pEntry; pEntry; pEntry=pNext){ + pNext = pEntry->pNext; + sqlite3_free(pEntry); + } + pTab->pEntry = 0; + fclose(pTab->pWriteFd); + pTab->pWriteFd = 0; + pTab->szCurrent = 0; + pTab->szOrig = 0; +} + +static int zipfileBegin(sqlite3_vtab *pVtab){ + return SQLITE_OK; +} + +static int zipfileCommit(sqlite3_vtab *pVtab){ + ZipfileTab *pTab = (ZipfileTab*)pVtab; + int rc = SQLITE_OK; + if( pTab->pWriteFd ){ + i64 iOffset = pTab->szCurrent; + ZipfileEntry *pEntry; + ZipfileEOCD eocd; + int nEntry = 0; + + /* Write out all entries */ + for(pEntry=pTab->pEntry; rc==SQLITE_OK && pEntry; pEntry=pEntry->pNext){ + rc = zipfileAppendData(pTab, pEntry->aCdsEntry, pEntry->nCdsEntry); + nEntry++; + } + + /* Write out the EOCD record */ + eocd.iDisk = 0; + eocd.iFirstDisk = 0; + eocd.nEntry = nEntry; + eocd.nEntryTotal = nEntry; + eocd.nSize = pTab->szCurrent - iOffset;; + eocd.iOffset = iOffset; + rc = zipfileAppendEOCD(pTab, &eocd); + + zipfileCleanupTransaction(pTab); + } + return rc; +} + +static int zipfileRollback(sqlite3_vtab *pVtab){ + return zipfileCommit(pVtab); +} + /* ** Register the "zipfile" virtual table. */ static int zipfileRegister(sqlite3 *db){ static sqlite3_module zipfileModule = { - 0, /* iVersion */ - 0, /* xCreate */ + 1, /* iVersion */ + zipfileConnect, /* xCreate */ zipfileConnect, /* xConnect */ zipfileBestIndex, /* xBestIndex */ zipfileDisconnect, /* xDisconnect */ - 0, /* xDestroy */ + zipfileDisconnect, /* xDestroy */ zipfileOpen, /* xOpen - open a cursor */ zipfileClose, /* xClose - close a cursor */ zipfileFilter, /* xFilter - configure scan constraints */ @@ -671,11 +1235,11 @@ static int zipfileRegister(sqlite3 *db){ zipfileEof, /* xEof - check for end of scan */ zipfileColumn, /* xColumn - read data */ zipfileRowid, /* xRowid - read data */ - 0, /* xUpdate */ - 0, /* xBegin */ + zipfileUpdate, /* xUpdate */ + zipfileBegin, /* xBegin */ 0, /* xSync */ - 0, /* xCommit */ - 0, /* xRollback */ + zipfileCommit, /* xCommit */ + zipfileRollback, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ }; @@ -687,8 +1251,6 @@ static int zipfileRegister(sqlite3 *db){ # define zipfileRegister(x) SQLITE_OK #endif -#include - /* ** zipfile_uncompress(DATA, SZ, METHOD) */ diff --git a/main.mk b/main.mk index ff379da861..9cdcc051e3 100644 --- a/main.mk +++ b/main.mk @@ -370,6 +370,7 @@ TESTSRC += \ $(TOP)/ext/misc/unionvtab.c \ $(TOP)/ext/misc/wholenumber.c \ $(TOP)/ext/misc/vfslog.c \ + $(TOP)/ext/misc/zipfile.c \ $(TOP)/ext/fts5/fts5_tcl.c \ $(TOP)/ext/fts5/fts5_test_mi.c \ $(TOP)/ext/fts5/fts5_test_tok.c diff --git a/manifest b/manifest index d6c9a543e5..c8433dc8ca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sthe\sshell\stool\s".ar\s--list\s--verbose"\scommand. -D 2017-12-27T21:13:21.423 +C Update\sext/misc/zipfile.c\sto\ssupport\screating\sand\sadding\sentries\sto\sexisting\nzip\sarchives. +D 2017-12-29T20:19:03.196 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in ceb40bfcb30ebba8e1202b34c56ff7e13e112f9809e2381d99be32c2726058f5 @@ -302,7 +302,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c ced1aa768904cf8182c3da93d42df4e3cf30fe7a2e66c9216f6bc64a8df4fd5b +F ext/misc/zipfile.c d9e0b0a4fdb4cb82ad22fd19d75563efdb1d6f812d62438bd30819781c282357 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -405,7 +405,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk fc13303745f7a06e2eac69406ee0e7ba481f6df37a528ceb6ebacc03e310a020 +F main.mk 9109d5786263a20fcf321a77c463d39c9ac84c871ea3774b0d213d8311dda105 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -492,7 +492,7 @@ F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6 F src/status.c 9737ed017279a9e0c5da748701c3c7bf1e8ae0dae459aad20dd64fcff97a7e35 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 F src/tclsqlite.c 1833388c01e3b77f4c712185ee7250b9423ee0981ce6ae7e401e47db0319a696 -F src/test1.c 8ef15f7a357f85dfc41c6c748ce9c947b4f676e01bb5ae6a45bee4923dff8b51 +F src/test1.c 1879ff5095def6091f83f54c6233bc19e2b7223068fb02da41f2396d55729764 F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6 @@ -1596,6 +1596,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e +F test/zipfile.test c5167d0d13ed7165b1982ac46b8aa94d65bdf41d94dd82f1d17ad2250650356c F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1692,7 +1693,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a532a0f6fd59e81086d46f09151ba7fb26725198231d902c71d0f95cb01dbe91 -R 7075030d907b0ffe212621eb709bb967 +P b64681a644c419bb98d00980a6cb56ef5a0aff5ef5321955631f0b4c88aac283 +R 407639481a191f472cd3497cc84b9ac5 U dan -Z 1c430e112380037cc2bfad44bf8be92e +Z a9a0bf4010ca982b681b075b8e4b53ca diff --git a/manifest.uuid b/manifest.uuid index aaba04f0ec..d0d83a4e81 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b64681a644c419bb98d00980a6cb56ef5a0aff5ef5321955631f0b4c88aac283 \ No newline at end of file +2dec2dec592c0726ebe87b841b9c8d493dea7074a99f278eb1bf0b744d658a9d \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index 446317d803..f9b3b69711 100644 --- a/src/test1.c +++ b/src/test1.c @@ -6960,6 +6960,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd( extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_unionvtab_init(sqlite3*,char**,const sqlite3_api_routines*); + extern int sqlite3_zipfile_init(sqlite3*,char**,const sqlite3_api_routines*); static const struct { const char *zExtName; int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*); @@ -6981,6 +6982,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd( { "totype", sqlite3_totype_init }, { "unionvtab", sqlite3_unionvtab_init }, { "wholenumber", sqlite3_wholenumber_init }, + { "zipfile", sqlite3_zipfile_init }, }; sqlite3 *db; const char *zName; diff --git a/test/zipfile.test b/test/zipfile.test new file mode 100644 index 0000000000..6c0ed4ba62 --- /dev/null +++ b/test/zipfile.test @@ -0,0 +1,60 @@ +# 2017 December 9 +# +# 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. +# +#*********************************************************************** +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix zipfile + +load_static_extension db zipfile + +forcedelete test.zip +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE temp.zz USING zipfile('test.zip'); + PRAGMA table_info(zz); +} { + 0 name {} 0 {} 0 + 1 mode {} 0 {} 0 + 2 mtime {} 0 {} 0 + 3 sz {} 0 {} 0 + 4 data {} 0 {} 0 + 5 method {} 0 {} 0 +} + +do_execsql_test 1.1 { + INSERT INTO zz VALUES('f.txt', '-rw-r--r--', 1000000000, 5, 'abcde', 0); + INSERT INTO zz VALUES('g.txt', '-rw-r--r--', 1000000002, 5, '12345', 0); +} + +do_execsql_test 1.2 { + SELECT name, mtime, data FROM zipfile('test.zip'); +} { + g.txt 1000000002 12345 + f.txt 1000000000 abcde +} + +do_execsql_test 1.3 { + INSERT INTO zz VALUES('h.txt', + '-rw-r--r--', 1000000004, 20, 'aaaaaaaaaabbbbbbbbbb', NULL + ); +} + +do_execsql_test 1.4 { + SELECT name, mtime, zipfile_uncompress(data, sz, method), method + FROM zipfile('test.zip'); +} { + h.txt 1000000004 aaaaaaaaaabbbbbbbbbb 8 + f.txt 1000000000 abcde 0 + g.txt 1000000002 12345 0 +} + +finish_test + From db0cb303ad93ed19e3f0cc3e20afb9b4fc7da22b Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 30 Dec 2017 14:26:29 +0000 Subject: [PATCH 024/190] Rearrange things a bit so that writing to a zipfile does not invert the order of objects it contains. FossilOrigin-Name: f69e8194bfa7de436c96028730ebd57f186d2e6207792e172e1aa38c7f4211c9 --- ext/misc/zipfile.c | 44 +++++++++++++++++++++++++++++++------------- manifest | 14 +++++++------- manifest.uuid | 2 +- test/zipfile.test | 4 ++-- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 5824965032..7c2a11b1ff 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -218,7 +218,7 @@ struct ZipfileCsr { ZipfileLFH lfh; /* Local File Header for current entry */ i64 iDataOff; /* Offset in zipfile to data */ u32 mTime; /* Extended mtime value */ - int flags; + int flags; /* Flags byte (see below for bits) */ }; /* @@ -229,9 +229,10 @@ struct ZipfileCsr { typedef struct ZipfileEntry ZipfileEntry; struct ZipfileEntry { char *zPath; /* Path of zipfile entry */ + i64 iRowid; /* Rowid for this value if queried */ u8 *aCdsEntry; /* Buffer containing entire CDS entry */ int nCdsEntry; /* Size of buffer aCdsEntry[] in bytes */ - ZipfileEntry *pNext; + ZipfileEntry *pNext; /* Next element in in-memory CDS */ }; typedef struct ZipfileTab ZipfileTab; @@ -241,7 +242,8 @@ struct ZipfileTab { u8 *aBuffer; /* Temporary buffer used for various tasks */ /* The following are used by write transactions only */ - ZipfileEntry *pEntry; /* Linked list of all files (if pWriteFd!=0) */ + ZipfileEntry *pFirstEntry; /* Linked list of all files (if pWriteFd!=0) */ + ZipfileEntry *pLastEntry; /* Last element in pFirstEntry list */ FILE *pWriteFd; /* File handle open on zip archive */ i64 szCurrent; /* Current size of zip archive */ i64 szOrig; /* Size of archive at start of transaction */ @@ -830,6 +832,22 @@ static int zipfileBestIndex( return SQLITE_OK; } +/* +** Add object pNew to the end of the linked list that begins at +** ZipfileTab.pFirstEntry and ends with pLastEntry. +*/ +static void zipfileAddEntry(ZipfileTab *pTab, ZipfileEntry *pNew){ + assert( (pTab->pFirstEntry==0)==(pTab->pLastEntry==0) ); + assert( pNew->pNext==0 ); + if( pTab->pFirstEntry==0 ){ + pTab->pFirstEntry = pTab->pLastEntry = pNew; + }else{ + assert( pTab->pLastEntry->pNext==0 ); + pTab->pLastEntry->pNext = pNew; + pTab->pLastEntry = pNew; + } +} + static int zipfileLoadDirectory(ZipfileTab *pTab){ ZipfileEOCD eocd; int rc; @@ -871,10 +889,9 @@ static int zipfileLoadDirectory(ZipfileTab *pTab){ pNew->zPath[nFile] = '\0'; pNew->aCdsEntry = (u8*)&pNew->zPath[nFile+1]; pNew->nCdsEntry = ZIPFILE_CDS_FIXED_SZ+nFile+nExtra+nComment; + pNew->pNext = 0; memcpy(pNew->aCdsEntry, aRec, pNew->nCdsEntry); - - pNew->pNext = pTab->pEntry; - pTab->pEntry = pNew; + zipfileAddEntry(pTab, pNew); } iOff += ZIPFILE_CDS_FIXED_SZ+nFile+nExtra+nComment; @@ -908,6 +925,7 @@ static ZipfileEntry *zipfileNewEntry( pNew->zPath = (char*)&pNew[1]; pNew->aCdsEntry = (u8*)&pNew->zPath[nPath+1]; pNew->nCdsEntry = ZIPFILE_CDS_FIXED_SZ + nPath + pCds->nExtra; + pNew->pNext = 0; memcpy(pNew->zPath, zPath, nPath+1); aWrite = pNew->aCdsEntry; @@ -1135,8 +1153,7 @@ static int zipfileUpdate( if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ - pNew->pNext = pTab->pEntry; - pTab->pEntry = pNew; + zipfileAddEntry(pTab, pNew); } } @@ -1169,11 +1186,12 @@ static void zipfileCleanupTransaction(ZipfileTab *pTab){ ZipfileEntry *pEntry; ZipfileEntry *pNext; - for(pEntry=pTab->pEntry; pEntry; pEntry=pNext){ + for(pEntry=pTab->pFirstEntry; pEntry; pEntry=pNext){ pNext = pEntry->pNext; sqlite3_free(pEntry); } - pTab->pEntry = 0; + pTab->pFirstEntry = 0; + pTab->pLastEntry = 0; fclose(pTab->pWriteFd); pTab->pWriteFd = 0; pTab->szCurrent = 0; @@ -1189,13 +1207,13 @@ static int zipfileCommit(sqlite3_vtab *pVtab){ int rc = SQLITE_OK; if( pTab->pWriteFd ){ i64 iOffset = pTab->szCurrent; - ZipfileEntry *pEntry; + ZipfileEntry *p; ZipfileEOCD eocd; int nEntry = 0; /* Write out all entries */ - for(pEntry=pTab->pEntry; rc==SQLITE_OK && pEntry; pEntry=pEntry->pNext){ - rc = zipfileAppendData(pTab, pEntry->aCdsEntry, pEntry->nCdsEntry); + for(p=pTab->pFirstEntry; rc==SQLITE_OK && p; p=p->pNext){ + rc = zipfileAppendData(pTab, p->aCdsEntry, p->nCdsEntry); nEntry++; } diff --git a/manifest b/manifest index c8433dc8ca..bc7687ee6e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sext/misc/zipfile.c\sto\ssupport\screating\sand\sadding\sentries\sto\sexisting\nzip\sarchives. -D 2017-12-29T20:19:03.196 +C Rearrange\sthings\sa\sbit\sso\sthat\swriting\sto\sa\szipfile\sdoes\snot\sinvert\sthe\sorder\nof\sobjects\sit\scontains. +D 2017-12-30T14:26:29.195 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in ceb40bfcb30ebba8e1202b34c56ff7e13e112f9809e2381d99be32c2726058f5 @@ -302,7 +302,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c d9e0b0a4fdb4cb82ad22fd19d75563efdb1d6f812d62438bd30819781c282357 +F ext/misc/zipfile.c cf093f797331e51fa6c0358698bc89d08a88d06cdf11484ee4ea9d079145289b F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1596,7 +1596,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e -F test/zipfile.test c5167d0d13ed7165b1982ac46b8aa94d65bdf41d94dd82f1d17ad2250650356c +F test/zipfile.test 63059e59024cacd01ba4c32a445cf75aac21393ff4460bddd1dc1ef4b78dd8bc F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1693,7 +1693,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b64681a644c419bb98d00980a6cb56ef5a0aff5ef5321955631f0b4c88aac283 -R 407639481a191f472cd3497cc84b9ac5 +P 2dec2dec592c0726ebe87b841b9c8d493dea7074a99f278eb1bf0b744d658a9d +R 64b99b9622049272ef5b18e73b616095 U dan -Z a9a0bf4010ca982b681b075b8e4b53ca +Z 6ef5282c9c40bbaf3432c6295db23abc diff --git a/manifest.uuid b/manifest.uuid index d0d83a4e81..f242346de1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2dec2dec592c0726ebe87b841b9c8d493dea7074a99f278eb1bf0b744d658a9d \ No newline at end of file +f69e8194bfa7de436c96028730ebd57f186d2e6207792e172e1aa38c7f4211c9 \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index 6c0ed4ba62..a0860f40bb 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -37,8 +37,8 @@ do_execsql_test 1.1 { do_execsql_test 1.2 { SELECT name, mtime, data FROM zipfile('test.zip'); } { - g.txt 1000000002 12345 f.txt 1000000000 abcde + g.txt 1000000002 12345 } do_execsql_test 1.3 { @@ -51,9 +51,9 @@ do_execsql_test 1.4 { SELECT name, mtime, zipfile_uncompress(data, sz, method), method FROM zipfile('test.zip'); } { - h.txt 1000000004 aaaaaaaaaabbbbbbbbbb 8 f.txt 1000000000 abcde 0 g.txt 1000000002 12345 0 + h.txt 1000000004 aaaaaaaaaabbbbbbbbbb 8 } finish_test From 0cde0c62b1e53c01d72a9a9227010e6afc4032dc Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 30 Dec 2017 18:32:27 +0000 Subject: [PATCH 025/190] Have zipfile support DELETE commands. FossilOrigin-Name: 01d4e866fb7b01aeada537d41c4a47747c7810e2028f51077ee5b8b78c348954 --- ext/misc/zipfile.c | 279 ++++++++++++++++++++++++++++----------------- manifest | 14 +-- manifest.uuid | 2 +- test/zipfile.test | 21 +++- 4 files changed, 202 insertions(+), 114 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 7c2a11b1ff..9d0865377d 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -201,40 +201,45 @@ struct ZipfileLFH { u16 nExtra; }; -/* -** Cursor type for recursively iterating through a directory structure. -*/ -typedef struct ZipfileCsr ZipfileCsr; - -struct ZipfileCsr { - sqlite3_vtab_cursor base; /* Base class - must be first */ - i64 iRowid; /* Rowid for current row */ - FILE *pFile; /* Zip file */ - i64 nByte; /* Size of zip file on disk */ - int bEof; /* True when at EOF */ - i64 iNextOff; /* Offset of next record in central directory */ - ZipfileEOCD eocd; /* Parse of central directory record */ - ZipfileCDS cds; /* Central Directory Structure */ - ZipfileLFH lfh; /* Local File Header for current entry */ - i64 iDataOff; /* Offset in zipfile to data */ - u32 mTime; /* Extended mtime value */ - int flags; /* Flags byte (see below for bits) */ -}; - -/* -** Values for ZipfileCsr.flags. -*/ -#define ZIPFILE_MTIME_VALID 0x0001 - typedef struct ZipfileEntry ZipfileEntry; struct ZipfileEntry { char *zPath; /* Path of zipfile entry */ i64 iRowid; /* Rowid for this value if queried */ u8 *aCdsEntry; /* Buffer containing entire CDS entry */ int nCdsEntry; /* Size of buffer aCdsEntry[] in bytes */ + int bDeleted; /* True if entry has been deleted */ ZipfileEntry *pNext; /* Next element in in-memory CDS */ }; +/* +** Cursor type for recursively iterating through a directory structure. +*/ +typedef struct ZipfileCsr ZipfileCsr; +struct ZipfileCsr { + sqlite3_vtab_cursor base; /* Base class - must be first */ + int bEof; /* True when at EOF */ + + /* Used outside of write transactions */ + FILE *pFile; /* Zip file */ + i64 iNextOff; /* Offset of next record in central directory */ + ZipfileEOCD eocd; /* Parse of central directory record */ + + /* Used inside write transactions */ + ZipfileEntry *pCurrent; + + ZipfileCDS cds; /* Central Directory Structure */ + ZipfileLFH lfh; /* Local File Header for current entry */ + i64 iDataOff; /* Offset in zipfile to data */ + u32 mTime; /* Extended mtime value */ + int flags; /* Flags byte (see below for bits) */ + ZipfileCsr *pCsrNext; /* Next cursor on same virtual table */ +}; + +/* +** Values for ZipfileCsr.flags. +*/ +#define ZIPFILE_MTIME_VALID 0x0001 + typedef struct ZipfileTab ZipfileTab; struct ZipfileTab { sqlite3_vtab base; /* Base class - must be first */ @@ -242,6 +247,7 @@ struct ZipfileTab { u8 *aBuffer; /* Temporary buffer used for various tasks */ /* The following are used by write transactions only */ + ZipfileCsr *pCsrList; /* List of cursors */ ZipfileEntry *pFirstEntry; /* Linked list of all files (if pWriteFd!=0) */ ZipfileEntry *pLastEntry; /* Last element in pFirstEntry list */ FILE *pWriteFd; /* File handle open on zip archive */ @@ -335,9 +341,16 @@ static int zipfileOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){ ** by zipfileOpen(). */ static void zipfileResetCursor(ZipfileCsr *pCsr){ + ZipfileTab *pTab = (ZipfileTab*)(pCsr->base.pVtab); + ZipfileCsr **pp; + + /* Remove this cursor from the ZipfileTab.pCsrList list. */ + for(pp=&pTab->pCsrList; *pp; pp=&((*pp)->pCsrNext)){ + if( *pp==pCsr ) *pp = pCsr->pCsrNext; + } + sqlite3_free(pCsr->cds.zFile); pCsr->cds.zFile = 0; - pCsr->iRowid = 0; pCsr->bEof = 0; if( pCsr->pFile ){ fclose(pCsr->pFile); @@ -438,18 +451,25 @@ static u8* zipfileCsrBuffer(ZipfileCsr *pCsr){ static int zipfileReadCDS(ZipfileCsr *pCsr){ char **pzErr = &pCsr->base.pVtab->zErrMsg; - u8 *aRead = zipfileCsrBuffer(pCsr); - int rc; + u8 *aRead; + int rc = SQLITE_OK; sqlite3_free(pCsr->cds.zFile); pCsr->cds.zFile = 0; - rc = zipfileReadData( - pCsr->pFile, aRead, ZIPFILE_CDS_FIXED_SZ, pCsr->iNextOff, pzErr - ); + if( pCsr->pCurrent==0 ){ + aRead = zipfileCsrBuffer(pCsr); + rc = zipfileReadData( + pCsr->pFile, aRead, ZIPFILE_CDS_FIXED_SZ, pCsr->iNextOff, pzErr + ); + }else{ + aRead = pCsr->pCurrent->aCdsEntry; + } + if( rc==SQLITE_OK ){ u32 sig = zipfileRead32(aRead); if( sig!=ZIPFILE_SIGNATURE_CDS ){ + assert( pCsr->pCurrent==0 ); zipfileSetErrmsg(pCsr,"failed to read CDS at offset %lld",pCsr->iNextOff); rc = SQLITE_ERROR; }else{ @@ -463,7 +483,9 @@ static int zipfileReadCDS(ZipfileCsr *pCsr){ pCsr->cds.crc32 = zipfileRead32(aRead); pCsr->cds.szCompressed = zipfileRead32(aRead); pCsr->cds.szUncompressed = zipfileRead32(aRead); - assert( aRead==zipfileCsrBuffer(pCsr)+ZIPFILE_CDS_NFILE_OFF ); + assert( pCsr->pCurrent + || aRead==zipfileCsrBuffer(pCsr)+ZIPFILE_CDS_NFILE_OFF + ); pCsr->cds.nFile = zipfileRead16(aRead); pCsr->cds.nExtra = zipfileRead16(aRead); pCsr->cds.nComment = zipfileRead16(aRead); @@ -471,13 +493,16 @@ static int zipfileReadCDS(ZipfileCsr *pCsr){ pCsr->cds.iInternalAttr = zipfileRead16(aRead); pCsr->cds.iExternalAttr = zipfileRead32(aRead); pCsr->cds.iOffset = zipfileRead32(aRead); + assert( pCsr->pCurrent + || aRead==zipfileCsrBuffer(pCsr)+ZIPFILE_CDS_FIXED_SZ + ); - assert( aRead==zipfileCsrBuffer(pCsr)+ZIPFILE_CDS_FIXED_SZ ); - - nRead = pCsr->cds.nFile + pCsr->cds.nExtra; - aRead = zipfileCsrBuffer(pCsr); - pCsr->iNextOff += ZIPFILE_CDS_FIXED_SZ; - rc = zipfileReadData(pCsr->pFile, aRead, nRead, pCsr->iNextOff, pzErr); + if( pCsr->pCurrent==0 ){ + nRead = pCsr->cds.nFile + pCsr->cds.nExtra; + aRead = zipfileCsrBuffer(pCsr); + pCsr->iNextOff += ZIPFILE_CDS_FIXED_SZ; + rc = zipfileReadData(pCsr->pFile, aRead, nRead, pCsr->iNextOff, pzErr); + } if( rc==SQLITE_OK ){ pCsr->cds.zFile = sqlite3_mprintf("%.*s", (int)pCsr->cds.nFile, aRead); @@ -522,13 +547,19 @@ static int zipfileReadCDS(ZipfileCsr *pCsr){ return rc; } +static FILE *zipfileGetFd(ZipfileCsr *pCsr){ + if( pCsr->pFile ) return pCsr->pFile; + return ((ZipfileTab*)(pCsr->base.pVtab))->pWriteFd; +} + static int zipfileReadLFH(ZipfileCsr *pCsr){ + FILE *pFile = zipfileGetFd(pCsr); char **pzErr = &pCsr->base.pVtab->zErrMsg; static const int szFix = ZIPFILE_LFH_FIXED_SZ; u8 *aRead = zipfileCsrBuffer(pCsr); int rc; - rc = zipfileReadData(pCsr->pFile, aRead, szFix, pCsr->cds.iOffset, pzErr); + rc = zipfileReadData(pFile, aRead, szFix, pCsr->cds.iOffset, pzErr); if( rc==SQLITE_OK ){ u32 sig = zipfileRead32(aRead); if( sig!=ZIPFILE_SIGNATURE_LFH ){ @@ -561,19 +592,31 @@ static int zipfileReadLFH(ZipfileCsr *pCsr){ */ static int zipfileNext(sqlite3_vtab_cursor *cur){ ZipfileCsr *pCsr = (ZipfileCsr*)cur; - i64 iEof = pCsr->eocd.iOffset + pCsr->eocd.nSize; int rc = SQLITE_OK; + pCsr->flags = 0; - if( pCsr->iNextOff>=iEof ){ - pCsr->bEof = 1; + if( pCsr->pCurrent==0 ){ + i64 iEof = pCsr->eocd.iOffset + pCsr->eocd.nSize; + if( pCsr->iNextOff>=iEof ){ + pCsr->bEof = 1; + } }else{ - pCsr->iRowid++; - pCsr->flags = 0; + assert( pCsr->pFile==0 ); + do { + pCsr->pCurrent = pCsr->pCurrent->pNext; + }while( pCsr->pCurrent && pCsr->pCurrent->bDeleted ); + if( pCsr->pCurrent==0 ){ + pCsr->bEof = 1; + } + } + + if( pCsr->bEof==0 ){ rc = zipfileReadCDS(pCsr); if( rc==SQLITE_OK ){ rc = zipfileReadLFH(pCsr); } } + return rc; } @@ -658,7 +701,8 @@ static int zipfileColumn( if( aBuf==0 ){ rc = SQLITE_NOMEM; }else{ - rc = zipfileReadData(pCsr->pFile, aBuf, sz, pCsr->iDataOff, + FILE *pFile = zipfileGetFd(pCsr); + rc = zipfileReadData(pFile, aBuf, sz, pCsr->iDataOff, &pCsr->base.pVtab->zErrMsg ); } @@ -678,13 +722,15 @@ static int zipfileColumn( } /* -** Return the rowid for the current row. In this implementation, the -** first row returned is assigned rowid value 1, and each subsequent -** row a value 1 more than that of the previous. +** Return the rowid for the current row. */ static int zipfileRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ ZipfileCsr *pCsr = (ZipfileCsr*)cur; - *pRowid = pCsr->iRowid; + if( pCsr->pCurrent ){ + *pRowid = pCsr->pCurrent->iRowid; + }else{ + *pRowid = pCsr->cds.iOffset; + } return SQLITE_OK; } @@ -771,32 +817,39 @@ static int zipfileFilter( zipfileResetCursor(pCsr); - assert( idxNum==argc && (idxNum==0 || idxNum==1) ); - if( idxNum==0 ){ - ZipfileTab *pTab = (ZipfileTab*)cur->pVtab; + if( pTab->zFile ){ zFile = pTab->zFile; - if( zFile==0 ){ - /* Error. This is an eponymous virtual table and the user has not - ** supplied a file name. */ - zipfileSetErrmsg(pCsr, "table function zipfile() requires an argument"); - return SQLITE_ERROR; - } + }else if( idxNum==0 ){ + /* Error. This is an eponymous virtual table and the user has not + ** supplied a file name. */ + zipfileSetErrmsg(pCsr, "table function zipfile() requires an argument"); + return SQLITE_ERROR; }else{ zFile = (const char*)sqlite3_value_text(argv[0]); } - pCsr->pFile = fopen(zFile, "rb"); - if( pCsr->pFile==0 ){ - zipfileSetErrmsg(pCsr, "cannot open file: %s", zFile); - rc = SQLITE_ERROR; - }else{ - rc = zipfileReadEOCD(pTab, pCsr->pFile, &pCsr->eocd); - if( rc==SQLITE_OK ){ - pCsr->iNextOff = pCsr->eocd.iOffset; - rc = zipfileNext(cur); - }else if( rc==SQLITE_EMPTY ){ - rc = SQLITE_OK; - pCsr->bEof = 1; + + if( pTab->pWriteFd==0 ){ + pCsr->pFile = fopen(zFile, "rb"); + if( pCsr->pFile==0 ){ + zipfileSetErrmsg(pCsr, "cannot open file: %s", zFile); + rc = SQLITE_ERROR; + }else{ + rc = zipfileReadEOCD(pTab, pCsr->pFile, &pCsr->eocd); + if( rc==SQLITE_OK ){ + pCsr->iNextOff = pCsr->eocd.iOffset; + rc = zipfileNext(cur); + }else if( rc==SQLITE_EMPTY ){ + rc = SQLITE_OK; + pCsr->bEof = 1; + } } + }else{ + ZipfileEntry e; + memset(&e, 0, sizeof(e)); + e.pNext = pTab->pFirstEntry; + pCsr->pCurrent = &e; + rc = zipfileNext(cur); + assert( pCsr->pCurrent!=&e ); } return rc; @@ -840,9 +893,11 @@ static void zipfileAddEntry(ZipfileTab *pTab, ZipfileEntry *pNew){ assert( (pTab->pFirstEntry==0)==(pTab->pLastEntry==0) ); assert( pNew->pNext==0 ); if( pTab->pFirstEntry==0 ){ + pNew->iRowid = 1; pTab->pFirstEntry = pTab->pLastEntry = pNew; }else{ assert( pTab->pLastEntry->pNext==0 ); + pNew->iRowid = pTab->pLastEntry->iRowid+1; pTab->pLastEntry->pNext = pNew; pTab->pLastEntry = pNew; } @@ -884,12 +939,12 @@ static int zipfileLoadDirectory(ZipfileTab *pTab){ if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ + memset(pNew, 0, sizeof(ZipfileEntry)); pNew->zPath = (char*)&pNew[1]; memcpy(pNew->zPath, &aBuf[ZIPFILE_CDS_FIXED_SZ], nFile); pNew->zPath[nFile] = '\0'; pNew->aCdsEntry = (u8*)&pNew->zPath[nFile+1]; pNew->nCdsEntry = ZIPFILE_CDS_FIXED_SZ+nFile+nExtra+nComment; - pNew->pNext = 0; memcpy(pNew->aCdsEntry, aRec, pNew->nCdsEntry); zipfileAddEntry(pTab, pNew); } @@ -922,10 +977,10 @@ static ZipfileEntry *zipfileNewEntry( ); if( pNew ){ + memset(pNew, 0, sizeof(ZipfileEntry)); pNew->zPath = (char*)&pNew[1]; pNew->aCdsEntry = (u8*)&pNew->zPath[nPath+1]; pNew->nCdsEntry = ZIPFILE_CDS_FIXED_SZ + nPath + pCds->nExtra; - pNew->pNext = 0; memcpy(pNew->zPath, zPath, nPath+1); aWrite = pNew->aCdsEntry; @@ -1057,38 +1112,19 @@ static int zipfileUpdate( u8 *pFree = 0; /* Free this */ ZipfileCDS cds; /* New Central Directory Structure entry */ + assert( pTab->zFile ); + assert( pTab->pWriteFd ); + if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){ - pTab->base.zErrMsg = sqlite3_mprintf( - "zipfile: UPDATE/DELETE not yet supported" - ); - return SQLITE_ERROR; - } - - /* This table is only writable if a default archive path was specified - ** as part of the CREATE VIRTUAL TABLE statement. */ - if( pTab->zFile==0 ){ - pTab->base.zErrMsg = sqlite3_mprintf( - "zipfile: writing requires a default archive" - ); - return SQLITE_ERROR; - } - - /* Open a write fd on the file. Also load the entire central directory - ** structure into memory. During the transaction any new file data is - ** appended to the archive file, but the central directory is accumulated - ** in main-memory until the transaction is committed. */ - if( pTab->pWriteFd==0 ){ - pTab->pWriteFd = fopen(pTab->zFile, "ab+"); - if( pTab->pWriteFd==0 ){ - pTab->base.zErrMsg = sqlite3_mprintf( - "zipfile: failed to open file %s for writing", pTab->zFile - ); - return SQLITE_ERROR; + i64 iDelete = sqlite3_value_int64(apVal[0]); + ZipfileEntry *p; + for(p=pTab->pFirstEntry; p; p=p->pNext){ + if( p->iRowid==iDelete ){ + p->bDeleted = 1; + break; + } } - fseek(pTab->pWriteFd, 0, SEEK_END); - pTab->szCurrent = pTab->szOrig = (i64)ftell(pTab->pWriteFd); - rc = zipfileLoadDirectory(pTab); - if( rc!=SQLITE_OK ) return rc; + if( nVal==1 ) return SQLITE_OK; } zPath = (const char*)sqlite3_value_text(apVal[2]); @@ -1199,7 +1235,41 @@ static void zipfileCleanupTransaction(ZipfileTab *pTab){ } static int zipfileBegin(sqlite3_vtab *pVtab){ - return SQLITE_OK; + ZipfileTab *pTab = (ZipfileTab*)pVtab; + int rc = SQLITE_OK; + + assert( pTab->pWriteFd==0 ); + + /* This table is only writable if a default archive path was specified + ** as part of the CREATE VIRTUAL TABLE statement. */ + if( pTab->zFile==0 ){ + pTab->base.zErrMsg = sqlite3_mprintf( + "zipfile: writing requires a default archive" + ); + return SQLITE_ERROR; + } + + /* Open a write fd on the file. Also load the entire central directory + ** structure into memory. During the transaction any new file data is + ** appended to the archive file, but the central directory is accumulated + ** in main-memory until the transaction is committed. */ + pTab->pWriteFd = fopen(pTab->zFile, "ab+"); + if( pTab->pWriteFd==0 ){ + pTab->base.zErrMsg = sqlite3_mprintf( + "zipfile: failed to open file %s for writing", pTab->zFile + ); + rc = SQLITE_ERROR; + }else{ + fseek(pTab->pWriteFd, 0, SEEK_END); + pTab->szCurrent = pTab->szOrig = (i64)ftell(pTab->pWriteFd); + rc = zipfileLoadDirectory(pTab); + } + + if( rc!=SQLITE_OK ){ + zipfileCleanupTransaction(pTab); + } + + return rc; } static int zipfileCommit(sqlite3_vtab *pVtab){ @@ -1211,8 +1281,9 @@ static int zipfileCommit(sqlite3_vtab *pVtab){ ZipfileEOCD eocd; int nEntry = 0; - /* Write out all entries */ + /* Write out all undeleted entries */ for(p=pTab->pFirstEntry; rc==SQLITE_OK && p; p=p->pNext){ + if( p->bDeleted ) continue; rc = zipfileAppendData(pTab, p->aCdsEntry, p->nCdsEntry); nEntry++; } diff --git a/manifest b/manifest index bc7687ee6e..6a47f6372c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rearrange\sthings\sa\sbit\sso\sthat\swriting\sto\sa\szipfile\sdoes\snot\sinvert\sthe\sorder\nof\sobjects\sit\scontains. -D 2017-12-30T14:26:29.195 +C Have\szipfile\ssupport\sDELETE\scommands. +D 2017-12-30T18:32:27.545 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in ceb40bfcb30ebba8e1202b34c56ff7e13e112f9809e2381d99be32c2726058f5 @@ -302,7 +302,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c cf093f797331e51fa6c0358698bc89d08a88d06cdf11484ee4ea9d079145289b +F ext/misc/zipfile.c 2df8f94003903fe3cc104b807418c54e68040964d4319c522ac2f485152f5abd F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1596,7 +1596,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e -F test/zipfile.test 63059e59024cacd01ba4c32a445cf75aac21393ff4460bddd1dc1ef4b78dd8bc +F test/zipfile.test d4f342ca918fd4d7981a12c1523f5041074cc592f25fecce4ee11446cc984f56 F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1693,7 +1693,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2dec2dec592c0726ebe87b841b9c8d493dea7074a99f278eb1bf0b744d658a9d -R 64b99b9622049272ef5b18e73b616095 +P f69e8194bfa7de436c96028730ebd57f186d2e6207792e172e1aa38c7f4211c9 +R 145246df93a24ee9820cce32c6b5afb4 U dan -Z 6ef5282c9c40bbaf3432c6295db23abc +Z 640cac8c8ac89e53412f930b0b057c7a diff --git a/manifest.uuid b/manifest.uuid index f242346de1..bc6078e242 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f69e8194bfa7de436c96028730ebd57f186d2e6207792e172e1aa38c7f4211c9 \ No newline at end of file +01d4e866fb7b01aeada537d41c4a47747c7810e2028f51077ee5b8b78c348954 \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index a0860f40bb..3f7b34d55d 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -29,13 +29,15 @@ do_execsql_test 1.0 { 5 method {} 0 {} 0 } -do_execsql_test 1.1 { +do_execsql_test 1.1.1 { INSERT INTO zz VALUES('f.txt', '-rw-r--r--', 1000000000, 5, 'abcde', 0); +} +do_execsql_test 1.1.2 { INSERT INTO zz VALUES('g.txt', '-rw-r--r--', 1000000002, 5, '12345', 0); } do_execsql_test 1.2 { - SELECT name, mtime, data FROM zipfile('test.zip'); + SELECT name, mtime, data FROM zipfile('test.zip') } { f.txt 1000000000 abcde g.txt 1000000002 12345 @@ -56,5 +58,20 @@ do_execsql_test 1.4 { h.txt 1000000004 aaaaaaaaaabbbbbbbbbb 8 } +do_execsql_test 1.5.1 { + BEGIN; + INSERT INTO zz VALUES('i.txt', '-rw-r--r--', 1000000006, 5, 'zxcvb', 0); + SELECT name FROM zz; + COMMIT; +} {f.txt g.txt h.txt i.txt} +do_execsql_test 1.5.2 { + SELECT name FROM zz; +} {f.txt g.txt h.txt i.txt} + +do_execsql_test 1.6.0 { + DELETE FROM zz WHERE name='g.txt'; + SELECT name FROM zz; +} {f.txt h.txt i.txt} + finish_test From 9eb8dbad4d09d3f65444f667f92d7ad38739e178 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 3 Jan 2018 01:47:30 +0000 Subject: [PATCH 026/190] Add another test case (found by OSSFuzz) for the problem fixed in check-in [2846458a] and described by ticket [dc3f932f5a147771]. No changes to code. FossilOrigin-Name: 4165fae920a1176c68bfaa1f2cfe17df7f8dd8793519d458b71e3e63670b5495 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/indexexpr1.test | 12 ++++++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 774549626b..ab818a843a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scode\sindentation.\s\sNo\slogic\schanges. -D 2018-01-02T21:29:42.540 +C Add\sanother\stest\scase\s(found\sby\sOSSFuzz)\sfor\sthe\sproblem\sfixed\sin\s\ncheck-in\s[2846458a]\sand\sdescribed\sby\sticket\s[dc3f932f5a147771].\nNo\schanges\sto\scode. +D 2018-01-03T01:47:30.287 F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc f68b4f9b83cfeb057b6265e0288ad653f319e2ceacca731e0f22e19617829a89 @@ -969,7 +969,7 @@ F test/index7.test 7feababe16f2091b229c22aff2bcc1d4d6b9d2bb F test/index8.test bc2e3db70e8e62459aaa1bd7e4a9b39664f8f9d7 F test/index9.test 0aa3e509dddf81f93380396e40e9bb386904c1054924ba8fa9bcdfe85a8e7721 F test/indexedby.test faa585e315e868f09bce0eb39c41d6134649b13d2801638294d3ae616edf1609 -F test/indexexpr1.test 60e2d6f1d1337fd213208270295c650d268503ff215de728f540ea31eb237f70 +F test/indexexpr1.test ace1ad489adc25325ad298434f13b1a515b36bf5dca9fe2a4b66cdf17aea3fa0 F test/indexexpr2.test 13247bac49143196556eb3f65e97ef301bd3e993f4511558b5db322ddc370ea6 F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 @@ -1688,7 +1688,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2846458af5d029a8e4fdcc8f50873a44e57897bbfe6aee8a23a01ffc34c5579f -R 9613ba300b7bd9cce413f2672960fb05 +P e115f2583499df0c7ee991d372bed4b89aa717b10a4e4b10977864390cb4fc11 +R 83a0b36c500269c331a5b5ebe1ebb55e U drh -Z 9fca118926b581510cc96e0ce3702687 +Z 192675b51835fbb18bda08bad08dd763 diff --git a/manifest.uuid b/manifest.uuid index 4bf24d86c2..01fb7976a7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e115f2583499df0c7ee991d372bed4b89aa717b10a4e4b10977864390cb4fc11 \ No newline at end of file +4165fae920a1176c68bfaa1f2cfe17df7f8dd8793519d458b71e3e63670b5495 \ No newline at end of file diff --git a/test/indexexpr1.test b/test/indexexpr1.test index 1caa3086be..28c23b9089 100644 --- a/test/indexexpr1.test +++ b/test/indexexpr1.test @@ -413,4 +413,16 @@ do_execsql_test indexexpr1-1500 { SELECT * FROM t1500; } {1 3} +# 2018-01-03 OSSFuzz discovers another test case for the same problem +# above. +# +do_execsql_test indexexpr-1510 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(a PRIMARY KEY,b UNIQUE); + REPLACE INTO t1 VALUES(2, 1); + REPLACE INTO t1 SELECT 6,1; + CREATE INDEX t1aa ON t1(a-a); + REPLACE INTO t1 SELECT a, randomblob(a) FROM t1 +} {} + finish_test From 64c1990c0044718bd3c11d238eb5be3eef48a4d8 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 4 Jan 2018 16:40:44 +0000 Subject: [PATCH 027/190] Fix a broken documentation hyperlink. No code changes. FossilOrigin-Name: d91e3f3d343d281af374dd23eea333e61228539023ad5c5aea622085e5863bc7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index ab818a843a..d48a41447d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sanother\stest\scase\s(found\sby\sOSSFuzz)\sfor\sthe\sproblem\sfixed\sin\s\ncheck-in\s[2846458a]\sand\sdescribed\sby\sticket\s[dc3f932f5a147771].\nNo\schanges\sto\scode. -D 2018-01-03T01:47:30.287 +C Fix\sa\sbroken\sdocumentation\shyperlink.\s\sNo\scode\schanges. +D 2018-01-04T16:40:44.063 F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc f68b4f9b83cfeb057b6265e0288ad653f319e2ceacca731e0f22e19617829a89 @@ -480,7 +480,7 @@ F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 F src/shell.c.in a418ddceef7a2789f18bdc2bcdd481b2562fe4a7754b8009c8dd33d5a67da332 -F src/sqlite.h.in c597ba5d11666bb2d0179a173cd25e44f0b0333f9e18ce60b07eac8bdc3de67f +F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 F src/sqliteInt.h fd8702c65994d7de3e2d8f7d85d958731da1ed29476571fdfa2290fd8ec0bf80 @@ -1688,7 +1688,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e115f2583499df0c7ee991d372bed4b89aa717b10a4e4b10977864390cb4fc11 -R 83a0b36c500269c331a5b5ebe1ebb55e +P 4165fae920a1176c68bfaa1f2cfe17df7f8dd8793519d458b71e3e63670b5495 +R d66f50893f4ffe9e2cfb6738dd929b34 U drh -Z 192675b51835fbb18bda08bad08dd763 +Z 6dbec8e8e1444dbd0ed402b28d5f012a diff --git a/manifest.uuid b/manifest.uuid index 01fb7976a7..66b07243fd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4165fae920a1176c68bfaa1f2cfe17df7f8dd8793519d458b71e3e63670b5495 \ No newline at end of file +d91e3f3d343d281af374dd23eea333e61228539023ad5c5aea622085e5863bc7 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index a6d328360a..f63b029312 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -8301,7 +8301,7 @@ int sqlite3_vtab_on_conflict(sqlite3 *); ** CAPI3REF: Determine The Collation For a Virtual Table Constraint ** ** This function may only be called from within a call to the [xBestIndex] -** method of a [virtual table implementation]. +** method of a [virtual table]. ** ** The first argument must be the sqlite3_index_info object that is the ** first parameter to the xBestIndex() method. The second argument must be From 35100fb194cfbaf75b31b504e7bf7d4480900c26 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 4 Jan 2018 19:20:37 +0000 Subject: [PATCH 028/190] Remove the snarky "_supported_" qualifier from the name of the sqlite_offset() SQL function. FossilOrigin-Name: a6eee0fcd89d3958f8720ebdb5f0a8558b4795d747128091dae283eb81c4f74f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/func.c | 3 +-- test/func6.test | 40 ++++++++++++++++++++-------------------- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index d48a41447d..3552e5e8ce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbroken\sdocumentation\shyperlink.\s\sNo\scode\schanges. -D 2018-01-04T16:40:44.063 +C Remove\sthe\ssnarky\s"_supported_"\squalifier\sfrom\sthe\sname\sof\sthe\nsqlite_offset()\sSQL\sfunction. +D 2018-01-04T19:20:37.203 F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc f68b4f9b83cfeb057b6265e0288ad653f319e2ceacca731e0f22e19617829a89 @@ -434,7 +434,7 @@ F src/delete.c 74667ad914ac143731a444a1bacf29ceb18f6eded8a0dd17aafae80baa07f8bb F src/expr.c ad6e7a9c34a4bab9d10cc857d647ae7ce370a633b5c0bfa71f1c29b81ae364b8 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c d617daf66b5515e2b42c1405b2b4984c30ca50fb705ab164271a9bf66c69e331 -F src/func.c 697a3ee3b8c8481db497226e9e71935727d6a9fb3d3cc049e82a1c717a0a8342 +F src/func.c bd528d5ed68ce5cbf78a762e3b735fa75009f7197ff07fab07fd771f35ebaa1b F src/global.c ac3094f1dc59fbeb919aef7cc0cc827a8459d1fb1adb7972ef75bd9e0c10b75b F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 @@ -917,7 +917,7 @@ F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test d202a7606d23f90988a664e88e268aed1087c11c F test/func4.test 6beacdfcb0e18c358e6c2dcacf1b65d1fa80955f F test/func5.test cdd224400bc3e48d891827cc913a57051a426fa4 -F test/func6.test 1a2bc511fedb779e2bd3154361385216c6d35080f36bfe896b8cdd1b1954294a +F test/func6.test a4281c8fcd42b56f7a60f28e8e4d444e8b2256f9e82658b7ab87699f8318f564 F test/fuzz-oss1.test e58330d01cbbd8215ee636b17a03fe220b37dbfa F test/fuzz.test 96083052bf5765e4518c1ba686ce2bab785670d1 F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1 @@ -1688,7 +1688,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4165fae920a1176c68bfaa1f2cfe17df7f8dd8793519d458b71e3e63670b5495 -R d66f50893f4ffe9e2cfb6738dd929b34 +P d91e3f3d343d281af374dd23eea333e61228539023ad5c5aea622085e5863bc7 +R 314fe8cfc8ec7f02f3acb6e4d50707fb U drh -Z 6dbec8e8e1444dbd0ed402b28d5f012a +Z 7ea7a34ef1d7c0cfd34c8e9e5f226383 diff --git a/manifest.uuid b/manifest.uuid index 66b07243fd..561f8b3f92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d91e3f3d343d281af374dd23eea333e61228539023ad5c5aea622085e5863bc7 \ No newline at end of file +a6eee0fcd89d3958f8720ebdb5f0a8558b4795d747128091dae283eb81c4f74f \ No newline at end of file diff --git a/src/func.c b/src/func.c index 4758b0191d..1076b97161 100644 --- a/src/func.c +++ b/src/func.c @@ -1800,8 +1800,7 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION2(affinity, 1, 0, 0, noopFunc, SQLITE_FUNC_AFFINITY), #endif #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC - FUNCTION2(sqlite_unsupported_offset, - 1, 0, 0, noopFunc, SQLITE_FUNC_OFFSET| + FUNCTION2(sqlite_offset, 1, 0, 0, noopFunc, SQLITE_FUNC_OFFSET| SQLITE_FUNC_TYPEOF), #endif FUNCTION(ltrim, 1, 1, 0, trimFunc ), diff --git a/test/func6.test b/test/func6.test index 0d3de8ef49..02e1998cd0 100644 --- a/test/func6.test +++ b/test/func6.test @@ -9,7 +9,7 @@ # #************************************************************************* # -# Test cases for the sqlite_unsupported_offset() function. +# Test cases for the sqlite_offset() function. # # Some of the tests in this file depend on the exact placement of content # within b-tree pages. Such placement is at the implementations discretion, @@ -34,51 +34,51 @@ do_execsql_test func6-100 { INSERT INTO t2(x,y) SELECT a, b FROM t1; } do_execsql_test func6-110 { - SELECT a, sqlite_unsupported_offset(d)/4096 + 1, - sqlite_unsupported_offset(d)%4096 FROM t1 + SELECT a, sqlite_offset(d)/4096 + 1, + sqlite_offset(d)%4096 FROM t1 ORDER BY rowid LIMIT 2; } {abc001 2 4084 abc002 2 4069} do_execsql_test func6-120 { - SELECT a, typeof(sqlite_unsupported_offset(+a)) FROM t1 + SELECT a, typeof(sqlite_offset(+a)) FROM t1 ORDER BY rowid LIMIT 2; } {abc001 null abc002 null} do_execsql_test func6-130 { - SELECT a, sqlite_unsupported_offset(a)/4096+1, - sqlite_unsupported_offset(a)%4096 + SELECT a, sqlite_offset(a)/4096+1, + sqlite_offset(a)%4096 FROM t1 ORDER BY a LIMIT 2; } {abc001 3 4087 abc002 3 4076} do_execsql_test func6-140 { - SELECT a, sqlite_unsupported_offset(d)/4096+1, - sqlite_unsupported_offset(d)%4096 + SELECT a, sqlite_offset(d)/4096+1, + sqlite_offset(d)%4096 FROM t1 ORDER BY a LIMIT 2; } {abc001 2 4084 abc002 2 4069} do_execsql_test func6-150 { SELECT a, - sqlite_unsupported_offset(a)/4096+1, - sqlite_unsupported_offset(a)%4096, - sqlite_unsupported_offset(d)/4096+1, - sqlite_unsupported_offset(d)%4096 + sqlite_offset(a)/4096+1, + sqlite_offset(a)%4096, + sqlite_offset(d)/4096+1, + sqlite_offset(d)%4096 FROM t1 ORDER BY a LIMIT 2; } {abc001 3 4087 2 4084 abc002 3 4076 2 4069} do_execsql_test func6-160 { SELECT b, - sqlite_unsupported_offset(b)/4096+1, - sqlite_unsupported_offset(b)%4096, - sqlite_unsupported_offset(c)/4096+1, - sqlite_unsupported_offset(c)%4096, - sqlite_unsupported_offset(d)/4096+1, - sqlite_unsupported_offset(d)%4096 + sqlite_offset(b)/4096+1, + sqlite_offset(b)%4096, + sqlite_offset(c)/4096+1, + sqlite_offset(c)%4096, + sqlite_offset(d)/4096+1, + sqlite_offset(d)%4096 FROM t1 ORDER BY b LIMIT 2; } {1 4 4090 4 4090 2 4084 2 4 4081 4 4081 2 4069} do_execsql_test func6-200 { - SELECT y, sqlite_unsupported_offset(y)/4096+1, - sqlite_unsupported_offset(y)%4096 + SELECT y, sqlite_offset(y)/4096+1, + sqlite_offset(y)%4096 FROM t2 ORDER BY x LIMIT 2; } {1 5 4087 2 5 4076} From dfdfd8c7f24dc5499019e5ed70f3e26a6118f837 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 4 Jan 2018 22:46:08 +0000 Subject: [PATCH 029/190] Get the shell enhancements compiling with MSVC. FossilOrigin-Name: 335387f9e0d4569097d34cd99cd332b38a282e9b7ae25f088eb47df5c25837ef --- Makefile.msc | 9 +++++-- ext/misc/fileio.c | 49 +++++++++++++++++++++++++++++++++---- ext/misc/zipfile.c | 58 ++++++++++++++++++++++++++------------------ manifest | 24 +++++++++--------- manifest.uuid | 2 +- src/shell.c.in | 10 ++++++-- src/test_windirent.h | 48 +++++++++++++++++++++++++++++++++--- test/shell8.test | 6 ++++- 8 files changed, 157 insertions(+), 49 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 5a479efb16..4fb128c567 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1506,7 +1506,8 @@ TESTEXT = \ $(TOP)\ext\misc\spellfix.c \ $(TOP)\ext\misc\totype.c \ $(TOP)\ext\misc\unionvtab.c \ - $(TOP)\ext\misc\wholenumber.c + $(TOP)\ext\misc\wholenumber.c \ + $(TOP)\ext\misc\zipfile.c # Source code to the library files needed by the test fixture # (non-amalgamation) @@ -2069,7 +2070,11 @@ SHELL_SRC = \ $(TOP)\src\shell.c.in \ $(TOP)\ext\misc\shathree.c \ $(TOP)\ext\misc\fileio.c \ - $(TOP)\ext\misc\completion.c + $(TOP)\ext\misc\completion.c \ + $(TOP)\ext\misc\sqlar.c \ + $(TOP)\ext\expert\sqlite3expert.c \ + $(TOP)\ext\expert\sqlite3expert.h \ + $(TOP)\ext\misc\zipfile.c shell.c: $(SHELL_SRC) $(TOP)\tool\mkshellc.tcl $(TCLSH_CMD) $(TOP)\tool\mkshellc.tcl > shell.c diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 7dbac4043f..2464d18f80 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -82,10 +82,21 @@ SQLITE_EXTENSION_INIT1 #include #include #include -#include -#include +#if !defined(_WIN32) && !defined(WIN32) +# include +# include +# include +#else +# include "windows.h" +# include +# include +# include "test_windirent.h" +# define dirent DIRENT +# define timespec TIMESPEC +# define mkdir(path,mode) _mkdir(path) +# define lstat(path,buf) _stat(path,buf) +#endif #include -#include #include @@ -203,10 +214,13 @@ static int writeFile( mode_t mode, /* MODE parameter passed to writefile() */ sqlite3_int64 mtime /* MTIME parameter (or -1 to not set time) */ ){ +#if !defined(_WIN32) && !defined(WIN32) if( S_ISLNK(mode) ){ const char *zTo = (const char*)sqlite3_value_text(pData); if( symlink(zTo, zFile)<0 ) return 1; - }else{ + }else +#endif + { if( S_ISDIR(mode) ){ if( mkdir(zFile, mode) ){ /* The mkdir() call to create the directory failed. This might not @@ -246,6 +260,7 @@ static int writeFile( } if( mtime>=0 ){ +#if !defined(_WIN32) && !defined(WIN32) struct timespec times[2]; times[0].tv_nsec = times[1].tv_nsec = 0; times[0].tv_sec = time(0); @@ -253,6 +268,28 @@ static int writeFile( if( utimensat(AT_FDCWD, zFile, times, AT_SYMLINK_NOFOLLOW) ){ return 1; } +#else + FILETIME lastAccess; + FILETIME lastWrite; + SYSTEMTIME currentTime; + LONGLONG intervals; + HANDLE hFile; + GetSystemTime(¤tTime); + SystemTimeToFileTime(¤tTime, &lastAccess); + intervals = Int32x32To64(mtime, 10000000) + 116444736000000000; + lastWrite.dwLowDateTime = (DWORD)intervals; + lastWrite.dwHighDateTime = intervals >> 32; + hFile = CreateFile( + zFile, FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, 0, NULL + ); + if( hFile!=INVALID_HANDLE_VALUE ){ + BOOL bResult = SetFileTime(hFile, NULL, &lastAccess, &lastWrite); + CloseHandle(hFile); + return !bResult; + }else{ + return 1; + } +#endif } return 0; @@ -282,7 +319,7 @@ static void writefileFunc( zFile = (const char*)sqlite3_value_text(argv[0]); if( zFile==0 ) return; if( argc>=3 ){ - mode = sqlite3_value_int(argv[2]); + mode = (mode_t)sqlite3_value_int(argv[2]); } if( argc==4 ){ mtime = sqlite3_value_int64(argv[3]); @@ -518,6 +555,7 @@ static int fsdirColumn( mode_t m = pCur->sStat.st_mode; if( S_ISDIR(m) ){ sqlite3_result_null(ctx); +#if !defined(_WIN32) && !defined(WIN32) }else if( S_ISLNK(m) ){ char aStatic[64]; char *aBuf = aStatic; @@ -538,6 +576,7 @@ static int fsdirColumn( sqlite3_result_text(ctx, aBuf, n, SQLITE_TRANSIENT); if( aBuf!=aStatic ) sqlite3_free(aBuf); +#endif }else{ readFileContents(ctx, pCur->zPath); } diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 9d0865377d..c3dc5f2d3e 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -20,10 +20,14 @@ SQLITE_EXTENSION_INIT1 #include #include #include -#include -#include +#if !defined(_WIN32) && !defined(WIN32) +# include +# include +# include +#else +# include +#endif #include -#include #include #include @@ -387,9 +391,9 @@ static int zipfileReadData( char **pzErrmsg /* OUT: Error message (from sqlite3_malloc) */ ){ size_t n; - fseek(pFile, iOff, SEEK_SET); + fseek(pFile, (long)iOff, SEEK_SET); n = fread(aRead, 1, nRead, pFile); - if( n!=nRead ){ + if( (int)n!=nRead ){ *pzErrmsg = sqlite3_mprintf("error in fread()"); return SQLITE_ERROR; } @@ -402,9 +406,9 @@ static int zipfileAppendData( int nWrite ){ size_t n; - fseek(pTab->pWriteFd, pTab->szCurrent, SEEK_SET); + fseek(pTab->pWriteFd, (long)pTab->szCurrent, SEEK_SET); n = fwrite(aWrite, 1, nWrite, pTab->pWriteFd); - if( n!=nWrite ){ + if( (int)n!=nWrite ){ pTab->base.zErrMsg = sqlite3_mprintf("error in fwrite()"); return SQLITE_ERROR; } @@ -649,17 +653,22 @@ static time_t zipfileMtime(ZipfileCsr *pCsr){ static void zipfileMtimeToDos(ZipfileCDS *pCds, u32 mTime){ time_t t = (time_t)mTime; struct tm res; - localtime_r(&t, &res); - pCds->mTime = +#if !defined(_WIN32) && !defined(WIN32) + localtime_r(&t, &res); +#else + memcpy(&res, localtime(&t), sizeof(struct tm)); +#endif + + pCds->mTime = (u16)( (res.tm_sec / 2) + (res.tm_min << 5) + - (res.tm_hour << 11); + (res.tm_hour << 11)); - pCds->mDate = + pCds->mDate = (u16)( (res.tm_mday-1) + ((res.tm_mon+1) << 5) + - ((res.tm_year-80) << 9); + ((res.tm_year-80) << 9)); } /* @@ -754,6 +763,7 @@ static int zipfileReadEOCD( i64 szFile; /* Total size of file in bytes */ int nRead; /* Bytes to read from file */ i64 iOff; /* Offset to read from */ + int rc; fseek(pFile, 0, SEEK_END); szFile = (i64)ftell(pFile); @@ -763,7 +773,7 @@ static int zipfileReadEOCD( nRead = (int)(MIN(szFile, ZIPFILE_BUFFER_SIZE)); iOff = szFile - nRead; - int rc = zipfileReadData(pFile, aRead, nRead, iOff, &pTab->base.zErrMsg); + rc = zipfileReadData(pFile, aRead, nRead, iOff, &pTab->base.zErrMsg); if( rc==SQLITE_OK ){ int i; @@ -968,7 +978,7 @@ static ZipfileEntry *zipfileNewEntry( ){ u8 *aWrite; ZipfileEntry *pNew; - pCds->nFile = nPath; + pCds->nFile = (u16)nPath; pCds->nExtra = mTime ? 9 : 0; pNew = (ZipfileEntry*)sqlite3_malloc( sizeof(ZipfileEntry) + @@ -1036,7 +1046,7 @@ static int zipfileAppendEntry( zipfileWrite32(aBuf, pCds->crc32); zipfileWrite32(aBuf, pCds->szCompressed); zipfileWrite32(aBuf, pCds->szUncompressed); - zipfileWrite16(aBuf, nPath); + zipfileWrite16(aBuf, (u16)nPath); zipfileWrite16(aBuf, pCds->nExtra); assert( aBuf==&pTab->aBuffer[ZIPFILE_LFH_FIXED_SZ] ); rc = zipfileAppendData(pTab, pTab->aBuffer, aBuf - pTab->aBuffer); @@ -1066,13 +1076,15 @@ static int zipfileGetMode(ZipfileTab *pTab, sqlite3_value *pVal, int *pMode){ if( z==0 || (z[0]>=0 && z[0]<=9) ){ mode = sqlite3_value_int(pVal); }else{ - const char zTemplate[10] = "-rwxrwxrwx"; + const char zTemplate[11] = "-rwxrwxrwx"; int i; if( strlen(z)!=10 ) goto parse_error; switch( z[0] ){ case '-': mode |= S_IFREG; break; case 'd': mode |= S_IFDIR; break; +#if !defined(_WIN32) && !defined(WIN32) case 'l': mode |= S_IFLNK; break; +#endif default: goto parse_error; } for(i=1; i<10; i++){ @@ -1178,13 +1190,13 @@ static int zipfileUpdate( cds.iVersionMadeBy = ZIPFILE_NEWENTRY_MADEBY; cds.iVersionExtract = ZIPFILE_NEWENTRY_REQUIRED; cds.flags = ZIPFILE_NEWENTRY_FLAGS; - cds.iCompression = iMethod; + cds.iCompression = (u16)iMethod; zipfileMtimeToDos(&cds, (u32)mTime); cds.crc32 = crc32(0, pData, nData); cds.szCompressed = nData; - cds.szUncompressed = sz; + cds.szUncompressed = (u32)sz; cds.iExternalAttr = (mode<<16); - cds.iOffset = pTab->szCurrent; + cds.iOffset = (u32)pTab->szCurrent; pNew = zipfileNewEntry(&cds, zPath, nPath, (u32)mTime); if( pNew==0 ){ rc = SQLITE_NOMEM; @@ -1291,10 +1303,10 @@ static int zipfileCommit(sqlite3_vtab *pVtab){ /* Write out the EOCD record */ eocd.iDisk = 0; eocd.iFirstDisk = 0; - eocd.nEntry = nEntry; - eocd.nEntryTotal = nEntry; - eocd.nSize = pTab->szCurrent - iOffset;; - eocd.iOffset = iOffset; + eocd.nEntry = (u16)nEntry; + eocd.nEntryTotal = (u16)nEntry; + eocd.nSize = (u32)(pTab->szCurrent - iOffset); + eocd.iOffset = (u32)iOffset; rc = zipfileAppendEOCD(pTab, &eocd); zipfileCleanupTransaction(pTab); diff --git a/manifest b/manifest index eb4d9552dd..32e1f5b38a 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Merge\sin\sall\srecent\strunk\senhancements. -D 2018-01-04T19:54:55.108 +C Get\sthe\sshell\senhancements\scompiling\swith\sMSVC. +D 2018-01-04T22:46:08.740 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 8723bebdec08013054d1ade8f65a13cad34bf8dd015f09649754be2b5f6edc59 +F Makefile.msc feaf722defab458cbf9583249e441239bae08fcf7fb907496c7d3fed16862f21 F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -276,7 +276,7 @@ F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 014152d4133e7b29eab8eb39d0c640659c23a6d23d882b4778f487ae7d1a457b +F ext/misc/fileio.c 16cf8d9b9372269a61644717929578a71c48eb018a76709f3bf1196bdc957d46 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -302,7 +302,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 2df8f94003903fe3cc104b807418c54e68040964d4319c522ac2f485152f5abd +F ext/misc/zipfile.c d88033b4748db9929a0096f627d3a75e9fe0e11d7a92724a6c1c575d5448cea4 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -483,7 +483,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 3e2db269982c4a6f7e8e32ef5620eda718a21a71bb2b5cd73c3ea9b87c6d21bc +F src/shell.c.in e17f15b3394206e5f0002267426d03fc4932da40af60a48e409238a8ee6c40ec F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -541,7 +541,7 @@ F src/test_thread.c 911d15fb14e19c0c542bdc8aabf981c2f10a4858 F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_windirent.c 17f91f5f2aa1bb7328abb49414c363b5d2a9d3ff -F src/test_windirent.h 5d67483a55442e31e1bde0f4a230e6e932ad5906 +F src/test_windirent.h e3de7323538e5233dfffd33538fc7e9d56c85e266d36540adb1cedb566e14eea F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 1003d6d90c6783206c711f0a9397656fa5b055209f4d092caa43bb3bf5215db5 @@ -1224,7 +1224,7 @@ F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f -F test/shell8.test 96f35965fe84d633fb2338696f5cbc1bcf6bdbdd79677244bc617a8452851dc7 +F test/shell8.test 7585847402452d594f0e5f93430d34ed63b2f34ca7e956f63db157f9327c6896 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 01d4e866fb7b01aeada537d41c4a47747c7810e2028f51077ee5b8b78c348954 a6eee0fcd89d3958f8720ebdb5f0a8558b4795d747128091dae283eb81c4f74f -R d4f5940088399233b1f4f56f19294263 -U drh -Z c1193b259bc575590a62665cc9281689 +P 406f79183736b6ad360169b837172afef2c82a4312f5787db08c54167a44b15e +R 73aa9301733dc3abdd11287ef3222fd8 +U mistachkin +Z 751be0dac1987ad178cccedeeaed1d64 diff --git a/manifest.uuid b/manifest.uuid index 0fefe4597b..f23cbae652 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -406f79183736b6ad360169b837172afef2c82a4312f5787db08c54167a44b15e \ No newline at end of file +335387f9e0d4569097d34cd99cd332b38a282e9b7ae25f088eb47df5c25837ef \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 6f1c92e006..21ca7edbb8 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -73,8 +73,9 @@ # include # endif # include -# include #endif +#include +#include #if HAVE_READLINE # include @@ -874,6 +875,11 @@ static void shellAddSchemaName( #define SQLITE_EXTENSION_INIT1 #define SQLITE_EXTENSION_INIT2(X) (void)(X) +#if defined(_WIN32) || defined(WIN32) +INCLUDE test_windirent.c +#define dirent DIRENT +#define timespec TIMESPEC +#endif INCLUDE ../ext/misc/shathree.c INCLUDE ../ext/misc/fileio.c INCLUDE ../ext/misc/completion.c @@ -4551,7 +4557,7 @@ static int arParseCommand( struct ArSwitch *pOpt; /* Iterator */ for(pOpt=&aSwitch[0]; pOptzLong; - if( (n-2)<=strlen(zLong) && 0==memcmp(&z[2], zLong, n-2) ){ + if( (n-2)<=(int)strlen(zLong) && 0==memcmp(&z[2], zLong, n-2) ){ if( pMatch ){ return arErrorMsg("ambiguous option: %s",z); }else{ diff --git a/src/test_windirent.h b/src/test_windirent.h index 578e2a7c22..2303c0c8fb 100644 --- a/src/test_windirent.h +++ b/src/test_windirent.h @@ -37,6 +37,33 @@ #include #include #include +#include +#include + +/* +** We may need several defines that should have been in "sys/stat.h". +*/ + +#ifndef S_ISREG +#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) +#endif + +#ifndef S_ISDIR +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#endif + +#ifndef S_ISLNK +#define S_ISLNK(mode) (0) +#endif + +/* +** We may need to provide the "mode_t" type. +*/ + +#ifndef MODE_T_DEFINED + #define MODE_T_DEFINED + typedef unsigned short mode_t; +#endif /* ** We may need to provide the "ino_t" type. @@ -75,22 +102,37 @@ ** We need to provide the necessary structures and related types. */ +#ifndef DIRENT_DEFINED +#define DIRENT_DEFINED typedef struct DIRENT DIRENT; -typedef struct DIR DIR; typedef DIRENT *LPDIRENT; -typedef DIR *LPDIR; - struct DIRENT { ino_t d_ino; /* Sequence number, do not use. */ unsigned d_attributes; /* Win32 file attributes. */ char d_name[NAME_MAX + 1]; /* Name within the directory. */ }; +#endif +#ifndef DIR_DEFINED +#define DIR_DEFINED +typedef struct DIR DIR; +typedef DIR *LPDIR; struct DIR { intptr_t d_handle; /* Value returned by "_findfirst". */ DIRENT d_first; /* DIRENT constructed based on "_findfirst". */ DIRENT d_next; /* DIRENT constructed based on "_findnext". */ }; +#endif + +#ifndef TIMESPEC_DEFINED +#define TIMESPEC_DEFINED +typedef struct TIMESPEC TIMESPEC; +typedef TIMESPEC *LPTIMESPEC; +struct TIMESPEC { + time_t tv_sec; /* Number of whole seconds. */ + long tv_nsec; /* Number of whole nanoseconds. */ +}; +#endif /* ** Provide a macro, for use by the implementation, to determine if a diff --git a/test/shell8.test b/test/shell8.test index 14980a84a5..50e269ef3e 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -40,7 +40,11 @@ proc dir_to_list {dirname {n -1}} { set res [list] foreach f [glob -nocomplain $dirname/*] { set mtime [file mtime $f] - set perm [file attributes $f -perm] + if {$::tcl_platform(platform)!="windows"} { + set perm [file attributes $f -perm] + } else { + set perm 0 + } set relpath [file join {*}[lrange [file split $f] $n end]] lappend res if {[file isdirectory $f]} { From e55988074fb9d5bb1936c66909251776482e2d5a Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 4 Jan 2018 22:50:52 +0000 Subject: [PATCH 030/190] Remove 'timespec' related code from the shell that has no effect and a (now) superfluous 'timespec' typedef from the Win32 dirent header file. FossilOrigin-Name: 57dac995dd028e4b7c8ce6806f5769831715c1bb9b886318fceb3fa50563d537 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 4 ---- src/test_windirent.h | 10 ---------- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 32e1f5b38a..dd247b2868 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Get\sthe\sshell\senhancements\scompiling\swith\sMSVC. -D 2018-01-04T22:46:08.740 +C Remove\s'timespec'\srelated\scode\sfrom\sthe\sshell\sthat\shas\sno\seffect\sand\sa\s(now)\ssuperfluous\s'timespec'\stypedef\sfrom\sthe\sWin32\sdirent\sheader\sfile. +D 2018-01-04T22:50:52.352 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 @@ -483,7 +483,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in e17f15b3394206e5f0002267426d03fc4932da40af60a48e409238a8ee6c40ec +F src/shell.c.in 84af7b92b6c937a0b4f323719f2069e669bd685a7dcc81a42c3d9b21d040ba23 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -541,7 +541,7 @@ F src/test_thread.c 911d15fb14e19c0c542bdc8aabf981c2f10a4858 F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_windirent.c 17f91f5f2aa1bb7328abb49414c363b5d2a9d3ff -F src/test_windirent.h e3de7323538e5233dfffd33538fc7e9d56c85e266d36540adb1cedb566e14eea +F src/test_windirent.h 5afeb2b1e2920d5149573a4c30a69cba91f2e8a80e00941b738036fca39aca61 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 1003d6d90c6783206c711f0a9397656fa5b055209f4d092caa43bb3bf5215db5 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 406f79183736b6ad360169b837172afef2c82a4312f5787db08c54167a44b15e -R 73aa9301733dc3abdd11287ef3222fd8 +P 335387f9e0d4569097d34cd99cd332b38a282e9b7ae25f088eb47df5c25837ef +R 1281cdb7398acc29fce34993c7e9c8c8 U mistachkin -Z 751be0dac1987ad178cccedeeaed1d64 +Z d412c9c0d87063cd46a5fbdafa7a7569 diff --git a/manifest.uuid b/manifest.uuid index f23cbae652..860fd9f513 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -335387f9e0d4569097d34cd99cd332b38a282e9b7ae25f088eb47df5c25837ef \ No newline at end of file +57dac995dd028e4b7c8ce6806f5769831715c1bb9b886318fceb3fa50563d537 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 21ca7edbb8..9cf62c7c22 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4755,7 +4755,6 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ - struct timespec times[2]; sqlite3_stmt *pSql = 0; int rc = SQLITE_OK; char *zDir = 0; @@ -4777,9 +4776,6 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ if( zDir==0 ) rc = SQLITE_NOMEM; } - memset(times, 0, sizeof(times)); - times[0].tv_sec = time(0); - shellPreparePrintf(db, &rc, &pSql, zSql1, azExtraArg[pAr->bZip], azSource[pAr->bZip], zWhere ); diff --git a/src/test_windirent.h b/src/test_windirent.h index 2303c0c8fb..d4474f80e0 100644 --- a/src/test_windirent.h +++ b/src/test_windirent.h @@ -124,16 +124,6 @@ struct DIR { }; #endif -#ifndef TIMESPEC_DEFINED -#define TIMESPEC_DEFINED -typedef struct TIMESPEC TIMESPEC; -typedef TIMESPEC *LPTIMESPEC; -struct TIMESPEC { - time_t tv_sec; /* Number of whole seconds. */ - long tv_nsec; /* Number of whole nanoseconds. */ -}; -#endif - /* ** Provide a macro, for use by the implementation, to determine if a ** particular directory entry should be skipped over when searching for From 104958cab09d00df8ad2a3d6a770e08dfb064811 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 4 Jan 2018 23:49:08 +0000 Subject: [PATCH 031/190] In the 'fileio' extension code for Win32, use the FILE_FLAG_BACKUP_SEMANTICS flag when setting the file times, just in case the file is actually a directory. FossilOrigin-Name: 4f3444060057127bce81787ed83cb5225cdbdd577596bc3fb06a40be2208f238 --- ext/misc/fileio.c | 3 ++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 2464d18f80..835b53f4fa 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -280,7 +280,8 @@ static int writeFile( lastWrite.dwLowDateTime = (DWORD)intervals; lastWrite.dwHighDateTime = intervals >> 32; hFile = CreateFile( - zFile, FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, 0, NULL + zFile, FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, NULL ); if( hFile!=INVALID_HANDLE_VALUE ){ BOOL bResult = SetFileTime(hFile, NULL, &lastAccess, &lastWrite); diff --git a/manifest b/manifest index dd247b2868..7dd19634db 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\s'timespec'\srelated\scode\sfrom\sthe\sshell\sthat\shas\sno\seffect\sand\sa\s(now)\ssuperfluous\s'timespec'\stypedef\sfrom\sthe\sWin32\sdirent\sheader\sfile. -D 2018-01-04T22:50:52.352 +C In\sthe\s'fileio'\sextension\scode\sfor\sWin32,\suse\sthe\sFILE_FLAG_BACKUP_SEMANTICS\sflag\swhen\ssetting\sthe\sfile\stimes,\sjust\sin\scase\sthe\sfile\sis\sactually\sa\sdirectory. +D 2018-01-04T23:49:08.958 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 @@ -276,7 +276,7 @@ F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 16cf8d9b9372269a61644717929578a71c48eb018a76709f3bf1196bdc957d46 +F ext/misc/fileio.c 868aa0572b08484323b172918882d5f8444e287b1e29e1d1b161633cf03aed10 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 335387f9e0d4569097d34cd99cd332b38a282e9b7ae25f088eb47df5c25837ef -R 1281cdb7398acc29fce34993c7e9c8c8 +P 57dac995dd028e4b7c8ce6806f5769831715c1bb9b886318fceb3fa50563d537 +R 02d2a190c58a7a01c71feee97e36cbb6 U mistachkin -Z d412c9c0d87063cd46a5fbdafa7a7569 +Z 088dbce32336167e7acacd4de5ece530 diff --git a/manifest.uuid b/manifest.uuid index 860fd9f513..d3c6c198e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -57dac995dd028e4b7c8ce6806f5769831715c1bb9b886318fceb3fa50563d537 \ No newline at end of file +4f3444060057127bce81787ed83cb5225cdbdd577596bc3fb06a40be2208f238 \ No newline at end of file From 3acaf4c07aa9f175334232d6e30091c853c1598d Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 00:53:03 +0000 Subject: [PATCH 032/190] Add missing #ifdef. FossilOrigin-Name: a0e18aea0950f5ebdf4112f826ff64d24e8660b341031132dcb65bb15579ef1c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 7dd19634db..dfb9ae6a88 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\s'fileio'\sextension\scode\sfor\sWin32,\suse\sthe\sFILE_FLAG_BACKUP_SEMANTICS\sflag\swhen\ssetting\sthe\sfile\stimes,\sjust\sin\scase\sthe\sfile\sis\sactually\sa\sdirectory. -D 2018-01-04T23:49:08.958 +C Add\smissing\s#ifdef. +D 2018-01-05T00:53:03.495 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 @@ -483,7 +483,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 84af7b92b6c937a0b4f323719f2069e669bd685a7dcc81a42c3d9b21d040ba23 +F src/shell.c.in f57fa72ec6aa5e330966adaa51a476f08a877a82e482cd26a06a7d7c1ecb666b F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 57dac995dd028e4b7c8ce6806f5769831715c1bb9b886318fceb3fa50563d537 -R 02d2a190c58a7a01c71feee97e36cbb6 +P 4f3444060057127bce81787ed83cb5225cdbdd577596bc3fb06a40be2208f238 +R c50a08a594d751082d54ba21ce6e9836 U mistachkin -Z 088dbce32336167e7acacd4de5ece530 +Z bad7a2c44b50561368222d84fba1c0b2 diff --git a/manifest.uuid b/manifest.uuid index d3c6c198e3..0737aa4078 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f3444060057127bce81787ed83cb5225cdbdd577596bc3fb06a40be2208f238 \ No newline at end of file +a0e18aea0950f5ebdf4112f826ff64d24e8660b341031132dcb65bb15579ef1c \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 9cf62c7c22..1844b39d61 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4967,7 +4967,9 @@ static int arDotCommand( return rc; } sqlite3_fileio_init(db, 0, 0); +#ifdef SQLITE_HAVE_ZLIB sqlite3_sqlar_init(db, 0, 0); +#endif }else{ db = pState->db; } From 1152250b448495f777c2e2a34ba1672071777f78 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 01:00:17 +0000 Subject: [PATCH 033/190] Enhance the 'zlib' build target for MSVC. FossilOrigin-Name: 0bc3b76ec9b83f3034e282ea0369a53673e2cb64dde42e8cf5e800f6d642d527 --- Makefile.msc | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 4fb128c567..c476f54f9e 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2080,7 +2080,7 @@ shell.c: $(SHELL_SRC) $(TOP)\tool\mkshellc.tcl $(TCLSH_CMD) $(TOP)\tool\mkshellc.tcl > shell.c zlib: - pushd $(ZLIBDIR) && $(MAKE) /f win32\Makefile.msc $(ZLIBLIB) && popd + pushd $(ZLIBDIR) && $(MAKE) /f win32\Makefile.msc clean $(ZLIBLIB) && popd # Rules to build the extension objects. # diff --git a/manifest b/manifest index dfb9ae6a88..c97886d88f 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Add\smissing\s#ifdef. -D 2018-01-05T00:53:03.495 +C Enhance\sthe\s'zlib'\sbuild\starget\sfor\sMSVC. +D 2018-01-05T01:00:17.962 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc feaf722defab458cbf9583249e441239bae08fcf7fb907496c7d3fed16862f21 +F Makefile.msc e8b973cd249b0db11c221c1bd7e9f738e8dac369275160342e1011f3932074c9 F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4f3444060057127bce81787ed83cb5225cdbdd577596bc3fb06a40be2208f238 -R c50a08a594d751082d54ba21ce6e9836 +P a0e18aea0950f5ebdf4112f826ff64d24e8660b341031132dcb65bb15579ef1c +R ae30dd8990fa7c0deb74a2452807863c U mistachkin -Z bad7a2c44b50561368222d84fba1c0b2 +Z 062c561092c9190b73f85a153a52c8b7 diff --git a/manifest.uuid b/manifest.uuid index 0737aa4078..eacddc6a99 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a0e18aea0950f5ebdf4112f826ff64d24e8660b341031132dcb65bb15579ef1c \ No newline at end of file +0bc3b76ec9b83f3034e282ea0369a53673e2cb64dde42e8cf5e800f6d642d527 \ No newline at end of file From 47be3b23e9c935930cc0dcb76c853512eabadc98 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 01:22:37 +0000 Subject: [PATCH 034/190] Revise detection of 'tclsh.exe' in the Makefile for MSVC. FossilOrigin-Name: 45fabd868dc690894f5a911d373a3d6410ba2d95d177307a42009afc8ae296cc --- Makefile.msc | 6 +++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index c476f54f9e..8f0fd1b82d 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -93,12 +93,12 @@ SPLIT_AMALGAMATION = 0 # <> # Set this non-0 to have this makefile assume the Tcl shell executable -# (tclsh*.exe) is available in the PATH. By default, this is enabled +# (tclsh*.exe) is available in the PATH. By default, this is disabled # for compatibility with older build environments. This setting only # applies if TCLSH_CMD is not set manually. # !IFNDEF USE_TCLSH_IN_PATH -USE_TCLSH_IN_PATH = 1 +USE_TCLSH_IN_PATH = 0 !ENDIF # Set this non-0 to use zlib, possibly compiling it from source code. @@ -909,7 +909,7 @@ LIBICU = icuuc.lib icuin.lib # specific Tcl shell to use. # !IFNDEF TCLSH_CMD -!IF $(USE_TCLSH_IN_PATH)!=0 +!IF $(USE_TCLSH_IN_PATH)!=0 || !EXIST("$(TCLDIR)\bin\tclsh.exe") TCLSH_CMD = tclsh !ELSE TCLSH_CMD = $(TCLDIR)\bin\tclsh.exe diff --git a/manifest b/manifest index c97886d88f..13547fdc1b 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Enhance\sthe\s'zlib'\sbuild\starget\sfor\sMSVC. -D 2018-01-05T01:00:17.962 +C Revise\sdetection\sof\s'tclsh.exe'\sin\sthe\sMakefile\sfor\sMSVC. +D 2018-01-05T01:22:37.774 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc e8b973cd249b0db11c221c1bd7e9f738e8dac369275160342e1011f3932074c9 +F Makefile.msc c4eaeff29b73d76437cf9c13d7a9654fc0e9e2578e20c12d0067c3d510e4e8e4 F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a0e18aea0950f5ebdf4112f826ff64d24e8660b341031132dcb65bb15579ef1c -R ae30dd8990fa7c0deb74a2452807863c +P 0bc3b76ec9b83f3034e282ea0369a53673e2cb64dde42e8cf5e800f6d642d527 +R ea85632748cb8c061fa075c4e05b7d5d U mistachkin -Z 062c561092c9190b73f85a153a52c8b7 +Z a7a75d6fbb0bbc541be826de9dbf52e8 diff --git a/manifest.uuid b/manifest.uuid index eacddc6a99..d4f3a5c95c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0bc3b76ec9b83f3034e282ea0369a53673e2cb64dde42e8cf5e800f6d642d527 \ No newline at end of file +45fabd868dc690894f5a911d373a3d6410ba2d95d177307a42009afc8ae296cc \ No newline at end of file From 8503d6451b9f09c0a862f14f909e5a0d453ab8d7 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 5 Jan 2018 07:57:54 +0000 Subject: [PATCH 035/190] Fix an LSM crash that could occur if LSM_CONFIG_AUTOFLUSH was set to 0. FossilOrigin-Name: 05346f83d587e6049da0e8ec5f62c749daa9e80359cf48f8c37e333e6a1e7d2a --- ext/lsm1/lsm-test/lsmtest.h | 1 + ext/lsm1/lsm-test/lsmtest_tdb.c | 1 + ext/lsm1/lsm-test/lsmtest_tdb3.c | 13 +++++++++++++ ext/lsm1/lsm_main.c | 2 +- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/ext/lsm1/lsm-test/lsmtest.h b/ext/lsm1/lsm-test/lsmtest.h index 249bc999e0..ca60424add 100644 --- a/ext/lsm1/lsm-test/lsmtest.h +++ b/ext/lsm1/lsm-test/lsmtest.h @@ -121,6 +121,7 @@ int test_mdb_scan(TestDb *, void *, int, void *, int, void *, int, */ int test_lsm_open(const char*, const char *zFile, int bClear, TestDb **ppDb); int test_lsm_lomem_open(const char*, const char*, int bClear, TestDb **ppDb); +int test_lsm_lomem2_open(const char*, const char*, int bClear, TestDb **ppDb); int test_lsm_zip_open(const char*, const char*, int bClear, TestDb **ppDb); int test_lsm_small_open(const char*, const char*, int bClear, TestDb **ppDb); int test_lsm_mt2(const char*, const char *zFile, int bClear, TestDb **ppDb); diff --git a/ext/lsm1/lsm-test/lsmtest_tdb.c b/ext/lsm1/lsm-test/lsmtest_tdb.c index 8377bc2ed2..9c4f9df8a4 100644 --- a/ext/lsm1/lsm-test/lsmtest_tdb.c +++ b/ext/lsm1/lsm-test/lsmtest_tdb.c @@ -721,6 +721,7 @@ static struct Lib { { "sqlite3", "testdb.sqlite", sql_open }, { "lsm_small", "testdb.lsm_small", test_lsm_small_open }, { "lsm_lomem", "testdb.lsm_lomem", test_lsm_lomem_open }, + { "lsm_lomem2", "testdb.lsm_lomem2", test_lsm_lomem2_open }, #ifdef HAVE_ZLIB { "lsm_zip", "testdb.lsm_zip", test_lsm_zip_open }, #endif diff --git a/ext/lsm1/lsm-test/lsmtest_tdb3.c b/ext/lsm1/lsm-test/lsmtest_tdb3.c index 1862023bad..c21e243b5c 100644 --- a/ext/lsm1/lsm-test/lsmtest_tdb3.c +++ b/ext/lsm1/lsm-test/lsmtest_tdb3.c @@ -1033,6 +1033,19 @@ int test_lsm_lomem_open( return testLsmOpen(zCfg, zFilename, bClear, ppDb); } +int test_lsm_lomem2_open( + const char *zSpec, + const char *zFilename, + int bClear, + TestDb **ppDb +){ + /* "max_freelist=4 autocheckpoint=32" */ + const char *zCfg = + "page_size=512 block_size=64 autoflush=0 mmap=0 " + ; + return testLsmOpen(zCfg, zFilename, bClear, ppDb); +} + int test_lsm_zip_open( const char *zSpec, const char *zFilename, diff --git a/ext/lsm1/lsm_main.c b/ext/lsm1/lsm_main.c index 539883c469..a9c48e004e 100644 --- a/ext/lsm1/lsm_main.c +++ b/ext/lsm1/lsm_main.c @@ -683,7 +683,7 @@ static int doWriteOp( int nDiff; if( nQuant>pDb->nTreeLimit ){ - nQuant = pDb->nTreeLimit; + nQuant = LSM_MAX(pDb->nTreeLimit, pgsz); } nBefore = lsmTreeSize(pDb); diff --git a/manifest b/manifest index 3552e5e8ce..f1eb6f56c5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\ssnarky\s"_supported_"\squalifier\sfrom\sthe\sname\sof\sthe\nsqlite_offset()\sSQL\sfunction. -D 2018-01-04T19:20:37.203 +C Fix\san\sLSM\scrash\sthat\scould\soccur\sif\sLSM_CONFIG_AUTOFLUSH\swas\sset\sto\s0. +D 2018-01-05T07:57:54.787 F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc f68b4f9b83cfeb057b6265e0288ad653f319e2ceacca731e0f22e19617829a89 @@ -221,7 +221,7 @@ F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/lsm1/Makefile 98b0a24b45e248283d6bea4b6cb3e58d7b394edd8e96a0ac28c5fa5104813bad F ext/lsm1/Makefile.msc f8c878b467232226de288da320e1ac71c131f5ec91e08b21f502303347260013 F ext/lsm1/lsm-test/README 87ea529d2abe615e856d4714bfe8bb185e6c2771b8612aa6298588b7b43e6f86 -F ext/lsm1/lsm-test/lsmtest.h 5847594d4b43ec3412e1fd97104f7eb5fd770be55e691e6cb2e80929f86bebe3 +F ext/lsm1/lsm-test/lsmtest.h cf58528ffe0cfe535e91b44584e2ec5fb1caacdabecef0d8dcf83bf83168bf28 F ext/lsm1/lsm-test/lsmtest1.c 33158978327f800e82b6a47c09b86ace809f56a9ff10b0162273ec1186cc3153 F ext/lsm1/lsm-test/lsmtest2.c 188b09aec776516aeedcfd13b9c6faf85ba16b3671a0897a2c740ee00a5dc4f8 F ext/lsm1/lsm-test/lsmtest3.c 9ab87528a36dbf4a61d7c8ad954f5ee368c0878c127b84b942b2e2abe522de26 @@ -237,10 +237,10 @@ F ext/lsm1/lsm-test/lsmtest_func.c 159aa401bc8032bfa3d8cf2977bd687abebab88025589 F ext/lsm1/lsm-test/lsmtest_io.c cf11b27b129c6bd5818fa1d440176502dc27229f0db892b4479118d61993ea20 F ext/lsm1/lsm-test/lsmtest_main.c a9bc647738c0dcaebf205d6d194b3ce4a6ef3925801cd2d919f0a4ea33a15aeb F ext/lsm1/lsm-test/lsmtest_mem.c 4e63c764345ab1df59d4f13a77980c6f3643798210b10d6cdbd785b4b888fda5 -F ext/lsm1/lsm-test/lsmtest_tdb.c 555fb101d2fe638abdd133e9294536c857fb38e0f227e049c00a67f51eaece06 +F ext/lsm1/lsm-test/lsmtest_tdb.c 618a8619183fda4f5540fcde15f9068293c5e3180e1a246e34409b0c148758b3 F ext/lsm1/lsm-test/lsmtest_tdb.h 8733eee249b12956a9df8322994b43d19bd8c02ad2e8b0bb5164db4d6ccc1735 F ext/lsm1/lsm-test/lsmtest_tdb2.cc 99ea7f2dd9c7536c8fb9bdd329e4cfeb76899f3ddf6f48bdd3926e016922b715 -F ext/lsm1/lsm-test/lsmtest_tdb3.c e44bf94e8bd724cd6ac161fd2cd44ffe43193932ad3a6bee1b07d80bb74012bb +F ext/lsm1/lsm-test/lsmtest_tdb3.c b4e46b1d2fec553fe4efb44e341b43abd20556fde610db0cfffdc2300b72defe F ext/lsm1/lsm-test/lsmtest_tdb4.c 47e8bb5eba266472d690fb8264f1855ebdba0ae5a0e541e35fcda61ebf1d277f F ext/lsm1/lsm-test/lsmtest_util.c 241622db5a332a09c8e6e7606b617d288a37b557f7d3bce0bb97809f67cc2806 F ext/lsm1/lsm-test/lsmtest_win32.c 0e0a224674c4d3170631c41b026b56c7e1672b151f5261e1b4cc19068641da2d @@ -249,7 +249,7 @@ F ext/lsm1/lsmInt.h 5983690e05e83653cc01ba9d8fbf8455e534ddf8349ed9adedbf46a75497 F ext/lsm1/lsm_ckpt.c 0eabfaf812ddb4ea43add38f05e430694cd054eb622c3e35af4c43118a2d5321 F ext/lsm1/lsm_file.c 3c51841d5b3e7da162693cbac9a9f47eeedf6bcbbe2969a4d25e30c428c9fe36 F ext/lsm1/lsm_log.c a8bf334532109bba05b09a504ee45fc393828b0d034ca61ab45e3940709d9a7c -F ext/lsm1/lsm_main.c 801295038b548ae2e5fae93f08c3f945154f40848a03ff26b16eab5d04ba573a +F ext/lsm1/lsm_main.c b5703f8042e71d3a2d65e671f6832e077e79e89e9975818f67f969922618db63 F ext/lsm1/lsm_mem.c 4c51ea9fa285ee6e35301b33491642d071740a0a F ext/lsm1/lsm_mutex.c 378edf0a2b142b4f7640ee982df06d50b98788ea F ext/lsm1/lsm_shared.c 76adfc1ed9ffebaf92746dde4b370ccc48143ca8b05b563816eadd2aadf1c525 @@ -1688,7 +1688,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d91e3f3d343d281af374dd23eea333e61228539023ad5c5aea622085e5863bc7 -R 314fe8cfc8ec7f02f3acb6e4d50707fb -U drh -Z 7ea7a34ef1d7c0cfd34c8e9e5f226383 +P a6eee0fcd89d3958f8720ebdb5f0a8558b4795d747128091dae283eb81c4f74f +R 2eb065da8ca94639b242562f929b4d2b +U dan +Z 4b1a53b69d218d7d45a85af2c33ced1c diff --git a/manifest.uuid b/manifest.uuid index 561f8b3f92..d679b61f5b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a6eee0fcd89d3958f8720ebdb5f0a8558b4795d747128091dae283eb81c4f74f \ No newline at end of file +05346f83d587e6049da0e8ec5f62c749daa9e80359cf48f8c37e333e6a1e7d2a \ No newline at end of file From 303b02cc0b3a3a85409a8b34e81db5eace1de9c8 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 5 Jan 2018 11:34:18 +0000 Subject: [PATCH 036/190] Fix an LSM problem causing the wrong amount of "auto-work" to be performed under fairly obscure circumstances. FossilOrigin-Name: a4876672edea4e96103efd2463ce9a34a0b994a8744c941660940578aafbd454 --- ext/lsm1/lsm_sorted.c | 5 ++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ext/lsm1/lsm_sorted.c b/ext/lsm1/lsm_sorted.c index 171d0ec05c..de962b8808 100644 --- a/ext/lsm1/lsm_sorted.c +++ b/ext/lsm1/lsm_sorted.c @@ -5252,16 +5252,15 @@ static int doLsmSingleWork( /* If the in-memory part of the free-list is too large, write a new ** top-level containing just the in-memory free-list entries to disk. */ if( rc==LSM_OK && pDb->pWorker->freelist.nEntry > pDb->nMaxFreelist ){ - int nPg = 0; while( rc==LSM_OK && lsmDatabaseFull(pDb) ){ + int nPg = 0; rc = sortedWork(pDb, 16, nMerge, 1, &nPg); nRem -= nPg; } if( rc==LSM_OK ){ rc = sortedNewFreelistOnly(pDb); } - nRem -= nPg; - if( nPg ) bDirty = 1; + bDirty = 1; } if( rc==LSM_OK ){ diff --git a/manifest b/manifest index f1eb6f56c5..ba1764d8aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sLSM\scrash\sthat\scould\soccur\sif\sLSM_CONFIG_AUTOFLUSH\swas\sset\sto\s0. -D 2018-01-05T07:57:54.787 +C Fix\san\sLSM\sproblem\scausing\sthe\swrong\samount\sof\s"auto-work"\sto\sbe\sperformed\nunder\sfairly\sobscure\scircumstances. +D 2018-01-05T11:34:18.736 F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc f68b4f9b83cfeb057b6265e0288ad653f319e2ceacca731e0f22e19617829a89 @@ -253,7 +253,7 @@ F ext/lsm1/lsm_main.c b5703f8042e71d3a2d65e671f6832e077e79e89e9975818f67f9699226 F ext/lsm1/lsm_mem.c 4c51ea9fa285ee6e35301b33491642d071740a0a F ext/lsm1/lsm_mutex.c 378edf0a2b142b4f7640ee982df06d50b98788ea F ext/lsm1/lsm_shared.c 76adfc1ed9ffebaf92746dde4b370ccc48143ca8b05b563816eadd2aadf1c525 -F ext/lsm1/lsm_sorted.c d07ff7c28758542b8b4da4b5a1fb67b22a4d33e50e7f684cffe1f6c45cf5182c +F ext/lsm1/lsm_sorted.c df7b393d9e4b85e6ad07181c6434d58a69a9145ee925d89c3ee1d2a210adaf9a F ext/lsm1/lsm_str.c 65e361b488c87b10bf3e5c0070b14ffc602cf84f094880bece77bbf6678bca82 F ext/lsm1/lsm_tree.c 682679d7ef2b8b6f2fe77aeb532c8d29695bca671c220b0abac77069de5fb9fb F ext/lsm1/lsm_unix.c 57361bcf5b1a1a028f5d66571ee490e9064d2cfb145a2cc9e5ddade467bb551b @@ -1688,7 +1688,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a6eee0fcd89d3958f8720ebdb5f0a8558b4795d747128091dae283eb81c4f74f -R 2eb065da8ca94639b242562f929b4d2b +P 05346f83d587e6049da0e8ec5f62c749daa9e80359cf48f8c37e333e6a1e7d2a +R 3aef1a930039ecc41e90c5782e1f14e5 U dan -Z 4b1a53b69d218d7d45a85af2c33ced1c +Z 26afacfab65aa4f19216c821cd8450d4 diff --git a/manifest.uuid b/manifest.uuid index d679b61f5b..78301508b4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -05346f83d587e6049da0e8ec5f62c749daa9e80359cf48f8c37e333e6a1e7d2a \ No newline at end of file +a4876672edea4e96103efd2463ce9a34a0b994a8744c941660940578aafbd454 \ No newline at end of file From af2770f842d025b8b11c704688a937d52faa6ee2 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 5 Jan 2018 14:55:43 +0000 Subject: [PATCH 037/190] Fix compiler warnings. FossilOrigin-Name: 364ac333b030f0e3372937df723f1098183da87913ba0e8ae162864ee24a50d3 --- ext/misc/fileio.c | 5 ++--- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/shell.c.in | 33 +++++++++++++++------------------ 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 835b53f4fa..f6df42f98e 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -176,12 +176,11 @@ static int makeDirectory( if( zCopy==0 ){ rc = SQLITE_NOMEM; }else{ - int nCopy = strlen(zCopy); + int nCopy = (int)strlen(zCopy); int i = 1; while( rc==SQLITE_OK ){ struct stat sStat; - int rc; for(; zCopy[i]!='/' && izBase = (const char*)sqlite3_value_text(argv[1]); } if( pCur->zBase ){ - pCur->nBase = strlen(pCur->zBase)+1; + pCur->nBase = (int)strlen(pCur->zBase)+1; pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zBase, zDir); }else{ pCur->zPath = sqlite3_mprintf("%s", zDir); diff --git a/manifest b/manifest index 13547fdc1b..2557324a67 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revise\sdetection\sof\s'tclsh.exe'\sin\sthe\sMakefile\sfor\sMSVC. -D 2018-01-05T01:22:37.774 +C Fix\scompiler\swarnings. +D 2018-01-05T14:55:43.233 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 @@ -276,7 +276,7 @@ F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 868aa0572b08484323b172918882d5f8444e287b1e29e1d1b161633cf03aed10 +F ext/misc/fileio.c 864984342ede6775976322a3a2731be5e3a70a2c71557e489e1730bd8ca57dd2 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -483,7 +483,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in f57fa72ec6aa5e330966adaa51a476f08a877a82e482cd26a06a7d7c1ecb666b +F src/shell.c.in 17fc28661aae277767db63fa90e644b8c9bf1242fbd167dcc2e7af0f0e620bb7 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0bc3b76ec9b83f3034e282ea0369a53673e2cb64dde42e8cf5e800f6d642d527 -R ea85632748cb8c061fa075c4e05b7d5d -U mistachkin -Z a7a75d6fbb0bbc541be826de9dbf52e8 +P 45fabd868dc690894f5a911d373a3d6410ba2d95d177307a42009afc8ae296cc +R 67924405c342403978f2d6d8e94eaa8e +U drh +Z e8ddc1cfcd8bdce50b891a625082402b diff --git a/manifest.uuid b/manifest.uuid index d4f3a5c95c..9b6d19bf86 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -45fabd868dc690894f5a911d373a3d6410ba2d95d177307a42009afc8ae296cc \ No newline at end of file +364ac333b030f0e3372937df723f1098183da87913ba0e8ae162864ee24a50d3 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 1844b39d61..eb5f0b42ed 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1955,7 +1955,7 @@ static void displayLinuxIoStats(FILE *out){ }; int i; for(i=0; i0 && z[i-1]==';' ){ i--; } utf8_printf(f, "%.*s;\n", i, z); } @@ -3549,7 +3549,7 @@ static void tryToCloneData( char *zInsert = 0; int rc; int i, j, n; - int nTable = (int)strlen(zTable); + int nTable = strlen30(zTable); int k = 0; int cnt = 0; const int spinRate = 10000; @@ -3570,7 +3570,7 @@ static void tryToCloneData( } sqlite3_snprintf(200+nTable,zInsert, "INSERT OR IGNORE INTO \"%s\" VALUES(?", zTable); - i = (int)strlen(zInsert); + i = strlen30(zInsert); for(j=1; j1 && sqlite3_strnicmp("-verbose", azArg[i], n)==0 ){ bVerbose = 1; } @@ -4255,7 +4255,7 @@ static int lintDotCommand( int nArg /* Number of entries in azArg[] */ ){ int n; - n = (nArg>=2 ? (int)strlen(azArg[1]) : 0); + n = (nArg>=2 ? strlen30(azArg[1]) : 0); if( n<1 || sqlite3_strnicmp(azArg[1], "fkey-indexes", n) ) goto usage; return lintFkeyIndexes(pState, azArg, nArg); @@ -4517,7 +4517,7 @@ static int arParseCommand( pAr->nArg = nArg-iArg; break; } - n = strlen(z); + n = strlen30(z); if( z[1]!='-' ){ int i; @@ -4557,7 +4557,7 @@ static int arParseCommand( struct ArSwitch *pOpt; /* Iterator */ for(pOpt=&aSwitch[0]; pOptzLong; - if( (n-2)<=(int)strlen(zLong) && 0==memcmp(&z[2], zLong, n-2) ){ + if( (n-2)<=strlen30(zLong) && 0==memcmp(&z[2], zLong, n-2) ){ if( pMatch ){ return arErrorMsg("ambiguous option: %s",z); }else{ @@ -4610,7 +4610,7 @@ static int arCheckEntries(sqlite3 *db, ArCommand *pAr){ } for(i=0; inArg && rc==SQLITE_OK; i++){ char *z = pAr->azArg[i]; - int n = strlen(z); + int n = strlen30(z); int bOk = 0; while( n>0 && z[n-1]=='/' ) n--; z[n] = '\0'; @@ -5025,7 +5025,7 @@ static int expertDotCommand( char *z = azArg[i]; int n; if( z[0]=='-' && z[1]=='-' ) z++; - n = strlen(z); + n = strlen30(z); if( n>=2 && 0==strncmp(z, "-verbose", n) ){ pState->expert.bVerbose = 1; } @@ -5908,7 +5908,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='m' && strncmp(azArg[0], "mode", n)==0 ){ const char *zMode = nArg>=2 ? azArg[1] : ""; - int n2 = (int)strlen(zMode); + int n2 = strlen30(zMode); int c2 = zMode[0]; if( c2=='l' && n2>2 && strncmp(azArg[1],"lines",n2)==0 ){ p->mode = MODE_Line; @@ -7147,8 +7147,7 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = 1; goto meta_command_exit; } - rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3], - (int)strlen(azArg[3])); + rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3], strlen30(azArg[3])); if( rc ){ utf8_printf(stderr, "Authentication failed for user %s\n", azArg[2]); rc = 1; @@ -7159,8 +7158,7 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = 1; goto meta_command_exit; } - rc = sqlite3_user_add(p->db, azArg[2], - azArg[3], (int)strlen(azArg[3]), + rc = sqlite3_user_add(p->db, azArg[2], azArg[3], strlen30(azArg[3]), booleanValue(azArg[4])); if( rc ){ raw_printf(stderr, "User-Add failed: %d\n", rc); @@ -7172,8 +7170,7 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = 1; goto meta_command_exit; } - rc = sqlite3_user_change(p->db, azArg[2], - azArg[3], (int)strlen(azArg[3]), + rc = sqlite3_user_change(p->db, azArg[2], azArg[3], strlen30(azArg[3]), booleanValue(azArg[4])); if( rc ){ raw_printf(stderr, "User-Edit failed: %d\n", rc); From 91f7211caa24dc0a6f83b7b81a386178111c4b8d Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 16:03:52 +0000 Subject: [PATCH 038/190] Add some missing #ifdefs for building without zlib. FossilOrigin-Name: c63fb1700c0f67d90857b1f3859c203880d0939f356a64d8ae7cafc814ea72bf --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/test1.c | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 2557324a67..53a4f9a14e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompiler\swarnings. -D 2018-01-05T14:55:43.233 +C Add\ssome\smissing\s#ifdefs\sfor\sbuilding\swithout\szlib. +D 2018-01-05T16:03:52.073 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 @@ -492,7 +492,7 @@ F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6 F src/status.c 9737ed017279a9e0c5da748701c3c7bf1e8ae0dae459aad20dd64fcff97a7e35 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 F src/tclsqlite.c 1833388c01e3b77f4c712185ee7250b9423ee0981ce6ae7e401e47db0319a696 -F src/test1.c 1879ff5095def6091f83f54c6233bc19e2b7223068fb02da41f2396d55729764 +F src/test1.c b52f9e7fe62016d357c3266fcfa0793cc1883d3cb2b11dfa39fcba2e70b0305c F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 45fabd868dc690894f5a911d373a3d6410ba2d95d177307a42009afc8ae296cc -R 67924405c342403978f2d6d8e94eaa8e -U drh -Z e8ddc1cfcd8bdce50b891a625082402b +P 364ac333b030f0e3372937df723f1098183da87913ba0e8ae162864ee24a50d3 +R 0ea7c4065b03d537986e987f96237bd2 +U mistachkin +Z 7bfc76075fe03643e9086a52bceca2fa diff --git a/manifest.uuid b/manifest.uuid index 9b6d19bf86..cff8285416 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -364ac333b030f0e3372937df723f1098183da87913ba0e8ae162864ee24a50d3 \ No newline at end of file +c63fb1700c0f67d90857b1f3859c203880d0939f356a64d8ae7cafc814ea72bf \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index f9b3b69711..55d92eb1fd 100644 --- a/src/test1.c +++ b/src/test1.c @@ -6960,7 +6960,9 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd( extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines*); extern int sqlite3_unionvtab_init(sqlite3*,char**,const sqlite3_api_routines*); +#ifdef SQLITE_HAVE_ZLIB extern int sqlite3_zipfile_init(sqlite3*,char**,const sqlite3_api_routines*); +#endif static const struct { const char *zExtName; int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*); @@ -6982,7 +6984,9 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd( { "totype", sqlite3_totype_init }, { "unionvtab", sqlite3_unionvtab_init }, { "wholenumber", sqlite3_wholenumber_init }, +#ifdef SQLITE_HAVE_ZLIB { "zipfile", sqlite3_zipfile_init }, +#endif }; sqlite3 *db; const char *zName; From 590522c18e06f6e18910c23e20535b43ac306a64 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 16:05:51 +0000 Subject: [PATCH 039/190] In the Makefile for MSVC, only attempt to link against Tcl when it is needed. Also, only compile 'zipfile.c' when use of zlib is enabled. FossilOrigin-Name: a33ad33cf031edee273afa4735c8564870465be22962a9c277e4ac43a307ff2c --- Makefile.msc | 28 +++++++++++++++++++--------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 8f0fd1b82d..e2a6bbe86d 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1148,8 +1148,8 @@ LDFLAGS = $(LDOPTS) # Start with the Tcl related linker options. # !IF $(NO_TCL)==0 -LTLIBPATHS = /LIBPATH:$(TCLLIBDIR) -LTLIBS = $(LTLIBS) $(LIBTCL) +TCLLIBPATHS = $(TCLLIBPATHS) /LIBPATH:$(TCLLIBDIR) +TCLLIBS = $(TCLLIBS) $(LIBTCL) !ENDIF # If zlib support is enabled, add the linker options for it. @@ -1506,8 +1506,13 @@ TESTEXT = \ $(TOP)\ext\misc\spellfix.c \ $(TOP)\ext\misc\totype.c \ $(TOP)\ext\misc\unionvtab.c \ - $(TOP)\ext\misc\wholenumber.c \ - $(TOP)\ext\misc\zipfile.c + $(TOP)\ext\misc\wholenumber.c + +# If use of zlib is enabled, add the "zipfile.c" source file. +# +!IF $(USE_ZLIB)!=0 +TESTEXT = $(TESTEXT) $(TOP)\ext\misc\zipfile.c +!ENDIF # Source code to the library files needed by the test fixture # (non-amalgamation) @@ -2025,7 +2030,7 @@ tclsqlite-shell.lo: $(TOP)\src\tclsqlite.c $(HDR) $(SQLITE_TCL_DEP) $(LTCOMPILE) $(NO_WARN) -DTCLSH -DBUILD_sqlite -I$(TCLINCDIR) -c $(TOP)\src\tclsqlite.c tclsqlite3.exe: tclsqlite-shell.lo $(SQLITE3C) $(SQLITE3H) $(LIBRESOBJS) - $(LTLINK) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /OUT:$@ tclsqlite-shell.lo $(LIBRESOBJS) $(LTLIBS) $(TLIBS) + $(LTLINK) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) $(TCLLIBPATHS) $(LTLIBPATHS) /OUT:$@ tclsqlite-shell.lo $(LIBRESOBJS) $(TCLLIBS) $(LTLIBS) $(TLIBS) # Rules to build opcodes.c and opcodes.h # @@ -2073,8 +2078,13 @@ SHELL_SRC = \ $(TOP)\ext\misc\completion.c \ $(TOP)\ext\misc\sqlar.c \ $(TOP)\ext\expert\sqlite3expert.c \ - $(TOP)\ext\expert\sqlite3expert.h \ - $(TOP)\ext\misc\zipfile.c + $(TOP)\ext\expert\sqlite3expert.h + +# If use of zlib is enabled, add the "zipfile.c" source file. +# +!IF $(USE_ZLIB)!=0 +SHELL_SRC = $(SHELL_SRC) $(TOP)\ext\misc\zipfile.c +!ENDIF shell.c: $(SHELL_SRC) $(TOP)\tool\mkshellc.tcl $(TCLSH_CMD) $(TOP)\tool\mkshellc.tcl > shell.c @@ -2262,7 +2272,7 @@ testfixture.exe: $(TESTFIXTURE_SRC) $(SQLITE3H) $(LIBRESOBJS) $(HDR) $(SQLITE_TC $(LTLINK) -DSQLITE_NO_SYNC=1 $(TESTFIXTURE_FLAGS) \ -DBUILD_sqlite -I$(TCLINCDIR) \ $(TESTFIXTURE_SRC) \ - /link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LTLIBS) $(TLIBS) + /link $(LDFLAGS) $(LTLINKOPTS) $(TCLLIBPATHS) $(LTLIBPATHS) $(LIBRESOBJS) $(TCLLIBS) $(LTLIBS) $(TLIBS) extensiontest: testfixture.exe testloadext.dll @set PATH=$(LIBTCLPATH);$(PATH) @@ -2312,7 +2322,7 @@ sqlite3_analyzer.c: $(SQLITE3C) $(SQLITE3H) $(TOP)\src\tclsqlite.c $(TOP)\tool\s sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS) $(LTLINK) $(NO_WARN) -DBUILD_sqlite -I$(TCLINCDIR) sqlite3_analyzer.c \ - /link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LTLIBS) $(TLIBS) + /link $(LDFLAGS) $(LTLINKOPTS) $(TCLLIBPATHS) $(LTLIBPATHS) $(LIBRESOBJS) $(TCLLIBS) $(LTLIBS) $(TLIBS) sqlite3_expert.exe: $(SQLITE3C) $(TOP)\ext\expert\sqlite3expert.h $(TOP)\ext\expert\sqlite3expert.c $(TOP)\ext\expert\expert.c $(LTLINK) $(NO_WARN) $(TOP)\ext\expert\sqlite3expert.c $(TOP)\ext\expert\expert.c $(SQLITE3C) $(TLIBS) diff --git a/manifest b/manifest index 53a4f9a14e..eb04d9429e 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Add\ssome\smissing\s#ifdefs\sfor\sbuilding\swithout\szlib. -D 2018-01-05T16:03:52.073 +C In\sthe\sMakefile\sfor\sMSVC,\sonly\sattempt\sto\slink\sagainst\sTcl\swhen\sit\sis\sneeded.\s\sAlso,\sonly\scompile\s'zipfile.c'\swhen\suse\sof\szlib\sis\senabled. +D 2018-01-05T16:05:51.162 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc c4eaeff29b73d76437cf9c13d7a9654fc0e9e2578e20c12d0067c3d510e4e8e4 +F Makefile.msc 72f437d37191eb122ae289f5583af5eb9cae288fbd7914111f029066c84fbc84 F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 364ac333b030f0e3372937df723f1098183da87913ba0e8ae162864ee24a50d3 -R 0ea7c4065b03d537986e987f96237bd2 +P c63fb1700c0f67d90857b1f3859c203880d0939f356a64d8ae7cafc814ea72bf +R b5c6776760b2ddd7e6d28c4945f67802 U mistachkin -Z 7bfc76075fe03643e9086a52bceca2fa +Z 02b062c480e829873866b47ba5cd168a diff --git a/manifest.uuid b/manifest.uuid index cff8285416..8f4fdf47f5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c63fb1700c0f67d90857b1f3859c203880d0939f356a64d8ae7cafc814ea72bf \ No newline at end of file +a33ad33cf031edee273afa4735c8564870465be22962a9c277e4ac43a307ff2c \ No newline at end of file From c93203363096c5946ae20f8339cc1539a8d83a5b Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 5 Jan 2018 16:23:43 +0000 Subject: [PATCH 040/190] Fix missing dependencies for shell.c in all makefiles. FossilOrigin-Name: 45495d3e256fef4d0669754726878ed17248fc781397ebb0421149ee9492f977 --- Makefile.in | 7 ++++++- Makefile.msc | 4 +++- main.mk | 3 ++- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Makefile.in b/Makefile.in index e3dfb01baa..f6933f6c7e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -994,7 +994,12 @@ SHELL_SRC = \ $(TOP)/src/shell.c.in \ $(TOP)/ext/misc/shathree.c \ $(TOP)/ext/misc/fileio.c \ - $(TOP)/ext/misc/completion.c + $(TOP)/ext/misc/completion.c \ + $(TOP)/ext/misc/sqlar.c \ + $(TOP)/ext/expert/sqlite3expert.c \ + $(TOP)/ext/expert/sqlite3expert.h \ + $(TOP)/ext/misc/zipfile.c \ + $(TOP)/src/test_windirent.c shell.c: $(SHELL_SRC) $(TOP)/tool/mkshellc.tcl $(TCLSH_CMD) $(TOP)/tool/mkshellc.tcl >shell.c diff --git a/Makefile.msc b/Makefile.msc index e2a6bbe86d..c9b78b68f8 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2078,7 +2078,9 @@ SHELL_SRC = \ $(TOP)\ext\misc\completion.c \ $(TOP)\ext\misc\sqlar.c \ $(TOP)\ext\expert\sqlite3expert.c \ - $(TOP)\ext\expert\sqlite3expert.h + $(TOP)\ext\expert\sqlite3expert.h \ + $(TOP)\ext\misc\zipfile.c \ + $(TOP)\src\test_windirent.c # If use of zlib is enabled, add the "zipfile.c" source file. # diff --git a/main.mk b/main.mk index a6a7dbf1c2..5b6775a841 100644 --- a/main.mk +++ b/main.mk @@ -699,7 +699,8 @@ SHELL_SRC = \ $(TOP)/ext/misc/sqlar.c \ $(TOP)/ext/expert/sqlite3expert.c \ $(TOP)/ext/expert/sqlite3expert.h \ - $(TOP)/ext/misc/zipfile.c + $(TOP)/ext/misc/zipfile.c \ + $(TOP)/src/test_windirent.c shell.c: $(SHELL_SRC) $(TOP)/tool/mkshellc.tcl tclsh $(TOP)/tool/mkshellc.tcl >shell.c diff --git a/manifest b/manifest index eb04d9429e..9f339b15a4 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C In\sthe\sMakefile\sfor\sMSVC,\sonly\sattempt\sto\slink\sagainst\sTcl\swhen\sit\sis\sneeded.\s\sAlso,\sonly\scompile\s'zipfile.c'\swhen\suse\sof\szlib\sis\senabled. -D 2018-01-05T16:05:51.162 +C Fix\smissing\sdependencies\sfor\sshell.c\sin\sall\smakefiles. +D 2018-01-05T16:23:43.149 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea -F Makefile.in 1b11037c5ed3399a79433cc82c59b5e36a7b3a3e4e195bb27640d0d2145e03e1 +F Makefile.in f5c6285ac43b2e567d6cf463dff3744da960a19f2cf141744b4472842a97681e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 72f437d37191eb122ae289f5583af5eb9cae288fbd7914111f029066c84fbc84 +F Makefile.msc 69711303f4062857b1f07ecfe74d7952ce56e7401ed0248eea0569fd63b7f664 F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -405,7 +405,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 739f832da37d29e252dd9f609c3864f3ecfa42136132eab9b11acb5162b7d02d +F main.mk 0c0ed98340ad4b7ebdfe587144a13cb12dfe3f09c16a6af5b4d4a7f3a881f2f8 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c63fb1700c0f67d90857b1f3859c203880d0939f356a64d8ae7cafc814ea72bf -R b5c6776760b2ddd7e6d28c4945f67802 -U mistachkin -Z 02b062c480e829873866b47ba5cd168a +P a33ad33cf031edee273afa4735c8564870465be22962a9c277e4ac43a307ff2c +R c9a59c27332856c5c3df1bda98801aaa +U drh +Z 3de3b81c4ea3d2cc9df2aeeb1cbc4214 diff --git a/manifest.uuid b/manifest.uuid index 8f4fdf47f5..bb30f4d234 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a33ad33cf031edee273afa4735c8564870465be22962a9c277e4ac43a307ff2c \ No newline at end of file +45495d3e256fef4d0669754726878ed17248fc781397ebb0421149ee9492f977 \ No newline at end of file From 9a5efdec7079a7f8a548631d5958b9f6f4a04b54 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 17:10:49 +0000 Subject: [PATCH 041/190] Fix compiler warnings. FossilOrigin-Name: 19aabccfe34c956599f33cd3ddc846816adc06784c2496838f1ef53059e038e5 --- ext/fts5/fts5_tcl.c | 2 +- ext/misc/fileio.c | 1 + ext/misc/unionvtab.c | 2 +- ext/misc/zipfile.c | 8 ++++---- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index e8d4c32a46..8f79397fbf 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -433,7 +433,7 @@ static int SQLITE_TCLAPI xF5tApi( int iVal; int bClear; if( Tcl_GetBooleanFromObj(interp, objv[2], &bClear) ) return TCL_ERROR; - iVal = ((char*)p->pApi->xGetAuxdata(p->pFts, bClear) - (char*)0); + iVal = (int)((char*)p->pApi->xGetAuxdata(p->pFts, bClear) - (char*)0); Tcl_SetObjResult(interp, Tcl_NewIntObj(iVal)); break; } diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index f6df42f98e..796bee399c 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -93,6 +93,7 @@ SQLITE_EXTENSION_INIT1 # include "test_windirent.h" # define dirent DIRENT # define timespec TIMESPEC +# define stat _stat # define mkdir(path,mode) _mkdir(path) # define lstat(path,buf) _stat(path,buf) #endif diff --git a/ext/misc/unionvtab.c b/ext/misc/unionvtab.c index 14cce84510..92d0b833c4 100644 --- a/ext/misc/unionvtab.c +++ b/ext/misc/unionvtab.c @@ -799,7 +799,7 @@ static void unionConfigureVtab( zVal = zOpt; if( *zVal==':' ) zVal++; while( union_isidchar(*zVal) ) zVal++; - nOpt = zVal-zOpt; + nOpt = (int)(zVal-zOpt); while( union_isspace(*zVal) ) zVal++; if( *zVal=='=' ){ diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index c3dc5f2d3e..d2715c4400 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -299,7 +299,7 @@ static int zipfileConnect( if( argc>3 ){ zFile = argv[3]; - nFile = strlen(zFile)+1; + nFile = (int)strlen(zFile)+1; } rc = sqlite3_declare_vtab(db, ZIPFILE_SCHEMA); @@ -1049,7 +1049,7 @@ static int zipfileAppendEntry( zipfileWrite16(aBuf, (u16)nPath); zipfileWrite16(aBuf, pCds->nExtra); assert( aBuf==&pTab->aBuffer[ZIPFILE_LFH_FIXED_SZ] ); - rc = zipfileAppendData(pTab, pTab->aBuffer, aBuf - pTab->aBuffer); + rc = zipfileAppendData(pTab, pTab->aBuffer, (int)(aBuf - pTab->aBuffer)); if( rc==SQLITE_OK ){ rc = zipfileAppendData(pTab, (const u8*)zPath, nPath); } @@ -1140,7 +1140,7 @@ static int zipfileUpdate( } zPath = (const char*)sqlite3_value_text(apVal[2]); - nPath = strlen(zPath); + nPath = (int)strlen(zPath); rc = zipfileGetMode(pTab, apVal[3], &mode); if( rc!=SQLITE_OK ) return rc; mTime = sqlite3_value_int64(apVal[4]); @@ -1227,7 +1227,7 @@ static int zipfileAppendEOCD(ZipfileTab *pTab, ZipfileEOCD *p){ zipfileWrite16(aBuf, 0); /* Size of trailing comment in bytes*/ assert( (aBuf-pTab->aBuffer)==22 ); - return zipfileAppendData(pTab, pTab->aBuffer, aBuf - pTab->aBuffer); + return zipfileAppendData(pTab, pTab->aBuffer, (int)(aBuf - pTab->aBuffer)); } static void zipfileCleanupTransaction(ZipfileTab *pTab){ diff --git a/manifest b/manifest index 9f339b15a4..fd16cab107 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\smissing\sdependencies\sfor\sshell.c\sin\sall\smakefiles. -D 2018-01-05T16:23:43.149 +C Fix\scompiler\swarnings. +D 2018-01-05T17:10:49.665 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in f5c6285ac43b2e567d6cf463dff3744da960a19f2cf141744b4472842a97681e @@ -116,7 +116,7 @@ F ext/fts5/fts5_hash.c 32be400cf761868c9db33efe81a06eb19a17c5402ad477ee9efb51301 F ext/fts5/fts5_index.c 5fe14375a29e8a7aa8f3e863babe180a19269206c254c8f47b216821d4ac1e15 F ext/fts5/fts5_main.c 24868f88ab2a865defbba7a92eebeb726cc991eb092b71b5f5508f180c72605b F ext/fts5/fts5_storage.c fb5ef3c27073f67ade2e1bea08405f9e43f68f5f3676ed0ab7013bce5ba10be6 -F ext/fts5/fts5_tcl.c a7df39442ae674dde877cf06fe02ebb7658e69c179a4d223241c90df4f14b54e +F ext/fts5/fts5_tcl.c b470467be4c5cab2d8b026992c05d86cd2293e7d8c4a10ba56d5f4f707981097 F ext/fts5/fts5_test_mi.c 65864ba1e5c34a61d409c4c587e0bbe0466eb4f8f478d85dc42a92caad1338e6 F ext/fts5/fts5_test_tok.c ffd657dd67e7fcdb31bf63fb60b6d867299a581d0f46e97086abacd66c2a9b26 F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 @@ -276,7 +276,7 @@ F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 864984342ede6775976322a3a2731be5e3a70a2c71557e489e1730bd8ca57dd2 +F ext/misc/fileio.c 1e3694706406fcca3a19d09dde9d01624f1d45f4b9e328f9adf61ffe568467ee F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -296,13 +296,13 @@ F ext/misc/spellfix.c 41cf26c6b89fcaa8798ae10ae64d39c1f1d9d6995152e545bd491c1305 F ext/misc/sqlar.c d355cd8b6e7280d2f61d4737672922acb512a2ab1cee52399ffb88980476e31c F ext/misc/stmt.c 6f16443abb3551e3f5813bb13ba19a30e7032830015b0f92fe0c0453045c0a11 F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 -F ext/misc/unionvtab.c de36c2c45583d68f99e45b392311967066b02e2651d05697da783698b245b387 +F ext/misc/unionvtab.c 2aa94902ea646e1aaf6c05eac944a14276cddd67735b2ad856030ffffbb6626c F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c d88033b4748db9929a0096f627d3a75e9fe0e11d7a92724a6c1c575d5448cea4 +F ext/misc/zipfile.c 8075df9296beeebc344567927d114c6d3201110a29110013388d233fa7d4fb2c F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a33ad33cf031edee273afa4735c8564870465be22962a9c277e4ac43a307ff2c -R c9a59c27332856c5c3df1bda98801aaa -U drh -Z 3de3b81c4ea3d2cc9df2aeeb1cbc4214 +P 45495d3e256fef4d0669754726878ed17248fc781397ebb0421149ee9492f977 +R fdf4e94235537d819e1c48759efffe29 +U mistachkin +Z 11d1a9bb2052215696c761adb1621865 diff --git a/manifest.uuid b/manifest.uuid index bb30f4d234..23f6ac3e69 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -45495d3e256fef4d0669754726878ed17248fc781397ebb0421149ee9492f977 \ No newline at end of file +19aabccfe34c956599f33cd3ddc846816adc06784c2496838f1ef53059e038e5 \ No newline at end of file From 5d7503a7894b0d263fe0103d15e2e9a023a75ff9 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 17:12:13 +0000 Subject: [PATCH 042/190] More adjustments to MSVC Makefile dependencies for zlib. FossilOrigin-Name: bb650e5d14642b925c5ea65ba7991b35c4e941405d2557d542b99c66ca4bc130 --- Makefile.msc | 10 +++++----- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index c9b78b68f8..f1d43c22c4 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -636,10 +636,11 @@ SHELL_CORE_DEP = !ENDIF # <> -# If zlib support is enabled, add the shell dependency for it. +# If zlib support is enabled, add the dependencies for it. # !IF $(USE_ZLIB)!=0 && $(BUILD_ZLIB)!=0 SHELL_CORE_DEP = zlib $(SHELL_CORE_DEP) +TESTFIXTURE_DEP = zlib $(TESTFIXTURE_DEP) !ENDIF # <> @@ -2076,15 +2077,14 @@ SHELL_SRC = \ $(TOP)\ext\misc\shathree.c \ $(TOP)\ext\misc\fileio.c \ $(TOP)\ext\misc\completion.c \ - $(TOP)\ext\misc\sqlar.c \ $(TOP)\ext\expert\sqlite3expert.c \ $(TOP)\ext\expert\sqlite3expert.h \ - $(TOP)\ext\misc\zipfile.c \ - $(TOP)\src\test_windirent.c + $(TOP)\src\test_windirent.c # If use of zlib is enabled, add the "zipfile.c" source file. # !IF $(USE_ZLIB)!=0 +SHELL_SRC = $(SHELL_SRC) $(TOP)\ext\misc\sqlar.c SHELL_SRC = $(SHELL_SRC) $(TOP)\ext\misc\zipfile.c !ENDIF @@ -2270,7 +2270,7 @@ sqlite_tcl.h: | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact "Tcl_HashEntry *(*createProc)" "Tcl_HashEntry *(SQLITE_TCLAPI *createProc)" >> $(SQLITETCLH) !ENDIF -testfixture.exe: $(TESTFIXTURE_SRC) $(SQLITE3H) $(LIBRESOBJS) $(HDR) $(SQLITE_TCL_DEP) +testfixture.exe: $(TESTFIXTURE_SRC) $(TESTFIXTURE_DEP) $(SQLITE3H) $(LIBRESOBJS) $(HDR) $(SQLITE_TCL_DEP) $(LTLINK) -DSQLITE_NO_SYNC=1 $(TESTFIXTURE_FLAGS) \ -DBUILD_sqlite -I$(TCLINCDIR) \ $(TESTFIXTURE_SRC) \ diff --git a/manifest b/manifest index fd16cab107..bc639547e1 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Fix\scompiler\swarnings. -D 2018-01-05T17:10:49.665 +C More\sadjustments\sto\sMSVC\sMakefile\sdependencies\sfor\szlib. +D 2018-01-05T17:12:13.607 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in f5c6285ac43b2e567d6cf463dff3744da960a19f2cf141744b4472842a97681e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 69711303f4062857b1f07ecfe74d7952ce56e7401ed0248eea0569fd63b7f664 +F Makefile.msc de37dcd0e875a72b3e4f0d5d962df007e7fffbdebcf588547aa9a414dc690dbc F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 45495d3e256fef4d0669754726878ed17248fc781397ebb0421149ee9492f977 -R fdf4e94235537d819e1c48759efffe29 +P 19aabccfe34c956599f33cd3ddc846816adc06784c2496838f1ef53059e038e5 +R 4f7a61feaaf912b14f8d84b71ecd0523 U mistachkin -Z 11d1a9bb2052215696c761adb1621865 +Z 232e8c03263ea4c4f59899620c8c44c4 diff --git a/manifest.uuid b/manifest.uuid index 23f6ac3e69..4cf798be0b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -19aabccfe34c956599f33cd3ddc846816adc06784c2496838f1ef53059e038e5 \ No newline at end of file +bb650e5d14642b925c5ea65ba7991b35c4e941405d2557d542b99c66ca4bc130 \ No newline at end of file From af23899318236a918af9cbfed85dcc57769077ec Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 17:40:38 +0000 Subject: [PATCH 043/190] In the Makefile for MSVC, the default target should not include binaries that link against the Tcl library. FossilOrigin-Name: 5c6d0a1d58533feb4ea6926f4d3611664a275ad216492b424056276da38e84a2 --- Makefile.msc | 10 +++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index f1d43c22c4..f485e37ca1 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1636,7 +1636,15 @@ ALL_TCL_TARGETS = # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # -all: dll libsqlite3.lib shell $(ALL_TCL_TARGETS) +core: dll libsqlite3.lib shell + +# Targets that require the Tcl library. +# +tcl: $(ALL_TCL_TARGETS) + +# This Makefile target builds all of the standard binaries. +# +all: core tcl # Dynamic link library section. # diff --git a/manifest b/manifest index bc639547e1..0c20fb2e6a 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C More\sadjustments\sto\sMSVC\sMakefile\sdependencies\sfor\szlib. -D 2018-01-05T17:12:13.607 +C In\sthe\sMakefile\sfor\sMSVC,\sthe\sdefault\starget\sshould\snot\sinclude\sbinaries\sthat\slink\sagainst\sthe\sTcl\slibrary. +D 2018-01-05T17:40:38.949 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in f5c6285ac43b2e567d6cf463dff3744da960a19f2cf141744b4472842a97681e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc de37dcd0e875a72b3e4f0d5d962df007e7fffbdebcf588547aa9a414dc690dbc +F Makefile.msc 2335db317697a3ea33ec3a258be9f46c973fcfd4e7cffe6798c6f3d55bc83d5b F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 19aabccfe34c956599f33cd3ddc846816adc06784c2496838f1ef53059e038e5 -R 4f7a61feaaf912b14f8d84b71ecd0523 +P bb650e5d14642b925c5ea65ba7991b35c4e941405d2557d542b99c66ca4bc130 +R cf861d2a1bc231834a93f636736946e1 U mistachkin -Z 232e8c03263ea4c4f59899620c8c44c4 +Z d9fbefa44671c9c82483590ecbf133ab diff --git a/manifest.uuid b/manifest.uuid index 4cf798be0b..a7d2b46577 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bb650e5d14642b925c5ea65ba7991b35c4e941405d2557d542b99c66ca4bc130 \ No newline at end of file +5c6d0a1d58533feb4ea6926f4d3611664a275ad216492b424056276da38e84a2 \ No newline at end of file From 7ee8836e08cca0ecd8af0749e5072e5bc36352cc Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 5 Jan 2018 18:51:25 +0000 Subject: [PATCH 044/190] Fix a bug introduced by efforts to reduce compiler warnings in check-in [364ac333b030f0] FossilOrigin-Name: 1d6cee9ad448b10e69f351ef9dbec09110c5b189cba8734e637f41abe8f35bf8 --- ext/misc/fileio.c | 5 +++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 796bee399c..030b417e40 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -182,13 +182,14 @@ static int makeDirectory( while( rc==SQLITE_OK ){ struct stat sStat; + int rc2; for(; zCopy[i]!='/' && i Date: Fri, 5 Jan 2018 19:25:52 +0000 Subject: [PATCH 045/190] For the MSVC Makefile, the 'sqlite3_checker.exe' target requires the Tcl library. FossilOrigin-Name: 38109a47ffa977f1f962af2e183285d4e5db6fac2344868c5f1de64779dd0839 --- Makefile.msc | 2 +- manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index f485e37ca1..74518e11a9 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2352,7 +2352,7 @@ sqlite3_checker.c: $(CHECKER_DEPS) sqlite3_checker.exe: sqlite3_checker.c $(LIBRESOBJS) $(LTLINK) $(NO_WARN) -DBUILD_sqlite -I$(TCLINCDIR) sqlite3_checker.c \ - /link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LTLIBS) $(TLIBS) + /link $(LDFLAGS) $(LTLINKOPTS) $(TCLLIBPATHS) $(LTLIBPATHS) $(LIBRESOBJS) $(TCLLIBS) $(LTLIBS) $(TLIBS) dbdump.exe: $(TOP)\ext\misc\dbdump.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) -DDBDUMP_STANDALONE $(TOP)\ext\misc\dbdump.c $(SQLITE3C) \ diff --git a/manifest b/manifest index 7a5a46f247..992a88310c 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Add\sthe\s".ar"\scommand\sto\sthe\scommand-line\sshell. -D 2018-01-05T19:01:05.842 +C For\sthe\sMSVC\sMakefile,\sthe\s'sqlite3_checker.exe'\starget\srequires\sthe\sTcl\slibrary. +D 2018-01-05T19:25:52.005 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in f5c6285ac43b2e567d6cf463dff3744da960a19f2cf141744b4472842a97681e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 2335db317697a3ea33ec3a258be9f46c973fcfd4e7cffe6798c6f3d55bc83d5b +F Makefile.msc d429170f3c6d35390280ce0dff79fa0ef3ec5bb11ff981d0195a77a97cd8f67f F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1694,8 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a4876672edea4e96103efd2463ce9a34a0b994a8744c941660940578aafbd454 1d6cee9ad448b10e69f351ef9dbec09110c5b189cba8734e637f41abe8f35bf8 -R af65ab601703ff43220f8cbd5a0328ec -T +closed 1d6cee9ad448b10e69f351ef9dbec09110c5b189cba8734e637f41abe8f35bf8 -U drh -Z 35e4e889b7dd1f4bdfa8de9e35b21bb1 +P 148b8aee78e40cab9a758a920589bd3ca8fc1c45cc93598bc50d96b85cd17e6c +R 3bd57aef0f7576f9a9295eae8b71396f +U mistachkin +Z 21f077ad1d1dc6de7af623b34ca85770 diff --git a/manifest.uuid b/manifest.uuid index ef03cb90bf..77e9c2d595 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -148b8aee78e40cab9a758a920589bd3ca8fc1c45cc93598bc50d96b85cd17e6c \ No newline at end of file +38109a47ffa977f1f962af2e183285d4e5db6fac2344868c5f1de64779dd0839 \ No newline at end of file From 992fdfc5d88f8ba7fca981296b259f2d9c2a3ae2 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 19:27:19 +0000 Subject: [PATCH 046/190] The 'releasetest' tool should pass the TCLDIR macro for MSVC to nmake. FossilOrigin-Name: eaa9c0dda73808f1458f9968be59947636fbd4781c9fc535eb50bcaf790093c1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/releasetest.tcl | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 992a88310c..56e9862e98 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sthe\sMSVC\sMakefile,\sthe\s'sqlite3_checker.exe'\starget\srequires\sthe\sTcl\slibrary. -D 2018-01-05T19:25:52.005 +C The\s'releasetest'\stool\sshould\spass\sthe\sTCLDIR\smacro\sfor\sMSVC\sto\snmake. +D 2018-01-05T19:27:19.800 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in f5c6285ac43b2e567d6cf463dff3744da960a19f2cf141744b4472842a97681e @@ -1151,7 +1151,7 @@ F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/regexp2.test 40e894223b3d6672655481493f1be12012f2b33c F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl 0b0b3d926e36822ff63b405d683544ce1014303b029f2678bbcf40c162b5f246 x +F test/releasetest.tcl 6aaa853f7a7bbdc458d4cb42c0425228729b0f3e5769e9b41088c08eee999a49 x F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test f580934279800d480a19176c6b44909df31ce7ad45267ea475a541daa522f3d3 F test/rollback2.test 8435d6ff0f13f51d2a4181c232e706005fa90fc5 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 148b8aee78e40cab9a758a920589bd3ca8fc1c45cc93598bc50d96b85cd17e6c -R 3bd57aef0f7576f9a9295eae8b71396f +P 38109a47ffa977f1f962af2e183285d4e5db6fac2344868c5f1de64779dd0839 +R 9eed99f952d882095a7640a2b2c94c61 U mistachkin -Z 21f077ad1d1dc6de7af623b34ca85770 +Z 7e88bc6a5eaa12b61e53263c5085cc0a diff --git a/manifest.uuid b/manifest.uuid index 77e9c2d595..f9e69f73df 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38109a47ffa977f1f962af2e183285d4e5db6fac2344868c5f1de64779dd0839 \ No newline at end of file +eaa9c0dda73808f1458f9968be59947636fbd4781c9fc535eb50bcaf790093c1 \ No newline at end of file diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 5055e81129..599ebd791d 100755 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -734,6 +734,9 @@ proc makeCommand { targets makeOpts cflags opts } { set nmakeDir [file nativename $::SRCDIR] set nmakeFile [file nativename [file join $nmakeDir Makefile.msc]] lappend result nmake /f $nmakeFile TOP=$nmakeDir + set tclDir [file nativename [file normalize \ + [file dirname [file dirname [info nameofexecutable]]]]] + lappend result "TCLDIR=$tclDir" if {[regexp {USE_STDCALL=1} $cflags]} { lappend result USE_STDCALL=1 } From b3ec2e1f4a6d75c7e1b959c8fdab2efc94f0a7c9 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 19:28:16 +0000 Subject: [PATCH 047/190] Sync up the autoconf Makefile for MSVC. FossilOrigin-Name: da8712bdb8f69dee9efb42b74d0b2ec10043f281c5f93e2724078bdf1370ecb1 --- autoconf/Makefile.msc | 11 ++++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index 5b5133c8b9..5f7c693d42 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -930,13 +930,22 @@ LIBRESOBJS = !IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_STMTVTAB SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB +SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_INTROSPECTION_PRAGMAS !ENDIF # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # -all: dll shell +core: dll shell + +# Targets that require the Tcl library. +# +tcl: $(ALL_TCL_TARGETS) + +# This Makefile target builds all of the standard binaries. +# +all: core tcl # Dynamic link library section. # diff --git a/manifest b/manifest index 56e9862e98..053d4e4270 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\s'releasetest'\stool\sshould\spass\sthe\sTCLDIR\smacro\sfor\sMSVC\sto\snmake. -D 2018-01-05T19:27:19.800 +C Sync\sup\sthe\sautoconf\sMakefile\sfor\sMSVC. +D 2018-01-05T19:28:16.538 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in f5c6285ac43b2e567d6cf463dff3744da960a19f2cf141744b4472842a97681e @@ -13,7 +13,7 @@ F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am 66c0befa511f0d95ba229e180067cf0357a9ebf8b3201b06d683c5ba6220fb39 -F autoconf/Makefile.msc 2b4b5e5ff7e7a9806ebdd4b441f8fb54695a3628701a97ae53860e67e872acc3 +F autoconf/Makefile.msc 2c50a59319af7da4eaca8c13e3240881b1bc245fd175845a055faab7d03d6e67 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 F autoconf/configure.ac 8dd08ca564279fff091c9bfdd2599d8f992c9f1f70c5396de2126ad2bd1b3bed @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 38109a47ffa977f1f962af2e183285d4e5db6fac2344868c5f1de64779dd0839 -R 9eed99f952d882095a7640a2b2c94c61 +P eaa9c0dda73808f1458f9968be59947636fbd4781c9fc535eb50bcaf790093c1 +R aebea1e00e37b18810f9236f36666933 U mistachkin -Z 7e88bc6a5eaa12b61e53263c5085cc0a +Z b1ea0ac834ae5e03c81c10b82e8229f6 diff --git a/manifest.uuid b/manifest.uuid index f9e69f73df..b571106f7f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eaa9c0dda73808f1458f9968be59947636fbd4781c9fc535eb50bcaf790093c1 \ No newline at end of file +da8712bdb8f69dee9efb42b74d0b2ec10043f281c5f93e2724078bdf1370ecb1 \ No newline at end of file From 411dfd4e6dc25a3b5e763b03ac1e7aeca46ee44d Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 5 Jan 2018 19:49:54 +0000 Subject: [PATCH 048/190] Fix the autoconf makefile so that it builds testfixture correctly. FossilOrigin-Name: fbfe04c0b4f261789cbda3d2e98d12508181c283eab0bb757b081f0383e891bd --- Makefile.in | 3 ++- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index f6933f6c7e..da01248f4f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -447,7 +447,8 @@ TESTSRC += \ $(TOP)/ext/misc/spellfix.c \ $(TOP)/ext/misc/totype.c \ $(TOP)/ext/misc/unionvtab.c \ - $(TOP)/ext/misc/wholenumber.c + $(TOP)/ext/misc/wholenumber.c \ + $(TOP)/ext/misc/zipfile.c # Source code to the library files needed by the test fixture # diff --git a/manifest b/manifest index 053d4e4270..bc23c568bb 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Sync\sup\sthe\sautoconf\sMakefile\sfor\sMSVC. -D 2018-01-05T19:28:16.538 +C Fix\sthe\sautoconf\smakefile\sso\sthat\sit\sbuilds\stestfixture\scorrectly. +D 2018-01-05T19:49:54.732 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea -F Makefile.in f5c6285ac43b2e567d6cf463dff3744da960a19f2cf141744b4472842a97681e +F Makefile.in c4a9842dcd07572a106da739fa4f76d5ae228e3c4c40c859c84ceaa71c36348e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d429170f3c6d35390280ce0dff79fa0ef3ec5bb11ff981d0195a77a97cd8f67f F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eaa9c0dda73808f1458f9968be59947636fbd4781c9fc535eb50bcaf790093c1 -R aebea1e00e37b18810f9236f36666933 -U mistachkin -Z b1ea0ac834ae5e03c81c10b82e8229f6 +P da8712bdb8f69dee9efb42b74d0b2ec10043f281c5f93e2724078bdf1370ecb1 +R 3f6a7684abe5e233e60eee143543b86b +U drh +Z 40c46b9c1ab67658db9ed4b73dac85b2 diff --git a/manifest.uuid b/manifest.uuid index b571106f7f..23f8f09cd2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -da8712bdb8f69dee9efb42b74d0b2ec10043f281c5f93e2724078bdf1370ecb1 \ No newline at end of file +fbfe04c0b4f261789cbda3d2e98d12508181c283eab0bb757b081f0383e891bd \ No newline at end of file From acae8c3e5d663907ab517f0575c28ef8cbac7dda Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 20:08:46 +0000 Subject: [PATCH 049/190] Fix shell compilation with MinGW by including the 'dirent.h' header. FossilOrigin-Name: dfe510b51046a53c7f5c54fe73ec9de3364923eabd4b909c11984552e6bea406 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 9 +++++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index bc23c568bb..98c8245baf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sautoconf\smakefile\sso\sthat\sit\sbuilds\stestfixture\scorrectly. -D 2018-01-05T19:49:54.732 +C Fix\sshell\scompilation\swith\sMinGW\sby\sincluding\sthe\s'dirent.h'\sheader. +D 2018-01-05T20:08:46.463 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in c4a9842dcd07572a106da739fa4f76d5ae228e3c4c40c859c84ceaa71c36348e @@ -483,7 +483,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 17fc28661aae277767db63fa90e644b8c9bf1242fbd167dcc2e7af0f0e620bb7 +F src/shell.c.in 54b689b5c4301c77c27cb74030387a8fa311ca8e419efde97c32368447496adf F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P da8712bdb8f69dee9efb42b74d0b2ec10043f281c5f93e2724078bdf1370ecb1 -R 3f6a7684abe5e233e60eee143543b86b -U drh -Z 40c46b9c1ab67658db9ed4b73dac85b2 +P fbfe04c0b4f261789cbda3d2e98d12508181c283eab0bb757b081f0383e891bd +R 67b7409129088d9700def94a0c3a7e6a +U mistachkin +Z 6191ddbb449a249c839487fd17b108da diff --git a/manifest.uuid b/manifest.uuid index 23f8f09cd2..26377c9417 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fbfe04c0b4f261789cbda3d2e98d12508181c283eab0bb757b081f0383e891bd \ No newline at end of file +dfe510b51046a53c7f5c54fe73ec9de3364923eabd4b909c11984552e6bea406 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index eb5f0b42ed..691e7750ad 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -72,7 +72,13 @@ # if !defined(__RTP__) && !defined(_WRS_KERNEL) # include # endif +#endif +#if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW_H) # include +# include +# if defined(__MINGW_H) +# define DIRENT dirent +# endif #endif #include #include @@ -875,10 +881,9 @@ static void shellAddSchemaName( #define SQLITE_EXTENSION_INIT1 #define SQLITE_EXTENSION_INIT2(X) (void)(X) -#if defined(_WIN32) || defined(WIN32) +#if defined(_WIN32) && defined(_MSC_VER) INCLUDE test_windirent.c #define dirent DIRENT -#define timespec TIMESPEC #endif INCLUDE ../ext/misc/shathree.c INCLUDE ../ext/misc/fileio.c From f2e8aa637e91814b4e823af4e474001fbddb1449 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 20:13:33 +0000 Subject: [PATCH 050/190] Skip running the 'zipfile' test if the necessary static package cannot be loaded. FossilOrigin-Name: 5bc816ec4010c20407396a1051e9f9b0a360ca27c0a99dafa867225cf974e306 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/zipfile.test | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 98c8245baf..b645c837cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sshell\scompilation\swith\sMinGW\sby\sincluding\sthe\s'dirent.h'\sheader. -D 2018-01-05T20:08:46.463 +C Skip\srunning\sthe\s'zipfile'\stest\sif\sthe\snecessary\sstatic\spackage\scannot\sbe\sloaded. +D 2018-01-05T20:13:33.577 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in c4a9842dcd07572a106da739fa4f76d5ae228e3c4c40c859c84ceaa71c36348e @@ -1597,7 +1597,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e -F test/zipfile.test d4f342ca918fd4d7981a12c1523f5041074cc592f25fecce4ee11446cc984f56 +F test/zipfile.test a1dd0429294cb9487900fc2b29aa9921329f20a7314aa0921b668246172ac090 F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fbfe04c0b4f261789cbda3d2e98d12508181c283eab0bb757b081f0383e891bd -R 67b7409129088d9700def94a0c3a7e6a +P dfe510b51046a53c7f5c54fe73ec9de3364923eabd4b909c11984552e6bea406 +R 77b0d484d37ac0b70535216ad42f574c U mistachkin -Z 6191ddbb449a249c839487fd17b108da +Z 2a7cfd5e6817597b58865e4e49810899 diff --git a/manifest.uuid b/manifest.uuid index 26377c9417..325fc3f2c3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dfe510b51046a53c7f5c54fe73ec9de3364923eabd4b909c11984552e6bea406 \ No newline at end of file +5bc816ec4010c20407396a1051e9f9b0a360ca27c0a99dafa867225cf974e306 \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index 3f7b34d55d..627945651b 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -14,7 +14,10 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix zipfile -load_static_extension db zipfile +if {[catch {load_static_extension db zipfile} error]} { + puts "Skipping zipfile tests, hit load error: $error" + finish_test; return +} forcedelete test.zip do_execsql_test 1.0 { From 2f74b3c3abbad9773b0cbca215b1fbf23d6ce068 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 5 Jan 2018 20:26:06 +0000 Subject: [PATCH 051/190] MinGW does not define the S_ISLNK macro; therefore, define it in the shell when needed. FossilOrigin-Name: 73023febbe57495a22db05904bd6ddff439d6c25970cbe87e0ba4a923f3e8a29 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index b645c837cd..bbcb9ab663 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Skip\srunning\sthe\s'zipfile'\stest\sif\sthe\snecessary\sstatic\spackage\scannot\sbe\sloaded. -D 2018-01-05T20:13:33.577 +C MinGW\sdoes\snot\sdefine\sthe\sS_ISLNK\smacro;\stherefore,\sdefine\sit\sin\sthe\sshell\swhen\sneeded. +D 2018-01-05T20:26:06.480 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in c4a9842dcd07572a106da739fa4f76d5ae228e3c4c40c859c84ceaa71c36348e @@ -483,7 +483,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 54b689b5c4301c77c27cb74030387a8fa311ca8e419efde97c32368447496adf +F src/shell.c.in df0e5728a6b41c676f0bb55716ca317081eba5e741ba45e513c842c4533bda58 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dfe510b51046a53c7f5c54fe73ec9de3364923eabd4b909c11984552e6bea406 -R 77b0d484d37ac0b70535216ad42f574c +P 5bc816ec4010c20407396a1051e9f9b0a360ca27c0a99dafa867225cf974e306 +R 1b1f2c1c694e2046fcfe9404f479b19a U mistachkin -Z 2a7cfd5e6817597b58865e4e49810899 +Z 8141067c4aab566b846a47904d7a2b0b diff --git a/manifest.uuid b/manifest.uuid index 325fc3f2c3..c2654be9be 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5bc816ec4010c20407396a1051e9f9b0a360ca27c0a99dafa867225cf974e306 \ No newline at end of file +73023febbe57495a22db05904bd6ddff439d6c25970cbe87e0ba4a923f3e8a29 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 691e7750ad..832450fea7 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -78,6 +78,9 @@ # include # if defined(__MINGW_H) # define DIRENT dirent +# ifndef S_ISLNK +# define S_ISLNK(mode) (0) +# endif # endif #endif #include From f5c75626ffeaa939a294259c4028a2bc27db6c50 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 5 Jan 2018 20:30:54 +0000 Subject: [PATCH 052/190] Fix the shell.c.in amalgamator script so that it avoids generating redundant typedef statements. FossilOrigin-Name: 6c53c740cb4f62305689ea0a73beca83e71ed86707094e850bed975965c8c9f2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/mkshellc.tcl | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index bbcb9ab663..9634780370 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C MinGW\sdoes\snot\sdefine\sthe\sS_ISLNK\smacro;\stherefore,\sdefine\sit\sin\sthe\sshell\swhen\sneeded. -D 2018-01-05T20:26:06.480 +C Fix\sthe\sshell.c.in\samalgamator\sscript\sso\sthat\sit\savoids\sgenerating\nredundant\stypedef\sstatements. +D 2018-01-05T20:30:54.903 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in c4a9842dcd07572a106da739fa4f76d5ae228e3c4c40c859c84ceaa71c36348e @@ -1630,7 +1630,7 @@ F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c F tool/mkopcodeh.tcl 4ee2a30ccbd900dc4d5cdb61bdab87cd2166cd2affcc78c9cc0b8d22a65b2eee F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkpragmatab.tcl 2144bc8550a6471a029db262a132d2df4b9e0db61b90398bf64f5b7b3f8d92cd -F tool/mkshellc.tcl 574307265b49d813301fba91ccd74e6a26d33f65f74b6891c320a0ffbee07895 +F tool/mkshellc.tcl 8cb90170e4aed5bd26f1664a83727c5d451f86948d3b759be26c1d7879fa346f F tool/mksourceid.c d458f9004c837bee87a6382228ac20d3eae3c49ea3b0a5aace936f8b60748d3b F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5bc816ec4010c20407396a1051e9f9b0a360ca27c0a99dafa867225cf974e306 -R 1b1f2c1c694e2046fcfe9404f479b19a -U mistachkin -Z 8141067c4aab566b846a47904d7a2b0b +P 73023febbe57495a22db05904bd6ddff439d6c25970cbe87e0ba4a923f3e8a29 +R 9251688fbd83640e3673feb22bd548ce +U drh +Z 4f1367bc1221f28464fd760bb035ab98 diff --git a/manifest.uuid b/manifest.uuid index c2654be9be..3810fe5730 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -73023febbe57495a22db05904bd6ddff439d6c25970cbe87e0ba4a923f3e8a29 \ No newline at end of file +6c53c740cb4f62305689ea0a73beca83e71ed86707094e850bed975965c8c9f2 \ No newline at end of file diff --git a/tool/mkshellc.tcl b/tool/mkshellc.tcl index 807a169826..1a98511ef9 100644 --- a/tool/mkshellc.tcl +++ b/tool/mkshellc.tcl @@ -30,15 +30,25 @@ puts $out {/* DO NOT EDIT! ** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script. */} set in [open $topdir/src/shell.c.in rb] +proc omit_redundant_typedefs {line} { + global typedef_seen + if {[regexp {^typedef .*;} $line]} { + if {[info exists typedef_seen($line)]} { + return "/* $line */" + } + set typedef_seen($line) 1 + } + return $line +} while {1} { - set lx [gets $in] + set lx [omit_redundant_typedefs [gets $in]] if {[eof $in]} break; if {[regexp {^INCLUDE } $lx]} { set cfile [lindex $lx 1] puts $out "/************************* Begin $cfile ******************/" set in2 [open $topdir/src/$cfile rb] while {![eof $in2]} { - set lx [gets $in2] + set lx [omit_redundant_typedefs [gets $in2]] if {[regexp {^#include "sqlite} $lx]} continue set lx [string map [list __declspec(dllexport) {}] $lx] puts $out $lx From 1e506b5527a1fd842610b973cf21969cab4ac269 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 5 Jan 2018 21:01:37 +0000 Subject: [PATCH 053/190] Make sure i64 and u64 typedefs are available throughout shell.c. FossilOrigin-Name: 656fb5aab32f40412389e43de209867cedee1589533949cc8c01ba24218ea434 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 9634780370..d848453f6a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sshell.c.in\samalgamator\sscript\sso\sthat\sit\savoids\sgenerating\nredundant\stypedef\sstatements. -D 2018-01-05T20:30:54.903 +C Make\ssure\si64\sand\su64\stypedefs\sare\savailable\sthroughout\sshell.c. +D 2018-01-05T21:01:37.129 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in c4a9842dcd07572a106da739fa4f76d5ae228e3c4c40c859c84ceaa71c36348e @@ -483,7 +483,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in df0e5728a6b41c676f0bb55716ca317081eba5e741ba45e513c842c4533bda58 +F src/shell.c.in 4cfa9394737306c5a5f3d7f72e74868df5f3010676d6a1a2a52db37b61b0c13a F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1694,7 +1694,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 73023febbe57495a22db05904bd6ddff439d6c25970cbe87e0ba4a923f3e8a29 -R 9251688fbd83640e3673feb22bd548ce +P 6c53c740cb4f62305689ea0a73beca83e71ed86707094e850bed975965c8c9f2 +R 7d026919c293c5c42c6d20698632fda7 U drh -Z 4f1367bc1221f28464fd760bb035ab98 +Z 6c996af85ed6472bcfa0c4295fc91bf0 diff --git a/manifest.uuid b/manifest.uuid index 3810fe5730..b50e96dbc6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6c53c740cb4f62305689ea0a73beca83e71ed86707094e850bed975965c8c9f2 \ No newline at end of file +656fb5aab32f40412389e43de209867cedee1589533949cc8c01ba24218ea434 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 832450fea7..bb4428fbc5 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -61,6 +61,8 @@ #include #include #include "sqlite3.h" +typedef sqlite3_int64 i64; +typedef sqlite3_uint64 u64; #if SQLITE_USER_AUTHENTICATION # include "sqlite3userauth.h" #endif From 9dea173154d490489c7794f945a153d1a9de058b Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 6 Jan 2018 04:34:05 +0000 Subject: [PATCH 054/190] Add sqltclsh.exe to the windows makefile. FossilOrigin-Name: a6d5c7c2aabd70b4fb2bd8f6278f70272a5bd166adf2f7225ea582e10a46fafa --- Makefile.msc | 11 ++++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 652bd81fd0..5bea16eab0 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1495,7 +1495,8 @@ TESTPROGS = \ sqlite3_analyzer.exe \ sqlite3_checker.exe \ sqldiff.exe \ - dbhash.exe + dbhash.exe \ + sqltclsh.exe # Databases containing fuzzer test cases # @@ -2222,6 +2223,14 @@ sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS) $(LTLINK) $(NO_WARN) -DBUILD_sqlite -I$(TCLINCDIR) sqlite3_analyzer.c \ /link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LTLIBS) $(TLIBS) +sqltclsh.c: sqlite3.c $(TOP)\src\tclsqlite.c $(TOP)\tool\sqltclsh.tcl $(TOP)\ext\misc\appendvfs.c $(TOP)\tool\mkccode.tcl $(TOP)\tool\sqltclsh.c.in + $(TCLSH_CMD) $(TOP)\tool\mkccode.tcl $(TOP)\tool\sqltclsh.c.in >sqltclsh.c + +sqltclsh.exe: sqltclsh.c + $(LTLINK) $(NO_WARN) -DBUILD_sqlite -I$(TCLINCDIR) sqltclsh.c \ + /link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) $(LTLIBS) $(TLIBS) + + sqlite3_expert.exe: $(SQLITE3C) $(TOP)\ext\expert\sqlite3expert.h $(TOP)\ext\expert\sqlite3expert.c $(TOP)\ext\expert\expert.c $(LTLINK) $(NO_WARN) $(TOP)\ext\expert\sqlite3expert.c $(TOP)\ext\expert\expert.c $(SQLITE3C) $(TLIBS) diff --git a/manifest b/manifest index c5aed3eac5..3f55a3838d 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Merge\srecent\senhancements\sfrom\strunk. -D 2017-12-23T18:40:39.094 +C Add\ssqltclsh.exe\sto\sthe\swindows\smakefile. +D 2018-01-06T04:34:05.887 F Makefile.in f2dc8c140e1d728157834da295eaaa8a0cb29620595c2a9f0efc7258797e6f24 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 6480671f7c129e61208d69492b3c71ce4310d49fceac83cfb17f1c081e242b69 +F Makefile.msc 80cca5fd5760cb3e26aaedaf6ef0df155cab3761a98efd0aa819973713839ca9 F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1690,7 +1690,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ee248b529c2396c5480fb99b0a1dc31032627ec8241eca4a8c0fff257bb4a088 07c773148d8db185fa54991df09298b64f4fef28879e6c9395759265e8183977 -R 38880472a25b77bfdeb87344d5313674 +P edceaccd66a65d6b36e53ce33d760a7bd9c2261a592d12189f5f55417b5d5d74 +R 724c729f15e9ebb158a68ffbc1395b1f U drh -Z 5274401ef77d35314ed9b1a10cd6e401 +Z adb127fe5f715fb70b7df6486f1fd9f2 diff --git a/manifest.uuid b/manifest.uuid index 9da9bac5e4..3d96106fb5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -edceaccd66a65d6b36e53ce33d760a7bd9c2261a592d12189f5f55417b5d5d74 \ No newline at end of file +a6d5c7c2aabd70b4fb2bd8f6278f70272a5bd166adf2f7225ea582e10a46fafa \ No newline at end of file From 6b9986e84a3e0b3edce6c7f5a7693c1d9d725616 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 6 Jan 2018 13:33:21 +0000 Subject: [PATCH 055/190] Fix the appendvfs so that it leaves sqlite3_file->pMethods as NULL if it fails to open. FossilOrigin-Name: 46b341e3ad11b807ae50f001b970299de7ea0d523dbb639ee10f1d5aca5d958b --- ext/misc/appendvfs.c | 13 +++++++------ manifest | 14 +++++++------- manifest.uuid | 2 +- tool/sqltclsh.tcl | 3 +++ 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/ext/misc/appendvfs.c b/ext/misc/appendvfs.c index c6e9e0d58b..24d5e5f15b 100644 --- a/ext/misc/appendvfs.c +++ b/ext/misc/appendvfs.c @@ -440,14 +440,14 @@ static int apndOpen( } p = (ApndFile*)pFile; memset(p, 0, sizeof(*p)); - p->base.pMethods = &apnd_io_methods; pSubFile = ORIGFILE(pFile); + p->base.pMethods = &apnd_io_methods; rc = pSubVfs->xOpen(pSubVfs, zName, pSubFile, flags, pOutFlags); - if( rc ) return rc; + if( rc ) goto apnd_open_done; rc = pSubFile->pMethods->xFileSize(pSubFile, &sz); if( rc ){ pSubFile->pMethods->xClose(pSubFile); - return rc; + goto apnd_open_done; } if( apndIsOrdinaryDatabaseFile(sz, pSubFile) ){ memmove(pFile, pSubFile, pSubVfs->szOsFile); @@ -460,11 +460,12 @@ static int apndOpen( } if( (flags & SQLITE_OPEN_CREATE)==0 ){ pSubFile->pMethods->xClose(pSubFile); - pFile->pMethods = 0; - return SQLITE_CANTOPEN; + rc = SQLITE_CANTOPEN; } p->iPgOne = (sz+0xfff) & ~(sqlite3_int64)0xfff; - return SQLITE_OK; +apnd_open_done: + if( rc ) pFile->pMethods = 0; + return rc; } /* diff --git a/manifest b/manifest index 3f55a3838d..f93f6fa978 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssqltclsh.exe\sto\sthe\swindows\smakefile. -D 2018-01-06T04:34:05.887 +C Fix\sthe\sappendvfs\sso\sthat\sit\sleaves\ssqlite3_file->pMethods\sas\sNULL\sif\sit\nfails\sto\sopen. +D 2018-01-06T13:33:21.118 F Makefile.in f2dc8c140e1d728157834da295eaaa8a0cb29620595c2a9f0efc7258797e6f24 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 80cca5fd5760cb3e26aaedaf6ef0df155cab3761a98efd0aa819973713839ca9 @@ -266,7 +266,7 @@ F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f607 F ext/misc/README.md 8e008c8d2b02e09096b31dfba033253ac27c6c06a18aa5826e299fa7601d90b2 F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb -F ext/misc/appendvfs.c 8cc3ae6633e7d97ca9c3c9a48c647e9ba23f8d24f3d5f5f596272a81dc50c398 +F ext/misc/appendvfs.c 24b72d0556e81939c19316ca48c628938b4bd0ec81dac076406260c3ccd51def F ext/misc/btreeinfo.c d7fd9a2fe2fa33ba28488e2fce703ebecc759219ea9e0bb3b254784866c0a676 F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 @@ -1658,7 +1658,7 @@ F tool/split-sqlite3c.tcl 3efcd4240b738f6bb2b5af0aea7e1e0ef9bc1c61654f645076cec8 F tool/sqldiff.c 30879bbc8de686df4624e86adce2d8981f500904c1cfb55b5d1eea2ffd9341eb F tool/sqlite3_analyzer.c.in 7eeaae8b0d7577662acaabbb11107af0659d1b41bc1dfdd4d91422de27127968 F tool/sqltclsh.c.in e1f48150f755bfbe0194478cba50aa9f2f5183bb1efbdd6456532cce3cd2e18d -F tool/sqltclsh.tcl 71bdb62c8f6b37c05b2d377e870c3dd13ee96cc4fee5b5ae5215ae9a0aca088d +F tool/sqltclsh.tcl 18adb7d4a24374a3c79a2acc011b5f54a22186beec13056b0fa3ca011711c4f3 F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d @@ -1690,7 +1690,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P edceaccd66a65d6b36e53ce33d760a7bd9c2261a592d12189f5f55417b5d5d74 -R 724c729f15e9ebb158a68ffbc1395b1f +P a6d5c7c2aabd70b4fb2bd8f6278f70272a5bd166adf2f7225ea582e10a46fafa +R 11d42f816c24c039c3f505e6266a4bae U drh -Z adb127fe5f715fb70b7df6486f1fd9f2 +Z 83fb91d11f3679f988cee9a994d344b9 diff --git a/manifest.uuid b/manifest.uuid index 3d96106fb5..73d812be11 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a6d5c7c2aabd70b4fb2bd8f6278f70272a5bd166adf2f7225ea582e10a46fafa \ No newline at end of file +46b341e3ad11b807ae50f001b970299de7ea0d523dbb639ee10f1d5aca5d958b \ No newline at end of file diff --git a/tool/sqltclsh.tcl b/tool/sqltclsh.tcl index 999f166ccb..61d00f1df2 100644 --- a/tool/sqltclsh.tcl +++ b/tool/sqltclsh.tcl @@ -2,6 +2,9 @@ # field where "scripts.name" is 'main.tcl' # catch { + if {![file exists $argv0] && [file exists $argv0.exe]} { + append argv0 .exe + } sqlite3 db $argv0 -vfs apndvfs -create 0 set mainscript [db one {SELECT data FROM scripts WHERE name='main.tcl'}] } From 0476b95c4333e0f0ee6854326518f2ecb00d0060 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 6 Jan 2018 14:43:33 +0000 Subject: [PATCH 056/190] Minor tweaks to the Makefile for MSVC. FossilOrigin-Name: 2f6cc5d8a0d9d961d1daf46e8725f7373f740afa788cf99ede9689f49d3a54ec --- Makefile.msc | 4 ++-- manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index feab1b0a40..88a0a23a4d 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2340,8 +2340,7 @@ sqltclsh.c: sqlite3.c $(TOP)\src\tclsqlite.c $(TOP)\tool\sqltclsh.tcl $(TOP)\ext sqltclsh.exe: sqltclsh.c $(LTLINK) $(NO_WARN) -DBUILD_sqlite -I$(TCLINCDIR) sqltclsh.c \ - /link $(LDFLAGS) $(LTLINKOPTS) $(TCLLIBPATHS) $(LTLIBPATHS) $(LIBRESOBJS) $(TCLLIBS) $(LTLIBS) $(TLIBS) - + /link $(LDFLAGS) $(LTLINKOPTS) $(TCLLIBPATHS) $(LTLIBPATHS) $(LIBRESOBJS) $(TCLLIBS) $(LTLIBS) $(TLIBS) sqlite3_expert.exe: $(SQLITE3C) $(TOP)\ext\expert\sqlite3expert.h $(TOP)\ext\expert\sqlite3expert.c $(TOP)\ext\expert\expert.c $(LTLINK) $(NO_WARN) $(TOP)\ext\expert\sqlite3expert.c $(TOP)\ext\expert\expert.c $(SQLITE3C) $(TLIBS) @@ -2462,6 +2461,7 @@ clean: del /Q sqlite3_analyzer.exe sqlite3_analyzer.c 2>NUL del /Q sqlite-*-output.vsix 2>NUL del /Q fuzzershell.exe fuzzcheck.exe sqldiff.exe dbhash.exe 2>NUL + del /Q sqltclsh.exe 2>NUL del /Q fts5.* fts5parse.* 2>NUL del /Q lsm.h lsm1.c 2>NUL # <> diff --git a/manifest b/manifest index 5b51a62935..e01a917ad1 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Add\sthe\sappendvfs\sextension\sand\scode\sfor\sthe\ssqltclsh.exe\sexecutable. -D 2018-01-06T13:42:27.074 +C Minor\stweaks\sto\sthe\sMakefile\sfor\sMSVC. +D 2018-01-06T14:43:33.919 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 9536f61ce33172d4868707ecc10844a0abef9e2e775ad2434245a60406fd7e38 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc b85c373ee4d962cb52beddda3bc78d289a768f8ca8bd3d68eea8eadf6dd04d43 +F Makefile.msc 50cadb65af908a048a5624330782a91bc831a79da19ba17dcf7d273739191413 F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1697,8 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 656fb5aab32f40412389e43de209867cedee1589533949cc8c01ba24218ea434 46b341e3ad11b807ae50f001b970299de7ea0d523dbb639ee10f1d5aca5d958b -R 554a8f967a9f4add06a7ff77d66966de -T +closed 46b341e3ad11b807ae50f001b970299de7ea0d523dbb639ee10f1d5aca5d958b -U drh -Z 85cb71c6d2228eace4706c2b9c3e1fa8 +P b0a43e325c53ec0df50fd41acffbbee65eac47b9318868e6959cd39da66fa8d6 +R c768913b6d54732f0058c9759aabde34 +U mistachkin +Z a162015bb17d305104612ae9f13f8b23 diff --git a/manifest.uuid b/manifest.uuid index 06963ea079..588573c2f4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b0a43e325c53ec0df50fd41acffbbee65eac47b9318868e6959cd39da66fa8d6 \ No newline at end of file +2f6cc5d8a0d9d961d1daf46e8725f7373f740afa788cf99ede9689f49d3a54ec \ No newline at end of file From 5e6f782f118c42b766163434a105071cb4904c0f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 6 Jan 2018 14:44:29 +0000 Subject: [PATCH 057/190] Remove a trailing tab from the Makefile for MSVC. FossilOrigin-Name: 00cc26e34d2b81f140b031aa2f9ae0e2a4835cdd261d68f94b3e18a1388ca73d --- Makefile.msc | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 88a0a23a4d..d103cdc6e3 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2335,7 +2335,7 @@ sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS) $(LTLINK) $(NO_WARN) -DBUILD_sqlite -I$(TCLINCDIR) sqlite3_analyzer.c \ /link $(LDFLAGS) $(LTLINKOPTS) $(TCLLIBPATHS) $(LTLIBPATHS) $(LIBRESOBJS) $(TCLLIBS) $(LTLIBS) $(TLIBS) -sqltclsh.c: sqlite3.c $(TOP)\src\tclsqlite.c $(TOP)\tool\sqltclsh.tcl $(TOP)\ext\misc\appendvfs.c $(TOP)\tool\mkccode.tcl $(TOP)\tool\sqltclsh.c.in +sqltclsh.c: sqlite3.c $(TOP)\src\tclsqlite.c $(TOP)\tool\sqltclsh.tcl $(TOP)\ext\misc\appendvfs.c $(TOP)\tool\mkccode.tcl $(TOP)\tool\sqltclsh.c.in $(TCLSH_CMD) $(TOP)\tool\mkccode.tcl $(TOP)\tool\sqltclsh.c.in >sqltclsh.c sqltclsh.exe: sqltclsh.c diff --git a/manifest b/manifest index e01a917ad1..7690a6a790 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Minor\stweaks\sto\sthe\sMakefile\sfor\sMSVC. -D 2018-01-06T14:43:33.919 +C Remove\sa\strailing\stab\sfrom\sthe\sMakefile\sfor\sMSVC. +D 2018-01-06T14:44:29.580 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 9536f61ce33172d4868707ecc10844a0abef9e2e775ad2434245a60406fd7e38 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 50cadb65af908a048a5624330782a91bc831a79da19ba17dcf7d273739191413 +F Makefile.msc 688fb6375f78dc41f3a4a67201e4d5ef62ef556faa776c7cbe2c50a887d1fa5d F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b0a43e325c53ec0df50fd41acffbbee65eac47b9318868e6959cd39da66fa8d6 -R c768913b6d54732f0058c9759aabde34 +P 2f6cc5d8a0d9d961d1daf46e8725f7373f740afa788cf99ede9689f49d3a54ec +R 5465f05e31d38450dc68aa4d6f2bc0a7 U mistachkin -Z a162015bb17d305104612ae9f13f8b23 +Z 16a3cdc1a076fc6d00702b3c46501e75 diff --git a/manifest.uuid b/manifest.uuid index 588573c2f4..165554be57 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f6cc5d8a0d9d961d1daf46e8725f7373f740afa788cf99ede9689f49d3a54ec \ No newline at end of file +00cc26e34d2b81f140b031aa2f9ae0e2a4835cdd261d68f94b3e18a1388ca73d \ No newline at end of file From 11be81d41365f3369434c81c8d62ced4c25f5b70 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 6 Jan 2018 15:46:20 +0000 Subject: [PATCH 058/190] Improved output from ".schema --indent" when a column definition is followed by a comment. FossilOrigin-Name: 87da7efff07327278b1437f862ed8683c2d5d6ada7ea7461601a58f9762646b4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 24 ++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 7690a6a790..b76e9b121f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\strailing\stab\sfrom\sthe\sMakefile\sfor\sMSVC. -D 2018-01-06T14:44:29.580 +C Improved\soutput\sfrom\s".schema\s--indent"\swhen\sa\scolumn\sdefinition\sis\sfollowed\nby\sa\scomment. +D 2018-01-06T15:46:20.603 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 9536f61ce33172d4868707ecc10844a0abef9e2e775ad2434245a60406fd7e38 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 4cfa9394737306c5a5f3d7f72e74868df5f3010676d6a1a2a52db37b61b0c13a +F src/shell.c.in 8874828ece41dc20767b1dcee40b0784dfb934cb8affe020b616542f57b42ea9 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2f6cc5d8a0d9d961d1daf46e8725f7373f740afa788cf99ede9689f49d3a54ec -R 5465f05e31d38450dc68aa4d6f2bc0a7 -U mistachkin -Z 16a3cdc1a076fc6d00702b3c46501e75 +P 00cc26e34d2b81f140b031aa2f9ae0e2a4835cdd261d68f94b3e18a1388ca73d +R eb5f4dd564d1c772c17fe91ddfa9e74c +U drh +Z 0810beaa8d664bc298dc9e0f39c4629f diff --git a/manifest.uuid b/manifest.uuid index 165554be57..d009b990da 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -00cc26e34d2b81f140b031aa2f9ae0e2a4835cdd261d68f94b3e18a1388ca73d \ No newline at end of file +87da7efff07327278b1437f862ed8683c2d5d6ada7ea7461601a58f9762646b4 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index bb4428fbc5..c113bdb934 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1411,6 +1411,22 @@ static void printSchemaLineN(FILE *out, char *z, int n, const char *zTail){ z[n] = c; } +/* +** Return true if string z[] has nothing but whitespace and comments to the +** end of the first line. +*/ +static int wsToEol(const char *z){ + int i; + for(i=0; z[i]; i++){ + if( z[i]=='\n' ) return 1; + if( IsSpace(z[i]) ) continue; + if( z[i]=='-' && z[i+1]=='-' ) return 1; + return 0; + } + return 1; +} + + /* ** This is the callback routine that the shell ** invokes for each row of a query result. @@ -1550,13 +1566,15 @@ static int shell_callback( while( j>0 && IsSpace(z[j-1]) ){ j--; } z[j] = 0; if( strlen30(z)>=79 ){ - for(i=j=0; (c = z[i])!=0; i++){ + for(i=j=0; (c = z[i])!=0; i++){ /* Copy changes from z[i] back to z[j] */ if( c==cEnd ){ cEnd = 0; }else if( c=='"' || c=='\'' || c=='`' ){ cEnd = c; }else if( c=='[' ){ cEnd = ']'; + }else if( c=='-' && z[i+1]=='-' ){ + cEnd = '\n'; }else if( c=='(' ){ nParen++; }else if( c==')' ){ @@ -1567,7 +1585,9 @@ static int shell_callback( } } z[j++] = c; - if( nParen==1 && (c=='(' || c==',' || c=='\n') ){ + if( nParen==1 && cEnd==0 + && (c=='(' || c=='\n' || (c==',' && !wsToEol(z+i+1))) + ){ if( c=='\n' ) j--; printSchemaLineN(p->out, z, j, "\n "); j = 0; From afba1802a059c5e2a1ca549c0ca6abb31586ab43 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 6 Jan 2018 15:49:57 +0000 Subject: [PATCH 059/190] Better whitespace in the "CREATE TABLE sqlar()" statement for the ".ar" command. FossilOrigin-Name: 252ee55a7fc0b068b707af27bd912e684c28320996e78f0675217046b8c2fb49 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index b76e9b121f..d08eceabe8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\soutput\sfrom\s".schema\s--indent"\swhen\sa\scolumn\sdefinition\sis\sfollowed\nby\sa\scomment. -D 2018-01-06T15:46:20.603 +C Better\swhitespace\sin\sthe\s"CREATE\sTABLE\ssqlar()"\sstatement\sfor\sthe\s".ar"\ncommand. +D 2018-01-06T15:49:57.663 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 9536f61ce33172d4868707ecc10844a0abef9e2e775ad2434245a60406fd7e38 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 8874828ece41dc20767b1dcee40b0784dfb934cb8affe020b616542f57b42ea9 +F src/shell.c.in 1f1d02e83a4805db87d9405893e5375c9f7e6906166dead2a783d3f175cebcb0 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 00cc26e34d2b81f140b031aa2f9ae0e2a4835cdd261d68f94b3e18a1388ca73d -R eb5f4dd564d1c772c17fe91ddfa9e74c +P 87da7efff07327278b1437f862ed8683c2d5d6ada7ea7461601a58f9762646b4 +R 1cf086413b922edba322b9602699139d U drh -Z 0810beaa8d664bc298dc9e0f39c4629f +Z a5d68d44f94deab667b4cbaa7e1747ee diff --git a/manifest.uuid b/manifest.uuid index d009b990da..24f4d757a4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87da7efff07327278b1437f862ed8683c2d5d6ada7ea7461601a58f9762646b4 \ No newline at end of file +252ee55a7fc0b068b707af27bd912e684c28320996e78f0675217046b8c2fb49 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index c113bdb934..78c9124736 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4858,13 +4858,13 @@ static int arCreateUpdate( ){ const char *zSql = "SELECT name, mode, mtime, data FROM fsdir(?, ?)"; const char *zCreate = - "CREATE TABLE IF NOT EXISTS sqlar(" - "name TEXT PRIMARY KEY, -- name of the file\n" - "mode INT, -- access permissions\n" - "mtime INT, -- last modification time\n" - "sz INT, -- original file size\n" - "data BLOB -- compressed content\n" - ")"; + "CREATE TABLE IF NOT EXISTS sqlar(\n" + " name TEXT PRIMARY KEY, -- name of the file\n" + " mode INT, -- access permissions\n" + " mtime INT, -- last modification time\n" + " sz INT, -- original file size\n" + " data BLOB -- compressed content\n" + ")"; const char *zDrop = "DROP TABLE IF EXISTS sqlar"; const char *zInsert = "REPLACE INTO sqlar VALUES(?,?,?,?,sqlar_compress(?))"; From e37c0e1ce786fd87e10ba40456ceff7f2f0e4d51 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 6 Jan 2018 19:19:50 +0000 Subject: [PATCH 060/190] In the shell, include the ".archive" command only if compiling with SQLITE_HAVE_ZLIB. Add ".archive" to the ".help" output. FossilOrigin-Name: 366469f5603367fabcadfc9ffe8cd1e23c649fea49a560178ca0858a16a7e4d1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 17 +++++++++++++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index d08eceabe8..59f92e796c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Better\swhitespace\sin\sthe\s"CREATE\sTABLE\ssqlar()"\sstatement\sfor\sthe\s".ar"\ncommand. -D 2018-01-06T15:49:57.663 +C In\sthe\sshell,\sinclude\sthe\s".archive"\scommand\sonly\sif\scompiling\swith\nSQLITE_HAVE_ZLIB.\s\sAdd\s".archive"\sto\sthe\s".help"\soutput. +D 2018-01-06T19:19:50.442 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 9536f61ce33172d4868707ecc10844a0abef9e2e775ad2434245a60406fd7e38 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 1f1d02e83a4805db87d9405893e5375c9f7e6906166dead2a783d3f175cebcb0 +F src/shell.c.in 9f2ab2d0b4b07310950ec84492c067f9c65a2c934b2704f07bf3f7abd81b1326 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 87da7efff07327278b1437f862ed8683c2d5d6ada7ea7461601a58f9762646b4 -R 1cf086413b922edba322b9602699139d +P 252ee55a7fc0b068b707af27bd912e684c28320996e78f0675217046b8c2fb49 +R 1106ed2dd57a38999d04b0134db88743 U drh -Z a5d68d44f94deab667b4cbaa7e1747ee +Z 0971e8c5cac3e7845d10877eae148e13 diff --git a/manifest.uuid b/manifest.uuid index 24f4d757a4..289c74b7d1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -252ee55a7fc0b068b707af27bd912e684c28320996e78f0675217046b8c2fb49 \ No newline at end of file +366469f5603367fabcadfc9ffe8cd1e23c649fea49a560178ca0858a16a7e4d1 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 78c9124736..bff3684321 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -2895,6 +2895,9 @@ static int run_schema_dump_query( ** Text of a help message */ static char zHelp[] = +#if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE) + ".archive ... Manage SQL archives: \".archive --help\" for details\n" +#endif #ifndef SQLITE_OMIT_AUTHORIZATION ".auth ON|OFF Show authorizer callbacks\n" #endif @@ -4296,6 +4299,10 @@ static int lintDotCommand( return SQLITE_ERROR; } +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) +/********************************************************************************* +** The ".archive" or ".ar" command. +*/ static void shellPrepare( sqlite3 *db, int *pRc, @@ -4365,8 +4372,7 @@ static void shellReset( *pRc = rc; } } - -/* +/* ** Structure representing a single ".ar" command. */ typedef struct ArCommand ArCommand; @@ -5034,6 +5040,9 @@ static int arDotCommand( return rc; } +/* End of the ".archive" or ".ar" command logic +**********************************************************************************/ +#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) */ /* ** Implementation of ".expert" dot command. @@ -5156,8 +5165,8 @@ static int do_meta_command(char *zLine, ShellState *p){ }else #endif -#ifndef SQLITE_OMIT_VIRTUALTABLE - if( c=='a' && strncmp(azArg[0], "ar", n)==0 ){ +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) + if( c=='a' && strncmp(azArg[0], "archive", n)==0 ){ open_db(p, 0); rc = arDotCommand(p, azArg, nArg); }else From 1fa6d9f96f8cda45b2a3123241cd7e4971914830 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 6 Jan 2018 21:46:01 +0000 Subject: [PATCH 061/190] The shell detects and opens ZIP archives using the zipfile extension. FossilOrigin-Name: 05c99eb8cefbb3366b6d4ae91e10aa0c82bdf5ea361f4b3375413783af9167ac --- manifest | 12 ++++---- manifest.uuid | 2 +- src/shell.c.in | 83 +++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 85 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 59f92e796c..83bebcd068 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sshell,\sinclude\sthe\s".archive"\scommand\sonly\sif\scompiling\swith\nSQLITE_HAVE_ZLIB.\s\sAdd\s".archive"\sto\sthe\s".help"\soutput. -D 2018-01-06T19:19:50.442 +C The\sshell\sdetects\sand\sopens\sZIP\sarchives\susing\sthe\szipfile\sextension. +D 2018-01-06T21:46:01.434 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 9536f61ce33172d4868707ecc10844a0abef9e2e775ad2434245a60406fd7e38 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 9f2ab2d0b4b07310950ec84492c067f9c65a2c934b2704f07bf3f7abd81b1326 +F src/shell.c.in c2231d96fc059e2a6c86d67571db0dc7e029de25553a42c3334a6ef4c8e92484 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 252ee55a7fc0b068b707af27bd912e684c28320996e78f0675217046b8c2fb49 -R 1106ed2dd57a38999d04b0134db88743 +P 366469f5603367fabcadfc9ffe8cd1e23c649fea49a560178ca0858a16a7e4d1 +R 0f23134ec1d9b30706dc56d4edcd4f2b U drh -Z 0971e8c5cac3e7845d10877eae148e13 +Z bf2fee513f6949a58534392bd37a9abf diff --git a/manifest.uuid b/manifest.uuid index 289c74b7d1..95d424063b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -366469f5603367fabcadfc9ffe8cd1e23c649fea49a560178ca0858a16a7e4d1 \ No newline at end of file +05c99eb8cefbb3366b6d4ae91e10aa0c82bdf5ea361f4b3375413783af9167ac \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index bff3684321..71f9f19cb2 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -63,6 +63,7 @@ #include "sqlite3.h" typedef sqlite3_int64 i64; typedef sqlite3_uint64 u64; +typedef unsigned char u8; #if SQLITE_USER_AUTHENTICATION # include "sqlite3userauth.h" #endif @@ -938,10 +939,11 @@ struct ExpertInfo { typedef struct ShellState ShellState; struct ShellState { sqlite3 *db; /* The database */ - int autoExplain; /* Automatically turn on .explain mode */ - int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */ - int statsOn; /* True to display memory stats before each finalize */ - int scanstatsOn; /* True to display scan stats before each finalize */ + u8 autoExplain; /* Automatically turn on .explain mode */ + u8 autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */ + u8 statsOn; /* True to display memory stats before each finalize */ + u8 scanstatsOn; /* True to display scan stats before each finalize */ + u8 openMode; /* SHELL_OPEN_NORMAL, _APPENDVFS, or _ZIPFILE */ int outCount; /* Revert to stdout when reaching zero */ int cnt; /* Number of records displayed so far */ FILE *out; /* Write results here */ @@ -978,6 +980,7 @@ struct ShellState { ExpertInfo expert; /* Valid if previous command was ".expert OPT..." */ }; + /* Allowed values for ShellState.autoEQP */ #define AUTOEQP_off 0 @@ -985,6 +988,13 @@ struct ShellState { #define AUTOEQP_trigger 2 #define AUTOEQP_full 3 +/* Allowed values for ShellState.openMode +*/ +#define SHELL_OPEN_UNSPEC 0 /* No open-mode specified */ +#define SHELL_OPEN_NORMAL 1 /* Normal database file */ +#define SHELL_OPEN_APPENDVFS 2 /* Use appendvfs */ +#define SHELL_OPEN_ZIPFILE 3 /* Use the zipfile virtual table */ + /* ** These are the allowed shellFlgs values */ @@ -3101,6 +3111,32 @@ static int session_filter(void *pCtx, const char *zTab){ } #endif +/* +** Try to deduce the type of file for zName based on its content. Return +** one of the SHELL_OPEN_* constants. +*/ +static int deduceDatabaseType(const char *zName){ + FILE *f = fopen(zName, "rb"); + size_t n; + int rc = SHELL_OPEN_UNSPEC; + char zBuf[100]; + if( f==0 ) return SHELL_OPEN_NORMAL; + fseek(f, -25, SEEK_END); + n = fread(zBuf, 25, 1, f); + if( n==1 && memcmp(zBuf, "Start-Of-SQLite3-", 17)==0 ){ + rc = SHELL_OPEN_APPENDVFS; + }else{ + fseek(f, -22, SEEK_END); + n = fread(zBuf, 22, 1, f); + if( n==1 && zBuf[0]==0x50 && zBuf[1]==0x4b && zBuf[2]==0x05 + && zBuf[3]==0x06 ){ + rc = SHELL_OPEN_ZIPFILE; + } + } + fclose(f); + return rc; +} + /* ** Make sure the database is open. If it is not, then open it. If ** the database fails to open, print an error message and exit. @@ -3108,7 +3144,25 @@ static int session_filter(void *pCtx, const char *zTab){ static void open_db(ShellState *p, int keepAlive){ if( p->db==0 ){ sqlite3_initialize(); - sqlite3_open(p->zDbFilename, &p->db); + if( p->openMode==SHELL_OPEN_UNSPEC && access(p->zDbFilename,0)==0 ){ + p->openMode = deduceDatabaseType(p->zDbFilename); + } + switch( p->openMode ){ + case SHELL_OPEN_APPENDVFS: { + sqlite3_open_v2(p->zDbFilename, &p->db, + SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "apndvfs"); + break; + } + case SHELL_OPEN_ZIPFILE: { + sqlite3_open(":memory:", &p->db); + break; + } + case SHELL_OPEN_UNSPEC: + case SHELL_OPEN_NORMAL: { + sqlite3_open(p->zDbFilename, &p->db); + break; + } + } globalDb = p->db; if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){ utf8_printf(stderr,"Error: unable to open database \"%s\": %s\n", @@ -3130,6 +3184,12 @@ static void open_db(ShellState *p, int keepAlive){ shellAddSchemaName, 0, 0); sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, 0, shellModuleSchema, 0, 0); + if( p->openMode==SHELL_OPEN_ZIPFILE ){ + char *zSql = sqlite3_mprintf( + "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename); + sqlite3_exec(p->db, zSql, 0, 0, 0); + sqlite3_free(zSql); + } } } @@ -6012,11 +6072,18 @@ static int do_meta_command(char *zLine, ShellState *p){ p->zDbFilename = 0; sqlite3_free(p->zFreeOnClose); p->zFreeOnClose = 0; + p->openMode = SHELL_OPEN_UNSPEC; /* Check for command-line arguments */ for(iName=1; iNameopenMode = SHELL_OPEN_ZIPFILE; +#endif + }else if( optionMatch(z, "append") ){ + p->openMode = SHELL_OPEN_APPENDVFS; }else if( z[0]=='-' ){ utf8_printf(stderr, "unknown option: %s\n", z); rc = 1; @@ -7937,6 +8004,12 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ }else if( strcmp(z,"-csv")==0 ){ data.mode = MODE_Csv; memcpy(data.colSeparator,",",2); +#ifdef SQLITE_HAVE_ZIP + }else if( strcmp(z,"-zip")==0 ){ + data.openMode = SHELL_OPEN_ZIPFILE; +#endif + }else if( strcmp(z,"-append")==0 ){ + data.openMode = SHELL_OPEN_APPENDVFS; }else if( strcmp(z,"-ascii")==0 ){ data.mode = MODE_Ascii; sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator, From acd6fdee98ba573ab1e3be9a7f6dd4eeb4a213c8 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 7 Jan 2018 19:52:28 +0000 Subject: [PATCH 062/190] Improved comments on the sqlar.c and compress.c extensions that describe the differences between the "zlib format" used by SQLAR, the raw deflate format used by ZIP, and the custom format used by compress.c. No changes to code. FossilOrigin-Name: c13415c5caf06eaa73086c500907451dfcdfd1354ac4a9ab63edb7255edbfa1b --- ext/misc/compress.c | 15 +++++++++++++++ ext/misc/sqlar.c | 8 ++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/ext/misc/compress.c b/ext/misc/compress.c index bf38d4c93c..6e7d8b6148 100644 --- a/ext/misc/compress.c +++ b/ext/misc/compress.c @@ -27,6 +27,21 @@ SQLITE_EXTENSION_INIT1 ** seven bits per integer stored in the lower seven bits of each byte. ** More significant bits occur first. The most significant bit (0x80) ** is a flag to indicate the end of the integer. +** +** This function, SQLAR, and ZIP all use the same "deflate" compression +** algorithm, but each is subtly different: +** +** * ZIP uses raw deflate. +** +** * SQLAR uses the "zlib format" which is raw deflate with a two-byte +** algorithm-identification header and a four-byte checksum at the end. +** +** * This utility uses the "zlib format" like SQLAR, but adds the variable- +** length integer uncompressed size value at the beginning. +** +** This function might be extended in the future to support compression +** formats other than deflate, by providing a different algorithm-id +** mark following the variable-length integer size parameter. */ static void compressFunc( sqlite3_context *context, diff --git a/ext/misc/sqlar.c b/ext/misc/sqlar.c index 17d0875938..e812d70c99 100644 --- a/ext/misc/sqlar.c +++ b/ext/misc/sqlar.c @@ -24,6 +24,14 @@ SQLITE_EXTENSION_INIT1 ** If the type of X is SQLITE_BLOB, and compressing that blob using ** zlib utility function compress() yields a smaller blob, return the ** compressed blob. Otherwise, return a copy of X. +** +** SQLar uses the "zlib format" for compressed content. The zlib format +** contains a two-byte identification header and a four-byte checksum at +** the end. This is different from ZIP which uses the raw deflate format. +** +** Future enhancements to SQLar might add support for new compression formats. +** If so, those new formats will be identified by alternative headers in the +** compressed data. */ static void sqlarCompressFunc( sqlite3_context *context, diff --git a/manifest b/manifest index 83bebcd068..88ec153d89 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sshell\sdetects\sand\sopens\sZIP\sarchives\susing\sthe\szipfile\sextension. -D 2018-01-06T21:46:01.434 +C Improved\scomments\son\sthe\ssqlar.c\sand\scompress.c\sextensions\sthat\sdescribe\nthe\sdifferences\sbetween\sthe\s"zlib\sformat"\sused\sby\sSQLAR,\sthe\sraw\sdeflate\nformat\sused\sby\sZIP,\sand\sthe\scustom\sformat\sused\sby\scompress.c.\s\sNo\schanges\nto\scode. +D 2018-01-07T19:52:28.395 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 9536f61ce33172d4868707ecc10844a0abef9e2e775ad2434245a60406fd7e38 @@ -273,7 +273,7 @@ F ext/misc/btreeinfo.c d7fd9a2fe2fa33ba28488e2fce703ebecc759219ea9e0bb3b25478486 F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/completion.c 52c3f01523e3e387eb321b4739a89d1fe47cbe6025aa1f2d8d3685e9e365df0f -F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 +F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f035b189 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 @@ -294,7 +294,7 @@ F ext/misc/sha1.c 0b9e9b855354910d3ca467bf39099d570e73db56 F ext/misc/shathree.c 9e960ba50483214c6a7a4b1517f8d8cef799e9db381195178c3fd3ad207e10c0 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c 41cf26c6b89fcaa8798ae10ae64d39c1f1d9d6995152e545bd491c13058b8fac -F ext/misc/sqlar.c d355cd8b6e7280d2f61d4737672922acb512a2ab1cee52399ffb88980476e31c +F ext/misc/sqlar.c 57d5bc45cd5492208e451f697404be88f8612527d64c9d42f96b325b64983d74 F ext/misc/stmt.c 6f16443abb3551e3f5813bb13ba19a30e7032830015b0f92fe0c0453045c0a11 F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/unionvtab.c 2aa94902ea646e1aaf6c05eac944a14276cddd67735b2ad856030ffffbb6626c @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 366469f5603367fabcadfc9ffe8cd1e23c649fea49a560178ca0858a16a7e4d1 -R 0f23134ec1d9b30706dc56d4edcd4f2b +P 05c99eb8cefbb3366b6d4ae91e10aa0c82bdf5ea361f4b3375413783af9167ac +R 1813bb08dedce0701d741a99a479782e U drh -Z bf2fee513f6949a58534392bd37a9abf +Z e662d2fceaa8f576c7d1d1fef9cf3ce7 diff --git a/manifest.uuid b/manifest.uuid index 95d424063b..348cdf03c2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -05c99eb8cefbb3366b6d4ae91e10aa0c82bdf5ea361f4b3375413783af9167ac \ No newline at end of file +c13415c5caf06eaa73086c500907451dfcdfd1354ac4a9ab63edb7255edbfa1b \ No newline at end of file From 8682e121906363c9573f66f4dd893969e095cc79 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 7 Jan 2018 20:38:10 +0000 Subject: [PATCH 063/190] Modify the sqltclsh startup script to look for a properly formatted SQLAR at the end of the executable. Fix the CLI so that it automatically links against appendvfs and so that the --append command-line option works. FossilOrigin-Name: 67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece16471ea4 --- Makefile.in | 1 + Makefile.msc | 1 + ext/misc/appendvfs.c | 4 +--- main.mk | 1 + manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- src/shell.c.in | 8 ++++++++ tool/sqltclsh.c.in | 5 +++++ tool/sqltclsh.tcl | 4 +++- 9 files changed, 33 insertions(+), 17 deletions(-) diff --git a/Makefile.in b/Makefile.in index 64cb62a135..af1bd61548 100644 --- a/Makefile.in +++ b/Makefile.in @@ -994,6 +994,7 @@ keywordhash.h: $(TOP)/tool/mkkeywordhash.c # Source files that go into making shell.c SHELL_SRC = \ $(TOP)/src/shell.c.in \ + $(TOP)/ext/misc/appendvfs.c \ $(TOP)/ext/misc/shathree.c \ $(TOP)/ext/misc/fileio.c \ $(TOP)/ext/misc/completion.c \ diff --git a/Makefile.msc b/Makefile.msc index d103cdc6e3..4d6c5c0cc2 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2083,6 +2083,7 @@ keywordhash.h: $(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe # Source files that go into making shell.c SHELL_SRC = \ $(TOP)\src\shell.c.in \ + $(TOP)\ext\misc\appendvfs.c \ $(TOP)\ext\misc\shathree.c \ $(TOP)\ext\misc\fileio.c \ $(TOP)\ext\misc\completion.c \ diff --git a/ext/misc/appendvfs.c b/ext/misc/appendvfs.c index 24d5e5f15b..1454243057 100644 --- a/ext/misc/appendvfs.c +++ b/ext/misc/appendvfs.c @@ -47,9 +47,7 @@ ** If the file being opened is not an appended database, then this shim is ** a pass-through into the default underlying VFS. **/ -#if !defined(SQLITEINT_H) -#include -#endif +#include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #include #include diff --git a/main.mk b/main.mk index a16aad3860..fc68d9d307 100644 --- a/main.mk +++ b/main.mk @@ -694,6 +694,7 @@ keywordhash.h: $(TOP)/tool/mkkeywordhash.c # Source files that go into making shell.c SHELL_SRC = \ $(TOP)/src/shell.c.in \ + $(TOP)/ext/misc/appendvfs.c \ $(TOP)/ext/misc/shathree.c \ $(TOP)/ext/misc/fileio.c \ $(TOP)/ext/misc/completion.c \ diff --git a/manifest b/manifest index 88ec153d89..f28f322507 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Improved\scomments\son\sthe\ssqlar.c\sand\scompress.c\sextensions\sthat\sdescribe\nthe\sdifferences\sbetween\sthe\s"zlib\sformat"\sused\sby\sSQLAR,\sthe\sraw\sdeflate\nformat\sused\sby\sZIP,\sand\sthe\scustom\sformat\sused\sby\scompress.c.\s\sNo\schanges\nto\scode. -D 2018-01-07T19:52:28.395 +C Modify\sthe\ssqltclsh\sstartup\sscript\sto\slook\sfor\sa\sproperly\sformatted\nSQLAR\sat\sthe\send\sof\sthe\sexecutable.\s\sFix\sthe\sCLI\sso\sthat\sit\sautomatically\nlinks\sagainst\sappendvfs\sand\sso\sthat\sthe\s--append\scommand-line\soption\sworks. +D 2018-01-07T20:38:10.880 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea -F Makefile.in 9536f61ce33172d4868707ecc10844a0abef9e2e775ad2434245a60406fd7e38 +F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 688fb6375f78dc41f3a4a67201e4d5ef62ef556faa776c7cbe2c50a887d1fa5d +F Makefile.msc b33f630258ce72fb3150c1a6819a484eba3950dc9397571d48672087e12abf4a F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -268,7 +268,7 @@ F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f607 F ext/misc/README.md 8e008c8d2b02e09096b31dfba033253ac27c6c06a18aa5826e299fa7601d90b2 F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb -F ext/misc/appendvfs.c 24b72d0556e81939c19316ca48c628938b4bd0ec81dac076406260c3ccd51def +F ext/misc/appendvfs.c 4c65f0b79686ae5a483134233d7fd912f0f2d4fd76023404f96f2290fff13b19 F ext/misc/btreeinfo.c d7fd9a2fe2fa33ba28488e2fce703ebecc759219ea9e0bb3b254784866c0a676 F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 @@ -406,7 +406,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk a1ecafe75de24b10286572033e195d0da53a7a05773b4f23ff509b54f7056f0f +F main.mk 7965d01485f7bec7945407c5238985ea8c7cb2cb686d2bfdbe3d5f79d6fd4eb2 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in c2231d96fc059e2a6c86d67571db0dc7e029de25553a42c3334a6ef4c8e92484 +F src/shell.c.in ffcef0e1b2497b32c13f00ab9a1fececeeeb678dd04f5b17c0b5fa0cc99cd105 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1664,8 +1664,8 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl 3efcd4240b738f6bb2b5af0aea7e1e0ef9bc1c61654f645076cec883030b710c F tool/sqldiff.c 30879bbc8de686df4624e86adce2d8981f500904c1cfb55b5d1eea2ffd9341eb F tool/sqlite3_analyzer.c.in 7eeaae8b0d7577662acaabbb11107af0659d1b41bc1dfdd4d91422de27127968 -F tool/sqltclsh.c.in e1f48150f755bfbe0194478cba50aa9f2f5183bb1efbdd6456532cce3cd2e18d -F tool/sqltclsh.tcl 18adb7d4a24374a3c79a2acc011b5f54a22186beec13056b0fa3ca011711c4f3 +F tool/sqltclsh.c.in 8b2529b6c3cdd8ad6aaff21e80eb58370c428cb207b4607d0da4def064dcec56 +F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 05c99eb8cefbb3366b6d4ae91e10aa0c82bdf5ea361f4b3375413783af9167ac -R 1813bb08dedce0701d741a99a479782e +P c13415c5caf06eaa73086c500907451dfcdfd1354ac4a9ab63edb7255edbfa1b +R 08ba8efa22e9576ef9e933cfe51a8274 U drh -Z e662d2fceaa8f576c7d1d1fef9cf3ce7 +Z 0db18b9089efefc8f8c5c54f23707a0d diff --git a/manifest.uuid b/manifest.uuid index 348cdf03c2..ec938d37c0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c13415c5caf06eaa73086c500907451dfcdfd1354ac4a9ab63edb7255edbfa1b \ No newline at end of file +67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece16471ea4 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 71f9f19cb2..21ad0aea7e 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -894,6 +894,7 @@ INCLUDE test_windirent.c INCLUDE ../ext/misc/shathree.c INCLUDE ../ext/misc/fileio.c INCLUDE ../ext/misc/completion.c +INCLUDE ../ext/misc/appendvfs.c #ifdef SQLITE_HAVE_ZLIB INCLUDE ../ext/misc/zipfile.c INCLUDE ../ext/misc/sqlar.c @@ -7952,6 +7953,12 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ utf8_printf(stderr, "no such VFS: \"%s\"\n", argv[i]); exit(1); } +#ifdef SQLITE_HAVE_ZIP + }else if( strcmp(z,"-zip")==0 ){ + data.openMode = SHELL_OPEN_ZIPFILE; +#endif + }else if( strcmp(z,"-append")==0 ){ + data.openMode = SHELL_OPEN_APPENDVFS; } } if( data.zDbFilename==0 ){ @@ -7964,6 +7971,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ #endif } data.out = stdout; + sqlite3_appendvfs_init(0,0,0); /* Go ahead and open the database file if it already exists. If the ** file does not exist, delay opening it. This prevents empty database diff --git a/tool/sqltclsh.c.in b/tool/sqltclsh.c.in index bdfac7dd00..2be05e136e 100644 --- a/tool/sqltclsh.c.in +++ b/tool/sqltclsh.c.in @@ -29,11 +29,16 @@ #define SQLITE_MAX_EXPR_DEPTH 0 INCLUDE sqlite3.c INCLUDE $ROOT/ext/misc/appendvfs.c +INCLUDE $ROOT/ext/misc/zipfile.c +INCLUDE $ROOT/ext/misc/sqlar.c INCLUDE $ROOT/src/tclsqlite.c const char *sqlite3_tclapp_init_proc(Tcl_Interp *interp){ (void)interp; sqlite3_appendvfs_init(0,0,0); + sqlite3_auto_extension((void(*)(void))sqlite3_sqlar_init); + sqlite3_auto_extension((void(*)(void))sqlite3_zipfile_init); + return BEGIN_STRING INCLUDE $ROOT/tool/sqltclsh.tcl diff --git a/tool/sqltclsh.tcl b/tool/sqltclsh.tcl index 61d00f1df2..6a4b1fe1f0 100644 --- a/tool/sqltclsh.tcl +++ b/tool/sqltclsh.tcl @@ -6,7 +6,9 @@ catch { append argv0 .exe } sqlite3 db $argv0 -vfs apndvfs -create 0 - set mainscript [db one {SELECT data FROM scripts WHERE name='main.tcl'}] + set mainscript [db one { + SELECT sqlar_uncompress(data,sz) FROM sqlar WHERE name='main.tcl' + }] } if {[info exists mainscript]} { eval $mainscript From 03491a1a1a29aa560e96b8f524a21e802a44db17 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 7 Jan 2018 21:58:17 +0000 Subject: [PATCH 064/190] Remove the dependency on test_windirent.h from the generated shell.c file. FossilOrigin-Name: 0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4b58b --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/shell.c.in | 1 + src/test_windirent.c | 1 - src/test_windirent.h | 3 ++- tool/mkshellc.tcl | 3 +++ 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index f28f322507..68cc1c4a7c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthe\ssqltclsh\sstartup\sscript\sto\slook\sfor\sa\sproperly\sformatted\nSQLAR\sat\sthe\send\sof\sthe\sexecutable.\s\sFix\sthe\sCLI\sso\sthat\sit\sautomatically\nlinks\sagainst\sappendvfs\sand\sso\sthat\sthe\s--append\scommand-line\soption\sworks. -D 2018-01-07T20:38:10.880 +C Remove\sthe\sdependency\son\stest_windirent.h\sfrom\sthe\sgenerated\sshell.c\sfile. +D 2018-01-07T21:58:17.629 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in ffcef0e1b2497b32c13f00ab9a1fececeeeb678dd04f5b17c0b5fa0cc99cd105 +F src/shell.c.in 0e20ac49a6c4458620084bf7715ad39cd9557d9116e447548d2282000e8ca361 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -541,8 +541,8 @@ F src/test_tclvar.c 33ff42149494a39c5fbb0df3d25d6fafb2f668888e41c0688d07273dcb26 F src/test_thread.c 911d15fb14e19c0c542bdc8aabf981c2f10a4858 F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 -F src/test_windirent.c 17f91f5f2aa1bb7328abb49414c363b5d2a9d3ff -F src/test_windirent.h 5afeb2b1e2920d5149573a4c30a69cba91f2e8a80e00941b738036fca39aca61 +F src/test_windirent.c a895e2c068a06644eef91a7f0a32182445a893b9a0f33d0cdb4283dca2486ac1 +F src/test_windirent.h 8782864172ba5ae52c5c313c70faeadb324ff74de9c3dcc6b56a557dccaa1de6 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 1003d6d90c6783206c711f0a9397656fa5b055209f4d092caa43bb3bf5215db5 @@ -1631,7 +1631,7 @@ F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c F tool/mkopcodeh.tcl 4ee2a30ccbd900dc4d5cdb61bdab87cd2166cd2affcc78c9cc0b8d22a65b2eee F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkpragmatab.tcl 2144bc8550a6471a029db262a132d2df4b9e0db61b90398bf64f5b7b3f8d92cd -F tool/mkshellc.tcl 8cb90170e4aed5bd26f1664a83727c5d451f86948d3b759be26c1d7879fa346f +F tool/mkshellc.tcl 1f45770aea226ac093a9c72f718efbb88a2a2833409ec2e1c4cecae4202626f5 F tool/mksourceid.c d458f9004c837bee87a6382228ac20d3eae3c49ea3b0a5aace936f8b60748d3b F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c13415c5caf06eaa73086c500907451dfcdfd1354ac4a9ab63edb7255edbfa1b -R 08ba8efa22e9576ef9e933cfe51a8274 +P 67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece16471ea4 +R 197244392d7f5491887179479c1074da U drh -Z 0db18b9089efefc8f8c5c54f23707a0d +Z 398e4f42db7ae412d7f484f52a78c5ae diff --git a/manifest.uuid b/manifest.uuid index ec938d37c0..cd48fce8f8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece16471ea4 \ No newline at end of file +0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4b58b \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 21ad0aea7e..fe4eb624a1 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -888,6 +888,7 @@ static void shellAddSchemaName( #define SQLITE_EXTENSION_INIT2(X) (void)(X) #if defined(_WIN32) && defined(_MSC_VER) +INCLUDE test_windirent.h INCLUDE test_windirent.c #define dirent DIRENT #endif diff --git a/src/test_windirent.c b/src/test_windirent.c index ca78d345d9..62165c4bea 100644 --- a/src/test_windirent.c +++ b/src/test_windirent.c @@ -14,7 +14,6 @@ */ #if defined(_WIN32) && defined(_MSC_VER) - #include "test_windirent.h" /* diff --git a/src/test_windirent.h b/src/test_windirent.h index d4474f80e0..d71b49f684 100644 --- a/src/test_windirent.h +++ b/src/test_windirent.h @@ -13,7 +13,8 @@ ** POSIX functions on Win32 using the MSVCRT. */ -#if defined(_WIN32) && defined(_MSC_VER) +#if defined(_WIN32) && defined(_MSC_VER) && !defined(SQLITE_WINDIRENT_H) +#define SQLITE_WINDIRENT_H /* ** We need several data types from the Windows SDK header. diff --git a/tool/mkshellc.tcl b/tool/mkshellc.tcl index 1a98511ef9..534ac6156a 100644 --- a/tool/mkshellc.tcl +++ b/tool/mkshellc.tcl @@ -50,6 +50,9 @@ while {1} { while {![eof $in2]} { set lx [omit_redundant_typedefs [gets $in2]] if {[regexp {^#include "sqlite} $lx]} continue + if {[regexp {^# *include "test_windirent.h"} $lx]} { + set lx "/* $lx */" + } set lx [string map [list __declspec(dllexport) {}] $lx] puts $out $lx } From a5da4ef4ad24b2353e6dde41eb2b357bd9129ed8 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 7 Jan 2018 23:28:10 +0000 Subject: [PATCH 065/190] Avoid the use of utimensat() on older unix platforms. FossilOrigin-Name: 90cb01d8d6ac12d0b88f2952a75aeefa81ba66f5e4a5377fdd8b9f86aec8e927 --- ext/misc/fileio.c | 29 ++++++++++++++++++++--------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 030b417e40..bb87f9524d 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -261,15 +261,8 @@ static int writeFile( } if( mtime>=0 ){ -#if !defined(_WIN32) && !defined(WIN32) - struct timespec times[2]; - times[0].tv_nsec = times[1].tv_nsec = 0; - times[0].tv_sec = time(0); - times[1].tv_sec = mtime; - if( utimensat(AT_FDCWD, zFile, times, AT_SYMLINK_NOFOLLOW) ){ - return 1; - } -#else +#if defined(_WIN32) + /* Windows */ FILETIME lastAccess; FILETIME lastWrite; SYSTEMTIME currentTime; @@ -291,6 +284,24 @@ static int writeFile( }else{ return 1; } +#elif defined(AT_FDCWD) + /* Recent unix */ + struct timespec times[2]; + times[0].tv_nsec = times[1].tv_nsec = 0; + times[0].tv_sec = time(0); + times[1].tv_sec = mtime; + if( utimensat(AT_FDCWD, zFile, times, AT_SYMLINK_NOFOLLOW) ){ + return 1; + } +#else + /* Legacy unix */ + struct timeval times[2]; + times[0].tv_usec = times[1].tv_usec = 0; + times[0].tv_sec = time(0); + times[1].tv_sec = mtime; + if( utimes(zFile, times) ){ + return 1; + } #endif } diff --git a/manifest b/manifest index 68cc1c4a7c..15727841f8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sdependency\son\stest_windirent.h\sfrom\sthe\sgenerated\sshell.c\sfile. -D 2018-01-07T21:58:17.629 +C Avoid\sthe\suse\sof\sutimensat()\son\solder\sunix\splatforms. +D 2018-01-07T23:28:10.983 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -277,7 +277,7 @@ F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f0 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c f16e2ef87928b768883b259b6c53a67076e98e8daa0bbb624910406d59630b26 +F ext/misc/fileio.c 672e89e125846848e07e025cbe601dc370a93433d571d9422541a9cefbd12b76 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece16471ea4 -R 197244392d7f5491887179479c1074da +P 0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4b58b +R 1b4834f0a49c166cef0f6faa748094c7 U drh -Z 398e4f42db7ae412d7f484f52a78c5ae +Z 0323f752d28821f22e44c20f1850c6dd diff --git a/manifest.uuid b/manifest.uuid index cd48fce8f8..253d7c078e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4b58b \ No newline at end of file +90cb01d8d6ac12d0b88f2952a75aeefa81ba66f5e4a5377fdd8b9f86aec8e927 \ No newline at end of file From 98dfb2fc0843ca480d6753c91ceb3dd6dd7b66af Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 8 Jan 2018 14:24:08 +0000 Subject: [PATCH 066/190] Fix compilation of 'sqltclsh.exe' for MSVC. FossilOrigin-Name: abb112d9e1a51c1c2f15d1e5f3dc161c9a947841f69a56715f5f1c62603096b2 --- Makefile.msc | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- tool/sqltclsh.c.in | 4 ++++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 4d6c5c0cc2..6d4538706c 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2339,7 +2339,7 @@ sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS) sqltclsh.c: sqlite3.c $(TOP)\src\tclsqlite.c $(TOP)\tool\sqltclsh.tcl $(TOP)\ext\misc\appendvfs.c $(TOP)\tool\mkccode.tcl $(TOP)\tool\sqltclsh.c.in $(TCLSH_CMD) $(TOP)\tool\mkccode.tcl $(TOP)\tool\sqltclsh.c.in >sqltclsh.c -sqltclsh.exe: sqltclsh.c +sqltclsh.exe: sqltclsh.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(LTLINK) $(NO_WARN) -DBUILD_sqlite -I$(TCLINCDIR) sqltclsh.c \ /link $(LDFLAGS) $(LTLINKOPTS) $(TCLLIBPATHS) $(LTLIBPATHS) $(LIBRESOBJS) $(TCLLIBS) $(LTLIBS) $(TLIBS) diff --git a/manifest b/manifest index 15727841f8..43e25b3a81 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Avoid\sthe\suse\sof\sutimensat()\son\solder\sunix\splatforms. -D 2018-01-07T23:28:10.983 +C Fix\scompilation\sof\s'sqltclsh.exe'\sfor\sMSVC. +D 2018-01-08T14:24:08.629 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc b33f630258ce72fb3150c1a6819a484eba3950dc9397571d48672087e12abf4a +F Makefile.msc 085d3b65cebdebec89dc8c91901c06f18e357eb320a0434bfa67a53e917f10de F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -1664,7 +1664,7 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl 3efcd4240b738f6bb2b5af0aea7e1e0ef9bc1c61654f645076cec883030b710c F tool/sqldiff.c 30879bbc8de686df4624e86adce2d8981f500904c1cfb55b5d1eea2ffd9341eb F tool/sqlite3_analyzer.c.in 7eeaae8b0d7577662acaabbb11107af0659d1b41bc1dfdd4d91422de27127968 -F tool/sqltclsh.c.in 8b2529b6c3cdd8ad6aaff21e80eb58370c428cb207b4607d0da4def064dcec56 +F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4b58b -R 1b4834f0a49c166cef0f6faa748094c7 -U drh -Z 0323f752d28821f22e44c20f1850c6dd +P 90cb01d8d6ac12d0b88f2952a75aeefa81ba66f5e4a5377fdd8b9f86aec8e927 +R 76adb99cb262a63e3f8964691f33ecc1 +U mistachkin +Z 00d4b6b04e6e70aa614f01ae7c47411b diff --git a/manifest.uuid b/manifest.uuid index 253d7c078e..d2412dd0a2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -90cb01d8d6ac12d0b88f2952a75aeefa81ba66f5e4a5377fdd8b9f86aec8e927 \ No newline at end of file +abb112d9e1a51c1c2f15d1e5f3dc161c9a947841f69a56715f5f1c62603096b2 \ No newline at end of file diff --git a/tool/sqltclsh.c.in b/tool/sqltclsh.c.in index 2be05e136e..da354ee935 100644 --- a/tool/sqltclsh.c.in +++ b/tool/sqltclsh.c.in @@ -29,15 +29,19 @@ #define SQLITE_MAX_EXPR_DEPTH 0 INCLUDE sqlite3.c INCLUDE $ROOT/ext/misc/appendvfs.c +#ifdef SQLITE_HAVE_ZLIB INCLUDE $ROOT/ext/misc/zipfile.c INCLUDE $ROOT/ext/misc/sqlar.c +#endif INCLUDE $ROOT/src/tclsqlite.c const char *sqlite3_tclapp_init_proc(Tcl_Interp *interp){ (void)interp; sqlite3_appendvfs_init(0,0,0); +#ifdef SQLITE_HAVE_ZLIB sqlite3_auto_extension((void(*)(void))sqlite3_sqlar_init); sqlite3_auto_extension((void(*)(void))sqlite3_zipfile_init); +#endif return BEGIN_STRING From dcfbff9a86ac17bae4578b944655945c516fd863 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 8 Jan 2018 17:05:32 +0000 Subject: [PATCH 067/190] Fix a malloc/sqlite3_free mismatch in the shell tool code. FossilOrigin-Name: fe053b2ecdc04b918367fa503bf10292fd7cd84a6929670857b2e9153df4d1f9 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 8 +++++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 43e25b3a81..1215056748 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompilation\sof\s'sqltclsh.exe'\sfor\sMSVC. -D 2018-01-08T14:24:08.629 +C Fix\sa\smalloc/sqlite3_free\smismatch\sin\sthe\sshell\stool\scode. +D 2018-01-08T17:05:32.727 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 0e20ac49a6c4458620084bf7715ad39cd9557d9116e447548d2282000e8ca361 +F src/shell.c.in be04d6797b4ee066f064dc370bdcb148c84c6c6979bf12f70025a7a89cf79346 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 90cb01d8d6ac12d0b88f2952a75aeefa81ba66f5e4a5377fdd8b9f86aec8e927 -R 76adb99cb262a63e3f8964691f33ecc1 -U mistachkin -Z 00d4b6b04e6e70aa614f01ae7c47411b +P abb112d9e1a51c1c2f15d1e5f3dc161c9a947841f69a56715f5f1c62603096b2 +R 97c2ea02cbe64fb40daf371bd5a56946 +U dan +Z dc8bc5606c8c9f2e7de507a70d755d15 diff --git a/manifest.uuid b/manifest.uuid index d2412dd0a2..095a867785 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -abb112d9e1a51c1c2f15d1e5f3dc161c9a947841f69a56715f5f1c62603096b2 \ No newline at end of file +fe053b2ecdc04b918367fa503bf10292fd7cd84a6929670857b2e9153df4d1f9 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index fe4eb624a1..9758d5d180 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -802,8 +802,9 @@ static void shellModuleSchema( const char *zName = (const char*)sqlite3_value_text(apVal[0]); char *zFake = shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName); if( zFake ){ - sqlite3_result_text(pCtx, sqlite3_mprintf("/* %z */", zFake), + sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake), -1, sqlite3_free); + free(zFake); } } @@ -863,10 +864,11 @@ static void shellAddSchemaName( && (zFake = shellFakeSchema(db, zSchema, zName))!=0 ){ if( z==0 ){ - z = sqlite3_mprintf("%s\n/* %z */", zIn, zFake); + z = sqlite3_mprintf("%s\n/* %s */", zIn, zFake); }else{ - z = sqlite3_mprintf("%z\n/* %z */", z, zFake); + z = sqlite3_mprintf("%z\n/* %s */", z, zFake); } + free(zFake); } if( z ){ sqlite3_result_text(pCtx, z, -1, sqlite3_free); From 1bc1e2fb5d5d67e6d730a4d061c3dbac50824c92 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 8 Jan 2018 17:09:05 +0000 Subject: [PATCH 068/190] Remove a superfluous define from the 'fileio' extension when compiled for Win32. FossilOrigin-Name: 6dcba6693f064b0e21360c5eab18abe4a1534f6699b5d7b92e60eab6be14c347 --- ext/misc/fileio.c | 1 - manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index bb87f9524d..31af50a0c0 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -92,7 +92,6 @@ SQLITE_EXTENSION_INIT1 # include # include "test_windirent.h" # define dirent DIRENT -# define timespec TIMESPEC # define stat _stat # define mkdir(path,mode) _mkdir(path) # define lstat(path,buf) _stat(path,buf) diff --git a/manifest b/manifest index 1215056748..df8f0eb071 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smalloc/sqlite3_free\smismatch\sin\sthe\sshell\stool\scode. -D 2018-01-08T17:05:32.727 +C Remove\sa\ssuperfluous\sdefine\sfrom\sthe\s'fileio'\sextension\swhen\scompiled\sfor\sWin32. +D 2018-01-08T17:09:05.559 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -277,7 +277,7 @@ F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f0 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 672e89e125846848e07e025cbe601dc370a93433d571d9422541a9cefbd12b76 +F ext/misc/fileio.c edf880df28f606f0b00ac872a6a957b544fa5a7edc602ad523a9e94a1a90cce9 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P abb112d9e1a51c1c2f15d1e5f3dc161c9a947841f69a56715f5f1c62603096b2 -R 97c2ea02cbe64fb40daf371bd5a56946 -U dan -Z dc8bc5606c8c9f2e7de507a70d755d15 +P fe053b2ecdc04b918367fa503bf10292fd7cd84a6929670857b2e9153df4d1f9 +R 976d51d50d3ac4cef737330f069bf895 +U mistachkin +Z ec6d23a123b55225bd923dacec25128f diff --git a/manifest.uuid b/manifest.uuid index 095a867785..26b32bfe54 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe053b2ecdc04b918367fa503bf10292fd7cd84a6929670857b2e9153df4d1f9 \ No newline at end of file +6dcba6693f064b0e21360c5eab18abe4a1534f6699b5d7b92e60eab6be14c347 \ No newline at end of file From 4064a4cc58d1c96e166174a1346cf4adfac06e30 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 8 Jan 2018 17:12:54 +0000 Subject: [PATCH 069/190] Add an "ifcapable trace {}" block to a test in fkey1.test that uses SQL tracing. FossilOrigin-Name: 7182591d351dde22ed2f6a60521d1d7c10a610d702e79693412efc6938167be0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fkey1.test | 20 +++++++++++--------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index df8f0eb071..c028a332d2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\ssuperfluous\sdefine\sfrom\sthe\s'fileio'\sextension\swhen\scompiled\sfor\sWin32. -D 2018-01-08T17:09:05.559 +C Add\san\s"ifcapable\strace\s{}"\sblock\sto\sa\stest\sin\sfkey1.test\sthat\suses\sSQL\ntracing. +D 2018-01-08T17:12:54.166 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -793,7 +793,7 @@ F test/extraquick.test cb254400bd42bfb777ff675356aabf3287978f79 F test/fallocate.test 87b5e43c872b7e69cd80b7b8813eb102b571a75d45dda24e38b65537bcc85733 F test/filectrl.test 6e871c2d35dead1d9a88e176e8d2ca094fec6bb3 F test/filefmt.test f393e80c4b8d493b7a7f8f3809a8425bbf4292af1f5140f01cb1427798a2bbd4 -F test/fkey1.test 9d7e3a0d409e7f64ab077af3b4fc5e5ce1a4e8d8f1272b65b9d93480aeb1fa2b +F test/fkey1.test d11dbb8a93ead9b5c46ae5d02da016d61245d47662fb2d844c99214f6163f768 F test/fkey2.test 155809016fad6b2a1491facf2ac53a551bc57c2c F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49 F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fe053b2ecdc04b918367fa503bf10292fd7cd84a6929670857b2e9153df4d1f9 -R 976d51d50d3ac4cef737330f069bf895 -U mistachkin -Z ec6d23a123b55225bd923dacec25128f +P 6dcba6693f064b0e21360c5eab18abe4a1534f6699b5d7b92e60eab6be14c347 +R 409a1d71985cee1ddb2e1600f67ae81d +U dan +Z 1ce57652dfb6237638a64015c88854e8 diff --git a/manifest.uuid b/manifest.uuid index 26b32bfe54..92c91bdd00 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6dcba6693f064b0e21360c5eab18abe4a1534f6699b5d7b92e60eab6be14c347 \ No newline at end of file +7182591d351dde22ed2f6a60521d1d7c10a610d702e79693412efc6938167be0 \ No newline at end of file diff --git a/test/fkey1.test b/test/fkey1.test index 2530327fce..fa87335888 100644 --- a/test/fkey1.test +++ b/test/fkey1.test @@ -174,16 +174,18 @@ do_catchsql_test fkey1-5.2 { # Make sure sqlite3_trace() output works with triggers used to implement # FK constraints # -proc sqltrace {txt} { - global traceoutput - lappend traceoutput $txt +ifcapable trace { + proc sqltrace {txt} { + global traceoutput + lappend traceoutput $txt + } + do_test fkey1-5.2.1 { + unset -nocomplain traceoutput + db trace sqltrace + catch {db eval {INSERT OR REPLACE INTO t11 VALUES(2,3);}} + set traceoutput + } {{INSERT OR REPLACE INTO t11 VALUES(2,3);} {INSERT OR REPLACE INTO t11 VALUES(2,3);} {INSERT OR REPLACE INTO t11 VALUES(2,3);}} } -do_test fkey1-5.2.1 { - unset -nocomplain traceoutput - db trace sqltrace - catch {db eval {INSERT OR REPLACE INTO t11 VALUES(2,3);}} - set traceoutput -} {{INSERT OR REPLACE INTO t11 VALUES(2,3);} {INSERT OR REPLACE INTO t11 VALUES(2,3);} {INSERT OR REPLACE INTO t11 VALUES(2,3);}} # A similar test to the above. do_execsql_test fkey1-5.3 { From d4bb7c180bf4532344f4968e4f6b66ae8ccaf277 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 8 Jan 2018 17:34:15 +0000 Subject: [PATCH 070/190] Fix problems in the sqlite3expert.c code revealed by -fsanitize. FossilOrigin-Name: 7a93dd784bfdbf01927979a61643796e0901d9ac285fe4214677838def93a9a4 --- ext/expert/sqlite3expert.c | 6 +++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/expert/sqlite3expert.c b/ext/expert/sqlite3expert.c index e4060de681..f347ddea6d 100644 --- a/ext/expert/sqlite3expert.c +++ b/ext/expert/sqlite3expert.c @@ -495,7 +495,7 @@ static int expertBestIndex(sqlite3_vtab *pVtab, sqlite3_index_info *pIdxInfo){ } } - pIdxInfo->estimatedCost = 1000000.0 / n; + pIdxInfo->estimatedCost = 1000000.0 / (n+1); return rc; } @@ -754,7 +754,7 @@ static char *idxAppendText(int *pRc, char *zIn, const char *zFmt, ...){ zRet = (char*)sqlite3_malloc(nIn + nAppend + 1); } if( zAppend && zRet ){ - memcpy(zRet, zIn, nIn); + if( nIn ) memcpy(zRet, zIn, nIn); memcpy(&zRet[nIn], zAppend, nAppend+1); }else{ sqlite3_free(zRet); @@ -908,7 +908,7 @@ static int idxCreateFromCons( char *zCols = 0; char *zIdx = 0; IdxConstraint *pCons; - int h = 0; + unsigned int h = 0; const char *zFmt; for(pCons=pEq; pCons; pCons=pCons->pLink){ diff --git a/manifest b/manifest index c028a332d2..5f5f829f97 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\s"ifcapable\strace\s{}"\sblock\sto\sa\stest\sin\sfkey1.test\sthat\suses\sSQL\ntracing. -D 2018-01-08T17:12:54.166 +C Fix\sproblems\sin\sthe\ssqlite3expert.c\scode\srevealed\sby\s-fsanitize. +D 2018-01-08T17:34:15.620 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -45,7 +45,7 @@ F ext/async/sqlite3async.h f489b080af7e72aec0e1ee6f1d98ab6cf2e4dcef F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c 4791c5e064aea81b2b829fa95228b22283380ee370ea88a1e580103b75516ebf F ext/expert/expert1.test 0c71a3453ce3a0b4dbe952713aec0ae8d416dd846820dd027b08f305f5278b30 -F ext/expert/sqlite3expert.c 252f3129f12a0e9df094a14711db98265c9c6d7afa033ec906d94e920f5c7ba7 +F ext/expert/sqlite3expert.c 9d352d8693a997402095a16791122ca5c1bff7627faee3625509fcaaef9b30db F ext/expert/sqlite3expert.h af6354f8ee5c9e025024e63fec3bd640a802afcc3099a44d804752cf0791d811 F ext/expert/test_expert.c 85f5c743a899063fa48296d21de2f32c26d09a21c8582b2a0bc482e8de183e7a F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6dcba6693f064b0e21360c5eab18abe4a1534f6699b5d7b92e60eab6be14c347 -R 409a1d71985cee1ddb2e1600f67ae81d +P 7182591d351dde22ed2f6a60521d1d7c10a610d702e79693412efc6938167be0 +R 49ecd97a6ce816710af5cab9bccdaf02 U dan -Z 1ce57652dfb6237638a64015c88854e8 +Z 0d0d547dd2ee63ac3d70f7968bc046aa diff --git a/manifest.uuid b/manifest.uuid index 92c91bdd00..0ced8aee6a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7182591d351dde22ed2f6a60521d1d7c10a610d702e79693412efc6938167be0 \ No newline at end of file +7a93dd784bfdbf01927979a61643796e0901d9ac285fe4214677838def93a9a4 \ No newline at end of file From 7c15ac1adac225c405d4632d38b41099997e186a Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 8 Jan 2018 19:59:59 +0000 Subject: [PATCH 071/190] Update the zipfile module so that it matches the documentation. FossilOrigin-Name: 7e7e472fa91a2bad2e521d4d67f176c8eb9edc1a07b283e425ea0fa2b6abba1f --- ext/misc/zipfile.c | 264 ++++++++++++++++++++++++++------------------- manifest | 16 +-- manifest.uuid | 2 +- src/shell.c.in | 4 +- test/zipfile.test | 21 ++-- 5 files changed, 175 insertions(+), 132 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index d2715c4400..c99bac080e 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -42,17 +42,18 @@ typedef unsigned long u32; #define MIN(a,b) ((a)<(b) ? (a) : (b)) #endif -#define ZIPFILE_SCHEMA "CREATE TABLE y(" \ - "name, /* Name of file in zip archive */" \ - "mode, /* POSIX mode for file */" \ - "mtime, /* Last modification time in seconds since epoch */" \ - "sz, /* Size of object */" \ - "data, /* Data stored in zip file (possibly compressed) */" \ - "method, /* Compression method (integer) */" \ - "f HIDDEN /* Name of zip file */" \ +#define ZIPFILE_SCHEMA "CREATE TABLE y(" \ + "name, /* 0: Name of file in zip archive */" \ + "mode, /* 1: POSIX mode for file */" \ + "mtime, /* 2: Last modification time in seconds since epoch */" \ + "sz, /* 3: Size of object */" \ + "rawdata, /* 4: Raw data */" \ + "data, /* 5: Uncompressed data */" \ + "method, /* 6: Compression method (integer) */" \ + "file HIDDEN /* Name of zip file */" \ ");" -#define ZIPFILE_F_COLUMN_IDX 6 /* Index of column "f" in the above */ +#define ZIPFILE_F_COLUMN_IDX 7 /* Index of column "f" in the above */ #define ZIPFILE_BUFFER_SIZE (64*1024) @@ -671,6 +672,80 @@ static void zipfileMtimeToDos(ZipfileCDS *pCds, u32 mTime){ ((res.tm_year-80) << 9)); } +static void zipfileInflate( + sqlite3_context *pCtx, /* Store error here, if any */ + const u8 *aIn, /* Compressed data */ + int nIn, /* Size of buffer aIn[] in bytes */ + int nOut /* Expected output size */ +){ + u8 *aRes = sqlite3_malloc(nOut); + if( aRes==0 ){ + sqlite3_result_error_nomem(pCtx); + }else{ + int err; + z_stream str; + memset(&str, 0, sizeof(str)); + + str.next_in = (Byte*)aIn; + str.avail_in = nIn; + str.next_out = (Byte*)aRes; + str.avail_out = nOut; + + err = inflateInit2(&str, -15); + if( err!=Z_OK ){ + zipfileCtxErrorMsg(pCtx, "inflateInit2() failed (%d)", err); + }else{ + err = inflate(&str, Z_NO_FLUSH); + if( err!=Z_STREAM_END ){ + zipfileCtxErrorMsg(pCtx, "inflate() failed (%d)", err); + }else{ + sqlite3_result_blob(pCtx, aRes, nOut, SQLITE_TRANSIENT); + } + } + sqlite3_free(aRes); + inflateEnd(&str); + } +} + +static int zipfileDeflate( + ZipfileTab *pTab, /* Set error message here */ + const u8 *aIn, int nIn, /* Input */ + u8 **ppOut, int *pnOut /* Output */ +){ + int nAlloc = (int)compressBound(nIn); + u8 *aOut; + int rc; + + aOut = (u8*)sqlite3_malloc(nAlloc); + if( aOut==0 ){ + rc = SQLITE_NOMEM; + }else{ + int res; + z_stream str; + memset(&str, 0, sizeof(str)); + str.next_in = (z_const Bytef*)aIn; + str.avail_in = nIn; + str.next_out = aOut; + str.avail_out = nAlloc; + + deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY); + res = deflate(&str, Z_FINISH); + + if( res==Z_STREAM_END ){ + *ppOut = aOut; + *pnOut = (int)str.total_out; + }else{ + sqlite3_free(aOut); + pTab->base.zErrMsg = sqlite3_mprintf("zipfile: deflate() error"); + rc = SQLITE_ERROR; + } + deflateEnd(&str); + } + + return rc; +} + + /* ** Return values of columns for the row at which the series_cursor ** is currently pointing. @@ -703,26 +778,33 @@ static int zipfileColumn( sqlite3_result_int64(ctx, pCsr->cds.szUncompressed); break; } - case 4: { /* data */ - int sz = pCsr->cds.szCompressed; - if( sz>0 ){ - u8 *aBuf = sqlite3_malloc(sz); - if( aBuf==0 ){ - rc = SQLITE_NOMEM; - }else{ - FILE *pFile = zipfileGetFd(pCsr); - rc = zipfileReadData(pFile, aBuf, sz, pCsr->iDataOff, - &pCsr->base.pVtab->zErrMsg - ); - } - if( rc==SQLITE_OK ){ - sqlite3_result_blob(ctx, aBuf, sz, SQLITE_TRANSIENT); - sqlite3_free(aBuf); + case 4: /* rawdata */ + case 5: { /* data */ + if( i==4 || pCsr->cds.iCompression==0 || pCsr->cds.iCompression==8 ){ + int sz = pCsr->cds.szCompressed; + if( sz>0 ){ + u8 *aBuf = sqlite3_malloc(sz); + if( aBuf==0 ){ + rc = SQLITE_NOMEM; + }else{ + FILE *pFile = zipfileGetFd(pCsr); + rc = zipfileReadData(pFile, aBuf, sz, pCsr->iDataOff, + &pCsr->base.pVtab->zErrMsg + ); + } + if( rc==SQLITE_OK ){ + if( i==5 && pCsr->cds.iCompression ){ + zipfileInflate(ctx, aBuf, sz, pCsr->cds.szUncompressed); + }else{ + sqlite3_result_blob(ctx, aBuf, sz, SQLITE_TRANSIENT); + } + sqlite3_free(aBuf); + } } } break; } - case 5: /* method */ + case 6: /* method */ sqlite3_result_int(ctx, pCsr->cds.iCompression); break; } @@ -1073,7 +1155,9 @@ static int zipfileAppendEntry( static int zipfileGetMode(ZipfileTab *pTab, sqlite3_value *pVal, int *pMode){ const char *z = (const char*)sqlite3_value_text(pVal); int mode = 0; - if( z==0 || (z[0]>=0 && z[0]<=9) ){ + if( z==0 ){ + mode = 33188; /* -rw-r--r-- */ + }else if( z[0]>=0 && z[0]<=9 ){ mode = sqlite3_value_int(pVal); }else{ const char zTemplate[11] = "-rwxrwxrwx"; @@ -1118,8 +1202,8 @@ static int zipfileUpdate( i64 sz; /* Uncompressed size */ const char *zPath; /* Path for new entry */ int nPath; /* strlen(zPath) */ - const u8 *pData; /* Pointer to buffer containing content */ - int nData; /* Size of pData buffer in bytes */ + const u8 *pData = 0; /* Pointer to buffer containing content */ + int nData = 0; /* Size of pData buffer in bytes */ int iMethod = 0; /* Compression method for new entry */ u8 *pFree = 0; /* Free this */ ZipfileCDS cds; /* New Central Directory Structure entry */ @@ -1143,45 +1227,54 @@ static int zipfileUpdate( nPath = (int)strlen(zPath); rc = zipfileGetMode(pTab, apVal[3], &mode); if( rc!=SQLITE_OK ) return rc; - mTime = sqlite3_value_int64(apVal[4]); - sz = sqlite3_value_int(apVal[5]); - pData = sqlite3_value_blob(apVal[6]); - nData = sqlite3_value_bytes(apVal[6]); - - /* If a NULL value is inserted into the 'method' column, do automatic - ** compression. */ - if( nData>0 && sqlite3_value_type(apVal[7])==SQLITE_NULL ){ - pFree = (u8*)sqlite3_malloc(nData); - if( pFree==0 ){ - rc = SQLITE_NOMEM; - }else{ - int res; - z_stream str; - memset(&str, 0, sizeof(str)); - str.next_in = (z_const Bytef*)pData; - str.avail_in = nData; - str.next_out = pFree; - str.avail_out = nData; - deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY); - res = deflate(&str, Z_FINISH); - if( res==Z_STREAM_END ){ - pData = pFree; - nData = str.total_out; - iMethod = 8; - }else if( res!=Z_OK ){ - pTab->base.zErrMsg = sqlite3_mprintf("zipfile: deflate() error"); - rc = SQLITE_ERROR; - } - deflateEnd(&str); - } + if( sqlite3_value_type(apVal[4])==SQLITE_NULL ){ + mTime = (sqlite3_int64)time(0); }else{ - iMethod = sqlite3_value_int(apVal[7]); + mTime = sqlite3_value_int64(apVal[4]); + } + + if( sqlite3_value_type(apVal[5])==SQLITE_NULL /* sz */ + && sqlite3_value_type(apVal[6])==SQLITE_NULL /* rawdata */ + && sqlite3_value_type(apVal[7])!=SQLITE_NULL /* data */ + ){ + const u8 *aIn = sqlite3_value_blob(apVal[7]); + int nIn = sqlite3_value_bytes(apVal[7]); + int bAuto = sqlite3_value_type(apVal[8])==SQLITE_NULL; + + iMethod = sqlite3_value_int(apVal[8]); + sz = nIn; + if( iMethod!=0 && iMethod!=8 ){ + rc = SQLITE_CONSTRAINT; + }else if( bAuto || iMethod ){ + rc = zipfileDeflate(pTab, aIn, nIn, &pFree, &nData); + if( rc==SQLITE_OK ){ + if( iMethod || nData65535 ){ pTab->base.zErrMsg = sqlite3_mprintf( "zipfile: invalid compression method: %d", iMethod ); rc = SQLITE_ERROR; } + }else{ + rc = SQLITE_CONSTRAINT; } if( rc==SQLITE_OK ){ @@ -1352,52 +1445,6 @@ static int zipfileRegister(sqlite3 *db){ # define zipfileRegister(x) SQLITE_OK #endif -/* -** zipfile_uncompress(DATA, SZ, METHOD) -*/ -static void zipfileUncompressFunc( - sqlite3_context *context, - int argc, - sqlite3_value **argv -){ - int iMethod; - - iMethod = sqlite3_value_int(argv[2]); - if( iMethod==0 ){ - sqlite3_result_value(context, argv[0]); - }else if( iMethod==8 ){ - Byte *res; - int sz = sqlite3_value_int(argv[1]); - z_stream str; - memset(&str, 0, sizeof(str)); - str.next_in = (Byte*)sqlite3_value_blob(argv[0]); - str.avail_in = sqlite3_value_bytes(argv[0]); - res = str.next_out = (Byte*)sqlite3_malloc(sz); - if( res==0 ){ - sqlite3_result_error_nomem(context); - }else{ - int err; - str.avail_out = sz; - - err = inflateInit2(&str, -15); - if( err!=Z_OK ){ - zipfileCtxErrorMsg(context, "inflateInit2() failed (%d)", err); - }else{ - err = inflate(&str, Z_NO_FLUSH); - if( err!=Z_STREAM_END ){ - zipfileCtxErrorMsg(context, "inflate() failed (%d)", err); - }else{ - sqlite3_result_blob(context, res, sz, SQLITE_TRANSIENT); - } - } - sqlite3_free(res); - inflateEnd(&str); - } - }else{ - zipfileCtxErrorMsg(context, "unrecognized compression method: %d", iMethod); - } -} - #ifdef _WIN32 __declspec(dllexport) #endif @@ -1406,13 +1453,8 @@ int sqlite3_zipfile_init( char **pzErrMsg, const sqlite3_api_routines *pApi ){ - int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi); (void)pzErrMsg; /* Unused parameter */ - rc = sqlite3_create_function(db, "zipfile_uncompress", 3, - SQLITE_UTF8, 0, zipfileUncompressFunc, 0, 0 - ); - if( rc!=SQLITE_OK ) return rc; return zipfileRegister(db); } diff --git a/manifest b/manifest index 5f5f829f97..67ccbcf14d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sproblems\sin\sthe\ssqlite3expert.c\scode\srevealed\sby\s-fsanitize. -D 2018-01-08T17:34:15.620 +C Update\sthe\szipfile\smodule\sso\sthat\sit\smatches\sthe\sdocumentation. +D 2018-01-08T19:59:59.813 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 8075df9296beeebc344567927d114c6d3201110a29110013388d233fa7d4fb2c +F ext/misc/zipfile.c d576a5b473333f5d14f9380cf005b52a684a1ee46d4a6cfb08802564e6365e5e F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in be04d6797b4ee066f064dc370bdcb148c84c6c6979bf12f70025a7a89cf79346 +F src/shell.c.in 2aa65d155202d1caf457cb7112ec47d1aded1bc54b20e7f8f7cf81ca1dbb43bf F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1598,7 +1598,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e -F test/zipfile.test a1dd0429294cb9487900fc2b29aa9921329f20a7314aa0921b668246172ac090 +F test/zipfile.test ad4278e1ebb1c7bc0fcd7f9b47df18916b9e8f841165119865a5a6a095a2d0ba F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7182591d351dde22ed2f6a60521d1d7c10a610d702e79693412efc6938167be0 -R 49ecd97a6ce816710af5cab9bccdaf02 +P 7a93dd784bfdbf01927979a61643796e0901d9ac285fe4214677838def93a9a4 +R 86cc2218634a3d23586f8875ed6e23c5 U dan -Z 0d0d547dd2ee63ac3d70f7968bc046aa +Z 3ef32c645be21defc25c769ce8063d43 diff --git a/manifest.uuid b/manifest.uuid index 0ced8aee6a..930322bb0b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7a93dd784bfdbf01927979a61643796e0901d9ac285fe4214677838def93a9a4 \ No newline at end of file +7e7e472fa91a2bad2e521d4d67f176c8eb9edc1a07b283e425ea0fa2b6abba1f \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 9758d5d180..aa92d372ab 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4847,14 +4847,12 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ const char *azExtraArg[] = { "sqlar_uncompress(data, sz)", - "zipfile_uncompress(data, sz, method)" + "data" }; const char *azSource[] = { "sqlar", "zipfile(?3)" }; - - sqlite3_stmt *pSql = 0; int rc = SQLITE_OK; char *zDir = 0; diff --git a/test/zipfile.test b/test/zipfile.test index 627945651b..4e0c9b18d1 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -28,15 +28,18 @@ do_execsql_test 1.0 { 1 mode {} 0 {} 0 2 mtime {} 0 {} 0 3 sz {} 0 {} 0 - 4 data {} 0 {} 0 - 5 method {} 0 {} 0 + 4 rawdata {} 0 {} 0 + 5 data {} 0 {} 0 + 6 method {} 0 {} 0 } do_execsql_test 1.1.1 { - INSERT INTO zz VALUES('f.txt', '-rw-r--r--', 1000000000, 5, 'abcde', 0); + INSERT INTO zz(name, mode, mtime, sz, rawdata, method) + VALUES('f.txt', '-rw-r--r--', 1000000000, 5, 'abcde', 0); } do_execsql_test 1.1.2 { - INSERT INTO zz VALUES('g.txt', '-rw-r--r--', 1000000002, 5, '12345', 0); + INSERT INTO zz(name, mtime, sz, rawdata, method) + VALUES('g.txt', 1000000002, 5, '12345', 0); } do_execsql_test 1.2 { @@ -47,14 +50,13 @@ do_execsql_test 1.2 { } do_execsql_test 1.3 { - INSERT INTO zz VALUES('h.txt', - '-rw-r--r--', 1000000004, 20, 'aaaaaaaaaabbbbbbbbbb', NULL + INSERT INTO zz(name, mode, mtime, data) VALUES('h.txt', + '-rw-r--r--', 1000000004, 'aaaaaaaaaabbbbbbbbbb' ); } do_execsql_test 1.4 { - SELECT name, mtime, zipfile_uncompress(data, sz, method), method - FROM zipfile('test.zip'); + SELECT name, mtime, data, method FROM zipfile('test.zip'); } { f.txt 1000000000 abcde 0 g.txt 1000000002 12345 0 @@ -63,7 +65,8 @@ do_execsql_test 1.4 { do_execsql_test 1.5.1 { BEGIN; - INSERT INTO zz VALUES('i.txt', '-rw-r--r--', 1000000006, 5, 'zxcvb', 0); + INSERT INTO zz(name, mode, mtime, data, method) + VALUES('i.txt', '-rw-r--r--', 1000000006, 'zxcvb', 0); SELECT name FROM zz; COMMIT; } {f.txt g.txt h.txt i.txt} From 88a1d6b92c21aa0830e04ce0811118cc0bcc4810 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 9 Jan 2018 00:26:39 +0000 Subject: [PATCH 072/190] Fix harmless compiler warnings. FossilOrigin-Name: 1adf4e60391326ba699260402c06604ea25b456e903157ecb05017e7ea954fc4 --- ext/misc/zipfile.c | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index c99bac080e..b6357545b2 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -714,7 +714,7 @@ static int zipfileDeflate( ){ int nAlloc = (int)compressBound(nIn); u8 *aOut; - int rc; + int rc = SQLITE_OK; aOut = (u8*)sqlite3_malloc(nAlloc); if( aOut==0 ){ @@ -1199,7 +1199,7 @@ static int zipfileUpdate( int mode; /* Mode for new entry */ i64 mTime; /* Modification time for new entry */ - i64 sz; /* Uncompressed size */ + i64 sz = 0; /* Uncompressed size */ const char *zPath; /* Path for new entry */ int nPath; /* strlen(zPath) */ const u8 *pData = 0; /* Pointer to buffer containing content */ diff --git a/manifest b/manifest index 67ccbcf14d..4fe1c88833 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\szipfile\smodule\sso\sthat\sit\smatches\sthe\sdocumentation. -D 2018-01-08T19:59:59.813 +C Fix\sharmless\scompiler\swarnings. +D 2018-01-09T00:26:39.624 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c d576a5b473333f5d14f9380cf005b52a684a1ee46d4a6cfb08802564e6365e5e +F ext/misc/zipfile.c 9c3f5d7ebee44c7d2ee271232fda5e787261fd082f673caea32f14739c782059 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7a93dd784bfdbf01927979a61643796e0901d9ac285fe4214677838def93a9a4 -R 86cc2218634a3d23586f8875ed6e23c5 -U dan -Z 3ef32c645be21defc25c769ce8063d43 +P 7e7e472fa91a2bad2e521d4d67f176c8eb9edc1a07b283e425ea0fa2b6abba1f +R 1c74e64e0b3c653606aafbb1d2f630fb +U mistachkin +Z 807ee13ef468838926808e39283b80c4 diff --git a/manifest.uuid b/manifest.uuid index 930322bb0b..0267b8f46a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7e7e472fa91a2bad2e521d4d67f176c8eb9edc1a07b283e425ea0fa2b6abba1f \ No newline at end of file +1adf4e60391326ba699260402c06604ea25b456e903157ecb05017e7ea954fc4 \ No newline at end of file From 562f0c8e468a5e0bdd216106f28ca6688cd6ce72 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 9 Jan 2018 00:28:24 +0000 Subject: [PATCH 073/190] Improve portability of compile-time MinGW detection for the command line shell. FossilOrigin-Name: 4a7236140cb0f40fa846da4673a0d56218def1929d58cf016909ce881a681140 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4fe1c88833..e191942b43 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings. -D 2018-01-09T00:26:39.624 +C Improve\sportability\sof\scompile-time\sMinGW\sdetection\sfor\sthe\scommand\sline\sshell. +D 2018-01-09T00:28:24.035 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 2aa65d155202d1caf457cb7112ec47d1aded1bc54b20e7f8f7cf81ca1dbb43bf +F src/shell.c.in fb615970a6ae95be99316d9e4ab14bd2d5c6ecdc15ff905c4107eadfd2e20d0c F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7e7e472fa91a2bad2e521d4d67f176c8eb9edc1a07b283e425ea0fa2b6abba1f -R 1c74e64e0b3c653606aafbb1d2f630fb +P 1adf4e60391326ba699260402c06604ea25b456e903157ecb05017e7ea954fc4 +R 5655f2550cccb3efdcb36901ceb7ce1e U mistachkin -Z 807ee13ef468838926808e39283b80c4 +Z 83883ba507a74a46a1e753825276cfba diff --git a/manifest.uuid b/manifest.uuid index 0267b8f46a..67d4f93659 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1adf4e60391326ba699260402c06604ea25b456e903157ecb05017e7ea954fc4 \ No newline at end of file +4a7236140cb0f40fa846da4673a0d56218def1929d58cf016909ce881a681140 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index aa92d372ab..8ef236054e 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -76,10 +76,10 @@ typedef unsigned char u8; # include # endif #endif -#if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW_H) +#if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW32__) # include # include -# if defined(__MINGW_H) +# if defined(__MINGW32__) # define DIRENT dirent # ifndef S_ISLNK # define S_ISLNK(mode) (0) From a8691309ddfc650f7aedc601abb7448d4f4b34a2 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 9 Jan 2018 02:27:13 +0000 Subject: [PATCH 074/190] Avoid a compiler warning when building with newer versions of MinGW FossilOrigin-Name: cba0206a15f30313e16a08634995ebfd5d325d83affb859a215e72509f539b4e --- ext/misc/fileio.c | 4 +++- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 31af50a0c0..76d9483624 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -92,7 +92,9 @@ SQLITE_EXTENSION_INIT1 # include # include "test_windirent.h" # define dirent DIRENT -# define stat _stat +# ifndef stat +# define stat _stat +# endif # define mkdir(path,mode) _mkdir(path) # define lstat(path,buf) _stat(path,buf) #endif diff --git a/manifest b/manifest index e191942b43..9ee3ad94d3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sportability\sof\scompile-time\sMinGW\sdetection\sfor\sthe\scommand\sline\sshell. -D 2018-01-09T00:28:24.035 +C Avoid\sa\scompiler\swarning\swhen\sbuilding\swith\snewer\sversions\sof\sMinGW +D 2018-01-09T02:27:13.505 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -277,7 +277,7 @@ F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f0 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c edf880df28f606f0b00ac872a6a957b544fa5a7edc602ad523a9e94a1a90cce9 +F ext/misc/fileio.c 8bc7277143ec73c9f27057f3f38bd912a98d3492346dd688f2f877130f765d02 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1adf4e60391326ba699260402c06604ea25b456e903157ecb05017e7ea954fc4 -R 5655f2550cccb3efdcb36901ceb7ce1e -U mistachkin -Z 83883ba507a74a46a1e753825276cfba +P 4a7236140cb0f40fa846da4673a0d56218def1929d58cf016909ce881a681140 +R 79b1c4b885f55f7c11d5769bd78fff72 +U drh +Z 1c8c6d539242ddf8ecab679f4369ea9e diff --git a/manifest.uuid b/manifest.uuid index 67d4f93659..900719d377 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4a7236140cb0f40fa846da4673a0d56218def1929d58cf016909ce881a681140 \ No newline at end of file +cba0206a15f30313e16a08634995ebfd5d325d83affb859a215e72509f539b4e \ No newline at end of file From cc234a4b664fc455209ae2b40b8d6cb286b1f882 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Jan 2018 07:16:51 +0000 Subject: [PATCH 075/190] Fix a problem in zipfile.c found by -fsanitize. FossilOrigin-Name: 4fe697fa6c2b45aec60c33eff1ce2ea97b8a2ca124ef0c0059930269d25cdb2e --- ext/misc/zipfile.c | 10 +++++----- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index b6357545b2..f9acdf014a 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -1152,13 +1152,13 @@ static int zipfileAppendEntry( return rc; } -static int zipfileGetMode(ZipfileTab *pTab, sqlite3_value *pVal, int *pMode){ +static int zipfileGetMode(ZipfileTab *pTab, sqlite3_value *pVal, u32 *pMode){ const char *z = (const char*)sqlite3_value_text(pVal); - int mode = 0; + u32 mode = 0; if( z==0 ){ - mode = 33188; /* -rw-r--r-- */ + mode = S_IFREG + 0644; /* -rw-r--r-- */ }else if( z[0]>=0 && z[0]<=9 ){ - mode = sqlite3_value_int(pVal); + mode = (unsigned int)sqlite3_value_int(pVal); }else{ const char zTemplate[11] = "-rwxrwxrwx"; int i; @@ -1197,7 +1197,7 @@ static int zipfileUpdate( int rc = SQLITE_OK; /* Return Code */ ZipfileEntry *pNew = 0; /* New in-memory CDS entry */ - int mode; /* Mode for new entry */ + u32 mode; /* Mode for new entry */ i64 mTime; /* Modification time for new entry */ i64 sz = 0; /* Uncompressed size */ const char *zPath; /* Path for new entry */ diff --git a/manifest b/manifest index 9ee3ad94d3..750572561e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sa\scompiler\swarning\swhen\sbuilding\swith\snewer\sversions\sof\sMinGW -D 2018-01-09T02:27:13.505 +C Fix\sa\sproblem\sin\szipfile.c\sfound\sby\s-fsanitize. +D 2018-01-09T07:16:51.597 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 9c3f5d7ebee44c7d2ee271232fda5e787261fd082f673caea32f14739c782059 +F ext/misc/zipfile.c b694574b715dc6ea353c90e0fa31f30faa2121e59bd9e1ae40f874300114a84f F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4a7236140cb0f40fa846da4673a0d56218def1929d58cf016909ce881a681140 -R 79b1c4b885f55f7c11d5769bd78fff72 -U drh -Z 1c8c6d539242ddf8ecab679f4369ea9e +P cba0206a15f30313e16a08634995ebfd5d325d83affb859a215e72509f539b4e +R 8cb58dd5bd00b76b67672fc7e3030d3c +U dan +Z bb6663f307bb629de0b63290f8475ee1 diff --git a/manifest.uuid b/manifest.uuid index 900719d377..02e21911d2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cba0206a15f30313e16a08634995ebfd5d325d83affb859a215e72509f539b4e \ No newline at end of file +4fe697fa6c2b45aec60c33eff1ce2ea97b8a2ca124ef0c0059930269d25cdb2e \ No newline at end of file From 128011a25846785a472f7c60c082693583f83df5 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Jan 2018 10:29:34 +0000 Subject: [PATCH 076/190] Fix a zipfile problem with adding new directories to an archive. FossilOrigin-Name: 5fed67033c9dd4492bf8cfcf98874284581f448d8cc84fa5470dde239f218375 --- ext/misc/zipfile.c | 70 +++++++++++++++++++++++++++++++--------------- manifest | 14 +++++----- manifest.uuid | 2 +- test/zipfile.test | 22 +++++++++++++++ 4 files changed, 78 insertions(+), 30 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index f9acdf014a..93b2a6d8bc 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -1152,11 +1152,16 @@ static int zipfileAppendEntry( return rc; } -static int zipfileGetMode(ZipfileTab *pTab, sqlite3_value *pVal, u32 *pMode){ +static int zipfileGetMode( + ZipfileTab *pTab, + sqlite3_value *pVal, + u32 defaultMode, /* Value to use if pVal IS NULL */ + u32 *pMode +){ const char *z = (const char*)sqlite3_value_text(pVal); u32 mode = 0; if( z==0 ){ - mode = S_IFREG + 0644; /* -rw-r--r-- */ + mode = defaultMode; }else if( z[0]>=0 && z[0]<=9 ){ mode = (unsigned int)sqlite3_value_int(pVal); }else{ @@ -1208,6 +1213,10 @@ static int zipfileUpdate( u8 *pFree = 0; /* Free this */ ZipfileCDS cds; /* New Central Directory Structure entry */ + int bIsDir = 0; + + int mNull; + assert( pTab->zFile ); assert( pTab->pWriteFd ); @@ -1223,20 +1232,17 @@ static int zipfileUpdate( if( nVal==1 ) return SQLITE_OK; } - zPath = (const char*)sqlite3_value_text(apVal[2]); - nPath = (int)strlen(zPath); - rc = zipfileGetMode(pTab, apVal[3], &mode); - if( rc!=SQLITE_OK ) return rc; - if( sqlite3_value_type(apVal[4])==SQLITE_NULL ){ - mTime = (sqlite3_int64)time(0); - }else{ - mTime = sqlite3_value_int64(apVal[4]); + mNull = (sqlite3_value_type(apVal[5])==SQLITE_NULL ? 0x0 : 0x8) /* sz */ + + (sqlite3_value_type(apVal[6])==SQLITE_NULL ? 0x0 : 0x4) /* rawdata */ + + (sqlite3_value_type(apVal[7])==SQLITE_NULL ? 0x0 : 0x2) /* data */ + + (sqlite3_value_type(apVal[8])==SQLITE_NULL ? 0x0 : 0x1); /* method */ + if( mNull==0x00 ){ + /* All four are NULL - this must be a directory */ + bIsDir = 1; } - - if( sqlite3_value_type(apVal[5])==SQLITE_NULL /* sz */ - && sqlite3_value_type(apVal[6])==SQLITE_NULL /* rawdata */ - && sqlite3_value_type(apVal[7])!=SQLITE_NULL /* data */ - ){ + else if( mNull==0x2 || mNull==0x3 ){ + /* Value specified for "data", and possibly "method". This must be + ** a regular file or a symlink. */ const u8 *aIn = sqlite3_value_blob(apVal[7]); int nIn = sqlite3_value_bytes(apVal[7]); int bAuto = sqlite3_value_type(apVal[8])==SQLITE_NULL; @@ -1257,12 +1263,10 @@ static int zipfileUpdate( } } } - }else - if( sqlite3_value_type(apVal[5])!=SQLITE_NULL /* sz */ - && sqlite3_value_type(apVal[6])!=SQLITE_NULL /* rawdata */ - && sqlite3_value_type(apVal[7])==SQLITE_NULL /* data */ - && sqlite3_value_type(apVal[8])!=SQLITE_NULL /* method */ - ){ + } + else if( mNull==0x0D ){ + /* Values specified for "sz", "rawdata" and "method". In other words, + ** pre-compressed data is being inserted. */ pData = sqlite3_value_blob(apVal[6]); nData = sqlite3_value_bytes(apVal[6]); sz = sqlite3_value_int(apVal[5]); @@ -1273,10 +1277,32 @@ static int zipfileUpdate( ); rc = SQLITE_ERROR; } - }else{ + } + else{ rc = SQLITE_CONSTRAINT; } + if( rc==SQLITE_OK ){ + rc = zipfileGetMode(pTab, apVal[3], + (bIsDir ? (S_IFDIR + 0755) : (S_IFREG + 0644)), &mode + ); + if( rc==SQLITE_OK && (bIsDir == ((mode & S_IFDIR)==0)) ){ + /* The "mode" attribute is a directory, but data has been specified. + ** Or vice-versa - no data but "mode" is a file or symlink. */ + rc = SQLITE_CONSTRAINT; + } + } + + if( rc==SQLITE_OK ){ + zPath = (const char*)sqlite3_value_text(apVal[2]); + nPath = (int)strlen(zPath); + if( sqlite3_value_type(apVal[4])==SQLITE_NULL ){ + mTime = (sqlite3_int64)time(0); + }else{ + mTime = sqlite3_value_int64(apVal[4]); + } + } + if( rc==SQLITE_OK ){ /* Create the new CDS record. */ memset(&cds, 0, sizeof(cds)); diff --git a/manifest b/manifest index 750572561e..309f6238dc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\szipfile.c\sfound\sby\s-fsanitize. -D 2018-01-09T07:16:51.597 +C Fix\sa\szipfile\sproblem\swith\sadding\snew\sdirectories\sto\san\sarchive. +D 2018-01-09T10:29:34.950 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c b694574b715dc6ea353c90e0fa31f30faa2121e59bd9e1ae40f874300114a84f +F ext/misc/zipfile.c eaab322dd4b24199b0c6bdfbf866d1d04f7e93f46b4b5ca8436edadece54b03f F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1598,7 +1598,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e -F test/zipfile.test ad4278e1ebb1c7bc0fcd7f9b47df18916b9e8f841165119865a5a6a095a2d0ba +F test/zipfile.test de2ee377705999bcd7391fb742d6b833ffab4f21dab1d4f484098a66d60eb4fb F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cba0206a15f30313e16a08634995ebfd5d325d83affb859a215e72509f539b4e -R 8cb58dd5bd00b76b67672fc7e3030d3c +P 4fe697fa6c2b45aec60c33eff1ce2ea97b8a2ca124ef0c0059930269d25cdb2e +R e226ce112b5f76c5d01abec530de4ed7 U dan -Z bb6663f307bb629de0b63290f8475ee1 +Z 162125bc358610b2bc72c2a7b07e618b diff --git a/manifest.uuid b/manifest.uuid index 02e21911d2..1a39c77410 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4fe697fa6c2b45aec60c33eff1ce2ea97b8a2ca124ef0c0059930269d25cdb2e \ No newline at end of file +5fed67033c9dd4492bf8cfcf98874284581f448d8cc84fa5470dde239f218375 \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index 4e0c9b18d1..4cb6630e09 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -79,5 +79,27 @@ do_execsql_test 1.6.0 { SELECT name FROM zz; } {f.txt h.txt i.txt} +#------------------------------------------------------------------------- +db close +forcedelete test.zip +reset_db +load_static_extension db zipfile +do_execsql_test 2.1 { + CREATE VIRTUAL TABLE zzz USING zipfile('test.zip'); + INSERT INTO zzz(name, mode) VALUES('dirname', 'drwxr-xr-x'); + SELECT name, mode, data FROM zzz; +} {dirname 16877 {}} +do_execsql_test 2.2 { + INSERT INTO zzz(name, data) VALUES('dirname2', NULL); + INSERT INTO zzz(name, data) VALUES('dirname2/file1.txt', 'abcdefghijklmnop'); + SELECT name, mode, data FROM zzz; +} { + dirname 16877 {} + dirname2 16877 {} + dirname2/file1.txt 33188 abcdefghijklmnop +} + + + finish_test From 8ee5d0fc053c441c082c218e4b8409f1c461bd3c Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 9 Jan 2018 14:27:58 +0000 Subject: [PATCH 077/190] Attempt to fix the fileio.c extension so that it builds on MinGW-64. FossilOrigin-Name: a7446d3217d39c96c884fbfb294dd320378255f3bfb34e35d15ba6d7c6698f53 --- ext/misc/fileio.c | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 76d9483624..8170e86379 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -96,7 +96,7 @@ SQLITE_EXTENSION_INIT1 # define stat _stat # endif # define mkdir(path,mode) _mkdir(path) -# define lstat(path,buf) _stat(path,buf) +# define lstat(path,buf) stat(path,buf) #endif #include #include diff --git a/manifest b/manifest index 309f6238dc..3e04ddeb45 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\szipfile\sproblem\swith\sadding\snew\sdirectories\sto\san\sarchive. -D 2018-01-09T10:29:34.950 +C Attempt\sto\sfix\sthe\sfileio.c\sextension\sso\sthat\sit\sbuilds\son\sMinGW-64. +D 2018-01-09T14:27:58.076 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -277,7 +277,7 @@ F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f0 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 8bc7277143ec73c9f27057f3f38bd912a98d3492346dd688f2f877130f765d02 +F ext/misc/fileio.c 5176893c15421e9c459f25478e3c1b066d19317b676ff0b142862de4e701af82 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4fe697fa6c2b45aec60c33eff1ce2ea97b8a2ca124ef0c0059930269d25cdb2e -R e226ce112b5f76c5d01abec530de4ed7 -U dan -Z 162125bc358610b2bc72c2a7b07e618b +P 5fed67033c9dd4492bf8cfcf98874284581f448d8cc84fa5470dde239f218375 +R 0ecfe311a33b1c3c21c3c128af696033 +U drh +Z 00bdd39cf3e409343f20bbdc5609780f diff --git a/manifest.uuid b/manifest.uuid index 1a39c77410..ff7756ae2e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5fed67033c9dd4492bf8cfcf98874284581f448d8cc84fa5470dde239f218375 \ No newline at end of file +a7446d3217d39c96c884fbfb294dd320378255f3bfb34e35d15ba6d7c6698f53 \ No newline at end of file From f87ae41f52f86c9aa05fd0f0933acdb3431f5f2c Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Jan 2018 14:30:49 +0000 Subject: [PATCH 078/190] Do not attempt to build the code in ext/expert/sqlite3expert.c if SQLITE_OMIT_VIRTUALTABLE is defined. FossilOrigin-Name: ba967ad2e38590fe2a51e814a087140089be5e6a06a795a958e70a8a47f6350f --- ext/expert/expert1.test | 5 +++++ ext/expert/sqlite3expert.c | 4 ++++ ext/expert/test_expert.c | 7 ++++++- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/ext/expert/expert1.test b/ext/expert/expert1.test index 3b3425f07f..3d693ec2e7 100644 --- a/ext/expert/expert1.test +++ b/ext/expert/expert1.test @@ -23,6 +23,11 @@ if {![info exists testdir]} { source $testdir/tester.tcl set testprefix expert1 +if {[info commands sqlite3_expert_new]==""} { + finish_test + return +} + set CLI [test_binary_name sqlite3] set CMD [test_binary_name sqlite3_expert] diff --git a/ext/expert/sqlite3expert.c b/ext/expert/sqlite3expert.c index f347ddea6d..fd09478fb5 100644 --- a/ext/expert/sqlite3expert.c +++ b/ext/expert/sqlite3expert.c @@ -15,6 +15,8 @@ #include #include +#ifndef SQLITE_OMIT_VIRTUALTABLE + typedef sqlite3_int64 i64; typedef sqlite3_uint64 u64; @@ -1932,3 +1934,5 @@ void sqlite3_expert_destroy(sqlite3expert *p){ sqlite3_free(p); } } + +#endif /* ifndef SQLITE_OMIT_VIRTUAL_TABLE */ diff --git a/ext/expert/test_expert.c b/ext/expert/test_expert.c index ad83872f9a..064c1908a9 100644 --- a/ext/expert/test_expert.c +++ b/ext/expert/test_expert.c @@ -26,6 +26,8 @@ # endif #endif +#ifndef SQLITE_OMIT_VIRTUALTABLE + /* ** Extract an sqlite3* db handle from the object passed as the second ** argument. If successful, set *pDb to point to the db handle and return @@ -195,7 +197,10 @@ static int SQLITE_TCLAPI test_sqlite3_expert_new( return rc; } +#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */ + int TestExpert_Init(Tcl_Interp *interp){ +#ifndef SQLITE_OMIT_VIRTUALTABLE struct Cmd { const char *zCmd; Tcl_ObjCmdProc *xProc; @@ -208,7 +213,7 @@ int TestExpert_Init(Tcl_Interp *interp){ struct Cmd *p = &aCmd[i]; Tcl_CreateObjCommand(interp, p->zCmd, p->xProc, 0, 0); } - +#endif return TCL_OK; } diff --git a/manifest b/manifest index 3e04ddeb45..8fd167235a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Attempt\sto\sfix\sthe\sfileio.c\sextension\sso\sthat\sit\sbuilds\son\sMinGW-64. -D 2018-01-09T14:27:58.076 +C Do\snot\sattempt\sto\sbuild\sthe\scode\sin\sext/expert/sqlite3expert.c\sif\nSQLITE_OMIT_VIRTUALTABLE\sis\sdefined. +D 2018-01-09T14:30:49.074 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -44,10 +44,10 @@ F ext/async/sqlite3async.c 0f3070cc3f5ede78f2b9361fb3b629ce200d7d74 F ext/async/sqlite3async.h f489b080af7e72aec0e1ee6f1d98ab6cf2e4dcef F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c 4791c5e064aea81b2b829fa95228b22283380ee370ea88a1e580103b75516ebf -F ext/expert/expert1.test 0c71a3453ce3a0b4dbe952713aec0ae8d416dd846820dd027b08f305f5278b30 -F ext/expert/sqlite3expert.c 9d352d8693a997402095a16791122ca5c1bff7627faee3625509fcaaef9b30db +F ext/expert/expert1.test fd21496d8e52c817a7741f467f42b0502c0ac7e07dcdd1d6e15a3e8154ed4e41 +F ext/expert/sqlite3expert.c 9f1b0a5ea34abe1ccd0e9aae6ba5f96865c0f08373a731dd1ed6226074a3d75b F ext/expert/sqlite3expert.h af6354f8ee5c9e025024e63fec3bd640a802afcc3099a44d804752cf0791d811 -F ext/expert/test_expert.c 85f5c743a899063fa48296d21de2f32c26d09a21c8582b2a0bc482e8de183e7a +F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72 F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e F ext/fts1/ft_hash.c 3927bd880e65329bdc6f506555b228b28924921b F ext/fts1/ft_hash.h 06df7bba40dadd19597aa400a875dbc2fed705ea @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5fed67033c9dd4492bf8cfcf98874284581f448d8cc84fa5470dde239f218375 -R 0ecfe311a33b1c3c21c3c128af696033 -U drh -Z 00bdd39cf3e409343f20bbdc5609780f +P a7446d3217d39c96c884fbfb294dd320378255f3bfb34e35d15ba6d7c6698f53 +R e70943770a9fc04a23bf01555115b0a6 +U dan +Z 4badcc0edcd89f4a5802d71ebe94c4d8 diff --git a/manifest.uuid b/manifest.uuid index ff7756ae2e..272863cff3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a7446d3217d39c96c884fbfb294dd320378255f3bfb34e35d15ba6d7c6698f53 \ No newline at end of file +ba967ad2e38590fe2a51e814a087140089be5e6a06a795a958e70a8a47f6350f \ No newline at end of file From 6b046be41ac527a19434ed010c8b2627c3cb4931 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Jan 2018 15:25:55 +0000 Subject: [PATCH 079/190] Fix the shell so that it can be built with SQLITE_OMIT_VIRTUALTABLE. FossilOrigin-Name: 931421a22507a5e1edb46e19cb5b3958ec3904807836ab5bcc7a90f37f476e6a --- manifest | 12 ++--- manifest.uuid | 2 +- src/shell.c.in | 121 ++++++++++++++++++++++++++----------------------- 3 files changed, 71 insertions(+), 64 deletions(-) diff --git a/manifest b/manifest index 8fd167235a..11afed6419 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sattempt\sto\sbuild\sthe\scode\sin\sext/expert/sqlite3expert.c\sif\nSQLITE_OMIT_VIRTUALTABLE\sis\sdefined. -D 2018-01-09T14:30:49.074 +C Fix\sthe\sshell\sso\sthat\sit\scan\sbe\sbuilt\swith\sSQLITE_OMIT_VIRTUALTABLE. +D 2018-01-09T15:25:55.758 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in fb615970a6ae95be99316d9e4ab14bd2d5c6ecdc15ff905c4107eadfd2e20d0c +F src/shell.c.in 2a752aed1dc3727b3845429540543ff7fea383f960c7fa9e3741f16eeaed8686 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a7446d3217d39c96c884fbfb294dd320378255f3bfb34e35d15ba6d7c6698f53 -R e70943770a9fc04a23bf01555115b0a6 +P ba967ad2e38590fe2a51e814a087140089be5e6a06a795a958e70a8a47f6350f +R bfa134ce14c4136d4127894dc7db3a26 U dan -Z 4badcc0edcd89f4a5802d71ebe94c4d8 +Z f58bc377dca6569bb98e68d46d49fa3f diff --git a/manifest.uuid b/manifest.uuid index 272863cff3..f183a9980d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ba967ad2e38590fe2a51e814a087140089be5e6a06a795a958e70a8a47f6350f \ No newline at end of file +931421a22507a5e1edb46e19cb5b3958ec3904807836ab5bcc7a90f37f476e6a \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 8ef236054e..e212510e98 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -2400,6 +2400,7 @@ static void exec_prepared_stmt( } } +#ifndef SQLITE_OMIT_VIRTUALTABLE /* ** This function is called to process SQL if the previous shell command ** was ".expert". It passes the SQL in the second argument directly to @@ -2472,6 +2473,63 @@ static int expertFinish( return rc; } +/* +** Implementation of ".expert" dot command. +*/ +static int expertDotCommand( + ShellState *pState, /* Current shell tool state */ + char **azArg, /* Array of arguments passed to dot command */ + int nArg /* Number of entries in azArg[] */ +){ + int rc = SQLITE_OK; + char *zErr = 0; + int i; + int iSample = 0; + + assert( pState->expert.pExpert==0 ); + memset(&pState->expert, 0, sizeof(ExpertInfo)); + + for(i=1; rc==SQLITE_OK && i=2 && 0==strncmp(z, "-verbose", n) ){ + pState->expert.bVerbose = 1; + } + else if( n>=2 && 0==strncmp(z, "-sample", n) ){ + if( i==(nArg-1) ){ + raw_printf(stderr, "option requires an argument: %s\n", z); + rc = SQLITE_ERROR; + }else{ + iSample = (int)integerValue(azArg[++i]); + if( iSample<0 || iSample>100 ){ + raw_printf(stderr, "value out of range: %s\n", azArg[i]); + rc = SQLITE_ERROR; + } + } + } + else{ + raw_printf(stderr, "unknown option: %s\n", z); + rc = SQLITE_ERROR; + } + } + + if( rc==SQLITE_OK ){ + pState->expert.pExpert = sqlite3_expert_new(pState->db, &zErr); + if( pState->expert.pExpert==0 ){ + raw_printf(stderr, "sqlite3_expert_new: %s\n", zErr); + rc = SQLITE_ERROR; + }else{ + sqlite3_expert_config( + pState->expert.pExpert, EXPERT_CONFIG_SAMPLE, iSample + ); + } + } + + return rc; +} +#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */ /* ** Execute a statement or set of statements. Print @@ -2499,10 +2557,12 @@ static int shell_exec( *pzErrMsg = NULL; } +#ifndef SQLITE_OMIT_VIRTUALTABLE if( pArg->expert.pExpert ){ rc = expertHandleSQL(pArg, zSql, pzErrMsg); return expertFinish(pArg, (rc!=SQLITE_OK), pzErrMsg); } +#endif while( zSql[0] && (SQLITE_OK == rc) ){ static const char *zStmtSql; @@ -5106,63 +5166,6 @@ static int arDotCommand( **********************************************************************************/ #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB) */ -/* -** Implementation of ".expert" dot command. -*/ -static int expertDotCommand( - ShellState *pState, /* Current shell tool state */ - char **azArg, /* Array of arguments passed to dot command */ - int nArg /* Number of entries in azArg[] */ -){ - int rc = SQLITE_OK; - char *zErr = 0; - int i; - int iSample = 0; - - assert( pState->expert.pExpert==0 ); - memset(&pState->expert, 0, sizeof(ExpertInfo)); - - for(i=1; rc==SQLITE_OK && i=2 && 0==strncmp(z, "-verbose", n) ){ - pState->expert.bVerbose = 1; - } - else if( n>=2 && 0==strncmp(z, "-sample", n) ){ - if( i==(nArg-1) ){ - raw_printf(stderr, "option requires an argument: %s\n", z); - rc = SQLITE_ERROR; - }else{ - iSample = (int)integerValue(azArg[++i]); - if( iSample<0 || iSample>100 ){ - raw_printf(stderr, "value out of range: %s\n", azArg[i]); - rc = SQLITE_ERROR; - } - } - } - else{ - raw_printf(stderr, "unknown option: %s\n", z); - rc = SQLITE_ERROR; - } - } - - if( rc==SQLITE_OK ){ - pState->expert.pExpert = sqlite3_expert_new(pState->db, &zErr); - if( pState->expert.pExpert==0 ){ - raw_printf(stderr, "sqlite3_expert_new: %s\n", zErr); - rc = SQLITE_ERROR; - }else{ - sqlite3_expert_config( - pState->expert.pExpert, EXPERT_CONFIG_SAMPLE, iSample - ); - } - } - - return rc; -} - /* ** If an input line begins with "." then invoke this routine to @@ -5177,9 +5180,11 @@ static int do_meta_command(char *zLine, ShellState *p){ int rc = 0; char *azArg[50]; +#ifndef SQLITE_OMIT_VIRTUALTABLE if( p->expert.pExpert ){ expertFinish(p, 1, 0); } +#endif /* Parse the input line into tokens. */ @@ -5544,10 +5549,12 @@ static int do_meta_command(char *zLine, ShellState *p){ } }else +#ifndef SQLITE_OMIT_VIRTUALTABLE if( c=='e' && strncmp(azArg[0], "expert", n)==0 ){ open_db(p, 0); expertDotCommand(p, azArg, nArg); }else +#endif if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){ ShellState data; From 4297584d66f40b71e71cc1779b08799965124e9f Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 9 Jan 2018 15:28:25 +0000 Subject: [PATCH 080/190] Updates to the README.md file for the ext/misc directory. No code changes. FossilOrigin-Name: 6b3f4349d7156501f05270d494d6002ee03a0860b6e77b46d17effcab027b753 --- ext/misc/README.md | 20 ++++++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ext/misc/README.md b/ext/misc/README.md index 970a09c2e9..69cb230255 100644 --- a/ext/misc/README.md +++ b/ext/misc/README.md @@ -14,11 +14,20 @@ as follows: It is a good example of how to go about implementing a custom [table-valued function](https://www.sqlite.org/vtab.html#tabfunc2). + * **csv.c** — A [virtual table](https://sqlite.org/vtab.html) + for reading + [Comma-Separated-Value (CSV) files](https://en.wikipedia.org/wiki/Comma-separated_values). + * **dbdump.c** — This is not actually a loadable extension, but rather a library that implements an approximate equivalent to the ".dump" command of the [command-line shell](https://www.sqlite.org/cli.html). + * **json1.c** — Various SQL functions and table-valued functions + for processing JSON. This extension is already built into the + [SQLite amalgamation](https://sqlite.org/amalgamation.html). See + for additional information. + * **memvfs.c** — This file implements a custom [VFS](https://www.sqlite.org/vfs.html) that stores an entire database file in a single block of RAM. It serves as a good example of how @@ -38,3 +47,14 @@ as follows: on the source filename with digits removed, so if we used the name "sha3.c" then the entry point would conflict with the prior "sha1.c" extension. + + * **unionvtab.c** — Implementation of the unionvtab and + [swarmvtab](https://sqlite.org/swarmvtab.html) virtual tables. + These virtual tables allow a single + large table to be spread out across multiple database files. In the + case of swarmvtab, the individual database files can be attached on + demand. + + * **zipfile.c** — A [virtual table](https://sqlite.org/vtab.html) + that can read and write a + [ZIP archive](https://en.wikipedia.org/wiki/Zip_%28file_format%29). diff --git a/manifest b/manifest index 11afed6419..831d360ffb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sshell\sso\sthat\sit\scan\sbe\sbuilt\swith\sSQLITE_OMIT_VIRTUALTABLE. -D 2018-01-09T15:25:55.758 +C Updates\sto\sthe\sREADME.md\sfile\sfor\sthe\sext/misc\sdirectory.\s\sNo\scode\schanges. +D 2018-01-09T15:28:25.708 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -265,7 +265,7 @@ F ext/lsm1/lsm_win32.c 0a4acbd7e8d136dd3a5753f0a9e7a9802263a9d96cef3278cf120bcaa F ext/lsm1/test/lsm1_common.tcl 5ed4bab07c93be2e4f300ebe46007ecf4b3e20bc5fbe1dedaf04a8774a6d8d82 F ext/lsm1/test/lsm1_simple.test ca949efefa102f4644231dcd9291d8cda7699a4ce1006b26e0e3fcb72233f422 F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f6078e07335398b0 -F ext/misc/README.md 8e008c8d2b02e09096b31dfba033253ac27c6c06a18aa5826e299fa7601d90b2 +F ext/misc/README.md d6dd0fe1d8af77040216798a6a2b0c46c73054d2f0ea544fbbcdccf6f238c240 F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb F ext/misc/appendvfs.c 4c65f0b79686ae5a483134233d7fd912f0f2d4fd76023404f96f2290fff13b19 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ba967ad2e38590fe2a51e814a087140089be5e6a06a795a958e70a8a47f6350f -R bfa134ce14c4136d4127894dc7db3a26 -U dan -Z f58bc377dca6569bb98e68d46d49fa3f +P 931421a22507a5e1edb46e19cb5b3958ec3904807836ab5bcc7a90f37f476e6a +R d817db25938f9e9b2bf2929fb858f109 +U drh +Z 5854e586ea789fbe92ed499c4878d58a diff --git a/manifest.uuid b/manifest.uuid index f183a9980d..b72d3fe4f4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -931421a22507a5e1edb46e19cb5b3958ec3904807836ab5bcc7a90f37f476e6a \ No newline at end of file +6b3f4349d7156501f05270d494d6002ee03a0860b6e77b46d17effcab027b753 \ No newline at end of file From e2d22ffaa34b145013311f9f4061037dc239c1b3 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Jan 2018 15:57:55 +0000 Subject: [PATCH 081/190] Fix another -fsanitize issue in new shell code. FossilOrigin-Name: 6ee7b54c580de0240e0f49a5fd2d11ddcdbcce8a2ae4b249618d0ab2d54b5e5b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 831d360ffb..b647cd36af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updates\sto\sthe\sREADME.md\sfile\sfor\sthe\sext/misc\sdirectory.\s\sNo\scode\schanges. -D 2018-01-09T15:28:25.708 +C Fix\sanother\s-fsanitize\sissue\sin\snew\sshell\scode. +D 2018-01-09T15:57:55.704 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 2a752aed1dc3727b3845429540543ff7fea383f960c7fa9e3741f16eeaed8686 +F src/shell.c.in 4121ecd9a812c9032726aa137a4504251d03f2001dd6c7c110e7cabd3ee1454b F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 931421a22507a5e1edb46e19cb5b3958ec3904807836ab5bcc7a90f37f476e6a -R d817db25938f9e9b2bf2929fb858f109 -U drh -Z 5854e586ea789fbe92ed499c4878d58a +P 6b3f4349d7156501f05270d494d6002ee03a0860b6e77b46d17effcab027b753 +R c9d51344455c4168d42531ca44edf723 +U dan +Z df7d69cf286a4b0474c2af6fdf8505cd diff --git a/manifest.uuid b/manifest.uuid index b72d3fe4f4..f31db62ff1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b3f4349d7156501f05270d494d6002ee03a0860b6e77b46d17effcab027b753 \ No newline at end of file +6ee7b54c580de0240e0f49a5fd2d11ddcdbcce8a2ae4b249618d0ab2d54b5e5b \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index e212510e98..d214850aa9 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -2473,6 +2473,8 @@ static int expertFinish( return rc; } +static sqlite3_int64 integerValue(const char *zArg); + /* ** Implementation of ".expert" dot command. */ From c48e0271f63cce3a122b4e94f95efc5c3a02556a Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Jan 2018 18:31:11 +0000 Subject: [PATCH 082/190] Fix a potential crash in sqlite3expert.c caused by a missing sqlite3_reset() call. FossilOrigin-Name: f6355970f04a3c4d85801c806366788139d8d5ad29383ec7faa81e2176ffe987 --- ext/expert/sqlite3expert.c | 1 + manifest | 18 +++++++++--------- manifest.uuid | 2 +- test/colname.test | 10 ++++++---- test/shell8.test | 4 ++++ test/zipfile.test | 3 +++ 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ext/expert/sqlite3expert.c b/ext/expert/sqlite3expert.c index fd09478fb5..9cafc448b2 100644 --- a/ext/expert/sqlite3expert.c +++ b/ext/expert/sqlite3expert.c @@ -1525,6 +1525,7 @@ static int idxPopulateOneStat1( ); zOrder = idxAppendText(&rc, zOrder, "%s%d", zComma, ++nCol); } + sqlite3_reset(pIndexXInfo); if( rc==SQLITE_OK ){ if( p->iSample==100 ){ zQuery = sqlite3_mprintf( diff --git a/manifest b/manifest index b647cd36af..9bd75e6383 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sanother\s-fsanitize\sissue\sin\snew\sshell\scode. -D 2018-01-09T15:57:55.704 +C Fix\sa\spotential\scrash\sin\ssqlite3expert.c\scaused\sby\sa\smissing\ssqlite3_reset()\ncall. +D 2018-01-09T18:31:11.283 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -45,7 +45,7 @@ F ext/async/sqlite3async.h f489b080af7e72aec0e1ee6f1d98ab6cf2e4dcef F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c 4791c5e064aea81b2b829fa95228b22283380ee370ea88a1e580103b75516ebf F ext/expert/expert1.test fd21496d8e52c817a7741f467f42b0502c0ac7e07dcdd1d6e15a3e8154ed4e41 -F ext/expert/sqlite3expert.c 9f1b0a5ea34abe1ccd0e9aae6ba5f96865c0f08373a731dd1ed6226074a3d75b +F ext/expert/sqlite3expert.c 55ea02e9fcc014f4252e8a8c78d2bddc6d7ef62f9cb54ee283a659516eabb711 F ext/expert/sqlite3expert.h af6354f8ee5c9e025024e63fec3bd640a802afcc3099a44d804752cf0791d811 F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72 F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e @@ -687,7 +687,7 @@ F test/collate9.test 3adcc799229545940df2f25308dd1ad65869145a F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/collateB.test 1e68906951b846570f29f20102ed91d29e634854ee47454d725f2151ecac0b95 F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1 -F test/colname.test 101aa39392a1f6883278f588836a3ab99178f8103f78032433400475cc05109f +F test/colname.test fb28b3687e03625425bc216edf8b186ce974aa71008e2aa1f426a7dcb75a601d F test/conflict.test 029faa2d81a0d1cafb5f88614beb663d972c01db F test/conflict2.test bb0b94cf7196c64a3cbd815c66d3ee98c2fecd9c F test/conflict3.test a83db76a6c3503b2fa057c7bfb08c318d8a422202d8bc5b86226e078e5b49ff9 @@ -1225,7 +1225,7 @@ F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f -F test/shell8.test 7585847402452d594f0e5f93430d34ed63b2f34ca7e956f63db157f9327c6896 +F test/shell8.test 5a1f2c6d5cc11e7c7d69e960972f447a9b01e80c419ff9ebaf059f94fe5b3ab9 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1598,7 +1598,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e -F test/zipfile.test de2ee377705999bcd7391fb742d6b833ffab4f21dab1d4f484098a66d60eb4fb +F test/zipfile.test 2f71a254a9c0fe84362156a8e8cb85188280b95bfc64a26da9179ef5da8557e0 F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6b3f4349d7156501f05270d494d6002ee03a0860b6e77b46d17effcab027b753 -R c9d51344455c4168d42531ca44edf723 +P 6ee7b54c580de0240e0f49a5fd2d11ddcdbcce8a2ae4b249618d0ab2d54b5e5b +R dc296443bd383bb63a4f4ed70dfa8f45 U dan -Z df7d69cf286a4b0474c2af6fdf8505cd +Z 3dfe6831182d02544e29db133db41f01 diff --git a/manifest.uuid b/manifest.uuid index f31db62ff1..7a9d58cc88 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6ee7b54c580de0240e0f49a5fd2d11ddcdbcce8a2ae4b249618d0ab2d54b5e5b \ No newline at end of file +f6355970f04a3c4d85801c806366788139d8d5ad29383ec7faa81e2176ffe987 \ No newline at end of file diff --git a/test/colname.test b/test/colname.test index 358ea77e07..f314f94f6e 100644 --- a/test/colname.test +++ b/test/colname.test @@ -393,10 +393,12 @@ do_execsql_test colname-9.300 { do_test colname-9.310 { execsql2 {SELECT BBb FROM (SELECT aaa AS Bbb FROM t1)} } {Bbb 123} -do_execsql_test colname-9.320 { - CREATE TABLE t2 AS SELECT BBb FROM (SELECT aaa AS Bbb FROM t1); - SELECT name FROM pragma_table_info('t2'); -} {Bbb} +ifcapable vtab { + do_execsql_test colname-9.320 { + CREATE TABLE t2 AS SELECT BBb FROM (SELECT aaa AS Bbb FROM t1); + SELECT name FROM pragma_table_info('t2'); + } {Bbb} +} # Issue detected by OSSFuzz on 2017-12-24 (Christmas Eve) # caused by check-in https://sqlite.org/src/info/6b2ff26c25 diff --git a/test/shell8.test b/test/shell8.test index 50e269ef3e..0dcb10d67b 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -15,6 +15,10 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix shell8 + +ifcapable !vtab { + finish_test; return +} set CLI [test_find_cli] proc populate_dir {dirname spec} { diff --git a/test/zipfile.test b/test/zipfile.test index 4cb6630e09..9fa38810ff 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -14,6 +14,9 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix zipfile +ifcapable !vtab { + finish_test; return +} if {[catch {load_static_extension db zipfile} error]} { puts "Skipping zipfile tests, hit load error: $error" finish_test; return From 9898c4a0c4ebe63f4ce5bacc8e133c83240c06e6 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Jan 2018 20:34:53 +0000 Subject: [PATCH 083/190] In the os_unix.c implementation of xOpen(), do not return SQLITE_READONLY_DIRECTORY in cases where the file cannot be opened for reasons other than a readonly directory, such as the process running out of file descriptors. FossilOrigin-Name: fa8b80bb967792de99808712ac03e37ace0f11eb8fbe444aacd3d19184c425ea --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 9bd75e6383..53754a8904 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spotential\scrash\sin\ssqlite3expert.c\scaused\sby\sa\smissing\ssqlite3_reset()\ncall. -D 2018-01-09T18:31:11.283 +C In\sthe\sos_unix.c\simplementation\sof\sxOpen(),\sdo\snot\sreturn\nSQLITE_READONLY_DIRECTORY\sin\scases\swhere\sthe\sfile\scannot\sbe\sopened\sfor\sreasons\nother\sthan\sa\sreadonly\sdirectory,\ssuch\sas\sthe\sprocess\srunning\sout\sof\sfile\ndescriptors. +D 2018-01-09T20:34:53.247 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -467,7 +467,7 @@ F src/os.c 22d31db3ca5a96a408fbf1ceeaaebcaf64c87024d2ff9fe1cf2ddbec3e75c104 F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c 7fc2735390a7809d5d893ed735d994ff12521224b89738226fff6f1a0aa1c932 +F src/os_unix.c a9edddcc35d664c8247a18abd10d73b7a80c0d897a5341de8feea5a47cd57e25 F src/os_win.c 0a4afa35cc8e812000df3ea2f64b476131b39e29e75d8007d0504726e4761de4 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9b9cb4e06c03d43d62480a7a685a012d645fcf3a39e7767ccb505fb41ee083ec @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6ee7b54c580de0240e0f49a5fd2d11ddcdbcce8a2ae4b249618d0ab2d54b5e5b -R dc296443bd383bb63a4f4ed70dfa8f45 +P f6355970f04a3c4d85801c806366788139d8d5ad29383ec7faa81e2176ffe987 +R d7d90fd061094f6c861c9386a57e031e U dan -Z 3dfe6831182d02544e29db133db41f01 +Z 2d88017ad0f4c9b72ee8a5b92f98fadf diff --git a/manifest.uuid b/manifest.uuid index 7a9d58cc88..0259e08e45 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f6355970f04a3c4d85801c806366788139d8d5ad29383ec7faa81e2176ffe987 \ No newline at end of file +fa8b80bb967792de99808712ac03e37ace0f11eb8fbe444aacd3d19184c425ea \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 2d377ef56a..3b2b2e2a59 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5917,7 +5917,9 @@ static int unixOpen( rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName); /* If unable to create a journal, change the error code to ** indicate that the directory permissions are wrong. */ - if( isNewJrnl && osAccess(zName, F_OK) ) rc = SQLITE_READONLY_DIRECTORY; + if( isNewJrnl && errno==EACCES && osAccess(zName, F_OK) ){ + rc = SQLITE_READONLY_DIRECTORY; + } goto open_finished; } From 2c4df97591568c0f5e0e14a59db7549717a3c481 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 9 Jan 2018 20:44:04 +0000 Subject: [PATCH 084/190] Return SQLITE_CONSTRAINT if a user attempts to update a zipfile table. FossilOrigin-Name: 64c9ccf6c5598a68135e78dad128ec070afa49416e1d1f35745a24276e7aeeea --- ext/misc/zipfile.c | 18 +++++++++++------- manifest | 14 +++++++------- manifest.uuid | 2 +- test/zipfile.test | 10 ++++++++++ 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 93b2a6d8bc..e4de24af76 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -1221,15 +1221,19 @@ static int zipfileUpdate( assert( pTab->pWriteFd ); if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){ - i64 iDelete = sqlite3_value_int64(apVal[0]); - ZipfileEntry *p; - for(p=pTab->pFirstEntry; p; p=p->pNext){ - if( p->iRowid==iDelete ){ - p->bDeleted = 1; - break; + if( nVal>1 ){ + return SQLITE_CONSTRAINT; + }else{ + i64 iDelete = sqlite3_value_int64(apVal[0]); + ZipfileEntry *p; + for(p=pTab->pFirstEntry; p; p=p->pNext){ + if( p->iRowid==iDelete ){ + p->bDeleted = 1; + break; + } } + return SQLITE_OK; } - if( nVal==1 ) return SQLITE_OK; } mNull = (sqlite3_value_type(apVal[5])==SQLITE_NULL ? 0x0 : 0x8) /* sz */ diff --git a/manifest b/manifest index 53754a8904..2c69e7fdca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sos_unix.c\simplementation\sof\sxOpen(),\sdo\snot\sreturn\nSQLITE_READONLY_DIRECTORY\sin\scases\swhere\sthe\sfile\scannot\sbe\sopened\sfor\sreasons\nother\sthan\sa\sreadonly\sdirectory,\ssuch\sas\sthe\sprocess\srunning\sout\sof\sfile\ndescriptors. -D 2018-01-09T20:34:53.247 +C Return\sSQLITE_CONSTRAINT\sif\sa\suser\sattempts\sto\supdate\sa\szipfile\stable. +D 2018-01-09T20:44:04.801 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c eaab322dd4b24199b0c6bdfbf866d1d04f7e93f46b4b5ca8436edadece54b03f +F ext/misc/zipfile.c be93d2bf946d0ded56cdc3e8ec5b67ebfbcc9da435860a3e46db5a61025dbed7 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1598,7 +1598,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e -F test/zipfile.test 2f71a254a9c0fe84362156a8e8cb85188280b95bfc64a26da9179ef5da8557e0 +F test/zipfile.test 9fb98a24f80fe0d5d09df15cd01bb290777572f45408fdfbe894f2413c9c1222 F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f6355970f04a3c4d85801c806366788139d8d5ad29383ec7faa81e2176ffe987 -R d7d90fd061094f6c861c9386a57e031e +P fa8b80bb967792de99808712ac03e37ace0f11eb8fbe444aacd3d19184c425ea +R 2995a8a6bc93b1ef1a6dc9c0ab114acb U dan -Z 2d88017ad0f4c9b72ee8a5b92f98fadf +Z 9abd730978f6c4ddfe88986e0606c7d3 diff --git a/manifest.uuid b/manifest.uuid index 0259e08e45..d0b70fca41 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fa8b80bb967792de99808712ac03e37ace0f11eb8fbe444aacd3d19184c425ea \ No newline at end of file +64c9ccf6c5598a68135e78dad128ec070afa49416e1d1f35745a24276e7aeeea \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index 9fa38810ff..2a4f9ad96a 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -102,6 +102,16 @@ do_execsql_test 2.2 { dirname2/file1.txt 33188 abcdefghijklmnop } +do_catchsql_test 2.3 { + UPDATE zzz SET name = 'dirname3' WHERE name = 'dirname'; +} {1 {constraint failed}} +do_execsql_test 2.4 { + SELECT name, mode, data FROM zzz; +} { + dirname 16877 {} + dirname2 16877 {} + dirname2/file1.txt 33188 abcdefghijklmnop +} finish_test From 7026bd67531ab5fb219ea928be456a9dee9e0937 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 9 Jan 2018 20:49:33 +0000 Subject: [PATCH 085/190] Fix harmless compiler warnings. FossilOrigin-Name: 0fb42090cb2c785e044abe273a00da134927db191fea7b0c67ba4028944bce3a --- ext/misc/zipfile.c | 8 ++++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index e4de24af76..9a8d3974c2 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -1202,11 +1202,11 @@ static int zipfileUpdate( int rc = SQLITE_OK; /* Return Code */ ZipfileEntry *pNew = 0; /* New in-memory CDS entry */ - u32 mode; /* Mode for new entry */ - i64 mTime; /* Modification time for new entry */ + u32 mode = 0; /* Mode for new entry */ + i64 mTime = 0; /* Modification time for new entry */ i64 sz = 0; /* Uncompressed size */ - const char *zPath; /* Path for new entry */ - int nPath; /* strlen(zPath) */ + const char *zPath = 0; /* Path for new entry */ + int nPath = 0; /* strlen(zPath) */ const u8 *pData = 0; /* Pointer to buffer containing content */ int nData = 0; /* Size of pData buffer in bytes */ int iMethod = 0; /* Compression method for new entry */ diff --git a/manifest b/manifest index 2c69e7fdca..d00cf8ce0e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Return\sSQLITE_CONSTRAINT\sif\sa\suser\sattempts\sto\supdate\sa\szipfile\stable. -D 2018-01-09T20:44:04.801 +C Fix\sharmless\scompiler\swarnings. +D 2018-01-09T20:49:33.189 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c be93d2bf946d0ded56cdc3e8ec5b67ebfbcc9da435860a3e46db5a61025dbed7 +F ext/misc/zipfile.c 92b840dc168126e192da7d6976f44b4453c40b27ad8f142a7c02dc31aaa31bd8 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fa8b80bb967792de99808712ac03e37ace0f11eb8fbe444aacd3d19184c425ea -R 2995a8a6bc93b1ef1a6dc9c0ab114acb -U dan -Z 9abd730978f6c4ddfe88986e0606c7d3 +P 64c9ccf6c5598a68135e78dad128ec070afa49416e1d1f35745a24276e7aeeea +R ec154d3d05b58458e2848c5eff3a9b08 +U mistachkin +Z cd319f239e5515c89a36567aa5d72543 diff --git a/manifest.uuid b/manifest.uuid index d0b70fca41..2efa251344 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -64c9ccf6c5598a68135e78dad128ec070afa49416e1d1f35745a24276e7aeeea \ No newline at end of file +0fb42090cb2c785e044abe273a00da134927db191fea7b0c67ba4028944bce3a \ No newline at end of file From dc006e05aa8ed9181b14924aa742e072dabba79a Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 9 Jan 2018 22:23:42 +0000 Subject: [PATCH 086/190] When disconnecting from the 'swarmvtab' extension, close each database prior to invoking the 'openclose' function on it. FossilOrigin-Name: 3e5647cb6c4553683e24b9cb62548f16c79c4e2ac9e39cf135ea52a623f7cc33 --- ext/misc/unionvtab.c | 5 +++-- manifest | 14 +++++++------- manifest.uuid | 2 +- test/swarmvtab3.test | 19 ++++++++++--------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/ext/misc/unionvtab.c b/ext/misc/unionvtab.c index 92d0b833c4..94a5c8f013 100644 --- a/ext/misc/unionvtab.c +++ b/ext/misc/unionvtab.c @@ -484,14 +484,15 @@ static int unionDisconnect(sqlite3_vtab *pVtab){ int i; for(i=0; inSrc; i++){ UnionSrc *pSrc = &pTab->aSrc[i]; - if( pSrc->db ){ + int bHaveSrcDb = (pSrc->db!=0); + sqlite3_close(pSrc->db); + if( bHaveSrcDb ){ unionInvokeOpenClose(pTab, pSrc, 1, 0); } sqlite3_free(pSrc->zDb); sqlite3_free(pSrc->zTab); sqlite3_free(pSrc->zFile); sqlite3_free(pSrc->zContext); - sqlite3_close(pSrc->db); } sqlite3_finalize(pTab->pNotFound); sqlite3_finalize(pTab->pOpenClose); diff --git a/manifest b/manifest index d00cf8ce0e..6b48ede1ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings. -D 2018-01-09T20:49:33.189 +C When\sdisconnecting\sfrom\sthe\s'swarmvtab'\sextension,\sclose\seach\sdatabase\sprior\sto\sinvoking\sthe\s'openclose'\sfunction\son\sit. +D 2018-01-09T22:23:42.971 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -297,7 +297,7 @@ F ext/misc/spellfix.c 41cf26c6b89fcaa8798ae10ae64d39c1f1d9d6995152e545bd491c1305 F ext/misc/sqlar.c 57d5bc45cd5492208e451f697404be88f8612527d64c9d42f96b325b64983d74 F ext/misc/stmt.c 6f16443abb3551e3f5813bb13ba19a30e7032830015b0f92fe0c0453045c0a11 F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 -F ext/misc/unionvtab.c 2aa94902ea646e1aaf6c05eac944a14276cddd67735b2ad856030ffffbb6626c +F ext/misc/unionvtab.c 0b3173f69b8899da640a13a345dc5ef1400199405f738abe6145b2454195b8ff F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 @@ -1275,7 +1275,7 @@ F test/subtype1.test 7fe09496352f97053af1437150751be2d0a0cae8 F test/superlock.test ec94f0556b6488d97f71c79f9061ae08d9ab8f12 F test/swarmvtab.test 9a3fd5ab3e9b3c976ad1b3d7646aab725114f2ac26b59395d0778b33bab6cdaf F test/swarmvtab2.test c948cb2fdfc5b01d85e8f6d6504854202dc1a0782ab2a0ed61538f27cbd0aa5c -F test/swarmvtab3.test c4c8d09e56ae99b90187ac225458f13f373873ea296fc442c7ad7511f25e7314 +F test/swarmvtab3.test 6cb664669630fcec4102a09333e52068734858fd2761eee3b0465c14cdbcee29 F test/swarmvtabfault.test 00aec54665909490f5c383f3cae3b5d18bd97c12490b429ff8752a3027acfa42 F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 64c9ccf6c5598a68135e78dad128ec070afa49416e1d1f35745a24276e7aeeea -R ec154d3d05b58458e2848c5eff3a9b08 +P 0fb42090cb2c785e044abe273a00da134927db191fea7b0c67ba4028944bce3a +R 6a5a34e76be8657e78b0d58d3645af35 U mistachkin -Z cd319f239e5515c89a36567aa5d72543 +Z b0c2e831274b963bd4ec05162b124f71 diff --git a/manifest.uuid b/manifest.uuid index 2efa251344..c9c91c407d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0fb42090cb2c785e044abe273a00da134927db191fea7b0c67ba4028944bce3a \ No newline at end of file +3e5647cb6c4553683e24b9cb62548f16c79c4e2ac9e39cf135ea52a623f7cc33 \ No newline at end of file diff --git a/test/swarmvtab3.test b/test/swarmvtab3.test index 70d6c7dca0..6e52355d95 100644 --- a/test/swarmvtab3.test +++ b/test/swarmvtab3.test @@ -74,7 +74,7 @@ proc check_dbcache {} { for {set i 0} {$i<100} {incr i} { set exists [file exists test.db$i] if {$exists!=($::dbcache(test.db$i)!=0)} { - error "inconsistent ::dbcache and disk" + error "inconsistent ::dbcache and disk ($i) - $exists" } incr n $exists } @@ -114,7 +114,7 @@ foreach {tn nMaxOpen cvt} { } { execsql { DROP TABLE IF EXISTS s } - + do_execsql_test 1.$tn.1 $cvt do_execsql_test 1.$tn.2 { @@ -192,7 +192,7 @@ proc check_dbcache {} { foreach k [array names ::dbcache] { set exists [file exists $k] if {$exists!=($::dbcache($k)!=0)} { - error "inconsistent ::dbcache and disk ($k)" + error "inconsistent ::dbcache and disk ($k) - $exists" } incr n $exists } @@ -210,23 +210,24 @@ foreach {tn nMaxOpen cvt} { } } { execsql { DROP TABLE IF EXISTS s } - - do_execsql_test 1.$tn.1 $cvt - do_execsql_test 1.$tn.2 { + do_execsql_test 3.$tn.1 $cvt + + do_execsql_test 3.$tn.2 { SELECT b FROM s WHERE a<10; } {0 1 2 3 4 5 6 7 8 9} - do_test 1.$tn.3 { check_dbcache } $nMaxOpen + do_test 3.$tn.3 { check_dbcache } $nMaxOpen - do_execsql_test 1.$tn.4 { + do_execsql_test 3.$tn.4 { SELECT b FROM s WHERE (b%10)=0; } {0 10 20 30 40 50 60 70 80 90} - do_test 1.$tn.5 { check_dbcache } $nMaxOpen + do_test 3.$tn.5 { check_dbcache } $nMaxOpen } db close +forcedelete {*}[glob test.db*] forcedelete {*}[glob test_remote.db*] finish_test From 6116ee4eeefeec9a0fc81ef4784cb774d50e36a2 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 00:40:06 +0000 Subject: [PATCH 087/190] Compute the correct column name even if the column identifier is the very last token in the SQL statement. This fixes a problem introduced by check-in [0fdf97efe5df745510c6b] and reported by the community during beta-testing. FossilOrigin-Name: 36b89d728ff13d395fe0e1db8e7c01263f73dccb278b3ece27f6ef78e909b492 --- manifest | 32 ++++++++++++++++---------------- manifest.uuid | 2 +- src/build.c | 2 +- src/parse.y | 7 +++++-- src/tokenize.c | 2 +- test/capi2.test | 2 +- test/capi3.test | 12 ++++++++++++ test/icu.test | 4 ++-- test/main.test | 4 ++-- test/select1.test | 2 +- test/shell3.test | 4 ++-- test/with2.test | 2 +- 12 files changed, 45 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index 6b48ede1ff..a8883b6f20 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sdisconnecting\sfrom\sthe\s'swarmvtab'\sextension,\sclose\seach\sdatabase\sprior\sto\sinvoking\sthe\s'openclose'\sfunction\son\sit. -D 2018-01-09T22:23:42.971 +C Compute\sthe\scorrect\scolumn\sname\seven\sif\sthe\scolumn\sidentifier\sis\sthe\nvery\slast\stoken\sin\sthe\sSQL\sstatement.\s\sThis\sfixes\sa\sproblem\sintroduced\nby\scheck-in\s[0fdf97efe5df745510c6b]\sand\sreported\sby\sthe\scommunity\sduring\nbeta-testing. +D 2018-01-10T00:40:06.636 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -428,7 +428,7 @@ F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca F src/btree.c 0a1f63b50ab1ac5d4b1637c30cb1ae123fbc162ec8cb6336ddb9491a0bc1e363 F src/btree.h 0866c0a08255142ea0e754aabd211c843cab32045c978a592a43152405ed0c84 F src/btreeInt.h 55b702efce17e5d1941865464227d3802cfc9c7c832fac81d4c94dced47a71fc -F src/build.c a03eb5a1cfff74784c24a4478ba5455711571936f1ac9d43f94fa7df57509977 +F src/build.c 9f9647454f236cab097f266ae970f899b53c71cadab6756c47e2b2e81392c2a1 F src/callback.c fe677cb5f5abb02f7a772a62a98c2f516426081df68856e8f2d5f950929b966a F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c ff1be3eed7bdd75aaca61ca8dc848f7c9f850ef2fb9cb56f2734e922a098f9c0 @@ -472,7 +472,7 @@ F src/os_win.c 0a4afa35cc8e812000df3ea2f64b476131b39e29e75d8007d0504726e4761de4 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9b9cb4e06c03d43d62480a7a685a012d645fcf3a39e7767ccb505fb41ee083ec F src/pager.h 581698f2177e8bd4008fe4760898ce20b6133d1df22139b9101b5155f900df7a -F src/parse.y 44cbbc3e132ea128258eff7be7f6d5c5dfa25522f89ec8b5501276966511bd50 +F src/parse.y 4e750e1b261ff9f1d0b6b5d40a829c66d691899f48953fde839d8b52d41aa148 F src/pcache.c 7ae91a4557a43d77d449accbfdc68846e6516f8e2eda46e8bbe4536fb669b201 F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170 F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880 @@ -545,7 +545,7 @@ F src/test_windirent.c a895e2c068a06644eef91a7f0a32182445a893b9a0f33d0cdb4283dca F src/test_windirent.h 8782864172ba5ae52c5c313c70faeadb324ff74de9c3dcc6b56a557dccaa1de6 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c 1003d6d90c6783206c711f0a9397656fa5b055209f4d092caa43bb3bf5215db5 +F src/tokenize.c 5b0c661a85f783d35b9883830736eeb63be4aefc4f6b7d9cd081d48782c041e2 F src/treeview.c eae35972ff44f67064de2eaf35f04afe94e7aea3271a8b3bcebb3f954880fec3 F src/trigger.c a34539c69433276d37b0da9a89c117726ff2d292c0902895af1f393a983cd3a1 F src/update.c 961bd1265d4d1e5cd65c9a54fa5122fb7aefcb003fcf2de0c092fceb7e58972c @@ -663,8 +663,8 @@ F test/busy.test 510dc6daaad18bcbbc085bcc6217d6dc418def5e73f72ce1475eea0cb783472 F test/cache.test 13bc046b26210471ca6f2889aceb1ea52dc717de F test/cacheflush.test af25bb1509df04c1da10e38d8f322d66eceedf61 F test/cachespill.test 895997f84a25b323b166aecb69baab2d6380ea98f9e0bcc688c4493c535cfab9 -F test/capi2.test d3267a146df2251e7ad09a672d59e33e836d74c6fbeb843c18e87835ef646c12 -F test/capi3.test 986e57cea8ab423b3fc8c2e3b69330394252d3d2a4496122ff3749e258305695 +F test/capi2.test 34a1a9a96d543a2ec2c209696b11b164444f57253b1f2cba1c2e53fadede6c7b +F test/capi3.test 36f5c859c91a9bb0075d6ddcfcf2476cad629b09f7bfd135776fb94b06c04706 F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 F test/capi3c.test 7ebed1d8fa2f3190149d556fe8cff5a006be62af437c5c4640db614470126098 F test/capi3d.test 485048dc5cd07bc68011e4917ad035ad6047ab82 @@ -945,7 +945,7 @@ F test/hexlit.test 4a6a5f46e3c65c4bf1fa06f5dd5a9507a5627751 F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711 F test/hook.test dbc0b87756e1e20e7497b56889c9e9cd2f8cc2b5 F test/hook2.test b9ff3b8c6519fb67f33192f1afe86e7782ee4ac8 -F test/icu.test 7fb00edc09e05d51e36be12b33e0af04e3394e3b02dbdcb2eefcb901203e28c4 +F test/icu.test 41aa8847745a879b897a7febea0f8f9efc8e67fe8bf680589b6e07c7b0a1569a F test/ieee754.test 806fc0ce7f305f57e3331eaceeddcfec9339e607 F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 F test/in.test 2fa2dfba1afe30eb830f327e7131dfadaa7a701d677de0eb65f9303d99e18fe0 @@ -1032,7 +1032,7 @@ F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5 F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431 F test/lock_common.tcl 7ffb45accf6ee91c736df9bafe0806a44358f035 F test/lookaside.test b17c99ae3aef96a8c9fa6f6be33cc75b93d657cb791d3827302b6835b71941f7 -F test/main.test bb75e406c9b64931f3dc7e7f04626633365bb22f +F test/main.test 6bbb3999fd461eb8fb335cbab97409a3d7f91bbb8da60635e8be3e4a04a77772 F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9 F test/malloc.test 21c213365f2cca95ab2d7dc078dc8525f96065f8 F test/malloc3.test e3b32c724b5a124b57cb0ed177f675249ad0c66a @@ -1188,7 +1188,7 @@ F test/schema5.test 29699b4421f183c8f0e88bd28ce7d75d13ea653e F test/schema6.test e4bd1f23d368695eb9e7b51ef6e02ca0642ea2ab4a52579959826b5e7dce1f9b F test/securedel.test 2f70b2449186a1921bd01ec9da407fbfa98c3a7a5521854c300c194b2ff09384 F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5 -F test/select1.test 460a5824df01575b18f7fa4bd8e40d09de20c542e90c1543e164bc7d3b0a0bb7 +F test/select1.test 2e760bab8f3658b3b97debcf52860d0d2e20aa6cbe8b40e678ddb99871a15491 F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 F test/select4.test 5389d9895968d1196c457d59b3ee6515d771d328 @@ -1220,7 +1220,7 @@ F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 F test/shell1.test 6d69e08039aea13f2c42749f162fe05eab7b5c93729f31d49d7d27cf36226e5a F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b -F test/shell3.test 9b95ba643eaa228376f06a898fb410ee9b6e57c1 +F test/shell3.test ac8c2b744014c3e9a0e26bfd829ab65f00923dc1a91ffd044863e9423cc91494 F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 @@ -1585,7 +1585,7 @@ F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972 F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc F test/with1.test ca08e291249a810a2ec9b72ceef5575e07d5925b360fcf6652ae6fe06ac4dced -F test/with2.test 2b40da883658eb74ad8ad06afabe11a408e7fb87 +F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab F test/with3.test e71604a0e53cba82bc04c703987cb1d6751ec0b6 F test/withM.test 693b61765f2b387b5e3e24a4536e2e82de15ff64 F test/without_rowid1.test 06b7215130882d6a072233820dd364c874c4fd69221e8fc756ec471009192874 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0fb42090cb2c785e044abe273a00da134927db191fea7b0c67ba4028944bce3a -R 6a5a34e76be8657e78b0d58d3645af35 -U mistachkin -Z b0c2e831274b963bd4ec05162b124f71 +P 3e5647cb6c4553683e24b9cb62548f16c79c4e2ac9e39cf135ea52a623f7cc33 +R 13437b6007d6ef55bf4d81b9dff0be71 +U drh +Z f9f9bd51ed93ca5bce3e08c7f811f3c5 diff --git a/manifest.uuid b/manifest.uuid index c9c91c407d..3bef9fc4db 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e5647cb6c4553683e24b9cb62548f16c79c4e2ac9e39cf135ea52a623f7cc33 \ No newline at end of file +36b89d728ff13d395fe0e1db8e7c01263f73dccb278b3ece27f6ef78e909b492 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 26eb0579e6..58b39d6475 100644 --- a/src/build.c +++ b/src/build.c @@ -2124,7 +2124,7 @@ void sqlite3CreateView( ** the end. */ sEnd = pParse->sLastToken; - assert( sEnd.z[0]!=0 ); + assert( sEnd.z[0]!=0 || sEnd.n==0 ); if( sEnd.z[0]!=';' ){ sEnd.z += sEnd.n; } diff --git a/src/parse.y b/src/parse.y index e780f8c3ab..d9cf1cb87d 100644 --- a/src/parse.y +++ b/src/parse.y @@ -31,8 +31,11 @@ // %syntax_error { UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ - assert( TOKEN.z[0] ); /* The tokenizer always gives us a token */ - sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); + if( TOKEN.z[0] ){ + sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); + }else{ + sqlite3ErrorMsg(pParse, "incomplete input"); + } } %stack_overflow { sqlite3ErrorMsg(pParse, "parser stack overflow"); diff --git a/src/tokenize.c b/src/tokenize.c index 2aab334ae9..e6da3fb547 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -526,7 +526,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ }else{ tokenType = TK_SEMI; } - zSql -= n; + n = 0; } if( tokenType>=TK_SPACE ){ assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL ); diff --git a/test/capi2.test b/test/capi2.test index 5e51871814..0680cf530c 100644 --- a/test/capi2.test +++ b/test/capi2.test @@ -163,7 +163,7 @@ do_test capi2-3.2 { sqlite3_prepare $DB {select bogus from } -1 TAIL } msg] lappend rc $msg $TAIL -} {1 {(1) near " ": syntax error} {}} +} {1 {(1) incomplete input} {}} do_test capi2-3.3 { set rc [catch { sqlite3_prepare $DB {;;;;select bogus from sqlite_master} -1 TAIL diff --git a/test/capi3.test b/test/capi3.test index becf1bf5db..01ce65b6a4 100644 --- a/test/capi3.test +++ b/test/capi3.test @@ -649,6 +649,18 @@ do_test capi3-5.33 { sqlite3_finalize $STMT } SQLITE_OK +# 2018-01-09: If a column is the last token if a string, the column name +# was not being set correctly, due to changes in check-in +# https://sqlite.org/src/info/0fdf97efe5df7455 +# +# This problem was detected by the community during beta-testing. +# +do_test capi3-5.34 { + set STMT [sqlite3_prepare $DB {SELECT :a, :b} -1 TAIL] + sqlite3_column_count $STMT +} 2 +check_header $STMT capi-5.35 {:a :b} {{} {}} +sqlite3_finalize $STMT set ::ENC [execsql {pragma encoding}] db close diff --git a/test/icu.test b/test/icu.test index b6d3b7f847..4c4e6d14ec 100644 --- a/test/icu.test +++ b/test/icu.test @@ -138,8 +138,8 @@ ifcapable icu { do_catchsql_test icu-5.4 { SELECT 'abc' REGEXP 'a[abc]c.*' } {0 1} - do_catchsql_test icu-5.4 {SELECT 'abc' REGEXP } {1 {near " ": syntax error}} - do_catchsql_test icu-5.5 {SELECT 'abc' REGEXP, 1} {1 {near ",": syntax error}} + do_catchsql_test icu-5.5 {SELECT 'abc' REGEXP } {1 {incomplete input}} + do_catchsql_test icu-5.6 {SELECT 'abc' REGEXP, 1} {1 {near ",": syntax error}} do_malloc_test icu-6.10 -sqlbody { SELECT upper(char(0xfb04,0xdf,0xfb04,0xe8,0xfb04)); diff --git a/test/main.test b/test/main.test index 9346cf6ced..13a385b7c4 100644 --- a/test/main.test +++ b/test/main.test @@ -434,7 +434,7 @@ do_test main-3.2.28 { } {0 246} do_test main-3.2.29 { catchsql {select 123/} -} {1 {near "/": syntax error}} +} {1 {incomplete input}} do_test main-3.2.30 { catchsql {select 123--5} } {0 123} @@ -467,7 +467,7 @@ do_test main-3.4 { do_test main-3.5 { set v [catch {execsql {create}} msg] lappend v $msg -} {1 {near "create": syntax error}} +} {1 {incomplete input}} do_test main-3.6 { catchsql {SELECT 'abc' + #9} } {1 {near "#9": syntax error}} diff --git a/test/select1.test b/test/select1.test index 43b20f6d15..7023a6e65d 100644 --- a/test/select1.test +++ b/test/select1.test @@ -688,7 +688,7 @@ do_test select1-7.2 { do_test select1-7.3 { set v [catch {execsql {SELECT f1 FROM test1 as 'hi', test2 as}} msg] lappend v $msg -} {1 {near "as": syntax error}} +} {1 {incomplete input}} do_test select1-7.4 { set v [catch {execsql { SELECT f1 FROM test1 ORDER BY; diff --git a/test/shell3.test b/test/shell3.test index bb2524c1cc..63c30a2682 100644 --- a/test/shell3.test +++ b/test/shell3.test @@ -66,7 +66,7 @@ do_test shell3-1.6 { } {0 {}} do_test shell3-1.7 { catchcmd "foo.db \"CREATE TABLE\"" -} {1 {Error: near "TABLE": syntax error}} +} {1 {Error: incomplete input}} #---------------------------------------------------------------------------- # shell3-2.*: Basic tests for running SQL file from command line. @@ -96,6 +96,6 @@ do_test shell3-2.6 { } {0 {}} do_test shell3-2.7 { catchcmd "foo.db" "CREATE TABLE" -} {1 {Error: near line 1: near "TABLE": syntax error}} +} {1 {Error: near line 1: incomplete input}} finish_test diff --git a/test/with2.test b/test/with2.test index 02d10b5112..004ec94b97 100644 --- a/test/with2.test +++ b/test/with2.test @@ -326,7 +326,7 @@ do_catchsql_test 6.5 { do_catchsql_test 6.6 { WITH x AS (SELECT * FROM t1) DELETE FROM t2 WHERE -} {/1 {near .* syntax error}/} +} {1 {incomplete input}} do_catchsql_test 6.7 { WITH x AS (SELECT * FROM t1) DELETE FROM t2 WHRE 1; From 5af06983564e35005dcb550981d8ebceb1b491d6 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 00:53:55 +0000 Subject: [PATCH 088/190] Rearrange some routines in shell.c to avoid the need to forward reference a static function. FossilOrigin-Name: fd7f51a107806666d5c3a3a7a62528ec3e1fb71c4256f49d57b4dcdac4bf8680 --- manifest | 12 ++--- manifest.uuid | 2 +- src/shell.c.in | 128 ++++++++++++++++++++++++------------------------- 3 files changed, 71 insertions(+), 71 deletions(-) diff --git a/manifest b/manifest index a8883b6f20..73254e8c88 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Compute\sthe\scorrect\scolumn\sname\seven\sif\sthe\scolumn\sidentifier\sis\sthe\nvery\slast\stoken\sin\sthe\sSQL\sstatement.\s\sThis\sfixes\sa\sproblem\sintroduced\nby\scheck-in\s[0fdf97efe5df745510c6b]\sand\sreported\sby\sthe\scommunity\sduring\nbeta-testing. -D 2018-01-10T00:40:06.636 +C Rearrange\ssome\sroutines\sin\sshell.c\sto\savoid\sthe\sneed\sto\sforward\sreference\sa\nstatic\sfunction. +D 2018-01-10T00:53:55.338 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 4121ecd9a812c9032726aa137a4504251d03f2001dd6c7c110e7cabd3ee1454b +F src/shell.c.in 1e50d66dc88bcc61d6300a5b8fb71d2d3821ec2d1418aee69337e391061514dd F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3e5647cb6c4553683e24b9cb62548f16c79c4e2ac9e39cf135ea52a623f7cc33 -R 13437b6007d6ef55bf4d81b9dff0be71 +P 36b89d728ff13d395fe0e1db8e7c01263f73dccb278b3ece27f6ef78e909b492 +R c0e5b3be89f9671131b70568ccd2de3b U drh -Z f9f9bd51ed93ca5bce3e08c7f811f3c5 +Z 058862bc11ed7b27f8f707a776eec676 diff --git a/manifest.uuid b/manifest.uuid index 3bef9fc4db..b802c2b17a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -36b89d728ff13d395fe0e1db8e7c01263f73dccb278b3ece27f6ef78e909b492 \ No newline at end of file +fd7f51a107806666d5c3a3a7a62528ec3e1fb71c4256f49d57b4dcdac4bf8680 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index d214850aa9..253b1c764d 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -352,6 +352,11 @@ static void endTimer(void){ */ #define UNUSED_PARAMETER(x) (void)(x) +/* +** Number of elements in an array +*/ +#define ArraySize(X) (int)(sizeof(X)/sizeof(X[0])) + /* ** If the following flag is set, then command execution stops ** at an error if we are not interactive. @@ -624,6 +629,65 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){ } return zResult; } + + +/* +** Return the value of a hexadecimal digit. Return -1 if the input +** is not a hex digit. +*/ +static int hexDigitValue(char c){ + if( c>='0' && c<='9' ) return c - '0'; + if( c>='a' && c<='f' ) return c - 'a' + 10; + if( c>='A' && c<='F' ) return c - 'A' + 10; + return -1; +} + +/* +** Interpret zArg as an integer value, possibly with suffixes. +*/ +static sqlite3_int64 integerValue(const char *zArg){ + sqlite3_int64 v = 0; + static const struct { char *zSuffix; int iMult; } aMult[] = { + { "KiB", 1024 }, + { "MiB", 1024*1024 }, + { "GiB", 1024*1024*1024 }, + { "KB", 1000 }, + { "MB", 1000000 }, + { "GB", 1000000000 }, + { "K", 1000 }, + { "M", 1000000 }, + { "G", 1000000000 }, + }; + int i; + int isNeg = 0; + if( zArg[0]=='-' ){ + isNeg = 1; + zArg++; + }else if( zArg[0]=='+' ){ + zArg++; + } + if( zArg[0]=='0' && zArg[1]=='x' ){ + int x; + zArg += 2; + while( (x = hexDigitValue(zArg[0]))>=0 ){ + v = (v<<4) + x; + zArg++; + } + }else{ + while( IsDigit(zArg[0]) ){ + v = v*10 + zArg[0] - '0'; + zArg++; + } + } + for(i=0; i='0' && c<='9' ) return c - '0'; - if( c>='a' && c<='f' ) return c - 'a' + 10; - if( c>='A' && c<='F' ) return c - 'A' + 10; - return -1; -} - -/* -** Interpret zArg as an integer value, possibly with suffixes. -*/ -static sqlite3_int64 integerValue(const char *zArg){ - sqlite3_int64 v = 0; - static const struct { char *zSuffix; int iMult; } aMult[] = { - { "KiB", 1024 }, - { "MiB", 1024*1024 }, - { "GiB", 1024*1024*1024 }, - { "KB", 1000 }, - { "MB", 1000000 }, - { "GB", 1000000000 }, - { "K", 1000 }, - { "M", 1000000 }, - { "G", 1000000000 }, - }; - int i; - int isNeg = 0; - if( zArg[0]=='-' ){ - isNeg = 1; - zArg++; - }else if( zArg[0]=='+' ){ - zArg++; - } - if( zArg[0]=='0' && zArg[1]=='x' ){ - int x; - zArg += 2; - while( (x = hexDigitValue(zArg[0]))>=0 ){ - v = (v<<4) + x; - zArg++; - } - }else{ - while( IsDigit(zArg[0]) ){ - v = v*10 + zArg[0] - '0'; - zArg++; - } - } - for(i=0; i Date: Wed, 10 Jan 2018 11:56:03 +0000 Subject: [PATCH 089/190] Fix a problem in os_unix.c causing it to return SQLITE_CANTOPEN instead of SQLITE_READONLY_RECOVERY. FossilOrigin-Name: 6a16f554f027ba268276b728588b5eaea837cbed85358a06a2f6da3b70e834ad --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/main.c | 1 + src/os_unix.c | 30 ++++++++++++++++-------------- test/misc7.test | 38 ++++++++++++++++++++++++++++++++++++-- 5 files changed, 63 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index 73254e8c88..b36b5fd4fb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rearrange\ssome\sroutines\sin\sshell.c\sto\savoid\sthe\sneed\sto\sforward\sreference\sa\nstatic\sfunction. -D 2018-01-10T00:53:55.338 +C Fix\sa\sproblem\sin\sos_unix.c\scausing\sit\sto\sreturn\sSQLITE_CANTOPEN\sinstead\sof\nSQLITE_READONLY_RECOVERY. +D 2018-01-10T11:56:03.281 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -448,7 +448,7 @@ F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 14686083cedc198540b15a79586cdd4be2acf6d5fa97627e355f817ab07e9fee F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e F src/loadext.c 55bcc3c741059a1056859e8adaf133aa179e22be12215c0936b2f354ef71209b -F src/main.c 690c4134f944cbd5b71d59dd6e61ce4131f6a50ab774f38108e57d07d79cf876 +F src/main.c 26918d50dd4a61b8f6f210320a522f46b5e7e592335b6aa664ab15b80b7c239b F src/malloc.c 6f684fd039f53bf9195193eb0cde731a2954970fabc6ef054ba379b6052dc296 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de @@ -467,7 +467,7 @@ F src/os.c 22d31db3ca5a96a408fbf1ceeaaebcaf64c87024d2ff9fe1cf2ddbec3e75c104 F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c a9edddcc35d664c8247a18abd10d73b7a80c0d897a5341de8feea5a47cd57e25 +F src/os_unix.c ecdffdc7fc25c07e42908be7c5ea30456fee6263e0d54cdf204557945b445da2 F src/os_win.c 0a4afa35cc8e812000df3ea2f64b476131b39e29e75d8007d0504726e4761de4 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9b9cb4e06c03d43d62480a7a685a012d645fcf3a39e7767ccb505fb41ee083ec @@ -1073,7 +1073,7 @@ F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 0d8be3466adf123a7791a66ba2bc8e8d229e87f3 F test/misc5.test 60e1fc758a93cacd19eb2fafcd1d40d150a05047546c7a92389c98047d621901 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 -F test/misc7.test edd0b63e2ee29a256900b0514f6fff27e19e9bb2 +F test/misc7.test 859894e3192257ce2fc4063b5438b220e352286974b387e485050f0ad1f665d6 F test/misc8.test ba03aaa08f02d62fbb8d3b2f5595c1b33aa9bbc5 F test/misuse.test 9e7f78402005e833af71dcab32d048003869eca5abcaccc985d4f8dc1d86bcc7 F test/mjournal.test 9d86e697dcbc5da2c4e8caba9b176b5765fe65e80c88c278b8c09a917e436795 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 36b89d728ff13d395fe0e1db8e7c01263f73dccb278b3ece27f6ef78e909b492 -R c0e5b3be89f9671131b70568ccd2de3b -U drh -Z 058862bc11ed7b27f8f707a776eec676 +P fd7f51a107806666d5c3a3a7a62528ec3e1fb71c4256f49d57b4dcdac4bf8680 +R b0aec6844a1353d3e8dcd58b6b9b074d +U dan +Z b1844f359ee67c65b8d14dad2349ae2c diff --git a/manifest.uuid b/manifest.uuid index b802c2b17a..e566611f17 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd7f51a107806666d5c3a3a7a62528ec3e1fb71c4256f49d57b4dcdac4bf8680 \ No newline at end of file +6a16f554f027ba268276b728588b5eaea837cbed85358a06a2f6da3b70e834ad \ No newline at end of file diff --git a/src/main.c b/src/main.c index 3c8035c120..ed41f98947 100644 --- a/src/main.c +++ b/src/main.c @@ -1318,6 +1318,7 @@ const char *sqlite3ErrName(int rc){ case SQLITE_READONLY_CANTINIT: zName = "SQLITE_READONLY_CANTINIT"; break; case SQLITE_READONLY_ROLLBACK: zName = "SQLITE_READONLY_ROLLBACK"; break; case SQLITE_READONLY_DBMOVED: zName = "SQLITE_READONLY_DBMOVED"; break; + case SQLITE_READONLY_DIRECTORY: zName = "SQLITE_READONLY_DIRECTORY";break; case SQLITE_INTERRUPT: zName = "SQLITE_INTERRUPT"; break; case SQLITE_IOERR: zName = "SQLITE_IOERR"; break; case SQLITE_IOERR_READ: zName = "SQLITE_IOERR_READ"; break; diff --git a/src/os_unix.c b/src/os_unix.c index 3b2b2e2a59..d368cb34ea 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5904,22 +5904,24 @@ static int unixOpen( fd = robust_open(zName, openFlags, openMode); OSTRACE(("OPENX %-3d %s 0%o\n", fd, zName, openFlags)); assert( !isExclusive || (openFlags & O_CREAT)!=0 ); - if( fd<0 && errno!=EISDIR && isReadWrite ){ - /* Failed to open the file for read/write access. Try read-only. */ - flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE); - openFlags &= ~(O_RDWR|O_CREAT); - flags |= SQLITE_OPEN_READONLY; - openFlags |= O_RDONLY; - isReadonly = 1; - fd = robust_open(zName, openFlags, openMode); + if( fd<0 ){ + if( isNewJrnl && errno==EACCES && osAccess(zName, F_OK) ){ + /* If unable to create a journal because the directory is not + ** writable, change the error code to indicate that. */ + rc = SQLITE_READONLY_DIRECTORY; + }else if( errno!=EISDIR && isReadWrite ){ + /* Failed to open the file for read/write access. Try read-only. */ + flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE); + openFlags &= ~(O_RDWR|O_CREAT); + flags |= SQLITE_OPEN_READONLY; + openFlags |= O_RDONLY; + isReadonly = 1; + fd = robust_open(zName, openFlags, openMode); + } } if( fd<0 ){ - rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName); - /* If unable to create a journal, change the error code to - ** indicate that the directory permissions are wrong. */ - if( isNewJrnl && errno==EACCES && osAccess(zName, F_OK) ){ - rc = SQLITE_READONLY_DIRECTORY; - } + int rc2 = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName); + if( rc==SQLITE_OK ) rc = rc2; goto open_finished; } diff --git a/test/misc7.test b/test/misc7.test index 8fd5fe7546..d0e84dfa47 100644 --- a/test/misc7.test +++ b/test/misc7.test @@ -14,6 +14,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix misc7 if {[clang_sanitize_address]==0} { do_test misc7-1-misuse { @@ -518,8 +519,41 @@ do_test misc7-22.3 { do_test misc7-22.4 { sqlite3_extended_errcode db } SQLITE_READONLY_ROLLBACK - -db close +catch { db close } forcedelete test.db +if {$::tcl_platform(platform)=="unix"} { + reset_db + do_execsql_test 23.0 { + CREATE TABLE t1(x, y); + INSERT INTO t1 VALUES(1, 2); + } + + do_test 23.1 { + db close + forcedelete tst + file mkdir tst + forcecopy test.db tst/test.db + file attributes tst -permissions r-xr-xr-x + } {} + + sqlite3 db tst/test.db + do_execsql_test 23.2 { + SELECT * FROM t1; + } {1 2} + + do_catchsql_test 23.3 { + INSERT INTO t1 VALUES(3, 4); + } {1 {attempt to write a readonly database}} + + do_test 23.4 { + sqlite3_extended_errcode db + } {SQLITE_READONLY_DIRECTORY} + + do_test 23.5 { + db close + forcedelete tst + } {} +} + finish_test From b376b3d6aa5648e1ffe9ca5ff09b2d29003834c7 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 13:11:51 +0000 Subject: [PATCH 090/190] Work on the ".archive" command. (1) Add the --dryrun option. (2) Do not require --file when open on a ZIP archive. (3) Miscellaneous code simplifications. This is an incremental check-in of work in progress. FossilOrigin-Name: a2baada429e84dc4b7243173a056e3c8bc042682f7efb01fdf8d2cc452c97e04 --- manifest | 15 +-- manifest.uuid | 2 +- src/shell.c.in | 269 ++++++++++++++++++++++++++----------------------- 3 files changed, 152 insertions(+), 134 deletions(-) diff --git a/manifest b/manifest index 73254e8c88..2b380e8b60 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rearrange\ssome\sroutines\sin\sshell.c\sto\savoid\sthe\sneed\sto\sforward\sreference\sa\nstatic\sfunction. -D 2018-01-10T00:53:55.338 +C Work\son\sthe\s".archive"\scommand.\n(1)\sAdd\sthe\s--dryrun\soption.\n(2)\sDo\snot\srequire\s--file\swhen\sopen\son\sa\sZIP\sarchive.\n(3)\sMiscellaneous\scode\ssimplifications.\nThis\sis\san\sincremental\scheck-in\sof\swork\sin\sprogress. +D 2018-01-10T13:11:51.661 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 1e50d66dc88bcc61d6300a5b8fb71d2d3821ec2d1418aee69337e391061514dd +F src/shell.c.in f86200b08a8201fab1c775edbff4a81cb7b07e5926b1ed1ad7c043453fdfa7b3 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 36b89d728ff13d395fe0e1db8e7c01263f73dccb278b3ece27f6ef78e909b492 -R c0e5b3be89f9671131b70568ccd2de3b +P fd7f51a107806666d5c3a3a7a62528ec3e1fb71c4256f49d57b4dcdac4bf8680 +R da66d185dcc66f20b0c30262a6b67fe7 +T *branch * archive-improvements +T *sym-archive-improvements * +T -sym-trunk * U drh -Z 058862bc11ed7b27f8f707a776eec676 +Z 75859d5801ea825c715cde8533b487b8 diff --git a/manifest.uuid b/manifest.uuid index b802c2b17a..822237285a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd7f51a107806666d5c3a3a7a62528ec3e1fb71c4256f49d57b4dcdac4bf8680 \ No newline at end of file +a2baada429e84dc4b7243173a056e3c8bc042682f7efb01fdf8d2cc452c97e04 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 253b1c764d..4bfc1c85cc 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4503,13 +4503,17 @@ static void shellReset( */ typedef struct ArCommand ArCommand; struct ArCommand { - int eCmd; /* An AR_CMD_* value */ + u8 eCmd; /* An AR_CMD_* value */ + u8 bVerbose; /* True if --verbose */ + u8 bZip; /* True if --zip */ + u8 bDryRun; /* True if --dry-run */ + int nArg; /* Number of command arguments */ + const char *zSrcTable; /* "sqlar", "zipfile($file)" or "zip" */ const char *zFile; /* --file argument, or NULL */ const char *zDir; /* --directory argument, or NULL */ - int bVerbose; /* True if --verbose */ - int bZip; /* True if --zip */ - int nArg; /* Number of command arguments */ char **azArg; /* Array of command arguments */ + ShellState *p; /* Shell state */ + sqlite3 *db; /* Database containing the archive */ }; /* @@ -4536,6 +4540,8 @@ static int arUsage(FILE *f){ " -v, --verbose Print each filename as it is processed\n" " -f FILE, --file FILE Operate on archive FILE (default is current db)\n" " -C DIR, --directory DIR Change to directory DIR to read/extract files\n" +" -n, --dryrun Show the SQL that would have occurred\n" +" -z, --zip Operate on a ZIP archive instead of an SQLAR\n" "\n" "See also: http://sqlite.org/cli.html#sqlar_archive_support\n" "\n" @@ -4570,10 +4576,11 @@ static int arErrorMsg(const char *zFmt, ...){ /* ** Other (non-command) switches. */ -#define AR_SWITCH_VERBOSE 6 -#define AR_SWITCH_FILE 7 -#define AR_SWITCH_DIRECTORY 8 -#define AR_SWITCH_ZIP 9 +#define AR_SWITCH_VERBOSE 6 +#define AR_SWITCH_FILE 7 +#define AR_SWITCH_DIRECTORY 8 +#define AR_SWITCH_ZIP 9 +#define AR_SWITCH_DRYRUN 10 static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ switch( eSwitch ){ @@ -4588,6 +4595,9 @@ static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ pAr->eCmd = eSwitch; break; + case AR_SWITCH_DRYRUN: + pAr->bDryRun = 1; + break; case AR_SWITCH_VERBOSE: pAr->bVerbose = 1; break; @@ -4618,20 +4628,21 @@ static int arParseCommand( ArCommand *pAr /* Populate this object */ ){ struct ArSwitch { - char cShort; const char *zLong; - int eSwitch; - int bArg; + char cShort; + u8 eSwitch; + u8 bArg; } aSwitch[] = { - { 'c', "create", AR_CMD_CREATE, 0 }, - { 'x', "extract", AR_CMD_EXTRACT, 0 }, - { 't', "list", AR_CMD_LIST, 0 }, - { 'u', "update", AR_CMD_UPDATE, 0 }, - { 'h', "help", AR_CMD_HELP, 0 }, - { 'v', "verbose", AR_SWITCH_VERBOSE, 0 }, - { 'f', "file", AR_SWITCH_FILE, 1 }, - { 'C', "directory", AR_SWITCH_DIRECTORY, 1 }, - { 'z', "zip", AR_SWITCH_ZIP, 0 } + { "create", 'c', AR_CMD_CREATE, 0 }, + { "extract", 'x', AR_CMD_EXTRACT, 0 }, + { "list", 't', AR_CMD_LIST, 0 }, + { "update", 'u', AR_CMD_UPDATE, 0 }, + { "help", 'h', AR_CMD_HELP, 0 }, + { "verbose", 'v', AR_SWITCH_VERBOSE, 0 }, + { "file", 'f', AR_SWITCH_FILE, 1 }, + { "directory", 'C', AR_SWITCH_DIRECTORY, 1 }, + { "zip", 'z', AR_SWITCH_ZIP, 0 }, + { "dryrun", 'n', AR_SWITCH_DRYRUN, 0 }, }; int nSwitch = sizeof(aSwitch) / sizeof(struct ArSwitch); struct ArSwitch *pEnd = &aSwitch[nSwitch]; @@ -4758,37 +4769,40 @@ static int arParseCommand( ** This is consistent with the way the [tar] command seems to work on ** Linux. */ -static int arCheckEntries(sqlite3 *db, ArCommand *pAr){ +static int arCheckEntries(ArCommand *pAr){ int rc = SQLITE_OK; if( pAr->nArg ){ - int i; + int i, j; sqlite3_stmt *pTest = 0; - shellPreparePrintf(db, &rc, &pTest, "SELECT name FROM %s WHERE name=?1", - pAr->bZip ? "zipfile(?2)" : "sqlar" + shellPreparePrintf(pAr->db, &rc, &pTest, + "SELECT name FROM %s WHERE name=$name", + pAr->zSrcTable ); - if( rc==SQLITE_OK && pAr->bZip ){ - sqlite3_bind_text(pTest, 2, pAr->zFile, -1, SQLITE_TRANSIENT); + if( rc==SQLITE_OK + && (j = sqlite3_bind_parameter_index(pTest, "$archiveFile"))>0 + ){ + sqlite3_bind_text(pTest, j, pAr->zFile, -1, SQLITE_TRANSIENT); } + j = sqlite3_bind_parameter_index(pTest, "$name"); for(i=0; inArg && rc==SQLITE_OK; i++){ char *z = pAr->azArg[i]; int n = strlen30(z); int bOk = 0; while( n>0 && z[n-1]=='/' ) n--; z[n] = '\0'; - sqlite3_bind_text(pTest, 1, z, -1, SQLITE_STATIC); + sqlite3_bind_text(pTest, j, z, -1, SQLITE_STATIC); if( SQLITE_ROW==sqlite3_step(pTest) ){ bOk = 1; } shellReset(&rc, pTest); if( rc==SQLITE_OK && bOk==0 ){ - raw_printf(stderr, "not found in archive: %s\n", z); + utf8_printf(stderr, "not found in archive: %s\n", z); rc = SQLITE_ERROR; } } shellFinalize(&rc, pTest); } - return rc; } @@ -4814,9 +4828,9 @@ static void arWhereClause( for(i=0; inArg; i++){ const char *z = pAr->azArg[i]; zWhere = sqlite3_mprintf( - "%z%s name = '%q' OR name BETWEEN '%q/' AND '%q0'", - zWhere, zSep, z, z, z - ); + "%z%s name = '%q' OR substr(name,1,%d) = '%q/'", + zWhere, zSep, z, strlen30(z)+1, z + ); if( zWhere==0 ){ *pRc = SQLITE_NOMEM; break; @@ -4858,9 +4872,8 @@ static void shellModeToString(char *zMode, int mode){ /* ** Implementation of .ar "lisT" command. */ -static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ +static int arListCommand(ArCommand *pAr){ const char *zSql = "SELECT %s FROM %s WHERE %s"; - const char *zTbl = (pAr->bZip ? "zipfile(?)" : "sqlar"); const char *azCols[] = { "name", "mode, sz, datetime(mtime, 'unixepoch'), name" @@ -4869,29 +4882,36 @@ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ char *zWhere = 0; sqlite3_stmt *pSql = 0; int rc; + int j; - rc = arCheckEntries(db, pAr); + rc = arCheckEntries(pAr); arWhereClause(&rc, pAr, &zWhere); - shellPreparePrintf(db, &rc, &pSql, zSql, azCols[pAr->bVerbose], zTbl, zWhere); - if( rc==SQLITE_OK && pAr->bZip ){ - sqlite3_bind_text(pSql, 1, pAr->zFile, -1, SQLITE_TRANSIENT); + shellPreparePrintf(pAr->db, &rc, &pSql, zSql, azCols[pAr->bVerbose], + pAr->zSrcTable, zWhere); + if( rc==SQLITE_OK + && (j = sqlite3_bind_parameter_index(pSql, "$archiveFile"))>0 + ){ + sqlite3_bind_text(pSql, j, pAr->zFile, -1, SQLITE_TRANSIENT); } - while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ - if( pAr->bVerbose ){ - char zMode[11]; - shellModeToString(zMode, sqlite3_column_int(pSql, 0)); - - raw_printf(p->out, "%s % 10d %s %s\n", zMode, - sqlite3_column_int(pSql, 1), - sqlite3_column_text(pSql, 2), - sqlite3_column_text(pSql, 3) - ); - }else{ - raw_printf(p->out, "%s\n", sqlite3_column_text(pSql, 0)); + if( pAr->bDryRun ){ + utf8_printf(pAr->p->out, "%s\n", sqlite3_sql(pSql)); + }else{ + while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ + if( pAr->bVerbose ){ + char zMode[11]; + shellModeToString(zMode, sqlite3_column_int(pSql, 0)); + + utf8_printf(pAr->p->out, "%s % 10d %s %s\n", zMode, + sqlite3_column_int(pSql, 1), + sqlite3_column_text(pSql, 2), + sqlite3_column_text(pSql, 3) + ); + }else{ + utf8_printf(pAr->p->out, "%s\n", sqlite3_column_text(pSql, 0)); + } } } - shellFinalize(&rc, pSql); return rc; } @@ -4900,31 +4920,28 @@ static int arListCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ /* ** Implementation of .ar "eXtract" command. */ -static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ +static int arExtractCommand(ArCommand *pAr){ const char *zSql1 = "SELECT " - " :1 || name, " - " writefile(?1 || name, %s, mode, mtime) " - "FROM %s WHERE (%s) AND (data IS NULL OR ?2 = 0)"; + " ($dir || name)," + " writefile(($dir || name), %s, mode, mtime) " + "FROM %s WHERE (%s) AND (data IS NULL OR $dirOnly = 0)"; const char *azExtraArg[] = { "sqlar_uncompress(data, sz)", "data" }; - const char *azSource[] = { - "sqlar", "zipfile(?3)" - }; sqlite3_stmt *pSql = 0; int rc = SQLITE_OK; char *zDir = 0; char *zWhere = 0; - int i; + int i, j; /* If arguments are specified, check that they actually exist within ** the archive before proceeding. And formulate a WHERE clause to ** match them. */ - rc = arCheckEntries(db, pAr); + rc = arCheckEntries(pAr); arWhereClause(&rc, pAr, &zWhere); if( rc==SQLITE_OK ){ @@ -4936,14 +4953,16 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ if( zDir==0 ) rc = SQLITE_NOMEM; } - shellPreparePrintf(db, &rc, &pSql, zSql1, - azExtraArg[pAr->bZip], azSource[pAr->bZip], zWhere + shellPreparePrintf(pAr->db, &rc, &pSql, zSql1, + azExtraArg[pAr->bZip], pAr->zSrcTable, zWhere ); if( rc==SQLITE_OK ){ - sqlite3_bind_text(pSql, 1, zDir, -1, SQLITE_STATIC); - if( pAr->bZip ){ - sqlite3_bind_text(pSql, 3, pAr->zFile, -1, SQLITE_STATIC); + j = sqlite3_bind_parameter_index(pSql, "$dir"); + sqlite3_bind_text(pSql, j, zDir, -1, SQLITE_STATIC); + j = sqlite3_bind_parameter_index(pSql, "$archiveFile"); + if( j ){ + sqlite3_bind_text(pSql, j, pAr->zFile, -1, SQLITE_STATIC); } /* Run the SELECT statement twice. The first time, writefile() is called @@ -4952,10 +4971,15 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ ** extracted directories must be reset after they are populated (as ** populating them changes the timestamp). */ for(i=0; i<2; i++){ - sqlite3_bind_int(pSql, 2, i); - while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ - if( i==0 && pAr->bVerbose ){ - raw_printf(p->out, "%s\n", sqlite3_column_text(pSql, 0)); + j = sqlite3_bind_parameter_index(pSql, "$dirOnly"); + sqlite3_bind_int(pSql, j, i); + if( pAr->bDryRun ){ + utf8_printf(pAr->p->out, "%s\n", sqlite3_sql(pSql)); + }else{ + while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ + if( i==0 && pAr->bVerbose ){ + utf8_printf(pAr->p->out, "%s\n", sqlite3_column_text(pSql, 0)); + } } } shellReset(&rc, pSql); @@ -4968,6 +4992,20 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ return rc; } +/* +** Run the SQL statement in zSql. Or if doing a --dryrun, merely print it out. +*/ +static int arExecSql(ArCommand *pAr, const char *zSql){ + int rc; + if( pAr->bDryRun ){ + utf8_printf(pAr->p->out, "%s\n", zSql); + rc = SQLITE_OK; + }else{ + rc = sqlite3_exec(pAr->db, zSql, 0, 0, 0); + } + return rc; +} + /* ** Implementation of .ar "create" and "update" commands. @@ -4980,11 +5018,9 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ ** The create command is the same as update, except that it drops ** any existing "sqlar" table before beginning. */ -static int arCreateUpdate( - ShellState *p, /* Shell state pointer */ - sqlite3 *db, +static int arCreateOrUpdateCommand( ArCommand *pAr, /* Command arguments and options */ - int bUpdate + int bUpdate /* true for a --create. false for --update */ ){ const char *zSql = "SELECT name, mode, mtime, data FROM fsdir(?, ?)"; const char *zCreate = @@ -5005,17 +5041,17 @@ static int arCreateUpdate( assert( pAr->bZip==0 ); - rc = sqlite3_exec(db, "SAVEPOINT ar;", 0, 0, 0); + rc = arExecSql(pAr, "SAVEPOINT ar;"); if( rc!=SQLITE_OK ) return rc; if( bUpdate==0 ){ - rc = sqlite3_exec(db, zDrop, 0, 0, 0); + rc = arExecSql(pAr, zDrop); if( rc!=SQLITE_OK ) return rc; } - rc = sqlite3_exec(db, zCreate, 0, 0, 0); - shellPrepare(db, &rc, zInsert, &pInsert); - shellPrepare(db, &rc, zSql, &pStmt); + rc = arExecSql(pAr, zCreate); + shellPrepare(pAr->db, &rc, zInsert, &pInsert); + shellPrepare(pAr->db, &rc, zSql, &pStmt); sqlite3_bind_text(pStmt, 2, pAr->zDir, -1, SQLITE_STATIC); for(i=0; inArg && rc==SQLITE_OK; i++){ @@ -5027,7 +5063,7 @@ static int arCreateUpdate( unsigned int mtime = sqlite3_column_int(pStmt, 2); if( pAr->bVerbose ){ - raw_printf(p->out, "%s\n", zName); + utf8_printf(pAr->p->out, "%s\n", zName); } sqlite3_bind_text(pInsert, 1, zName, -1, SQLITE_STATIC); @@ -5047,46 +5083,26 @@ static int arCreateUpdate( } sqlite3_bind_int(pInsert, 4, sz); - sqlite3_step(pInsert); + if( pAr->bDryRun ){ + utf8_printf(pAr->p->out, "%s\n", sqlite3_sql(pInsert)); + }else{ + sqlite3_step(pInsert); + } rc = sqlite3_reset(pInsert); } shellReset(&rc, pStmt); } if( rc!=SQLITE_OK ){ - sqlite3_exec(db, "ROLLBACK TO ar; RELEASE ar;", 0, 0, 0); + arExecSql(pAr, "ROLLBACK TO ar; RELEASE ar;"); }else{ - rc = sqlite3_exec(db, "RELEASE ar;", 0, 0, 0); + rc = arExecSql(pAr, "RELEASE ar;"); } shellFinalize(&rc, pStmt); shellFinalize(&rc, pInsert); return rc; } -/* -** Implementation of .ar "Create" command. -** -** Create the "sqlar" table in the database if it does not already exist. -** Then add each file in the azFile[] array to the archive. Directories -** are added recursively. If argument bVerbose is non-zero, a message is -** printed on stdout for each file archived. -*/ -static int arCreateCommand( - ShellState *p, /* Shell state pointer */ - sqlite3 *db, - ArCommand *pAr /* Command arguments and options */ -){ - return arCreateUpdate(p, db, pAr, 0); -} - -/* -** Implementation of .ar "Update" command. -*/ -static int arUpdateCmd(ShellState *p, sqlite3 *db, ArCommand *pAr){ - return arCreateUpdate(p, db, pAr, 1); -} - - /* ** Implementation of ".ar" dot command. */ @@ -5099,18 +5115,19 @@ static int arDotCommand( int rc; rc = arParseCommand(azArg, nArg, &cmd); if( rc==SQLITE_OK ){ - sqlite3 *db = 0; /* Database handle to use as archive */ - + cmd.p = pState; + cmd.db = pState->db; + cmd.zSrcTable = "sqlar"; if( cmd.bZip ){ - if( cmd.zFile==0 ){ - raw_printf(stderr, "zip format requires a --file switch\n"); - return SQLITE_ERROR; - }else + if( pState->openMode==SHELL_OPEN_ZIPFILE ){ + cmd.zSrcTable = "zip"; + }else{ + cmd.zSrcTable = "zipfile($archiveFile)"; + } if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_UPDATE ){ - raw_printf(stderr, "zip archives are read-only\n"); + utf8_printf(stderr, "zip archives are read-only\n"); return SQLITE_ERROR; } - db = pState->db; }else if( cmd.zFile ){ int flags; if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_UPDATE ){ @@ -5118,33 +5135,31 @@ static int arDotCommand( }else{ flags = SQLITE_OPEN_READONLY; } - rc = sqlite3_open_v2(cmd.zFile, &db, flags, 0); + rc = sqlite3_open_v2(cmd.zFile, &cmd.db, flags, 0); if( rc!=SQLITE_OK ){ - raw_printf(stderr, "cannot open file: %s (%s)\n", - cmd.zFile, sqlite3_errmsg(db) + utf8_printf(stderr, "cannot open file: %s (%s)\n", + cmd.zFile, sqlite3_errmsg(cmd.db) ); - sqlite3_close(db); + sqlite3_close(cmd.db); return rc; } - sqlite3_fileio_init(db, 0, 0); + sqlite3_fileio_init(cmd.db, 0, 0); #ifdef SQLITE_HAVE_ZLIB - sqlite3_sqlar_init(db, 0, 0); + sqlite3_sqlar_init(cmd.db, 0, 0); #endif - }else{ - db = pState->db; } switch( cmd.eCmd ){ case AR_CMD_CREATE: - rc = arCreateCommand(pState, db, &cmd); + rc = arCreateOrUpdateCommand(&cmd, 0); break; case AR_CMD_EXTRACT: - rc = arExtractCommand(pState, db, &cmd); + rc = arExtractCommand(&cmd); break; case AR_CMD_LIST: - rc = arListCommand(pState, db, &cmd); + rc = arListCommand(&cmd); break; case AR_CMD_HELP: @@ -5153,12 +5168,12 @@ static int arDotCommand( default: assert( cmd.eCmd==AR_CMD_UPDATE ); - rc = arUpdateCmd(pState, db, &cmd); + rc = arCreateOrUpdateCommand(&cmd, 1); break; } if( cmd.zFile ){ - sqlite3_close(db); + sqlite3_close(cmd.db); } } From e75d1f5290361d7a0de2b10c842ce2983c1ce6c2 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 13:58:23 +0000 Subject: [PATCH 091/190] Tag an unreachable branch using ALWAYS(). FossilOrigin-Name: c42c734f11c58724f5d8b32cb1c92e274be350028868d6ed045b2cfd274c64e7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/malloc.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index b36b5fd4fb..8e88f6ca98 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sos_unix.c\scausing\sit\sto\sreturn\sSQLITE_CANTOPEN\sinstead\sof\nSQLITE_READONLY_RECOVERY. -D 2018-01-10T11:56:03.281 +C Tag\san\sunreachable\sbranch\susing\sALWAYS(). +D 2018-01-10T13:58:23.623 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -449,7 +449,7 @@ F src/insert.c 14686083cedc198540b15a79586cdd4be2acf6d5fa97627e355f817ab07e9fee F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e F src/loadext.c 55bcc3c741059a1056859e8adaf133aa179e22be12215c0936b2f354ef71209b F src/main.c 26918d50dd4a61b8f6f210320a522f46b5e7e592335b6aa664ab15b80b7c239b -F src/malloc.c 6f684fd039f53bf9195193eb0cde731a2954970fabc6ef054ba379b6052dc296 +F src/malloc.c 07295435093ce354c6d9063ac05a2eeae28bd251d2e63c48b3d67c12c76f7e18 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fd7f51a107806666d5c3a3a7a62528ec3e1fb71c4256f49d57b4dcdac4bf8680 -R b0aec6844a1353d3e8dcd58b6b9b074d -U dan -Z b1844f359ee67c65b8d14dad2349ae2c +P 6a16f554f027ba268276b728588b5eaea837cbed85358a06a2f6da3b70e834ad +R 8ba57fadebb1bef28ae4cd97ec4b22a9 +U drh +Z 3f9f5c48f04edbfb2783cc163a50a4b5 diff --git a/manifest.uuid b/manifest.uuid index e566611f17..91ba96987f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a16f554f027ba268276b728588b5eaea837cbed85358a06a2f6da3b70e834ad \ No newline at end of file +c42c734f11c58724f5d8b32cb1c92e274be350028868d6ed045b2cfd274c64e7 \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index ec2d93ac89..d7f9df5efc 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -636,7 +636,7 @@ char *sqlite3DbSpanDup(sqlite3 *db, const char *zStart, const char *zEnd){ int n; while( sqlite3Isspace(zStart[0]) ) zStart++; n = (int)(zEnd - zStart); - while( n>0 && sqlite3Isspace(zStart[n-1]) ) n--; + while( ALWAYS(n>0) && sqlite3Isspace(zStart[n-1]) ) n--; return sqlite3DbStrNDup(db, zStart, n); } From a82c95b47d17c172077bdc9c1b225a577498efdd Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 14:00:00 +0000 Subject: [PATCH 092/190] Allow the use of ".ar -t" without specifying an archive file or the "-z" option when the command-line shell is opened on a ZIP archive. FossilOrigin-Name: 9340a2c145bcb4b38d19276a16264a37341c617f0554d66e1da653f1d9f85163 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/shell.c.in | 14 ++++++++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 2b380e8b60..96ab066f1b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Work\son\sthe\s".archive"\scommand.\n(1)\sAdd\sthe\s--dryrun\soption.\n(2)\sDo\snot\srequire\s--file\swhen\sopen\son\sa\sZIP\sarchive.\n(3)\sMiscellaneous\scode\ssimplifications.\nThis\sis\san\sincremental\scheck-in\sof\swork\sin\sprogress. -D 2018-01-10T13:11:51.661 +C Allow\sthe\suse\sof\s".ar\s-t"\swithout\sspecifying\san\sarchive\sfile\sor\sthe\s"-z"\noption\swhen\sthe\scommand-line\sshell\sis\sopened\son\sa\sZIP\sarchive. +D 2018-01-10T14:00:00.949 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in f86200b08a8201fab1c775edbff4a81cb7b07e5926b1ed1ad7c043453fdfa7b3 +F src/shell.c.in aae06c143e7c70cfe616a96af8b5656f3891916beee172c7a40b084dab221b79 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,10 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fd7f51a107806666d5c3a3a7a62528ec3e1fb71c4256f49d57b4dcdac4bf8680 -R da66d185dcc66f20b0c30262a6b67fe7 -T *branch * archive-improvements -T *sym-archive-improvements * -T -sym-trunk * +P a2baada429e84dc4b7243173a056e3c8bc042682f7efb01fdf8d2cc452c97e04 +R 870698cbfc790bad8e7df783afd6e385 U drh -Z 75859d5801ea825c715cde8533b487b8 +Z 6cb4ecc388fb1e11ac7a5d118227df45 diff --git a/manifest.uuid b/manifest.uuid index 822237285a..94454fbf0d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a2baada429e84dc4b7243173a056e3c8bc042682f7efb01fdf8d2cc452c97e04 \ No newline at end of file +9340a2c145bcb4b38d19276a16264a37341c617f0554d66e1da653f1d9f85163 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 4bfc1c85cc..ad5300336e 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -5118,11 +5118,16 @@ static int arDotCommand( cmd.p = pState; cmd.db = pState->db; cmd.zSrcTable = "sqlar"; - if( cmd.bZip ){ - if( pState->openMode==SHELL_OPEN_ZIPFILE ){ + if( cmd.bZip || pState->openMode==SHELL_OPEN_ZIPFILE ){ + if( cmd.zFile==0 + && sqlite3_table_column_metadata(cmd.db,0,"zip","name",0,0,0,0,0)==SQLITE_OK + ){ cmd.zSrcTable = "zip"; - }else{ + }else if( cmd.zFile!=0 ){ cmd.zSrcTable = "zipfile($archiveFile)"; + }else{ + utf8_printf(stderr, "no zip archive file specified\n"); + return SQLITE_ERROR; } if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_UPDATE ){ utf8_printf(stderr, "zip archives are read-only\n"); @@ -5135,6 +5140,7 @@ static int arDotCommand( }else{ flags = SQLITE_OPEN_READONLY; } + cmd.db = 0; rc = sqlite3_open_v2(cmd.zFile, &cmd.db, flags, 0); if( rc!=SQLITE_OK ){ utf8_printf(stderr, "cannot open file: %s (%s)\n", @@ -5172,7 +5178,7 @@ static int arDotCommand( break; } - if( cmd.zFile ){ + if( cmd.db!=pState->db ){ sqlite3_close(cmd.db); } } From a5676c4d2df3bae5d2da4706e44e6e0ee5955bf0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 15:17:34 +0000 Subject: [PATCH 093/190] The ".ar" command deduces whether or not the target file is a ZIP or SQLAR and does the appropropriate thing. The "-z" option is omitted. The "--append" option is added to open auxiliary databases using apndvfs. FossilOrigin-Name: 430d1a7daa823ae53606b7a158af4e7c16f62ff9b072b90606524e7c3f6131df --- manifest | 14 +++---- manifest.uuid | 2 +- src/shell.c.in | 103 +++++++++++++++++++++++++++-------------------- test/shell8.test | 3 +- 4 files changed, 68 insertions(+), 54 deletions(-) diff --git a/manifest b/manifest index 96ab066f1b..da3f059664 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sthe\suse\sof\s".ar\s-t"\swithout\sspecifying\san\sarchive\sfile\sor\sthe\s"-z"\noption\swhen\sthe\scommand-line\sshell\sis\sopened\son\sa\sZIP\sarchive. -D 2018-01-10T14:00:00.949 +C The\s".ar"\scommand\sdeduces\swhether\sor\snot\sthe\starget\sfile\sis\na\sZIP\sor\sSQLAR\sand\sdoes\sthe\sappropropriate\sthing.\s\sThe\s"-z"\soption\sis\somitted.\nThe\s"--append"\soption\sis\sadded\sto\sopen\sauxiliary\sdatabases\susing\sapndvfs. +D 2018-01-10T15:17:34.832 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in aae06c143e7c70cfe616a96af8b5656f3891916beee172c7a40b084dab221b79 +F src/shell.c.in 7d49ed78c6d8298d38d4733c3cc24f3a4230cd2f151564b7c11ab2e280007f9c F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1225,7 +1225,7 @@ F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f -F test/shell8.test 5a1f2c6d5cc11e7c7d69e960972f447a9b01e80c419ff9ebaf059f94fe5b3ab9 +F test/shell8.test c836470ccde867e1f438a7acad7560805cc04f9dbab84cb55d92925942b76247 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a2baada429e84dc4b7243173a056e3c8bc042682f7efb01fdf8d2cc452c97e04 -R 870698cbfc790bad8e7df783afd6e385 +P 9340a2c145bcb4b38d19276a16264a37341c617f0554d66e1da653f1d9f85163 +R 9764fa4832552c458077bab9b9143a51 U drh -Z 6cb4ecc388fb1e11ac7a5d118227df45 +Z fa68d24d45da969d4d63bf64e8c4f030 diff --git a/manifest.uuid b/manifest.uuid index 94454fbf0d..8a5e2767d2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9340a2c145bcb4b38d19276a16264a37341c617f0554d66e1da653f1d9f85163 \ No newline at end of file +430d1a7daa823ae53606b7a158af4e7c16f62ff9b072b90606524e7c3f6131df \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index ad5300336e..83b21b1663 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4505,10 +4505,11 @@ typedef struct ArCommand ArCommand; struct ArCommand { u8 eCmd; /* An AR_CMD_* value */ u8 bVerbose; /* True if --verbose */ - u8 bZip; /* True if --zip */ + u8 bZip; /* True if the archive is a ZIP */ u8 bDryRun; /* True if --dry-run */ + u8 bAppend; /* True if --append */ int nArg; /* Number of command arguments */ - const char *zSrcTable; /* "sqlar", "zipfile($file)" or "zip" */ + char *zSrcTable; /* "sqlar", "zipfile($file)" or "zip" */ const char *zFile; /* --file argument, or NULL */ const char *zDir; /* --directory argument, or NULL */ char **azArg; /* Array of command arguments */ @@ -4541,7 +4542,7 @@ static int arUsage(FILE *f){ " -f FILE, --file FILE Operate on archive FILE (default is current db)\n" " -C DIR, --directory DIR Change to directory DIR to read/extract files\n" " -n, --dryrun Show the SQL that would have occurred\n" -" -z, --zip Operate on a ZIP archive instead of an SQLAR\n" +" -a, --append Append the SQLAR to an existing file\n" "\n" "See also: http://sqlite.org/cli.html#sqlar_archive_support\n" "\n" @@ -4579,7 +4580,7 @@ static int arErrorMsg(const char *zFmt, ...){ #define AR_SWITCH_VERBOSE 6 #define AR_SWITCH_FILE 7 #define AR_SWITCH_DIRECTORY 8 -#define AR_SWITCH_ZIP 9 +#define AR_SWITCH_APPEND 9 #define AR_SWITCH_DRYRUN 10 static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ @@ -4601,8 +4602,8 @@ static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ case AR_SWITCH_VERBOSE: pAr->bVerbose = 1; break; - case AR_SWITCH_ZIP: - pAr->bZip = 1; + case AR_SWITCH_APPEND: + pAr->bAppend = 1; break; case AR_SWITCH_FILE: @@ -4641,7 +4642,7 @@ static int arParseCommand( { "verbose", 'v', AR_SWITCH_VERBOSE, 0 }, { "file", 'f', AR_SWITCH_FILE, 1 }, { "directory", 'C', AR_SWITCH_DIRECTORY, 1 }, - { "zip", 'z', AR_SWITCH_ZIP, 0 }, + { "append", 'a', AR_SWITCH_APPEND, 0 }, { "dryrun", 'n', AR_SWITCH_DRYRUN, 0 }, }; int nSwitch = sizeof(aSwitch) / sizeof(struct ArSwitch); @@ -4779,11 +4780,6 @@ static int arCheckEntries(ArCommand *pAr){ "SELECT name FROM %s WHERE name=$name", pAr->zSrcTable ); - if( rc==SQLITE_OK - && (j = sqlite3_bind_parameter_index(pTest, "$archiveFile"))>0 - ){ - sqlite3_bind_text(pTest, j, pAr->zFile, -1, SQLITE_TRANSIENT); - } j = sqlite3_bind_parameter_index(pTest, "$name"); for(i=0; inArg && rc==SQLITE_OK; i++){ char *z = pAr->azArg[i]; @@ -4882,18 +4878,12 @@ static int arListCommand(ArCommand *pAr){ char *zWhere = 0; sqlite3_stmt *pSql = 0; int rc; - int j; rc = arCheckEntries(pAr); arWhereClause(&rc, pAr, &zWhere); shellPreparePrintf(pAr->db, &rc, &pSql, zSql, azCols[pAr->bVerbose], pAr->zSrcTable, zWhere); - if( rc==SQLITE_OK - && (j = sqlite3_bind_parameter_index(pSql, "$archiveFile"))>0 - ){ - sqlite3_bind_text(pSql, j, pAr->zFile, -1, SQLITE_TRANSIENT); - } if( pAr->bDryRun ){ utf8_printf(pAr->p->out, "%s\n", sqlite3_sql(pSql)); }else{ @@ -4960,10 +4950,6 @@ static int arExtractCommand(ArCommand *pAr){ if( rc==SQLITE_OK ){ j = sqlite3_bind_parameter_index(pSql, "$dir"); sqlite3_bind_text(pSql, j, zDir, -1, SQLITE_STATIC); - j = sqlite3_bind_parameter_index(pSql, "$archiveFile"); - if( j ){ - sqlite3_bind_text(pSql, j, pAr->zFile, -1, SQLITE_STATIC); - } /* Run the SELECT statement twice. The first time, writefile() is called ** for all archive members that should be extracted. The second time, @@ -5022,7 +5008,7 @@ static int arCreateOrUpdateCommand( ArCommand *pAr, /* Command arguments and options */ int bUpdate /* true for a --create. false for --update */ ){ - const char *zSql = "SELECT name, mode, mtime, data FROM fsdir(?, ?)"; + const char *zSql = "SELECT name, mode, mtime, data FROM fsdir($name, $dir)"; const char *zCreate = "CREATE TABLE IF NOT EXISTS sqlar(\n" " name TEXT PRIMARY KEY, -- name of the file\n" @@ -5037,6 +5023,7 @@ static int arCreateOrUpdateCommand( sqlite3_stmt *pStmt = 0; /* Directory traverser */ sqlite3_stmt *pInsert = 0; /* Compilation of zInsert */ int i; /* For iterating through azFile[] */ + int j; /* Parameter index */ int rc; /* Return code */ assert( pAr->bZip==0 ); @@ -5050,12 +5037,19 @@ static int arCreateOrUpdateCommand( } rc = arExecSql(pAr, zCreate); - shellPrepare(pAr->db, &rc, zInsert, &pInsert); + if( !pAr->bDryRun ){ + shellPrepare(pAr->db, &rc, zInsert, &pInsert); + } shellPrepare(pAr->db, &rc, zSql, &pStmt); - sqlite3_bind_text(pStmt, 2, pAr->zDir, -1, SQLITE_STATIC); + j = sqlite3_bind_parameter_index(pStmt, "$dir"); + sqlite3_bind_text(pStmt, j, pAr->zDir, -1, SQLITE_STATIC); + if( pAr->bDryRun ){ + utf8_printf(pAr->p->out, "%s;\n", sqlite3_sql(pStmt)); + } for(i=0; inArg && rc==SQLITE_OK; i++){ - sqlite3_bind_text(pStmt, 1, pAr->azArg[i], -1, SQLITE_STATIC); + j = sqlite3_bind_parameter_index(pStmt, "$name"); + sqlite3_bind_text(pStmt, j, pAr->azArg[i], -1, SQLITE_STATIC); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ int sz; const char *zName = (const char*)sqlite3_column_text(pStmt, 0); @@ -5065,6 +5059,10 @@ static int arCreateOrUpdateCommand( if( pAr->bVerbose ){ utf8_printf(pAr->p->out, "%s\n", zName); } + if( pAr->bDryRun ){ + utf8_printf(pAr->p->out, "%s;\n", zInsert); + continue; + } sqlite3_bind_text(pInsert, 1, zName, -1, SQLITE_STATIC); sqlite3_bind_int(pInsert, 2, mode); @@ -5115,45 +5113,61 @@ static int arDotCommand( int rc; rc = arParseCommand(azArg, nArg, &cmd); if( rc==SQLITE_OK ){ + int eDbType = SHELL_OPEN_UNSPEC; cmd.p = pState; cmd.db = pState->db; - cmd.zSrcTable = "sqlar"; - if( cmd.bZip || pState->openMode==SHELL_OPEN_ZIPFILE ){ - if( cmd.zFile==0 - && sqlite3_table_column_metadata(cmd.db,0,"zip","name",0,0,0,0,0)==SQLITE_OK - ){ - cmd.zSrcTable = "zip"; - }else if( cmd.zFile!=0 ){ - cmd.zSrcTable = "zipfile($archiveFile)"; + cmd.zSrcTable = 0; + if( cmd.zFile ){ + eDbType = deduceDatabaseType(cmd.zFile); + }else{ + eDbType = pState->openMode; + } + if( eDbType==SHELL_OPEN_ZIPFILE ){ + if( cmd.zFile==0 ){ + cmd.zSrcTable = sqlite3_mprintf("zip"); }else{ - utf8_printf(stderr, "no zip archive file specified\n"); - return SQLITE_ERROR; + cmd.zSrcTable = sqlite3_mprintf("zipfile(%Q)", cmd.zFile); } if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_UPDATE ){ utf8_printf(stderr, "zip archives are read-only\n"); - return SQLITE_ERROR; + rc = SQLITE_ERROR; + goto end_ar_command; } + cmd.bZip = 1; }else if( cmd.zFile ){ int flags; + if( cmd.bAppend ) eDbType = SHELL_OPEN_APPENDVFS; if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_UPDATE ){ flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE; }else{ flags = SQLITE_OPEN_READONLY; } cmd.db = 0; - rc = sqlite3_open_v2(cmd.zFile, &cmd.db, flags, 0); + if( cmd.bDryRun ){ + utf8_printf(pState->out, "-- open database '%s'%s\n", cmd.zFile, + eDbType==SHELL_OPEN_APPENDVFS ? " using 'apndvfs'" : ""); + } + rc = sqlite3_open_v2(cmd.zFile, &cmd.db, flags, + eDbType==SHELL_OPEN_APPENDVFS ? "apndvfs" : 0); if( rc!=SQLITE_OK ){ utf8_printf(stderr, "cannot open file: %s (%s)\n", cmd.zFile, sqlite3_errmsg(cmd.db) ); - sqlite3_close(cmd.db); - return rc; + goto end_ar_command; } sqlite3_fileio_init(cmd.db, 0, 0); #ifdef SQLITE_HAVE_ZLIB sqlite3_sqlar_init(cmd.db, 0, 0); #endif } + if( cmd.zSrcTable==0 ){ + if( sqlite3_table_column_metadata(cmd.db,0,"sqlar","name",0,0,0,0,0) ){ + utf8_printf(stderr, "database does not contain an 'sqlar' table\n"); + rc = SQLITE_ERROR; + goto end_ar_command; + } + cmd.zSrcTable = sqlite3_mprintf("sqlar"); + } switch( cmd.eCmd ){ case AR_CMD_CREATE: @@ -5177,11 +5191,12 @@ static int arDotCommand( rc = arCreateOrUpdateCommand(&cmd, 1); break; } - - if( cmd.db!=pState->db ){ - sqlite3_close(cmd.db); - } } +end_ar_command: + if( cmd.db!=pState->db ){ + sqlite3_close(cmd.db); + } + sqlite3_free(cmd.zSrcTable); return rc; } diff --git a/test/shell8.test b/test/shell8.test index 0dcb10d67b..de0f237f72 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -101,7 +101,7 @@ foreach {tn tcl} { set x2 ".ar --extract --dir ar3" set c3 ".ar --creat --dir ar1 --file test_xyz.db ." - set x3 ".ar --e --d ar3 --f test_xyz.db" + set x3 ".ar --e --dir ar3 --f test_xyz.db" } 4 { @@ -169,4 +169,3 @@ finish_test finish_test - From 6c237b1fa79ae303a76a93878dff71cd2897f163 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 15:53:06 +0000 Subject: [PATCH 094/190] Add the "filetype()" SQL function for interpreting file modes to the fileio.c extension. FossilOrigin-Name: 58c0c74c407d93f48930a4964b6cc48f008b522d193a62a559de0e6a319a8bd0 --- ext/misc/fileio.c | 28 ++++++++++++++++++++++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 8170e86379..8f6de7a80f 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -357,6 +357,30 @@ static void writefileFunc( } } +/* +** SQL function: filetype(MODE) +** +** Based on the integer mode, return one of "file", "directory", or "symlink". +*/ +static void fileTypeFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + const char *zMode; + int iMode = sqlite3_value_int(argv[0]); + if( S_ISLNK(iMode) ){ + zMode = "symlink"; + }else if( S_ISREG(iMode) ){ + zMode = "file"; + }else if( S_ISDIR(iMode) ){ + zMode = "directory"; + }else{ + zMode = "unknown"; + } + sqlite3_result_text(context, zMode, -1, SQLITE_STATIC); +} + #ifndef SQLITE_OMIT_VIRTUALTABLE /* @@ -768,6 +792,10 @@ int sqlite3_fileio_init( rc = sqlite3_create_function(db, "writefile", -1, SQLITE_UTF8, 0, writefileFunc, 0, 0); } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "fileType", 1, SQLITE_UTF8, 0, + fileTypeFunc, 0, 0); + } if( rc==SQLITE_OK ){ rc = fsdirRegister(db); } diff --git a/manifest b/manifest index da3f059664..2de51ed59b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\s".ar"\scommand\sdeduces\swhether\sor\snot\sthe\starget\sfile\sis\na\sZIP\sor\sSQLAR\sand\sdoes\sthe\sappropropriate\sthing.\s\sThe\s"-z"\soption\sis\somitted.\nThe\s"--append"\soption\sis\sadded\sto\sopen\sauxiliary\sdatabases\susing\sapndvfs. -D 2018-01-10T15:17:34.832 +C Add\sthe\s"filetype()"\sSQL\sfunction\sfor\sinterpreting\sfile\smodes\sto\sthe\nfileio.c\sextension. +D 2018-01-10T15:53:06.284 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -277,7 +277,7 @@ F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f0 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 5176893c15421e9c459f25478e3c1b066d19317b676ff0b142862de4e701af82 +F ext/misc/fileio.c 19d4e5590a3505dc12e652a64730a935a865bb70eb2bb8bfe75767355a09a6e2 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9340a2c145bcb4b38d19276a16264a37341c617f0554d66e1da653f1d9f85163 -R 9764fa4832552c458077bab9b9143a51 +P 430d1a7daa823ae53606b7a158af4e7c16f62ff9b072b90606524e7c3f6131df +R 54a0e19016ae7cc0ce7d6a9a20dca28f U drh -Z fa68d24d45da969d4d63bf64e8c4f030 +Z d67640218b4e3095d4e0ccc9365f61ee diff --git a/manifest.uuid b/manifest.uuid index 8a5e2767d2..91f7e865d7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -430d1a7daa823ae53606b7a158af4e7c16f62ff9b072b90606524e7c3f6131df \ No newline at end of file +58c0c74c407d93f48930a4964b6cc48f008b522d193a62a559de0e6a319a8bd0 \ No newline at end of file From f2ed70e4dea086e0e46d0fe884dd084d0ed70818 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 10 Jan 2018 16:30:40 +0000 Subject: [PATCH 095/190] Have the zipfile module automatically append "/" to directory names that do not already end with such a character. This is required for info-zip compatibility. FossilOrigin-Name: 94bc3c60e7d2ec849b90444b06e3057ed645edf3af334f2737252960602868e5 --- ext/misc/zipfile.c | 15 +++++++++++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/zipfile.test | 31 +++++++++++++++++++++++++------ 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 9a8d3974c2..8ce2e41801 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -1211,6 +1211,7 @@ static int zipfileUpdate( int nData = 0; /* Size of pData buffer in bytes */ int iMethod = 0; /* Compression method for new entry */ u8 *pFree = 0; /* Free this */ + char *zFree = 0; /* Also free this */ ZipfileCDS cds; /* New Central Directory Structure entry */ int bIsDir = 0; @@ -1307,6 +1308,19 @@ static int zipfileUpdate( } } + if( rc==SQLITE_OK && bIsDir ){ + /* For a directory, check that the last character in the path is a + ** '/'. This appears to be required for compatibility with info-zip + ** (the unzip command on unix). It does not create directories + ** otherwise. */ + if( zPath[nPath-1]!='/' ){ + zFree = sqlite3_mprintf("%s/", zPath); + if( zFree==0 ){ rc = SQLITE_NOMEM; } + zPath = (const char*)zFree; + nPath++; + } + } + if( rc==SQLITE_OK ){ /* Create the new CDS record. */ memset(&cds, 0, sizeof(cds)); @@ -1334,6 +1348,7 @@ static int zipfileUpdate( } sqlite3_free(pFree); + sqlite3_free(zFree); return rc; } diff --git a/manifest b/manifest index 8e88f6ca98..327ce28b5d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Tag\san\sunreachable\sbranch\susing\sALWAYS(). -D 2018-01-10T13:58:23.623 +C Have\sthe\szipfile\smodule\sautomatically\sappend\s"/"\sto\sdirectory\snames\sthat\sdo\nnot\salready\send\swith\ssuch\sa\scharacter.\sThis\sis\srequired\sfor\sinfo-zip\ncompatibility. +D 2018-01-10T16:30:40.654 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 92b840dc168126e192da7d6976f44b4453c40b27ad8f142a7c02dc31aaa31bd8 +F ext/misc/zipfile.c 08ec2ee0093d7a91d66db4ce1d8543cc4c19fc3fb57ee113ef49f95b8613f501 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1598,7 +1598,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e -F test/zipfile.test 9fb98a24f80fe0d5d09df15cd01bb290777572f45408fdfbe894f2413c9c1222 +F test/zipfile.test 355e499ed4e8e0081e136510d8a7895496ee1196be10905e5dd61b0f7fdda39e F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a16f554f027ba268276b728588b5eaea837cbed85358a06a2f6da3b70e834ad -R 8ba57fadebb1bef28ae4cd97ec4b22a9 -U drh -Z 3f9f5c48f04edbfb2783cc163a50a4b5 +P c42c734f11c58724f5d8b32cb1c92e274be350028868d6ed045b2cfd274c64e7 +R f9e0f45080131d91f8369d2321791b35 +U dan +Z be2a3cd4c41b45eb12aa75b434fd5e7e diff --git a/manifest.uuid b/manifest.uuid index 91ba96987f..839b0e04c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c42c734f11c58724f5d8b32cb1c92e274be350028868d6ed045b2cfd274c64e7 \ No newline at end of file +94bc3c60e7d2ec849b90444b06e3057ed645edf3af334f2737252960602868e5 \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index 2a4f9ad96a..cafbdcefb4 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -91,28 +91,47 @@ do_execsql_test 2.1 { CREATE VIRTUAL TABLE zzz USING zipfile('test.zip'); INSERT INTO zzz(name, mode) VALUES('dirname', 'drwxr-xr-x'); SELECT name, mode, data FROM zzz; -} {dirname 16877 {}} +} {dirname/ 16877 {}} do_execsql_test 2.2 { INSERT INTO zzz(name, data) VALUES('dirname2', NULL); INSERT INTO zzz(name, data) VALUES('dirname2/file1.txt', 'abcdefghijklmnop'); SELECT name, mode, data FROM zzz; } { - dirname 16877 {} - dirname2 16877 {} + dirname/ 16877 {} + dirname2/ 16877 {} dirname2/file1.txt 33188 abcdefghijklmnop } do_catchsql_test 2.3 { - UPDATE zzz SET name = 'dirname3' WHERE name = 'dirname'; + UPDATE zzz SET name = 'dirname3' WHERE name = 'dirname/'; } {1 {constraint failed}} do_execsql_test 2.4 { SELECT name, mode, data FROM zzz; } { - dirname 16877 {} - dirname2 16877 {} + dirname/ 16877 {} + dirname2/ 16877 {} dirname2/file1.txt 33188 abcdefghijklmnop } +# If on unix, check that the [unzip] utility can unpack our archive. +# +if {$::tcl_platform(platform)=="unix"} { + do_test 2.5.1 { + forcedelete dirname + forcedelete dirname2 + set rc [catch { exec unzip test.zip > /dev/null } msg] + list $rc $msg + } {0 {}} + do_test 2.5.2 { file isdir dirname } 1 + do_test 2.5.3 { file isdir dirname2 } 1 + do_test 2.5.4 { file isdir dirname2/file1.txt } 0 + do_test 2.5.5 { + set fd [open dirname2/file1.txt] + set data [read $fd] + close $fd + set data + } {abcdefghijklmnop} +} finish_test From 634c70fa1586565fe08a8f208691061cd36602dc Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 16:50:18 +0000 Subject: [PATCH 096/190] Implement the ".ar --create" command using a single "REPLACE INTO sqlar SELECT ... FROM fsdir();" statement. Add the shell_putsnl() SQL function for providing --verbose output. FossilOrigin-Name: 28ab930436fea33c79073e84f39d9e381fa60b4702a5dcbfaaed72baeeae8431 --- manifest | 12 +++--- manifest.uuid | 2 +- src/shell.c.in | 104 +++++++++++++++++++------------------------------ 3 files changed, 46 insertions(+), 72 deletions(-) diff --git a/manifest b/manifest index 2de51ed59b..dcc5c90bb1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"filetype()"\sSQL\sfunction\sfor\sinterpreting\sfile\smodes\sto\sthe\nfileio.c\sextension. -D 2018-01-10T15:53:06.284 +C Implement\sthe\s".ar\s--create"\scommand\susing\sa\ssingle\s\n"REPLACE\sINTO\ssqlar\sSELECT\s...\sFROM\sfsdir();"\sstatement.\s\sAdd\sthe\nshell_putsnl()\sSQL\sfunction\sfor\sproviding\s--verbose\soutput. +D 2018-01-10T16:50:18.954 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 7d49ed78c6d8298d38d4733c3cc24f3a4230cd2f151564b7c11ab2e280007f9c +F src/shell.c.in f8ae3a792ba5ae09d6ad89845fc1cae75eb5b467f8534f654b8107b54e4aa81e F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 430d1a7daa823ae53606b7a158af4e7c16f62ff9b072b90606524e7c3f6131df -R 54a0e19016ae7cc0ce7d6a9a20dca28f +P 58c0c74c407d93f48930a4964b6cc48f008b522d193a62a559de0e6a319a8bd0 +R 6861922f8b8e02d4e242f42a1464e5df U drh -Z d67640218b4e3095d4e0ccc9365f61ee +Z dfee26c5de1e816e5523347d081a1560 diff --git a/manifest.uuid b/manifest.uuid index 91f7e865d7..398fb8a627 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58c0c74c407d93f48930a4964b6cc48f008b522d193a62a559de0e6a319a8bd0 \ No newline at end of file +28ab930436fea33c79073e84f39d9e381fa60b4702a5dcbfaaed72baeeae8431 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 83b21b1663..80ca7305ec 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1135,6 +1135,22 @@ static void shellLog(void *pArg, int iErrCode, const char *zMsg){ fflush(p->pLog); } +/* +** SQL function: shell_putsnl(X) +** +** Write the text X to the screen (or whatever output is being directed) +** adding a newline at the end, and then return X. +*/ +static void shellPutsFunc( + sqlite3_context *pCtx, + int nVal, + sqlite3_value **apVal +){ + ShellState *p = (ShellState*)sqlite3_user_data(pCtx); + utf8_printf(p->out, "%s\n", sqlite3_value_text(apVal[0])); + sqlite3_result_value(pCtx, apVal[0]); +} + /* ** Output the given string as a hex-encoded blob (eg. X'1234' ) */ @@ -3307,6 +3323,8 @@ static void open_db(ShellState *p, int keepAlive){ shellAddSchemaName, 0, 0); sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, 0, shellModuleSchema, 0, 0); + sqlite3_create_function(p->db, "shell_putsnl", 1, SQLITE_UTF8, p, + shellPutsFunc, 0, 0); if( p->openMode==SHELL_OPEN_ZIPFILE ){ char *zSql = sqlite3_mprintf( "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename); @@ -5008,7 +5026,6 @@ static int arCreateOrUpdateCommand( ArCommand *pAr, /* Command arguments and options */ int bUpdate /* true for a --create. false for --update */ ){ - const char *zSql = "SELECT name, mode, mtime, data FROM fsdir($name, $dir)"; const char *zCreate = "CREATE TABLE IF NOT EXISTS sqlar(\n" " name TEXT PRIMARY KEY, -- name of the file\n" @@ -5018,86 +5035,41 @@ static int arCreateOrUpdateCommand( " data BLOB -- compressed content\n" ")"; const char *zDrop = "DROP TABLE IF EXISTS sqlar"; - const char *zInsert = "REPLACE INTO sqlar VALUES(?,?,?,?,sqlar_compress(?))"; - - sqlite3_stmt *pStmt = 0; /* Directory traverser */ - sqlite3_stmt *pInsert = 0; /* Compilation of zInsert */ + const char *zInsertFmt = + "REPLACE INTO sqlar(name,mode,mtime,sz,data)\n" + " SELECT\n" + " %s,\n" + " mode,\n" + " mtime,\n" + " CASE filetype(mode)\n" + " WHEN 'file' THEN length(data)\n" + " WHEN 'directory' THEN 0\n" + " ELSE -1 END,\n" + " CASE WHEN filetype(mode)<>'directory' THEN data ELSE NULL END\n" + " FROM fsdir(%Q,%Q)\n" + " WHERE filetype(mode)<>'unknown'"; int i; /* For iterating through azFile[] */ - int j; /* Parameter index */ int rc; /* Return code */ - assert( pAr->bZip==0 ); - rc = arExecSql(pAr, "SAVEPOINT ar;"); if( rc!=SQLITE_OK ) return rc; - if( bUpdate==0 ){ rc = arExecSql(pAr, zDrop); if( rc!=SQLITE_OK ) return rc; } - rc = arExecSql(pAr, zCreate); - if( !pAr->bDryRun ){ - shellPrepare(pAr->db, &rc, zInsert, &pInsert); - } - shellPrepare(pAr->db, &rc, zSql, &pStmt); - j = sqlite3_bind_parameter_index(pStmt, "$dir"); - sqlite3_bind_text(pStmt, j, pAr->zDir, -1, SQLITE_STATIC); - if( pAr->bDryRun ){ - utf8_printf(pAr->p->out, "%s;\n", sqlite3_sql(pStmt)); - } - for(i=0; inArg && rc==SQLITE_OK; i++){ - j = sqlite3_bind_parameter_index(pStmt, "$name"); - sqlite3_bind_text(pStmt, j, pAr->azArg[i], -1, SQLITE_STATIC); - while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ - int sz; - const char *zName = (const char*)sqlite3_column_text(pStmt, 0); - int mode = sqlite3_column_int(pStmt, 1); - unsigned int mtime = sqlite3_column_int(pStmt, 2); - - if( pAr->bVerbose ){ - utf8_printf(pAr->p->out, "%s\n", zName); - } - if( pAr->bDryRun ){ - utf8_printf(pAr->p->out, "%s;\n", zInsert); - continue; - } - - sqlite3_bind_text(pInsert, 1, zName, -1, SQLITE_STATIC); - sqlite3_bind_int(pInsert, 2, mode); - sqlite3_bind_int64(pInsert, 3, (sqlite3_int64)mtime); - - if( S_ISDIR(mode) ){ - sz = 0; - sqlite3_bind_null(pInsert, 5); - }else{ - sqlite3_bind_value(pInsert, 5, sqlite3_column_value(pStmt, 3)); - if( S_ISLNK(mode) ){ - sz = -1; - }else{ - sz = sqlite3_column_bytes(pStmt, 3); - } - } - - sqlite3_bind_int(pInsert, 4, sz); - if( pAr->bDryRun ){ - utf8_printf(pAr->p->out, "%s\n", sqlite3_sql(pInsert)); - }else{ - sqlite3_step(pInsert); - } - rc = sqlite3_reset(pInsert); - } - shellReset(&rc, pStmt); + char *zSql = sqlite3_mprintf(zInsertFmt, + pAr->bVerbose ? "shell_putsnl(name)" : "name", + pAr->azArg[i], pAr->zDir); + rc = arExecSql(pAr, zSql); + sqlite3_free(zSql); } - if( rc!=SQLITE_OK ){ arExecSql(pAr, "ROLLBACK TO ar; RELEASE ar;"); }else{ rc = arExecSql(pAr, "RELEASE ar;"); } - shellFinalize(&rc, pStmt); - shellFinalize(&rc, pInsert); return rc; } @@ -5161,7 +5133,9 @@ static int arDotCommand( #endif } if( cmd.zSrcTable==0 ){ - if( sqlite3_table_column_metadata(cmd.db,0,"sqlar","name",0,0,0,0,0) ){ + if( cmd.eCmd!=AR_CMD_CREATE + && sqlite3_table_column_metadata(cmd.db,0,"sqlar","name",0,0,0,0,0) + ){ utf8_printf(stderr, "database does not contain an 'sqlar' table\n"); rc = SQLITE_ERROR; goto end_ar_command; From 410cad975f82a286ca3a0256ea865947be0a31cb Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 17:19:16 +0000 Subject: [PATCH 097/190] In the fileio.c extension, change the filetype(MODE) function into lsmode(MODE). Use the new lsmode(MODE) function in shell.c. FossilOrigin-Name: 52d12ba9f33c1f2620776e189c81f3bf991759344ecdd167ea2a6107f0972b9d --- ext/misc/fileio.c | 32 +++++++++++++++++++---------- manifest | 14 ++++++------- manifest.uuid | 2 +- src/shell.c.in | 52 +++++++++++++---------------------------------- 4 files changed, 43 insertions(+), 57 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 8f6de7a80f..f126a2e435 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -358,27 +358,37 @@ static void writefileFunc( } /* -** SQL function: filetype(MODE) +** SQL function: lsmode(MODE) ** -** Based on the integer mode, return one of "file", "directory", or "symlink". +** Given a numberic st_mode from stat(), convert it into a human-readable +** text string in the style of "ls -l". */ -static void fileTypeFunc( +static void lsModeFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ - const char *zMode; + int i; int iMode = sqlite3_value_int(argv[0]); + char z[16]; if( S_ISLNK(iMode) ){ - zMode = "symlink"; + z[0] = 'l'; }else if( S_ISREG(iMode) ){ - zMode = "file"; + z[0] = '-'; }else if( S_ISDIR(iMode) ){ - zMode = "directory"; + z[0] = 'd'; }else{ - zMode = "unknown"; + z[0] = '?'; } - sqlite3_result_text(context, zMode, -1, SQLITE_STATIC); + for(i=0; i<3; i++){ + int m = (iMode >> ((2-i)*3)); + char *a = &z[1 + i*3]; + a[0] = (m & 0x4) ? 'r' : '-'; + a[1] = (m & 0x2) ? 'w' : '-'; + a[2] = (m & 0x1) ? 'x' : '-'; + } + z[10] = '\0'; + sqlite3_result_text(context, z, -1, SQLITE_TRANSIENT); } #ifndef SQLITE_OMIT_VIRTUALTABLE @@ -793,8 +803,8 @@ int sqlite3_fileio_init( writefileFunc, 0, 0); } if( rc==SQLITE_OK ){ - rc = sqlite3_create_function(db, "fileType", 1, SQLITE_UTF8, 0, - fileTypeFunc, 0, 0); + rc = sqlite3_create_function(db, "lsmode", 1, SQLITE_UTF8, 0, + lsModeFunc, 0, 0); } if( rc==SQLITE_OK ){ rc = fsdirRegister(db); diff --git a/manifest b/manifest index dcc5c90bb1..36a782cc0d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Implement\sthe\s".ar\s--create"\scommand\susing\sa\ssingle\s\n"REPLACE\sINTO\ssqlar\sSELECT\s...\sFROM\sfsdir();"\sstatement.\s\sAdd\sthe\nshell_putsnl()\sSQL\sfunction\sfor\sproviding\s--verbose\soutput. -D 2018-01-10T16:50:18.954 +C In\sthe\sfileio.c\sextension,\schange\sthe\sfiletype(MODE)\sfunction\sinto\slsmode(MODE).\nUse\sthe\snew\slsmode(MODE)\sfunction\sin\sshell.c. +D 2018-01-10T17:19:16.761 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -277,7 +277,7 @@ F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f0 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 19d4e5590a3505dc12e652a64730a935a865bb70eb2bb8bfe75767355a09a6e2 +F ext/misc/fileio.c 1194228c96d6b7a374e93602e2ba1899b42d0fc4d4c5253962fb13e1c9ed1f77 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in f8ae3a792ba5ae09d6ad89845fc1cae75eb5b467f8534f654b8107b54e4aa81e +F src/shell.c.in 926858c02fd4f644c79caca8e266bf6391dfc391fc07770d69a9db95c964eded F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 58c0c74c407d93f48930a4964b6cc48f008b522d193a62a559de0e6a319a8bd0 -R 6861922f8b8e02d4e242f42a1464e5df +P 28ab930436fea33c79073e84f39d9e381fa60b4702a5dcbfaaed72baeeae8431 +R 820c3174d3fb9a7cd02211a2c674f634 U drh -Z dfee26c5de1e816e5523347d081a1560 +Z 3f66494887095c0b877f4d9025ad2b7a diff --git a/manifest.uuid b/manifest.uuid index 398fb8a627..77b89e1854 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -28ab930436fea33c79073e84f39d9e381fa60b4702a5dcbfaaed72baeeae8431 \ No newline at end of file +52d12ba9f33c1f2620776e189c81f3bf991759344ecdd167ea2a6107f0972b9d \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 80ca7305ec..b6d51e081d 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4856,33 +4856,6 @@ static void arWhereClause( *pzWhere = zWhere; } -/* -** Argument zMode must point to a buffer at least 11 bytes in size. This -** function populates this buffer with the string interpretation of -** the unix file mode passed as the second argument (e.g. "drwxr-xr-x"). -*/ -static void shellModeToString(char *zMode, int mode){ - int i; - - /* Magic numbers copied from [man 2 stat] */ - if( mode & 0040000 ){ - zMode[0] = 'd'; - }else if( (mode & 0120000)==0120000 ){ - zMode[0] = 'l'; - }else{ - zMode[0] = '-'; - } - - for(i=0; i<3; i++){ - int m = (mode >> ((2-i)*3)); - char *a = &zMode[1 + i*3]; - a[0] = (m & 0x4) ? 'r' : '-'; - a[1] = (m & 0x2) ? 'w' : '-'; - a[2] = (m & 0x1) ? 'x' : '-'; - } - zMode[10] = '\0'; -} - /* ** Implementation of .ar "lisT" command. */ @@ -4890,7 +4863,7 @@ static int arListCommand(ArCommand *pAr){ const char *zSql = "SELECT %s FROM %s WHERE %s"; const char *azCols[] = { "name", - "mode, sz, datetime(mtime, 'unixepoch'), name" + "lsmode(mode), sz, datetime(mtime, 'unixepoch'), name" }; char *zWhere = 0; @@ -4907,10 +4880,8 @@ static int arListCommand(ArCommand *pAr){ }else{ while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ if( pAr->bVerbose ){ - char zMode[11]; - shellModeToString(zMode, sqlite3_column_int(pSql, 0)); - - utf8_printf(pAr->p->out, "%s % 10d %s %s\n", zMode, + utf8_printf(pAr->p->out, "%s % 10d %s %s\n", + sqlite3_column_text(pSql, 0), sqlite3_column_int(pSql, 1), sqlite3_column_text(pSql, 2), sqlite3_column_text(pSql, 3) @@ -5005,7 +4976,12 @@ static int arExecSql(ArCommand *pAr, const char *zSql){ utf8_printf(pAr->p->out, "%s\n", zSql); rc = SQLITE_OK; }else{ - rc = sqlite3_exec(pAr->db, zSql, 0, 0, 0); + char *zErr = 0; + rc = sqlite3_exec(pAr->db, zSql, 0, 0, &zErr); + if( zErr ){ + utf8_printf(stdout, "ERROR: %s\n", zErr); + sqlite3_free(zErr); + } } return rc; } @@ -5041,13 +5017,13 @@ static int arCreateOrUpdateCommand( " %s,\n" " mode,\n" " mtime,\n" - " CASE filetype(mode)\n" - " WHEN 'file' THEN length(data)\n" - " WHEN 'directory' THEN 0\n" + " CASE substr(lsmode(mode),1,1)\n" + " WHEN '-' THEN length(data)\n" + " WHEN 'd' THEN 0\n" " ELSE -1 END,\n" - " CASE WHEN filetype(mode)<>'directory' THEN data ELSE NULL END\n" + " CASE WHEN lsmode(mode) LIKE 'd%%' THEN NULL else data END\n" " FROM fsdir(%Q,%Q)\n" - " WHERE filetype(mode)<>'unknown'"; + " WHERE lsmode(mode) NOT LIKE '?%%';"; int i; /* For iterating through azFile[] */ int rc; /* Return code */ From 4bfd182939211ca2bda599d9da11210cc4454b5d Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 10 Jan 2018 17:37:58 +0000 Subject: [PATCH 098/190] Return an SQLITE_CONSTRAINT error if an attempt is made to insert duplicate entries into a zip archive. FossilOrigin-Name: 1f099b2b45074c89eeff8ff241aa49489c95c2221b25c305fcda670ebf63fb4e --- ext/misc/zipfile.c | 25 ++++++++++++++++++++++++- manifest | 14 +++++++------- manifest.uuid | 2 +- test/zipfile.test | 28 ++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 8ce2e41801..6785c9610c 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -1033,7 +1033,7 @@ static int zipfileLoadDirectory(ZipfileTab *pTab){ }else{ memset(pNew, 0, sizeof(ZipfileEntry)); pNew->zPath = (char*)&pNew[1]; - memcpy(pNew->zPath, &aBuf[ZIPFILE_CDS_FIXED_SZ], nFile); + memcpy(pNew->zPath, &aRec[ZIPFILE_CDS_FIXED_SZ], nFile); pNew->zPath[nFile] = '\0'; pNew->aCdsEntry = (u8*)&pNew->zPath[nFile+1]; pNew->nCdsEntry = ZIPFILE_CDS_FIXED_SZ+nFile+nExtra+nComment; @@ -1189,6 +1189,18 @@ static int zipfileGetMode( return SQLITE_ERROR; } +/* +** Both (const char*) arguments point to nul-terminated strings. Argument +** nB is the value of strlen(zB). This function returns 0 if the strings are +** identical, ignoring any trailing '/' character in either path. */ +static int zipfileComparePath(const char *zA, const char *zB, int nB){ + int nA = strlen(zA); + if( zA[nA-1]=='/' ) nA--; + if( zB[nB-1]=='/' ) nB--; + if( nA==nB && memcmp(zA, zB, nA)==0 ) return 0; + return 1; +} + /* ** xUpdate method. */ @@ -1321,6 +1333,17 @@ static int zipfileUpdate( } } + /* Check that we're not inserting a duplicate entry */ + if( rc==SQLITE_OK ){ + ZipfileEntry *p; + for(p=pTab->pFirstEntry; p; p=p->pNext){ + if( zipfileComparePath(p->zPath, zPath, nPath)==0 ){ + rc = SQLITE_CONSTRAINT; + break; + } + } + } + if( rc==SQLITE_OK ){ /* Create the new CDS record. */ memset(&cds, 0, sizeof(cds)); diff --git a/manifest b/manifest index 327ce28b5d..3b5c001489 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sthe\szipfile\smodule\sautomatically\sappend\s"/"\sto\sdirectory\snames\sthat\sdo\nnot\salready\send\swith\ssuch\sa\scharacter.\sThis\sis\srequired\sfor\sinfo-zip\ncompatibility. -D 2018-01-10T16:30:40.654 +C Return\san\sSQLITE_CONSTRAINT\serror\sif\san\sattempt\sis\smade\sto\sinsert\sduplicate\nentries\sinto\sa\szip\sarchive. +D 2018-01-10T17:37:58.434 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 08ec2ee0093d7a91d66db4ce1d8543cc4c19fc3fb57ee113ef49f95b8613f501 +F ext/misc/zipfile.c 00d78e61f0b0a7f51a4d5ffef302ef840336f09d75a97a8e0be1fabf048511b8 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1598,7 +1598,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e -F test/zipfile.test 355e499ed4e8e0081e136510d8a7895496ee1196be10905e5dd61b0f7fdda39e +F test/zipfile.test e7132ca60031ca5d1df684cf644952bb3f253de3671a5b502780c5de3126a453 F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c42c734f11c58724f5d8b32cb1c92e274be350028868d6ed045b2cfd274c64e7 -R f9e0f45080131d91f8369d2321791b35 +P 94bc3c60e7d2ec849b90444b06e3057ed645edf3af334f2737252960602868e5 +R 9dfa6dcaeef4eb497b2c9753cb4a2823 U dan -Z be2a3cd4c41b45eb12aa75b434fd5e7e +Z 2990c2df8ab5dd5a7f9266ba3fc45276 diff --git a/manifest.uuid b/manifest.uuid index 839b0e04c8..b72ce7ac03 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -94bc3c60e7d2ec849b90444b06e3057ed645edf3af334f2737252960602868e5 \ No newline at end of file +1f099b2b45074c89eeff8ff241aa49489c95c2221b25c305fcda670ebf63fb4e \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index cafbdcefb4..df02797bd8 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -133,5 +133,33 @@ if {$::tcl_platform(platform)=="unix"} { } {abcdefghijklmnop} } +#------------------------------------------------------------------------- +reset_db +forcedelete test.zip +load_static_extension db zipfile + +do_execsql_test 3.0 { + CREATE VIRTUAL TABLE temp.x1 USING zipfile('test.zip'); + INSERT INTO x1(name, data) VALUES('dir1/', NULL); + INSERT INTO x1(name, data) VALUES('file1', '1234'); + INSERT INTO x1(name, data) VALUES('dir1/file2', '5678'); +} +foreach {tn fname} { + 1 dir1 + 2 file1 + 3 dir1/file2 +} { + do_catchsql_test 3.1.$tn.0 { + INSERT INTO x1(name, data) VALUES($fname, NULL); + } {1 {constraint failed}} + do_catchsql_test 3.1.$tn.1 { + INSERT INTO x1(name, data) VALUES($fname || '/', NULL); + } {1 {constraint failed}} + do_catchsql_test 3.1.$tn.2 { + INSERT INTO x1(name, data) VALUES($fname, 'abcd'); + } {1 {constraint failed}} +} + + finish_test From 346606494a3a5e176b273faebd8c9b9772e598f3 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 17:39:54 +0000 Subject: [PATCH 099/190] Fix minor problems with the new ".archive" command changes. FossilOrigin-Name: 612b30c95f948438016bd11470e9dd114d7bb064418a57e5954a094d2ca77f69 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 36a782cc0d..7c0f0180e3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sfileio.c\sextension,\schange\sthe\sfiletype(MODE)\sfunction\sinto\slsmode(MODE).\nUse\sthe\snew\slsmode(MODE)\sfunction\sin\sshell.c. -D 2018-01-10T17:19:16.761 +C Fix\sminor\sproblems\swith\sthe\snew\s".archive"\scommand\schanges. +D 2018-01-10T17:39:54.594 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 926858c02fd4f644c79caca8e266bf6391dfc391fc07770d69a9db95c964eded +F src/shell.c.in 4cb216da4adaac57faf03a502584d44d96f99b3235a6d2956750670c6aabc8b1 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 28ab930436fea33c79073e84f39d9e381fa60b4702a5dcbfaaed72baeeae8431 -R 820c3174d3fb9a7cd02211a2c674f634 +P 52d12ba9f33c1f2620776e189c81f3bf991759344ecdd167ea2a6107f0972b9d +R 1170208662cbaecd416c0d66fbee2d48 U drh -Z 3f66494887095c0b877f4d9025ad2b7a +Z 6adbf06d453c4d240bb3d139f4f72e24 diff --git a/manifest.uuid b/manifest.uuid index 77b89e1854..c546e6b5ff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -52d12ba9f33c1f2620776e189c81f3bf991759344ecdd167ea2a6107f0972b9d \ No newline at end of file +612b30c95f948438016bd11470e9dd114d7bb064418a57e5954a094d2ca77f69 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index b6d51e081d..f9942446a5 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -5059,12 +5059,12 @@ static int arDotCommand( ){ ArCommand cmd; int rc; + memset(&cmd, 0, sizeof(cmd)); rc = arParseCommand(azArg, nArg, &cmd); if( rc==SQLITE_OK ){ int eDbType = SHELL_OPEN_UNSPEC; cmd.p = pState; cmd.db = pState->db; - cmd.zSrcTable = 0; if( cmd.zFile ){ eDbType = deduceDatabaseType(cmd.zFile); }else{ @@ -5107,6 +5107,9 @@ static int arDotCommand( #ifdef SQLITE_HAVE_ZLIB sqlite3_sqlar_init(cmd.db, 0, 0); #endif + sqlite3_create_function(cmd.db, "shell_putsnl", 1, SQLITE_UTF8, cmd.p, + shellPutsFunc, 0, 0); + } if( cmd.zSrcTable==0 ){ if( cmd.eCmd!=AR_CMD_CREATE From ca7733b782c3177d0759c09bd69394a178b0cee8 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 18:09:20 +0000 Subject: [PATCH 100/190] Modify the new "--append" option to the .archive so that it takes a filename argument, the same as "--file". FossilOrigin-Name: 58e3b07cc8cb5cc915f7d430483bd455b03f14120e0db23286d2e20dbb5391c5 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/shell.c.in | 7 +++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index a7fe4fa39d..747f1758ed 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\slsmode(MODE)\sfunction\sin\sthe\sfileio.c\sextension\sand\suse\sthat\sfunction\nin\sthe\s.archive\simplementation.\s\sAdd\sthe\s--append\sand\s--dryrun\soptions\sto\nthe\s.archive\scommand\sand\sremove\sthe\s--zip\soption,\smaking\sit\sautomatic. -D 2018-01-10T17:44:03.548 +C Modify\sthe\snew\s"--append"\soption\sto\sthe\s.archive\sso\sthat\sit\stakes\sa\sfilename\nargument,\sthe\ssame\sas\s"--file". +D 2018-01-10T18:09:20.329 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 4cb216da4adaac57faf03a502584d44d96f99b3235a6d2956750670c6aabc8b1 +F src/shell.c.in 2e72b9dc9dabde7e1d26142bf1080dfbc182ac1bf9431f85307b5931062a041b F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,8 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1f099b2b45074c89eeff8ff241aa49489c95c2221b25c305fcda670ebf63fb4e 612b30c95f948438016bd11470e9dd114d7bb064418a57e5954a094d2ca77f69 -R 92ad9119ea4a1b866aa95ac38fa72e64 -T +closed 612b30c95f948438016bd11470e9dd114d7bb064418a57e5954a094d2ca77f69 +P 38f28029d16df8489772c27867de8888dd1c26b170861acdc977fd4023939dde +R 816b51584860870ca4a8d73ef0ed2ba2 U drh -Z 0e2d546e002bd2ff2da7a7782cc6fb79 +Z 8ced30e3ccc67e3689656b52b7db29d9 diff --git a/manifest.uuid b/manifest.uuid index cc72e08c3d..f3f36f5301 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38f28029d16df8489772c27867de8888dd1c26b170861acdc977fd4023939dde \ No newline at end of file +58e3b07cc8cb5cc915f7d430483bd455b03f14120e0db23286d2e20dbb5391c5 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index f9942446a5..e1fca6a072 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4558,9 +4558,9 @@ static int arUsage(FILE *f){ "And zero or more optional options:\n" " -v, --verbose Print each filename as it is processed\n" " -f FILE, --file FILE Operate on archive FILE (default is current db)\n" +" -a FILE, --append FILE Operate on FILE opened using the apndvfs VFS\n" " -C DIR, --directory DIR Change to directory DIR to read/extract files\n" " -n, --dryrun Show the SQL that would have occurred\n" -" -a, --append Append the SQLAR to an existing file\n" "\n" "See also: http://sqlite.org/cli.html#sqlar_archive_support\n" "\n" @@ -4622,8 +4622,7 @@ static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ break; case AR_SWITCH_APPEND: pAr->bAppend = 1; - break; - + /* Fall thru into --file */ case AR_SWITCH_FILE: pAr->zFile = zArg; break; @@ -4659,8 +4658,8 @@ static int arParseCommand( { "help", 'h', AR_CMD_HELP, 0 }, { "verbose", 'v', AR_SWITCH_VERBOSE, 0 }, { "file", 'f', AR_SWITCH_FILE, 1 }, + { "append", 'a', AR_SWITCH_APPEND, 1 }, { "directory", 'C', AR_SWITCH_DIRECTORY, 1 }, - { "append", 'a', AR_SWITCH_APPEND, 0 }, { "dryrun", 'n', AR_SWITCH_DRYRUN, 0 }, }; int nSwitch = sizeof(aSwitch) / sizeof(struct ArSwitch); From d99c7b7bcb54e7e3531a79c6a86f2cffdb147ef1 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 19:15:21 +0000 Subject: [PATCH 101/190] Include RTREE in the default CLI build. FossilOrigin-Name: 6a6a3d495633b906ca31f513c30d31e6daf0f0f105be9ba0a0dc07d201d5b630 --- Makefile.in | 3 ++- Makefile.msc | 1 + main.mk | 1 + manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Makefile.in b/Makefile.in index af1bd61548..f340178c7a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -578,7 +578,8 @@ TESTOPTS = --verbose=file --output=test-out.txt # Extra compiler options for various shell tools # SHELL_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -# SHELL_OPT += -DSQLITE_ENABLE_FTS5 +#SHELL_OPT += -DSQLITE_ENABLE_FTS5 +SHELL_OPT += -DSQLITE_ENABLE_RTREE SHELL_OPT += -DSQLITE_ENABLE_EXPLAIN_COMMENTS SHELL_OPT += -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION SHELL_OPT += -DSQLITE_ENABLE_STMTVTAB diff --git a/Makefile.msc b/Makefile.msc index 6d4538706c..73c8df2e29 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1606,6 +1606,7 @@ FUZZDATA = \ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_STMTVTAB SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_INTROSPECTION_PRAGMAS +SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_RTREE !ENDIF # <> diff --git a/main.mk b/main.mk index fc68d9d307..281de5d335 100644 --- a/main.mk +++ b/main.mk @@ -506,6 +506,7 @@ TESTOPTS = --verbose=file --output=test-out.txt # Extra compiler options for various shell tools # SHELL_OPT += -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 +SHELL_OPT += -DSQLITE_ENABLE_RTREE SHELL_OPT += -DSQLITE_ENABLE_EXPLAIN_COMMENTS SHELL_OPT += -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION SHELL_OPT += -DSQLITE_ENABLE_STMTVTAB diff --git a/manifest b/manifest index 747f1758ed..612fc85322 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Modify\sthe\snew\s"--append"\soption\sto\sthe\s.archive\sso\sthat\sit\stakes\sa\sfilename\nargument,\sthe\ssame\sas\s"--file". -D 2018-01-10T18:09:20.329 +C Include\sRTREE\sin\sthe\sdefault\sCLI\sbuild. +D 2018-01-10T19:15:21.479 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea -F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb +F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 085d3b65cebdebec89dc8c91901c06f18e357eb320a0434bfa67a53e917f10de +F Makefile.msc ede26e3fb675e0b3b07627640ce5917154a6ee7f8f2c97424eb5ab5f651cbd56 F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -406,7 +406,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 7965d01485f7bec7945407c5238985ea8c7cb2cb686d2bfdbe3d5f79d6fd4eb2 +F main.mk fc0edb268998a049ce70ee3dc056b2a96cc8aa4ef0c6da296700d7081d167627 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 38f28029d16df8489772c27867de8888dd1c26b170861acdc977fd4023939dde -R 816b51584860870ca4a8d73ef0ed2ba2 +P 58e3b07cc8cb5cc915f7d430483bd455b03f14120e0db23286d2e20dbb5391c5 +R 2e662e06c18ea15ed95bfe93585d99c1 U drh -Z 8ced30e3ccc67e3689656b52b7db29d9 +Z 73fb00a74c3f6ec900cd40e3e36e7246 diff --git a/manifest.uuid b/manifest.uuid index f3f36f5301..3fcaee05db 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58e3b07cc8cb5cc915f7d430483bd455b03f14120e0db23286d2e20dbb5391c5 \ No newline at end of file +6a6a3d495633b906ca31f513c30d31e6daf0f0f105be9ba0a0dc07d201d5b630 \ No newline at end of file From cc9c26a092dbd39949a8e441adcda0aab413ca58 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 19:50:40 +0000 Subject: [PATCH 102/190] Fix a harmless compiler warning in zipfile.c FossilOrigin-Name: 60c694c1ab26a7a096f17ccea5a93ecda0f9f2113ab5fdc8b17dbffc787724fc --- ext/misc/zipfile.c | 3 +-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 6785c9610c..1a65a8896b 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -1194,7 +1194,7 @@ static int zipfileGetMode( ** nB is the value of strlen(zB). This function returns 0 if the strings are ** identical, ignoring any trailing '/' character in either path. */ static int zipfileComparePath(const char *zA, const char *zB, int nB){ - int nA = strlen(zA); + int nA = (int)strlen(zA); if( zA[nA-1]=='/' ) nA--; if( zB[nB-1]=='/' ) nB--; if( nA==nB && memcmp(zA, zB, nA)==0 ) return 0; @@ -1525,4 +1525,3 @@ int sqlite3_zipfile_init( (void)pzErrMsg; /* Unused parameter */ return zipfileRegister(db); } - diff --git a/manifest b/manifest index 612fc85322..63c68f6f7e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Include\sRTREE\sin\sthe\sdefault\sCLI\sbuild. -D 2018-01-10T19:15:21.479 +C Fix\sa\sharmless\scompiler\swarning\sin\szipfile.c +D 2018-01-10T19:50:40.811 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 00d78e61f0b0a7f51a4d5ffef302ef840336f09d75a97a8e0be1fabf048511b8 +F ext/misc/zipfile.c 0d12ad852af1732c9a4bd0be9f28886b049e0591a871e3246a5347d2cea15430 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 58e3b07cc8cb5cc915f7d430483bd455b03f14120e0db23286d2e20dbb5391c5 -R 2e662e06c18ea15ed95bfe93585d99c1 +P 6a6a3d495633b906ca31f513c30d31e6daf0f0f105be9ba0a0dc07d201d5b630 +R 47ef8e39d746f78565d92ddee819e4f1 U drh -Z 73fb00a74c3f6ec900cd40e3e36e7246 +Z 8e9572c27b3beeb784a18b126ea860dc diff --git a/manifest.uuid b/manifest.uuid index 3fcaee05db..12625a7794 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a6a3d495633b906ca31f513c30d31e6daf0f0f105be9ba0a0dc07d201d5b630 \ No newline at end of file +60c694c1ab26a7a096f17ccea5a93ecda0f9f2113ab5fdc8b17dbffc787724fc \ No newline at end of file From 13c209330d03e162aa8cabc196fb1f1f24c24b7c Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 21:41:55 +0000 Subject: [PATCH 103/190] Add support for the ".excel" command (and ".once -e" and ".once -x") in the CLI. FossilOrigin-Name: 23fa7c57c2b204d1ddcc2a939b5271628cf26689ad4ede6976038113095a9801 --- manifest | 15 +++++---- manifest.uuid | 2 +- src/shell.c.in | 90 +++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 95 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 63c68f6f7e..751835d013 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning\sin\szipfile.c -D 2018-01-10T19:50:40.811 +C Add\ssupport\sfor\sthe\s".excel"\scommand\s(and\s".once\s-e"\sand\s".once\s-x")\sin\nthe\sCLI. +D 2018-01-10T21:41:55.211 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 2e72b9dc9dabde7e1d26142bf1080dfbc182ac1bf9431f85307b5931062a041b +F src/shell.c.in d1dbc1514d74b425db41be006f2a4f91d26c5e1c2db4ab198b45c12920171e11 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a6a3d495633b906ca31f513c30d31e6daf0f0f105be9ba0a0dc07d201d5b630 -R 47ef8e39d746f78565d92ddee819e4f1 +P 60c694c1ab26a7a096f17ccea5a93ecda0f9f2113ab5fdc8b17dbffc787724fc +R bd40eb18946fee4f15d02cd4e13ad69c +T *branch * excel-shell-cmd +T *sym-excel-shell-cmd * +T -sym-trunk * U drh -Z 8e9572c27b3beeb784a18b126ea860dc +Z f708fb338ffb9679393be576ce4d2140 diff --git a/manifest.uuid b/manifest.uuid index 12625a7794..5bb31c1d62 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -60c694c1ab26a7a096f17ccea5a93ecda0f9f2113ab5fdc8b17dbffc787724fc \ No newline at end of file +23fa7c57c2b204d1ddcc2a939b5271628cf26689ad4ede6976038113095a9801 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index e1fca6a072..81677bf5e8 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1012,6 +1012,7 @@ struct ShellState { u8 statsOn; /* True to display memory stats before each finalize */ u8 scanstatsOn; /* True to display scan stats before each finalize */ u8 openMode; /* SHELL_OPEN_NORMAL, _APPENDVFS, or _ZIPFILE */ + u8 doXdgOpen; /* Invoke start/open/xdg-open in output_reset() */ int outCount; /* Revert to stdout when reaching zero */ int cnt; /* Number of records displayed so far */ FILE *out; /* Write results here */ @@ -1025,6 +1026,7 @@ struct ShellState { int nCheck; /* Number of ".check" commands run */ unsigned shellFlgs; /* Various flags */ char *zDestTable; /* Name of destination table when MODE_Insert */ + char *zTempFile; /* Temporary file that might need deleting */ char zTestcase[30]; /* Name of current test case */ char colSeparator[20]; /* Column separator character for several modes */ char rowSeparator[20]; /* Row separator character for MODE_Ascii */ @@ -3064,6 +3066,7 @@ static char zHelp[] = " LIKE pattern TABLE.\n" ".echo on|off Turn command echo on or off\n" ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN\n" + ".excel Display the output of next command in a spreadsheet\n" ".exit Exit this program\n" ".expert EXPERIMENTAL. Suggest indexes for specified queries\n" /* Because explain mode comes on automatically now, the ".explain" mode @@ -3926,7 +3929,11 @@ static void tryToClone(ShellState *p, const char *zNewDb){ } /* -** Change the output file back to stdout +** Change the output file back to stdout. +** +** If the p->doXdgOpen flag is set, that means the output was being +** redirected to a temporary file named by p->zTempFile. In that case, +** launch start/open/xdg-open on that temporary file. */ static void output_reset(ShellState *p){ if( p->outfile[0]=='|' ){ @@ -3935,6 +3942,22 @@ static void output_reset(ShellState *p){ #endif }else{ output_file_close(p->out); + if( p->doXdgOpen ){ + const char *zXdgOpenCmd = +#if defined(_WIN32) + "start"; +#elif defined(__APPLE__) + "open"; +#else + "xdg-open"; +#endif + char *zCmd; + zCmd = sqlite3_mprintf("%s %s", zXdgOpenCmd, p->zTempFile); + system(zCmd); + sqlite3_free(zCmd); + p->mode = p->doXdgOpen - 1; + p->doXdgOpen = 0; + } } p->outfile[0] = 0; p->out = stdout; @@ -4193,6 +4216,38 @@ int shellDeleteFile(const char *zFilename){ return rc; } +/* +** Try to delete the temporary file (if there is one) and free the +** memory used to hold the name of the temp file. +*/ +static void clearTempFile(ShellState *p){ + if( p->zTempFile==0 ) return; + if( shellDeleteFile(p->zTempFile) ) return; + sqlite3_free(p->zTempFile); + p->zTempFile = 0; +} + +/* +** Create a new temp file name with the given suffix. +*/ +static void newTempFile(ShellState *p, const char *zSuffix){ + clearTempFile(p); + sqlite3_free(p->zTempFile); + p->zTempFile = 0; + sqlite3_file_control(p->db, 0, SQLITE_FCNTL_TEMPFILENAME, &p->zTempFile); + if( p->zTempFile==0 ){ + sqlite3_uint64 r; + sqlite3_randomness(sizeof(r), &r); + p->zTempFile = sqlite3_mprintf("temp%llx.%s", r, zSuffix); + }else{ + p->zTempFile = sqlite3_mprintf("%z.%s", p->zTempFile, zSuffix); + } + if( p->zTempFile==0 ){ + raw_printf(stderr, "out of memory\n"); + exit(1); + } +} + /* ** The implementation of SQL scalar function fkey_collate_clause(), used @@ -5205,6 +5260,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==0 ) return 0; /* no tokens, no error */ n = strlen30(azArg[0]); c = azArg[0][0]; + clearTempFile(p); #ifndef SQLITE_OMIT_AUTHORIZATION if( c=='a' && strncmp(azArg[0], "auth", n)==0 ){ @@ -6109,18 +6165,26 @@ static int do_meta_command(char *zLine, ShellState *p){ } }else - if( c=='o' - && (strncmp(azArg[0], "output", n)==0 || strncmp(azArg[0], "once", n)==0) + if( (c=='o' + && (strncmp(azArg[0], "output", n)==0||strncmp(azArg[0], "once", n)==0)) + || (c=='e' && n==5 && strcmp(azArg[0],"excel")==0) ){ const char *zFile = nArg>=2 ? azArg[1] : "stdout"; + if( azArg[0][0]=='e' ){ + /* Transform the ".excel" command into ".once -x" */ + nArg = 2; + azArg[0] = "once"; + zFile = azArg[1] = "-x"; + n = 4; + } if( nArg>2 ){ - utf8_printf(stderr, "Usage: .%s FILE\n", azArg[0]); + utf8_printf(stderr, "Usage: .%s [-e|-x|FILE]\n", azArg[0]); rc = 1; goto meta_command_exit; } if( n>1 && strncmp(azArg[0], "once", n)==0 ){ if( nArg<2 ){ - raw_printf(stderr, "Usage: .once FILE\n"); + raw_printf(stderr, "Usage: .once (-e|-x|FILE)\n"); rc = 1; goto meta_command_exit; } @@ -6129,6 +6193,19 @@ static int do_meta_command(char *zLine, ShellState *p){ p->outCount = 0; } output_reset(p); + if( zFile[0]=='-' && zFile[1]=='-' ) zFile++; + if( strcmp(zFile, "-e")==0 || strcmp(zFile, "-x")==0 ){ + p->doXdgOpen = p->mode + 1; + if( zFile[1]=='x' ){ + newTempFile(p, "csv"); + p->mode = MODE_Csv; + sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma); + sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_CrLf); + }else{ + newTempFile(p, "txt"); + } + zFile = p->zTempFile; + } if( zFile[0]=='|' ){ #ifdef SQLITE_OMIT_POPEN raw_printf(stderr, "Error: pipes are not supported in this OS\n"); @@ -7558,6 +7635,8 @@ static int process_input(ShellState *p, FILE *in){ if( p->outCount ){ output_reset(p); p->outCount = 0; + }else{ + clearTempFile(p); } }else if( nSql && _all_whitespace(zSql) ){ if( ShellHasFlag(p, SHFLG_Echo) ) printf("%s\n", zSql); @@ -8180,6 +8259,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ } sqlite3_free(data.zFreeOnClose); find_home_dir(1); + clearTempFile(&data); #if !SQLITE_SHELL_IS_UTF8 for(i=0; i Date: Wed, 10 Jan 2018 21:50:08 +0000 Subject: [PATCH 104/190] Fix a potential SQLITE_MISUSE in the .excel command when no database is open. FossilOrigin-Name: 9b95ff1abfb8d49bbe5a727f5c917a455e4289b4d69196377dc9294409341d70 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/shell.c.in | 4 +++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 751835d013..6b08444735 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\sthe\s".excel"\scommand\s(and\s".once\s-e"\sand\s".once\s-x")\sin\nthe\sCLI. -D 2018-01-10T21:41:55.211 +C Fix\sa\spotential\sSQLITE_MISUSE\sin\sthe\s.excel\scommand\swhen\sno\sdatabase\sis\sopen. +D 2018-01-10T21:50:08.964 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in d1dbc1514d74b425db41be006f2a4f91d26c5e1c2db4ab198b45c12920171e11 +F src/shell.c.in 362e3af76b80c3bd688f1f6fc8df407e651b71a65f0d919287eb6db5c357260c F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,10 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 60c694c1ab26a7a096f17ccea5a93ecda0f9f2113ab5fdc8b17dbffc787724fc -R bd40eb18946fee4f15d02cd4e13ad69c -T *branch * excel-shell-cmd -T *sym-excel-shell-cmd * -T -sym-trunk * +P 23fa7c57c2b204d1ddcc2a939b5271628cf26689ad4ede6976038113095a9801 +R ba511ddf16c10fcf8fdff3518b957cd4 U drh -Z f708fb338ffb9679393be576ce4d2140 +Z 0681d6d553d7112baca91b9b1918eb9d diff --git a/manifest.uuid b/manifest.uuid index 5bb31c1d62..4442a7e3cf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -23fa7c57c2b204d1ddcc2a939b5271628cf26689ad4ede6976038113095a9801 \ No newline at end of file +9b95ff1abfb8d49bbe5a727f5c917a455e4289b4d69196377dc9294409341d70 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 81677bf5e8..c76b305450 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4234,7 +4234,9 @@ static void newTempFile(ShellState *p, const char *zSuffix){ clearTempFile(p); sqlite3_free(p->zTempFile); p->zTempFile = 0; - sqlite3_file_control(p->db, 0, SQLITE_FCNTL_TEMPFILENAME, &p->zTempFile); + if( p->db ){ + sqlite3_file_control(p->db, 0, SQLITE_FCNTL_TEMPFILENAME, &p->zTempFile); + } if( p->zTempFile==0 ){ sqlite3_uint64 r; sqlite3_randomness(sizeof(r), &r); From a92a01a77eadf7a582f2973efe2fd371c38fe92b Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 22:15:37 +0000 Subject: [PATCH 105/190] An attempt to get ".once -e" working reliably on Windows. FossilOrigin-Name: 9b97f9d2c876162139dbd9485fcf68412d1572d9ddc179b08938b8a602e895d6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 18 +++++++++++------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 6b08444735..acd4d81085 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spotential\sSQLITE_MISUSE\sin\sthe\s.excel\scommand\swhen\sno\sdatabase\sis\sopen. -D 2018-01-10T21:50:08.964 +C An\sattempt\sto\sget\s".once\s-e"\sworking\sreliably\son\sWindows. +D 2018-01-10T22:15:37.810 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 362e3af76b80c3bd688f1f6fc8df407e651b71a65f0d919287eb6db5c357260c +F src/shell.c.in 8ac56c0e57d87f04c7c021d17d541063fd4cd9e5cd558caf40a63bf42875b8a9 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 23fa7c57c2b204d1ddcc2a939b5271628cf26689ad4ede6976038113095a9801 -R ba511ddf16c10fcf8fdff3518b957cd4 +P 9b95ff1abfb8d49bbe5a727f5c917a455e4289b4d69196377dc9294409341d70 +R 0c911dcb6179b38e957861df043bdcc3 U drh -Z 0681d6d553d7112baca91b9b1918eb9d +Z 8c9fcb0a09d556e95bbd5b8371ae82b1 diff --git a/manifest.uuid b/manifest.uuid index 4442a7e3cf..e5bf4629ab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b95ff1abfb8d49bbe5a727f5c917a455e4289b4d69196377dc9294409341d70 \ No newline at end of file +9b97f9d2c876162139dbd9485fcf68412d1572d9ddc179b08938b8a602e895d6 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index c76b305450..fae70a1ece 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3507,7 +3507,7 @@ static void output_file_close(FILE *f){ ** recognized and do the right thing. NULL is returned if the output ** filename is "off". */ -static FILE *output_file_open(const char *zFile){ +static FILE *output_file_open(const char *zFile, int bTextMode){ FILE *f; if( strcmp(zFile,"stdout")==0 ){ f = stdout; @@ -3516,7 +3516,7 @@ static FILE *output_file_open(const char *zFile){ }else if( strcmp(zFile, "off")==0 ){ f = 0; }else{ - f = fopen(zFile, "wb"); + f = fopen(zFile, bTextMode ? "w" : "wb"); if( f==0 ){ utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile); } @@ -3953,7 +3953,9 @@ static void output_reset(ShellState *p){ #endif char *zCmd; zCmd = sqlite3_mprintf("%s %s", zXdgOpenCmd, p->zTempFile); - system(zCmd); + if( system(zCmd) ){ + utf8_printf(stderr, "Failed: [%s]\n", zCmd); + } sqlite3_free(zCmd); p->mode = p->doXdgOpen - 1; p->doXdgOpen = 0; @@ -6058,7 +6060,7 @@ static int do_meta_command(char *zLine, ShellState *p){ }else{ const char *zFile = azArg[1]; output_file_close(p->pLog); - p->pLog = output_file_open(zFile); + p->pLog = output_file_open(zFile, 0); } }else @@ -6172,6 +6174,7 @@ static int do_meta_command(char *zLine, ShellState *p){ || (c=='e' && n==5 && strcmp(azArg[0],"excel")==0) ){ const char *zFile = nArg>=2 ? azArg[1] : "stdout"; + int bTxtMode = 0; if( azArg[0][0]=='e' ){ /* Transform the ".excel" command into ".once -x" */ nArg = 2; @@ -6205,6 +6208,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_CrLf); }else{ newTempFile(p, "txt"); + bTxtMode = 1; } zFile = p->zTempFile; } @@ -6224,7 +6228,7 @@ static int do_meta_command(char *zLine, ShellState *p){ } #endif }else{ - p->out = output_file_open(zFile); + p->out = output_file_open(zFile, bTxtMode); if( p->out==0 ){ if( strcmp(zFile,"off")!=0 ){ utf8_printf(stderr,"Error: cannot write to \"%s\"\n", zFile); @@ -7101,7 +7105,7 @@ static int do_meta_command(char *zLine, ShellState *p){ /* Begin redirecting output to the file "testcase-out.txt" */ if( c=='t' && strcmp(azArg[0],"testcase")==0 ){ output_reset(p); - p->out = output_file_open("testcase-out.txt"); + p->out = output_file_open("testcase-out.txt", 0); if( p->out==0 ){ raw_printf(stderr, "Error: cannot open 'testcase-out.txt'\n"); } @@ -7307,7 +7311,7 @@ static int do_meta_command(char *zLine, ShellState *p){ goto meta_command_exit; } output_file_close(p->traceOut); - p->traceOut = output_file_open(azArg[1]); + p->traceOut = output_file_open(azArg[1], 0); #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) if( p->traceOut==0 ){ sqlite3_trace_v2(p->db, 0, 0, 0); From 3c484e8c1f87eddca84af1b63f3751c6265614e8 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 22:27:21 +0000 Subject: [PATCH 106/190] Save and restore the output mode when doing ".once -x" or ".excel". FossilOrigin-Name: f697c164518d36f2a63c87d9f2708d0f9481fad3ded2de61f3f48c393cf7a500 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 22 ++++++++++++++++++++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index acd4d81085..34e956876e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\sattempt\sto\sget\s".once\s-e"\sworking\sreliably\son\sWindows. -D 2018-01-10T22:15:37.810 +C Save\sand\srestore\sthe\soutput\smode\swhen\sdoing\s".once\s-x"\sor\s".excel". +D 2018-01-10T22:27:21.115 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 8ac56c0e57d87f04c7c021d17d541063fd4cd9e5cd558caf40a63bf42875b8a9 +F src/shell.c.in 0baa3d017e3e46ed935413f7e8d09b8c77a8f870c84cf8b2d8b81528517bf485 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9b95ff1abfb8d49bbe5a727f5c917a455e4289b4d69196377dc9294409341d70 -R 0c911dcb6179b38e957861df043bdcc3 +P 9b97f9d2c876162139dbd9485fcf68412d1572d9ddc179b08938b8a602e895d6 +R d864377b5e3ba9e6ed72c01bab712abd U drh -Z 8c9fcb0a09d556e95bbd5b8371ae82b1 +Z 372298188cf6cc90b3d7d11dd46f07c5 diff --git a/manifest.uuid b/manifest.uuid index e5bf4629ab..3358c70b40 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b97f9d2c876162139dbd9485fcf68412d1572d9ddc179b08938b8a602e895d6 \ No newline at end of file +f697c164518d36f2a63c87d9f2708d0f9481fad3ded2de61f3f48c393cf7a500 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index fae70a1ece..e9c268e42a 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1019,6 +1019,7 @@ struct ShellState { FILE *traceOut; /* Output for sqlite3_trace() */ int nErr; /* Number of errors seen */ int mode; /* An output mode setting */ + int modePrior; /* Saved mode */ int cMode; /* temporary output mode for the current query */ int normalMode; /* Output mode before ".explain on" */ int writableSchema; /* True if PRAGMA writable_schema=ON */ @@ -1030,6 +1031,8 @@ struct ShellState { char zTestcase[30]; /* Name of current test case */ char colSeparator[20]; /* Column separator character for several modes */ char rowSeparator[20]; /* Row separator character for MODE_Ascii */ + char colSepPrior[20]; /* Saved column separator */ + char rowSepPrior[20]; /* Saved row separator */ int colWidth[100]; /* Requested width of each column when in column mode*/ int actualWidth[100]; /* Actual width of each column */ char nullValue[20]; /* The text to print when a NULL comes back from @@ -1153,6 +1156,20 @@ static void shellPutsFunc( sqlite3_result_value(pCtx, apVal[0]); } +/* +** Save or restore the current output mode +*/ +static void outputModePush(ShellState *p){ + p->modePrior = p->mode; + memcpy(p->colSepPrior, p->colSeparator, sizeof(p->colSeparator)); + memcpy(p->rowSepPrior, p->rowSeparator, sizeof(p->rowSeparator)); +} +static void outputModePop(ShellState *p){ + p->mode = p->modePrior; + memcpy(p->colSeparator, p->colSepPrior, sizeof(p->colSeparator)); + memcpy(p->rowSeparator, p->rowSepPrior, sizeof(p->rowSeparator)); +} + /* ** Output the given string as a hex-encoded blob (eg. X'1234' ) */ @@ -3957,7 +3974,7 @@ static void output_reset(ShellState *p){ utf8_printf(stderr, "Failed: [%s]\n", zCmd); } sqlite3_free(zCmd); - p->mode = p->doXdgOpen - 1; + outputModePop(p); p->doXdgOpen = 0; } } @@ -6200,7 +6217,8 @@ static int do_meta_command(char *zLine, ShellState *p){ output_reset(p); if( zFile[0]=='-' && zFile[1]=='-' ) zFile++; if( strcmp(zFile, "-e")==0 || strcmp(zFile, "-x")==0 ){ - p->doXdgOpen = p->mode + 1; + p->doXdgOpen = 1; + outputModePush(p); if( zFile[1]=='x' ){ newTempFile(p, "csv"); p->mode = MODE_Csv; From 6c9dcc427d38a3eccf4ed8ae5b4218c981a737d0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 10 Jan 2018 23:27:30 +0000 Subject: [PATCH 107/190] Update test cases for the new "usage" for .output. FossilOrigin-Name: fbf5e43c07e7c012cb39b33a74b3fab9e46ba946c48497fbd990110692125f57 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/shell1.test | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 34e956876e..4766b6496a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Save\sand\srestore\sthe\soutput\smode\swhen\sdoing\s".once\s-x"\sor\s".excel". -D 2018-01-10T22:27:21.115 +C Update\stest\scases\sfor\sthe\snew\s"usage"\sfor\s.output. +D 2018-01-10T23:27:30.001 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -1218,7 +1218,7 @@ F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5 F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test 6d69e08039aea13f2c42749f162fe05eab7b5c93729f31d49d7d27cf36226e5a +F test/shell1.test 9f8b8da05a79b134e252a5e1d8d411245ad83ac7126c262900b9f42b43108ffd F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test ac8c2b744014c3e9a0e26bfd829ab65f00923dc1a91ffd044863e9423cc91494 F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9b97f9d2c876162139dbd9485fcf68412d1572d9ddc179b08938b8a602e895d6 -R d864377b5e3ba9e6ed72c01bab712abd +P f697c164518d36f2a63c87d9f2708d0f9481fad3ded2de61f3f48c393cf7a500 +R cbc8182064251451cd032585a1a8098f U drh -Z 372298188cf6cc90b3d7d11dd46f07c5 +Z 0fca8af732176ea4c3e2417e5169029d diff --git a/manifest.uuid b/manifest.uuid index 3358c70b40..6ef1621db8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f697c164518d36f2a63c87d9f2708d0f9481fad3ded2de61f3f48c393cf7a500 \ No newline at end of file +fbf5e43c07e7c012cb39b33a74b3fab9e46ba946c48497fbd990110692125f57 \ No newline at end of file diff --git a/test/shell1.test b/test/shell1.test index 0d03c64f78..81883a8d18 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -495,7 +495,7 @@ do_test shell1-3.15.2 { do_test shell1-3.15.3 { # too many arguments catchcmd "test.db" ".output FOO BAD" -} {1 {Usage: .output FILE}} +} {1 {Usage: .output [-e|-x|FILE]}} # .output stdout Send output to the screen do_test shell1-3.16.1 { @@ -504,7 +504,7 @@ do_test shell1-3.16.1 { do_test shell1-3.16.2 { # too many arguments catchcmd "test.db" ".output stdout BAD" -} {1 {Usage: .output FILE}} +} {1 {Usage: .output [-e|-x|FILE]}} # .prompt MAIN CONTINUE Replace the standard prompts do_test shell1-3.17.1 { From 97913134747525664f280839889cd66718752cb3 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 Jan 2018 00:04:00 +0000 Subject: [PATCH 108/190] Add the built-in edit(VALUE) and edit(VALUE,EDITOR) function to the CLI. FossilOrigin-Name: ef823c47a0ac4f3b001e6c89c38354b45b5229d872cfc69a29c82e99414b89c8 --- manifest | 13 +++-- manifest.uuid | 2 +- src/shell.c.in | 130 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 18f1e54d50..f1234ab340 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s".once\s-e"\sand\s".once\s-x"\scommands\sto\sthe\sCLI,\sand\sthe\s".excel"\scommand\nthat\sis\san\salias\sfor\s".once\s-x". -D 2018-01-10T23:29:42.447 +C Add\sthe\sbuilt-in\sedit(VALUE)\sand\sedit(VALUE,EDITOR)\sfunction\sto\sthe\sCLI. +D 2018-01-11T00:04:00.842 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 0baa3d017e3e46ed935413f7e8d09b8c77a8f870c84cf8b2d8b81528517bf485 +F src/shell.c.in 52aef9f2f61915c9226d6ff87444102b744a48e7b001e50d88d262fed3526030 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,8 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 60c694c1ab26a7a096f17ccea5a93ecda0f9f2113ab5fdc8b17dbffc787724fc fbf5e43c07e7c012cb39b33a74b3fab9e46ba946c48497fbd990110692125f57 -R cbc8182064251451cd032585a1a8098f -T +closed fbf5e43c07e7c012cb39b33a74b3fab9e46ba946c48497fbd990110692125f57 +P a6ed5ab9bc9741267fd1207e63b4c49d074291085c7e3f25e9f62a82f916a656 +R 178e506824f095711305ed729320460e U drh -Z c9d5887fceb0e0e24e4f6ea11d33b5eb +Z c1ee7e4e075a7abb60497a235dd7f461 diff --git a/manifest.uuid b/manifest.uuid index ff97541f24..07d9f13bed 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a6ed5ab9bc9741267fd1207e63b4c49d074291085c7e3f25e9f62a82f916a656 \ No newline at end of file +ef823c47a0ac4f3b001e6c89c38354b45b5229d872cfc69a29c82e99414b89c8 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index e9c268e42a..e03eebd042 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1156,6 +1156,132 @@ static void shellPutsFunc( sqlite3_result_value(pCtx, apVal[0]); } +/* +** SQL function: edit(VALUE) +** edit(VALUE,EDITOR) +** +** These steps: +** +** (1) Write VALUE into a temporary file. +** (2) Run program EDITOR on that temporary file. +** (3) Read the temporary file back and return its content as the result. +** (4) Delete the temporary file +** +** If the EDITOR argument is omitted, use the value in the VISUAL +** environment variable. If still there is no EDITOR, through an error. +** +** Also throw an error if the EDITOR program returns a non-zero exit code. +*/ +static void editFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + const char *zEditor; + char *zTempFile = 0; + sqlite3 *db; + char *zCmd = 0; + int bBin; + int rc; + FILE *f = 0; + sqlite3_int64 sz; + sqlite3_int64 x; + unsigned char *p = 0; + + if( argc==2 ){ + zEditor = (const char*)sqlite3_value_text(argv[1]); + }else{ + zEditor = getenv("VISUAL"); + } + if( zEditor==0 ){ + sqlite3_result_error(context, "no editor for edit()", -1); + return; + } + if( sqlite3_value_type(argv[0])==SQLITE_NULL ){ + sqlite3_result_error(context, "NULL input to edit()", -1); + return; + } + db = sqlite3_context_db_handle(context); + zTempFile = 0; + sqlite3_file_control(db, 0, SQLITE_FCNTL_TEMPFILENAME, &zTempFile); + if( zTempFile==0 ){ + sqlite3_uint64 r = 0; + sqlite3_randomness(sizeof(r), &r); + zTempFile = sqlite3_mprintf("temp%llx", r); + if( zTempFile==0 ){ + sqlite3_result_error_nomem(context); + return; + } + } + bBin = sqlite3_value_type(argv[0])==SQLITE_BLOB; + f = fopen(zTempFile, bBin ? "wb" : "w"); + if( f==0 ){ + sqlite3_result_error(context, "edit() cannot open temp file", -1); + goto edit_func_end; + } + sz = sqlite3_value_bytes(argv[0]); + if( bBin ){ + x = fwrite(sqlite3_value_blob(argv[0]), 1, sz, f); + }else{ + x = fwrite(sqlite3_value_text(argv[0]), 1, sz, f); + } + fclose(f); + f = 0; + if( x!=sz ){ + sqlite3_result_error(context, "edit() could not write the whole file", -1); + goto edit_func_end; + } + zCmd = sqlite3_mprintf("%s \"%s\"", zEditor, zTempFile); + if( zCmd==0 ){ + sqlite3_result_error_nomem(context); + goto edit_func_end; + } + rc = system(zCmd); + sqlite3_free(zCmd); + if( rc ){ + sqlite3_result_error(context, "EDITOR returned non-zero", -1); + goto edit_func_end; + } + f = fopen(zTempFile, bBin ? "rb" : "r"); + if( f==0 ){ + sqlite3_result_error(context, + "edit() cannot reopen temp file after edit", -1); + goto edit_func_end; + } + fseek(f, 0, SEEK_END); + sz = ftell(f); + rewind(f); + p = sqlite3_malloc64( sz+(bBin==0) ); + if( p==0 ){ + sqlite3_result_error_nomem(context); + goto edit_func_end; + } + if( bBin ){ + x = fread(p, 1, sz, f); + }else{ + x = fread(p, 1, sz, f); + p[sz] = 0; + } + fclose(f); + f = 0; + if( x!=sz ){ + sqlite3_result_error(context, "could not read back the whole file", -1); + goto edit_func_end; + } + if( bBin ){ + sqlite3_result_blob(context, p, sz, sqlite3_free); + }else{ + sqlite3_result_text(context, (const char*)p, sz, sqlite3_free); + } + p = 0; + +edit_func_end: + if( f ) fclose(f); + unlink(zTempFile); + sqlite3_free(zTempFile); + sqlite3_free(p); +} + /* ** Save or restore the current output mode */ @@ -3345,6 +3471,10 @@ static void open_db(ShellState *p, int keepAlive){ shellModuleSchema, 0, 0); sqlite3_create_function(p->db, "shell_putsnl", 1, SQLITE_UTF8, p, shellPutsFunc, 0, 0); + sqlite3_create_function(p->db, "edit", 1, SQLITE_UTF8, 0, + editFunc, 0, 0); + sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0, + editFunc, 0, 0); if( p->openMode==SHELL_OPEN_ZIPFILE ){ char *zSql = sqlite3_mprintf( "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", p->zDbFilename); From 536c345107d784c85a4976ee576bee4554d35af3 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 Jan 2018 00:38:39 +0000 Subject: [PATCH 109/190] Update the .help screen in the CLI. Make sure the temporary files for ".open" are not deleted too soon. FossilOrigin-Name: b8d92d8dc239597c6f01a6e572b047f98ce374a8f48257683fa839dde3ec993f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 9 +++++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f1234ab340..45bcfa6cca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sbuilt-in\sedit(VALUE)\sand\sedit(VALUE,EDITOR)\sfunction\sto\sthe\sCLI. -D 2018-01-11T00:04:00.842 +C Update\sthe\s.help\sscreen\sin\sthe\sCLI.\s\sMake\ssure\sthe\stemporary\sfiles\sfor\n".open"\sare\snot\sdeleted\stoo\ssoon. +D 2018-01-11T00:38:39.192 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 52aef9f2f61915c9226d6ff87444102b744a48e7b001e50d88d262fed3526030 +F src/shell.c.in b87abffd0db09203ad8a133d56fe8f154ace5ec0a14197a153fb7d80b1438c01 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a6ed5ab9bc9741267fd1207e63b4c49d074291085c7e3f25e9f62a82f916a656 -R 178e506824f095711305ed729320460e +P ef823c47a0ac4f3b001e6c89c38354b45b5229d872cfc69a29c82e99414b89c8 +R 3f7dbb61aadad578b23395ee859b8a4c U drh -Z c1ee7e4e075a7abb60497a235dd7f461 +Z c33398289b510440ef343bbf6c1308f4 diff --git a/manifest.uuid b/manifest.uuid index 07d9f13bed..9cf4eb9896 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ef823c47a0ac4f3b001e6c89c38354b45b5229d872cfc69a29c82e99414b89c8 \ No newline at end of file +b8d92d8dc239597c6f01a6e572b047f98ce374a8f48257683fa839dde3ec993f \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index e03eebd042..ee21a83d6f 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3247,10 +3247,12 @@ static char zHelp[] = " tabs Tab-separated values\n" " tcl TCL list elements\n" ".nullvalue STRING Use STRING in place of NULL values\n" - ".once FILENAME Output for the next SQL command only to FILENAME\n" + ".once (-e|-x|FILE) Output for the next SQL command only to FILE\n" + " or invoke system text editor (-e) or spreadsheet (-x)\n" + " on the output.\n" ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE\n" " The --new option starts with an empty file\n" - ".output ?FILENAME? Send output to FILENAME or stdout\n" + ".output ?FILE? Send output to FILE or stdout\n" ".print STRING... Print literal STRING\n" ".prompt MAIN CONTINUE Replace the standard prompts\n" ".quit Exit this program\n" @@ -4371,6 +4373,7 @@ int shellDeleteFile(const char *zFilename){ */ static void clearTempFile(ShellState *p){ if( p->zTempFile==0 ) return; + if( p->doXdgOpen ) return; if( shellDeleteFile(p->zTempFile) ) return; sqlite3_free(p->zTempFile); p->zTempFile = 0; @@ -8413,6 +8416,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ } sqlite3_free(data.zFreeOnClose); find_home_dir(1); + output_reset(&data); + data.doXdgOpen = 0; clearTempFile(&data); #if !SQLITE_SHELL_IS_UTF8 for(i=0; i Date: Thu, 11 Jan 2018 13:43:04 +0000 Subject: [PATCH 110/190] Fix typo in comment. No code changes. FossilOrigin-Name: 2c55571baaae58d6f5b6210cf85d0fa325a9977682bd449e3802191f7a4142de --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/update.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 45bcfa6cca..67e2fbd266 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\s.help\sscreen\sin\sthe\sCLI.\s\sMake\ssure\sthe\stemporary\sfiles\sfor\n".open"\sare\snot\sdeleted\stoo\ssoon. -D 2018-01-11T00:38:39.192 +C Fix\stypo\sin\scomment.\s\sNo\scode\schanges. +D 2018-01-11T13:43:04.788 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -548,7 +548,7 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 5b0c661a85f783d35b9883830736eeb63be4aefc4f6b7d9cd081d48782c041e2 F src/treeview.c eae35972ff44f67064de2eaf35f04afe94e7aea3271a8b3bcebb3f954880fec3 F src/trigger.c a34539c69433276d37b0da9a89c117726ff2d292c0902895af1f393a983cd3a1 -F src/update.c 961bd1265d4d1e5cd65c9a54fa5122fb7aefcb003fcf2de0c092fceb7e58972c +F src/update.c f75a8bf497219fa0c4ba9293022db64cca13e457e33d62f58306f107327506ac F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/util.c 7315e97a8dc2c8e19ca64196c652cf0a65d13fd0a211b2cec082062372dc6261 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ef823c47a0ac4f3b001e6c89c38354b45b5229d872cfc69a29c82e99414b89c8 -R 3f7dbb61aadad578b23395ee859b8a4c +P b8d92d8dc239597c6f01a6e572b047f98ce374a8f48257683fa839dde3ec993f +R 7aa5de08d44a1e2c05aadb2e5fa21a20 U drh -Z c33398289b510440ef343bbf6c1308f4 +Z af4c8b3a64ae000c2affb5a4b97dbea6 diff --git a/manifest.uuid b/manifest.uuid index 9cf4eb9896..f5e80a94e6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8d92d8dc239597c6f01a6e572b047f98ce374a8f48257683fa839dde3ec993f \ No newline at end of file +2c55571baaae58d6f5b6210cf85d0fa325a9977682bd449e3802191f7a4142de \ No newline at end of file diff --git a/src/update.c b/src/update.c index 15e8f4a6ce..3e9d11bbf7 100644 --- a/src/update.c +++ b/src/update.c @@ -807,7 +807,7 @@ static void updateVirtualTable( int bOnePass; /* True to use onepass strategy */ int addr; /* Address of OP_OpenEphemeral */ - /* Allocate nArg registers to martial the arguments to VUpdate. Then + /* Allocate nArg registers in which to gather the arguments for VUpdate. Then ** create and open the ephemeral table in which the records created from ** these arguments will be temporarily stored. */ assert( v ); From e4185bda9ac72005bae1308665d07596573f7cf5 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 Jan 2018 14:50:40 +0000 Subject: [PATCH 111/190] Minor formatting changes in zipfile.c. No logical code differences. FossilOrigin-Name: 4f68bed3b9a63a349a2a2d7f26609491577e9717034ad86af404cf9eed9d6aaf --- ext/misc/zipfile.c | 36 +++++++++++++++++++++++++----------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 1a65a8896b..280bc6a4ed 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -10,6 +10,19 @@ ** ****************************************************************************** ** +** This file implements a virtual table for reading and writing ZIP archive +** files. +** +** Usage example: +** +** SELECT name, sz, datetime(mtime,'unixepoch') FROM zipfile($filename); +** +** Current limitations: +** +** * No support for encryption +** * No support for ZIP archives spanning multiple files +** * No support for zip64 extensions +** * Only the "inflate/deflate" (zlib) compression method is supported */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 @@ -42,18 +55,19 @@ typedef unsigned long u32; #define MIN(a,b) ((a)<(b) ? (a) : (b)) #endif -#define ZIPFILE_SCHEMA "CREATE TABLE y(" \ - "name, /* 0: Name of file in zip archive */" \ - "mode, /* 1: POSIX mode for file */" \ - "mtime, /* 2: Last modification time in seconds since epoch */" \ - "sz, /* 3: Size of object */" \ - "rawdata, /* 4: Raw data */" \ - "data, /* 5: Uncompressed data */" \ - "method, /* 6: Compression method (integer) */" \ - "file HIDDEN /* Name of zip file */" \ -");" +static const char ZIPFILE_SCHEMA[] = + "CREATE TABLE y(" + "name," /* 0: Name of file in zip archive */ + "mode," /* 1: POSIX mode for file */ + "mtime," /* 2: Last modification time (secs since 1970)*/ + "sz," /* 3: Size of object */ + "rawdata," /* 4: Raw data */ + "data," /* 5: Uncompressed data */ + "method," /* 6: Compression method (integer) */ + "file HIDDEN" /* 7: Name of zip file */ + ");"; -#define ZIPFILE_F_COLUMN_IDX 7 /* Index of column "f" in the above */ +#define ZIPFILE_F_COLUMN_IDX 7 /* Index of column "file" in the above */ #define ZIPFILE_BUFFER_SIZE (64*1024) diff --git a/manifest b/manifest index 67e2fbd266..ee79e40a2b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\scomment.\s\sNo\scode\schanges. -D 2018-01-11T13:43:04.788 +C Minor\sformatting\schanges\sin\szipfile.c.\s\sNo\slogical\scode\sdifferences. +D 2018-01-11T14:50:40.176 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 0d12ad852af1732c9a4bd0be9f28886b049e0591a871e3246a5347d2cea15430 +F ext/misc/zipfile.c cbf9dfaf94c25dfd835e79c1474fdc75517a45a37916dec66623b0937af10e51 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b8d92d8dc239597c6f01a6e572b047f98ce374a8f48257683fa839dde3ec993f -R 7aa5de08d44a1e2c05aadb2e5fa21a20 +P 2c55571baaae58d6f5b6210cf85d0fa325a9977682bd449e3802191f7a4142de +R 33de751c900466ee2a12d260dcb2a3de U drh -Z af4c8b3a64ae000c2affb5a4b97dbea6 +Z 324651d5684ea52cfa823d4ea5809b01 diff --git a/manifest.uuid b/manifest.uuid index f5e80a94e6..774aa87cbe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2c55571baaae58d6f5b6210cf85d0fa325a9977682bd449e3802191f7a4142de \ No newline at end of file +4f68bed3b9a63a349a2a2d7f26609491577e9717034ad86af404cf9eed9d6aaf \ No newline at end of file From 5e9bbe1924b8ba158bb697a3d4568bab09f39f39 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 11 Jan 2018 16:16:03 +0000 Subject: [PATCH 112/190] Add test cases for running multiple RBU operations within the same process concurrently. FossilOrigin-Name: 407b5ed35c178bb0dbc69c8b902652038a0653d55a58a7543f9d4857c6baf3ea --- ext/rbu/rbumulti.test | 175 ++++++++++++++++++++++++++++++++++++++++++ manifest | 13 ++-- manifest.uuid | 2 +- 3 files changed, 183 insertions(+), 7 deletions(-) create mode 100644 ext/rbu/rbumulti.test diff --git a/ext/rbu/rbumulti.test b/ext/rbu/rbumulti.test new file mode 100644 index 0000000000..59c6538c6c --- /dev/null +++ b/ext/rbu/rbumulti.test @@ -0,0 +1,175 @@ +# 2018 January 11 +# +# 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 contains tests of multiple RBU operations running +# concurrently within the same process. +# + +source [file join [file dirname [info script]] rbu_common.tcl] +set ::testprefix rbumulti + +db close +sqlite3_shutdown +sqlite3_config_uri 1 + +autoinstall_test_functions + +proc build_db {db} { + $db eval { + CREATE TABLE t1(a PRIMARY KEY, b, c); + CREATE INDEX i1 ON t1(b); + CREATE INDEX i2 ON t1(c); + + WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<500 ) + INSERT INTO t1 + SELECT randomblob(10), randomblob(100), randomblob(100) FROM s; + } +} + +proc build_rbu {db} { + $db eval { + CREATE TABLE data_t1(a, b, c, rbu_control); + WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100 ) + INSERT INTO data_t1 + SELECT randomblob(10), randomblob(100), randomblob(100), 0 FROM s; + } +} + +proc step_rbu2 {bOpenClose openr1 openr2} { + + forcedelete teststate.db1 + forcedelete teststate.db2 + + if {$bOpenClose!=0 && $bOpenClose!=1} { error $bOpenClose } + if {$bOpenClose==0} { + eval $openr1 + eval $openr2 + } + + set b1 0 + set b2 0 + + while {$b1==0 || $b2==0} { + if {$bOpenClose==1} { + if {$b1==0} { eval $openr1 teststate.db1 } + if {$b2==0} { eval $openr2 teststate.db2 } + } + if {$b1==0} { + set rc1 [r1 step] + if {$rc1 != "SQLITE_OK"} { set b1 1 } + } + if {$b2==0} { + set rc2 [r2 step] + if {$rc2 != "SQLITE_OK"} { set b2 1 } + } + if {$bOpenClose==1} { + if {$b1==0} { r1 close } + if {$b2==0} { r2 close } + } + } + + set rc1 [r1 close] + set rc2 [r2 close] + + list $rc1 $rc2 +} + + +for {set i 0} {$i<=3} {incr i} { + + if {$i & 0x01} { + sqlite3rbu_create_vfs -default myrbu "" + } + set bOpenClose [expr $i>>1] + + forcedelete test.db + forcedelete test.db2 + forcedelete rbu.db + forcedelete rbu.db2 + + do_test 1.$i.0 { + sqlite3 db test.db + sqlite3 db2 test.db2 + build_db db + build_db db2 + + sqlite3 rbu1 rbu.db + sqlite3 rbu2 rbu.db2 + + build_rbu rbu1 + build_rbu rbu2 + + rbu1 close + rbu2 close + } {} + + set m1 [db eval {SELECT md5sum(a, b, c) FROM t1}] + set m2 [db2 eval {SELECT md5sum(a, b, c) FROM t1}] + + do_test 1.$i.1 { + step_rbu2 $bOpenClose { + sqlite3rbu r1 test.db rbu.db + } { + sqlite3rbu r2 test.db2 rbu.db2 + } + } {SQLITE_DONE SQLITE_DONE} + + do_execsql_test -db db 1.$i.2.1 { PRAGMA integrity_check } ok + do_execsql_test -db db2 1.$i.2.2 { PRAGMA integrity_check } ok + + do_execsql_test -db db 1.$i.3.1 { SELECT md5sum(a, b, c)==$m1 FROM t1 } 0 + do_execsql_test -db db2 1.$i.3.2 { SELECT md5sum(a, b, c)==$m2 FROM t1 } 0 + + catch { db close } + catch { db2 close } + #----------------------------------------------------------------------- + forcedelete test.db2 + forcedelete test.db + forcedelete rbu.db2 + + do_test 1.$i.4 { + sqlite3 db test.db + sqlite3 db2 test.db2 + build_db db + build_db db2 + sqlite3 rbu2 rbu.db2 + build_rbu rbu2 + rbu2 close + } {} + + set m1 [db eval {SELECT md5sum(a, b, c) FROM t1}] + set m2 [db2 eval {SELECT md5sum(a, b, c) FROM t1}] + + do_test 1.$i.5 { + step_rbu2 $bOpenClose { + sqlite3rbu_vacuum r1 test.db + } { + sqlite3rbu r2 test.db2 rbu.db2 + } + } {SQLITE_DONE SQLITE_DONE} + + do_execsql_test -db db 1.$i.6.1 { SELECT md5sum(a, b, c)==$m1 FROM t1 } 1 + do_execsql_test -db db2 1.$i.6.2 { SELECT md5sum(a, b, c)==$m2 FROM t1 } 0 + + do_execsql_test -db db 1.$i.7.1 { PRAGMA integrity_check } ok + do_execsql_test -db db2 1.$i.7.2 { PRAGMA integrity_check } ok + + catch { db close } + catch { db2 close } + if {$i & 0x01} { + sqlite3rbu_destroy_vfs myrbu + } + +} + + +finish_test + diff --git a/manifest b/manifest index ee79e40a2b..fcbf2dda8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sformatting\schanges\sin\szipfile.c.\s\sNo\slogical\scode\sdifferences. -D 2018-01-11T14:50:40.176 +C Add\stest\scases\sfor\srunning\smultiple\sRBU\soperations\swithin\sthe\ssame\sprocess\nconcurrently. +D 2018-01-11T16:16:03.148 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -330,6 +330,7 @@ F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06 F ext/rbu/rbufault3.test 0913c1aeaee266d9c36c33179341a5a504aad7d423d1979cfec43c8346a29899 F ext/rbu/rbufault4.test 34e70701cbec51571ffbd9fbf9d4e0f2ec495ca7 F ext/rbu/rbufts.test a2bbd202c9321fba15fb4a62a90add7d70e07bd8404e1e598135adbfff8a0508 +F ext/rbu/rbumulti.test 2cf153ab3d5861ff26517dc6cbaec430787a59f1d50e8771fe7a7529a0551cf1 F ext/rbu/rbuprogress.test 1849d4e0e50616edf5ce75ce7db86622e656b5cf F ext/rbu/rburesume.test 8acb77f4a422ff55acfcfc9cc15a5cb210b1de83 F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48 @@ -1697,7 +1698,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2c55571baaae58d6f5b6210cf85d0fa325a9977682bd449e3802191f7a4142de -R 33de751c900466ee2a12d260dcb2a3de -U drh -Z 324651d5684ea52cfa823d4ea5809b01 +P 4f68bed3b9a63a349a2a2d7f26609491577e9717034ad86af404cf9eed9d6aaf +R b4712b12dc6463238ee69f57e3b3a2cb +U dan +Z e742283e882b3ab287b40d1d09763224 diff --git a/manifest.uuid b/manifest.uuid index 774aa87cbe..0d3f74a2d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f68bed3b9a63a349a2a2d7f26609491577e9717034ad86af404cf9eed9d6aaf \ No newline at end of file +407b5ed35c178bb0dbc69c8b902652038a0653d55a58a7543f9d4857c6baf3ea \ No newline at end of file From 6f390beb7f96774e81420548ef0be7c16567bca1 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 11 Jan 2018 17:04:26 +0000 Subject: [PATCH 113/190] Add the sqlite3_vtab_nochange() method which virtual table implementations can use to optimize UPDATEs. FossilOrigin-Name: d444b1ff39f0a1673a977b8047e1e14a49d461c9934be080d27c2392a830c1c0 --- manifest | 23 +++++++++++++---------- manifest.uuid | 2 +- src/sqlite.h.in | 12 ++++++++++++ src/update.c | 2 +- src/vdbe.c | 15 +++++++++++---- src/vdbeInt.h | 1 + src/vdbeapi.c | 19 +++++++++++++++++++ 7 files changed, 58 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index ee79e40a2b..977b35bb02 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sformatting\schanges\sin\szipfile.c.\s\sNo\slogical\scode\sdifferences. -D 2018-01-11T14:50:40.176 +C Add\sthe\ssqlite3_vtab_nochange()\smethod\swhich\svirtual\stable\simplementations\ncan\suse\sto\soptimize\sUPDATEs. +D 2018-01-11T17:04:26.957 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -485,7 +485,7 @@ F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 F src/shell.c.in b87abffd0db09203ad8a133d56fe8f154ace5ec0a14197a153fb7d80b1438c01 -F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c +F src/sqlite.h.in f83e63a48fb31fefc69c83bbe8700b4b44acdd64e440219087b0f14e35eeb8d4 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 F src/sqliteInt.h fd8702c65994d7de3e2d8f7d85d958731da1ed29476571fdfa2290fd8ec0bf80 @@ -548,14 +548,14 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 5b0c661a85f783d35b9883830736eeb63be4aefc4f6b7d9cd081d48782c041e2 F src/treeview.c eae35972ff44f67064de2eaf35f04afe94e7aea3271a8b3bcebb3f954880fec3 F src/trigger.c a34539c69433276d37b0da9a89c117726ff2d292c0902895af1f393a983cd3a1 -F src/update.c f75a8bf497219fa0c4ba9293022db64cca13e457e33d62f58306f107327506ac +F src/update.c 8bd52c38d6d426925be4488ee106db26d9ee344406315671ed246ddace8d6091 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/util.c 7315e97a8dc2c8e19ca64196c652cf0a65d13fd0a211b2cec082062372dc6261 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 -F src/vdbe.c c70267613df80345ed9bbd9c249c365b53bb9cbbe9d3e78e6d5c049d00ef5501 +F src/vdbe.c 4d0666741d884dfaceb6ac5bbededbd947068e4b742163898feea84a027dace6 F src/vdbe.h d50cadf12bcf9fb99117ef392ce1ea283aa429270481426b6e8b0280c101fd97 -F src/vdbeInt.h 1fe00770144c12c4913128f35262d11527ef3284561baaab59b947a41c08d0d9 -F src/vdbeapi.c 9c670ca0dcc1cd86373aa353b747b26fe531ca5cd4331690c611d1f03842e2a1 +F src/vdbeInt.h a0969c14950bcc61b2dfa19c6f62b42c5012013fcda342ca927a192ed37e6592 +F src/vdbeapi.c f519346f6db99a1eb3f85ca3ae8aede9ff9c4d90fec809dae7cb946786b2e270 F src/vdbeaux.c 7ae48b180e5dd5d282e6752d155f1ab7929196d8e6577b82742044188152ca85 F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191 F src/vdbemem.c 8478f7fb1948bf8fdeec7c2cb59ea58155c31258b9cd43c56d485e03ed40bd07 @@ -1697,7 +1697,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2c55571baaae58d6f5b6210cf85d0fa325a9977682bd449e3802191f7a4142de -R 33de751c900466ee2a12d260dcb2a3de +P 4f68bed3b9a63a349a2a2d7f26609491577e9717034ad86af404cf9eed9d6aaf +R ca3c0ce043db4afb0303f36904592ef8 +T *branch * sqlite3_vtab_nochange +T *sym-sqlite3_vtab_nochange * +T -sym-trunk * U drh -Z 324651d5684ea52cfa823d4ea5809b01 +Z 5a280540fff60985c8c72fc104fac16d diff --git a/manifest.uuid b/manifest.uuid index 774aa87cbe..3f07edeeb6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f68bed3b9a63a349a2a2d7f26609491577e9717034ad86af404cf9eed9d6aaf \ No newline at end of file +d444b1ff39f0a1673a977b8047e1e14a49d461c9934be080d27c2392a830c1c0 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index f63b029312..ba673748ed 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -8297,6 +8297,18 @@ int sqlite3_vtab_config(sqlite3*, int op, ...); */ int sqlite3_vtab_on_conflict(sqlite3 *); +/* +** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE +** +** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn] +** method of a [virtual table], then it returns true if and only if the +** column is being fetched as part of an UPDATE operation during which the +** column value will not change. Applications might use this to substitute +** a lighter-weight value to return that the corresponding [xUpdate] method +** understands as a "no-change" value. +*/ +int sqlite3_vtab_nochange(sqlite3_context*); + /* ** CAPI3REF: Determine The Collation For a Virtual Table Constraint ** diff --git a/src/update.c b/src/update.c index 3e9d11bbf7..3de36fe211 100644 --- a/src/update.c +++ b/src/update.c @@ -827,7 +827,7 @@ static void updateVirtualTable( if( aXRef[i]>=0 ){ sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i); }else{ - sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i); + sqlite3VdbeAddOp4Int(v, OP_VColumn, iCsr, i, regArg+2+i, 1); } } if( HasRowid(pTab) ){ diff --git a/src/vdbe.c b/src/vdbe.c index 4d643d7266..b00174bb10 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6693,12 +6693,18 @@ case OP_VFilter: { /* jump */ #endif /* SQLITE_OMIT_VIRTUALTABLE */ #ifndef SQLITE_OMIT_VIRTUALTABLE -/* Opcode: VColumn P1 P2 P3 * * +/* Opcode: VColumn P1 P2 P3 P4 * ** Synopsis: r[P3]=vcolumn(P2) ** -** Store the value of the P2-th column of -** the row of the virtual-table that the -** P1 cursor is pointing to into register P3. +** Store in register P3 the value of the P2-th column of +** the current row of the virtual-table of cursor P1. +** +** If the VColumn opcode is being used to fetch the value of +** an unchanging column during an UPDATE operation, then the P4 +** value is 1. Otherwise, P4 is 0. The P4 value is returned +** by sqlite3_vtab_nochange() routine can can be used +** by virtual table implementations to return special "no-change" +** marks which can be more efficient, depending on the virtual table. */ case OP_VColumn: { sqlite3_vtab *pVtab; @@ -6720,6 +6726,7 @@ case OP_VColumn: { assert( pModule->xColumn ); memset(&sContext, 0, sizeof(sContext)); sContext.pOut = pDest; + sContext.bVtabNoChng = pOp->p4.i!=0; MemSetTypeFlag(pDest, MEM_Null); rc = pModule->xColumn(pCur->uc.pVCur, &sContext, pOp->p2); sqlite3VtabImportErrmsg(p, pVtab); diff --git a/src/vdbeInt.h b/src/vdbeInt.h index cb783653c0..f646a4036a 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -318,6 +318,7 @@ struct sqlite3_context { int isError; /* Error code returned by the function. */ u8 skipFlag; /* Skip accumulator loading if true */ u8 fErrorOrAux; /* isError!=0 or pVdbe->pAuxData modified */ + u8 bVtabNoChng; /* Fetching an unchanging column in a vtab UPDATE */ u8 argc; /* Number of arguments */ sqlite3_value *argv[1]; /* Argument set */ }; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index b9df40b8fd..19aa783bb6 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -745,6 +745,25 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ return p->pOut->db; } +/* +** If this routine is invoked from within an xColumn method of a virtual +** table, then it returns true if and only if the the call is during an +** UPDATE operation and the value of the column will not be modified +** by the UPDATE. +** +** If this routine is called from any context other than within the +** xColumn method of a virtual table, then the return value is meaningless +** and arbitrary. +** +** Virtual table implements might use this routine to optimize their +** performance by substituting a NULL result, or some other light-weight +** value, as a signal to the xUpdate routine that the column is unchanged. +*/ +int sqlite3_vtab_nochange(sqlite3_context *p){ + assert( p ); + return p->bVtabNoChng; +} + /* ** Return the current time for a statement. If the current time ** is requested more than once within the same run of a single prepared From 66a3a91aa6ddc324dd396f0efc475f552c89c9cd Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 11 Jan 2018 17:33:48 +0000 Subject: [PATCH 114/190] Change zipfile to be a WITHOUT ROWID virtual table and table-valued function. FossilOrigin-Name: 931201f64e04247ed613a0301fcc86c3a337c2ed162c6370a80c67a1dd919e7c --- ext/misc/zipfile.c | 19 ++++++------------- manifest | 14 +++++++------- manifest.uuid | 2 +- test/zipfile.test | 6 +++++- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 280bc6a4ed..7ec8a222e7 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -57,7 +57,7 @@ typedef unsigned long u32; static const char ZIPFILE_SCHEMA[] = "CREATE TABLE y(" - "name," /* 0: Name of file in zip archive */ + "name PRIMARY KEY," /* 0: Name of file in zip archive */ "mode," /* 1: POSIX mode for file */ "mtime," /* 2: Last modification time (secs since 1970)*/ "sz," /* 3: Size of object */ @@ -65,7 +65,7 @@ static const char ZIPFILE_SCHEMA[] = "data," /* 5: Uncompressed data */ "method," /* 6: Compression method (integer) */ "file HIDDEN" /* 7: Name of zip file */ - ");"; + ") WITHOUT ROWID;"; #define ZIPFILE_F_COLUMN_IDX 7 /* Index of column "file" in the above */ #define ZIPFILE_BUFFER_SIZE (64*1024) @@ -223,7 +223,6 @@ struct ZipfileLFH { typedef struct ZipfileEntry ZipfileEntry; struct ZipfileEntry { char *zPath; /* Path of zipfile entry */ - i64 iRowid; /* Rowid for this value if queried */ u8 *aCdsEntry; /* Buffer containing entire CDS entry */ int nCdsEntry; /* Size of buffer aCdsEntry[] in bytes */ int bDeleted; /* True if entry has been deleted */ @@ -830,12 +829,7 @@ static int zipfileColumn( ** Return the rowid for the current row. */ static int zipfileRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ - ZipfileCsr *pCsr = (ZipfileCsr*)cur; - if( pCsr->pCurrent ){ - *pRowid = pCsr->pCurrent->iRowid; - }else{ - *pRowid = pCsr->cds.iOffset; - } + assert( 0 ); return SQLITE_OK; } @@ -999,11 +993,9 @@ static void zipfileAddEntry(ZipfileTab *pTab, ZipfileEntry *pNew){ assert( (pTab->pFirstEntry==0)==(pTab->pLastEntry==0) ); assert( pNew->pNext==0 ); if( pTab->pFirstEntry==0 ){ - pNew->iRowid = 1; pTab->pFirstEntry = pTab->pLastEntry = pNew; }else{ assert( pTab->pLastEntry->pNext==0 ); - pNew->iRowid = pTab->pLastEntry->iRowid+1; pTab->pLastEntry->pNext = pNew; pTab->pLastEntry = pNew; } @@ -1251,10 +1243,11 @@ static int zipfileUpdate( if( nVal>1 ){ return SQLITE_CONSTRAINT; }else{ - i64 iDelete = sqlite3_value_int64(apVal[0]); + const char *zDelete = (const char*)sqlite3_value_text(apVal[0]); + int nDelete = strlen(zDelete); ZipfileEntry *p; for(p=pTab->pFirstEntry; p; p=p->pNext){ - if( p->iRowid==iDelete ){ + if( zipfileComparePath(p->zPath, zDelete, nDelete)==0 ){ p->bDeleted = 1; break; } diff --git a/manifest b/manifest index fcbf2dda8e..c426ee99bf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scases\sfor\srunning\smultiple\sRBU\soperations\swithin\sthe\ssame\sprocess\nconcurrently. -D 2018-01-11T16:16:03.148 +C Change\szipfile\sto\sbe\sa\sWITHOUT\sROWID\svirtual\stable\sand\stable-valued\sfunction. +D 2018-01-11T17:33:48.340 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c cbf9dfaf94c25dfd835e79c1474fdc75517a45a37916dec66623b0937af10e51 +F ext/misc/zipfile.c e42d3ae79511ee86545bed07e9e5e7321f8139b55cdf73f60849352070bf12ad F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1599,7 +1599,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e -F test/zipfile.test e7132ca60031ca5d1df684cf644952bb3f253de3671a5b502780c5de3126a453 +F test/zipfile.test a5cd98e91aebf343e21a32b97fadd6aefe02d249d5c6a1a3c2e624b88d7bdbe2 F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1698,7 +1698,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4f68bed3b9a63a349a2a2d7f26609491577e9717034ad86af404cf9eed9d6aaf -R b4712b12dc6463238ee69f57e3b3a2cb +P 407b5ed35c178bb0dbc69c8b902652038a0653d55a58a7543f9d4857c6baf3ea +R 6ae1fe2ba1a1ad2ab58089676c32c82f U dan -Z e742283e882b3ab287b40d1d09763224 +Z df7413e90ffcbb11e6d9a408fc886735 diff --git a/manifest.uuid b/manifest.uuid index 0d3f74a2d6..91e729e259 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -407b5ed35c178bb0dbc69c8b902652038a0653d55a58a7543f9d4857c6baf3ea \ No newline at end of file +931201f64e04247ed613a0301fcc86c3a337c2ed162c6370a80c67a1dd919e7c \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index df02797bd8..fe1ad89c55 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -27,7 +27,7 @@ do_execsql_test 1.0 { CREATE VIRTUAL TABLE temp.zz USING zipfile('test.zip'); PRAGMA table_info(zz); } { - 0 name {} 0 {} 0 + 0 name {} 1 {} 1 1 mode {} 0 {} 0 2 mtime {} 0 {} 0 3 sz {} 0 {} 0 @@ -160,6 +160,10 @@ foreach {tn fname} { } {1 {constraint failed}} } +do_catchsql_test 3.2 { + SELECT rowid FROM x1 +} {1 {no such column: rowid}} + finish_test From f225059b8b674af30beeaf557873f7bb32d45ad4 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 12 Jan 2018 12:02:02 +0000 Subject: [PATCH 115/190] Add a test to ensure that the sqlite3changeset_apply() function ignores tables that do not have the expected primary keys. FossilOrigin-Name: bf2daf06279e46bc37cc92ad1becec1b12d2aa804a14b101fca8b3a7fdb280c3 --- ext/session/sessionG.test | 34 ++++++++++++++++++++++++++++++++++ manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/ext/session/sessionG.test b/ext/session/sessionG.test index 5c057350e4..2b6c0410a7 100644 --- a/ext/session/sessionG.test +++ b/ext/session/sessionG.test @@ -173,5 +173,39 @@ do_test 4.3 { compare_db db db2 } {} +#------------------------------------------------------------------------- +reset_db +catch { db2 close } +forcedelete test.db2 +sqlite3 db2 test.db2 + +do_execsql_test 5.0.1 { + CREATE TABLE t1(a PRIMARY KEY, b, c); + CREATE TABLE t2(a, b, c PRIMARY KEY); + CREATE TABLE t3(a, b PRIMARY KEY, c); +} +do_execsql_test -db db2 5.0.2 { + CREATE TABLE t1(a PRIMARY KEY, b, c); + CREATE TABLE t2(a, b, c); + CREATE TABLE t3(a, b PRIMARY KEY, c); +} + +do_test 5.1 { + do_then_apply_sql { + INSERT INTO t1 VALUES(1, 2, 3); + INSERT INTO t2 VALUES(4, 5, 6); + INSERT INTO t3 VALUES(7, 8, 9); + } + + db2 eval { + SELECT * FROM t1; + SELECT * FROM t2; + SELECT * FROM t3; + } +} {1 2 3 7 8 9} + + + + finish_test diff --git a/manifest b/manifest index e13040d2fc..628128b51f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_vtab_nochange()\sinterface.\s\sTest\scases\sare\sin\sTH3. -D 2018-01-11T18:15:40.111 +C Add\sa\stest\sto\sensure\sthat\sthe\ssqlite3changeset_apply()\sfunction\signores\stables\nthat\sdo\snot\shave\sthe\sexpected\sprimary\skeys. +D 2018-01-12T12:02:02.075 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -390,7 +390,7 @@ F ext/session/sessionC.test 97556f5164ac29f2344b24bd7de6a3a35a95c390 F ext/session/sessionD.test d4744c78334162851d2a2f285c7e603e31b49aa2 F ext/session/sessionE.test 0a616c4ad8fd2c05f23217ebb6212ef80b7fef30f5f086a6633a081f93e84637 F ext/session/sessionF.test c2f178d4dfd723a5fd94a730ea2ccb44c669e3ce -F ext/session/sessionG.test 01ef705096a9d3984eebdcca79807a211dee1b60 +F ext/session/sessionG.test 63f9a744341d670775af29e4f19c1ef09a4810798400f28cd76704803a2e56ff F ext/session/session_common.tcl 7776eda579773113b30c7abfd4545c445228cb73 F ext/session/session_speed_test.c edc1f96fd5e0e4b16eb03e2a73041013d59e8723 F ext/session/sessionat.test feb7d22b3124882064b9d9df69f5484a9bb8c123dc9ddc6ffcd357521848139f @@ -1698,8 +1698,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 931201f64e04247ed613a0301fcc86c3a337c2ed162c6370a80c67a1dd919e7c d444b1ff39f0a1673a977b8047e1e14a49d461c9934be080d27c2392a830c1c0 -R 9b5e5f478942b3c80eb44a5edc905e08 -T +closed d444b1ff39f0a1673a977b8047e1e14a49d461c9934be080d27c2392a830c1c0 -U drh -Z 90bbe9ce2100212cdce59fb9703ab09f +P a5d09dfaa337fa51d6e702c6aefe58824ab1e7d221c6e79166e2c6f9c7ab1501 +R 180a0996d52ee7f7f835ebd96e9ccca1 +U dan +Z 12f762acfd5b059fba2b906c66463308 diff --git a/manifest.uuid b/manifest.uuid index dea0f276ff..5e594f1a72 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a5d09dfaa337fa51d6e702c6aefe58824ab1e7d221c6e79166e2c6f9c7ab1501 \ No newline at end of file +bf2daf06279e46bc37cc92ad1becec1b12d2aa804a14b101fca8b3a7fdb280c3 \ No newline at end of file From 6ac7303e1ab5e0b224124e1c8f180cfa4d491e03 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 12 Jan 2018 14:34:45 +0000 Subject: [PATCH 116/190] Always use utimes() instead of utimensat() since the latter is not available even on some recent unix systems. FossilOrigin-Name: 30ed7a4b6408f0ca921abc4d8b7bb5404fc7708cedcd104b017b361054e7148c --- ext/misc/fileio.c | 3 ++- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index f126a2e435..7035889482 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -86,6 +86,7 @@ SQLITE_EXTENSION_INIT1 # include # include # include +# include #else # include "windows.h" # include @@ -285,7 +286,7 @@ static int writeFile( }else{ return 1; } -#elif defined(AT_FDCWD) +#elif defined(AT_FDCWD) && 0 /* utimensat() is not univerally available */ /* Recent unix */ struct timespec times[2]; times[0].tv_nsec = times[1].tv_nsec = 0; diff --git a/manifest b/manifest index 628128b51f..59bb960e32 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\sto\sensure\sthat\sthe\ssqlite3changeset_apply()\sfunction\signores\stables\nthat\sdo\snot\shave\sthe\sexpected\sprimary\skeys. -D 2018-01-12T12:02:02.075 +C Always\suse\sutimes()\sinstead\sof\sutimensat()\ssince\sthe\slatter\sis\snot\savailable\neven\son\ssome\srecent\sunix\ssystems. +D 2018-01-12T14:34:45.816 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -277,7 +277,7 @@ F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f0 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 1194228c96d6b7a374e93602e2ba1899b42d0fc4d4c5253962fb13e1c9ed1f77 +F ext/misc/fileio.c 777c13f00b4505df3bfab602568c98d2b067f7d1d265de88160d0f1ac92f3dcf F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -1698,7 +1698,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a5d09dfaa337fa51d6e702c6aefe58824ab1e7d221c6e79166e2c6f9c7ab1501 -R 180a0996d52ee7f7f835ebd96e9ccca1 -U dan -Z 12f762acfd5b059fba2b906c66463308 +P bf2daf06279e46bc37cc92ad1becec1b12d2aa804a14b101fca8b3a7fdb280c3 +R 2f0bebc7abfba03f2a023e68e468fd71 +U drh +Z 3cf98027077857228d4585915175b98d diff --git a/manifest.uuid b/manifest.uuid index 5e594f1a72..95795ed262 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf2daf06279e46bc37cc92ad1becec1b12d2aa804a14b101fca8b3a7fdb280c3 \ No newline at end of file +30ed7a4b6408f0ca921abc4d8b7bb5404fc7708cedcd104b017b361054e7148c \ No newline at end of file From 614efe2b4b42f58968e59a4ae69ff78151adc6d5 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 12 Jan 2018 16:44:29 +0000 Subject: [PATCH 117/190] Experimental change to include changes made to the sqlite_stat1 table in changesets generated by the sessions module. sqlite_stat1 entries in such changesets are ignored by legacy clients. FossilOrigin-Name: bd46c4429693545eb16db85692fc591ac529796aa746f5f21df1ce4380619320 --- ext/session/sessionstat1.test | 125 ++++++++++++++++++++++++++++++++++ ext/session/sqlite3session.c | 11 ++- manifest | 28 ++++---- manifest.uuid | 2 +- src/analyze.c | 22 ++++++ src/delete.c | 2 +- src/vdbe.c | 3 +- src/vdbe.h | 1 + src/vdbeaux.c | 2 + test/hook.test | 51 ++++++++++++++ 10 files changed, 231 insertions(+), 16 deletions(-) create mode 100644 ext/session/sessionstat1.test diff --git a/ext/session/sessionstat1.test b/ext/session/sessionstat1.test new file mode 100644 index 0000000000..47bbda15a9 --- /dev/null +++ b/ext/session/sessionstat1.test @@ -0,0 +1,125 @@ +# 2018 January 12 +# +# 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. +# +#*********************************************************************** +# + +if {![info exists testdir]} { + set testdir [file join [file dirname [info script]] .. .. test] +} +source [file join [file dirname [info script]] session_common.tcl] +source $testdir/tester.tcl +ifcapable !session {finish_test; return} + +set testprefix sessionstat1 + +do_execsql_test 1.0 { + CREATE TABLE t1(a PRIMARY KEY, b, c); + CREATE INDEX t1b ON t1(b); + CREATE INDEX t1c ON t1(c); + + WITH s(i) AS ( + SELECT 0 UNION ALL SELECT i+1 FROM s WHERE (i+1)<32 + ) + INSERT INTO t1 SELECT i, i%8, i%2 FROM s; +} + +do_iterator_test 1.1 {} { + ANALYZE +} { + {INSERT sqlite_stat1 0 XX. {} {t t1 t sqlite_autoindex_t1_1 t {32 1}}} + {INSERT sqlite_stat1 0 XX. {} {t t1 t t1b t {32 4}}} + {INSERT sqlite_stat1 0 XX. {} {t t1 t t1c t {32 16}}} +} + +do_execsql_test 1.2 { + WITH s(i) AS ( + SELECT 32 UNION ALL SELECT i+1 FROM s WHERE (i+1)<64 + ) + INSERT INTO t1 SELECT i, i%8, i%2 FROM s; +} + +do_iterator_test 1.3 {} { + ANALYZE +} { + {UPDATE sqlite_stat1 0 XX. {t t1 t sqlite_autoindex_t1_1 t {32 1}} {{} {} {} {} t {64 1}}} + {UPDATE sqlite_stat1 0 XX. {t t1 t t1b t {32 4}} {{} {} {} {} t {64 8}}} + {UPDATE sqlite_stat1 0 XX. {t t1 t t1c t {32 16}} {{} {} {} {} t {64 32}}} +} + +do_iterator_test 1.5 {} { + DROP INDEX t1b; +} { + {DELETE sqlite_stat1 0 XX. {t t1 t t1b t {64 8}} {}} +} + +do_iterator_test 1.6 {} { + DROP TABLE t1; +} { + {DELETE sqlite_stat1 0 XX. {t t1 t sqlite_autoindex_t1_1 t {64 1}} {}} + {DELETE sqlite_stat1 0 XX. {t t1 t t1c t {64 32}} {}} +} + +#------------------------------------------------------------------------- +# +catch { db2 close } +forcedelete test.db2 +sqlite3 db2 test.db2 + +do_test 2.0 { + do_common_sql { + CREATE TABLE t1(a PRIMARY KEY, b, c); + CREATE INDEX t1b ON t1(b); + CREATE INDEX t1c ON t1(c); + ANALYZE; + } +} {} + +do_test 2.1 { + do_then_apply_sql { + WITH s(i) AS ( + SELECT 0 UNION ALL SELECT i+1 FROM s WHERE (i+1)<32 + ) + INSERT INTO t1 SELECT i, i%8, i%2 FROM s; + ANALYZE; + } +} {} + +do_execsql_test -db db2 2.2 { + SELECT * FROM sqlite_stat1 +} { + t1 sqlite_autoindex_t1_1 {32 1} + t1 t1b {32 4} + t1 t1c {32 16} +} + +do_test 2.3 { + do_then_apply_sql { DROP INDEX t1c } +} {} + +do_execsql_test -db db2 2.4 { + SELECT * FROM sqlite_stat1 +} { + t1 sqlite_autoindex_t1_1 {32 1} + t1 t1b {32 4} +} + +do_test 2.3 { + do_then_apply_sql { DROP TABLE t1 } +} {} + +do_execsql_test -db db2 2.4 { + SELECT * FROM sqlite_stat1 +} { +} + +do_execsql_test -db db2 2.4 { SELECT count(*) FROM t1 } 32 + +finish_test + diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index d5cb467374..ffaa4c98b0 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -944,7 +944,16 @@ static int sessionTableInfo( assert( pazCol && pabPK ); nThis = sqlite3Strlen30(zThis); - zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); + if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){ + /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */ + zPragma = sqlite3_mprintf( + "SELECT 0, 'tbl', '', 0, '', 1 UNION ALL " + "SELECT 1, 'idx', '', 0, '', 2 UNION ALL " + "SELECT 2, 'stat', '', 0, '', 0" + ); + }else{ + zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); + } if( !zPragma ) return SQLITE_NOMEM; rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0); diff --git a/manifest b/manifest index 628128b51f..7e21810e82 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\sto\sensure\sthat\sthe\ssqlite3changeset_apply()\sfunction\signores\stables\nthat\sdo\snot\shave\sthe\sexpected\sprimary\skeys. -D 2018-01-12T12:02:02.075 +C Experimental\schange\sto\sinclude\schanges\smade\sto\sthe\ssqlite_stat1\stable\sin\nchangesets\sgenerated\sby\sthe\ssessions\smodule.\ssqlite_stat1\sentries\sin\ssuch\nchangesets\sare\signored\sby\slegacy\sclients. +D 2018-01-12T16:44:29.077 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -397,8 +397,9 @@ F ext/session/sessionat.test feb7d22b3124882064b9d9df69f5484a9bb8c123dc9ddc6ffcd F ext/session/sessiondiff.test ad13dd65664bae26744e1f18eb3cbd5588349b7e9118851d8f9364248d67bcec F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 +F ext/session/sessionstat1.test a361997e6ea72d427cb4b1313226b56278b9c74d3045817c33c99de5bef0f2e9 F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc -F ext/session/sqlite3session.c cc127222a9ea6f4eaa31281aa9da924f5244f6099be0ee526c950684fb3513a6 +F ext/session/sqlite3session.c 604aa21fa17c161a982595ec76c533add0e3f02ad7fb48bd4ece59335901a421 F ext/session/sqlite3session.h cb4d860101ba6d3ac810f18684539b766d24d668fa2436cdde90d711af9464fb F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 @@ -420,7 +421,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c cf7a8af45cb0ace672f47a1b29ab24092a9e8cd8d945a9974e3b5d925f548594 -F src/analyze.c 0d0ccf7520a201d8747ea2f02c92c26e26f801bc161f714f27b9f7630dde0421 +F src/analyze.c f9bfffd0416c547a916cb96793b94684bdb0d26a71542ea31819c6757741c19d F src/attach.c 84c477e856b24c2b9a0983b438a707c0cf4d616cee7a425401d418e58afec24c F src/auth.c 6277d63837357549fe14e723490d6dc1a38768d71c795c5eb5c0f8a99f918f73 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b @@ -436,7 +437,7 @@ F src/ctime.c ff1be3eed7bdd75aaca61ca8dc848f7c9f850ef2fb9cb56f2734e922a098f9c0 F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957 F src/dbpage.c 8db4c97f630e7d83f884ea75caf1ffd0988c160e9d530194d93721c80821e0f6 F src/dbstat.c 7a4ba8518b6369ef3600c49cf9c918ad979acba610b2aebef1b656d649b96720 -F src/delete.c 74667ad914ac143731a444a1bacf29ceb18f6eded8a0dd17aafae80baa07f8bb +F src/delete.c 20c8788451dc737a967c87ea53ad43544d617f5b57d32ccce8bd52a0daf9e89b F src/expr.c ad6e7a9c34a4bab9d10cc857d647ae7ce370a633b5c0bfa71f1c29b81ae364b8 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c d617daf66b5515e2b42c1405b2b4984c30ca50fb705ab164271a9bf66c69e331 @@ -553,11 +554,11 @@ F src/update.c 8bd52c38d6d426925be4488ee106db26d9ee344406315671ed246ddace8d6091 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/util.c 7315e97a8dc2c8e19ca64196c652cf0a65d13fd0a211b2cec082062372dc6261 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 -F src/vdbe.c 4d0666741d884dfaceb6ac5bbededbd947068e4b742163898feea84a027dace6 -F src/vdbe.h d50cadf12bcf9fb99117ef392ce1ea283aa429270481426b6e8b0280c101fd97 +F src/vdbe.c 5d83f28acbce72f3bb35917c75c34131022010f0a54dbd5ae2cbbf21f08c38c1 +F src/vdbe.h 134beb7a12a6213c00eba58febaede33447cc4441bc568a0d9c144b33fc3720a F src/vdbeInt.h a0969c14950bcc61b2dfa19c6f62b42c5012013fcda342ca927a192ed37e6592 F src/vdbeapi.c f519346f6db99a1eb3f85ca3ae8aede9ff9c4d90fec809dae7cb946786b2e270 -F src/vdbeaux.c 7ae48b180e5dd5d282e6752d155f1ab7929196d8e6577b82742044188152ca85 +F src/vdbeaux.c 7d635c30e55196ee8e0af605aceab0c3036ed6d6ed55dd6639c4b2a2a4593b4f F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191 F src/vdbemem.c 8478f7fb1948bf8fdeec7c2cb59ea58155c31258b9cd43c56d485e03ed40bd07 F src/vdbesort.c 731a09e5cb9e96b70c394c1b7cf3860fbe84acca7682e178615eb941a3a0ef2f @@ -944,7 +945,7 @@ F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 F test/having.test e4098a4b8962f9596035c3b87a8928a10648acc509f1bb8d6f96413bbf79a1b3 F test/hexlit.test 4a6a5f46e3c65c4bf1fa06f5dd5a9507a5627751 F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711 -F test/hook.test dbc0b87756e1e20e7497b56889c9e9cd2f8cc2b5 +F test/hook.test 1604b3b2f5931430087540404555c1b6be3618600b81558657c66b533ed70b13 F test/hook2.test b9ff3b8c6519fb67f33192f1afe86e7782ee4ac8 F test/icu.test 41aa8847745a879b897a7febea0f8f9efc8e67fe8bf680589b6e07c7b0a1569a F test/ieee754.test 806fc0ce7f305f57e3331eaceeddcfec9339e607 @@ -1698,7 +1699,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a5d09dfaa337fa51d6e702c6aefe58824ab1e7d221c6e79166e2c6f9c7ab1501 -R 180a0996d52ee7f7f835ebd96e9ccca1 +P bf2daf06279e46bc37cc92ad1becec1b12d2aa804a14b101fca8b3a7fdb280c3 +R df0683427f9c775029b8cffecc77e29c +T *branch * sessions-stat1 +T *sym-sessions-stat1 * +T -sym-trunk * U dan -Z 12f762acfd5b059fba2b906c66463308 +Z e2d0263dd242b14c8f682e74527ab3ca diff --git a/manifest.uuid b/manifest.uuid index 5e594f1a72..00b7d3d5a5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf2daf06279e46bc37cc92ad1becec1b12d2aa804a14b101fca8b3a7fdb280c3 \ No newline at end of file +bd46c4429693545eb16db85692fc591ac529796aa746f5f21df1ce4380619320 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 495cc954ac..85c603ffdf 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -234,6 +234,10 @@ static void openStatTable( "DELETE FROM %Q.%s WHERE %s=%Q", pDb->zDbSName, zTab, zWhereType, zWhere ); +#ifdef SQLITE_ENABLE_PREUPDATE_HOOK + }else if( db->xPreUpdateCallback ){ + sqlite3NestedParse(pParse, "DELETE FROM %Q.%s", pDb->zDbSName, zTab); +#endif }else{ /* The sqlite_stat[134] table already exists. Delete all rows. */ sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb); @@ -998,6 +1002,9 @@ static void analyzeOneTable( int regIdxname = iMem++; /* Register containing index name */ int regStat1 = iMem++; /* Value for the stat column of sqlite_stat1 */ int regPrev = iMem; /* MUST BE LAST (see below) */ +#ifdef SQLITE_ENABLE_PREUPDATE_HOOK + Table *pStat1 = 0; +#endif pParse->nMem = MAX(pParse->nMem, iMem); v = sqlite3GetVdbe(pParse); @@ -1023,6 +1030,18 @@ static void analyzeOneTable( } #endif +#ifdef SQLITE_ENABLE_PREUPDATE_HOOK + if( db->xPreUpdateCallback ){ + pStat1 = (Table*)sqlite3DbMallocZero(db, sizeof(Table) + 13); + if( pStat1==0 ) return; + pStat1->zName = (char*)&pStat1[1]; + memcpy(pStat1->zName, "sqlite_stat1", 13); + pStat1->nCol = 3; + pStat1->iPKey = -1; + sqlite3VdbeAddOp4(pParse->pVdbe, OP_Noop, 0, 0, 0,(char*)pStat1,P4_DYNBLOB); + } +#endif + /* Establish a read-lock on the table at the shared-cache level. ** Open a read-only cursor on the table. Also allocate a cursor number ** to use for scanning indexes (iIdxCur). No index cursor is opened at @@ -1224,6 +1243,9 @@ static void analyzeOneTable( sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, "BBB", 0); sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid); +#ifdef SQLITE_ENABLE_PREUPDATE_HOOK + sqlite3VdbeChangeP4(v, -1, (char*)pStat1, P4_TABLE); +#endif sqlite3VdbeChangeP5(v, OPFLAG_APPEND); /* Add the entries to the stat3 or stat4 table. */ diff --git a/src/delete.c b/src/delete.c index 5808ac51d4..2b69e4763a 100644 --- a/src/delete.c +++ b/src/delete.c @@ -760,7 +760,7 @@ void sqlite3GenerateRowDelete( u8 p5 = 0; sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek); sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0)); - if( pParse->nested==0 ){ + if( pParse->nested==0 || 0==sqlite3_stricmp(pTab->zName, "sqlite_stat1") ){ sqlite3VdbeAppendP4(v, (char*)pTab, P4_TABLE); } if( eMode!=ONEPASS_OFF ){ diff --git a/src/vdbe.c b/src/vdbe.c index b00174bb10..f5112e0daa 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4483,7 +4483,8 @@ case OP_InsertInt: { /* Invoke the update-hook if required. */ if( rc ) goto abort_due_to_error; - if( db->xUpdateCallback && op ){ + assert( !op || pTab->aCol || !sqlite3_stricmp(pTab->zName,"sqlite_stat1") ); + if( db->xUpdateCallback && op && pTab->aCol ){ db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey); } break; diff --git a/src/vdbe.h b/src/vdbe.h index 3e77eb9db5..f002e05d81 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -127,6 +127,7 @@ typedef struct VdbeOpList VdbeOpList; #define P4_INT64 (-14) /* P4 is a 64-bit signed integer */ #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */ #define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */ +#define P4_DYNBLOB (-17) /* Pointer to memory from sqliteMalloc() */ /* Error message codes for OP_Halt */ #define P5_ConstraintNotNull 1 diff --git a/src/vdbeaux.c b/src/vdbeaux.c index bc4bbda8e4..1780d37b8c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -866,6 +866,7 @@ static void freeP4(sqlite3 *db, int p4type, void *p4){ case P4_REAL: case P4_INT64: case P4_DYNAMIC: + case P4_DYNBLOB: case P4_INTARRAY: { sqlite3DbFree(db, p4); break; @@ -1407,6 +1408,7 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){ sqlite3XPrintf(&x, "program"); break; } + case P4_DYNBLOB: case P4_ADVANCE: { zTemp[0] = 0; break; diff --git a/test/hook.test b/test/hook.test index 9ba220cded..1c9145baef 100644 --- a/test/hook.test +++ b/test/hook.test @@ -906,5 +906,56 @@ do_preupdate_test 10.3 { DELETE FROM t3 WHERE b=1 } {DELETE main t3 1 1 0 {} 1} +#------------------------------------------------------------------------- +# Test that the "update" hook is not fired for operations on the +# sqlite_stat1 table performed by ANALYZE, even if a pre-update hook is +# registered. +ifcapable analyze { + reset_db + do_execsql_test 11.1 { + CREATE TABLE t1(a, b); + CREATE INDEX idx1 ON t1(a); + CREATE INDEX idx2 ON t1(b); + + INSERT INTO t1 VALUES(1, 2); + INSERT INTO t1 VALUES(3, 4); + INSERT INTO t1 VALUES(5, 6); + INSERT INTO t1 VALUES(7, 8); + } + + db preupdate hook preupdate_cb + db update_hook update_cb + + proc preupdate_cb {args} { lappend ::res "preupdate" $args } + proc update_cb {args} { lappend ::res "update" $args } + + set ::res [list] + do_test 11.2 { + execsql ANALYZE + set ::res + } [list {*}{ + preupdate {INSERT main sqlite_stat1 1 1} + preupdate {INSERT main sqlite_stat1 2 2} + }] + + do_execsql_test 11.3 { + INSERT INTO t1 VALUES(9, 10); + INSERT INTO t1 VALUES(11, 12); + INSERT INTO t1 VALUES(13, 14); + INSERT INTO t1 VALUES(15, 16); + } + + set ::res [list] + do_test 11.4 { + execsql ANALYZE + set ::res + } [list {*}{ + preupdate {DELETE main sqlite_stat1 1 1} + preupdate {DELETE main sqlite_stat1 2 2} + preupdate {INSERT main sqlite_stat1 1 1} + preupdate {INSERT main sqlite_stat1 2 2} + }] +} + finish_test From 3f975373cea89cd3a1fd81a06064a5188e7cfefe Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 12 Jan 2018 18:03:38 +0000 Subject: [PATCH 118/190] Fix obsolete comments. No changes to code. FossilOrigin-Name: ec39c99bea024ffce9b87bbf3d80087ff772f43f7fb7e238754c364f7db2a17b --- ext/session/sqlite3session.c | 8 ++------ manifest | 15 +++++++-------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index ffaa4c98b0..de27acd0db 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -894,9 +894,7 @@ static int sessionGrowHash(int bPatchset, SessionTable *pTab){ /* ** This function queries the database for the names of the columns of table -** zThis, in schema zDb. It is expected that the table has nCol columns. If -** not, SQLITE_SCHEMA is returned and none of the output variables are -** populated. +** zThis, in schema zDb. ** ** Otherwise, if they are not NULL, variable *pnCol is set to the number ** of columns in the database table and variable *pzTab is set to point to a @@ -917,9 +915,7 @@ static int sessionGrowHash(int bPatchset, SessionTable *pTab){ ** *pabPK = {1, 0, 0, 1} ** ** All returned buffers are part of the same single allocation, which must -** be freed using sqlite3_free() by the caller. If pazCol was not NULL, then -** pointer *pazCol should be freed to release all memory. Otherwise, pointer -** *pabPK. It is illegal for both pazCol and pabPK to be NULL. +** be freed using sqlite3_free() by the caller */ static int sessionTableInfo( sqlite3 *db, /* Database connection */ diff --git a/manifest b/manifest index 1218593ff5..b928840625 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Include\schanges\smade\sto\sthe\ssqlite_stat1\stable\sin\schangesets\ngenerated\sby\sthe\ssessions\smodule.\ssqlite_stat1\sentries\sin\ssuch\schangesets\sare\nignored\sby\slegacy\sclients. -D 2018-01-12T17:25:25.310 +C Fix\sobsolete\scomments.\s\sNo\schanges\sto\scode. +D 2018-01-12T18:03:38.307 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -399,7 +399,7 @@ F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sessionstat1.test a361997e6ea72d427cb4b1313226b56278b9c74d3045817c33c99de5bef0f2e9 F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc -F ext/session/sqlite3session.c 604aa21fa17c161a982595ec76c533add0e3f02ad7fb48bd4ece59335901a421 +F ext/session/sqlite3session.c 0153359f97800a7dddf1c06f4b18d78dd4b233c96bc3e2e63879a71fc80a4b09 F ext/session/sqlite3session.h cb4d860101ba6d3ac810f18684539b766d24d668fa2436cdde90d711af9464fb F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 @@ -1699,8 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 30ed7a4b6408f0ca921abc4d8b7bb5404fc7708cedcd104b017b361054e7148c bd46c4429693545eb16db85692fc591ac529796aa746f5f21df1ce4380619320 -R 45cb3eae3cd802c11970c064766b4af9 -T +closed bd46c4429693545eb16db85692fc591ac529796aa746f5f21df1ce4380619320 -U dan -Z f2dd6a8e929126a4d6fd50f30c0d0ed2 +P 2064233533edec0308d0212fb08e72fd14c760a1c88452424cae298e9eaf4af8 +R 3e8aedeebf1827d98e1081cfd8339e33 +U drh +Z 59c372a6dec67f6ff695d342429f4b78 diff --git a/manifest.uuid b/manifest.uuid index 72de6258fe..7b4544545f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2064233533edec0308d0212fb08e72fd14c760a1c88452424cae298e9eaf4af8 \ No newline at end of file +ec39c99bea024ffce9b87bbf3d80087ff772f43f7fb7e238754c364f7db2a17b \ No newline at end of file From 84ebe2b303f61d0ee99c560f802aec7cbf8a1cdd Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 12 Jan 2018 18:46:52 +0000 Subject: [PATCH 119/190] Avoid an unnecessary branch when not using pre-update hooks. FossilOrigin-Name: ec96707eb359c7e0597ee22e5ae017774366463dffa6bdb06e4438b09549f5c0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 17 ++++++++++------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index b928840625..c7f4c5f847 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sobsolete\scomments.\s\sNo\schanges\sto\scode. -D 2018-01-12T18:03:38.307 +C Avoid\san\sunnecessary\sbranch\swhen\snot\susing\spre-update\shooks. +D 2018-01-12T18:46:52.041 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -554,7 +554,7 @@ F src/update.c 8bd52c38d6d426925be4488ee106db26d9ee344406315671ed246ddace8d6091 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/util.c 7315e97a8dc2c8e19ca64196c652cf0a65d13fd0a211b2cec082062372dc6261 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 -F src/vdbe.c 5d83f28acbce72f3bb35917c75c34131022010f0a54dbd5ae2cbbf21f08c38c1 +F src/vdbe.c a7d0f8312eea5c2084349f0ea13b25fa7ecdb3606d8aab393d4a98ca7ac4c62b F src/vdbe.h 134beb7a12a6213c00eba58febaede33447cc4441bc568a0d9c144b33fc3720a F src/vdbeInt.h a0969c14950bcc61b2dfa19c6f62b42c5012013fcda342ca927a192ed37e6592 F src/vdbeapi.c f519346f6db99a1eb3f85ca3ae8aede9ff9c4d90fec809dae7cb946786b2e270 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2064233533edec0308d0212fb08e72fd14c760a1c88452424cae298e9eaf4af8 -R 3e8aedeebf1827d98e1081cfd8339e33 +P ec39c99bea024ffce9b87bbf3d80087ff772f43f7fb7e238754c364f7db2a17b +R 639f4697487bdd2e7953131ba8eccf21 U drh -Z 59c372a6dec67f6ff695d342429f4b78 +Z a0b90d4f07f3f08da8d3bc6f5ca171c6 diff --git a/manifest.uuid b/manifest.uuid index 7b4544545f..c70f198da6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ec39c99bea024ffce9b87bbf3d80087ff772f43f7fb7e238754c364f7db2a17b \ No newline at end of file +ec96707eb359c7e0597ee22e5ae017774366463dffa6bdb06e4438b09549f5c0 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index f5112e0daa..5a3908cda6 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4454,11 +4454,14 @@ case OP_InsertInt: { #ifdef SQLITE_ENABLE_PREUPDATE_HOOK /* Invoke the pre-update hook, if any */ - if( db->xPreUpdateCallback - && pOp->p4type==P4_TABLE - && !(pOp->p5 & OPFLAG_ISUPDATE) - ){ - sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey, pOp->p2); + if( pOp->p4type==P4_TABLE ){ + if( db->xPreUpdateCallback && !(pOp->p5 & OPFLAG_ISUPDATE) ){ + sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey,pOp->p2); + } + if( op && pTab->aCol==0 ){ + assert( sqlite3_stricmp(pTab->zName, "sqlite_stat1")==0 ); + op = 0; + } } if( pOp->p5 & OPFLAG_ISNOOP ) break; #endif @@ -4483,8 +4486,8 @@ case OP_InsertInt: { /* Invoke the update-hook if required. */ if( rc ) goto abort_due_to_error; - assert( !op || pTab->aCol || !sqlite3_stricmp(pTab->zName,"sqlite_stat1") ); - if( db->xUpdateCallback && op && pTab->aCol ){ + if( db->xUpdateCallback && op ){ + assert( pTab->aCol ); db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey); } break; From 5871318407de833aefbc8721b3a3c1a2e574f512 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 12 Jan 2018 19:20:15 +0000 Subject: [PATCH 120/190] Fix error handling in sqlite3session_diff() when it is invoked for table "sqlite_stat1". FossilOrigin-Name: 874285e477dd9bd164e25ddb08b6b80daaa8cfd111b4180ecce59b1ce26f77a5 --- ext/session/sessionD.test | 33 +++++++++++++++++++++++++++++++++ ext/session/sessionstat1.test | 2 +- ext/session/sqlite3session.c | 20 +++++++++++++------- manifest | 18 +++++++++--------- manifest.uuid | 2 +- 5 files changed, 57 insertions(+), 18 deletions(-) diff --git a/ext/session/sessionD.test b/ext/session/sessionD.test index b8572782e2..84c31cbc2f 100644 --- a/ext/session/sessionD.test +++ b/ext/session/sessionD.test @@ -221,5 +221,38 @@ do_test 4.2.2 { } {1 {SQLITE_SCHEMA - table schemas do not match}} S delete +do_test 4.3.1 { + sqlite3session S db main + S attach t4 + execsql { CREATE TABLE t4(i PRIMARY KEY, b) } + list [catch { S diff ixua t4 } msg] $msg +} {1 {SQLITE_SCHEMA - table schemas do not match}} +S delete +do_catchsql_test 4.3.2 { + SELECT * FROM ixua.t4; +} {1 {no such table: ixua.t4}} + +do_test 4.4.1 { + sqlite3session S db main + S attach sqlite_stat1 + execsql { ANALYZE } + execsql { DROP TABLE ixua.sqlite_stat1 } + list [catch { S diff ixua sqlite_stat1 } msg] $msg +} {1 {SQLITE_SCHEMA - table schemas do not match}} +S delete +do_catchsql_test 4.4.2 { + SELECT * FROM ixua.sqlite_stat1; +} {1 {no such table: ixua.sqlite_stat1}} + +do_test 4.5.1 { + sqlite3session S db main + S attach t8 + list [catch { S diff ixua t8 } msg] $msg +} {0 {}} +S delete +do_catchsql_test 4.5.2 { + SELECT * FROM ixua.i8; +} {1 {no such table: ixua.i8}} + finish_test diff --git a/ext/session/sessionstat1.test b/ext/session/sessionstat1.test index 47bbda15a9..59de1cf1b4 100644 --- a/ext/session/sessionstat1.test +++ b/ext/session/sessionstat1.test @@ -119,7 +119,7 @@ do_execsql_test -db db2 2.4 { } { } -do_execsql_test -db db2 2.4 { SELECT count(*) FROM t1 } 32 +do_execsql_test -db db2 2.5 { SELECT count(*) FROM t1 } 32 finish_test diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index de27acd0db..bd83ce87d3 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -941,12 +941,19 @@ static int sessionTableInfo( nThis = sqlite3Strlen30(zThis); if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){ - /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */ - zPragma = sqlite3_mprintf( - "SELECT 0, 'tbl', '', 0, '', 1 UNION ALL " - "SELECT 1, 'idx', '', 0, '', 2 UNION ALL " - "SELECT 2, 'stat', '', 0, '', 0" - ); + rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0); + if( rc==SQLITE_OK ){ + /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */ + zPragma = sqlite3_mprintf( + "SELECT 0, 'tbl', '', 0, '', 1 UNION ALL " + "SELECT 1, 'idx', '', 0, '', 2 UNION ALL " + "SELECT 2, 'stat', '', 0, '', 0" + ); + }else if( rc==SQLITE_ERROR ){ + zPragma = sqlite3_mprintf(""); + }else{ + return rc; + } }else{ zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); } @@ -1506,7 +1513,6 @@ int sqlite3session_diff( if( abPK[i] ) bHasPk = 1; } } - } sqlite3_free((char*)azCol); if( bMismatch ){ diff --git a/manifest b/manifest index c7f4c5f847..c35fcce386 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\san\sunnecessary\sbranch\swhen\snot\susing\spre-update\shooks. -D 2018-01-12T18:46:52.041 +C Fix\serror\shandling\sin\ssqlite3session_diff()\swhen\sit\sis\sinvoked\sfor\stable\n"sqlite_stat1". +D 2018-01-12T19:20:15.804 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -387,7 +387,7 @@ F ext/session/session9.test 5409d90d8141881d08285ed1c2c0d8d10fb92069 F ext/session/sessionA.test 1feeab0b8e03527f08f2f1defb442da25480138f F ext/session/sessionB.test 886252dcb7e692e62ef7e357456200912e367823 F ext/session/sessionC.test 97556f5164ac29f2344b24bd7de6a3a35a95c390 -F ext/session/sessionD.test d4744c78334162851d2a2f285c7e603e31b49aa2 +F ext/session/sessionD.test d3617e29aa15c9413aee5286d99587633245d58d2ad28f3f331c822735418a22 F ext/session/sessionE.test 0a616c4ad8fd2c05f23217ebb6212ef80b7fef30f5f086a6633a081f93e84637 F ext/session/sessionF.test c2f178d4dfd723a5fd94a730ea2ccb44c669e3ce F ext/session/sessionG.test 63f9a744341d670775af29e4f19c1ef09a4810798400f28cd76704803a2e56ff @@ -397,9 +397,9 @@ F ext/session/sessionat.test feb7d22b3124882064b9d9df69f5484a9bb8c123dc9ddc6ffcd F ext/session/sessiondiff.test ad13dd65664bae26744e1f18eb3cbd5588349b7e9118851d8f9364248d67bcec F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 -F ext/session/sessionstat1.test a361997e6ea72d427cb4b1313226b56278b9c74d3045817c33c99de5bef0f2e9 +F ext/session/sessionstat1.test e3a3f5876ce1526b48f6f447ee0b18960ac683e3fc891791e1ca0c08e823d498 F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc -F ext/session/sqlite3session.c 0153359f97800a7dddf1c06f4b18d78dd4b233c96bc3e2e63879a71fc80a4b09 +F ext/session/sqlite3session.c a18bfdab0de090597fb50aae734e2cd41bf5e5d394bbd9a2189308f2bc8525d5 F ext/session/sqlite3session.h cb4d860101ba6d3ac810f18684539b766d24d668fa2436cdde90d711af9464fb F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ec39c99bea024ffce9b87bbf3d80087ff772f43f7fb7e238754c364f7db2a17b -R 639f4697487bdd2e7953131ba8eccf21 -U drh -Z a0b90d4f07f3f08da8d3bc6f5ca171c6 +P ec96707eb359c7e0597ee22e5ae017774366463dffa6bdb06e4438b09549f5c0 +R 4a057707a8e14443ce6ba2a239747c3f +U dan +Z 642ce6373e880706da1a2277f3f81df3 diff --git a/manifest.uuid b/manifest.uuid index c70f198da6..660ff79469 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ec96707eb359c7e0597ee22e5ae017774366463dffa6bdb06e4438b09549f5c0 \ No newline at end of file +874285e477dd9bd164e25ddb08b6b80daaa8cfd111b4180ecce59b1ce26f77a5 \ No newline at end of file From 4ec6f3a075b8b0214f567e5fab7bf653e42eb31b Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 12 Jan 2018 19:33:18 +0000 Subject: [PATCH 121/190] Simplification to the implementation of OP_Insert. FossilOrigin-Name: 6acbdba59e9df4313a6232d925a70390acdc43dfa380b4fba7bb8bd442d6e728 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbe.c | 22 +++++++++++----------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index c35fcce386..d9b6cfb745 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\serror\shandling\sin\ssqlite3session_diff()\swhen\sit\sis\sinvoked\sfor\stable\n"sqlite_stat1". -D 2018-01-12T19:20:15.804 +C Simplification\sto\sthe\simplementation\sof\sOP_Insert. +D 2018-01-12T19:33:18.062 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -554,7 +554,7 @@ F src/update.c 8bd52c38d6d426925be4488ee106db26d9ee344406315671ed246ddace8d6091 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/util.c 7315e97a8dc2c8e19ca64196c652cf0a65d13fd0a211b2cec082062372dc6261 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 -F src/vdbe.c a7d0f8312eea5c2084349f0ea13b25fa7ecdb3606d8aab393d4a98ca7ac4c62b +F src/vdbe.c e660530c799acf41616200373cdaec7af3fce5a25de40d900e8319d50971df73 F src/vdbe.h 134beb7a12a6213c00eba58febaede33447cc4441bc568a0d9c144b33fc3720a F src/vdbeInt.h a0969c14950bcc61b2dfa19c6f62b42c5012013fcda342ca927a192ed37e6592 F src/vdbeapi.c f519346f6db99a1eb3f85ca3ae8aede9ff9c4d90fec809dae7cb946786b2e270 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ec96707eb359c7e0597ee22e5ae017774366463dffa6bdb06e4438b09549f5c0 -R 4a057707a8e14443ce6ba2a239747c3f -U dan -Z 642ce6373e880706da1a2277f3f81df3 +P 874285e477dd9bd164e25ddb08b6b80daaa8cfd111b4180ecce59b1ce26f77a5 +R 0ce0db05c5816c8a3f6d5399a0318468 +U drh +Z 101b1825b326975007694adf2a0d837c diff --git a/manifest.uuid b/manifest.uuid index 660ff79469..cf6d922bb8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -874285e477dd9bd164e25ddb08b6b80daaa8cfd111b4180ecce59b1ce26f77a5 \ No newline at end of file +6acbdba59e9df4313a6232d925a70390acdc43dfa380b4fba7bb8bd442d6e728 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 5a3908cda6..d66387d239 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4415,10 +4415,8 @@ case OP_InsertInt: { int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */ const char *zDb; /* database name - used by the update hook */ Table *pTab; /* Table structure - used by update and pre-update hooks */ - int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */ BtreePayload x; /* Payload to be inserted */ - op = 0; pData = &aMem[pOp->p2]; assert( pOp->p1>=0 && pOp->p1nCursor ); assert( memIsValid(pData) ); @@ -4446,21 +4444,20 @@ case OP_InsertInt: { zDb = db->aDb[pC->iDb].zDbSName; pTab = pOp->p4.pTab; assert( (pOp->p5 & OPFLAG_ISNOOP) || HasRowid(pTab) ); - op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT); }else{ - pTab = 0; /* Not needed. Silence a compiler warning. */ + pTab = 0; zDb = 0; /* Not needed. Silence a compiler warning. */ } #ifdef SQLITE_ENABLE_PREUPDATE_HOOK /* Invoke the pre-update hook, if any */ - if( pOp->p4type==P4_TABLE ){ + if( pTab ){ if( db->xPreUpdateCallback && !(pOp->p5 & OPFLAG_ISUPDATE) ){ sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey,pOp->p2); } - if( op && pTab->aCol==0 ){ - assert( sqlite3_stricmp(pTab->zName, "sqlite_stat1")==0 ); - op = 0; + if( db->xUpdateCallback==0 || pTab->aCol==0 ){ + /* Prevent post-update hook from running in cases when it should not */ + pTab = 0; } } if( pOp->p5 & OPFLAG_ISNOOP ) break; @@ -4486,9 +4483,12 @@ case OP_InsertInt: { /* Invoke the update-hook if required. */ if( rc ) goto abort_due_to_error; - if( db->xUpdateCallback && op ){ - assert( pTab->aCol ); - db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey); + if( pTab ){ + assert( db->xUpdateCallback!=0 ); + assert( pTab->aCol!=0 ); + db->xUpdateCallback(db->pUpdateArg, + (pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT, + zDb, pTab->zName, x.nKey); } break; } From ce2fbd1b029477fd8745ca6381cd0b264fd901c5 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 12 Jan 2018 21:00:14 +0000 Subject: [PATCH 122/190] Add the experimental sqlite3_value_nochange() interface usable by xUpdate methods of virtual tables to see if a column has actually changed values. FossilOrigin-Name: 8b7be15ece9e2e83959bb0e21e240106fe1077431242c3cc6b81f1baa2382f40 --- manifest | 27 +++++++++++++++------------ manifest.uuid | 2 +- src/sqlite.h.in | 7 +++++++ src/update.c | 4 +++- src/vdbe.c | 23 ++++++++++++++++------- src/vdbeInt.h | 2 ++ src/vdbeapi.c | 7 ++++++- src/vdbeaux.c | 6 +++++- src/vdbemem.c | 2 +- 9 files changed, 56 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index d9b6cfb745..c96606d8a9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sto\sthe\simplementation\sof\sOP_Insert. -D 2018-01-12T19:33:18.062 +C Add\sthe\sexperimental\ssqlite3_value_nochange()\sinterface\susable\sby\sxUpdate\nmethods\sof\svirtual\stables\sto\ssee\sif\sa\scolumn\shas\sactually\schanged\svalues. +D 2018-01-12T21:00:14.387 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -487,7 +487,7 @@ F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 F src/shell.c.in b87abffd0db09203ad8a133d56fe8f154ace5ec0a14197a153fb7d80b1438c01 -F src/sqlite.h.in f83e63a48fb31fefc69c83bbe8700b4b44acdd64e440219087b0f14e35eeb8d4 +F src/sqlite.h.in 8c9b7bf8f635c13371d8060061e83d19623c77e7e4430dff7713e47761d1b972 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 F src/sqliteInt.h fd8702c65994d7de3e2d8f7d85d958731da1ed29476571fdfa2290fd8ec0bf80 @@ -550,17 +550,17 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 5b0c661a85f783d35b9883830736eeb63be4aefc4f6b7d9cd081d48782c041e2 F src/treeview.c eae35972ff44f67064de2eaf35f04afe94e7aea3271a8b3bcebb3f954880fec3 F src/trigger.c a34539c69433276d37b0da9a89c117726ff2d292c0902895af1f393a983cd3a1 -F src/update.c 8bd52c38d6d426925be4488ee106db26d9ee344406315671ed246ddace8d6091 +F src/update.c 7736ffc60d9fdfaae4e294d76158c0a9f752b369ae2b22ef9fc800d08e0bf31e F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/util.c 7315e97a8dc2c8e19ca64196c652cf0a65d13fd0a211b2cec082062372dc6261 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 -F src/vdbe.c e660530c799acf41616200373cdaec7af3fce5a25de40d900e8319d50971df73 +F src/vdbe.c 07dd1909ceac146717cc248838ffe2f85165e50e468e6a0c378d840c1caf6e98 F src/vdbe.h 134beb7a12a6213c00eba58febaede33447cc4441bc568a0d9c144b33fc3720a -F src/vdbeInt.h a0969c14950bcc61b2dfa19c6f62b42c5012013fcda342ca927a192ed37e6592 -F src/vdbeapi.c f519346f6db99a1eb3f85ca3ae8aede9ff9c4d90fec809dae7cb946786b2e270 -F src/vdbeaux.c 7d635c30e55196ee8e0af605aceab0c3036ed6d6ed55dd6639c4b2a2a4593b4f +F src/vdbeInt.h 5442fc816b6cf19c8801724199fd6b77a02eb31a7a174021713f8c59b30e51fa +F src/vdbeapi.c 02f773681d06e46454b0606339068d4d4490873dc4a7334bc0c6030552bb2c8c +F src/vdbeaux.c fc124962c9900b19d201e57084a4302d07136a77f51fdbdfabd625a3ca3b6dc1 F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191 -F src/vdbemem.c 8478f7fb1948bf8fdeec7c2cb59ea58155c31258b9cd43c56d485e03ed40bd07 +F src/vdbemem.c 7548dd5af03d24d534a5dbc41e3bbdf1fab83e9c8856a8d2549ed2ccf33d0e80 F src/vdbesort.c 731a09e5cb9e96b70c394c1b7cf3860fbe84acca7682e178615eb941a3a0ef2f F src/vdbetrace.c 48e11ebe040c6b41d146abed2602e3d00d621d7ebe4eb29b0a0f1617fd3c2f6c F src/vtab.c 0e4885495172e1bdf54b12cce23b395ac74ef5729031f15e1bc1e3e6b360ed1a @@ -1699,7 +1699,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 874285e477dd9bd164e25ddb08b6b80daaa8cfd111b4180ecce59b1ce26f77a5 -R 0ce0db05c5816c8a3f6d5399a0318468 +P 6acbdba59e9df4313a6232d925a70390acdc43dfa380b4fba7bb8bd442d6e728 +R 6f0b4cb15335f84e55c45be4e670230a +T *branch * sqlite3_value_nochange +T *sym-sqlite3_value_nochange * +T -sym-trunk * U drh -Z 101b1825b326975007694adf2a0d837c +Z 9655b705be92f16dc668ac363b3cc0e3 diff --git a/manifest.uuid b/manifest.uuid index cf6d922bb8..7fcc0b51be 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6acbdba59e9df4313a6232d925a70390acdc43dfa380b4fba7bb8bd442d6e728 \ No newline at end of file +8b7be15ece9e2e83959bb0e21e240106fe1077431242c3cc6b81f1baa2382f40 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index ba673748ed..7579b9926d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4847,6 +4847,12 @@ SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), ** then the conversion is performed. Otherwise no conversion occurs. ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^ ** +** ^Within the [xUpdate] method of a [virtual table], the +** sqlite3_value_nochange(X) interface returns true if and only if +** the column corresponding to X is unchanged by the UPDATE operation +** and the [xColumn] method had previously queried [sqlite3_vtab_nochange()] +** for that column and returned a NULL as a result. +** ** Please pay particular attention to the fact that the pointer returned ** from [sqlite3_value_blob()], [sqlite3_value_text()], or ** [sqlite3_value_text16()] can be invalidated by a subsequent call to @@ -4869,6 +4875,7 @@ int sqlite3_value_bytes(sqlite3_value*); int sqlite3_value_bytes16(sqlite3_value*); int sqlite3_value_type(sqlite3_value*); int sqlite3_value_numeric_type(sqlite3_value*); +int sqlite3_value_nochange(sqlite3_value*); /* ** CAPI3REF: Finding The Subtype Of SQL Values diff --git a/src/update.c b/src/update.c index 3de36fe211..ee920d2a5d 100644 --- a/src/update.c +++ b/src/update.c @@ -827,7 +827,8 @@ static void updateVirtualTable( if( aXRef[i]>=0 ){ sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i); }else{ - sqlite3VdbeAddOp4Int(v, OP_VColumn, iCsr, i, regArg+2+i, 1); + sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i); + sqlite3VdbeChangeP5(v, 1); } } if( HasRowid(pTab) ){ @@ -862,6 +863,7 @@ static void updateVirtualTable( /* Create a record from the argument register contents and insert it into ** the ephemeral table. */ sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec); + sqlite3VdbeChangeP5(v, 2); sqlite3VdbeAddOp2(v, OP_NewRowid, ephemTab, regRowid); sqlite3VdbeAddOp3(v, OP_Insert, ephemTab, regRec, regRowid); } diff --git a/src/vdbe.c b/src/vdbe.c index d66387d239..dc058b65ff 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -464,7 +464,7 @@ static void memTracePrint(Mem *p){ if( p->flags & MEM_Undefined ){ printf(" undefined"); }else if( p->flags & MEM_Null ){ - printf(" NULL"); + printf(p->flags & MEM_Zero ? " NULL-nochng" : " NULL"); }else if( (p->flags & (MEM_Int|MEM_Str))==(MEM_Int|MEM_Str) ){ printf(" si:%lld", p->u.i); }else if( p->flags & MEM_Int ){ @@ -2794,7 +2794,11 @@ case OP_MakeRecord: { assert( memIsValid(pRec) ); pRec->uTemp = serial_type = sqlite3VdbeSerialType(pRec, file_format, &len); if( pRec->flags & MEM_Zero ){ - if( nData ){ + if( serial_type==0 ){ + assert( pOp->p5==2 || CORRUPT_DB ); + /* serial_type 10 used internally only */ + pRec->uTemp = 10; + }else if( nData ){ if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem; }else{ nZero += pRec->u.nZero; @@ -6697,15 +6701,15 @@ case OP_VFilter: { /* jump */ #endif /* SQLITE_OMIT_VIRTUALTABLE */ #ifndef SQLITE_OMIT_VIRTUALTABLE -/* Opcode: VColumn P1 P2 P3 P4 * +/* Opcode: VColumn P1 P2 P3 * P5 ** Synopsis: r[P3]=vcolumn(P2) ** ** Store in register P3 the value of the P2-th column of ** the current row of the virtual-table of cursor P1. ** ** If the VColumn opcode is being used to fetch the value of -** an unchanging column during an UPDATE operation, then the P4 -** value is 1. Otherwise, P4 is 0. The P4 value is returned +** an unchanging column during an UPDATE operation, then the P5 +** value is 1. Otherwise, P5 is 0. The P5 value is returned ** by sqlite3_vtab_nochange() routine can can be used ** by virtual table implementations to return special "no-change" ** marks which can be more efficient, depending on the virtual table. @@ -6730,8 +6734,13 @@ case OP_VColumn: { assert( pModule->xColumn ); memset(&sContext, 0, sizeof(sContext)); sContext.pOut = pDest; - sContext.bVtabNoChng = pOp->p4.i!=0; - MemSetTypeFlag(pDest, MEM_Null); + if( pOp->p5 ){ + sqlite3VdbeMemSetNull(pDest); + pDest->flags = MEM_Null|MEM_Zero; + pDest->u.nZero = 0; + }else{ + MemSetTypeFlag(pDest, MEM_Null); + } rc = pModule->xColumn(pCur->uc.pVCur, &sContext, pOp->p2); sqlite3VtabImportErrmsg(p, pVtab); if( sContext.isError ){ diff --git a/src/vdbeInt.h b/src/vdbeInt.h index f646a4036a..b7e324c94b 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -224,6 +224,8 @@ struct sqlite3_value { ** If the MEM_Null flag is set, then the value is an SQL NULL value. ** For a pointer type created using sqlite3_bind_pointer() or ** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set. +** If both MEM_Null and MEM_Zero are set, that means that the value is +** an unchanging column value from VColumn. ** ** If the MEM_Str flag is set then Mem.z points at a string representation. ** Usually this is encoded in the same unicode encoding as the main diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 19aa783bb6..bdd6d1cd07 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -268,6 +268,11 @@ int sqlite3_value_type(sqlite3_value* pVal){ return aType[pVal->flags&MEM_AffMask]; } +/* Return true if a parameter to xUpdate represents an unchanged column */ +int sqlite3_value_nochange(sqlite3_value *pVal){ + return (pVal->flags&(MEM_Null|MEM_Zero))==(MEM_Null|MEM_Zero); +} + /* Make a copy of an sqlite3_value object */ sqlite3_value *sqlite3_value_dup(const sqlite3_value *pOrig){ @@ -761,7 +766,7 @@ sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ */ int sqlite3_vtab_nochange(sqlite3_context *p){ assert( p ); - return p->bVtabNoChng; + return sqlite3_value_nochange(p->pOut); } /* diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 1780d37b8c..72a5b96bba 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3454,7 +3454,11 @@ u32 sqlite3VdbeSerialGet( Mem *pMem /* Memory cell to write value into */ ){ switch( serial_type ){ - case 10: /* Reserved for future use */ + case 10: { /* Internal use only: NULL with virtual table + ** UPDATE no-change flag set */ + pMem->flags = MEM_Null|MEM_Zero; + break; + } case 11: /* Reserved for future use */ case 0: { /* Null */ /* EVIDENCE-OF: R-24078-09375 Value is a NULL. */ diff --git a/src/vdbemem.c b/src/vdbemem.c index 107d831f4c..d8f1e64328 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -43,7 +43,7 @@ int sqlite3VdbeCheckMemInvariants(Mem *p){ if( p->flags & MEM_Null ){ /* Cannot be both MEM_Null and some other type */ assert( (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob - |MEM_RowSet|MEM_Frame|MEM_Agg|MEM_Zero))==0 ); + |MEM_RowSet|MEM_Frame|MEM_Agg))==0 ); /* If MEM_Null is set, then either the value is a pure NULL (the usual ** case) or it is a pointer set using sqlite3_bind_pointer() or From 41fb367a2c5aec8973fa004ba030f2aa55bbad5c Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 12 Jan 2018 23:18:38 +0000 Subject: [PATCH 123/190] Improved comments. Slightly tighter implementation, but no big changes. FossilOrigin-Name: a1b3f28569f2a8d82b2931527fdfe191b421f3e1ea18ee30e04211e1ad645993 --- manifest | 21 +++++++++------------ manifest.uuid | 2 +- src/sqlite.h.in | 9 +++++++-- src/sqliteInt.h | 1 + src/update.c | 8 ++++++-- src/vdbe.c | 14 ++++++++++---- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index c96606d8a9..06de123c8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sexperimental\ssqlite3_value_nochange()\sinterface\susable\sby\sxUpdate\nmethods\sof\svirtual\stables\sto\ssee\sif\sa\scolumn\shas\sactually\schanged\svalues. -D 2018-01-12T21:00:14.387 +C Improved\scomments.\s\sSlightly\stighter\simplementation,\sbut\sno\sbig\schanges. +D 2018-01-12T23:18:38.948 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -487,10 +487,10 @@ F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 F src/shell.c.in b87abffd0db09203ad8a133d56fe8f154ace5ec0a14197a153fb7d80b1438c01 -F src/sqlite.h.in 8c9b7bf8f635c13371d8060061e83d19623c77e7e4430dff7713e47761d1b972 +F src/sqlite.h.in 86cc0db2b9a55ae7bbde80c9387cdb56aabe24221ee69069ec09626493cff9a8 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 -F src/sqliteInt.h fd8702c65994d7de3e2d8f7d85d958731da1ed29476571fdfa2290fd8ec0bf80 +F src/sqliteInt.h 9c70315598b34810a83e4894455acb18e95cf63ce4e6cbb451ac2d17eabc2544 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c 9737ed017279a9e0c5da748701c3c7bf1e8ae0dae459aad20dd64fcff97a7e35 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 @@ -550,11 +550,11 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 5b0c661a85f783d35b9883830736eeb63be4aefc4f6b7d9cd081d48782c041e2 F src/treeview.c eae35972ff44f67064de2eaf35f04afe94e7aea3271a8b3bcebb3f954880fec3 F src/trigger.c a34539c69433276d37b0da9a89c117726ff2d292c0902895af1f393a983cd3a1 -F src/update.c 7736ffc60d9fdfaae4e294d76158c0a9f752b369ae2b22ef9fc800d08e0bf31e +F src/update.c a90a32ffc0100265b0693dbbdbe490756447af181f5ea2c138cce515b08c8795 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/util.c 7315e97a8dc2c8e19ca64196c652cf0a65d13fd0a211b2cec082062372dc6261 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 -F src/vdbe.c 07dd1909ceac146717cc248838ffe2f85165e50e468e6a0c378d840c1caf6e98 +F src/vdbe.c ccc1e17a30325068ae4f0292e8601997946886d23acc989c68f2a261a2795c70 F src/vdbe.h 134beb7a12a6213c00eba58febaede33447cc4441bc568a0d9c144b33fc3720a F src/vdbeInt.h 5442fc816b6cf19c8801724199fd6b77a02eb31a7a174021713f8c59b30e51fa F src/vdbeapi.c 02f773681d06e46454b0606339068d4d4490873dc4a7334bc0c6030552bb2c8c @@ -1699,10 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6acbdba59e9df4313a6232d925a70390acdc43dfa380b4fba7bb8bd442d6e728 -R 6f0b4cb15335f84e55c45be4e670230a -T *branch * sqlite3_value_nochange -T *sym-sqlite3_value_nochange * -T -sym-trunk * +P 8b7be15ece9e2e83959bb0e21e240106fe1077431242c3cc6b81f1baa2382f40 +R f998d1f4e8803d74f5f45b4d8b5e31dd U drh -Z 9655b705be92f16dc668ac363b3cc0e3 +Z 1d40e26fdb71cc6674c4c60bc100f971 diff --git a/manifest.uuid b/manifest.uuid index 7fcc0b51be..20282b7174 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b7be15ece9e2e83959bb0e21e240106fe1077431242c3cc6b81f1baa2382f40 \ No newline at end of file +a1b3f28569f2a8d82b2931527fdfe191b421f3e1ea18ee30e04211e1ad645993 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 7579b9926d..cd524a046f 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4850,8 +4850,13 @@ SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), ** ^Within the [xUpdate] method of a [virtual table], the ** sqlite3_value_nochange(X) interface returns true if and only if ** the column corresponding to X is unchanged by the UPDATE operation -** and the [xColumn] method had previously queried [sqlite3_vtab_nochange()] -** for that column and returned a NULL as a result. +** that the xUpdate method call was invoked to implement and if +** and the prior [xColumn] method call that was invoked to extracted +** the value for that column returned without setting a result (probably +** because it queried [sqlite3_vtab_nochange()] and found that the column +** was unchanging). If sqlite3_value_nochange(X) is invoked anywhere other +** than within an [xUpdate] method call for an UPDATE statement, then +** the return value is arbitrary and meaningless. ** ** Please pay particular attention to the fact that the pointer returned ** from [sqlite3_value_blob()], [sqlite3_value_text()], or diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8e79133200..b7b402b8e0 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3117,6 +3117,7 @@ struct AuthContext { #define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */ #define OPFLAG_SAVEPOSITION 0x02 /* OP_Delete/Insert: save cursor pos */ #define OPFLAG_AUXDELETE 0x04 /* OP_Delete: index in a DELETE op */ +#define OPFLAG_NOCHNG_MAGIC 0x6d /* OP_MakeRecord: serialtype 10 is ok */ /* * Each trigger present in the database schema is stored as an instance of diff --git a/src/update.c b/src/update.c index ee920d2a5d..32c1a8371a 100644 --- a/src/update.c +++ b/src/update.c @@ -828,7 +828,7 @@ static void updateVirtualTable( sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i); }else{ sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i); - sqlite3VdbeChangeP5(v, 1); + sqlite3VdbeChangeP5(v, 1); /* Enable sqlite3_vtab_nochange() */ } } if( HasRowid(pTab) ){ @@ -863,7 +863,11 @@ static void updateVirtualTable( /* Create a record from the argument register contents and insert it into ** the ephemeral table. */ sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec); - sqlite3VdbeChangeP5(v, 2); +#ifdef SQLITE_DEBUG + /* Signal an assert() within OP_MakeRecord that it is allowed to + ** accept no-change records with serial_type 10 */ + sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG_MAGIC); +#endif sqlite3VdbeAddOp2(v, OP_NewRowid, ephemTab, regRowid); sqlite3VdbeAddOp3(v, OP_Insert, ephemTab, regRec, regRowid); } diff --git a/src/vdbe.c b/src/vdbe.c index dc058b65ff..d878ca8e31 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2792,12 +2792,17 @@ case OP_MakeRecord: { pRec = pLast; do{ assert( memIsValid(pRec) ); - pRec->uTemp = serial_type = sqlite3VdbeSerialType(pRec, file_format, &len); + serial_type = sqlite3VdbeSerialType(pRec, file_format, &len); if( pRec->flags & MEM_Zero ){ if( serial_type==0 ){ - assert( pOp->p5==2 || CORRUPT_DB ); - /* serial_type 10 used internally only */ - pRec->uTemp = 10; + /* Values with MEM_Null and MEM_Zero are created by xColumn virtual + ** table methods that never invoke sqlite3_result_xxxxx() while + ** computing an unchanging column value in an UPDATE statement. + ** Give such values a special internal-use-only serial-type of 10 + ** so that they can be passed through to xUpdate and have + ** a true sqlite3_value_nochange(). */ + assert( pOp->p5==OPFLAG_NOCHNG_MAGIC || CORRUPT_DB ); + serial_type = 10; }else if( nData ){ if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem; }else{ @@ -2809,6 +2814,7 @@ case OP_MakeRecord: { testcase( serial_type==127 ); testcase( serial_type==128 ); nHdr += serial_type<=127 ? 1 : sqlite3VarintLen(serial_type); + pRec->uTemp = serial_type; if( pRec==pData0 ) break; pRec--; }while(1); From 76506cd3a7b5cb51fe339f753eb6951cc5f3dca3 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 13 Jan 2018 01:53:09 +0000 Subject: [PATCH 124/190] Add the new "nochange" APIs to the extension loading mechanism. FossilOrigin-Name: cd7c42699e73b688dbed29ed5d243d06439d7dbe0ba8c42d8299e04cc0dd4464 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/loadext.c | 5 ++++- src/sqlite3ext.h | 5 +++++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 8932dc15ad..0237685bce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_value_nochange()\sAPI,\susable\sfrom\swithin\sthe\sxUpdate\smethod\nof\sa\svirtual\stable\sto\sdiscover\swhether\sor\snot\sa\scolumn\swas\sunchanged\sat\sthe\nSQL\slevel. -D 2018-01-12T23:38:10.473 +C Add\sthe\snew\s"nochange"\sAPIs\sto\sthe\sextension\sloading\smechanism. +D 2018-01-13T01:53:09.144 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -449,7 +449,7 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 14686083cedc198540b15a79586cdd4be2acf6d5fa97627e355f817ab07e9fee F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e -F src/loadext.c 55bcc3c741059a1056859e8adaf133aa179e22be12215c0936b2f354ef71209b +F src/loadext.c 8d5d9c3ab3c4d600a161f389988bdee6a04dad7c4c1754f04f257734b9d1ce8c F src/main.c 26918d50dd4a61b8f6f210320a522f46b5e7e592335b6aa664ab15b80b7c239b F src/malloc.c 07295435093ce354c6d9063ac05a2eeae28bd251d2e63c48b3d67c12c76f7e18 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -489,7 +489,7 @@ F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 F src/shell.c.in b87abffd0db09203ad8a133d56fe8f154ace5ec0a14197a153fb7d80b1438c01 F src/sqlite.h.in 9daf78e8f3cecc9ea0c3a82201f75bb74f789ecbfcda28d2e47fa80b3d956961 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 +F src/sqlite3ext.h 3737a51c5798e47a8ff2af0720f6dbc00fabd5ea401db392d05b1916085857a6 F src/sqliteInt.h 9c70315598b34810a83e4894455acb18e95cf63ce4e6cbb451ac2d17eabc2544 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c 9737ed017279a9e0c5da748701c3c7bf1e8ae0dae459aad20dd64fcff97a7e35 @@ -1699,8 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6acbdba59e9df4313a6232d925a70390acdc43dfa380b4fba7bb8bd442d6e728 a1b3f28569f2a8d82b2931527fdfe191b421f3e1ea18ee30e04211e1ad645993 -R 33c612cb07bc4c3b03c1437b3563b788 -T +closed a1b3f28569f2a8d82b2931527fdfe191b421f3e1ea18ee30e04211e1ad645993 +P dec3ea4e4e6c4b1761ddc883a29eaa50dcd663ce6199667cc0ff82f7849d4f2a +R 901f5f730b71efe02ff8601865925ddd U drh -Z 1fe0c448d0c954d66825b437c30d556c +Z db401e20fe7110735f2f14be8ffea4bc diff --git a/manifest.uuid b/manifest.uuid index 39a147bce2..cf5a25ebf1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dec3ea4e4e6c4b1761ddc883a29eaa50dcd663ce6199667cc0ff82f7849d4f2a \ No newline at end of file +cd7c42699e73b688dbed29ed5d243d06439d7dbe0ba8c42d8299e04cc0dd4464 \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index abc6b3ff1d..80d40a4429 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -430,7 +430,10 @@ static const sqlite3_api_routines sqlite3Apis = { sqlite3_prepare16_v3, sqlite3_bind_pointer, sqlite3_result_pointer, - sqlite3_value_pointer + sqlite3_value_pointer, + /* Version 3.22.0 and later */ + sqlite3_vtab_nochange, + sqlite3_value_nochange }; /* diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index d1d2c574ae..4252063909 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -292,6 +292,8 @@ struct sqlite3_api_routines { int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*)); void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*)); void *(*value_pointer)(sqlite3_value*,const char*); + int (*vtab_nochange)(sqlite3_context*); + int (*value_nochange)(sqlite3_value*); }; /* @@ -558,6 +560,9 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_bind_pointer sqlite3_api->bind_pointer #define sqlite3_result_pointer sqlite3_api->result_pointer #define sqlite3_value_pointer sqlite3_api->value_pointer +/* Version 3.22.0 and later */ +#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange +#define sqlite3_value_nochange sqltie3_api->value_nochange #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) From 2034353db430f3339c8cd3297730063f881ad0a2 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 13 Jan 2018 02:07:16 +0000 Subject: [PATCH 125/190] Updates and minor typo fix for the README. FossilOrigin-Name: bb196fcb677e962db4308c02097968615729a51fe4a1292e468aaf3e4bf522d3 --- README.md | 15 +++++++-------- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f70b512d41..e5fa2acb67 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

SQLite Source Repository

This repository contains the complete source code for the SQLite database -engine. Some test scripts are also include. However, many other test scripts +engine. Some test scripts are also included. However, many other test scripts and most of the documentation are managed separately. If you are reading this on a Git mirror someplace, you are doing it wrong. @@ -104,7 +104,6 @@ recommended. SQLite does not require [Tcl](http://www.tcl.tk/) to run, but a Tcl installation is required by the makefiles (including those for MSVC). SQLite contains a lot of generated code and Tcl is used to do much of that code generation. -The makefiles also require AWK. ## Source Code Tour @@ -116,7 +115,7 @@ The **src/** also contains the "shell.c" file which is the main program for the "sqlite3.exe" [command-line shell](https://sqlite.org/cli.html) and the "tclsqlite.c" file which implements the -[TCL bindings](https://sqlite.org/tclsqlite.html) for SQLite. +[Tcl bindings](https://sqlite.org/tclsqlite.html) for SQLite. (Historical note: SQLite began as a Tcl extension and only later escaped to the wild as an independent library.) @@ -163,14 +162,14 @@ template for generating its parser. Lemon also generates the **parse.h** header file, at the same time it generates parse.c. But the parse.h header file is -modified further (to add additional symbols) using the ./addopcodes.awk -AWK script. +modified further (to add additional symbols) using the ./addopcodes.tcl +Tcl script. The **opcodes.h** header file contains macros that define the numbers corresponding to opcodes in the "VDBE" virtual machine. The opcodes.h file is generated by the scanning the src/vdbe.c source file. The -AWK script at ./mkopcodeh.awk does this scan and generates opcodes.h. -A second AWK script, ./mkopcodec.awk, then scans opcodes.h to generate +Tcl script at ./mkopcodeh.tcl does this scan and generates opcodes.h. +A second Tcl script, ./mkopcodec.tcl, then scans opcodes.h to generate the **opcodes.c** source file, which contains a reverse mapping from opcode-number to opcode-name that is used for EXPLAIN output. @@ -280,7 +279,7 @@ Key files: * **test*.c** - Files in the src/ folder that begin with "test" go into building the "testfixture.exe" program. The testfixture.exe program is - an enhanced TCL shell. The testfixture.exe program runs scripts in the + an enhanced Tcl shell. The testfixture.exe program runs scripts in the test/ folder to validate the core SQLite code. The testfixture program (and some other test programs too) is build and run when you type "make test". diff --git a/manifest b/manifest index 0237685bce..7b0d218ffc 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Add\sthe\snew\s"nochange"\sAPIs\sto\sthe\sextension\sloading\smechanism. -D 2018-01-13T01:53:09.144 +C Updates\sand\sminor\stypo\sfix\sfor\sthe\sREADME. +D 2018-01-13T02:07:16.057 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ede26e3fb675e0b3b07627640ce5917154a6ee7f8f2c97424eb5ab5f651cbd56 -F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681 +F README.md d748f58e3ab0fe0307fb4ae0942b415d93dcc4288756e366cc9e7cf8260c093f F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dec3ea4e4e6c4b1761ddc883a29eaa50dcd663ce6199667cc0ff82f7849d4f2a -R 901f5f730b71efe02ff8601865925ddd -U drh -Z db401e20fe7110735f2f14be8ffea4bc +P cd7c42699e73b688dbed29ed5d243d06439d7dbe0ba8c42d8299e04cc0dd4464 +R 5af93dd5d7e603d352f9007674349f27 +U mistachkin +Z e985e4fc81de14351414b5000a144309 diff --git a/manifest.uuid b/manifest.uuid index cf5a25ebf1..b074e985c2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd7c42699e73b688dbed29ed5d243d06439d7dbe0ba8c42d8299e04cc0dd4464 \ No newline at end of file +bb196fcb677e962db4308c02097968615729a51fe4a1292e468aaf3e4bf522d3 \ No newline at end of file From 69aedc8db441c25749a0693f42dea0462ba09f9b Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 13 Jan 2018 13:07:49 +0000 Subject: [PATCH 126/190] Fix various problems in test scripts preventing "make test" from passing on F2FS file-systems with the "atomic-write" feature. FossilOrigin-Name: 56d93d070d6b92d8a5a3fec1b09aae8911116c73d072fc5022f0b51668ed996b --- manifest | 58 ++++++++++++++++++++++---------------------- manifest.uuid | 2 +- test/crash8.test | 10 ++++++-- test/delete_db.test | 5 ++++ test/exclusive.test | 7 +++++- test/fallocate.test | 1 + test/journal1.test | 7 +++++- test/journal3.test | 4 ++- test/jrnlmode.test | 4 +++ test/jrnlmode2.test | 5 ++++ test/lock4.test | 8 ++++++ test/pager1.test | 5 ++++ test/pager3.test | 4 +++ test/rollback.test | 1 + test/sharedA.test | 5 ++++ test/stmt.test | 5 ++++ test/symlink.test | 2 +- test/sync.test | 4 +++ test/sync2.test | 1 + test/tempdb.test | 5 ++++ test/tkt3457.test | 4 +++ test/vacuum5.test | 8 +++--- test/wal2.test | 16 +++++++++--- test/walmode.test | 32 ++++++++++++++---------- test/zerodamage.test | 4 +-- 25 files changed, 149 insertions(+), 58 deletions(-) diff --git a/manifest b/manifest index 7b0d218ffc..4999390916 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updates\sand\sminor\stypo\sfix\sfor\sthe\sREADME. -D 2018-01-13T02:07:16.057 +C Fix\svarious\sproblems\sin\stest\sscripts\spreventing\s"make\stest"\sfrom\spassing\son\nF2FS\sfile-systems\swith\sthe\s"atomic-write"\sfeature. +D 2018-01-13T13:07:49.167 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -724,7 +724,7 @@ F test/crash4.test fe2821baf37168dc59dd733dcf7dba2a401487bc F test/crash5.test 05dd3aa9dbb751a22d5cdaf22a9c49b6667aa219 F test/crash6.test 4c56f1e40d0291e1110790a99807aa875b1647ba F test/crash7.test 1a194c4900a255258cf94b7fcbfd29536db572df -F test/crash8.test a63907617d8e74fb54b4bff23eca8a4435625245 +F test/crash8.test 64e464f22883be5184535a9620eb9070027073610d997bd2784227ca9564fb84 F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 @@ -744,7 +744,7 @@ F test/delete.test acc38fca8ee4851467705b1c2cfea64cd26667e5 F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab F test/delete4.test 21d2113217eeaacac2d99defe14fe6611615ae86 -F test/delete_db.test c70a43629dd4d3e1dd03fdaf7a22153af6a69d92 +F test/delete_db.test 096d828493c7907f9ea11a7098ea6a0f73edba89406487d5d6cc2228dc4ab8b0 F test/descidx1.test 6d03b44c8538fe0eb4924e19fba10cdd8f3c9240 F test/descidx2.test 9f1a0c83fd57f8667c82310ca21b30a350888b5d F test/descidx3.test 09ddbe3f5295f482d2f8b687cf6db8bad7acd9a2 @@ -785,14 +785,14 @@ F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020 F test/eqp.test 3fe051af50921284189d1970eb653f9fcf5117d2 F test/errmsg.test eae9f091eb39ce7e20305de45d8e5d115b68fa856fba4ea6757b6ca3705ff7f9 F test/eval.test a64c9105d6ff163df7cf09d6ac29cdad5922078c -F test/exclusive.test 9a57bd66e39144b888ca75c309914fcdefb4e3f9 +F test/exclusive.test 1206b87e192497d78c7f35552e86a9d05421498da300fb1cce5ca5351ccde3c3 F test/exclusive2.test 984090e8e9d1b331d2e8111daf6e5d61dda0bef7 F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 F test/exists.test 79a75323c78f02bbe9c251ea502a092f9ef63dac F test/expr.test 66a2c9ac34f74f036faa4092f5402c7d3162fc93 F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9 F test/extraquick.test cb254400bd42bfb777ff675356aabf3287978f79 -F test/fallocate.test 87b5e43c872b7e69cd80b7b8813eb102b571a75d45dda24e38b65537bcc85733 +F test/fallocate.test 07416bd593a116d5893cb244f45a94d5c6fe030561df3bd972e6135f8106e509 F test/filectrl.test 6e871c2d35dead1d9a88e176e8d2ca094fec6bb3 F test/filefmt.test f393e80c4b8d493b7a7f8f3809a8425bbf4292af1f5140f01cb1427798a2bbd4 F test/fkey1.test d11dbb8a93ead9b5c46ae5d02da016d61245d47662fb2d844c99214f6163f768 @@ -1004,11 +1004,11 @@ F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0 F test/join4.test 1a352e4e267114444c29266ce79e941af5885916 F test/join5.test bc98ea4b4e5003f5b1453701ebb8cd7d1c01a550 F test/join6.test cfe6503791ceb0cbb509966740286ec423cbf10b -F test/journal1.test 69abc726c51b4a0409189f9a85191205297c0577 +F test/journal1.test c7b768041b7f494471531e17abc2f4f5ebf9e5096984f43ed17c4eb80ba34497 F test/journal2.test 9dac6b4ba0ca79c3b21446bbae993a462c2397c4 -F test/journal3.test ff8af941f9e06161d3db1b46bb9f965ff0e7f307 -F test/jrnlmode.test 7864d59cf7f6e552b9b99ba0f38acd167edc10fa -F test/jrnlmode2.test 81610545a4e6ed239ea8fa661891893385e23a1d +F test/journal3.test c9c29883f5bf535ae82ae21c472df6263806a22e467b6db7cd0d6d545305b4f6 +F test/jrnlmode.test a6693f2bed4541a21e703aaa37bb3e10de154130645952933b82b2dec0a8b539 +F test/jrnlmode2.test 8759a1d4657c064637f8b079592651530db738419e1d649c6df7048cd724363d F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa F test/json101.test d7cdf3e6731d41e0c4bde1c88806abd17f1f478486a1409933c1d8eac9120095 F test/json102.test eeb54efa221e50b74a2d6fb9259963b48d7414dca3ce2fdfdeed45cb28487bc1 @@ -1028,7 +1028,7 @@ F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00 -F test/lock4.test e175ae13865bc87680607563bafba21f31a26f12 +F test/lock4.test 27143363eda1622f03c133efc8db808fc331afd973486cb571ea71cd717d37b8 F test/lock5.test c6c5e0ebcb21c61a572870cc86c0cb9f14cede38 F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5 F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431 @@ -1116,9 +1116,9 @@ F test/oserror.test b32dc34f2363ef18532e3a0a7358e3e7e321974f F test/ossfuzz.c 7f5cc87a0280a5854c1bfa7d5c4d07d34731f08ec34dc9c916aa35ed292b1468 F test/ossshell.c 296ab63067841bd1b1e97b46a0b2af48ee7f69d50d1a723008bee12dd7122622 F test/ovfl.test 199c482696defceacee8c8e0e0ef36da62726b2f -F test/pager1.test 8149b2a8986fee667ab6a8171ab310be19e77ae215bebad0e90c857b0df1935c +F test/pager1.test f596d3bd53ce96e1d87d44d223d2ae6c8867dd782c425e5eb28b5721fa6aaa97 F test/pager2.test 67b8f40ae98112bcdba1f2b2d03ea83266418c71 -F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f +F test/pager3.test 4e9a83d6ca0838d7c602c9eb93d1357562d9059c1e02ffb138a8271020838370 F test/pager4.test a122e9e6925d5b23b31e3dfef8c6a44bbf19590e F test/pagerfault.test 263c5442c06caf0b9b9e3fe42acdeb11f254dcebe533f69f401aaef9111eaf20 F test/pagerfault2.test caf4c7facb914fd3b03a17b31ae2b180c8d6ca1f @@ -1156,7 +1156,7 @@ F test/regexp2.test 40e894223b3d6672655481493f1be12012f2b33c F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 F test/releasetest.tcl 6aaa853f7a7bbdc458d4cb42c0425228729b0f3e5769e9b41088c08eee999a49 x F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb -F test/rollback.test f580934279800d480a19176c6b44909df31ce7ad45267ea475a541daa522f3d3 +F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa F test/rollback2.test 8435d6ff0f13f51d2a4181c232e706005fa90fc5 F test/rollbackfault.test 0e646aeab8840c399cfbfa43daab46fd609cf04a F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc @@ -1216,7 +1216,7 @@ F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 F test/shared7.test a81e99f83e6c51b02ac99c96fb3a2a7b5978c956 F test/shared8.test 00a07bf5e1337ecf72e94542bdefdc330d7a2538 F test/shared9.test 5f2a8f79b4d6c7d107a01ffa1ed05ae7e6333e21 -F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5 +F test/sharedA.test 49d87ec54ab640fbbc3786ee3c01de94aaa482a3a9f834ad3fe92770eb69e281 F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 @@ -1266,7 +1266,7 @@ F test/sqllimits1.test a74ee2a3740b9f9c2437c246d8fb77354862a142 F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a F test/stat.test f8f1279ffffabe6df825723af18cc6e0ae70a893 F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 -F test/stmt.test 64844332db69cf1a735fcb3e11548557fc95392f +F test/stmt.test 54ed2cc0764bf3e48a058331813c3dbd19fc1d0827c3d8369914a5d8f564ec75 F test/stmtvtab1.test 6873dfb24f8e79cbb5b799b95c2e4349060eb7a3b811982749a84b359468e2d5 F test/subjournal.test 8d4e2572c0ee9a15549f0d8e40863161295107e52f07a3e8012a2e1fdd093c49 F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f @@ -1279,9 +1279,9 @@ F test/swarmvtab.test 9a3fd5ab3e9b3c976ad1b3d7646aab725114f2ac26b59395d0778b33ba F test/swarmvtab2.test c948cb2fdfc5b01d85e8f6d6504854202dc1a0782ab2a0ed61538f27cbd0aa5c F test/swarmvtab3.test 6cb664669630fcec4102a09333e52068734858fd2761eee3b0465c14cdbcee29 F test/swarmvtabfault.test 00aec54665909490f5c383f3cae3b5d18bd97c12490b429ff8752a3027acfa42 -F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 -F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 -F test/sync2.test 6be8ed007fa063b147773c1982b5bdba97a32badc536bdc6077eff5cf8710ece +F test/symlink.test 0d816670325536b8973ec08d32b45136baddb80bd45fd178e0ce7a9e8153f3e7 +F test/sync.test 89539f4973c010eda5638407e71ca7fddbcd8e0594f4c9980229f804d4333092 +F test/sync2.test 8f9f7d4f6d5be8ca8941a8dadcc4299e558cb6a1ff653a9469146c7a76ef2039 F test/syscall.test a39d9a36f852ae6e4800f861bc2f2e83f68bbc2112d9399931ecfadeabd2d69d F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 F test/tabfunc01.test c47171c36b3d411df2bd49719dcaa5d034f8d277477fd41d253940723b969a51 @@ -1289,7 +1289,7 @@ F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 F test/tclsqlite.test c3d7ac9449634b9f17fd048a3c0212e88a7448be810a9c5bd051acc1ffa00d2f -F test/tempdb.test bd92eba8f20e16a9136e434e20b280794de3cdb6 +F test/tempdb.test 4cdaa23ddd8acb4d79cbb1b68ccdfd09b0537aaba909ca69a876157c2a2cbd08 F test/tempdb2.test 27e41ed540b2f9b056c2e77e9bddc1b875358507 F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 @@ -1416,7 +1416,7 @@ F test/tkt3357.test 77c37c6482b526fe89941ce951c22d011f5922ed F test/tkt3419.test 1bbf36d7ea03b638c15804251287c2391f5c1f6b F test/tkt3424.test 61f831bd2b071bd128fa5d00fbda57e656ca5812 F test/tkt3442.test 53840ec5325bb94544792aad4c20476f81dc26b1 -F test/tkt3457.test 44e980fe5334753dcc27b94fa4deabc485a92f74 +F test/tkt3457.test 5651e2cbb94645b677ec663160b9e192b87b7d365aecdfb24e19f749575a6fc2 F test/tkt3461.test 228ea328a5a21e8663f80ee3d212a6ad92549a19 F test/tkt3493.test 1686cbde85f8721fc1bdc0ee72f2ef2f63139218 F test/tkt3508.test d75704db9501625c7f7deec119fcaf1696aefb7d @@ -1499,7 +1499,7 @@ F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d F test/vacuum2.test aa048abee196c16c9ba308465494009057b79f9b F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d F test/vacuum4.test 7ea76b769fffeb41f925303b04cbcf5a5bbeabe55e4c60ae754ff24eeeb7c010 -F test/vacuum5.test c87234e8ca4107f349da4edbeda3e4ea5adc93f3 +F test/vacuum5.test 263b144d537e92ad8e9ca8a73cc6e1583f41cfd0dda9432b87f7806174a2f48c F test/vacuummem.test 7b42abb3208bd82dd23a7536588396f295a314f2 F test/varint.test bbce22cda8fc4d135bcc2b589574be8410614e62 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 @@ -1526,7 +1526,7 @@ F test/vtab_alter.test 736e66fb5ec7b4fee58229aa3ada2f27ec58bc58c00edae4836890c37 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test 5253bff2355a9a3f014c15337da7e177ab0ef8ad F test/wal.test 613efec03e517e1775d86b993a54877d2e29a477 -F test/wal2.test 2d81ffe2a02d9e5c7447b266f7153716cfcba7aecda5ed832db4544617399e29 +F test/wal2.test 155b9efa999bdb38ce1cd729b9a4fcdbffd6b88be27f039bad1d2929d287d918 F test/wal3.test 2a93004bc0fb2b5c29888964024695bade278ab2 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c F test/wal5.test 9c11da7aeccd83a46d79a556ad11a18d3cb15aa9 @@ -1546,7 +1546,7 @@ F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af F test/walcrash4.test e7b6e7639a950a0cca8e210e248c8dad4d63bf20 F test/walfault.test 1f8389f7709877e9b4cc679033d71d6fe529056b F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 -F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c +F test/walmode.test cd6e7cff618eaaa5910ce57c3657aa50110397f86213886a2400afb9bfec7b7b F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496 F test/waloverwrite.test dad2f26567f1b45174e54fbf9a8dc1cb876a7f03 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6 @@ -1599,7 +1599,7 @@ F test/without_rowid6.test 1f99644e6508447fb050f73697350c7ceca3392e F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf8ac F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa -F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e +F test/zerodamage.test 9c41628db7e8d9e8a0181e59ea5f189df311a9f6ce99cc376dc461f66db6f8dc F test/zipfile.test a5cd98e91aebf343e21a32b97fadd6aefe02d249d5c6a1a3c2e624b88d7bdbe2 F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cd7c42699e73b688dbed29ed5d243d06439d7dbe0ba8c42d8299e04cc0dd4464 -R 5af93dd5d7e603d352f9007674349f27 -U mistachkin -Z e985e4fc81de14351414b5000a144309 +P bb196fcb677e962db4308c02097968615729a51fe4a1292e468aaf3e4bf522d3 +R 3bf69d486c995f84804eb3abae6dd335 +U dan +Z ecacbd8e6749e1f68b1f30b320420a3c diff --git a/manifest.uuid b/manifest.uuid index b074e985c2..a32f986633 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bb196fcb677e962db4308c02097968615729a51fe4a1292e468aaf3e4bf522d3 \ No newline at end of file +56d93d070d6b92d8a5a3fec1b09aae8911116c73d072fc5022f0b51668ed996b \ No newline at end of file diff --git a/test/crash8.test b/test/crash8.test index f3b6f6e244..2c6487b38b 100644 --- a/test/crash8.test +++ b/test/crash8.test @@ -142,6 +142,7 @@ proc write_file {zFile zData} { # b) Less than 512, or # c) Greater than SQLITE_MAX_PAGE_SIZE # +if {[atomic_batch_write test.db]==0} { do_test crash8-3.1 { list [file exists test.db-joural] [file exists test.db] } {0 1} @@ -228,6 +229,7 @@ do_test crash8-3.11 { PRAGMA integrity_check } } {6 ok} +} # If a connection running in persistent-journal mode is part of a @@ -266,8 +268,12 @@ ifcapable pragma { UPDATE aux.ab SET b = randstr(1000,1000) WHERE a>=1; UPDATE ab SET b = randstr(1000,1000) WHERE a>=1; } - list [file exists test.db-journal] [file exists test2.db-journal] - } {1 1} + } {persist persist} + if {[atomic_batch_write test.db]==0} { + do_test crash8.4.1.1 { + list [file exists test.db-journal] [file exists test2.db-journal] + } [list $bJrnl $bJrnl] + } do_test crash8-4.2 { execsql { diff --git a/test/delete_db.test b/test/delete_db.test index 09c44ff9f3..6edd9c242e 100644 --- a/test/delete_db.test +++ b/test/delete_db.test @@ -17,6 +17,11 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix delete_db +if {[atomic_batch_write test.db]} { + finish_test + return +} + proc delete_all {} { foreach f [glob -nocomplain test2*] { file delete $f } foreach f [glob -nocomplain test3*] { file delete $f } diff --git a/test/exclusive.test b/test/exclusive.test index 45f9318205..04de529137 100644 --- a/test/exclusive.test +++ b/test/exclusive.test @@ -252,7 +252,9 @@ db2 close # opens the journal file for exclusive access, preventing its contents # from being inspected externally. # -if {$tcl_platform(platform) != "windows"} { +if {$tcl_platform(platform) != "windows" + && [atomic_batch_write test.db]==0 +} { # Return a list of two booleans (either 0 or 1). The first is true # if the named file exists. The second is true only if the file @@ -391,6 +393,7 @@ do_test exclusive-4.5 { # Tests exclusive-5.X - test that statement journals are truncated # instead of deleted when in exclusive access mode. # +if {[atomic_batch_write test.db]==0} { # Close and reopen the database so that the temp database is no # longer active. @@ -508,4 +511,6 @@ do_execsql_test exclusive-6.5 { SELECT * FROM sqlite_master; } {exclusive} +} ;# atomic_batch_write==0 + finish_test diff --git a/test/fallocate.test b/test/fallocate.test index 63d88ea885..0c971c08c1 100644 --- a/test/fallocate.test +++ b/test/fallocate.test @@ -61,6 +61,7 @@ do_test fallocate-1.7 { execsql { BEGIN; INSERT INTO t1 VALUES(1, 2); } if {[permutation] != "inmemory_journal" && [permutation] != "atomic-batch-write" + && [atomic_batch_write test.db]==0 } { hexio_get_int [hexio_read test.db-journal 16 4] } else { diff --git a/test/journal1.test b/test/journal1.test index c89dd2b4c9..bcbafe30f6 100644 --- a/test/journal1.test +++ b/test/journal1.test @@ -22,7 +22,12 @@ source $testdir/tester.tcl # These tests will not work on windows because windows uses # manditory file locking which breaks the copy_file command. # -if {$tcl_platform(platform)=="windows"} { +# Or with atomic_batch_write systems, as journal files are +# not created. +# +if {$tcl_platform(platform)=="windows" + || [atomic_batch_write test.db] +} { finish_test return } diff --git a/test/journal3.test b/test/journal3.test index 939cc27c70..b907352329 100644 --- a/test/journal3.test +++ b/test/journal3.test @@ -20,7 +20,9 @@ source $testdir/malloc_common.tcl # If a connection is required to create a journal file, it creates it with # the same file-system permissions as the database file itself. Test this. # -if {$::tcl_platform(platform) == "unix"} { +if {$::tcl_platform(platform) == "unix" + && [atomic_batch_write test.db]==0 +} { # Changed on 2012-02-13: umask is deliberately ignored for -wal, -journal, # and -shm files. diff --git a/test/jrnlmode.test b/test/jrnlmode.test index 2ba56f2b00..3112f6184e 100644 --- a/test/jrnlmode.test +++ b/test/jrnlmode.test @@ -302,6 +302,7 @@ ifcapable autovacuum&&pragma { # The following test caes, jrnlmode-5.*, test the journal_size_limit # pragma. ifcapable pragma { +if {[atomic_batch_write test.db]==0} { db close forcedelete test.db test2.db test3.db sqlite3 db test.db @@ -454,8 +455,10 @@ ifcapable pragma { list [file exists test.db-journal] [file size test.db-journal] } {1 0} } +} ifcapable pragma { +if {[atomic_batch_write test.db]==0} { # These tests are not run as part of the "journaltest" permutation, # as the test_journal.c layer is incompatible with in-memory journaling. if {[permutation] ne "journaltest"} { @@ -507,6 +510,7 @@ ifcapable pragma { } {0} } } +} ifcapable pragma { catch { db close } diff --git a/test/jrnlmode2.test b/test/jrnlmode2.test index 6ea87d704b..6cc54dc5df 100644 --- a/test/jrnlmode2.test +++ b/test/jrnlmode2.test @@ -18,6 +18,11 @@ ifcapable {!pager_pragmas} { return } +if {[atomic_batch_write test.db]} { + finish_test + return +} + #------------------------------------------------------------------------- # The tests in this file check that the following two bugs (both now fixed) # do not reappear. diff --git a/test/lock4.test b/test/lock4.test index b0b1c74fbe..58dd206997 100644 --- a/test/lock4.test +++ b/test/lock4.test @@ -17,6 +17,14 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +if {[atomic_batch_write test.db]} { + # This test uses two processes, one of which blocks until the other + # creates a *-journal file. Which doesn't work if atomic writes are + # available. + finish_test + return +} + do_not_use_codec # Initialize the test.db database so that it is non-empty diff --git a/test/pager1.test b/test/pager1.test index 8451e0b3d2..42edc3d16b 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -17,6 +17,11 @@ source $testdir/malloc_common.tcl source $testdir/wal_common.tcl set testprefix pager1 +if {[atomic_batch_write test.db]} { + finish_test + return +} + # Do not use a codec for tests in this file, as the database file is # manipulated directly using tcl scripts (using the [hexio_write] command). # diff --git a/test/pager3.test b/test/pager3.test index 23435a79b7..e815f2788b 100644 --- a/test/pager3.test +++ b/test/pager3.test @@ -16,6 +16,10 @@ source $testdir/lock_common.tcl source $testdir/malloc_common.tcl source $testdir/wal_common.tcl +if {[atomic_batch_write test.db]} { + finish_test + return +} foreach {tn sql res j} { 1 "PRAGMA journal_mode = DELETE" delete 0 diff --git a/test/rollback.test b/test/rollback.test index 60a6190317..423bf20fce 100644 --- a/test/rollback.test +++ b/test/rollback.test @@ -83,6 +83,7 @@ if {$tcl_platform(platform) == "unix" && [permutation] ne "onefile" && [permutation] ne "inmemory_journal" && [permutation] ne "atomic-batch-write" + && [atomic_batch_write test.db]==0 } { do_test rollback-2.1 { execsql { diff --git a/test/sharedA.test b/test/sharedA.test index 146fb26be0..55ed5749bb 100644 --- a/test/sharedA.test +++ b/test/sharedA.test @@ -19,6 +19,11 @@ if {[run_thread_tests]==0} { finish_test ; return } db close set ::testprefix sharedA +if {[atomic_batch_write test.db]} { + finish_test + return +} + set ::enable_shared_cache [sqlite3_enable_shared_cache 1] #------------------------------------------------------------------------- diff --git a/test/stmt.test b/test/stmt.test index df501f7654..138ce19860 100644 --- a/test/stmt.test +++ b/test/stmt.test @@ -16,6 +16,11 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +if {[atomic_batch_write test.db]} { + finish_test + return +} + do_test stmt-1.1 { execsql { CREATE TABLE t1(a integer primary key, b INTEGER NOT NULL) } } {} diff --git a/test/symlink.test b/test/symlink.test index 949102cf8a..4695b29fa0 100644 --- a/test/symlink.test +++ b/test/symlink.test @@ -102,7 +102,7 @@ foreach {tn f} {1 test.db2 2 test.db3} { INSERT INTO t1 VALUES(1); } db2 file exists test.db-journal - } 1 + } [expr [atomic_batch_write test.db]==0] do_test 2.$tn.3 { list [file exists test2.db-journal] [file exists test3.db-journal] } {0 0} diff --git a/test/sync.test b/test/sync.test index 210039acb5..023425e6b1 100644 --- a/test/sync.test +++ b/test/sync.test @@ -26,6 +26,10 @@ ifcapable !pager_pragmas||!attach { finish_test return } +if {[atomic_batch_write test.db]} { + finish_test + return +} set sqlite_sync_count 0 proc cond_incr_sync_count {adj} { diff --git a/test/sync2.test b/test/sync2.test index 46e8bc72fb..89e66c8455 100644 --- a/test/sync2.test +++ b/test/sync2.test @@ -29,6 +29,7 @@ ifcapable !pager_pragmas||!attach||!dirsync { if {$::tcl_platform(platform)!="unix" || [permutation] == "journaltest" || [permutation] == "inmemory_journal" + || [atomic_batch_write test.db] } { finish_test return diff --git a/test/tempdb.test b/test/tempdb.test index 61416ec81c..a32ef06f44 100644 --- a/test/tempdb.test +++ b/test/tempdb.test @@ -17,6 +17,11 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +if {[atomic_batch_write test.db]} { + finish_test + return +} + # Use a temporary database. # db close diff --git a/test/tkt3457.test b/test/tkt3457.test index 0475741322..24b4f0eac0 100644 --- a/test/tkt3457.test +++ b/test/tkt3457.test @@ -19,6 +19,10 @@ if {$tcl_platform(platform) != "unix"} { finish_test return } +if {[atomic_batch_write test.db]} { + finish_test + return +} #----------------------------------------------------------------------- # To roll back a hot-journal file, the application needs read and write diff --git a/test/vacuum5.test b/test/vacuum5.test index 8e76a9393c..f203fb87ba 100644 --- a/test/vacuum5.test +++ b/test/vacuum5.test @@ -143,9 +143,11 @@ if {$::TEMP_STORE<3 && [permutation]!="inmemory_journal"} { db close tvfs delete - do_test 3.2 { - lrange $::openfiles 0 4 - } {test.db test.db-journal test.db-journal {} test.db-journal} + if {[atomic_batch_write test.db]==0} { + do_test 3.2 { + lrange $::openfiles 0 4 + } {test.db test.db-journal test.db-journal {} test.db-journal} + } } diff --git a/test/wal2.test b/test/wal2.test index a9cafec66d..b26f5ca877 100644 --- a/test/wal2.test +++ b/test/wal2.test @@ -584,15 +584,23 @@ do_test wal2-6.3.4 { BEGIN; INSERT INTO t1 VALUES('Groucho'); } - list [file exists test.db-wal] [file exists test.db-journal] -} {0 1} +} {} +if {[atomic_batch_write test.db]==0} { + do_test wal2-6.3.4.1 { + list [file exists test.db-wal] [file exists test.db-journal] + } {0 1} +} do_test wal2-6.3.5 { execsql { PRAGMA lock_status } } {main exclusive temp closed} do_test wal2-6.3.6 { execsql { COMMIT } - list [file exists test.db-wal] [file exists test.db-journal] -} {0 1} +} {} +if {[atomic_batch_write test.db]==0} { + do_test wal2-6.3.6.1 { + list [file exists test.db-wal] [file exists test.db-journal] + } {0 1} +} do_test wal2-6.3.7 { execsql { PRAGMA lock_status } } {main exclusive temp closed} diff --git a/test/walmode.test b/test/walmode.test index 4e14d54d4f..f760823c8d 100644 --- a/test/walmode.test +++ b/test/walmode.test @@ -45,15 +45,17 @@ do_test walmode-1.2 { file size test.db } {1024} -set expected_sync_count 3 -if {$::tcl_platform(platform)!="windows"} { - ifcapable dirsync { - incr expected_sync_count +if {[atomic_batch_write test.db]==0} { + set expected_sync_count 3 + if {$::tcl_platform(platform)!="windows"} { + ifcapable dirsync { + incr expected_sync_count + } } + do_test walmode-1.3 { + set sqlite_sync_count + } $expected_sync_count } -do_test walmode-1.3 { - set sqlite_sync_count -} $expected_sync_count do_test walmode-1.4 { file exists test.db-wal @@ -106,9 +108,11 @@ do_test walmode-4.1 { execsql { INSERT INTO t1 VALUES(1, 2) } execsql { PRAGMA journal_mode = persist } } {persist} -do_test walmode-4.2 { - list [file exists test.db-journal] [file exists test.db-wal] -} {1 0} +if {[atomic_batch_write test.db]==0} { + do_test walmode-4.2 { + list [file exists test.db-journal] [file exists test.db-wal] + } {1 0} +} do_test walmode-4.3 { execsql { SELECT * FROM t1 } } {1 2} @@ -117,9 +121,11 @@ do_test walmode-4.4 { sqlite3 db test.db execsql { SELECT * FROM t1 } } {1 2} -do_test walmode-4.5 { - list [file exists test.db-journal] [file exists test.db-wal] -} {1 0} +if {[atomic_batch_write test.db]==0} { + do_test walmode-4.5 { + list [file exists test.db-journal] [file exists test.db-wal] + } {1 0} +} # Test that nothing goes wrong if a connection is prevented from changing # from WAL to rollback mode because a second connection has the database diff --git a/test/zerodamage.test b/test/zerodamage.test index a87e50b7b5..83bae737df 100644 --- a/test/zerodamage.test +++ b/test/zerodamage.test @@ -74,7 +74,7 @@ do_test zerodamage-2.0 { UPDATE t1 SET y=randomblob(50) WHERE x=123; } concat [file_control_powersafe_overwrite db -1] [set ::max_journal_size] -} {0 1 2576} +} [list 0 1 [expr ([atomic_batch_write test.db]==0)*2576]] # Repeat the previous step with zero-damage turned off. This time the # maximum rollback journal size should be much larger. @@ -87,7 +87,7 @@ do_test zerodamage-2.1 { UPDATE t1 SET y=randomblob(50) WHERE x=124; } concat [file_control_powersafe_overwrite db -1] [set ::max_journal_size] -} {0 0 24704} +} [list 0 0 [expr ([atomic_batch_write test.db]==0)*24704]] if {[wal_is_capable]} { # Run a WAL-mode transaction with POWERSAFE_OVERWRITE on to verify that the From 2483a111dbb53917457dea750e6869a4b9272a80 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 13 Jan 2018 14:01:26 +0000 Subject: [PATCH 127/190] Fix a typo in crash8.test. FossilOrigin-Name: c3dc7b8d9de94e46fae75fcc96ec68743205e0a2591e14391c394fff203004d1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/crash8.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4999390916..a2d500f819 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\svarious\sproblems\sin\stest\sscripts\spreventing\s"make\stest"\sfrom\spassing\son\nF2FS\sfile-systems\swith\sthe\s"atomic-write"\sfeature. -D 2018-01-13T13:07:49.167 +C Fix\sa\stypo\sin\scrash8.test. +D 2018-01-13T14:01:26.293 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -724,7 +724,7 @@ F test/crash4.test fe2821baf37168dc59dd733dcf7dba2a401487bc F test/crash5.test 05dd3aa9dbb751a22d5cdaf22a9c49b6667aa219 F test/crash6.test 4c56f1e40d0291e1110790a99807aa875b1647ba F test/crash7.test 1a194c4900a255258cf94b7fcbfd29536db572df -F test/crash8.test 64e464f22883be5184535a9620eb9070027073610d997bd2784227ca9564fb84 +F test/crash8.test 63cd5aea313222d7a69637cf7174c34d151676cc187d57193b66d4c89dedede3 F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bb196fcb677e962db4308c02097968615729a51fe4a1292e468aaf3e4bf522d3 -R 3bf69d486c995f84804eb3abae6dd335 +P 56d93d070d6b92d8a5a3fec1b09aae8911116c73d072fc5022f0b51668ed996b +R 095d7894b995bcb80e7e3cee4fddb19c U dan -Z ecacbd8e6749e1f68b1f30b320420a3c +Z 4ed30e44a783453de01bc7b75236f201 diff --git a/manifest.uuid b/manifest.uuid index a32f986633..69eabfe26d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -56d93d070d6b92d8a5a3fec1b09aae8911116c73d072fc5022f0b51668ed996b \ No newline at end of file +c3dc7b8d9de94e46fae75fcc96ec68743205e0a2591e14391c394fff203004d1 \ No newline at end of file diff --git a/test/crash8.test b/test/crash8.test index 2c6487b38b..7916e9b641 100644 --- a/test/crash8.test +++ b/test/crash8.test @@ -272,7 +272,7 @@ ifcapable pragma { if {[atomic_batch_write test.db]==0} { do_test crash8.4.1.1 { list [file exists test.db-journal] [file exists test2.db-journal] - } [list $bJrnl $bJrnl] + } {1 1} } do_test crash8-4.2 { From cdb60978b9f2251e903cdd100df8278615628aea Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 13 Jan 2018 14:28:00 +0000 Subject: [PATCH 128/190] Fully initialize the Mem object for serial-type 10, in case such a serial-type is found in a corrupt database file. FossilOrigin-Name: bd70a07d819a54346cb6c40fab681424c5af0dfb6bf29321a3de9fc99d285376 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/vdbeaux.c | 2 ++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 043e201dd1..8cef8f94b4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\svarious\sproblems\sin\stest\sscripts\spreventing\s"make\stest"\sfrom\spassing\son\nF2FS\sfile-systems\swith\sthe\s"atomic-write"\sfeature. -D 2018-01-13T14:02:16.056 +C Fully\sinitialize\sthe\sMem\sobject\sfor\sserial-type\s10,\sin\scase\ssuch\sa\nserial-type\sis\sfound\sin\sa\scorrupt\sdatabase\sfile. +D 2018-01-13T14:28:00.767 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -558,7 +558,7 @@ F src/vdbe.c ccc1e17a30325068ae4f0292e8601997946886d23acc989c68f2a261a2795c70 F src/vdbe.h 134beb7a12a6213c00eba58febaede33447cc4441bc568a0d9c144b33fc3720a F src/vdbeInt.h 5442fc816b6cf19c8801724199fd6b77a02eb31a7a174021713f8c59b30e51fa F src/vdbeapi.c 02f773681d06e46454b0606339068d4d4490873dc4a7334bc0c6030552bb2c8c -F src/vdbeaux.c fc124962c9900b19d201e57084a4302d07136a77f51fdbdfabd625a3ca3b6dc1 +F src/vdbeaux.c 2756ac68ac259c416554100598fc291870063288cd7e1af22847f57b3e130e56 F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191 F src/vdbemem.c 7548dd5af03d24d534a5dbc41e3bbdf1fab83e9c8856a8d2549ed2ccf33d0e80 F src/vdbesort.c 731a09e5cb9e96b70c394c1b7cf3860fbe84acca7682e178615eb941a3a0ef2f @@ -1699,8 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bb196fcb677e962db4308c02097968615729a51fe4a1292e468aaf3e4bf522d3 c3dc7b8d9de94e46fae75fcc96ec68743205e0a2591e14391c394fff203004d1 -R 095d7894b995bcb80e7e3cee4fddb19c -T +closed c3dc7b8d9de94e46fae75fcc96ec68743205e0a2591e14391c394fff203004d1 -U dan -Z 11c45edcc4119d583f229c1e527d94cf +P 6bedc7435d26c1f21c0d1b3a52daa0169fa5416b690a99347328dcafdcd78740 +R a7ff4a80a5a33de73167133f07814a11 +U drh +Z 940a381e739a90351c545fb8067ae8cb diff --git a/manifest.uuid b/manifest.uuid index 065366082a..b60772254f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6bedc7435d26c1f21c0d1b3a52daa0169fa5416b690a99347328dcafdcd78740 \ No newline at end of file +bd70a07d819a54346cb6c40fab681424c5af0dfb6bf29321a3de9fc99d285376 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 72a5b96bba..78777bd5a6 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3457,6 +3457,8 @@ u32 sqlite3VdbeSerialGet( case 10: { /* Internal use only: NULL with virtual table ** UPDATE no-change flag set */ pMem->flags = MEM_Null|MEM_Zero; + pMem->n = 0; + pMem->u.nZero = 0; break; } case 11: /* Reserved for future use */ From f42884c307241c46994b05915e356c7931c352bc Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 13 Jan 2018 19:08:24 +0000 Subject: [PATCH 129/190] Support UPDATE statements against zipfile virtual tables. FossilOrigin-Name: f2d2a5df4f29b47212fd2411eae6545087b901a270655640c87ceb472e02a24c --- ext/misc/zipfile.c | 302 +++++++++++++++++++++++++++------------------ manifest | 16 +-- manifest.uuid | 2 +- test/zipfile.test | 79 +++++++++++- 4 files changed, 267 insertions(+), 132 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 7ec8a222e7..88b7403f82 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -464,10 +464,47 @@ static u8* zipfileCsrBuffer(ZipfileCsr *pCsr){ /* ** Magic numbers used to read CDS records. */ -#define ZIPFILE_CDS_FIXED_SZ 46 -#define ZIPFILE_CDS_NFILE_OFF 28 +#define ZIPFILE_CDS_FIXED_SZ 46 +#define ZIPFILE_CDS_NFILE_OFF 28 -static int zipfileReadCDS(ZipfileCsr *pCsr){ +/* +** Decode the CDS record in buffer aBuf into (*pCDS). Return SQLITE_ERROR +** if the record is not well-formed, or SQLITE_OK otherwise. +*/ +static int zipfileReadCDS(u8 *aBuf, ZipfileCDS *pCDS){ + u8 *aRead = aBuf; + u32 sig = zipfileRead32(aRead); + int rc = SQLITE_OK; + if( sig!=ZIPFILE_SIGNATURE_CDS ){ + rc = SQLITE_ERROR; + }else{ + pCDS->iVersionMadeBy = zipfileRead16(aRead); + pCDS->iVersionExtract = zipfileRead16(aRead); + pCDS->flags = zipfileRead16(aRead); + pCDS->iCompression = zipfileRead16(aRead); + pCDS->mTime = zipfileRead16(aRead); + pCDS->mDate = zipfileRead16(aRead); + pCDS->crc32 = zipfileRead32(aRead); + pCDS->szCompressed = zipfileRead32(aRead); + pCDS->szUncompressed = zipfileRead32(aRead); + assert( aRead==&aBuf[ZIPFILE_CDS_NFILE_OFF] ); + pCDS->nFile = zipfileRead16(aRead); + pCDS->nExtra = zipfileRead16(aRead); + pCDS->nComment = zipfileRead16(aRead); + pCDS->iDiskStart = zipfileRead16(aRead); + pCDS->iInternalAttr = zipfileRead16(aRead); + pCDS->iExternalAttr = zipfileRead32(aRead); + pCDS->iOffset = zipfileRead32(aRead); + assert( aRead==&aBuf[ZIPFILE_CDS_FIXED_SZ] ); + } + + return rc; +} + +/* +** Read the CDS record for the current entry from disk into pCsr->cds. +*/ +static int zipfileCsrReadCDS(ZipfileCsr *pCsr){ char **pzErr = &pCsr->base.pVtab->zErrMsg; u8 *aRead; int rc = SQLITE_OK; @@ -485,41 +522,19 @@ static int zipfileReadCDS(ZipfileCsr *pCsr){ } if( rc==SQLITE_OK ){ - u32 sig = zipfileRead32(aRead); - if( sig!=ZIPFILE_SIGNATURE_CDS ){ + rc = zipfileReadCDS(aRead, &pCsr->cds); + if( rc!=SQLITE_OK ){ assert( pCsr->pCurrent==0 ); zipfileSetErrmsg(pCsr,"failed to read CDS at offset %lld",pCsr->iNextOff); - rc = SQLITE_ERROR; }else{ int nRead; - pCsr->cds.iVersionMadeBy = zipfileRead16(aRead); - pCsr->cds.iVersionExtract = zipfileRead16(aRead); - pCsr->cds.flags = zipfileRead16(aRead); - pCsr->cds.iCompression = zipfileRead16(aRead); - pCsr->cds.mTime = zipfileRead16(aRead); - pCsr->cds.mDate = zipfileRead16(aRead); - pCsr->cds.crc32 = zipfileRead32(aRead); - pCsr->cds.szCompressed = zipfileRead32(aRead); - pCsr->cds.szUncompressed = zipfileRead32(aRead); - assert( pCsr->pCurrent - || aRead==zipfileCsrBuffer(pCsr)+ZIPFILE_CDS_NFILE_OFF - ); - pCsr->cds.nFile = zipfileRead16(aRead); - pCsr->cds.nExtra = zipfileRead16(aRead); - pCsr->cds.nComment = zipfileRead16(aRead); - pCsr->cds.iDiskStart = zipfileRead16(aRead); - pCsr->cds.iInternalAttr = zipfileRead16(aRead); - pCsr->cds.iExternalAttr = zipfileRead32(aRead); - pCsr->cds.iOffset = zipfileRead32(aRead); - assert( pCsr->pCurrent - || aRead==zipfileCsrBuffer(pCsr)+ZIPFILE_CDS_FIXED_SZ - ); - if( pCsr->pCurrent==0 ){ nRead = pCsr->cds.nFile + pCsr->cds.nExtra; aRead = zipfileCsrBuffer(pCsr); pCsr->iNextOff += ZIPFILE_CDS_FIXED_SZ; rc = zipfileReadData(pCsr->pFile, aRead, nRead, pCsr->iNextOff, pzErr); + }else{ + aRead = &aRead[ZIPFILE_CDS_FIXED_SZ]; } if( rc==SQLITE_OK ){ @@ -570,37 +585,47 @@ static FILE *zipfileGetFd(ZipfileCsr *pCsr){ return ((ZipfileTab*)(pCsr->base.pVtab))->pWriteFd; } -static int zipfileReadLFH(ZipfileCsr *pCsr){ - FILE *pFile = zipfileGetFd(pCsr); - char **pzErr = &pCsr->base.pVtab->zErrMsg; +static int zipfileReadLFH( + FILE *pFd, + i64 iOffset, + u8 *aTmp, + ZipfileLFH *pLFH, + char **pzErr +){ + u8 *aRead = aTmp; static const int szFix = ZIPFILE_LFH_FIXED_SZ; - u8 *aRead = zipfileCsrBuffer(pCsr); int rc; - rc = zipfileReadData(pFile, aRead, szFix, pCsr->cds.iOffset, pzErr); + rc = zipfileReadData(pFd, aRead, szFix, iOffset, pzErr); if( rc==SQLITE_OK ){ u32 sig = zipfileRead32(aRead); if( sig!=ZIPFILE_SIGNATURE_LFH ){ - zipfileSetErrmsg(pCsr, "failed to read LFH at offset %d", - (int)pCsr->cds.iOffset - ); + *pzErr = sqlite3_mprintf("failed to read LFH at offset %d", (int)iOffset); rc = SQLITE_ERROR; }else{ - pCsr->lfh.iVersionExtract = zipfileRead16(aRead); - pCsr->lfh.flags = zipfileRead16(aRead); - pCsr->lfh.iCompression = zipfileRead16(aRead); - pCsr->lfh.mTime = zipfileRead16(aRead); - pCsr->lfh.mDate = zipfileRead16(aRead); - pCsr->lfh.crc32 = zipfileRead32(aRead); - pCsr->lfh.szCompressed = zipfileRead32(aRead); - pCsr->lfh.szUncompressed = zipfileRead32(aRead); - pCsr->lfh.nFile = zipfileRead16(aRead); - pCsr->lfh.nExtra = zipfileRead16(aRead); - assert( aRead==zipfileCsrBuffer(pCsr)+szFix ); - pCsr->iDataOff = pCsr->cds.iOffset+szFix+pCsr->lfh.nFile+pCsr->lfh.nExtra; + pLFH->iVersionExtract = zipfileRead16(aRead); + pLFH->flags = zipfileRead16(aRead); + pLFH->iCompression = zipfileRead16(aRead); + pLFH->mTime = zipfileRead16(aRead); + pLFH->mDate = zipfileRead16(aRead); + pLFH->crc32 = zipfileRead32(aRead); + pLFH->szCompressed = zipfileRead32(aRead); + pLFH->szUncompressed = zipfileRead32(aRead); + pLFH->nFile = zipfileRead16(aRead); + pLFH->nExtra = zipfileRead16(aRead); + assert( aRead==&aTmp[szFix] ); } } + return rc; +} +static int zipfileCsrReadLFH(ZipfileCsr *pCsr){ + FILE *pFile = zipfileGetFd(pCsr); + char **pzErr = &pCsr->base.pVtab->zErrMsg; + u8 *aRead = zipfileCsrBuffer(pCsr); + int rc = zipfileReadLFH(pFile, pCsr->cds.iOffset, aRead, &pCsr->lfh, pzErr); + pCsr->iDataOff = pCsr->cds.iOffset + ZIPFILE_LFH_FIXED_SZ; + pCsr->iDataOff += pCsr->lfh.nFile+pCsr->lfh.nExtra; return rc; } @@ -629,9 +654,9 @@ static int zipfileNext(sqlite3_vtab_cursor *cur){ } if( pCsr->bEof==0 ){ - rc = zipfileReadCDS(pCsr); + rc = zipfileCsrReadCDS(pCsr); if( rc==SQLITE_OK ){ - rc = zipfileReadLFH(pCsr); + rc = zipfileCsrReadLFH(pCsr); } } @@ -770,6 +795,9 @@ static int zipfileColumn( ){ ZipfileCsr *pCsr = (ZipfileCsr*)cur; int rc = SQLITE_OK; + if( i>=3 && sqlite3_vtab_nochange(ctx) ){ + return SQLITE_OK; + } switch( i ){ case 0: /* name */ sqlite3_result_text(ctx, pCsr->cds.zFile, -1, SQLITE_TRANSIENT); @@ -989,15 +1017,26 @@ static int zipfileBestIndex( ** Add object pNew to the end of the linked list that begins at ** ZipfileTab.pFirstEntry and ends with pLastEntry. */ -static void zipfileAddEntry(ZipfileTab *pTab, ZipfileEntry *pNew){ +static void zipfileAddEntry( + ZipfileTab *pTab, + ZipfileEntry *pBefore, + ZipfileEntry *pNew +){ assert( (pTab->pFirstEntry==0)==(pTab->pLastEntry==0) ); assert( pNew->pNext==0 ); - if( pTab->pFirstEntry==0 ){ - pTab->pFirstEntry = pTab->pLastEntry = pNew; + if( pBefore==0 ){ + if( pTab->pFirstEntry==0 ){ + pTab->pFirstEntry = pTab->pLastEntry = pNew; + }else{ + assert( pTab->pLastEntry->pNext==0 ); + pTab->pLastEntry->pNext = pNew; + pTab->pLastEntry = pNew; + } }else{ - assert( pTab->pLastEntry->pNext==0 ); - pTab->pLastEntry->pNext = pNew; - pTab->pLastEntry = pNew; + ZipfileEntry **pp; + for(pp=&pTab->pFirstEntry; *pp!=pBefore; pp=&((*pp)->pNext)); + pNew->pNext = pBefore; + *pp = pNew; } } @@ -1044,7 +1083,7 @@ static int zipfileLoadDirectory(ZipfileTab *pTab){ pNew->aCdsEntry = (u8*)&pNew->zPath[nFile+1]; pNew->nCdsEntry = ZIPFILE_CDS_FIXED_SZ+nFile+nExtra+nComment; memcpy(pNew->aCdsEntry, aRec, pNew->nCdsEntry); - zipfileAddEntry(pTab, pNew); + zipfileAddEntry(pTab, 0, pNew); } iOff += ZIPFILE_CDS_FIXED_SZ+nFile+nExtra+nComment; @@ -1168,7 +1207,7 @@ static int zipfileGetMode( u32 mode = 0; if( z==0 ){ mode = defaultMode; - }else if( z[0]>=0 && z[0]<=9 ){ + }else if( z[0]>='0' && z[0]<='9' ){ mode = (unsigned int)sqlite3_value_int(pVal); }else{ const char zTemplate[11] = "-rwxrwxrwx"; @@ -1231,79 +1270,104 @@ static int zipfileUpdate( u8 *pFree = 0; /* Free this */ char *zFree = 0; /* Also free this */ ZipfileCDS cds; /* New Central Directory Structure entry */ - + ZipfileEntry *pOld = 0; int bIsDir = 0; - int mNull; - assert( pTab->zFile ); assert( pTab->pWriteFd ); if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){ - if( nVal>1 ){ - return SQLITE_CONSTRAINT; - }else{ - const char *zDelete = (const char*)sqlite3_value_text(apVal[0]); - int nDelete = strlen(zDelete); - ZipfileEntry *p; - for(p=pTab->pFirstEntry; p; p=p->pNext){ - if( zipfileComparePath(p->zPath, zDelete, nDelete)==0 ){ - p->bDeleted = 1; - break; - } + const char *zDelete = (const char*)sqlite3_value_text(apVal[0]); + int nDelete = strlen(zDelete); + for(pOld=pTab->pFirstEntry; 1; pOld=pOld->pNext){ + if( pOld->bDeleted ) continue; + if( zipfileComparePath(pOld->zPath, zDelete, nDelete)==0 ){ + pOld->bDeleted = 1; + break; } - return SQLITE_OK; + assert( pOld->pNext ); } + if( nVal==1 ) return SQLITE_OK; } - mNull = (sqlite3_value_type(apVal[5])==SQLITE_NULL ? 0x0 : 0x8) /* sz */ - + (sqlite3_value_type(apVal[6])==SQLITE_NULL ? 0x0 : 0x4) /* rawdata */ - + (sqlite3_value_type(apVal[7])==SQLITE_NULL ? 0x0 : 0x2) /* data */ - + (sqlite3_value_type(apVal[8])==SQLITE_NULL ? 0x0 : 0x1); /* method */ - if( mNull==0x00 ){ - /* All four are NULL - this must be a directory */ - bIsDir = 1; - } - else if( mNull==0x2 || mNull==0x3 ){ - /* Value specified for "data", and possibly "method". This must be - ** a regular file or a symlink. */ - const u8 *aIn = sqlite3_value_blob(apVal[7]); - int nIn = sqlite3_value_bytes(apVal[7]); - int bAuto = sqlite3_value_type(apVal[8])==SQLITE_NULL; - - iMethod = sqlite3_value_int(apVal[8]); - sz = nIn; - if( iMethod!=0 && iMethod!=8 ){ - rc = SQLITE_CONSTRAINT; - }else if( bAuto || iMethod ){ - rc = zipfileDeflate(pTab, aIn, nIn, &pFree, &nData); + if( sqlite3_value_nochange(apVal[5]) && sqlite3_value_nochange(apVal[6]) + && sqlite3_value_nochange(apVal[7]) && sqlite3_value_nochange(apVal[8]) + ){ + /* Reuse the data from the existing entry. */ + FILE *pFile = pTab->pWriteFd; + ZipfileCDS cds; + zipfileReadCDS(pOld->aCdsEntry, &cds); + + bIsDir = ((cds.iExternalAttr>>16) & S_IFDIR) ? 1 : 0; + sz = cds.szUncompressed; + iMethod = cds.iCompression; + if( sz>0 ){ + char **pzErr = &pTab->base.zErrMsg; + ZipfileLFH lfh; + rc = zipfileReadLFH(pFile, cds.iOffset, pTab->aBuffer, &lfh, pzErr); if( rc==SQLITE_OK ){ - if( iMethod || nData65535 ){ - pTab->base.zErrMsg = sqlite3_mprintf( - "zipfile: invalid compression method: %d", iMethod - ); - rc = SQLITE_ERROR; + }else{ + int mNull; + mNull = (sqlite3_value_type(apVal[5])==SQLITE_NULL ? 0x0 : 0x8) /* sz */ + + (sqlite3_value_type(apVal[6])==SQLITE_NULL ? 0x0 : 0x4) /* rawdata */ + + (sqlite3_value_type(apVal[7])==SQLITE_NULL ? 0x0 : 0x2) /* data */ + + (sqlite3_value_type(apVal[8])==SQLITE_NULL ? 0x0 : 0x1); /* method */ + if( mNull==0x00 ){ + /* All four are NULL - this must be a directory */ + bIsDir = 1; + } + else if( mNull==0x2 || mNull==0x3 ){ + /* Value specified for "data", and possibly "method". This must be + ** a regular file or a symlink. */ + const u8 *aIn = sqlite3_value_blob(apVal[7]); + int nIn = sqlite3_value_bytes(apVal[7]); + int bAuto = sqlite3_value_type(apVal[8])==SQLITE_NULL; + + iMethod = sqlite3_value_int(apVal[8]); + sz = nIn; + pData = aIn; + nData = nIn; + if( iMethod!=0 && iMethod!=8 ){ + rc = SQLITE_CONSTRAINT; + }else if( bAuto || iMethod ){ + int nCmp; + rc = zipfileDeflate(pTab, aIn, nIn, &pFree, &nCmp); + if( rc==SQLITE_OK ){ + if( iMethod || nCmp65535 ){ + pTab->base.zErrMsg = sqlite3_mprintf( + "zipfile: invalid compression method: %d", iMethod + ); + rc = SQLITE_ERROR; + } + } + else{ + rc = SQLITE_CONSTRAINT; } - } - else{ - rc = SQLITE_CONSTRAINT; } if( rc==SQLITE_OK ){ @@ -1344,6 +1408,7 @@ static int zipfileUpdate( if( rc==SQLITE_OK ){ ZipfileEntry *p; for(p=pTab->pFirstEntry; p; p=p->pNext){ + if( p->bDeleted ) continue; if( zipfileComparePath(p->zPath, zPath, nPath)==0 ){ rc = SQLITE_CONSTRAINT; break; @@ -1368,7 +1433,7 @@ static int zipfileUpdate( if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ - zipfileAddEntry(pTab, pNew); + zipfileAddEntry(pTab, pOld, pNew); } } @@ -1377,6 +1442,9 @@ static int zipfileUpdate( rc = zipfileAppendEntry(pTab, &cds, zPath, nPath, pData, nData, (u32)mTime); } + if( rc!=SQLITE_OK && pOld ){ + pOld->bDeleted = 0; + } sqlite3_free(pFree); sqlite3_free(zFree); return rc; diff --git a/manifest b/manifest index 8cef8f94b4..5633e43082 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fully\sinitialize\sthe\sMem\sobject\sfor\sserial-type\s10,\sin\scase\ssuch\sa\nserial-type\sis\sfound\sin\sa\scorrupt\sdatabase\sfile. -D 2018-01-13T14:28:00.767 +C Support\sUPDATE\sstatements\sagainst\szipfile\svirtual\stables. +D 2018-01-13T19:08:24.877 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c e42d3ae79511ee86545bed07e9e5e7321f8139b55cdf73f60849352070bf12ad +F ext/misc/zipfile.c fd05292abc98fb9ad84ffc24ac8f39a25472c992f81d3ea6f3379e0df36ef4a1 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1600,7 +1600,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test 9c41628db7e8d9e8a0181e59ea5f189df311a9f6ce99cc376dc461f66db6f8dc -F test/zipfile.test a5cd98e91aebf343e21a32b97fadd6aefe02d249d5c6a1a3c2e624b88d7bdbe2 +F test/zipfile.test 61c6daf74f71f6d0c4d925cd7e23eb9ffe642491f8927b26aebba476d3244e50 F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6bedc7435d26c1f21c0d1b3a52daa0169fa5416b690a99347328dcafdcd78740 -R a7ff4a80a5a33de73167133f07814a11 -U drh -Z 940a381e739a90351c545fb8067ae8cb +P bd70a07d819a54346cb6c40fab681424c5af0dfb6bf29321a3de9fc99d285376 +R 353db64d08ace436e64659cf45ce290c +U dan +Z 6cc524f643589f82fe6965a2f7fe8556 diff --git a/manifest.uuid b/manifest.uuid index b60772254f..f828d42ddb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bd70a07d819a54346cb6c40fab681424c5af0dfb6bf29321a3de9fc99d285376 \ No newline at end of file +f2d2a5df4f29b47212fd2411eae6545087b901a270655640c87ceb472e02a24c \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index fe1ad89c55..e766cb31bf 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -76,12 +76,79 @@ do_execsql_test 1.5.1 { do_execsql_test 1.5.2 { SELECT name FROM zz; } {f.txt g.txt h.txt i.txt} +do_execsql_test 1.5.3 { + SELECT data FROM zz WHERE name='i.txt'; +} {zxcvb} do_execsql_test 1.6.0 { DELETE FROM zz WHERE name='g.txt'; SELECT name FROM zz; } {f.txt h.txt i.txt} +do_execsql_test 1.6.1 { + SELECT name, mode, mtime, data, method FROM zipfile('test.zip'); +} { + f.txt 33188 1000000000 abcde 0 + h.txt 33188 1000000004 aaaaaaaaaabbbbbbbbbb 8 + i.txt 33188 1000000006 zxcvb 0 +} + +do_execsql_test 1.6.2 { + UPDATE zz SET mtime=4 WHERE name='i.txt'; + SELECT name, mode, mtime, data, method FROM zipfile('test.zip'); +} { + f.txt 33188 1000000000 abcde 0 + h.txt 33188 1000000004 aaaaaaaaaabbbbbbbbbb 8 + i.txt 33188 4 zxcvb 0 +} + +do_execsql_test 1.6.3 { + UPDATE zz SET mode='-rw-r--r-x' WHERE name='h.txt'; + SELECT name, mode, mtime, data, method FROM zipfile('test.zip'); +} { + f.txt 33188 1000000000 abcde 0 + h.txt 33189 1000000004 aaaaaaaaaabbbbbbbbbb 8 + i.txt 33188 4 zxcvb 0 +} + +do_execsql_test 1.6.4 { + UPDATE zz SET name = 'blue.txt' WHERE name='f.txt'; + SELECT name, mode, mtime, data, method FROM zipfile('test.zip'); +} { + blue.txt 33188 1000000000 abcde 0 + h.txt 33189 1000000004 aaaaaaaaaabbbbbbbbbb 8 + i.txt 33188 4 zxcvb 0 +} + +do_execsql_test 1.6.5 { + UPDATE zz SET data = 'edcba' WHERE name='blue.txt'; + SELECT name, mode, mtime, data, method FROM zipfile('test.zip'); +} { + blue.txt 33188 1000000000 edcba 0 + h.txt 33189 1000000004 aaaaaaaaaabbbbbbbbbb 8 + i.txt 33188 4 zxcvb 0 +} + +do_execsql_test 1.6.6 { + UPDATE zz SET mode=NULL, data = NULL WHERE name='blue.txt'; + SELECT name, mode, mtime, data, method FROM zipfile('test.zip'); +} { + blue.txt/ 16877 1000000000 {} 0 + h.txt 33189 1000000004 aaaaaaaaaabbbbbbbbbb 8 + i.txt 33188 4 zxcvb 0 +} + +do_catchsql_test 1.6.7 { + UPDATE zz SET data=NULL WHERE name='i.txt' +} {1 {constraint failed}} +do_execsql_test 1.6.8 { + SELECT name, mode, mtime, data, method FROM zipfile('test.zip'); +} { + blue.txt/ 16877 1000000000 {} 0 + h.txt 33189 1000000004 aaaaaaaaaabbbbbbbbbb 8 + i.txt 33188 4 zxcvb 0 +} + #------------------------------------------------------------------------- db close forcedelete test.zip @@ -104,11 +171,11 @@ do_execsql_test 2.2 { do_catchsql_test 2.3 { UPDATE zzz SET name = 'dirname3' WHERE name = 'dirname/'; -} {1 {constraint failed}} +} {0 {}} do_execsql_test 2.4 { SELECT name, mode, data FROM zzz; } { - dirname/ 16877 {} + dirname3/ 16877 {} dirname2/ 16877 {} dirname2/file1.txt 33188 abcdefghijklmnop } @@ -118,11 +185,11 @@ do_execsql_test 2.4 { if {$::tcl_platform(platform)=="unix"} { do_test 2.5.1 { forcedelete dirname - forcedelete dirname2 - set rc [catch { exec unzip test.zip > /dev/null } msg] - list $rc $msg + forcedelete dirname2 + set rc [catch { exec unzip test.zip > /dev/null } msg] + list $rc $msg } {0 {}} - do_test 2.5.2 { file isdir dirname } 1 + do_test 2.5.2 { file isdir dirname3 } 1 do_test 2.5.3 { file isdir dirname2 } 1 do_test 2.5.4 { file isdir dirname2/file1.txt } 0 do_test 2.5.5 { From eb545004193ed95aa41213b8aa24496e158085ac Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 13 Jan 2018 23:28:33 +0000 Subject: [PATCH 130/190] Fix harmless compiler warnings in zipfile.c. FossilOrigin-Name: 8f7a592f8c044d75b4615a95e27454100b10c2b26f4cafee97dec23343821130 --- ext/misc/zipfile.c | 3 +-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 88b7403f82..63828e3c09 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -1278,7 +1278,7 @@ static int zipfileUpdate( if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){ const char *zDelete = (const char*)sqlite3_value_text(apVal[0]); - int nDelete = strlen(zDelete); + int nDelete = (int)strlen(zDelete); for(pOld=pTab->pFirstEntry; 1; pOld=pOld->pNext){ if( pOld->bDeleted ) continue; if( zipfileComparePath(pOld->zPath, zDelete, nDelete)==0 ){ @@ -1295,7 +1295,6 @@ static int zipfileUpdate( ){ /* Reuse the data from the existing entry. */ FILE *pFile = pTab->pWriteFd; - ZipfileCDS cds; zipfileReadCDS(pOld->aCdsEntry, &cds); bIsDir = ((cds.iExternalAttr>>16) & S_IFDIR) ? 1 : 0; diff --git a/manifest b/manifest index 5633e43082..296050499c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Support\sUPDATE\sstatements\sagainst\szipfile\svirtual\stables. -D 2018-01-13T19:08:24.877 +C Fix\sharmless\scompiler\swarnings\sin\szipfile.c. +D 2018-01-13T23:28:33.571 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c fd05292abc98fb9ad84ffc24ac8f39a25472c992f81d3ea6f3379e0df36ef4a1 +F ext/misc/zipfile.c 7001d7ca733d34a8b4fbacf7f8d322f3b2bf402f41052a021b5eda8227f0f5d4 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bd70a07d819a54346cb6c40fab681424c5af0dfb6bf29321a3de9fc99d285376 -R 353db64d08ace436e64659cf45ce290c -U dan -Z 6cc524f643589f82fe6965a2f7fe8556 +P f2d2a5df4f29b47212fd2411eae6545087b901a270655640c87ceb472e02a24c +R 8e0eefc806344b75dcd41a32589e33e5 +U drh +Z 25a119edfc3f91c75d6d9bd6eb4524cb diff --git a/manifest.uuid b/manifest.uuid index f828d42ddb..0bd548e74c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f2d2a5df4f29b47212fd2411eae6545087b901a270655640c87ceb472e02a24c \ No newline at end of file +8f7a592f8c044d75b4615a95e27454100b10c2b26f4cafee97dec23343821130 \ No newline at end of file From b058d05452079aee046a07e94a406b547c02b9f5 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 14 Jan 2018 20:12:23 +0000 Subject: [PATCH 131/190] Avoid excess stack usage when a VALUES clause with lots of rows occurs within a scalar expression. This fixes a problem discovered by OSSFuzz. FossilOrigin-Name: a4fa0581ba7cfd45fabe0198f55b3c2c8ee3ecfd2825aeed91116f44e77d760b --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 1 - src/select.c | 11 ++++++++--- test/selectG.test | 20 ++++++++++++++++++++ 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 296050499c..4a8b555cf8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\szipfile.c. -D 2018-01-13T23:28:33.571 +C Avoid\sexcess\sstack\susage\swhen\sa\sVALUES\sclause\swith\slots\sof\srows\soccurs\nwithin\sa\sscalar\sexpression.\s\sThis\sfixes\sa\sproblem\sdiscovered\sby\sOSSFuzz. +D 2018-01-14T20:12:23.878 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -438,7 +438,7 @@ F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957 F src/dbpage.c 8db4c97f630e7d83f884ea75caf1ffd0988c160e9d530194d93721c80821e0f6 F src/dbstat.c 7a4ba8518b6369ef3600c49cf9c918ad979acba610b2aebef1b656d649b96720 F src/delete.c 20c8788451dc737a967c87ea53ad43544d617f5b57d32ccce8bd52a0daf9e89b -F src/expr.c ad6e7a9c34a4bab9d10cc857d647ae7ce370a633b5c0bfa71f1c29b81ae364b8 +F src/expr.c 46a7d73d5579feaee7a7274fac0efea0bbae71dd5b107a569501d89e0280c762 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c d617daf66b5515e2b42c1405b2b4984c30ca50fb705ab164271a9bf66c69e331 F src/func.c bd528d5ed68ce5cbf78a762e3b735fa75009f7197ff07fab07fd771f35ebaa1b @@ -485,7 +485,7 @@ F src/printf.c 9506b4b96e59c0467047155f09015750cb2878aeda3d39e5610c1192ddc3c41c F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 +F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba F src/shell.c.in b87abffd0db09203ad8a133d56fe8f154ace5ec0a14197a153fb7d80b1438c01 F src/sqlite.h.in 9daf78e8f3cecc9ea0c3a82201f75bb74f789ecbfcda28d2e47fa80b3d956961 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1205,7 +1205,7 @@ F test/selectC.test e25243f8ca503e06f252eb0218976d07cfeceac3 F test/selectD.test b0f02a04ef7737decb24e08be2c39b9664b43394 F test/selectE.test a8730ca330fcf40ace158f134f4fe0eb00c7edbf F test/selectF.test 21c94e6438f76537b72532fa9fd4710cdd455fc3 -F test/selectG.test e8600e379589e85e9fefd2fe4d44a4cdd63f6982 +F test/selectG.test 089f7d3d7e6db91566f00b036cb353107a2cca6220eb1cb264085a836dae8840 F test/server1.test 46803bd3fe8b99b30dbc5ff38ffc756f5c13a118 F test/session.test 78fa2365e93d3663a6e933f86e7afc395adf18be F test/shared.test 1da9dbad400cee0d93f252ccf76e1ae007a63746 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f2d2a5df4f29b47212fd2411eae6545087b901a270655640c87ceb472e02a24c -R 8e0eefc806344b75dcd41a32589e33e5 +P 8f7a592f8c044d75b4615a95e27454100b10c2b26f4cafee97dec23343821130 +R 5b961a6038bd65800f58ecff32ab6963 U drh -Z 25a119edfc3f91c75d6d9bd6eb4524cb +Z 3c12035fed53223a4dcc5a3ae6914444 diff --git a/manifest.uuid b/manifest.uuid index 0bd548e74c..2a881ffea9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8f7a592f8c044d75b4615a95e27454100b10c2b26f4cafee97dec23343821130 \ No newline at end of file +a4fa0581ba7cfd45fabe0198f55b3c2c8ee3ecfd2825aeed91116f44e77d760b \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 32cc4423fa..a63de5d9fc 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2764,7 +2764,6 @@ int sqlite3CodeSubselect( pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0); } pSel->iLimit = 0; - pSel->selFlags &= ~SF_MultiValue; if( sqlite3Select(pParse, pSel, &dest) ){ return 0; } diff --git a/src/select.c b/src/select.c index 1a4b0a93af..c3cb4082fe 100644 --- a/src/select.c +++ b/src/select.c @@ -2184,9 +2184,14 @@ static int multiSelectOrderBy( ** on a VALUES clause. ** ** Because the Select object originates from a VALUES clause: -** (1) It has no LIMIT or OFFSET +** (1) There is no LIMIT or OFFSET or else there is a LIMIT of exactly 1 ** (2) All terms are UNION ALL ** (3) There is no ORDER BY clause +** +** The "LIMIT of exactly 1" case of condition (1) comes about when a VALUES +** clause occurs within scalar expression (ex: "SELECT (VALUES(1),(2),(3))"). +** The sqlite3CodeSubselect will have added the LIMIT 1 clause in tht case. +** Since the limit is exactly 1, we only need to evalutes the left-most VALUES. */ static int multiSelectValues( Parse *pParse, /* Parsing context */ @@ -2194,13 +2199,13 @@ static int multiSelectValues( SelectDest *pDest /* What to do with query results */ ){ Select *pPrior; + Select *pRightmost = p; int nRow = 1; int rc = 0; assert( p->selFlags & SF_MultiValue ); do{ assert( p->selFlags & SF_Values ); assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) ); - assert( p->pLimit==0 ); assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr ); if( p->pPrior==0 ) break; assert( p->pPrior->pNext==p ); @@ -2212,7 +2217,7 @@ static int multiSelectValues( p->pPrior = 0; rc = sqlite3Select(pParse, p, pDest); p->pPrior = pPrior; - if( rc ) break; + if( rc || pRightmost->pLimit ) break; p->nSelectRow = nRow; p = p->pNext; } diff --git a/test/selectG.test b/test/selectG.test index 86d89b121b..fab4c4ed4d 100644 --- a/test/selectG.test +++ b/test/selectG.test @@ -36,4 +36,24 @@ do_test 100 { } } {100000 5000050000 50000.5 1} +# 2018-01-14. A 100K-entry VALUES clause within a scalar expression does +# not cause processor stack overflow. +# +do_test 110 { + set sql "SELECT (VALUES" + for {set i 1} {$i<100000} {incr i} { + append sql "($i)," + } + append sql "($i));" + db eval $sql +} {1} + +# Only the left-most term of a multi-valued VALUES within a scalar +# expression is evaluated. +# +do_test 120 { + set n [llength [split [db eval "explain $sql"] \n]] + expr {$n<10} +} {1} + finish_test From a9be508a9766d69194212dd89c17d6feaa68cbc3 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 15 Jan 2018 14:32:37 +0000 Subject: [PATCH 132/190] Fix an error in the setDeviceCharacteristics() procedure for the (unsupported) QNX code in os_unix.c. FossilOrigin-Name: 8151913a3987f4dd2d6efee046727f5fa9b6f11d5d3867ea8f512c03a212ac2b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4a8b555cf8..687bdf64d0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sexcess\sstack\susage\swhen\sa\sVALUES\sclause\swith\slots\sof\srows\soccurs\nwithin\sa\sscalar\sexpression.\s\sThis\sfixes\sa\sproblem\sdiscovered\sby\sOSSFuzz. -D 2018-01-14T20:12:23.878 +C Fix\san\serror\sin\sthe\ssetDeviceCharacteristics()\sprocedure\sfor\sthe\n(unsupported)\sQNX\scode\sin\sos_unix.c. +D 2018-01-15T14:32:37.594 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -469,7 +469,7 @@ F src/os.c 22d31db3ca5a96a408fbf1ceeaaebcaf64c87024d2ff9fe1cf2ddbec3e75c104 F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c ecdffdc7fc25c07e42908be7c5ea30456fee6263e0d54cdf204557945b445da2 +F src/os_unix.c a82505be158d8ce42b38dcc9b426187d776904c12cdc68dc8925e1dfcc5cb6ce F src/os_win.c 0a4afa35cc8e812000df3ea2f64b476131b39e29e75d8007d0504726e4761de4 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9b9cb4e06c03d43d62480a7a685a012d645fcf3a39e7767ccb505fb41ee083ec @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8f7a592f8c044d75b4615a95e27454100b10c2b26f4cafee97dec23343821130 -R 5b961a6038bd65800f58ecff32ab6963 +P a4fa0581ba7cfd45fabe0198f55b3c2c8ee3ecfd2825aeed91116f44e77d760b +R 755347b860dbdbaa8de782672cfa2550 U drh -Z 3c12035fed53223a4dcc5a3ae6914444 +Z bf44e658c85afb034dcb761e50e86217 diff --git a/manifest.uuid b/manifest.uuid index 2a881ffea9..3e03feb0d3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a4fa0581ba7cfd45fabe0198f55b3c2c8ee3ecfd2825aeed91116f44e77d760b \ No newline at end of file +8151913a3987f4dd2d6efee046727f5fa9b6f11d5d3867ea8f512c03a212ac2b \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index d368cb34ea..94b1efd87d 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3950,7 +3950,7 @@ static void setDeviceCharacteristics(unixFile *pFile){ pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; pFile->deviceCharacteristics = 0; if( fstatvfs(pFile->h, &fsInfo) == -1 ) { - return pFile->sectorSize; + return; } if( !strcmp(fsInfo.f_basetype, "tmp") ) { From 89fa74694149ca5c4f57338f6f161737f991bedc Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 15 Jan 2018 15:49:46 +0000 Subject: [PATCH 133/190] Fix a zipfile problem with extracting zero length files compressed using deflate. FossilOrigin-Name: cf64087224aff1a2fe169d23996d9e5ed8d86459c655eb5d0bace0466a557ec6 --- ext/misc/zipfile.c | 129 ++++++++++++++++++++++++++++++++++++++++----- manifest | 14 ++--- manifest.uuid | 2 +- 3 files changed, 124 insertions(+), 21 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 63828e3c09..27f55f6c14 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -64,7 +64,7 @@ static const char ZIPFILE_SCHEMA[] = "rawdata," /* 4: Raw data */ "data," /* 5: Uncompressed data */ "method," /* 6: Compression method (integer) */ - "file HIDDEN" /* 7: Name of zip file */ + "z HIDDEN" /* 7: Name of zip file */ ") WITHOUT ROWID;"; #define ZIPFILE_F_COLUMN_IDX 7 /* Index of column "file" in the above */ @@ -235,6 +235,7 @@ struct ZipfileEntry { typedef struct ZipfileCsr ZipfileCsr; struct ZipfileCsr { sqlite3_vtab_cursor base; /* Base class - must be first */ + i64 iId; /* Cursor ID */ int bEof; /* True when at EOF */ /* Used outside of write transactions */ @@ -264,8 +265,10 @@ struct ZipfileTab { char *zFile; /* Zip file this table accesses (may be NULL) */ u8 *aBuffer; /* Temporary buffer used for various tasks */ - /* The following are used by write transactions only */ ZipfileCsr *pCsrList; /* List of cursors */ + i64 iNextCsrid; + + /* The following are used by write transactions only */ ZipfileEntry *pFirstEntry; /* Linked list of all files (if pWriteFd!=0) */ ZipfileEntry *pLastEntry; /* Last element in pFirstEntry list */ FILE *pWriteFd; /* File handle open on zip archive */ @@ -344,6 +347,7 @@ static int zipfileDisconnect(sqlite3_vtab *pVtab){ ** Constructor for a new ZipfileCsr object. */ static int zipfileOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){ + ZipfileTab *pTab = (ZipfileTab*)p; ZipfileCsr *pCsr; pCsr = sqlite3_malloc(sizeof(*pCsr)); *ppCsr = (sqlite3_vtab_cursor*)pCsr; @@ -351,6 +355,9 @@ static int zipfileOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){ return SQLITE_NOMEM; } memset(pCsr, 0, sizeof(*pCsr)); + pCsr->iId = ++pTab->iNextCsrid; + pCsr->pCsrNext = pTab->pCsrList; + pTab->pCsrList = pCsr; return SQLITE_OK; } @@ -359,14 +366,6 @@ static int zipfileOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){ ** by zipfileOpen(). */ static void zipfileResetCursor(ZipfileCsr *pCsr){ - ZipfileTab *pTab = (ZipfileTab*)(pCsr->base.pVtab); - ZipfileCsr **pp; - - /* Remove this cursor from the ZipfileTab.pCsrList list. */ - for(pp=&pTab->pCsrList; *pp; pp=&((*pp)->pCsrNext)){ - if( *pp==pCsr ) *pp = pCsr->pCsrNext; - } - sqlite3_free(pCsr->cds.zFile); pCsr->cds.zFile = 0; pCsr->bEof = 0; @@ -381,7 +380,18 @@ static void zipfileResetCursor(ZipfileCsr *pCsr){ */ static int zipfileClose(sqlite3_vtab_cursor *cur){ ZipfileCsr *pCsr = (ZipfileCsr*)cur; + ZipfileTab *pTab = (ZipfileTab*)(pCsr->base.pVtab); + ZipfileCsr **pp; zipfileResetCursor(pCsr); + + /* Remove this cursor from the ZipfileTab.pCsrList list. */ + for(pp=&pTab->pCsrList; *pp; pp=&((*pp)->pCsrNext)){ + if( *pp==pCsr ){ + *pp = pCsr->pCsrNext; + break; + } + } + sqlite3_free(pCsr); return SQLITE_OK; } @@ -823,7 +833,8 @@ static int zipfileColumn( case 5: { /* data */ if( i==4 || pCsr->cds.iCompression==0 || pCsr->cds.iCompression==8 ){ int sz = pCsr->cds.szCompressed; - if( sz>0 ){ + int szFinal = pCsr->cds.szUncompressed; + if( szFinal>0 ){ u8 *aBuf = sqlite3_malloc(sz); if( aBuf==0 ){ rc = SQLITE_NOMEM; @@ -835,12 +846,20 @@ static int zipfileColumn( } if( rc==SQLITE_OK ){ if( i==5 && pCsr->cds.iCompression ){ - zipfileInflate(ctx, aBuf, sz, pCsr->cds.szUncompressed); + zipfileInflate(ctx, aBuf, sz, szFinal); }else{ sqlite3_result_blob(ctx, aBuf, sz, SQLITE_TRANSIENT); } sqlite3_free(aBuf); } + }else{ + /* Figure out if this is a directory or a zero-sized file. Consider + ** it to be a directory either if the mode suggests so, or if + ** the final character in the name is '/'. */ + u32 mode = pCsr->cds.iExternalAttr >> 16; + if( !(mode & S_IFDIR) && pCsr->cds.zFile[pCsr->cds.nFile-1]!='/' ){ + sqlite3_result_blob(ctx, "", 0, SQLITE_STATIC); + } } } break; @@ -848,6 +867,9 @@ static int zipfileColumn( case 6: /* method */ sqlite3_result_int(ctx, pCsr->cds.iCompression); break; + case 7: /* z */ + sqlite3_result_int64(ctx, pCsr->iId); + break; } return SQLITE_OK; @@ -1553,6 +1575,84 @@ static int zipfileRollback(sqlite3_vtab *pVtab){ return zipfileCommit(pVtab); } +static ZipfileCsr *zipfileFindCursor(ZipfileTab *pTab, i64 iId){ + ZipfileCsr *pCsr; + for(pCsr=pTab->pCsrList; pCsr; pCsr=pCsr->pCsrNext){ + if( iId==pCsr->iId ) break; + } + return pCsr; +} + +static void zipfileFunctionCds( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + ZipfileCsr *pCsr; + ZipfileTab *pTab = (ZipfileTab*)sqlite3_user_data(context); + assert( argc>0 ); + + pCsr = zipfileFindCursor(pTab, sqlite3_value_int64(argv[0])); + if( pCsr ){ + ZipfileCDS *p = &pCsr->cds; + char *zRes = sqlite3_mprintf("{" + "\"version-made-by\" : %u, " + "\"version-to-extract\" : %u, " + "\"flags\" : %u, " + "\"compression\" : %u, " + "\"time\" : %u, " + "\"date\" : %u, " + "\"crc32\" : %u, " + "\"compressed-size\" : %u, " + "\"uncompressed-size\" : %u, " + "\"file-name-length\" : %u, " + "\"extra-field-length\" : %u, " + "\"file-comment-length\" : %u, " + "\"disk-number-start\" : %u, " + "\"internal-attr\" : %u, " + "\"external-attr\" : %u, " + "\"offset\" : %u }", + (u32)p->iVersionMadeBy, (u32)p->iVersionExtract, + (u32)p->flags, (u32)p->iCompression, + (u32)p->mTime, (u32)p->mDate, + (u32)p->crc32, (u32)p->szCompressed, + (u32)p->szUncompressed, (u32)p->nFile, + (u32)p->nExtra, (u32)p->nComment, + (u32)p->iDiskStart, (u32)p->iInternalAttr, + (u32)p->iExternalAttr, (u32)p->iOffset + ); + + if( zRes==0 ){ + sqlite3_result_error_nomem(context); + }else{ + sqlite3_result_text(context, zRes, -1, SQLITE_TRANSIENT); + sqlite3_free(zRes); + } + } +} + + +/* +** xFindFunction method. +*/ +static int zipfileFindFunction( + sqlite3_vtab *pVtab, /* Virtual table handle */ + int nArg, /* Number of SQL function arguments */ + const char *zName, /* Name of SQL function */ + void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */ + void **ppArg /* OUT: User data for *pxFunc */ +){ + if( nArg>0 ){ + if( sqlite3_stricmp("zipfile_cds", zName)==0 ){ + *pxFunc = zipfileFunctionCds; + *ppArg = (void*)pVtab; + return 1; + } + } + + return 0; +} + /* ** Register the "zipfile" virtual table. */ @@ -1576,11 +1676,14 @@ static int zipfileRegister(sqlite3 *db){ 0, /* xSync */ zipfileCommit, /* xCommit */ zipfileRollback, /* xRollback */ - 0, /* xFindMethod */ + zipfileFindFunction, /* xFindMethod */ 0, /* xRename */ }; int rc = sqlite3_create_module(db, "zipfile" , &zipfileModule, 0); + if( rc==SQLITE_OK ){ + rc = sqlite3_overload_function(db, "zipfile_cds", -1); + } return rc; } #else /* SQLITE_OMIT_VIRTUALTABLE */ diff --git a/manifest b/manifest index 687bdf64d0..f7654f5e02 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\serror\sin\sthe\ssetDeviceCharacteristics()\sprocedure\sfor\sthe\n(unsupported)\sQNX\scode\sin\sos_unix.c. -D 2018-01-15T14:32:37.594 +C Fix\sa\szipfile\sproblem\swith\sextracting\szero\slength\sfiles\scompressed\susing\ndeflate. +D 2018-01-15T15:49:46.517 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 7001d7ca733d34a8b4fbacf7f8d322f3b2bf402f41052a021b5eda8227f0f5d4 +F ext/misc/zipfile.c 46171a19439d0c76acf48770e736c281536f160d3a5a96a0511e34402e262fac F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a4fa0581ba7cfd45fabe0198f55b3c2c8ee3ecfd2825aeed91116f44e77d760b -R 755347b860dbdbaa8de782672cfa2550 -U drh -Z bf44e658c85afb034dcb761e50e86217 +P 8151913a3987f4dd2d6efee046727f5fa9b6f11d5d3867ea8f512c03a212ac2b +R d9864f9f3d3219c31b427d2f3aa9a193 +U dan +Z 4b1456c73d542678caf828eee79b5bff diff --git a/manifest.uuid b/manifest.uuid index 3e03feb0d3..19ee4478a0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8151913a3987f4dd2d6efee046727f5fa9b6f11d5d3867ea8f512c03a212ac2b \ No newline at end of file +cf64087224aff1a2fe169d23996d9e5ed8d86459c655eb5d0bace0466a557ec6 \ No newline at end of file From 2d620070b945c86515261863a6cbecc11bfd2991 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 15 Jan 2018 19:00:35 +0000 Subject: [PATCH 134/190] Fix a problem in the zipfile module causing it to generate incorrect checksums. Remove the ability to insert compressed data into a zip archive. FossilOrigin-Name: b0b7d0363acf38c2178e2d3041d8ce2a0de061a51caa64670dbf539ee6d4356b --- ext/misc/zipfile.c | 91 +++++++++++++--------------------------------- manifest | 14 +++---- manifest.uuid | 2 +- test/zipfile.test | 15 ++++++-- 4 files changed, 46 insertions(+), 76 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 27f55f6c14..f17b3735fb 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -805,9 +805,6 @@ static int zipfileColumn( ){ ZipfileCsr *pCsr = (ZipfileCsr*)cur; int rc = SQLITE_OK; - if( i>=3 && sqlite3_vtab_nochange(ctx) ){ - return SQLITE_OK; - } switch( i ){ case 0: /* name */ sqlite3_result_text(ctx, pCsr->cds.zFile, -1, SQLITE_TRANSIENT); @@ -826,10 +823,13 @@ static int zipfileColumn( break; } case 3: { /* sz */ - sqlite3_result_int64(ctx, pCsr->cds.szUncompressed); + if( sqlite3_vtab_nochange(ctx)==0 ){ + sqlite3_result_int64(ctx, pCsr->cds.szUncompressed); + } break; } case 4: /* rawdata */ + if( sqlite3_vtab_nochange(ctx) ) break; case 5: { /* data */ if( i==4 || pCsr->cds.iCompression==0 || pCsr->cds.iCompression==8 ){ int sz = pCsr->cds.szCompressed; @@ -872,7 +872,7 @@ static int zipfileColumn( break; } - return SQLITE_OK; + return rc; } /* @@ -908,7 +908,8 @@ static int zipfileReadEOCD( fseek(pFile, 0, SEEK_END); szFile = (i64)ftell(pFile); if( szFile==0 ){ - return SQLITE_EMPTY; + memset(pEOCD, 0, sizeof(ZipfileEOCD)); + return SQLITE_OK; } nRead = (int)(MIN(szFile, ZIPFILE_BUFFER_SIZE)); iOff = szFile - nRead; @@ -986,11 +987,12 @@ static int zipfileFilter( }else{ rc = zipfileReadEOCD(pTab, pCsr->pFile, &pCsr->eocd); if( rc==SQLITE_OK ){ - pCsr->iNextOff = pCsr->eocd.iOffset; - rc = zipfileNext(cur); - }else if( rc==SQLITE_EMPTY ){ - rc = SQLITE_OK; - pCsr->bEof = 1; + if( pCsr->eocd.nEntry==0 ){ + pCsr->bEof = 1; + }else{ + pCsr->iNextOff = pCsr->eocd.iOffset; + rc = zipfileNext(cur); + } } } }else{ @@ -1067,7 +1069,7 @@ static int zipfileLoadDirectory(ZipfileTab *pTab){ int rc; rc = zipfileReadEOCD(pTab, pTab->pWriteFd, &eocd); - if( rc==SQLITE_OK ){ + if( rc==SQLITE_OK && eocd.nEntry>0 ){ int i; int iOff = 0; u8 *aBuf = sqlite3_malloc(eocd.nSize); @@ -1112,8 +1114,6 @@ static int zipfileLoadDirectory(ZipfileTab *pTab){ } sqlite3_free(aBuf); - }else if( rc==SQLITE_EMPTY ){ - rc = SQLITE_OK; } return rc; @@ -1294,6 +1294,7 @@ static int zipfileUpdate( ZipfileCDS cds; /* New Central Directory Structure entry */ ZipfileEntry *pOld = 0; int bIsDir = 0; + u32 iCrc32 = 0; assert( pTab->zFile ); assert( pTab->pWriteFd ); @@ -1312,42 +1313,18 @@ static int zipfileUpdate( if( nVal==1 ) return SQLITE_OK; } - if( sqlite3_value_nochange(apVal[5]) && sqlite3_value_nochange(apVal[6]) - && sqlite3_value_nochange(apVal[7]) && sqlite3_value_nochange(apVal[8]) + /* Check that "sz" and "rawdata" are both NULL: */ + if( sqlite3_value_type(apVal[5])!=SQLITE_NULL + || sqlite3_value_type(apVal[6])!=SQLITE_NULL ){ - /* Reuse the data from the existing entry. */ - FILE *pFile = pTab->pWriteFd; - zipfileReadCDS(pOld->aCdsEntry, &cds); + rc = SQLITE_CONSTRAINT; + } - bIsDir = ((cds.iExternalAttr>>16) & S_IFDIR) ? 1 : 0; - sz = cds.szUncompressed; - iMethod = cds.iCompression; - if( sz>0 ){ - char **pzErr = &pTab->base.zErrMsg; - ZipfileLFH lfh; - rc = zipfileReadLFH(pFile, cds.iOffset, pTab->aBuffer, &lfh, pzErr); - if( rc==SQLITE_OK ){ - nData = lfh.szCompressed; - pData = pFree = sqlite3_malloc(nData); - if( pFree==NULL ){ - rc = SQLITE_NOMEM; - }else{ - i64 iRead = cds.iOffset + ZIPFILE_LFH_FIXED_SZ + lfh.nFile+lfh.nExtra; - rc = zipfileReadData(pFile, pFree, nData, iRead, pzErr); - } - } - } - }else{ - int mNull; - mNull = (sqlite3_value_type(apVal[5])==SQLITE_NULL ? 0x0 : 0x8) /* sz */ - + (sqlite3_value_type(apVal[6])==SQLITE_NULL ? 0x0 : 0x4) /* rawdata */ - + (sqlite3_value_type(apVal[7])==SQLITE_NULL ? 0x0 : 0x2) /* data */ - + (sqlite3_value_type(apVal[8])==SQLITE_NULL ? 0x0 : 0x1); /* method */ - if( mNull==0x00 ){ - /* All four are NULL - this must be a directory */ + if( rc==SQLITE_OK ){ + if( sqlite3_value_type(apVal[7])==SQLITE_NULL ){ + /* data=NULL. A directory */ bIsDir = 1; - } - else if( mNull==0x2 || mNull==0x3 ){ + }else{ /* Value specified for "data", and possibly "method". This must be ** a regular file or a symlink. */ const u8 *aIn = sqlite3_value_blob(apVal[7]); @@ -1370,25 +1347,9 @@ static int zipfileUpdate( nData = nCmp; } } + iCrc32 = crc32(0, aIn, nIn); } } - else if( mNull==0x0D ){ - /* Values specified for "sz", "rawdata" and "method". In other words, - ** pre-compressed data is being inserted. */ - pData = sqlite3_value_blob(apVal[6]); - nData = sqlite3_value_bytes(apVal[6]); - sz = sqlite3_value_int(apVal[5]); - iMethod = sqlite3_value_int(apVal[8]); - if( iMethod<0 || iMethod>65535 ){ - pTab->base.zErrMsg = sqlite3_mprintf( - "zipfile: invalid compression method: %d", iMethod - ); - rc = SQLITE_ERROR; - } - } - else{ - rc = SQLITE_CONSTRAINT; - } } if( rc==SQLITE_OK ){ @@ -1445,7 +1406,7 @@ static int zipfileUpdate( cds.flags = ZIPFILE_NEWENTRY_FLAGS; cds.iCompression = (u16)iMethod; zipfileMtimeToDos(&cds, (u32)mTime); - cds.crc32 = crc32(0, pData, nData); + cds.crc32 = iCrc32; cds.szCompressed = nData; cds.szUncompressed = (u32)sz; cds.iExternalAttr = (mode<<16); diff --git a/manifest b/manifest index f7654f5e02..47646bc8de 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\szipfile\sproblem\swith\sextracting\szero\slength\sfiles\scompressed\susing\ndeflate. -D 2018-01-15T15:49:46.517 +C Fix\sa\sproblem\sin\sthe\szipfile\smodule\scausing\sit\sto\sgenerate\sincorrect\nchecksums.\sRemove\sthe\sability\sto\sinsert\scompressed\sdata\sinto\sa\szip\sarchive. +D 2018-01-15T19:00:35.051 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 46171a19439d0c76acf48770e736c281536f160d3a5a96a0511e34402e262fac +F ext/misc/zipfile.c 7e48d2947a1fe71d22e54f3b499d6d0581efa105033683585d3dbde76cffaed7 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1600,7 +1600,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test 9c41628db7e8d9e8a0181e59ea5f189df311a9f6ce99cc376dc461f66db6f8dc -F test/zipfile.test 61c6daf74f71f6d0c4d925cd7e23eb9ffe642491f8927b26aebba476d3244e50 +F test/zipfile.test 71a9d37bb928a1dcee6ab624e8be7bca9f807364440d20fc84363c44ab2f4ac5 F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8151913a3987f4dd2d6efee046727f5fa9b6f11d5d3867ea8f512c03a212ac2b -R d9864f9f3d3219c31b427d2f3aa9a193 +P cf64087224aff1a2fe169d23996d9e5ed8d86459c655eb5d0bace0466a557ec6 +R 5e0c54dfbab7bd3d719e333800776169 U dan -Z 4b1456c73d542678caf828eee79b5bff +Z a41cf66d60fe2e5069108d980e3c47d6 diff --git a/manifest.uuid b/manifest.uuid index 19ee4478a0..78a1e43434 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cf64087224aff1a2fe169d23996d9e5ed8d86459c655eb5d0bace0466a557ec6 \ No newline at end of file +b0b7d0363acf38c2178e2d3041d8ce2a0de061a51caa64670dbf539ee6d4356b \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index e766cb31bf..e246c9ab18 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -36,13 +36,22 @@ do_execsql_test 1.0 { 6 method {} 0 {} 0 } -do_execsql_test 1.1.1 { +do_catchsql_test 1.1.0.1 { INSERT INTO zz(name, mode, mtime, sz, rawdata, method) VALUES('f.txt', '-rw-r--r--', 1000000000, 5, 'abcde', 0); -} -do_execsql_test 1.1.2 { +} {1 {constraint failed}} +do_catchsql_test 1.1.0.1 { INSERT INTO zz(name, mtime, sz, rawdata, method) VALUES('g.txt', 1000000002, 5, '12345', 0); +} {1 {constraint failed}} + +do_execsql_test 1.1.1 { + INSERT INTO zz(name, mode, mtime, data, method) + VALUES('f.txt', '-rw-r--r--', 1000000000, 'abcde', 0); +} +do_execsql_test 1.1.2 { + INSERT INTO zz(name, mode, mtime, data, method) + VALUES('g.txt', NULL, 1000000002, '12345', 0); } do_execsql_test 1.2 { From ded2d99d739f3c0b767883e1eea368cf6ecf78f8 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 16 Jan 2018 02:38:35 +0000 Subject: [PATCH 135/190] Disable the ".archive" command tests in shell8.test if the CLI is compiled without ZLIB support. FossilOrigin-Name: ce8bfe6c2b87090a2de1e04bc88fcb878597fe1f4ecd5df6d9d588a65601c901 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/shell8.test | 6 ++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 47646bc8de..fe09344538 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\szipfile\smodule\scausing\sit\sto\sgenerate\sincorrect\nchecksums.\sRemove\sthe\sability\sto\sinsert\scompressed\sdata\sinto\sa\szip\sarchive. -D 2018-01-15T19:00:35.051 +C Disable\sthe\s".archive"\scommand\stests\sin\sshell8.test\sif\sthe\sCLI\sis\scompiled\swithout\nZLIB\ssupport. +D 2018-01-16T02:38:35.189 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -1227,7 +1227,7 @@ F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f -F test/shell8.test c836470ccde867e1f438a7acad7560805cc04f9dbab84cb55d92925942b76247 +F test/shell8.test 96be02ea0c21f05b24c1883d7b711a1fa8525a68ab7b636aacf6057876941013 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cf64087224aff1a2fe169d23996d9e5ed8d86459c655eb5d0bace0466a557ec6 -R 5e0c54dfbab7bd3d719e333800776169 -U dan -Z a41cf66d60fe2e5069108d980e3c47d6 +P b0b7d0363acf38c2178e2d3041d8ce2a0de061a51caa64670dbf539ee6d4356b +R 7e32bbd83b21ce648e53afd2544cab2d +U drh +Z 4c459e37e4b5a5b61d3c298abef31f05 diff --git a/manifest.uuid b/manifest.uuid index 78a1e43434..82ff37d4da 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b0b7d0363acf38c2178e2d3041d8ce2a0de061a51caa64670dbf539ee6d4356b \ No newline at end of file +ce8bfe6c2b87090a2de1e04bc88fcb878597fe1f4ecd5df6d9d588a65601c901 \ No newline at end of file diff --git a/test/shell8.test b/test/shell8.test index de0f237f72..3658a8ac5d 100644 --- a/test/shell8.test +++ b/test/shell8.test @@ -21,6 +21,12 @@ ifcapable !vtab { } set CLI [test_find_cli] +# Check to make sure the shell has been compiled with ".archive" support. +# +if {[string match {*unknown command*} [catchcmd :memory: .archive]]} { + finish_test; return +} + proc populate_dir {dirname spec} { # First delete the current tree, if one exists. file delete -force $dirname From 0c2ba13e02348eff515dfc6f9028d562ade8403e Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 16 Jan 2018 13:37:43 +0000 Subject: [PATCH 136/190] Fix a problem causing an infinite loop or other malfunction in some UPDATE statements with an OR term in the WHERE clause. FossilOrigin-Name: feb2c2b6f66b0f45490beb1642d99cdb89fa220e299a8c118929df557c814189 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/where.c | 25 +++++++++++++++++++++---- test/update2.test | 15 +++++++++++++++ 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index fe09344538..31ecdf30e1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\s".archive"\scommand\stests\sin\sshell8.test\sif\sthe\sCLI\sis\scompiled\swithout\nZLIB\ssupport. -D 2018-01-16T02:38:35.189 +C Fix\sa\sproblem\scausing\san\sinfinite\sloop\sor\sother\smalfunction\sin\ssome\sUPDATE\nstatements\swith\san\sOR\sterm\sin\sthe\sWHERE\sclause. +D 2018-01-16T13:37:43.188 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -568,7 +568,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 5a3f464edd64596f601683ed321d12e6fd93c5fb9afdfb3653d6ffd0fee9c48f F src/wal.h 8de5d2d3de0956d6f6cb48c83a4012d5f227b8fe940f3a349a4b7e85ebcb492a F src/walker.c da987a20d40145c0a03c07d8fefcb2ed363becc7680d0500d9c79915591f5b1f -F src/where.c 36b92103f726609cc3dbe07c619426bd6886bede455de56ccff54c8e567f5582 +F src/where.c caf0b6c9d31f22f0b2c91aba723858de52b5d665aaa89034099015aaf9bb8219 F src/whereInt.h 82c04c5075308abbac59180c8bad5ecb45b07453981f60a53f3c7dee21e1e971 F src/wherecode.c af1e79154aaa88cd802d6f2e5b945f67eaca7c958d1525fbf8ee19d5bd7b9020 F src/whereexpr.c 427ea8e96ec24f2a7814c67b8024ad664a9c7656264c4566c34743cb23186e46 @@ -1490,7 +1490,7 @@ F test/unique2.test 3674e9f2a3f1fbbfd4772ac74b7a97090d0f77d2 F test/unixexcl.test d936ba2b06794018e136418addd59a2354eeae97 F test/unordered.test ca7adce0419e4ca0c50f039885e76ed2c531eda8 F test/update.test 6c68446b8a0a33d522a7c72b320934596a2d7d32 -F test/update2.test fffc92e72ae568fe048588762e650cd8ccbd8c8b6e4fe9099231766bfe4b51de +F test/update2.test 5e67667e1c54017d964e626db765cf8bedcf87483c184f4c575bdb8c1dd2313e F test/uri.test 3481026f00ade6dfe8adb7acb6e1e47b04369568 F test/uri2.test 9d3ba7a53ee167572d53a298ee4a5d38ec4a8fb7 F test/userauth01.test e740a2697a7b40d7c5003a7d7edaee16acd349a9 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b0b7d0363acf38c2178e2d3041d8ce2a0de061a51caa64670dbf539ee6d4356b -R 7e32bbd83b21ce648e53afd2544cab2d -U drh -Z 4c459e37e4b5a5b61d3c298abef31f05 +P ce8bfe6c2b87090a2de1e04bc88fcb878597fe1f4ecd5df6d9d588a65601c901 +R 1aa7995509c0f191863de5587ae93f47 +U dan +Z 2e5fd108f2c4172f1f8c00e9ff432235 diff --git a/manifest.uuid b/manifest.uuid index 82ff37d4da..239a9bce67 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ce8bfe6c2b87090a2de1e04bc88fcb878597fe1f4ecd5df6d9d588a65601c901 \ No newline at end of file +feb2c2b6f66b0f45490beb1642d99cdb89fa220e299a8c118929df557c814189 \ No newline at end of file diff --git a/src/where.c b/src/where.c index ec53527943..3152c8e9aa 100644 --- a/src/where.c +++ b/src/where.c @@ -4801,15 +4801,32 @@ WhereInfo *sqlite3WhereBegin( /* If the caller is an UPDATE or DELETE statement that is requesting ** to use a one-pass algorithm, determine if this is appropriate. + ** + ** A one-pass approach can be used if the caller has requested one + ** and either (a) the scan visits at most one row or (b) each + ** of the following are true: + ** + ** * the caller has indicated that a one-pass approach can be used + ** with multiple rows (by setting WHERE_ONEPASS_MULTIROW), and + ** * the table is not a virtual table, and + ** * either the scan does not use the OR optimization or the caller + ** is a DELETE operation (WHERE_DUPLICATES_OK is only specified + ** for DELETE). + ** + ** The last qualification is because an UPDATE statement uses + ** WhereInfo.aiCurOnePass[1] to determine whether or not it really can + ** use a one-pass approach, and this is not set accurately for scans + ** that use the OR optimization. */ assert( (wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || pWInfo->nLevel==1 ); if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 ){ int wsFlags = pWInfo->a[0].pWLoop->wsFlags; int bOnerow = (wsFlags & WHERE_ONEROW)!=0; - if( bOnerow - || ((wctrlFlags & WHERE_ONEPASS_MULTIROW)!=0 - && 0==(wsFlags & WHERE_VIRTUALTABLE)) - ){ + if( bOnerow || ( + 0!=(wctrlFlags & WHERE_ONEPASS_MULTIROW) + && 0==(wsFlags & WHERE_VIRTUALTABLE) + && (0==(wsFlags & WHERE_MULTI_OR) || (wctrlFlags & WHERE_DUPLICATES_OK)) + )){ pWInfo->eOnePass = bOnerow ? ONEPASS_SINGLE : ONEPASS_MULTI; if( HasRowid(pTabList->a[0].pTab) && (wsFlags & WHERE_IDX_ONLY) ){ if( wctrlFlags & WHERE_ONEPASS_MULTIROW ){ diff --git a/test/update2.test b/test/update2.test index af4ce96e7f..a6c3113400 100644 --- a/test/update2.test +++ b/test/update2.test @@ -200,5 +200,20 @@ do_test 5.2 { set A(NotExists) } {1} +#------------------------------------------------------------------------- +do_execsql_test 6.0 { + CREATE TABLE d1(a,b); + CREATE INDEX d1b ON d1(a); + CREATE INDEX d1c ON d1(b); + INSERT INTO d1 VALUES(1,2); +} + +do_execsql_test 6.1 { + UPDATE d1 SET a = a+2 WHERE a>0 OR b>0; +} + +do_execsql_test 6.2 { + SELECT * FROM d1; +} {3 2} finish_test From 194a17bbb7b58562792c3ed762f4eee6c683064f Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 16 Jan 2018 17:33:09 +0000 Subject: [PATCH 137/190] Change a cat in zipfile.c from (z_const Bytef*) to just (Bytef*). This allows the module to build with older versions of zlib. FossilOrigin-Name: ac9af91d5a2927e71903461e7bbdd2c0168fde9a042853c8bcd4c7ebd0d51e0d --- ext/misc/zipfile.c | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index f17b3735fb..5100bc4f79 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -771,7 +771,7 @@ static int zipfileDeflate( int res; z_stream str; memset(&str, 0, sizeof(str)); - str.next_in = (z_const Bytef*)aIn; + str.next_in = (Bytef*)aIn; str.avail_in = nIn; str.next_out = aOut; str.avail_out = nAlloc; diff --git a/manifest b/manifest index 31ecdf30e1..255197fd5b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scausing\san\sinfinite\sloop\sor\sother\smalfunction\sin\ssome\sUPDATE\nstatements\swith\san\sOR\sterm\sin\sthe\sWHERE\sclause. -D 2018-01-16T13:37:43.188 +C Change\sa\scat\sin\szipfile.c\sfrom\s(z_const\sBytef*)\sto\sjust\s(Bytef*).\sThis\sallows\sthe\smodule\sto\sbuild\swith\solder\sversions\sof\szlib. +D 2018-01-16T17:33:09.985 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 -F ext/misc/zipfile.c 7e48d2947a1fe71d22e54f3b499d6d0581efa105033683585d3dbde76cffaed7 +F ext/misc/zipfile.c cc12e900e12eec2358c0dc2cb341bf192217aab0932873958c62a4ae7cbf9988 F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842 F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ce8bfe6c2b87090a2de1e04bc88fcb878597fe1f4ecd5df6d9d588a65601c901 -R 1aa7995509c0f191863de5587ae93f47 +P feb2c2b6f66b0f45490beb1642d99cdb89fa220e299a8c118929df557c814189 +R 9fb18308fe7bf47a56b5953076efa014 U dan -Z 2e5fd108f2c4172f1f8c00e9ff432235 +Z cc16d38e7e88ca94b914298c53e9f0f1 diff --git a/manifest.uuid b/manifest.uuid index 239a9bce67..653213b754 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -feb2c2b6f66b0f45490beb1642d99cdb89fa220e299a8c118929df557c814189 \ No newline at end of file +ac9af91d5a2927e71903461e7bbdd2c0168fde9a042853c8bcd4c7ebd0d51e0d \ No newline at end of file From fff5367c24875cf771bfcdc0165c387cfdfe8365 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 16 Jan 2018 19:03:51 +0000 Subject: [PATCH 138/190] Show version of zlib in use when running the shell tool in interactive mode. FossilOrigin-Name: a8906b527a8f7a2cec88cc3b05c063a2785f0d1d141e148d954fc7440972a484 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 255197fd5b..9860dc22cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sa\scat\sin\szipfile.c\sfrom\s(z_const\sBytef*)\sto\sjust\s(Bytef*).\sThis\sallows\sthe\smodule\sto\sbuild\swith\solder\sversions\sof\szlib. -D 2018-01-16T17:33:09.985 +C Show\sversion\sof\szlib\sin\suse\swhen\srunning\sthe\sshell\stool\sin\sinteractive\smode. +D 2018-01-16T19:03:51.951 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -486,7 +486,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba -F src/shell.c.in b87abffd0db09203ad8a133d56fe8f154ace5ec0a14197a153fb7d80b1438c01 +F src/shell.c.in 594f9427e519a77b2d6d18e223b370caf9e81e588f47fd5dc463e0910365cdfa F src/sqlite.h.in 9daf78e8f3cecc9ea0c3a82201f75bb74f789ecbfcda28d2e47fa80b3d956961 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3737a51c5798e47a8ff2af0720f6dbc00fabd5ea401db392d05b1916085857a6 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P feb2c2b6f66b0f45490beb1642d99cdb89fa220e299a8c118929df557c814189 -R 9fb18308fe7bf47a56b5953076efa014 -U dan -Z cc16d38e7e88ca94b914298c53e9f0f1 +P ac9af91d5a2927e71903461e7bbdd2c0168fde9a042853c8bcd4c7ebd0d51e0d +R 039d269ff5ea61ab17b17f8244c27f58 +U mistachkin +Z 588ee2b95c490fe538f28f786da31468 diff --git a/manifest.uuid b/manifest.uuid index 653213b754..6dcfedfad6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac9af91d5a2927e71903461e7bbdd2c0168fde9a042853c8bcd4c7ebd0d51e0d \ No newline at end of file +a8906b527a8f7a2cec88cc3b05c063a2785f0d1d141e148d954fc7440972a484 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index ee21a83d6f..ce5294de81 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8380,6 +8380,9 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ "Enter \".help\" for usage hints.\n", sqlite3_libversion(), sqlite3_sourceid() ); +#if SQLITE_HAVE_ZLIB + printf("Using zlib version %s.\n", zlibVersion()); +#endif if( warnInmemoryDb ){ printf("Connected to a "); printBold("transient in-memory database"); From 0ed2fd8a254afeb2b6112ddba474cb21efa32eb0 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 16 Jan 2018 20:05:27 +0000 Subject: [PATCH 139/190] Move the ZLIB version announcement in the CLI out of the default banner and put it in the ".version" command. FossilOrigin-Name: 231679d6f8c0c3d957c8daa88b0743449b60b47159e114f4bc073a8612a73b2a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 9860dc22cc..a5f191ee14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Show\sversion\sof\szlib\sin\suse\swhen\srunning\sthe\sshell\stool\sin\sinteractive\smode. -D 2018-01-16T19:03:51.951 +C Move\sthe\sZLIB\sversion\sannouncement\sin\sthe\sCLI\sout\sof\sthe\sdefault\sbanner\nand\sput\sit\sin\sthe\s".version"\scommand. +D 2018-01-16T20:05:27.199 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -486,7 +486,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba -F src/shell.c.in 594f9427e519a77b2d6d18e223b370caf9e81e588f47fd5dc463e0910365cdfa +F src/shell.c.in 568aacb5b15520fa7981ebcf976ebd99849e6a4777858706762f201a446626f3 F src/sqlite.h.in 9daf78e8f3cecc9ea0c3a82201f75bb74f789ecbfcda28d2e47fa80b3d956961 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3737a51c5798e47a8ff2af0720f6dbc00fabd5ea401db392d05b1916085857a6 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ac9af91d5a2927e71903461e7bbdd2c0168fde9a042853c8bcd4c7ebd0d51e0d -R 039d269ff5ea61ab17b17f8244c27f58 -U mistachkin -Z 588ee2b95c490fe538f28f786da31468 +P a8906b527a8f7a2cec88cc3b05c063a2785f0d1d141e148d954fc7440972a484 +R 98c56f352f44e579ba7b90a6b8abb9cd +U drh +Z e359cfb1d91fd4e09231f1eb354cb112 diff --git a/manifest.uuid b/manifest.uuid index 6dcfedfad6..1d606c74b9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a8906b527a8f7a2cec88cc3b05c063a2785f0d1d141e148d954fc7440972a484 \ No newline at end of file +231679d6f8c0c3d957c8daa88b0743449b60b47159e114f4bc073a8612a73b2a \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index ce5294de81..523d7ef7bf 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -7537,6 +7537,20 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='v' && strncmp(azArg[0], "version", n)==0 ){ utf8_printf(p->out, "SQLite %s %s\n" /*extra-version-info*/, sqlite3_libversion(), sqlite3_sourceid()); +#if SQLITE_HAVE_ZLIB + utf8_printf(p->out, "zlib version %s\n", zlibVersion()); +#endif +#define CTIMEOPT_VAL_(opt) #opt +#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt) +#if defined(__clang__) && defined(__clang_major__) + utf8_printf(p->out, "clang-" CTIMEOPT_VAL(__clang_major__) "." + CTIMEOPT_VAL(__clang_minor__) "." + CTIMEOPT_VAL(__clang_patchlevel__) "\n"); +#elif defined(_MSC_VER) + utf8_printf(p->out, "msvc-" CTIMEOPT_VAL(_MSC_VER) "\n"); +#elif defined(__GNUC__) && defined(__VERSION__) + utf8_printf(p->out, "gcc-" __VERSION__ "\n"); +#endif }else if( c=='v' && strncmp(azArg[0], "vfsinfo", n)==0 ){ @@ -8380,9 +8394,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ "Enter \".help\" for usage hints.\n", sqlite3_libversion(), sqlite3_sourceid() ); -#if SQLITE_HAVE_ZLIB - printf("Using zlib version %s.\n", zlibVersion()); -#endif if( warnInmemoryDb ){ printf("Connected to a "); printBold("transient in-memory database"); From 70bc717c0eee621b753f8859c2cd24a1ce20953c Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 16 Jan 2018 20:20:00 +0000 Subject: [PATCH 140/190] Fix a makefile problem causing -DSQLITE_ENABLE_STMTVTAB builds to fail. FossilOrigin-Name: 7f6e5bdf9021c31e8bde82c224bf53be3c93b79f7bb5c2802c54be8031cf89fb --- main.mk | 3 ++- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/main.mk b/main.mk index 281de5d335..504ff34e1c 100644 --- a/main.mk +++ b/main.mk @@ -366,6 +366,7 @@ TESTSRC += \ $(TOP)/ext/misc/remember.c \ $(TOP)/ext/misc/series.c \ $(TOP)/ext/misc/spellfix.c \ + $(TOP)/ext/misc/stmt.c \ $(TOP)/ext/misc/totype.c \ $(TOP)/ext/misc/unionvtab.c \ $(TOP)/ext/misc/wholenumber.c \ @@ -373,7 +374,7 @@ TESTSRC += \ $(TOP)/ext/misc/zipfile.c \ $(TOP)/ext/fts5/fts5_tcl.c \ $(TOP)/ext/fts5/fts5_test_mi.c \ - $(TOP)/ext/fts5/fts5_test_tok.c + $(TOP)/ext/fts5/fts5_test_tok.c #TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c diff --git a/manifest b/manifest index a5f191ee14..bc0ce0d4a3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Move\sthe\sZLIB\sversion\sannouncement\sin\sthe\sCLI\sout\sof\sthe\sdefault\sbanner\nand\sput\sit\sin\sthe\s".version"\scommand. -D 2018-01-16T20:05:27.199 +C Fix\sa\smakefile\sproblem\scausing\s-DSQLITE_ENABLE_STMTVTAB\sbuilds\sto\sfail. +D 2018-01-16T20:20:00.594 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -408,7 +408,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk fc0edb268998a049ce70ee3dc056b2a96cc8aa4ef0c6da296700d7081d167627 +F main.mk 69bce07f975e6835a544f43df8d9619ea31d2c8e7b3a8d2cb4c21ac704c9c9c2 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a8906b527a8f7a2cec88cc3b05c063a2785f0d1d141e148d954fc7440972a484 -R 98c56f352f44e579ba7b90a6b8abb9cd -U drh -Z e359cfb1d91fd4e09231f1eb354cb112 +P 231679d6f8c0c3d957c8daa88b0743449b60b47159e114f4bc073a8612a73b2a +R 6b159b88b50b86cd5639c2b511315c42 +U dan +Z 8749febdaf33c2d94ed547e3c6b0b72c diff --git a/manifest.uuid b/manifest.uuid index 1d606c74b9..53e6471160 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -231679d6f8c0c3d957c8daa88b0743449b60b47159e114f4bc073a8612a73b2a \ No newline at end of file +7f6e5bdf9021c31e8bde82c224bf53be3c93b79f7bb5c2802c54be8031cf89fb \ No newline at end of file From eb0b6f364e1fc007fde8ebe40a447e098f49df72 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 16 Jan 2018 20:37:56 +0000 Subject: [PATCH 141/190] Remove the unused SQLITE_CANTOPEN_DIRTYWAL result code. FossilOrigin-Name: 3c786305fc6eaa6856ec6c71fc7969f61de266ba1bea0abf0ae133eb94e54b2d --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index bc0ce0d4a3..8e532533b7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smakefile\sproblem\scausing\s-DSQLITE_ENABLE_STMTVTAB\sbuilds\sto\sfail. -D 2018-01-16T20:20:00.594 +C Remove\sthe\sunused\sSQLITE_CANTOPEN_DIRTYWAL\sresult\scode. +D 2018-01-16T20:37:56.341 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -487,7 +487,7 @@ F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba F src/shell.c.in 568aacb5b15520fa7981ebcf976ebd99849e6a4777858706762f201a446626f3 -F src/sqlite.h.in 9daf78e8f3cecc9ea0c3a82201f75bb74f789ecbfcda28d2e47fa80b3d956961 +F src/sqlite.h.in 840e8aee0d7f8592bd69730797582b342a413eceaff7a220fb5f9db9c412cea9 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3737a51c5798e47a8ff2af0720f6dbc00fabd5ea401db392d05b1916085857a6 F src/sqliteInt.h 9c70315598b34810a83e4894455acb18e95cf63ce4e6cbb451ac2d17eabc2544 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 231679d6f8c0c3d957c8daa88b0743449b60b47159e114f4bc073a8612a73b2a -R 6b159b88b50b86cd5639c2b511315c42 -U dan -Z 8749febdaf33c2d94ed547e3c6b0b72c +P 7f6e5bdf9021c31e8bde82c224bf53be3c93b79f7bb5c2802c54be8031cf89fb +R 0d3241ffa7f896b9008a93ec004c8dbb +U drh +Z f5ef3a49cfd0d1f0bb95f024d28d366c diff --git a/manifest.uuid b/manifest.uuid index 53e6471160..3971e7693e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7f6e5bdf9021c31e8bde82c224bf53be3c93b79f7bb5c2802c54be8031cf89fb \ No newline at end of file +3c786305fc6eaa6856ec6c71fc7969f61de266ba1bea0abf0ae133eb94e54b2d \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 2661c8f35f..1f7f6a0792 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -510,7 +510,6 @@ int sqlite3_exec( #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) -#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) From 4bd387495fac0c8cf3474eac1b5aa388fa34761c Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 16 Jan 2018 20:44:00 +0000 Subject: [PATCH 142/190] Fix a test problem causing an error in fts5fault9.test. FossilOrigin-Name: 8e2048113fc6ed87fc7d5ba470261926aa0bd35474744bb2b99ea596bc468f02 --- ext/fts5/fts5_tcl.c | 4 ++-- ext/fts5/test/fts5fault9.test | 8 ++++++-- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index 8f79397fbf..c30ed4ae0d 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -482,7 +482,7 @@ static int SQLITE_TCLAPI xF5tApi( rc = p->pApi->xPhraseFirstColumn(p->pFts, iPhrase, &iter, &iCol); if( rc!=SQLITE_OK ){ - Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); + Tcl_SetResult(interp, sqlite3ErrName(rc), TCL_VOLATILE); return TCL_ERROR; } for( ; iCol>=0; p->pApi->xPhraseNextColumn(p->pFts, &iter, &iCol)){ @@ -924,7 +924,7 @@ static int SQLITE_TCLAPI f5tTokenizerReturn( rc = p->xToken(p->pCtx, tflags, zToken, nToken, iStart, iEnd); Tcl_SetResult(interp, (char*)sqlite3ErrName(rc), TCL_VOLATILE); - return TCL_OK; + return rc==SQLITE_OK ? TCL_OK : TCL_ERROR; usage: Tcl_WrongNumArgs(interp, 1, objv, "?-colocated? TEXT START END"); diff --git a/ext/fts5/test/fts5fault9.test b/ext/fts5/test/fts5fault9.test index 1daa5c1cc9..669b13efe7 100644 --- a/ext/fts5/test/fts5fault9.test +++ b/ext/fts5/test/fts5fault9.test @@ -24,6 +24,8 @@ ifcapable !fts5 { foreach_detail_mode $testprefix { +if {"%DETAIL%" != "none"} continue + fts5_aux_test_functions db do_execsql_test 1.0 { @@ -98,14 +100,16 @@ do_faultsim_test 4.1 -faults oom-t* -body { execsql { SELECT rowid, fts5_test_collist(t4) FROM t4('2') } } -test { faultsim_test_result \ - {0 {1 {0.0 0.1 0.2} 2 {0.0 0.1 0.2} 3 {0.0 0.1 0.2}}} {1 SQLITE_NOMEM} + {0 {1 {0.0 0.1 0.2} 2 {0.0 0.1 0.2} 3 {0.0 0.1 0.2}}} \ + {1 SQLITE_NOMEM} {1 SQLITE_ERROR} {1 {SQL logic error}} } do_faultsim_test 4.2 -faults oom-t* -body { execsql { SELECT rowid, fts5_test_collist(t4) FROM t4('a5 OR b5 OR c5') } } -test { faultsim_test_result \ - {0 {4 {0.0 0.1 0.2} 5 {1.0 1.1 1.2} 6 {2.0 2.1 2.2}}} {1 SQLITE_NOMEM} + {0 {4 {0.0 0.1 0.2} 5 {1.0 1.1 1.2} 6 {2.0 2.1 2.2}}} \ + {1 SQLITE_NOMEM} {1 SQLITE_ERROR} {1 {SQL logic error}} } diff --git a/manifest b/manifest index 8e532533b7..84a37b3671 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sunused\sSQLITE_CANTOPEN_DIRTYWAL\sresult\scode. -D 2018-01-16T20:37:56.341 +C Fix\sa\stest\sproblem\scausing\san\serror\sin\sfts5fault9.test. +D 2018-01-16T20:44:00.735 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -116,7 +116,7 @@ F ext/fts5/fts5_hash.c 32be400cf761868c9db33efe81a06eb19a17c5402ad477ee9efb51301 F ext/fts5/fts5_index.c 5fe14375a29e8a7aa8f3e863babe180a19269206c254c8f47b216821d4ac1e15 F ext/fts5/fts5_main.c 24868f88ab2a865defbba7a92eebeb726cc991eb092b71b5f5508f180c72605b F ext/fts5/fts5_storage.c fb5ef3c27073f67ade2e1bea08405f9e43f68f5f3676ed0ab7013bce5ba10be6 -F ext/fts5/fts5_tcl.c b470467be4c5cab2d8b026992c05d86cd2293e7d8c4a10ba56d5f4f707981097 +F ext/fts5/fts5_tcl.c a021468dfa204a4a48717d7709503ab062a010e8b79ea73e2a23ba5a0a9a6ec6 F ext/fts5/fts5_test_mi.c 65864ba1e5c34a61d409c4c587e0bbe0466eb4f8f478d85dc42a92caad1338e6 F ext/fts5/fts5_test_tok.c ffd657dd67e7fcdb31bf63fb60b6d867299a581d0f46e97086abacd66c2a9b26 F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 @@ -168,7 +168,7 @@ F ext/fts5/test/fts5fault5.test a336e4e11847de24c9497f80cce18e00bb3fab7fb11f97d0 F ext/fts5/test/fts5fault6.test 8a3c61402e36960ba46a419e73121fcefdc9160e0c04b6f5318c7fb0e3180dbc F ext/fts5/test/fts5fault7.test 0acbec416edb24b8881f154e99c31e9ccf73f539cfcd164090be139e9e97ed4c F ext/fts5/test/fts5fault8.test 318238659d35f82ad215ecb57ca4c87486ea85d45dbeedaee42f148ff5105ee2 -F ext/fts5/test/fts5fault9.test 0111b229388bdf251b91cfead68580227801dd30960a19aa8fe9021a1e73cb6d +F ext/fts5/test/fts5fault9.test 098e6b894bbdf9b2192f994a30f4043673fb3f338b6b8ab1624c704422f39119 F ext/fts5/test/fts5faultA.test be4487576bff8c22cee6597d1893b312f306504a8c6ccd3c53ca85af12290c8c F ext/fts5/test/fts5faultB.test e6d04f9ea7b21be1d89abb8df2cb4baf65b0453b744d5a805fcd3ef45ff86a7e F ext/fts5/test/fts5faultD.test cc5d1225556e356615e719c612e845d41bff7d5a @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7f6e5bdf9021c31e8bde82c224bf53be3c93b79f7bb5c2802c54be8031cf89fb -R 0d3241ffa7f896b9008a93ec004c8dbb -U drh -Z f5ef3a49cfd0d1f0bb95f024d28d366c +P 3c786305fc6eaa6856ec6c71fc7969f61de266ba1bea0abf0ae133eb94e54b2d +R 0c8190aebc59833d33e61d80979c7e84 +U dan +Z 09329f4d67456c2fa346b8eec49ecdd6 diff --git a/manifest.uuid b/manifest.uuid index 3971e7693e..0e21792b69 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3c786305fc6eaa6856ec6c71fc7969f61de266ba1bea0abf0ae133eb94e54b2d \ No newline at end of file +8e2048113fc6ed87fc7d5ba470261926aa0bd35474744bb2b99ea596bc468f02 \ No newline at end of file From 4a4532bbb7515e2e8cacb5acdbc2b126e24b93d5 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 16 Jan 2018 20:50:37 +0000 Subject: [PATCH 143/190] Make the new sqlite3_vtab_collation() interface accessible to loadable extensions. FossilOrigin-Name: f301db3c2343fd2086bc5b69a17b2d226175584ccd09549ebb2cb603590da487 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/loadext.c | 3 ++- src/sqlite3ext.h | 2 ++ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 84a37b3671..16dea517f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stest\sproblem\scausing\san\serror\sin\sfts5fault9.test. -D 2018-01-16T20:44:00.735 +C Make\sthe\snew\ssqlite3_vtab_collation()\sinterface\saccessible\sto\sloadable\nextensions. +D 2018-01-16T20:50:37.717 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -449,7 +449,7 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c 14686083cedc198540b15a79586cdd4be2acf6d5fa97627e355f817ab07e9fee F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e -F src/loadext.c 8d5d9c3ab3c4d600a161f389988bdee6a04dad7c4c1754f04f257734b9d1ce8c +F src/loadext.c f6e4e416a736369f9e80eba609f0acda97148a8b0453784d670c78d3eed2f302 F src/main.c 26918d50dd4a61b8f6f210320a522f46b5e7e592335b6aa664ab15b80b7c239b F src/malloc.c 07295435093ce354c6d9063ac05a2eeae28bd251d2e63c48b3d67c12c76f7e18 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -489,7 +489,7 @@ F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba F src/shell.c.in 568aacb5b15520fa7981ebcf976ebd99849e6a4777858706762f201a446626f3 F src/sqlite.h.in 840e8aee0d7f8592bd69730797582b342a413eceaff7a220fb5f9db9c412cea9 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 3737a51c5798e47a8ff2af0720f6dbc00fabd5ea401db392d05b1916085857a6 +F src/sqlite3ext.h 99189e7611eb0bf98f21c7835dc74730a84e2e809c98e1e31c33896dee7a2849 F src/sqliteInt.h 9c70315598b34810a83e4894455acb18e95cf63ce4e6cbb451ac2d17eabc2544 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c 9737ed017279a9e0c5da748701c3c7bf1e8ae0dae459aad20dd64fcff97a7e35 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3c786305fc6eaa6856ec6c71fc7969f61de266ba1bea0abf0ae133eb94e54b2d -R 0c8190aebc59833d33e61d80979c7e84 -U dan -Z 09329f4d67456c2fa346b8eec49ecdd6 +P 8e2048113fc6ed87fc7d5ba470261926aa0bd35474744bb2b99ea596bc468f02 +R 267bc65de959febfa028d4a40cdbf39c +U drh +Z 9b16902ddc51de02e55cd9f83731d91e diff --git a/manifest.uuid b/manifest.uuid index 0e21792b69..d7ea59dec0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e2048113fc6ed87fc7d5ba470261926aa0bd35474744bb2b99ea596bc468f02 \ No newline at end of file +f301db3c2343fd2086bc5b69a17b2d226175584ccd09549ebb2cb603590da487 \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index 80d40a4429..cf58237bf9 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -433,7 +433,8 @@ static const sqlite3_api_routines sqlite3Apis = { sqlite3_value_pointer, /* Version 3.22.0 and later */ sqlite3_vtab_nochange, - sqlite3_value_nochange + sqlite3_value_nochange, + sqlite3_vtab_collation }; /* diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 4252063909..ac92a74901 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -294,6 +294,7 @@ struct sqlite3_api_routines { void *(*value_pointer)(sqlite3_value*,const char*); int (*vtab_nochange)(sqlite3_context*); int (*value_nochange)(sqlite3_value*); + const char *(*vtab_collation)(sqlite3_index_info*,int); }; /* @@ -563,6 +564,7 @@ typedef int (*sqlite3_loadext_entry)( /* Version 3.22.0 and later */ #define sqlite3_vtab_nochange sqlite3_api->vtab_nochange #define sqlite3_value_nochange sqltie3_api->value_nochange +#define sqlite3_vtab_collation sqltie3_api->vtab_collation #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) From 2d9e8c55dab0e7a38a179a65e7c87e8ee94b59d6 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 16 Jan 2018 21:00:58 +0000 Subject: [PATCH 144/190] Fix compiler warning in the FTS5 test interface. FossilOrigin-Name: 2ab4e8d5d82ab410c00f048c12555f2f40f9fd8bffda64ccbdd3dfe036727315 --- ext/fts5/fts5_tcl.c | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/fts5/fts5_tcl.c b/ext/fts5/fts5_tcl.c index c30ed4ae0d..f33dcae033 100644 --- a/ext/fts5/fts5_tcl.c +++ b/ext/fts5/fts5_tcl.c @@ -482,7 +482,7 @@ static int SQLITE_TCLAPI xF5tApi( rc = p->pApi->xPhraseFirstColumn(p->pFts, iPhrase, &iter, &iCol); if( rc!=SQLITE_OK ){ - Tcl_SetResult(interp, sqlite3ErrName(rc), TCL_VOLATILE); + Tcl_SetResult(interp, (char*)sqlite3ErrName(rc), TCL_VOLATILE); return TCL_ERROR; } for( ; iCol>=0; p->pApi->xPhraseNextColumn(p->pFts, &iter, &iCol)){ diff --git a/manifest b/manifest index 16dea517f1..c2ef7d0ba3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\snew\ssqlite3_vtab_collation()\sinterface\saccessible\sto\sloadable\nextensions. -D 2018-01-16T20:50:37.717 +C Fix\scompiler\swarning\sin\sthe\sFTS5\stest\sinterface. +D 2018-01-16T21:00:58.725 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -116,7 +116,7 @@ F ext/fts5/fts5_hash.c 32be400cf761868c9db33efe81a06eb19a17c5402ad477ee9efb51301 F ext/fts5/fts5_index.c 5fe14375a29e8a7aa8f3e863babe180a19269206c254c8f47b216821d4ac1e15 F ext/fts5/fts5_main.c 24868f88ab2a865defbba7a92eebeb726cc991eb092b71b5f5508f180c72605b F ext/fts5/fts5_storage.c fb5ef3c27073f67ade2e1bea08405f9e43f68f5f3676ed0ab7013bce5ba10be6 -F ext/fts5/fts5_tcl.c a021468dfa204a4a48717d7709503ab062a010e8b79ea73e2a23ba5a0a9a6ec6 +F ext/fts5/fts5_tcl.c 39bcbae507f594aad778172fa914cad0f585bf92fd3b078c686e249282db0d95 F ext/fts5/fts5_test_mi.c 65864ba1e5c34a61d409c4c587e0bbe0466eb4f8f478d85dc42a92caad1338e6 F ext/fts5/fts5_test_tok.c ffd657dd67e7fcdb31bf63fb60b6d867299a581d0f46e97086abacd66c2a9b26 F ext/fts5/fts5_tokenize.c 2ce7b44183538ec46b7907726262ee43ffdd39a8 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8e2048113fc6ed87fc7d5ba470261926aa0bd35474744bb2b99ea596bc468f02 -R 267bc65de959febfa028d4a40cdbf39c +P f301db3c2343fd2086bc5b69a17b2d226175584ccd09549ebb2cb603590da487 +R 0b7a4854cd40ff8848724ee789fa5f0a U drh -Z 9b16902ddc51de02e55cd9f83731d91e +Z a8abeaf4b85a720e69d65b8f52daa4a1 diff --git a/manifest.uuid b/manifest.uuid index d7ea59dec0..d471974b0f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f301db3c2343fd2086bc5b69a17b2d226175584ccd09549ebb2cb603590da487 \ No newline at end of file +2ab4e8d5d82ab410c00f048c12555f2f40f9fd8bffda64ccbdd3dfe036727315 \ No newline at end of file From 8c9e30ba2f1ae1b70129a4a34e3659f177d7d816 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 16 Jan 2018 21:05:10 +0000 Subject: [PATCH 145/190] Remove an unused field from the internal definition of the sqlite3_context object. FossilOrigin-Name: 948a26b5a64d8a89c4ec7546ec4a4bee36e29e82edda677ca75424e7091325d0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeInt.h | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c2ef7d0ba3..0b65bd2902 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompiler\swarning\sin\sthe\sFTS5\stest\sinterface. -D 2018-01-16T21:00:58.725 +C Remove\san\sunused\sfield\sfrom\sthe\sinternal\sdefinition\sof\sthe\ssqlite3_context\nobject. +D 2018-01-16T21:05:10.561 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -556,7 +556,7 @@ F src/util.c 7315e97a8dc2c8e19ca64196c652cf0a65d13fd0a211b2cec082062372dc6261 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 F src/vdbe.c ccc1e17a30325068ae4f0292e8601997946886d23acc989c68f2a261a2795c70 F src/vdbe.h 134beb7a12a6213c00eba58febaede33447cc4441bc568a0d9c144b33fc3720a -F src/vdbeInt.h 5442fc816b6cf19c8801724199fd6b77a02eb31a7a174021713f8c59b30e51fa +F src/vdbeInt.h c8cfbbc28e37e67a493c3f892fb0596add56a31a00e7537a06049af9ef2f51b0 F src/vdbeapi.c 02f773681d06e46454b0606339068d4d4490873dc4a7334bc0c6030552bb2c8c F src/vdbeaux.c 2756ac68ac259c416554100598fc291870063288cd7e1af22847f57b3e130e56 F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f301db3c2343fd2086bc5b69a17b2d226175584ccd09549ebb2cb603590da487 -R 0b7a4854cd40ff8848724ee789fa5f0a +P 2ab4e8d5d82ab410c00f048c12555f2f40f9fd8bffda64ccbdd3dfe036727315 +R e4f4080f808433f06cbdcdcd7e3a3a16 U drh -Z a8abeaf4b85a720e69d65b8f52daa4a1 +Z f5b1113de44f2b59daf15f747c8d38d4 diff --git a/manifest.uuid b/manifest.uuid index d471974b0f..63872b4ad3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2ab4e8d5d82ab410c00f048c12555f2f40f9fd8bffda64ccbdd3dfe036727315 \ No newline at end of file +948a26b5a64d8a89c4ec7546ec4a4bee36e29e82edda677ca75424e7091325d0 \ No newline at end of file diff --git a/src/vdbeInt.h b/src/vdbeInt.h index b7e324c94b..976abb3938 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -320,7 +320,6 @@ struct sqlite3_context { int isError; /* Error code returned by the function. */ u8 skipFlag; /* Skip accumulator loading if true */ u8 fErrorOrAux; /* isError!=0 or pVdbe->pAuxData modified */ - u8 bVtabNoChng; /* Fetching an unchanging column in a vtab UPDATE */ u8 argc; /* Number of arguments */ sqlite3_value *argv[1]; /* Argument set */ }; From 2879952faac68d9350f7b149fdbfa80a3bee5b9b Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 16 Jan 2018 21:09:00 +0000 Subject: [PATCH 146/190] Fix a problem causing zipfile to store 0 in place of the CRC32 value for uncompressed files. FossilOrigin-Name: ba44724bcca2e87788b7c6d8c5de7fa388360127bd894ee6a171fd66e794fcae --- ext/misc/zipfile.c | 18 ++++++++++-------- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/zipfile.test | 9 +++++++++ 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c index 5100bc4f79..fa31d62d11 100644 --- a/ext/misc/zipfile.c +++ b/ext/misc/zipfile.c @@ -1337,14 +1337,16 @@ static int zipfileUpdate( nData = nIn; if( iMethod!=0 && iMethod!=8 ){ rc = SQLITE_CONSTRAINT; - }else if( bAuto || iMethod ){ - int nCmp; - rc = zipfileDeflate(pTab, aIn, nIn, &pFree, &nCmp); - if( rc==SQLITE_OK ){ - if( iMethod || nCmp Date: Wed, 17 Jan 2018 01:15:08 +0000 Subject: [PATCH 147/190] Fix duplicate test names in 'walfault.test'. FossilOrigin-Name: 7274d05ff43fc9872f0e4857ae583689e4a6c429b7fa991dcc29744da3048879 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/walfault.test | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 8d65b34b6c..c0e128cc24 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scausing\szipfile\sto\sstore\s0\sin\splace\sof\sthe\sCRC32\svalue\sfor\nuncompressed\sfiles. -D 2018-01-16T21:09:00.543 +C Fix\sduplicate\stest\snames\sin\s'walfault.test'. +D 2018-01-17T01:15:08.464 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -1544,7 +1544,7 @@ F test/walcrash.test 21038858cc552077b0522f50b0fa87e38139306a F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36 F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af F test/walcrash4.test e7b6e7639a950a0cca8e210e248c8dad4d63bf20 -F test/walfault.test 1f8389f7709877e9b4cc679033d71d6fe529056b +F test/walfault.test 09b8ad7e52d2f54bce50e31aa7ea51412bb9f70ac13c74e669ddcd8b48b0d98d F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test cd6e7cff618eaaa5910ce57c3657aa50110397f86213886a2400afb9bfec7b7b F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 948a26b5a64d8a89c4ec7546ec4a4bee36e29e82edda677ca75424e7091325d0 -R fa20b259f24a93ee214da4f46c94ddf6 -U dan -Z c12f29c5e46aaf9ede6fab6c939cd772 +P ba44724bcca2e87788b7c6d8c5de7fa388360127bd894ee6a171fd66e794fcae +R f3a35383cfb8ac5b9a76f4dd696ca9d1 +U mistachkin +Z 9ba015577ebd6a341cfca228abd228a2 diff --git a/manifest.uuid b/manifest.uuid index 95edffa509..e4ae655096 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ba44724bcca2e87788b7c6d8c5de7fa388360127bd894ee6a171fd66e794fcae \ No newline at end of file +7274d05ff43fc9872f0e4857ae583689e4a6c429b7fa991dcc29744da3048879 \ No newline at end of file diff --git a/test/walfault.test b/test/walfault.test index 4e7064d53b..6cb760b258 100644 --- a/test/walfault.test +++ b/test/walfault.test @@ -552,7 +552,7 @@ do_faultsim_test walfault-14 -prep { #------------------------------------------------------------------------- # Test fault-handling when switching out of exclusive-locking mode. # -do_test walfault-14-pre { +do_test walfault-15-pre { faultsim_delete_and_reopen execsql { PRAGMA auto_vacuum = 0; @@ -565,7 +565,7 @@ do_test walfault-14-pre { } faultsim_save_and_close } {} -do_faultsim_test walfault-14 -prep { +do_faultsim_test walfault-15 -prep { faultsim_restore_and_reopen execsql { SELECT count(*) FROM abc; From 5685257b83124cffa6e22c4dafedd8ca3060f390 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 17 Jan 2018 01:26:05 +0000 Subject: [PATCH 148/190] Corrections to error code handling in os_win.c, pursuant to walfault.test. FossilOrigin-Name: 568192228c9578b8ea34c363e10ff28450045cda76248b2f0f89f84b3a57e680 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 30 ++++++++++++++++++++---------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index c0e128cc24..2670429108 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sduplicate\stest\snames\sin\s'walfault.test'. -D 2018-01-17T01:15:08.464 +C Corrections\sto\serror\scode\shandling\sin\sos_win.c,\spursuant\sto\swalfault.test. +D 2018-01-17T01:26:05.915 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -470,7 +470,7 @@ F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c a82505be158d8ce42b38dcc9b426187d776904c12cdc68dc8925e1dfcc5cb6ce -F src/os_win.c 0a4afa35cc8e812000df3ea2f64b476131b39e29e75d8007d0504726e4761de4 +F src/os_win.c 196b2b38953a3678e0ae1be40875c9c303ff216ec56ac2a6721e56ce9a9a454e F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9b9cb4e06c03d43d62480a7a685a012d645fcf3a39e7767ccb505fb41ee083ec F src/pager.h 581698f2177e8bd4008fe4760898ce20b6133d1df22139b9101b5155f900df7a @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ba44724bcca2e87788b7c6d8c5de7fa388360127bd894ee6a171fd66e794fcae -R f3a35383cfb8ac5b9a76f4dd696ca9d1 +P 7274d05ff43fc9872f0e4857ae583689e4a6c429b7fa991dcc29744da3048879 +R a85767f9e76828ee76ff125e1a16892d U mistachkin -Z 9ba015577ebd6a341cfca228abd228a2 +Z 21eee94f9fdd383abaac3542e6cde8fb diff --git a/manifest.uuid b/manifest.uuid index e4ae655096..f91d56d71c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7274d05ff43fc9872f0e4857ae583689e4a6c429b7fa991dcc29744da3048879 \ No newline at end of file +568192228c9578b8ea34c363e10ff28450045cda76248b2f0f89f84b3a57e680 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index e3243a9c68..6df66f1d7a 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -3899,6 +3899,8 @@ static int winOpenSharedMemory(winFile *pDbFd){ if( pShmNode ){ sqlite3_free(pNew); }else{ + int bReadonly; + pShmNode = pNew; pNew = 0; ((winFile*)(&pShmNode->hFile))->h = INVALID_HANDLE_VALUE; @@ -3913,7 +3915,9 @@ static int winOpenSharedMemory(winFile *pDbFd){ } } - if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){ + bReadonly = sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0); + + if( !bReadonly ){ rc2 = winOpen(pDbFd->pVfs, pShmNode->zFilename, (sqlite3_file*)&pShmNode->hFile, @@ -3921,13 +3925,13 @@ static int winOpenSharedMemory(winFile *pDbFd){ 0); } if( rc2!=SQLITE_OK ){ - rc2 = winOpen(pDbFd->pVfs, + int rc3 = winOpen(pDbFd->pVfs, pShmNode->zFilename, (sqlite3_file*)&pShmNode->hFile, SQLITE_OPEN_WAL|SQLITE_OPEN_READONLY, 0); - if( rc2!=SQLITE_OK ){ - rc = winLogError(rc2, osGetLastError(), "winOpenShm", + if( rc3!=SQLITE_OK ){ + rc = winLogError(bReadonly ? rc3 : rc2, osGetLastError(), "winOpenShm", pShmNode->zFilename); goto shm_open_err; } @@ -5118,8 +5122,10 @@ static int winOpen( &extendedParameters); if( h!=INVALID_HANDLE_VALUE ) break; if( isReadWrite ){ - int isRO = 0; - int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO); + int rc2, isRO = 0; + sqlite3BeginBenignMalloc(); + rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO); + sqlite3EndBenignMalloc(); if( rc2==SQLITE_OK && isRO ) break; } }while( winRetryIoerr(&cnt, &lastErrno) ); @@ -5133,8 +5139,10 @@ static int winOpen( NULL); if( h!=INVALID_HANDLE_VALUE ) break; if( isReadWrite ){ - int isRO = 0; - int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO); + int rc2, isRO = 0; + sqlite3BeginBenignMalloc(); + rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO); + sqlite3EndBenignMalloc(); if( rc2==SQLITE_OK && isRO ) break; } }while( winRetryIoerr(&cnt, &lastErrno) ); @@ -5151,8 +5159,10 @@ static int winOpen( NULL); if( h!=INVALID_HANDLE_VALUE ) break; if( isReadWrite ){ - int isRO = 0; - int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO); + int rc2, isRO = 0; + sqlite3BeginBenignMalloc(); + rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO); + sqlite3EndBenignMalloc(); if( rc2==SQLITE_OK && isRO ) break; } }while( winRetryIoerr(&cnt, &lastErrno) ); From 98e2cb8bd181cb2f1195b431a4fba9055c459ea6 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 17 Jan 2018 01:40:57 +0000 Subject: [PATCH 149/190] Simplifications to winOpenSharedMemory in the Win32 VFS. FossilOrigin-Name: 3e04999dabb87715de46255b1a9b08d5dfa70d140e0a09a37ea2842d71c77caf --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 36 ++++++++++++++---------------------- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index 2670429108..3faeefe23f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Corrections\sto\serror\scode\shandling\sin\sos_win.c,\spursuant\sto\swalfault.test. -D 2018-01-17T01:26:05.915 +C Simplifications\sto\swinOpenSharedMemory\sin\sthe\sWin32\sVFS. +D 2018-01-17T01:40:57.173 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -470,7 +470,7 @@ F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c a82505be158d8ce42b38dcc9b426187d776904c12cdc68dc8925e1dfcc5cb6ce -F src/os_win.c 196b2b38953a3678e0ae1be40875c9c303ff216ec56ac2a6721e56ce9a9a454e +F src/os_win.c 501dde1ee770f4ffa458bfe1cf376a556de3ab00bb8320d659c5984403991d62 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 9b9cb4e06c03d43d62480a7a685a012d645fcf3a39e7767ccb505fb41ee083ec F src/pager.h 581698f2177e8bd4008fe4760898ce20b6133d1df22139b9101b5155f900df7a @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7274d05ff43fc9872f0e4857ae583689e4a6c429b7fa991dcc29744da3048879 -R a85767f9e76828ee76ff125e1a16892d +P 568192228c9578b8ea34c363e10ff28450045cda76248b2f0f89f84b3a57e680 +R 74d0fd9e585002553a9ac7b39220a819 U mistachkin -Z 21eee94f9fdd383abaac3542e6cde8fb +Z 373464fa908aa53424186ef8053b7fb1 diff --git a/manifest.uuid b/manifest.uuid index f91d56d71c..e6427cfa9a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -568192228c9578b8ea34c363e10ff28450045cda76248b2f0f89f84b3a57e680 \ No newline at end of file +3e04999dabb87715de46255b1a9b08d5dfa70d140e0a09a37ea2842d71c77caf \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 6df66f1d7a..2b2b8ebd56 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -3865,7 +3865,6 @@ static int winOpenSharedMemory(winFile *pDbFd){ struct winShm *p; /* The connection to be opened */ winShmNode *pShmNode = 0; /* The underlying mmapped file */ int rc = SQLITE_OK; /* Result code */ - int rc2 = SQLITE_ERROR; /* winOpen result code */ winShmNode *pNew; /* Newly allocated winShmNode */ int nName; /* Size of zName in bytes */ @@ -3899,7 +3898,8 @@ static int winOpenSharedMemory(winFile *pDbFd){ if( pShmNode ){ sqlite3_free(pNew); }else{ - int bReadonly; + int inFlags = SQLITE_OPEN_WAL; + int outFlags = 0; pShmNode = pNew; pNew = 0; @@ -3915,28 +3915,20 @@ static int winOpenSharedMemory(winFile *pDbFd){ } } - bReadonly = sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0); - - if( !bReadonly ){ - rc2 = winOpen(pDbFd->pVfs, - pShmNode->zFilename, - (sqlite3_file*)&pShmNode->hFile, - SQLITE_OPEN_WAL|SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, - 0); + if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){ + inFlags |= SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; + }else{ + inFlags |= SQLITE_OPEN_READONLY; } - if( rc2!=SQLITE_OK ){ - int rc3 = winOpen(pDbFd->pVfs, - pShmNode->zFilename, - (sqlite3_file*)&pShmNode->hFile, - SQLITE_OPEN_WAL|SQLITE_OPEN_READONLY, - 0); - if( rc3!=SQLITE_OK ){ - rc = winLogError(bReadonly ? rc3 : rc2, osGetLastError(), "winOpenShm", - pShmNode->zFilename); - goto shm_open_err; - } - pShmNode->isReadonly = 1; + rc = winOpen(pDbFd->pVfs, pShmNode->zFilename, + (sqlite3_file*)&pShmNode->hFile, + inFlags, &outFlags); + if( rc!=SQLITE_OK ){ + rc = winLogError(rc, osGetLastError(), "winOpenShm", + pShmNode->zFilename); + goto shm_open_err; } + if( outFlags==SQLITE_OPEN_READONLY ) pShmNode->isReadonly = 1; rc = winLockSharedMemory(pShmNode); if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err; From 30fe26c47f6f0d486cad4ba1b438b1b0333fb6e9 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Jan 2018 12:57:07 +0000 Subject: [PATCH 150/190] Update test file fts5fault6.test to account for test tokenizers implemented in Tcl returning SQLITE_ERROR instead of SQLITE_NOMEM following an OOM error. FossilOrigin-Name: c232f6424a858ede44940a927fe4e26ee99c6ab614aa6f63e13ba46e88dbb280 --- ext/fts5/test/fts5fault6.test | 6 +++--- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ext/fts5/test/fts5fault6.test b/ext/fts5/test/fts5fault6.test index 1c1c9f20c1..a39063a356 100644 --- a/ext/fts5/test/fts5fault6.test +++ b/ext/fts5/test/fts5fault6.test @@ -253,7 +253,7 @@ do_faultsim_test 5.2 -faults oom* -prep { SELECT rowid, mit(matchinfo(t1, 'x')) FROM t1 WHERE t1 MATCH 'a AND c' } } -test { - faultsim_test_result [list 0 $::res] + faultsim_test_result [list 0 $::res] {1 {SQL logic error}} } do_faultsim_test 5.3 -faults oom* -prep { @@ -264,7 +264,7 @@ do_faultsim_test 5.3 -faults oom* -prep { SELECT count(*) FROM t1 WHERE t1 MATCH 'd AND e AND f' } } -test { - faultsim_test_result {0 29} + faultsim_test_result {0 29} {1 {SQL logic error}} } do_faultsim_test 5.4 -faults oom* -prep { @@ -275,7 +275,7 @@ do_faultsim_test 5.4 -faults oom* -prep { SELECT count(*) FROM t1 WHERE t1 MATCH 'x + e' } } -test { - faultsim_test_result {0 1} + faultsim_test_result {0 1} {1 {SQL logic error}} } #------------------------------------------------------------------------- diff --git a/manifest b/manifest index 3faeefe23f..65dfc625fb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\swinOpenSharedMemory\sin\sthe\sWin32\sVFS. -D 2018-01-17T01:40:57.173 +C Update\stest\sfile\sfts5fault6.test\sto\saccount\sfor\stest\stokenizers\simplemented\sin\nTcl\sreturning\sSQLITE_ERROR\sinstead\sof\sSQLITE_NOMEM\sfollowing\san\sOOM\serror. +D 2018-01-17T12:57:07.649 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -165,7 +165,7 @@ F ext/fts5/test/fts5fault2.test 69c8fdbef830cd0d450908d4504d5bb86609e255af99c421 F ext/fts5/test/fts5fault3.test da2f9e3e56ff5740d68ebdd6877c97089e7ed28ddff28a0da87a6afea27e5522 F ext/fts5/test/fts5fault4.test 1c1db5fcfe59401e7833146100f1d8de284a0a686fac31ddac9fb56c459f725b F ext/fts5/test/fts5fault5.test a336e4e11847de24c9497f80cce18e00bb3fab7fb11f97d04eb9af898900a762 -F ext/fts5/test/fts5fault6.test 8a3c61402e36960ba46a419e73121fcefdc9160e0c04b6f5318c7fb0e3180dbc +F ext/fts5/test/fts5fault6.test a0fc0a8f99e4b16500c31dfc7e38e1defe0f1693ac47650517ac7b723b1956f8 F ext/fts5/test/fts5fault7.test 0acbec416edb24b8881f154e99c31e9ccf73f539cfcd164090be139e9e97ed4c F ext/fts5/test/fts5fault8.test 318238659d35f82ad215ecb57ca4c87486ea85d45dbeedaee42f148ff5105ee2 F ext/fts5/test/fts5fault9.test 098e6b894bbdf9b2192f994a30f4043673fb3f338b6b8ab1624c704422f39119 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 568192228c9578b8ea34c363e10ff28450045cda76248b2f0f89f84b3a57e680 -R 74d0fd9e585002553a9ac7b39220a819 -U mistachkin -Z 373464fa908aa53424186ef8053b7fb1 +P 3e04999dabb87715de46255b1a9b08d5dfa70d140e0a09a37ea2842d71c77caf +R 941f33fbf2a23d6c019574c3e00d86d4 +U dan +Z f10d4208193a5de16aeae87ee4be55df diff --git a/manifest.uuid b/manifest.uuid index e6427cfa9a..9d255d110e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e04999dabb87715de46255b1a9b08d5dfa70d140e0a09a37ea2842d71c77caf \ No newline at end of file +c232f6424a858ede44940a927fe4e26ee99c6ab614aa6f63e13ba46e88dbb280 \ No newline at end of file From f193937620052be8a23ffced856831668e88d6b3 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Jan 2018 12:58:11 +0000 Subject: [PATCH 151/190] Omit the single test from zipfile.test that uses json functionality in non-SQLITE_ENABLE_JSON1 builds. FossilOrigin-Name: 6bb2a10fad71bf8cec6bca538db7b00be0d26418ab62b83092d3a6a68d1c0d9f --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/zipfile.test | 16 +++++++++------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 65dfc625fb..d7a2894498 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\stest\sfile\sfts5fault6.test\sto\saccount\sfor\stest\stokenizers\simplemented\sin\nTcl\sreturning\sSQLITE_ERROR\sinstead\sof\sSQLITE_NOMEM\sfollowing\san\sOOM\serror. -D 2018-01-17T12:57:07.649 +C Omit\sthe\ssingle\stest\sfrom\szipfile.test\sthat\suses\sjson\sfunctionality\sin\nnon-SQLITE_ENABLE_JSON1\sbuilds. +D 2018-01-17T12:58:11.883 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -1600,7 +1600,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test 9c41628db7e8d9e8a0181e59ea5f189df311a9f6ce99cc376dc461f66db6f8dc -F test/zipfile.test 17e3ed850c7f182a5ce746fadc1a0497495aeacba216d73ece7b3b2c5dfd8867 +F test/zipfile.test cb42e8fa6ba5db4a03ce6baa4401fc6236baf6eb5e62b44f3e463bf6aafd631d F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3e04999dabb87715de46255b1a9b08d5dfa70d140e0a09a37ea2842d71c77caf -R 941f33fbf2a23d6c019574c3e00d86d4 +P c232f6424a858ede44940a927fe4e26ee99c6ab614aa6f63e13ba46e88dbb280 +R 1693bc0c1e569048e8eec005916d4449 U dan -Z f10d4208193a5de16aeae87ee4be55df +Z 8dee77e444940dc97285c3ee0298e6bb diff --git a/manifest.uuid b/manifest.uuid index 9d255d110e..ac4e921489 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c232f6424a858ede44940a927fe4e26ee99c6ab614aa6f63e13ba46e88dbb280 \ No newline at end of file +6bb2a10fad71bf8cec6bca538db7b00be0d26418ab62b83092d3a6a68d1c0d9f \ No newline at end of file diff --git a/test/zipfile.test b/test/zipfile.test index c324e0d7c7..07fc80f602 100644 --- a/test/zipfile.test +++ b/test/zipfile.test @@ -75,13 +75,15 @@ do_execsql_test 1.4 { h.txt 1000000004 aaaaaaaaaabbbbbbbbbb 8 } -do_execsql_test 1.4.1 { - SELECT name, json_extract( zipfile_cds(z) , '$.crc32')!=0 - FROM zipfile('test.zip'); -} { - f.txt 1 - g.txt 1 - h.txt 1 +ifcapable json1 { + do_execsql_test 1.4.1 { + SELECT name, json_extract( zipfile_cds(z) , '$.crc32')!=0 + FROM zipfile('test.zip'); + } { + f.txt 1 + g.txt 1 + h.txt 1 + } } do_execsql_test 1.5.1 { From b96851855972a35f30b554fda1c4d1b6f9a14965 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 17 Jan 2018 13:15:23 +0000 Subject: [PATCH 152/190] Fix harmless compiler warnings, mostly unused parameters for UDFs in the CLI. FossilOrigin-Name: bfbeffab7735461acb3773242ba31dae15af9f8b0291c54a6734747bb1b36e66 --- ext/expert/sqlite3expert.c | 17 +++++++++++++++-- ext/misc/appendvfs.c | 2 ++ ext/misc/fileio.c | 15 ++++++++++++--- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- src/shell.c.in | 3 +++ tool/lempar.c | 2 ++ 7 files changed, 46 insertions(+), 17 deletions(-) diff --git a/ext/expert/sqlite3expert.c b/ext/expert/sqlite3expert.c index 9cafc448b2..e0602bc65e 100644 --- a/ext/expert/sqlite3expert.c +++ b/ext/expert/sqlite3expert.c @@ -507,6 +507,10 @@ static int expertUpdate( sqlite3_value **azData, sqlite_int64 *pRowid ){ + (void)pVtab; + (void)nData; + (void)azData; + (void)pRowid; return SQLITE_OK; } @@ -516,6 +520,7 @@ static int expertUpdate( static int expertOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ int rc = SQLITE_OK; ExpertCsr *pCsr; + (void)pVTab; pCsr = idxMalloc(&rc, sizeof(ExpertCsr)); *ppCursor = (sqlite3_vtab_cursor*)pCsr; return rc; @@ -565,6 +570,7 @@ static int expertNext(sqlite3_vtab_cursor *cur){ ** Virtual table module xRowid method. */ static int expertRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ + (void)cur; *pRowid = 0; return SQLITE_OK; } @@ -595,6 +601,10 @@ static int expertFilter( sqlite3expert *pExpert = pVtab->pExpert; int rc; + (void)idxNum; + (void)idxStr; + (void)argc; + (void)argv; rc = sqlite3_finalize(pCsr->pData); pCsr->pData = 0; if( rc==SQLITE_OK ){ @@ -1005,7 +1015,7 @@ static int idxCreateFromWhere( ** Create candidate indexes in database [dbm] based on the data in ** linked-list pScan. */ -static int idxCreateCandidates(sqlite3expert *p, char **pzErr){ +static int idxCreateCandidates(sqlite3expert *p){ int rc = SQLITE_OK; IdxScan *pIter; @@ -1168,6 +1178,8 @@ static int idxAuthCallback( const char *zTrigger ){ int rc = SQLITE_OK; + (void)z4; + (void)zTrigger; if( eOp==SQLITE_INSERT || eOp==SQLITE_UPDATE || eOp==SQLITE_DELETE ){ if( sqlite3_stricmp(zDb, "main")==0 ){ sqlite3expert *p = (sqlite3expert*)pCtx; @@ -1370,6 +1382,7 @@ static void idxSampleFunc( struct IdxSampleCtx *p = (struct IdxSampleCtx*)sqlite3_user_data(pCtx); int bRet; + (void)argv; assert( argc==0 ); if( p->nRow==0.0 ){ bRet = 1; @@ -1855,7 +1868,7 @@ int sqlite3_expert_analyze(sqlite3expert *p, char **pzErr){ /* Create candidate indexes within the in-memory database file */ if( rc==SQLITE_OK ){ - rc = idxCreateCandidates(p, pzErr); + rc = idxCreateCandidates(p); } /* Generate the stat1 data */ diff --git a/ext/misc/appendvfs.c b/ext/misc/appendvfs.c index 1454243057..b224245f3d 100644 --- a/ext/misc/appendvfs.c +++ b/ext/misc/appendvfs.c @@ -548,6 +548,8 @@ int sqlite3_appendvfs_init( int rc = SQLITE_OK; sqlite3_vfs *pOrig; SQLITE_EXTENSION_INIT2(pApi); + (void)pzErrMsg; + (void)db; pOrig = sqlite3_vfs_find(0); apnd_vfs.iVersion = pOrig->iVersion; apnd_vfs.pAppData = pOrig; diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 7035889482..60a960f310 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -372,6 +372,7 @@ static void lsModeFunc( int i; int iMode = sqlite3_value_int(argv[0]); char z[16]; + (void)argc; if( S_ISLNK(iMode) ){ z[0] = 'l'; }else if( S_ISREG(iMode) ){ @@ -437,7 +438,10 @@ static int fsdirConnect( ){ fsdir_tab *pNew = 0; int rc; - + (void)pAux; + (void)argc; + (void)argv; + (void)pzErr; rc = sqlite3_declare_vtab(db, "CREATE TABLE x" FSDIR_SCHEMA); if( rc==SQLITE_OK ){ pNew = (fsdir_tab*)sqlite3_malloc( sizeof(*pNew) ); @@ -461,6 +465,7 @@ static int fsdirDisconnect(sqlite3_vtab *pVtab){ */ static int fsdirOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ fsdir_cursor *pCur; + (void)p; pCur = sqlite3_malloc( sizeof(*pCur) ); if( pCur==0 ) return SQLITE_NOMEM; memset(pCur, 0, sizeof(*pCur)); @@ -664,7 +669,7 @@ static int fsdirFilter( ){ const char *zDir = 0; fsdir_cursor *pCur = (fsdir_cursor*)cur; - + (void)idxStr; fsdirResetCursor(pCur); if( idxNum==0 ){ @@ -722,8 +727,9 @@ static int fsdirBestIndex( int i; /* Loop over constraints */ int idx4 = -1; int idx5 = -1; - const struct sqlite3_index_constraint *pConstraint; + + (void)tab; pConstraint = pIdxInfo->aConstraint; for(i=0; inConstraint; i++, pConstraint++){ if( pConstraint->usable==0 ) continue; @@ -777,6 +783,9 @@ static int fsdirRegister(sqlite3 *db){ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ + 0, /* xSavepoint */ + 0, /* xRelease */ + 0 /* xRollbackTo */ }; int rc = sqlite3_create_module(db, "fsdir", &fsdirModule, 0); diff --git a/manifest b/manifest index d7a2894498..ca58247446 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sthe\ssingle\stest\sfrom\szipfile.test\sthat\suses\sjson\sfunctionality\sin\nnon-SQLITE_ENABLE_JSON1\sbuilds. -D 2018-01-17T12:58:11.883 +C Fix\sharmless\scompiler\swarnings,\smostly\sunused\sparameters\sfor\sUDFs\sin\sthe\sCLI. +D 2018-01-17T13:15:23.987 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -45,7 +45,7 @@ F ext/async/sqlite3async.h f489b080af7e72aec0e1ee6f1d98ab6cf2e4dcef F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c 4791c5e064aea81b2b829fa95228b22283380ee370ea88a1e580103b75516ebf F ext/expert/expert1.test fd21496d8e52c817a7741f467f42b0502c0ac7e07dcdd1d6e15a3e8154ed4e41 -F ext/expert/sqlite3expert.c 55ea02e9fcc014f4252e8a8c78d2bddc6d7ef62f9cb54ee283a659516eabb711 +F ext/expert/sqlite3expert.c 1dfa561e64dc0f89d56b96e6afda87468c34b43604c2df50c47e3f4362778fb2 F ext/expert/sqlite3expert.h af6354f8ee5c9e025024e63fec3bd640a802afcc3099a44d804752cf0791d811 F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72 F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e @@ -268,7 +268,7 @@ F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f607 F ext/misc/README.md d6dd0fe1d8af77040216798a6a2b0c46c73054d2f0ea544fbbcdccf6f238c240 F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb -F ext/misc/appendvfs.c 4c65f0b79686ae5a483134233d7fd912f0f2d4fd76023404f96f2290fff13b19 +F ext/misc/appendvfs.c 3777f22ec1057dc4e5fd89f2fbddcc7a29fbeef1ad038c736c54411bb1967af7 F ext/misc/btreeinfo.c d7fd9a2fe2fa33ba28488e2fce703ebecc759219ea9e0bb3b254784866c0a676 F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 @@ -277,7 +277,7 @@ F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f0 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 777c13f00b4505df3bfab602568c98d2b067f7d1d265de88160d0f1ac92f3dcf +F ext/misc/fileio.c 06bd79dcc43d0887da27ffaadd69b8a698b1bafe203d1d134a3a2964f69368f9 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -486,7 +486,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba -F src/shell.c.in 568aacb5b15520fa7981ebcf976ebd99849e6a4777858706762f201a446626f3 +F src/shell.c.in 4e1bcf8c70b8fb97c7cbaca6602e2a291d7fe17eff23a5de003d6fabd87f27d1 F src/sqlite.h.in 840e8aee0d7f8592bd69730797582b342a413eceaff7a220fb5f9db9c412cea9 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 99189e7611eb0bf98f21c7835dc74730a84e2e809c98e1e31c33896dee7a2849 @@ -1619,7 +1619,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f F tool/lemon.c 7f7735326ca9c3b48327b241063cee52d35d44e20ebe1b3624a81658052a4d39 -F tool/lempar.c dddd4f592b8bad36aec4500d456c5db5fe42fefc4ee384913880439d8917f87a +F tool/lempar.c da840fc8a6fbac23599a65ff075e6e3d01320417c794ff577088e09f5d74b689 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c232f6424a858ede44940a927fe4e26ee99c6ab614aa6f63e13ba46e88dbb280 -R 1693bc0c1e569048e8eec005916d4449 -U dan -Z 8dee77e444940dc97285c3ee0298e6bb +P 6bb2a10fad71bf8cec6bca538db7b00be0d26418ab62b83092d3a6a68d1c0d9f +R 3ce13cb6be5e7cd3831ddb44a0279981 +U drh +Z 43432e1e2cf79a7dd14125e4a977e1e5 diff --git a/manifest.uuid b/manifest.uuid index ac4e921489..6038ac149a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6bb2a10fad71bf8cec6bca538db7b00be0d26418ab62b83092d3a6a68d1c0d9f \ No newline at end of file +bfbeffab7735461acb3773242ba31dae15af9f8b0291c54a6734747bb1b36e66 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 523d7ef7bf..d9c8705e70 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -865,6 +865,7 @@ static void shellModuleSchema( ){ const char *zName = (const char*)sqlite3_value_text(apVal[0]); char *zFake = shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName); + UNUSED_PARAMETER(nVal); if( zFake ){ sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake), -1, sqlite3_free); @@ -909,6 +910,7 @@ static void shellAddSchemaName( const char *zSchema = (const char*)sqlite3_value_text(apVal[1]); const char *zName = (const char*)sqlite3_value_text(apVal[2]); sqlite3 *db = sqlite3_context_db_handle(pCtx); + UNUSED_PARAMETER(nVal); if( zIn!=0 && strncmp(zIn, "CREATE ", 7)==0 ){ for(i=0; i<(int)(sizeof(aPrefix)/sizeof(aPrefix[0])); i++){ int n = strlen30(aPrefix[i]); @@ -1152,6 +1154,7 @@ static void shellPutsFunc( sqlite3_value **apVal ){ ShellState *p = (ShellState*)sqlite3_user_data(pCtx); + (void)nVal; utf8_printf(p->out, "%s\n", sqlite3_value_text(apVal[0])); sqlite3_result_value(pCtx, apVal[0]); } diff --git a/tool/lempar.c b/tool/lempar.c index 9164eb0c1e..ecc0e6389b 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -706,6 +706,8 @@ static void yy_reduce( yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ ParseARG_FETCH; + (void)yyLookahead; + (void)yyLookaheadToken; yymsp = yypParser->yytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ From 26893c98d21a2d50b521407e255131504ccf742a Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Jan 2018 16:11:26 +0000 Subject: [PATCH 153/190] Fix main.mk so that testfixture can be built either from the amalgamation or from individual source files. No changes to code. FossilOrigin-Name: a8aea925f8fde8f2dc5ff4b744d54aa2bf8916f3ee57f22d77fd1ddb5a35a9cc --- main.mk | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/main.mk b/main.mk index 504ff34e1c..f2640b4339 100644 --- a/main.mk +++ b/main.mk @@ -366,7 +366,6 @@ TESTSRC += \ $(TOP)/ext/misc/remember.c \ $(TOP)/ext/misc/series.c \ $(TOP)/ext/misc/spellfix.c \ - $(TOP)/ext/misc/stmt.c \ $(TOP)/ext/misc/totype.c \ $(TOP)/ext/misc/unionvtab.c \ $(TOP)/ext/misc/wholenumber.c \ @@ -423,6 +422,7 @@ TESTSRC2 = \ $(TOP)/ext/fts3/fts3_tokenizer.c \ $(TOP)/ext/fts3/fts3_write.c \ $(TOP)/ext/async/sqlite3async.c \ + $(TOP)/ext/misc/stmt.c \ $(TOP)/ext/session/sqlite3session.c \ $(TOP)/ext/session/test_session.c diff --git a/manifest b/manifest index ca58247446..90624ae36c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings,\smostly\sunused\sparameters\sfor\sUDFs\sin\sthe\sCLI. -D 2018-01-17T13:15:23.987 +C Fix\smain.mk\sso\sthat\stestfixture\scan\sbe\sbuilt\seither\sfrom\sthe\samalgamation\sor\nfrom\sindividual\ssource\sfiles.\sNo\schanges\sto\scode. +D 2018-01-17T16:11:26.562 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -408,7 +408,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 69bce07f975e6835a544f43df8d9619ea31d2c8e7b3a8d2cb4c21ac704c9c9c2 +F main.mk 4d19895cb268021474ade6244119c80b8a3f1d910cb5b13cf5e04f5f37c3d61b F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1699,7 +1699,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6bb2a10fad71bf8cec6bca538db7b00be0d26418ab62b83092d3a6a68d1c0d9f -R 3ce13cb6be5e7cd3831ddb44a0279981 -U drh -Z 43432e1e2cf79a7dd14125e4a977e1e5 +P bfbeffab7735461acb3773242ba31dae15af9f8b0291c54a6734747bb1b36e66 +R ec2f214ab6dea8dc121fe027cc99d1ce +U dan +Z d15337a42013c6ddacd72bec21ca6a84 diff --git a/manifest.uuid b/manifest.uuid index 6038ac149a..505eed63be 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bfbeffab7735461acb3773242ba31dae15af9f8b0291c54a6734747bb1b36e66 \ No newline at end of file +a8aea925f8fde8f2dc5ff4b744d54aa2bf8916f3ee57f22d77fd1ddb5a35a9cc \ No newline at end of file From 61c758b53a9782d0b31422ad705cc53f672f8e83 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Jan 2018 17:38:18 +0000 Subject: [PATCH 154/190] Fix a problem causing the sessions module to occasionally lose track of rows with composite primary keys when there are two rows with the same text value in the leftmost column of the PK. FossilOrigin-Name: 09aed13678374bf22087cd808808b711dc703b7c18bc8aaf704850611e17f5cd --- ext/session/sessionH.test | 39 ++++++++++++++++++++++++++++++++++++ ext/session/sessionat.test | 4 ++++ ext/session/sqlite3session.c | 1 - manifest | 15 +++++++------- manifest.uuid | 2 +- 5 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 ext/session/sessionH.test diff --git a/ext/session/sessionH.test b/ext/session/sessionH.test new file mode 100644 index 0000000000..643fdb3fbe --- /dev/null +++ b/ext/session/sessionH.test @@ -0,0 +1,39 @@ +# 2018 January 18 +# +# 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. +# +#*********************************************************************** +# + +if {![info exists testdir]} { + set testdir [file join [file dirname [info script]] .. .. test] +} +source [file join [file dirname [info script]] session_common.tcl] +source $testdir/tester.tcl +ifcapable !session {finish_test; return} +set testprefix sessionH + +forcedelete test.db2 +sqlite3 db2 test.db2 + +do_test 1.0 { + do_common_sql { + CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b)); + } + do_then_apply_sql { + WITH s(i) AS ( + VALUES(1) UNION ALL SELECT i+1 FROM s WHERe i<10000 + ) + INSERT INTO t1 SELECT 'abcde', randomblob(16), i FROM s; + } + compare_db db db2 +} {} + + +finish_test + diff --git a/ext/session/sessionat.test b/ext/session/sessionat.test index f482d01520..4a3f59a441 100644 --- a/ext/session/sessionat.test +++ b/ext/session/sessionat.test @@ -241,5 +241,9 @@ eval [string map [list %WR% $trailing] { }] } +catch { db close } +catch { db2 close } +sqlite3_shutdown +test_sqlite3_log finish_test diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index bd83ce87d3..6ef90037de 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -838,7 +838,6 @@ static int sessionPreupdateEqual( } if( memcmp(a, z, n) ) return 0; a += n; - break; } } } diff --git a/manifest b/manifest index 90624ae36c..5e365cf00f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\smain.mk\sso\sthat\stestfixture\scan\sbe\sbuilt\seither\sfrom\sthe\samalgamation\sor\nfrom\sindividual\ssource\sfiles.\sNo\schanges\sto\scode. -D 2018-01-17T16:11:26.562 +C Fix\sa\sproblem\scausing\sthe\ssessions\smodule\sto\soccasionally\slose\strack\sof\srows\nwith\scomposite\sprimary\skeys\swhen\sthere\sare\stwo\srows\swith\sthe\ssame\stext\svalue\nin\sthe\sleftmost\scolumn\sof\sthe\sPK. +D 2018-01-17T17:38:18.448 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -391,15 +391,16 @@ F ext/session/sessionD.test d3617e29aa15c9413aee5286d99587633245d58d2ad28f3f331c F ext/session/sessionE.test 0a616c4ad8fd2c05f23217ebb6212ef80b7fef30f5f086a6633a081f93e84637 F ext/session/sessionF.test c2f178d4dfd723a5fd94a730ea2ccb44c669e3ce F ext/session/sessionG.test 63f9a744341d670775af29e4f19c1ef09a4810798400f28cd76704803a2e56ff +F ext/session/sessionH.test 332b60e4c2e0a680105e11936201cabe378216f307e2747803cea56fa7d9ebae F ext/session/session_common.tcl 7776eda579773113b30c7abfd4545c445228cb73 F ext/session/session_speed_test.c edc1f96fd5e0e4b16eb03e2a73041013d59e8723 -F ext/session/sessionat.test feb7d22b3124882064b9d9df69f5484a9bb8c123dc9ddc6ffcd357521848139f +F ext/session/sessionat.test efe88965e74ff1bc2af9c310b28358c02d420c1fb2705cc7a28f0c1cc142c3ec F ext/session/sessiondiff.test ad13dd65664bae26744e1f18eb3cbd5588349b7e9118851d8f9364248d67bcec F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sessionstat1.test e3a3f5876ce1526b48f6f447ee0b18960ac683e3fc891791e1ca0c08e823d498 F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc -F ext/session/sqlite3session.c a18bfdab0de090597fb50aae734e2cd41bf5e5d394bbd9a2189308f2bc8525d5 +F ext/session/sqlite3session.c c9d813ffa8db0670257da0a0c931e7188dfbb0010bf1a38274775c9b6300dd5c F ext/session/sqlite3session.h cb4d860101ba6d3ac810f18684539b766d24d668fa2436cdde90d711af9464fb F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 @@ -1699,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bfbeffab7735461acb3773242ba31dae15af9f8b0291c54a6734747bb1b36e66 -R ec2f214ab6dea8dc121fe027cc99d1ce +P a8aea925f8fde8f2dc5ff4b744d54aa2bf8916f3ee57f22d77fd1ddb5a35a9cc +R fffe7fea955e558a2fcc7877bcdc39db U dan -Z d15337a42013c6ddacd72bec21ca6a84 +Z 8da05c1c6303c10ad33f099cfa382df7 diff --git a/manifest.uuid b/manifest.uuid index 505eed63be..41ac115dac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a8aea925f8fde8f2dc5ff4b744d54aa2bf8916f3ee57f22d77fd1ddb5a35a9cc \ No newline at end of file +09aed13678374bf22087cd808808b711dc703b7c18bc8aaf704850611e17f5cd \ No newline at end of file From 3739f29807180878a77c37405f3f166c05dfb086 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Jan 2018 20:57:20 +0000 Subject: [PATCH 155/190] Fix a problem in the sessions module with logging sqlite_stat1 rows for which (idx IS NULL) is true. FossilOrigin-Name: 25bf734be1b3883fccf12ac4d93d50289aa307fb60a52e0e32df12f7ee4edc7a --- ext/session/sessionstat1.test | 109 +++++++++++++++++++++ ext/session/sqlite3session.c | 176 +++++++++++++++++++++++++--------- manifest | 19 ++-- manifest.uuid | 2 +- src/analyze.c | 3 + 5 files changed, 253 insertions(+), 56 deletions(-) diff --git a/ext/session/sessionstat1.test b/ext/session/sessionstat1.test index 59de1cf1b4..22b2de8dbc 100644 --- a/ext/session/sessionstat1.test +++ b/ext/session/sessionstat1.test @@ -121,5 +121,114 @@ do_execsql_test -db db2 2.4 { do_execsql_test -db db2 2.5 { SELECT count(*) FROM t1 } 32 +#------------------------------------------------------------------------- +db2 close +forcedelete test.db2 +reset_db +sqlite3 db2 test.db2 + +do_test 3.0 { + do_common_sql { + CREATE TABLE t1(a, b, c); + ANALYZE; + DELETE FROM sqlite_stat1; + } + execsql { + INSERT INTO t1 VALUES(1, 1, 1); + INSERT INTO t1 VALUES(2, 2, 2); + INSERT INTO t1 VALUES(3, 3, 3); + INSERT INTO t1 VALUES(4, 4, 4); + } +} {} + +do_iterator_test 3.1 {} { + ANALYZE +} { + {INSERT sqlite_stat1 0 XX. {} {t t1 b {} t 4}} +} +db null null +db2 null null +do_execsql_test 3.2 { + SELECT * FROM sqlite_stat1; +} {t1 null 4} +do_test 3.3 { + execsql { DELETE FROM sqlite_stat1 } + do_then_apply_sql { ANALYZE } + execsql { SELECT * FROM sqlite_stat1 } db2 +} {t1 null 4} +do_test 3.4 { + execsql { INSERT INTO t1 VALUES(5,5,5) } + do_then_apply_sql { ANALYZE } + execsql { SELECT * FROM sqlite_stat1 } db2 +} {t1 null 5} +do_test 3.5 { + do_then_apply_sql { DROP TABLE t1 } + execsql { SELECT * FROM sqlite_stat1 } db2 +} {} + +do_test 3.6.1 { + execsql { + CREATE TABLE t1(a, b, c); + CREATE TABLE t2(x, y, z); + INSERT INTO t1 VALUES(1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5); + INSERT INTO t2 SELECT * FROM t1; + DELETE FROM sqlite_stat1; + } + sqlite3session S db main + S attach sqlite_stat1 + execsql { ANALYZE } +} {} +do_changeset_test 3.6.2 S { + {INSERT sqlite_stat1 0 XX. {} {t t2 b {} t 5}} + {INSERT sqlite_stat1 0 XX. {} {t t1 b {} t 5}} +} +do_changeset_invert_test 3.6.3 S { + {DELETE sqlite_stat1 0 XX. {t t2 b {} t 5} {}} + {DELETE sqlite_stat1 0 XX. {t t1 b {} t 5} {}} +} +do_test 3.6.4 { S delete } {} + +proc sql_changeset_concat {args} { + foreach sql $args { + sqlite3session S db main + S attach sqlite_stat1 + execsql $sql + set change [S changeset] + S delete + + if {[info vars ret]!=""} { + set ret [sqlite3changeset_concat $ret $change] + } else { + set ret $change + } + } + + changeset_to_list $ret +} + +proc do_scc_test {tn args} { + uplevel [list \ + do_test $tn [concat sql_changeset_concat [lrange $args 0 end-1]] \ + [list {*}[ lindex $args end ]] + ] +} + +do_execsql_test 3.7.0 { + DELETE FROM sqlite_stat1; +} +do_scc_test 3.7.1 { + ANALYZE; +} { + INSERT INTO t2 VALUES(6,6,6); + ANALYZE; +} { + {INSERT sqlite_stat1 0 XX. {} {t t1 b {} t 5}} + {INSERT sqlite_stat1 0 XX. {} {t t2 b {} t 6}} +} + + + + + finish_test diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index 6ef90037de..cbe75d5667 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -113,6 +113,7 @@ struct SessionTable { SessionTable *pNext; char *zName; /* Local name of table */ int nCol; /* Number of columns in table zName */ + int bStat1; /* True if this is sqlite_stat1 */ const char **azCol; /* Column names */ u8 *abPK; /* Array of primary key flags */ int nEntry; /* Total number of entries in hash table */ @@ -472,31 +473,35 @@ static int sessionPreupdateHash( if( rc!=SQLITE_OK ) return rc; eType = sqlite3_value_type(pVal); - h = sessionHashAppendType(h, eType); - if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ - i64 iVal; - if( eType==SQLITE_INTEGER ){ - iVal = sqlite3_value_int64(pVal); - }else{ - double rVal = sqlite3_value_double(pVal); - assert( sizeof(iVal)==8 && sizeof(rVal)==8 ); - memcpy(&iVal, &rVal, 8); - } - h = sessionHashAppendI64(h, iVal); - }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){ - const u8 *z; - int n; - if( eType==SQLITE_TEXT ){ - z = (const u8 *)sqlite3_value_text(pVal); - }else{ - z = (const u8 *)sqlite3_value_blob(pVal); - } - n = sqlite3_value_bytes(pVal); - if( !z && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM; - h = sessionHashAppendBlob(h, n, z); + if( pTab->bStat1 && eType==SQLITE_NULL ){ + h = sessionHashAppendType(h, SQLITE_BLOB); }else{ - assert( eType==SQLITE_NULL ); - *pbNullPK = 1; + h = sessionHashAppendType(h, eType); + if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ + i64 iVal; + if( eType==SQLITE_INTEGER ){ + iVal = sqlite3_value_int64(pVal); + }else{ + double rVal = sqlite3_value_double(pVal); + assert( sizeof(iVal)==8 && sizeof(rVal)==8 ); + memcpy(&iVal, &rVal, 8); + } + h = sessionHashAppendI64(h, iVal); + }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){ + const u8 *z; + int n; + if( eType==SQLITE_TEXT ){ + z = (const u8 *)sqlite3_value_text(pVal); + }else{ + z = (const u8 *)sqlite3_value_blob(pVal); + } + n = sqlite3_value_bytes(pVal); + if( !z && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM; + h = sessionHashAppendBlob(h, n, z); + }else{ + assert( eType==SQLITE_NULL ); + *pbNullPK = 1; + } } } } @@ -550,7 +555,7 @@ static unsigned int sessionChangeHash( || eType==SQLITE_TEXT || eType==SQLITE_BLOB || eType==SQLITE_NULL || eType==0 ); - assert( !isPK || (eType!=0 && eType!=SQLITE_NULL) ); + assert( !isPK || (eType!=0 && (pTab->bStat1 || eType!=SQLITE_NULL)) ); if( isPK ){ a++; @@ -558,7 +563,7 @@ static unsigned int sessionChangeHash( if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ h = sessionHashAppendI64(h, sessionGetI64(a)); a += 8; - }else{ + }else if( eType!=SQLITE_NULL ){ int n; a += sessionVarintGet(a, &n); h = sessionHashAppendBlob(h, n, a); @@ -794,6 +799,7 @@ static int sessionPreupdateEqual( sqlite3_value *pVal; /* Value returned by preupdate_new/old */ int rc; /* Error code from preupdate_new/old */ int eType = *a++; /* Type of value from change record */ + int eValType; /* The following calls to preupdate_new() and preupdate_old() can not ** fail. This is because they cache their return values, and by the @@ -808,7 +814,14 @@ static int sessionPreupdateEqual( rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal); } assert( rc==SQLITE_OK ); - if( sqlite3_value_type(pVal)!=eType ) return 0; + eValType = sqlite3_value_type(pVal); + if( eType==SQLITE_BLOB && eValType==SQLITE_NULL && pTab->bStat1 ){ + int n; + a += sessionVarintGet(a, &n); + if( n!=0 ) return 0; + continue; + } + if( eValType!=eType ) return 0; /* A SessionChange object never has a NULL value in a PK column */ assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT @@ -1047,6 +1060,9 @@ static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ break; } } + if( 0==sqlite3_stricmp("sqlite_stat1", pTab->zName) ){ + pTab->bStat1 = 1; + } } } return (pSession->rc || pTab->abPK==0); @@ -1093,7 +1109,7 @@ static void sessionPreupdateOneChange( rc = sessionPreupdateHash(pSession, pTab, op==SQLITE_INSERT, &iHash, &bNull); if( rc!=SQLITE_OK ) goto error_out; - if( bNull==0 ){ + if( bNull==0 || pTab->bStat1 ){ /* Search the hash table for an existing record for this row. */ SessionChange *pC; for(pC=pTab->apChange[iHash]; pC; pC=pC->pNext){ @@ -1128,6 +1144,7 @@ static void sessionPreupdateOneChange( rc = sessionSerializeValue(0, p, &nByte); if( rc!=SQLITE_OK ) goto error_out; } + if( pTab->bStat1 ) nByte += 30; /* Allocate the change object */ pChange = (SessionChange *)sqlite3_malloc(nByte); @@ -1151,7 +1168,12 @@ static void sessionPreupdateOneChange( }else if( pTab->abPK[i] ){ pSession->hook.xNew(pSession->hook.pCtx, i, &p); } - sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte); + if( p && pTab->bStat1 && sqlite3_value_type(p)==SQLITE_NULL ){ + pChange->aRecord[nByte++] = SQLITE_BLOB; + nByte += sessionVarintPut(&pChange->aRecord[nByte], 0); + }else{ + sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte); + } } /* Add the change to the hash-table */ @@ -2104,28 +2126,41 @@ static int sessionSelectStmt( sqlite3_stmt **ppStmt /* OUT: Prepared SELECT statement */ ){ int rc = SQLITE_OK; - int i; - const char *zSep = ""; - SessionBuffer buf = {0, 0, 0}; + char *zSql = 0; + int nSql = -1; - sessionAppendStr(&buf, "SELECT * FROM ", &rc); - sessionAppendIdent(&buf, zDb, &rc); - sessionAppendStr(&buf, ".", &rc); - sessionAppendIdent(&buf, zTab, &rc); - sessionAppendStr(&buf, " WHERE ", &rc); - for(i=0; ipInsert, + "INSERT INTO main.sqlite_stat1 VALUES(?1, " + "CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END, " + "?3)" + ); + } + if( rc==SQLITE_OK ){ + rc = sessionPrepare(db, &p->pUpdate, + "UPDATE main.sqlite_stat1 SET " + "tbl = CASE WHEN ?2 THEN ?3 ELSE tbl END, " + "idx = CASE WHEN ?5 THEN ?6 ELSE idx END, " + "stat = CASE WHEN ?8 THEN ?9 ELSE stat END " + "WHERE tbl=?1 AND idx IS " + "CASE WHEN length(?4)=0 AND typeof(?4)='blob' THEN NULL ELSE ?4 END " + "AND (?10 OR ?8=0 OR stat IS ?7)" + ); + } + if( rc==SQLITE_OK ){ + rc = sessionPrepare(db, &p->pDelete, + "DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS " + "CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END " + "AND (?4 OR stat IS ?3)" + ); + } + assert( rc==SQLITE_OK ); + return rc; +} + /* ** A wrapper around sqlite3_bind_value() that detects an extra problem. ** See comments in the body of this function for details. @@ -4092,6 +4169,11 @@ static int sessionChangesetApply( } else{ sApply.nCol = nCol; + if( 0==sqlite3_stricmp(zTab, "sqlite_stat1") ){ + if( (rc = sessionStat1Sql(db, &sApply) ) ){ + break; + } + }else if((rc = sessionSelectRow(db, zTab, &sApply)) || (rc = sessionUpdateRow(db, zTab, &sApply)) || (rc = sessionDeleteRow(db, zTab, &sApply)) diff --git a/manifest b/manifest index 5e365cf00f..ce17059a62 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scausing\sthe\ssessions\smodule\sto\soccasionally\slose\strack\sof\srows\nwith\scomposite\sprimary\skeys\swhen\sthere\sare\stwo\srows\swith\sthe\ssame\stext\svalue\nin\sthe\sleftmost\scolumn\sof\sthe\sPK. -D 2018-01-17T17:38:18.448 +C Fix\sa\sproblem\sin\sthe\ssessions\smodule\swith\slogging\ssqlite_stat1\srows\sfor\swhich\n(idx\sIS\sNULL)\sis\strue. +D 2018-01-17T20:57:20.602 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -398,9 +398,9 @@ F ext/session/sessionat.test efe88965e74ff1bc2af9c310b28358c02d420c1fb2705cc7a28 F ext/session/sessiondiff.test ad13dd65664bae26744e1f18eb3cbd5588349b7e9118851d8f9364248d67bcec F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 -F ext/session/sessionstat1.test e3a3f5876ce1526b48f6f447ee0b18960ac683e3fc891791e1ca0c08e823d498 +F ext/session/sessionstat1.test 16268a9bf62ab19c9bc9e41404bf7a13b5fd37c9cb6cf278a472f0c6c50d7ac1 F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc -F ext/session/sqlite3session.c c9d813ffa8db0670257da0a0c931e7188dfbb0010bf1a38274775c9b6300dd5c +F ext/session/sqlite3session.c 870d142ec13c0e053139e7f3427aa550e59faf1775ae2bca051766089d9faf7b F ext/session/sqlite3session.h cb4d860101ba6d3ac810f18684539b766d24d668fa2436cdde90d711af9464fb F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 @@ -422,7 +422,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c cf7a8af45cb0ace672f47a1b29ab24092a9e8cd8d945a9974e3b5d925f548594 -F src/analyze.c f9bfffd0416c547a916cb96793b94684bdb0d26a71542ea31819c6757741c19d +F src/analyze.c 6b42e36a5dcc2703a771f2411bd5e99524bd62c7ecde209bb88dfb04c72f046e F src/attach.c 84c477e856b24c2b9a0983b438a707c0cf4d616cee7a425401d418e58afec24c F src/auth.c 6277d63837357549fe14e723490d6dc1a38768d71c795c5eb5c0f8a99f918f73 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b @@ -1700,7 +1700,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a8aea925f8fde8f2dc5ff4b744d54aa2bf8916f3ee57f22d77fd1ddb5a35a9cc -R fffe7fea955e558a2fcc7877bcdc39db +P 09aed13678374bf22087cd808808b711dc703b7c18bc8aaf704850611e17f5cd +R 99a2e08bb84b46a9c74125d0aa1dbedc +T *branch * sessions-stat1 +T *sym-sessions-stat1 * +T -sym-trunk * U dan -Z 8da05c1c6303c10ad33f099cfa382df7 +Z 913b883400e9793131764656e068c1a3 diff --git a/manifest.uuid b/manifest.uuid index 41ac115dac..a3bd20f4c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -09aed13678374bf22087cd808808b711dc703b7c18bc8aaf704850611e17f5cd \ No newline at end of file +25bf734be1b3883fccf12ac4d93d50289aa307fb60a52e0e32df12f7ee4edc7a \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 85c603ffdf..0d13d77790 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -1309,6 +1309,9 @@ static void analyzeOneTable( sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid); sqlite3VdbeChangeP5(v, OPFLAG_APPEND); +#ifdef SQLITE_ENABLE_PREUPDATE_HOOK + sqlite3VdbeChangeP4(v, -1, (char*)pStat1, P4_TABLE); +#endif sqlite3VdbeJumpHere(v, jZeroRows); } } From 3dc9727782af8eea33c5b35ce16b6dbe675388c6 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 17 Jan 2018 21:14:17 +0000 Subject: [PATCH 156/190] Alternative implementation for the internal sqlite3Pow10() utility for MSVC, which is more accurate on that platform. FossilOrigin-Name: 469b96be5350ba2291518280ffe179b87aa7fbe701e2813ef63843922771517a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/util.c | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5e365cf00f..9206bfe480 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scausing\sthe\ssessions\smodule\sto\soccasionally\slose\strack\sof\srows\nwith\scomposite\sprimary\skeys\swhen\sthere\sare\stwo\srows\swith\sthe\ssame\stext\svalue\nin\sthe\sleftmost\scolumn\sof\sthe\sPK. -D 2018-01-17T17:38:18.448 +C Alternative\simplementation\sfor\sthe\sinternal\ssqlite3Pow10()\sutility\sfor\sMSVC,\nwhich\sis\smore\saccurate\son\sthat\splatform. +D 2018-01-17T21:14:17.292 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -553,7 +553,7 @@ F src/treeview.c eae35972ff44f67064de2eaf35f04afe94e7aea3271a8b3bcebb3f954880fec F src/trigger.c a34539c69433276d37b0da9a89c117726ff2d292c0902895af1f393a983cd3a1 F src/update.c a90a32ffc0100265b0693dbbdbe490756447af181f5ea2c138cce515b08c8795 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 -F src/util.c 7315e97a8dc2c8e19ca64196c652cf0a65d13fd0a211b2cec082062372dc6261 +F src/util.c ef4a5f904d942e660abade7fbf3e6bdb402dabe9e7c27f3361ecf40b945538b5 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 F src/vdbe.c ccc1e17a30325068ae4f0292e8601997946886d23acc989c68f2a261a2795c70 F src/vdbe.h 134beb7a12a6213c00eba58febaede33447cc4441bc568a0d9c144b33fc3720a @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a8aea925f8fde8f2dc5ff4b744d54aa2bf8916f3ee57f22d77fd1ddb5a35a9cc -R fffe7fea955e558a2fcc7877bcdc39db -U dan -Z 8da05c1c6303c10ad33f099cfa382df7 +P 09aed13678374bf22087cd808808b711dc703b7c18bc8aaf704850611e17f5cd +R aea01f6bc87a81119a2fde124523cf0a +U drh +Z 99d77d5f6e6371ac4335dbc304fd54d9 diff --git a/manifest.uuid b/manifest.uuid index 41ac115dac..430019ccf5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -09aed13678374bf22087cd808808b711dc703b7c18bc8aaf704850611e17f5cd \ No newline at end of file +469b96be5350ba2291518280ffe179b87aa7fbe701e2813ef63843922771517a \ No newline at end of file diff --git a/src/util.c b/src/util.c index 75de4b3b30..456317cfa9 100644 --- a/src/util.c +++ b/src/util.c @@ -327,6 +327,26 @@ int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){ ** This routine only works for values of E between 1 and 341. */ static LONGDOUBLE_TYPE sqlite3Pow10(int E){ +#if defined(_MSC_VER) + static const LONGDOUBLE_TYPE x[] = { + 1.0e+001, + 1.0e+002, + 1.0e+004, + 1.0e+008, + 1.0e+016, + 1.0e+032, + 1.0e+064, + 1.0e+128, + 1.0e+256 + }; + LONGDOUBLE_TYPE r = 1.0; + int i; + assert( E>=0 && E<=307 ); + for(i=0; E!=0; i++, E >>=1){ + if( E & 1 ) r *= x[i]; + } + return r; +#else LONGDOUBLE_TYPE x = 10.0; LONGDOUBLE_TYPE r = 1.0; while(1){ @@ -336,6 +356,7 @@ static LONGDOUBLE_TYPE sqlite3Pow10(int E){ x *= x; } return r; +#endif } /* From 1611e5a301fdda3843759c335f073142fc2dd271 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 18 Jan 2018 15:06:23 +0000 Subject: [PATCH 157/190] Simplify the sessions preupdate-hook logic for transforming NULL to X'' for column sqlite_stat1.idx. FossilOrigin-Name: 089d7cecaaa47db58320b216a111a5e56123d022008be6c81bc0746148bbdb58 --- ext/session/sqlite3session.c | 143 +++++++++++++++++++++++------------ manifest | 15 ++-- manifest.uuid | 2 +- 3 files changed, 103 insertions(+), 57 deletions(-) diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index cbe75d5667..fa7dd677a1 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -46,6 +46,7 @@ struct sqlite3_session { int rc; /* Non-zero if an error has occurred */ void *pFilterCtx; /* First argument to pass to xTableFilter */ int (*xTableFilter)(void *pCtx, const char *zTab); + sqlite3_value *pZeroBlob; /* Value containing X'' */ sqlite3_session *pNext; /* Next session object on same db. */ SessionTable *pTable; /* List of attached tables */ SessionHook hook; /* APIs to grab new and old data with */ @@ -473,35 +474,32 @@ static int sessionPreupdateHash( if( rc!=SQLITE_OK ) return rc; eType = sqlite3_value_type(pVal); - if( pTab->bStat1 && eType==SQLITE_NULL ){ - h = sessionHashAppendType(h, SQLITE_BLOB); - }else{ - h = sessionHashAppendType(h, eType); - if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ - i64 iVal; - if( eType==SQLITE_INTEGER ){ - iVal = sqlite3_value_int64(pVal); - }else{ - double rVal = sqlite3_value_double(pVal); - assert( sizeof(iVal)==8 && sizeof(rVal)==8 ); - memcpy(&iVal, &rVal, 8); - } - h = sessionHashAppendI64(h, iVal); - }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){ - const u8 *z; - int n; - if( eType==SQLITE_TEXT ){ - z = (const u8 *)sqlite3_value_text(pVal); - }else{ - z = (const u8 *)sqlite3_value_blob(pVal); - } - n = sqlite3_value_bytes(pVal); - if( !z && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM; - h = sessionHashAppendBlob(h, n, z); + h = sessionHashAppendType(h, eType); + if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ + i64 iVal; + if( eType==SQLITE_INTEGER ){ + iVal = sqlite3_value_int64(pVal); }else{ - assert( eType==SQLITE_NULL ); - *pbNullPK = 1; + double rVal = sqlite3_value_double(pVal); + assert( sizeof(iVal)==8 && sizeof(rVal)==8 ); + memcpy(&iVal, &rVal, 8); } + h = sessionHashAppendI64(h, iVal); + }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){ + const u8 *z; + int n; + if( eType==SQLITE_TEXT ){ + z = (const u8 *)sqlite3_value_text(pVal); + }else{ + z = (const u8 *)sqlite3_value_blob(pVal); + } + n = sqlite3_value_bytes(pVal); + if( !z && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM; + h = sessionHashAppendBlob(h, n, z); + }else{ + assert( eType==SQLITE_NULL ); + assert( pTab->bStat1==0 || i!=1 ); + *pbNullPK = 1; } } } @@ -555,7 +553,7 @@ static unsigned int sessionChangeHash( || eType==SQLITE_TEXT || eType==SQLITE_BLOB || eType==SQLITE_NULL || eType==0 ); - assert( !isPK || (eType!=0 && (pTab->bStat1 || eType!=SQLITE_NULL)) ); + assert( !isPK || (eType!=0 && eType!=SQLITE_NULL) ); if( isPK ){ a++; @@ -563,7 +561,7 @@ static unsigned int sessionChangeHash( if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ h = sessionHashAppendI64(h, sessionGetI64(a)); a += 8; - }else if( eType!=SQLITE_NULL ){ + }else{ int n; a += sessionVarintGet(a, &n); h = sessionHashAppendBlob(h, n, a); @@ -799,7 +797,6 @@ static int sessionPreupdateEqual( sqlite3_value *pVal; /* Value returned by preupdate_new/old */ int rc; /* Error code from preupdate_new/old */ int eType = *a++; /* Type of value from change record */ - int eValType; /* The following calls to preupdate_new() and preupdate_old() can not ** fail. This is because they cache their return values, and by the @@ -814,14 +811,7 @@ static int sessionPreupdateEqual( rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal); } assert( rc==SQLITE_OK ); - eValType = sqlite3_value_type(pVal); - if( eType==SQLITE_BLOB && eValType==SQLITE_NULL && pTab->bStat1 ){ - int n; - a += sessionVarintGet(a, &n); - if( n!=0 ) return 0; - continue; - } - if( eValType!=eType ) return 0; + if( sqlite3_value_type(pVal)!=eType ) return 0; /* A SessionChange object never has a NULL value in a PK column */ assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT @@ -1068,6 +1058,47 @@ static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ return (pSession->rc || pTab->abPK==0); } +/* +** Versions of the four methods in object SessionHook for use with the +** sqlite_stat1 table. The purpose of this is to substitute a zero-length +** blob each time a NULL value is read from the "idx" column of the +** sqlite_stat1 table. +*/ +typedef struct SessionStat1Ctx SessionStat1Ctx; +struct SessionStat1Ctx { + SessionHook hook; + sqlite3_session *pSession; +}; +static int sessionStat1Old(void *pCtx, int iCol, sqlite3_value **ppVal){ + SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx; + sqlite3_value *pVal = 0; + int rc = p->hook.xOld(p->hook.pCtx, iCol, &pVal); + if( rc==SQLITE_OK && iCol==1 && sqlite3_value_type(pVal)==SQLITE_NULL ){ + pVal = p->pSession->pZeroBlob; + } + *ppVal = pVal; + return rc; +} +static int sessionStat1New(void *pCtx, int iCol, sqlite3_value **ppVal){ + SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx; + sqlite3_value *pVal = 0; + int rc = p->hook.xNew(p->hook.pCtx, iCol, &pVal); + if( rc==SQLITE_OK && iCol==1 && sqlite3_value_type(pVal)==SQLITE_NULL ){ + pVal = p->pSession->pZeroBlob; + } + *ppVal = pVal; + return rc; +} +static int sessionStat1Count(void *pCtx){ + SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx; + return p->hook.xCount(p->hook.pCtx); +} +static int sessionStat1Depth(void *pCtx){ + SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx; + return p->hook.xDepth(p->hook.pCtx); +} + + /* ** This function is only called from with a pre-update-hook reporting a ** change on table pTab (attached to session pSession). The type of change @@ -1084,6 +1115,7 @@ static void sessionPreupdateOneChange( int iHash; int bNull = 0; int rc = SQLITE_OK; + SessionStat1Ctx stat1; if( pSession->rc ) return; @@ -1103,13 +1135,32 @@ static void sessionPreupdateOneChange( return; } + if( pTab->bStat1 ){ + stat1.hook = pSession->hook; + stat1.pSession = pSession; + pSession->hook.pCtx = (void*)&stat1; + pSession->hook.xNew = sessionStat1New; + pSession->hook.xOld = sessionStat1Old; + pSession->hook.xCount = sessionStat1Count; + pSession->hook.xDepth = sessionStat1Depth; + if( pSession->pZeroBlob==0 ){ + sqlite3_value *p = sqlite3ValueNew(0); + if( p==0 ){ + rc = SQLITE_NOMEM; + goto error_out; + } + sqlite3ValueSetStr(p, 0, "", 0, SQLITE_STATIC); + pSession->pZeroBlob = p; + } + } + /* Calculate the hash-key for this change. If the primary key of the row ** includes a NULL value, exit early. Such changes are ignored by the ** session module. */ rc = sessionPreupdateHash(pSession, pTab, op==SQLITE_INSERT, &iHash, &bNull); if( rc!=SQLITE_OK ) goto error_out; - if( bNull==0 || pTab->bStat1 ){ + if( bNull==0 ){ /* Search the hash table for an existing record for this row. */ SessionChange *pC; for(pC=pTab->apChange[iHash]; pC; pC=pC->pNext){ @@ -1144,7 +1195,6 @@ static void sessionPreupdateOneChange( rc = sessionSerializeValue(0, p, &nByte); if( rc!=SQLITE_OK ) goto error_out; } - if( pTab->bStat1 ) nByte += 30; /* Allocate the change object */ pChange = (SessionChange *)sqlite3_malloc(nByte); @@ -1168,12 +1218,7 @@ static void sessionPreupdateOneChange( }else if( pTab->abPK[i] ){ pSession->hook.xNew(pSession->hook.pCtx, i, &p); } - if( p && pTab->bStat1 && sqlite3_value_type(p)==SQLITE_NULL ){ - pChange->aRecord[nByte++] = SQLITE_BLOB; - nByte += sessionVarintPut(&pChange->aRecord[nByte], 0); - }else{ - sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte); - } + sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte); } /* Add the change to the hash-table */ @@ -1198,6 +1243,9 @@ static void sessionPreupdateOneChange( /* If an error has occurred, mark the session object as failed. */ error_out: + if( pTab->bStat1 ){ + pSession->hook = stat1.hook; + } if( rc!=SQLITE_OK ){ pSession->rc = rc; } @@ -1659,6 +1707,7 @@ void sqlite3session_delete(sqlite3_session *pSession){ } } sqlite3_mutex_leave(sqlite3_db_mutex(db)); + sqlite3ValueFree(pSession->pZeroBlob); /* Delete all attached table objects. And the contents of their ** associated hash-tables. */ @@ -2188,7 +2237,7 @@ static int sessionSelectBind( switch( eType ){ case 0: case SQLITE_NULL: - /* assert( abPK[i]==0 ); */ + assert( abPK[i]==0 ); break; case SQLITE_INTEGER: { diff --git a/manifest b/manifest index ce17059a62..8c535b9409 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\ssessions\smodule\swith\slogging\ssqlite_stat1\srows\sfor\swhich\n(idx\sIS\sNULL)\sis\strue. -D 2018-01-17T20:57:20.602 +C Simplify\sthe\ssessions\spreupdate-hook\slogic\sfor\stransforming\sNULL\sto\sX''\sfor\ncolumn\ssqlite_stat1.idx. +D 2018-01-18T15:06:23.750 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -400,7 +400,7 @@ F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sessionstat1.test 16268a9bf62ab19c9bc9e41404bf7a13b5fd37c9cb6cf278a472f0c6c50d7ac1 F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc -F ext/session/sqlite3session.c 870d142ec13c0e053139e7f3427aa550e59faf1775ae2bca051766089d9faf7b +F ext/session/sqlite3session.c 55f20fa4a9b6acc338e11867439633c7faa3d18809cdd826fde6abf9a75dd7a0 F ext/session/sqlite3session.h cb4d860101ba6d3ac810f18684539b766d24d668fa2436cdde90d711af9464fb F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 @@ -1700,10 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 09aed13678374bf22087cd808808b711dc703b7c18bc8aaf704850611e17f5cd -R 99a2e08bb84b46a9c74125d0aa1dbedc -T *branch * sessions-stat1 -T *sym-sessions-stat1 * -T -sym-trunk * +P 25bf734be1b3883fccf12ac4d93d50289aa307fb60a52e0e32df12f7ee4edc7a +R f7c998dd2622eae2189b630c53aa0780 U dan -Z 913b883400e9793131764656e068c1a3 +Z 3f8bd6ff445f731b364c070e53a9b8ca diff --git a/manifest.uuid b/manifest.uuid index a3bd20f4c8..0823a466b2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -25bf734be1b3883fccf12ac4d93d50289aa307fb60a52e0e32df12f7ee4edc7a \ No newline at end of file +089d7cecaaa47db58320b216a111a5e56123d022008be6c81bc0746148bbdb58 \ No newline at end of file From d1cccf19b5fd00ed45613d4f14dde59024942158 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 18 Jan 2018 16:42:11 +0000 Subject: [PATCH 158/190] Fix sessions module conflict handling for the sqlite_stat1 table. FossilOrigin-Name: f05ee74e05c401eb075a1ba65179662a08a5c3d5b55fc81f2acc841e841dd055 --- ext/session/sessionstat1.test | 77 +++++++++++++++++++++++++++++++++++ ext/session/sqlite3session.c | 41 +++++++++++++------ manifest | 14 +++---- manifest.uuid | 2 +- 4 files changed, 114 insertions(+), 20 deletions(-) diff --git a/ext/session/sessionstat1.test b/ext/session/sessionstat1.test index 22b2de8dbc..082c02bcf1 100644 --- a/ext/session/sessionstat1.test +++ b/ext/session/sessionstat1.test @@ -226,9 +226,86 @@ do_scc_test 3.7.1 { {INSERT sqlite_stat1 0 XX. {} {t t2 b {} t 6}} } +#------------------------------------------------------------------------- +catch { db2 close } +reset_db +forcedelete test.db2 +sqlite3 db2 test.db2 +do_test 4.1.0 { + do_common_sql { + CREATE TABLE t1(a, b); + CREATE INDEX i1 ON t1(a); + CREATE INDEX i2 ON t1(b); + INSERT INTO t1 VALUES(1,1), (2,2); + ANALYZE; + } + execsql { DELETE FROM sqlite_stat1 } +} {} +do_test 4.1.1 { + execsql { INSERT INTO t1 VALUES(3,3); } + set C [changeset_from_sql {ANALYZE}] + set ::c [list] + proc xConflict {args} { + lappend ::c $args + return "OMIT" + } + sqlite3changeset_apply db2 $C xConflict + set ::c +} [list {*}{ + {INSERT sqlite_stat1 CONFLICT {t t1 t i1 t {3 1}} {t t1 t i1 t {2 1}}} + {INSERT sqlite_stat1 CONFLICT {t t1 t i2 t {3 1}} {t t1 t i2 t {2 1}}} +}] +do_execsql_test -db db2 4.1.2 { + SELECT * FROM sqlite_stat1 ORDER BY 1,2; +} {t1 i1 {2 1} t1 i2 {2 1}} + +do_test 4.1.3 { + proc xConflict {args} { + return "REPLACE" + } + sqlite3changeset_apply db2 $C xConflict + execsql { SELECT * FROM sqlite_stat1 ORDER BY 1,2 } db2 +} {t1 i1 {3 1} t1 i2 {3 1}} + +do_test 4.2.0 { + do_common_sql { + DROP TABLE t1; + CREATE TABLE t3(x,y); + INSERT INTO t3 VALUES('a','a'); + INSERT INTO t3 VALUES('b','b'); + ANALYZE; + } + execsql { DELETE FROM sqlite_stat1 } +} {} +do_test 4.2.1 { + execsql { INSERT INTO t3 VALUES('c','c'); } + set C [changeset_from_sql {ANALYZE}] + set ::c [list] + proc xConflict {args} { + lappend ::c $args + return "OMIT" + } + sqlite3changeset_apply db2 $C xConflict + set ::c +} [list {*}{ + {INSERT sqlite_stat1 CONFLICT {t t3 b {} t 3} {t t3 b {} t 2}} +}] + +db2 null null +do_execsql_test -db db2 4.2.2 { + SELECT * FROM sqlite_stat1 ORDER BY 1,2; +} {t3 null 2} + +do_test 4.2.3 { + proc xConflict {args} { + return "REPLACE" + } + sqlite3changeset_apply db2 $C xConflict + execsql { SELECT * FROM sqlite_stat1 ORDER BY 1,2 } db2 +} {t3 null 3} finish_test diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index fa7dd677a1..ec1a93e08e 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -3378,7 +3378,7 @@ struct SessionApplyCtx { int nCol; /* Size of azCol[] and abPK[] arrays */ const char **azCol; /* Array of column names */ u8 *abPK; /* Boolean array - true if column is in PK */ - + int bStat1; /* True if table is sqlite_stat1 */ int bDeferConstraints; /* True to defer constraints */ SessionBuffer constraints; /* Deferred constraints are stored here */ }; @@ -3981,11 +3981,25 @@ static int sessionApplyOneOp( }else{ assert( op==SQLITE_INSERT ); - rc = sessionBindRow(pIter, sqlite3changeset_new, nCol, 0, p->pInsert); - if( rc!=SQLITE_OK ) return rc; + if( p->bStat1 ){ + /* Check if there is a conflicting row. For sqlite_stat1, this needs + ** to be done using a SELECT, as there is no PRIMARY KEY in the + ** database schema to throw an exception if a duplicate is inserted. */ + rc = sessionSeekToRow(p->db, pIter, p->abPK, p->pSelect); + if( rc==SQLITE_ROW ){ + rc = SQLITE_CONSTRAINT; + sqlite3_reset(p->pSelect); + } + } + + if( rc==SQLITE_OK ){ + rc = sessionBindRow(pIter, sqlite3changeset_new, nCol, 0, p->pInsert); + if( rc!=SQLITE_OK ) return rc; + + sqlite3_step(p->pInsert); + rc = sqlite3_reset(p->pInsert); + } - sqlite3_step(p->pInsert); - rc = sqlite3_reset(p->pInsert); if( (rc&0xff)==SQLITE_CONSTRAINT ){ rc = sessionConflictHandler( SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, pbReplace @@ -4222,13 +4236,16 @@ static int sessionChangesetApply( if( (rc = sessionStat1Sql(db, &sApply) ) ){ break; } - }else - if((rc = sessionSelectRow(db, zTab, &sApply)) - || (rc = sessionUpdateRow(db, zTab, &sApply)) - || (rc = sessionDeleteRow(db, zTab, &sApply)) - || (rc = sessionInsertRow(db, zTab, &sApply)) - ){ - break; + sApply.bStat1 = 1; + }else{ + if((rc = sessionSelectRow(db, zTab, &sApply)) + || (rc = sessionUpdateRow(db, zTab, &sApply)) + || (rc = sessionDeleteRow(db, zTab, &sApply)) + || (rc = sessionInsertRow(db, zTab, &sApply)) + ){ + break; + } + sApply.bStat1 = 0; } } nTab = sqlite3Strlen30(zTab); diff --git a/manifest b/manifest index 8c535b9409..1dd8d9aec3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplify\sthe\ssessions\spreupdate-hook\slogic\sfor\stransforming\sNULL\sto\sX''\sfor\ncolumn\ssqlite_stat1.idx. -D 2018-01-18T15:06:23.750 +C Fix\ssessions\smodule\sconflict\shandling\sfor\sthe\ssqlite_stat1\stable. +D 2018-01-18T16:42:11.152 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -398,9 +398,9 @@ F ext/session/sessionat.test efe88965e74ff1bc2af9c310b28358c02d420c1fb2705cc7a28 F ext/session/sessiondiff.test ad13dd65664bae26744e1f18eb3cbd5588349b7e9118851d8f9364248d67bcec F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 -F ext/session/sessionstat1.test 16268a9bf62ab19c9bc9e41404bf7a13b5fd37c9cb6cf278a472f0c6c50d7ac1 +F ext/session/sessionstat1.test 41cd97c2e48619a41cdf8ae749e1b25f34719de638689221aa43971be693bf4e F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc -F ext/session/sqlite3session.c 55f20fa4a9b6acc338e11867439633c7faa3d18809cdd826fde6abf9a75dd7a0 +F ext/session/sqlite3session.c 989466bba4dff0ede8d4c450b1fc65ca222b87e31193eddbf3931b88bf898a57 F ext/session/sqlite3session.h cb4d860101ba6d3ac810f18684539b766d24d668fa2436cdde90d711af9464fb F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 25bf734be1b3883fccf12ac4d93d50289aa307fb60a52e0e32df12f7ee4edc7a -R f7c998dd2622eae2189b630c53aa0780 +P 089d7cecaaa47db58320b216a111a5e56123d022008be6c81bc0746148bbdb58 +R b26168110a43028fdb5773dcda862810 U dan -Z 3f8bd6ff445f731b364c070e53a9b8ca +Z 3667003c7f66cdcf6e4cbccaf82894fb diff --git a/manifest.uuid b/manifest.uuid index 0823a466b2..fd362a9c44 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -089d7cecaaa47db58320b216a111a5e56123d022008be6c81bc0746148bbdb58 \ No newline at end of file +f05ee74e05c401eb075a1ba65179662a08a5c3d5b55fc81f2acc841e841dd055 \ No newline at end of file From 4b3931ef336a3bbc7cad9290827eb5524b099f63 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 18 Jan 2018 16:52:35 +0000 Subject: [PATCH 159/190] Fix to the documentation for sqlite3_trace_v2(). No changes to code. FossilOrigin-Name: 6fbd0a11a66f8eb4d7820cb49c23bdcb917db98a22c29d76edea1eea6dab0a4e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 9206bfe480..d77626ecd2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Alternative\simplementation\sfor\sthe\sinternal\ssqlite3Pow10()\sutility\sfor\sMSVC,\nwhich\sis\smore\saccurate\son\sthat\splatform. -D 2018-01-17T21:14:17.292 +C Fix\sto\sthe\sdocumentation\sfor\ssqlite3_trace_v2().\s\sNo\schanges\sto\scode. +D 2018-01-18T16:52:35.238 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -488,7 +488,7 @@ F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba F src/shell.c.in 4e1bcf8c70b8fb97c7cbaca6602e2a291d7fe17eff23a5de003d6fabd87f27d1 -F src/sqlite.h.in 840e8aee0d7f8592bd69730797582b342a413eceaff7a220fb5f9db9c412cea9 +F src/sqlite.h.in 959deaad89679e31d7f68fda668b0c5d1f592fffed7a9c1740fb8ded4e4e754a F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 99189e7611eb0bf98f21c7835dc74730a84e2e809c98e1e31c33896dee7a2849 F src/sqliteInt.h 9c70315598b34810a83e4894455acb18e95cf63ce4e6cbb451ac2d17eabc2544 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 09aed13678374bf22087cd808808b711dc703b7c18bc8aaf704850611e17f5cd -R aea01f6bc87a81119a2fde124523cf0a +P 469b96be5350ba2291518280ffe179b87aa7fbe701e2813ef63843922771517a +R 2b93eecc1bfa73dda9a58b538de6c0af U drh -Z 99d77d5f6e6371ac4335dbc304fd54d9 +Z f64363038b04686cc1ed3a7aa13703ce diff --git a/manifest.uuid b/manifest.uuid index 430019ccf5..9ea54531fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -469b96be5350ba2291518280ffe179b87aa7fbe701e2813ef63843922771517a \ No newline at end of file +6fbd0a11a66f8eb4d7820cb49c23bdcb917db98a22c29d76edea1eea6dab0a4e \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 1f7f6a0792..ed1c24de4c 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2951,8 +2951,8 @@ SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** KEYWORDS: SQLITE_TRACE ** ** These constants identify classes of events that can be monitored -** using the [sqlite3_trace_v2()] tracing logic. The third argument -** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of +** using the [sqlite3_trace_v2()] tracing logic. The M argument +** to [sqlite3_trace_v2(D,M,X,P)] is an OR-ed combination of one or more of ** the following constants. ^The first argument to the trace callback ** is one of the following constants. ** From e3ca3831bae7ae6f7a7ba2d858f8bf95d6e1af83 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 18 Jan 2018 16:53:41 +0000 Subject: [PATCH 160/190] Add comments describing the special sqlite_stat1 handling to sqlite3session.h. FossilOrigin-Name: 4431a3256f7436e34b3c33edc1f3e53df7eb3c87daec9bac8d038895d93ca7f2 --- ext/session/sqlite3session.h | 24 ++++++++++++++++++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/ext/session/sqlite3session.h b/ext/session/sqlite3session.h index b22df129cb..23d8e689fc 100644 --- a/ext/session/sqlite3session.h +++ b/ext/session/sqlite3session.h @@ -147,6 +147,30 @@ int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect); ** ** SQLITE_OK is returned if the call completes without error. Or, if an error ** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned. +** +**

Special sqlite_stat1 Handling

+** +** The "sqlite_stat1" table is an exception to some of the rules above. In +** SQLite, the schema of sqlite_stat1 is: +**
+**        CREATE TABLE sqlite_stat1(tbl,idx,stat)  
+**  
+** +** Even though sqlite_stat1 does not have a PRIMARY KEY, changes are +** recorded for it as if the PRIMARY KEY is (tbl,idx). Additionally, changes +** are recorded for rows for which (idx IS NULL) is true. However, for such +** rows a zero-length blob (SQL value X'') is stored in the changeset or +** patchset instead of a NULL value. This allows such changesets to be +** manipulated by legacy implementations of sqlite3changeset_invert(), +** concat() and similar. +** +** The sqlite3changeset_apply() function automatically converts the +** zero-length blob back to a NULL value when updating the sqlite_stat1 +** table. However, if the application calls sqlite3changeset_new(), +** sqlite3changeset_old() or sqlite3changeset_conflict on a changeset +** iterator directly (including on a changeset iterator passed to a +** conflict-handler callback) then the X'' value is returned. The application +** must translate X'' to NULL itself if required. */ int sqlite3session_attach( sqlite3_session *pSession, /* Session object */ diff --git a/manifest b/manifest index 1dd8d9aec3..5cb2ef0657 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssessions\smodule\sconflict\shandling\sfor\sthe\ssqlite_stat1\stable. -D 2018-01-18T16:42:11.152 +C Add\scomments\sdescribing\sthe\sspecial\ssqlite_stat1\shandling\sto\ssqlite3session.h. +D 2018-01-18T16:53:41.289 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -401,7 +401,7 @@ F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sessionstat1.test 41cd97c2e48619a41cdf8ae749e1b25f34719de638689221aa43971be693bf4e F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc F ext/session/sqlite3session.c 989466bba4dff0ede8d4c450b1fc65ca222b87e31193eddbf3931b88bf898a57 -F ext/session/sqlite3session.h cb4d860101ba6d3ac810f18684539b766d24d668fa2436cdde90d711af9464fb +F ext/session/sqlite3session.h 1bf32a9598ae4288bf7ecbda032a0479d6225ab8d2283fd252056a26b1046946 F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 089d7cecaaa47db58320b216a111a5e56123d022008be6c81bc0746148bbdb58 -R b26168110a43028fdb5773dcda862810 +P f05ee74e05c401eb075a1ba65179662a08a5c3d5b55fc81f2acc841e841dd055 +R 62c81de92f4cf24f6460f153aeb30b06 U dan -Z 3667003c7f66cdcf6e4cbccaf82894fb +Z 4f9e979274bbe8dc16dfd6dd12c05029 diff --git a/manifest.uuid b/manifest.uuid index fd362a9c44..699a6f987c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f05ee74e05c401eb075a1ba65179662a08a5c3d5b55fc81f2acc841e841dd055 \ No newline at end of file +4431a3256f7436e34b3c33edc1f3e53df7eb3c87daec9bac8d038895d93ca7f2 \ No newline at end of file From cae5b9feacb655ede761d15cc00d37b82e35b5b2 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 18 Jan 2018 16:56:19 +0000 Subject: [PATCH 161/190] Clarify the handling of the sqlite_stat1 table by legacy versions of the sessions module. FossilOrigin-Name: dc7c48cb4126db9e25c73512cc743155293fe1c4c2516f8c84102228695b6e70 --- ext/session/sqlite3session.h | 9 +++++++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ext/session/sqlite3session.h b/ext/session/sqlite3session.h index 23d8e689fc..9f33855df0 100644 --- a/ext/session/sqlite3session.h +++ b/ext/session/sqlite3session.h @@ -150,8 +150,8 @@ int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect); ** **

Special sqlite_stat1 Handling

** -** The "sqlite_stat1" table is an exception to some of the rules above. In -** SQLite, the schema of sqlite_stat1 is: +** As of SQLite version 3.22.0, the "sqlite_stat1" table is an exception to +** some of the rules above. In SQLite, the schema of sqlite_stat1 is: **
 **        CREATE TABLE sqlite_stat1(tbl,idx,stat)  
 **  
@@ -171,6 +171,11 @@ int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect); ** iterator directly (including on a changeset iterator passed to a ** conflict-handler callback) then the X'' value is returned. The application ** must translate X'' to NULL itself if required. +** +** Legacy (older than 3.22.0) versions of the sessions module cannot capture +** changes made to the sqlite_stat1 table. Legacy versions of the +** sqlite3changeset_apply() function silently ignore any modifications to the +** sqlite_stat1 table that are part of a changeset or patchset. */ int sqlite3session_attach( sqlite3_session *pSession, /* Session object */ diff --git a/manifest b/manifest index 5cb2ef0657..44a95be5ce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\scomments\sdescribing\sthe\sspecial\ssqlite_stat1\shandling\sto\ssqlite3session.h. -D 2018-01-18T16:53:41.289 +C Clarify\sthe\shandling\sof\sthe\ssqlite_stat1\stable\sby\slegacy\sversions\sof\sthe\nsessions\smodule. +D 2018-01-18T16:56:19.115 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -401,7 +401,7 @@ F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sessionstat1.test 41cd97c2e48619a41cdf8ae749e1b25f34719de638689221aa43971be693bf4e F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc F ext/session/sqlite3session.c 989466bba4dff0ede8d4c450b1fc65ca222b87e31193eddbf3931b88bf898a57 -F ext/session/sqlite3session.h 1bf32a9598ae4288bf7ecbda032a0479d6225ab8d2283fd252056a26b1046946 +F ext/session/sqlite3session.h 01774161cbd328fe3d496323655b9cc142317ff1fb1ae15c1232075ea240e3a4 F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f05ee74e05c401eb075a1ba65179662a08a5c3d5b55fc81f2acc841e841dd055 -R 62c81de92f4cf24f6460f153aeb30b06 +P 4431a3256f7436e34b3c33edc1f3e53df7eb3c87daec9bac8d038895d93ca7f2 +R 6488443bbec455d1afdebff112c6cb1b U dan -Z 4f9e979274bbe8dc16dfd6dd12c05029 +Z 8531e6daca6e4a95660fec10c24747c3 diff --git a/manifest.uuid b/manifest.uuid index 699a6f987c..ecf7bc63d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4431a3256f7436e34b3c33edc1f3e53df7eb3c87daec9bac8d038895d93ca7f2 \ No newline at end of file +dc7c48cb4126db9e25c73512cc743155293fe1c4c2516f8c84102228695b6e70 \ No newline at end of file From 80db2d65212b1d029ea042e7d6350ac313b3b096 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 18 Jan 2018 17:09:26 +0000 Subject: [PATCH 162/190] Update the autoconf configure.ac script and Makefile.am templates so that ZLIB is automatically detected and used. FossilOrigin-Name: 41bfb6b8d61699d09a7e67d2289149abfbb9ce8e75e6ff8560546cad0d2e3f2b --- autoconf/Makefile.am | 2 +- autoconf/configure.ac | 3 +++ manifest | 17 ++++++++--------- manifest.uuid | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/autoconf/Makefile.am b/autoconf/Makefile.am index 8c046f822d..0f0706873a 100644 --- a/autoconf/Makefile.am +++ b/autoconf/Makefile.am @@ -1,5 +1,5 @@ -AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ @SESSION_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE +AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ @ZLIB_FLAGS@ @SESSION_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE lib_LTLIBRARIES = libsqlite3.la libsqlite3_la_SOURCES = sqlite3.c diff --git a/autoconf/configure.ac b/autoconf/configure.ac index c207bdf74d..c1e28043d8 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -164,6 +164,9 @@ AC_SUBST(EXTRA_SHELL_OBJ) #----------------------------------------------------------------------- AC_CHECK_FUNCS(posix_fallocate) +AC_CHECK_HEADERS(zlib.h) +AC_SEARCH_LIBS(deflate,z,[ZLIB_FLAGS="-DSQLITE_HAVE_ZLIB"]) +AC_SUBST(ZLIB_FLAGS) #----------------------------------------------------------------------- # UPDATE: Maybe it's better if users just set CFLAGS before invoking diff --git a/manifest b/manifest index 3cd31bd5cc..44d3a7e510 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssessions\smodule\shandling\sof\ssqlite_stat1\srows\swith\s(idx\sIS\sNULL). -D 2018-01-18T16:59:52.652 +C Update\sthe\sautoconf\sconfigure.ac\sscript\sand\sMakefile.am\stemplates\sso\sthat\nZLIB\sis\sautomatically\sdetected\sand\sused. +D 2018-01-18T17:09:26.634 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -12,11 +12,11 @@ F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 -F autoconf/Makefile.am 66c0befa511f0d95ba229e180067cf0357a9ebf8b3201b06d683c5ba6220fb39 +F autoconf/Makefile.am 6cca3f797c649b40c762484ce26491839fec54de72d376d774969e76ed13931f F autoconf/Makefile.msc 2c50a59319af7da4eaca8c13e3240881b1bc245fd175845a055faab7d03d6e67 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 -F autoconf/configure.ac 8dd08ca564279fff091c9bfdd2599d8f992c9f1f70c5396de2126ad2bd1b3bed +F autoconf/configure.ac c610cbec367dfdcbbe1341f445699700a0f9e157150254e1d3460fa1602e33c5 F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -1700,8 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6fbd0a11a66f8eb4d7820cb49c23bdcb917db98a22c29d76edea1eea6dab0a4e dc7c48cb4126db9e25c73512cc743155293fe1c4c2516f8c84102228695b6e70 -R e340b654f2343cebf57c71c1eef74e4f -T +closed dc7c48cb4126db9e25c73512cc743155293fe1c4c2516f8c84102228695b6e70 -U dan -Z 94f64c633d9eca20229572c5d0ac1d82 +P 0e916416331d7948b312a5dd58ac0c145030bb3b47a37dab2636564397249a86 +R 5056e176b64caf38b7d602040a3b5ee2 +U drh +Z 40c80df1df52239dfd839811e525ac68 diff --git a/manifest.uuid b/manifest.uuid index 368a3978bc..6a3e896c14 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0e916416331d7948b312a5dd58ac0c145030bb3b47a37dab2636564397249a86 \ No newline at end of file +41bfb6b8d61699d09a7e67d2289149abfbb9ce8e75e6ff8560546cad0d2e3f2b \ No newline at end of file From 5a7da86f5bc2f5b18320911ae82730a76b459f6c Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 18 Jan 2018 17:46:08 +0000 Subject: [PATCH 163/190] Check for both zlib.h and -lz before enabling zlib support in the amalgamation configure script. FossilOrigin-Name: 8ecd13a1b38e58d4464585c388c1aa27d1f056dba0db239316623e81d3eb5284 --- autoconf/configure.ac | 5 +++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index c1e28043d8..19975e96c7 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -164,8 +164,9 @@ AC_SUBST(EXTRA_SHELL_OBJ) #----------------------------------------------------------------------- AC_CHECK_FUNCS(posix_fallocate) -AC_CHECK_HEADERS(zlib.h) -AC_SEARCH_LIBS(deflate,z,[ZLIB_FLAGS="-DSQLITE_HAVE_ZLIB"]) +AC_CHECK_HEADERS(zlib.h,[ + AC_SEARCH_LIBS(deflate,z,[ZLIB_FLAGS="-DSQLITE_HAVE_ZLIB"]) +]) AC_SUBST(ZLIB_FLAGS) #----------------------------------------------------------------------- diff --git a/manifest b/manifest index 44d3a7e510..6d30478671 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sautoconf\sconfigure.ac\sscript\sand\sMakefile.am\stemplates\sso\sthat\nZLIB\sis\sautomatically\sdetected\sand\sused. -D 2018-01-18T17:09:26.634 +C Check\sfor\sboth\szlib.h\sand\s-lz\sbefore\senabling\szlib\ssupport\sin\sthe\samalgamation\nconfigure\sscript. +D 2018-01-18T17:46:08.702 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -16,7 +16,7 @@ F autoconf/Makefile.am 6cca3f797c649b40c762484ce26491839fec54de72d376d774969e76e F autoconf/Makefile.msc 2c50a59319af7da4eaca8c13e3240881b1bc245fd175845a055faab7d03d6e67 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 -F autoconf/configure.ac c610cbec367dfdcbbe1341f445699700a0f9e157150254e1d3460fa1602e33c5 +F autoconf/configure.ac aeeed858e5e54e79052ae44ba774e56595dcb787f23a2155aa98a8aa27327b66 F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0e916416331d7948b312a5dd58ac0c145030bb3b47a37dab2636564397249a86 -R 5056e176b64caf38b7d602040a3b5ee2 -U drh -Z 40c80df1df52239dfd839811e525ac68 +P 41bfb6b8d61699d09a7e67d2289149abfbb9ce8e75e6ff8560546cad0d2e3f2b +R 6ef8367290b0a71ac4c6dc7b9f60b8d6 +U dan +Z 5d28bdaaa8634c1e4ea00e17fbeb8b59 diff --git a/manifest.uuid b/manifest.uuid index 6a3e896c14..7dab0d2ef4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -41bfb6b8d61699d09a7e67d2289149abfbb9ce8e75e6ff8560546cad0d2e3f2b \ No newline at end of file +8ecd13a1b38e58d4464585c388c1aa27d1f056dba0db239316623e81d3eb5284 \ No newline at end of file From 1a3a3086163d90e6e71d1c103a2e0dc93438f368 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 18 Jan 2018 19:00:54 +0000 Subject: [PATCH 164/190] Use a loop to avoid recursion in the heightOfSelect() function. FossilOrigin-Name: 86de43595cb2ecebd680fe654affcfb9fbcfff6575c893293ae298124a357bfe --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6d30478671..46d6df3929 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Check\sfor\sboth\szlib.h\sand\s-lz\sbefore\senabling\szlib\ssupport\sin\sthe\samalgamation\nconfigure\sscript. -D 2018-01-18T17:46:08.702 +C Use\sa\sloop\sto\savoid\srecursion\sin\sthe\sheightOfSelect()\sfunction. +D 2018-01-18T19:00:54.739 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -439,7 +439,7 @@ F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957 F src/dbpage.c 8db4c97f630e7d83f884ea75caf1ffd0988c160e9d530194d93721c80821e0f6 F src/dbstat.c 7a4ba8518b6369ef3600c49cf9c918ad979acba610b2aebef1b656d649b96720 F src/delete.c 20c8788451dc737a967c87ea53ad43544d617f5b57d32ccce8bd52a0daf9e89b -F src/expr.c 46a7d73d5579feaee7a7274fac0efea0bbae71dd5b107a569501d89e0280c762 +F src/expr.c 9e06de431c09f144438aa6895ea4d4290fa3c6875bfcc3ba331012ca78deadf0 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c d617daf66b5515e2b42c1405b2b4984c30ca50fb705ab164271a9bf66c69e331 F src/func.c bd528d5ed68ce5cbf78a762e3b735fa75009f7197ff07fab07fd771f35ebaa1b @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 41bfb6b8d61699d09a7e67d2289149abfbb9ce8e75e6ff8560546cad0d2e3f2b -R 6ef8367290b0a71ac4c6dc7b9f60b8d6 +P 8ecd13a1b38e58d4464585c388c1aa27d1f056dba0db239316623e81d3eb5284 +R 9a4e211a827ab99465bb99e30ad64851 U dan -Z 5d28bdaaa8634c1e4ea00e17fbeb8b59 +Z e6a246820ca47f13d6230f5df19d2f34 diff --git a/manifest.uuid b/manifest.uuid index 7dab0d2ef4..27f50bd5da 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ecd13a1b38e58d4464585c388c1aa27d1f056dba0db239316623e81d3eb5284 \ No newline at end of file +86de43595cb2ecebd680fe654affcfb9fbcfff6575c893293ae298124a357bfe \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index a63de5d9fc..1b87734923 100644 --- a/src/expr.c +++ b/src/expr.c @@ -658,15 +658,15 @@ static void heightOfExprList(ExprList *p, int *pnHeight){ } } } -static void heightOfSelect(Select *p, int *pnHeight){ - if( p ){ +static void heightOfSelect(Select *pSelect, int *pnHeight){ + Select *p; + for(p=pSelect; p; p=p->pPrior){ heightOfExpr(p->pWhere, pnHeight); heightOfExpr(p->pHaving, pnHeight); heightOfExpr(p->pLimit, pnHeight); heightOfExprList(p->pEList, pnHeight); heightOfExprList(p->pGroupBy, pnHeight); heightOfExprList(p->pOrderBy, pnHeight); - heightOfSelect(p->pPrior, pnHeight); } } From 2f949354094eb96f40d3f5d998e18ea123266791 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 20 Jan 2018 15:48:45 +0000 Subject: [PATCH 165/190] Allow the shell to be built from the configure script with SQLITE_OMIT_VIRTUALTABLE defined. FossilOrigin-Name: 136bf323e42dc90e1780199a381bcbb084b069eca5c7343ee6fc6e2550831536 --- ext/rtree/rtree.c | 3 ++- ext/rtree/rtree.h | 4 ++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index ddabacf408..c0fd8c1819 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -52,7 +52,8 @@ ** child page. */ -#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE) +#if !defined(SQLITE_CORE) \ + || (defined(SQLITE_ENABLE_RTREE) && !defined(SQLITE_OMIT_VIRTUALTABLE)) #ifndef SQLITE_CORE #include "sqlite3ext.h" diff --git a/ext/rtree/rtree.h b/ext/rtree/rtree.h index 1fdbcccc5e..8f41500db1 100644 --- a/ext/rtree/rtree.h +++ b/ext/rtree/rtree.h @@ -15,6 +15,10 @@ */ #include "sqlite3.h" +#ifdef SQLITE_OMIT_VIRTUALTABLE +# undef SQLITE_ENABLE_RTREE +#endif + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/manifest b/manifest index 46d6df3929..42c7b8baef 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sa\sloop\sto\savoid\srecursion\sin\sthe\sheightOfSelect()\sfunction. -D 2018-01-18T19:00:54.739 +C Allow\sthe\sshell\sto\sbe\sbuilt\sfrom\sthe\sconfigure\sscript\swith\nSQLITE_OMIT_VIRTUALTABLE\sdefined. +D 2018-01-20T15:48:45.590 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -350,8 +350,8 @@ F ext/repair/test/checkfreelist01.test 3e8aa6aeb4007680c94a8d07b41c339aa635cc782 F ext/repair/test/checkindex01.test 6945d0ffc0c1dc993b2ce88036b26e0f5d6fcc65da70fc9df27c2647bb358b0f F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 2111f685ae07988622c241f819b56fea60782f56e32f97e334473c59f6083481 -F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e +F ext/rtree/rtree.c d941e44ad901da039caebb9f9fa99d81f2a4fc822e67cafe33fa4f6f789074a0 +F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 F ext/rtree/rtree1.test 82a353747fcab1083d114b2ac84723dfefdbf86c1a6e1df57bf588c7d4285436 F ext/rtree/rtree2.test 5f25b01acd03470067a2d52783b2eb0a50bf836803d4342d20ca39e541220fe2 F ext/rtree/rtree3.test 2cafe8265d1ff28f206fce88d114f208349df482 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8ecd13a1b38e58d4464585c388c1aa27d1f056dba0db239316623e81d3eb5284 -R 9a4e211a827ab99465bb99e30ad64851 +P 86de43595cb2ecebd680fe654affcfb9fbcfff6575c893293ae298124a357bfe +R 2aef84e59a8aa705a9da75b37e8e2525 U dan -Z e6a246820ca47f13d6230f5df19d2f34 +Z bdb13a1015e901b31413d002f63ee72f diff --git a/manifest.uuid b/manifest.uuid index 27f50bd5da..fbb8d7d872 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -86de43595cb2ecebd680fe654affcfb9fbcfff6575c893293ae298124a357bfe \ No newline at end of file +136bf323e42dc90e1780199a381bcbb084b069eca5c7343ee6fc6e2550831536 \ No newline at end of file From 88284b0dc3077939450b4341a0e6ea365f15a8da Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 22 Jan 2018 14:49:15 +0000 Subject: [PATCH 166/190] On the walro2-X.4.2.2 test case, show the size as part of the test output. FossilOrigin-Name: ac5091d7f870f1d0659a576723de454d544e5bfa2bdbba307d7c81eb5ab34e3b --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/walro2.test | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 42c7b8baef..246b9c257a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sthe\sshell\sto\sbe\sbuilt\sfrom\sthe\sconfigure\sscript\swith\nSQLITE_OMIT_VIRTUALTABLE\sdefined. -D 2018-01-20T15:48:45.590 +C On\sthe\swalro2-X.4.2.2\stest\scase,\sshow\sthe\ssize\sas\spart\sof\sthe\stest\soutput. +D 2018-01-22T14:49:15.357 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -1553,7 +1553,7 @@ F test/waloverwrite.test dad2f26567f1b45174e54fbf9a8dc1cb876a7f03 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6 F test/walprotocol.test a112aba0b79e3adeaa485fed09484b32c654e97df58e454aa8489ac2cd57bf84 F test/walro.test cb438d05ba0d191f10b688e39c4f0cd5b71569a1d1f4440e5bdf3c6880e08c20 -F test/walro2.test 5cd57d192ee334c3894330303b5f8cb6789fef49b2c83ad1b50b9b132d0f7ae1 +F test/walro2.test 71064938e9361bcaefaf5c49bf1be43d7abf44191775eb420e2a1b49dc24824c F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cfd51af68 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417 F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 86de43595cb2ecebd680fe654affcfb9fbcfff6575c893293ae298124a357bfe -R 2aef84e59a8aa705a9da75b37e8e2525 -U dan -Z bdb13a1015e901b31413d002f63ee72f +P 136bf323e42dc90e1780199a381bcbb084b069eca5c7343ee6fc6e2550831536 +R bce02ef85f0218ef6af27099f7e6faff +U drh +Z d37652af866e22c18f57c4be2ebbb16f diff --git a/manifest.uuid b/manifest.uuid index fbb8d7d872..ee0b016b91 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -136bf323e42dc90e1780199a381bcbb084b069eca5c7343ee6fc6e2550831536 \ No newline at end of file +ac5091d7f870f1d0659a576723de454d544e5bfa2bdbba307d7c81eb5ab34e3b \ No newline at end of file diff --git a/test/walro2.test b/test/walro2.test index 876a03196b..14ed050a86 100644 --- a/test/walro2.test +++ b/test/walro2.test @@ -263,6 +263,7 @@ do_multiclient_test tn { } {500} do_test $TN.4.2.2 { set sz [file size test.db-wal] + puts -nonewline " (sz=$sz)" expr {$sz>400000 && $sz<500000} } {1} do_test $TN.4.2.4 { From 3a9b9b7749d993f066580b58783009ae6acc1d13 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 22 Jan 2018 15:20:59 +0000 Subject: [PATCH 167/190] Fix a test case in walro2.test so that it works with encryption extensions (when each page has a little less usable space available than usual). FossilOrigin-Name: b79521d255a4aa2a7b4424f3498443f27d329ab5428171ba6b87c987f3ccdfc2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/walro2.test | 7 +++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 246b9c257a..377da8a826 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\sthe\swalro2-X.4.2.2\stest\scase,\sshow\sthe\ssize\sas\spart\sof\sthe\stest\soutput. -D 2018-01-22T14:49:15.357 +C Fix\sa\stest\scase\sin\swalro2.test\sso\sthat\sit\sworks\swith\sencryption\sextensions\n(when\seach\spage\shas\sa\slittle\sless\susable\sspace\savailable\sthan\susual). +D 2018-01-22T15:20:59.941 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -1553,7 +1553,7 @@ F test/waloverwrite.test dad2f26567f1b45174e54fbf9a8dc1cb876a7f03 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6 F test/walprotocol.test a112aba0b79e3adeaa485fed09484b32c654e97df58e454aa8489ac2cd57bf84 F test/walro.test cb438d05ba0d191f10b688e39c4f0cd5b71569a1d1f4440e5bdf3c6880e08c20 -F test/walro2.test 71064938e9361bcaefaf5c49bf1be43d7abf44191775eb420e2a1b49dc24824c +F test/walro2.test 6c73e8e4b5ccc55f907f4603ba36458b45c085fb6dfb04f30e3c0babbc1c2f41 F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cfd51af68 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417 F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 136bf323e42dc90e1780199a381bcbb084b069eca5c7343ee6fc6e2550831536 -R bce02ef85f0218ef6af27099f7e6faff -U drh -Z d37652af866e22c18f57c4be2ebbb16f +P ac5091d7f870f1d0659a576723de454d544e5bfa2bdbba307d7c81eb5ab34e3b +R 9a2bdae57204fedd8fbbe0575e4c9803 +U dan +Z 65b36c011f8ff7d800b7cbb8bc8e96b2 diff --git a/manifest.uuid b/manifest.uuid index ee0b016b91..89345a02b5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac5091d7f870f1d0659a576723de454d544e5bfa2bdbba307d7c81eb5ab34e3b \ No newline at end of file +b79521d255a4aa2a7b4424f3498443f27d329ab5428171ba6b87c987f3ccdfc2 \ No newline at end of file diff --git a/test/walro2.test b/test/walro2.test index 14ed050a86..1c51e91ec5 100644 --- a/test/walro2.test +++ b/test/walro2.test @@ -261,10 +261,9 @@ do_multiclient_test tn { SELECT count(*) FROM t2; } } {500} - do_test $TN.4.2.2 { - set sz [file size test.db-wal] - puts -nonewline " (sz=$sz)" - expr {$sz>400000 && $sz<500000} + set sz [file size test.db-wal] + do_test $TN.4.2.2.(sz=$sz) { + expr {$sz>400000} } {1} do_test $TN.4.2.4 { file_control_persist_wal db 1; db close From 8bfe66a9c4da70834daca140227f2b3a0460a9ab Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 22 Jan 2018 15:45:12 +0000 Subject: [PATCH 168/190] Avoid unnecessary OOM detection warnings in a debugging routine. FossilOrigin-Name: 395f8ea790e6e295800fa8927f0585b2419b9521ef4fd591d51d2a48db2a90c4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 5 ++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 377da8a826..f11b306145 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stest\scase\sin\swalro2.test\sso\sthat\sit\sworks\swith\sencryption\sextensions\n(when\seach\spage\shas\sa\slittle\sless\susable\sspace\savailable\sthan\susual). -D 2018-01-22T15:20:59.941 +C Avoid\sunnecessary\sOOM\sdetection\swarnings\sin\sa\sdebugging\sroutine. +D 2018-01-22T15:45:12.922 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -428,7 +428,7 @@ F src/auth.c 6277d63837357549fe14e723490d6dc1a38768d71c795c5eb5c0f8a99f918f73 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca -F src/btree.c 0a1f63b50ab1ac5d4b1637c30cb1ae123fbc162ec8cb6336ddb9491a0bc1e363 +F src/btree.c bfc453babec9aa8196ab5db5e588ac5d3f0c398d72faa37296167a84a61c9f2f F src/btree.h 0866c0a08255142ea0e754aabd211c843cab32045c978a592a43152405ed0c84 F src/btreeInt.h 55b702efce17e5d1941865464227d3802cfc9c7c832fac81d4c94dced47a71fc F src/build.c 9f9647454f236cab097f266ae970f899b53c71cadab6756c47e2b2e81392c2a1 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ac5091d7f870f1d0659a576723de454d544e5bfa2bdbba307d7c81eb5ab34e3b -R 9a2bdae57204fedd8fbbe0575e4c9803 -U dan -Z 65b36c011f8ff7d800b7cbb8bc8e96b2 +P b79521d255a4aa2a7b4424f3498443f27d329ab5428171ba6b87c987f3ccdfc2 +R e7cccb4f976b9eb07c1586193cc26ec5 +U drh +Z b64137fc7f67b8d25a73e5d06cbfe718 diff --git a/manifest.uuid b/manifest.uuid index 89345a02b5..3c8a7f3fb9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b79521d255a4aa2a7b4424f3498443f27d329ab5428171ba6b87c987f3ccdfc2 \ No newline at end of file +395f8ea790e6e295800fa8927f0585b2419b9521ef4fd591d51d2a48db2a90c4 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 8cd5ee6739..3b42f68f9f 100644 --- a/src/btree.c +++ b/src/btree.c @@ -123,9 +123,12 @@ int sqlite3_enable_shared_cache(int enable){ */ #ifdef SQLITE_DEBUG int corruptPageError(int lineno, MemPage *p){ - char *zMsg = sqlite3_mprintf("database corruption page %d of %s", + char *zMsg; + sqlite3BeginBenignMalloc(); + zMsg = sqlite3_mprintf("database corruption page %d of %s", (int)p->pgno, sqlite3PagerFilename(p->pBt->pPager, 0) ); + sqlite3EndBenignMalloc(); if( zMsg ){ sqlite3ReportError(SQLITE_CORRUPT, lineno, zMsg); } From 138d4f8de22f24317fc77c301d545c43542ae592 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 22 Jan 2018 18:45:57 +0000 Subject: [PATCH 169/190] Version 3.22.0 FossilOrigin-Name: 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d --- manifest | 11 +++++++---- manifest.uuid | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/manifest b/manifest index f11b306145..59cd9b34a1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sunnecessary\sOOM\sdetection\swarnings\sin\sa\sdebugging\sroutine. -D 2018-01-22T15:45:12.922 +C Version\s3.22.0 +D 2018-01-22T18:45:57.681 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -1700,7 +1700,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b79521d255a4aa2a7b4424f3498443f27d329ab5428171ba6b87c987f3ccdfc2 +P 395f8ea790e6e295800fa8927f0585b2419b9521ef4fd591d51d2a48db2a90c4 R e7cccb4f976b9eb07c1586193cc26ec5 +T +bgcolor * #d0c0ff +T +sym-release * +T +sym-version-3.22.0 * U drh -Z b64137fc7f67b8d25a73e5d06cbfe718 +Z 9c0e858ece53e1ee810a8a479ae4dc82 diff --git a/manifest.uuid b/manifest.uuid index 3c8a7f3fb9..ed79ed6466 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -395f8ea790e6e295800fa8927f0585b2419b9521ef4fd591d51d2a48db2a90c4 \ No newline at end of file +0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d \ No newline at end of file From b71aa0955bdea9fefdfe991f623da6f5f828bd6c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 23 Jan 2018 00:05:18 +0000 Subject: [PATCH 170/190] Fix harmless compiler warnings seen with MSVC. FossilOrigin-Name: 76a11a80e94d1e9c9645e6e348948f3fd508266d4569c85d80a3879862d0a819 --- ext/session/sqlite3session.c | 2 +- manifest | 19 ++++++++----------- manifest.uuid | 2 +- src/shell.c.in | 13 +++++++------ 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index ec1a93e08e..67915e04f1 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -1115,7 +1115,7 @@ static void sessionPreupdateOneChange( int iHash; int bNull = 0; int rc = SQLITE_OK; - SessionStat1Ctx stat1; + SessionStat1Ctx stat1 = {0, 0}; if( pSession->rc ) return; diff --git a/manifest b/manifest index 59cd9b34a1..31134887c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.22.0 -D 2018-01-22T18:45:57.681 +C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. +D 2018-01-23T00:05:18.184 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -400,7 +400,7 @@ F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sessionstat1.test 41cd97c2e48619a41cdf8ae749e1b25f34719de638689221aa43971be693bf4e F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc -F ext/session/sqlite3session.c 989466bba4dff0ede8d4c450b1fc65ca222b87e31193eddbf3931b88bf898a57 +F ext/session/sqlite3session.c 63cfde70155b597480b2d01e65031f8e60d204103db7adf6156fe48e3e379392 F ext/session/sqlite3session.h 01774161cbd328fe3d496323655b9cc142317ff1fb1ae15c1232075ea240e3a4 F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 @@ -487,7 +487,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba -F src/shell.c.in 4e1bcf8c70b8fb97c7cbaca6602e2a291d7fe17eff23a5de003d6fabd87f27d1 +F src/shell.c.in 06ffe417973eacbee77a8402e26553b938e7c07f735c811701fc5cd1e642fb5c F src/sqlite.h.in 959deaad89679e31d7f68fda668b0c5d1f592fffed7a9c1740fb8ded4e4e754a F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 99189e7611eb0bf98f21c7835dc74730a84e2e809c98e1e31c33896dee7a2849 @@ -1700,10 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 395f8ea790e6e295800fa8927f0585b2419b9521ef4fd591d51d2a48db2a90c4 -R e7cccb4f976b9eb07c1586193cc26ec5 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.22.0 * -U drh -Z 9c0e858ece53e1ee810a8a479ae4dc82 +P 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d +R 8f662370d27c0dbf362ba912c090e456 +U mistachkin +Z fc242cf748005a9ff5528ff032a48505 diff --git a/manifest.uuid b/manifest.uuid index ed79ed6466..ae3e0fe06b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d \ No newline at end of file +76a11a80e94d1e9c9645e6e348948f3fd508266d4569c85d80a3879862d0a819 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index d9c8705e70..e3a1f30752 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1272,9 +1272,10 @@ static void editFunc( goto edit_func_end; } if( bBin ){ - sqlite3_result_blob(context, p, sz, sqlite3_free); + sqlite3_result_blob64(context, p, sz, sqlite3_free); }else{ - sqlite3_result_text(context, (const char*)p, sz, sqlite3_free); + sqlite3_result_text64(context, (const char*)p, sz, + sqlite3_free, SQLITE_UTF8); } p = 0; @@ -3435,7 +3436,7 @@ static void open_db(ShellState *p, int keepAlive){ if( p->db==0 ){ sqlite3_initialize(); if( p->openMode==SHELL_OPEN_UNSPEC && access(p->zDbFilename,0)==0 ){ - p->openMode = deduceDatabaseType(p->zDbFilename); + p->openMode = (u8)deduceDatabaseType(p->zDbFilename); } switch( p->openMode ){ case SHELL_OPEN_APPENDVFS: { @@ -5715,7 +5716,7 @@ static int do_meta_command(char *zLine, ShellState *p){ }else if( strcmp(azArg[1],"trigger")==0 ){ p->autoEQP = AUTOEQP_trigger; }else{ - p->autoEQP = booleanValue(azArg[1]); + p->autoEQP = (u8)booleanValue(azArg[1]); } }else{ raw_printf(stderr, "Usage: .eqp off|on|trigger|full\n"); @@ -6488,7 +6489,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='s' && strncmp(azArg[0], "scanstats", n)==0 ){ if( nArg==2 ){ - p->scanstatsOn = booleanValue(azArg[1]); + p->scanstatsOn = (u8)booleanValue(azArg[1]); #ifndef SQLITE_ENABLE_STMT_SCANSTATUS raw_printf(stderr, "Warning: .scanstats not available in this build.\n"); #endif @@ -7139,7 +7140,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='s' && strncmp(azArg[0], "stats", n)==0 ){ if( nArg==2 ){ - p->statsOn = booleanValue(azArg[1]); + p->statsOn = (u8)booleanValue(azArg[1]); }else if( nArg==1 ){ display_stats(p->db, p, 0); }else{ From fa3d7855801803a701daff30ec466a0c4d8ad8e4 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 23 Jan 2018 00:17:27 +0000 Subject: [PATCH 171/190] Simplify one of the compiler warning fixes from the previous check-in. FossilOrigin-Name: 012d7d49c571207087bbe24af05d639627b96df526bfcb2098a3e975b74d865d --- ext/session/sqlite3session.c | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/session/sqlite3session.c b/ext/session/sqlite3session.c index 67915e04f1..bdecdd1031 100644 --- a/ext/session/sqlite3session.c +++ b/ext/session/sqlite3session.c @@ -1115,7 +1115,7 @@ static void sessionPreupdateOneChange( int iHash; int bNull = 0; int rc = SQLITE_OK; - SessionStat1Ctx stat1 = {0, 0}; + SessionStat1Ctx stat1 = {0}; if( pSession->rc ) return; diff --git a/manifest b/manifest index 31134887c3..6dc303c771 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. -D 2018-01-23T00:05:18.184 +C Simplify\sone\sof\sthe\scompiler\swarning\sfixes\sfrom\sthe\sprevious\scheck-in. +D 2018-01-23T00:17:27.230 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -400,7 +400,7 @@ F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 F ext/session/sessionstat1.test 41cd97c2e48619a41cdf8ae749e1b25f34719de638689221aa43971be693bf4e F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc -F ext/session/sqlite3session.c 63cfde70155b597480b2d01e65031f8e60d204103db7adf6156fe48e3e379392 +F ext/session/sqlite3session.c a5b7aed647abe7e366254b755597fce3f2719d82c98990cb0e1e07a3d203fe2b F ext/session/sqlite3session.h 01774161cbd328fe3d496323655b9cc142317ff1fb1ae15c1232075ea240e3a4 F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d -R 8f662370d27c0dbf362ba912c090e456 +P 76a11a80e94d1e9c9645e6e348948f3fd508266d4569c85d80a3879862d0a819 +R 47270bb77ce74e463612a801d427faba U mistachkin -Z fc242cf748005a9ff5528ff032a48505 +Z c93f87a6596350b67f49dd4ebf8496b6 diff --git a/manifest.uuid b/manifest.uuid index ae3e0fe06b..58bcb92a1a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76a11a80e94d1e9c9645e6e348948f3fd508266d4569c85d80a3879862d0a819 \ No newline at end of file +012d7d49c571207087bbe24af05d639627b96df526bfcb2098a3e975b74d865d \ No newline at end of file From f09ac0b336b7fa8b0205fcd8494992264f4283d6 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Jan 2018 03:44:06 +0000 Subject: [PATCH 172/190] Slightly faster function dispatch in the virtual machine by avoiding unnecessary reinitialization of variables that are already correctly initialized. FossilOrigin-Name: edd4e6876cc08ab907bb21f075380de946562d4c56a04923760848b4b11536ac --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/func.c | 1 + src/vdbe.c | 50 +++++++++++++++++++++++++++++--------------------- src/vdbeInt.h | 3 --- src/vdbeapi.c | 12 ++---------- 6 files changed, 43 insertions(+), 45 deletions(-) diff --git a/manifest b/manifest index 6dc303c771..71deaf9781 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplify\sone\sof\sthe\scompiler\swarning\sfixes\sfrom\sthe\sprevious\scheck-in. -D 2018-01-23T00:17:27.230 +C Slightly\sfaster\sfunction\sdispatch\sin\sthe\svirtual\smachine\sby\savoiding\nunnecessary\sreinitialization\sof\svariables\sthat\sare\salready\scorrectly\ninitialized. +D 2018-01-23T03:44:06.287 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -442,7 +442,7 @@ F src/delete.c 20c8788451dc737a967c87ea53ad43544d617f5b57d32ccce8bd52a0daf9e89b F src/expr.c 9e06de431c09f144438aa6895ea4d4290fa3c6875bfcc3ba331012ca78deadf0 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c d617daf66b5515e2b42c1405b2b4984c30ca50fb705ab164271a9bf66c69e331 -F src/func.c bd528d5ed68ce5cbf78a762e3b735fa75009f7197ff07fab07fd771f35ebaa1b +F src/func.c 24d4746d347442c99153b5f9ac3204f6932d8d591008a94d6967de6b62fc0102 F src/global.c ac3094f1dc59fbeb919aef7cc0cc827a8459d1fb1adb7972ef75bd9e0c10b75b F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 @@ -555,10 +555,10 @@ F src/update.c a90a32ffc0100265b0693dbbdbe490756447af181f5ea2c138cce515b08c8795 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/util.c ef4a5f904d942e660abade7fbf3e6bdb402dabe9e7c27f3361ecf40b945538b5 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 -F src/vdbe.c ccc1e17a30325068ae4f0292e8601997946886d23acc989c68f2a261a2795c70 +F src/vdbe.c 5aa6fb85281b6af058d2a87b65c1a8a8e0bd2fe554fb3391497ee3702b61e0be F src/vdbe.h 134beb7a12a6213c00eba58febaede33447cc4441bc568a0d9c144b33fc3720a -F src/vdbeInt.h c8cfbbc28e37e67a493c3f892fb0596add56a31a00e7537a06049af9ef2f51b0 -F src/vdbeapi.c 02f773681d06e46454b0606339068d4d4490873dc4a7334bc0c6030552bb2c8c +F src/vdbeInt.h 8d7d07f13cb3c4cbca91e22ba4a1920e542dda7c5d9299920432a0b3d5b009f5 +F src/vdbeapi.c fea41171884a4de119f8b10ab514c788674eeeb7f27218bb6d008e1310bfd07f F src/vdbeaux.c 2756ac68ac259c416554100598fc291870063288cd7e1af22847f57b3e130e56 F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191 F src/vdbemem.c 7548dd5af03d24d534a5dbc41e3bbdf1fab83e9c8856a8d2549ed2ccf33d0e80 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 76a11a80e94d1e9c9645e6e348948f3fd508266d4569c85d80a3879862d0a819 -R 47270bb77ce74e463612a801d427faba -U mistachkin -Z c93f87a6596350b67f49dd4ebf8496b6 +P 012d7d49c571207087bbe24af05d639627b96df526bfcb2098a3e975b74d865d +R 117511e55335ee1f52b85cfdea90c38c +U drh +Z e3904fade688ed958d5e16ed2185daad diff --git a/manifest.uuid b/manifest.uuid index 58bcb92a1a..993b1dc61a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -012d7d49c571207087bbe24af05d639627b96df526bfcb2098a3e975b74d865d \ No newline at end of file +edd4e6876cc08ab907bb21f075380de946562d4c56a04923760848b4b11536ac \ No newline at end of file diff --git a/src/func.c b/src/func.c index 1076b97161..8f409a0ad1 100644 --- a/src/func.c +++ b/src/func.c @@ -35,6 +35,7 @@ static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ ** iteration of the aggregate loop. */ static void sqlite3SkipAccumulatorLoad(sqlite3_context *context){ + if( context->isError==0 ) context->isError = -1; context->skipFlag = 1; } diff --git a/src/vdbe.c b/src/vdbe.c index d878ca8e31..8d0b35a6f4 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6204,12 +6204,17 @@ case OP_AggStep0: { assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) ); assert( pOp->p3p2 || pOp->p3>=pOp->p2+n ); - pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*)); + pCtx = sqlite3DbMallocRawNN(db, n*sizeof(sqlite3_value*) + + (sizeof(pCtx[0]) + sizeof(Mem) - sizeof(sqlite3_value*))); if( pCtx==0 ) goto no_mem; pCtx->pMem = 0; + pCtx->pOut = (Mem*)&(pCtx->argv[n]); + sqlite3VdbeMemInit(pCtx->pOut, db, MEM_Null); pCtx->pFunc = pOp->p4.pFunc; pCtx->iOp = (int)(pOp - aOp); pCtx->pVdbe = p; + pCtx->skipFlag = 0; + pCtx->isError = 0; pCtx->argc = n; pOp->p4type = P4_FUNCCTX; pOp->p4.pCtx = pCtx; @@ -6220,7 +6225,6 @@ case OP_AggStep: { int i; sqlite3_context *pCtx; Mem *pMem; - Mem t; assert( pOp->p4type==P4_FUNCCTX ); pCtx = pOp->p4.pCtx; @@ -6243,26 +6247,28 @@ case OP_AggStep: { #endif pMem->n++; - sqlite3VdbeMemInit(&t, db, MEM_Null); - pCtx->pOut = &t; - pCtx->fErrorOrAux = 0; - pCtx->skipFlag = 0; + assert( pCtx->pOut->flags==MEM_Null ); + assert( pCtx->isError==0 ); + assert( pCtx->skipFlag==0 ); (pCtx->pFunc->xSFunc)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */ - if( pCtx->fErrorOrAux ){ - if( pCtx->isError ){ - sqlite3VdbeError(p, "%s", sqlite3_value_text(&t)); + if( pCtx->isError ){ + if( pCtx->isError>0 ){ + sqlite3VdbeError(p, "%s", sqlite3_value_text(pCtx->pOut)); rc = pCtx->isError; } - sqlite3VdbeMemRelease(&t); + if( pCtx->skipFlag ){ + assert( pOp[-1].opcode==OP_CollSeq ); + i = pOp[-1].p1; + if( i ) sqlite3VdbeMemSetInt64(&aMem[i], 1); + pCtx->skipFlag = 0; + } + sqlite3VdbeMemRelease(pCtx->pOut); + pCtx->pOut->flags = MEM_Null; + pCtx->isError = 0; if( rc ) goto abort_due_to_error; - }else{ - assert( t.flags==MEM_Null ); - } - if( pCtx->skipFlag ){ - assert( pOp[-1].opcode==OP_CollSeq ); - i = pOp[-1].p1; - if( i ) sqlite3VdbeMemSetInt64(&aMem[i], 1); } + assert( pCtx->pOut->flags==MEM_Null ); + assert( pCtx->skipFlag==0 ); break; } @@ -6749,7 +6755,7 @@ case OP_VColumn: { } rc = pModule->xColumn(pCur->uc.pVCur, &sContext, pOp->p2); sqlite3VtabImportErrmsg(p, pVtab); - if( sContext.isError ){ + if( sContext.isError>0 ){ rc = sContext.isError; } sqlite3VdbeChangeEncoding(pDest, encoding); @@ -7014,6 +7020,7 @@ case OP_Function0: { pCtx->pFunc = pOp->p4.pFunc; pCtx->iOp = (int)(pOp - aOp); pCtx->pVdbe = p; + pCtx->isError = 0; pCtx->argc = n; pOp->p4type = P4_FUNCCTX; pOp->p4.pCtx = pCtx; @@ -7048,16 +7055,17 @@ case OP_Function: { } #endif MemSetTypeFlag(pOut, MEM_Null); - pCtx->fErrorOrAux = 0; + assert( pCtx->isError==0 ); (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */ /* If the function returned an error, throw an exception */ - if( pCtx->fErrorOrAux ){ - if( pCtx->isError ){ + if( pCtx->isError ){ + if( pCtx->isError>0 ){ sqlite3VdbeError(p, "%s", sqlite3_value_text(pOut)); rc = pCtx->isError; } sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1); + pCtx->isError = 0; if( rc ) goto abort_due_to_error; } diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 976abb3938..1e4f615ba2 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -224,8 +224,6 @@ struct sqlite3_value { ** If the MEM_Null flag is set, then the value is an SQL NULL value. ** For a pointer type created using sqlite3_bind_pointer() or ** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set. -** If both MEM_Null and MEM_Zero are set, that means that the value is -** an unchanging column value from VColumn. ** ** If the MEM_Str flag is set then Mem.z points at a string representation. ** Usually this is encoded in the same unicode encoding as the main @@ -319,7 +317,6 @@ struct sqlite3_context { int iOp; /* Instruction number of OP_Function */ int isError; /* Error code returned by the function. */ u8 skipFlag; /* Skip accumulator loading if true */ - u8 fErrorOrAux; /* isError!=0 or pVdbe->pAuxData modified */ u8 argc; /* Number of arguments */ sqlite3_value *argv[1]; /* Argument set */ }; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index bdd6d1cd07..dd4a352003 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -372,14 +372,12 @@ void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); pCtx->isError = SQLITE_ERROR; - pCtx->fErrorOrAux = 1; sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); } #ifndef SQLITE_OMIT_UTF16 void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); pCtx->isError = SQLITE_ERROR; - pCtx->fErrorOrAux = 1; sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT); } #endif @@ -485,8 +483,7 @@ int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ return SQLITE_OK; } void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ - pCtx->isError = errCode; - pCtx->fErrorOrAux = 1; + pCtx->isError = errCode ? errCode : -1; #ifdef SQLITE_DEBUG if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; #endif @@ -500,7 +497,6 @@ void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ void sqlite3_result_error_toobig(sqlite3_context *pCtx){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); pCtx->isError = SQLITE_TOOBIG; - pCtx->fErrorOrAux = 1; sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1, SQLITE_UTF8, SQLITE_STATIC); } @@ -510,7 +506,6 @@ void sqlite3_result_error_nomem(sqlite3_context *pCtx){ assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); sqlite3VdbeMemSetNull(pCtx->pOut); pCtx->isError = SQLITE_NOMEM_BKPT; - pCtx->fErrorOrAux = 1; sqlite3OomFault(pCtx->pOut->db); } @@ -917,10 +912,7 @@ void sqlite3_set_auxdata( pAuxData->iAuxArg = iArg; pAuxData->pNextAux = pVdbe->pAuxData; pVdbe->pAuxData = pAuxData; - if( pCtx->fErrorOrAux==0 ){ - pCtx->isError = 0; - pCtx->fErrorOrAux = 1; - } + if( pCtx->isError==0 ) pCtx->isError = -1; }else if( pAuxData->xDeleteAux ){ pAuxData->xDeleteAux(pAuxData->pAux); } From 7ea3469e539fd296eaf2e5d16d9d1b0796f47bcb Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Jan 2018 04:22:33 +0000 Subject: [PATCH 173/190] Slightly faster implementation of the length() SQL function. FossilOrigin-Name: 9a4199aedb039141a50a68943ef863d7df9637ada318793cce6c12b9d39bcdc5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 16 +++++++++------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 71deaf9781..79e0bb8fd9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Slightly\sfaster\sfunction\sdispatch\sin\sthe\svirtual\smachine\sby\savoiding\nunnecessary\sreinitialization\sof\svariables\sthat\sare\salready\scorrectly\ninitialized. -D 2018-01-23T03:44:06.287 +C Slightly\sfaster\simplementation\sof\sthe\slength()\sSQL\sfunction. +D 2018-01-23T04:22:33.527 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -442,7 +442,7 @@ F src/delete.c 20c8788451dc737a967c87ea53ad43544d617f5b57d32ccce8bd52a0daf9e89b F src/expr.c 9e06de431c09f144438aa6895ea4d4290fa3c6875bfcc3ba331012ca78deadf0 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c d617daf66b5515e2b42c1405b2b4984c30ca50fb705ab164271a9bf66c69e331 -F src/func.c 24d4746d347442c99153b5f9ac3204f6932d8d591008a94d6967de6b62fc0102 +F src/func.c 227d17a030b75f7495fc3b8d1aca19850e794397433175c1ba21b713d9833f14 F src/global.c ac3094f1dc59fbeb919aef7cc0cc827a8459d1fb1adb7972ef75bd9e0c10b75b F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 012d7d49c571207087bbe24af05d639627b96df526bfcb2098a3e975b74d865d -R 117511e55335ee1f52b85cfdea90c38c +P edd4e6876cc08ab907bb21f075380de946562d4c56a04923760848b4b11536ac +R aa1994289d6ea2ba21f905f276b2d5c2 U drh -Z e3904fade688ed958d5e16ed2185daad +Z fced45fd12f23e9379e90a75bf8cc2b6 diff --git a/manifest.uuid b/manifest.uuid index 993b1dc61a..70318058cb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -edd4e6876cc08ab907bb21f075380de946562d4c56a04923760848b4b11536ac \ No newline at end of file +9a4199aedb039141a50a68943ef863d7df9637ada318793cce6c12b9d39bcdc5 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 8f409a0ad1..36cfa44230 100644 --- a/src/func.c +++ b/src/func.c @@ -102,8 +102,6 @@ static void lengthFunc( int argc, sqlite3_value **argv ){ - int len; - assert( argc==1 ); UNUSED_PARAMETER(argc); switch( sqlite3_value_type(argv[0]) ){ @@ -115,13 +113,17 @@ static void lengthFunc( } case SQLITE_TEXT: { const unsigned char *z = sqlite3_value_text(argv[0]); + const unsigned char *z0; + unsigned char c; if( z==0 ) return; - len = 0; - while( *z ){ - len++; - SQLITE_SKIP_UTF8(z); + z0 = z; + while( (c = *z)!=0 ){ + z++; + if( c>=0xc0 ){ + while( (*z & 0xc0)==0x80 ){ z++; z0++; } + } } - sqlite3_result_int(context, len); + sqlite3_result_int(context, (int)(z-z0)); break; } default: { From 176b3a09b2b2ded371af0a9e078fde1fd03e5bda Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 23 Jan 2018 07:11:05 +0000 Subject: [PATCH 174/190] Skip defining WIN32_LEAN_AND_MEAN when it is already defined. FossilOrigin-Name: 195f5323df800f7963df2ea251c497c72e4d7ff0b88a70f1fa60f13bb1a9fd3b --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/tclsqlite.c | 4 +++- src/test_windirent.h | 3 +++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 79e0bb8fd9..1bb19cf6b3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Slightly\sfaster\simplementation\sof\sthe\slength()\sSQL\sfunction. -D 2018-01-23T04:22:33.527 +C Skip\sdefining\sWIN32_LEAN_AND_MEAN\swhen\sit\sis\salready\sdefined. +D 2018-01-23T07:11:05.143 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -495,7 +495,7 @@ F src/sqliteInt.h 9c70315598b34810a83e4894455acb18e95cf63ce4e6cbb451ac2d17eabc25 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c 9737ed017279a9e0c5da748701c3c7bf1e8ae0dae459aad20dd64fcff97a7e35 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 -F src/tclsqlite.c 1833388c01e3b77f4c712185ee7250b9423ee0981ce6ae7e401e47db0319a696 +F src/tclsqlite.c 11a2618c227fd13ccad73ee02d1199f9880c59db2b3144fd7432db1980a2577d F src/test1.c b52f9e7fe62016d357c3266fcfa0793cc1883d3cb2b11dfa39fcba2e70b0305c F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b @@ -545,7 +545,7 @@ F src/test_thread.c 911d15fb14e19c0c542bdc8aabf981c2f10a4858 F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698 F src/test_windirent.c a895e2c068a06644eef91a7f0a32182445a893b9a0f33d0cdb4283dca2486ac1 -F src/test_windirent.h 8782864172ba5ae52c5c313c70faeadb324ff74de9c3dcc6b56a557dccaa1de6 +F src/test_windirent.h 90dfbe95442c9762357fe128dc7ae3dc199d006de93eb33ba3972e0a90484215 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 5b0c661a85f783d35b9883830736eeb63be4aefc4f6b7d9cd081d48782c041e2 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P edd4e6876cc08ab907bb21f075380de946562d4c56a04923760848b4b11536ac -R aa1994289d6ea2ba21f905f276b2d5c2 -U drh -Z fced45fd12f23e9379e90a75bf8cc2b6 +P 9a4199aedb039141a50a68943ef863d7df9637ada318793cce6c12b9d39bcdc5 +R fc52a77923ed3abf898f25d3a24aab55 +U mistachkin +Z 3cd93d9679b9898485b5f29a3393d5bf diff --git a/manifest.uuid b/manifest.uuid index 70318058cb..3eb8b75e11 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a4199aedb039141a50a68943ef863d7df9637ada318793cce6c12b9d39bcdc5 \ No newline at end of file +195f5323df800f7963df2ea251c497c72e4d7ff0b88a70f1fa60f13bb1a9fd3b \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index eed86eee34..252b246e6e 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -64,7 +64,9 @@ # define GETPID getpid #elif !defined(_WIN32_WCE) # ifndef SQLITE_AMALGAMATION -# define WIN32_LEAN_AND_MEAN +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif # include # endif # define GETPID (int)GetCurrentProcessId diff --git a/src/test_windirent.h b/src/test_windirent.h index d71b49f684..ada5322530 100644 --- a/src/test_windirent.h +++ b/src/test_windirent.h @@ -20,7 +20,10 @@ ** We need several data types from the Windows SDK header. */ +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif + #include "windows.h" /* From 8d7f1630154e98eba7b0364a5cebe759abf90f6e Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Jan 2018 13:30:38 +0000 Subject: [PATCH 175/190] Fix comment typos. No changes to code. FossilOrigin-Name: 8e5e74c66b9cdb348392e3db2d9f32cfa20fcec35bf09d9e1f623e7ad875ec97 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 7 +++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 1bb19cf6b3..d4c218ede1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Skip\sdefining\sWIN32_LEAN_AND_MEAN\swhen\sit\sis\salready\sdefined. -D 2018-01-23T07:11:05.143 +C Fix\scomment\stypos.\s\sNo\schanges\sto\scode. +D 2018-01-23T13:30:38.622 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -428,7 +428,7 @@ F src/auth.c 6277d63837357549fe14e723490d6dc1a38768d71c795c5eb5c0f8a99f918f73 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca -F src/btree.c bfc453babec9aa8196ab5db5e588ac5d3f0c398d72faa37296167a84a61c9f2f +F src/btree.c 1beceb1c5f9563271241fd0c294484668e4ad28cf6aa970eab70e50ff6f75e25 F src/btree.h 0866c0a08255142ea0e754aabd211c843cab32045c978a592a43152405ed0c84 F src/btreeInt.h 55b702efce17e5d1941865464227d3802cfc9c7c832fac81d4c94dced47a71fc F src/build.c 9f9647454f236cab097f266ae970f899b53c71cadab6756c47e2b2e81392c2a1 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9a4199aedb039141a50a68943ef863d7df9637ada318793cce6c12b9d39bcdc5 -R fc52a77923ed3abf898f25d3a24aab55 -U mistachkin -Z 3cd93d9679b9898485b5f29a3393d5bf +P 195f5323df800f7963df2ea251c497c72e4d7ff0b88a70f1fa60f13bb1a9fd3b +R 7c865206c0c32ef523d258872610a2c7 +U drh +Z b85d901c66e70c5307b2badbaae893be diff --git a/manifest.uuid b/manifest.uuid index 3eb8b75e11..bd24eaa7d9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -195f5323df800f7963df2ea251c497c72e4d7ff0b88a70f1fa60f13bb1a9fd3b \ No newline at end of file +8e5e74c66b9cdb348392e3db2d9f32cfa20fcec35bf09d9e1f623e7ad875ec97 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 3b42f68f9f..168f3105fb 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6189,9 +6189,8 @@ static void freePage(MemPage *pPage, int *pRC){ } /* -** Free any overflow pages associated with the given Cell. Write the -** local Cell size (the number of bytes on the original page, omitting -** overflow) into *pnSize. +** Free any overflow pages associated with the given Cell. Store +** size information about the cell in pInfo. */ static int clearCell( MemPage *pPage, /* The page that contains the Cell */ @@ -7395,7 +7394,7 @@ static int balance_nonroot( } /* Load b.apCell[] with pointers to all cells in pOld. If pOld - ** constains overflow cells, include them in the b.apCell[] array + ** contains overflow cells, include them in the b.apCell[] array ** in the correct spot. ** ** Note that when there are multiple overflow cells, it is always the From b8fff29c68cdb68b472051c6f892216e388196d9 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 23 Jan 2018 14:01:51 +0000 Subject: [PATCH 176/190] In SQLITE_ENABLE_BATCH_ATOMIC_WRITE builds on F2FS file-systems, invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE if an SQLITE_FCNTL_COMMIT_ATOMIC_WRITE call fails. Also, do not use an atomic transaction to create the initial database. This is because if an error occurs while writing to the db file, any changes to the file-size do not seem to be rolled back automatically. The only time this matters is when the file was 0 bytes in size to start with. FossilOrigin-Name: b3122db1545aeb48b7c28d480534b4b0fe04e83d5336225714c3cad926e5960e --- manifest | 22 +++++----- manifest.uuid | 2 +- src/pager.c | 7 ++-- test/malloc3.test | 11 +++++ test/misc7.test | 24 ++++++----- test/pagerfault.test | 14 ++++--- test/walthread.test | 98 ++++++++++++++++++++++---------------------- 7 files changed, 99 insertions(+), 79 deletions(-) diff --git a/manifest b/manifest index d4c218ede1..a1f2ca4ed7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scomment\stypos.\s\sNo\schanges\sto\scode. -D 2018-01-23T13:30:38.622 +C In\sSQLITE_ENABLE_BATCH_ATOMIC_WRITE\sbuilds\son\s\sF2FS\sfile-systems,\sinvoke\nSQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE\sif\san\sSQLITE_FCNTL_COMMIT_ATOMIC_WRITE\scall\nfails.\sAlso,\sdo\snot\suse\san\satomic\stransaction\sto\screate\sthe\sinitial\sdatabase.\nThis\sis\sbecause\sif\san\serror\soccurs\swhile\swriting\sto\sthe\sdb\sfile,\sany\schanges\nto\sthe\sfile-size\sdo\snot\sseem\sto\sbe\srolled\sback\sautomatically.\sThe\sonly\stime\nthis\smatters\sis\swhen\sthe\sfile\swas\s0\sbytes\sin\ssize\sto\sstart\swith. +D 2018-01-23T14:01:51.708 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -473,7 +473,7 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c a82505be158d8ce42b38dcc9b426187d776904c12cdc68dc8925e1dfcc5cb6ce F src/os_win.c 501dde1ee770f4ffa458bfe1cf376a556de3ab00bb8320d659c5984403991d62 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c 9b9cb4e06c03d43d62480a7a685a012d645fcf3a39e7767ccb505fb41ee083ec +F src/pager.c cd194a8793ce061e184ddc369fadbc1020c6f431014d22093f6c5e55c9234033 F src/pager.h 581698f2177e8bd4008fe4760898ce20b6133d1df22139b9101b5155f900df7a F src/parse.y 4e750e1b261ff9f1d0b6b5d40a829c66d691899f48953fde839d8b52d41aa148 F src/pcache.c 7ae91a4557a43d77d449accbfdc68846e6516f8e2eda46e8bbe4536fb669b201 @@ -1038,7 +1038,7 @@ F test/lookaside.test b17c99ae3aef96a8c9fa6f6be33cc75b93d657cb791d3827302b6835b7 F test/main.test 6bbb3999fd461eb8fb335cbab97409a3d7f91bbb8da60635e8be3e4a04a77772 F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9 F test/malloc.test 21c213365f2cca95ab2d7dc078dc8525f96065f8 -F test/malloc3.test e3b32c724b5a124b57cb0ed177f675249ad0c66a +F test/malloc3.test 6e88bae6312854a4adb4ecc2a6a5ea8c59b4db778b724ba718e1c43fc8c3c136 F test/malloc4.test 957337613002b7058a85116493a262f679f3a261 F test/malloc5.test f6eb6eca07a4c75f2897bf43a404689b6295bb95ab2e07d4b52eda743f925a27 F test/malloc6.test 2f039d9821927eacae43e1831f815e157659a151 @@ -1076,7 +1076,7 @@ F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 0d8be3466adf123a7791a66ba2bc8e8d229e87f3 F test/misc5.test 60e1fc758a93cacd19eb2fafcd1d40d150a05047546c7a92389c98047d621901 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 -F test/misc7.test 859894e3192257ce2fc4063b5438b220e352286974b387e485050f0ad1f665d6 +F test/misc7.test 567e223b6497da2226a0340befaf2d663c91ad57a48aede21a35a984a2882d41 F test/misc8.test ba03aaa08f02d62fbb8d3b2f5595c1b33aa9bbc5 F test/misuse.test 9e7f78402005e833af71dcab32d048003869eca5abcaccc985d4f8dc1d86bcc7 F test/mjournal.test 9d86e697dcbc5da2c4e8caba9b176b5765fe65e80c88c278b8c09a917e436795 @@ -1121,7 +1121,7 @@ F test/pager1.test f596d3bd53ce96e1d87d44d223d2ae6c8867dd782c425e5eb28b5721fa6aa F test/pager2.test 67b8f40ae98112bcdba1f2b2d03ea83266418c71 F test/pager3.test 4e9a83d6ca0838d7c602c9eb93d1357562d9059c1e02ffb138a8271020838370 F test/pager4.test a122e9e6925d5b23b31e3dfef8c6a44bbf19590e -F test/pagerfault.test 263c5442c06caf0b9b9e3fe42acdeb11f254dcebe533f69f401aaef9111eaf20 +F test/pagerfault.test 63c5da625562c66345ab4528790327ca63db2f6f9cbae2aba8cb7c51de3d1628 F test/pagerfault2.test caf4c7facb914fd3b03a17b31ae2b180c8d6ca1f F test/pagerfault3.test 1003fcda009bf48a8e22a516e193b6ef0dd1bbd8 F test/pageropt.test 84e4cc5cbca285357f7906e99b21be4f2bf5abc0 @@ -1557,7 +1557,7 @@ F test/walro2.test 6c73e8e4b5ccc55f907f4603ba36458b45c085fb6dfb04f30e3c0babbc1c2 F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cfd51af68 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417 F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f -F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e +F test/walthread.test 14b20fcfa6ae152f5d8e12f5dc8a8a724b7ef189f5d8ef1e2ceab79f2af51747 F test/where.test f0c325563acde44f2c4ea6ba348e9e29f7121757 F test/where2.test 478d2170637b9211f593120648858593bf2445a1 F test/where3.test 54cdeb02157acc979de41530b804ae7b09552bf1 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 195f5323df800f7963df2ea251c497c72e4d7ff0b88a70f1fa60f13bb1a9fd3b -R 7c865206c0c32ef523d258872610a2c7 -U drh -Z b85d901c66e70c5307b2badbaae893be +P 8e5e74c66b9cdb348392e3db2d9f32cfa20fcec35bf09d9e1f623e7ad875ec97 +R aeb88c53e35ebccb3804c1a2544a24b3 +U dan +Z a8da060b421183a740953cd83b7ad3ac diff --git a/manifest.uuid b/manifest.uuid index bd24eaa7d9..d3c9f66b6a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e5e74c66b9cdb348392e3db2d9f32cfa20fcec35bf09d9e1f623e7ad875ec97 \ No newline at end of file +b3122db1545aeb48b7c28d480534b4b0fe04e83d5336225714c3cad926e5960e \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 295cbe04c5..e4680bfbfe 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1213,7 +1213,7 @@ static int jrnlBufferSize(Pager *pPager){ #endif #ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE - if( dc&SQLITE_IOCAP_BATCH_ATOMIC ){ + if( pPager->dbSize>0 && (dc&SQLITE_IOCAP_BATCH_ATOMIC) ){ return -1; } #endif @@ -6499,8 +6499,9 @@ int sqlite3PagerCommitPhaseOne( if( bBatch ){ if( rc==SQLITE_OK ){ rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0); - }else{ - sqlite3OsFileControl(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0); + } + if( rc!=SQLITE_OK ){ + sqlite3OsFileControlHint(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0); } } diff --git a/test/malloc3.test b/test/malloc3.test index f4a6c3bbe9..b497ab66e9 100644 --- a/test/malloc3.test +++ b/test/malloc3.test @@ -27,6 +27,17 @@ if {!$MEMDEBUG} { return } +# Do not run these tests if F2FS batch writes are supported. In this case, +# it is possible for a single DML statement in an implicit transaction +# to fail with SQLITE_NOMEM, but for the transaction to still end up +# committed to disk. Which confuses the tests in this module. +# +if {[atomic_batch_write test.db]} { + puts "Skipping malloc3 tests: atomic-batch support" + finish_test + return +} + # Do not run these tests with an in-memory journal. # diff --git a/test/misc7.test b/test/misc7.test index d0e84dfa47..8df95575c1 100644 --- a/test/misc7.test +++ b/test/misc7.test @@ -43,15 +43,17 @@ do_test misc7-4 { # Try to open a file with a directory where its journal file should be. # -do_test misc7-5 { - delete_file mydir - file mkdir mydir-journal - sqlite3 db2 ./mydir - catchsql { - CREATE TABLE abc(a, b, c); - } db2 -} {1 {unable to open database file}} -db2 close +if {[atomic_batch_write test.db]==0} { + do_test misc7-5 { + delete_file mydir + file mkdir mydir-journal + sqlite3 db2 ./mydir + catchsql { + CREATE TABLE abc(a, b, c); + } db2 + } {1 {unable to open database file}} + db2 close +} #-------------------------------------------------------------------- # The following tests, misc7-6.* test the libraries behaviour when @@ -522,7 +524,9 @@ do_test misc7-22.4 { catch { db close } forcedelete test.db -if {$::tcl_platform(platform)=="unix"} { +if {$::tcl_platform(platform)=="unix" + && [atomic_batch_write test.db]==0 +} { reset_db do_execsql_test 23.0 { CREATE TABLE t1(x, y); diff --git a/test/pagerfault.test b/test/pagerfault.test index 392c1a2b98..3006dad7cc 100644 --- a/test/pagerfault.test +++ b/test/pagerfault.test @@ -1203,12 +1203,14 @@ do_faultsim_test pagerfault-26 -prep { set contents [db eval {SELECT * FROM t1}] if {$contents != "1 2"} { error "Bad database contents ($contents)" } - set sz [file size test.db] - if {$testrc!=0 && $sz!=1024*3 && $sz!=4096*3} { - error "Expected file size to be 3072 or 12288 bytes - actual size $sz bytes" - } - if {$testrc==0 && $sz!=4096*3} { - error "Expected file size to be 12288 bytes - actual size $sz bytes" + if {[atomic_batch_write test.db]==0} { + set sz [file size test.db] + if {$testrc!=0 && $sz!=1024*3 && $sz!=4096*3} { + error "Expected file size 3072 or 12288 bytes - actual size $sz bytes" + } + if {$testrc==0 && $sz!=4096*3} { + error "Expected file size to be 12288 bytes - actual size $sz bytes" + } } } diff --git a/test/walthread.test b/test/walthread.test index 6249ce11af..8e5df9e589 100644 --- a/test/walthread.test +++ b/test/walthread.test @@ -327,59 +327,61 @@ do_thread_test2 walthread-1 -seconds $seconds(walthread-1) -init { # the number of write-transactions performed using a rollback journal. # For example, "192 w, 185 r". # -do_thread_test2 walthread-2 -seconds $seconds(walthread-2) -init { - execsql { CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE) } -} -thread RB 2 { +if {[atomic_batch_write test.db]==0} { + do_thread_test2 walthread-2 -seconds $seconds(walthread-2) -init { + execsql { CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE) } + } -thread RB 2 { - db close - set nRun 0 - set nDel 0 - while {[tt_continue]} { - sqlite3 db test.db - db busy busyhandler - db eval { SELECT * FROM sqlite_master } - catch { db eval { PRAGMA journal_mode = DELETE } } - db eval { - BEGIN; - INSERT INTO t1 VALUES(NULL, randomblob(100+$E(pid))); - } - incr nRun 1 - incr nDel [file exists test.db-journal] - if {[file exists test.db-journal] + [file exists test.db-wal] != 1} { - error "File-system looks bad..." - } - db eval COMMIT - - integrity_check db close - } - list $nRun $nDel - set {} "[expr $nRun-$nDel] w, $nDel r" - -} -thread WAL 2 { - db close - set nRun 0 - set nDel 0 - while {[tt_continue]} { - sqlite3 db test.db - db busy busyhandler - db eval { SELECT * FROM sqlite_master } - catch { db eval { PRAGMA journal_mode = WAL } } - db eval { - BEGIN; - INSERT INTO t1 VALUES(NULL, randomblob(110+$E(pid))); + set nRun 0 + set nDel 0 + while {[tt_continue]} { + sqlite3 db test.db + db busy busyhandler + db eval { SELECT * FROM sqlite_master } + catch { db eval { PRAGMA journal_mode = DELETE } } + db eval { + BEGIN; + INSERT INTO t1 VALUES(NULL, randomblob(100+$E(pid))); + } + incr nRun 1 + incr nDel [file exists test.db-journal] + if {[file exists test.db-journal] + [file exists test.db-wal] != 1} { + error "File-system looks bad..." + } + db eval COMMIT + + integrity_check + db close } - incr nRun 1 - incr nDel [file exists test.db-journal] - if {[file exists test.db-journal] + [file exists test.db-wal] != 1} { - error "File-system looks bad..." - } - db eval COMMIT - - integrity_check + list $nRun $nDel + set {} "[expr $nRun-$nDel] w, $nDel r" + + } -thread WAL 2 { db close + set nRun 0 + set nDel 0 + while {[tt_continue]} { + sqlite3 db test.db + db busy busyhandler + db eval { SELECT * FROM sqlite_master } + catch { db eval { PRAGMA journal_mode = WAL } } + db eval { + BEGIN; + INSERT INTO t1 VALUES(NULL, randomblob(110+$E(pid))); + } + incr nRun 1 + incr nDel [file exists test.db-journal] + if {[file exists test.db-journal] + [file exists test.db-wal] != 1} { + error "File-system looks bad..." + } + db eval COMMIT + + integrity_check + db close + } + set {} "[expr $nRun-$nDel] w, $nDel r" } - set {} "[expr $nRun-$nDel] w, $nDel r" } do_thread_test walthread-3 -seconds $seconds(walthread-3) -init { From 61d04974f06ad307a56442602c910783f7fa02a0 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Jan 2018 15:26:30 +0000 Subject: [PATCH 177/190] Fix the modification-time setting logic in the fileio.c extension on Windows so that it works with utf8 filenames. FossilOrigin-Name: f785b9041556912edbacdbfb3dfc38705058d7c10d874544295c25db54628bc2 --- ext/misc/fileio.c | 9 +++++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 60a960f310..e51b3e620b 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -270,15 +270,20 @@ static int writeFile( SYSTEMTIME currentTime; LONGLONG intervals; HANDLE hFile; + LPWSTR zUnicodeName; + extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*); + GetSystemTime(¤tTime); SystemTimeToFileTime(¤tTime, &lastAccess); intervals = Int32x32To64(mtime, 10000000) + 116444736000000000; lastWrite.dwLowDateTime = (DWORD)intervals; lastWrite.dwHighDateTime = intervals >> 32; - hFile = CreateFile( - zFile, FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, + zUnicodeName = sqlite3_win32_utf8_to_unicode(zFile); + hFile = CreateFileW( + zUnicodeName, FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL ); + sqlite3_free(zUnicodeName); if( hFile!=INVALID_HANDLE_VALUE ){ BOOL bResult = SetFileTime(hFile, NULL, &lastAccess, &lastWrite); CloseHandle(hFile); diff --git a/manifest b/manifest index a1f2ca4ed7..c77f83cc4b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sSQLITE_ENABLE_BATCH_ATOMIC_WRITE\sbuilds\son\s\sF2FS\sfile-systems,\sinvoke\nSQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE\sif\san\sSQLITE_FCNTL_COMMIT_ATOMIC_WRITE\scall\nfails.\sAlso,\sdo\snot\suse\san\satomic\stransaction\sto\screate\sthe\sinitial\sdatabase.\nThis\sis\sbecause\sif\san\serror\soccurs\swhile\swriting\sto\sthe\sdb\sfile,\sany\schanges\nto\sthe\sfile-size\sdo\snot\sseem\sto\sbe\srolled\sback\sautomatically.\sThe\sonly\stime\nthis\smatters\sis\swhen\sthe\sfile\swas\s0\sbytes\sin\ssize\sto\sstart\swith. -D 2018-01-23T14:01:51.708 +C Fix\sthe\smodification-time\ssetting\slogic\sin\sthe\sfileio.c\sextension\son\sWindows\nso\sthat\sit\sworks\swith\sutf8\sfilenames. +D 2018-01-23T15:26:30.163 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -277,7 +277,7 @@ F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f0 F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11 F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 -F ext/misc/fileio.c 06bd79dcc43d0887da27ffaadd69b8a698b1bafe203d1d134a3a2964f69368f9 +F ext/misc/fileio.c bd2f717be63a9ae9ff85977a756c43a96d47a7763d98ae913636c64b714c232b F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8e5e74c66b9cdb348392e3db2d9f32cfa20fcec35bf09d9e1f623e7ad875ec97 -R aeb88c53e35ebccb3804c1a2544a24b3 -U dan -Z a8da060b421183a740953cd83b7ad3ac +P b3122db1545aeb48b7c28d480534b4b0fe04e83d5336225714c3cad926e5960e +R e90c01c3df65c4d4d3208d8c47984c27 +U drh +Z 0631a5977bb4ccdfaf551e9a8368b5ad diff --git a/manifest.uuid b/manifest.uuid index d3c9f66b6a..35210204e2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b3122db1545aeb48b7c28d480534b4b0fe04e83d5336225714c3cad926e5960e \ No newline at end of file +f785b9041556912edbacdbfb3dfc38705058d7c10d874544295c25db54628bc2 \ No newline at end of file From a916b570137f728a04d4a3be0cb792dd5a22cf63 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 23 Jan 2018 16:38:57 +0000 Subject: [PATCH 178/190] Fix a bug causing spurious "sub-select returns N columns expected 1" errors in join queries with a term like "(a, b) IN (SELECT ...)" in the WHERE clause. FossilOrigin-Name: 14dfd96f9bca2df5033b2d894bf63cc8bf450a45ca11df5e3bbb814fdf96b656 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/wherecode.c | 6 ++++++ test/rowvalue.test | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c77f83cc4b..7ea1bf4a4f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\smodification-time\ssetting\slogic\sin\sthe\sfileio.c\sextension\son\sWindows\nso\sthat\sit\sworks\swith\sutf8\sfilenames. -D 2018-01-23T15:26:30.163 +C Fix\sa\sbug\scausing\sspurious\s"sub-select\sreturns\sN\scolumns\sexpected\s1"\serrors\nin\sjoin\squeries\swith\sa\sterm\slike\s"(a,\sb)\sIN\s(SELECT\s...)"\sin\sthe\sWHERE\sclause. +D 2018-01-23T16:38:57.346 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -571,7 +571,7 @@ F src/wal.h 8de5d2d3de0956d6f6cb48c83a4012d5f227b8fe940f3a349a4b7e85ebcb492a F src/walker.c da987a20d40145c0a03c07d8fefcb2ed363becc7680d0500d9c79915591f5b1f F src/where.c caf0b6c9d31f22f0b2c91aba723858de52b5d665aaa89034099015aaf9bb8219 F src/whereInt.h 82c04c5075308abbac59180c8bad5ecb45b07453981f60a53f3c7dee21e1e971 -F src/wherecode.c af1e79154aaa88cd802d6f2e5b945f67eaca7c958d1525fbf8ee19d5bd7b9020 +F src/wherecode.c cb360c511f69294ddf00340d7b390e6b1d601a1cfb77b42c4d316fe2f4cd01c3 F src/whereexpr.c 427ea8e96ec24f2a7814c67b8024ad664a9c7656264c4566c34743cb23186e46 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1163,7 +1163,7 @@ F test/rollbackfault.test 0e646aeab8840c399cfbfa43daab46fd609cf04a F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 F test/rowid.test 5b7509f384f4f6fae1af3c8c104c8ca299fea18d -F test/rowvalue.test 44f3492f415cc9f374e8388a5eb61503eaca5230 +F test/rowvalue.test e1bd1690d891abff6138f9612241615d2de7671cb28eb58ebdd591a5b01089a4 F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256 F test/rowvalue4.test 4b556d7de161a0dd8cff095c336e913986398bea @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b3122db1545aeb48b7c28d480534b4b0fe04e83d5336225714c3cad926e5960e -R e90c01c3df65c4d4d3208d8c47984c27 -U drh -Z 0631a5977bb4ccdfaf551e9a8368b5ad +P f785b9041556912edbacdbfb3dfc38705058d7c10d874544295c25db54628bc2 +R e2c75936c44819f701f68ae9ff6a70d2 +U dan +Z d0f66b0bfa51e27a550c6dffd5ce24ce diff --git a/manifest.uuid b/manifest.uuid index 35210204e2..d83d65e8de 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f785b9041556912edbacdbfb3dfc38705058d7c10d874544295c25db54628bc2 \ No newline at end of file +14dfd96f9bca2df5033b2d894bf63cc8bf450a45ca11df5e3bbb814fdf96b656 \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index 32dd2048bf..8e8672ff9f 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -2170,6 +2170,12 @@ Bitmask sqlite3WhereCodeOneLoopStart( WO_EQ|WO_IN|WO_IS, 0); if( pAlt==0 ) continue; if( pAlt->wtFlags & (TERM_CODED) ) continue; + if( (pAlt->eOperator & WO_IN) + && (pAlt->pExpr->flags & EP_xIsSelect) + && (pAlt->pExpr->x.pSelect->pEList->nExpr>1) + ){ + continue; + } testcase( pAlt->eOperator & WO_EQ ); testcase( pAlt->eOperator & WO_IS ); testcase( pAlt->eOperator & WO_IN ); diff --git a/test/rowvalue.test b/test/rowvalue.test index 5f2701c733..d900e0daa3 100644 --- a/test/rowvalue.test +++ b/test/rowvalue.test @@ -394,4 +394,49 @@ do_execsql_test 16.5 { 3 i ii iii iv } +do_execsql_test 17.0 { + CREATE TABLE b1(a, b); + CREATE TABLE b2(x); +} + +do_execsql_test 17.1 { + SELECT * FROM b2 CROSS JOIN b1 + WHERE b2.x=b1.a AND (b1.a, 2) + IN (VALUES(1, 2)); +} {} + +do_execsql_test 18.0 { + CREATE TABLE b3 ( a, b, PRIMARY KEY (a, b) ); + CREATE TABLE b4 ( a ); + CREATE TABLE b5 ( a, b ); + INSERT INTO b3 VALUES (1, 1), (1, 2); + INSERT INTO b4 VALUES (1); + INSERT INTO b5 VALUES (1, 1), (1, 2); +} + +do_execsql_test 18.1 { + SELECT * FROM b3 WHERE (SELECT b3.a, b3.b) IN ( SELECT a, b FROM b5 ) +} {1 1 1 2} +do_execsql_test 18.2 { + SELECT * FROM b3 WHERE (VALUES(b3.a, b3.b)) IN ( SELECT a, b FROM b5 ); +} {1 1 1 2} +do_execsql_test 18.3 { + SELECT * FROM b3 WHERE (b3.a, b3.b) IN ( SELECT a, b FROM b5 ); +} {1 1 1 2} +do_execsql_test 18.4 { + SELECT * FROM b3 JOIN b4 ON b4.a = b3.a + WHERE (SELECT b3.a, b3.b) IN ( SELECT a, b FROM b5 ); +} {1 1 1 1 2 1} +do_execsql_test 18.5 { + SELECT * FROM b3 JOIN b4 ON b4.a = b3.a + WHERE (VALUES(b3.a, b3.b)) IN ( SELECT a, b FROM b5 ); +} {1 1 1 1 2 1} +do_execsql_test 18.6 { + SELECT * FROM b3 JOIN b4 ON b4.a = b3.a + WHERE (b3.a, b3.b) IN ( SELECT a, b FROM b5 ); +} {1 1 1 1 2 1} + + +finish_test + finish_test From d15046ac080f4633186fe0e31712525a4326a4bc Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Jan 2018 17:33:42 +0000 Subject: [PATCH 179/190] Work around a problem with GCC on 32-bit machines that cause the CAST operator to generate a floating-point result for strings that could be represented as very large integers. FossilOrigin-Name: 1b02731962c21bb097a88801ece76ff441bf882519a821a246da84f4e2a33455 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbemem.c | 14 +++++++++++++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 7ea1bf4a4f..7691a2251e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\scausing\sspurious\s"sub-select\sreturns\sN\scolumns\sexpected\s1"\serrors\nin\sjoin\squeries\swith\sa\sterm\slike\s"(a,\sb)\sIN\s(SELECT\s...)"\sin\sthe\sWHERE\sclause. -D 2018-01-23T16:38:57.346 +C Work\saround\sa\sproblem\swith\sGCC\son\s32-bit\smachines\sthat\scause\sthe\sCAST\noperator\sto\sgenerate\sa\sfloating-point\sresult\sfor\sstrings\sthat\scould\sbe\nrepresented\sas\svery\slarge\sintegers. +D 2018-01-23T17:33:42.218 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -561,7 +561,7 @@ F src/vdbeInt.h 8d7d07f13cb3c4cbca91e22ba4a1920e542dda7c5d9299920432a0b3d5b009f5 F src/vdbeapi.c fea41171884a4de119f8b10ab514c788674eeeb7f27218bb6d008e1310bfd07f F src/vdbeaux.c 2756ac68ac259c416554100598fc291870063288cd7e1af22847f57b3e130e56 F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191 -F src/vdbemem.c 7548dd5af03d24d534a5dbc41e3bbdf1fab83e9c8856a8d2549ed2ccf33d0e80 +F src/vdbemem.c 943e41881e6317c9f93c77c1d60d3b37ddc8d26a3f852233ce7423d3e581523e F src/vdbesort.c 731a09e5cb9e96b70c394c1b7cf3860fbe84acca7682e178615eb941a3a0ef2f F src/vdbetrace.c 48e11ebe040c6b41d146abed2602e3d00d621d7ebe4eb29b0a0f1617fd3c2f6c F src/vtab.c 0e4885495172e1bdf54b12cce23b395ac74ef5729031f15e1bc1e3e6b360ed1a @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f785b9041556912edbacdbfb3dfc38705058d7c10d874544295c25db54628bc2 -R e2c75936c44819f701f68ae9ff6a70d2 -U dan -Z d0f66b0bfa51e27a550c6dffd5ce24ce +P 14dfd96f9bca2df5033b2d894bf63cc8bf450a45ca11df5e3bbb814fdf96b656 +R aad1a01a1cf0d877a8df52447d73431f +U drh +Z 57954c94bf10856d82150b78a27b3537 diff --git a/manifest.uuid b/manifest.uuid index d83d65e8de..8e916bf612 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -14dfd96f9bca2df5033b2d894bf63cc8bf450a45ca11df5e3bbb814fdf96b656 \ No newline at end of file +1b02731962c21bb097a88801ece76ff441bf882519a821a246da84f4e2a33455 \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index d8f1e64328..e2912b3a6f 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -582,6 +582,18 @@ int sqlite3VdbeMemRealify(Mem *pMem){ return SQLITE_OK; } +/* Compare a floating point value to an integer. Return true if the two +** values are the same within the precision of the floating point value. +** +** For some versions of GCC on 32-bit machines, if you do the more obvious +** comparison of "r1==(double)i" you sometimes get an answer of false even +** though the r1 and (double)i values are bit-for-bit the same. +*/ +static int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){ + double r2 = (double)i; + return memcmp(&r1, &r2, sizeof(r1))==0; +} + /* ** Convert pMem so that it has types MEM_Real or MEM_Int or both. ** Invalidate any prior representations. @@ -601,7 +613,7 @@ int sqlite3VdbeMemNumerify(Mem *pMem){ }else{ i64 i = pMem->u.i; sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc); - if( rc==1 && pMem->u.r==(double)i ){ + if( rc==1 && sqlite3RealSameAsInt(pMem->u.r, i) ){ pMem->u.i = i; MemSetTypeFlag(pMem, MEM_Int); }else{ From 21d59784227e227674f6a313090e5b84291dfcbe Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Jan 2018 19:24:54 +0000 Subject: [PATCH 180/190] Remove an unreachable branch from sqlite3SkipAccumulatorLoad(). FossilOrigin-Name: 8b9c8eab60b692e45c55a718d76b70e63040416040696907463692cbf83fb0c5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7691a2251e..3592d2f2a5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Work\saround\sa\sproblem\swith\sGCC\son\s32-bit\smachines\sthat\scause\sthe\sCAST\noperator\sto\sgenerate\sa\sfloating-point\sresult\sfor\sstrings\sthat\scould\sbe\nrepresented\sas\svery\slarge\sintegers. -D 2018-01-23T17:33:42.218 +C Remove\san\sunreachable\sbranch\sfrom\ssqlite3SkipAccumulatorLoad(). +D 2018-01-23T19:24:54.783 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -442,7 +442,7 @@ F src/delete.c 20c8788451dc737a967c87ea53ad43544d617f5b57d32ccce8bd52a0daf9e89b F src/expr.c 9e06de431c09f144438aa6895ea4d4290fa3c6875bfcc3ba331012ca78deadf0 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c d617daf66b5515e2b42c1405b2b4984c30ca50fb705ab164271a9bf66c69e331 -F src/func.c 227d17a030b75f7495fc3b8d1aca19850e794397433175c1ba21b713d9833f14 +F src/func.c 9970db37cc004136996a5c9b966b86f06583bcf3f275449b977fbb06d75e7300 F src/global.c ac3094f1dc59fbeb919aef7cc0cc827a8459d1fb1adb7972ef75bd9e0c10b75b F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 14dfd96f9bca2df5033b2d894bf63cc8bf450a45ca11df5e3bbb814fdf96b656 -R aad1a01a1cf0d877a8df52447d73431f +P 1b02731962c21bb097a88801ece76ff441bf882519a821a246da84f4e2a33455 +R 69d183e51c910b309adf151023208c58 U drh -Z 57954c94bf10856d82150b78a27b3537 +Z 10ad556e955465f2ef5a7781922bad82 diff --git a/manifest.uuid b/manifest.uuid index 8e916bf612..4cadc19d58 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1b02731962c21bb097a88801ece76ff441bf882519a821a246da84f4e2a33455 \ No newline at end of file +8b9c8eab60b692e45c55a718d76b70e63040416040696907463692cbf83fb0c5 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 36cfa44230..4e80535e81 100644 --- a/src/func.c +++ b/src/func.c @@ -35,7 +35,8 @@ static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ ** iteration of the aggregate loop. */ static void sqlite3SkipAccumulatorLoad(sqlite3_context *context){ - if( context->isError==0 ) context->isError = -1; + assert( context->isError<=0 ); + context->isError = -1; context->skipFlag = 1; } From 588049cc997bbd6ea5b62b4ac336916517348a01 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 23 Jan 2018 20:22:15 +0000 Subject: [PATCH 181/190] Increase the version number to 3.23.0 for the next development cycle. FossilOrigin-Name: b58b60b2c0729b73c0ef35bd1a5aa90965d1c01043413ca45b412d8b68f59bce --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index a7e7070f80..ee893b7e0e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.22.0 +3.23.0 diff --git a/configure b/configure index 8e735c6b12..3df19e8ec5 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sqlite 3.22.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.23.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -726,8 +726,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.22.0' -PACKAGE_STRING='sqlite 3.22.0' +PACKAGE_VERSION='3.23.0' +PACKAGE_STRING='sqlite 3.23.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1465,7 +1465,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.22.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.23.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1530,7 +1530,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.22.0:";; + short | recursive ) echo "Configuration of sqlite 3.23.0:";; esac cat <<\_ACEOF @@ -1655,7 +1655,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.22.0 +sqlite configure 3.23.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2074,7 +2074,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.22.0, which was +It was created by sqlite $as_me 3.23.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -12242,7 +12242,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.22.0, which was +This file was extended by sqlite $as_me 3.23.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12308,7 +12308,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.22.0 +sqlite config.status 3.23.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/manifest b/manifest index 3592d2f2a5..e85d602ab7 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Remove\san\sunreachable\sbranch\sfrom\ssqlite3SkipAccumulatorLoad(). -D 2018-01-23T19:24:54.783 +C Increase\sthe\sversion\snumber\sto\s3.23.0\sfor\sthe\snext\sdevelopment\scycle. +D 2018-01-23T20:22:15.707 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ede26e3fb675e0b3b07627640ce5917154a6ee7f8f2c97424eb5ab5f651cbd56 F README.md d748f58e3ab0fe0307fb4ae0942b415d93dcc4288756e366cc9e7cf8260c093f -F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf +F VERSION cdf91ac446255ecf3d8f6d8c3ee40d64123235ae5b3cef29d344e61b45ec3759 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 @@ -32,7 +32,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 9af547be0e0e1a8fca8553b82599b5a3be1528a3d78deb68cb49d3b611215cb7 x +F configure 2c71f331b463e987567a2dd942f728534f1aa7a174551e08a7b31b328e9da4ff x F configure.ac d4529ebb26ae046269334f1dac65f2b1d6927c2efe22b2ec24dce24dfe4f83dd F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 278113807f49d12d04179a93fab92b5b917a08771152ca7949d34e928efa3941 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1b02731962c21bb097a88801ece76ff441bf882519a821a246da84f4e2a33455 -R 69d183e51c910b309adf151023208c58 +P 8b9c8eab60b692e45c55a718d76b70e63040416040696907463692cbf83fb0c5 +R 9d516b9e9b7b18aa4204187b9b851494 U drh -Z 10ad556e955465f2ef5a7781922bad82 +Z 99c4b4459effdc8153fba53651e59b2d diff --git a/manifest.uuid b/manifest.uuid index 4cadc19d58..18af264478 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b9c8eab60b692e45c55a718d76b70e63040416040696907463692cbf83fb0c5 \ No newline at end of file +b58b60b2c0729b73c0ef35bd1a5aa90965d1c01043413ca45b412d8b68f59bce \ No newline at end of file From 5347f3c111edac51f199191b1be942327fed08b7 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Jan 2018 01:02:23 +0000 Subject: [PATCH 182/190] Invoke the sqlite3_complete() interface from the fuzzer. FossilOrigin-Name: 332bf84625d2034c9e1c029aa8243aa34088217e52e34e1f5472217743a31af3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/ossfuzz.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index e85d602ab7..a9e8ac9a9c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Increase\sthe\sversion\snumber\sto\s3.23.0\sfor\sthe\snext\sdevelopment\scycle. -D 2018-01-23T20:22:15.707 +C Invoke\sthe\ssqlite3_complete()\sinterface\sfrom\sthe\sfuzzer. +D 2018-01-24T01:02:23.624 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -1114,7 +1114,7 @@ F test/orderby7.test 3d1383d52ade5b9eb3a173b3147fdd296f0202da F test/orderby8.test 23ef1a5d72bd3adcc2f65561c654295d1b8047bd F test/orderby9.test 87fb9548debcc2cd141c5299002dd94672fa76a3 F test/oserror.test b32dc34f2363ef18532e3a0a7358e3e7e321974f -F test/ossfuzz.c 7f5cc87a0280a5854c1bfa7d5c4d07d34731f08ec34dc9c916aa35ed292b1468 +F test/ossfuzz.c b4bb024f9713a4c4e6442df1e6882ef53e29b4a3c27190a0562c16edab69052a F test/ossshell.c 296ab63067841bd1b1e97b46a0b2af48ee7f69d50d1a723008bee12dd7122622 F test/ovfl.test 199c482696defceacee8c8e0e0ef36da62726b2f F test/pager1.test f596d3bd53ce96e1d87d44d223d2ae6c8867dd782c425e5eb28b5721fa6aaa97 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8b9c8eab60b692e45c55a718d76b70e63040416040696907463692cbf83fb0c5 -R 9d516b9e9b7b18aa4204187b9b851494 +P b58b60b2c0729b73c0ef35bd1a5aa90965d1c01043413ca45b412d8b68f59bce +R 77d670e2fdf91ca12668cb80fdb4cad4 U drh -Z 99c4b4459effdc8153fba53651e59b2d +Z 7daabf9677fc11b22b33a4599e9eabe2 diff --git a/manifest.uuid b/manifest.uuid index 18af264478..3a0f01961b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b58b60b2c0729b73c0ef35bd1a5aa90965d1c01043413ca45b412d8b68f59bce \ No newline at end of file +332bf84625d2034c9e1c029aa8243aa34088217e52e34e1f5472217743a31af3 \ No newline at end of file diff --git a/test/ossfuzz.c b/test/ossfuzz.c index 7b28cf6a7e..50410e4597 100644 --- a/test/ossfuzz.c +++ b/test/ossfuzz.c @@ -160,6 +160,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run the SQL. The sqlite_exec() interface expects a zero-terminated ** string, so make a copy. */ zSql = sqlite3_mprintf("%.*s", (int)size, data); + sqlite3_complete(zSql); sqlite3_exec(cx.db, zSql, exec_handler, (void*)&execCnt, &zErrMsg); /* Show any errors */ From 56f177460314ceba1ae766ed486e079c71e0be72 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Jan 2018 01:58:49 +0000 Subject: [PATCH 183/190] Make the shell functional even if compiled with SQLITE_OMIT_COMPLETE. Omit the sqlite3_complete() call from the fuzzing interface if it is compiled with SQLITE_OMIT_COMPLETE. FossilOrigin-Name: c3e816cca4ddf0967c4c790cdde2345101dde3f2d854e62589f1ac1d7f3c60b8 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 10 ++++++++++ test/ossfuzz.c | 2 ++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a9e8ac9a9c..c8b0baec36 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Invoke\sthe\ssqlite3_complete()\sinterface\sfrom\sthe\sfuzzer. -D 2018-01-24T01:02:23.624 +C Make\sthe\sshell\sfunctional\seven\sif\scompiled\swith\sSQLITE_OMIT_COMPLETE.\nOmit\sthe\ssqlite3_complete()\scall\sfrom\sthe\sfuzzing\sinterface\sif\sit\sis\ncompiled\swith\sSQLITE_OMIT_COMPLETE. +D 2018-01-24T01:58:49.043 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -487,7 +487,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba -F src/shell.c.in 06ffe417973eacbee77a8402e26553b938e7c07f735c811701fc5cd1e642fb5c +F src/shell.c.in 7cea439c3f7f2e4ed6eb4b3a633cd93dccb1349241400de4da0c1291285ed514 F src/sqlite.h.in 959deaad89679e31d7f68fda668b0c5d1f592fffed7a9c1740fb8ded4e4e754a F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 99189e7611eb0bf98f21c7835dc74730a84e2e809c98e1e31c33896dee7a2849 @@ -1114,7 +1114,7 @@ F test/orderby7.test 3d1383d52ade5b9eb3a173b3147fdd296f0202da F test/orderby8.test 23ef1a5d72bd3adcc2f65561c654295d1b8047bd F test/orderby9.test 87fb9548debcc2cd141c5299002dd94672fa76a3 F test/oserror.test b32dc34f2363ef18532e3a0a7358e3e7e321974f -F test/ossfuzz.c b4bb024f9713a4c4e6442df1e6882ef53e29b4a3c27190a0562c16edab69052a +F test/ossfuzz.c 3613bc516386234cf2e513fb94dc677ab3862eb7ebc5b3671c319a80f86839fb F test/ossshell.c 296ab63067841bd1b1e97b46a0b2af48ee7f69d50d1a723008bee12dd7122622 F test/ovfl.test 199c482696defceacee8c8e0e0ef36da62726b2f F test/pager1.test f596d3bd53ce96e1d87d44d223d2ae6c8867dd782c425e5eb28b5721fa6aaa97 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b58b60b2c0729b73c0ef35bd1a5aa90965d1c01043413ca45b412d8b68f59bce -R 77d670e2fdf91ca12668cb80fdb4cad4 +P 332bf84625d2034c9e1c029aa8243aa34088217e52e34e1f5472217743a31af3 +R b1d50b050a44eb29893416acc04ad8bf U drh -Z 7daabf9677fc11b22b33a4599e9eabe2 +Z 6cd3cb0cbe81acd6296afde81215523a diff --git a/manifest.uuid b/manifest.uuid index 3a0f01961b..2e7a511d22 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -332bf84625d2034c9e1c029aa8243aa34088217e52e34e1f5472217743a31af3 \ No newline at end of file +c3e816cca4ddf0967c4c790cdde2345101dde3f2d854e62589f1ac1d7f3c60b8 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index e3a1f30752..a785517503 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -7680,6 +7680,16 @@ static int line_is_command_terminator(const char *zLine){ return 0; } +/* +** We need a default sqlite3_complete() implementation to use in case +** the shell is compiled with SQLITE_OMIT_COMPLETE. The default assumes +** any arbitrary text is a complete SQL statement. This is not very +** user-friendly, but it does seem to work. +*/ +#ifdef SQLITE_OMIT_COMPLETE +int sqlite3_complete(const char *zSql){ return 1; } +#endif + /* ** Return true if zSql is a complete SQL statement. Return false if it ** ends in the middle of a string literal or C-style comment. diff --git a/test/ossfuzz.c b/test/ossfuzz.c index 50410e4597..fa6e9142fe 100644 --- a/test/ossfuzz.c +++ b/test/ossfuzz.c @@ -160,7 +160,9 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run the SQL. The sqlite_exec() interface expects a zero-terminated ** string, so make a copy. */ zSql = sqlite3_mprintf("%.*s", (int)size, data); +#ifndef SQLITE_OMIT_COMPLETE sqlite3_complete(zSql); +#endif sqlite3_exec(cx.db, zSql, exec_handler, (void*)&execCnt, &zErrMsg); /* Show any errors */ From 0aac5613d924af3cf62d4ce159ab1d1f8ba932d4 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 24 Jan 2018 06:30:10 +0000 Subject: [PATCH 184/190] Update a couple of test scripts so that they work on F2FS file-systems that support atomic transactions. FossilOrigin-Name: 49e58e645e0c114c71935a3b7fa4771e8a23e28127efd2efe0f2f18813c8f391 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/ioerr.test | 4 ++-- test/malloc.test | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index c8b0baec36..062910f484 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\sshell\sfunctional\seven\sif\scompiled\swith\sSQLITE_OMIT_COMPLETE.\nOmit\sthe\ssqlite3_complete()\scall\sfrom\sthe\sfuzzing\sinterface\sif\sit\sis\ncompiled\swith\sSQLITE_OMIT_COMPLETE. -D 2018-01-24T01:58:49.043 +C Update\sa\scouple\sof\stest\sscripts\sso\sthat\sthey\swork\son\sF2FS\sfile-systems\sthat\nsupport\satomic\stransactions. +D 2018-01-24T06:30:10.922 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -993,7 +993,7 @@ F test/interrupt.test 16ea879ec728cb76414c148c5f24afd5d1f91054 F test/interrupt2.test e4408ca770a6feafbadb0801e54a0dcd1a8d108d F test/intpkey.test ac71107a49a06492b69b82aafaf225400598d3c8 F test/io.test f95bca1783b01ea7761671560d023360d2dfa4cc -F test/ioerr.test 2a24bd6ed5a8b062e64bfe1f6cf94fb25e92210d +F test/ioerr.test 470fcc78e9cd352d162baf782fe301ea807d764241f58a48fc58109c2dfcdb6b F test/ioerr2.test 2593563599e2cc6b6b4fcf5878b177bdd5d8df26 F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd F test/ioerr4.test f130fe9e71008577b342b8874d52984bd04ede2c @@ -1037,7 +1037,7 @@ F test/lock_common.tcl 7ffb45accf6ee91c736df9bafe0806a44358f035 F test/lookaside.test b17c99ae3aef96a8c9fa6f6be33cc75b93d657cb791d3827302b6835b71941f7 F test/main.test 6bbb3999fd461eb8fb335cbab97409a3d7f91bbb8da60635e8be3e4a04a77772 F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9 -F test/malloc.test 21c213365f2cca95ab2d7dc078dc8525f96065f8 +F test/malloc.test 18dd1c4188c81ca79cf123527c71b19ee0c31feb9947fdffb0dc6ceb1436816a F test/malloc3.test 6e88bae6312854a4adb4ecc2a6a5ea8c59b4db778b724ba718e1c43fc8c3c136 F test/malloc4.test 957337613002b7058a85116493a262f679f3a261 F test/malloc5.test f6eb6eca07a4c75f2897bf43a404689b6295bb95ab2e07d4b52eda743f925a27 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 332bf84625d2034c9e1c029aa8243aa34088217e52e34e1f5472217743a31af3 -R b1d50b050a44eb29893416acc04ad8bf -U drh -Z 6cd3cb0cbe81acd6296afde81215523a +P c3e816cca4ddf0967c4c790cdde2345101dde3f2d854e62589f1ac1d7f3c60b8 +R 43ada520e2e68e9100c12d4e5015a43b +U dan +Z 212cc80a5ee1b25bc75e6299ee001b27 diff --git a/manifest.uuid b/manifest.uuid index 2e7a511d22..071e9f08e1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c3e816cca4ddf0967c4c790cdde2345101dde3f2d854e62589f1ac1d7f3c60b8 \ No newline at end of file +49e58e645e0c114c71935a3b7fa4771e8a23e28127efd2efe0f2f18813c8f391 \ No newline at end of file diff --git a/test/ioerr.test b/test/ioerr.test index e59647fe50..f42beef5b4 100644 --- a/test/ioerr.test +++ b/test/ioerr.test @@ -172,7 +172,7 @@ ifcapable crashtest&&attach { # These tests can't be run on windows because the windows version of # SQLite holds a mandatory exclusive lock on journal files it has open. # -if {$tcl_platform(platform)!="windows"} { +if {$tcl_platform(platform)!="windows" && ![atomic_batch_write test.db]} { do_ioerr_test ioerr-7 -tclprep { db close sqlite3 db2 test2.db @@ -211,7 +211,7 @@ do_ioerr_test ioerr-8 -ckrefcount true -tclprep { # For test coverage: Cause an IO error whilst reading the master-journal # name from a journal file. -if {$tcl_platform(platform)=="unix"} { +if {$tcl_platform(platform)=="unix" && [atomic_batch_write test.db]==0} { do_ioerr_test ioerr-9 -ckrefcount true -tclprep { execsql { CREATE TABLE t1(a,b,c); diff --git a/test/malloc.test b/test/malloc.test index dbf4699b27..5e82e8028b 100644 --- a/test/malloc.test +++ b/test/malloc.test @@ -329,7 +329,7 @@ ifcapable crashtest&&attach { } } -if {$tcl_platform(platform)!="windows"} { +if {$tcl_platform(platform)!="windows" && [atomic_batch_write test.db]==0} { do_malloc_test 14 -tclprep { catch {db close} sqlite3 db2 test2.db From 9ccc0fd1f90f8872bddcf31adbf915818867d339 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Jan 2018 11:25:59 +0000 Subject: [PATCH 185/190] Fix the sqlite3ext.h header file so that it correctly accesses the new sqlite3_value_nochange() and sqlite3_vtab_collation() interfaces. FossilOrigin-Name: 6185d190e250faae0d979a24cb1039c7fce178478ae75df8e4af1d94cd38c18e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite3ext.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 062910f484..f9ef0358f5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sa\scouple\sof\stest\sscripts\sso\sthat\sthey\swork\son\sF2FS\sfile-systems\sthat\nsupport\satomic\stransactions. -D 2018-01-24T06:30:10.922 +C Fix\sthe\ssqlite3ext.h\sheader\sfile\sso\sthat\sit\scorrectly\saccesses\sthe\nnew\ssqlite3_value_nochange()\sand\ssqlite3_vtab_collation()\sinterfaces. +D 2018-01-24T11:25:59.042 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -490,7 +490,7 @@ F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba F src/shell.c.in 7cea439c3f7f2e4ed6eb4b3a633cd93dccb1349241400de4da0c1291285ed514 F src/sqlite.h.in 959deaad89679e31d7f68fda668b0c5d1f592fffed7a9c1740fb8ded4e4e754a F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 -F src/sqlite3ext.h 99189e7611eb0bf98f21c7835dc74730a84e2e809c98e1e31c33896dee7a2849 +F src/sqlite3ext.h 83a3c4ce93d650bedfd1aa558cb85a516bd6d094445ee989740827d0d944368d F src/sqliteInt.h 9c70315598b34810a83e4894455acb18e95cf63ce4e6cbb451ac2d17eabc2544 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c 9737ed017279a9e0c5da748701c3c7bf1e8ae0dae459aad20dd64fcff97a7e35 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c3e816cca4ddf0967c4c790cdde2345101dde3f2d854e62589f1ac1d7f3c60b8 -R 43ada520e2e68e9100c12d4e5015a43b -U dan -Z 212cc80a5ee1b25bc75e6299ee001b27 +P 49e58e645e0c114c71935a3b7fa4771e8a23e28127efd2efe0f2f18813c8f391 +R f4b5f9525aa88d51005feed4871dc3a5 +U drh +Z 5d5ae0811eec10d9ce697f3704c67092 diff --git a/manifest.uuid b/manifest.uuid index 071e9f08e1..3af162c09e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -49e58e645e0c114c71935a3b7fa4771e8a23e28127efd2efe0f2f18813c8f391 \ No newline at end of file +6185d190e250faae0d979a24cb1039c7fce178478ae75df8e4af1d94cd38c18e \ No newline at end of file diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index ac92a74901..1409370a6f 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -563,8 +563,8 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_value_pointer sqlite3_api->value_pointer /* Version 3.22.0 and later */ #define sqlite3_vtab_nochange sqlite3_api->vtab_nochange -#define sqlite3_value_nochange sqltie3_api->value_nochange -#define sqlite3_vtab_collation sqltie3_api->vtab_collation +#define sqlite3_value_nochange sqlite3_api->value_nochange +#define sqlite3_vtab_collation sqlite3_api->vtab_collation #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) From 93117f0c4ba23d977f143a83cd1a34656b457d47 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Jan 2018 11:29:42 +0000 Subject: [PATCH 186/190] Fix a formatting issue in sqlite3_prepare_v3() documentation. No changes to code. FossilOrigin-Name: 9e6066de84285252fb8999a8d8e02a46c5bb6c822e4f7421ad3911687357ee5d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f9ef0358f5..7a565b0918 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\ssqlite3ext.h\sheader\sfile\sso\sthat\sit\scorrectly\saccesses\sthe\nnew\ssqlite3_value_nochange()\sand\ssqlite3_vtab_collation()\sinterfaces. -D 2018-01-24T11:25:59.042 +C Fix\sa\sformatting\sissue\sin\ssqlite3_prepare_v3()\sdocumentation.\s\sNo\schanges\nto\scode. +D 2018-01-24T11:29:42.778 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -488,7 +488,7 @@ F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c bebe7cce45d899d2237c76bce059d525abf5b861f2fce92f6b53914a961c01ba F src/shell.c.in 7cea439c3f7f2e4ed6eb4b3a633cd93dccb1349241400de4da0c1291285ed514 -F src/sqlite.h.in 959deaad89679e31d7f68fda668b0c5d1f592fffed7a9c1740fb8ded4e4e754a +F src/sqlite.h.in 51f9acf52c80113d793ddd38b3940ad6895d97b4752503b19291fb8fcbf54c5e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 83a3c4ce93d650bedfd1aa558cb85a516bd6d094445ee989740827d0d944368d F src/sqliteInt.h 9c70315598b34810a83e4894455acb18e95cf63ce4e6cbb451ac2d17eabc2544 @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 49e58e645e0c114c71935a3b7fa4771e8a23e28127efd2efe0f2f18813c8f391 -R f4b5f9525aa88d51005feed4871dc3a5 +P 6185d190e250faae0d979a24cb1039c7fce178478ae75df8e4af1d94cd38c18e +R 6dab6bedb07a7e4f2ba5c731abd1af01 U drh -Z 5d5ae0811eec10d9ce697f3704c67092 +Z b088841a3f96415d8879d1e430cf291c diff --git a/manifest.uuid b/manifest.uuid index 3af162c09e..1c96166857 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6185d190e250faae0d979a24cb1039c7fce178478ae75df8e4af1d94cd38c18e \ No newline at end of file +9e6066de84285252fb8999a8d8e02a46c5bb6c822e4f7421ad3911687357ee5d \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index ed1c24de4c..1a0164150b 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3659,13 +3659,13 @@ int sqlite3_limit(sqlite3*, int id, int newVal); ** or [GLOB] operator or if the parameter is compared to an indexed column ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. ** +** ** **

^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having ** the extra prepFlags parameter, which is a bit array consisting of zero or ** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The ** sqlite3_prepare_v2() interface works exactly the same as ** sqlite3_prepare_v3() with a zero prepFlags parameter. -** */ int sqlite3_prepare( sqlite3 *db, /* Database handle */ From b9f4799b5523e479078db4e23ab73b07a9905ebc Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Jan 2018 12:14:43 +0000 Subject: [PATCH 187/190] Prevent a harmless unused variable warning when compiling with SQLITE_OMIT_TRACE. FossilOrigin-Name: 61a44961b5811c993ae8d4f820a21a0ee739fe5e88cbfe5e4190e0091912ca19 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7a565b0918..70f6b23f88 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sformatting\sissue\sin\ssqlite3_prepare_v3()\sdocumentation.\s\sNo\schanges\nto\scode. -D 2018-01-24T11:29:42.778 +C Prevent\sa\sharmless\sunused\svariable\swarning\swhen\scompiling\swith\nSQLITE_OMIT_TRACE. +D 2018-01-24T12:14:43.331 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -555,7 +555,7 @@ F src/update.c a90a32ffc0100265b0693dbbdbe490756447af181f5ea2c138cce515b08c8795 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5 F src/util.c ef4a5f904d942e660abade7fbf3e6bdb402dabe9e7c27f3361ecf40b945538b5 F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739 -F src/vdbe.c 5aa6fb85281b6af058d2a87b65c1a8a8e0bd2fe554fb3391497ee3702b61e0be +F src/vdbe.c d4684bd5efad095d9e4405e5ca2e1168dc7aff643cae04c424e4bade70641d70 F src/vdbe.h 134beb7a12a6213c00eba58febaede33447cc4441bc568a0d9c144b33fc3720a F src/vdbeInt.h 8d7d07f13cb3c4cbca91e22ba4a1920e542dda7c5d9299920432a0b3d5b009f5 F src/vdbeapi.c fea41171884a4de119f8b10ab514c788674eeeb7f27218bb6d008e1310bfd07f @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6185d190e250faae0d979a24cb1039c7fce178478ae75df8e4af1d94cd38c18e -R 6dab6bedb07a7e4f2ba5c731abd1af01 +P 9e6066de84285252fb8999a8d8e02a46c5bb6c822e4f7421ad3911687357ee5d +R 7e73e9644a1ec009a08fcc00aee933cc U drh -Z b088841a3f96415d8879d1e430cf291c +Z e8177042bd88031a5c0c9d9fb215dabd diff --git a/manifest.uuid b/manifest.uuid index 1c96166857..38eb19867d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e6066de84285252fb8999a8d8e02a46c5bb6c822e4f7421ad3911687357ee5d \ No newline at end of file +61a44961b5811c993ae8d4f820a21a0ee739fe5e88cbfe5e4190e0091912ca19 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 8d0b35a6f4..81a2361a55 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -7107,8 +7107,10 @@ case OP_Function: { */ case OP_Trace: case OP_Init: { /* jump */ - char *zTrace; int i; +#ifndef SQLITE_OMIT_TRACE + char *zTrace; +#endif /* If the P4 argument is not NULL, then it must be an SQL comment string. ** The "--" string is broken up to prevent false-positives with srcck1.c. From a87f8ce262cdb1901e4dc8a871dd967f94e33022 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Jan 2018 13:15:56 +0000 Subject: [PATCH 188/190] Improved error message output when the btreeinfo.c extension is run in a connection that lacks sqlite_dbpage support. FossilOrigin-Name: 461b0b81b2acedb1b9ca520657518d6778417c375aeb58c41ead840b75a6d985 --- ext/misc/btreeinfo.c | 3 ++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ext/misc/btreeinfo.c b/ext/misc/btreeinfo.c index d75f06277f..131b210a79 100644 --- a/ext/misc/btreeinfo.c +++ b/ext/misc/btreeinfo.c @@ -339,7 +339,8 @@ static int binfoColumn( sqlite3 *db = sqlite3_context_db_handle(ctx); int rc = binfoCompute(db, pgno, pCsr); if( rc ){ - return rc; + pCursor->pVtab->zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(db)); + return SQLITE_ERROR; } } switch( i ){ diff --git a/manifest b/manifest index 70f6b23f88..f93da218d6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\sa\sharmless\sunused\svariable\swarning\swhen\scompiling\swith\nSQLITE_OMIT_TRACE. -D 2018-01-24T12:14:43.331 +C Improved\serror\smessage\soutput\swhen\sthe\sbtreeinfo.c\sextension\sis\srun\sin\na\sconnection\sthat\slacks\ssqlite_dbpage\ssupport. +D 2018-01-24T13:15:56.698 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -269,7 +269,7 @@ F ext/misc/README.md d6dd0fe1d8af77040216798a6a2b0c46c73054d2f0ea544fbbcdccf6f23 F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb F ext/misc/appendvfs.c 3777f22ec1057dc4e5fd89f2fbddcc7a29fbeef1ad038c736c54411bb1967af7 -F ext/misc/btreeinfo.c d7fd9a2fe2fa33ba28488e2fce703ebecc759219ea9e0bb3b254784866c0a676 +F ext/misc/btreeinfo.c 78c8c57d325185ccc04b7679e5b020e34a4d9c87453e6b7ac943d0a26cee3256 F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005 F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/completion.c 52c3f01523e3e387eb321b4739a89d1fe47cbe6025aa1f2d8d3685e9e365df0f @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9e6066de84285252fb8999a8d8e02a46c5bb6c822e4f7421ad3911687357ee5d -R 7e73e9644a1ec009a08fcc00aee933cc +P 61a44961b5811c993ae8d4f820a21a0ee739fe5e88cbfe5e4190e0091912ca19 +R 9aa3fb89b7c642ba6cb5e4ab21b67bf7 U drh -Z e8177042bd88031a5c0c9d9fb215dabd +Z 08e16fd59762f7c574401c408bcad9ff diff --git a/manifest.uuid b/manifest.uuid index 38eb19867d..a06a90d5fc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -61a44961b5811c993ae8d4f820a21a0ee739fe5e88cbfe5e4190e0091912ca19 \ No newline at end of file +461b0b81b2acedb1b9ca520657518d6778417c375aeb58c41ead840b75a6d985 \ No newline at end of file From 4d6d872c4937bdbb62d4758e8a80e46bfbf02ef9 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Jan 2018 14:39:18 +0000 Subject: [PATCH 189/190] Adjust the fts3rank.test module so that it works on big-endian systems (hopefully - I don't have a big-endian machine to test the change on.) FossilOrigin-Name: e4766cabdf64d8e998048ae43154466fc9c3fad0b86102a42b65122abfcbbe55 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/fts3rank.test | 15 ++++++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index f93da218d6..0d0cc09116 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\serror\smessage\soutput\swhen\sthe\sbtreeinfo.c\sextension\sis\srun\sin\na\sconnection\sthat\slacks\ssqlite_dbpage\ssupport. -D 2018-01-24T13:15:56.698 +C Adjust\sthe\sfts3rank.test\smodule\sso\sthat\sit\sworks\son\sbig-endian\ssystems\n(hopefully\s-\sI\sdon't\shave\sa\sbig-endian\smachine\sto\stest\sthe\schange\son.) +D 2018-01-24T14:39:18.624 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -894,7 +894,7 @@ F test/fts3offsets.test b85fd382abdc78ebce721d8117bd552dfb75094c F test/fts3prefix.test fa794eaab0bdae466494947b0b153d7844478ab2 F test/fts3prefix2.test e1f0a822ca661dced7f12ce392e14eaf65609dce F test/fts3query.test f33eb71a1fe1084ea585eeb7ee76b390729f5170 -F test/fts3rank.test e4d2e16a28c98cae95001a75e2b4b05b19b051ffd6aaab15491c5e0595127b9b +F test/fts3rank.test cd99bc83a3c923c8d52afd90d86979cf05fc41849f892faeac3988055ef37b99 F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0 F test/fts3shared.test 57e26a801f21027b7530da77db54286a6fe4997e F test/fts3snippet.test 01a4231816e03a0660ae53ba2404fe69012fe0db @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 61a44961b5811c993ae8d4f820a21a0ee739fe5e88cbfe5e4190e0091912ca19 -R 9aa3fb89b7c642ba6cb5e4ab21b67bf7 +P 461b0b81b2acedb1b9ca520657518d6778417c375aeb58c41ead840b75a6d985 +R d7da84a0a0cbf9001c093c5227ed5c74 U drh -Z 08e16fd59762f7c574401c408bcad9ff +Z d9c76d204a4febeaadf3db9edf524e66 diff --git a/manifest.uuid b/manifest.uuid index a06a90d5fc..a774a7d7aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -461b0b81b2acedb1b9ca520657518d6778417c375aeb58c41ead840b75a6d985 \ No newline at end of file +e4766cabdf64d8e998048ae43154466fc9c3fad0b86102a42b65122abfcbbe55 \ No newline at end of file diff --git a/test/fts3rank.test b/test/fts3rank.test index 7ee3143a76..fd1a1c89d7 100644 --- a/test/fts3rank.test +++ b/test/fts3rank.test @@ -14,7 +14,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl -set testprefix fts3expr5 +set testprefix fts3rank # If SQLITE_ENABLE_FTS3 is defined, omit this file. ifcapable !fts3 { @@ -56,9 +56,14 @@ do_catchsql_test 1.4 { SELECT * FROM t1 ORDER BY rank(x'0000000000000000') DESC, rowid } {0 {{one two} one {one two} three {one two} two}} -do_catchsql_test 1.5 { - SELECT * FROM t1 ORDER BY rank(x'0100000001000000') DESC, rowid -} {1 {invalid matchinfo blob passed to function rank()}} +if {$tcl_platform(byteOrder)=="littleEndian"} { + do_catchsql_test 1.5le { + SELECT * FROM t1 ORDER BY rank(x'0100000001000000') DESC, rowid + } {1 {invalid matchinfo blob passed to function rank()}} +} else { + do_catchsql_test 1.5be { + SELECT * FROM t1 ORDER BY rank(x'0000000100000001') DESC, rowid + } {1 {invalid matchinfo blob passed to function rank()}} +} finish_test - From a8519d79b953b4249de75781d11f0cf4aafb57a1 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 24 Jan 2018 14:40:01 +0000 Subject: [PATCH 190/190] Interchange the numeric codes for CURSOR_VALID and CURSOR_INVALID to obtain a small size decrease and performance increase. FossilOrigin-Name: e0f192ea6dda4fa0b243d58c8ce41932519141bcae0689a90318b4f866f54edd --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btreeInt.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 0d0cc09116..ffdd6c23cb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sthe\sfts3rank.test\smodule\sso\sthat\sit\sworks\son\sbig-endian\ssystems\n(hopefully\s-\sI\sdon't\shave\sa\sbig-endian\smachine\sto\stest\sthe\schange\son.) -D 2018-01-24T14:39:18.624 +C Interchange\sthe\snumeric\scodes\sfor\sCURSOR_VALID\sand\sCURSOR_INVALID\sto\sobtain\na\ssmall\ssize\sdecrease\sand\sperformance\sincrease. +D 2018-01-24T14:40:01.721 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -430,7 +430,7 @@ F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca F src/btree.c 1beceb1c5f9563271241fd0c294484668e4ad28cf6aa970eab70e50ff6f75e25 F src/btree.h 0866c0a08255142ea0e754aabd211c843cab32045c978a592a43152405ed0c84 -F src/btreeInt.h 55b702efce17e5d1941865464227d3802cfc9c7c832fac81d4c94dced47a71fc +F src/btreeInt.h 6e70d15435b60a29386ae9864875618ca225c31bf815038bbd8f510a66bb9cb1 F src/build.c 9f9647454f236cab097f266ae970f899b53c71cadab6756c47e2b2e81392c2a1 F src/callback.c fe677cb5f5abb02f7a772a62a98c2f516426081df68856e8f2d5f950929b966a F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e @@ -1700,7 +1700,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 461b0b81b2acedb1b9ca520657518d6778417c375aeb58c41ead840b75a6d985 -R d7da84a0a0cbf9001c093c5227ed5c74 +P e4766cabdf64d8e998048ae43154466fc9c3fad0b86102a42b65122abfcbbe55 +R db620f4cdcf6bbd9d15c47f8bc8f1349 U drh -Z d9c76d204a4febeaadf3db9edf524e66 +Z 93685aa7f4c0affe18e092c9d91e885b diff --git a/manifest.uuid b/manifest.uuid index a774a7d7aa..e81bb2abcc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e4766cabdf64d8e998048ae43154466fc9c3fad0b86102a42b65122abfcbbe55 \ No newline at end of file +e0f192ea6dda4fa0b243d58c8ce41932519141bcae0689a90318b4f866f54edd \ No newline at end of file diff --git a/src/btreeInt.h b/src/btreeInt.h index ac7a3c0a26..87d3247e13 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -566,8 +566,8 @@ struct BtCursor { ** Do nothing else with this cursor. Any attempt to use the cursor ** should return the error code stored in BtCursor.skipNext */ -#define CURSOR_INVALID 0 -#define CURSOR_VALID 1 +#define CURSOR_VALID 0 +#define CURSOR_INVALID 1 #define CURSOR_SKIPNEXT 2 #define CURSOR_REQUIRESEEK 3 #define CURSOR_FAULT 4