| | @@ -1186,11 +1186,11 @@ |
| 1186 | 1186 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1187 | 1187 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1188 | 1188 | */ |
| 1189 | 1189 | #define SQLITE_VERSION "3.35.0" |
| 1190 | 1190 | #define SQLITE_VERSION_NUMBER 3035000 |
| 1191 | | -#define SQLITE_SOURCE_ID "2021-03-09 21:20:12 9645fe1a050e8b61aea1fba2f142819c387ecb043741392c5719bf7ad303bf8b" |
| 1191 | +#define SQLITE_SOURCE_ID "2021-03-12 15:10:09 acd63062eb06748bfe9e4886639e4f2b54ea6a496a83f10716abbaba4115500b" |
| 1192 | 1192 | |
| 1193 | 1193 | /* |
| 1194 | 1194 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1195 | 1195 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1196 | 1196 | ** |
| | @@ -11623,22 +11623,27 @@ |
| 11623 | 11623 | ** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator |
| 11624 | 11624 | ** created by [sqlite3changeset_start()]. In the latter case, the most recent |
| 11625 | 11625 | ** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this |
| 11626 | 11626 | ** is not the case, this function returns [SQLITE_MISUSE]. |
| 11627 | 11627 | ** |
| 11628 | | -** If argument pzTab is not NULL, then *pzTab is set to point to a |
| 11629 | | -** nul-terminated utf-8 encoded string containing the name of the table |
| 11630 | | -** affected by the current change. The buffer remains valid until either |
| 11631 | | -** sqlite3changeset_next() is called on the iterator or until the |
| 11632 | | -** conflict-handler function returns. If pnCol is not NULL, then *pnCol is |
| 11633 | | -** set to the number of columns in the table affected by the change. If |
| 11634 | | -** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change |
| 11628 | +** Arguments pOp, pnCol and pzTab may not be NULL. Upon return, three |
| 11629 | +** outputs are set through these pointers: |
| 11630 | +** |
| 11631 | +** *pOp is set to one of [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], |
| 11632 | +** depending on the type of change that the iterator currently points to; |
| 11633 | +** |
| 11634 | +** *pnCol is set to the number of columns in the table affected by the change; and |
| 11635 | +** |
| 11636 | +** *pzTab is set to point to a nul-terminated utf-8 encoded string containing |
| 11637 | +** the name of the table affected by the current change. The buffer remains |
| 11638 | +** valid until either sqlite3changeset_next() is called on the iterator |
| 11639 | +** or until the conflict-handler function returns. |
| 11640 | +** |
| 11641 | +** If pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change |
| 11635 | 11642 | ** is an indirect change, or false (0) otherwise. See the documentation for |
| 11636 | 11643 | ** [sqlite3session_indirect()] for a description of direct and indirect |
| 11637 | | -** changes. Finally, if pOp is not NULL, then *pOp is set to one of |
| 11638 | | -** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the |
| 11639 | | -** type of change that the iterator currently points to. |
| 11644 | +** changes. |
| 11640 | 11645 | ** |
| 11641 | 11646 | ** If no error occurs, SQLITE_OK is returned. If an error does occur, an |
| 11642 | 11647 | ** SQLite error code is returned. The values of the output variables may not |
| 11643 | 11648 | ** be trusted in this case. |
| 11644 | 11649 | */ |
| | @@ -16948,10 +16953,15 @@ |
| 16948 | 16953 | #define SQLITE_TRACE_LEGACY 0 |
| 16949 | 16954 | #define SQLITE_TRACE_XPROFILE 0 |
| 16950 | 16955 | #endif /* SQLITE_OMIT_DEPRECATED */ |
| 16951 | 16956 | #define SQLITE_TRACE_NONLEGACY_MASK 0x0f /* Normal flags */ |
| 16952 | 16957 | |
| 16958 | +/* |
| 16959 | +** Maximum number of sqlite3.aDb[] entries. This is the number of attached |
| 16960 | +** databases plus 2 for "main" and "temp". |
| 16961 | +*/ |
| 16962 | +#define SQLITE_MAX_DB (SQLITE_MAX_ATTACHED+2) |
| 16953 | 16963 | |
| 16954 | 16964 | /* |
| 16955 | 16965 | ** Each database connection is an instance of the following structure. |
| 16956 | 16966 | */ |
| 16957 | 16967 | struct sqlite3 { |
| | @@ -103196,11 +103206,11 @@ |
| 103196 | 103206 | assert( p->pSrc!=0 ); /* Because of isCandidateForInOpt(p) */ |
| 103197 | 103207 | pTab = p->pSrc->a[0].pTab; |
| 103198 | 103208 | |
| 103199 | 103209 | /* Code an OP_Transaction and OP_TableLock for <table>. */ |
| 103200 | 103210 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 103201 | | - assert( iDb>=0 && iDb<SQLITE_MAX_ATTACHED ); |
| 103211 | + assert( iDb>=0 && iDb<SQLITE_MAX_DB ); |
| 103202 | 103212 | sqlite3CodeVerifySchema(pParse, iDb); |
| 103203 | 103213 | sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); |
| 103204 | 103214 | |
| 103205 | 103215 | assert(v); /* sqlite3GetVdbe() has always been previously called */ |
| 103206 | 103216 | if( nExpr==1 && pEList->a[0].pExpr->iColumn<0 ){ |
| | @@ -116368,11 +116378,11 @@ |
| 116368 | 116378 | ** later, by sqlite3FinishCoding(). |
| 116369 | 116379 | */ |
| 116370 | 116380 | static void sqlite3CodeVerifySchemaAtToplevel(Parse *pToplevel, int iDb){ |
| 116371 | 116381 | assert( iDb>=0 && iDb<pToplevel->db->nDb ); |
| 116372 | 116382 | assert( pToplevel->db->aDb[iDb].pBt!=0 || iDb==1 ); |
| 116373 | | - assert( iDb<SQLITE_MAX_ATTACHED+2 ); |
| 116383 | + assert( iDb<SQLITE_MAX_DB ); |
| 116374 | 116384 | assert( sqlite3SchemaMutexHeld(pToplevel->db, iDb, 0) ); |
| 116375 | 116385 | if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){ |
| 116376 | 116386 | DbMaskSet(pToplevel->cookieMask, iDb); |
| 116377 | 116387 | if( !OMIT_TEMPDB && iDb==1 ){ |
| 116378 | 116388 | sqlite3OpenTempDatabase(pToplevel); |
| | @@ -129424,11 +129434,11 @@ |
| 129424 | 129434 | ** PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate |
| 129425 | 129435 | ** |
| 129426 | 129436 | ** Checkpoint the database. |
| 129427 | 129437 | */ |
| 129428 | 129438 | case PragTyp_WAL_CHECKPOINT: { |
| 129429 | | - int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED); |
| 129439 | + int iBt = (pId2->z?iDb:SQLITE_MAX_DB); |
| 129430 | 129440 | int eMode = SQLITE_CHECKPOINT_PASSIVE; |
| 129431 | 129441 | if( zRight ){ |
| 129432 | 129442 | if( sqlite3StrICmp(zRight, "full")==0 ){ |
| 129433 | 129443 | eMode = SQLITE_CHECKPOINT_FULL; |
| 129434 | 129444 | }else if( sqlite3StrICmp(zRight, "restart")==0 ){ |
| | @@ -166301,11 +166311,11 @@ |
| 166301 | 166311 | ){ |
| 166302 | 166312 | #ifdef SQLITE_OMIT_WAL |
| 166303 | 166313 | return SQLITE_OK; |
| 166304 | 166314 | #else |
| 166305 | 166315 | int rc; /* Return code */ |
| 166306 | | - int iDb = SQLITE_MAX_ATTACHED; /* sqlite3.aDb[] index of db to checkpoint */ |
| 166316 | + int iDb; /* Schema to checkpoint */ |
| 166307 | 166317 | |
| 166308 | 166318 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 166309 | 166319 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| 166310 | 166320 | #endif |
| 166311 | 166321 | |
| | @@ -166324,10 +166334,12 @@ |
| 166324 | 166334 | } |
| 166325 | 166335 | |
| 166326 | 166336 | sqlite3_mutex_enter(db->mutex); |
| 166327 | 166337 | if( zDb && zDb[0] ){ |
| 166328 | 166338 | iDb = sqlite3FindDbName(db, zDb); |
| 166339 | + }else{ |
| 166340 | + iDb = SQLITE_MAX_DB; /* This means process all schemas */ |
| 166329 | 166341 | } |
| 166330 | 166342 | if( iDb<0 ){ |
| 166331 | 166343 | rc = SQLITE_ERROR; |
| 166332 | 166344 | sqlite3ErrorWithMsg(db, SQLITE_ERROR, "unknown database: %s", zDb); |
| 166333 | 166345 | }else{ |
| | @@ -166372,11 +166384,11 @@ |
| 166372 | 166384 | ** |
| 166373 | 166385 | ** The mutex on database handle db should be held by the caller. The mutex |
| 166374 | 166386 | ** associated with the specific b-tree being checkpointed is taken by |
| 166375 | 166387 | ** this function while the checkpoint is running. |
| 166376 | 166388 | ** |
| 166377 | | -** If iDb is passed SQLITE_MAX_ATTACHED, then all attached databases are |
| 166389 | +** If iDb is passed SQLITE_MAX_DB then all attached databases are |
| 166378 | 166390 | ** checkpointed. If an error is encountered it is returned immediately - |
| 166379 | 166391 | ** no attempt is made to checkpoint any remaining databases. |
| 166380 | 166392 | ** |
| 166381 | 166393 | ** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL, RESTART |
| 166382 | 166394 | ** or TRUNCATE. |
| | @@ -166387,13 +166399,15 @@ |
| 166387 | 166399 | int bBusy = 0; /* True if SQLITE_BUSY has been encountered */ |
| 166388 | 166400 | |
| 166389 | 166401 | assert( sqlite3_mutex_held(db->mutex) ); |
| 166390 | 166402 | assert( !pnLog || *pnLog==-1 ); |
| 166391 | 166403 | assert( !pnCkpt || *pnCkpt==-1 ); |
| 166404 | + testcase( iDb==SQLITE_MAX_ATTACHED ); /* See forum post a006d86f72 */ |
| 166405 | + testcase( iDb==SQLITE_MAX_DB ); |
| 166392 | 166406 | |
| 166393 | 166407 | for(i=0; i<db->nDb && rc==SQLITE_OK; i++){ |
| 166394 | | - if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){ |
| 166408 | + if( i==iDb || iDb==SQLITE_MAX_DB ){ |
| 166395 | 166409 | rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt, eMode, pnLog, pnCkpt); |
| 166396 | 166410 | pnLog = 0; |
| 166397 | 166411 | pnCkpt = 0; |
| 166398 | 166412 | if( rc==SQLITE_BUSY ){ |
| 166399 | 166413 | bBusy = 1; |
| | @@ -187931,10 +187945,11 @@ |
| 187931 | 187945 | memset(pCsr, 0, sizeof(unicode_cursor)); |
| 187932 | 187946 | |
| 187933 | 187947 | pCsr->aInput = (const unsigned char *)aInput; |
| 187934 | 187948 | if( aInput==0 ){ |
| 187935 | 187949 | pCsr->nInput = 0; |
| 187950 | + pCsr->aInput = (const unsigned char*)""; |
| 187936 | 187951 | }else if( nInput<0 ){ |
| 187937 | 187952 | pCsr->nInput = (int)strlen(aInput); |
| 187938 | 187953 | }else{ |
| 187939 | 187954 | pCsr->nInput = nInput; |
| 187940 | 187955 | } |
| | @@ -224510,13 +224525,15 @@ |
| 224510 | 224525 | static void fts5DoclistIterInit( |
| 224511 | 224526 | Fts5Buffer *pBuf, |
| 224512 | 224527 | Fts5DoclistIter *pIter |
| 224513 | 224528 | ){ |
| 224514 | 224529 | memset(pIter, 0, sizeof(*pIter)); |
| 224515 | | - pIter->aPoslist = pBuf->p; |
| 224516 | | - pIter->aEof = &pBuf->p[pBuf->n]; |
| 224517 | | - fts5DoclistIterNext(pIter); |
| 224530 | + if( pBuf->n>0 ){ |
| 224531 | + pIter->aPoslist = pBuf->p; |
| 224532 | + pIter->aEof = &pBuf->p[pBuf->n]; |
| 224533 | + fts5DoclistIterNext(pIter); |
| 224534 | + } |
| 224518 | 224535 | } |
| 224519 | 224536 | |
| 224520 | 224537 | #if 0 |
| 224521 | 224538 | /* |
| 224522 | 224539 | ** Append a doclist to buffer pBuf. |
| | @@ -225274,12 +225291,13 @@ |
| 225274 | 225291 | ** Return the current term. |
| 225275 | 225292 | */ |
| 225276 | 225293 | static const char *sqlite3Fts5IterTerm(Fts5IndexIter *pIndexIter, int *pn){ |
| 225277 | 225294 | int n; |
| 225278 | 225295 | const char *z = (const char*)fts5MultiIterTerm((Fts5Iter*)pIndexIter, &n); |
| 225296 | + assert_nc( z || n<=1 ); |
| 225279 | 225297 | *pn = n-1; |
| 225280 | | - return &z[1]; |
| 225298 | + return (z ? &z[1] : 0); |
| 225281 | 225299 | } |
| 225282 | 225300 | |
| 225283 | 225301 | /* |
| 225284 | 225302 | ** Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery(). |
| 225285 | 225303 | */ |
| | @@ -228561,11 +228579,12 @@ |
| 228561 | 228579 | ){ |
| 228562 | 228580 | Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; |
| 228563 | 228581 | int n; |
| 228564 | 228582 | int rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n); |
| 228565 | 228583 | if( rc==SQLITE_OK ){ |
| 228566 | | - pIter->b = &pIter->a[n]; |
| 228584 | + assert( pIter->a || n==0 ); |
| 228585 | + pIter->b = (pIter->a ? &pIter->a[n] : 0); |
| 228567 | 228586 | *piCol = 0; |
| 228568 | 228587 | *piOff = 0; |
| 228569 | 228588 | fts5ApiPhraseNext(pCtx, pIter, piCol, piOff); |
| 228570 | 228589 | } |
| 228571 | 228590 | return rc; |
| | @@ -228620,19 +228639,21 @@ |
| 228620 | 228639 | pIter->a = &pSorter->aPoslist[i1]; |
| 228621 | 228640 | }else{ |
| 228622 | 228641 | rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n); |
| 228623 | 228642 | } |
| 228624 | 228643 | if( rc==SQLITE_OK ){ |
| 228625 | | - pIter->b = &pIter->a[n]; |
| 228644 | + assert( pIter->a || n==0 ); |
| 228645 | + pIter->b = (pIter->a ? &pIter->a[n] : 0); |
| 228626 | 228646 | *piCol = 0; |
| 228627 | 228647 | fts5ApiPhraseNextColumn(pCtx, pIter, piCol); |
| 228628 | 228648 | } |
| 228629 | 228649 | }else{ |
| 228630 | 228650 | int n; |
| 228631 | 228651 | rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n); |
| 228632 | 228652 | if( rc==SQLITE_OK ){ |
| 228633 | | - pIter->b = &pIter->a[n]; |
| 228653 | + assert( pIter->a || n==0 ); |
| 228654 | + pIter->b = (pIter->a ? &pIter->a[n] : 0); |
| 228634 | 228655 | if( n<=0 ){ |
| 228635 | 228656 | *piCol = -1; |
| 228636 | 228657 | }else if( pIter->a[0]==0x01 ){ |
| 228637 | 228658 | pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol); |
| 228638 | 228659 | }else{ |
| | @@ -229106,11 +229127,11 @@ |
| 229106 | 229127 | assert( nArg>0 ); |
| 229107 | 229128 | rc = SQLITE_ERROR; |
| 229108 | 229129 | *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); |
| 229109 | 229130 | }else{ |
| 229110 | 229131 | rc = pMod->x.xCreate( |
| 229111 | | - pMod->pUserData, &azArg[1], (nArg?nArg-1:0), &pConfig->pTok |
| 229132 | + pMod->pUserData, (azArg?&azArg[1]:0), (nArg?nArg-1:0), &pConfig->pTok |
| 229112 | 229133 | ); |
| 229113 | 229134 | pConfig->pTokApi = &pMod->x; |
| 229114 | 229135 | if( rc!=SQLITE_OK ){ |
| 229115 | 229136 | if( pzErr ) *pzErr = sqlite3_mprintf("error in tokenizer constructor"); |
| 229116 | 229137 | }else{ |
| | @@ -229169,11 +229190,11 @@ |
| 229169 | 229190 | int nArg, /* Number of args */ |
| 229170 | 229191 | sqlite3_value **apUnused /* Function arguments */ |
| 229171 | 229192 | ){ |
| 229172 | 229193 | assert( nArg==0 ); |
| 229173 | 229194 | UNUSED_PARAM2(nArg, apUnused); |
| 229174 | | - sqlite3_result_text(pCtx, "fts5: 2021-03-09 21:20:12 9645fe1a050e8b61aea1fba2f142819c387ecb043741392c5719bf7ad303bf8b", -1, SQLITE_TRANSIENT); |
| 229195 | + sqlite3_result_text(pCtx, "fts5: 2021-03-12 15:10:09 acd63062eb06748bfe9e4886639e4f2b54ea6a496a83f10716abbaba4115500b", -1, SQLITE_TRANSIENT); |
| 229175 | 229196 | } |
| 229176 | 229197 | |
| 229177 | 229198 | /* |
| 229178 | 229199 | ** Return true if zName is the extension on one of the shadow tables used |
| 229179 | 229200 | ** by this module. |
| | @@ -234095,12 +234116,12 @@ |
| 234095 | 234116 | } |
| 234096 | 234117 | #endif /* SQLITE_CORE */ |
| 234097 | 234118 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 234098 | 234119 | |
| 234099 | 234120 | /************** End of stmt.c ************************************************/ |
| 234100 | | -#if __LINE__!=234100 |
| 234121 | +#if __LINE__!=234121 |
| 234101 | 234122 | #undef SQLITE_SOURCE_ID |
| 234102 | | -#define SQLITE_SOURCE_ID "2021-03-09 21:20:12 9645fe1a050e8b61aea1fba2f142819c387ecb043741392c5719bf7ad303alt2" |
| 234123 | +#define SQLITE_SOURCE_ID "2021-03-12 15:10:09 acd63062eb06748bfe9e4886639e4f2b54ea6a496a83f10716abbaba4115alt2" |
| 234103 | 234124 | #endif |
| 234104 | 234125 | /* Return the source-id for this library */ |
| 234105 | 234126 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 234106 | 234127 | /************************** End of sqlite3.c ******************************/ |
| 234107 | 234128 | |