From a7b3b635244620ce805245355309689724212eb1 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 14 Feb 2014 23:35:49 +0000 Subject: [PATCH 1/7] Better support for MinGW 4.x. FossilOrigin-Name: e147230767383ed9f64085b613fd18508f74be21 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index d8dd849567..8c86fcc99c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reduce\sthe\snumber\sof\scases\swhere\sit\sis\snecessary\sto\scheck\sfor\sNULL\safter\nthe\sloop\sterminating\scondition. -D 2014-02-14T20:59:53.587 +C Better\ssupport\sfor\sMinGW\s4.x. +D 2014-02-14T23:35:49.555 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -221,7 +221,7 @@ F src/shell.c 3dd86bf73ccd079f0e32ef5069600586085e8239 F src/sqlite.h.in eed7f7d66a60daaa7b4a597dcd9bad87aad9611b F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h 5b1f4e30c8332270e4c14254ef1fbcbd92a4a4c7 +F src/sqliteInt.h bc5e9c7e30d3d65ce2cd218b737f0057de0ce135 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1150,7 +1150,10 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P b6bea903ac8e1717ed50b221d73bd0be061c7663 -R f976ccc3e6f99e20be380cc680402b19 -U drh -Z d8a7427791a9ddd9c5e417477ea3c5a6 +P 3c1ae447dec8fc2af1c5105134061717594ac0e0 +R ce6f8022fe93ee0d0d6cf8a6cc271c33 +T *branch * mingw4x +T *sym-mingw4x * +T -sym-trunk * +U mistachkin +Z c1377b93302be214ebcce2f123ef84cb diff --git a/manifest.uuid b/manifest.uuid index 3ff1fc2f3d..0a1ac78ab8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3c1ae447dec8fc2af1c5105134061717594ac0e0 \ No newline at end of file +e147230767383ed9f64085b613fd18508f74be21 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8b9337a2b0..41e7e2d74d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -48,6 +48,38 @@ # define _LARGEFILE_SOURCE 1 #endif +/* +** For MinGW, check to see if we can include the header file containing its +** version information, among other things. Normally, this internal MinGW +** header file would [only] be included automatically by other MinGW header +** files; however, the contained version information is now required by this +** header file to work around binary compatibility issues (see below) and +** this is the only known way to reliably obtain it. This entire #if block +** would be completely unnecessary if there was any other way of detecting +** MinGW via their preprocessor (e.g. if they customized their GCC to define +** some MinGW-specific macros). When compiling for MinGW, either the +** _HAVE_MINGW_H or _HAVE__MINGW_H (note the extra underscore) macro must be +** defined; otherwise, detection of conditions specific to MinGW will be +** disabled. +*/ +#if defined(_HAVE_MINGW_H) +# include "mingw.h" +#elif defined(_HAVE__MINGW_H) +# include "_mingw.h" +#endif + +/* +** For MinGW version 4.x (and higher), check to see if the _USE_32BIT_TIME_T +** define is required to maintain binary compatibility with the MSVC runtime +** library in use (e.g. for Windows XP). +*/ +#if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \ + defined(_WIN32) && !defined(_WIN64) && \ + defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 4 && \ + defined(__MSVCRT__) +# define _USE_32BIT_TIME_T +#endif + /* ** Include the configuration header output by 'configure' if we're using the ** autoconf-based build From 65acf373c953f387d4a5166e7becee9135d88292 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sun, 16 Feb 2014 19:20:00 +0000 Subject: [PATCH 2/7] Use the modern MinGW major version macro, not the deprecated one. FossilOrigin-Name: 057c16ee9786efcad6372a29b02d743ff3d628ff --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 8c86fcc99c..2473432345 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Better\ssupport\sfor\sMinGW\s4.x. -D 2014-02-14T23:35:49.555 +C Use\sthe\smodern\sMinGW\smajor\sversion\smacro,\snot\sthe\sdeprecated\sone. +D 2014-02-16T19:20:00.825 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -221,7 +221,7 @@ F src/shell.c 3dd86bf73ccd079f0e32ef5069600586085e8239 F src/sqlite.h.in eed7f7d66a60daaa7b4a597dcd9bad87aad9611b F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h bc5e9c7e30d3d65ce2cd218b737f0057de0ce135 +F src/sqliteInt.h 168f311aa9887711ac5f31b52dc83f1ee33f7ab4 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1150,10 +1150,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 3c1ae447dec8fc2af1c5105134061717594ac0e0 -R ce6f8022fe93ee0d0d6cf8a6cc271c33 -T *branch * mingw4x -T *sym-mingw4x * -T -sym-trunk * +P e147230767383ed9f64085b613fd18508f74be21 +R 093f1edd2723941164ffa92a68b20dd8 U mistachkin -Z c1377b93302be214ebcce2f123ef84cb +Z f128626e0ed2b197fa14de6fa8f864a7 diff --git a/manifest.uuid b/manifest.uuid index 0a1ac78ab8..f4e941d42e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e147230767383ed9f64085b613fd18508f74be21 \ No newline at end of file +057c16ee9786efcad6372a29b02d743ff3d628ff \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 41e7e2d74d..0276d37045 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -75,7 +75,7 @@ */ #if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \ defined(_WIN32) && !defined(_WIN64) && \ - defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 4 && \ + defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \ defined(__MSVCRT__) # define _USE_32BIT_TIME_T #endif From 5b4627e957d25d1ad4c57df4e940c9563c5a81bb Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 21 Feb 2014 05:44:18 +0000 Subject: [PATCH 3/7] Better loadable extension handling in the Win32 VFS when compiled for Cygwin. FossilOrigin-Name: 6676475c47558a52cb2632e92a541e13d143b2dc --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/os_win.c | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 419633cc87..4ed19202d6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\stext\sof\sa\scomment\sused\sto\sgenerate\sVDBE\sopcode\sdocumentation\sso\sthat\nit\somits\ssymbols\sthat\scan\sbe\smistaken\sfor\sa\shyperlink\sby\sthe\sparser. -D 2014-02-20T19:42:00.531 +C Better\sloadable\sextension\shandling\sin\sthe\sWin32\sVFS\swhen\scompiled\sfor\sCygwin. +D 2014-02-21T05:44:18.393 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -203,7 +203,7 @@ F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 18f7f95dc6bcb9cf4d4a238d8e2de96611bc2ae5 -F src/os_win.c d4284f003445054a26689f1264b1b9bf7261bd1b +F src/os_win.c 23bd567f897b8934096ee7ce51b21ba43aa94ec7 F src/pager.c 0ffa313a30ed6d061d9c6601b7b175cc50a1cab7 F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 F src/parse.y 2613ca5d609c2f3d71dd297351f010bcec16e1e0 @@ -1151,7 +1151,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 824029090d1c4c4c608f67dd197961eba29c039d -R 819e2e4df777a2f59b5f5445b2831eb5 -U drh -Z c4d587ace814e560a6dc901fdec24d15 +P b46d4e8923e6e367412bba7aeac07039bbcbabd1 +R a7d693d1ea11a2ee85a54f6ea757a9d1 +T *branch * cygDlOpen +T *sym-cygDlOpen * +T -sym-trunk * +U mistachkin +Z 4b80816c39a01dfdffbdf857b2bcb9b9 diff --git a/manifest.uuid b/manifest.uuid index 32d13dfb30..b559183c43 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b46d4e8923e6e367412bba7aeac07039bbcbabd1 \ No newline at end of file +6676475c47558a52cb2632e92a541e13d143b2dc \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index d393c0d016..27f2337287 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -5141,8 +5141,23 @@ static int winFullPathname( */ static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){ HANDLE h; +#if defined(__CYGWIN__) + int nFull = pVfs->mxPathname+1; + char *zFull = sqlite3MallocZero( nFull ); + void *zConverted = 0; + if( zFull==0 ){ + return 0; + } + if( winFullPathname(pVfs, zFilename, nFull, zFull)!=SQLITE_OK ){ + sqlite3_free(zFull); + return 0; + } + zConverted = winConvertFromUtf8Filename(zFull); + sqlite3_free(zFull); +#else void *zConverted = winConvertFromUtf8Filename(zFilename); UNUSED_PARAMETER(pVfs); +#endif if( zConverted==0 ){ return 0; } From b6e8fd105c0923bde373188d0251d2440888ac8f Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 6 Mar 2014 01:56:33 +0000 Subject: [PATCH 4/7] Fix some incorrect comments and typos in comments. Add testcase() macros to some of the new record comparison code. FossilOrigin-Name: b83cfe899d84fe9d61540e9984321ca30401638c --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/btree.c | 2 +- src/insert.c | 9 ++++----- src/vdbe.c | 6 +++--- src/vdbeaux.c | 37 ++++++++++++++++++++++++++++++++++--- 6 files changed, 53 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 9ebba25618..0317e45b49 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Better\sloadable\sextension\shandling\sin\sthe\sWin32\sVFS\swhen\scompiled\sfor\sCygwin. -D 2014-03-06T00:30:27.980 +C Fix\ssome\sincorrect\scomments\sand\stypos\sin\scomments.\s\sAdd\stestcase()\smacros\nto\ssome\sof\sthe\snew\srecord\scomparison\scode. +D 2014-03-06T01:56:33.418 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,7 +163,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c ad795be588e394a0921796f87cc27717359738cc +F src/btree.c 4d28fb15543f0e071b1780b2af8cd2ee489de32d F src/btree.h 9e0f97c01b972f779eb7655cfb4f8727fd6dc26f F src/btreeInt.h 0be66063468a520e4d66b80c7a1dc26d04ee6ea4 F src/build.c 0d50ef95aad63f4c4fc47f3fa2670d4557c45db0 @@ -180,7 +180,7 @@ F src/global.c 1d7bb7ea8254ae6a68ed9bfaf65fcb3d1690b486 F src/hash.c d139319967164f139c8d1bb8a11b14db9c4ba3cd F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c d3d1164299faa53b5347f8ff676d3787537fa9e5 +F src/insert.c d8bb30535c8c0785876025a4a07f9074640a15d1 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b @@ -277,11 +277,11 @@ F src/update.c 5b3e74a03b3811e586b4f2b4cbd7c49f01c93115 F src/utf.c 6dc9ec9f1b3db43ae8ba0365377f11df1ee4c01c F src/util.c c46c90459ef9bdc0c6c73803cf4c55425b4771cf F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 -F src/vdbe.c 8c6fc7bb9f2218c0e43f24d847e596effa8671e2 +F src/vdbe.c b2ca9b8e3a47a3bcecdb2b551279a2ba750a19e5 F src/vdbe.h d189f92468a17a6f04daeec9df3b767f50557b21 F src/vdbeInt.h e54fc4f289fce48e81b3371128446033d097733b F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 -F src/vdbeaux.c 43bee29ac866f7ce6af90c4f084bb22c160b8b70 +F src/vdbeaux.c e45e3f9daf38c5be3fd39e9aacc1c9066af57a06 F src/vdbeblob.c d939997de046b8fcc607cfee4248f3d33dbcca50 F src/vdbemem.c 6fc77594c60f6155404f3f8d71bf36d1fdeb4447 F src/vdbesort.c 46801acb342e5e4c07ba1777fe58880c143abb59 @@ -1155,7 +1155,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 170e0585202eec6882e9513eba05e6d5767bfc5b 854d410ad3a2bb3af5465d933ac9535fe3f22bfe -R dbc36dfda03a0ba225e8ff052c2c6fea -U mistachkin -Z 97b3517e69e758ff54d2564329fd6e38 +P 29b0a4f158785449b6f3da6fcceeb63442c9711c +R 6ebc5b98243298bdc1108377764c8e0d +U drh +Z 431ba6c46f093bf18085ee790e19125c diff --git a/manifest.uuid b/manifest.uuid index 41cd05f2ef..d5463c1070 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -29b0a4f158785449b6f3da6fcceeb63442c9711c \ No newline at end of file +b83cfe899d84fe9d61540e9984321ca30401638c \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index eebf6f1e89..29ead1c67a 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4576,7 +4576,7 @@ int sqlite3BtreeMovetoUnpacked( || pIdxKey->default_rc==-1 ); }else{ - xRecordCompare = 0; /* Not actually used. Avoids a compiler warning. */ + xRecordCompare = 0; /* All keys are integers */ } rc = moveToRoot(pCur); diff --git a/src/insert.c b/src/insert.c index 1d29da3092..abdf1ada95 100644 --- a/src/insert.c +++ b/src/insert.c @@ -101,13 +101,13 @@ const char *sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){ ** Compute the affinity string for table pTab, if it has not already been ** computed. As an optimization, omit trailing SQLITE_AFF_NONE affinities. ** -** If the affinity exists (if it is no entirely SQLITE_AFF_NONE values and +** If the affinity exists (if it is no entirely SQLITE_AFF_NONE values) and ** if iReg>0 then code an OP_Affinity opcode that will set the affinities ** for register iReg and following. Or if affinities exists and iReg==0, ** then just set the P4 operand of the previous opcode (which should be ** an OP_MakeRecord) to the affinity string. ** -** A column affinity string has one character column: +** A column affinity string has one character per column: ** ** Character Column affinity ** ------------------------------ @@ -148,10 +148,9 @@ void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){ /* ** Return non-zero if the table pTab in database iDb or any of its indices -** have been opened at any point in the VDBE program beginning at location -** iStartAddr throught the end of the program. This is used to see if +** have been opened at any point in the VDBE program. This is used to see if ** a statement of the form "INSERT INTO SELECT ..." can -** run without using temporary table for the results of the SELECT. +** run without using a temporary table for the results of the SELECT. */ static int readsTable(Parse *p, int iDb, Table *pTab){ Vdbe *v = sqlite3GetVdbe(p); diff --git a/src/vdbe.c b/src/vdbe.c index b9d49e3620..4c36e12090 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -28,7 +28,7 @@ ** pointer to the string or blob, not the content. If the original ** is changed while the copy is still in use, the string or blob might ** be changed out from under the copy. This macro verifies that nothing -** like that every happens. +** like that ever happens. */ #ifdef SQLITE_DEBUG # define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M) @@ -2166,8 +2166,8 @@ case OP_BitNot: { /* same as TK_BITNOT, in1, out2 */ ** ** Check if OP_Once flag P1 is set. If so, jump to instruction P2. Otherwise, ** set the flag and fall through to the next instruction. In other words, -** this opcode causes all following up codes up through P2 (but not including -** P2) to run just once and skipped on subsequent times through the loop. +** this opcode causes all following opcodes up through P2 (but not including +** P2) to run just once and to be skipped on subsequent times through the loop. */ case OP_Once: { /* jump */ assert( pOp->p1nOnceFlag ); diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 00ec901588..a641a72ec8 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1234,6 +1234,10 @@ static void releaseMemArray(Mem *p, int N){ ** with no indexes using a single prepared INSERT statement, bind() ** and reset(). Inserts are grouped into a transaction. */ + testcase( p->flags & MEM_Agg ); + testcase( p->flags & MEM_Dyn ); + testcase( p->flags & MEM_Frame ); + testcase( p->flags & MEM_RowSet ); if( p->flags&(MEM_Agg|MEM_Dyn|MEM_Frame|MEM_RowSet) ){ sqlite3VdbeMemRelease(p); }else if( p->zMalloc ){ @@ -2962,27 +2966,32 @@ u32 sqlite3VdbeSerialGet( case 1: { /* 1-byte signed integer */ pMem->u.i = ONE_BYTE_INT(buf); pMem->flags = MEM_Int; + testcase( pMem->u.i<0 ); return 1; } case 2: { /* 2-byte signed integer */ pMem->u.i = TWO_BYTE_INT(buf); pMem->flags = MEM_Int; + testcase( pMem->u.i<0 ); return 2; } case 3: { /* 3-byte signed integer */ pMem->u.i = THREE_BYTE_INT(buf); pMem->flags = MEM_Int; + testcase( pMem->u.i<0 ); return 3; } case 4: { /* 4-byte signed integer */ y = FOUR_BYTE_UINT(buf); pMem->u.i = (i64)*(int*)&y; pMem->flags = MEM_Int; + testcase( pMem->u.i<0 ); return 4; } case 5: { /* 6-byte signed integer */ pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf); pMem->flags = MEM_Int; + testcase( pMem->u.i<0 ); return 6; } case 6: /* 8-byte signed integer */ @@ -3005,6 +3014,7 @@ u32 sqlite3VdbeSerialGet( if( serial_type==6 ){ pMem->u.i = *(i64*)&x; pMem->flags = MEM_Int; + testcase( pMem->u.i<0 ); }else{ assert( sizeof(x)==8 && sizeof(pMem->r)==8 ); swapMixedEndianFloat(x); @@ -3350,20 +3360,26 @@ static i64 vdbeRecordDecodeInt(u32 serial_type, const u8 *aKey){ switch( serial_type ){ case 0: case 1: + testcase( aKey[0]&0x80 ); return ONE_BYTE_INT(aKey); case 2: + testcase( aKey[0]&0x80 ); return TWO_BYTE_INT(aKey); case 3: + testcase( aKey[0]&0x80 ); return THREE_BYTE_INT(aKey); case 4: { + testcase( aKey[0]&0x80 ); y = FOUR_BYTE_UINT(aKey); return (i64)*(int*)&y; } case 5: { + testcase( aKey[0]&0x80 ); return FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey); } case 6: { u64 x = FOUR_BYTE_UINT(aKey); + testcase( aKey[0]&0x80 ); x = (x<<32) | FOUR_BYTE_UINT(aKey+4); return (i64)*(i64*)&x; } @@ -3431,6 +3447,7 @@ int sqlite3VdbeRecordCompare( /* RHS is an integer */ if( pRhs->flags & MEM_Int ){ serial_type = aKey1[idx1]; + testcase( serial_type==12 ); if( serial_type>=12 ){ rc = +1; }else if( serial_type==0 ){ @@ -3481,12 +3498,15 @@ int sqlite3VdbeRecordCompare( /* RHS is a string */ else if( pRhs->flags & MEM_Str ){ getVarint32(&aKey1[idx1], serial_type); + testcase( serial_type==12 ); if( serial_type<12 ){ rc = -1; }else if( !(serial_type & 0x01) ){ rc = +1; }else{ mem1.n = (serial_type - 12) / 2; + testcase( (d1+mem1.n)==(unsigned)nKey1 ); + testcase( (d1+mem1.n+1)==(unsigned)nKey1 ); if( (d1+mem1.n) > (unsigned)nKey1 ){ rc = 1; /* Corruption */ }else if( pKeyInfo->aColl[i] ){ @@ -3506,10 +3526,13 @@ int sqlite3VdbeRecordCompare( /* RHS is a blob */ else if( pRhs->flags & MEM_Blob ){ getVarint32(&aKey1[idx1], serial_type); + testcase( serial_type==12 ); if( serial_type<12 || (serial_type & 0x01) ){ rc = -1; }else{ int nStr = (serial_type - 12) / 2; + testcase( (d1+nStr)==(unsigned)nKey1 ); + testcase( (d1+nStr+1)==(unsigned)nKey1 ); if( (d1+nStr) > (unsigned)nKey1 ){ rc = 1; /* Corruption */ }else{ @@ -3583,29 +3606,35 @@ static int vdbeRecordCompareInt( switch( serial_type ){ case 1: { /* 1-byte signed integer */ lhs = ONE_BYTE_INT(aKey); + testcase( lhs<0 ); break; } case 2: { /* 2-byte signed integer */ lhs = TWO_BYTE_INT(aKey); + testcase( lhs<0 ); break; } case 3: { /* 3-byte signed integer */ lhs = THREE_BYTE_INT(aKey); + testcase( lhs<0 ); break; } case 4: { /* 4-byte signed integer */ y = FOUR_BYTE_UINT(aKey); lhs = (i64)*(int*)&y; + testcase( lhs<0 ); break; } case 5: { /* 6-byte signed integer */ lhs = FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey); + testcase( lhs<0 ); break; } case 6: { /* 8-byte signed integer */ x = FOUR_BYTE_UINT(aKey); x = (x<<32) | FOUR_BYTE_UINT(aKey+4); lhs = *(i64*)&x; + testcase( lhs<0 ); break; } case 8: @@ -3742,9 +3771,11 @@ RecordCompare sqlite3VdbeFindCompare(UnpackedRecord *p){ if( (flags & MEM_Int) ){ return vdbeRecordCompareInt; } - if( (flags & (MEM_Int|MEM_Real|MEM_Null|MEM_Blob))==0 - && p->pKeyInfo->aColl[0]==0 - ){ + testcase( flags & MEM_Real ); + testcase( flags & MEM_Null ); + testcase( flags & MEM_Blob ); + if( (flags & (MEM_Real|MEM_Null|MEM_Blob))==0 && p->pKeyInfo->aColl[0]==0 ){ + assert( flags & MEM_Str ); return vdbeRecordCompareString; } } From 378d01aa949d5b49b9f31e91909d4fe5ba2b598b Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 6 Mar 2014 02:15:42 +0000 Subject: [PATCH 5/7] Cosmetic change to the shell in-memory database warning to skip coloring the trailing period. FossilOrigin-Name: c87d8e07ec596d5f0ef3003cfeb226d4b7c49549 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 0317e45b49..d66f7070db 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\sincorrect\scomments\sand\stypos\sin\scomments.\s\sAdd\stestcase()\smacros\nto\ssome\sof\sthe\snew\srecord\scomparison\scode. -D 2014-03-06T01:56:33.418 +C Cosmetic\schange\sto\sthe\sshell\sin-memory\sdatabase\swarning\sto\sskip\scoloring\sthe\strailing\speriod. +D 2014-03-06T02:15:42.988 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -217,7 +217,7 @@ F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece F src/resolve.c 273d5f47c4e2c05b2d3d2bffeda939551ab59e66 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 0adf172d33cc610ff5ffe26edfd2ba67c3551655 -F src/shell.c 7bf07bcacb181ecc3fc3ccacfdfeb4084aee67ed +F src/shell.c c0cbbbe5eec0923caafd1b9593925f8b241addb8 F src/sqlite.h.in a2ef671f92747a5a1c8a47bad5c585a8dd9eca80 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc @@ -1155,7 +1155,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 29b0a4f158785449b6f3da6fcceeb63442c9711c -R 6ebc5b98243298bdc1108377764c8e0d -U drh -Z 431ba6c46f093bf18085ee790e19125c +P b83cfe899d84fe9d61540e9984321ca30401638c +R a229689d692fc13174e0ca3780072f0f +U mistachkin +Z 057b46befe5b696e1f097c5fbeb7d34a diff --git a/manifest.uuid b/manifest.uuid index d5463c1070..adad07e5fd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b83cfe899d84fe9d61540e9984321ca30401638c \ No newline at end of file +c87d8e07ec596d5f0ef3003cfeb226d4b7c49549 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 7ecedfd3c1..f3f80bfd71 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3817,8 +3817,8 @@ int main(int argc, char **argv){ ); if( warnInmemoryDb ){ printf("Connected to a "); - printBold("transient in-memory database."); - printf("\nUse \".open FILENAME\" to reopen on a " + printBold("transient in-memory database"); + printf(".\nUse \".open FILENAME\" to reopen on a " "persistent database.\n"); } zHome = find_home_dir(); From 0df163a9f06f402bc985b6d53fe1257245b12b01 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 6 Mar 2014 12:36:26 +0000 Subject: [PATCH 6/7] Remove a branch that is never taken from where.c. FossilOrigin-Name: 4a4997221f3d61c1411a993053b40c787beea736 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d66f7070db..8bc91eb7e3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Cosmetic\schange\sto\sthe\sshell\sin-memory\sdatabase\swarning\sto\sskip\scoloring\sthe\strailing\speriod. -D 2014-03-06T02:15:42.988 +C Remove\sa\sbranch\sthat\sis\snever\staken\sfrom\swhere.c. +D 2014-03-06T12:36:26.240 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -290,7 +290,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 76e7fc6de229bea8b30bb2539110f03a494dc3a8 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 2269342f82ea97596564bdc981c362a5177b72c5 +F src/where.c 95d30485879122acc5284d4523e01399b23b6148 F src/whereInt.h 921f935af8b684ffb49705610bda7284db1db138 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1155,7 +1155,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P b83cfe899d84fe9d61540e9984321ca30401638c -R a229689d692fc13174e0ca3780072f0f -U mistachkin -Z 057b46befe5b696e1f097c5fbeb7d34a +P c87d8e07ec596d5f0ef3003cfeb226d4b7c49549 +R 8a41ab31fe82e4eb8dd3f6f960d87359 +U dan +Z 9504b4a4d2685ecc17b4e7b160b2fd5f diff --git a/manifest.uuid b/manifest.uuid index adad07e5fd..0a317e3270 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c87d8e07ec596d5f0ef3003cfeb226d4b7c49549 \ No newline at end of file +4a4997221f3d61c1411a993053b40c787beea736 \ No newline at end of file diff --git a/src/where.c b/src/where.c index c29c94ae0a..963878d009 100644 --- a/src/where.c +++ b/src/where.c @@ -3057,13 +3057,13 @@ static Bitmask codeOneLoopStart( pRangeEnd = pLoop->aLTerm[j++]; nExtraReg = 1; if( pRangeStart==0 - && (pRangeEnd->wtFlags & TERM_VNULL)==0 && (j = pIdx->aiColumn[nEq])>=0 && pIdx->pTable->aCol[j].notNull==0 ){ bSeekPastNull = 1; } } + assert( pRangeEnd==0 || (pRangeEnd->wtFlags & TERM_VNULL)==0 ); /* Generate code to evaluate all constraint terms using == or IN ** and store the values of those terms in an array of registers From fe70510aa757c4579e9943052f828a3cad5d6d74 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 6 Mar 2014 13:38:37 +0000 Subject: [PATCH 7/7] Improved EXPLAIN indentation of a loop in the ANALYZE logic for STAT4. Mark the not-found jump of a seek operation in that loop as never taken. FossilOrigin-Name: 0a4200f95cf46ad620b9fd91f4444114a0c74730 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/analyze.c | 7 +++++-- src/shell.c | 5 ++++- src/vdbe.c | 5 +++++ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 8bc91eb7e3..c1695f1700 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\sbranch\sthat\sis\snever\staken\sfrom\swhere.c. -D 2014-03-06T12:36:26.240 +C Improved\sEXPLAIN\sindentation\sof\sa\sloop\sin\sthe\sANALYZE\slogic\sfor\sSTAT4.\nMark\sthe\snot-found\sjump\sof\sa\sseek\soperation\sin\sthat\sloop\sas\snever\staken. +D 2014-03-06T13:38:37.861 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -157,7 +157,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 3d8b83c91651f53472ca17599dae3457b8b89494 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 5d99edbac5bc416032772b723ee30182ee6e5de0 -F src/analyze.c 69761e1677142d180a9f55250dee2952f45e4793 +F src/analyze.c 663e0b291d27eb03c9fd6b421e2d61ba348a2389 F src/attach.c 3801129015ef59d76bf23c95ef9b0069d18a0c52 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53 @@ -217,7 +217,7 @@ F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece F src/resolve.c 273d5f47c4e2c05b2d3d2bffeda939551ab59e66 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 0adf172d33cc610ff5ffe26edfd2ba67c3551655 -F src/shell.c c0cbbbe5eec0923caafd1b9593925f8b241addb8 +F src/shell.c bab4de12b441369491812ecc93212ff4deda68fa F src/sqlite.h.in a2ef671f92747a5a1c8a47bad5c585a8dd9eca80 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc @@ -277,7 +277,7 @@ F src/update.c 5b3e74a03b3811e586b4f2b4cbd7c49f01c93115 F src/utf.c 6dc9ec9f1b3db43ae8ba0365377f11df1ee4c01c F src/util.c c46c90459ef9bdc0c6c73803cf4c55425b4771cf F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 -F src/vdbe.c b2ca9b8e3a47a3bcecdb2b551279a2ba750a19e5 +F src/vdbe.c 5f0fffa9bf49a90c05dc3d46d8217603fd0ee00e F src/vdbe.h d189f92468a17a6f04daeec9df3b767f50557b21 F src/vdbeInt.h e54fc4f289fce48e81b3371128446033d097733b F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 @@ -1155,7 +1155,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P c87d8e07ec596d5f0ef3003cfeb226d4b7c49549 -R 8a41ab31fe82e4eb8dd3f6f960d87359 -U dan -Z 9504b4a4d2685ecc17b4e7b160b2fd5f +P 4a4997221f3d61c1411a993053b40c787beea736 +R 6c77c921c71ee968c47f10dbbbd337e5 +U drh +Z 43128f0b9615c8a6ed241332450c076a diff --git a/manifest.uuid b/manifest.uuid index 0a317e3270..de8a5a7e02 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4a4997221f3d61c1411a993053b40c787beea736 \ No newline at end of file +0a4200f95cf46ad620b9fd91f4444114a0c74730 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 235a2abaf8..2a03e292c8 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -1178,7 +1178,10 @@ static void analyzeOneTable( callStatGet(v, regStat4, STAT_GET_NLT, regLt); callStatGet(v, regStat4, STAT_GET_NDLT, regDLt); sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0); - VdbeCoverage(v); + /* We know that the regSampleRowid row exists because it was read by + ** the previous loop. Thus the not-found jump of seekOp will never + ** be taken */ + VdbeCoverageNeverTaken(v); #ifdef SQLITE_ENABLE_STAT3 sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, pIdx->aiColumn[0], regSample); @@ -1192,7 +1195,7 @@ static void analyzeOneTable( sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp); sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid); sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regTemp, regNewRowid); - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrNext); + sqlite3VdbeAddOp2(v, OP_Goto, 1, addrNext); /* P1==1 for end-of-loop */ sqlite3VdbeJumpHere(v, addrIsNull); } #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */ diff --git a/src/shell.c b/src/shell.c index f3f80bfd71..2cff102e91 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1184,6 +1184,7 @@ static int str_in_array(const char *zStr, const char **azArray){ ** * For each "Goto", if the jump destination is earlier in the program ** and ends on one of: ** Yield SeekGt SeekLt RowSetRead Rewind +** or if the P1 parameter is one instead of zero, ** then indent all opcodes between the earlier instruction ** and "Goto" by 2 spaces. */ @@ -1231,7 +1232,9 @@ static void explain_data_prepare(struct callback_data *p, sqlite3_stmt *pSql){ if( str_in_array(zOp, azNext) ){ for(i=p2op; iaiIndent[i] += 2; } - if( str_in_array(zOp, azGoto) && p2opnIndent && abYield[p2op] ){ + if( str_in_array(zOp, azGoto) && p2opnIndent + && (abYield[p2op] || sqlite3_column_int(pSql, 2)) + ){ for(i=p2op+1; iaiIndent[i] += 2; } } diff --git a/src/vdbe.c b/src/vdbe.c index 4c36e12090..c58b5d9fda 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -671,6 +671,11 @@ int sqlite3VdbeExec( ** The next instruction executed will be ** the one at index P2 from the beginning of ** the program. +** +** The P1 parameter is not actually used by this opcode. However, it +** is sometimes set to 1 instead of 0 as a hint to the command-line shell +** that this Goto is the bottom of a loop and that the lines from P2 down +** to the current line should be indented for EXPLAIN output. */ case OP_Goto: { /* jump */ pc = pOp->p2 - 1;