| | @@ -452,11 +452,11 @@ |
| 452 | 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | 454 | */ |
| 455 | 455 | #define SQLITE_VERSION "3.37.0" |
| 456 | 456 | #define SQLITE_VERSION_NUMBER 3037000 |
| 457 | | -#define SQLITE_SOURCE_ID "2021-09-06 11:44:19 b3cfe23bec0b95ca673802526704200e2396df715fdded72aa71addd7f47e0e1" |
| 457 | +#define SQLITE_SOURCE_ID "2021-09-22 13:43:16 56da0e9c0321d1fd3c360722cd6284296f9ba459f6b37ab35c81ecabd18f12e3" |
| 458 | 458 | |
| 459 | 459 | /* |
| 460 | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 462 | ** |
| | @@ -19842,11 +19842,11 @@ |
| 19842 | 19842 | #ifdef SQLITE_TEST |
| 19843 | 19843 | SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char*); |
| 19844 | 19844 | #endif |
| 19845 | 19845 | |
| 19846 | 19846 | #ifdef SQLITE_OMIT_VIRTUALTABLE |
| 19847 | | -# define sqlite3VtabClear(Y) |
| 19847 | +# define sqlite3VtabClear(D,T) |
| 19848 | 19848 | # define sqlite3VtabSync(X,Y) SQLITE_OK |
| 19849 | 19849 | # define sqlite3VtabRollback(X) |
| 19850 | 19850 | # define sqlite3VtabCommit(X) |
| 19851 | 19851 | # define sqlite3VtabInSync(db) 0 |
| 19852 | 19852 | # define sqlite3VtabLock(X) |
| | @@ -48856,11 +48856,11 @@ |
| 48856 | 48856 | MemStore *p = 0; |
| 48857 | 48857 | int szName; |
| 48858 | 48858 | if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){ |
| 48859 | 48859 | return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFd, flags, pOutFlags); |
| 48860 | 48860 | } |
| 48861 | | - memset(pFile, 0, sizeof(*p)); |
| 48861 | + memset(pFile, 0, sizeof(*pFile)); |
| 48862 | 48862 | szName = sqlite3Strlen30(zName); |
| 48863 | 48863 | if( szName>1 && zName[0]=='/' ){ |
| 48864 | 48864 | int i; |
| 48865 | 48865 | #ifndef SQLITE_MUTEX_OMIT |
| 48866 | 48866 | sqlite3_mutex *pVfsMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1); |
| | @@ -53160,12 +53160,12 @@ |
| 53160 | 53160 | |
| 53161 | 53161 | u16 nExtra; /* Add this many bytes to each in-memory page */ |
| 53162 | 53162 | i16 nReserve; /* Number of unused bytes at end of each page */ |
| 53163 | 53163 | u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */ |
| 53164 | 53164 | u32 sectorSize; /* Assumed sector size during rollback */ |
| 53165 | | - int pageSize; /* Number of bytes in a page */ |
| 53166 | 53165 | Pgno mxPgno; /* Maximum allowed size of the database */ |
| 53166 | + i64 pageSize; /* Number of bytes in a page */ |
| 53167 | 53167 | i64 journalSizeLimit; /* Size limit for persistent journal files */ |
| 53168 | 53168 | char *zFilename; /* Name of the database file */ |
| 53169 | 53169 | char *zJournal; /* Name of the journal file */ |
| 53170 | 53170 | int (*xBusyHandler)(void*); /* Function to call when busy */ |
| 53171 | 53171 | void *pBusyHandlerArg; /* Context argument for xBusyHandler */ |
| | @@ -59218,12 +59218,12 @@ |
| 59218 | 59218 | /* |
| 59219 | 59219 | ** Return the approximate number of bytes of memory currently |
| 59220 | 59220 | ** used by the pager and its associated cache. |
| 59221 | 59221 | */ |
| 59222 | 59222 | SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager *pPager){ |
| 59223 | | - int perPageSize = pPager->pageSize + pPager->nExtra + sizeof(PgHdr) |
| 59224 | | - + 5*sizeof(void*); |
| 59223 | + int perPageSize = pPager->pageSize + pPager->nExtra |
| 59224 | + + (int)(sizeof(PgHdr) + 5*sizeof(void*)); |
| 59225 | 59225 | return perPageSize*sqlite3PcachePagecount(pPager->pPCache) |
| 59226 | 59226 | + sqlite3MallocSize(pPager) |
| 59227 | 59227 | + pPager->pageSize; |
| 59228 | 59228 | } |
| 59229 | 59229 | |
| | @@ -59413,18 +59413,18 @@ |
| 59413 | 59413 | for(ii=nNew; ii<pPager->nSavepoint; ii++){ |
| 59414 | 59414 | sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint); |
| 59415 | 59415 | } |
| 59416 | 59416 | pPager->nSavepoint = nNew; |
| 59417 | 59417 | |
| 59418 | | - /* If this is a release of the outermost savepoint, truncate |
| 59419 | | - ** the sub-journal to zero bytes in size. */ |
| 59418 | + /* Truncate the sub-journal so that it only includes the parts |
| 59419 | + ** that are still in use. */ |
| 59420 | 59420 | if( op==SAVEPOINT_RELEASE ){ |
| 59421 | 59421 | PagerSavepoint *pRel = &pPager->aSavepoint[nNew]; |
| 59422 | 59422 | if( pRel->bTruncateOnRelease && isOpen(pPager->sjfd) ){ |
| 59423 | 59423 | /* Only truncate if it is an in-memory sub-journal. */ |
| 59424 | 59424 | if( sqlite3JournalIsInMemory(pPager->sjfd) ){ |
| 59425 | | - i64 sz = (pPager->pageSize+4)*pRel->iSubRec; |
| 59425 | + i64 sz = (pPager->pageSize+4)*(i64)pRel->iSubRec; |
| 59426 | 59426 | rc = sqlite3OsTruncate(pPager->sjfd, sz); |
| 59427 | 59427 | assert( rc==SQLITE_OK ); |
| 59428 | 59428 | } |
| 59429 | 59429 | pPager->nSubRec = pRel->iSubRec; |
| 59430 | 59430 | } |
| | @@ -72713,10 +72713,11 @@ |
| 72713 | 72713 | nCell -= nTail; |
| 72714 | 72714 | } |
| 72715 | 72715 | |
| 72716 | 72716 | pData = &aData[get2byteNotZero(&aData[hdr+5])]; |
| 72717 | 72717 | if( pData<pBegin ) goto editpage_fail; |
| 72718 | + if( NEVER(pData>pPg->aDataEnd) ) goto editpage_fail; |
| 72718 | 72719 | |
| 72719 | 72720 | /* Add cells to the start of the page */ |
| 72720 | 72721 | if( iNew<iOld ){ |
| 72721 | 72722 | int nAdd = MIN(nNew,iOld-iNew); |
| 72722 | 72723 | assert( (iOld-iNew)<nNew || nCell==0 || CORRUPT_DB ); |
| | @@ -74118,11 +74119,11 @@ |
| 74118 | 74119 | pBt = pPage->pBt; |
| 74119 | 74120 | ovflPageSize = pBt->usableSize - 4; |
| 74120 | 74121 | do{ |
| 74121 | 74122 | rc = btreeGetPage(pBt, ovflPgno, &pPage, 0); |
| 74122 | 74123 | if( rc ) return rc; |
| 74123 | | - if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 ){ |
| 74124 | + if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 || pPage->isInit ){ |
| 74124 | 74125 | rc = SQLITE_CORRUPT_BKPT; |
| 74125 | 74126 | }else{ |
| 74126 | 74127 | if( iOffset+ovflPageSize<(u32)nTotal ){ |
| 74127 | 74128 | ovflPgno = get4byte(pPage->aData); |
| 74128 | 74129 | }else{ |
| | @@ -94795,10 +94796,15 @@ |
| 94795 | 94796 | rc = SQLITE_NOMEM_BKPT; |
| 94796 | 94797 | }else if( rc==SQLITE_IOERR_CORRUPTFS ){ |
| 94797 | 94798 | rc = SQLITE_CORRUPT_BKPT; |
| 94798 | 94799 | } |
| 94799 | 94800 | assert( rc ); |
| 94801 | +#ifdef SQLITE_DEBUG |
| 94802 | + if( db->flags & SQLITE_VdbeTrace ){ |
| 94803 | + printf("ABORT-due-to-error. rc=%d\n", rc); |
| 94804 | + } |
| 94805 | +#endif |
| 94800 | 94806 | if( p->zErrMsg==0 && rc!=SQLITE_IOERR_NOMEM ){ |
| 94801 | 94807 | sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc)); |
| 94802 | 94808 | } |
| 94803 | 94809 | p->rc = rc; |
| 94804 | 94810 | sqlite3SystemError(db, rc); |
| | @@ -105161,10 +105167,11 @@ |
| 105161 | 105167 | |
| 105162 | 105168 | /*********************************************************************** |
| 105163 | 105169 | ** Test-only SQL functions that are only usable if enabled |
| 105164 | 105170 | ** via SQLITE_TESTCTRL_INTERNAL_FUNCTIONS |
| 105165 | 105171 | */ |
| 105172 | +#if !defined(SQLITE_UNTESTABLE) |
| 105166 | 105173 | case INLINEFUNC_expr_compare: { |
| 105167 | 105174 | /* Compare two expressions using sqlite3ExprCompare() */ |
| 105168 | 105175 | assert( nFarg==2 ); |
| 105169 | 105176 | sqlite3VdbeAddOp2(v, OP_Integer, |
| 105170 | 105177 | sqlite3ExprCompare(0,pFarg->a[0].pExpr, pFarg->a[1].pExpr,-1), |
| | @@ -105194,11 +105201,10 @@ |
| 105194 | 105201 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 105195 | 105202 | } |
| 105196 | 105203 | break; |
| 105197 | 105204 | } |
| 105198 | 105205 | |
| 105199 | | -#ifdef SQLITE_DEBUG |
| 105200 | 105206 | case INLINEFUNC_affinity: { |
| 105201 | 105207 | /* The AFFINITY() function evaluates to a string that describes |
| 105202 | 105208 | ** the type affinity of the argument. This is used for testing of |
| 105203 | 105209 | ** the SQLite type logic. |
| 105204 | 105210 | */ |
| | @@ -105208,11 +105214,11 @@ |
| 105208 | 105214 | aff = sqlite3ExprAffinity(pFarg->a[0].pExpr); |
| 105209 | 105215 | sqlite3VdbeLoadString(v, target, |
| 105210 | 105216 | (aff<=SQLITE_AFF_NONE) ? "none" : azAff[aff-SQLITE_AFF_BLOB]); |
| 105211 | 105217 | break; |
| 105212 | 105218 | } |
| 105213 | | -#endif |
| 105219 | +#endif /* !defined(SQLITE_UNTESTABLE) */ |
| 105214 | 105220 | } |
| 105215 | 105221 | return target; |
| 105216 | 105222 | } |
| 105217 | 105223 | |
| 105218 | 105224 | |
| | @@ -108172,12 +108178,11 @@ |
| 108172 | 108178 | bQuote = sqlite3Isquote(pNew->z[0]); |
| 108173 | 108179 | sqlite3NestedParse(pParse, |
| 108174 | 108180 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET " |
| 108175 | 108181 | "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, %d) " |
| 108176 | 108182 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' " |
| 108177 | | - " AND (type != 'index' OR tbl_name = %Q)" |
| 108178 | | - " AND sql NOT LIKE 'create virtual%%'", |
| 108183 | + " AND (type != 'index' OR tbl_name = %Q)", |
| 108179 | 108184 | zDb, |
| 108180 | 108185 | zDb, pTab->zName, iCol, zNew, bQuote, iSchema==1, |
| 108181 | 108186 | pTab->zName |
| 108182 | 108187 | ); |
| 108183 | 108188 | |
| | @@ -109023,11 +109028,11 @@ |
| 109023 | 109028 | rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc); |
| 109024 | 109029 | if( rc==SQLITE_OK ){ |
| 109025 | 109030 | sqlite3WalkSelect(&sWalker, pSelect); |
| 109026 | 109031 | } |
| 109027 | 109032 | if( rc!=SQLITE_OK ) goto renameColumnFunc_done; |
| 109028 | | - }else if( ALWAYS(IsOrdinaryTable(sParse.pNewTable)) ){ |
| 109033 | + }else if( IsOrdinaryTable(sParse.pNewTable) ){ |
| 109029 | 109034 | /* A regular table */ |
| 109030 | 109035 | int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName); |
| 109031 | 109036 | FKey *pFKey; |
| 109032 | 109037 | sCtx.pTab = sParse.pNewTable; |
| 109033 | 109038 | if( bFKOnly==0 ){ |
| | @@ -120209,13 +120214,13 @@ |
| 120209 | 120214 | } |
| 120210 | 120215 | |
| 120211 | 120216 | /* |
| 120212 | 120217 | ** Implementation of the changes() SQL function. |
| 120213 | 120218 | ** |
| 120214 | | -** IMP: R-62073-11209 The changes() SQL function is a wrapper |
| 120215 | | -** around the sqlite3_changes64() C/C++ function and hence follows the same |
| 120216 | | -** rules for counting changes. |
| 120219 | +** IMP: R-32760-32347 The changes() SQL function is a wrapper |
| 120220 | +** around the sqlite3_changes64() C/C++ function and hence follows the |
| 120221 | +** same rules for counting changes. |
| 120217 | 120222 | */ |
| 120218 | 120223 | static void changes( |
| 120219 | 120224 | sqlite3_context *context, |
| 120220 | 120225 | int NotUsed, |
| 120221 | 120226 | sqlite3_value **NotUsed2 |
| | @@ -120234,12 +120239,12 @@ |
| 120234 | 120239 | int NotUsed, |
| 120235 | 120240 | sqlite3_value **NotUsed2 |
| 120236 | 120241 | ){ |
| 120237 | 120242 | sqlite3 *db = sqlite3_context_db_handle(context); |
| 120238 | 120243 | UNUSED_PARAMETER2(NotUsed, NotUsed2); |
| 120239 | | - /* IMP: R-52756-41993 This function was a wrapper around the |
| 120240 | | - ** sqlite3_total_changes() C/C++ interface. */ |
| 120244 | + /* IMP: R-11217-42568 This function is a wrapper around the |
| 120245 | + ** sqlite3_total_changes64() C/C++ interface. */ |
| 120241 | 120246 | sqlite3_result_int64(context, sqlite3_total_changes64(db)); |
| 120242 | 120247 | } |
| 120243 | 120248 | |
| 120244 | 120249 | /* |
| 120245 | 120250 | ** A structure defining how to do GLOB-style comparisons. |
| | @@ -121761,16 +121766,16 @@ |
| 121761 | 121766 | ** |
| 121762 | 121767 | ** For peak efficiency, put the most frequently used function last. |
| 121763 | 121768 | */ |
| 121764 | 121769 | static FuncDef aBuiltinFunc[] = { |
| 121765 | 121770 | /***** Functions only available with SQLITE_TESTCTRL_INTERNAL_FUNCTIONS *****/ |
| 121771 | +#if !defined(SQLITE_UNTESTABLE) |
| 121766 | 121772 | TEST_FUNC(implies_nonnull_row, 2, INLINEFUNC_implies_nonnull_row, 0), |
| 121767 | 121773 | TEST_FUNC(expr_compare, 2, INLINEFUNC_expr_compare, 0), |
| 121768 | 121774 | TEST_FUNC(expr_implies_expr, 2, INLINEFUNC_expr_implies_expr, 0), |
| 121769 | | -#ifdef SQLITE_DEBUG |
| 121770 | | - TEST_FUNC(affinity, 1, INLINEFUNC_affinity, 0), |
| 121771 | | -#endif |
| 121775 | + TEST_FUNC(affinity, 1, INLINEFUNC_affinity, 0), |
| 121776 | +#endif /* !defined(SQLITE_UNTESTABLE) */ |
| 121772 | 121777 | /***** Regular functions *****/ |
| 121773 | 121778 | #ifdef SQLITE_SOUNDEX |
| 121774 | 121779 | FUNCTION(soundex, 1, 0, 0, soundexFunc ), |
| 121775 | 121780 | #endif |
| 121776 | 121781 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| | @@ -128264,17 +128269,18 @@ |
| 128264 | 128269 | #define PragTyp_SECURE_DELETE 33 |
| 128265 | 128270 | #define PragTyp_SHRINK_MEMORY 34 |
| 128266 | 128271 | #define PragTyp_SOFT_HEAP_LIMIT 35 |
| 128267 | 128272 | #define PragTyp_SYNCHRONOUS 36 |
| 128268 | 128273 | #define PragTyp_TABLE_INFO 37 |
| 128269 | | -#define PragTyp_TEMP_STORE 38 |
| 128270 | | -#define PragTyp_TEMP_STORE_DIRECTORY 39 |
| 128271 | | -#define PragTyp_THREADS 40 |
| 128272 | | -#define PragTyp_WAL_AUTOCHECKPOINT 41 |
| 128273 | | -#define PragTyp_WAL_CHECKPOINT 42 |
| 128274 | | -#define PragTyp_LOCK_STATUS 43 |
| 128275 | | -#define PragTyp_STATS 44 |
| 128274 | +#define PragTyp_TABLE_LIST 38 |
| 128275 | +#define PragTyp_TEMP_STORE 39 |
| 128276 | +#define PragTyp_TEMP_STORE_DIRECTORY 40 |
| 128277 | +#define PragTyp_THREADS 41 |
| 128278 | +#define PragTyp_WAL_AUTOCHECKPOINT 42 |
| 128279 | +#define PragTyp_WAL_CHECKPOINT 43 |
| 128280 | +#define PragTyp_LOCK_STATUS 44 |
| 128281 | +#define PragTyp_STATS 45 |
| 128276 | 128282 | |
| 128277 | 128283 | /* Property flags associated with various pragma. */ |
| 128278 | 128284 | #define PragFlg_NeedSchema 0x01 /* Force schema load before running */ |
| 128279 | 128285 | #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */ |
| 128280 | 128286 | #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */ |
| | @@ -128303,49 +128309,55 @@ |
| 128303 | 128309 | /* 11 */ "notnull", |
| 128304 | 128310 | /* 12 */ "dflt_value", |
| 128305 | 128311 | /* 13 */ "pk", |
| 128306 | 128312 | /* 14 */ "hidden", |
| 128307 | 128313 | /* table_info reuses 8 */ |
| 128308 | | - /* 15 */ "seqno", /* Used by: index_xinfo */ |
| 128309 | | - /* 16 */ "cid", |
| 128310 | | - /* 17 */ "name", |
| 128311 | | - /* 18 */ "desc", |
| 128312 | | - /* 19 */ "coll", |
| 128313 | | - /* 20 */ "key", |
| 128314 | | - /* 21 */ "name", /* Used by: function_list */ |
| 128315 | | - /* 22 */ "builtin", |
| 128316 | | - /* 23 */ "type", |
| 128317 | | - /* 24 */ "enc", |
| 128318 | | - /* 25 */ "narg", |
| 128319 | | - /* 26 */ "flags", |
| 128320 | | - /* 27 */ "tbl", /* Used by: stats */ |
| 128321 | | - /* 28 */ "idx", |
| 128322 | | - /* 29 */ "wdth", |
| 128323 | | - /* 30 */ "hght", |
| 128324 | | - /* 31 */ "flgs", |
| 128325 | | - /* 32 */ "seq", /* Used by: index_list */ |
| 128326 | | - /* 33 */ "name", |
| 128327 | | - /* 34 */ "unique", |
| 128328 | | - /* 35 */ "origin", |
| 128329 | | - /* 36 */ "partial", |
| 128330 | | - /* 37 */ "table", /* Used by: foreign_key_check */ |
| 128331 | | - /* 38 */ "rowid", |
| 128332 | | - /* 39 */ "parent", |
| 128333 | | - /* 40 */ "fkid", |
| 128334 | | - /* index_info reuses 15 */ |
| 128335 | | - /* 41 */ "seq", /* Used by: database_list */ |
| 128336 | | - /* 42 */ "name", |
| 128337 | | - /* 43 */ "file", |
| 128338 | | - /* 44 */ "busy", /* Used by: wal_checkpoint */ |
| 128339 | | - /* 45 */ "log", |
| 128340 | | - /* 46 */ "checkpointed", |
| 128341 | | - /* collation_list reuses 32 */ |
| 128342 | | - /* 47 */ "database", /* Used by: lock_status */ |
| 128343 | | - /* 48 */ "status", |
| 128344 | | - /* 49 */ "cache_size", /* Used by: default_cache_size */ |
| 128314 | + /* 15 */ "schema", /* Used by: table_list */ |
| 128315 | + /* 16 */ "name", |
| 128316 | + /* 17 */ "type", |
| 128317 | + /* 18 */ "ncol", |
| 128318 | + /* 19 */ "wr", |
| 128319 | + /* 20 */ "strict", |
| 128320 | + /* 21 */ "seqno", /* Used by: index_xinfo */ |
| 128321 | + /* 22 */ "cid", |
| 128322 | + /* 23 */ "name", |
| 128323 | + /* 24 */ "desc", |
| 128324 | + /* 25 */ "coll", |
| 128325 | + /* 26 */ "key", |
| 128326 | + /* 27 */ "name", /* Used by: function_list */ |
| 128327 | + /* 28 */ "builtin", |
| 128328 | + /* 29 */ "type", |
| 128329 | + /* 30 */ "enc", |
| 128330 | + /* 31 */ "narg", |
| 128331 | + /* 32 */ "flags", |
| 128332 | + /* 33 */ "tbl", /* Used by: stats */ |
| 128333 | + /* 34 */ "idx", |
| 128334 | + /* 35 */ "wdth", |
| 128335 | + /* 36 */ "hght", |
| 128336 | + /* 37 */ "flgs", |
| 128337 | + /* 38 */ "seq", /* Used by: index_list */ |
| 128338 | + /* 39 */ "name", |
| 128339 | + /* 40 */ "unique", |
| 128340 | + /* 41 */ "origin", |
| 128341 | + /* 42 */ "partial", |
| 128342 | + /* 43 */ "table", /* Used by: foreign_key_check */ |
| 128343 | + /* 44 */ "rowid", |
| 128344 | + /* 45 */ "parent", |
| 128345 | + /* 46 */ "fkid", |
| 128346 | + /* index_info reuses 21 */ |
| 128347 | + /* 47 */ "seq", /* Used by: database_list */ |
| 128348 | + /* 48 */ "name", |
| 128349 | + /* 49 */ "file", |
| 128350 | + /* 50 */ "busy", /* Used by: wal_checkpoint */ |
| 128351 | + /* 51 */ "log", |
| 128352 | + /* 52 */ "checkpointed", |
| 128353 | + /* collation_list reuses 38 */ |
| 128354 | + /* 53 */ "database", /* Used by: lock_status */ |
| 128355 | + /* 54 */ "status", |
| 128356 | + /* 55 */ "cache_size", /* Used by: default_cache_size */ |
| 128345 | 128357 | /* module_list pragma_list reuses 9 */ |
| 128346 | | - /* 50 */ "timeout", /* Used by: busy_timeout */ |
| 128358 | + /* 56 */ "timeout", /* Used by: busy_timeout */ |
| 128347 | 128359 | }; |
| 128348 | 128360 | |
| 128349 | 128361 | /* Definitions of all built-in pragmas */ |
| 128350 | 128362 | typedef struct PragmaName { |
| 128351 | 128363 | const char *const zName; /* Name of pragma */ |
| | @@ -128392,11 +128404,11 @@ |
| 128392 | 128404 | #endif |
| 128393 | 128405 | #endif |
| 128394 | 128406 | {/* zName: */ "busy_timeout", |
| 128395 | 128407 | /* ePragTyp: */ PragTyp_BUSY_TIMEOUT, |
| 128396 | 128408 | /* ePragFlg: */ PragFlg_Result0, |
| 128397 | | - /* ColNames: */ 50, 1, |
| 128409 | + /* ColNames: */ 56, 1, |
| 128398 | 128410 | /* iArg: */ 0 }, |
| 128399 | 128411 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 128400 | 128412 | {/* zName: */ "cache_size", |
| 128401 | 128413 | /* ePragTyp: */ PragTyp_CACHE_SIZE, |
| 128402 | 128414 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1, |
| | @@ -128431,11 +128443,11 @@ |
| 128431 | 128443 | #endif |
| 128432 | 128444 | #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
| 128433 | 128445 | {/* zName: */ "collation_list", |
| 128434 | 128446 | /* ePragTyp: */ PragTyp_COLLATION_LIST, |
| 128435 | 128447 | /* ePragFlg: */ PragFlg_Result0, |
| 128436 | | - /* ColNames: */ 32, 2, |
| 128448 | + /* ColNames: */ 38, 2, |
| 128437 | 128449 | /* iArg: */ 0 }, |
| 128438 | 128450 | #endif |
| 128439 | 128451 | #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS) |
| 128440 | 128452 | {/* zName: */ "compile_options", |
| 128441 | 128453 | /* ePragTyp: */ PragTyp_COMPILE_OPTIONS, |
| | @@ -128466,18 +128478,18 @@ |
| 128466 | 128478 | #endif |
| 128467 | 128479 | #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
| 128468 | 128480 | {/* zName: */ "database_list", |
| 128469 | 128481 | /* ePragTyp: */ PragTyp_DATABASE_LIST, |
| 128470 | 128482 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0, |
| 128471 | | - /* ColNames: */ 41, 3, |
| 128483 | + /* ColNames: */ 47, 3, |
| 128472 | 128484 | /* iArg: */ 0 }, |
| 128473 | 128485 | #endif |
| 128474 | 128486 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) |
| 128475 | 128487 | {/* zName: */ "default_cache_size", |
| 128476 | 128488 | /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE, |
| 128477 | 128489 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1, |
| 128478 | | - /* ColNames: */ 49, 1, |
| 128490 | + /* ColNames: */ 55, 1, |
| 128479 | 128491 | /* iArg: */ 0 }, |
| 128480 | 128492 | #endif |
| 128481 | 128493 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 128482 | 128494 | #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) |
| 128483 | 128495 | {/* zName: */ "defer_foreign_keys", |
| | @@ -128503,11 +128515,11 @@ |
| 128503 | 128515 | #endif |
| 128504 | 128516 | #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) |
| 128505 | 128517 | {/* zName: */ "foreign_key_check", |
| 128506 | 128518 | /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK, |
| 128507 | 128519 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128508 | | - /* ColNames: */ 37, 4, |
| 128520 | + /* ColNames: */ 43, 4, |
| 128509 | 128521 | /* iArg: */ 0 }, |
| 128510 | 128522 | #endif |
| 128511 | 128523 | #if !defined(SQLITE_OMIT_FOREIGN_KEY) |
| 128512 | 128524 | {/* zName: */ "foreign_key_list", |
| 128513 | 128525 | /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST, |
| | @@ -128546,11 +128558,11 @@ |
| 128546 | 128558 | #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
| 128547 | 128559 | #if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS) |
| 128548 | 128560 | {/* zName: */ "function_list", |
| 128549 | 128561 | /* ePragTyp: */ PragTyp_FUNCTION_LIST, |
| 128550 | 128562 | /* ePragFlg: */ PragFlg_Result0, |
| 128551 | | - /* ColNames: */ 21, 6, |
| 128563 | + /* ColNames: */ 27, 6, |
| 128552 | 128564 | /* iArg: */ 0 }, |
| 128553 | 128565 | #endif |
| 128554 | 128566 | #endif |
| 128555 | 128567 | {/* zName: */ "hard_heap_limit", |
| 128556 | 128568 | /* ePragTyp: */ PragTyp_HARD_HEAP_LIMIT, |
| | @@ -128575,21 +128587,21 @@ |
| 128575 | 128587 | #endif |
| 128576 | 128588 | #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
| 128577 | 128589 | {/* zName: */ "index_info", |
| 128578 | 128590 | /* ePragTyp: */ PragTyp_INDEX_INFO, |
| 128579 | 128591 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128580 | | - /* ColNames: */ 15, 3, |
| 128592 | + /* ColNames: */ 21, 3, |
| 128581 | 128593 | /* iArg: */ 0 }, |
| 128582 | 128594 | {/* zName: */ "index_list", |
| 128583 | 128595 | /* ePragTyp: */ PragTyp_INDEX_LIST, |
| 128584 | 128596 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128585 | | - /* ColNames: */ 32, 5, |
| 128597 | + /* ColNames: */ 38, 5, |
| 128586 | 128598 | /* iArg: */ 0 }, |
| 128587 | 128599 | {/* zName: */ "index_xinfo", |
| 128588 | 128600 | /* ePragTyp: */ PragTyp_INDEX_INFO, |
| 128589 | 128601 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128590 | | - /* ColNames: */ 15, 6, |
| 128602 | + /* ColNames: */ 21, 6, |
| 128591 | 128603 | /* iArg: */ 1 }, |
| 128592 | 128604 | #endif |
| 128593 | 128605 | #if !defined(SQLITE_OMIT_INTEGRITY_CHECK) |
| 128594 | 128606 | {/* zName: */ "integrity_check", |
| 128595 | 128607 | /* ePragTyp: */ PragTyp_INTEGRITY_CHECK, |
| | @@ -128625,11 +128637,11 @@ |
| 128625 | 128637 | #endif |
| 128626 | 128638 | #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) |
| 128627 | 128639 | {/* zName: */ "lock_status", |
| 128628 | 128640 | /* ePragTyp: */ PragTyp_LOCK_STATUS, |
| 128629 | 128641 | /* ePragFlg: */ PragFlg_Result0, |
| 128630 | | - /* ColNames: */ 47, 2, |
| 128642 | + /* ColNames: */ 53, 2, |
| 128631 | 128643 | /* iArg: */ 0 }, |
| 128632 | 128644 | #endif |
| 128633 | 128645 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 128634 | 128646 | {/* zName: */ "locking_mode", |
| 128635 | 128647 | /* ePragTyp: */ PragTyp_LOCKING_MODE, |
| | @@ -128764,11 +128776,11 @@ |
| 128764 | 128776 | #endif |
| 128765 | 128777 | #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG) |
| 128766 | 128778 | {/* zName: */ "stats", |
| 128767 | 128779 | /* ePragTyp: */ PragTyp_STATS, |
| 128768 | 128780 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq, |
| 128769 | | - /* ColNames: */ 27, 5, |
| 128781 | + /* ColNames: */ 33, 5, |
| 128770 | 128782 | /* iArg: */ 0 }, |
| 128771 | 128783 | #endif |
| 128772 | 128784 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 128773 | 128785 | {/* zName: */ "synchronous", |
| 128774 | 128786 | /* ePragTyp: */ PragTyp_SYNCHRONOUS, |
| | @@ -128780,10 +128792,15 @@ |
| 128780 | 128792 | {/* zName: */ "table_info", |
| 128781 | 128793 | /* ePragTyp: */ PragTyp_TABLE_INFO, |
| 128782 | 128794 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128783 | 128795 | /* ColNames: */ 8, 6, |
| 128784 | 128796 | /* iArg: */ 0 }, |
| 128797 | + {/* zName: */ "table_list", |
| 128798 | + /* ePragTyp: */ PragTyp_TABLE_LIST, |
| 128799 | + /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1, |
| 128800 | + /* ColNames: */ 15, 6, |
| 128801 | + /* iArg: */ 1 }, |
| 128785 | 128802 | {/* zName: */ "table_xinfo", |
| 128786 | 128803 | /* ePragTyp: */ PragTyp_TABLE_INFO, |
| 128787 | 128804 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128788 | 128805 | /* ColNames: */ 8, 7, |
| 128789 | 128806 | /* iArg: */ 1 }, |
| | @@ -128855,11 +128872,11 @@ |
| 128855 | 128872 | /* ColNames: */ 0, 0, |
| 128856 | 128873 | /* iArg: */ 0 }, |
| 128857 | 128874 | {/* zName: */ "wal_checkpoint", |
| 128858 | 128875 | /* ePragTyp: */ PragTyp_WAL_CHECKPOINT, |
| 128859 | 128876 | /* ePragFlg: */ PragFlg_NeedSchema, |
| 128860 | | - /* ColNames: */ 44, 3, |
| 128877 | + /* ColNames: */ 50, 3, |
| 128861 | 128878 | /* iArg: */ 0 }, |
| 128862 | 128879 | #endif |
| 128863 | 128880 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 128864 | 128881 | {/* zName: */ "writable_schema", |
| 128865 | 128882 | /* ePragTyp: */ PragTyp_FLAG, |
| | @@ -128866,11 +128883,11 @@ |
| 128866 | 128883 | /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, |
| 128867 | 128884 | /* ColNames: */ 0, 0, |
| 128868 | 128885 | /* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError }, |
| 128869 | 128886 | #endif |
| 128870 | 128887 | }; |
| 128871 | | -/* Number of pragmas: 67 on by default, 77 total. */ |
| 128888 | +/* Number of pragmas: 68 on by default, 78 total. */ |
| 128872 | 128889 | |
| 128873 | 128890 | /************** End of pragma.h **********************************************/ |
| 128874 | 128891 | /************** Continuing where we left off in pragma.c *********************/ |
| 128875 | 128892 | |
| 128876 | 128893 | /* |
| | @@ -130035,10 +130052,58 @@ |
| 130035 | 130052 | } |
| 130036 | 130053 | } |
| 130037 | 130054 | } |
| 130038 | 130055 | break; |
| 130039 | 130056 | |
| 130057 | + /* |
| 130058 | + ** PRAGMA table_list |
| 130059 | + ** |
| 130060 | + ** Return a single row for each table, virtual table, or view in the |
| 130061 | + ** entire schema. |
| 130062 | + ** |
| 130063 | + ** schema: Name of attached database hold this table |
| 130064 | + ** name: Name of the table itself |
| 130065 | + ** type: "table", "view", "virtual", "shadow" |
| 130066 | + ** ncol: Number of columns |
| 130067 | + ** wr: True for a WITHOUT ROWID table |
| 130068 | + ** strict: True for a STRICT table |
| 130069 | + */ |
| 130070 | + case PragTyp_TABLE_LIST: { |
| 130071 | + int ii; |
| 130072 | + pParse->nMem = 6; |
| 130073 | + sqlite3CodeVerifyNamedSchema(pParse, zDb); |
| 130074 | + for(ii=0; ii<db->nDb; ii++){ |
| 130075 | + HashElem *k; |
| 130076 | + Hash *pHash; |
| 130077 | + if( zDb && sqlite3_stricmp(zDb, db->aDb[ii].zDbSName)!=0 ) continue; |
| 130078 | + pHash = &db->aDb[ii].pSchema->tblHash; |
| 130079 | + for(k=sqliteHashFirst(pHash); k; k=sqliteHashNext(k) ){ |
| 130080 | + Table *pTab = sqliteHashData(k); |
| 130081 | + const char *zType; |
| 130082 | + if( zRight && sqlite3_stricmp(zRight, pTab->zName)!=0 ) continue; |
| 130083 | + if( IsView(pTab) ){ |
| 130084 | + zType = "view"; |
| 130085 | + }else if( IsVirtual(pTab) ){ |
| 130086 | + zType = "virtual"; |
| 130087 | + }else if( pTab->tabFlags & TF_Shadow ){ |
| 130088 | + zType = "shadow"; |
| 130089 | + }else{ |
| 130090 | + zType = "table"; |
| 130091 | + } |
| 130092 | + sqlite3VdbeMultiLoad(v, 1, "sssiii", |
| 130093 | + db->aDb[ii].zDbSName, |
| 130094 | + pTab->zName, |
| 130095 | + zType, |
| 130096 | + pTab->nCol, |
| 130097 | + (pTab->tabFlags & TF_WithoutRowid)!=0, |
| 130098 | + (pTab->tabFlags & TF_Strict)!=0 |
| 130099 | + ); |
| 130100 | + } |
| 130101 | + } |
| 130102 | + } |
| 130103 | + break; |
| 130104 | + |
| 130040 | 130105 | #ifdef SQLITE_DEBUG |
| 130041 | 130106 | case PragTyp_STATS: { |
| 130042 | 130107 | Index *pIdx; |
| 130043 | 130108 | HashElem *i; |
| 130044 | 130109 | pParse->nMem = 5; |
| | @@ -130544,11 +130609,13 @@ |
| 130544 | 130609 | }else{ |
| 130545 | 130610 | integrityCheckResultRow(v); |
| 130546 | 130611 | } |
| 130547 | 130612 | sqlite3VdbeJumpHere(v, jmp2); |
| 130548 | 130613 | } |
| 130549 | | - if( pTab->tabFlags & TF_Strict ){ |
| 130614 | + if( (pTab->tabFlags & TF_Strict)!=0 |
| 130615 | + && pCol->eCType!=COLTYPE_ANY |
| 130616 | + ){ |
| 130550 | 130617 | jmp2 = sqlite3VdbeAddOp3(v, OP_IsNullOrType, 3, 0, |
| 130551 | 130618 | sqlite3StdTypeMap[pCol->eCType-1]); |
| 130552 | 130619 | VdbeCoverage(v); |
| 130553 | 130620 | zErr = sqlite3MPrintf(db, "non-%s value in %s.%s", |
| 130554 | 130621 | sqlite3StdType[pCol->eCType-1], |
| | @@ -132836,10 +132903,13 @@ |
| 132836 | 132903 | |
| 132837 | 132904 | pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft); |
| 132838 | 132905 | pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight); |
| 132839 | 132906 | |
| 132840 | 132907 | pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2); |
| 132908 | + assert( pE2!=0 || pEq==0 ); /* Due to db->mallocFailed test |
| 132909 | + ** in sqlite3DbMallocRawNN() called from |
| 132910 | + ** sqlite3PExpr(). */ |
| 132841 | 132911 | if( pEq && isOuterJoin ){ |
| 132842 | 132912 | ExprSetProperty(pEq, EP_FromJoin); |
| 132843 | 132913 | assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) ); |
| 132844 | 132914 | ExprSetVVAProperty(pEq, EP_NoReduce); |
| 132845 | 132915 | pEq->iRightJoinTable = pE2->iTable; |
| | @@ -148365,11 +148435,11 @@ |
| 148365 | 148435 | ** 2019-06-14 https://sqlite.org/src/info/ce8717f0885af975 |
| 148366 | 148436 | ** 2019-09-03 https://sqlite.org/src/info/0f0428096f17252a |
| 148367 | 148437 | */ |
| 148368 | 148438 | if( pLeft->op!=TK_COLUMN |
| 148369 | 148439 | || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT |
| 148370 | | - || IsVirtual(pLeft->y.pTab) /* Value might be numeric */ |
| 148440 | + || (pLeft->y.pTab && IsVirtual(pLeft->y.pTab)) /* Might be numeric */ |
| 148371 | 148441 | ){ |
| 148372 | 148442 | int isNum; |
| 148373 | 148443 | double rDummy; |
| 148374 | 148444 | isNum = sqlite3AtoF(zNew, &rDummy, iTo, SQLITE_UTF8); |
| 148375 | 148445 | if( isNum<=0 ){ |
| | @@ -156490,10 +156560,13 @@ |
| 156490 | 156560 | ); |
| 156491 | 156561 | SELECTTRACE(1,pParse,pSub, |
| 156492 | 156562 | ("New window-function subquery in FROM clause of (%u/%p)\n", |
| 156493 | 156563 | p->selId, p)); |
| 156494 | 156564 | p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); |
| 156565 | + assert( pSub!=0 || p->pSrc==0 ); /* Due to db->mallocFailed test inside |
| 156566 | + ** of sqlite3DbMallocRawNN() called from |
| 156567 | + ** sqlite3SrcListAppend() */ |
| 156495 | 156568 | if( p->pSrc ){ |
| 156496 | 156569 | Table *pTab2; |
| 156497 | 156570 | p->pSrc->a[0].pSelect = pSub; |
| 156498 | 156571 | sqlite3SrcListAssignCursors(pParse, p->pSrc); |
| 156499 | 156572 | pSub->selFlags |= SF_Expanded|SF_OrderByReqd; |
| | @@ -192908,11 +192981,15 @@ |
| 192908 | 192981 | #else |
| 192909 | 192982 | /* #include "sqlite3.h" */ |
| 192910 | 192983 | #endif |
| 192911 | 192984 | SQLITE_PRIVATE int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */ |
| 192912 | 192985 | |
| 192913 | | -#ifndef SQLITE_AMALGAMATION |
| 192986 | +/* |
| 192987 | +** If building separately, we will need some setup that is normally |
| 192988 | +** found in sqliteInt.h |
| 192989 | +*/ |
| 192990 | +#if !defined(SQLITE_AMALGAMATION) |
| 192914 | 192991 | #include "sqlite3rtree.h" |
| 192915 | 192992 | typedef sqlite3_int64 i64; |
| 192916 | 192993 | typedef sqlite3_uint64 u64; |
| 192917 | 192994 | typedef unsigned char u8; |
| 192918 | 192995 | typedef unsigned short u16; |
| | @@ -192921,11 +192998,21 @@ |
| 192921 | 192998 | # define NDEBUG 1 |
| 192922 | 192999 | #endif |
| 192923 | 193000 | #if defined(NDEBUG) && defined(SQLITE_DEBUG) |
| 192924 | 193001 | # undef NDEBUG |
| 192925 | 193002 | #endif |
| 193003 | +#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST) |
| 193004 | +# define ALWAYS(X) (1) |
| 193005 | +# define NEVER(X) (0) |
| 193006 | +#elif !defined(NDEBUG) |
| 193007 | +# define ALWAYS(X) ((X)?1:(assert(0),0)) |
| 193008 | +# define NEVER(X) ((X)?(assert(0),1):0) |
| 193009 | +#else |
| 193010 | +# define ALWAYS(X) (X) |
| 193011 | +# define NEVER(X) (X) |
| 192926 | 193012 | #endif |
| 193013 | +#endif /* !defined(SQLITE_AMALGAMATION) */ |
| 192927 | 193014 | |
| 192928 | 193015 | /* #include <string.h> */ |
| 192929 | 193016 | /* #include <stdio.h> */ |
| 192930 | 193017 | /* #include <assert.h> */ |
| 192931 | 193018 | /* #include <stdlib.h> */ |
| | @@ -192979,11 +193066,13 @@ |
| 192979 | 193066 | u8 nDim2; /* Twice the number of dimensions */ |
| 192980 | 193067 | u8 eCoordType; /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */ |
| 192981 | 193068 | u8 nBytesPerCell; /* Bytes consumed per cell */ |
| 192982 | 193069 | u8 inWrTrans; /* True if inside write transaction */ |
| 192983 | 193070 | u8 nAux; /* # of auxiliary columns in %_rowid */ |
| 193071 | +#ifdef SQLITE_ENABLE_GEOPOLY |
| 192984 | 193072 | u8 nAuxNotNull; /* Number of initial not-null aux columns */ |
| 193073 | +#endif |
| 192985 | 193074 | #ifdef SQLITE_DEBUG |
| 192986 | 193075 | u8 bCorrupt; /* Shadow table corruption detected */ |
| 192987 | 193076 | #endif |
| 192988 | 193077 | int iDepth; /* Current depth of the r-tree structure */ |
| 192989 | 193078 | char *zDb; /* Name of database containing r-tree table */ |
| | @@ -193510,22 +193599,10 @@ |
| 193510 | 193599 | pRtree->pNodeBlob = 0; |
| 193511 | 193600 | sqlite3_blob_close(pBlob); |
| 193512 | 193601 | } |
| 193513 | 193602 | } |
| 193514 | 193603 | |
| 193515 | | -/* |
| 193516 | | -** Check to see if pNode is the same as pParent or any of the parents |
| 193517 | | -** of pParent. |
| 193518 | | -*/ |
| 193519 | | -static int nodeInParentChain(const RtreeNode *pNode, const RtreeNode *pParent){ |
| 193520 | | - do{ |
| 193521 | | - if( pNode==pParent ) return 1; |
| 193522 | | - pParent = pParent->pParent; |
| 193523 | | - }while( pParent ); |
| 193524 | | - return 0; |
| 193525 | | -} |
| 193526 | | - |
| 193527 | 193604 | /* |
| 193528 | 193605 | ** Obtain a reference to an r-tree node. |
| 193529 | 193606 | */ |
| 193530 | 193607 | static int nodeAcquire( |
| 193531 | 193608 | Rtree *pRtree, /* R-tree structure */ |
| | @@ -193538,18 +193615,11 @@ |
| 193538 | 193615 | |
| 193539 | 193616 | /* Check if the requested node is already in the hash table. If so, |
| 193540 | 193617 | ** increase its reference count and return it. |
| 193541 | 193618 | */ |
| 193542 | 193619 | if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){ |
| 193543 | | - if( pParent && !pNode->pParent ){ |
| 193544 | | - if( nodeInParentChain(pNode, pParent) ){ |
| 193545 | | - RTREE_IS_CORRUPT(pRtree); |
| 193546 | | - return SQLITE_CORRUPT_VTAB; |
| 193547 | | - } |
| 193548 | | - pParent->nRef++; |
| 193549 | | - pNode->pParent = pParent; |
| 193550 | | - }else if( pParent && pNode->pParent && pParent!=pNode->pParent ){ |
| 193620 | + if( pParent && pParent!=pNode->pParent ){ |
| 193551 | 193621 | RTREE_IS_CORRUPT(pRtree); |
| 193552 | 193622 | return SQLITE_CORRUPT_VTAB; |
| 193553 | 193623 | } |
| 193554 | 193624 | pNode->nRef++; |
| 193555 | 193625 | *ppNode = pNode; |
| | @@ -193603,11 +193673,11 @@ |
| 193603 | 193673 | ** of the r-tree structure. A height of zero means all data is stored on |
| 193604 | 193674 | ** the root node. A height of one means the children of the root node |
| 193605 | 193675 | ** are the leaves, and so on. If the depth as specified on the root node |
| 193606 | 193676 | ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt. |
| 193607 | 193677 | */ |
| 193608 | | - if( pNode && rc==SQLITE_OK && iNode==1 ){ |
| 193678 | + if( rc==SQLITE_OK && pNode && iNode==1 ){ |
| 193609 | 193679 | pRtree->iDepth = readInt16(pNode->zData); |
| 193610 | 193680 | if( pRtree->iDepth>RTREE_MAX_DEPTH ){ |
| 193611 | 193681 | rc = SQLITE_CORRUPT_VTAB; |
| 193612 | 193682 | RTREE_IS_CORRUPT(pRtree); |
| 193613 | 193683 | } |
| | @@ -194209,15 +194279,16 @@ |
| 194209 | 194279 | ** Return the index of the cell containing a pointer to node pNode |
| 194210 | 194280 | ** in its parent. If pNode is the root node, return -1. |
| 194211 | 194281 | */ |
| 194212 | 194282 | static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){ |
| 194213 | 194283 | RtreeNode *pParent = pNode->pParent; |
| 194214 | | - if( pParent ){ |
| 194284 | + if( ALWAYS(pParent) ){ |
| 194215 | 194285 | return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex); |
| 194286 | + }else{ |
| 194287 | + *piIndex = -1; |
| 194288 | + return SQLITE_OK; |
| 194216 | 194289 | } |
| 194217 | | - *piIndex = -1; |
| 194218 | | - return SQLITE_OK; |
| 194219 | 194290 | } |
| 194220 | 194291 | |
| 194221 | 194292 | /* |
| 194222 | 194293 | ** Compare two search points. Return negative, zero, or positive if the first |
| 194223 | 194294 | ** is less than, equal to, or greater than the second. |
| | @@ -194336,11 +194407,12 @@ |
| 194336 | 194407 | if( pCur->bPoint ){ |
| 194337 | 194408 | int ii; |
| 194338 | 194409 | pNew = rtreeEnqueue(pCur, rScore, iLevel); |
| 194339 | 194410 | if( pNew==0 ) return 0; |
| 194340 | 194411 | ii = (int)(pNew - pCur->aPoint) + 1; |
| 194341 | | - if( ii<RTREE_CACHE_SZ ){ |
| 194412 | + assert( ii==1 ); |
| 194413 | + if( ALWAYS(ii<RTREE_CACHE_SZ) ){ |
| 194342 | 194414 | assert( pCur->aNode[ii]==0 ); |
| 194343 | 194415 | pCur->aNode[ii] = pCur->aNode[0]; |
| 194344 | 194416 | }else{ |
| 194345 | 194417 | nodeRelease(RTREE_OF_CURSOR(pCur), pCur->aNode[0]); |
| 194346 | 194418 | } |
| | @@ -194397,11 +194469,11 @@ |
| 194397 | 194469 | p->aNode[i] = 0; |
| 194398 | 194470 | } |
| 194399 | 194471 | if( p->bPoint ){ |
| 194400 | 194472 | p->anQueue[p->sPoint.iLevel]--; |
| 194401 | 194473 | p->bPoint = 0; |
| 194402 | | - }else if( p->nPoint ){ |
| 194474 | + }else if( ALWAYS(p->nPoint) ){ |
| 194403 | 194475 | p->anQueue[p->aPoint[0].iLevel]--; |
| 194404 | 194476 | n = --p->nPoint; |
| 194405 | 194477 | p->aPoint[0] = p->aPoint[n]; |
| 194406 | 194478 | if( n<RTREE_CACHE_SZ-1 ){ |
| 194407 | 194479 | p->aNode[1] = p->aNode[n+1]; |
| | @@ -194538,11 +194610,11 @@ |
| 194538 | 194610 | static int rtreeRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){ |
| 194539 | 194611 | RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor; |
| 194540 | 194612 | RtreeSearchPoint *p = rtreeSearchPointFirst(pCsr); |
| 194541 | 194613 | int rc = SQLITE_OK; |
| 194542 | 194614 | RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc); |
| 194543 | | - if( rc==SQLITE_OK && p ){ |
| 194615 | + if( rc==SQLITE_OK && ALWAYS(p) ){ |
| 194544 | 194616 | *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell); |
| 194545 | 194617 | } |
| 194546 | 194618 | return rc; |
| 194547 | 194619 | } |
| 194548 | 194620 | |
| | @@ -194556,11 +194628,11 @@ |
| 194556 | 194628 | RtreeCoord c; |
| 194557 | 194629 | int rc = SQLITE_OK; |
| 194558 | 194630 | RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc); |
| 194559 | 194631 | |
| 194560 | 194632 | if( rc ) return rc; |
| 194561 | | - if( p==0 ) return SQLITE_OK; |
| 194633 | + if( NEVER(p==0) ) return SQLITE_OK; |
| 194562 | 194634 | if( i==0 ){ |
| 194563 | 194635 | sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell)); |
| 194564 | 194636 | }else if( i<=pRtree->nDim2 ){ |
| 194565 | 194637 | nodeGetCoord(pRtree, pNode, p->iCell, i-1, &c); |
| 194566 | 194638 | #ifndef SQLITE_RTREE_INT_ONLY |
| | @@ -194755,12 +194827,15 @@ |
| 194755 | 194827 | } |
| 194756 | 194828 | } |
| 194757 | 194829 | } |
| 194758 | 194830 | if( rc==SQLITE_OK ){ |
| 194759 | 194831 | RtreeSearchPoint *pNew; |
| 194832 | + assert( pCsr->bPoint==0 ); /* Due to the resetCursor() call above */ |
| 194760 | 194833 | pNew = rtreeSearchPointNew(pCsr, RTREE_ZERO, (u8)(pRtree->iDepth+1)); |
| 194761 | | - if( pNew==0 ) return SQLITE_NOMEM; |
| 194834 | + if( NEVER(pNew==0) ){ /* Because pCsr->bPoint was FALSE */ |
| 194835 | + return SQLITE_NOMEM; |
| 194836 | + } |
| 194762 | 194837 | pNew->id = 1; |
| 194763 | 194838 | pNew->iCell = 0; |
| 194764 | 194839 | pNew->eWithin = PARTLY_WITHIN; |
| 194765 | 194840 | assert( pCsr->bPoint==1 ); |
| 194766 | 194841 | pCsr->aNode[0] = pRoot; |
| | @@ -194833,11 +194908,11 @@ |
| 194833 | 194908 | assert( pIdxInfo->idxStr==0 ); |
| 194834 | 194909 | for(ii=0; ii<pIdxInfo->nConstraint && iIdx<(int)(sizeof(zIdxStr)-1); ii++){ |
| 194835 | 194910 | struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii]; |
| 194836 | 194911 | |
| 194837 | 194912 | if( bMatch==0 && p->usable |
| 194838 | | - && p->iColumn==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ |
| 194913 | + && p->iColumn<=0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ |
| 194839 | 194914 | ){ |
| 194840 | 194915 | /* We have an equality constraint on the rowid. Use strategy 1. */ |
| 194841 | 194916 | int jj; |
| 194842 | 194917 | for(jj=0; jj<ii; jj++){ |
| 194843 | 194918 | pIdxInfo->aConstraintUsage[jj].argvIndex = 0; |
| | @@ -195086,16 +195161,23 @@ |
| 195086 | 195161 | RtreeNode *pNode, /* Adjust ancestry of this node. */ |
| 195087 | 195162 | RtreeCell *pCell /* This cell was just inserted */ |
| 195088 | 195163 | ){ |
| 195089 | 195164 | RtreeNode *p = pNode; |
| 195090 | 195165 | int cnt = 0; |
| 195166 | + int rc; |
| 195091 | 195167 | while( p->pParent ){ |
| 195092 | 195168 | RtreeNode *pParent = p->pParent; |
| 195093 | 195169 | RtreeCell cell; |
| 195094 | 195170 | int iCell; |
| 195095 | 195171 | |
| 195096 | | - if( (++cnt)>1000 || nodeParentIndex(pRtree, p, &iCell) ){ |
| 195172 | + cnt++; |
| 195173 | + if( NEVER(cnt>100) ){ |
| 195174 | + RTREE_IS_CORRUPT(pRtree); |
| 195175 | + return SQLITE_CORRUPT_VTAB; |
| 195176 | + } |
| 195177 | + rc = nodeParentIndex(pRtree, p, &iCell); |
| 195178 | + if( NEVER(rc!=SQLITE_OK) ){ |
| 195097 | 195179 | RTREE_IS_CORRUPT(pRtree); |
| 195098 | 195180 | return SQLITE_CORRUPT_VTAB; |
| 195099 | 195181 | } |
| 195100 | 195182 | |
| 195101 | 195183 | nodeGetCell(pRtree, pParent, iCell, &cell); |
| | @@ -195475,15 +195557,16 @@ |
| 195475 | 195557 | } |
| 195476 | 195558 | }else{ |
| 195477 | 195559 | RtreeNode *pParent = pLeft->pParent; |
| 195478 | 195560 | int iCell; |
| 195479 | 195561 | rc = nodeParentIndex(pRtree, pLeft, &iCell); |
| 195480 | | - if( rc==SQLITE_OK ){ |
| 195562 | + if( ALWAYS(rc==SQLITE_OK) ){ |
| 195481 | 195563 | nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell); |
| 195482 | 195564 | rc = AdjustTree(pRtree, pParent, &leftbbox); |
| 195565 | + assert( rc==SQLITE_OK ); |
| 195483 | 195566 | } |
| 195484 | | - if( rc!=SQLITE_OK ){ |
| 195567 | + if( NEVER(rc!=SQLITE_OK) ){ |
| 195485 | 195568 | goto splitnode_out; |
| 195486 | 195569 | } |
| 195487 | 195570 | } |
| 195488 | 195571 | if( (rc = rtreeInsertCell(pRtree, pRight->pParent, &rightbbox, iHeight+1)) ){ |
| 195489 | 195572 | goto splitnode_out; |
| | @@ -195554,11 +195637,11 @@ |
| 195554 | 195637 | ** want to do this as it leads to a memory leak when trying to delete |
| 195555 | 195638 | ** the referenced counted node structures. |
| 195556 | 195639 | */ |
| 195557 | 195640 | iNode = sqlite3_column_int64(pRtree->pReadParent, 0); |
| 195558 | 195641 | for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent); |
| 195559 | | - if( !pTest ){ |
| 195642 | + if( pTest==0 ){ |
| 195560 | 195643 | rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent); |
| 195561 | 195644 | } |
| 195562 | 195645 | } |
| 195563 | 195646 | rc = sqlite3_reset(pRtree->pReadParent); |
| 195564 | 195647 | if( rc==SQLITE_OK ) rc = rc2; |
| | @@ -195585,10 +195668,11 @@ |
| 195585 | 195668 | rc = nodeParentIndex(pRtree, pNode, &iCell); |
| 195586 | 195669 | if( rc==SQLITE_OK ){ |
| 195587 | 195670 | pParent = pNode->pParent; |
| 195588 | 195671 | pNode->pParent = 0; |
| 195589 | 195672 | rc = deleteCell(pRtree, pParent, iCell, iHeight+1); |
| 195673 | + testcase( rc!=SQLITE_OK ); |
| 195590 | 195674 | } |
| 195591 | 195675 | rc2 = nodeRelease(pRtree, pParent); |
| 195592 | 195676 | if( rc==SQLITE_OK ){ |
| 195593 | 195677 | rc = rc2; |
| 195594 | 195678 | } |
| | @@ -195807,11 +195891,11 @@ |
| 195807 | 195891 | pRtree->iReinsertHeight = iHeight; |
| 195808 | 195892 | rc = Reinsert(pRtree, pNode, pCell, iHeight); |
| 195809 | 195893 | } |
| 195810 | 195894 | }else{ |
| 195811 | 195895 | rc = AdjustTree(pRtree, pNode, pCell); |
| 195812 | | - if( rc==SQLITE_OK ){ |
| 195896 | + if( ALWAYS(rc==SQLITE_OK) ){ |
| 195813 | 195897 | if( iHeight==0 ){ |
| 195814 | 195898 | rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode); |
| 195815 | 195899 | }else{ |
| 195816 | 195900 | rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode); |
| 195817 | 195901 | } |
| | @@ -195913,11 +195997,11 @@ |
| 195913 | 195997 | */ |
| 195914 | 195998 | if( rc==SQLITE_OK && pRtree->iDepth>0 && NCELL(pRoot)==1 ){ |
| 195915 | 195999 | int rc2; |
| 195916 | 196000 | RtreeNode *pChild = 0; |
| 195917 | 196001 | i64 iChild = nodeGetRowid(pRtree, pRoot, 0); |
| 195918 | | - rc = nodeAcquire(pRtree, iChild, pRoot, &pChild); |
| 196002 | + rc = nodeAcquire(pRtree, iChild, pRoot, &pChild); /* tag-20210916a */ |
| 195919 | 196003 | if( rc==SQLITE_OK ){ |
| 195920 | 196004 | rc = removeNode(pRtree, pChild, pRtree->iDepth-1); |
| 195921 | 196005 | } |
| 195922 | 196006 | rc2 = nodeRelease(pRtree, pChild); |
| 195923 | 196007 | if( rc==SQLITE_OK ) rc = rc2; |
| | @@ -196248,11 +196332,11 @@ |
| 196248 | 196332 | static int rtreeQueryStat1(sqlite3 *db, Rtree *pRtree){ |
| 196249 | 196333 | const char *zFmt = "SELECT stat FROM %Q.sqlite_stat1 WHERE tbl = '%q_rowid'"; |
| 196250 | 196334 | char *zSql; |
| 196251 | 196335 | sqlite3_stmt *p; |
| 196252 | 196336 | int rc; |
| 196253 | | - i64 nRow = 0; |
| 196337 | + i64 nRow = RTREE_MIN_ROWEST; |
| 196254 | 196338 | |
| 196255 | 196339 | rc = sqlite3_table_column_metadata( |
| 196256 | 196340 | db, pRtree->zDb, "sqlite_stat1",0,0,0,0,0,0 |
| 196257 | 196341 | ); |
| 196258 | 196342 | if( rc!=SQLITE_OK ){ |
| | @@ -196265,24 +196349,14 @@ |
| 196265 | 196349 | }else{ |
| 196266 | 196350 | rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0); |
| 196267 | 196351 | if( rc==SQLITE_OK ){ |
| 196268 | 196352 | if( sqlite3_step(p)==SQLITE_ROW ) nRow = sqlite3_column_int64(p, 0); |
| 196269 | 196353 | rc = sqlite3_finalize(p); |
| 196270 | | - }else if( rc!=SQLITE_NOMEM ){ |
| 196271 | | - rc = SQLITE_OK; |
| 196272 | | - } |
| 196273 | | - |
| 196274 | | - if( rc==SQLITE_OK ){ |
| 196275 | | - if( nRow==0 ){ |
| 196276 | | - pRtree->nRowEst = RTREE_DEFAULT_ROWEST; |
| 196277 | | - }else{ |
| 196278 | | - pRtree->nRowEst = MAX(nRow, RTREE_MIN_ROWEST); |
| 196279 | | - } |
| 196280 | 196354 | } |
| 196281 | 196355 | sqlite3_free(zSql); |
| 196282 | 196356 | } |
| 196283 | | - |
| 196357 | + pRtree->nRowEst = MAX(nRow, RTREE_MIN_ROWEST); |
| 196284 | 196358 | return rc; |
| 196285 | 196359 | } |
| 196286 | 196360 | |
| 196287 | 196361 | |
| 196288 | 196362 | /* |
| | @@ -196428,13 +196502,16 @@ |
| 196428 | 196502 | int ii; |
| 196429 | 196503 | char *zSql; |
| 196430 | 196504 | sqlite3_str_appendf(p, "UPDATE \"%w\".\"%w_rowid\"SET ", zDb, zPrefix); |
| 196431 | 196505 | for(ii=0; ii<pRtree->nAux; ii++){ |
| 196432 | 196506 | if( ii ) sqlite3_str_append(p, ",", 1); |
| 196507 | +#ifdef SQLITE_ENABLE_GEOPOLY |
| 196433 | 196508 | if( ii<pRtree->nAuxNotNull ){ |
| 196434 | 196509 | sqlite3_str_appendf(p,"a%d=coalesce(?%d,a%d)",ii,ii+2,ii); |
| 196435 | | - }else{ |
| 196510 | + }else |
| 196511 | +#endif |
| 196512 | + { |
| 196436 | 196513 | sqlite3_str_appendf(p,"a%d=?%d",ii,ii+2); |
| 196437 | 196514 | } |
| 196438 | 196515 | } |
| 196439 | 196516 | sqlite3_str_appendf(p, " WHERE rowid=?1"); |
| 196440 | 196517 | zSql = sqlite3_str_finish(p); |
| | @@ -197109,12 +197186,14 @@ |
| 197109 | 197186 | if( check.rc==SQLITE_OK ){ |
| 197110 | 197187 | pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab); |
| 197111 | 197188 | if( pStmt ){ |
| 197112 | 197189 | nAux = sqlite3_column_count(pStmt) - 2; |
| 197113 | 197190 | sqlite3_finalize(pStmt); |
| 197191 | + }else |
| 197192 | + if( check.rc!=SQLITE_NOMEM ){ |
| 197193 | + check.rc = SQLITE_OK; |
| 197114 | 197194 | } |
| 197115 | | - check.rc = SQLITE_OK; |
| 197116 | 197195 | } |
| 197117 | 197196 | |
| 197118 | 197197 | /* Find number of dimensions in the rtree table. */ |
| 197119 | 197198 | pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.%Q", zDb, zTab); |
| 197120 | 197199 | if( pStmt ){ |
| | @@ -199185,11 +199264,14 @@ |
| 199185 | 199264 | ){ |
| 199186 | 199265 | RtreeGeomCallback *pGeomCtx; /* Context object for new user-function */ |
| 199187 | 199266 | |
| 199188 | 199267 | /* Allocate and populate the context object. */ |
| 199189 | 199268 | pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback)); |
| 199190 | | - if( !pGeomCtx ) return SQLITE_NOMEM; |
| 199269 | + if( !pGeomCtx ){ |
| 199270 | + if( xDestructor ) xDestructor(pContext); |
| 199271 | + return SQLITE_NOMEM; |
| 199272 | + } |
| 199191 | 199273 | pGeomCtx->xGeom = 0; |
| 199192 | 199274 | pGeomCtx->xQueryFunc = xQueryFunc; |
| 199193 | 199275 | pGeomCtx->xDestructor = xDestructor; |
| 199194 | 199276 | pGeomCtx->pContext = pContext; |
| 199195 | 199277 | return sqlite3_create_function_v2(db, zQueryFunc, -1, SQLITE_ANY, |
| | @@ -222468,10 +222550,46 @@ |
| 222468 | 222550 | if( p->pStruct!=(Fts5Structure*)pStruct ){ |
| 222469 | 222551 | return SQLITE_ABORT; |
| 222470 | 222552 | } |
| 222471 | 222553 | return SQLITE_OK; |
| 222472 | 222554 | } |
| 222555 | + |
| 222556 | +/* |
| 222557 | +** Ensure that structure object (*pp) is writable. |
| 222558 | +** |
| 222559 | +** This function is a no-op if (*pRc) is not SQLITE_OK when it is called. If |
| 222560 | +** an error occurs, (*pRc) is set to an SQLite error code before returning. |
| 222561 | +*/ |
| 222562 | +static void fts5StructureMakeWritable(int *pRc, Fts5Structure **pp){ |
| 222563 | + Fts5Structure *p = *pp; |
| 222564 | + if( *pRc==SQLITE_OK && p->nRef>1 ){ |
| 222565 | + int nByte = sizeof(Fts5Structure)+(p->nLevel-1)*sizeof(Fts5StructureLevel); |
| 222566 | + Fts5Structure *pNew; |
| 222567 | + pNew = (Fts5Structure*)sqlite3Fts5MallocZero(pRc, nByte); |
| 222568 | + if( pNew ){ |
| 222569 | + int i; |
| 222570 | + memcpy(pNew, p, nByte); |
| 222571 | + for(i=0; i<p->nLevel; i++) pNew->aLevel[i].aSeg = 0; |
| 222572 | + for(i=0; i<p->nLevel; i++){ |
| 222573 | + Fts5StructureLevel *pLvl = &pNew->aLevel[i]; |
| 222574 | + int nByte = sizeof(Fts5StructureSegment) * pNew->aLevel[i].nSeg; |
| 222575 | + pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(pRc, nByte); |
| 222576 | + if( pLvl->aSeg==0 ){ |
| 222577 | + for(i=0; i<p->nLevel; i++){ |
| 222578 | + sqlite3_free(pNew->aLevel[i].aSeg); |
| 222579 | + } |
| 222580 | + sqlite3_free(pNew); |
| 222581 | + return; |
| 222582 | + } |
| 222583 | + memcpy(pLvl->aSeg, p->aLevel[i].aSeg, nByte); |
| 222584 | + } |
| 222585 | + p->nRef--; |
| 222586 | + pNew->nRef = 1; |
| 222587 | + } |
| 222588 | + *pp = pNew; |
| 222589 | + } |
| 222590 | +} |
| 222473 | 222591 | |
| 222474 | 222592 | /* |
| 222475 | 222593 | ** Deserialize and return the structure record currently stored in serialized |
| 222476 | 222594 | ** form within buffer pData/nData. |
| 222477 | 222595 | ** |
| | @@ -222570,13 +222688,15 @@ |
| 222570 | 222688 | *ppOut = pRet; |
| 222571 | 222689 | return rc; |
| 222572 | 222690 | } |
| 222573 | 222691 | |
| 222574 | 222692 | /* |
| 222575 | | -** |
| 222693 | +** Add a level to the Fts5Structure.aLevel[] array of structure object |
| 222694 | +** (*ppStruct). |
| 222576 | 222695 | */ |
| 222577 | 222696 | static void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){ |
| 222697 | + fts5StructureMakeWritable(pRc, ppStruct); |
| 222578 | 222698 | if( *pRc==SQLITE_OK ){ |
| 222579 | 222699 | Fts5Structure *pStruct = *ppStruct; |
| 222580 | 222700 | int nLevel = pStruct->nLevel; |
| 222581 | 222701 | sqlite3_int64 nByte = ( |
| 222582 | 222702 | sizeof(Fts5Structure) + /* Main structure */ |
| | @@ -231175,11 +231295,11 @@ |
| 231175 | 231295 | int nArg, /* Number of args */ |
| 231176 | 231296 | sqlite3_value **apUnused /* Function arguments */ |
| 231177 | 231297 | ){ |
| 231178 | 231298 | assert( nArg==0 ); |
| 231179 | 231299 | UNUSED_PARAM2(nArg, apUnused); |
| 231180 | | - sqlite3_result_text(pCtx, "fts5: 2021-09-06 11:44:19 b3cfe23bec0b95ca673802526704200e2396df715fdded72aa71addd7f47e0e1", -1, SQLITE_TRANSIENT); |
| 231300 | + sqlite3_result_text(pCtx, "fts5: 2021-09-22 13:43:16 56da0e9c0321d1fd3c360722cd6284296f9ba459f6b37ab35c81ecabd18f12e3", -1, SQLITE_TRANSIENT); |
| 231181 | 231301 | } |
| 231182 | 231302 | |
| 231183 | 231303 | /* |
| 231184 | 231304 | ** Return true if zName is the extension on one of the shadow tables used |
| 231185 | 231305 | ** by this module. |
| 231186 | 231306 | |