| | @@ -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.38.0" |
| 456 | 456 | #define SQLITE_VERSION_NUMBER 3038000 |
| 457 | | -#define SQLITE_SOURCE_ID "2022-01-12 00:28:12 adebb9d7478d092f16fb0ef7d5246ce152b166479d6f949110b5878b89ea2cec" |
| 457 | +#define SQLITE_SOURCE_ID "2022-01-25 00:03:25 a8db69411b0d1275909adeb21027784ada17af24efe3a59ae0ae2a897659ff17" |
| 458 | 458 | |
| 459 | 459 | /* |
| 460 | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 462 | ** |
| | @@ -9775,25 +9775,26 @@ |
| 9775 | 9775 | */ |
| 9776 | 9776 | SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*); |
| 9777 | 9777 | |
| 9778 | 9778 | /* |
| 9779 | 9779 | ** CAPI3REF: Determine The Collation For a Virtual Table Constraint |
| 9780 | +** METHOD: sqlite3_index_info |
| 9780 | 9781 | ** |
| 9781 | 9782 | ** This function may only be called from within a call to the [xBestIndex] |
| 9782 | 9783 | ** method of a [virtual table]. This function returns a pointer to a string |
| 9783 | 9784 | ** that is the name of the appropriate collation sequence to use for text |
| 9784 | 9785 | ** comparisons on the constraint identified by its arguments. |
| 9785 | 9786 | ** |
| 9786 | | -** The first argument must be the pointer to the sqlite3_index_info object |
| 9787 | +** The first argument must be the pointer to the [sqlite3_index_info] object |
| 9787 | 9788 | ** that is the first parameter to the xBestIndex() method. The second argument |
| 9788 | 9789 | ** must be an index into the aConstraint[] array belonging to the |
| 9789 | 9790 | ** sqlite3_index_info structure passed to xBestIndex. |
| 9790 | 9791 | ** |
| 9791 | 9792 | ** Important: |
| 9792 | 9793 | ** The first parameter must be the same pointer that is passed into the |
| 9793 | 9794 | ** xBestMethod() method. The first parameter may not be a pointer to a |
| 9794 | | -** different sqlite3_index_info object, even an exact copy. |
| 9795 | +** different [sqlite3_index_info] object, even an exact copy. |
| 9795 | 9796 | ** |
| 9796 | 9797 | ** The return value is computed as follows: |
| 9797 | 9798 | ** |
| 9798 | 9799 | ** <ol> |
| 9799 | 9800 | ** <li><p> If the constraint comes from a WHERE clause expression that contains |
| | @@ -9807,10 +9808,103 @@ |
| 9807 | 9808 | ** <li><p> Otherwise, "BINARY" is returned. |
| 9808 | 9809 | ** </ol> |
| 9809 | 9810 | */ |
| 9810 | 9811 | SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int); |
| 9811 | 9812 | |
| 9813 | +/* |
| 9814 | +** CAPI3REF: Determine if a virtual table query is DISTINCT |
| 9815 | +** METHOD: sqlite3_index_info |
| 9816 | +** |
| 9817 | +** This API may only be used from within an xBestIndex() callback. The |
| 9818 | +** results of calling it from outside of an xBestIndex() callback are |
| 9819 | +** undefined and probably harmful. |
| 9820 | +** |
| 9821 | +** ^The sqlite3_vtab_distinct() returns an integer that is either 0, 1, or |
| 9822 | +** 2. The integer returned by sqlite3_vtab_distinct() gives the virtual table |
| 9823 | +** additional information about how the query planner wants the output to be |
| 9824 | +** ordered. As long as the virtual table can meet the ordering requirements |
| 9825 | +** of the query planner, it may set the "orderByConsumed" flag. |
| 9826 | +** |
| 9827 | +** <ol><li value="0"><p> |
| 9828 | +** ^If the sqlite3_vtab_distinct() interface returns 0, that means |
| 9829 | +** that the query planner needs the virtual table to return all rows in the |
| 9830 | +** sort order defined by the "nOrderBy" and "aOrderBy" fields of the |
| 9831 | +** [sqlite3_index_info] object. This is the default expectation. If the |
| 9832 | +** virtual table outputs all rows in sorted order, then it is always safe for |
| 9833 | +** the xBestIndex method to set the "orderByConsumed" flag, regardless of |
| 9834 | +** what the return value from sqlite3_vtab_distinct(). |
| 9835 | +** <li value="1"><p> |
| 9836 | +** ^(If the sqlite3_vtab_distinct() interface returns 1, that means |
| 9837 | +** that the query planner does not need the rows to be returned in sorted order |
| 9838 | +** as long as all rows with the same values in all columns identified by the |
| 9839 | +** "aOrderBy" field are adjacent.)^ This mode is used when the query planner |
| 9840 | +** is doing a GROUP BY. |
| 9841 | +** <li value="2"><p> |
| 9842 | +** ^(If the sqlite3_vtab_distinct() interface returns 2, that means |
| 9843 | +** that the query planner does not need the rows returned in any particular |
| 9844 | +** order, as long as rows with the same values in all "aOrderBy" columns |
| 9845 | +** are adjacent.)^ ^(Furthermore, only a single row for each particular |
| 9846 | +** combination of values in the columns identified by the "aOrderBy" field |
| 9847 | +** needs to be returned.)^ ^It is ok always for two or more rows with the same |
| 9848 | +** values in all "aOrderBy" columns to be returned, as long as all such rows |
| 9849 | +** are adjacent. ^The virtual table may, if it chooses, omit extra rows |
| 9850 | +** that have the same value for all columns identified by "aOrderBy". |
| 9851 | +** ^However omitting the extra rows is optional. |
| 9852 | +** This mode is used for a DISTINCT query. |
| 9853 | +** </ol> |
| 9854 | +** |
| 9855 | +** ^For the purposes of comparing virtual table output values to see if the |
| 9856 | +** values are same value for sorting purposes, two NULL values are considered |
| 9857 | +** to be the same. In other words, the comparison operator is "IS" |
| 9858 | +** (or "IS NOT DISTINCT FROM") and not "==". |
| 9859 | +** |
| 9860 | +** If a virtual table implementation is unable to meet the requirements |
| 9861 | +** specified above, then it must not set the "orderByConsumed" flag in the |
| 9862 | +** [sqlite3_index_info] object or an incorrect answer may result. |
| 9863 | +** |
| 9864 | +** ^A virtual table implementation is always free to return rows in any order |
| 9865 | +** it wants, as long as the "orderByConsumed" flag is not set. ^When the |
| 9866 | +** the "orderByConsumed" flag is unset, the query planner will add extra |
| 9867 | +** [bytecode] to ensure that the final results returned by the SQL query are |
| 9868 | +** ordered correctly. The use of the "orderByConsumed" flag and the |
| 9869 | +** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful |
| 9870 | +** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed" |
| 9871 | +** flag might help queries against a virtual table to run faster. Being |
| 9872 | +** overly aggressive and setting the "orderByConsumed" flag when it is not |
| 9873 | +** valid to do so, on the other hand, might cause SQLite to return incorrect |
| 9874 | +** results. |
| 9875 | +*/ |
| 9876 | +SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*); |
| 9877 | + |
| 9878 | +/* |
| 9879 | +** CAPI3REF: Constraint values in xBestIndex() |
| 9880 | +** METHOD: sqlite3_index_info |
| 9881 | +** |
| 9882 | +** This API may only be used from within an xBestIndex() callback. The |
| 9883 | +** results of calling it from outside of an xBestIndex() callback are |
| 9884 | +** undefined and probably harmful. |
| 9885 | +** |
| 9886 | +** ^When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within |
| 9887 | +** the [xBestIndex] method of a [virtual table] implementation, with P being |
| 9888 | +** a copy of the [sqlite3_index_info] object pointer passed into xBestIndex and |
| 9889 | +** J being a 0-based index into P->aConstraint[], then this routine |
| 9890 | +** attempts to set *V to be the value on the right-hand side of |
| 9891 | +** that constraint if the right-hand side is a known constant. ^If the |
| 9892 | +** right-hand side of the constraint is not known, then *V is set to a NULL |
| 9893 | +** pointer. ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if |
| 9894 | +** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V) |
| 9895 | +** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th |
| 9896 | +** constraint is not available. ^The sqlite3_vtab_rhs_value() interface |
| 9897 | +** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if |
| 9898 | +** something goes wrong. |
| 9899 | +** |
| 9900 | +** ^The sqlite3_value object returned in *V remains valid for the duration of |
| 9901 | +** the xBestIndex method code. ^When xBestIndex returns, the sqlite3_value |
| 9902 | +** object returned by sqlite3_vtab_rhs_value() is automatically deallocated. |
| 9903 | +*/ |
| 9904 | +SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal); |
| 9905 | + |
| 9812 | 9906 | /* |
| 9813 | 9907 | ** CAPI3REF: Conflict resolution modes |
| 9814 | 9908 | ** KEYWORDS: {conflict resolution mode} |
| 9815 | 9909 | ** |
| 9816 | 9910 | ** These constants are returned by [sqlite3_vtab_on_conflict()] to |
| | @@ -18576,10 +18670,11 @@ |
| 18576 | 18670 | ** initialized as they will be set before being used. The boundary is |
| 18577 | 18671 | ** determined by offsetof(Parse,aTempReg). |
| 18578 | 18672 | **************************************************************************/ |
| 18579 | 18673 | |
| 18580 | 18674 | int aTempReg[8]; /* Holding area for temporary registers */ |
| 18675 | + Parse *pOuterParse; /* Outer Parse object when nested */ |
| 18581 | 18676 | Token sNameToken; /* Token with unqualified schema object name */ |
| 18582 | 18677 | |
| 18583 | 18678 | /************************************************************************ |
| 18584 | 18679 | ** Above is constant between recursions. Below is reset before and after |
| 18585 | 18680 | ** each recursion. The boundary between these two regions is determined |
| | @@ -18626,11 +18721,12 @@ |
| 18626 | 18721 | #define PARSE_MODE_UNMAP 3 |
| 18627 | 18722 | |
| 18628 | 18723 | /* |
| 18629 | 18724 | ** Sizes and pointers of various parts of the Parse object. |
| 18630 | 18725 | */ |
| 18631 | | -#define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/ |
| 18726 | +#define PARSE_HDR(X) (((char*)(X))+offsetof(Parse,zErrMsg)) |
| 18727 | +#define PARSE_HDR_SZ (offsetof(Parse,aTempReg)-offsetof(Parse,zErrMsg)) /* Recursive part w/o aColCache*/ |
| 18632 | 18728 | #define PARSE_RECURSE_SZ offsetof(Parse,sLastToken) /* Recursive part */ |
| 18633 | 18729 | #define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */ |
| 18634 | 18730 | #define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ) /* Pointer to tail */ |
| 18635 | 18731 | |
| 18636 | 18732 | /* |
| | @@ -19966,11 +20062,11 @@ |
| 19966 | 20062 | void (*)(sqlite3_context*), |
| 19967 | 20063 | void (*)(sqlite3_context*,int,sqlite3_value **), |
| 19968 | 20064 | FuncDestructor *pDestructor |
| 19969 | 20065 | ); |
| 19970 | 20066 | SQLITE_PRIVATE void sqlite3NoopDestructor(void*); |
| 19971 | | -SQLITE_PRIVATE void sqlite3OomFault(sqlite3*); |
| 20067 | +SQLITE_PRIVATE void *sqlite3OomFault(sqlite3*); |
| 19972 | 20068 | SQLITE_PRIVATE void sqlite3OomClear(sqlite3*); |
| 19973 | 20069 | SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); |
| 19974 | 20070 | SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); |
| 19975 | 20071 | |
| 19976 | 20072 | SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int); |
| | @@ -20087,11 +20183,12 @@ |
| 20087 | 20183 | SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *); |
| 20088 | 20184 | SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*); |
| 20089 | 20185 | SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*); |
| 20090 | 20186 | SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); |
| 20091 | 20187 | SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *); |
| 20092 | | -SQLITE_PRIVATE void sqlite3ParserReset(Parse*); |
| 20188 | +SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*); |
| 20189 | +SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*); |
| 20093 | 20190 | SQLITE_PRIVATE void *sqlite3ParserAddCleanup(Parse*,void(*)(sqlite3*,void*),void*); |
| 20094 | 20191 | #ifdef SQLITE_ENABLE_NORMALIZE |
| 20095 | 20192 | SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*); |
| 20096 | 20193 | #endif |
| 20097 | 20194 | SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*); |
| | @@ -20520,10 +20617,18 @@ |
| 20520 | 20617 | |
| 20521 | 20618 | #endif /* !defined(_OS_COMMON_H_) */ |
| 20522 | 20619 | |
| 20523 | 20620 | /************** End of os_common.h *******************************************/ |
| 20524 | 20621 | /************** Begin file ctime.c *******************************************/ |
| 20622 | +/* DO NOT EDIT! |
| 20623 | +** This file is automatically generated by the script in the canonical |
| 20624 | +** SQLite source tree at tool/mkctimec.tcl. |
| 20625 | +** |
| 20626 | +** To modify this header, edit any of the various lists in that script |
| 20627 | +** which specify categories of generated conditionals in this file. |
| 20628 | +*/ |
| 20629 | + |
| 20525 | 20630 | /* |
| 20526 | 20631 | ** 2010 February 23 |
| 20527 | 20632 | ** |
| 20528 | 20633 | ** The author disclaims copyright to this source code. In place of |
| 20529 | 20634 | ** a legal notice, here is a blessing: |
| | @@ -20568,13 +20673,10 @@ |
| 20568 | 20673 | ** only a handful of compile-time options, so most times this array is usually |
| 20569 | 20674 | ** rather short and uses little memory space. |
| 20570 | 20675 | */ |
| 20571 | 20676 | static const char * const sqlite3azCompileOpt[] = { |
| 20572 | 20677 | |
| 20573 | | -/* |
| 20574 | | -** BEGIN CODE GENERATED BY tool/mkctime.tcl |
| 20575 | | -*/ |
| 20576 | 20678 | #ifdef SQLITE_32BIT_ROWID |
| 20577 | 20679 | "32BIT_ROWID", |
| 20578 | 20680 | #endif |
| 20579 | 20681 | #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC |
| 20580 | 20682 | "4_BYTE_ALIGNED_MALLOC", |
| | @@ -20701,13 +20803,10 @@ |
| 20701 | 20803 | "DISABLE_FTS4_DEFERRED", |
| 20702 | 20804 | #endif |
| 20703 | 20805 | #ifdef SQLITE_DISABLE_INTRINSIC |
| 20704 | 20806 | "DISABLE_INTRINSIC", |
| 20705 | 20807 | #endif |
| 20706 | | -#ifdef SQLITE_DISABLE_JSON |
| 20707 | | - "DISABLE_JSON", |
| 20708 | | -#endif |
| 20709 | 20808 | #ifdef SQLITE_DISABLE_LFS |
| 20710 | 20809 | "DISABLE_LFS", |
| 20711 | 20810 | #endif |
| 20712 | 20811 | #ifdef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS |
| 20713 | 20812 | "DISABLE_PAGECACHE_OVERFLOW_STATS", |
| | @@ -21104,10 +21203,13 @@ |
| 21104 | 21203 | #ifdef SQLITE_OMIT_INTEGRITY_CHECK |
| 21105 | 21204 | "OMIT_INTEGRITY_CHECK", |
| 21106 | 21205 | #endif |
| 21107 | 21206 | #ifdef SQLITE_OMIT_INTROSPECTION_PRAGMAS |
| 21108 | 21207 | "OMIT_INTROSPECTION_PRAGMAS", |
| 21208 | +#endif |
| 21209 | +#ifdef SQLITE_OMIT_JSON |
| 21210 | + "OMIT_JSON", |
| 21109 | 21211 | #endif |
| 21110 | 21212 | #ifdef SQLITE_OMIT_LIKE_OPTIMIZATION |
| 21111 | 21213 | "OMIT_LIKE_OPTIMIZATION", |
| 21112 | 21214 | #endif |
| 21113 | 21215 | #ifdef SQLITE_OMIT_LOAD_EXTENSION |
| | @@ -21293,14 +21395,12 @@ |
| 21293 | 21395 | "WIN32_MALLOC", |
| 21294 | 21396 | #endif |
| 21295 | 21397 | #ifdef SQLITE_ZERO_MALLOC |
| 21296 | 21398 | "ZERO_MALLOC", |
| 21297 | 21399 | #endif |
| 21298 | | -/* |
| 21299 | | -** END CODE GENERATED BY tool/mkctime.tcl |
| 21300 | | -*/ |
| 21301 | | -}; |
| 21400 | + |
| 21401 | +} ; |
| 21302 | 21402 | |
| 21303 | 21403 | SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){ |
| 21304 | 21404 | *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]); |
| 21305 | 21405 | return (const char**)sqlite3azCompileOpt; |
| 21306 | 21406 | } |
| | @@ -23406,11 +23506,12 @@ |
| 23406 | 23506 | */ |
| 23407 | 23507 | static int parseModifier( |
| 23408 | 23508 | sqlite3_context *pCtx, /* Function context */ |
| 23409 | 23509 | const char *z, /* The text of the modifier */ |
| 23410 | 23510 | int n, /* Length of zMod in bytes */ |
| 23411 | | - DateTime *p /* The date/time value to be modified */ |
| 23511 | + DateTime *p, /* The date/time value to be modified */ |
| 23512 | + int idx /* Parameter index of the modifier */ |
| 23412 | 23513 | ){ |
| 23413 | 23514 | int rc = 1; |
| 23414 | 23515 | double r; |
| 23415 | 23516 | switch(sqlite3UpperToLower[(u8)z[0]] ){ |
| 23416 | 23517 | case 'a': { |
| | @@ -23419,10 +23520,11 @@ |
| 23419 | 23520 | ** |
| 23420 | 23521 | ** If rawS is available, then interpret as a julian day number, or |
| 23421 | 23522 | ** a unix timestamp, depending on its magnitude. |
| 23422 | 23523 | */ |
| 23423 | 23524 | if( sqlite3_stricmp(z, "auto")==0 ){ |
| 23525 | + if( idx>1 ) return 1; /* IMP: R-33611-57934 */ |
| 23424 | 23526 | if( !p->rawS || p->validJD ){ |
| 23425 | 23527 | rc = 0; |
| 23426 | 23528 | p->rawS = 0; |
| 23427 | 23529 | }else if( p->s>=-210866760000 && p->s<=253402300799 ){ |
| 23428 | 23530 | r = p->s*1000.0 + 210866760000000.0; |
| | @@ -23443,10 +23545,11 @@ |
| 23443 | 23545 | ** is not the first modifier, or if the prior argument is not a numeric |
| 23444 | 23546 | ** value in the allowed range of julian day numbers understood by |
| 23445 | 23547 | ** SQLite (0..5373484.5) then the result will be NULL. |
| 23446 | 23548 | */ |
| 23447 | 23549 | if( sqlite3_stricmp(z, "julianday")==0 ){ |
| 23550 | + if( idx>1 ) return 1; |
| 23448 | 23551 | if( p->validJD && p->rawS ){ |
| 23449 | 23552 | rc = 0; |
| 23450 | 23553 | p->rawS = 0; |
| 23451 | 23554 | } |
| 23452 | 23555 | } |
| | @@ -23686,11 +23789,11 @@ |
| 23686 | 23789 | } |
| 23687 | 23790 | } |
| 23688 | 23791 | for(i=1; i<argc; i++){ |
| 23689 | 23792 | z = sqlite3_value_text(argv[i]); |
| 23690 | 23793 | n = sqlite3_value_bytes(argv[i]); |
| 23691 | | - if( z==0 || parseModifier(context, (char*)z, n, p) ) return 1; |
| 23794 | + if( z==0 || parseModifier(context, (char*)z, n, p, i) ) return 1; |
| 23692 | 23795 | } |
| 23693 | 23796 | computeJD(p); |
| 23694 | 23797 | if( p->isError || !validJulianDay(p->iJD) ) return 1; |
| 23695 | 23798 | return 0; |
| 23696 | 23799 | } |
| | @@ -28956,22 +29059,31 @@ |
| 28956 | 29059 | /* |
| 28957 | 29060 | ** Call this routine to record the fact that an OOM (out-of-memory) error |
| 28958 | 29061 | ** has happened. This routine will set db->mallocFailed, and also |
| 28959 | 29062 | ** temporarily disable the lookaside memory allocator and interrupt |
| 28960 | 29063 | ** any running VDBEs. |
| 29064 | +** |
| 29065 | +** Always return a NULL pointer so that this routine can be invoked using |
| 29066 | +** |
| 29067 | +** return sqlite3OomFault(db); |
| 29068 | +** |
| 29069 | +** and thereby avoid unnecessary stack frame allocations for the overwhelmingly |
| 29070 | +** common case where no OOM occurs. |
| 28961 | 29071 | */ |
| 28962 | | -SQLITE_PRIVATE void sqlite3OomFault(sqlite3 *db){ |
| 29072 | +SQLITE_PRIVATE void *sqlite3OomFault(sqlite3 *db){ |
| 28963 | 29073 | if( db->mallocFailed==0 && db->bBenignMalloc==0 ){ |
| 28964 | 29074 | db->mallocFailed = 1; |
| 28965 | 29075 | if( db->nVdbeExec>0 ){ |
| 28966 | 29076 | AtomicStore(&db->u1.isInterrupted, 1); |
| 28967 | 29077 | } |
| 28968 | 29078 | DisableLookaside; |
| 28969 | 29079 | if( db->pParse ){ |
| 29080 | + sqlite3ErrorMsg(db->pParse, "out of memory"); |
| 28970 | 29081 | db->pParse->rc = SQLITE_NOMEM_BKPT; |
| 28971 | 29082 | } |
| 28972 | 29083 | } |
| 29084 | + return 0; |
| 28973 | 29085 | } |
| 28974 | 29086 | |
| 28975 | 29087 | /* |
| 28976 | 29088 | ** This routine reactivates the memory allocator and clears the |
| 28977 | 29089 | ** db->mallocFailed flag as necessary. |
| | @@ -32356,17 +32468,23 @@ |
| 32356 | 32468 | */ |
| 32357 | 32469 | SQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){ |
| 32358 | 32470 | char *zMsg; |
| 32359 | 32471 | va_list ap; |
| 32360 | 32472 | sqlite3 *db = pParse->db; |
| 32473 | + assert( db!=0 ); |
| 32474 | + assert( db->pParse==pParse ); |
| 32361 | 32475 | db->errByteOffset = -2; |
| 32362 | 32476 | va_start(ap, zFormat); |
| 32363 | 32477 | zMsg = sqlite3VMPrintf(db, zFormat, ap); |
| 32364 | 32478 | va_end(ap); |
| 32365 | 32479 | if( db->errByteOffset<-1 ) db->errByteOffset = -1; |
| 32366 | 32480 | if( db->suppressErr ){ |
| 32367 | 32481 | sqlite3DbFree(db, zMsg); |
| 32482 | + if( db->mallocFailed ){ |
| 32483 | + pParse->nErr++; |
| 32484 | + pParse->rc = SQLITE_NOMEM; |
| 32485 | + } |
| 32368 | 32486 | }else{ |
| 32369 | 32487 | pParse->nErr++; |
| 32370 | 32488 | sqlite3DbFree(db, pParse->zErrMsg); |
| 32371 | 32489 | pParse->zErrMsg = zMsg; |
| 32372 | 32490 | pParse->rc = SQLITE_ERROR; |
| | @@ -56722,12 +56840,11 @@ |
| 56722 | 56840 | ** Once this function has been called, the transaction must either be |
| 56723 | 56841 | ** rolled back or committed. It is not safe to call this function and |
| 56724 | 56842 | ** then continue writing to the database. |
| 56725 | 56843 | */ |
| 56726 | 56844 | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){ |
| 56727 | | - assert( pPager->dbSize>=nPage || CORRUPT_DB ); |
| 56728 | | - testcase( pPager->dbSize<nPage ); |
| 56845 | + assert( pPager->dbSize>=nPage ); |
| 56729 | 56846 | assert( pPager->eState>=PAGER_WRITER_CACHEMOD ); |
| 56730 | 56847 | pPager->dbSize = nPage; |
| 56731 | 56848 | |
| 56732 | 56849 | /* At one point the code here called assertTruncateConstraint() to |
| 56733 | 56850 | ** ensure that all pages being truncated away by this operation are, |
| | @@ -63102,11 +63219,13 @@ |
| 63102 | 63219 | rc = WAL_RETRY; |
| 63103 | 63220 | goto begin_unreliable_shm_out; |
| 63104 | 63221 | } |
| 63105 | 63222 | |
| 63106 | 63223 | /* Allocate a buffer to read frames into */ |
| 63107 | | - szFrame = pWal->hdr.szPage + WAL_FRAME_HDRSIZE; |
| 63224 | + assert( (pWal->szPage & (pWal->szPage-1))==0 ); |
| 63225 | + assert( pWal->szPage>=512 && pWal->szPage<=65536 ); |
| 63226 | + szFrame = pWal->szPage + WAL_FRAME_HDRSIZE; |
| 63108 | 63227 | aFrame = (u8 *)sqlite3_malloc64(szFrame); |
| 63109 | 63228 | if( aFrame==0 ){ |
| 63110 | 63229 | rc = SQLITE_NOMEM_BKPT; |
| 63111 | 63230 | goto begin_unreliable_shm_out; |
| 63112 | 63231 | } |
| | @@ -63116,11 +63235,11 @@ |
| 63116 | 63235 | ** wal file since the heap-memory wal-index was created. If so, the |
| 63117 | 63236 | ** heap-memory wal-index is discarded and WAL_RETRY returned to |
| 63118 | 63237 | ** the caller. */ |
| 63119 | 63238 | aSaveCksum[0] = pWal->hdr.aFrameCksum[0]; |
| 63120 | 63239 | aSaveCksum[1] = pWal->hdr.aFrameCksum[1]; |
| 63121 | | - for(iOffset=walFrameOffset(pWal->hdr.mxFrame+1, pWal->hdr.szPage); |
| 63240 | + for(iOffset=walFrameOffset(pWal->hdr.mxFrame+1, pWal->szPage); |
| 63122 | 63241 | iOffset+szFrame<=szWal; |
| 63123 | 63242 | iOffset+=szFrame |
| 63124 | 63243 | ){ |
| 63125 | 63244 | u32 pgno; /* Database page number for frame */ |
| 63126 | 63245 | u32 nTruncate; /* dbsize field from frame header */ |
| | @@ -68934,13 +69053,17 @@ |
| 68934 | 69053 | freeTempSpace(pBt); |
| 68935 | 69054 | rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, |
| 68936 | 69055 | pageSize-usableSize); |
| 68937 | 69056 | return rc; |
| 68938 | 69057 | } |
| 68939 | | - if( sqlite3WritableSchema(pBt->db)==0 && nPage>nPageFile ){ |
| 68940 | | - rc = SQLITE_CORRUPT_BKPT; |
| 68941 | | - goto page1_init_failed; |
| 69058 | + if( nPage>nPageFile ){ |
| 69059 | + if( sqlite3WritableSchema(pBt->db)==0 ){ |
| 69060 | + rc = SQLITE_CORRUPT_BKPT; |
| 69061 | + goto page1_init_failed; |
| 69062 | + }else{ |
| 69063 | + nPage = nPageFile; |
| 69064 | + } |
| 68942 | 69065 | } |
| 68943 | 69066 | /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to |
| 68944 | 69067 | ** be less than 480. In other words, if the page size is 512, then the |
| 68945 | 69068 | ** reserved space size cannot exceed 32. */ |
| 68946 | 69069 | if( usableSize<480 ){ |
| | @@ -76691,18 +76814,17 @@ |
| 76691 | 76814 | int i = sqlite3FindDbName(pDb, zDb); |
| 76692 | 76815 | |
| 76693 | 76816 | if( i==1 ){ |
| 76694 | 76817 | Parse sParse; |
| 76695 | 76818 | int rc = 0; |
| 76696 | | - memset(&sParse, 0, sizeof(sParse)); |
| 76697 | | - sParse.db = pDb; |
| 76819 | + sqlite3ParseObjectInit(&sParse,pErrorDb); |
| 76698 | 76820 | if( sqlite3OpenTempDatabase(&sParse) ){ |
| 76699 | 76821 | sqlite3ErrorWithMsg(pErrorDb, sParse.rc, "%s", sParse.zErrMsg); |
| 76700 | 76822 | rc = SQLITE_ERROR; |
| 76701 | 76823 | } |
| 76702 | 76824 | sqlite3DbFree(pErrorDb, sParse.zErrMsg); |
| 76703 | | - sqlite3ParserReset(&sParse); |
| 76825 | + sqlite3ParseObjectReset(&sParse); |
| 76704 | 76826 | if( rc ){ |
| 76705 | 76827 | return 0; |
| 76706 | 76828 | } |
| 76707 | 76829 | } |
| 76708 | 76830 | |
| | @@ -80707,12 +80829,11 @@ |
| 80707 | 80829 | ** makes the code easier to read during debugging. None of this happens |
| 80708 | 80830 | ** in a production build. |
| 80709 | 80831 | */ |
| 80710 | 80832 | static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){ |
| 80711 | 80833 | assert( p->nOp>0 || p->aOp==0 ); |
| 80712 | | - assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed |
| 80713 | | - || p->pParse->nErr>0 ); |
| 80834 | + assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->pParse->nErr>0 ); |
| 80714 | 80835 | if( p->nOp ){ |
| 80715 | 80836 | assert( p->aOp ); |
| 80716 | 80837 | sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment); |
| 80717 | 80838 | p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap); |
| 80718 | 80839 | } |
| | @@ -87537,11 +87658,10 @@ |
| 87537 | 87658 | */ |
| 87538 | 87659 | static u64 filterHash(const Mem *aMem, const Op *pOp){ |
| 87539 | 87660 | int i, mx; |
| 87540 | 87661 | u64 h = 0; |
| 87541 | 87662 | |
| 87542 | | - i = pOp->p3; |
| 87543 | 87663 | assert( pOp->p4type==P4_INT32 ); |
| 87544 | 87664 | for(i=pOp->p3, mx=i+pOp->p4.i; i<mx; i++){ |
| 87545 | 87665 | const Mem *p = &aMem[i]; |
| 87546 | 87666 | if( p->flags & (MEM_Int|MEM_IntReal) ){ |
| 87547 | 87667 | h += p->u.i; |
| | @@ -89020,11 +89140,11 @@ |
| 89020 | 89140 | testcase( pIn1->flags & MEM_Real ); |
| 89021 | 89141 | testcase( pIn1->flags & MEM_IntReal ); |
| 89022 | 89142 | sqlite3VdbeMemStringify(pIn1, encoding, 1); |
| 89023 | 89143 | testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); |
| 89024 | 89144 | flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); |
| 89025 | | - if( NEVER(pIn1==pIn3) ) flags3 = flags1 | MEM_Str; |
| 89145 | + if( pIn1==pIn3 ) flags3 = flags1 | MEM_Str; |
| 89026 | 89146 | } |
| 89027 | 89147 | if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ |
| 89028 | 89148 | testcase( pIn3->flags & MEM_Int ); |
| 89029 | 89149 | testcase( pIn3->flags & MEM_Real ); |
| 89030 | 89150 | testcase( pIn3->flags & MEM_IntReal ); |
| | @@ -89846,10 +89966,12 @@ |
| 89846 | 89966 | case COLTYPE_TEXT: { |
| 89847 | 89967 | if( (pIn1->flags & MEM_Str)==0 ) goto vdbe_type_error; |
| 89848 | 89968 | break; |
| 89849 | 89969 | } |
| 89850 | 89970 | case COLTYPE_REAL: { |
| 89971 | + testcase( (pIn1->flags & (MEM_Real|MEM_IntReal))==MEM_Real ); |
| 89972 | + testcase( (pIn1->flags & (MEM_Real|MEM_IntReal))==MEM_IntReal ); |
| 89851 | 89973 | if( pIn1->flags & MEM_Int ){ |
| 89852 | 89974 | /* When applying REAL affinity, if the result is still an MEM_Int |
| 89853 | 89975 | ** that will fit in 6 bytes, then change the type to MEM_IntReal |
| 89854 | 89976 | ** so that we keep the high-resolution integer value but know that |
| 89855 | 89977 | ** the type really wants to be REAL. */ |
| | @@ -89863,11 +89985,11 @@ |
| 89863 | 89985 | }else{ |
| 89864 | 89986 | pIn1->u.r = (double)pIn1->u.i; |
| 89865 | 89987 | pIn1->flags |= MEM_Real; |
| 89866 | 89988 | pIn1->flags &= ~MEM_Int; |
| 89867 | 89989 | } |
| 89868 | | - }else if( (pIn1->flags & MEM_Real)==0 ){ |
| 89990 | + }else if( (pIn1->flags & (MEM_Real|MEM_IntReal))==0 ){ |
| 89869 | 89991 | goto vdbe_type_error; |
| 89870 | 89992 | } |
| 89871 | 89993 | break; |
| 89872 | 89994 | } |
| 89873 | 89995 | default: { |
| | @@ -95579,14 +95701,13 @@ |
| 95579 | 95701 | wrFlag = !!wrFlag; /* wrFlag = (wrFlag ? 1 : 0); */ |
| 95580 | 95702 | |
| 95581 | 95703 | sqlite3_mutex_enter(db->mutex); |
| 95582 | 95704 | |
| 95583 | 95705 | pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob)); |
| 95584 | | - do { |
| 95585 | | - memset(&sParse, 0, sizeof(Parse)); |
| 95706 | + while(1){ |
| 95707 | + sqlite3ParseObjectInit(&sParse,db); |
| 95586 | 95708 | if( !pBlob ) goto blob_open_out; |
| 95587 | | - sParse.db = db; |
| 95588 | 95709 | sqlite3DbFree(db, zErr); |
| 95589 | 95710 | zErr = 0; |
| 95590 | 95711 | |
| 95591 | 95712 | sqlite3BtreeEnterAll(db); |
| 95592 | 95713 | pTab = sqlite3LocateTable(&sParse, 0, zTable, zDb); |
| | @@ -95759,11 +95880,13 @@ |
| 95759 | 95880 | sqlite3BtreeLeaveAll(db); |
| 95760 | 95881 | if( db->mallocFailed ){ |
| 95761 | 95882 | goto blob_open_out; |
| 95762 | 95883 | } |
| 95763 | 95884 | rc = blobSeekToRow(pBlob, iRow, &zErr); |
| 95764 | | - } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA ); |
| 95885 | + if( (++nAttempt)>=SQLITE_MAX_SCHEMA_RETRY || rc!=SQLITE_SCHEMA ) break; |
| 95886 | + sqlite3ParseObjectReset(&sParse); |
| 95887 | + } |
| 95765 | 95888 | |
| 95766 | 95889 | blob_open_out: |
| 95767 | 95890 | if( rc==SQLITE_OK && db->mallocFailed==0 ){ |
| 95768 | 95891 | *ppBlob = (sqlite3_blob *)pBlob; |
| 95769 | 95892 | }else{ |
| | @@ -95770,11 +95893,11 @@ |
| 95770 | 95893 | if( pBlob && pBlob->pStmt ) sqlite3VdbeFinalize((Vdbe *)pBlob->pStmt); |
| 95771 | 95894 | sqlite3DbFree(db, pBlob); |
| 95772 | 95895 | } |
| 95773 | 95896 | sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr); |
| 95774 | 95897 | sqlite3DbFree(db, zErr); |
| 95775 | | - sqlite3ParserReset(&sParse); |
| 95898 | + sqlite3ParseObjectReset(&sParse); |
| 95776 | 95899 | rc = sqlite3ApiExit(db, rc); |
| 95777 | 95900 | sqlite3_mutex_leave(db->mutex); |
| 95778 | 95901 | return rc; |
| 95779 | 95902 | } |
| 95780 | 95903 | |
| | @@ -101054,11 +101177,12 @@ |
| 101054 | 101177 | sqlite3ErrorMsg(pParse, "row value misused"); |
| 101055 | 101178 | } |
| 101056 | 101179 | break; |
| 101057 | 101180 | } |
| 101058 | 101181 | } |
| 101059 | | - return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue; |
| 101182 | + assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 ); |
| 101183 | + return pParse->nErr ? WRC_Abort : WRC_Continue; |
| 101060 | 101184 | } |
| 101061 | 101185 | |
| 101062 | 101186 | /* |
| 101063 | 101187 | ** pEList is a list of expressions which are really the result set of the |
| 101064 | 101188 | ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause. |
| | @@ -101468,11 +101592,11 @@ |
| 101468 | 101592 | ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and |
| 101469 | 101593 | ** this routine in the correct order. |
| 101470 | 101594 | */ |
| 101471 | 101595 | if( (p->selFlags & SF_Expanded)==0 ){ |
| 101472 | 101596 | sqlite3SelectPrep(pParse, p, pOuterNC); |
| 101473 | | - return (pParse->nErr || db->mallocFailed) ? WRC_Abort : WRC_Prune; |
| 101597 | + return pParse->nErr ? WRC_Abort : WRC_Prune; |
| 101474 | 101598 | } |
| 101475 | 101599 | |
| 101476 | 101600 | isCompound = p->pPrior!=0; |
| 101477 | 101601 | nCompound = 0; |
| 101478 | 101602 | pLeftmost = p; |
| | @@ -101516,11 +101640,12 @@ |
| 101516 | 101640 | const char *zSavedContext = pParse->zAuthContext; |
| 101517 | 101641 | |
| 101518 | 101642 | if( pItem->zName ) pParse->zAuthContext = pItem->zName; |
| 101519 | 101643 | sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC); |
| 101520 | 101644 | pParse->zAuthContext = zSavedContext; |
| 101521 | | - if( pParse->nErr || db->mallocFailed ) return WRC_Abort; |
| 101645 | + if( pParse->nErr ) return WRC_Abort; |
| 101646 | + assert( db->mallocFailed==0 ); |
| 101522 | 101647 | |
| 101523 | 101648 | /* If the number of references to the outer context changed when |
| 101524 | 101649 | ** expressions in the sub-select were resolved, the sub-select |
| 101525 | 101650 | ** is correlated. It is not required to check the refcount on any |
| 101526 | 101651 | ** but the innermost outer context object, as lookupName() increments |
| | @@ -104696,12 +104821,11 @@ |
| 104696 | 104821 | Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i); |
| 104697 | 104822 | Expr *pRhs = pEList->a[i].pExpr; |
| 104698 | 104823 | CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs); |
| 104699 | 104824 | int j; |
| 104700 | 104825 | |
| 104701 | | - assert( pReq!=0 || pRhs->iColumn==XN_ROWID |
| 104702 | | - || pParse->nErr || db->mallocFailed ); |
| 104826 | + assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr ); |
| 104703 | 104827 | for(j=0; j<nExpr; j++){ |
| 104704 | 104828 | if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue; |
| 104705 | 104829 | assert( pIdx->azColl[j] ); |
| 104706 | 104830 | if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){ |
| 104707 | 104831 | continue; |
| | @@ -105173,14 +105297,12 @@ |
| 105173 | 105297 | pLimit = sqlite3Expr(pParse->db, TK_INTEGER, "1"); |
| 105174 | 105298 | pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0); |
| 105175 | 105299 | } |
| 105176 | 105300 | pSel->iLimit = 0; |
| 105177 | 105301 | if( sqlite3Select(pParse, pSel, &dest) ){ |
| 105178 | | - if( pParse->nErr ){ |
| 105179 | | - pExpr->op2 = pExpr->op; |
| 105180 | | - pExpr->op = TK_ERROR; |
| 105181 | | - } |
| 105302 | + pExpr->op2 = pExpr->op; |
| 105303 | + pExpr->op = TK_ERROR; |
| 105182 | 105304 | return 0; |
| 105183 | 105305 | } |
| 105184 | 105306 | pExpr->iTable = rReg = dest.iSDParm; |
| 105185 | 105307 | ExprSetVVAProperty(pExpr, EP_NoReduce); |
| 105186 | 105308 | if( addrOnce ){ |
| | @@ -105393,14 +105515,14 @@ |
| 105393 | 105515 | if( destIfNull==destIfFalse ){ |
| 105394 | 105516 | destStep2 = destIfFalse; |
| 105395 | 105517 | }else{ |
| 105396 | 105518 | destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse); |
| 105397 | 105519 | } |
| 105398 | | - if( pParse->nErr ) goto sqlite3ExprCodeIN_finished; |
| 105520 | +// if( pParse->nErr ) goto sqlite3ExprCodeIN_finished; |
| 105399 | 105521 | for(i=0; i<nVector; i++){ |
| 105400 | 105522 | Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i); |
| 105401 | | - if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error; |
| 105523 | + if( pParse->nErr ) goto sqlite3ExprCodeIN_oom_error; |
| 105402 | 105524 | if( sqlite3ExprCanBeNull(p) ){ |
| 105403 | 105525 | sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2); |
| 105404 | 105526 | VdbeCoverage(v); |
| 105405 | 105527 | } |
| 105406 | 105528 | } |
| | @@ -108571,11 +108693,13 @@ |
| 108571 | 108693 | sqlite3 *db; /* The database connection; */ |
| 108572 | 108694 | Vdbe *v; /* The prepared statement under construction */ |
| 108573 | 108695 | int r1; /* Temporary registers */ |
| 108574 | 108696 | |
| 108575 | 108697 | db = pParse->db; |
| 108576 | | - if( pParse->nErr || db->mallocFailed ) return; |
| 108698 | + assert( db->pParse==pParse ); |
| 108699 | + if( pParse->nErr ) return; |
| 108700 | + assert( db->mallocFailed==0 ); |
| 108577 | 108701 | pNew = pParse->pNewTable; |
| 108578 | 108702 | assert( pNew ); |
| 108579 | 108703 | |
| 108580 | 108704 | assert( sqlite3BtreeHoldsAllMutexes(db) ); |
| 108581 | 108705 | iDb = sqlite3SchemaToIndex(db, pNew->pSchema); |
| | @@ -108697,11 +108821,11 @@ |
| 108697 | 108821 | sqlite3NestedParse(pParse, |
| 108698 | 108822 | "SELECT CASE WHEN quick_check GLOB 'CHECK*'" |
| 108699 | 108823 | " THEN raise(ABORT,'CHECK constraint failed')" |
| 108700 | 108824 | " ELSE raise(ABORT,'NOT NULL constraint failed')" |
| 108701 | 108825 | " END" |
| 108702 | | - " FROM pragma_quick_check(\"%w\",\"%w\")" |
| 108826 | + " FROM pragma_quick_check(%Q,%Q)" |
| 108703 | 108827 | " WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'", |
| 108704 | 108828 | zTab, zDb |
| 108705 | 108829 | ); |
| 108706 | 108830 | } |
| 108707 | 108831 | } |
| | @@ -108982,11 +109106,13 @@ |
| 108982 | 109106 | ** |
| 108983 | 109107 | ** Technically, as x no longer points into a valid object or to the byte |
| 108984 | 109108 | ** following a valid object, it may not be used in comparison operations. |
| 108985 | 109109 | */ |
| 108986 | 109110 | static void renameTokenCheckAll(Parse *pParse, const void *pPtr){ |
| 108987 | | - if( pParse->nErr==0 && pParse->db->mallocFailed==0 ){ |
| 109111 | + assert( pParse==pParse->db->pParse ); |
| 109112 | + assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 ); |
| 109113 | + if( pParse->nErr==0 ){ |
| 108988 | 109114 | const RenameToken *p; |
| 108989 | 109115 | u8 i = 0; |
| 108990 | 109116 | for(p=pParse->pRename; p; p=p->pNext){ |
| 108991 | 109117 | if( p->p ){ |
| 108992 | 109118 | assert( p->p!=pPtr ); |
| | @@ -109379,11 +109505,11 @@ |
| 109379 | 109505 | db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb); |
| 109380 | 109506 | |
| 109381 | 109507 | /* Parse the SQL statement passed as the first argument. If no error |
| 109382 | 109508 | ** occurs and the parse does not result in a new table, index or |
| 109383 | 109509 | ** trigger object, the database must be corrupt. */ |
| 109384 | | - memset(p, 0, sizeof(Parse)); |
| 109510 | + sqlite3ParseObjectInit(p, db); |
| 109385 | 109511 | p->eParseMode = PARSE_MODE_RENAME; |
| 109386 | 109512 | p->db = db; |
| 109387 | 109513 | p->nQueryLoop = 1; |
| 109388 | 109514 | rc = zSql ? sqlite3RunParser(p, zSql) : SQLITE_NOMEM; |
| 109389 | 109515 | if( db->mallocFailed ) rc = SQLITE_NOMEM; |
| | @@ -109664,11 +109790,11 @@ |
| 109664 | 109790 | sqlite3FreeIndex(db, pIdx); |
| 109665 | 109791 | } |
| 109666 | 109792 | sqlite3DeleteTrigger(db, pParse->pNewTrigger); |
| 109667 | 109793 | sqlite3DbFree(db, pParse->zErrMsg); |
| 109668 | 109794 | renameTokenFree(db, pParse->pRename); |
| 109669 | | - sqlite3ParserReset(pParse); |
| 109795 | + sqlite3ParseObjectReset(pParse); |
| 109670 | 109796 | } |
| 109671 | 109797 | |
| 109672 | 109798 | /* |
| 109673 | 109799 | ** SQL function: |
| 109674 | 109800 | ** |
| | @@ -110378,10 +110504,16 @@ |
| 110378 | 110504 | |
| 110379 | 110505 | /* Edit the sqlite_schema table */ |
| 110380 | 110506 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 110381 | 110507 | assert( iDb>=0 ); |
| 110382 | 110508 | zDb = db->aDb[iDb].zDbSName; |
| 110509 | +#ifndef SQLITE_OMIT_AUTHORIZATION |
| 110510 | + /* Invoke the authorization callback. */ |
| 110511 | + if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, zCol) ){ |
| 110512 | + goto exit_drop_column; |
| 110513 | + } |
| 110514 | +#endif |
| 110383 | 110515 | renameTestSchema(pParse, zDb, iDb==1, "", 0); |
| 110384 | 110516 | renameFixQuotes(pParse, zDb, iDb==1); |
| 110385 | 110517 | sqlite3NestedParse(pParse, |
| 110386 | 110518 | "UPDATE \"%w\"." LEGACY_SCHEMA_TABLE " SET " |
| 110387 | 110519 | "sql = sqlite_drop_column(%d, sql, %d) " |
| | @@ -112765,11 +112897,11 @@ |
| 112765 | 112897 | ){ |
| 112766 | 112898 | goto attach_end; |
| 112767 | 112899 | } |
| 112768 | 112900 | |
| 112769 | 112901 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 112770 | | - if( pAuthArg ){ |
| 112902 | + if( ALWAYS(pAuthArg) ){ |
| 112771 | 112903 | char *zAuthArg; |
| 112772 | 112904 | if( pAuthArg->op==TK_STRING ){ |
| 112773 | 112905 | assert( !ExprHasProperty(pAuthArg, EP_IntValue) ); |
| 112774 | 112906 | zAuthArg = pAuthArg->u.zToken; |
| 112775 | 112907 | }else{ |
| | @@ -113426,15 +113558,17 @@ |
| 113426 | 113558 | sqlite3 *db; |
| 113427 | 113559 | Vdbe *v; |
| 113428 | 113560 | |
| 113429 | 113561 | assert( pParse->pToplevel==0 ); |
| 113430 | 113562 | db = pParse->db; |
| 113563 | + assert( db->pParse==pParse ); |
| 113431 | 113564 | if( pParse->nested ) return; |
| 113432 | | - if( db->mallocFailed || pParse->nErr ){ |
| 113433 | | - if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR; |
| 113565 | + if( pParse->nErr ){ |
| 113566 | + if( db->mallocFailed ) pParse->rc = SQLITE_NOMEM; |
| 113434 | 113567 | return; |
| 113435 | 113568 | } |
| 113569 | + assert( db->mallocFailed==0 ); |
| 113436 | 113570 | |
| 113437 | 113571 | /* Begin by generating some termination code at the end of the |
| 113438 | 113572 | ** vdbe program |
| 113439 | 113573 | */ |
| 113440 | 113574 | v = pParse->pVdbe; |
| | @@ -113563,11 +113697,13 @@ |
| 113563 | 113697 | } |
| 113564 | 113698 | } |
| 113565 | 113699 | |
| 113566 | 113700 | /* Get the VDBE program ready for execution |
| 113567 | 113701 | */ |
| 113568 | | - if( v && pParse->nErr==0 && !db->mallocFailed ){ |
| 113702 | + assert( v!=0 || pParse->nErr ); |
| 113703 | + assert( db->mallocFailed==0 || pParse->nErr ); |
| 113704 | + if( pParse->nErr==0 ){ |
| 113569 | 113705 | /* A minimum of one cursor is required if autoincrement is used |
| 113570 | 113706 | * See ticket [a696379c1f08866] */ |
| 113571 | 113707 | assert( pParse->pAinc==0 || pParse->nTab>0 ); |
| 113572 | 113708 | sqlite3VdbeMakeReady(v, pParse); |
| 113573 | 113709 | pParse->rc = SQLITE_DONE; |
| | @@ -115667,14 +115803,15 @@ |
| 115667 | 115803 | pList->a[0].sortFlags = pParse->iPkSortOrder; |
| 115668 | 115804 | assert( pParse->pNewTable==pTab ); |
| 115669 | 115805 | pTab->iPKey = -1; |
| 115670 | 115806 | sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0, |
| 115671 | 115807 | SQLITE_IDXTYPE_PRIMARYKEY); |
| 115672 | | - if( db->mallocFailed || pParse->nErr ){ |
| 115808 | + if( pParse->nErr ){ |
| 115673 | 115809 | pTab->tabFlags &= ~TF_WithoutRowid; |
| 115674 | 115810 | return; |
| 115675 | 115811 | } |
| 115812 | + assert( db->mallocFailed==0 ); |
| 115676 | 115813 | pPk = sqlite3PrimaryKeyIndex(pTab); |
| 115677 | 115814 | assert( pPk->nKeyCol==1 ); |
| 115678 | 115815 | }else{ |
| 115679 | 115816 | pPk = sqlite3PrimaryKeyIndex(pTab); |
| 115680 | 115817 | assert( pPk!=0 ); |
| | @@ -116411,14 +116548,14 @@ |
| 116411 | 116548 | ** normally holds CHECK constraints on an ordinary table, but for |
| 116412 | 116549 | ** a VIEW it holds the list of column names. |
| 116413 | 116550 | */ |
| 116414 | 116551 | sqlite3ColumnsFromExprList(pParse, pTable->pCheck, |
| 116415 | 116552 | &pTable->nCol, &pTable->aCol); |
| 116416 | | - if( db->mallocFailed==0 |
| 116417 | | - && pParse->nErr==0 |
| 116553 | + if( pParse->nErr==0 |
| 116418 | 116554 | && pTable->nCol==pSel->pEList->nExpr |
| 116419 | 116555 | ){ |
| 116556 | + assert( db->mallocFailed==0 ); |
| 116420 | 116557 | sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel, |
| 116421 | 116558 | SQLITE_AFF_NONE); |
| 116422 | 116559 | } |
| 116423 | 116560 | }else{ |
| 116424 | 116561 | /* CREATE VIEW name AS... without an argument list. Construct |
| | @@ -117033,11 +117170,11 @@ |
| 117033 | 117170 | tnum = (Pgno)memRootPage; |
| 117034 | 117171 | }else{ |
| 117035 | 117172 | tnum = pIndex->tnum; |
| 117036 | 117173 | } |
| 117037 | 117174 | pKey = sqlite3KeyInfoOfIndex(pParse, pIndex); |
| 117038 | | - assert( pKey!=0 || db->mallocFailed || pParse->nErr ); |
| 117175 | + assert( pKey!=0 || pParse->nErr ); |
| 117039 | 117176 | |
| 117040 | 117177 | /* Open the sorter cursor if we are to use one. */ |
| 117041 | 117178 | iSorter = pParse->nTab++; |
| 117042 | 117179 | sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, pIndex->nKeyCol, (char*) |
| 117043 | 117180 | sqlite3KeyInfoRef(pKey), P4_KEYINFO); |
| | @@ -117197,13 +117334,15 @@ |
| 117197 | 117334 | int nExtra = 0; /* Space allocated for zExtra[] */ |
| 117198 | 117335 | int nExtraCol; /* Number of extra columns needed */ |
| 117199 | 117336 | char *zExtra = 0; /* Extra space after the Index object */ |
| 117200 | 117337 | Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */ |
| 117201 | 117338 | |
| 117202 | | - if( db->mallocFailed || pParse->nErr>0 ){ |
| 117339 | + assert( db->pParse==pParse ); |
| 117340 | + if( pParse->nErr ){ |
| 117203 | 117341 | goto exit_create_index; |
| 117204 | 117342 | } |
| 117343 | + assert( db->mallocFailed==0 ); |
| 117205 | 117344 | if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){ |
| 117206 | 117345 | goto exit_create_index; |
| 117207 | 117346 | } |
| 117208 | 117347 | if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ |
| 117209 | 117348 | goto exit_create_index; |
| | @@ -117263,11 +117402,10 @@ |
| 117263 | 117402 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 117264 | 117403 | } |
| 117265 | 117404 | pDb = &db->aDb[iDb]; |
| 117266 | 117405 | |
| 117267 | 117406 | assert( pTab!=0 ); |
| 117268 | | - assert( pParse->nErr==0 ); |
| 117269 | 117407 | if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 |
| 117270 | 117408 | && db->init.busy==0 |
| 117271 | 117409 | && pTblName!=0 |
| 117272 | 117410 | #if SQLITE_USER_AUTHENTICATION |
| 117273 | 117411 | && sqlite3UserAuthTable(pTab->zName)==0 |
| | @@ -117827,14 +117965,14 @@ |
| 117827 | 117965 | Index *pIndex; |
| 117828 | 117966 | Vdbe *v; |
| 117829 | 117967 | sqlite3 *db = pParse->db; |
| 117830 | 117968 | int iDb; |
| 117831 | 117969 | |
| 117832 | | - assert( pParse->nErr==0 ); /* Never called with prior errors */ |
| 117833 | 117970 | if( db->mallocFailed ){ |
| 117834 | 117971 | goto exit_drop_index; |
| 117835 | 117972 | } |
| 117973 | + assert( pParse->nErr==0 ); /* Never called with prior non-OOM errors */ |
| 117836 | 117974 | assert( pName->nSrc==1 ); |
| 117837 | 117975 | if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ |
| 117838 | 117976 | goto exit_drop_index; |
| 117839 | 117977 | } |
| 117840 | 117978 | pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase); |
| | @@ -119746,13 +119884,15 @@ |
| 119746 | 119884 | Trigger *pTrigger; /* List of table triggers, if required */ |
| 119747 | 119885 | #endif |
| 119748 | 119886 | |
| 119749 | 119887 | memset(&sContext, 0, sizeof(sContext)); |
| 119750 | 119888 | db = pParse->db; |
| 119751 | | - if( pParse->nErr || db->mallocFailed ){ |
| 119889 | + assert( db->pParse==pParse ); |
| 119890 | + if( pParse->nErr ){ |
| 119752 | 119891 | goto delete_from_cleanup; |
| 119753 | 119892 | } |
| 119893 | + assert( db->mallocFailed==0 ); |
| 119754 | 119894 | assert( pTabList->nSrc==1 ); |
| 119755 | 119895 | |
| 119756 | 119896 | |
| 119757 | 119897 | /* Locate the table which we want to delete. This table has to be |
| 119758 | 119898 | ** put in an SrcList structure because some of the subroutines we |
| | @@ -125014,13 +125154,15 @@ |
| 125014 | 125154 | Trigger *pTrigger; /* List of triggers on pTab, if required */ |
| 125015 | 125155 | int tmask; /* Mask of trigger times */ |
| 125016 | 125156 | #endif |
| 125017 | 125157 | |
| 125018 | 125158 | db = pParse->db; |
| 125019 | | - if( pParse->nErr || db->mallocFailed ){ |
| 125159 | + assert( db->pParse==pParse ); |
| 125160 | + if( pParse->nErr ){ |
| 125020 | 125161 | goto insert_cleanup; |
| 125021 | 125162 | } |
| 125163 | + assert( db->mallocFailed==0 ); |
| 125022 | 125164 | dest.iSDParm = 0; /* Suppress a harmless compiler warning */ |
| 125023 | 125165 | |
| 125024 | 125166 | /* If the Select object is really just a simple VALUES() list with a |
| 125025 | 125167 | ** single row (the common case) then keep that one row of values |
| 125026 | 125168 | ** and discard the other (unused) parts of the pSelect object |
| | @@ -125192,11 +125334,13 @@ |
| 125192 | 125334 | sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield); |
| 125193 | 125335 | dest.iSdst = bIdListInOrder ? regData : 0; |
| 125194 | 125336 | dest.nSdst = pTab->nCol; |
| 125195 | 125337 | rc = sqlite3Select(pParse, pSelect, &dest); |
| 125196 | 125338 | regFromSelect = dest.iSdst; |
| 125197 | | - if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup; |
| 125339 | + assert( db->pParse==pParse ); |
| 125340 | + if( rc || pParse->nErr ) goto insert_cleanup; |
| 125341 | + assert( db->mallocFailed==0 ); |
| 125198 | 125342 | sqlite3VdbeEndCoroutine(v, regYield); |
| 125199 | 125343 | sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */ |
| 125200 | 125344 | assert( pSelect->pEList ); |
| 125201 | 125345 | nColumn = pSelect->pEList->nExpr; |
| 125202 | 125346 | |
| | @@ -127937,10 +128081,12 @@ |
| 127937 | 128081 | int (*autovacuum_pages)(sqlite3*, |
| 127938 | 128082 | unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int), |
| 127939 | 128083 | void*, void(*)(void*)); |
| 127940 | 128084 | /* Version 3.38.0 and later */ |
| 127941 | 128085 | int (*error_offset)(sqlite3*); |
| 128086 | + int (*vtab_rhs_value)(sqlite3_index_info*,int,sqlite3_value**); |
| 128087 | + int (*vtab_distinct)(sqlite3_index_info*); |
| 127942 | 128088 | }; |
| 127943 | 128089 | |
| 127944 | 128090 | /* |
| 127945 | 128091 | ** This is the function signature used for all extension entry points. It |
| 127946 | 128092 | ** is also defined in the file "loadext.c". |
| | @@ -128250,10 +128396,12 @@ |
| 128250 | 128396 | #define sqlite3_total_changes64 sqlite3_api->total_changes64 |
| 128251 | 128397 | /* Version 3.37.0 and later */ |
| 128252 | 128398 | #define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages |
| 128253 | 128399 | /* Version 3.38.0 and later */ |
| 128254 | 128400 | #define sqlite3_error_offset sqlite3_api->error_offset |
| 128401 | +#define sqlite3_vtab_rhs_value sqlite3_api->vtab_rhs_value |
| 128402 | +#define sqlite3_vtab_distinct sqlite3_api->vtab_distinct |
| 128255 | 128403 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ |
| 128256 | 128404 | |
| 128257 | 128405 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 128258 | 128406 | /* This case when the file really is being compiled as a loadable |
| 128259 | 128407 | ** extension */ |
| | @@ -128741,10 +128889,12 @@ |
| 128741 | 128889 | sqlite3_total_changes64, |
| 128742 | 128890 | /* Version 3.37.0 and later */ |
| 128743 | 128891 | sqlite3_autovacuum_pages, |
| 128744 | 128892 | /* Version 3.38.0 and later */ |
| 128745 | 128893 | sqlite3_error_offset, |
| 128894 | + sqlite3_vtab_rhs_value, |
| 128895 | + sqlite3_vtab_distinct, |
| 128746 | 128896 | }; |
| 128747 | 128897 | |
| 128748 | 128898 | /* True if x is the directory separator character |
| 128749 | 128899 | */ |
| 128750 | 128900 | #if SQLITE_OS_WIN |
| | @@ -131042,10 +131192,14 @@ |
| 131042 | 131192 | sqlite3_stmt *pDummy = 0; |
| 131043 | 131193 | (void)sqlite3_prepare(db, zSql, -1, &pDummy, 0); |
| 131044 | 131194 | (void)sqlite3_finalize(pDummy); |
| 131045 | 131195 | sqlite3DbFree(db, zSql); |
| 131046 | 131196 | } |
| 131197 | + if( db->mallocFailed ){ |
| 131198 | + sqlite3ErrorMsg(db->pParse, "out of memory"); |
| 131199 | + db->pParse->rc = SQLITE_NOMEM_BKPT; |
| 131200 | + } |
| 131047 | 131201 | pHash = &db->aDb[ii].pSchema->tblHash; |
| 131048 | 131202 | break; |
| 131049 | 131203 | } |
| 131050 | 131204 | } |
| 131051 | 131205 | } |
| | @@ -133078,12 +133232,14 @@ |
| 133078 | 133232 | } |
| 133079 | 133233 | |
| 133080 | 133234 | /* |
| 133081 | 133235 | ** Free all memory allocations in the pParse object |
| 133082 | 133236 | */ |
| 133083 | | -SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){ |
| 133237 | +SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse *pParse){ |
| 133084 | 133238 | sqlite3 *db = pParse->db; |
| 133239 | + assert( db!=0 ); |
| 133240 | + assert( db->pParse==pParse ); |
| 133085 | 133241 | assert( pParse->nested==0 ); |
| 133086 | 133242 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 133087 | 133243 | sqlite3DbFree(db, pParse->aTableLock); |
| 133088 | 133244 | #endif |
| 133089 | 133245 | while( pParse->pCleanup ){ |
| | @@ -133094,15 +133250,16 @@ |
| 133094 | 133250 | } |
| 133095 | 133251 | sqlite3DbFree(db, pParse->aLabel); |
| 133096 | 133252 | if( pParse->pConstExpr ){ |
| 133097 | 133253 | sqlite3ExprListDelete(db, pParse->pConstExpr); |
| 133098 | 133254 | } |
| 133099 | | - if( db ){ |
| 133100 | | - assert( db->lookaside.bDisable >= pParse->disableLookaside ); |
| 133101 | | - db->lookaside.bDisable -= pParse->disableLookaside; |
| 133102 | | - db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue; |
| 133103 | | - } |
| 133255 | + assert( db->lookaside.bDisable >= pParse->disableLookaside ); |
| 133256 | + db->lookaside.bDisable -= pParse->disableLookaside; |
| 133257 | + db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue; |
| 133258 | + assert( pParse->db->pParse==pParse ); |
| 133259 | + db->pParse = pParse->pOuterParse; |
| 133260 | + pParse->db = 0; |
| 133104 | 133261 | pParse->disableLookaside = 0; |
| 133105 | 133262 | } |
| 133106 | 133263 | |
| 133107 | 133264 | /* |
| 133108 | 133265 | ** Add a new cleanup operation to a Parser. The cleanup should happen when |
| | @@ -133111,11 +133268,11 @@ |
| 133111 | 133268 | ** |
| 133112 | 133269 | ** Use this mechanism for uncommon cleanups. There is a higher setup |
| 133113 | 133270 | ** cost for this mechansim (an extra malloc), so it should not be used |
| 133114 | 133271 | ** for common cleanups that happen on most calls. But for less |
| 133115 | 133272 | ** common cleanups, we save a single NULL-pointer comparison in |
| 133116 | | -** sqlite3ParserReset(), which reduces the total CPU cycle count. |
| 133273 | +** sqlite3ParseObjectReset(), which reduces the total CPU cycle count. |
| 133117 | 133274 | ** |
| 133118 | 133275 | ** If a memory allocation error occurs, then the cleanup happens immediately. |
| 133119 | 133276 | ** When either SQLITE_DEBUG or SQLITE_COVERAGE_TEST are defined, the |
| 133120 | 133277 | ** pParse->earlyCleanup flag is set in that case. Calling code show verify |
| 133121 | 133278 | ** that test cases exist for which this happens, to guard against possible |
| | @@ -133150,10 +133307,28 @@ |
| 133150 | 133307 | pParse->earlyCleanup = 1; |
| 133151 | 133308 | #endif |
| 133152 | 133309 | } |
| 133153 | 133310 | return pPtr; |
| 133154 | 133311 | } |
| 133312 | + |
| 133313 | +/* |
| 133314 | +** Turn bulk memory into a valid Parse object and link that Parse object |
| 133315 | +** into database connection db. |
| 133316 | +** |
| 133317 | +** Call sqlite3ParseObjectReset() to undo this operation. |
| 133318 | +** |
| 133319 | +** Caution: Do not confuse this routine with sqlite3ParseObjectInit() which |
| 133320 | +** is generated by Lemon. |
| 133321 | +*/ |
| 133322 | +SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse *pParse, sqlite3 *db){ |
| 133323 | + memset(PARSE_HDR(pParse), 0, PARSE_HDR_SZ); |
| 133324 | + memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ); |
| 133325 | + assert( db->pParse!=pParse ); |
| 133326 | + pParse->pOuterParse = db->pParse; |
| 133327 | + db->pParse = pParse; |
| 133328 | + pParse->db = db; |
| 133329 | +} |
| 133155 | 133330 | |
| 133156 | 133331 | /* |
| 133157 | 133332 | ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. |
| 133158 | 133333 | */ |
| 133159 | 133334 | static int sqlite3Prepare( |
| | @@ -133167,12 +133342,16 @@ |
| 133167 | 133342 | ){ |
| 133168 | 133343 | int rc = SQLITE_OK; /* Result code */ |
| 133169 | 133344 | int i; /* Loop counter */ |
| 133170 | 133345 | Parse sParse; /* Parsing context */ |
| 133171 | 133346 | |
| 133172 | | - memset(&sParse, 0, PARSE_HDR_SZ); |
| 133347 | + /* sqlite3ParseObjectInit(&sParse, db); // inlined for performance */ |
| 133348 | + memset(PARSE_HDR(&sParse), 0, PARSE_HDR_SZ); |
| 133173 | 133349 | memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ); |
| 133350 | + sParse.pOuterParse = db->pParse; |
| 133351 | + db->pParse = &sParse; |
| 133352 | + sParse.db = db; |
| 133174 | 133353 | sParse.pReprepare = pReprepare; |
| 133175 | 133354 | assert( ppStmt && *ppStmt==0 ); |
| 133176 | 133355 | /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */ |
| 133177 | 133356 | assert( sqlite3_mutex_held(db->mutex) ); |
| 133178 | 133357 | |
| | @@ -133224,11 +133403,10 @@ |
| 133224 | 133403 | } |
| 133225 | 133404 | } |
| 133226 | 133405 | |
| 133227 | 133406 | sqlite3VtabUnlockList(db); |
| 133228 | 133407 | |
| 133229 | | - sParse.db = db; |
| 133230 | 133408 | if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){ |
| 133231 | 133409 | char *zSqlCopy; |
| 133232 | 133410 | int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; |
| 133233 | 133411 | testcase( nBytes==mxLen ); |
| 133234 | 133412 | testcase( nBytes==mxLen+1 ); |
| | @@ -133291,11 +133469,11 @@ |
| 133291 | 133469 | sqlite3DbFree(db, pT); |
| 133292 | 133470 | } |
| 133293 | 133471 | |
| 133294 | 133472 | end_prepare: |
| 133295 | 133473 | |
| 133296 | | - sqlite3ParserReset(&sParse); |
| 133474 | + sqlite3ParseObjectReset(&sParse); |
| 133297 | 133475 | return rc; |
| 133298 | 133476 | } |
| 133299 | 133477 | static int sqlite3LockAndPrepare( |
| 133300 | 133478 | sqlite3 *db, /* Database handle. */ |
| 133301 | 133479 | const char *zSql, /* UTF-8 encoded SQL statement. */ |
| | @@ -134946,11 +135124,11 @@ |
| 134946 | 135124 | p->enc = ENC(db); |
| 134947 | 135125 | p->db = db; |
| 134948 | 135126 | p->nRef = 1; |
| 134949 | 135127 | memset(&p[1], 0, nExtra); |
| 134950 | 135128 | }else{ |
| 134951 | | - sqlite3OomFault(db); |
| 135129 | + return (KeyInfo*)sqlite3OomFault(db); |
| 134952 | 135130 | } |
| 134953 | 135131 | return p; |
| 134954 | 135132 | } |
| 134955 | 135133 | |
| 134956 | 135134 | /* |
| | @@ -135117,10 +135295,13 @@ |
| 135117 | 135295 | } |
| 135118 | 135296 | #endif |
| 135119 | 135297 | |
| 135120 | 135298 | iTab = pSort->iECursor; |
| 135121 | 135299 | if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){ |
| 135300 | + if( eDest==SRT_Mem && p->iOffset ){ |
| 135301 | + sqlite3VdbeAddOp2(v, OP_Null, 0, pDest->iSdst); |
| 135302 | + } |
| 135122 | 135303 | regRowid = 0; |
| 135123 | 135304 | regRow = pDest->iSdst; |
| 135124 | 135305 | }else{ |
| 135125 | 135306 | regRowid = sqlite3GetTempReg(pParse); |
| 135126 | 135307 | if( eDest==SRT_EphemTab || eDest==SRT_Table ){ |
| | @@ -136975,10 +137156,11 @@ |
| 136975 | 137156 | }else{ |
| 136976 | 137157 | pSplit = p; |
| 136977 | 137158 | for(i=2; i<nSelect; i+=2){ pSplit = pSplit->pPrior; } |
| 136978 | 137159 | } |
| 136979 | 137160 | pPrior = pSplit->pPrior; |
| 137161 | + assert( pPrior!=0 ); |
| 136980 | 137162 | pSplit->pPrior = 0; |
| 136981 | 137163 | pPrior->pNext = 0; |
| 136982 | 137164 | assert( p->pOrderBy == pOrderBy ); |
| 136983 | 137165 | assert( pOrderBy!=0 || db->mallocFailed ); |
| 136984 | 137166 | pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0); |
| | @@ -139126,11 +139308,12 @@ |
| 139126 | 139308 | } |
| 139127 | 139309 | } |
| 139128 | 139310 | |
| 139129 | 139311 | /* Process NATURAL keywords, and ON and USING clauses of joins. |
| 139130 | 139312 | */ |
| 139131 | | - if( pParse->nErr || db->mallocFailed || sqliteProcessJoin(pParse, p) ){ |
| 139313 | + assert( db->mallocFailed==0 || pParse->nErr!=0 ); |
| 139314 | + if( pParse->nErr || sqliteProcessJoin(pParse, p) ){ |
| 139132 | 139315 | return WRC_Abort; |
| 139133 | 139316 | } |
| 139134 | 139317 | |
| 139135 | 139318 | /* For every "*" that occurs in the column list, insert the names of |
| 139136 | 139319 | ** all columns in all tables. And for every TABLE.* insert the names |
| | @@ -139423,16 +139606,17 @@ |
| 139423 | 139606 | Parse *pParse, /* The parser context */ |
| 139424 | 139607 | Select *p, /* The SELECT statement being coded. */ |
| 139425 | 139608 | NameContext *pOuterNC /* Name context for container */ |
| 139426 | 139609 | ){ |
| 139427 | 139610 | assert( p!=0 || pParse->db->mallocFailed ); |
| 139611 | + assert( pParse->db->pParse==pParse ); |
| 139428 | 139612 | if( pParse->db->mallocFailed ) return; |
| 139429 | 139613 | if( p->selFlags & SF_HasTypeInfo ) return; |
| 139430 | 139614 | sqlite3SelectExpand(pParse, p); |
| 139431 | | - if( pParse->nErr || pParse->db->mallocFailed ) return; |
| 139615 | + if( pParse->nErr ) return; |
| 139432 | 139616 | sqlite3ResolveSelectNames(pParse, p, pOuterNC); |
| 139433 | | - if( pParse->nErr || pParse->db->mallocFailed ) return; |
| 139617 | + if( pParse->nErr ) return; |
| 139434 | 139618 | sqlite3SelectAddTypeInfo(pParse, p); |
| 139435 | 139619 | } |
| 139436 | 139620 | |
| 139437 | 139621 | /* |
| 139438 | 139622 | ** Reset the aggregate accumulator. |
| | @@ -139445,12 +139629,14 @@ |
| 139445 | 139629 | static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ |
| 139446 | 139630 | Vdbe *v = pParse->pVdbe; |
| 139447 | 139631 | int i; |
| 139448 | 139632 | struct AggInfo_func *pFunc; |
| 139449 | 139633 | int nReg = pAggInfo->nFunc + pAggInfo->nColumn; |
| 139634 | + assert( pParse->db->pParse==pParse ); |
| 139635 | + assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 ); |
| 139450 | 139636 | if( nReg==0 ) return; |
| 139451 | | - if( pParse->nErr || pParse->db->mallocFailed ) return; |
| 139637 | + if( pParse->nErr ) return; |
| 139452 | 139638 | #ifdef SQLITE_DEBUG |
| 139453 | 139639 | /* Verify that all AggInfo registers are within the range specified by |
| 139454 | 139640 | ** AggInfo.mnReg..AggInfo.mxReg */ |
| 139455 | 139641 | assert( nReg==pAggInfo->mxReg-pAggInfo->mnReg+1 ); |
| 139456 | 139642 | for(i=0; i<pAggInfo->nColumn; i++){ |
| | @@ -139869,14 +140055,16 @@ |
| 139869 | 140055 | sqlite3 *db; /* The database connection */ |
| 139870 | 140056 | ExprList *pMinMaxOrderBy = 0; /* Added ORDER BY for min/max queries */ |
| 139871 | 140057 | u8 minMaxFlag; /* Flag for min/max queries */ |
| 139872 | 140058 | |
| 139873 | 140059 | db = pParse->db; |
| 140060 | + assert( pParse==db->pParse ); |
| 139874 | 140061 | v = sqlite3GetVdbe(pParse); |
| 139875 | | - if( p==0 || db->mallocFailed || pParse->nErr ){ |
| 140062 | + if( p==0 || pParse->nErr ){ |
| 139876 | 140063 | return 1; |
| 139877 | 140064 | } |
| 140065 | + assert( db->mallocFailed==0 ); |
| 139878 | 140066 | if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1; |
| 139879 | 140067 | #if SELECTTRACE_ENABLED |
| 139880 | 140068 | SELECTTRACE(1,pParse,p, ("begin processing:\n", pParse->addrExplain)); |
| 139881 | 140069 | if( sqlite3SelectTrace & 0x100 ){ |
| 139882 | 140070 | sqlite3TreeViewSelect(0, p, 0); |
| | @@ -139907,13 +140095,14 @@ |
| 139907 | 140095 | } |
| 139908 | 140096 | p->selFlags &= ~SF_Distinct; |
| 139909 | 140097 | p->selFlags |= SF_NoopOrderBy; |
| 139910 | 140098 | } |
| 139911 | 140099 | sqlite3SelectPrep(pParse, p, 0); |
| 139912 | | - if( pParse->nErr || db->mallocFailed ){ |
| 140100 | + if( pParse->nErr ){ |
| 139913 | 140101 | goto select_end; |
| 139914 | 140102 | } |
| 140103 | + assert( db->mallocFailed==0 ); |
| 139915 | 140104 | assert( p->pEList!=0 ); |
| 139916 | 140105 | #if SELECTTRACE_ENABLED |
| 139917 | 140106 | if( sqlite3SelectTrace & 0x104 ){ |
| 139918 | 140107 | SELECTTRACE(0x104,pParse,p, ("after name resolution:\n")); |
| 139919 | 140108 | sqlite3TreeViewSelect(0, p, 0); |
| | @@ -139953,11 +140142,11 @@ |
| 139953 | 140142 | sqlite3GenerateColumnNames(pParse, p); |
| 139954 | 140143 | } |
| 139955 | 140144 | |
| 139956 | 140145 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 139957 | 140146 | if( sqlite3WindowRewrite(pParse, p) ){ |
| 139958 | | - assert( db->mallocFailed || pParse->nErr>0 ); |
| 140147 | + assert( pParse->nErr ); |
| 139959 | 140148 | goto select_end; |
| 139960 | 140149 | } |
| 139961 | 140150 | #if SELECTTRACE_ENABLED |
| 139962 | 140151 | if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){ |
| 139963 | 140152 | SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n")); |
| | @@ -141048,11 +141237,11 @@ |
| 141048 | 141237 | /* Control jumps to here if an error is encountered above, or upon |
| 141049 | 141238 | ** successful coding of the SELECT. |
| 141050 | 141239 | */ |
| 141051 | 141240 | select_end: |
| 141052 | 141241 | assert( db->mallocFailed==0 || db->mallocFailed==1 ); |
| 141053 | | - pParse->nErr += db->mallocFailed; |
| 141242 | + assert( db->mallocFailed==0 || pParse->nErr!=0 ); |
| 141054 | 141243 | sqlite3ExprListDelete(db, pMinMaxOrderBy); |
| 141055 | 141244 | #ifdef SQLITE_DEBUG |
| 141056 | 141245 | if( pAggInfo && !db->mallocFailed ){ |
| 141057 | 141246 | for(i=0; i<pAggInfo->nColumn; i++){ |
| 141058 | 141247 | Expr *pExpr = pAggInfo->aCol[i].pCExpr; |
| | @@ -142200,10 +142389,11 @@ |
| 142200 | 142389 | Select sSelect; |
| 142201 | 142390 | SrcList sFrom; |
| 142202 | 142391 | |
| 142203 | 142392 | assert( v!=0 ); |
| 142204 | 142393 | assert( pParse->bReturning ); |
| 142394 | + assert( db->pParse==pParse ); |
| 142205 | 142395 | pReturning = pParse->u1.pReturning; |
| 142206 | 142396 | assert( pTrigger == &(pReturning->retTrig) ); |
| 142207 | 142397 | memset(&sSelect, 0, sizeof(sSelect)); |
| 142208 | 142398 | memset(&sFrom, 0, sizeof(sFrom)); |
| 142209 | 142399 | sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0); |
| | @@ -142210,11 +142400,12 @@ |
| 142210 | 142400 | sSelect.pSrc = &sFrom; |
| 142211 | 142401 | sFrom.nSrc = 1; |
| 142212 | 142402 | sFrom.a[0].pTab = pTab; |
| 142213 | 142403 | sFrom.a[0].iCursor = -1; |
| 142214 | 142404 | sqlite3SelectPrep(pParse, &sSelect, 0); |
| 142215 | | - if( db->mallocFailed==0 && pParse->nErr==0 ){ |
| 142405 | + if( pParse->nErr==0 ){ |
| 142406 | + assert( db->mallocFailed==0 ); |
| 142216 | 142407 | sqlite3GenerateColumnNames(pParse, &sSelect); |
| 142217 | 142408 | } |
| 142218 | 142409 | sqlite3ExprListDelete(db, sSelect.pEList); |
| 142219 | 142410 | pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); |
| 142220 | 142411 | if( !db->mallocFailed ){ |
| | @@ -142228,11 +142419,11 @@ |
| 142228 | 142419 | sNC.uNC.iBaseReg = regIn; |
| 142229 | 142420 | sNC.ncFlags = NC_UBaseReg; |
| 142230 | 142421 | pParse->eTriggerOp = pTrigger->op; |
| 142231 | 142422 | pParse->pTriggerTab = pTab; |
| 142232 | 142423 | if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK |
| 142233 | | - && !db->mallocFailed |
| 142424 | + && ALWAYS(!db->mallocFailed) |
| 142234 | 142425 | ){ |
| 142235 | 142426 | int i; |
| 142236 | 142427 | int nCol = pNew->nExpr; |
| 142237 | 142428 | int reg = pParse->nMem+1; |
| 142238 | 142429 | pParse->nMem += nCol+2; |
| | @@ -142392,12 +142583,12 @@ |
| 142392 | 142583 | TriggerPrg *pPrg; /* Value to return */ |
| 142393 | 142584 | Expr *pWhen = 0; /* Duplicate of trigger WHEN expression */ |
| 142394 | 142585 | Vdbe *v; /* Temporary VM */ |
| 142395 | 142586 | NameContext sNC; /* Name context for sub-vdbe */ |
| 142396 | 142587 | SubProgram *pProgram = 0; /* Sub-vdbe for trigger program */ |
| 142397 | | - Parse *pSubParse; /* Parse context for sub-vdbe */ |
| 142398 | 142588 | int iEndTrigger = 0; /* Label to jump to if WHEN is false */ |
| 142589 | + Parse sSubParse; /* Parse context for sub-vdbe */ |
| 142399 | 142590 | |
| 142400 | 142591 | assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) ); |
| 142401 | 142592 | assert( pTop->pVdbe ); |
| 142402 | 142593 | |
| 142403 | 142594 | /* Allocate the TriggerPrg and SubProgram objects. To ensure that they |
| | @@ -142415,23 +142606,21 @@ |
| 142415 | 142606 | pPrg->aColmask[0] = 0xffffffff; |
| 142416 | 142607 | pPrg->aColmask[1] = 0xffffffff; |
| 142417 | 142608 | |
| 142418 | 142609 | /* Allocate and populate a new Parse context to use for coding the |
| 142419 | 142610 | ** trigger sub-program. */ |
| 142420 | | - pSubParse = sqlite3StackAllocZero(db, sizeof(Parse)); |
| 142421 | | - if( !pSubParse ) return 0; |
| 142611 | + sqlite3ParseObjectInit(&sSubParse, db); |
| 142422 | 142612 | memset(&sNC, 0, sizeof(sNC)); |
| 142423 | | - sNC.pParse = pSubParse; |
| 142424 | | - pSubParse->db = db; |
| 142425 | | - pSubParse->pTriggerTab = pTab; |
| 142426 | | - pSubParse->pToplevel = pTop; |
| 142427 | | - pSubParse->zAuthContext = pTrigger->zName; |
| 142428 | | - pSubParse->eTriggerOp = pTrigger->op; |
| 142429 | | - pSubParse->nQueryLoop = pParse->nQueryLoop; |
| 142430 | | - pSubParse->disableVtab = pParse->disableVtab; |
| 142431 | | - |
| 142432 | | - v = sqlite3GetVdbe(pSubParse); |
| 142613 | + sNC.pParse = &sSubParse; |
| 142614 | + sSubParse.pTriggerTab = pTab; |
| 142615 | + sSubParse.pToplevel = pTop; |
| 142616 | + sSubParse.zAuthContext = pTrigger->zName; |
| 142617 | + sSubParse.eTriggerOp = pTrigger->op; |
| 142618 | + sSubParse.nQueryLoop = pParse->nQueryLoop; |
| 142619 | + sSubParse.disableVtab = pParse->disableVtab; |
| 142620 | + |
| 142621 | + v = sqlite3GetVdbe(&sSubParse); |
| 142433 | 142622 | if( v ){ |
| 142434 | 142623 | VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)", |
| 142435 | 142624 | pTrigger->zName, onErrorText(orconf), |
| 142436 | 142625 | (pTrigger->tr_tm==TRIGGER_BEFORE ? "BEFORE" : "AFTER"), |
| 142437 | 142626 | (pTrigger->op==TK_UPDATE ? "UPDATE" : ""), |
| | @@ -142453,42 +142642,43 @@ |
| 142453 | 142642 | if( pTrigger->pWhen ){ |
| 142454 | 142643 | pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0); |
| 142455 | 142644 | if( db->mallocFailed==0 |
| 142456 | 142645 | && SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) |
| 142457 | 142646 | ){ |
| 142458 | | - iEndTrigger = sqlite3VdbeMakeLabel(pSubParse); |
| 142459 | | - sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL); |
| 142647 | + iEndTrigger = sqlite3VdbeMakeLabel(&sSubParse); |
| 142648 | + sqlite3ExprIfFalse(&sSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL); |
| 142460 | 142649 | } |
| 142461 | 142650 | sqlite3ExprDelete(db, pWhen); |
| 142462 | 142651 | } |
| 142463 | 142652 | |
| 142464 | 142653 | /* Code the trigger program into the sub-vdbe. */ |
| 142465 | | - codeTriggerProgram(pSubParse, pTrigger->step_list, orconf); |
| 142654 | + codeTriggerProgram(&sSubParse, pTrigger->step_list, orconf); |
| 142466 | 142655 | |
| 142467 | 142656 | /* Insert an OP_Halt at the end of the sub-program. */ |
| 142468 | 142657 | if( iEndTrigger ){ |
| 142469 | 142658 | sqlite3VdbeResolveLabel(v, iEndTrigger); |
| 142470 | 142659 | } |
| 142471 | 142660 | sqlite3VdbeAddOp0(v, OP_Halt); |
| 142472 | 142661 | VdbeComment((v, "End: %s.%s", pTrigger->zName, onErrorText(orconf))); |
| 142662 | + transferParseError(pParse, &sSubParse); |
| 142473 | 142663 | |
| 142474 | | - transferParseError(pParse, pSubParse); |
| 142475 | | - if( db->mallocFailed==0 && pParse->nErr==0 ){ |
| 142664 | + if( pParse->nErr==0 ){ |
| 142665 | + assert( db->mallocFailed==0 ); |
| 142476 | 142666 | pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg); |
| 142477 | 142667 | } |
| 142478 | | - pProgram->nMem = pSubParse->nMem; |
| 142479 | | - pProgram->nCsr = pSubParse->nTab; |
| 142668 | + pProgram->nMem = sSubParse.nMem; |
| 142669 | + pProgram->nCsr = sSubParse.nTab; |
| 142480 | 142670 | pProgram->token = (void *)pTrigger; |
| 142481 | | - pPrg->aColmask[0] = pSubParse->oldmask; |
| 142482 | | - pPrg->aColmask[1] = pSubParse->newmask; |
| 142671 | + pPrg->aColmask[0] = sSubParse.oldmask; |
| 142672 | + pPrg->aColmask[1] = sSubParse.newmask; |
| 142483 | 142673 | sqlite3VdbeDelete(v); |
| 142674 | + }else{ |
| 142675 | + transferParseError(pParse, &sSubParse); |
| 142484 | 142676 | } |
| 142485 | 142677 | |
| 142486 | | - assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg ); |
| 142487 | | - sqlite3ParserReset(pSubParse); |
| 142488 | | - sqlite3StackFree(db, pSubParse); |
| 142489 | | - |
| 142678 | + assert( !sSubParse.pTriggerPrg && !sSubParse.nMaxArg ); |
| 142679 | + sqlite3ParseObjectReset(&sSubParse); |
| 142490 | 142680 | return pPrg; |
| 142491 | 142681 | } |
| 142492 | 142682 | |
| 142493 | 142683 | /* |
| 142494 | 142684 | ** Return a pointer to a TriggerPrg object containing the sub-program for |
| | @@ -142539,11 +142729,11 @@ |
| 142539 | 142729 | int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */ |
| 142540 | 142730 | ){ |
| 142541 | 142731 | Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */ |
| 142542 | 142732 | TriggerPrg *pPrg; |
| 142543 | 142733 | pPrg = getRowTrigger(pParse, p, pTab, orconf); |
| 142544 | | - assert( pPrg || pParse->nErr || pParse->db->mallocFailed ); |
| 142734 | + assert( pPrg || pParse->nErr ); |
| 142545 | 142735 | |
| 142546 | 142736 | /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program |
| 142547 | 142737 | ** is a pointer to the sub-vdbe containing the trigger program. */ |
| 142548 | 142738 | if( pPrg ){ |
| 142549 | 142739 | int bRecursive = (p->zName && 0==(pParse->db->flags&SQLITE_RecTriggers)); |
| | @@ -143057,13 +143247,15 @@ |
| 143057 | 143247 | int regRowSet = 0; /* Rowset of rows to be updated */ |
| 143058 | 143248 | int regKey = 0; /* composite PRIMARY KEY value */ |
| 143059 | 143249 | |
| 143060 | 143250 | memset(&sContext, 0, sizeof(sContext)); |
| 143061 | 143251 | db = pParse->db; |
| 143062 | | - if( pParse->nErr || db->mallocFailed ){ |
| 143252 | + assert( db->pParse==pParse ); |
| 143253 | + if( pParse->nErr ){ |
| 143063 | 143254 | goto update_cleanup; |
| 143064 | 143255 | } |
| 143256 | + assert( db->mallocFailed==0 ); |
| 143065 | 143257 | |
| 143066 | 143258 | /* Locate the table which we want to update. |
| 143067 | 143259 | */ |
| 143068 | 143260 | pTab = sqlite3SrcListLookup(pParse, pTabList); |
| 143069 | 143261 | if( pTab==0 ) goto update_cleanup; |
| | @@ -145598,13 +145790,12 @@ |
| 145598 | 145790 | return SQLITE_MISUSE_BKPT; |
| 145599 | 145791 | } |
| 145600 | 145792 | pTab = pCtx->pTab; |
| 145601 | 145793 | assert( IsVirtual(pTab) ); |
| 145602 | 145794 | |
| 145603 | | - memset(&sParse, 0, sizeof(sParse)); |
| 145795 | + sqlite3ParseObjectInit(&sParse, db); |
| 145604 | 145796 | sParse.eParseMode = PARSE_MODE_DECLARE_VTAB; |
| 145605 | | - sParse.db = db; |
| 145606 | 145797 | /* We should never be able to reach this point while loading the |
| 145607 | 145798 | ** schema. Nevertheless, defend against that (turn off db->init.busy) |
| 145608 | 145799 | ** in case a bug arises. */ |
| 145609 | 145800 | assert( db->init.busy==0 ); |
| 145610 | 145801 | initBusy = db->init.busy; |
| | @@ -145654,11 +145845,11 @@ |
| 145654 | 145845 | |
| 145655 | 145846 | if( sParse.pVdbe ){ |
| 145656 | 145847 | sqlite3VdbeFinalize(sParse.pVdbe); |
| 145657 | 145848 | } |
| 145658 | 145849 | sqlite3DeleteTable(db, sParse.pNewTable); |
| 145659 | | - sqlite3ParserReset(&sParse); |
| 145850 | + sqlite3ParseObjectReset(&sParse); |
| 145660 | 145851 | db->init.busy = initBusy; |
| 145661 | 145852 | |
| 145662 | 145853 | assert( (rc&0xff)==rc ); |
| 145663 | 145854 | rc = sqlite3ApiExit(db, rc); |
| 145664 | 145855 | sqlite3_mutex_leave(db->mutex); |
| | @@ -146528,11 +146719,10 @@ |
| 146528 | 146719 | ** to construct WhereLoop objects for a particular query. |
| 146529 | 146720 | */ |
| 146530 | 146721 | struct WhereLoopBuilder { |
| 146531 | 146722 | WhereInfo *pWInfo; /* Information about this WHERE */ |
| 146532 | 146723 | WhereClause *pWC; /* WHERE clause terms */ |
| 146533 | | - ExprList *pOrderBy; /* ORDER BY clause */ |
| 146534 | 146724 | WhereLoop *pNew; /* Template WhereLoop */ |
| 146535 | 146725 | WhereOrSet *pOrSet; /* Record best loops here, if not NULL */ |
| 146536 | 146726 | #ifdef SQLITE_ENABLE_STAT4 |
| 146537 | 146727 | UnpackedRecord *pRec; /* Probe for stat4 (if required) */ |
| 146538 | 146728 | int nRecValid; /* Number of valid fields currently in pRec */ |
| | @@ -147561,10 +147751,13 @@ |
| 147561 | 147751 | regBase = r1; |
| 147562 | 147752 | }else{ |
| 147563 | 147753 | sqlite3VdbeAddOp2(v, OP_Copy, r1, regBase+j); |
| 147564 | 147754 | } |
| 147565 | 147755 | } |
| 147756 | + } |
| 147757 | + for(j=nSkip; j<nEq; j++){ |
| 147758 | + pTerm = pLoop->aLTerm[j]; |
| 147566 | 147759 | if( pTerm->eOperator & WO_IN ){ |
| 147567 | 147760 | if( pTerm->pExpr->flags & EP_xIsSelect ){ |
| 147568 | 147761 | /* No affinity ever needs to be (or should be) applied to a value |
| 147569 | 147762 | ** from the RHS of an "? IN (SELECT ...)" expression. The |
| 147570 | 147763 | ** sqlite3FindInIndex() routine has already ensured that the |
| | @@ -147575,11 +147768,12 @@ |
| 147575 | 147768 | Expr *pRight = pTerm->pExpr->pRight; |
| 147576 | 147769 | if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){ |
| 147577 | 147770 | sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk); |
| 147578 | 147771 | VdbeCoverage(v); |
| 147579 | 147772 | } |
| 147580 | | - if( pParse->db->mallocFailed==0 && pParse->nErr==0 ){ |
| 147773 | + if( pParse->nErr==0 ){ |
| 147774 | + assert( pParse->db->mallocFailed==0 ); |
| 147581 | 147775 | if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){ |
| 147582 | 147776 | zAff[j] = SQLITE_AFF_BLOB; |
| 147583 | 147777 | } |
| 147584 | 147778 | if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){ |
| 147585 | 147779 | zAff[j] = SQLITE_AFF_BLOB; |
| | @@ -149093,11 +149287,11 @@ |
| 149093 | 149287 | /* Loop through table entries that match term pOrTerm. */ |
| 149094 | 149288 | ExplainQueryPlan((pParse, 1, "INDEX %d", ii+1)); |
| 149095 | 149289 | WHERETRACE(0xffff, ("Subplan for OR-clause:\n")); |
| 149096 | 149290 | pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, |
| 149097 | 149291 | WHERE_OR_SUBCLAUSE, iCovCur); |
| 149098 | | - assert( pSubWInfo || pParse->nErr || db->mallocFailed ); |
| 149292 | + assert( pSubWInfo || pParse->nErr ); |
| 149099 | 149293 | if( pSubWInfo ){ |
| 149100 | 149294 | WhereLoop *pSubLoop; |
| 149101 | 149295 | int addrExplain = sqlite3WhereExplainOneScan( |
| 149102 | 149296 | pParse, pOrTab, &pSubWInfo->a[0], 0 |
| 149103 | 149297 | ); |
| | @@ -151167,12 +151361,16 @@ |
| 151167 | 151361 | ** next. As long as allocateIndexInfo() and sqlite3_vtab_collation() |
| 151168 | 151362 | ** agree on the structure, all will be well. |
| 151169 | 151363 | */ |
| 151170 | 151364 | typedef struct HiddenIndexInfo HiddenIndexInfo; |
| 151171 | 151365 | struct HiddenIndexInfo { |
| 151172 | | - WhereClause *pWC; /* The Where clause being analyzed */ |
| 151173 | | - Parse *pParse; /* The parsing context */ |
| 151366 | + WhereClause *pWC; /* The Where clause being analyzed */ |
| 151367 | + Parse *pParse; /* The parsing context */ |
| 151368 | + int eDistinct; /* Value to return from sqlite3_vtab_distinct() */ |
| 151369 | + sqlite3_value *aRhs[1]; /* RHS values for constraints. MUST BE LAST |
| 151370 | + ** because extra space is allocated to hold up |
| 151371 | + ** to nTerm such values */ |
| 151174 | 151372 | }; |
| 151175 | 151373 | |
| 151176 | 151374 | /* Forward declaration of methods */ |
| 151177 | 151375 | static int whereLoopResize(sqlite3*, WhereLoop*, int); |
| 151178 | 151376 | |
| | @@ -152232,31 +152430,33 @@ |
| 152232 | 152430 | |
| 152233 | 152431 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 152234 | 152432 | /* |
| 152235 | 152433 | ** Allocate and populate an sqlite3_index_info structure. It is the |
| 152236 | 152434 | ** responsibility of the caller to eventually release the structure |
| 152237 | | -** by passing the pointer returned by this function to sqlite3_free(). |
| 152435 | +** by passing the pointer returned by this function to freeIndexInfo(). |
| 152238 | 152436 | */ |
| 152239 | 152437 | static sqlite3_index_info *allocateIndexInfo( |
| 152240 | | - Parse *pParse, /* The parsing context */ |
| 152438 | + WhereInfo *pWInfo, /* The WHERE clause */ |
| 152241 | 152439 | WhereClause *pWC, /* The WHERE clause being analyzed */ |
| 152242 | 152440 | Bitmask mUnusable, /* Ignore terms with these prereqs */ |
| 152243 | 152441 | SrcItem *pSrc, /* The FROM clause term that is the vtab */ |
| 152244 | | - ExprList *pOrderBy, /* The ORDER BY clause */ |
| 152245 | 152442 | u16 *pmNoOmit /* Mask of terms not to omit */ |
| 152246 | 152443 | ){ |
| 152247 | 152444 | int i, j; |
| 152248 | 152445 | int nTerm; |
| 152446 | + Parse *pParse = pWInfo->pParse; |
| 152249 | 152447 | struct sqlite3_index_constraint *pIdxCons; |
| 152250 | 152448 | struct sqlite3_index_orderby *pIdxOrderBy; |
| 152251 | 152449 | struct sqlite3_index_constraint_usage *pUsage; |
| 152252 | 152450 | struct HiddenIndexInfo *pHidden; |
| 152253 | 152451 | WhereTerm *pTerm; |
| 152254 | 152452 | int nOrderBy; |
| 152255 | 152453 | sqlite3_index_info *pIdxInfo; |
| 152256 | 152454 | u16 mNoOmit = 0; |
| 152257 | 152455 | const Table *pTab; |
| 152456 | + int eDistinct = 0; |
| 152457 | + ExprList *pOrderBy = pWInfo->pOrderBy; |
| 152258 | 152458 | |
| 152259 | 152459 | assert( pSrc!=0 ); |
| 152260 | 152460 | pTab = pSrc->pTab; |
| 152261 | 152461 | assert( pTab!=0 ); |
| 152262 | 152462 | assert( IsVirtual(pTab) ); |
| | @@ -152337,31 +152537,36 @@ |
| 152337 | 152537 | /* No matches cause a break out of the loop */ |
| 152338 | 152538 | break; |
| 152339 | 152539 | } |
| 152340 | 152540 | if( i==n){ |
| 152341 | 152541 | nOrderBy = n; |
| 152542 | + if( (pWInfo->wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY)) ){ |
| 152543 | + eDistinct = 1 + ((pWInfo->wctrlFlags & WHERE_DISTINCTBY)!=0); |
| 152544 | + } |
| 152342 | 152545 | } |
| 152343 | 152546 | } |
| 152344 | 152547 | |
| 152345 | 152548 | /* Allocate the sqlite3_index_info structure |
| 152346 | 152549 | */ |
| 152347 | 152550 | pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo) |
| 152348 | 152551 | + (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm |
| 152349 | | - + sizeof(*pIdxOrderBy)*nOrderBy + sizeof(*pHidden) ); |
| 152552 | + + sizeof(*pIdxOrderBy)*nOrderBy + sizeof(*pHidden) |
| 152553 | + + sizeof(sqlite3_value*)*nTerm ); |
| 152350 | 152554 | if( pIdxInfo==0 ){ |
| 152351 | 152555 | sqlite3ErrorMsg(pParse, "out of memory"); |
| 152352 | 152556 | return 0; |
| 152353 | 152557 | } |
| 152354 | 152558 | pHidden = (struct HiddenIndexInfo*)&pIdxInfo[1]; |
| 152355 | | - pIdxCons = (struct sqlite3_index_constraint*)&pHidden[1]; |
| 152559 | + pIdxCons = (struct sqlite3_index_constraint*)&pHidden->aRhs[nTerm]; |
| 152356 | 152560 | pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm]; |
| 152357 | 152561 | pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy]; |
| 152358 | 152562 | pIdxInfo->aConstraint = pIdxCons; |
| 152359 | 152563 | pIdxInfo->aOrderBy = pIdxOrderBy; |
| 152360 | 152564 | pIdxInfo->aConstraintUsage = pUsage; |
| 152361 | 152565 | pHidden->pWC = pWC; |
| 152362 | 152566 | pHidden->pParse = pParse; |
| 152567 | + pHidden->eDistinct = eDistinct; |
| 152363 | 152568 | for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){ |
| 152364 | 152569 | u16 op; |
| 152365 | 152570 | if( (pTerm->wtFlags & TERM_OK)==0 ) continue; |
| 152366 | 152571 | pIdxCons[j].iColumn = pTerm->u.x.leftColumn; |
| 152367 | 152572 | pIdxCons[j].iTermOffset = i; |
| | @@ -152414,10 +152619,28 @@ |
| 152414 | 152619 | pIdxInfo->nOrderBy = j; |
| 152415 | 152620 | |
| 152416 | 152621 | *pmNoOmit = mNoOmit; |
| 152417 | 152622 | return pIdxInfo; |
| 152418 | 152623 | } |
| 152624 | + |
| 152625 | +/* |
| 152626 | +** Free an sqlite3_index_info structure allocated by allocateIndexInfo() |
| 152627 | +** and possibly modified by xBestIndex methods. |
| 152628 | +*/ |
| 152629 | +static void freeIndexInfo(sqlite3 *db, sqlite3_index_info *pIdxInfo){ |
| 152630 | + HiddenIndexInfo *pHidden; |
| 152631 | + int i; |
| 152632 | + assert( pIdxInfo!=0 ); |
| 152633 | + pHidden = (HiddenIndexInfo*)&pIdxInfo[1]; |
| 152634 | + assert( pHidden->pParse!=0 ); |
| 152635 | + assert( pHidden->pParse->db==db ); |
| 152636 | + for(i=0; i<pIdxInfo->nConstraint; i++){ |
| 152637 | + sqlite3ValueFree(pHidden->aRhs[i]); /* IMP: R-14553-25174 */ |
| 152638 | + pHidden->aRhs[i] = 0; |
| 152639 | + } |
| 152640 | + sqlite3DbFree(db, pIdxInfo); |
| 152641 | +} |
| 152419 | 152642 | |
| 152420 | 152643 | /* |
| 152421 | 152644 | ** The table object reference passed as the second argument to this function |
| 152422 | 152645 | ** must represent a virtual table. This function invokes the xBestIndex() |
| 152423 | 152646 | ** method of the virtual table with the sqlite3_index_info object that |
| | @@ -154769,10 +154992,58 @@ |
| 154769 | 154992 | } |
| 154770 | 154993 | zRet = (pC ? pC->zName : sqlite3StrBINARY); |
| 154771 | 154994 | } |
| 154772 | 154995 | return zRet; |
| 154773 | 154996 | } |
| 154997 | + |
| 154998 | +/* |
| 154999 | +** This interface is callable from within the xBestIndex callback only. |
| 155000 | +** |
| 155001 | +** If possible, set (*ppVal) to point to an object containing the value |
| 155002 | +** on the right-hand-side of constraint iCons. |
| 155003 | +*/ |
| 155004 | +SQLITE_API int sqlite3_vtab_rhs_value( |
| 155005 | + sqlite3_index_info *pIdxInfo, /* Copy of first argument to xBestIndex */ |
| 155006 | + int iCons, /* Constraint for which RHS is wanted */ |
| 155007 | + sqlite3_value **ppVal /* Write value extracted here */ |
| 155008 | +){ |
| 155009 | + HiddenIndexInfo *pH = (HiddenIndexInfo*)&pIdxInfo[1]; |
| 155010 | + sqlite3_value *pVal = 0; |
| 155011 | + int rc = SQLITE_OK; |
| 155012 | + if( iCons<0 || iCons>=pIdxInfo->nConstraint ){ |
| 155013 | + rc = SQLITE_MISUSE; /* EV: R-30545-25046 */ |
| 155014 | + }else{ |
| 155015 | + if( pH->aRhs[iCons]==0 ){ |
| 155016 | + WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset]; |
| 155017 | + rc = sqlite3ValueFromExpr( |
| 155018 | + pH->pParse->db, pTerm->pExpr->pRight, ENC(pH->pParse->db), |
| 155019 | + SQLITE_AFF_BLOB, &pH->aRhs[iCons] |
| 155020 | + ); |
| 155021 | + testcase( rc!=SQLITE_OK ); |
| 155022 | + } |
| 155023 | + pVal = pH->aRhs[iCons]; |
| 155024 | + } |
| 155025 | + *ppVal = pVal; |
| 155026 | + |
| 155027 | + if( rc==SQLITE_OK && pVal==0 ){ /* IMP: R-19933-32160 */ |
| 155028 | + rc = SQLITE_NOTFOUND; /* IMP: R-36424-56542 */ |
| 155029 | + } |
| 155030 | + |
| 155031 | + return rc; |
| 155032 | +} |
| 155033 | + |
| 155034 | + |
| 155035 | +/* |
| 155036 | +** Return true if ORDER BY clause may be handled as DISTINCT. |
| 155037 | +*/ |
| 155038 | +SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info *pIdxInfo){ |
| 155039 | + HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1]; |
| 155040 | + assert( pHidden->eDistinct==0 |
| 155041 | + || pHidden->eDistinct==1 |
| 155042 | + || pHidden->eDistinct==2 ); |
| 155043 | + return pHidden->eDistinct; |
| 155044 | +} |
| 154774 | 155045 | |
| 154775 | 155046 | /* |
| 154776 | 155047 | ** Add all WhereLoop objects for a table of the join identified by |
| 154777 | 155048 | ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table. |
| 154778 | 155049 | ** |
| | @@ -154819,20 +155090,19 @@ |
| 154819 | 155090 | pParse = pWInfo->pParse; |
| 154820 | 155091 | pWC = pBuilder->pWC; |
| 154821 | 155092 | pNew = pBuilder->pNew; |
| 154822 | 155093 | pSrc = &pWInfo->pTabList->a[pNew->iTab]; |
| 154823 | 155094 | assert( IsVirtual(pSrc->pTab) ); |
| 154824 | | - p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy, |
| 154825 | | - &mNoOmit); |
| 155095 | + p = allocateIndexInfo(pWInfo, pWC, mUnusable, pSrc, &mNoOmit); |
| 154826 | 155096 | if( p==0 ) return SQLITE_NOMEM_BKPT; |
| 154827 | 155097 | pNew->rSetup = 0; |
| 154828 | 155098 | pNew->wsFlags = WHERE_VIRTUALTABLE; |
| 154829 | 155099 | pNew->nLTerm = 0; |
| 154830 | 155100 | pNew->u.vtab.needFree = 0; |
| 154831 | 155101 | nConstraint = p->nConstraint; |
| 154832 | 155102 | if( whereLoopResize(pParse->db, pNew, nConstraint) ){ |
| 154833 | | - sqlite3DbFree(pParse->db, p); |
| 155103 | + freeIndexInfo(pParse->db, p); |
| 154834 | 155104 | return SQLITE_NOMEM_BKPT; |
| 154835 | 155105 | } |
| 154836 | 155106 | |
| 154837 | 155107 | /* First call xBestIndex() with all constraints usable. */ |
| 154838 | 155108 | WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName)); |
| | @@ -154908,11 +155178,11 @@ |
| 154908 | 155178 | pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn); |
| 154909 | 155179 | } |
| 154910 | 155180 | } |
| 154911 | 155181 | |
| 154912 | 155182 | if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr); |
| 154913 | | - sqlite3DbFreeNN(pParse->db, p); |
| 155183 | + freeIndexInfo(pParse->db, p); |
| 154914 | 155184 | WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pTab->zName, rc)); |
| 154915 | 155185 | return rc; |
| 154916 | 155186 | } |
| 154917 | 155187 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 154918 | 155188 | |
| | @@ -154952,11 +155222,10 @@ |
| 154952 | 155222 | WhereTerm *pOrTerm; |
| 154953 | 155223 | int once = 1; |
| 154954 | 155224 | int i, j; |
| 154955 | 155225 | |
| 154956 | 155226 | sSubBuild = *pBuilder; |
| 154957 | | - sSubBuild.pOrderBy = 0; |
| 154958 | 155227 | sSubBuild.pOrSet = &sCur; |
| 154959 | 155228 | |
| 154960 | 155229 | WHERETRACE(0x200, ("Begin processing OR-clause %p\n", pTerm)); |
| 154961 | 155230 | for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){ |
| 154962 | 155231 | if( (pOrTerm->eOperator & WO_AND)!=0 ){ |
| | @@ -156344,11 +156613,10 @@ |
| 156344 | 156613 | memset(&sWLB, 0, sizeof(sWLB)); |
| 156345 | 156614 | |
| 156346 | 156615 | /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */ |
| 156347 | 156616 | testcase( pOrderBy && pOrderBy->nExpr==BMS-1 ); |
| 156348 | 156617 | if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0; |
| 156349 | | - sWLB.pOrderBy = pOrderBy; |
| 156350 | 156618 | |
| 156351 | 156619 | /* The number of tables in the FROM clause is limited by the number of |
| 156352 | 156620 | ** bits in a Bitmask |
| 156353 | 156621 | */ |
| 156354 | 156622 | testcase( pTabList->nSrc==BMS ); |
| | @@ -156554,13 +156822,14 @@ |
| 156554 | 156822 | } |
| 156555 | 156823 | } |
| 156556 | 156824 | if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ |
| 156557 | 156825 | pWInfo->revMask = ALLBITS; |
| 156558 | 156826 | } |
| 156559 | | - if( pParse->nErr || db->mallocFailed ){ |
| 156827 | + if( pParse->nErr ){ |
| 156560 | 156828 | goto whereBeginError; |
| 156561 | 156829 | } |
| 156830 | + assert( db->mallocFailed==0 ); |
| 156562 | 156831 | #ifdef WHERETRACE_ENABLED |
| 156563 | 156832 | if( sqlite3WhereTrace ){ |
| 156564 | 156833 | sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut); |
| 156565 | 156834 | if( pWInfo->nOBSat>0 ){ |
| 156566 | 156835 | sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask); |
| | @@ -158264,16 +158533,11 @@ |
| 158264 | 158533 | ** there could still be references to that table embedded in the |
| 158265 | 158534 | ** result-set or ORDER BY clause of the SELECT statement p. */ |
| 158266 | 158535 | sqlite3ParserAddCleanup(pParse, sqlite3DbFree, pTab); |
| 158267 | 158536 | } |
| 158268 | 158537 | |
| 158269 | | - if( rc ){ |
| 158270 | | - if( pParse->nErr==0 ){ |
| 158271 | | - assert( pParse->db->mallocFailed ); |
| 158272 | | - sqlite3ErrorToParser(pParse->db, SQLITE_NOMEM); |
| 158273 | | - } |
| 158274 | | - } |
| 158538 | + assert( rc==SQLITE_OK || pParse->nErr!=0 ); |
| 158275 | 158539 | return rc; |
| 158276 | 158540 | } |
| 158277 | 158541 | |
| 158278 | 158542 | /* |
| 158279 | 158543 | ** Unlink the Window object from the Select to which it is attached, |
| | @@ -193955,12 +194219,12 @@ |
| 193955 | 194219 | sqlite3_result_error_nomem(ctx); |
| 193956 | 194220 | goto jsonSetDone; |
| 193957 | 194221 | }else if( x.nErr ){ |
| 193958 | 194222 | goto jsonSetDone; |
| 193959 | 194223 | }else if( pNode && (bApnd || bIsSet) ){ |
| 193960 | | - testcase( pNode->eU!=0 && pNode->eU!=1 && pNode->eU!=4 ); |
| 193961 | | - assert( pNode->eU!=3 || pNode->eU!=5 ); |
| 194224 | + testcase( pNode->eU!=0 && pNode->eU!=1 ); |
| 194225 | + assert( pNode->eU!=3 && pNode->eU!=5 ); |
| 193962 | 194226 | VVA( pNode->eU = 4 ); |
| 193963 | 194227 | pNode->jnFlags |= (u8)JNODE_REPLACE; |
| 193964 | 194228 | pNode->u.iReplace = i + 1; |
| 193965 | 194229 | } |
| 193966 | 194230 | } |
| | @@ -233334,11 +233598,11 @@ |
| 233334 | 233598 | int nArg, /* Number of args */ |
| 233335 | 233599 | sqlite3_value **apUnused /* Function arguments */ |
| 233336 | 233600 | ){ |
| 233337 | 233601 | assert( nArg==0 ); |
| 233338 | 233602 | UNUSED_PARAM2(nArg, apUnused); |
| 233339 | | - sqlite3_result_text(pCtx, "fts5: 2022-01-12 00:28:12 adebb9d7478d092f16fb0ef7d5246ce152b166479d6f949110b5878b89ea2cec", -1, SQLITE_TRANSIENT); |
| 233603 | + sqlite3_result_text(pCtx, "fts5: 2022-01-25 00:03:25 a8db69411b0d1275909adeb21027784ada17af24efe3a59ae0ae2a897659ff17", -1, SQLITE_TRANSIENT); |
| 233340 | 233604 | } |
| 233341 | 233605 | |
| 233342 | 233606 | /* |
| 233343 | 233607 | ** Return true if zName is the extension on one of the shadow tables used |
| 233344 | 233608 | ** by this module. |
| 233345 | 233609 | |