extralite-bundle 2.3 → 2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.editorconfig +6 -0
- data/.github/workflows/test.yml +15 -1
- data/.gitignore +3 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile-bundle +5 -0
- data/Gemfile.lock +3 -3
- data/README.md +69 -10
- data/bin/update_sqlite_source +10 -3
- data/ext/extralite/common.c +67 -23
- data/ext/extralite/database.c +74 -26
- data/ext/extralite/extralite.h +15 -8
- data/ext/extralite/iterator.c +5 -5
- data/ext/extralite/query.c +37 -29
- data/ext/sqlite3/sqlite3.c +196 -90
- data/ext/sqlite3/sqlite3.h +55 -12
- data/lib/extralite/version.rb +1 -1
- data/lib/extralite.rb +27 -0
- data/test/fixtures/image.png +0 -0
- data/test/helper.rb +2 -0
- data/test/issue-38.rb +80 -0
- data/test/perf_ary.rb +6 -3
- data/test/perf_hash.rb +7 -4
- data/test/test_database.rb +256 -4
- data/test/test_iterator.rb +2 -1
- data/test/test_query.rb +40 -4
- metadata +6 -2
    
        data/ext/sqlite3/sqlite3.c
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            /******************************************************************************
         | 
| 2 2 | 
             
            ** This file is an amalgamation of many separate C source files from SQLite
         | 
| 3 | 
            -
            ** version 3.44. | 
| 3 | 
            +
            ** version 3.44.2.  By combining all the individual C code files into this
         | 
| 4 4 | 
             
            ** single large file, the entire code can be compiled as a single translation
         | 
| 5 5 | 
             
            ** unit.  This allows many compilers to do optimizations that would not be
         | 
| 6 6 | 
             
            ** possible if the files were compiled separately.  Performance improvements
         | 
| @@ -18,7 +18,7 @@ | |
| 18 18 | 
             
            ** separate file. This file contains only code for the core SQLite library.
         | 
| 19 19 | 
             
            **
         | 
| 20 20 | 
             
            ** The content in this amalgamation comes from Fossil check-in
         | 
| 21 | 
            -
            **  | 
| 21 | 
            +
            ** ebead0e7230cd33bcec9f95d2183069565b9.
         | 
| 22 22 | 
             
            */
         | 
| 23 23 | 
             
            #define SQLITE_CORE 1
         | 
| 24 24 | 
             
            #define SQLITE_AMALGAMATION 1
         | 
| @@ -459,9 +459,9 @@ extern "C" { | |
| 459 459 | 
             
            ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
         | 
| 460 460 | 
             
            ** [sqlite_version()] and [sqlite_source_id()].
         | 
| 461 461 | 
             
            */
         | 
| 462 | 
            -
            #define SQLITE_VERSION        "3.44. | 
| 463 | 
            -
            #define SQLITE_VERSION_NUMBER  | 
| 464 | 
            -
            #define SQLITE_SOURCE_ID      "2023-11- | 
| 462 | 
            +
            #define SQLITE_VERSION        "3.44.2"
         | 
| 463 | 
            +
            #define SQLITE_VERSION_NUMBER 3044002
         | 
| 464 | 
            +
            #define SQLITE_SOURCE_ID      "2023-11-24 11:41:44 ebead0e7230cd33bcec9f95d2183069565b9e709bf745c9b5db65cc0cbf92c0f"
         | 
| 465 465 |  | 
| 466 466 | 
             
            /*
         | 
| 467 467 | 
             
            ** CAPI3REF: Run-Time Library Version Numbers
         | 
| @@ -5886,13 +5886,27 @@ SQLITE_API int sqlite3_create_window_function( | |
| 5886 5886 | 
             
            ** </dd>
         | 
| 5887 5887 | 
             
            **
         | 
| 5888 5888 | 
             
            ** [[SQLITE_SUBTYPE]] <dt>SQLITE_SUBTYPE</dt><dd>
         | 
| 5889 | 
            -
            ** The SQLITE_SUBTYPE flag indicates to SQLite that a function  | 
| 5889 | 
            +
            ** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
         | 
| 5890 5890 | 
             
            ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments.
         | 
| 5891 | 
            -
            **  | 
| 5892 | 
            -
            **  | 
| 5893 | 
            -
            **  | 
| 5894 | 
            -
            **  | 
| 5895 | 
            -
            **  | 
| 5891 | 
            +
            ** This flag instructs SQLite to omit some corner-case optimizations that
         | 
| 5892 | 
            +
            ** might disrupt the operation of the [sqlite3_value_subtype()] function,
         | 
| 5893 | 
            +
            ** causing it to return zero rather than the correct subtype().
         | 
| 5894 | 
            +
            ** SQL functions that invokes [sqlite3_value_subtype()] should have this
         | 
| 5895 | 
            +
            ** property.  If the SQLITE_SUBTYPE property is omitted, then the return
         | 
| 5896 | 
            +
            ** value from [sqlite3_value_subtype()] might sometimes be zero even though
         | 
| 5897 | 
            +
            ** a non-zero subtype was specified by the function argument expression.
         | 
| 5898 | 
            +
            **
         | 
| 5899 | 
            +
            ** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
         | 
| 5900 | 
            +
            ** The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call
         | 
| 5901 | 
            +
            ** [sqlite3_result_subtype()] to cause a sub-type to be associated with its
         | 
| 5902 | 
            +
            ** result.
         | 
| 5903 | 
            +
            ** Every function that invokes [sqlite3_result_subtype()] should have this
         | 
| 5904 | 
            +
            ** property.  If it does not, then the call to [sqlite3_result_subtype()]
         | 
| 5905 | 
            +
            ** might become a no-op if the function is used as term in an
         | 
| 5906 | 
            +
            ** [expression index].  On the other hand, SQL functions that never invoke
         | 
| 5907 | 
            +
            ** [sqlite3_result_subtype()] should avoid setting this property, as the
         | 
| 5908 | 
            +
            ** purpose of this property is to disable certain optimizations that are
         | 
| 5909 | 
            +
            ** incompatible with subtypes.
         | 
| 5896 5910 | 
             
            ** </dd>
         | 
| 5897 5911 | 
             
            ** </dl>
         | 
| 5898 5912 | 
             
            */
         | 
| @@ -5900,6 +5914,7 @@ SQLITE_API int sqlite3_create_window_function( | |
| 5900 5914 | 
             
            #define SQLITE_DIRECTONLY       0x000080000
         | 
| 5901 5915 | 
             
            #define SQLITE_SUBTYPE          0x000100000
         | 
| 5902 5916 | 
             
            #define SQLITE_INNOCUOUS        0x000200000
         | 
| 5917 | 
            +
            #define SQLITE_RESULT_SUBTYPE   0x001000000
         | 
| 5903 5918 |  | 
| 5904 5919 | 
             
            /*
         | 
| 5905 5920 | 
             
            ** CAPI3REF: Deprecated Functions
         | 
| @@ -6096,6 +6111,12 @@ SQLITE_API int sqlite3_value_encoding(sqlite3_value*); | |
| 6096 6111 | 
             
            ** information can be used to pass a limited amount of context from
         | 
| 6097 6112 | 
             
            ** one SQL function to another.  Use the [sqlite3_result_subtype()]
         | 
| 6098 6113 | 
             
            ** routine to set the subtype for the return value of an SQL function.
         | 
| 6114 | 
            +
            **
         | 
| 6115 | 
            +
            ** Every [application-defined SQL function] that invoke this interface
         | 
| 6116 | 
            +
            ** should include the [SQLITE_SUBTYPE] property in the text
         | 
| 6117 | 
            +
            ** encoding argument when the function is [sqlite3_create_function|registered].
         | 
| 6118 | 
            +
            ** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
         | 
| 6119 | 
            +
            ** might return zero instead of the upstream subtype in some corner cases.
         | 
| 6099 6120 | 
             
            */
         | 
| 6100 6121 | 
             
            SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
         | 
| 6101 6122 |  | 
| @@ -6226,14 +6247,22 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); | |
| 6226 6247 | 
             
            ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
         | 
| 6227 6248 | 
             
            **       parameter)^, or
         | 
| 6228 6249 | 
             
            ** <li> ^(during the original sqlite3_set_auxdata() call when a memory
         | 
| 6229 | 
            -
            **      allocation error occurs.)^ | 
| 6250 | 
            +
            **      allocation error occurs.)^
         | 
| 6251 | 
            +
            ** <li> ^(during the original sqlite3_set_auxdata() call if the function
         | 
| 6252 | 
            +
            **      is evaluated during query planning instead of during query execution,
         | 
| 6253 | 
            +
            **      as sometimes happens with [SQLITE_ENABLE_STAT4].)^ </ul>
         | 
| 6230 6254 | 
             
            **
         | 
| 6231 | 
            -
            ** Note the last  | 
| 6255 | 
            +
            ** Note the last two bullets in particular.  The destructor X in
         | 
| 6232 6256 | 
             
            ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
         | 
| 6233 6257 | 
             
            ** sqlite3_set_auxdata() interface even returns.  Hence sqlite3_set_auxdata()
         | 
| 6234 6258 | 
             
            ** should be called near the end of the function implementation and the
         | 
| 6235 6259 | 
             
            ** function implementation should not make any use of P after
         | 
| 6236 | 
            -
            ** sqlite3_set_auxdata() has been called.
         | 
| 6260 | 
            +
            ** sqlite3_set_auxdata() has been called.  Furthermore, a call to
         | 
| 6261 | 
            +
            ** sqlite3_get_auxdata() that occurs immediately after a corresponding call
         | 
| 6262 | 
            +
            ** to sqlite3_set_auxdata() might still return NULL if an out-of-memory
         | 
| 6263 | 
            +
            ** condition occurred during the sqlite3_set_auxdata() call or if the
         | 
| 6264 | 
            +
            ** function is being evaluated during query planning rather than during
         | 
| 6265 | 
            +
            ** query execution.
         | 
| 6237 6266 | 
             
            **
         | 
| 6238 6267 | 
             
            ** ^(In practice, auxiliary data is preserved between function calls for
         | 
| 6239 6268 | 
             
            ** function parameters that are compile-time constants, including literal
         | 
| @@ -6507,6 +6536,20 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); | |
| 6507 6536 | 
             
            ** higher order bits are discarded.
         | 
| 6508 6537 | 
             
            ** The number of subtype bytes preserved by SQLite might increase
         | 
| 6509 6538 | 
             
            ** in future releases of SQLite.
         | 
| 6539 | 
            +
            **
         | 
| 6540 | 
            +
            ** Every [application-defined SQL function] that invokes this interface
         | 
| 6541 | 
            +
            ** should include the [SQLITE_RESULT_SUBTYPE] property in its
         | 
| 6542 | 
            +
            ** text encoding argument when the SQL function is
         | 
| 6543 | 
            +
            ** [sqlite3_create_function|registered].  If the [SQLITE_RESULT_SUBTYPE]
         | 
| 6544 | 
            +
            ** property is omitted from the function that invokes sqlite3_result_subtype(),
         | 
| 6545 | 
            +
            ** then in some cases the sqlite3_result_subtype() might fail to set
         | 
| 6546 | 
            +
            ** the result subtype.
         | 
| 6547 | 
            +
            **
         | 
| 6548 | 
            +
            ** If SQLite is compiled with -DSQLITE_STRICT_SUBTYPE=1, then any
         | 
| 6549 | 
            +
            ** SQL function that invokes the sqlite3_result_subtype() interface
         | 
| 6550 | 
            +
            ** and that does not have the SQLITE_RESULT_SUBTYPE property will raise
         | 
| 6551 | 
            +
            ** an error.  Future versions of SQLite might enable -DSQLITE_STRICT_SUBTYPE=1
         | 
| 6552 | 
            +
            ** by default.
         | 
| 6510 6553 | 
             
            */
         | 
| 6511 6554 | 
             
            SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int);
         | 
| 6512 6555 |  | 
| @@ -17811,14 +17854,15 @@ struct FuncDestructor { | |
| 17811 17854 | 
             
            #define SQLITE_FUNC_SLOCHNG  0x2000 /* "Slow Change". Value constant during a
         | 
| 17812 17855 | 
             
                                                ** single query - might change over time */
         | 
| 17813 17856 | 
             
            #define SQLITE_FUNC_TEST     0x4000 /* Built-in testing functions */
         | 
| 17814 | 
            -
             | 
| 17857 | 
            +
            #define SQLITE_FUNC_RUNONLY  0x8000 /* Cannot be used by valueFromFunction */
         | 
| 17815 17858 | 
             
            #define SQLITE_FUNC_WINDOW   0x00010000 /* Built-in window-only function */
         | 
| 17816 17859 | 
             
            #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
         | 
| 17817 17860 | 
             
            #define SQLITE_FUNC_DIRECT   0x00080000 /* Not for use in TRIGGERs or VIEWs */
         | 
| 17818 | 
            -
             | 
| 17861 | 
            +
            /* SQLITE_SUBTYPE            0x00100000 // Consumer of subtypes */
         | 
| 17819 17862 | 
             
            #define SQLITE_FUNC_UNSAFE   0x00200000 /* Function has side effects */
         | 
| 17820 17863 | 
             
            #define SQLITE_FUNC_INLINE   0x00400000 /* Functions implemented in-line */
         | 
| 17821 17864 | 
             
            #define SQLITE_FUNC_BUILTIN  0x00800000 /* This is a built-in function */
         | 
| 17865 | 
            +
            /*  SQLITE_RESULT_SUBTYPE    0x01000000 // Generator of subtypes */
         | 
| 17822 17866 | 
             
            #define SQLITE_FUNC_ANYORDER 0x08000000 /* count/min/max aggregate */
         | 
| 17823 17867 |  | 
| 17824 17868 | 
             
            /* Identifier numbers for each in-line function */
         | 
| @@ -17910,9 +17954,10 @@ struct FuncDestructor { | |
| 17910 17954 | 
             
            #define MFUNCTION(zName, nArg, xPtr, xFunc) \
         | 
| 17911 17955 | 
             
              {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
         | 
| 17912 17956 | 
             
               xPtr, 0, xFunc, 0, 0, 0, #zName, {0} }
         | 
| 17913 | 
            -
            #define JFUNCTION(zName, nArg, iArg, xFunc) \
         | 
| 17914 | 
            -
              {nArg, SQLITE_FUNC_BUILTIN|SQLITE_DETERMINISTIC|\
         | 
| 17915 | 
            -
                | 
| 17957 | 
            +
            #define JFUNCTION(zName, nArg, bUseCache, bWS, bRS, iArg, xFunc) \
         | 
| 17958 | 
            +
              {nArg, SQLITE_FUNC_BUILTIN|SQLITE_DETERMINISTIC|SQLITE_FUNC_CONSTANT|\
         | 
| 17959 | 
            +
               SQLITE_UTF8|((bUseCache)*SQLITE_FUNC_RUNONLY)|\
         | 
| 17960 | 
            +
               ((bRS)*SQLITE_SUBTYPE)|((bWS)*SQLITE_RESULT_SUBTYPE), \
         | 
| 17916 17961 | 
             
               SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
         | 
| 17917 17962 | 
             
            #define INLINE_FUNC(zName, nArg, iArg, mFlags) \
         | 
| 17918 17963 | 
             
              {nArg, SQLITE_FUNC_BUILTIN|\
         | 
| @@ -29453,7 +29498,7 @@ SQLITE_PRIVATE void sqlite3MemoryBarrier(void){ | |
| 29453 29498 | 
             
              SQLITE_MEMORY_BARRIER;
         | 
| 29454 29499 | 
             
            #elif defined(__GNUC__)
         | 
| 29455 29500 | 
             
              __sync_synchronize();
         | 
| 29456 | 
            -
            #elif MSVC_VERSION>= | 
| 29501 | 
            +
            #elif MSVC_VERSION>=1400
         | 
| 29457 29502 | 
             
              _ReadWriteBarrier();
         | 
| 29458 29503 | 
             
            #elif defined(MemoryBarrier)
         | 
| 29459 29504 | 
             
              MemoryBarrier();
         | 
| @@ -61447,10 +61492,13 @@ act_like_temp_file: | |
| 61447 61492 | 
             
            */
         | 
| 61448 61493 | 
             
            SQLITE_API sqlite3_file *sqlite3_database_file_object(const char *zName){
         | 
| 61449 61494 | 
             
              Pager *pPager;
         | 
| 61495 | 
            +
              const char *p;
         | 
| 61450 61496 | 
             
              while( zName[-1]!=0 || zName[-2]!=0 || zName[-3]!=0 || zName[-4]!=0 ){
         | 
| 61451 61497 | 
             
                zName--;
         | 
| 61452 61498 | 
             
              }
         | 
| 61453 | 
            -
               | 
| 61499 | 
            +
              p = zName - 4 - sizeof(Pager*);
         | 
| 61500 | 
            +
              assert( EIGHT_BYTE_ALIGNMENT(p) );
         | 
| 61501 | 
            +
              pPager = *(Pager**)p;
         | 
| 61454 61502 | 
             
              return pPager->fd;
         | 
| 61455 61503 | 
             
            }
         | 
| 61456 61504 |  | 
| @@ -83411,7 +83459,7 @@ static int valueFromFunction( | |
| 83411 83459 | 
             
            #endif
         | 
| 83412 83460 | 
             
              assert( pFunc );
         | 
| 83413 83461 | 
             
              if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0
         | 
| 83414 | 
            -
               || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)
         | 
| 83462 | 
            +
               || (pFunc->funcFlags & (SQLITE_FUNC_NEEDCOLL|SQLITE_FUNC_RUNONLY))!=0
         | 
| 83415 83463 | 
             
              ){
         | 
| 83416 83464 | 
             
                return SQLITE_OK;
         | 
| 83417 83465 | 
             
              }
         | 
| @@ -84135,10 +84183,11 @@ static int growOpArray(Vdbe *v, int nOp){ | |
| 84135 84183 | 
             
            **   sqlite3CantopenError(lineno)
         | 
| 84136 84184 | 
             
            */
         | 
| 84137 84185 | 
             
            static void test_addop_breakpoint(int pc, Op *pOp){
         | 
| 84138 | 
            -
              static  | 
| 84186 | 
            +
              static u64 n = 0;
         | 
| 84139 84187 | 
             
              (void)pc;
         | 
| 84140 84188 | 
             
              (void)pOp;
         | 
| 84141 84189 | 
             
              n++;
         | 
| 84190 | 
            +
              if( n==LARGEST_UINT64 ) abort(); /* so that n is used, preventing a warning */
         | 
| 84142 84191 | 
             
            }
         | 
| 84143 84192 | 
             
            #endif
         | 
| 84144 84193 |  | 
| @@ -89952,6 +90001,18 @@ SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubt | |
| 89952 90001 | 
             
            #ifdef SQLITE_ENABLE_API_ARMOR
         | 
| 89953 90002 | 
             
              if( pCtx==0 ) return;
         | 
| 89954 90003 | 
             
            #endif
         | 
| 90004 | 
            +
            #if defined(SQLITE_STRICT_SUBTYPE) && SQLITE_STRICT_SUBTYPE+0!=0
         | 
| 90005 | 
            +
              if( pCtx->pFunc!=0
         | 
| 90006 | 
            +
               && (pCtx->pFunc->funcFlags & SQLITE_RESULT_SUBTYPE)==0
         | 
| 90007 | 
            +
              ){
         | 
| 90008 | 
            +
                char zErr[200];
         | 
| 90009 | 
            +
                sqlite3_snprintf(sizeof(zErr), zErr,
         | 
| 90010 | 
            +
                                 "misuse of sqlite3_result_subtype() by %s()",
         | 
| 90011 | 
            +
                                 pCtx->pFunc->zName);
         | 
| 90012 | 
            +
                sqlite3_result_error(pCtx, zErr, -1);
         | 
| 90013 | 
            +
                return;
         | 
| 90014 | 
            +
              }
         | 
| 90015 | 
            +
            #endif /* SQLITE_STRICT_SUBTYPE */
         | 
| 89955 90016 | 
             
              pOut = pCtx->pOut;
         | 
| 89956 90017 | 
             
              assert( sqlite3_mutex_held(pOut->db->mutex) );
         | 
| 89957 90018 | 
             
              pOut->eSubtype = eSubtype & 0xff;
         | 
| @@ -92270,11 +92331,12 @@ SQLITE_API int sqlite3_found_count = 0; | |
| 92270 92331 | 
             
            **   sqlite3CantopenError(lineno)
         | 
| 92271 92332 | 
             
            */
         | 
| 92272 92333 | 
             
            static void test_trace_breakpoint(int pc, Op *pOp, Vdbe *v){
         | 
| 92273 | 
            -
              static  | 
| 92334 | 
            +
              static u64 n = 0;
         | 
| 92274 92335 | 
             
              (void)pc;
         | 
| 92275 92336 | 
             
              (void)pOp;
         | 
| 92276 92337 | 
             
              (void)v;
         | 
| 92277 92338 | 
             
              n++;
         | 
| 92339 | 
            +
              if( n==LARGEST_UINT64 ) abort(); /* So that n is used, preventing a warning */
         | 
| 92278 92340 | 
             
            }
         | 
| 92279 92341 | 
             
            #endif
         | 
| 92280 92342 |  | 
| @@ -100321,7 +100383,7 @@ case OP_VCheck: {             /* out2 */ | |
| 100321 100383 | 
             
              pTab = pOp->p4.pTab;
         | 
| 100322 100384 | 
             
              assert( pTab!=0 );
         | 
| 100323 100385 | 
             
              assert( IsVirtual(pTab) );
         | 
| 100324 | 
            -
               | 
| 100386 | 
            +
              if( pTab->u.vtab.p==0 ) break;
         | 
| 100325 100387 | 
             
              pVtab = pTab->u.vtab.p->pVtab;
         | 
| 100326 100388 | 
             
              assert( pVtab!=0 );
         | 
| 100327 100389 | 
             
              pModule = pVtab->pModule;
         | 
| @@ -113917,8 +113979,8 @@ SQLITE_PRIVATE int sqlite3ExprListCompare(const ExprList *pA, const ExprList *pB | |
| 113917 113979 | 
             
            */
         | 
| 113918 113980 | 
             
            SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA,Expr *pB, int iTab){
         | 
| 113919 113981 | 
             
              return sqlite3ExprCompare(0,
         | 
| 113920 | 
            -
                          | 
| 113921 | 
            -
                          | 
| 113982 | 
            +
                         sqlite3ExprSkipCollate(pA),
         | 
| 113983 | 
            +
                         sqlite3ExprSkipCollate(pB),
         | 
| 113922 113984 | 
             
                         iTab);
         | 
| 113923 113985 | 
             
            }
         | 
| 113924 113986 |  | 
| @@ -143552,7 +143614,8 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes( | |
| 143552 143614 | 
             
              NameContext sNC;
         | 
| 143553 143615 |  | 
| 143554 143616 | 
             
              assert( pSelect!=0 );
         | 
| 143555 | 
            -
               | 
| 143617 | 
            +
              testcase( (pSelect->selFlags & SF_Resolved)==0 );
         | 
| 143618 | 
            +
              assert( (pSelect->selFlags & SF_Resolved)!=0 || IN_RENAME_OBJECT );
         | 
| 143556 143619 | 
             
              assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 );
         | 
| 143557 143620 | 
             
              assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB );
         | 
| 143558 143621 | 
             
              if( db->mallocFailed || IN_RENAME_OBJECT ) return;
         | 
| @@ -147605,10 +147668,11 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ | |
| 147605 147668 | 
             
              SrcList *pTabList;
         | 
| 147606 147669 | 
             
              SrcItem *pFrom;
         | 
| 147607 147670 |  | 
| 147608 | 
            -
              assert( p->selFlags & SF_Resolved );
         | 
| 147609 147671 | 
             
              if( p->selFlags & SF_HasTypeInfo ) return;
         | 
| 147610 147672 | 
             
              p->selFlags |= SF_HasTypeInfo;
         | 
| 147611 147673 | 
             
              pParse = pWalker->pParse;
         | 
| 147674 | 
            +
              testcase( (p->selFlags & SF_Resolved)==0 );
         | 
| 147675 | 
            +
              assert( (p->selFlags & SF_Resolved) || IN_RENAME_OBJECT );
         | 
| 147612 147676 | 
             
              pTabList = p->pSrc;
         | 
| 147613 147677 | 
             
              for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
         | 
| 147614 147678 | 
             
                Table *pTab = pFrom->pTab;
         | 
| @@ -148630,6 +148694,7 @@ SQLITE_PRIVATE int sqlite3Select( | |
| 148630 148694 | 
             
                      TREETRACE(0x1000,pParse,p,
         | 
| 148631 148695 | 
             
                                ("LEFT-JOIN simplifies to JOIN on term %d\n",i));
         | 
| 148632 148696 | 
             
                      pItem->fg.jointype &= ~(JT_LEFT|JT_OUTER);
         | 
| 148697 | 
            +
                      unsetJoinExpr(p->pWhere, pItem->iCursor, 0);
         | 
| 148633 148698 | 
             
                    }
         | 
| 148634 148699 | 
             
                  }
         | 
| 148635 148700 | 
             
                  if( pItem->fg.jointype & JT_LTORJ ){
         | 
| @@ -148644,17 +148709,15 @@ SQLITE_PRIVATE int sqlite3Select( | |
| 148644 148709 | 
             
                          TREETRACE(0x1000,pParse,p,
         | 
| 148645 148710 | 
             
                                    ("RIGHT-JOIN simplifies to JOIN on term %d\n",j));
         | 
| 148646 148711 | 
             
                          pI2->fg.jointype &= ~(JT_RIGHT|JT_OUTER);
         | 
| 148712 | 
            +
                          unsetJoinExpr(p->pWhere, pI2->iCursor, 1);
         | 
| 148647 148713 | 
             
                        }
         | 
| 148648 148714 | 
             
                      }
         | 
| 148649 148715 | 
             
                    }
         | 
| 148650 | 
            -
                    for(j=pTabList->nSrc-1; j>= | 
| 148716 | 
            +
                    for(j=pTabList->nSrc-1; j>=0; j--){
         | 
| 148651 148717 | 
             
                      pTabList->a[j].fg.jointype &= ~JT_LTORJ;
         | 
| 148652 148718 | 
             
                      if( pTabList->a[j].fg.jointype & JT_RIGHT ) break;
         | 
| 148653 148719 | 
             
                    }
         | 
| 148654 148720 | 
             
                  }
         | 
| 148655 | 
            -
                  assert( pItem->iCursor>=0 );
         | 
| 148656 | 
            -
                  unsetJoinExpr(p->pWhere, pItem->iCursor,
         | 
| 148657 | 
            -
                                pTabList->a[0].fg.jointype & JT_LTORJ);
         | 
| 148658 148721 | 
             
                }
         | 
| 148659 148722 |  | 
| 148660 148723 | 
             
                /* No further action if this term of the FROM clause is not a subquery */
         | 
| @@ -166058,6 +166121,20 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( | |
| 166058 166121 | 
             
                  continue;
         | 
| 166059 166122 | 
             
                }
         | 
| 166060 166123 | 
             
                if( sqlite3ExprIsConstant(pExpr) ) continue;
         | 
| 166124 | 
            +
                if( pExpr->op==TK_FUNCTION ){
         | 
| 166125 | 
            +
                  /* Functions that might set a subtype should not be replaced by the
         | 
| 166126 | 
            +
                  ** value taken from an expression index since the index omits the
         | 
| 166127 | 
            +
                  ** subtype.  https://sqlite.org/forum/forumpost/68d284c86b082c3e */
         | 
| 166128 | 
            +
                  int n;
         | 
| 166129 | 
            +
                  FuncDef *pDef;
         | 
| 166130 | 
            +
                  sqlite3 *db = pParse->db;
         | 
| 166131 | 
            +
                  assert( ExprUseXList(pExpr) );
         | 
| 166132 | 
            +
                  n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0;
         | 
| 166133 | 
            +
                  pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0);
         | 
| 166134 | 
            +
                  if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){
         | 
| 166135 | 
            +
                    continue;
         | 
| 166136 | 
            +
                  }
         | 
| 166137 | 
            +
                }
         | 
| 166061 166138 | 
             
                p = sqlite3DbMallocRaw(pParse->db,  sizeof(IndexedExpr));
         | 
| 166062 166139 | 
             
                if( p==0 ) break;
         | 
| 166063 166140 | 
             
                p->pIENext = pParse->pIdxEpr;
         | 
| @@ -168240,7 +168317,7 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ | |
| 168240 168317 | 
             
                  assert( ExprUseXList(pWin->pOwner) );
         | 
| 168241 168318 | 
             
                  assert( pWin->pWFunc!=0 );
         | 
| 168242 168319 | 
             
                  pArgs = pWin->pOwner->x.pList;
         | 
| 168243 | 
            -
                  if( pWin->pWFunc->funcFlags &  | 
| 168320 | 
            +
                  if( pWin->pWFunc->funcFlags & SQLITE_SUBTYPE ){
         | 
| 168244 168321 | 
             
                    selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist);
         | 
| 168245 168322 | 
             
                    pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
         | 
| 168246 168323 | 
             
                    pWin->bExprArgs = 1;
         | 
| @@ -179414,7 +179491,7 @@ SQLITE_PRIVATE int sqlite3CreateFunc( | |
| 179414 179491 | 
             
              assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
         | 
| 179415 179492 | 
             
              assert( SQLITE_FUNC_DIRECT==SQLITE_DIRECTONLY );
         | 
| 179416 179493 | 
             
              extraFlags = enc &  (SQLITE_DETERMINISTIC|SQLITE_DIRECTONLY|
         | 
| 179417 | 
            -
                                   SQLITE_SUBTYPE|SQLITE_INNOCUOUS);
         | 
| 179494 | 
            +
                                   SQLITE_SUBTYPE|SQLITE_INNOCUOUS|SQLITE_RESULT_SUBTYPE);
         | 
| 179418 179495 | 
             
              enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY);
         | 
| 179419 179496 |  | 
| 179420 179497 | 
             
              /* The SQLITE_INNOCUOUS flag is the same bit as SQLITE_FUNC_UNSAFE.  But
         | 
| @@ -202995,13 +203072,19 @@ static void jsonAppendNormalizedString(JsonString *p, const char *zIn, u32 N){ | |
| 202995 203072 | 
             
              zIn++;
         | 
| 202996 203073 | 
             
              N -= 2;
         | 
| 202997 203074 | 
             
              while( N>0 ){
         | 
| 202998 | 
            -
                for(i=0; i<N && zIn[i]!='\\'; i++){}
         | 
| 203075 | 
            +
                for(i=0; i<N && zIn[i]!='\\' && zIn[i]!='"'; i++){}
         | 
| 202999 203076 | 
             
                if( i>0 ){
         | 
| 203000 203077 | 
             
                  jsonAppendRawNZ(p, zIn, i);
         | 
| 203001 203078 | 
             
                  zIn += i;
         | 
| 203002 203079 | 
             
                  N -= i;
         | 
| 203003 203080 | 
             
                  if( N==0 ) break;
         | 
| 203004 203081 | 
             
                }
         | 
| 203082 | 
            +
                if( zIn[0]=='"' ){
         | 
| 203083 | 
            +
                  jsonAppendRawNZ(p, "\\\"", 2);
         | 
| 203084 | 
            +
                  zIn++;
         | 
| 203085 | 
            +
                  N--;
         | 
| 203086 | 
            +
                  continue;
         | 
| 203087 | 
            +
                }
         | 
| 203005 203088 | 
             
                assert( zIn[0]=='\\' );
         | 
| 203006 203089 | 
             
                switch( (u8)zIn[1] ){
         | 
| 203007 203090 | 
             
                  case '\'':
         | 
| @@ -203396,7 +203479,8 @@ static void jsonReturnJson( | |
| 203396 203479 | 
             
              JsonParse *pParse,          /* The complete JSON */
         | 
| 203397 203480 | 
             
              JsonNode *pNode,            /* Node to return */
         | 
| 203398 203481 | 
             
              sqlite3_context *pCtx,      /* Return value for this function */
         | 
| 203399 | 
            -
              int bGenerateAlt | 
| 203482 | 
            +
              int bGenerateAlt,           /* Also store the rendered text in zAlt */
         | 
| 203483 | 
            +
              int omitSubtype             /* Do not call sqlite3_result_subtype() */
         | 
| 203400 203484 | 
             
            ){
         | 
| 203401 203485 | 
             
              JsonString s;
         | 
| 203402 203486 | 
             
              if( pParse->oom ){
         | 
| @@ -203411,7 +203495,7 @@ static void jsonReturnJson( | |
| 203411 203495 | 
             
                  pParse->nAlt = s.nUsed;
         | 
| 203412 203496 | 
             
                }
         | 
| 203413 203497 | 
             
                jsonResult(&s);
         | 
| 203414 | 
            -
                sqlite3_result_subtype(pCtx, JSON_SUBTYPE);
         | 
| 203498 | 
            +
                if( !omitSubtype ) sqlite3_result_subtype(pCtx, JSON_SUBTYPE);
         | 
| 203415 203499 | 
             
              }
         | 
| 203416 203500 | 
             
            }
         | 
| 203417 203501 |  | 
| @@ -203452,7 +203536,8 @@ static u32 jsonHexToInt4(const char *z){ | |
| 203452 203536 | 
             
            static void jsonReturn(
         | 
| 203453 203537 | 
             
              JsonParse *pParse,          /* Complete JSON parse tree */
         | 
| 203454 203538 | 
             
              JsonNode *pNode,            /* Node to return */
         | 
| 203455 | 
            -
              sqlite3_context *pCtx | 
| 203539 | 
            +
              sqlite3_context *pCtx,      /* Return value for this function */
         | 
| 203540 | 
            +
              int omitSubtype             /* Do not call sqlite3_result_subtype() */
         | 
| 203456 203541 | 
             
            ){
         | 
| 203457 203542 | 
             
              switch( pNode->eType ){
         | 
| 203458 203543 | 
             
                default: {
         | 
| @@ -203598,7 +203683,7 @@ static void jsonReturn( | |
| 203598 203683 | 
             
                }
         | 
| 203599 203684 | 
             
                case JSON_ARRAY:
         | 
| 203600 203685 | 
             
                case JSON_OBJECT: {
         | 
| 203601 | 
            -
                  jsonReturnJson(pParse, pNode, pCtx, 0);
         | 
| 203686 | 
            +
                  jsonReturnJson(pParse, pNode, pCtx, 0, omitSubtype);
         | 
| 203602 203687 | 
             
                  break;
         | 
| 203603 203688 | 
             
                }
         | 
| 203604 203689 | 
             
              }
         | 
| @@ -204950,7 +205035,7 @@ static void jsonParseFunc( | |
| 204950 205035 | 
             
              printf("iSubst    = %u\n", p->iSubst);
         | 
| 204951 205036 | 
             
              printf("iHold     = %u\n", p->iHold);
         | 
| 204952 205037 | 
             
              jsonDebugPrintNodeEntries(p->aNode, p->nNode);
         | 
| 204953 | 
            -
              jsonReturnJson(p, p->aNode, ctx, 1);
         | 
| 205038 | 
            +
              jsonReturnJson(p, p->aNode, ctx, 1, 0);
         | 
| 204954 205039 | 
             
            }
         | 
| 204955 205040 |  | 
| 204956 205041 | 
             
            /*
         | 
| @@ -205136,15 +205221,14 @@ static void jsonExtractFunc( | |
| 205136 205221 | 
             
                  }
         | 
| 205137 205222 | 
             
                  if( pNode ){
         | 
| 205138 205223 | 
             
                    if( flags & JSON_JSON ){
         | 
| 205139 | 
            -
                      jsonReturnJson(p, pNode, ctx, 0);
         | 
| 205224 | 
            +
                      jsonReturnJson(p, pNode, ctx, 0, 0);
         | 
| 205140 205225 | 
             
                    }else{
         | 
| 205141 | 
            -
                      jsonReturn(p, pNode, ctx);
         | 
| 205142 | 
            -
                      sqlite3_result_subtype(ctx, 0);
         | 
| 205226 | 
            +
                      jsonReturn(p, pNode, ctx, 1);
         | 
| 205143 205227 | 
             
                    }
         | 
| 205144 205228 | 
             
                  }
         | 
| 205145 205229 | 
             
                }else{
         | 
| 205146 205230 | 
             
                  pNode = jsonLookup(p, zPath, 0, ctx);
         | 
| 205147 | 
            -
                  if( p->nErr==0 && pNode ) jsonReturn(p, pNode, ctx);
         | 
| 205231 | 
            +
                  if( p->nErr==0 && pNode ) jsonReturn(p, pNode, ctx, 0);
         | 
| 205148 205232 | 
             
                }
         | 
| 205149 205233 | 
             
              }else{
         | 
| 205150 205234 | 
             
                /* Two or more PATH arguments results in a JSON array with each
         | 
| @@ -205270,7 +205354,7 @@ static void jsonPatchFunc( | |
| 205270 205354 | 
             
              if( pResult && pX->oom==0 ){
         | 
| 205271 205355 | 
             
                jsonDebugPrintParse(pX);
         | 
| 205272 205356 | 
             
                jsonDebugPrintNode(pResult);
         | 
| 205273 | 
            -
                jsonReturnJson(pX, pResult, ctx, 0);
         | 
| 205357 | 
            +
                jsonReturnJson(pX, pResult, ctx, 0, 0);
         | 
| 205274 205358 | 
             
              }else{
         | 
| 205275 205359 | 
             
                sqlite3_result_error_nomem(ctx);
         | 
| 205276 205360 | 
             
              }
         | 
| @@ -205349,7 +205433,7 @@ static void jsonRemoveFunc( | |
| 205349 205433 | 
             
                }
         | 
| 205350 205434 | 
             
              }
         | 
| 205351 205435 | 
             
              if( (pParse->aNode[0].jnFlags & JNODE_REMOVE)==0 ){
         | 
| 205352 | 
            -
                jsonReturnJson(pParse, pParse->aNode, ctx, 1);
         | 
| 205436 | 
            +
                jsonReturnJson(pParse, pParse->aNode, ctx, 1, 0);
         | 
| 205353 205437 | 
             
              }
         | 
| 205354 205438 | 
             
            remove_done:
         | 
| 205355 205439 | 
             
              jsonDebugPrintParse(p);
         | 
| @@ -205478,7 +205562,7 @@ static void jsonReplaceFunc( | |
| 205478 205562 | 
             
                  jsonReplaceNode(ctx, pParse, (u32)(pNode - pParse->aNode), argv[i+1]);
         | 
| 205479 205563 | 
             
                }
         | 
| 205480 205564 | 
             
              }
         | 
| 205481 | 
            -
              jsonReturnJson(pParse, pParse->aNode, ctx, 1);
         | 
| 205565 | 
            +
              jsonReturnJson(pParse, pParse->aNode, ctx, 1, 0);
         | 
| 205482 205566 | 
             
            replace_err:
         | 
| 205483 205567 | 
             
              jsonDebugPrintParse(pParse);
         | 
| 205484 205568 | 
             
              jsonParseFree(pParse);
         | 
| @@ -205532,7 +205616,7 @@ static void jsonSetFunc( | |
| 205532 205616 | 
             
                }
         | 
| 205533 205617 | 
             
              }
         | 
| 205534 205618 | 
             
              jsonDebugPrintParse(pParse);
         | 
| 205535 | 
            -
              jsonReturnJson(pParse, pParse->aNode, ctx, 1);
         | 
| 205619 | 
            +
              jsonReturnJson(pParse, pParse->aNode, ctx, 1, 0);
         | 
| 205536 205620 | 
             
            jsonSetDone:
         | 
| 205537 205621 | 
             
              jsonParseFree(pParse);
         | 
| 205538 205622 | 
             
            }
         | 
| @@ -206047,7 +206131,7 @@ static int jsonEachColumn( | |
| 206047 206131 | 
             
                case JEACH_KEY: {
         | 
| 206048 206132 | 
             
                  if( p->i==0 ) break;
         | 
| 206049 206133 | 
             
                  if( p->eType==JSON_OBJECT ){
         | 
| 206050 | 
            -
                    jsonReturn(&p->sParse, pThis, ctx);
         | 
| 206134 | 
            +
                    jsonReturn(&p->sParse, pThis, ctx, 0);
         | 
| 206051 206135 | 
             
                  }else if( p->eType==JSON_ARRAY ){
         | 
| 206052 206136 | 
             
                    u32 iKey;
         | 
| 206053 206137 | 
             
                    if( p->bRecursive ){
         | 
| @@ -206063,7 +206147,7 @@ static int jsonEachColumn( | |
| 206063 206147 | 
             
                }
         | 
| 206064 206148 | 
             
                case JEACH_VALUE: {
         | 
| 206065 206149 | 
             
                  if( pThis->jnFlags & JNODE_LABEL ) pThis++;
         | 
| 206066 | 
            -
                  jsonReturn(&p->sParse, pThis, ctx);
         | 
| 206150 | 
            +
                  jsonReturn(&p->sParse, pThis, ctx, 0);
         | 
| 206067 206151 | 
             
                  break;
         | 
| 206068 206152 | 
             
                }
         | 
| 206069 206153 | 
             
                case JEACH_TYPE: {
         | 
| @@ -206074,7 +206158,7 @@ static int jsonEachColumn( | |
| 206074 206158 | 
             
                case JEACH_ATOM: {
         | 
| 206075 206159 | 
             
                  if( pThis->jnFlags & JNODE_LABEL ) pThis++;
         | 
| 206076 206160 | 
             
                  if( pThis->eType>=JSON_ARRAY ) break;
         | 
| 206077 | 
            -
                  jsonReturn(&p->sParse, pThis, ctx);
         | 
| 206161 | 
            +
                  jsonReturn(&p->sParse, pThis, ctx, 0);
         | 
| 206078 206162 | 
             
                  break;
         | 
| 206079 206163 | 
             
                }
         | 
| 206080 206164 | 
             
                case JEACH_ID: {
         | 
| @@ -206367,34 +206451,43 @@ static sqlite3_module jsonTreeModule = { | |
| 206367 206451 | 
             
            SQLITE_PRIVATE void sqlite3RegisterJsonFunctions(void){
         | 
| 206368 206452 | 
             
            #ifndef SQLITE_OMIT_JSON
         | 
| 206369 206453 | 
             
              static FuncDef aJsonFunc[] = {
         | 
| 206370 | 
            -
                 | 
| 206371 | 
            -
                 | 
| 206372 | 
            -
                 | 
| 206373 | 
            -
                 | 
| 206374 | 
            -
                 | 
| 206375 | 
            -
                 | 
| 206376 | 
            -
                 | 
| 206377 | 
            -
                JFUNCTION( | 
| 206378 | 
            -
                JFUNCTION( | 
| 206379 | 
            -
                JFUNCTION( | 
| 206380 | 
            -
                JFUNCTION( | 
| 206381 | 
            -
                JFUNCTION( | 
| 206382 | 
            -
                JFUNCTION( | 
| 206383 | 
            -
                JFUNCTION( | 
| 206384 | 
            -
                JFUNCTION( | 
| 206385 | 
            -
                JFUNCTION( | 
| 206386 | 
            -
                JFUNCTION( | 
| 206387 | 
            -
                JFUNCTION( | 
| 206388 | 
            -
             | 
| 206389 | 
            -
                JFUNCTION( | 
| 206390 | 
            -
                JFUNCTION( | 
| 206454 | 
            +
                /*                     calls sqlite3_result_subtype()                    */
         | 
| 206455 | 
            +
                /*                                  |                                    */
         | 
| 206456 | 
            +
                /*              Uses cache ______   |   __ calls sqlite3_value_subtype() */
         | 
| 206457 | 
            +
                /*                               |  |  |                                 */
         | 
| 206458 | 
            +
                /*          Num args _________   |  |  |   ___ Flags                     */
         | 
| 206459 | 
            +
                /*                            |  |  |  |  |                              */
         | 
| 206460 | 
            +
                /*                            |  |  |  |  |                              */
         | 
| 206461 | 
            +
                JFUNCTION(json,               1, 1, 1, 0, 0,          jsonRemoveFunc),
         | 
| 206462 | 
            +
                JFUNCTION(json_array,        -1, 0, 1, 1, 0,          jsonArrayFunc),
         | 
| 206463 | 
            +
                JFUNCTION(json_array_length,  1, 1, 0, 0, 0,          jsonArrayLengthFunc),
         | 
| 206464 | 
            +
                JFUNCTION(json_array_length,  2, 1, 0, 0, 0,          jsonArrayLengthFunc),
         | 
| 206465 | 
            +
                JFUNCTION(json_error_position,1, 1, 0, 0, 0,          jsonErrorFunc),
         | 
| 206466 | 
            +
                JFUNCTION(json_extract,      -1, 1, 1, 0, 0,          jsonExtractFunc),
         | 
| 206467 | 
            +
                JFUNCTION(->,                 2, 1, 1, 0, JSON_JSON,  jsonExtractFunc),
         | 
| 206468 | 
            +
                JFUNCTION(->>,                2, 1, 0, 0, JSON_SQL,   jsonExtractFunc),
         | 
| 206469 | 
            +
                JFUNCTION(json_insert,       -1, 1, 1, 1, 0,          jsonSetFunc),
         | 
| 206470 | 
            +
                JFUNCTION(json_object,       -1, 0, 1, 1, 0,          jsonObjectFunc),
         | 
| 206471 | 
            +
                JFUNCTION(json_patch,         2, 1, 1, 0, 0,          jsonPatchFunc),
         | 
| 206472 | 
            +
                JFUNCTION(json_quote,         1, 0, 1, 1, 0,          jsonQuoteFunc),
         | 
| 206473 | 
            +
                JFUNCTION(json_remove,       -1, 1, 1, 0, 0,          jsonRemoveFunc),
         | 
| 206474 | 
            +
                JFUNCTION(json_replace,      -1, 1, 1, 1, 0,          jsonReplaceFunc),
         | 
| 206475 | 
            +
                JFUNCTION(json_set,          -1, 1, 1, 1, JSON_ISSET, jsonSetFunc),
         | 
| 206476 | 
            +
                JFUNCTION(json_type,          1, 1, 0, 0, 0,          jsonTypeFunc),
         | 
| 206477 | 
            +
                JFUNCTION(json_type,          2, 1, 0, 0, 0,          jsonTypeFunc),
         | 
| 206478 | 
            +
                JFUNCTION(json_valid,         1, 1, 0, 0, 0,          jsonValidFunc),
         | 
| 206479 | 
            +
            #ifdef SQLITE_DEBUG
         | 
| 206480 | 
            +
                JFUNCTION(json_parse,         1, 1, 1, 0, 0,          jsonParseFunc),
         | 
| 206481 | 
            +
                JFUNCTION(json_test1,         1, 1, 0, 1, 0,          jsonTest1Func),
         | 
| 206391 206482 | 
             
            #endif
         | 
| 206392 206483 | 
             
                WAGGREGATE(json_group_array,  1, 0, 0,
         | 
| 206393 206484 | 
             
                   jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse,
         | 
| 206394 | 
            -
                   SQLITE_SUBTYPE|SQLITE_UTF8| | 
| 206485 | 
            +
                   SQLITE_SUBTYPE|SQLITE_RESULT_SUBTYPE|SQLITE_UTF8|
         | 
| 206486 | 
            +
                   SQLITE_DETERMINISTIC),
         | 
| 206395 206487 | 
             
                WAGGREGATE(json_group_object, 2, 0, 0,
         | 
| 206396 206488 | 
             
                   jsonObjectStep, jsonObjectFinal, jsonObjectValue, jsonGroupInverse,
         | 
| 206397 | 
            -
                   SQLITE_SUBTYPE|SQLITE_UTF8| | 
| 206489 | 
            +
                   SQLITE_SUBTYPE|SQLITE_RESULT_SUBTYPE|SQLITE_UTF8|
         | 
| 206490 | 
            +
                   SQLITE_DETERMINISTIC)
         | 
| 206398 206491 | 
             
              };
         | 
| 206399 206492 | 
             
              sqlite3InsertBuiltinFuncs(aJsonFunc, ArraySize(aJsonFunc));
         | 
| 206400 206493 | 
             
            #endif
         | 
| @@ -236131,10 +236224,8 @@ static Fts5HashEntry *fts5HashEntryMerge( | |
| 236131 236224 | 
             
            }
         | 
| 236132 236225 |  | 
| 236133 236226 | 
             
            /*
         | 
| 236134 | 
            -
            **  | 
| 236135 | 
            -
            **  | 
| 236136 | 
            -
            ** the responsibility of the caller to free the elements of the returned
         | 
| 236137 | 
            -
            ** list.
         | 
| 236227 | 
            +
            ** Link all tokens from hash table iHash into a list in sorted order. The
         | 
| 236228 | 
            +
            ** tokens are not removed from the hash table.
         | 
| 236138 236229 | 
             
            */
         | 
| 236139 236230 | 
             
            static int fts5HashEntrySort(
         | 
| 236140 236231 | 
             
              Fts5Hash *pHash,
         | 
| @@ -239000,6 +239091,14 @@ static void fts5SegIterHashInit( | |
| 239000 239091 | 
             
                    pLeaf->p = (u8*)pList;
         | 
| 239001 239092 | 
             
                  }
         | 
| 239002 239093 | 
             
                }
         | 
| 239094 | 
            +
             | 
| 239095 | 
            +
                /* The call to sqlite3Fts5HashScanInit() causes the hash table to
         | 
| 239096 | 
            +
                ** fill the size field of all existing position lists. This means they
         | 
| 239097 | 
            +
                ** can no longer be appended to. Since the only scenario in which they
         | 
| 239098 | 
            +
                ** can be appended to is if the previous operation on this table was
         | 
| 239099 | 
            +
                ** a DELETE, by clearing the Fts5Index.bDelete flag we can avoid this
         | 
| 239100 | 
            +
                ** possibility altogether.  */
         | 
| 239101 | 
            +
                p->bDelete = 0;
         | 
| 239003 239102 | 
             
              }else{
         | 
| 239004 239103 | 
             
                p->rc = sqlite3Fts5HashQuery(p->pHash, sizeof(Fts5Data),
         | 
| 239005 239104 | 
             
                    (const char*)pTerm, nTerm, (void**)&pLeaf, &nList
         | 
| @@ -240677,7 +240776,7 @@ static void fts5WriteAppendPoslistData( | |
| 240677 240776 | 
             
              const u8 *a = aData;
         | 
| 240678 240777 | 
             
              int n = nData;
         | 
| 240679 240778 |  | 
| 240680 | 
            -
              assert( p->pConfig->pgsz>0 );
         | 
| 240779 | 
            +
              assert( p->pConfig->pgsz>0 || p->rc!=SQLITE_OK );
         | 
| 240681 240780 | 
             
              while( p->rc==SQLITE_OK
         | 
| 240682 240781 | 
             
                 && (pPage->buf.n + pPage->pgidx.n + n)>=p->pConfig->pgsz
         | 
| 240683 240782 | 
             
              ){
         | 
| @@ -241410,18 +241509,24 @@ static void fts5DoSecureDelete( | |
| 241410 241509 |  | 
| 241411 241510 | 
             
              iOff = iStart;
         | 
| 241412 241511 |  | 
| 241413 | 
            -
              /*  | 
| 241414 | 
            -
              ** the  | 
| 241512 | 
            +
              /* If the position-list for the entry being removed flows over past
         | 
| 241513 | 
            +
              ** the end of this page, delete the portion of the position-list on the
         | 
| 241514 | 
            +
              ** next page and beyond.
         | 
| 241515 | 
            +
              **
         | 
| 241516 | 
            +
              ** Set variable bLastInDoclist to true if this entry happens
         | 
| 241517 | 
            +
              ** to be the last rowid in the doclist for its term.  */
         | 
| 241518 | 
            +
              if( iNextOff>=iPgIdx ){
         | 
| 241519 | 
            +
                int pgno = pSeg->iLeafPgno+1;
         | 
| 241520 | 
            +
                fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist);
         | 
| 241521 | 
            +
                iNextOff = iPgIdx;
         | 
| 241522 | 
            +
              }
         | 
| 241523 | 
            +
             | 
| 241415 241524 | 
             
              if( pSeg->bDel==0 ){
         | 
| 241416 | 
            -
                if( iNextOff | 
| 241417 | 
            -
                  int pgno = pSeg->iLeafPgno+1;
         | 
| 241418 | 
            -
                  fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist);
         | 
| 241419 | 
            -
                  iNextOff = iPgIdx;
         | 
| 241420 | 
            -
                }else{
         | 
| 241525 | 
            +
                if( iNextOff!=iPgIdx ){
         | 
| 241421 241526 | 
             
                  /* Loop through the page-footer. If iNextOff (offset of the
         | 
| 241422 241527 | 
             
                  ** entry following the one we are removing) is equal to the
         | 
| 241423 241528 | 
             
                  ** offset of a key on this page, then the entry is the last
         | 
| 241424 | 
            -
                  ** in its doclist. | 
| 241529 | 
            +
                  ** in its doclist. */
         | 
| 241425 241530 | 
             
                  int iKeyOff = 0;
         | 
| 241426 241531 | 
             
                  for(iIdx=0; iIdx<nIdx; /* no-op */){
         | 
| 241427 241532 | 
             
                    u32 iVal = 0;
         | 
| @@ -241937,8 +242042,9 @@ static int sqlite3Fts5IndexOptimize(Fts5Index *p){ | |
| 241937 242042 |  | 
| 241938 242043 | 
             
              assert( p->rc==SQLITE_OK );
         | 
| 241939 242044 | 
             
              fts5IndexFlush(p);
         | 
| 241940 | 
            -
              assert( p->nContentlessDelete==0 );
         | 
| 242045 | 
            +
              assert( p->rc!=SQLITE_OK || p->nContentlessDelete==0 );
         | 
| 241941 242046 | 
             
              pStruct = fts5StructureRead(p);
         | 
| 242047 | 
            +
              assert( p->rc!=SQLITE_OK || pStruct!=0 );
         | 
| 241942 242048 | 
             
              fts5StructureInvalidate(p);
         | 
| 241943 242049 |  | 
| 241944 242050 | 
             
              if( pStruct ){
         | 
| @@ -247515,7 +247621,7 @@ static void fts5SourceIdFunc( | |
| 247515 247621 | 
             
            ){
         | 
| 247516 247622 | 
             
              assert( nArg==0 );
         | 
| 247517 247623 | 
             
              UNUSED_PARAM2(nArg, apUnused);
         | 
| 247518 | 
            -
              sqlite3_result_text(pCtx, "fts5: 2023-11- | 
| 247624 | 
            +
              sqlite3_result_text(pCtx, "fts5: 2023-11-24 11:41:44 ebead0e7230cd33bcec9f95d2183069565b9e709bf745c9b5db65cc0cbf92c0f", -1, SQLITE_TRANSIENT);
         | 
| 247519 247625 | 
             
            }
         | 
| 247520 247626 |  | 
| 247521 247627 | 
             
            /*
         |