| | @@ -398,11 +398,11 @@ |
| 398 | 398 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 399 | 399 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 400 | 400 | */ |
| 401 | 401 | #define SQLITE_VERSION "3.18.0" |
| 402 | 402 | #define SQLITE_VERSION_NUMBER 3018000 |
| 403 | | -#define SQLITE_SOURCE_ID "2017-03-10 17:03:11 f8560c60d10c0365b33342ab05b5a953987b0471" |
| 403 | +#define SQLITE_SOURCE_ID "2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f" |
| 404 | 404 | |
| 405 | 405 | /* |
| 406 | 406 | ** CAPI3REF: Run-Time Library Version Numbers |
| 407 | 407 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 408 | 408 | ** |
| | @@ -26264,10 +26264,14 @@ |
| 26264 | 26264 | ** Generate a human-readable description of a Select object. |
| 26265 | 26265 | */ |
| 26266 | 26266 | SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){ |
| 26267 | 26267 | int n = 0; |
| 26268 | 26268 | int cnt = 0; |
| 26269 | + if( p==0 ){ |
| 26270 | + sqlite3TreeViewLine(pView, "nil-SELECT"); |
| 26271 | + return; |
| 26272 | + } |
| 26269 | 26273 | pView = sqlite3TreeViewPush(pView, moreToFollow); |
| 26270 | 26274 | if( p->pWith ){ |
| 26271 | 26275 | sqlite3TreeViewWith(pView, p->pWith, 1); |
| 26272 | 26276 | cnt = 1; |
| 26273 | 26277 | sqlite3TreeViewPush(pView, 1); |
| | @@ -78469,13 +78473,11 @@ |
| 78469 | 78473 | c = 'e'; |
| 78470 | 78474 | assert( (f & (MEM_Static|MEM_Dyn))==0 ); |
| 78471 | 78475 | }else{ |
| 78472 | 78476 | c = 's'; |
| 78473 | 78477 | } |
| 78474 | | - |
| 78475 | | - sqlite3_snprintf(100, zCsr, "%c", c); |
| 78476 | | - zCsr += sqlite3Strlen30(zCsr); |
| 78478 | + *(zCsr++) = c; |
| 78477 | 78479 | sqlite3_snprintf(100, zCsr, "%d[", pMem->n); |
| 78478 | 78480 | zCsr += sqlite3Strlen30(zCsr); |
| 78479 | 78481 | for(i=0; i<16 && i<pMem->n; i++){ |
| 78480 | 78482 | sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF)); |
| 78481 | 78483 | zCsr += sqlite3Strlen30(zCsr); |
| | @@ -78483,13 +78485,11 @@ |
| 78483 | 78485 | for(i=0; i<16 && i<pMem->n; i++){ |
| 78484 | 78486 | char z = pMem->z[i]; |
| 78485 | 78487 | if( z<32 || z>126 ) *zCsr++ = '.'; |
| 78486 | 78488 | else *zCsr++ = z; |
| 78487 | 78489 | } |
| 78488 | | - |
| 78489 | | - sqlite3_snprintf(100, zCsr, "]%s", encnames[pMem->enc]); |
| 78490 | | - zCsr += sqlite3Strlen30(zCsr); |
| 78490 | + *(zCsr++) = ']'; |
| 78491 | 78491 | if( f & MEM_Zero ){ |
| 78492 | 78492 | sqlite3_snprintf(100, zCsr,"+%dz",pMem->u.nZero); |
| 78493 | 78493 | zCsr += sqlite3Strlen30(zCsr); |
| 78494 | 78494 | } |
| 78495 | 78495 | *zCsr = '\0'; |
| | @@ -92537,10 +92537,11 @@ |
| 92537 | 92537 | ** in *pValue. If the expression is not an integer or if it is too big |
| 92538 | 92538 | ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged. |
| 92539 | 92539 | */ |
| 92540 | 92540 | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){ |
| 92541 | 92541 | int rc = 0; |
| 92542 | + if( p==0 ) return 0; /* Can only happen following on OOM */ |
| 92542 | 92543 | |
| 92543 | 92544 | /* If an expression is an integer literal that fits in a signed 32-bit |
| 92544 | 92545 | ** integer, then the EP_IntValue flag will have already been set */ |
| 92545 | 92546 | assert( p->op!=TK_INTEGER || (p->flags & EP_IntValue)!=0 |
| 92546 | 92547 | || sqlite3GetInt32(p->u.zToken, &rc)==0 ); |
| | @@ -93209,11 +93210,10 @@ |
| 93209 | 93210 | if( ALWAYS(pEList->nExpr==nVal) ){ |
| 93210 | 93211 | SelectDest dest; |
| 93211 | 93212 | int i; |
| 93212 | 93213 | sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable); |
| 93213 | 93214 | dest.zAffSdst = exprINAffinity(pParse, pExpr); |
| 93214 | | - assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable ); |
| 93215 | 93215 | pSelect->iLimit = 0; |
| 93216 | 93216 | testcase( pSelect->selFlags & SF_Distinct ); |
| 93217 | 93217 | testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ |
| 93218 | 93218 | if( sqlite3Select(pParse, pSelect, &dest) ){ |
| 93219 | 93219 | sqlite3DbFree(pParse->db, dest.zAffSdst); |
| | @@ -105435,19 +105435,17 @@ |
| 105435 | 105435 | nNeedle = sqlite3_value_bytes(argv[1]); |
| 105436 | 105436 | if( nNeedle>0 ){ |
| 105437 | 105437 | if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){ |
| 105438 | 105438 | zHaystack = sqlite3_value_blob(argv[0]); |
| 105439 | 105439 | zNeedle = sqlite3_value_blob(argv[1]); |
| 105440 | | - assert( zNeedle!=0 ); |
| 105441 | | - assert( zHaystack!=0 || nHaystack==0 ); |
| 105442 | 105440 | isText = 0; |
| 105443 | 105441 | }else{ |
| 105444 | 105442 | zHaystack = sqlite3_value_text(argv[0]); |
| 105445 | 105443 | zNeedle = sqlite3_value_text(argv[1]); |
| 105446 | 105444 | isText = 1; |
| 105447 | | - if( zHaystack==0 || zNeedle==0 ) return; |
| 105448 | 105445 | } |
| 105446 | + if( zNeedle==0 || (nHaystack && zHaystack==0) ) return; |
| 105449 | 105447 | while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){ |
| 105450 | 105448 | N++; |
| 105451 | 105449 | do{ |
| 105452 | 105450 | nHaystack--; |
| 105453 | 105451 | zHaystack++; |
| | @@ -113916,11 +113914,11 @@ |
| 113916 | 113914 | returnSingleInt(v, pDb->safety_level-1); |
| 113917 | 113915 | }else{ |
| 113918 | 113916 | if( !db->autoCommit ){ |
| 113919 | 113917 | sqlite3ErrorMsg(pParse, |
| 113920 | 113918 | "Safety level may not be changed inside a transaction"); |
| 113921 | | - }else{ |
| 113919 | + }else if( iDb!=1 ){ |
| 113922 | 113920 | int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK; |
| 113923 | 113921 | if( iLevel==0 ) iLevel = 1; |
| 113924 | 113922 | pDb->safety_level = iLevel; |
| 113925 | 113923 | pDb->bSyncSet = 1; |
| 113926 | 113924 | setAllPagerFlags(db); |
| | @@ -119936,11 +119934,13 @@ |
| 119936 | 119934 | assert( pParent->pGroupBy==0 ); |
| 119937 | 119935 | pParent->pGroupBy = sqlite3ExprListDup(db, pSub->pGroupBy, 0); |
| 119938 | 119936 | }else{ |
| 119939 | 119937 | pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere); |
| 119940 | 119938 | } |
| 119941 | | - substSelect(pParse, pParent, iParent, pSub->pEList, 0); |
| 119939 | + if( db->mallocFailed==0 ){ |
| 119940 | + substSelect(pParse, pParent, iParent, pSub->pEList, 0); |
| 119941 | + } |
| 119942 | 119942 | |
| 119943 | 119943 | /* The flattened query is distinct if either the inner or the |
| 119944 | 119944 | ** outer query is distinct. |
| 119945 | 119945 | */ |
| 119946 | 119946 | pParent->selFlags |= pSub->selFlags & SF_Distinct; |
| | @@ -130289,18 +130289,20 @@ |
| 130289 | 130289 | ** cursor iTabCur are transformed into OP_Null. Or, if bIncrRowid is non-zero, |
| 130290 | 130290 | ** then each OP_Rowid is transformed into an instruction to increment the |
| 130291 | 130291 | ** value stored in its output register. |
| 130292 | 130292 | */ |
| 130293 | 130293 | static void translateColumnToCopy( |
| 130294 | | - Vdbe *v, /* The VDBE containing code to translate */ |
| 130294 | + Parse *pParse, /* Parsing context */ |
| 130295 | 130295 | int iStart, /* Translate from this opcode to the end */ |
| 130296 | 130296 | int iTabCur, /* OP_Column/OP_Rowid references to this table */ |
| 130297 | 130297 | int iRegister, /* The first column is in this register */ |
| 130298 | 130298 | int bIncrRowid /* If non-zero, transform OP_rowid to OP_AddImm(1) */ |
| 130299 | 130299 | ){ |
| 130300 | + Vdbe *v = pParse->pVdbe; |
| 130300 | 130301 | VdbeOp *pOp = sqlite3VdbeGetOp(v, iStart); |
| 130301 | 130302 | int iEnd = sqlite3VdbeCurrentAddr(v); |
| 130303 | + if( pParse->db->mallocFailed ) return; |
| 130302 | 130304 | for(; iStart<iEnd; iStart++, pOp++){ |
| 130303 | 130305 | if( pOp->p1!=iTabCur ) continue; |
| 130304 | 130306 | if( pOp->opcode==OP_Column ){ |
| 130305 | 130307 | pOp->opcode = OP_Copy; |
| 130306 | 130308 | pOp->p1 = pOp->p2 + iRegister; |
| | @@ -130574,11 +130576,13 @@ |
| 130574 | 130576 | sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord); |
| 130575 | 130577 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 130576 | 130578 | if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue); |
| 130577 | 130579 | if( pTabItem->fg.viaCoroutine ){ |
| 130578 | 130580 | sqlite3VdbeChangeP2(v, addrCounter, regBase+n); |
| 130579 | | - translateColumnToCopy(v, addrTop, pLevel->iTabCur, pTabItem->regResult, 1); |
| 130581 | + testcase( pParse->db->mallocFailed ); |
| 130582 | + translateColumnToCopy(pParse, addrTop, pLevel->iTabCur, |
| 130583 | + pTabItem->regResult, 1); |
| 130580 | 130584 | sqlite3VdbeGoto(v, addrTop); |
| 130581 | 130585 | pTabItem->fg.viaCoroutine = 0; |
| 130582 | 130586 | }else{ |
| 130583 | 130587 | sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v); |
| 130584 | 130588 | } |
| | @@ -134692,12 +134696,13 @@ |
| 134692 | 134696 | |
| 134693 | 134697 | /* For a co-routine, change all OP_Column references to the table of |
| 134694 | 134698 | ** the co-routine into OP_Copy of result contained in a register. |
| 134695 | 134699 | ** OP_Rowid becomes OP_Null. |
| 134696 | 134700 | */ |
| 134697 | | - if( pTabItem->fg.viaCoroutine && !db->mallocFailed ){ |
| 134698 | | - translateColumnToCopy(v, pLevel->addrBody, pLevel->iTabCur, |
| 134701 | + if( pTabItem->fg.viaCoroutine ){ |
| 134702 | + testcase( pParse->db->mallocFailed ); |
| 134703 | + translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur, |
| 134699 | 134704 | pTabItem->regResult, 0); |
| 134700 | 134705 | continue; |
| 134701 | 134706 | } |
| 134702 | 134707 | |
| 134703 | 134708 | /* If this scan uses an index, make VDBE code substitutions to read data |
| | @@ -198067,11 +198072,11 @@ |
| 198067 | 198072 | int nArg, /* Number of args */ |
| 198068 | 198073 | sqlite3_value **apUnused /* Function arguments */ |
| 198069 | 198074 | ){ |
| 198070 | 198075 | assert( nArg==0 ); |
| 198071 | 198076 | UNUSED_PARAM2(nArg, apUnused); |
| 198072 | | - sqlite3_result_text(pCtx, "fts5: 2017-03-10 17:03:11 f8560c60d10c0365b33342ab05b5a953987b0471", -1, SQLITE_TRANSIENT); |
| 198077 | + sqlite3_result_text(pCtx, "fts5: 2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f", -1, SQLITE_TRANSIENT); |
| 198073 | 198078 | } |
| 198074 | 198079 | |
| 198075 | 198080 | static int fts5Init(sqlite3 *db){ |
| 198076 | 198081 | static const sqlite3_module fts5Mod = { |
| 198077 | 198082 | /* iVersion */ 2, |
| 198078 | 198083 | |