From 45ac1c70b30d151cbcceb9ffa5ad1b3be38ce919 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 18 Dec 2015 03:59:16 +0000 Subject: [PATCH 01/37] Reduce the size of the CellInfo object from 32 to 24 bytes on 64-bit machines. FossilOrigin-Name: 7850715406458a61cff9eba5ad915f61f6d99482 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/btree.c | 33 ++++++++++++++------------------- src/btreeInt.h | 1 - 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/manifest b/manifest index 799ac619df..20d4d08510 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sspellfix1_scriptcode()\sfunction\sto\signore\swhitespace\sand\spunctuation,\nand\sto\srecognize\shebrew\sand\sarabic\sscripts. -D 2015-12-17T14:18:21.904 +C Reduce\sthe\ssize\sof\sthe\sCellInfo\sobject\sfrom\s32\sto\s24\sbytes\son\s64-bit\smachines. +D 2015-12-18T03:59:16.912 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -276,9 +276,9 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 84ede51e371a11c3dbb3e24ccc5e3e99594a6c00 +F src/btree.c 5ac3f868d4f20a67f0f00a1014940f902b511558 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 -F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 +F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f @@ -1405,7 +1405,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 85ebd46c701e0a094a4690cd8f1d0cbae9aa257c -R 70cdc580d7d9b92b032d33f5e0d50f2e +P 7adfa4a5794e47f97491c08abeaaac90e826b331 +R 235be975857692987ba30e4b3c7418db +T *branch * optimize-cellinfo +T *sym-optimize-cellinfo * +T -sym-trunk * U drh -Z 6d4b5ed9cd1870281d7d851922f323d8 +Z cc2df912aa2ee31453d3047ea3468b1b diff --git a/manifest.uuid b/manifest.uuid index eebc618153..b71ad0f19e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7adfa4a5794e47f97491c08abeaaac90e826b331 \ No newline at end of file +7850715406458a61cff9eba5ad915f61f6d99482 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 4e384e2c4f..df9455bc5b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1051,8 +1051,7 @@ static SQLITE_NOINLINE void btreeParseCellAdjustSizeForOverflow( }else{ pInfo->nLocal = (u16)minLocal; } - pInfo->iOverflow = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell); - pInfo->nSize = pInfo->iOverflow + 4; + pInfo->nSize = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell) + 4; } /* @@ -1084,7 +1083,6 @@ static void btreeParseCellPtrNoPayload( pInfo->nSize = 4 + getVarint(&pCell[4], (u64*)&pInfo->nKey); pInfo->nPayload = 0; pInfo->nLocal = 0; - pInfo->iOverflow = 0; pInfo->pPayload = 0; return; } @@ -1154,7 +1152,6 @@ static void btreeParseCellPtr( pInfo->nSize = nPayload + (u16)(pIter - pCell); if( pInfo->nSize<4 ) pInfo->nSize = 4; pInfo->nLocal = (u16)nPayload; - pInfo->iOverflow = 0; }else{ btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo); } @@ -1193,7 +1190,6 @@ static void btreeParseCellPtrIndex( pInfo->nSize = nPayload + (u16)(pIter - pCell); if( pInfo->nSize<4 ) pInfo->nSize = 4; pInfo->nLocal = (u16)nPayload; - pInfo->iOverflow = 0; }else{ btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo); } @@ -1309,8 +1305,8 @@ static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){ if( *pRC ) return; assert( pCell!=0 ); pPage->xParseCell(pPage, pCell, &info); - if( info.iOverflow ){ - Pgno ovfl = get4byte(&pCell[info.iOverflow]); + if( info.nLocalpBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC); } } @@ -3348,11 +3344,11 @@ static int modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){ if( eType==PTRMAP_OVERFLOW1 ){ CellInfo info; pPage->xParseCell(pPage, pCell, &info); - if( info.iOverflow - && pCell+info.iOverflow+3<=pPage->aData+pPage->maskPage - && iFrom==get4byte(&pCell[info.iOverflow]) + if( info.nLocalaData+pPage->maskPage + && iFrom==get4byte(pCell+info.nSize-4) ){ - put4byte(&pCell[info.iOverflow], iTo); + put4byte(pCell+info.nSize-4, iTo); break; } }else{ @@ -5994,13 +5990,13 @@ static int clearCell( assert( sqlite3_mutex_held(pPage->pBt->mutex) ); pPage->xParseCell(pPage, pCell, &info); *pnSize = info.nSize; - if( info.iOverflow==0 ){ + if( info.nLocal==info.nPayload ){ return SQLITE_OK; /* No overflow pages. Return without doing anything */ } - if( pCell+info.iOverflow+3 > pPage->aData+pPage->maskPage ){ + if( pCell+info.nSize-1 > pPage->aData+pPage->maskPage ){ return SQLITE_CORRUPT_BKPT; /* Cell extends past end of page */ } - ovflPgno = get4byte(&pCell[info.iOverflow]); + ovflPgno = get4byte(pCell + info.nSize - 4); assert( pBt->usableSize > 4 ); ovflPageSize = pBt->usableSize - 4; nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize; @@ -6149,7 +6145,6 @@ static int fillInCell( assert( info.nKey==nKey ); assert( *pnSize == info.nSize ); assert( spaceLeft == info.nLocal ); - assert( pPrior == &pCell[info.iOverflow] ); } #endif @@ -6859,8 +6854,8 @@ static int ptrmapCheckPages(MemPage **apPage, int nPage){ z = findCell(pPage, j); pPage->xParseCell(pPage, z, &info); - if( info.iOverflow ){ - Pgno ovfl = get4byte(&z[info.iOverflow]); + if( info.nLocalpgno && e==PTRMAP_OVERFLOW1 ); } @@ -9166,9 +9161,9 @@ static int checkTreePage( if( info.nPayload>info.nLocal ){ int nPage; /* Number of pages on the overflow chain */ Pgno pgnoOvfl; /* First page of the overflow chain */ - assert( pc + info.iOverflow <= usableSize ); + assert( pc + info.nSize - 4 <= usableSize ); nPage = (info.nPayload - info.nLocal + usableSize - 5)/(usableSize - 4); - pgnoOvfl = get4byte(&pCell[info.iOverflow]); + pgnoOvfl = get4byte(&pCell[info.nSize - 4]); #ifndef SQLITE_OMIT_AUTOVACUUM if( pBt->autoVacuum ){ checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage); diff --git a/src/btreeInt.h b/src/btreeInt.h index e43ff1210a..a196e18a28 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -470,7 +470,6 @@ struct CellInfo { u8 *pPayload; /* Pointer to the start of payload */ u32 nPayload; /* Bytes of payload */ u16 nLocal; /* Amount of payload held locally, not on overflow */ - u16 iOverflow; /* Offset to overflow page number. Zero if no overflow */ u16 nSize; /* Size of the cell content on the main b-tree page */ }; From d319b8c1438de286caa9a2aa74938bb788430111 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 18 Dec 2015 16:29:47 +0000 Subject: [PATCH 02/37] Micro-optimizations and comment fixes on the mem5.c memory allocator module. FossilOrigin-Name: 8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/mem5.c | 29 ++++++++++------------------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index 799ac619df..fa04e7372c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sspellfix1_scriptcode()\sfunction\sto\signore\swhitespace\sand\spunctuation,\nand\sto\srecognize\shebrew\sand\sarabic\sscripts. -D 2015-12-17T14:18:21.904 +C Micro-optimizations\sand\scomment\sfixes\son\sthe\smem5.c\smemory\sallocator\smodule. +D 2015-12-18T16:29:47.912 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -304,7 +304,7 @@ F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a -F src/mem5.c 5c267678ba9f745a2ee58102a9f482d64a58577a +F src/mem5.c 262055c242fa7db59c5f07ad77fdc4e97888c054 F src/memjournal.c 3eb2c0b51adbd869cb6a44780323f05fa904dc85 F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 85ebd46c701e0a094a4690cd8f1d0cbae9aa257c -R 70cdc580d7d9b92b032d33f5e0d50f2e +P 7adfa4a5794e47f97491c08abeaaac90e826b331 +R 1b3cde8c2a6658c08ed08e4868245c5a U drh -Z 6d4b5ed9cd1870281d7d851922f323d8 +Z 526b8930cb4e95afc320a389b1027b99 diff --git a/manifest.uuid b/manifest.uuid index eebc618153..51cf94b6da 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7adfa4a5794e47f97491c08abeaaac90e826b331 \ No newline at end of file +8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b \ No newline at end of file diff --git a/src/mem5.c b/src/mem5.c index b34a04e8b6..49bebca093 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -25,7 +25,7 @@ ** ** This memory allocator uses the following algorithm: ** -** 1. All memory allocations sizes are rounded up to a power of 2. +** 1. All memory allocation sizes are rounded up to a power of 2. ** ** 2. If two adjacent free blocks are the halves of a larger block, ** then the two blocks are coalesced into the single larger block. @@ -117,7 +117,7 @@ static SQLITE_WSD struct Mem5Global { /* ** Lists of free blocks. aiFreelist[0] is a list of free blocks of ** size mem5.szAtom. aiFreelist[1] holds blocks of size szAtom*2. - ** and so forth. + ** aiFreelist[2] holds free blocks of size szAtom*4. And so forth. */ int aiFreelist[LOGMAX+1]; @@ -183,9 +183,7 @@ static void memsys5Link(int i, int iLogsize){ } /* -** If the STATIC_MEM mutex is not already held, obtain it now. The mutex -** will already be held (obtained by code in malloc.c) if -** sqlite3GlobalConfig.bMemStat is true. +** Obtain or release the mutex needed to access global data structures. */ static void memsys5Enter(void){ sqlite3_mutex_enter(mem5.mutex); @@ -195,9 +193,8 @@ static void memsys5Leave(void){ } /* -** Return the size of an outstanding allocation, in bytes. The -** size returned omits the 8-byte header overhead. This only -** works for chunks that are currently checked out. +** Return the size of an outstanding allocation, in bytes. +** This only works for chunks that are currently checked out. */ static int memsys5Size(void *p){ int iSize, i; @@ -230,16 +227,12 @@ static void *memsys5MallocUnsafe(int nByte){ /* Keep track of the maximum allocation request. Even unfulfilled ** requests are counted */ if( (u32)nByte>mem5.maxRequest ){ + /* Abort if the requested allocation size is larger than the largest + ** power of two that we can represent using 32-bit signed integers. */ + if( nByte > 0x40000000 ) return 0; mem5.maxRequest = nByte; } - /* Abort if the requested allocation size is larger than the largest - ** power of two that we can represent using 32-bit signed integers. - */ - if( nByte > 0x40000000 ){ - return 0; - } - /* Round nByte up to the next valid power of two */ for(iFullSz=mem5.szAtom,iLogsize=0; iFullSz Date: Mon, 21 Dec 2015 15:22:13 +0000 Subject: [PATCH 03/37] Ensure that the Expr objects that describe indexed expressions are not modified by code generation. Fix for an assert() problem found by Jon Metzman using AFL. FossilOrigin-Name: 34073ce87d88a02313217023ae92e15939192cd9 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/expr.c | 16 ++++++++++++++-- src/insert.c | 2 +- src/sqliteInt.h | 1 + test/indexexpr1.test | 16 ++++++++++++++++ 6 files changed, 42 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index fa04e7372c..e171b344af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Micro-optimizations\sand\scomment\sfixes\son\sthe\smem5.c\smemory\sallocator\smodule. -D 2015-12-18T16:29:47.912 +C Ensure\sthat\sthe\sExpr\sobjects\sthat\sdescribe\sindexed\sexpressions\sare\snot\smodified\nby\scode\sgeneration.\s\sFix\sfor\san\sassert()\sproblem\sfound\sby\sJon\sMetzman\susing\sAFL. +D 2015-12-21T15:22:13.811 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -286,7 +286,7 @@ F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c ccb93d7b7e1ac5d187c9b153bae145933f93ee5c +F src/expr.c 414f4c6b016c4494bfb11713da79f27966871d91 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 F src/func.c fe50a9ab977acc0bb0fcd46741e0071fa388888e @@ -294,7 +294,7 @@ F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c e1d20ae8979e25519c2670233718676bedcfedc9 +F src/insert.c 4622e544a6f054b8f36bb06ae85f4aa09fcd6b5b F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b @@ -338,7 +338,7 @@ F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h beb4a63b94428f52a3d7c7af2ba8bdc7d4682a03 +F src/sqliteInt.h 5a2770eb1fdf3542b9c5ac3fd87836f0d46e1b08 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -787,7 +787,7 @@ F test/index5.test 8621491915800ec274609e42e02a97d67e9b13e7 F test/index6.test 7102ec371414c42dfb1d5ca37eb4519aa9edc23a F test/index7.test 9c6765a74fc3fcde7aebc5b3bd40d98df14a527c F test/indexedby.test 9c4cd331224e57f79fbf411ae245e6272d415985 -F test/indexexpr1.test bbb52b5d5717d9f23853826963b0af5110009366 +F test/indexexpr1.test cb71b6586177b840e28110dd952178bb2bdfedc2 F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 F test/insert.test 38742b5e9601c8f8d76e9b7555f7270288c2d371 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7adfa4a5794e47f97491c08abeaaac90e826b331 -R 1b3cde8c2a6658c08ed08e4868245c5a +P 8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b +R e0404c0cd537e70ac5aa95195290d5e7 U drh -Z 526b8930cb4e95afc320a389b1027b99 +Z ae8c1424b866e12742c6a5c15035540f diff --git a/manifest.uuid b/manifest.uuid index 51cf94b6da..9837f3d4d4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b \ No newline at end of file +34073ce87d88a02313217023ae92e15939192cd9 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 8f6377e664..5c67de1297 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2468,7 +2468,7 @@ void sqlite3ExprCodeLoadIndexColumn( assert( pIdx->aColExpr ); assert( pIdx->aColExpr->nExpr>iIdxCol ); pParse->iSelfTab = iTabCur; - sqlite3ExprCode(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut); + sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut); }else{ sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur, iTabCol, regOut); @@ -3321,13 +3321,25 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){ sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target); }else{ inReg = sqlite3ExprCodeTarget(pParse, pExpr, target); - assert( pParse->pVdbe || pParse->db->mallocFailed ); + assert( pParse->pVdbe!=0 || pParse->db->mallocFailed ); if( inReg!=target && pParse->pVdbe ){ sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target); } } } +/* +** Make a transient copy of expression pExpr and then code it using +** sqlite3ExprCode(). This routine works just like sqlite3ExprCode() +** except that the input expression is guaranteed to be unchanged. +*/ +void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){ + sqlite3 *db = pParse->db; + pExpr = sqlite3ExprDup(db, pExpr, 0); + if( !db->mallocFailed ) sqlite3ExprCode(pParse, pExpr, target); + sqlite3ExprDelete(db, pExpr); +} + /* ** Generate code that will evaluate expression pExpr and store the ** results in register target. The results are guaranteed to appear diff --git a/src/insert.c b/src/insert.c index 52769e9c4f..7ac2a2559d 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1408,7 +1408,7 @@ void sqlite3GenerateConstraintChecks( int x; if( iField==XN_EXPR ){ pParse->ckBase = regNewData+1; - sqlite3ExprCode(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i); + sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i); pParse->ckBase = 0; VdbeComment((v, "%s column %d", pIdx->zName, i)); }else{ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4249ef768a..a328aff013 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3461,6 +3461,7 @@ void sqlite3ExprCacheRemove(Parse*, int, int); void sqlite3ExprCacheClear(Parse*); void sqlite3ExprCacheAffinityChange(Parse*, int, int); void sqlite3ExprCode(Parse*, Expr*, int); +void sqlite3ExprCodeCopy(Parse*, Expr*, int); void sqlite3ExprCodeFactorable(Parse*, Expr*, int); void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8); int sqlite3ExprCodeTemp(Parse*, Expr*, int*); diff --git a/test/indexexpr1.test b/test/indexexpr1.test index 89bea1877f..a8a74f259e 100644 --- a/test/indexexpr1.test +++ b/test/indexexpr1.test @@ -307,5 +307,21 @@ do_catchsql_test indexexpr1-910 { INSERT INTO t9(a,b,c,d) VALUES(5,6,7,-8); } {1 {UNIQUE constraint failed: index 't9x1'}} +# Test cases derived from a NEVER() maro failure discovered by +# Jonathan Metzman using AFL +# +do_execsql_test indexexpr1-1000 { + DROP TABLE IF EXISTS t0; + CREATE TABLE t0(a,b,t); + CREATE INDEX i ON t0(a in(0,1)); + INSERT INTO t0 VALUES(0,1,2),(2,3,4),(5,6,7); + UPDATE t0 SET b=99 WHERE (a in(0,1))=0; + SELECT *, '|' FROM t0 ORDER BY +a; +} {0 1 2 | 2 99 4 | 5 99 7 |} +do_execsql_test indexexpr1-1010 { + UPDATE t0 SET b=88 WHERE (a in(0,1))=1; + SELECT *, '|' FROM t0 ORDER BY +a; +} {0 88 2 | 2 99 4 | 5 99 7 |} + finish_test From caeca516a7df7ca63e662006f34a1b968a20b369 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 23 Dec 2015 10:54:48 +0000 Subject: [PATCH 04/37] Enhance the 'utc' modifier on date/time functions so that if the LHS is already known to be in UTC, the modifier becomes a no-op. This is not an incompatibility because the behavior is documented as "undefined" in that scenario. FossilOrigin-Name: b910a3d53769689d9212a06f974ccce54844bbe4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/date.c | 21 ++++++++++++++------- test/date.test | 9 +++++++++ 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index e171b344af..078eaef167 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthe\sExpr\sobjects\sthat\sdescribe\sindexed\sexpressions\sare\snot\smodified\nby\scode\sgeneration.\s\sFix\sfor\san\sassert()\sproblem\sfound\sby\sJon\sMetzman\susing\sAFL. -D 2015-12-21T15:22:13.811 +C Enhance\sthe\s'utc'\smodifier\son\sdate/time\sfunctions\sso\sthat\sif\sthe\sLHS\sis\nalready\sknown\sto\sbe\sin\sUTC,\sthe\smodifier\sbecomes\sa\sno-op.\s\sThis\sis\snot\san\nincompatibility\sbecause\sthe\sbehavior\sis\sdocumented\sas\s"undefined"\sin\sthat\nscenario. +D 2015-12-23T10:54:48.693 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -283,7 +283,7 @@ F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 -F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 +F src/date.c e4655393bb403fa310eef66cc4583d75d4d7fd93 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c 414f4c6b016c4494bfb11713da79f27966871d91 @@ -563,7 +563,7 @@ F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 F test/cursorhint.test 432811b62bd5ffb812729f49bba3b9ad687550bb -F test/date.test 42973251b9429f2c41b77eb98a7b0b0ba2d3b2c0 +F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 F test/dbstatus2.test 10418e62b3db5dca070f0c3eef3ea13946f339c2 F test/default.test 0cb49b1c315a0d81c81d775e407f66906a2a604d @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b -R e0404c0cd537e70ac5aa95195290d5e7 +P 34073ce87d88a02313217023ae92e15939192cd9 +R fb37875a5634d72cf8280c2958a6e17e U drh -Z ae8c1424b866e12742c6a5c15035540f +Z 5e4e9bf785bd86d0086510037196235b diff --git a/manifest.uuid b/manifest.uuid index 9837f3d4d4..c74bd62134 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -34073ce87d88a02313217023ae92e15939192cd9 \ No newline at end of file +b910a3d53769689d9212a06f974ccce54844bbe4 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 8a66eae900..3d7604ab45 100644 --- a/src/date.c +++ b/src/date.c @@ -65,6 +65,7 @@ struct DateTime { char validHMS; /* True (1) if h,m,s are valid */ char validJD; /* True (1) if iJD is valid */ char validTZ; /* True (1) if tz is valid */ + char tzSet; /* Timezone was set explicitly */ }; @@ -158,6 +159,7 @@ static int parseTimezone(const char *zDate, DateTime *p){ p->tz = sgn*(nMn + nHr*60); zulu_time: while( sqlite3Isspace(*zDate) ){ zDate++; } + p->tzSet = 1; return *zDate!=0; } @@ -590,13 +592,18 @@ static int parseModifier(sqlite3_context *pCtx, const char *zMod, DateTime *p){ } #ifndef SQLITE_OMIT_LOCALTIME else if( strcmp(z, "utc")==0 ){ - sqlite3_int64 c1; - computeJD(p); - c1 = localtimeOffset(p, pCtx, &rc); - if( rc==SQLITE_OK ){ - p->iJD -= c1; - clearYMD_HMS_TZ(p); - p->iJD += c1 - localtimeOffset(p, pCtx, &rc); + if( p->tzSet==0 ){ + sqlite3_int64 c1; + computeJD(p); + c1 = localtimeOffset(p, pCtx, &rc); + if( rc==SQLITE_OK ){ + p->iJD -= c1; + clearYMD_HMS_TZ(p); + p->iJD += c1 - localtimeOffset(p, pCtx, &rc); + } + p->tzSet = 1; + }else{ + rc = SQLITE_OK; } } #endif diff --git a/test/date.test b/test/date.test index b1d1c677c1..2f48b111e6 100644 --- a/test/date.test +++ b/test/date.test @@ -336,6 +336,15 @@ if {$tzoffset_new==4} { datetest 6.8.1 {datetime('2006-04-02 02:00:00','utc')} {2006-04-02 06:00:00} datetest 6.8.2 {datetime('2007-03-11 02:00:00','utc')} {2007-03-11 06:00:00} + # The 'utc' modifier is a no-op if the LHS is known to already be in UTC + datetest 6.9.1 {datetime('2015-12-23 12:00:00','utc')} {2015-12-23 17:00:00} + datetest 6.9.2 {datetime('2015-12-23 12:00:00z','utc')} {2015-12-23 12:00:00} + datetest 6.9.3 {datetime('2015-12-23 12:00:00-03:00','utc')} \ + {2015-12-23 15:00:00} + datetest 6.9.4 {datetime('2015-12-23 12:00:00','utc','utc','utc')} \ + {2015-12-23 17:00:00} + + datetest 6.10 {datetime('2000-01-01 12:00:00','localtime')} \ {2000-01-01 07:00:00} datetest 6.11 {datetime('1969-01-01 12:00:00','localtime')} \ From 3e6a1411300a1d0251369b5cf156b1f745895dcf Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 23 Dec 2015 16:42:27 +0000 Subject: [PATCH 05/37] Fix some harmless gcc compiler warnings. Mostly in fts5, but also two in the core code. FossilOrigin-Name: 5d44d4a6cf5c6b983cbd846d9bc34251df8f4bc5 --- ext/fts5/fts5_aux.c | 2 +- ext/fts5/fts5_expr.c | 6 +++--- ext/fts5/fts5_main.c | 4 ++-- ext/fts5/fts5_storage.c | 2 +- ext/fts5/fts5_tokenize.c | 2 +- manifest | 26 +++++++++++++------------- manifest.uuid | 2 +- src/expr.c | 2 +- src/mutex_unix.c | 2 ++ 9 files changed, 25 insertions(+), 23 deletions(-) diff --git a/ext/fts5/fts5_aux.c b/ext/fts5/fts5_aux.c index 928a26a8bb..011064d405 100644 --- a/ext/fts5/fts5_aux.c +++ b/ext/fts5/fts5_aux.c @@ -544,7 +544,7 @@ int sqlite3Fts5AuxInit(fts5_api *pApi){ int rc = SQLITE_OK; /* Return code */ int i; /* To iterate through builtin functions */ - for(i=0; rc==SQLITE_OK && ixCreateFunction(pApi, aBuiltin[i].zFunc, aBuiltin[i].pUserData, diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index eb167b4407..a747a64c9b 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -407,7 +407,7 @@ static int fts5ExprPhraseIsMatch( /* If the aStatic[] array is not large enough, allocate a large array ** using sqlite3_malloc(). This approach could be improved upon. */ - if( pPhrase->nTerm>(sizeof(aStatic) / sizeof(aStatic[0])) ){ + if( pPhrase->nTerm>(int)ArraySize(aStatic) ){ int nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm; aIter = (Fts5PoslistReader*)sqlite3_malloc(nByte); if( !aIter ) return SQLITE_NOMEM; @@ -543,7 +543,7 @@ static int fts5ExprNearIsMatch(int *pRc, Fts5ExprNearset *pNear){ /* If the aStatic[] array is not large enough, allocate a large array ** using sqlite3_malloc(). This approach could be improved upon. */ - if( pNear->nPhrase>(sizeof(aStatic) / sizeof(aStatic[0])) ){ + if( pNear->nPhrase>(int)ArraySize(aStatic) ){ int nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase; a = (Fts5NearTrimmer*)sqlite3Fts5MallocZero(&rc, nByte); }else{ @@ -2190,7 +2190,7 @@ int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){ int rc = SQLITE_OK; void *pCtx = (void*)pGlobal; - for(i=0; rc==SQLITE_OK && i<(sizeof(aFunc) / sizeof(aFunc[0])); i++){ + for(i=0; rc==SQLITE_OK && i<(int)ArraySize(aFunc); i++){ struct Fts5ExprFunc *p = &aFunc[i]; rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0); } diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index cf2c748c4c..70912de4f8 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -537,7 +537,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ for(i=0; inConstraint; i++){ struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; int j; - for(j=0; jiColumn==aColMap[pC->iCol] && p->op & pC->op ){ if( p->usable ){ @@ -584,7 +584,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ /* Assign argvIndex values to each constraint in use. */ iNext = 1; - for(i=0; iiConsIndex>=0 ){ pInfo->aConstraintUsage[pC->iConsIndex].argvIndex = iNext++; diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 5fd5dc51a2..13297c1509 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -338,7 +338,7 @@ int sqlite3Fts5StorageClose(Fts5Storage *p){ int i; /* Finalize all SQL statements */ - for(i=0; iaStmt); i++){ + for(i=0; i<(int)ArraySize(p->aStmt); i++){ sqlite3_finalize(p->aStmt[i]); } diff --git a/ext/fts5/fts5_tokenize.c b/ext/fts5/fts5_tokenize.c index 1df7ba9e35..e60183c095 100644 --- a/ext/fts5/fts5_tokenize.c +++ b/ext/fts5/fts5_tokenize.c @@ -1220,7 +1220,7 @@ int sqlite3Fts5TokenizerInit(fts5_api *pApi){ int rc = SQLITE_OK; /* Return code */ int i; /* To iterate through builtin functions */ - for(i=0; rc==SQLITE_OK && ixCreateTokenizer(pApi, aBuiltin[i].zName, (void*)pApi, diff --git a/manifest b/manifest index 078eaef167..0c1d15f84d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\s'utc'\smodifier\son\sdate/time\sfunctions\sso\sthat\sif\sthe\sLHS\sis\nalready\sknown\sto\sbe\sin\sUTC,\sthe\smodifier\sbecomes\sa\sno-op.\s\sThis\sis\snot\san\nincompatibility\sbecause\sthe\sbehavior\sis\sdocumented\sas\s"undefined"\sin\sthat\nscenario. -D 2015-12-23T10:54:48.693 +C Fix\ssome\sharmless\sgcc\scompiler\swarnings.\sMostly\sin\sfts5,\sbut\salso\stwo\sin\sthe\score\scode. +D 2015-12-23T16:42:27.781 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -98,17 +98,17 @@ F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 8b9a13b309b180e9fb88ea5666c0d8d73c6102d9 F ext/fts5/fts5Int.h acf968e43d57b6b1caf7554d34ec35d6ed3b4fe8 -F ext/fts5/fts5_aux.c 1f384972d606375b8fa078319f25ab4b5feb1b35 +F ext/fts5/fts5_aux.c 2dafc3aee0c70d643140c77d8d70daffa51a9e9e F ext/fts5/fts5_buffer.c 1e49512a535045e621246dc7f4f65f3593fa0fc2 F ext/fts5/fts5_config.c 0ee66188609a62342e9f9aeefa3c3e44518a4dd6 -F ext/fts5/fts5_expr.c 80075fa45091bad42100c4a5c4f2efc83e43e3af +F ext/fts5/fts5_expr.c 8228aca3e9af626a1ca9b093d4d24b4f2488ad23 F ext/fts5/fts5_hash.c 25838d525e97f8662ff3504be94d0bad24f9a37e F ext/fts5/fts5_index.c 578f46697080f11a1e26cd45a1c039c043a3111d -F ext/fts5/fts5_main.c ef04699949ab8e42d590ae30188afef7ad58776e -F ext/fts5/fts5_storage.c 9ea3d92178743758b6c54d9fe8836bbbdcc92e3b +F ext/fts5/fts5_main.c e11b525778e6fce416d916bfa96926bd1ce4616d +F ext/fts5/fts5_storage.c 57c636d87cbb829d6147c8c8bf78fa53b9ebb526 F ext/fts5/fts5_tcl.c 3bf445e66de32137d4693694ff7b1fd6074e32bd F ext/fts5/fts5_test_mi.c e96be827aa8f571031e65e481251dc1981d608bf -F ext/fts5/fts5_tokenize.c 618efe033bceb80c521b1e9ddfd9fee85fb5946e +F ext/fts5/fts5_tokenize.c 504984ac6993323247221eebe3cd55bead01b5f8 F ext/fts5/fts5_unicode2.c 78273fbd588d1d9bd0a7e4e0ccc9207348bae33c F ext/fts5/fts5_varint.c 3f86ce09cab152e3d45490d7586b7ed2e40c13f1 F ext/fts5/fts5_vocab.c 3742d0abfe8aa8c3cb4a7df56aa38f2e3c3fb1c2 @@ -286,7 +286,7 @@ F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c e4655393bb403fa310eef66cc4583d75d4d7fd93 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c 414f4c6b016c4494bfb11713da79f27966871d91 +F src/expr.c 38790e65d1219f2b7dc26458f39a5252fe7c60cd F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 F src/func.c fe50a9ab977acc0bb0fcd46741e0071fa388888e @@ -310,7 +310,7 @@ F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85 F src/mutex_noop.c 9d4309c075ba9cc7249e19412d3d62f7f94839c4 -F src/mutex_unix.c fc54f25b2a750d53b32512a4a728cec28039ae2a +F src/mutex_unix.c 27bb6cc49485ee46711a6580ab7b3f1402211d23 F src/mutex_w32.c 5e6fe1c298fb5a8a15aaed4161d5759311431c17 F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7 F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 34073ce87d88a02313217023ae92e15939192cd9 -R fb37875a5634d72cf8280c2958a6e17e -U drh -Z 5e4e9bf785bd86d0086510037196235b +P b910a3d53769689d9212a06f974ccce54844bbe4 +R 5ab375194afd22e61de829d90abd4fea +U dan +Z 1812011a4512993ca315aa42f142cb2e diff --git a/manifest.uuid b/manifest.uuid index c74bd62134..47ad4e4422 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b910a3d53769689d9212a06f974ccce54844bbe4 \ No newline at end of file +5d44d4a6cf5c6b983cbd846d9bc34251df8f4bc5 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 5c67de1297..d8d36afa54 100644 --- a/src/expr.c +++ b/src/expr.c @@ -888,7 +888,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ assert( ExprHasProperty(p, EP_Reduced)==0 ); memcpy(zAlloc, p, nNewSize); }else{ - int nSize = exprStructSize(p); + u32 nSize = (u32)exprStructSize(p); memcpy(zAlloc, p, nSize); if( nSize Date: Thu, 24 Dec 2015 14:53:27 +0000 Subject: [PATCH 06/37] Avoid a harmless compiler warning on systems where the byteorder cannot be determined at compile-time. FossilOrigin-Name: 7c7b7f26306b6aa6ff35b871ad756f43f5db9838 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqliteInt.h | 10 +++++----- src/utf.c | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 0c1d15f84d..0bcc78c649 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\sharmless\sgcc\scompiler\swarnings.\sMostly\sin\sfts5,\sbut\salso\stwo\sin\sthe\score\scode. -D 2015-12-23T16:42:27.781 +C Avoid\sa\sharmless\scompiler\swarning\son\ssystems\swhere\sthe\sbyteorder\scannot\nbe\sdetermined\sat\scompile-time. +D 2015-12-24T14:53:27.528 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -338,7 +338,7 @@ F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 5a2770eb1fdf3542b9c5ac3fd87836f0d46e1b08 +F src/sqliteInt.h 6e0c1082268e99aa337de1547df32b220e812fb3 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -395,7 +395,7 @@ F src/tokenize.c 5606871a377f390af7040ec3c12e0d183512d785 F src/treeview.c 78842e90c1f71269e7a73a1d4221b6fe360bab66 F src/trigger.c de3ed31ad3218a20d7d7e18bf1b3b734e78bda66 F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 -F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c +F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 F src/vdbe.c 984c2be6691d3f67deb2e6747c2132150d776f32 @@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b910a3d53769689d9212a06f974ccce54844bbe4 -R 5ab375194afd22e61de829d90abd4fea -U dan -Z 1812011a4512993ca315aa42f142cb2e +P 5d44d4a6cf5c6b983cbd846d9bc34251df8f4bc5 +R c0120dd70eca82393527f5b4b745caa6 +U drh +Z 6af8ad4397eb3ff04028cb96b6439a6e diff --git a/manifest.uuid b/manifest.uuid index 47ad4e4422..6d6b0b7302 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d44d4a6cf5c6b983cbd846d9bc34251df8f4bc5 \ No newline at end of file +7c7b7f26306b6aa6ff35b871ad756f43f5db9838 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index a328aff013..18d20b1068 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -692,11 +692,6 @@ typedef INT16_TYPE LogEst; ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined ** at run-time. */ -#ifdef SQLITE_AMALGAMATION -const int sqlite3one = 1; -#else -extern const int sqlite3one; -#endif #if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ @@ -714,6 +709,11 @@ extern const int sqlite3one; # define SQLITE_UTF16NATIVE SQLITE_UTF16BE #endif #if !defined(SQLITE_BYTEORDER) +# ifdef SQLITE_AMALGAMATION + const int sqlite3one = 1; +# else + extern const int sqlite3one; +# endif # define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */ # define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0) # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1) diff --git a/src/utf.c b/src/utf.c index 25f4dadf0c..ee367c1399 100644 --- a/src/utf.c +++ b/src/utf.c @@ -37,13 +37,13 @@ #include #include "vdbeInt.h" -#ifndef SQLITE_AMALGAMATION +#if !defined(SQLITE_AMALGAMATION) && SQLITE_BYTEORDER==0 /* ** The following constant value is used by the SQLITE_BIGENDIAN and ** SQLITE_LITTLEENDIAN macros. */ const int sqlite3one = 1; -#endif /* SQLITE_AMALGAMATION */ +#endif /* SQLITE_AMALGAMATION && SQLITE_BYTEORDER==0 */ /* ** This lookup table is used to help decode the first byte of From ff135ae4c33040e3f5f22b2a1bfe51a06cfa9424 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 30 Dec 2015 01:07:02 +0000 Subject: [PATCH 07/37] Add the json_group_array() and json_group_object() aggregate functions to the JSON1 extension. FossilOrigin-Name: 7f386a9332237100a345035ca213327e21d95855 --- ext/misc/json1.c | 112 +++++++++++++++++++++++++++++++++++++++++++++- manifest | 13 +++--- manifest.uuid | 2 +- test/json103.test | 65 +++++++++++++++++++++++++++ 4 files changed, 184 insertions(+), 8 deletions(-) create mode 100644 test/json103.test diff --git a/ext/misc/json1.c b/ext/misc/json1.c index 61d013ea4b..0bd0baff12 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -1181,7 +1181,7 @@ static void jsonTest1Func( #endif /* SQLITE_DEBUG */ /**************************************************************************** -** SQL function implementations +** Scalar SQL function implementations ****************************************************************************/ /* @@ -1514,6 +1514,102 @@ static void jsonValidFunc( sqlite3_result_int(ctx, rc); } + +/**************************************************************************** +** Aggregate SQL function implementations +****************************************************************************/ +/* +** json_group_array(VALUE) +** +** Return a JSON array composed of all values in the aggregate. +*/ +static void jsonArrayStep( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + JsonString *pStr; + pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); + if( pStr ){ + if( pStr->zBuf==0 ){ + jsonInit(pStr, ctx); + jsonAppendChar(pStr, '['); + }else{ + jsonAppendChar(pStr, ','); + pStr->pCtx = ctx; + } + jsonAppendValue(pStr, argv[0]); + } +} +static void jsonArrayFinal(sqlite3_context *ctx){ + JsonString *pStr; + pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); + if( pStr ){ + pStr->pCtx = ctx; + jsonAppendChar(pStr, ']'); + if( pStr->bErr ){ + sqlite3_result_error_nomem(ctx); + if( !pStr->bStatic ) sqlite3_free(pStr->zBuf); + }else{ + sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, + pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); + pStr->bStatic = 1; + } + }else{ + sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC); + } + sqlite3_result_subtype(ctx, JSON_SUBTYPE); +} + +/* +** json_group_obj(NAME,VALUE) +** +** Return a JSON object composed of all names and values in the aggregate. +*/ +static void jsonObjectStep( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + JsonString *pStr; + const char *z; + u32 n; + pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); + if( pStr ){ + if( pStr->zBuf==0 ){ + jsonInit(pStr, ctx); + jsonAppendChar(pStr, '{'); + }else{ + jsonAppendChar(pStr, ','); + pStr->pCtx = ctx; + } + z = (const char*)sqlite3_value_text(argv[0]); + n = (u32)sqlite3_value_bytes(argv[0]); + jsonAppendString(pStr, z, n); + jsonAppendChar(pStr, ':'); + jsonAppendValue(pStr, argv[1]); + } +} +static void jsonObjectFinal(sqlite3_context *ctx){ + JsonString *pStr; + pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); + if( pStr ){ + jsonAppendChar(pStr, '}'); + if( pStr->bErr ){ + sqlite3_result_error_nomem(ctx); + if( !pStr->bStatic ) sqlite3_free(pStr->zBuf); + }else{ + sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, + pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); + pStr->bStatic = 1; + } + }else{ + sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC); + } + sqlite3_result_subtype(ctx, JSON_SUBTYPE); +} + + #ifndef SQLITE_OMIT_VIRTUALTABLE /**************************************************************************** ** The json_each virtual table @@ -2012,6 +2108,15 @@ int sqlite3Json1Init(sqlite3 *db){ { "json_test1", 1, 0, jsonTest1Func }, #endif }; + static const struct { + const char *zName; + int nArg; + void (*xStep)(sqlite3_context*,int,sqlite3_value**); + void (*xFinal)(sqlite3_context*); + } aAgg[] = { + { "json_group_array", 1, jsonArrayStep, jsonArrayFinal }, + { "json_group_object", 2, jsonObjectStep, jsonObjectFinal }, + }; #ifndef SQLITE_OMIT_VIRTUALTABLE static const struct { const char *zName; @@ -2027,6 +2132,11 @@ int sqlite3Json1Init(sqlite3 *db){ (void*)&aFunc[i].flag, aFunc[i].xFunc, 0, 0); } + for(i=0; i Date: Wed, 30 Dec 2015 13:36:57 +0000 Subject: [PATCH 08/37] Enhance the command-line shell to handle MBCS characters on input and output. FossilOrigin-Name: a0a08b8c0bbd4d71955261f6b7e997701ca68e18 --- manifest | 15 +++-- manifest.uuid | 2 +- src/shell.c | 173 +++++++++++++++++++++++++++++++++----------------- 3 files changed, 124 insertions(+), 66 deletions(-) diff --git a/manifest b/manifest index 20c9426af8..7af5edf4d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sjson_group_array()\sand\sjson_group_object()\saggregate\sfunctions\sto\nthe\sJSON1\sextension. -D 2015-12-30T01:07:02.009 +C Enhance\sthe\scommand-line\sshell\sto\shandle\sMBCS\scharacters\son\sinput\sand\soutput. +D 2015-12-30T13:36:57.561 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -334,7 +334,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f -F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 +F src/shell.c ace08b69cd9702143cf87b5bd20b744a56f832fd F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d @@ -1406,7 +1406,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7c7b7f26306b6aa6ff35b871ad756f43f5db9838 -R 9a71d4f0e52af46677f6902fe927abd2 +P 7f386a9332237100a345035ca213327e21d95855 +R 5acb3019b0f92c56ad605906cb883a23 +T *branch * mbcs-shell +T *sym-mbcs-shell * +T -sym-trunk * U drh -Z d3d1e4137b6ba95a64ac245c7769bfd5 +Z 2dbfb8e7ec032a3367036522c7c27bf6 diff --git a/manifest.uuid b/manifest.uuid index 9a8ba9a337..e3eb9a8dac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7f386a9332237100a345035ca213327e21d95855 \ No newline at end of file +a0a08b8c0bbd4d71955261f6b7e997701ca68e18 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index ff1336a4b7..a6d75176c2 100644 --- a/src/shell.c +++ b/src/shell.c @@ -329,6 +329,13 @@ static int bail_on_error = 0; */ static int stdin_is_interactive = 1; +/* +** On Windows systems we have to know if standard output is a console +** in order to translate UTF-8 into MBCS. The following variable is +** true if translation is required. +*/ +static int stdout_is_console = 1; + /* ** The following is the open SQLite database. We make a pointer ** to this database a static variable so that it can be accessed @@ -430,6 +437,16 @@ static void shellstaticFunc( } +/* +** Compute a string length that is limited to what can be stored in +** lower 30 bits of a 32-bit signed integer. +*/ +static int strlen30(const char *z){ + const char *z2 = z; + while( *z2 ){ z2++; } + return 0x3fffffff & (int)(z2 - z); +} + /* ** This routine reads a line of text from FILE in, stores ** the text in memory obtained from malloc() and returns a pointer @@ -465,6 +482,26 @@ static char *local_getline(char *zLine, FILE *in){ break; } } +#if defined(_WIN32) || defined(WIN32) + /* For interactive input on Windows systems, translate the + ** multi-byte characterset characters into UTF-8. */ + if( stdin_is_interactive ){ + extern char *sqlite3_win32_mbcs_to_utf8(const char*); + char *zTrans = sqlite3_win32_mbcs_to_utf8(zLine); + if( zTrans ){ + int nTrans = strlen30(zTrans)+1; + if( nTrans>nLine ){ + zLine = realloc(zLine, nTrans); + if( zLine==0 ){ + sqlite3_free(zTrans); + return 0; + } + } + memcpy(zLine, zTrans, nTrans); + sqlite3_free(zTrans); + } + } +#endif /* defined(_WIN32) || defined(WIN32) */ return zLine; } @@ -502,6 +539,31 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){ return zResult; } +/* +** Render output like fprintf(). Except, if the output is going to the +** console and if this is running on a Windows machine, translate the +** output from UTF-8 into MBCS. +*/ +#if defined(_WIN32) || defined(WIN32) +void utf8_printf(FILE *out, const char *zFormat, ...){ + va_list ap; + va_start(ap, zFormat); + if( stdout_is_console && out==stdout ){ + extern char *sqlite3_win32_utf8_to_mbcs(const char*); + char *z1 = sqlite3_vmprintf(zFormat, ap); + char *z2 = sqlite3_win32_utf8_to_mbcs(z1); + sqlite3_free(z1); + fputs(z2, out); + sqlite3_free(z2); + }else{ + vfprintf(out, zFormat, ap); + } + va_end(ap); +} +#else +# define utf8_printf fprintf +#endif + /* ** Shell output mode information from before ".explain on", ** saved so that it can be restored by ".explain off" @@ -607,16 +669,6 @@ static const char *modeDescr[] = { */ #define ArraySize(X) (int)(sizeof(X)/sizeof(X[0])) -/* -** Compute a string length that is limited to what can be stored in -** lower 30 bits of a 32-bit signed integer. -*/ -static int strlen30(const char *z){ - const char *z2 = z; - while( *z2 ){ z2++; } - return 0x3fffffff & (int)(z2 - z); -} - /* ** A callback for the sqlite3_log() interface. */ @@ -649,7 +701,7 @@ static void output_quoted_string(FILE *out, const char *z){ if( z[i]=='\'' ) nSingle++; } if( nSingle==0 ){ - fprintf(out,"'%s'",z); + utf8_printf(out,"'%s'",z); }else{ fprintf(out,"'"); while( *z ){ @@ -658,10 +710,10 @@ static void output_quoted_string(FILE *out, const char *z){ fprintf(out,"''"); z++; }else if( z[i]=='\'' ){ - fprintf(out,"%.*s''",i,z); + utf8_printf(out,"%.*s''",i,z); z += i+1; }else{ - fprintf(out,"%s",z); + utf8_printf(out,"%s",z); break; } } @@ -717,7 +769,7 @@ static void output_html_string(FILE *out, const char *z){ && z[i]!='\''; i++){} if( i>0 ){ - fprintf(out,"%.*s",i,z); + utf8_printf(out,"%.*s",i,z); } if( z[i]=='<' ){ fprintf(out,"<"); @@ -768,7 +820,7 @@ static const char needCsvQuote[] = { static void output_csv(ShellState *p, const char *z, int bSep){ FILE *out = p->out; if( z==0 ){ - fprintf(out,"%s",p->nullValue); + utf8_printf(out,"%s",p->nullValue); }else{ int i; int nSep = strlen30(p->colSeparator); @@ -788,11 +840,11 @@ static void output_csv(ShellState *p, const char *z, int bSep){ } putc('"', out); }else{ - fprintf(out, "%s", z); + utf8_printf(out, "%s", z); } } if( bSep ){ - fprintf(p->out, "%s", p->colSeparator); + utf8_printf(p->out, "%s", p->colSeparator); } } @@ -830,9 +882,9 @@ static int shell_callback( int len = strlen30(azCol[i] ? azCol[i] : ""); if( len>w ) w = len; } - if( p->cnt++>0 ) fprintf(p->out, "%s", p->rowSeparator); + if( p->cnt++>0 ) utf8_printf(p->out, "%s", p->rowSeparator); for(i=0; iout,"%*s = %s%s", w, azCol[i], + utf8_printf(p->out,"%*s = %s%s", w, azCol[i], azArg[i] ? azArg[i] : p->nullValue, p->rowSeparator); } break; @@ -858,10 +910,10 @@ static int shell_callback( } if( p->showHeader ){ if( w<0 ){ - fprintf(p->out,"%*.*s%s",-w,-w,azCol[i], + utf8_printf(p->out,"%*.*s%s",-w,-w,azCol[i], i==nArg-1 ? p->rowSeparator : " "); }else{ - fprintf(p->out,"%-*.*s%s",w,w,azCol[i], + utf8_printf(p->out,"%-*.*s%s",w,w,azCol[i], i==nArg-1 ? p->rowSeparator : " "); } } @@ -875,7 +927,8 @@ static int shell_callback( }else{ w = 10; } - fprintf(p->out,"%-*.*s%s",w,w,"-----------------------------------" + fprintf(p->out,"%-*.*s%s",w,w, + "----------------------------------------------------------" "----------------------------------------------------------", i==nArg-1 ? p->rowSeparator : " "); } @@ -899,11 +952,11 @@ static int shell_callback( p->iIndent++; } if( w<0 ){ - fprintf(p->out,"%*.*s%s",-w,-w, + utf8_printf(p->out,"%*.*s%s",-w,-w, azArg[i] ? azArg[i] : p->nullValue, i==nArg-1 ? p->rowSeparator : " "); }else{ - fprintf(p->out,"%-*.*s%s",w,w, + utf8_printf(p->out,"%-*.*s%s",w,w, azArg[i] ? azArg[i] : p->nullValue, i==nArg-1 ? p->rowSeparator : " "); } @@ -914,7 +967,7 @@ static int shell_callback( case MODE_List: { if( p->cnt++==0 && p->showHeader ){ for(i=0; iout,"%s%s",azCol[i], + utf8_printf(p->out,"%s%s",azCol[i], i==nArg-1 ? p->rowSeparator : p->colSeparator); } } @@ -922,13 +975,13 @@ static int shell_callback( for(i=0; inullValue; - fprintf(p->out, "%s", z); + utf8_printf(p->out, "%s", z); if( iout, "%s", p->colSeparator); + utf8_printf(p->out, "%s", p->colSeparator); }else if( p->mode==MODE_Semi ){ - fprintf(p->out, ";%s", p->rowSeparator); + utf8_printf(p->out, ";%s", p->rowSeparator); }else{ - fprintf(p->out, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); } } break; @@ -957,16 +1010,16 @@ static int shell_callback( if( p->cnt++==0 && p->showHeader ){ for(i=0; iout,azCol[i] ? azCol[i] : ""); - if(iout, "%s", p->colSeparator); + if(iout, "%s", p->colSeparator); } - fprintf(p->out, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); } if( azArg==0 ) break; for(i=0; iout, azArg[i] ? azArg[i] : p->nullValue); - if(iout, "%s", p->colSeparator); + if(iout, "%s", p->colSeparator); } - fprintf(p->out, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); break; } case MODE_Csv: { @@ -975,13 +1028,13 @@ static int shell_callback( for(i=0; iout, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); } if( nArg>0 ){ for(i=0; iout, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); } setTextMode(p->out); break; @@ -989,12 +1042,12 @@ static int shell_callback( case MODE_Insert: { p->cnt++; if( azArg==0 ) break; - fprintf(p->out,"INSERT INTO %s",p->zDestTable); + utf8_printf(p->out,"INSERT INTO %s",p->zDestTable); if( p->showHeader ){ fprintf(p->out,"("); for(i=0; i0 ? ",": ""; - fprintf(p->out, "%s%s", zSep, azCol[i]); + utf8_printf(p->out, "%s%s", zSep, azCol[i]); } fprintf(p->out,")"); } @@ -1008,14 +1061,14 @@ static int shell_callback( output_quoted_string(p->out, azArg[i]); }else if( aiType && (aiType[i]==SQLITE_INTEGER || aiType[i]==SQLITE_FLOAT) ){ - fprintf(p->out,"%s%s",zSep, azArg[i]); + utf8_printf(p->out,"%s%s",zSep, azArg[i]); }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){ const void *pBlob = sqlite3_column_blob(p->pStmt, i); int nBlob = sqlite3_column_bytes(p->pStmt, i); if( zSep[0] ) fprintf(p->out,"%s",zSep); output_hex_blob(p->out, pBlob, nBlob); }else if( isNumber(azArg[i], 0) ){ - fprintf(p->out,"%s%s",zSep, azArg[i]); + utf8_printf(p->out,"%s%s",zSep, azArg[i]); }else{ if( zSep[0] ) fprintf(p->out,"%s",zSep); output_quoted_string(p->out, azArg[i]); @@ -1027,17 +1080,17 @@ static int shell_callback( case MODE_Ascii: { if( p->cnt++==0 && p->showHeader ){ for(i=0; i0 ) fprintf(p->out, "%s", p->colSeparator); - fprintf(p->out,"%s",azCol[i] ? azCol[i] : ""); + if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator); + utf8_printf(p->out,"%s",azCol[i] ? azCol[i] : ""); } - fprintf(p->out, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); } if( azArg==0 ) break; for(i=0; i0 ) fprintf(p->out, "%s", p->colSeparator); - fprintf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue); + if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator); + utf8_printf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue); } - fprintf(p->out, "%s", p->rowSeparator); + utf8_printf(p->out, "%s", p->rowSeparator); break; } } @@ -1167,13 +1220,13 @@ static int run_table_dump_query( nResult = sqlite3_column_count(pSelect); while( rc==SQLITE_ROW ){ if( zFirstRow ){ - fprintf(p->out, "%s", zFirstRow); + utf8_printf(p->out, "%s", zFirstRow); zFirstRow = 0; } z = (const char*)sqlite3_column_text(pSelect, 0); - fprintf(p->out, "%s", z); + utf8_printf(p->out, "%s", z); for(i=1; iout, ",%s", sqlite3_column_text(pSelect, i)); + utf8_printf(p->out, ",%s", sqlite3_column_text(pSelect, i)); } if( z==0 ) z = ""; while( z[0] && (z[0]!='-' || z[1]!='-') ) z++; @@ -1361,7 +1414,7 @@ static void display_scanstats( sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit); sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst); sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain); - fprintf(pArg->out, "Loop %2d: %s\n", n, zExplain); + utf8_printf(pArg->out, "Loop %2d: %s\n", n, zExplain); rEstLoop *= rEst; fprintf(pArg->out, " nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n", @@ -1522,7 +1575,7 @@ static int shell_exec( /* echo the sql statement if echo on */ if( pArg && pArg->echoOn ){ const char *zStmtSql = sqlite3_sql(pStmt); - fprintf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql); + utf8_printf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql); } /* Show the EXPLAIN QUERY PLAN if .eqp is on */ @@ -1536,7 +1589,7 @@ static int shell_exec( fprintf(pArg->out,"--EQP-- %d,", sqlite3_column_int(pExplain, 0)); fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1)); fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2)); - fprintf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3)); + utf8_printf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3)); } } sqlite3_finalize(pExplain); @@ -1677,11 +1730,11 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){ "INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)" "VALUES('table','%q','%q',0,'%q');", zTable, zTable, zSql); - fprintf(p->out, "%s\n", zIns); + utf8_printf(p->out, "%s\n", zIns); sqlite3_free(zIns); return 0; }else{ - fprintf(p->out, "%s;\n", zSql); + utf8_printf(p->out, "%s;\n", zSql); } if( strcmp(zType, "table")==0 ){ @@ -2126,7 +2179,7 @@ static void sql_trace_callback(void *pArg, const char *z){ if( f ){ int i = (int)strlen(z); while( i>0 && z[i-1]==';' ){ i--; } - fprintf(f, "%.*s;\n", i, z); + utf8_printf(f, "%.*s;\n", i, z); } } @@ -2609,7 +2662,7 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){ char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab); int val = db_int(p, zSql); sqlite3_free(zSql); - fprintf(p->out, "%-20s %d\n", aQuery[i].zName, val); + utf8_printf(p->out, "%-20s %d\n", aQuery[i].zName, val); } sqlite3_free(zSchemaTab); return 0; @@ -3449,7 +3502,7 @@ static int do_meta_command(char *zLine, ShellState *p){ int i; for(i=1; i1 ) fprintf(p->out, " "); - fprintf(p->out, "%s", azArg[i]); + utf8_printf(p->out, "%s", azArg[i]); } fprintf(p->out, "\n"); }else @@ -3643,7 +3696,7 @@ static int do_meta_command(char *zLine, ShellState *p){ int i, v; for(i=1; iout, "%s: %d 0x%x\n", azArg[i], v, v); + utf8_printf(p->out, "%s: %d 0x%x\n", azArg[i], v, v); } } if( strncmp(azArg[0]+9, "integer", n-9)==0 ){ @@ -3652,7 +3705,7 @@ static int do_meta_command(char *zLine, ShellState *p){ char zBuf[200]; v = integerValue(azArg[i]); sqlite3_snprintf(sizeof(zBuf),zBuf,"%s: %lld 0x%llx\n", azArg[i],v,v); - fprintf(p->out, "%s", zBuf); + utf8_printf(p->out, "%s", zBuf); } } }else @@ -3826,7 +3879,8 @@ static int do_meta_command(char *zLine, ShellState *p){ for(i=0; iout, "%s%-*s", zSp, maxlen, azResult[j] ? azResult[j]:""); + utf8_printf(p->out, "%s%-*s", zSp, maxlen, + azResult[j] ? azResult[j]:""); } fprintf(p->out, "\n"); } @@ -4547,6 +4601,7 @@ int SQLITE_CDECL main(int argc, char **argv){ Argv0 = argv[0]; main_init(&data); stdin_is_interactive = isatty(0); + stdout_is_console = isatty(1); /* Make sure we have a valid signal handler early, before anything ** else is done. From 31d175dde485bc4b6b573ef8ca8218378468e926 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 30 Dec 2015 14:06:22 +0000 Subject: [PATCH 09/37] Remove unnecessary tests from the LIKE pattern matcher. Slightly faster and slightly smaller, and it should also now works with EBCDIC. FossilOrigin-Name: 0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 20c9426af8..e2ed7e0ab2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sjson_group_array()\sand\sjson_group_object()\saggregate\sfunctions\sto\nthe\sJSON1\sextension. -D 2015-12-30T01:07:02.009 +C Remove\sunnecessary\stests\sfrom\sthe\sLIKE\spattern\smatcher.\s\sSlightly\sfaster\sand\nslightly\ssmaller,\sand\sit\sshould\salso\snow\sworks\swith\sEBCDIC. +D 2015-12-30T14:06:22.463 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -289,7 +289,7 @@ F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c 38790e65d1219f2b7dc26458f39a5252fe7c60cd F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 -F src/func.c fe50a9ab977acc0bb0fcd46741e0071fa388888e +F src/func.c cf5e10af9125b245f1b962e8ba4d520a37818795 F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7c7b7f26306b6aa6ff35b871ad756f43f5db9838 -R 9a71d4f0e52af46677f6902fe927abd2 +P 7f386a9332237100a345035ca213327e21d95855 +R 7d1c2a289a785f636ce602a7472437a7 U drh -Z d3d1e4137b6ba95a64ac245c7769bfd5 +Z 72bb50259efca9e2c772b83f9c123827 diff --git a/manifest.uuid b/manifest.uuid index 9a8ba9a337..fbd1be6203 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7f386a9332237100a345035ca213327e21d95855 \ No newline at end of file +0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 3fbd2b736b..ad4cf73c31 100644 --- a/src/func.c +++ b/src/func.c @@ -747,7 +747,7 @@ static int patternCompare( } c2 = Utf8Read(zString); if( c==c2 ) continue; - if( noCase && c<0x80 && c2<0x80 && sqlite3Tolower(c)==sqlite3Tolower(c2) ){ + if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) ){ continue; } if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue; From 0472af91ec58d0d61101fb9f93970b774e25313a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 30 Dec 2015 15:18:16 +0000 Subject: [PATCH 10/37] Simplification to the xfer-optimization logic. FossilOrigin-Name: f35ba018da843897acca58f70541b940598bc271 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/insert.c | 18 ++---------------- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index e2ed7e0ab2..ca0b8299dc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunnecessary\stests\sfrom\sthe\sLIKE\spattern\smatcher.\s\sSlightly\sfaster\sand\nslightly\ssmaller,\sand\sit\sshould\salso\snow\sworks\swith\sEBCDIC. -D 2015-12-30T14:06:22.463 +C Simplification\sto\sthe\sxfer-optimization\slogic. +D 2015-12-30T15:18:16.130 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -294,7 +294,7 @@ F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 4622e544a6f054b8f36bb06ae85f4aa09fcd6b5b +F src/insert.c 756ae3281e465e5d489a3409ccb4f1041069d530 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7f386a9332237100a345035ca213327e21d95855 -R 7d1c2a289a785f636ce602a7472437a7 +P 0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 +R 5e4c4e8e37aad85efb78266b71a902b5 U drh -Z 72bb50259efca9e2c772b83f9c123827 +Z 91b12f25ba51396a818d59a327f065c9 diff --git a/manifest.uuid b/manifest.uuid index fbd1be6203..3a118b9b08 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 \ No newline at end of file +f35ba018da843897acca58f70541b940598bc271 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 7ac2a2559d..858bcf27af 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1709,20 +1709,6 @@ int sqlite3_xferopt_count; #ifndef SQLITE_OMIT_XFER_OPT -/* -** Check to collation names to see if they are compatible. -*/ -static int xferCompatibleCollation(const char *z1, const char *z2){ - if( z1==0 ){ - return z2==0; - } - if( z2==0 ){ - return 0; - } - return sqlite3StrICmp(z1, z2)==0; -} - - /* ** Check to see if index pSrc is compatible as a source of data ** for index pDest in an insert transfer optimization. The rules @@ -1758,7 +1744,7 @@ static int xferCompatibleIndex(Index *pDest, Index *pSrc){ if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){ return 0; /* Different sort orders */ } - if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){ + if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){ return 0; /* Different collating sequences */ } } @@ -1919,7 +1905,7 @@ static int xferOptimization( if( pDestCol->affinity!=pSrcCol->affinity ){ return 0; /* Affinity must be the same on all columns */ } - if( !xferCompatibleCollation(pDestCol->zColl, pSrcCol->zColl) ){ + if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){ return 0; /* Collating sequence must be the same on all columns */ } if( pDestCol->notNull && !pSrcCol->notNull ){ From f19aa5fa6f1cf6bcb11759a663bc44b10de87c49 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 30 Dec 2015 16:51:20 +0000 Subject: [PATCH 11/37] Changes to the way that the default BINARY collating sequence is recorded result in a slightly smaller and slightly faster executable. More work could be done to make this cleaner. FossilOrigin-Name: 2081d75767dc590b4c8457e5f8e5f18ba5f8eaa7 --- manifest | 26 +++++++++++++------------- manifest.uuid | 2 +- src/build.c | 17 ++++++++--------- src/fkey.c | 6 ++---- src/global.c | 5 +++++ src/insert.c | 7 ++++--- src/main.c | 11 +++++------ src/sqliteInt.h | 3 ++- src/where.c | 8 ++++---- src/whereInt.h | 2 +- 10 files changed, 45 insertions(+), 42 deletions(-) diff --git a/manifest b/manifest index ca0b8299dc..d2e54f9d90 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sto\sthe\sxfer-optimization\slogic. -D 2015-12-30T15:18:16.130 +C Changes\sto\sthe\sway\sthat\sthe\sdefault\sBINARY\scollating\ssequence\sis\srecorded\nresult\sin\sa\sslightly\ssmaller\sand\sslightly\sfaster\sexecutable.\s\sMore\swork\scould\nbe\sdone\sto\smake\sthis\scleaner. +D 2015-12-30T16:51:20.187 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -279,7 +279,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 84ede51e371a11c3dbb3e24ccc5e3e99594a6c00 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 -F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b +F src/build.c 5a8611a01cbf67c736d81304e054ec361ef8963d F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -288,17 +288,17 @@ F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da F src/expr.c 38790e65d1219f2b7dc26458f39a5252fe7c60cd F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 +F src/fkey.c e18b3dff7d47c7bcac5ac4fc178a89b9fd322b44 F src/func.c cf5e10af9125b245f1b962e8ba4d520a37818795 -F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9 +F src/global.c bd5a0af3f30b0c01be6db756c626cd3c33a3d260 F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5 F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 756ae3281e465e5d489a3409ccb4f1041069d530 +F src/insert.c 6b45cc86967da11aa024d034745f93f66d53f650 F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b -F src/main.c 2f33510a6a392c606fe64964e695e55ad124242f +F src/main.c b9641a4f650230bfc5dbb0bebf7b33ff4d27586a F src/malloc.c 8f787669e79de26efc42272b5797bc00fff527c6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b @@ -338,7 +338,7 @@ F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 6e0c1082268e99aa337de1547df32b220e812fb3 +F src/sqliteInt.h 526c8514d0cb0768d014d04445c6eebd1d0b1a2c F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -412,8 +412,8 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 974928c988681c5157202c79dd9f26afaa7b5086 F src/wal.h 907943dfdef10b583e81906679a347e0ec6f1b1b F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba -F src/where.c b18edbb9e5afabb77f4f27550c471c5c824e0fe7 -F src/whereInt.h e20801d89e34de1912bb6a3babb30c390da27add +F src/where.c c6d3d2f6af57d574a7365ee2b225a5024f2a6bec +F src/whereInt.h 78b6b4de94db84aecbdc07fe3e38f648eb391e9a F src/wherecode.c dfbfe198e418b01f208b489e088edd230c91a4e7 F src/whereexpr.c eebba8340c90de73b3d3bbe8c43b84559b8e6e2c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6 -R 5e4c4e8e37aad85efb78266b71a902b5 +P f35ba018da843897acca58f70541b940598bc271 +R 73bd359208653598962819ad055e1d11 U drh -Z 91b12f25ba51396a818d59a327f065c9 +Z 53e385ce34cbe66e9c94953f6b43b3a2 diff --git a/manifest.uuid b/manifest.uuid index 3a118b9b08..9d879ff1c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f35ba018da843897acca58f70541b940598bc271 \ No newline at end of file +2081d75767dc590b4c8457e5f8e5f18ba5f8eaa7 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 765196f821..5d6201a533 100644 --- a/src/build.c +++ b/src/build.c @@ -1635,7 +1635,7 @@ static int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){ zExtra = sqlite3DbMallocZero(db, nByte); if( zExtra==0 ) return SQLITE_NOMEM; memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn); - pIdx->azColl = (char**)zExtra; + pIdx->azColl = (const char**)zExtra; zExtra += sizeof(char*)*N; memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn); pIdx->aiColumn = (i16*)zExtra; @@ -1816,7 +1816,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ if( !hasColumn(pPk->aiColumn, j, i) ){ assert( jnColumn ); pPk->aiColumn[j] = i; - pPk->azColl[j] = "BINARY"; + pPk->azColl[j] = sqlite3StrBINARY; j++; } } @@ -2866,7 +2866,7 @@ Index *sqlite3AllocateIndexObject( p = sqlite3DbMallocZero(db, nByte + nExtra); if( p ){ char *pExtra = ((char*)p)+ROUND8(sizeof(Index)); - p->azColl = (char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol); + p->azColl = (const char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol); p->aiRowLogEst = (LogEst*)pExtra; pExtra += sizeof(LogEst)*(nCol+1); p->aiColumn = (i16*)pExtra; pExtra += sizeof(i16)*nCol; p->aSortOrder = (u8*)pExtra; @@ -3143,7 +3143,7 @@ Index *sqlite3CreateIndex( for(i=0, pListItem=pList->a; inExpr; i++, pListItem++){ Expr *pCExpr; /* The i-th index expression */ int requestedSortOrder; /* ASC or DESC on the i-th expression */ - char *zColl; /* Collation sequence name */ + const char *zColl; /* Collation sequence name */ sqlite3StringToId(pListItem->pExpr); sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0); @@ -3189,7 +3189,7 @@ Index *sqlite3CreateIndex( }else if( j>=0 ){ zColl = pTab->aCol[j].zColl; } - if( !zColl ) zColl = "BINARY"; + if( !zColl ) zColl = sqlite3StrBINARY; if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){ goto exit_create_index; } @@ -3218,7 +3218,7 @@ Index *sqlite3CreateIndex( assert( i==pIndex->nColumn ); }else{ pIndex->aiColumn[i] = XN_ROWID; - pIndex->azColl[i] = "BINARY"; + pIndex->azColl[i] = sqlite3StrBINARY; } sqlite3DefaultRowEst(pIndex); if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex); @@ -4342,9 +4342,8 @@ KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){ if( pKey ){ assert( sqlite3KeyInfoIsWriteable(pKey) ); for(i=0; iazColl[i]; - assert( zColl!=0 ); - pKey->aColl[i] = strcmp(zColl,"BINARY")==0 ? 0 : + const char *zColl = pIdx->azColl[i]; + pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 : sqlite3LocateCollSeq(pParse, zColl); pKey->aSortOrder[i] = pIdx->aSortOrder[i]; } diff --git a/src/fkey.c b/src/fkey.c index b55e2a9813..2abd06c693 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -249,7 +249,7 @@ int sqlite3FkLocateIndex( int i, j; for(i=0; iaiColumn[i]; /* Index of column in parent tbl */ - char *zDfltColl; /* Def. collation for column */ + const char *zDfltColl; /* Def. collation for column */ char *zIdxCol; /* Name of indexed column */ if( iCol<0 ) break; /* No foreign keys against expression indexes */ @@ -258,9 +258,7 @@ int sqlite3FkLocateIndex( ** the default collation sequence for the column, this index is ** unusable. Bail out early in this case. */ zDfltColl = pParent->aCol[iCol].zColl; - if( !zDfltColl ){ - zDfltColl = "BINARY"; - } + if( !zDfltColl ) zDfltColl = sqlite3StrBINARY; if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break; zIdxCol = pParent->aCol[iCol].zName; diff --git a/src/global.c b/src/global.c index ef4fe56ae1..64966b35d7 100644 --- a/src/global.c +++ b/src/global.c @@ -260,3 +260,8 @@ int sqlite3PendingByte = 0x40000000; ** the vdbe.c file. */ const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER; + +/* +** Name of the default collating sequence +*/ +const char sqlite3StrBINARY[] = "BINARY"; diff --git a/src/insert.c b/src/insert.c index 858bcf27af..3e4aac8f4d 100644 --- a/src/insert.c +++ b/src/insert.c @@ -2052,9 +2052,10 @@ static int xferOptimization( ** a VACUUM command. In that case keys may not be written in strictly ** sorted order. */ for(i=0; inColumn; i++){ - char *zColl = pSrcIdx->azColl[i]; - assert( zColl!=0 ); - if( sqlite3_stricmp("BINARY", zColl) ) break; + const char *zColl = pSrcIdx->azColl[i]; + assert( sqlite3_stricmp(sqlite3StrBINARY, zColl)!=0 + || sqlite3StrBINARY==zColl ); + if( sqlite3_stricmp(sqlite3StrBINARY, zColl) ) break; } if( i==pSrcIdx->nColumn ){ idxInsFlags = OPFLAG_USESEEKRESULT; diff --git a/src/main.c b/src/main.c index 5b2130511e..8b75e71500 100644 --- a/src/main.c +++ b/src/main.c @@ -2829,9 +2829,9 @@ static int openDatabase( ** EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating ** functions: */ - createCollation(db, "BINARY", SQLITE_UTF8, 0, binCollFunc, 0); - createCollation(db, "BINARY", SQLITE_UTF16BE, 0, binCollFunc, 0); - createCollation(db, "BINARY", SQLITE_UTF16LE, 0, binCollFunc, 0); + createCollation(db, sqlite3StrBINARY, SQLITE_UTF8, 0, binCollFunc, 0); + createCollation(db, sqlite3StrBINARY, SQLITE_UTF16BE, 0, binCollFunc, 0); + createCollation(db, sqlite3StrBINARY, SQLITE_UTF16LE, 0, binCollFunc, 0); createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0); createCollation(db, "RTRIM", SQLITE_UTF8, (void*)1, binCollFunc, 0); if( db->mallocFailed ){ @@ -2840,7 +2840,7 @@ static int openDatabase( /* EVIDENCE-OF: R-08308-17224 The default collating function for all ** strings is BINARY. */ - db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0); + db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0); assert( db->pDfltColl!=0 ); /* Parse the filename/URI argument. */ @@ -3340,7 +3340,7 @@ int sqlite3_table_column_metadata( primarykey = 1; } if( !zCollSeq ){ - zCollSeq = "BINARY"; + zCollSeq = sqlite3StrBINARY; } error_out: @@ -3948,4 +3948,3 @@ void sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){ sqlite3_free(pSnapshot); } #endif /* SQLITE_ENABLE_SNAPSHOT */ - diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 18d20b1068..99a42d152d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1932,7 +1932,7 @@ struct Index { Index *pNext; /* The next index associated with the same table */ Schema *pSchema; /* Schema containing this index */ u8 *aSortOrder; /* for each column: True==DESC, False==ASC */ - char **azColl; /* Array of collation sequence names for index */ + const char **azColl; /* Array of collation sequence names for index */ Expr *pPartIdxWhere; /* WHERE clause for partial indices */ ExprList *aColExpr; /* Column expressions */ int tnum; /* DB Page containing root of this index */ @@ -3699,6 +3699,7 @@ int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **); void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); #ifndef SQLITE_AMALGAMATION extern const unsigned char sqlite3OpcodeProperty[]; +extern const char sqlite3StrBINARY[]; extern const unsigned char sqlite3UpperToLower[]; extern const unsigned char sqlite3CtypeMap[]; extern const Token sqlite3IntTokens[]; diff --git a/src/where.c b/src/where.c index 7d68664598..e86e26ef1a 100644 --- a/src/where.c +++ b/src/where.c @@ -718,7 +718,7 @@ static void constructAutomaticIndex( idxCols |= cMask; pIdx->aiColumn[n] = pTerm->u.leftColumn; pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); - pIdx->azColl[n] = pColl ? pColl->zName : "BINARY"; + pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY; n++; } } @@ -730,20 +730,20 @@ static void constructAutomaticIndex( for(i=0; iaiColumn[n] = i; - pIdx->azColl[n] = "BINARY"; + pIdx->azColl[n] = sqlite3StrBINARY; n++; } } if( pSrc->colUsed & MASKBIT(BMS-1) ){ for(i=BMS-1; inCol; i++){ pIdx->aiColumn[n] = i; - pIdx->azColl[n] = "BINARY"; + pIdx->azColl[n] = sqlite3StrBINARY; n++; } } assert( n==nKeyCol ); pIdx->aiColumn[n] = XN_ROWID; - pIdx->azColl[n] = "BINARY"; + pIdx->azColl[n] = sqlite3StrBINARY; /* Create the automatic index */ assert( pLevel->iIdxCur>=0 ); diff --git a/src/whereInt.h b/src/whereInt.h index 63d2d71cb4..1a189980ef 100644 --- a/src/whereInt.h +++ b/src/whereInt.h @@ -288,7 +288,7 @@ struct WhereTerm { struct WhereScan { WhereClause *pOrigWC; /* Original, innermost WhereClause */ WhereClause *pWC; /* WhereClause currently being scanned */ - char *zCollName; /* Required collating sequence, if not NULL */ + const char *zCollName; /* Required collating sequence, if not NULL */ Expr *pIdxExpr; /* Search for this index expression */ char idxaff; /* Must match this affinity, if zCollName!=NULL */ unsigned char nEquiv; /* Number of entries in aEquiv[] */ From e5520e2f0648268bfd1ff3677fc83752150de34a Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 31 Dec 2015 04:34:26 +0000 Subject: [PATCH 12/37] Small size and performance optimization to the VDBE comparison opcodes. FossilOrigin-Name: 7a0b9413fa94d3f4fa9751ddf9b213a1238954f1 --- manifest | 17 ++++++++--------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- src/vdbe.c | 13 ++++++------- src/vdbeaux.c | 2 +- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 4fb51ec6d3..63b6375876 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reduce\sthe\ssize\sof\sthe\sCellInfo\sobject\sfrom\s32\sto\s24\sbytes\son\s64-bit\smachines,\nfor\sa\ssmall\sperformance\sincrease\sand\slibrary\ssize\sreduction. -D 2015-12-30T18:18:46.481 +C Small\ssize\sand\sperformance\soptimization\sto\sthe\sVDBE\scomparison\sopcodes. +D 2015-12-31T04:34:26.528 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -338,7 +338,7 @@ F src/shell.c ace08b69cd9702143cf87b5bd20b744a56f832fd F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 526c8514d0cb0768d014d04445c6eebd1d0b1a2c +F src/sqliteInt.h d68c05b69767224eea116f07793a531286946776 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -398,11 +398,11 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 984c2be6691d3f67deb2e6747c2132150d776f32 +F src/vdbe.c 39d7628bb8eed10a5378adcf97cca6dce7829a8f F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 68082d9991fc1b8625d34c8b5db1775c9dee426e +F src/vdbeaux.c ca523180c128dc6c64894efc61eb14374117c864 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,8 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3d81dfe3bc5ca9588b7796769d9be7a182f38b1c 7850715406458a61cff9eba5ad915f61f6d99482 -R 53c67154b7bbcd33ca0c18e39c81df1f -T +closed 7850715406458a61cff9eba5ad915f61f6d99482 +P 6a4cfc7ab62046eb718ce59eff6b632f239312ac +R 38bdbc546325a042578b5eb533fe5e2f U drh -Z f674907b91bbe0647e025dbc39f72b55 +Z 5aa34f553c2d2033c492b62e2956faac diff --git a/manifest.uuid b/manifest.uuid index 4b77ee57d3..7de58c7d75 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a4cfc7ab62046eb718ce59eff6b632f239312ac \ No newline at end of file +7a0b9413fa94d3f4fa9751ddf9b213a1238954f1 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 99a42d152d..299fe8647d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1522,7 +1522,7 @@ struct Column { char *zColl; /* Collating sequence. If NULL, use the default */ u8 notNull; /* An OE_ code for handling a NOT NULL constraint */ char affinity; /* One of the SQLITE_AFF_... values */ - u8 szEst; /* Estimated size of this column. INT==1 */ + u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */ u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */ }; diff --git a/src/vdbe.c b/src/vdbe.c index 894758a01c..5021720c54 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1996,21 +1996,21 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ /* Neither operand is NULL. Do a comparison. */ affinity = pOp->p5 & SQLITE_AFF_MASK; if( affinity>=SQLITE_AFF_NUMERIC ){ - if( (pIn1->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ + if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ applyNumericAffinity(pIn1,0); } - if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ + if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ applyNumericAffinity(pIn3,0); } }else if( affinity==SQLITE_AFF_TEXT ){ - if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){ + if( (flags1 & MEM_Str)==0 && (flags1 & (MEM_Int|MEM_Real))!=0 ){ testcase( pIn1->flags & MEM_Int ); testcase( pIn1->flags & MEM_Real ); sqlite3VdbeMemStringify(pIn1, encoding, 1); testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); } - if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){ + if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){ testcase( pIn3->flags & MEM_Int ); testcase( pIn3->flags & MEM_Real ); sqlite3VdbeMemStringify(pIn3, encoding, 1); @@ -2019,15 +2019,14 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ } } assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); - if( pIn1->flags & MEM_Zero ){ + if( flags1 & MEM_Zero ){ sqlite3VdbeMemExpandBlob(pIn1); flags1 &= ~MEM_Zero; } - if( pIn3->flags & MEM_Zero ){ + if( flags3 & MEM_Zero ){ sqlite3VdbeMemExpandBlob(pIn3); flags3 &= ~MEM_Zero; } - if( db->mallocFailed ) goto no_mem; res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl); } switch( pOp->opcode ){ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index a266177ac5..10353e839f 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3748,7 +3748,7 @@ int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){ return -1; } - assert( pMem1->enc==pMem2->enc ); + assert( pMem1->enc==pMem2->enc || pMem1->db->mallocFailed ); assert( pMem1->enc==SQLITE_UTF8 || pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE ); From e6110505c91d8f1f6b6e34c069bc8fdd4a104c99 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 31 Dec 2015 15:34:03 +0000 Subject: [PATCH 13/37] Fix harmless compiler warnings associated with SQLITE_ENABLE_HIDDEN_COLUMNS. FossilOrigin-Name: 9c392c1019ee15f27c8e05b41246d2844f91f6c0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 4 ++-- src/sqliteInt.h | 6 +++++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 63b6375876..74fac31c3e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\ssize\sand\sperformance\soptimization\sto\sthe\sVDBE\scomparison\sopcodes. -D 2015-12-31T04:34:26.528 +C Fix\sharmless\scompiler\swarnings\sassociated\swith\sSQLITE_ENABLE_HIDDEN_COLUMNS. +D 2015-12-31T15:34:03.678 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -279,7 +279,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 5ac3f868d4f20a67f0f00a1014940f902b511558 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 -F src/build.c 5a8611a01cbf67c736d81304e054ec361ef8963d +F src/build.c 249e9605fc423feeca0316e7018df04da8c345d5 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -338,7 +338,7 @@ F src/shell.c ace08b69cd9702143cf87b5bd20b744a56f832fd F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h d68c05b69767224eea116f07793a531286946776 +F src/sqliteInt.h 92f83ab4612141f95cdd663ea55fa4528f3f8c2a F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6a4cfc7ab62046eb718ce59eff6b632f239312ac -R 38bdbc546325a042578b5eb533fe5e2f +P 7a0b9413fa94d3f4fa9751ddf9b213a1238954f1 +R 793126e19a875ee34b3c925c6d9cf329 U drh -Z 5aa34f553c2d2033c492b62e2956faac +Z 7a54e045f07d4dcaeff2de7160303dce diff --git a/manifest.uuid b/manifest.uuid index 7de58c7d75..6672b8e8dd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7a0b9413fa94d3f4fa9751ddf9b213a1238954f1 \ No newline at end of file +9c392c1019ee15f27c8e05b41246d2844f91f6c0 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 5d6201a533..553e249fa4 100644 --- a/src/build.c +++ b/src/build.c @@ -1047,15 +1047,15 @@ begin_table_error: /* Set properties of a table column based on the (magical) ** name of the column. */ -void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ #if SQLITE_ENABLE_HIDDEN_COLUMNS +void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){ pCol->colFlags |= COLFLAG_HIDDEN; }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){ pTab->tabFlags |= TF_OOOHidden; } -#endif } +#endif /* diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 299fe8647d..e1fe6dae79 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3348,7 +3348,11 @@ void sqlite3OpenMasterTable(Parse *, int); Index *sqlite3PrimaryKeyIndex(Table*); i16 sqlite3ColumnOfIndex(Index*, i16); void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); -void sqlite3ColumnPropertiesFromName(Table*, Column*); +#if SQLITE_ENABLE_HIDDEN_COLUMNS + void sqlite3ColumnPropertiesFromName(Table*, Column*); +#else +# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */ +#endif void sqlite3AddColumn(Parse*,Token*); void sqlite3AddNotNull(Parse*, int); void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); From 5905f86b338500b3360342871d6aaf5fcd48f612 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 31 Dec 2015 19:04:42 +0000 Subject: [PATCH 14/37] Fix harmless compiler warning seen with MSVC. FossilOrigin-Name: 98ec778daac835d9ae103f6460b7d897981a5dd6 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/build.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 74fac31c3e..3b002abdc1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sassociated\swith\sSQLITE_ENABLE_HIDDEN_COLUMNS. -D 2015-12-31T15:34:03.678 +C Fix\sharmless\scompiler\swarning\sseen\swith\sMSVC. +D 2015-12-31T19:04:42.799 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -279,7 +279,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 5ac3f868d4f20a67f0f00a1014940f902b511558 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 -F src/build.c 249e9605fc423feeca0316e7018df04da8c345d5 +F src/build.c 1c9fb552148ee8f9234435a38833f8fca2081a71 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7a0b9413fa94d3f4fa9751ddf9b213a1238954f1 -R 793126e19a875ee34b3c925c6d9cf329 -U drh -Z 7a54e045f07d4dcaeff2de7160303dce +P 9c392c1019ee15f27c8e05b41246d2844f91f6c0 +R 55161c92d22f1816c3b9c126a24128f9 +U mistachkin +Z b7a8bb994d81380f55ad5f17330fd4b6 diff --git a/manifest.uuid b/manifest.uuid index 6672b8e8dd..60606fbdfc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9c392c1019ee15f27c8e05b41246d2844f91f6c0 \ No newline at end of file +98ec778daac835d9ae103f6460b7d897981a5dd6 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 553e249fa4..ffefead9db 100644 --- a/src/build.c +++ b/src/build.c @@ -444,7 +444,7 @@ static void freeIndex(sqlite3 *db, Index *p){ sqlite3ExprDelete(db, p->pPartIdxWhere); sqlite3ExprListDelete(db, p->aColExpr); sqlite3DbFree(db, p->zColAff); - if( p->isResized ) sqlite3DbFree(db, p->azColl); + if( p->isResized ) sqlite3DbFree(db, (void *)p->azColl); #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 sqlite3_free(p->aiRowEst); #endif From aae280ef8b69b38a56aabdd322d59fc8686c7b82 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 31 Dec 2015 19:06:24 +0000 Subject: [PATCH 15/37] In the shell, use utf8_printf() when any string formatting is present and raw_printf() otherwise. FossilOrigin-Name: 8cf01fff232d15d3c7b7b62b2d890d983e1945f2 --- manifest | 12 +- manifest.uuid | 2 +- src/shell.c | 535 ++++++++++++++++++++++++++------------------------ 3 files changed, 286 insertions(+), 263 deletions(-) diff --git a/manifest b/manifest index 3b002abdc1..3c7f5db48d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning\sseen\swith\sMSVC. -D 2015-12-31T19:04:42.799 +C In\sthe\sshell,\suse\sutf8_printf()\swhen\sany\sstring\sformatting\sis\spresent\sand\sraw_printf()\sotherwise. +D 2015-12-31T19:06:24.721 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -334,7 +334,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f -F src/shell.c ace08b69cd9702143cf87b5bd20b744a56f832fd +F src/shell.c 8d152e833c3b79825978deb83175234749c5cdf3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9c392c1019ee15f27c8e05b41246d2844f91f6c0 -R 55161c92d22f1816c3b9c126a24128f9 +P 98ec778daac835d9ae103f6460b7d897981a5dd6 +R cd1e993dc14f9af3b107557468145aaf U mistachkin -Z b7a8bb994d81380f55ad5f17330fd4b6 +Z 770ade254ba97d3649a2f5b30f5d6fd8 diff --git a/manifest.uuid b/manifest.uuid index 60606fbdfc..4302de3a4a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -98ec778daac835d9ae103f6460b7d897981a5dd6 \ No newline at end of file +8cf01fff232d15d3c7b7b62b2d890d983e1945f2 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index a6d75176c2..ecb591a32a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -382,7 +382,7 @@ static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){ va_start(ap, zFormat); z = sqlite3_vmprintf(zFormat, ap); va_end(ap); - fprintf(iotrace, "%s", z); + utf8_printf(iotrace, "%s", z); sqlite3_free(z); } #endif @@ -548,7 +548,7 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){ void utf8_printf(FILE *out, const char *zFormat, ...){ va_list ap; va_start(ap, zFormat); - if( stdout_is_console && out==stdout ){ + if( stdout_is_console && (out==stdout || out==stderr) ){ extern char *sqlite3_win32_utf8_to_mbcs(const char*); char *z1 = sqlite3_vmprintf(zFormat, ap); char *z2 = sqlite3_win32_utf8_to_mbcs(z1); @@ -560,10 +560,18 @@ void utf8_printf(FILE *out, const char *zFormat, ...){ } va_end(ap); } -#else +#elif !defined(utf8_printf) # define utf8_printf fprintf #endif +/* +** Render output like fprintf(). This should not be used on anything that +** includes string formatting (e.g. "%s"). +*/ +#if !defined(raw_printf) +# define raw_printf fprintf +#endif + /* ** Shell output mode information from before ".explain on", ** saved so that it can be restored by ".explain off" @@ -675,7 +683,7 @@ static const char *modeDescr[] = { static void shellLog(void *pArg, int iErrCode, const char *zMsg){ ShellState *p = (ShellState*)pArg; if( p->pLog==0 ) return; - fprintf(p->pLog, "(%d) %s\n", iErrCode, zMsg); + utf8_printf(p->pLog, "(%d) %s\n", iErrCode, zMsg); fflush(p->pLog); } @@ -685,9 +693,9 @@ static void shellLog(void *pArg, int iErrCode, const char *zMsg){ static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){ int i; char *zBlob = (char *)pBlob; - fprintf(out,"X'"); - for(i=0; i' ){ - fprintf(out,">"); + raw_printf(out,">"); }else if( z[i]=='\"' ){ - fprintf(out,"""); + raw_printf(out,"""); }else if( z[i]=='\'' ){ - fprintf(out,"'"); + raw_printf(out,"'"); }else{ break; } @@ -927,7 +935,7 @@ static int shell_callback( }else{ w = 10; } - fprintf(p->out,"%-*.*s%s",w,w, + utf8_printf(p->out,"%-*.*s%s",w,w, "----------------------------------------------------------" "----------------------------------------------------------", i==nArg-1 ? p->rowSeparator : " "); @@ -947,7 +955,7 @@ static int shell_callback( } if( i==1 && p->aiIndent && p->pStmt ){ if( p->iIndentnIndent ){ - fprintf(p->out, "%*.s", p->aiIndent[p->iIndent], ""); + utf8_printf(p->out, "%*.s", p->aiIndent[p->iIndent], ""); } p->iIndent++; } @@ -988,22 +996,22 @@ static int shell_callback( } case MODE_Html: { if( p->cnt++==0 && p->showHeader ){ - fprintf(p->out,""); + raw_printf(p->out,""); for(i=0; iout,""); + raw_printf(p->out,""); output_html_string(p->out, azCol[i]); - fprintf(p->out,"\n"); + raw_printf(p->out,"\n"); } - fprintf(p->out,"\n"); + raw_printf(p->out,"\n"); } if( azArg==0 ) break; - fprintf(p->out,""); + raw_printf(p->out,""); for(i=0; iout,""); + raw_printf(p->out,""); output_html_string(p->out, azArg[i] ? azArg[i] : p->nullValue); - fprintf(p->out,"\n"); + raw_printf(p->out,"\n"); } - fprintf(p->out,"\n"); + raw_printf(p->out,"\n"); break; } case MODE_Tcl: { @@ -1044,20 +1052,20 @@ static int shell_callback( if( azArg==0 ) break; utf8_printf(p->out,"INSERT INTO %s",p->zDestTable); if( p->showHeader ){ - fprintf(p->out,"("); + raw_printf(p->out,"("); for(i=0; i0 ? ",": ""; utf8_printf(p->out, "%s%s", zSep, azCol[i]); } - fprintf(p->out,")"); + raw_printf(p->out,")"); } - fprintf(p->out," VALUES("); + raw_printf(p->out," VALUES("); for(i=0; i0 ? ",": ""; if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){ - fprintf(p->out,"%sNULL",zSep); + utf8_printf(p->out,"%sNULL",zSep); }else if( aiType && aiType[i]==SQLITE_TEXT ){ - if( zSep[0] ) fprintf(p->out,"%s",zSep); + if( zSep[0] ) utf8_printf(p->out,"%s",zSep); output_quoted_string(p->out, azArg[i]); }else if( aiType && (aiType[i]==SQLITE_INTEGER || aiType[i]==SQLITE_FLOAT) ){ @@ -1065,16 +1073,16 @@ static int shell_callback( }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){ const void *pBlob = sqlite3_column_blob(p->pStmt, i); int nBlob = sqlite3_column_bytes(p->pStmt, i); - if( zSep[0] ) fprintf(p->out,"%s",zSep); + if( zSep[0] ) utf8_printf(p->out,"%s",zSep); output_hex_blob(p->out, pBlob, nBlob); }else if( isNumber(azArg[i], 0) ){ utf8_printf(p->out,"%s%s",zSep, azArg[i]); }else{ - if( zSep[0] ) fprintf(p->out,"%s",zSep); + if( zSep[0] ) utf8_printf(p->out,"%s",zSep); output_quoted_string(p->out, azArg[i]); } } - fprintf(p->out,");\n"); + raw_printf(p->out,");\n"); break; } case MODE_Ascii: { @@ -1131,7 +1139,7 @@ static void set_table_name(ShellState *p, const char *zName){ if( needQuote ) n += 2; z = p->zDestTable = malloc( n+1 ); if( z==0 ){ - fprintf(stderr,"Error: out of memory\n"); + raw_printf(stderr,"Error: out of memory\n"); exit(1); } n = 0; @@ -1212,7 +1220,8 @@ static int run_table_dump_query( const char *z; rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0); if( rc!=SQLITE_OK || !pSelect ){ - fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); + utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, + sqlite3_errmsg(p->db)); if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++; return rc; } @@ -1231,15 +1240,16 @@ static int run_table_dump_query( if( z==0 ) z = ""; while( z[0] && (z[0]!='-' || z[1]!='-') ) z++; if( z[0] ){ - fprintf(p->out, "\n;\n"); + raw_printf(p->out, "\n;\n"); }else{ - fprintf(p->out, ";\n"); + raw_printf(p->out, ";\n"); } rc = sqlite3_step(pSelect); } rc = sqlite3_finalize(pSelect); if( rc!=SQLITE_OK ){ - fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); + utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, + sqlite3_errmsg(p->db)); if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++; } return rc; @@ -1274,52 +1284,53 @@ static int display_stats( iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, + raw_printf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", + raw_printf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", iCur, iHiwtr); if( pArg->shellFlgs & SHFLG_Pagecache ){ iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, + raw_printf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr); } iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, + raw_printf(pArg->out, "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr); if( pArg->shellFlgs & SHFLG_Scratch ){ iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", + raw_printf(pArg->out, + "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr); } iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, + raw_printf(pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Largest Allocation: %d bytes\n", + raw_printf(pArg->out, "Largest Allocation: %d bytes\n", iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Largest Pcache Allocation: %d bytes\n", + raw_printf(pArg->out, "Largest Pcache Allocation: %d bytes\n", iHiwtr); iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Largest Scratch Allocation: %d bytes\n", + raw_printf(pArg->out, "Largest Scratch Allocation: %d bytes\n", iHiwtr); #ifdef YYTRACKMAXSTACKDEPTH iHiwtr = iCur = -1; sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", + raw_printf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr); #endif } @@ -1329,48 +1340,55 @@ static int display_stats( iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", + raw_printf(pArg->out, + "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr); sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr); + raw_printf(pArg->out, "Successful lookaside attempts: %d\n", + iHiwtr); sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr); + raw_printf(pArg->out, "Lookaside failures due to size: %d\n", + iHiwtr); sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr); + raw_printf(pArg->out, "Lookaside failures due to OOM: %d\n", + iHiwtr); } iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Pager Heap Usage: %d bytes\n",iCur); + raw_printf(pArg->out, "Pager Heap Usage: %d bytes\n", + iCur); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1); - fprintf(pArg->out, "Page cache hits: %d\n", iCur); + raw_printf(pArg->out, "Page cache hits: %d\n", iCur); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1); - fprintf(pArg->out, "Page cache misses: %d\n", iCur); + raw_printf(pArg->out, "Page cache misses: %d\n", iCur); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1); - fprintf(pArg->out, "Page cache writes: %d\n", iCur); + raw_printf(pArg->out, "Page cache writes: %d\n", iCur); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Schema Heap Usage: %d bytes\n",iCur); + raw_printf(pArg->out, "Schema Heap Usage: %d bytes\n", + iCur); iHiwtr = iCur = -1; sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset); - fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n",iCur); + raw_printf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", + iCur); } if( pArg && pArg->out && db && pArg->pStmt ){ iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, bReset); - fprintf(pArg->out, "Fullscan Steps: %d\n", iCur); + raw_printf(pArg->out, "Fullscan Steps: %d\n", iCur); iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset); - fprintf(pArg->out, "Sort Operations: %d\n", iCur); + raw_printf(pArg->out, "Sort Operations: %d\n", iCur); iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset); - fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur); + raw_printf(pArg->out, "Autoindex Inserts: %d\n", iCur); iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset); - fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur); + raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur); } /* Do not remove this machine readable comment: extra-stats-output-here */ @@ -1390,7 +1408,7 @@ static void display_scanstats( UNUSED_PARAMETER(pArg); #else int i, k, n, mx; - fprintf(pArg->out, "-------- scanstats --------\n"); + raw_printf(pArg->out, "-------- scanstats --------\n"); mx = 0; for(k=0; k<=mx; k++){ double rEstLoop = 1.0; @@ -1408,7 +1426,7 @@ static void display_scanstats( if( iSid!=k ) continue; if( n==0 ){ rEstLoop = (double)nLoop; - if( k>0 ) fprintf(pArg->out, "-------- subquery %d -------\n", k); + if( k>0 ) raw_printf(pArg->out, "-------- subquery %d -------\n", k); } n++; sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit); @@ -1416,13 +1434,13 @@ static void display_scanstats( sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain); utf8_printf(pArg->out, "Loop %2d: %s\n", n, zExplain); rEstLoop *= rEst; - fprintf(pArg->out, + raw_printf(pArg->out, " nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n", nLoop, nVisit, (sqlite3_int64)(rEstLoop+0.5), rEst ); } } - fprintf(pArg->out, "---------------------------\n"); + raw_printf(pArg->out, "---------------------------\n"); #endif } @@ -1586,9 +1604,9 @@ static int shell_exec( rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0); if( rc==SQLITE_OK ){ while( sqlite3_step(pExplain)==SQLITE_ROW ){ - fprintf(pArg->out,"--EQP-- %d,", sqlite3_column_int(pExplain, 0)); - fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1)); - fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2)); + raw_printf(pArg->out,"--EQP-- %d,",sqlite3_column_int(pExplain, 0)); + raw_printf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1)); + raw_printf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2)); utf8_printf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3)); } } @@ -1717,13 +1735,13 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){ if( strcmp(zTable, "sqlite_sequence")==0 ){ zPrepStmt = "DELETE FROM sqlite_sequence;\n"; }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){ - fprintf(p->out, "ANALYZE sqlite_master;\n"); + raw_printf(p->out, "ANALYZE sqlite_master;\n"); }else if( strncmp(zTable, "sqlite_", 7)==0 ){ return 0; }else if( strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){ char *zIns; if( !p->writableSchema ){ - fprintf(p->out, "PRAGMA writable_schema=ON;\n"); + raw_printf(p->out, "PRAGMA writable_schema=ON;\n"); p->writableSchema = 1; } zIns = sqlite3_mprintf( @@ -1811,9 +1829,9 @@ static int run_schema_dump_query( if( rc==SQLITE_CORRUPT ){ char *zQ2; int len = strlen30(zQuery); - fprintf(p->out, "/****** CORRUPTION ERROR *******/\n"); + raw_printf(p->out, "/****** CORRUPTION ERROR *******/\n"); if( zErr ){ - fprintf(p->out, "/****** %s ******/\n", zErr); + utf8_printf(p->out, "/****** %s ******/\n", zErr); sqlite3_free(zErr); zErr = 0; } @@ -1822,7 +1840,7 @@ static int run_schema_dump_query( sqlite3_snprintf(len+100, zQ2, "%s ORDER BY rowid DESC", zQuery); rc = sqlite3_exec(p->db, zQ2, dump_callback, p, &zErr); if( rc ){ - fprintf(p->out, "/****** ERROR: %s ******/\n", zErr); + utf8_printf(p->out, "/****** ERROR: %s ******/\n", zErr); }else{ rc = SQLITE_CORRUPT; } @@ -1987,7 +2005,7 @@ static void open_db(ShellState *p, int keepAlive){ shellstaticFunc, 0, 0); } if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){ - fprintf(stderr,"Error: unable to open database \"%s\": %s\n", + utf8_printf(stderr,"Error: unable to open database \"%s\": %s\n", p->zDbFilename, sqlite3_errmsg(p->db)); if( keepAlive ) return; exit(1); @@ -2137,7 +2155,7 @@ static int booleanValue(char *zArg){ if( sqlite3_stricmp(zArg, "off")==0 || sqlite3_stricmp(zArg,"no")==0 ){ return 0; } - fprintf(stderr, "ERROR: Not a boolean value: \"%s\". Assuming \"no\".\n", + utf8_printf(stderr, "ERROR: Not a boolean value: \"%s\". Assuming \"no\".\n", zArg); return 0; } @@ -2165,7 +2183,7 @@ static FILE *output_file_open(const char *zFile){ }else{ f = fopen(zFile, "wb"); if( f==0 ){ - fprintf(stderr, "Error: cannot open \"%s\"\n", zFile); + utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile); } } return f; @@ -2214,7 +2232,7 @@ static void import_append_char(ImportCtx *p, int c){ p->nAlloc += p->nAlloc + 100; p->z = sqlite3_realloc64(p->z, p->nAlloc); if( p->z==0 ){ - fprintf(stderr, "out of memory\n"); + raw_printf(stderr, "out of memory\n"); exit(1); } } @@ -2268,11 +2286,11 @@ static char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){ break; } if( pc==cQuote && c!='\r' ){ - fprintf(stderr, "%s:%d: unescaped %c character\n", + utf8_printf(stderr, "%s:%d: unescaped %c character\n", p->zFile, p->nLine, cQuote); } if( c==EOF ){ - fprintf(stderr, "%s:%d: unterminated %c-quoted field\n", + utf8_printf(stderr, "%s:%d: unterminated %c-quoted field\n", p->zFile, startLine, cQuote); p->cTerm = c; break; @@ -2354,7 +2372,7 @@ static void tryToCloneData( zQuery = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable); rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); if( rc ){ - fprintf(stderr, "Error %d: %s on [%s]\n", + utf8_printf(stderr, "Error %d: %s on [%s]\n", sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zQuery); goto end_data_xfer; @@ -2362,7 +2380,7 @@ static void tryToCloneData( n = sqlite3_column_count(pQuery); zInsert = sqlite3_malloc64(200 + nTable + n*3); if( zInsert==0 ){ - fprintf(stderr, "out of memory\n"); + raw_printf(stderr, "out of memory\n"); goto end_data_xfer; } sqlite3_snprintf(200+nTable,zInsert, @@ -2375,7 +2393,7 @@ static void tryToCloneData( memcpy(zInsert+i, ");", 3); rc = sqlite3_prepare_v2(newDb, zInsert, -1, &pInsert, 0); if( rc ){ - fprintf(stderr, "Error %d: %s on [%s]\n", + utf8_printf(stderr, "Error %d: %s on [%s]\n", sqlite3_extended_errcode(newDb), sqlite3_errmsg(newDb), zQuery); goto end_data_xfer; @@ -2412,7 +2430,7 @@ static void tryToCloneData( } /* End for */ rc = sqlite3_step(pInsert); if( rc!=SQLITE_OK && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ - fprintf(stderr, "Error %d: %s\n", sqlite3_extended_errcode(newDb), + utf8_printf(stderr, "Error %d: %s\n", sqlite3_extended_errcode(newDb), sqlite3_errmsg(newDb)); } sqlite3_reset(pInsert); @@ -2429,7 +2447,7 @@ static void tryToCloneData( zTable); rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); if( rc ){ - fprintf(stderr, "Warning: cannot step \"%s\" backwards", zTable); + utf8_printf(stderr, "Warning: cannot step \"%s\" backwards", zTable); break; } } /* End for(k=0...) */ @@ -2465,7 +2483,7 @@ static void tryToCloneSchema( " WHERE %s", zWhere); rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); if( rc ){ - fprintf(stderr, "Error: (%d) %s on [%s]\n", + utf8_printf(stderr, "Error: (%d) %s on [%s]\n", sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zQuery); goto end_schema_xfer; @@ -2476,7 +2494,7 @@ static void tryToCloneSchema( printf("%s... ", zName); fflush(stdout); sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg); if( zErrMsg ){ - fprintf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); + utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); sqlite3_free(zErrMsg); zErrMsg = 0; } @@ -2492,7 +2510,7 @@ static void tryToCloneSchema( " WHERE %s ORDER BY rowid DESC", zWhere); rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); if( rc ){ - fprintf(stderr, "Error: (%d) %s on [%s]\n", + utf8_printf(stderr, "Error: (%d) %s on [%s]\n", sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zQuery); goto end_schema_xfer; @@ -2503,7 +2521,7 @@ static void tryToCloneSchema( printf("%s... ", zName); fflush(stdout); sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg); if( zErrMsg ){ - fprintf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); + utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); sqlite3_free(zErrMsg); zErrMsg = 0; } @@ -2527,12 +2545,12 @@ static void tryToClone(ShellState *p, const char *zNewDb){ int rc; sqlite3 *newDb = 0; if( access(zNewDb,0)==0 ){ - fprintf(stderr, "File \"%s\" already exists.\n", zNewDb); + utf8_printf(stderr, "File \"%s\" already exists.\n", zNewDb); return; } rc = sqlite3_open(zNewDb, &newDb); if( rc ){ - fprintf(stderr, "Cannot create output database: %s\n", + utf8_printf(stderr, "Cannot create output database: %s\n", sqlite3_errmsg(newDb)); }else{ sqlite3_exec(p->db, "PRAGMA writable_schema=ON;", 0, 0, 0); @@ -2629,27 +2647,27 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){ } i = pFile->pMethods->xRead(pFile, aHdr, 100, 0); if( i!=SQLITE_OK ){ - fprintf(stderr, "unable to read database header\n"); + raw_printf(stderr, "unable to read database header\n"); return 1; } i = get2byteInt(aHdr+16); if( i==1 ) i = 65536; - fprintf(p->out, "%-20s %d\n", "database page size:", i); - fprintf(p->out, "%-20s %d\n", "write format:", aHdr[18]); - fprintf(p->out, "%-20s %d\n", "read format:", aHdr[19]); - fprintf(p->out, "%-20s %d\n", "reserved bytes:", aHdr[20]); + utf8_printf(p->out, "%-20s %d\n", "database page size:", i); + utf8_printf(p->out, "%-20s %d\n", "write format:", aHdr[18]); + utf8_printf(p->out, "%-20s %d\n", "read format:", aHdr[19]); + utf8_printf(p->out, "%-20s %d\n", "reserved bytes:", aHdr[20]); for(i=0; iout, "%-20s %u", aField[i].zName, val); + utf8_printf(p->out, "%-20s %u", aField[i].zName, val); switch( ofst ){ case 56: { - if( val==1 ) fprintf(p->out, " (utf8)"); - if( val==2 ) fprintf(p->out, " (utf16le)"); - if( val==3 ) fprintf(p->out, " (utf16be)"); + if( val==1 ) raw_printf(p->out, " (utf8)"); + if( val==2 ) raw_printf(p->out, " (utf16le)"); + if( val==3 ) raw_printf(p->out, " (utf16be)"); } } - fprintf(p->out, "\n"); + raw_printf(p->out, "\n"); } if( zDb==0 ){ zSchemaTab = sqlite3_mprintf("main.sqlite_master"); @@ -2673,7 +2691,7 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){ */ static int shellDatabaseError(sqlite3 *db){ const char *zErr = sqlite3_errmsg(db); - fprintf(stderr, "Error: %s\n", zErr); + utf8_printf(stderr, "Error: %s\n", zErr); return 1; } @@ -2681,7 +2699,7 @@ static int shellDatabaseError(sqlite3 *db){ ** Print an out-of-memory message to stderr and return 1. */ static int shellNomemError(void){ - fprintf(stderr, "Error: out of memory\n"); + raw_printf(stderr, "Error: out of memory\n"); return 1; } @@ -2741,7 +2759,7 @@ static int do_meta_command(char *zLine, ShellState *p){ while( z[0]=='-' ) z++; /* No options to process at this time */ { - fprintf(stderr, "unknown option: %s\n", azArg[j]); + utf8_printf(stderr, "unknown option: %s\n", azArg[j]); return 1; } }else if( zDestFile==0 ){ @@ -2750,25 +2768,25 @@ static int do_meta_command(char *zLine, ShellState *p){ zDb = zDestFile; zDestFile = azArg[j]; }else{ - fprintf(stderr, "too many arguments to .backup\n"); + raw_printf(stderr, "too many arguments to .backup\n"); return 1; } } if( zDestFile==0 ){ - fprintf(stderr, "missing FILENAME argument on .backup\n"); + raw_printf(stderr, "missing FILENAME argument on .backup\n"); return 1; } if( zDb==0 ) zDb = "main"; rc = sqlite3_open(zDestFile, &pDest); if( rc!=SQLITE_OK ){ - fprintf(stderr, "Error: cannot open \"%s\"\n", zDestFile); + utf8_printf(stderr, "Error: cannot open \"%s\"\n", zDestFile); sqlite3_close(pDest); return 1; } open_db(p, 0); pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb); if( pBackup==0 ){ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); sqlite3_close(pDest); return 1; } @@ -2777,7 +2795,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( rc==SQLITE_DONE ){ rc = 0; }else{ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(pDest)); rc = 1; } sqlite3_close(pDest); @@ -2787,7 +2805,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ bail_on_error = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .bail on|off\n"); + raw_printf(stderr, "Usage: .bail on|off\n"); rc = 1; } }else @@ -2800,7 +2818,7 @@ static int do_meta_command(char *zLine, ShellState *p){ setTextMode(p->out); } }else{ - fprintf(stderr, "Usage: .binary on|off\n"); + raw_printf(stderr, "Usage: .binary on|off\n"); rc = 1; } }else @@ -2816,7 +2834,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ p->countChanges = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .changes on|off\n"); + raw_printf(stderr, "Usage: .changes on|off\n"); rc = 1; } }else @@ -2825,7 +2843,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ tryToClone(p, azArg[1]); }else{ - fprintf(stderr, "Usage: .clone FILENAME\n"); + raw_printf(stderr, "Usage: .clone FILENAME\n"); rc = 1; } }else @@ -2843,7 +2861,7 @@ static int do_meta_command(char *zLine, ShellState *p){ data.cnt = 0; sqlite3_exec(p->db, "PRAGMA database_list; ", callback, &data, &zErrMsg); if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); + utf8_printf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; } @@ -2859,12 +2877,12 @@ static int do_meta_command(char *zLine, ShellState *p){ ** which causes immediate foreign key constraints to be violated. ** So disable foreign-key constraint enforcement to prevent problems. */ if( nArg!=1 && nArg!=2 ){ - fprintf(stderr, "Usage: .dump ?LIKE-PATTERN?\n"); + raw_printf(stderr, "Usage: .dump ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; } - fprintf(p->out, "PRAGMA foreign_keys=OFF;\n"); - fprintf(p->out, "BEGIN TRANSACTION;\n"); + raw_printf(p->out, "PRAGMA foreign_keys=OFF;\n"); + raw_printf(p->out, "BEGIN TRANSACTION;\n"); p->writableSchema = 0; sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0); p->nErr = 0; @@ -2899,19 +2917,19 @@ static int do_meta_command(char *zLine, ShellState *p){ } } if( p->writableSchema ){ - fprintf(p->out, "PRAGMA writable_schema=OFF;\n"); + raw_printf(p->out, "PRAGMA writable_schema=OFF;\n"); p->writableSchema = 0; } sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0); sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0); - fprintf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n"); + raw_printf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n"); }else if( c=='e' && strncmp(azArg[0], "echo", n)==0 ){ if( nArg==2 ){ p->echoOn = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .echo on|off\n"); + raw_printf(stderr, "Usage: .echo on|off\n"); rc = 1; } }else @@ -2920,7 +2938,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ p->autoEQP = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .eqp on|off\n"); + raw_printf(stderr, "Usage: .eqp on|off\n"); rc = 1; } }else @@ -2970,7 +2988,7 @@ static int do_meta_command(char *zLine, ShellState *p){ char *zErrMsg = 0; int doStats = 0; if( nArg!=1 ){ - fprintf(stderr, "Usage: .fullschema\n"); + raw_printf(stderr, "Usage: .fullschema\n"); rc = 1; goto meta_command_exit; } @@ -2997,9 +3015,9 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_finalize(pStmt); } if( doStats==0 ){ - fprintf(p->out, "/* No STAT tables available */\n"); + raw_printf(p->out, "/* No STAT tables available */\n"); }else{ - fprintf(p->out, "ANALYZE sqlite_master;\n"); + raw_printf(p->out, "ANALYZE sqlite_master;\n"); sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_master'", callback, &data, &zErrMsg); data.mode = MODE_Insert; @@ -3012,7 +3030,7 @@ static int do_meta_command(char *zLine, ShellState *p){ data.zDestTable = "sqlite_stat4"; shell_exec(p->db, "SELECT * FROM sqlite_stat4", shell_callback, &data, &zErrMsg); - fprintf(p->out, "ANALYZE sqlite_master;\n"); + raw_printf(p->out, "ANALYZE sqlite_master;\n"); } }else @@ -3020,13 +3038,13 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ p->showHeader = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .headers on|off\n"); + raw_printf(stderr, "Usage: .headers on|off\n"); rc = 1; } }else if( c=='h' && strncmp(azArg[0], "help", n)==0 ){ - fprintf(p->out, "%s", zHelp); + utf8_printf(p->out, "%s", zHelp); }else if( c=='i' && strncmp(azArg[0], "import", n)==0 ){ @@ -3044,7 +3062,7 @@ static int do_meta_command(char *zLine, ShellState *p){ int (SQLITE_CDECL *xCloser)(FILE*); /* Func to close file */ if( nArg!=3 ){ - fprintf(stderr, "Usage: .import FILE TABLE\n"); + raw_printf(stderr, "Usage: .import FILE TABLE\n"); goto meta_command_exit; } zFile = azArg[1]; @@ -3054,17 +3072,18 @@ static int do_meta_command(char *zLine, ShellState *p){ open_db(p, 0); nSep = strlen30(p->colSeparator); if( nSep==0 ){ - fprintf(stderr, "Error: non-null column separator required for import\n"); + raw_printf(stderr, + "Error: non-null column separator required for import\n"); return 1; } if( nSep>1 ){ - fprintf(stderr, "Error: multi-character column separators not allowed" + raw_printf(stderr, "Error: multi-character column separators not allowed" " for import\n"); return 1; } nSep = strlen30(p->rowSeparator); if( nSep==0 ){ - fprintf(stderr, "Error: non-null row separator required for import\n"); + raw_printf(stderr, "Error: non-null row separator required for import\n"); return 1; } if( nSep==2 && p->mode==MODE_Csv && strcmp(p->rowSeparator, SEP_CrLf)==0 ){ @@ -3076,7 +3095,7 @@ static int do_meta_command(char *zLine, ShellState *p){ nSep = strlen30(p->rowSeparator); } if( nSep>1 ){ - fprintf(stderr, "Error: multi-character row separators not allowed" + raw_printf(stderr, "Error: multi-character row separators not allowed" " for import\n"); return 1; } @@ -3084,7 +3103,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sCtx.nLine = 1; if( sCtx.zFile[0]=='|' ){ #ifdef SQLITE_OMIT_POPEN - fprintf(stderr, "Error: pipes are not supported in this OS\n"); + raw_printf(stderr, "Error: pipes are not supported in this OS\n"); return 1; #else sCtx.in = popen(sCtx.zFile+1, "r"); @@ -3101,14 +3120,14 @@ static int do_meta_command(char *zLine, ShellState *p){ xRead = csv_read_one_field; } if( sCtx.in==0 ){ - fprintf(stderr, "Error: cannot open \"%s\"\n", zFile); + utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile); return 1; } sCtx.cColSep = p->colSeparator[0]; sCtx.cRowSep = p->rowSeparator[0]; zSql = sqlite3_mprintf("SELECT * FROM %s", zTable); if( zSql==0 ){ - fprintf(stderr, "Error: out of memory\n"); + raw_printf(stderr, "Error: out of memory\n"); xCloser(sCtx.in); return 1; } @@ -3127,14 +3146,14 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_free(zCreate); sqlite3_free(sCtx.z); xCloser(sCtx.in); - fprintf(stderr,"%s: empty file\n", sCtx.zFile); + utf8_printf(stderr,"%s: empty file\n", sCtx.zFile); return 1; } zCreate = sqlite3_mprintf("%z\n)", zCreate); rc = sqlite3_exec(p->db, zCreate, 0, 0, 0); sqlite3_free(zCreate); if( rc ){ - fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable, + utf8_printf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable, sqlite3_errmsg(p->db)); sqlite3_free(sCtx.z); xCloser(sCtx.in); @@ -3145,7 +3164,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_free(zSql); if( rc ){ if (pStmt) sqlite3_finalize(pStmt); - fprintf(stderr,"Error: %s\n", sqlite3_errmsg(p->db)); + utf8_printf(stderr,"Error: %s\n", sqlite3_errmsg(p->db)); xCloser(sCtx.in); return 1; } @@ -3155,7 +3174,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nCol==0 ) return 0; /* no columns, no error */ zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 ); if( zSql==0 ){ - fprintf(stderr, "Error: out of memory\n"); + raw_printf(stderr, "Error: out of memory\n"); xCloser(sCtx.in); return 1; } @@ -3170,7 +3189,7 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rc ){ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); if (pStmt) sqlite3_finalize(pStmt); xCloser(sCtx.in); return 1; @@ -3194,7 +3213,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( p->mode==MODE_Ascii && (z==0 || z[0]==0) && i==0 ) break; sqlite3_bind_text(pStmt, i+1, z, -1, SQLITE_TRANSIENT); if( idb)); + utf8_printf(stderr, "%s:%d: INSERT failed: %s\n", sCtx.zFile, + startLine, sqlite3_errmsg(p->db)); } } }while( sCtx.cTerm!=EOF ); @@ -3257,16 +3276,17 @@ static int do_meta_command(char *zLine, ShellState *p){ ); zShellStatic = 0; }else{ - fprintf(stderr, "Usage: .indexes ?LIKE-PATTERN?\n"); + raw_printf(stderr, "Usage: .indexes ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; } if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); + utf8_printf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; }else if( rc != SQLITE_OK ){ - fprintf(stderr,"Error: querying sqlite_master and sqlite_temp_master\n"); + raw_printf(stderr, + "Error: querying sqlite_master and sqlite_temp_master\n"); rc = 1; } }else @@ -3284,7 +3304,7 @@ static int do_meta_command(char *zLine, ShellState *p){ }else{ iotrace = fopen(azArg[1], "w"); if( iotrace==0 ){ - fprintf(stderr, "Error: cannot open \"%s\"\n", azArg[1]); + utf8_printf(stderr, "Error: cannot open \"%s\"\n", azArg[1]); sqlite3IoTrace = 0; rc = 1; }else{ @@ -3319,7 +3339,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_limit(p->db, aLimit[i].limitCode, -1)); } }else if( nArg>3 ){ - fprintf(stderr, "Usage: .limit NAME ?NEW-VALUE?\n"); + raw_printf(stderr, "Usage: .limit NAME ?NEW-VALUE?\n"); rc = 1; goto meta_command_exit; }else{ @@ -3330,14 +3350,14 @@ static int do_meta_command(char *zLine, ShellState *p){ if( iLimit<0 ){ iLimit = i; }else{ - fprintf(stderr, "ambiguous limit: \"%s\"\n", azArg[1]); + utf8_printf(stderr, "ambiguous limit: \"%s\"\n", azArg[1]); rc = 1; goto meta_command_exit; } } } if( iLimit<0 ){ - fprintf(stderr, "unknown limit: \"%s\"\n" + utf8_printf(stderr, "unknown limit: \"%s\"\n" "enter \".limits\" with no arguments for a list.\n", azArg[1]); rc = 1; @@ -3357,7 +3377,7 @@ static int do_meta_command(char *zLine, ShellState *p){ const char *zFile, *zProc; char *zErrMsg = 0; if( nArg<2 ){ - fprintf(stderr, "Usage: .load FILE ?ENTRYPOINT?\n"); + raw_printf(stderr, "Usage: .load FILE ?ENTRYPOINT?\n"); rc = 1; goto meta_command_exit; } @@ -3366,7 +3386,7 @@ static int do_meta_command(char *zLine, ShellState *p){ open_db(p, 0); rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg); if( rc!=SQLITE_OK ){ - fprintf(stderr, "Error: %s\n", zErrMsg); + utf8_printf(stderr, "Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; } @@ -3375,7 +3395,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='l' && strncmp(azArg[0], "log", n)==0 ){ if( nArg!=2 ){ - fprintf(stderr, "Usage: .log FILENAME\n"); + raw_printf(stderr, "Usage: .log FILENAME\n"); rc = 1; }else{ const char *zFile = azArg[1]; @@ -3414,7 +3434,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit); sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record); }else { - fprintf(stderr,"Error: mode should be one of: " + raw_printf(stderr, "Error: mode should be one of: " "ascii column csv html insert line list tabs tcl\n"); rc = 1; } @@ -3425,7 +3445,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_snprintf(sizeof(p->nullValue), p->nullValue, "%.*s", (int)ArraySize(p->nullValue)-1, azArg[1]); }else{ - fprintf(stderr, "Usage: .nullvalue STRING\n"); + raw_printf(stderr, "Usage: .nullvalue STRING\n"); rc = 1; } }else @@ -3454,13 +3474,13 @@ static int do_meta_command(char *zLine, ShellState *p){ ){ const char *zFile = nArg>=2 ? azArg[1] : "stdout"; if( nArg>2 ){ - fprintf(stderr, "Usage: .%s FILE\n", azArg[0]); + utf8_printf(stderr, "Usage: .%s FILE\n", azArg[0]); rc = 1; goto meta_command_exit; } if( n>1 && strncmp(azArg[0], "once", n)==0 ){ if( nArg<2 ){ - fprintf(stderr, "Usage: .once FILE\n"); + raw_printf(stderr, "Usage: .once FILE\n"); rc = 1; goto meta_command_exit; } @@ -3471,13 +3491,13 @@ static int do_meta_command(char *zLine, ShellState *p){ output_reset(p); if( zFile[0]=='|' ){ #ifdef SQLITE_OMIT_POPEN - fprintf(stderr,"Error: pipes are not supported in this OS\n"); + raw_printf(stderr, "Error: pipes are not supported in this OS\n"); rc = 1; p->out = stdout; #else p->out = popen(zFile + 1, "w"); if( p->out==0 ){ - fprintf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1); + utf8_printf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1); p->out = stdout; rc = 1; }else{ @@ -3488,7 +3508,7 @@ static int do_meta_command(char *zLine, ShellState *p){ p->out = output_file_open(zFile); if( p->out==0 ){ if( strcmp(zFile,"off")!=0 ){ - fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile); + utf8_printf(stderr,"Error: cannot write to \"%s\"\n", zFile); } p->out = stdout; rc = 1; @@ -3501,10 +3521,10 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='p' && n>=3 && strncmp(azArg[0], "print", n)==0 ){ int i; for(i=1; i1 ) fprintf(p->out, " "); + if( i>1 ) raw_printf(p->out, " "); utf8_printf(p->out, "%s", azArg[i]); } - fprintf(p->out, "\n"); + raw_printf(p->out, "\n"); }else if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){ @@ -3523,13 +3543,13 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 ){ FILE *alt; if( nArg!=2 ){ - fprintf(stderr, "Usage: .read FILE\n"); + raw_printf(stderr, "Usage: .read FILE\n"); rc = 1; goto meta_command_exit; } alt = fopen(azArg[1], "rb"); if( alt==0 ){ - fprintf(stderr,"Error: cannot open \"%s\"\n", azArg[1]); + utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]); rc = 1; }else{ rc = process_input(p, alt); @@ -3551,20 +3571,20 @@ static int do_meta_command(char *zLine, ShellState *p){ zSrcFile = azArg[2]; zDb = azArg[1]; }else{ - fprintf(stderr, "Usage: .restore ?DB? FILE\n"); + raw_printf(stderr, "Usage: .restore ?DB? FILE\n"); rc = 1; goto meta_command_exit; } rc = sqlite3_open(zSrcFile, &pSrc); if( rc!=SQLITE_OK ){ - fprintf(stderr, "Error: cannot open \"%s\"\n", zSrcFile); + utf8_printf(stderr, "Error: cannot open \"%s\"\n", zSrcFile); sqlite3_close(pSrc); return 1; } open_db(p, 0); pBackup = sqlite3_backup_init(p->db, zDb, pSrc, "main"); if( pBackup==0 ){ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); sqlite3_close(pSrc); return 1; } @@ -3579,10 +3599,10 @@ static int do_meta_command(char *zLine, ShellState *p){ if( rc==SQLITE_DONE ){ rc = 0; }else if( rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){ - fprintf(stderr, "Error: source database is busy\n"); + raw_printf(stderr, "Error: source database is busy\n"); rc = 1; }else{ - fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); + utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db)); rc = 1; } sqlite3_close(pSrc); @@ -3593,10 +3613,10 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ p->scanstatsOn = booleanValue(azArg[1]); #ifndef SQLITE_ENABLE_STMT_SCANSTATUS - fprintf(stderr, "Warning: .scanstats not available in this build.\n"); + raw_printf(stderr, "Warning: .scanstats not available in this build.\n"); #endif }else{ - fprintf(stderr, "Usage: .scanstats on|off\n"); + raw_printf(stderr, "Usage: .scanstats on|off\n"); rc = 1; } }else @@ -3663,16 +3683,16 @@ static int do_meta_command(char *zLine, ShellState *p){ callback, &data, &zErrMsg ); }else{ - fprintf(stderr, "Usage: .schema ?LIKE-PATTERN?\n"); + raw_printf(stderr, "Usage: .schema ?LIKE-PATTERN?\n"); rc = 1; goto meta_command_exit; } if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); + utf8_printf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); rc = 1; }else if( rc != SQLITE_OK ){ - fprintf(stderr,"Error: querying schema information\n"); + raw_printf(stderr,"Error: querying schema information\n"); rc = 1; }else{ rc = 0; @@ -3713,7 +3733,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='s' && strncmp(azArg[0], "separator", n)==0 ){ if( nArg<2 || nArg>3 ){ - fprintf(stderr, "Usage: .separator COL ?ROW?\n"); + raw_printf(stderr, "Usage: .separator COL ?ROW?\n"); rc = 1; } if( nArg>=2 ){ @@ -3732,7 +3752,7 @@ static int do_meta_command(char *zLine, ShellState *p){ char *zCmd; int i, x; if( nArg<2 ){ - fprintf(stderr, "Usage: .system COMMAND\n"); + raw_printf(stderr, "Usage: .system COMMAND\n"); rc = 1; goto meta_command_exit; } @@ -3743,45 +3763,45 @@ static int do_meta_command(char *zLine, ShellState *p){ } x = system(zCmd); sqlite3_free(zCmd); - if( x ) fprintf(stderr, "System command returns %d\n", x); + if( x ) raw_printf(stderr, "System command returns %d\n", x); }else if( c=='s' && strncmp(azArg[0], "show", n)==0 ){ int i; if( nArg!=1 ){ - fprintf(stderr, "Usage: .show\n"); + raw_printf(stderr, "Usage: .show\n"); rc = 1; goto meta_command_exit; } - fprintf(p->out,"%12.12s: %s\n","echo", p->echoOn ? "on" : "off"); - fprintf(p->out,"%12.12s: %s\n","eqp", p->autoEQP ? "on" : "off"); - fprintf(p->out,"%9.9s: %s\n","explain", p->normalMode.valid ? "on" :"off"); - fprintf(p->out,"%12.12s: %s\n","headers", p->showHeader ? "on" : "off"); - fprintf(p->out,"%12.12s: %s\n","mode", modeDescr[p->mode]); - fprintf(p->out,"%12.12s: ", "nullvalue"); + utf8_printf(p->out, "%12.12s: %s\n","echo", p->echoOn ? "on" : "off"); + utf8_printf(p->out, "%12.12s: %s\n","eqp", p->autoEQP ? "on" : "off"); + utf8_printf(p->out,"%9.9s: %s\n","explain",p->normalMode.valid?"on":"off"); + utf8_printf(p->out,"%12.12s: %s\n","headers", p->showHeader ? "on" : "off"); + utf8_printf(p->out, "%12.12s: %s\n","mode", modeDescr[p->mode]); + utf8_printf(p->out, "%12.12s: ", "nullvalue"); output_c_string(p->out, p->nullValue); - fprintf(p->out, "\n"); - fprintf(p->out,"%12.12s: %s\n","output", + raw_printf(p->out, "\n"); + utf8_printf(p->out,"%12.12s: %s\n","output", strlen30(p->outfile) ? p->outfile : "stdout"); - fprintf(p->out,"%12.12s: ", "colseparator"); + utf8_printf(p->out,"%12.12s: ", "colseparator"); output_c_string(p->out, p->colSeparator); - fprintf(p->out, "\n"); - fprintf(p->out,"%12.12s: ", "rowseparator"); + raw_printf(p->out, "\n"); + utf8_printf(p->out,"%12.12s: ", "rowseparator"); output_c_string(p->out, p->rowSeparator); - fprintf(p->out, "\n"); - fprintf(p->out,"%12.12s: %s\n","stats", p->statsOn ? "on" : "off"); - fprintf(p->out,"%12.12s: ","width"); + raw_printf(p->out, "\n"); + utf8_printf(p->out, "%12.12s: %s\n","stats", p->statsOn ? "on" : "off"); + utf8_printf(p->out, "%12.12s: ", "width"); for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) { - fprintf(p->out,"%d ",p->colWidth[i]); + raw_printf(p->out, "%d ", p->colWidth[i]); } - fprintf(p->out,"\n"); + raw_printf(p->out, "\n"); }else if( c=='s' && strncmp(azArg[0], "stats", n)==0 ){ if( nArg==2 ){ p->statsOn = booleanValue(azArg[1]); }else{ - fprintf(stderr, "Usage: .stats on|off\n"); + raw_printf(stderr, "Usage: .stats on|off\n"); rc = 1; } }else @@ -3882,7 +3902,7 @@ static int do_meta_command(char *zLine, ShellState *p){ utf8_printf(p->out, "%s%-*s", zSp, maxlen, azResult[j] ? azResult[j]:""); } - fprintf(p->out, "\n"); + raw_printf(p->out, "\n"); } } @@ -3925,7 +3945,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( testctrl<0 ){ testctrl = aCtrl[i].ctrlCode; }else{ - fprintf(stderr, "ambiguous option name: \"%s\"\n", azArg[1]); + utf8_printf(stderr, "ambiguous option name: \"%s\"\n", azArg[1]); testctrl = -1; break; } @@ -3933,7 +3953,7 @@ static int do_meta_command(char *zLine, ShellState *p){ } if( testctrl<0 ) testctrl = (int)integerValue(azArg[1]); if( (testctrlSQLITE_TESTCTRL_LAST) ){ - fprintf(stderr,"Error: invalid testctrl option: %s\n", azArg[1]); + utf8_printf(stderr,"Error: invalid testctrl option: %s\n", azArg[1]); }else{ switch(testctrl){ @@ -3943,9 +3963,9 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==3 ){ int opt = (int)strtol(azArg[2], 0, 0); rc2 = sqlite3_test_control(testctrl, p->db, opt); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { - fprintf(stderr,"Error: testctrl %s takes a single int option\n", + utf8_printf(stderr,"Error: testctrl %s takes a single int option\n", azArg[1]); } break; @@ -3957,9 +3977,10 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_BYTEORDER: if( nArg==2 ){ rc2 = sqlite3_test_control(testctrl); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { - fprintf(stderr,"Error: testctrl %s takes no options\n", azArg[1]); + utf8_printf(stderr,"Error: testctrl %s takes no options\n", + azArg[1]); } break; @@ -3968,9 +3989,9 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==3 ){ unsigned int opt = (unsigned int)integerValue(azArg[2]); rc2 = sqlite3_test_control(testctrl, opt); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { - fprintf(stderr,"Error: testctrl %s takes a single unsigned" + utf8_printf(stderr,"Error: testctrl %s takes a single unsigned" " int option\n", azArg[1]); } break; @@ -3982,9 +4003,9 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==3 ){ int opt = booleanValue(azArg[2]); rc2 = sqlite3_test_control(testctrl, opt); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { - fprintf(stderr,"Error: testctrl %s takes a single int option\n", + utf8_printf(stderr,"Error: testctrl %s takes a single int option\n", azArg[1]); } break; @@ -3995,10 +4016,11 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==3 ){ const char *opt = azArg[2]; rc2 = sqlite3_test_control(testctrl, opt); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); } else { - fprintf(stderr,"Error: testctrl %s takes a single char * option\n", - azArg[1]); + utf8_printf(stderr, + "Error: testctrl %s takes a single char * option\n", + azArg[1]); } break; #endif @@ -4009,9 +4031,9 @@ static int do_meta_command(char *zLine, ShellState *p){ azArg[2], integerValue(azArg[3]), integerValue(azArg[4])); - fprintf(p->out, "%d (0x%08x)\n", rc2, rc2); + raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2); }else{ - fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n"); + raw_printf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n"); } break; @@ -4020,8 +4042,9 @@ static int do_meta_command(char *zLine, ShellState *p){ case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: case SQLITE_TESTCTRL_SCRATCHMALLOC: default: - fprintf(stderr,"Error: CLI support for testctrl %s not implemented\n", - azArg[1]); + utf8_printf(stderr, + "Error: CLI support for testctrl %s not implemented\n", + azArg[1]); break; } } @@ -4036,11 +4059,11 @@ static int do_meta_command(char *zLine, ShellState *p){ if( nArg==2 ){ enableTimer = booleanValue(azArg[1]); if( enableTimer && !HAS_TIMER ){ - fprintf(stderr, "Error: timer not available on this system.\n"); + raw_printf(stderr, "Error: timer not available on this system.\n"); enableTimer = 0; } }else{ - fprintf(stderr, "Usage: .timer on|off\n"); + raw_printf(stderr, "Usage: .timer on|off\n"); rc = 1; } }else @@ -4048,7 +4071,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='t' && strncmp(azArg[0], "trace", n)==0 ){ open_db(p, 0); if( nArg!=2 ){ - fprintf(stderr, "Usage: .trace FILE|off\n"); + raw_printf(stderr, "Usage: .trace FILE|off\n"); rc = 1; goto meta_command_exit; } @@ -4066,26 +4089,26 @@ static int do_meta_command(char *zLine, ShellState *p){ #if SQLITE_USER_AUTHENTICATION if( c=='u' && strncmp(azArg[0], "user", n)==0 ){ if( nArg<2 ){ - fprintf(stderr, "Usage: .user SUBCOMMAND ...\n"); + raw_printf(stderr, "Usage: .user SUBCOMMAND ...\n"); rc = 1; goto meta_command_exit; } open_db(p, 0); if( strcmp(azArg[1],"login")==0 ){ if( nArg!=4 ){ - fprintf(stderr, "Usage: .user login USER PASSWORD\n"); + raw_printf(stderr, "Usage: .user login USER PASSWORD\n"); rc = 1; goto meta_command_exit; } rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3], (int)strlen(azArg[3])); if( rc ){ - fprintf(stderr, "Authentication failed for user %s\n", azArg[2]); + utf8_printf(stderr, "Authentication failed for user %s\n", azArg[2]); rc = 1; } }else if( strcmp(azArg[1],"add")==0 ){ if( nArg!=5 ){ - fprintf(stderr, "Usage: .user add USER PASSWORD ISADMIN\n"); + raw_printf(stderr, "Usage: .user add USER PASSWORD ISADMIN\n"); rc = 1; goto meta_command_exit; } @@ -4093,12 +4116,12 @@ static int do_meta_command(char *zLine, ShellState *p){ azArg[3], (int)strlen(azArg[3]), booleanValue(azArg[4])); if( rc ){ - fprintf(stderr, "User-Add failed: %d\n", rc); + raw_printf(stderr, "User-Add failed: %d\n", rc); rc = 1; } }else if( strcmp(azArg[1],"edit")==0 ){ if( nArg!=5 ){ - fprintf(stderr, "Usage: .user edit USER PASSWORD ISADMIN\n"); + raw_printf(stderr, "Usage: .user edit USER PASSWORD ISADMIN\n"); rc = 1; goto meta_command_exit; } @@ -4106,22 +4129,22 @@ static int do_meta_command(char *zLine, ShellState *p){ azArg[3], (int)strlen(azArg[3]), booleanValue(azArg[4])); if( rc ){ - fprintf(stderr, "User-Edit failed: %d\n", rc); + raw_printf(stderr, "User-Edit failed: %d\n", rc); rc = 1; } }else if( strcmp(azArg[1],"delete")==0 ){ if( nArg!=3 ){ - fprintf(stderr, "Usage: .user delete USER\n"); + raw_printf(stderr, "Usage: .user delete USER\n"); rc = 1; goto meta_command_exit; } rc = sqlite3_user_delete(p->db, azArg[2]); if( rc ){ - fprintf(stderr, "User-Delete failed: %d\n", rc); + raw_printf(stderr, "User-Delete failed: %d\n", rc); rc = 1; } }else{ - fprintf(stderr, "Usage: .user login|add|edit|delete ...\n"); + raw_printf(stderr, "Usage: .user login|add|edit|delete ...\n"); rc = 1; goto meta_command_exit; } @@ -4129,7 +4152,7 @@ static int do_meta_command(char *zLine, ShellState *p){ #endif /* SQLITE_USER_AUTHENTICATION */ if( c=='v' && strncmp(azArg[0], "version", n)==0 ){ - fprintf(p->out, "SQLite %s %s\n" /*extra-version-info*/, + utf8_printf(p->out, "SQLite %s %s\n" /*extra-version-info*/, sqlite3_libversion(), sqlite3_sourceid()); }else @@ -4139,10 +4162,10 @@ static int do_meta_command(char *zLine, ShellState *p){ if( p->db ){ sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFS_POINTER, &pVfs); if( pVfs ){ - fprintf(p->out, "vfs.zName = \"%s\"\n", pVfs->zName); - fprintf(p->out, "vfs.iVersion = %d\n", pVfs->iVersion); - fprintf(p->out, "vfs.szOsFile = %d\n", pVfs->szOsFile); - fprintf(p->out, "vfs.mxPathname = %d\n", pVfs->mxPathname); + utf8_printf(p->out, "vfs.zName = \"%s\"\n", pVfs->zName); + raw_printf(p->out, "vfs.iVersion = %d\n", pVfs->iVersion); + raw_printf(p->out, "vfs.szOsFile = %d\n", pVfs->szOsFile); + raw_printf(p->out, "vfs.mxPathname = %d\n", pVfs->mxPathname); } } }else @@ -4153,7 +4176,7 @@ static int do_meta_command(char *zLine, ShellState *p){ if( p->db ){ sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFSNAME, &zVfsName); if( zVfsName ){ - fprintf(p->out, "%s\n", zVfsName); + utf8_printf(p->out, "%s\n", zVfsName); sqlite3_free(zVfsName); } } @@ -4175,7 +4198,7 @@ static int do_meta_command(char *zLine, ShellState *p){ }else { - fprintf(stderr, "Error: unknown command or invalid arguments: " + utf8_printf(stderr, "Error: unknown command or invalid arguments: " " \"%s\". Enter \".help\" for help\n", azArg[0]); rc = 1; } @@ -4310,7 +4333,7 @@ static int process_input(ShellState *p, FILE *in){ nAlloc = nSql+nLine+100; zSql = realloc(zSql, nAlloc); if( zSql==0 ){ - fprintf(stderr, "Error: out of memory\n"); + raw_printf(stderr, "Error: out of memory\n"); exit(1); } } @@ -4344,15 +4367,15 @@ static int process_input(ShellState *p, FILE *in){ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "Error:"); } if( zErrMsg!=0 ){ - fprintf(stderr, "%s %s\n", zPrefix, zErrMsg); + utf8_printf(stderr, "%s %s\n", zPrefix, zErrMsg); sqlite3_free(zErrMsg); zErrMsg = 0; }else{ - fprintf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db)); + utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db)); } errCnt++; }else if( p->countChanges ){ - fprintf(p->out, "changes: %3d total_changes: %d\n", + raw_printf(p->out, "changes: %3d total_changes: %d\n", sqlite3_changes(p->db), sqlite3_total_changes(p->db)); } nSql = 0; @@ -4367,7 +4390,7 @@ static int process_input(ShellState *p, FILE *in){ } if( nSql ){ if( !_all_whitespace(zSql) ){ - fprintf(stderr, "Error: incomplete SQL: %s\n", zSql); + utf8_printf(stderr, "Error: incomplete SQL: %s\n", zSql); errCnt++; } } @@ -4458,7 +4481,7 @@ static void process_sqliterc( if (sqliterc == NULL) { home_dir = find_home_dir(); if( home_dir==0 ){ - fprintf(stderr, "-- warning: cannot find home directory;" + raw_printf(stderr, "-- warning: cannot find home directory;" " cannot read ~/.sqliterc\n"); return; } @@ -4469,7 +4492,7 @@ static void process_sqliterc( in = fopen(sqliterc,"rb"); if( in ){ if( stdin_is_interactive ){ - fprintf(stderr,"-- Loading resources from %s\n",sqliterc); + utf8_printf(stderr,"-- Loading resources from %s\n",sqliterc); } process_input(p,in); fclose(in); @@ -4516,14 +4539,14 @@ static const char zOptions[] = #endif ; static void usage(int showDetail){ - fprintf(stderr, + utf8_printf(stderr, "Usage: %s [OPTIONS] FILENAME [SQL]\n" "FILENAME is the name of an SQLite database. A new database is created\n" "if the file does not previously exist.\n", Argv0); if( showDetail ){ - fprintf(stderr, "OPTIONS include:\n%s", zOptions); + utf8_printf(stderr, "OPTIONS include:\n%s", zOptions); }else{ - fprintf(stderr, "Use the -help option for additional information\n"); + raw_printf(stderr, "Use the -help option for additional information\n"); } exit(1); } @@ -4571,7 +4594,7 @@ static void printBold(const char *zText){ */ static char *cmdline_option_value(int argc, char **argv, int i){ if( i==argc ){ - fprintf(stderr, "%s: Error: missing argument to %s\n", + utf8_printf(stderr, "%s: Error: missing argument to %s\n", argv[0], argv[argc-1]); exit(1); } @@ -4591,7 +4614,7 @@ int SQLITE_CDECL main(int argc, char **argv){ #if USE_SYSTEM_SQLITE+0!=1 if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){ - fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", + utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", sqlite3_sourceid(), SQLITE_SOURCE_ID); exit(1); } @@ -4640,7 +4663,7 @@ int SQLITE_CDECL main(int argc, char **argv){ nCmd++; azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd); if( azCmd==0 ){ - fprintf(stderr, "out of memory\n"); + raw_printf(stderr, "out of memory\n"); exit(1); } azCmd[nCmd-1] = z; @@ -4722,7 +4745,7 @@ int SQLITE_CDECL main(int argc, char **argv){ if( pVfs ){ sqlite3_vfs_register(pVfs, 1); }else{ - fprintf(stderr, "no such VFS: \"%s\"\n", argv[i]); + utf8_printf(stderr, "no such VFS: \"%s\"\n", argv[i]); exit(1); } } @@ -4732,7 +4755,7 @@ int SQLITE_CDECL main(int argc, char **argv){ data.zDbFilename = ":memory:"; warnInmemoryDb = argc==1; #else - fprintf(stderr,"%s: Error: no database filename specified\n", Argv0); + utf8_printf(stderr,"%s: Error: no database filename specified\n", Argv0); return 1; #endif } @@ -4854,16 +4877,16 @@ int SQLITE_CDECL main(int argc, char **argv){ open_db(&data, 0); rc = shell_exec(data.db, z, shell_callback, &data, &zErrMsg); if( zErrMsg!=0 ){ - fprintf(stderr,"Error: %s\n", zErrMsg); + utf8_printf(stderr,"Error: %s\n", zErrMsg); if( bail_on_error ) return rc!=0 ? rc : 1; }else if( rc!=0 ){ - fprintf(stderr,"Error: unable to process SQL \"%s\"\n", z); + utf8_printf(stderr,"Error: unable to process SQL \"%s\"\n", z); if( bail_on_error ) return rc; } } }else{ - fprintf(stderr,"%s: Error: unknown option: %s\n", Argv0, z); - fprintf(stderr,"Use -help for a list of options.\n"); + utf8_printf(stderr,"%s: Error: unknown option: %s\n", Argv0, z); + raw_printf(stderr,"Use -help for a list of options.\n"); return 1; } } @@ -4881,10 +4904,10 @@ int SQLITE_CDECL main(int argc, char **argv){ open_db(&data, 0); rc = shell_exec(data.db, azCmd[i], shell_callback, &data, &zErrMsg); if( zErrMsg!=0 ){ - fprintf(stderr,"Error: %s\n", zErrMsg); + utf8_printf(stderr,"Error: %s\n", zErrMsg); return rc!=0 ? rc : 1; }else if( rc!=0 ){ - fprintf(stderr,"Error: unable to process SQL: %s\n", azCmd[i]); + utf8_printf(stderr,"Error: unable to process SQL: %s\n", azCmd[i]); return rc; } } From bdfa1b94e9a459159f063a5cd5d79ea738cc3a38 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 31 Dec 2015 22:29:36 +0000 Subject: [PATCH 16/37] Fix the ieee754.test module so that it works both on systems that report infinity as "inf" and as "Inf". FossilOrigin-Name: d41d4d7396fba60895535f21c438f8c75e7b2097 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/ieee754.test | 16 ++++++++++------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 3c7f5db48d..777a162846 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sshell,\suse\sutf8_printf()\swhen\sany\sstring\sformatting\sis\spresent\sand\sraw_printf()\sotherwise. -D 2015-12-31T19:06:24.721 +C Fix\sthe\sieee754.test\smodule\sso\sthat\sit\sworks\sboth\son\ssystems\sthat\sreport\ninfinity\sas\s"inf"\sand\sas\s"Inf". +D 2015-12-31T22:29:36.133 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -761,7 +761,7 @@ F test/hexlit.test d7b0a5f41123df1e43985b91b8b2e70f95282d21 F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711 F test/hook.test 162d7cef7a2d2b04839fe14402934e6a1b79442f F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4 -F test/ieee754.test 118b665a97a8df0e8f2fbdb07d113e596f4a6b53 +F test/ieee754.test 806fc0ce7f305f57e3331eaceeddcfec9339e607 F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 F test/in.test 61a24ae38d4b64ec69f06ccdf022992f68a98176 F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 98ec778daac835d9ae103f6460b7d897981a5dd6 -R cd1e993dc14f9af3b107557468145aaf -U mistachkin -Z 770ade254ba97d3649a2f5b30f5d6fd8 +P 8cf01fff232d15d3c7b7b62b2d890d983e1945f2 +R 1c5d971ba298f5f3c5fb001aa5fe882d +U drh +Z d166bbddc4f1202c8b662a343755f966 diff --git a/manifest.uuid b/manifest.uuid index 4302de3a4a..80841183f5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8cf01fff232d15d3c7b7b62b2d890d983e1945f2 \ No newline at end of file +d41d4d7396fba60895535f21c438f8c75e7b2097 \ No newline at end of file diff --git a/test/ieee754.test b/test/ieee754.test index c0bf9d7995..bf0676429b 100644 --- a/test/ieee754.test +++ b/test/ieee754.test @@ -43,12 +43,16 @@ foreach {id float rep} { } } -do_execsql_test ieee754-110 { - SELECT ieee754(1,1024), ieee754(4503599627370495,972); -} {Inf 1.79769313486232e+308} -do_execsql_test ieee754-111 { - SELECT ieee754(-1,1024), ieee754(-4503599627370495,972); -} {-Inf -1.79769313486232e+308} +do_test ieee754-110 { + string tolower [ + db eval {SELECT ieee754(1,1024), ieee754(4503599627370495,972);} + ] +} {inf 1.79769313486232e+308} +do_test ieee754-111 { + string tolower [ + db eval {SELECT ieee754(-1,1024), ieee754(-4503599627370495,972);} + ] +} {-inf -1.79769313486232e+308} do_execsql_test ieee754-112 { SELECT ieee754(4503599627370495,973) is null; } {1} From 2307926ea9c6f5da271c6662b3441d6765366bbb Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Jan 2016 00:15:59 +0000 Subject: [PATCH 17/37] Remove unreachable branches from the new JSON aggregate functions. FossilOrigin-Name: 6e30f8c6c3af9b0df39783888a1479f88271f989 --- ext/misc/json1.c | 4 ++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/misc/json1.c b/ext/misc/json1.c index 0bd0baff12..3707516660 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -1549,7 +1549,7 @@ static void jsonArrayFinal(sqlite3_context *ctx){ jsonAppendChar(pStr, ']'); if( pStr->bErr ){ sqlite3_result_error_nomem(ctx); - if( !pStr->bStatic ) sqlite3_free(pStr->zBuf); + assert( pStr->bStatic ); }else{ sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); @@ -1597,7 +1597,7 @@ static void jsonObjectFinal(sqlite3_context *ctx){ jsonAppendChar(pStr, '}'); if( pStr->bErr ){ sqlite3_result_error_nomem(ctx); - if( !pStr->bStatic ) sqlite3_free(pStr->zBuf); + assert( pStr->bStatic ); }else{ sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed, pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); diff --git a/manifest b/manifest index 777a162846..5325ac3c14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sieee754.test\smodule\sso\sthat\sit\sworks\sboth\son\ssystems\sthat\sreport\ninfinity\sas\s"inf"\sand\sas\s"Inf". -D 2015-12-31T22:29:36.133 +C Remove\sunreachable\sbranches\sfrom\sthe\snew\sJSON\saggregate\sfunctions. +D 2016-01-01T00:15:59.486 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -191,7 +191,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c -F ext/misc/json1.c b7ed42db00f7429c0f0b5068209c95c41b531596 +F ext/misc/json1.c 7b1155f520d5e8ec1c005d978ac675e8a7f2688a F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8cf01fff232d15d3c7b7b62b2d890d983e1945f2 -R 1c5d971ba298f5f3c5fb001aa5fe882d +P d41d4d7396fba60895535f21c438f8c75e7b2097 +R 2a5f60ea0e38c7e7f43524504946739d U drh -Z d166bbddc4f1202c8b662a343755f966 +Z 26d827cb451c91d1af0425a029635f07 diff --git a/manifest.uuid b/manifest.uuid index 80841183f5..f52f04dccd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d41d4d7396fba60895535f21c438f8c75e7b2097 \ No newline at end of file +6e30f8c6c3af9b0df39783888a1479f88271f989 \ No newline at end of file From a660caf2f01c99ef48085c731e200b5a2fa575b5 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Jan 2016 03:37:44 +0000 Subject: [PATCH 18/37] Fix an assert() that might be false for a corrupt database. FossilOrigin-Name: 68360cd2211b7ab25dd4ca55a2e82e31f51f2976 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5325ac3c14..b08341888c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunreachable\sbranches\sfrom\sthe\snew\sJSON\saggregate\sfunctions. -D 2016-01-01T00:15:59.486 +C Fix\san\sassert()\sthat\smight\sbe\sfalse\sfor\sa\scorrupt\sdatabase. +D 2016-01-01T03:37:44.301 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -276,7 +276,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 5ac3f868d4f20a67f0f00a1014940f902b511558 +F src/btree.c 4d3452b2a3daf875490ac4f0a278da7f85fabe12 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 F src/build.c 1c9fb552148ee8f9234435a38833f8fca2081a71 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d41d4d7396fba60895535f21c438f8c75e7b2097 -R 2a5f60ea0e38c7e7f43524504946739d +P 6e30f8c6c3af9b0df39783888a1479f88271f989 +R 6e164f424e8aa8f067cc3a49970e615a U drh -Z 26d827cb451c91d1af0425a029635f07 +Z 284865b0f74f185e26863aa2df0b68aa diff --git a/manifest.uuid b/manifest.uuid index f52f04dccd..7d85a2b67d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6e30f8c6c3af9b0df39783888a1479f88271f989 \ No newline at end of file +68360cd2211b7ab25dd4ca55a2e82e31f51f2976 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index df9455bc5b..f5feff8a4c 100644 --- a/src/btree.c +++ b/src/btree.c @@ -8221,7 +8221,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, int bPreserve){ if( rc==SQLITE_OK ){ if( bSkipnext ){ - assert( bPreserve && pCur->iPage==iCellDepth ); + assert( bPreserve && (pCur->iPage==iCellDepth || CORRUPT_DB) ); assert( pPage==pCur->apPage[pCur->iPage] ); assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell ); pCur->eState = CURSOR_SKIPNEXT; From 3c19bb60d108a48a6b9ddf7f84bf085edc7e8e17 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Jan 2016 16:26:22 +0000 Subject: [PATCH 19/37] Avoid misaligned memory allocations on Sparc in sqlite3VdbeMakeReady(). FossilOrigin-Name: a304e34675404aee860fcc97fa4ffcc57c014812 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 5 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index b08341888c..7e83b58a5a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sassert()\sthat\smight\sbe\sfalse\sfor\sa\scorrupt\sdatabase. -D 2016-01-01T03:37:44.301 +C Avoid\smisaligned\smemory\sallocations\son\sSparc\sin\ssqlite3VdbeMakeReady(). +D 2016-01-01T16:26:22.999 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -402,7 +402,7 @@ F src/vdbe.c 39d7628bb8eed10a5378adcf97cca6dce7829a8f F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c ca523180c128dc6c64894efc61eb14374117c864 +F src/vdbeaux.c 2a25e57e140a3cdef14dc11912c174cf6eb9d5a6 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6e30f8c6c3af9b0df39783888a1479f88271f989 -R 6e164f424e8aa8f067cc3a49970e615a +P 68360cd2211b7ab25dd4ca55a2e82e31f51f2976 +R be44c4e5edec4a82a16bfbdbf7214b99 U drh -Z 284865b0f74f185e26863aa2df0b68aa +Z f1917e9fad1e2726446c5b64d14d6919 diff --git a/manifest.uuid b/manifest.uuid index 7d85a2b67d..940d1e52e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -68360cd2211b7ab25dd4ca55a2e82e31f51f2976 \ No newline at end of file +a304e34675404aee860fcc97fa4ffcc57c014812 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 10353e839f..9c35fc12d9 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1849,9 +1849,8 @@ void sqlite3VdbeMakeReady( /* Allocate space for memory registers, SQL variables, VDBE cursors and ** an array to marshal SQL function arguments in. */ - zCsr = (u8*)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ - assert( pParse->nOpAlloc*sizeof(Op) <= 0x7fffff00 ); - nFree = (pParse->nOpAlloc - p->nOp)*sizeof(p->aOp[0]); /* Available space */ + zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ + nFree = sqlite3_msize(p->aOp) - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); From bd57308eef5dfaf99b0d242caaac0f69067b4e61 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 1 Jan 2016 16:42:09 +0000 Subject: [PATCH 20/37] Remember the size of the Vdbe.aOp[] array in bytes, to avoid unnecessary calls to sqlite3_msize(). FossilOrigin-Name: 3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 1 + src/vdbeaux.c | 8 +++++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 7e83b58a5a..677f2d0a83 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\smisaligned\smemory\sallocations\son\sSparc\sin\ssqlite3VdbeMakeReady(). -D 2016-01-01T16:26:22.999 +C Remember\sthe\ssize\sof\sthe\sVdbe.aOp[]\sarray\sin\sbytes,\sto\savoid\sunnecessary\ncalls\sto\ssqlite3_msize(). +D 2016-01-01T16:42:09.017 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -338,7 +338,7 @@ F src/shell.c 8d152e833c3b79825978deb83175234749c5cdf3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 92f83ab4612141f95cdd663ea55fa4528f3f8c2a +F src/sqliteInt.h 30f7e8957ed7d244be027be72ded385154c635df F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -402,7 +402,7 @@ F src/vdbe.c 39d7628bb8eed10a5378adcf97cca6dce7829a8f F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 2a25e57e140a3cdef14dc11912c174cf6eb9d5a6 +F src/vdbeaux.c 66b546a1da82dfa6e67985ae0442ba5fd9efe0ff F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 68360cd2211b7ab25dd4ca55a2e82e31f51f2976 -R be44c4e5edec4a82a16bfbdbf7214b99 +P a304e34675404aee860fcc97fa4ffcc57c014812 +R 4471a4984cac341d5421a7094690c1b8 U drh -Z f1917e9fad1e2726446c5b64d14d6919 +Z 73de58c32dddcab1338ba5f059ee0a34 diff --git a/manifest.uuid b/manifest.uuid index 940d1e52e4..85183cd86a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a304e34675404aee860fcc97fa4ffcc57c014812 \ No newline at end of file +3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index e1fe6dae79..53f0709645 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2732,6 +2732,7 @@ struct Parse { int nSet; /* Number of sets used so far */ int nOnce; /* Number of OP_Once instructions so far */ int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */ + int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */ int iFixedOp; /* Never back out opcodes iFixedOp-1 or earlier */ int ckBase; /* Base register of data during check constraints */ int iSelfTab; /* Table of an index whose exprs are being coded */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 9c35fc12d9..7d547e5830 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -35,6 +35,7 @@ Vdbe *sqlite3VdbeCreate(Parse *pParse){ assert( pParse->aLabel==0 ); assert( pParse->nLabel==0 ); assert( pParse->nOpAlloc==0 ); + assert( pParse->szOpAlloc==0 ); return p; } @@ -124,7 +125,8 @@ static int growOpArray(Vdbe *v, int nOp){ assert( nNew>=(p->nOpAlloc+nOp) ); pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op)); if( pNew ){ - p->nOpAlloc = sqlite3DbMallocSize(p->db, pNew)/sizeof(Op); + p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew); + p->nOpAlloc = p->szOpAlloc/sizeof(Op); v->aOp = pNew; } return (pNew ? SQLITE_OK : SQLITE_NOMEM); @@ -1849,8 +1851,8 @@ void sqlite3VdbeMakeReady( /* Allocate space for memory registers, SQL variables, VDBE cursors and ** an array to marshal SQL function arguments in. */ - zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ - nFree = sqlite3_msize(p->aOp) - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ + zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ + nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); From 9abe841e9e7cdd4736001ab45f2d7b879ba716be Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 2 Jan 2016 05:00:31 +0000 Subject: [PATCH 21/37] Fix a (harmless) typo in an #ifdef for SQLITE_ENABLE_CURSOR_HINTS FossilOrigin-Name: 2047d2deabf2021ea05d620c3dd4919448027b11 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 677f2d0a83..517a481aea 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remember\sthe\ssize\sof\sthe\sVdbe.aOp[]\sarray\sin\sbytes,\sto\savoid\sunnecessary\ncalls\sto\ssqlite3_msize(). -D 2016-01-01T16:42:09.017 +C Fix\sa\s(harmless)\stypo\sin\san\s#ifdef\sfor\sSQLITE_ENABLE_CURSOR_HINTS +D 2016-01-02T05:00:31.568 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -398,7 +398,7 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 39d7628bb8eed10a5378adcf97cca6dce7829a8f +F src/vdbe.c 638c20bae996d8037a114294016768b6bc8ebc14 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a304e34675404aee860fcc97fa4ffcc57c014812 -R 4471a4984cac341d5421a7094690c1b8 +P 3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc +R 5906d6b78129d8858a23ea4c57fad965 U drh -Z 73de58c32dddcab1338ba5f059ee0a34 +Z 4843af3fcc8c5413e769bb1983160a44 diff --git a/manifest.uuid b/manifest.uuid index 85183cd86a..2fbf3ac886 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc \ No newline at end of file +2047d2deabf2021ea05d620c3dd4919448027b11 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 5021720c54..c8fc6ff45b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3402,7 +3402,7 @@ open_cursor_set_hints: assert( OPFLAG_BULKCSR==BTREE_BULKLOAD ); assert( OPFLAG_SEEKEQ==BTREE_SEEK_EQ ); testcase( pOp->p5 & OPFLAG_BULKCSR ); -#ifdef SQLITE_ENABLE_CURSOR_HINT +#ifdef SQLITE_ENABLE_CURSOR_HINTS testcase( pOp->p2 & OPFLAG_SEEKEQ ); #endif sqlite3BtreeCursorHintFlags(pCur->uc.pCursor, From 573d88e8ed091fd3ace6f6f87458d06dc45e9e6f Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 3 Jan 2016 11:17:04 +0000 Subject: [PATCH 22/37] Add the number of cores used and the name of the host computer to the summary at the end of releasetest.tcl. FossilOrigin-Name: cd3ae0f14c6b28b328b208431d0effcb7b062ec6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/releasetest.tcl | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 517a481aea..394319edbf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\s(harmless)\stypo\sin\san\s#ifdef\sfor\sSQLITE_ENABLE_CURSOR_HINTS -D 2016-01-02T05:00:31.568 +C Add\sthe\snumber\sof\scores\sused\sand\sthe\sname\sof\sthe\shost\scomputer\sto\sthe\nsummary\sat\sthe\send\sof\sreleasetest.tcl. +D 2016-01-03T11:17:04.115 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -947,7 +947,7 @@ F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl 622f2381b217facdf429584a5c292cc1fc47e7c0 +F test/releasetest.tcl f84ff16fef79ee5d328eee7c48da084a775d101c F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc -R 5906d6b78129d8858a23ea4c57fad965 +P 2047d2deabf2021ea05d620c3dd4919448027b11 +R ea21a9ede315d15a7b1dfcf0bcd428e9 U drh -Z 4843af3fcc8c5413e769bb1983160a44 +Z a5cb2210a915d9603f738ab23bc99890 diff --git a/manifest.uuid b/manifest.uuid index 2fbf3ac886..72d55b1f12 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2047d2deabf2021ea05d620c3dd4919448027b11 \ No newline at end of file +cd3ae0f14c6b28b328b208431d0effcb7b062ec6 \ No newline at end of file diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 7f53fd1523..8cf7a76fb8 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -830,8 +830,8 @@ proc process_options {argv} { } default { - PUTSERR stderr "" - PUTSERR stderr [string trim $::USAGE_MESSAGE] + PUTSERR "" + PUTSERR [string trim $::USAGE_MESSAGE] exit -1 } } @@ -945,6 +945,8 @@ proc main {argv} { set min [expr {($elapsetime/60)%60}] set sec [expr {$elapsetime%60}] set etime [format (%02d:%02d:%02d) $hr $min $sec] + if {$::JOBS>1} {append etime " $::JOBS cores"} + if {[catch {exec hostname} HNAME]==0} {append etime " on $HNAME"} PUTS [string repeat * 79] incr ::NERRCASE $::NERR PUTS "$::NERRCASE failures out of $::NTESTCASE tests in $etime" From 41d0ba72aeb274578ea3f06437d363a0ae5377ce Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 3 Jan 2016 11:27:47 +0000 Subject: [PATCH 23/37] Fix a premature reference to utf8_printf in shell.c. FossilOrigin-Name: 76f5efa68728d899a63a74f2528dfd0c497aa5f0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 394319edbf..218d499932 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\snumber\sof\scores\sused\sand\sthe\sname\sof\sthe\shost\scomputer\sto\sthe\nsummary\sat\sthe\send\sof\sreleasetest.tcl. -D 2016-01-03T11:17:04.115 +C Fix\sa\spremature\sreference\sto\sutf8_printf\sin\sshell.c. +D 2016-01-03T11:27:47.410 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -334,7 +334,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f -F src/shell.c 8d152e833c3b79825978deb83175234749c5cdf3 +F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2047d2deabf2021ea05d620c3dd4919448027b11 -R ea21a9ede315d15a7b1dfcf0bcd428e9 +P cd3ae0f14c6b28b328b208431d0effcb7b062ec6 +R 17c9e71fcd959bf7c676bff4a8176b10 U drh -Z a5cb2210a915d9603f738ab23bc99890 +Z cf0da92d1077e771f4727b72b37c0046 diff --git a/manifest.uuid b/manifest.uuid index 72d55b1f12..1130aa9c0e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd3ae0f14c6b28b328b208431d0effcb7b062ec6 \ No newline at end of file +76f5efa68728d899a63a74f2528dfd0c497aa5f0 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index ecb591a32a..b7a7abcd33 100644 --- a/src/shell.c +++ b/src/shell.c @@ -382,7 +382,7 @@ static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){ va_start(ap, zFormat); z = sqlite3_vmprintf(zFormat, ap); va_end(ap); - utf8_printf(iotrace, "%s", z); + fprintf(iotrace, "%s", z); sqlite3_free(z); } #endif From dc0b1f1c29e949a6145ed0e548846ba42b64d729 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 3 Jan 2016 18:07:57 +0000 Subject: [PATCH 24/37] Bug fix: the conflict resolution behavior for the implied NOT NULL constraint on the PRIMARY KEY of a WITHOUT ROWID table should be ABORT. FossilOrigin-Name: e30062e9f6cae980150dda7df440b36dfdcb7bbe --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/build.c | 2 +- test/conflict2.test | 8 ++++---- test/without_rowid5.test | 6 +++++- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 218d499932..584914720e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spremature\sreference\sto\sutf8_printf\sin\sshell.c. -D 2016-01-03T11:27:47.410 +C Bug\sfix:\sthe\sconflict\sresolution\sbehavior\sfor\sthe\simplied\sNOT\sNULL\sconstraint\non\sthe\sPRIMARY\sKEY\sof\sa\sWITHOUT\sROWID\stable\sshould\sbe\sABORT. +D 2016-01-03T18:07:57.631 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -279,7 +279,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 F src/btree.c 4d3452b2a3daf875490ac4f0a278da7f85fabe12 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 -F src/build.c 1c9fb552148ee8f9234435a38833f8fca2081a71 +F src/build.c d8006e9030c61b9495d0b2f724edd3fcdae16930 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -524,7 +524,7 @@ F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1 F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/conflict.test 841bcf7cabbfca39c577eb8411ea8601843b46a8 -F test/conflict2.test 0d3af4fb534fa1bd020c79960bb56e4d52655f09 +F test/conflict2.test 0f0e810aef6739650d7f442164975e932cf18afc F test/conflict3.test dec0634c0f31dec9a4b01c63063e939f0cd21b6b F test/contrib01.test 2a1cbc0f2f48955d7d073f725765da6fbceda6b4 F test/corrupt.test 141c39ea650c1365e85a49e402fa05cb9617fb97 @@ -1340,7 +1340,7 @@ F test/without_rowid1.test 1a7b9bd51b899928d327052df9741d2fe8dbe701 F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99 F test/without_rowid3.test aad4f9d383e199349b6c7e508a778f7dff5dff79 F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a -F test/without_rowid5.test 61256715b686359df48ca1742db50cc7e3e7b862 +F test/without_rowid5.test 89b1c587bd92a0590e440da33e7666bf4891572a F test/without_rowid6.test 1f99644e6508447fb050f73697350c7ceca3392e F test/wordcount.c 2a0a6c0d0e8e8bbbac1f06d72a6791828c37c0cf F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P cd3ae0f14c6b28b328b208431d0effcb7b062ec6 -R 17c9e71fcd959bf7c676bff4a8176b10 +P 76f5efa68728d899a63a74f2528dfd0c497aa5f0 +R 478df71a9631f4b73fcefbae5de2f355 U drh -Z cf0da92d1077e771f4727b72b37c0046 +Z 2ce3cb02ff6782c368c437352328d0d1 diff --git a/manifest.uuid b/manifest.uuid index 1130aa9c0e..c0ad5b411d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76f5efa68728d899a63a74f2528dfd0c497aa5f0 \ No newline at end of file +e30062e9f6cae980150dda7df440b36dfdcb7bbe \ No newline at end of file diff --git a/src/build.c b/src/build.c index ffefead9db..63e3004657 100644 --- a/src/build.c +++ b/src/build.c @@ -1774,7 +1774,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ ** do not enforce this for imposter tables.) */ if( !db->init.imposterTable ){ for(i=0; iaCol[pPk->aiColumn[i]].notNull = 1; + pTab->aCol[pPk->aiColumn[i]].notNull = OE_Abort; } pPk->uniqNotNull = 1; } diff --git a/test/conflict2.test b/test/conflict2.test index 8419f1a3ff..e8880635f1 100644 --- a/test/conflict2.test +++ b/test/conflict2.test @@ -289,11 +289,11 @@ do_test conflict2-6.0 { # foreach {i conf1 cmd t0 t1 t2 t3 t4} { 1 {} UPDATE 1 {6 7 8 9} 1 0 1 - 2 REPLACE UPDATE 0 {7 6 9} 1 0 0 - 3 IGNORE UPDATE 0 {6 7 3 9} 1 0 0 - 4 FAIL UPDATE 1 {6 7 3 4} 1 0 0 + 2 REPLACE UPDATE 0 {7 6 9} 1 1 0 + 3 IGNORE UPDATE 0 {6 7 3 9} 1 1 0 + 4 FAIL UPDATE 1 {6 7 3 4} 1 1 0 5 ABORT UPDATE 1 {1 2 3 4} 1 0 1 - 6 ROLLBACK UPDATE 1 {1 2 3 4} 0 0 0 + 6 ROLLBACK UPDATE 1 {1 2 3 4} 0 1 0 7 REPLACE {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 8 IGNORE {UPDATE OR REPLACE} 0 {7 6 9} 1 0 1 9 FAIL {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 diff --git a/test/without_rowid5.test b/test/without_rowid5.test index d163d9c1bc..31a440ad87 100644 --- a/test/without_rowid5.test +++ b/test/without_rowid5.test @@ -132,9 +132,13 @@ do_execsql_test without_rowid5-5.1 { INSERT INTO ipk VALUES('rival','bonus'); -- ok to insert non-integer key SELECT * FROM ipk; } {rival bonus} -do_catchsql_test without_rowid5-5.2 { +do_catchsql_test without_rowid5-5.2a { + BEGIN; INSERT INTO ipk VALUES(NULL,'sample'); -- no automatic generation of keys } {1 {NOT NULL constraint failed: ipk.key}} +do_execsql_test without_rowid5-5.2b { + ROLLBACK; +} {} # EVIDENCE-OF: R-33142-02092 AUTOINCREMENT does not work on WITHOUT # ROWID tables. From 7f10579a82a158b71ca3fd05c241c5ebb9cb3fee Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 01:08:50 +0000 Subject: [PATCH 25/37] Add releasetest.tcl cases for SQLITE_LIKE_DOESNT_MATCH_BLOB and for SQLITE_ENABLE_CURSOR_HINTS. FossilOrigin-Name: f300c35efa5f7383b2a74b1c9466c243c17815e4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/cursorhint.test | 12 ++++++------ test/releasetest.tcl | 2 ++ 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 584914720e..00ec784d9b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bug\sfix:\sthe\sconflict\sresolution\sbehavior\sfor\sthe\simplied\sNOT\sNULL\sconstraint\non\sthe\sPRIMARY\sKEY\sof\sa\sWITHOUT\sROWID\stable\sshould\sbe\sABORT. -D 2016-01-03T18:07:57.631 +C Add\sreleasetest.tcl\scases\sfor\sSQLITE_LIKE_DOESNT_MATCH_BLOB\sand\nfor\sSQLITE_ENABLE_CURSOR_HINTS. +D 2016-01-04T01:08:50.342 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -562,7 +562,7 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 -F test/cursorhint.test 432811b62bd5ffb812729f49bba3b9ad687550bb +F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856 F test/date.test 984ac1e3e5e031386866f034006148d3972b4a65 F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204 F test/dbstatus2.test 10418e62b3db5dca070f0c3eef3ea13946f339c2 @@ -947,7 +947,7 @@ F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736 F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl f84ff16fef79ee5d328eee7c48da084a775d101c +F test/releasetest.tcl 975449bf742b8bb9025208292208af816a1fcb58 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 76f5efa68728d899a63a74f2528dfd0c497aa5f0 -R 478df71a9631f4b73fcefbae5de2f355 +P e30062e9f6cae980150dda7df440b36dfdcb7bbe +R 60c0d617eaaaa3eb60de4d61ace77f3f U drh -Z 2ce3cb02ff6782c368c437352328d0d1 +Z bf759b86247c24cfa4d33f391ba06db6 diff --git a/manifest.uuid b/manifest.uuid index c0ad5b411d..6624b9ab92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e30062e9f6cae980150dda7df440b36dfdcb7bbe \ No newline at end of file +f300c35efa5f7383b2a74b1c9466c243c17815e4 \ No newline at end of file diff --git a/test/cursorhint.test b/test/cursorhint.test index 69bc248cd7..ae86120fa8 100644 --- a/test/cursorhint.test +++ b/test/cursorhint.test @@ -46,10 +46,10 @@ proc p4_of_opcode {db opcode sql} { # Run EXPLAIN on $sql. Return a list of P5 values for all $opcode # opcodes that contain regexp $comment in their comment # -proc p5_of_opcode {db opcode comment sql} { +proc p5_of_opcode {db opcode sql} { set res {} $db eval "EXPLAIN $sql" x { - if {$x(opcode)==$opcode && [regexp $comment $x(comment)]} { + if {$x(opcode)==$opcode} { lappend res $x(p5) } } @@ -66,7 +66,7 @@ do_test 1.1 { } } {{EQ(r[1],c0)}} do_test 1.2 { - p5_of_opcode db OpenRead . { + p5_of_opcode db OpenRead { SELECT * FROM t1 CROSS JOIN t2 WHERE a=x } } {00 00} @@ -79,7 +79,7 @@ do_test 2.1 { } } {{EQ(c0,r[1])}} do_test 2.2 { - p5_of_opcode db OpenRead . { + p5_of_opcode db OpenRead { SELECT * FROM t2 CROSS JOIN t1 WHERE a=x } } {00 00} @@ -114,7 +114,7 @@ do_test 4.1desc { } } {GT(c0,11)} do_test 4.2 { - p5_of_opcode db OpenRead . { + p5_of_opcode db OpenRead { SELECT * FROM t1 WHERE b>11; } } {02 00} @@ -129,7 +129,7 @@ do_test 4.3desc { } } {} do_test 4.4 { - p5_of_opcode db OpenRead . { + p5_of_opcode db OpenRead { SELECT c FROM t1 WHERE b<11; } } {00} diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 8cf7a76fb8..bb902eec3e 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -86,6 +86,8 @@ array set ::Configs [strip_comments { -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 -DSQLITE_ENABLE_STMT_SCANSTATUS + -DSQLITE_LIKE_DOESNT_MATCH_BLOBS + -DSQLITE_ENABLE_CURSOR_HINTS --enable-json1 } "Check-Symbols" { From 9fbc885afcbf09b90322bab8f0daf613df2fa26b Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 03:48:46 +0000 Subject: [PATCH 26/37] Fix a harmless compiler warning. FossilOrigin-Name: 4b404a99aa9bfa6cfe8998f5dc1f84f8be20b840 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 00ec784d9b..39fe0a1326 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sreleasetest.tcl\scases\sfor\sSQLITE_LIKE_DOESNT_MATCH_BLOB\sand\nfor\sSQLITE_ENABLE_CURSOR_HINTS. -D 2016-01-04T01:08:50.342 +C Fix\sa\sharmless\scompiler\swarning. +D 2016-01-04T03:48:46.399 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -398,7 +398,7 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 638c20bae996d8037a114294016768b6bc8ebc14 +F src/vdbe.c 6ac8e5d808d48afc369316e147c191102f0584c1 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P e30062e9f6cae980150dda7df440b36dfdcb7bbe -R 60c0d617eaaaa3eb60de4d61ace77f3f +P f300c35efa5f7383b2a74b1c9466c243c17815e4 +R a3643a709add89c526ff9d85846c177f U drh -Z bf759b86247c24cfa4d33f391ba06db6 +Z 723a886ae851aa4686263a1002cc64d8 diff --git a/manifest.uuid b/manifest.uuid index 6624b9ab92..44b7d4d4a2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f300c35efa5f7383b2a74b1c9466c243c17815e4 \ No newline at end of file +4b404a99aa9bfa6cfe8998f5dc1f84f8be20b840 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index c8fc6ff45b..5acb3b3137 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2524,7 +2524,7 @@ case OP_Column: { goto op_column_error; } }else{ - VVA_ONLY( t = 0; ) /* Only needed by assert() statements */ + t = 0; } /* If after trying to extract new entries from the header, nHdrParsed is From 6044bf8bf3c5cada8e985a6fefa3aededbc19dea Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 04:28:11 +0000 Subject: [PATCH 27/37] Limit the length of sqlite3_mprintf() output to 2^30 bytes, even if SQLITE_MAX_LENGTH is set larger at compile-time. FossilOrigin-Name: d655a665acfae676d30e90e3731f483bee6acc63 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/printf.c | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 39fe0a1326..6b8109daa6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning. -D 2016-01-04T03:48:46.399 +C Limit\sthe\slength\sof\ssqlite3_mprintf()\soutput\sto\s2^30\sbytes,\seven\sif\nSQLITE_MAX_LENGTH\sis\sset\slarger\sat\scompile-time. +D 2016-01-04T04:28:11.861 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -329,7 +329,7 @@ F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051 F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 -F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 +F src/printf.c 79265c0b36bca9b8582592a4f3fa73a1cc1cfa2f F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f300c35efa5f7383b2a74b1c9466c243c17815e4 -R a3643a709add89c526ff9d85846c177f +P 4b404a99aa9bfa6cfe8998f5dc1f84f8be20b840 +R 3d16cb95a338f71bf305a9aee47b6af1 U drh -Z 723a886ae851aa4686263a1002cc64d8 +Z b5d1ace2d67c86c8eec357e62ba7f839 diff --git a/manifest.uuid b/manifest.uuid index 44b7d4d4a2..7a3a9597af 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4b404a99aa9bfa6cfe8998f5dc1f84f8be20b840 \ No newline at end of file +d655a665acfae676d30e90e3731f483bee6acc63 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 969950c154..fed9acd736 100644 --- a/src/printf.c +++ b/src/printf.c @@ -965,7 +965,12 @@ char *sqlite3_vmprintf(const char *zFormat, va_list ap){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif +#if SQLITE_MAX_LENGTH<0x40000000 sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH); +#else + sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), 0x3fffffff); +#endif + sqlite3VXPrintf(&acc, 0, zFormat, ap); z = sqlite3StrAccumFinish(&acc); return z; From 5a60c7d1428ab0540b888228dc86f566519cbe67 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 04:41:13 +0000 Subject: [PATCH 28/37] Adjust the vtabH.test module to ignore files in the root directory of Windows machines that contain the "$" character. FossilOrigin-Name: 73e3355004b8b7ce2e1bb937725f429795528a4f --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/vtabH.test | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 6b8109daa6..d08d409a94 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Limit\sthe\slength\sof\ssqlite3_mprintf()\soutput\sto\s2^30\sbytes,\seven\sif\nSQLITE_MAX_LENGTH\sis\sset\slarger\sat\scompile-time. -D 2016-01-04T04:28:11.861 +C Adjust\sthe\svtabH.test\smodule\sto\signore\sfiles\sin\sthe\sroot\sdirectory\sof\sWindows\nmachines\sthat\scontain\sthe\s"$"\scharacter. +D 2016-01-04T04:41:13.895 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -1274,7 +1274,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test f77296bbf55675b72817cc10fbbcb236ac986abf +F test/vtabH.test 0def52cbcf8d68793d982329a72d70cef8308e35 F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4b404a99aa9bfa6cfe8998f5dc1f84f8be20b840 -R 3d16cb95a338f71bf305a9aee47b6af1 +P d655a665acfae676d30e90e3731f483bee6acc63 +R 0d20e16c42f612598f302d493261df54 U drh -Z b5d1ace2d67c86c8eec357e62ba7f839 +Z 4891b25ab1f0ba8193051c36d1d029ea diff --git a/manifest.uuid b/manifest.uuid index 7a3a9597af..7e2cd0ba52 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d655a665acfae676d30e90e3731f483bee6acc63 \ No newline at end of file +73e3355004b8b7ce2e1bb937725f429795528a4f \ No newline at end of file diff --git a/test/vtabH.test b/test/vtabH.test index 7973819bd1..606c8f1da1 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -147,13 +147,13 @@ if {1} { set res [list] foreach p [lrange [list_root_files] 0 4] { if {$::tcl_platform(platform) eq "windows"} { - lappend res $p + if {![regexp {\$} $p]} {lappend res $p} } else { lappend res "/$p" } } do_execsql_test 3.1 { - SELECT path FROM fstree LIMIT 5; + SELECT path FROM fstree WHERE path NOT GLOB '*$*' LIMIT 5; } $res # Read all entries in the current directory. From cc54f43442076f01ccda13db4fc576cd468817f6 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 04:44:31 +0000 Subject: [PATCH 29/37] Improved comment on the vtabH-3.1 test. FossilOrigin-Name: 22abe08038cc7b66cbc25e733246d210197c9215 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/vtabH.test | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index d08d409a94..7763520f01 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sthe\svtabH.test\smodule\sto\signore\sfiles\sin\sthe\sroot\sdirectory\sof\sWindows\nmachines\sthat\scontain\sthe\s"$"\scharacter. -D 2016-01-04T04:41:13.895 +C Improved\scomment\son\sthe\svtabH-3.1\stest. +D 2016-01-04T04:44:31.090 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -1274,7 +1274,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test 0def52cbcf8d68793d982329a72d70cef8308e35 +F test/vtabH.test 7a21f18546cb9ab38df009e718300c40b552bb2b F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d655a665acfae676d30e90e3731f483bee6acc63 -R 0d20e16c42f612598f302d493261df54 +P 73e3355004b8b7ce2e1bb937725f429795528a4f +R add896a0a928f0a416eb15bec81a6801 U drh -Z 4891b25ab1f0ba8193051c36d1d029ea +Z 9b39ca76b9261d7edc0d476f6827134f diff --git a/manifest.uuid b/manifest.uuid index 7e2cd0ba52..3bbab58916 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -73e3355004b8b7ce2e1bb937725f429795528a4f \ No newline at end of file +22abe08038cc7b66cbc25e733246d210197c9215 \ No newline at end of file diff --git a/test/vtabH.test b/test/vtabH.test index 606c8f1da1..c15ab87de8 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -142,7 +142,9 @@ if {1} { } } - # Read the first 5 entries from the root directory. + # Read the first 5 entries from the root directory. Except, ignore + # files that contain the "$" character in their names as these are + # special files on some Windows platforms. # set res [list] foreach p [lrange [list_root_files] 0 4] { From fa385edff34587e544690236dc9bf47114c3d333 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 12:07:27 +0000 Subject: [PATCH 30/37] A new approach to very large sqlite3_mprintf() strings: Back out the [d655a665] check-in and instead make the size fields in StrAccum unsigned. Strings generated by sqlite3_mprintf() can now be as large as 2^31-1 bytes. FossilOrigin-Name: 7adb789f45698e5569b840d23f3f9488db3ed109 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/printf.c | 5 ----- src/sqliteInt.h | 6 +++--- test/analyzeF.test | 5 +---- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 7763520f01..5d4a5d2f79 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\scomment\son\sthe\svtabH-3.1\stest. -D 2016-01-04T04:44:31.090 +C A\snew\sapproach\sto\svery\slarge\ssqlite3_mprintf()\sstrings:\s\sBack\sout\sthe\n[d655a665]\scheck-in\sand\sinstead\smake\sthe\ssize\sfields\sin\sStrAccum\sunsigned.\nStrings\sgenerated\sby\ssqlite3_mprintf()\scan\snow\sbe\sas\slarge\sas\s2^31-1\sbytes. +D 2016-01-04T12:07:27.503 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -329,7 +329,7 @@ F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051 F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 -F src/printf.c 79265c0b36bca9b8582592a4f3fa73a1cc1cfa2f +F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e @@ -338,7 +338,7 @@ F src/shell.c ed71dc7679e6f087a3f1ea3f9dae4b0fae7209c3 F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 30f7e8957ed7d244be027be72ded385154c635df +F src/sqliteInt.h f97614d43833bae0ed6c51ac8e550f0099a1d0ba F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e @@ -441,7 +441,7 @@ F test/analyzeB.test 8bf35ee0a548aea831bf56762cb8e7fdb1db083d F test/analyzeC.test 555a6cc388b9818b6eda6df816f01ce0a75d3a93 F test/analyzeD.test 08f9d0bee4e118a66fff3a32d02dbe0ee0a2b594 F test/analyzeE.test 8684e8ac5722fb97c251887ad97e5d496a98af1d -F test/analyzeF.test 7ccd7a04f7d3061bde1a8a4dacc4792edccf6bf2 +F test/analyzeF.test 5d1fe1024ba2dfea3c18bede8c1ccef8aba1ab34 F test/analyzer1.test 498e2ff4b62740c2751c3a2f8b744fe26689fae9 F test/async.test 1d0e056ba1bb9729283a0f22718d3a25e82c277b F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 73e3355004b8b7ce2e1bb937725f429795528a4f -R add896a0a928f0a416eb15bec81a6801 +P 22abe08038cc7b66cbc25e733246d210197c9215 +R 50b92b9e9c9cae33b4950afbfcff914c U drh -Z 9b39ca76b9261d7edc0d476f6827134f +Z 208fc2f95f59628c3ac39711f08181ab diff --git a/manifest.uuid b/manifest.uuid index 3bbab58916..982d15ab22 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -22abe08038cc7b66cbc25e733246d210197c9215 \ No newline at end of file +7adb789f45698e5569b840d23f3f9488db3ed109 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index fed9acd736..969950c154 100644 --- a/src/printf.c +++ b/src/printf.c @@ -965,12 +965,7 @@ char *sqlite3_vmprintf(const char *zFormat, va_list ap){ #ifndef SQLITE_OMIT_AUTOINIT if( sqlite3_initialize() ) return 0; #endif -#if SQLITE_MAX_LENGTH<0x40000000 sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH); -#else - sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), 0x3fffffff); -#endif - sqlite3VXPrintf(&acc, 0, zFormat, ap); z = sqlite3StrAccumFinish(&acc); return z; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 53f0709645..c01bbc7869 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2964,9 +2964,9 @@ struct StrAccum { sqlite3 *db; /* Optional database for lookaside. Can be NULL */ char *zBase; /* A base allocation. Not from malloc. */ char *zText; /* The string collected so far */ - int nChar; /* Length of the string so far */ - int nAlloc; /* Amount of space allocated in zText */ - int mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */ + u32 nChar; /* Length of the string so far */ + u32 nAlloc; /* Amount of space allocated in zText */ + u32 mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */ u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */ u8 bMalloced; /* zText points to allocated space */ }; diff --git a/test/analyzeF.test b/test/analyzeF.test index 670d178a81..3cbc5f47be 100644 --- a/test/analyzeF.test +++ b/test/analyzeF.test @@ -106,7 +106,7 @@ do_catchsql_test 4.1 { } {1 {error one}} do_catchsql_test 4.2 { - SELECT * FROM t1 WHERE x = zeroblob(2000000000) AND y = 4; + SELECT * FROM t1 WHERE x = zeroblob(2200000000) AND y = 4; } {1 {string or blob too big}} sqlite3_limit db SQLITE_LIMIT_LENGTH 1000000 @@ -122,6 +122,3 @@ do_catchsql_test 4.4 { finish_test - - - From 4b4da16344ccb0235df07a5e686d5baf4a888eff Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 13:06:53 +0000 Subject: [PATCH 31/37] Fix the conflict2.test module which was broken by check-in [e30062e9f6c]. FossilOrigin-Name: b779ca8a7580e2a0bb1176316c4540867b635229 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/conflict2.test | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 5d4a5d2f79..1628852800 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C A\snew\sapproach\sto\svery\slarge\ssqlite3_mprintf()\sstrings:\s\sBack\sout\sthe\n[d655a665]\scheck-in\sand\sinstead\smake\sthe\ssize\sfields\sin\sStrAccum\sunsigned.\nStrings\sgenerated\sby\ssqlite3_mprintf()\scan\snow\sbe\sas\slarge\sas\s2^31-1\sbytes. -D 2016-01-04T12:07:27.503 +C Fix\sthe\sconflict2.test\smodule\swhich\swas\sbroken\sby\scheck-in\s[e30062e9f6c]. +D 2016-01-04T13:06:53.893 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -524,7 +524,7 @@ F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1 F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/conflict.test 841bcf7cabbfca39c577eb8411ea8601843b46a8 -F test/conflict2.test 0f0e810aef6739650d7f442164975e932cf18afc +F test/conflict2.test a82dd3b9b41fceb5dd6ff0707c5c7ffba208d538 F test/conflict3.test dec0634c0f31dec9a4b01c63063e939f0cd21b6b F test/contrib01.test 2a1cbc0f2f48955d7d073f725765da6fbceda6b4 F test/corrupt.test 141c39ea650c1365e85a49e402fa05cb9617fb97 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 22abe08038cc7b66cbc25e733246d210197c9215 -R 50b92b9e9c9cae33b4950afbfcff914c +P 7adb789f45698e5569b840d23f3f9488db3ed109 +R 16019d64036d1aa36ba8b50ba392c4e8 U drh -Z 208fc2f95f59628c3ac39711f08181ab +Z 8bde812e449e210a56672af13ac69445 diff --git a/manifest.uuid b/manifest.uuid index 982d15ab22..fa6d00eef8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7adb789f45698e5569b840d23f3f9488db3ed109 \ No newline at end of file +b779ca8a7580e2a0bb1176316c4540867b635229 \ No newline at end of file diff --git a/test/conflict2.test b/test/conflict2.test index e8880635f1..6496913849 100644 --- a/test/conflict2.test +++ b/test/conflict2.test @@ -289,11 +289,11 @@ do_test conflict2-6.0 { # foreach {i conf1 cmd t0 t1 t2 t3 t4} { 1 {} UPDATE 1 {6 7 8 9} 1 0 1 - 2 REPLACE UPDATE 0 {7 6 9} 1 1 0 - 3 IGNORE UPDATE 0 {6 7 3 9} 1 1 0 - 4 FAIL UPDATE 1 {6 7 3 4} 1 1 0 + 2 REPLACE UPDATE 0 {7 6 9} 1 0 1 + 3 IGNORE UPDATE 0 {6 7 3 9} 1 0 1 + 4 FAIL UPDATE 1 {6 7 3 4} 1 0 1 5 ABORT UPDATE 1 {1 2 3 4} 1 0 1 - 6 ROLLBACK UPDATE 1 {1 2 3 4} 0 1 0 + 6 ROLLBACK UPDATE 1 {1 2 3 4} 0 0 1 7 REPLACE {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 8 IGNORE {UPDATE OR REPLACE} 0 {7 6 9} 1 0 1 9 FAIL {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 From 11e3e538d672188c95430b7277b1e238533c5ee1 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 4 Jan 2016 23:43:47 +0000 Subject: [PATCH 32/37] Fix a corner case in the opcode-array reuse logic where the number of bytes of reusable space might be computed to be a negative number, due to unusual system alignment restrictions and rounding error. FossilOrigin-Name: 1aa530144643582658c8c1dd66548662f950efe3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 9 ++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 1628852800..ac0852705f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sconflict2.test\smodule\swhich\swas\sbroken\sby\scheck-in\s[e30062e9f6c]. -D 2016-01-04T13:06:53.893 +C Fix\sa\scorner\scase\sin\sthe\sopcode-array\sreuse\slogic\swhere\sthe\snumber\sof\sbytes\sof\nreusable\sspace\smight\sbe\scomputed\sto\sbe\sa\snegative\snumber,\sdue\sto\sunusual\nsystem\salignment\srestrictions\sand\srounding\serror. +D 2016-01-04T23:43:47.141 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -402,7 +402,7 @@ F src/vdbe.c 6ac8e5d808d48afc369316e147c191102f0584c1 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 66b546a1da82dfa6e67985ae0442ba5fd9efe0ff +F src/vdbeaux.c 141ee231ad190240d0d1ee133c9ea28eecd55824 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7adb789f45698e5569b840d23f3f9488db3ed109 -R 16019d64036d1aa36ba8b50ba392c4e8 +P b779ca8a7580e2a0bb1176316c4540867b635229 +R 3b3e1e83b8e4867e299c87ba108024a8 U drh -Z 8bde812e449e210a56672af13ac69445 +Z b5772777614dc8e4c77919f902a0659c diff --git a/manifest.uuid b/manifest.uuid index fa6d00eef8..bc138403e1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b779ca8a7580e2a0bb1176316c4540867b635229 \ No newline at end of file +1aa530144643582658c8c1dd66548662f950efe3 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 7d547e5830..de7f482126 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1848,18 +1848,21 @@ void sqlite3VdbeMakeReady( */ nMem += nCursor; - /* Allocate space for memory registers, SQL variables, VDBE cursors and - ** an array to marshal SQL function arguments in. + /* zCsr will initially point to nFree bytes of unused space at the + ** end of the opcode array, p->aOp. The computation of nFree is + ** conservative - it might be smaller than the true number of free + ** bytes, but never larger. nFree might be negative. But the allocation + ** loop will still function correctly. */ zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ + if( nFree>0 ) memset(zCsr, 0, nFree); resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); if( pParse->explain && nMem<10 ){ nMem = 10; } - memset(zCsr, 0, nFree); assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) ); p->expired = 0; From 98486c046f1d245b5ffa1df8a850e349e4e25154 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 5 Jan 2016 01:48:29 +0000 Subject: [PATCH 33/37] Permit the 'test_fs' test module to be compiled and used on MinGW. FossilOrigin-Name: ac27f38eef7a241d56124c263d9f8c91f372a77f --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/test_fs.c | 13 +++++++++++-- test/vtabH.test | 28 ++++++---------------------- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/manifest b/manifest index ac0852705f..40d0611359 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scorner\scase\sin\sthe\sopcode-array\sreuse\slogic\swhere\sthe\snumber\sof\sbytes\sof\nreusable\sspace\smight\sbe\scomputed\sto\sbe\sa\snegative\snumber,\sdue\sto\sunusual\nsystem\salignment\srestrictions\sand\srounding\serror. -D 2016-01-04T23:43:47.141 +C Permit\sthe\s'test_fs'\stest\smodule\sto\sbe\scompiled\sand\sused\son\sMinGW. +D 2016-01-05T01:48:29.005 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -360,7 +360,7 @@ F src/test_btree.c 2e9978eca99a9a4bfa8cae949efb00886860a64f F src/test_config.c 0dee90328e3dedf8ba002ee94b6a7e7ea7726fe4 F src/test_demovfs.c 0de72c2c89551629f58486fde5734b7d90758852 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc -F src/test_fs.c 993c7eab65bed6add4bb48cca29775e963f710cf +F src/test_fs.c a61f54247fdb843761d709879c3bcd1989b2050c F src/test_func.c 0d9c25956152adefee8881c6fadc8354793764d0 F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_init.c 66b33120ffe9cd853b5a905ec850d51151337b32 @@ -1274,7 +1274,7 @@ F test/vtabC.test 4528f459a13136f982e75614d120aef165f17292 F test/vtabD.test 05b3f1d77117271671089e48719524b676842e96 F test/vtabE.test d5024aa42754962f6bb0afd261681686488e7afe F test/vtabF.test fd5ad376f5a34fe0891df1f3cddb4fe7c3eb077e -F test/vtabH.test 7a21f18546cb9ab38df009e718300c40b552bb2b +F test/vtabH.test 492ba03dcb7bb8fedcc53f258c410d04013adbc9 F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b779ca8a7580e2a0bb1176316c4540867b635229 -R 3b3e1e83b8e4867e299c87ba108024a8 -U drh -Z b5772777614dc8e4c77919f902a0659c +P 1aa530144643582658c8c1dd66548662f950efe3 +R 6490ec858048a3d7899751e10a44fa21 +U mistachkin +Z b205e33bbbedd23793ff52ce1287fb1d diff --git a/manifest.uuid b/manifest.uuid index bc138403e1..515a791f4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1aa530144643582658c8c1dd66548662f950efe3 \ No newline at end of file +ac27f38eef7a241d56124c263d9f8c91f372a77f \ No newline at end of file diff --git a/src/test_fs.c b/src/test_fs.c index ab6bed8a95..45db0b53b8 100644 --- a/src/test_fs.c +++ b/src/test_fs.c @@ -70,7 +70,7 @@ #include #include -#if SQLITE_OS_UNIX +#if SQLITE_OS_UNIX || defined(__MINGW_H) # include # include # ifndef DIRENT @@ -79,7 +79,9 @@ #endif #if SQLITE_OS_WIN # include -# include "test_windirent.h" +# if !defined(__MINGW_H) +# include "test_windirent.h" +# endif # ifndef S_ISREG # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) # endif @@ -231,7 +233,14 @@ static int fsdirNext(sqlite3_vtab_cursor *cur){ if( pCsr->pDir ){ struct DIRENT *pRes = 0; +#if defined(__MINGW_H) + pRes = readdir(pCsr->pDir); + if( pRes!=0 ){ + memcpy(&pCsr->entry, pRes, sizeof(struct DIRENT)); + } +#else readdir_r(pCsr->pDir, &pCsr->entry, &pRes); +#endif if( pRes==0 ){ closedir(pCsr->pDir); pCsr->pDir = 0; diff --git a/test/vtabH.test b/test/vtabH.test index c15ab87de8..7bd542e05b 100644 --- a/test/vtabH.test +++ b/test/vtabH.test @@ -32,12 +32,12 @@ do_execsql_test 1.0 { foreach {tn sql expect} { 1 "SELECT * FROM e6 WHERE b LIKE 'abc'" { - xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b like ?} + xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b like ?} xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} abc } 2 "SELECT * FROM e6 WHERE b GLOB 'abc'" { - xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b glob ?} + xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b glob ?} xFilter {SELECT rowid, a, b FROM 't6' WHERE b glob ?} abc } } { @@ -115,7 +115,7 @@ if {1} { SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db'; SELECT name FROM fsdir WHERE dir = '.' AND name = '.' } {test.db .} - + proc list_root_files {} { if {$::tcl_platform(platform) eq "windows"} { set res [list] @@ -142,22 +142,6 @@ if {1} { } } - # Read the first 5 entries from the root directory. Except, ignore - # files that contain the "$" character in their names as these are - # special files on some Windows platforms. - # - set res [list] - foreach p [lrange [list_root_files] 0 4] { - if {$::tcl_platform(platform) eq "windows"} { - if {![regexp {\$} $p]} {lappend res $p} - } else { - lappend res "/$p" - } - } - do_execsql_test 3.1 { - SELECT path FROM fstree WHERE path NOT GLOB '*$*' LIMIT 5; - } $res - # Read all entries in the current directory. # proc contents {pattern} { @@ -175,7 +159,7 @@ if {1} { do_execsql_test 3.2 { SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1 } [lsort $res] - + # Add some sub-directories and files to the current directory. # do_test 3.3 { @@ -183,7 +167,7 @@ if {1} { foreach {path sz} { subdir/x1.txt 143 subdir/x2.txt 153 - } { + } { set dir [file dirname $path] catch { file mkdir $dir } set fd [open $path w] @@ -191,7 +175,7 @@ if {1} { close $fd } } {} - + set pwd [pwd] do_execsql_test 3.5 { SELECT path, size FROM fstree WHERE path GLOB $pwd || '/subdir/*' ORDER BY 1 From 0816905cddf7f545301f14abf6554e30ead246cc Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Jan 2016 03:39:25 +0000 Subject: [PATCH 34/37] Another attempt to get reuse of excess opcode array space working correctly on all architectures and platforms. FossilOrigin-Name: 2f8583748abab1e15029d3a8693ba9a66c978c2b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 17 +++++++++++------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 40d0611359..c2c3d233a0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Permit\sthe\s'test_fs'\stest\smodule\sto\sbe\scompiled\sand\sused\son\sMinGW. -D 2016-01-05T01:48:29.005 +C Another\sattempt\sto\sget\sreuse\sof\sexcess\sopcode\sarray\sspace\sworking\scorrectly\non\sall\sarchitectures\sand\splatforms. +D 2016-01-05T03:39:25.682 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -402,7 +402,7 @@ F src/vdbe.c 6ac8e5d808d48afc369316e147c191102f0584c1 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 141ee231ad190240d0d1ee133c9ea28eecd55824 +F src/vdbeaux.c 3308a07a6b0b64e22e83cbcc76773eaf330b056a F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1aa530144643582658c8c1dd66548662f950efe3 -R 6490ec858048a3d7899751e10a44fa21 -U mistachkin -Z b205e33bbbedd23793ff52ce1287fb1d +P ac27f38eef7a241d56124c263d9f8c91f372a77f +R 60123ea1ef3684554ab03afc4196be5d +U drh +Z f77bc5a04736277ef260f43c3525df33 diff --git a/manifest.uuid b/manifest.uuid index 515a791f4f..ea174478b6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac27f38eef7a241d56124c263d9f8c91f372a77f \ No newline at end of file +2f8583748abab1e15029d3a8693ba9a66c978c2b \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index de7f482126..dbbb2a6ccb 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1851,19 +1851,24 @@ void sqlite3VdbeMakeReady( /* zCsr will initially point to nFree bytes of unused space at the ** end of the opcode array, p->aOp. The computation of nFree is ** conservative - it might be smaller than the true number of free - ** bytes, but never larger. nFree might be negative. But the allocation - ** loop will still function correctly. + ** bytes, but never larger. nFree must be a multiple of 8 - it is + ** rounded down if is not. */ - zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ - nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ - if( nFree>0 ) memset(zCsr, 0, nFree); + n = ROUND8(sizeof(Op)*p->nOp); /* Bytes of opcode space used */ + zCsr = &((u8*)p->aOp)[n]; /* Unused opcode space */ + assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); + nFree = ROUNDDOWN8(pParse->szOpAlloc - n); /* Bytes of unused space */ + assert( nFree>=0 ); + if( nFree>0 ){ + memset(zCsr, 0, nFree); + assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) ); + } resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); if( pParse->explain && nMem<10 ){ nMem = 10; } - assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) ); p->expired = 0; /* Memory for registers, parameters, cursor, etc, is allocated in two From 9d4c9824da4d23e1b40678f84a542ce5d93d0b97 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 5 Jan 2016 03:39:52 +0000 Subject: [PATCH 35/37] Always use -DSQLITE_ENABLE_MEMSYS5 for fuzzcheck so that the --limit-mem option will work. FossilOrigin-Name: a855697719e288c908ddb7950d32fd17ef546509 --- Makefile.in | 2 +- Makefile.msc | 2 +- main.mk | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index d06b3ca49d..1fe49d6789 100644 --- a/Makefile.in +++ b/Makefile.in @@ -550,7 +550,7 @@ TESTOPTS = --verbose=file --output=test-out.txt # SHELL_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1 -FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 +FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. diff --git a/Makefile.msc b/Makefile.msc index aa2bd9a2f1..92561a8a32 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1218,7 +1218,7 @@ FUZZDATA = \ # SHELL_COMPILE_OPTS = -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 FUZZERSHELL_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -FUZZCHECK_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 +FUZZCHECK_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 # Standard options to testfixture # diff --git a/main.mk b/main.mk index 398bb9d149..e6ca1acbd6 100644 --- a/main.mk +++ b/main.mk @@ -460,7 +460,7 @@ TESTOPTS = --verbose=file --output=test-out.txt # SHELL_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1 -FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 +FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. diff --git a/manifest b/manifest index c2c3d233a0..2cff2948a6 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Another\sattempt\sto\sget\sreuse\sof\sexcess\sopcode\sarray\sspace\sworking\scorrectly\non\sall\sarchitectures\sand\splatforms. -D 2016-01-05T03:39:25.682 -F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d +C Always\suse\s-DSQLITE_ENABLE_MEMSYS5\sfor\sfuzzcheck\sso\sthat\sthe\s--limit-mem\noption\swill\swork. +D 2016-01-05T03:39:52.336 +F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 +F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION 8b9d3ac6f1962f94e06ba05462422a544f9c4e36 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -257,7 +257,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk ed77cbb97848c8dae1ab928245432f74b0580162 +F main.mk 20e46c09ac8732a74a9e2d55e8d90257d97eb844 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 @@ -1406,7 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ac27f38eef7a241d56124c263d9f8c91f372a77f -R 60123ea1ef3684554ab03afc4196be5d +P 2f8583748abab1e15029d3a8693ba9a66c978c2b +R 658872c8eaad4f517adfb9642371bf29 U drh -Z f77bc5a04736277ef260f43c3525df33 +Z 68ad1defdc3264df127031e5fb4da721 diff --git a/manifest.uuid b/manifest.uuid index ea174478b6..a1640cccc8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f8583748abab1e15029d3a8693ba9a66c978c2b \ No newline at end of file +a855697719e288c908ddb7950d32fd17ef546509 \ No newline at end of file From 02a59fab74794a70fe3e41744c646467067bcdb0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Jan 2016 11:01:07 +0000 Subject: [PATCH 36/37] Version 3.10.0 FossilOrigin-Name: fd0a50f0797d154fefff724624f00548b5320566 --- manifest | 11 +++++++---- manifest.uuid | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/manifest b/manifest index 2cff2948a6..84ab4c9e57 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Always\suse\s-DSQLITE_ENABLE_MEMSYS5\sfor\sfuzzcheck\sso\sthat\sthe\s--limit-mem\noption\swill\swork. -D 2016-01-05T03:39:52.336 +C Version\s3.10.0 +D 2016-01-06T11:01:07.739 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -1406,7 +1406,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 2f8583748abab1e15029d3a8693ba9a66c978c2b +P a855697719e288c908ddb7950d32fd17ef546509 R 658872c8eaad4f517adfb9642371bf29 +T +bgcolor * #d0c0ff +T +sym-release * +T +sym-version-3.10.0 * U drh -Z 68ad1defdc3264df127031e5fb4da721 +Z 024a1b2bbd235a427c0ebcd39a99300a diff --git a/manifest.uuid b/manifest.uuid index a1640cccc8..01d9768cad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a855697719e288c908ddb7950d32fd17ef546509 \ No newline at end of file +fd0a50f0797d154fefff724624f00548b5320566 \ No newline at end of file From 8d52c3b7671b478c744b05dd3d8f0ccde8fb135f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 6 Jan 2016 15:54:53 +0000 Subject: [PATCH 37/37] Disable the --limit-mem option on fuzzcheck unless the SQLITE_ENABLE_MEMSYS5 or SQLITE_ENABLE_MEMSYS3 compile-time options are used. FossilOrigin-Name: 55a11fd627eaf046b3783622b2925399a50a65b4 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- test/fuzzcheck.c | 5 +++++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 84ab4c9e57..d238fa51c2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.10.0 -D 2016-01-06T11:01:07.739 +C Disable\sthe\s--limit-mem\soption\son\sfuzzcheck\sunless\sthe\sSQLITE_ENABLE_MEMSYS5\sor\nSQLITE_ENABLE_MEMSYS3\scompile-time\soptions\sare\sused. +D 2016-01-06T15:54:53.139 F Makefile.in 7c8cc4c2f0179efc6fa9492141d1fb65f4807054 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e45d8b9b56dfa3f2cd860b2c28bd9d304513b042 @@ -749,7 +749,7 @@ F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1 F test/fuzz3.test 53fabcd5f0f430f8b221282f6c12c4d0903c21eb F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26 -F test/fuzzcheck.c ccdcdc28579b2c9744696bca8726bdbd729eea11 +F test/fuzzcheck.c 3309d793165ca61a9996271cb799694839348f9a F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664 F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -1406,10 +1406,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a855697719e288c908ddb7950d32fd17ef546509 -R 658872c8eaad4f517adfb9642371bf29 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.10.0 * +P fd0a50f0797d154fefff724624f00548b5320566 +R 87a59d21671d8eb854da54e44c1cb06d U drh -Z 024a1b2bbd235a427c0ebcd39a99300a +Z 6b66decd394482c2ac340e90e8473c2f diff --git a/manifest.uuid b/manifest.uuid index 01d9768cad..6cc9954870 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd0a50f0797d154fefff724624f00548b5320566 \ No newline at end of file +55a11fd627eaf046b3783622b2925399a50a65b4 \ No newline at end of file diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index 6d9c745528..03776f1e70 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -865,8 +865,13 @@ int main(int argc, char **argv){ return 0; }else if( strcmp(z,"limit-mem")==0 ){ +#if !defined(SQLITE_ENABLE_MEMSYS3) && !defined(SQLITE_ENABLE_MEMSYS5) + fatalError("the %s option requires -DSQLITE_ENABLE_MEMSYS5 or _MEMSYS3", + argv[i]); +#else if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); nMem = integerValue(argv[++i]); +#endif }else if( strcmp(z,"limit-vdbe")==0 ){ vdbeLimitFlag = 1;