| | @@ -1171,11 +1171,11 @@ |
| 1171 | 1171 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1172 | 1172 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1173 | 1173 | */ |
| 1174 | 1174 | #define SQLITE_VERSION "3.34.0" |
| 1175 | 1175 | #define SQLITE_VERSION_NUMBER 3034000 |
| 1176 | | -#define SQLITE_SOURCE_ID "2020-11-23 21:05:29 4f1573b146193e5d552981a9d1d11e50da4da4a843f790e4af1cf0cc19a0b020" |
| 1176 | +#define SQLITE_SOURCE_ID "2020-12-01 16:14:00 a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089fed5b" |
| 1177 | 1177 | |
| 1178 | 1178 | /* |
| 1179 | 1179 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1180 | 1180 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1181 | 1181 | ** |
| | @@ -7239,11 +7239,11 @@ |
| 7239 | 7239 | ** CAPI3REF: Determine the transaction state of a database |
| 7240 | 7240 | ** METHOD: sqlite3 |
| 7241 | 7241 | ** |
| 7242 | 7242 | ** ^The sqlite3_txn_state(D,S) interface returns the current |
| 7243 | 7243 | ** [transaction state] of schema S in database connection D. ^If S is NULL, |
| 7244 | | -** then the highest transaction state of any schema on databse connection D |
| 7244 | +** then the highest transaction state of any schema on database connection D |
| 7245 | 7245 | ** is returned. Transaction states are (in order of lowest to highest): |
| 7246 | 7246 | ** <ol> |
| 7247 | 7247 | ** <li value="0"> SQLITE_TXN_NONE |
| 7248 | 7248 | ** <li value="1"> SQLITE_TXN_READ |
| 7249 | 7249 | ** <li value="2"> SQLITE_TXN_WRITE |
| | @@ -8786,11 +8786,10 @@ |
| 8786 | 8786 | */ |
| 8787 | 8787 | #define SQLITE_TESTCTRL_FIRST 5 |
| 8788 | 8788 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 |
| 8789 | 8789 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
| 8790 | 8790 | #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ |
| 8791 | | -#define SQLITE_TESTCTRL_SEEK_COUNT 7 |
| 8792 | 8791 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 |
| 8793 | 8792 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
| 8794 | 8793 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
| 8795 | 8794 | #define SQLITE_TESTCTRL_PENDING_BYTE 11 |
| 8796 | 8795 | #define SQLITE_TESTCTRL_ASSERT 12 |
| | @@ -8811,11 +8810,12 @@ |
| 8811 | 8810 | #define SQLITE_TESTCTRL_IMPOSTER 25 |
| 8812 | 8811 | #define SQLITE_TESTCTRL_PARSER_COVERAGE 26 |
| 8813 | 8812 | #define SQLITE_TESTCTRL_RESULT_INTREAL 27 |
| 8814 | 8813 | #define SQLITE_TESTCTRL_PRNG_SEED 28 |
| 8815 | 8814 | #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 |
| 8816 | | -#define SQLITE_TESTCTRL_LAST 29 /* Largest TESTCTRL */ |
| 8815 | +#define SQLITE_TESTCTRL_SEEK_COUNT 30 |
| 8816 | +#define SQLITE_TESTCTRL_LAST 30 /* Largest TESTCTRL */ |
| 8817 | 8817 | |
| 8818 | 8818 | /* |
| 8819 | 8819 | ** CAPI3REF: SQL Keyword Checking |
| 8820 | 8820 | ** |
| 8821 | 8821 | ** These routines provide access to the set of SQL language keywords |
| | @@ -54402,10 +54402,11 @@ |
| 54402 | 54402 | sqlite3_file *pJournal; /* Malloc'd child-journal file descriptor */ |
| 54403 | 54403 | char *zSuperJournal = 0; /* Contents of super-journal file */ |
| 54404 | 54404 | i64 nSuperJournal; /* Size of super-journal file */ |
| 54405 | 54405 | char *zJournal; /* Pointer to one journal within MJ file */ |
| 54406 | 54406 | char *zSuperPtr; /* Space to hold super-journal filename */ |
| 54407 | + char *zFree = 0; /* Free this buffer */ |
| 54407 | 54408 | int nSuperPtr; /* Amount of space allocated to zSuperPtr[] */ |
| 54408 | 54409 | |
| 54409 | 54410 | /* Allocate space for both the pJournal and pSuper file descriptors. |
| 54410 | 54411 | ** If successful, open the super-journal file for reading. |
| 54411 | 54412 | */ |
| | @@ -54426,15 +54427,17 @@ |
| 54426 | 54427 | ** files extracted from regular rollback-journals. |
| 54427 | 54428 | */ |
| 54428 | 54429 | rc = sqlite3OsFileSize(pSuper, &nSuperJournal); |
| 54429 | 54430 | if( rc!=SQLITE_OK ) goto delsuper_out; |
| 54430 | 54431 | nSuperPtr = pVfs->mxPathname+1; |
| 54431 | | - zSuperJournal = sqlite3Malloc(nSuperJournal + nSuperPtr + 2); |
| 54432 | | - if( !zSuperJournal ){ |
| 54432 | + zFree = sqlite3Malloc(4 + nSuperJournal + nSuperPtr + 2); |
| 54433 | + if( !zFree ){ |
| 54433 | 54434 | rc = SQLITE_NOMEM_BKPT; |
| 54434 | 54435 | goto delsuper_out; |
| 54435 | 54436 | } |
| 54437 | + zFree[0] = zFree[1] = zFree[2] = zFree[3] = 0; |
| 54438 | + zSuperJournal = &zFree[4]; |
| 54436 | 54439 | zSuperPtr = &zSuperJournal[nSuperJournal+2]; |
| 54437 | 54440 | rc = sqlite3OsRead(pSuper, zSuperJournal, (int)nSuperJournal, 0); |
| 54438 | 54441 | if( rc!=SQLITE_OK ) goto delsuper_out; |
| 54439 | 54442 | zSuperJournal[nSuperJournal] = 0; |
| 54440 | 54443 | zSuperJournal[nSuperJournal+1] = 0; |
| | @@ -54478,11 +54481,11 @@ |
| 54478 | 54481 | |
| 54479 | 54482 | sqlite3OsClose(pSuper); |
| 54480 | 54483 | rc = sqlite3OsDelete(pVfs, zSuper, 0); |
| 54481 | 54484 | |
| 54482 | 54485 | delsuper_out: |
| 54483 | | - sqlite3_free(zSuperJournal); |
| 54486 | + sqlite3_free(zFree); |
| 54484 | 54487 | if( pSuper ){ |
| 54485 | 54488 | sqlite3OsClose(pSuper); |
| 54486 | 54489 | assert( !isOpen(pJournal) ); |
| 54487 | 54490 | sqlite3_free(pSuper); |
| 54488 | 54491 | } |
| | @@ -54816,11 +54819,15 @@ |
| 54816 | 54819 | ** in case this has happened, clear the changeCountDone flag now. |
| 54817 | 54820 | */ |
| 54818 | 54821 | pPager->changeCountDone = pPager->tempFile; |
| 54819 | 54822 | |
| 54820 | 54823 | if( rc==SQLITE_OK ){ |
| 54821 | | - zSuper = pPager->pTmpSpace; |
| 54824 | + /* Leave 4 bytes of space before the super-journal filename in memory. |
| 54825 | + ** This is because it may end up being passed to sqlite3OsOpen(), in |
| 54826 | + ** which case it requires 4 0x00 bytes in memory immediately before |
| 54827 | + ** the filename. */ |
| 54828 | + zSuper = &pPager->pTmpSpace[4]; |
| 54822 | 54829 | rc = readSuperJournal(pPager->jfd, zSuper, pPager->pVfs->mxPathname+1); |
| 54823 | 54830 | testcase( rc!=SQLITE_OK ); |
| 54824 | 54831 | } |
| 54825 | 54832 | if( rc==SQLITE_OK |
| 54826 | 54833 | && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) |
| | @@ -54833,10 +54840,12 @@ |
| 54833 | 54840 | } |
| 54834 | 54841 | if( rc==SQLITE_OK && zSuper[0] && res ){ |
| 54835 | 54842 | /* If there was a super-journal and this routine will return success, |
| 54836 | 54843 | ** see if it is possible to delete the super-journal. |
| 54837 | 54844 | */ |
| 54845 | + assert( zSuper==&pPager->pTmpSpace[4] ); |
| 54846 | + memset(&zSuper[-4], 0, 4); |
| 54838 | 54847 | rc = pager_delsuper(pPager, zSuper); |
| 54839 | 54848 | testcase( rc!=SQLITE_OK ); |
| 54840 | 54849 | } |
| 54841 | 54850 | if( isHot && nPlayback ){ |
| 54842 | 54851 | sqlite3_log(SQLITE_NOTICE_RECOVER_ROLLBACK, "recovered %d pages from %s", |
| | @@ -64822,11 +64831,11 @@ |
| 64822 | 64831 | #define hasReadConflicts(a, b) 0 |
| 64823 | 64832 | #endif |
| 64824 | 64833 | |
| 64825 | 64834 | #ifdef SQLITE_DEBUG |
| 64826 | 64835 | /* |
| 64827 | | -** Return an reset the seek counter for a Btree object. |
| 64836 | +** Return and reset the seek counter for a Btree object. |
| 64828 | 64837 | */ |
| 64829 | 64838 | SQLITE_PRIVATE sqlite3_uint64 sqlite3BtreeSeekCount(Btree *pBt){ |
| 64830 | 64839 | u64 n = pBt->nSeek; |
| 64831 | 64840 | pBt->nSeek = 0; |
| 64832 | 64841 | return n; |
| | @@ -124412,10 +124421,12 @@ |
| 124412 | 124421 | /* Version 3.32.0 and later */ |
| 124413 | 124422 | char *(*create_filename)(const char*,const char*,const char*, |
| 124414 | 124423 | int,const char**); |
| 124415 | 124424 | void (*free_filename)(char*); |
| 124416 | 124425 | sqlite3_file *(*database_file_object)(const char*); |
| 124426 | + /* Version 3.34.0 and later */ |
| 124427 | + int (*txn_state)(sqlite3*,const char*); |
| 124417 | 124428 | }; |
| 124418 | 124429 | |
| 124419 | 124430 | /* |
| 124420 | 124431 | ** This is the function signature used for all extension entry points. It |
| 124421 | 124432 | ** is also defined in the file "loadext.c". |
| | @@ -124716,10 +124727,12 @@ |
| 124716 | 124727 | #define sqlite3_filename_wal sqlite3_api->filename_wal |
| 124717 | 124728 | /* Version 3.32.0 and later */ |
| 124718 | 124729 | #define sqlite3_create_filename sqlite3_api->create_filename |
| 124719 | 124730 | #define sqlite3_free_filename sqlite3_api->free_filename |
| 124720 | 124731 | #define sqlite3_database_file_object sqlite3_api->database_file_object |
| 124732 | +/* Version 3.34.0 and later */ |
| 124733 | +#define sqlite3_txn_state sqlite3_api->txn_state |
| 124721 | 124734 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ |
| 124722 | 124735 | |
| 124723 | 124736 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 124724 | 124737 | /* This case when the file really is being compiled as a loadable |
| 124725 | 124738 | ** extension */ |
| | @@ -125198,10 +125211,12 @@ |
| 125198 | 125211 | sqlite3_filename_wal, |
| 125199 | 125212 | /* Version 3.32.0 and later */ |
| 125200 | 125213 | sqlite3_create_filename, |
| 125201 | 125214 | sqlite3_free_filename, |
| 125202 | 125215 | sqlite3_database_file_object, |
| 125216 | + /* Version 3.34.0 and later */ |
| 125217 | + sqlite3_txn_state, |
| 125203 | 125218 | }; |
| 125204 | 125219 | |
| 125205 | 125220 | /* True if x is the directory separator character |
| 125206 | 125221 | */ |
| 125207 | 125222 | #if SQLITE_OS_WIN |
| | @@ -194344,11 +194359,11 @@ |
| 194344 | 194359 | p->aSegment = (GeoSegment*)&p->aEvent[nVertex*2]; |
| 194345 | 194360 | p->nEvent = p->nSegment = 0; |
| 194346 | 194361 | geopolyAddSegments(p, p1, 1); |
| 194347 | 194362 | geopolyAddSegments(p, p2, 2); |
| 194348 | 194363 | pThisEvent = geopolySortEventsByX(p->aEvent, p->nEvent); |
| 194349 | | - rX = pThisEvent->x==0.0 ? -1.0 : 0.0; |
| 194364 | + rX = pThisEvent && pThisEvent->x==0.0 ? -1.0 : 0.0; |
| 194350 | 194365 | memset(aOverlap, 0, sizeof(aOverlap)); |
| 194351 | 194366 | while( pThisEvent ){ |
| 194352 | 194367 | if( pThisEvent->x!=rX ){ |
| 194353 | 194368 | GeoSegment *pPrev = 0; |
| 194354 | 194369 | int iMask = 0; |
| | @@ -212253,11 +212268,11 @@ |
| 212253 | 212268 | Fts5Bm25Data **ppData /* OUT: bm25-data object for this query */ |
| 212254 | 212269 | ){ |
| 212255 | 212270 | int rc = SQLITE_OK; /* Return code */ |
| 212256 | 212271 | Fts5Bm25Data *p; /* Object to return */ |
| 212257 | 212272 | |
| 212258 | | - p = pApi->xGetAuxdata(pFts, 0); |
| 212273 | + p = (Fts5Bm25Data*)pApi->xGetAuxdata(pFts, 0); |
| 212259 | 212274 | if( p==0 ){ |
| 212260 | 212275 | int nPhrase; /* Number of phrases in query */ |
| 212261 | 212276 | sqlite3_int64 nRow = 0; /* Number of rows in table */ |
| 212262 | 212277 | sqlite3_int64 nToken = 0; /* Number of tokens in table */ |
| 212263 | 212278 | sqlite3_int64 nByte; /* Bytes of space to allocate */ |
| | @@ -212327,11 +212342,11 @@ |
| 212327 | 212342 | int nVal, /* Number of values in apVal[] array */ |
| 212328 | 212343 | sqlite3_value **apVal /* Array of trailing arguments */ |
| 212329 | 212344 | ){ |
| 212330 | 212345 | const double k1 = 1.2; /* Constant "k1" from BM25 formula */ |
| 212331 | 212346 | const double b = 0.75; /* Constant "b" from BM25 formula */ |
| 212332 | | - int rc = SQLITE_OK; /* Error code */ |
| 212347 | + int rc; /* Error code */ |
| 212333 | 212348 | double score = 0.0; /* SQL function return value */ |
| 212334 | 212349 | Fts5Bm25Data *pData; /* Values allocated/calculated once only */ |
| 212335 | 212350 | int i; /* Iterator variable */ |
| 212336 | 212351 | int nInst = 0; /* Value returned by xInstCount() */ |
| 212337 | 212352 | double D = 0.0; /* Total number of tokens in row */ |
| | @@ -212359,21 +212374,19 @@ |
| 212359 | 212374 | int nTok; |
| 212360 | 212375 | rc = pApi->xColumnSize(pFts, -1, &nTok); |
| 212361 | 212376 | D = (double)nTok; |
| 212362 | 212377 | } |
| 212363 | 212378 | |
| 212364 | | - /* Determine the BM25 score for the current row. */ |
| 212365 | | - for(i=0; rc==SQLITE_OK && i<pData->nPhrase; i++){ |
| 212366 | | - score += pData->aIDF[i] * ( |
| 212367 | | - ( aFreq[i] * (k1 + 1.0) ) / |
| 212368 | | - ( aFreq[i] + k1 * (1 - b + b * D / pData->avgdl) ) |
| 212369 | | - ); |
| 212370 | | - } |
| 212371 | | - |
| 212372 | | - /* If no error has occurred, return the calculated score. Otherwise, |
| 212373 | | - ** throw an SQL exception. */ |
| 212379 | + /* Determine and return the BM25 score for the current row. Or, if an |
| 212380 | + ** error has occurred, throw an exception. */ |
| 212374 | 212381 | if( rc==SQLITE_OK ){ |
| 212382 | + for(i=0; i<pData->nPhrase; i++){ |
| 212383 | + score += pData->aIDF[i] * ( |
| 212384 | + ( aFreq[i] * (k1 + 1.0) ) / |
| 212385 | + ( aFreq[i] + k1 * (1 - b + b * D / pData->avgdl) ) |
| 212386 | + ); |
| 212387 | + } |
| 212375 | 212388 | sqlite3_result_double(pCtx, -1.0 * score); |
| 212376 | 212389 | }else{ |
| 212377 | 212390 | sqlite3_result_error_code(pCtx, rc); |
| 212378 | 212391 | } |
| 212379 | 212392 | } |
| | @@ -223508,10 +223521,11 @@ |
| 223508 | 223521 | cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, 0, 0, -1, z, n); |
| 223509 | 223522 | } |
| 223510 | 223523 | }else{ |
| 223511 | 223524 | poslist.n = 0; |
| 223512 | 223525 | fts5SegiterPoslist(p, &pIter->aSeg[pIter->aFirst[1].iFirst], 0, &poslist); |
| 223526 | + fts5BufferAppendBlob(&p->rc, &poslist, 4, (const u8*)"\0\0\0\0"); |
| 223513 | 223527 | while( 0==sqlite3Fts5PoslistNext64(poslist.p, poslist.n, &iOff, &iPos) ){ |
| 223514 | 223528 | int iCol = FTS5_POS2COLUMN(iPos); |
| 223515 | 223529 | int iTokOff = FTS5_POS2OFFSET(iPos); |
| 223516 | 223530 | cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, iCol, iTokOff, -1, z, n); |
| 223517 | 223531 | } |
| | @@ -226803,11 +226817,11 @@ |
| 226803 | 226817 | int nArg, /* Number of args */ |
| 226804 | 226818 | sqlite3_value **apUnused /* Function arguments */ |
| 226805 | 226819 | ){ |
| 226806 | 226820 | assert( nArg==0 ); |
| 226807 | 226821 | UNUSED_PARAM2(nArg, apUnused); |
| 226808 | | - sqlite3_result_text(pCtx, "fts5: 2020-11-19 21:12:08 c38dec6f52c01614c1bee8356daf0fcd9f708d029116e9bff51e06719a730dde", -1, SQLITE_TRANSIENT); |
| 226822 | + sqlite3_result_text(pCtx, "fts5: 2020-12-01 16:14:00 a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089fed5b", -1, SQLITE_TRANSIENT); |
| 226809 | 226823 | } |
| 226810 | 226824 | |
| 226811 | 226825 | /* |
| 226812 | 226826 | ** Return true if zName is the extension on one of the shadow tables used |
| 226813 | 226827 | ** by this module. |
| | @@ -229376,17 +229390,18 @@ |
| 229376 | 229390 | |
| 229377 | 229391 | /* |
| 229378 | 229392 | ** Allocate a trigram tokenizer. |
| 229379 | 229393 | */ |
| 229380 | 229394 | static int fts5TriCreate( |
| 229381 | | - void *pCtx, |
| 229395 | + void *pUnused, |
| 229382 | 229396 | const char **azArg, |
| 229383 | 229397 | int nArg, |
| 229384 | 229398 | Fts5Tokenizer **ppOut |
| 229385 | 229399 | ){ |
| 229386 | 229400 | int rc = SQLITE_OK; |
| 229387 | 229401 | TrigramTokenizer *pNew = (TrigramTokenizer*)sqlite3_malloc(sizeof(*pNew)); |
| 229402 | + UNUSED_PARAM(pUnused); |
| 229388 | 229403 | if( pNew==0 ){ |
| 229389 | 229404 | rc = SQLITE_NOMEM; |
| 229390 | 229405 | }else{ |
| 229391 | 229406 | int i; |
| 229392 | 229407 | pNew->bFold = 1; |
| | @@ -229415,11 +229430,11 @@ |
| 229415 | 229430 | ** Trigram tokenizer tokenize routine. |
| 229416 | 229431 | */ |
| 229417 | 229432 | static int fts5TriTokenize( |
| 229418 | 229433 | Fts5Tokenizer *pTok, |
| 229419 | 229434 | void *pCtx, |
| 229420 | | - int flags, |
| 229435 | + int unusedFlags, |
| 229421 | 229436 | const char *pText, int nText, |
| 229422 | 229437 | int (*xToken)(void*, int, const char*, int, int, int) |
| 229423 | 229438 | ){ |
| 229424 | 229439 | TrigramTokenizer *p = (TrigramTokenizer*)pTok; |
| 229425 | 229440 | int rc = SQLITE_OK; |
| | @@ -229426,10 +229441,11 @@ |
| 229426 | 229441 | char aBuf[32]; |
| 229427 | 229442 | const unsigned char *zIn = (const unsigned char*)pText; |
| 229428 | 229443 | const unsigned char *zEof = &zIn[nText]; |
| 229429 | 229444 | u32 iCode; |
| 229430 | 229445 | |
| 229446 | + UNUSED_PARAM(unusedFlags); |
| 229431 | 229447 | while( 1 ){ |
| 229432 | 229448 | char *zOut = aBuf; |
| 229433 | 229449 | int iStart = zIn - (const unsigned char*)pText; |
| 229434 | 229450 | const unsigned char *zNext; |
| 229435 | 229451 | |
| | @@ -230288,10 +230304,11 @@ |
| 230288 | 230304 | } |
| 230289 | 230305 | iTbl++; |
| 230290 | 230306 | } |
| 230291 | 230307 | aAscii[0] = 0; /* 0x00 is never a token character */ |
| 230292 | 230308 | } |
| 230309 | + |
| 230293 | 230310 | |
| 230294 | 230311 | /* |
| 230295 | 230312 | ** 2015 May 30 |
| 230296 | 230313 | ** |
| 230297 | 230314 | ** The author disclaims copyright to this source code. In place of |
| | @@ -231726,12 +231743,12 @@ |
| 231726 | 231743 | } |
| 231727 | 231744 | #endif /* SQLITE_CORE */ |
| 231728 | 231745 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 231729 | 231746 | |
| 231730 | 231747 | /************** End of stmt.c ************************************************/ |
| 231731 | | -#if __LINE__!=231731 |
| 231748 | +#if __LINE__!=231748 |
| 231732 | 231749 | #undef SQLITE_SOURCE_ID |
| 231733 | | -#define SQLITE_SOURCE_ID "2020-11-23 21:05:29 4f1573b146193e5d552981a9d1d11e50da4da4a843f790e4af1cf0cc19a0alt2" |
| 231750 | +#define SQLITE_SOURCE_ID "2020-12-01 16:14:00 a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089falt2" |
| 231734 | 231751 | #endif |
| 231735 | 231752 | /* Return the source-id for this library */ |
| 231736 | 231753 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 231737 | 231754 | /************************** End of sqlite3.c ******************************/ |
| 231738 | 231755 | |