| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.52.0. By combining all the individual C code files into this |
| 3 | +** version 3.53.0. By combining all the individual C code files into this |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| | @@ -16,11 +16,11 @@ |
| 16 | 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | 19 | ** |
| 20 | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | | -** 557aeb43869d3585137b17690cb3b64f7de6 with changes in files: |
| 21 | +** 5c237f1f863a32cf229010d2024d0d1e76a0 with changes in files: |
| 22 | 22 | ** |
| 23 | 23 | ** |
| 24 | 24 | */ |
| 25 | 25 | #ifndef SQLITE_AMALGAMATION |
| 26 | 26 | #define SQLITE_CORE 1 |
| | @@ -465,16 +465,16 @@ |
| 465 | 465 | ** |
| 466 | 466 | ** See also: [sqlite3_libversion()], |
| 467 | 467 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 468 | 468 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 469 | 469 | */ |
| 470 | | -#define SQLITE_VERSION "3.52.0" |
| 471 | | -#define SQLITE_VERSION_NUMBER 3052000 |
| 472 | | -#define SQLITE_SOURCE_ID "2026-03-06 16:01:44 557aeb43869d3585137b17690cb3b64f7de6921774daae9e56403c3717dceab6" |
| 470 | +#define SQLITE_VERSION "3.53.0" |
| 471 | +#define SQLITE_VERSION_NUMBER 3053000 |
| 472 | +#define SQLITE_SOURCE_ID "2026-03-18 22:31:56 5c237f1f863a32cf229010d2024d0d1e76a07a4d8b9492b26503b959f1c32485" |
| 473 | 473 | #define SQLITE_SCM_BRANCH "trunk" |
| 474 | | -#define SQLITE_SCM_TAGS "release major-release version-3.52.0" |
| 475 | | -#define SQLITE_SCM_DATETIME "2026-03-06T16:01:44.367Z" |
| 474 | +#define SQLITE_SCM_TAGS "" |
| 475 | +#define SQLITE_SCM_DATETIME "2026-03-18T22:31:56.220Z" |
| 476 | 476 | |
| 477 | 477 | /* |
| 478 | 478 | ** CAPI3REF: Run-Time Library Version Numbers |
| 479 | 479 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 480 | 480 | ** |
| | @@ -2977,11 +2977,11 @@ |
| 2977 | 2977 | ** default value 17, as of SQLite version 3.52.0. The value was 15 in all |
| 2978 | 2978 | ** prior versions.<p> |
| 2979 | 2979 | ** This option takes two arguments which are an integer and a pointer |
| 2980 | 2980 | ** to an integer. The first argument is a small integer, between 3 and 23, or |
| 2981 | 2981 | ** zero. The FP_DIGITS setting is changed to that small integer, or left |
| 2982 | | -** altered if the first argument is zero or out of range. The second argument |
| 2982 | +** unaltered if the first argument is zero or out of range. The second argument |
| 2983 | 2983 | ** is a pointer to an integer. If the pointer is not NULL, then the value of |
| 2984 | 2984 | ** the FP_DIGITS setting, after possibly being modified by the first |
| 2985 | 2985 | ** arguments, is written into the integer to which the second argument points. |
| 2986 | 2986 | ** </dd> |
| 2987 | 2987 | ** |
| | @@ -4807,11 +4807,11 @@ |
| 4807 | 4807 | ** are constructors for the [prepared statement] object. |
| 4808 | 4808 | ** |
| 4809 | 4809 | ** The preferred routine to use is [sqlite3_prepare_v2()]. The |
| 4810 | 4810 | ** [sqlite3_prepare()] interface is legacy and should be avoided. |
| 4811 | 4811 | ** [sqlite3_prepare_v3()] has an extra |
| 4812 | | -** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is some times |
| 4812 | +** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is sometimes |
| 4813 | 4813 | ** needed for special purpose or to pass along security restrictions. |
| 4814 | 4814 | ** |
| 4815 | 4815 | ** The use of the UTF-8 interfaces is preferred, as SQLite currently |
| 4816 | 4816 | ** does all parsing using UTF-8. The UTF-16 interfaces are provided |
| 4817 | 4817 | ** as a convenience. The UTF-16 interfaces work by converting the |
| | @@ -6814,11 +6814,11 @@ |
| 6814 | 6814 | ** application-defined function to be a text string in an encoding |
| 6815 | 6815 | ** specified the E parameter, which must be one |
| 6816 | 6816 | ** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE], |
| 6817 | 6817 | ** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that |
| 6818 | 6818 | ** the result text is both UTF-8 and zero-terminated. In other words, |
| 6819 | | -** SQLITE_UTF8_ZT means that the Z array holds at least N+1 byes and that |
| 6819 | +** SQLITE_UTF8_ZT means that the Z array holds at least N+1 bytes and that |
| 6820 | 6820 | ** the Z[N] is zero. |
| 6821 | 6821 | ** ^SQLite takes the text result from the application from |
| 6822 | 6822 | ** the 2nd parameter of the sqlite3_result_text* interfaces. |
| 6823 | 6823 | ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces |
| 6824 | 6824 | ** other than sqlite3_result_text64() is negative, then SQLite computes |
| | @@ -9184,11 +9184,11 @@ |
| 9184 | 9184 | ** |
| 9185 | 9185 | ** ^The [sqlite3_str_reset(X)] method resets the string under construction |
| 9186 | 9186 | ** inside [sqlite3_str] object X back to zero bytes in length. |
| 9187 | 9187 | ** |
| 9188 | 9188 | ** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string |
| 9189 | | -** under construction to be N bytes are less. This routine is a no-op if |
| 9189 | +** under construction to be N bytes or less. This routine is a no-op if |
| 9190 | 9190 | ** N is negative or if the string is already N bytes or smaller in size. |
| 9191 | 9191 | ** |
| 9192 | 9192 | ** These methods do not return a result code. ^If an error occurs, that fact |
| 9193 | 9193 | ** is recorded in the [sqlite3_str] object and can be recovered by a |
| 9194 | 9194 | ** subsequent call to [sqlite3_str_errcode(X)]. |
| | @@ -11048,11 +11048,11 @@ |
| 11048 | 11048 | ** - less than -1 or greater than or equal to the total number of query |
| 11049 | 11049 | ** elements used to implement the statement - a non-zero value is returned and |
| 11050 | 11050 | ** the variable that pOut points to is unchanged. |
| 11051 | 11051 | ** |
| 11052 | 11052 | ** See also: [sqlite3_stmt_scanstatus_reset()] and the |
| 11053 | | -** [nexec and ncycle] columnes of the [bytecode virtual table]. |
| 11053 | +** [nexec and ncycle] columns of the [bytecode virtual table]. |
| 11054 | 11054 | */ |
| 11055 | 11055 | SQLITE_API int sqlite3_stmt_scanstatus( |
| 11056 | 11056 | sqlite3_stmt *pStmt, /* Prepared statement for which info desired */ |
| 11057 | 11057 | int idx, /* Index of loop to report on */ |
| 11058 | 11058 | int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */ |
| | @@ -11604,21 +11604,21 @@ |
| 11604 | 11604 | ** |
| 11605 | 11605 | ** If the X argument is not a NULL pointer or one of the special |
| 11606 | 11606 | ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke |
| 11607 | 11607 | ** the function X with argument D when it is finished using the data in P. |
| 11608 | 11608 | ** The call to X(D) is a destructor for the array P. The destructor X(D) |
| 11609 | | -** is invoked even if the call to sqlite3_carray_bind() fails. If the X |
| 11609 | +** is invoked even if the call to sqlite3_carray_bind_v2() fails. If the X |
| 11610 | 11610 | ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes |
| 11611 | 11611 | ** that the data static and the destructor is never invoked. If the X |
| 11612 | 11612 | ** parameter is the special-case value [SQLITE_TRANSIENT], then |
| 11613 | 11613 | ** sqlite3_carray_bind_v2() makes its own private copy of the data prior |
| 11614 | 11614 | ** to returning and never invokes the destructor X. |
| 11615 | 11615 | ** |
| 11616 | | -** The sqlite3_carray_bind() function works the same as sqlite_carray_bind_v2() |
| 11616 | +** The sqlite3_carray_bind() function works the same as sqlite3_carray_bind_v2() |
| 11617 | 11617 | ** with a D parameter set to P. In other words, |
| 11618 | 11618 | ** sqlite3_carray_bind(S,I,P,N,F,X) is same as |
| 11619 | | -** sqlite3_carray_bind(S,I,P,N,F,X,P). |
| 11619 | +** sqlite3_carray_bind_v2(S,I,P,N,F,X,P). |
| 11620 | 11620 | */ |
| 11621 | 11621 | SQLITE_API int sqlite3_carray_bind_v2( |
| 11622 | 11622 | sqlite3_stmt *pStmt, /* Statement to be bound */ |
| 11623 | 11623 | int i, /* Parameter index */ |
| 11624 | 11624 | void *aData, /* Pointer to array data */ |
| | @@ -14740,13 +14740,11 @@ |
| 14740 | 14740 | #endif |
| 14741 | 14741 | |
| 14742 | 14742 | /* |
| 14743 | 14743 | ** Include standard header files as necessary |
| 14744 | 14744 | */ |
| 14745 | | -#ifdef HAVE_STDINT_H |
| 14746 | 14745 | #include <stdint.h> |
| 14747 | | -#endif |
| 14748 | 14746 | #ifdef HAVE_INTTYPES_H |
| 14749 | 14747 | #include <inttypes.h> |
| 14750 | 14748 | #endif |
| 14751 | 14749 | |
| 14752 | 14750 | /* |
| | @@ -17315,10 +17313,11 @@ |
| 17315 | 17313 | KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */ |
| 17316 | 17314 | u32 *ai; /* Used when p4type is P4_INTARRAY */ |
| 17317 | 17315 | SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */ |
| 17318 | 17316 | Table *pTab; /* Used when p4type is P4_TABLE */ |
| 17319 | 17317 | SubrtnSig *pSubrtnSig; /* Used when p4type is P4_SUBRTNSIG */ |
| 17318 | + Index *pIdx; /* Used when p4type is P4_INDEX */ |
| 17320 | 17319 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 17321 | 17320 | Expr *pExpr; /* Used when p4type is P4_EXPR */ |
| 17322 | 17321 | #endif |
| 17323 | 17322 | } p4; |
| 17324 | 17323 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| | @@ -17369,24 +17368,25 @@ |
| 17369 | 17368 | #define P4_STATIC (-1) /* Pointer to a static string */ |
| 17370 | 17369 | #define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */ |
| 17371 | 17370 | #define P4_INT32 (-3) /* P4 is a 32-bit signed integer */ |
| 17372 | 17371 | #define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */ |
| 17373 | 17372 | #define P4_TABLE (-5) /* P4 is a pointer to a Table structure */ |
| 17373 | +#define P4_INDEX (-6) /* P4 is a pointer to an Index structure */ |
| 17374 | 17374 | /* Above do not own any resources. Must free those below */ |
| 17375 | | -#define P4_FREE_IF_LE (-6) |
| 17376 | | -#define P4_DYNAMIC (-6) /* Pointer to memory from sqliteMalloc() */ |
| 17377 | | -#define P4_FUNCDEF (-7) /* P4 is a pointer to a FuncDef structure */ |
| 17378 | | -#define P4_KEYINFO (-8) /* P4 is a pointer to a KeyInfo structure */ |
| 17379 | | -#define P4_EXPR (-9) /* P4 is a pointer to an Expr tree */ |
| 17380 | | -#define P4_MEM (-10) /* P4 is a pointer to a Mem* structure */ |
| 17381 | | -#define P4_VTAB (-11) /* P4 is a pointer to an sqlite3_vtab structure */ |
| 17382 | | -#define P4_REAL (-12) /* P4 is a 64-bit floating point value */ |
| 17383 | | -#define P4_INT64 (-13) /* P4 is a 64-bit signed integer */ |
| 17384 | | -#define P4_INTARRAY (-14) /* P4 is a vector of 32-bit integers */ |
| 17385 | | -#define P4_FUNCCTX (-15) /* P4 is a pointer to an sqlite3_context object */ |
| 17386 | | -#define P4_TABLEREF (-16) /* Like P4_TABLE, but reference counted */ |
| 17387 | | -#define P4_SUBRTNSIG (-17) /* P4 is a SubrtnSig pointer */ |
| 17375 | +#define P4_FREE_IF_LE (-7) |
| 17376 | +#define P4_DYNAMIC (-7) /* Pointer to memory from sqliteMalloc() */ |
| 17377 | +#define P4_FUNCDEF (-8) /* P4 is a pointer to a FuncDef structure */ |
| 17378 | +#define P4_KEYINFO (-9) /* P4 is a pointer to a KeyInfo structure */ |
| 17379 | +#define P4_EXPR (-10) /* P4 is a pointer to an Expr tree */ |
| 17380 | +#define P4_MEM (-11) /* P4 is a pointer to a Mem* structure */ |
| 17381 | +#define P4_VTAB (-12) /* P4 is a pointer to an sqlite3_vtab structure */ |
| 17382 | +#define P4_REAL (-13) /* P4 is a 64-bit floating point value */ |
| 17383 | +#define P4_INT64 (-14) /* P4 is a 64-bit signed integer */ |
| 17384 | +#define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */ |
| 17385 | +#define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */ |
| 17386 | +#define P4_TABLEREF (-17) /* Like P4_TABLE, but reference counted */ |
| 17387 | +#define P4_SUBRTNSIG (-18) /* P4 is a SubrtnSig pointer */ |
| 17388 | 17388 | |
| 17389 | 17389 | /* Error message codes for OP_Halt */ |
| 17390 | 17390 | #define P5_ConstraintNotNull 1 |
| 17391 | 17391 | #define P5_ConstraintUnique 2 |
| 17392 | 17392 | #define P5_ConstraintCheck 3 |
| | @@ -17471,66 +17471,66 @@ |
| 17471 | 17471 | #define OP_IdxGT 42 /* jump, synopsis: key=r[P3@P4] */ |
| 17472 | 17472 | #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 17473 | 17473 | #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 17474 | 17474 | #define OP_IdxLT 45 /* jump, synopsis: key=r[P3@P4] */ |
| 17475 | 17475 | #define OP_IdxGE 46 /* jump, synopsis: key=r[P3@P4] */ |
| 17476 | | -#define OP_RowSetRead 47 /* jump, synopsis: r[P3]=rowset(P1) */ |
| 17477 | | -#define OP_RowSetTest 48 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 17478 | | -#define OP_Program 49 /* jump0 */ |
| 17479 | | -#define OP_FkIfZero 50 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ |
| 17476 | +#define OP_IFindKey 47 /* jump */ |
| 17477 | +#define OP_RowSetRead 48 /* jump, synopsis: r[P3]=rowset(P1) */ |
| 17478 | +#define OP_RowSetTest 49 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 17479 | +#define OP_Program 50 /* jump0 */ |
| 17480 | 17480 | #define OP_IsNull 51 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 17481 | 17481 | #define OP_NotNull 52 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 17482 | 17482 | #define OP_Ne 53 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| 17483 | 17483 | #define OP_Eq 54 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */ |
| 17484 | 17484 | #define OP_Gt 55 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */ |
| 17485 | 17485 | #define OP_Le 56 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */ |
| 17486 | 17486 | #define OP_Lt 57 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 17487 | 17487 | #define OP_Ge 58 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 17488 | 17488 | #define OP_ElseEq 59 /* jump, same as TK_ESCAPE */ |
| 17489 | | -#define OP_IfPos 60 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 17490 | | -#define OP_IfNotZero 61 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ |
| 17491 | | -#define OP_DecrJumpZero 62 /* jump, synopsis: if (--r[P1])==0 goto P2 */ |
| 17492 | | -#define OP_IncrVacuum 63 /* jump */ |
| 17493 | | -#define OP_VNext 64 /* jump */ |
| 17494 | | -#define OP_Filter 65 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */ |
| 17495 | | -#define OP_PureFunc 66 /* synopsis: r[P3]=func(r[P2@NP]) */ |
| 17496 | | -#define OP_Function 67 /* synopsis: r[P3]=func(r[P2@NP]) */ |
| 17497 | | -#define OP_Return 68 |
| 17498 | | -#define OP_EndCoroutine 69 |
| 17499 | | -#define OP_HaltIfNull 70 /* synopsis: if r[P3]=null halt */ |
| 17500 | | -#define OP_Halt 71 |
| 17501 | | -#define OP_Integer 72 /* synopsis: r[P2]=P1 */ |
| 17502 | | -#define OP_Int64 73 /* synopsis: r[P2]=P4 */ |
| 17503 | | -#define OP_String 74 /* synopsis: r[P2]='P4' (len=P1) */ |
| 17504 | | -#define OP_BeginSubrtn 75 /* synopsis: r[P2]=NULL */ |
| 17505 | | -#define OP_Null 76 /* synopsis: r[P2..P3]=NULL */ |
| 17506 | | -#define OP_SoftNull 77 /* synopsis: r[P1]=NULL */ |
| 17507 | | -#define OP_Blob 78 /* synopsis: r[P2]=P4 (len=P1) */ |
| 17508 | | -#define OP_Variable 79 /* synopsis: r[P2]=parameter(P1) */ |
| 17509 | | -#define OP_Move 80 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 17510 | | -#define OP_Copy 81 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 17511 | | -#define OP_SCopy 82 /* synopsis: r[P2]=r[P1] */ |
| 17512 | | -#define OP_IntCopy 83 /* synopsis: r[P2]=r[P1] */ |
| 17513 | | -#define OP_FkCheck 84 |
| 17514 | | -#define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */ |
| 17515 | | -#define OP_CollSeq 86 |
| 17516 | | -#define OP_AddImm 87 /* synopsis: r[P1]=r[P1]+P2 */ |
| 17517 | | -#define OP_RealAffinity 88 |
| 17518 | | -#define OP_Cast 89 /* synopsis: affinity(r[P1]) */ |
| 17519 | | -#define OP_Permutation 90 |
| 17520 | | -#define OP_Compare 91 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 17521 | | -#define OP_IsTrue 92 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ |
| 17522 | | -#define OP_ZeroOrNull 93 /* synopsis: r[P2] = 0 OR NULL */ |
| 17523 | | -#define OP_Offset 94 /* synopsis: r[P3] = sqlite_offset(P1) */ |
| 17524 | | -#define OP_Column 95 /* synopsis: r[P3]=PX cursor P1 column P2 */ |
| 17525 | | -#define OP_TypeCheck 96 /* synopsis: typecheck(r[P1@P2]) */ |
| 17526 | | -#define OP_Affinity 97 /* synopsis: affinity(r[P1@P2]) */ |
| 17527 | | -#define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 17528 | | -#define OP_Count 99 /* synopsis: r[P2]=count() */ |
| 17529 | | -#define OP_ReadCookie 100 |
| 17530 | | -#define OP_SetCookie 101 |
| 17531 | | -#define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */ |
| 17489 | +#define OP_FkIfZero 60 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ |
| 17490 | +#define OP_IfPos 61 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 17491 | +#define OP_IfNotZero 62 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ |
| 17492 | +#define OP_DecrJumpZero 63 /* jump, synopsis: if (--r[P1])==0 goto P2 */ |
| 17493 | +#define OP_IncrVacuum 64 /* jump */ |
| 17494 | +#define OP_VNext 65 /* jump */ |
| 17495 | +#define OP_Filter 66 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */ |
| 17496 | +#define OP_PureFunc 67 /* synopsis: r[P3]=func(r[P2@NP]) */ |
| 17497 | +#define OP_Function 68 /* synopsis: r[P3]=func(r[P2@NP]) */ |
| 17498 | +#define OP_Return 69 |
| 17499 | +#define OP_EndCoroutine 70 |
| 17500 | +#define OP_HaltIfNull 71 /* synopsis: if r[P3]=null halt */ |
| 17501 | +#define OP_Halt 72 |
| 17502 | +#define OP_Integer 73 /* synopsis: r[P2]=P1 */ |
| 17503 | +#define OP_Int64 74 /* synopsis: r[P2]=P4 */ |
| 17504 | +#define OP_String 75 /* synopsis: r[P2]='P4' (len=P1) */ |
| 17505 | +#define OP_BeginSubrtn 76 /* synopsis: r[P2]=NULL */ |
| 17506 | +#define OP_Null 77 /* synopsis: r[P2..P3]=NULL */ |
| 17507 | +#define OP_SoftNull 78 /* synopsis: r[P1]=NULL */ |
| 17508 | +#define OP_Blob 79 /* synopsis: r[P2]=P4 (len=P1) */ |
| 17509 | +#define OP_Variable 80 /* synopsis: r[P2]=parameter(P1) */ |
| 17510 | +#define OP_Move 81 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 17511 | +#define OP_Copy 82 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 17512 | +#define OP_SCopy 83 /* synopsis: r[P2]=r[P1] */ |
| 17513 | +#define OP_IntCopy 84 /* synopsis: r[P2]=r[P1] */ |
| 17514 | +#define OP_FkCheck 85 |
| 17515 | +#define OP_ResultRow 86 /* synopsis: output=r[P1@P2] */ |
| 17516 | +#define OP_CollSeq 87 |
| 17517 | +#define OP_AddImm 88 /* synopsis: r[P1]=r[P1]+P2 */ |
| 17518 | +#define OP_RealAffinity 89 |
| 17519 | +#define OP_Cast 90 /* synopsis: affinity(r[P1]) */ |
| 17520 | +#define OP_Permutation 91 |
| 17521 | +#define OP_Compare 92 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 17522 | +#define OP_IsTrue 93 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ |
| 17523 | +#define OP_ZeroOrNull 94 /* synopsis: r[P2] = 0 OR NULL */ |
| 17524 | +#define OP_Offset 95 /* synopsis: r[P3] = sqlite_offset(P1) */ |
| 17525 | +#define OP_Column 96 /* synopsis: r[P3]=PX cursor P1 column P2 */ |
| 17526 | +#define OP_TypeCheck 97 /* synopsis: typecheck(r[P1@P2]) */ |
| 17527 | +#define OP_Affinity 98 /* synopsis: affinity(r[P1@P2]) */ |
| 17528 | +#define OP_MakeRecord 99 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 17529 | +#define OP_Count 100 /* synopsis: r[P2]=count() */ |
| 17530 | +#define OP_ReadCookie 101 |
| 17531 | +#define OP_SetCookie 102 |
| 17532 | 17532 | #define OP_BitAnd 103 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 17533 | 17533 | #define OP_BitOr 104 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 17534 | 17534 | #define OP_ShiftLeft 105 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 17535 | 17535 | #define OP_ShiftRight 106 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 17536 | 17536 | #define OP_Add 107 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| | @@ -17537,88 +17537,89 @@ |
| 17537 | 17537 | #define OP_Subtract 108 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 17538 | 17538 | #define OP_Multiply 109 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 17539 | 17539 | #define OP_Divide 110 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 17540 | 17540 | #define OP_Remainder 111 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 17541 | 17541 | #define OP_Concat 112 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 17542 | | -#define OP_OpenRead 113 /* synopsis: root=P2 iDb=P3 */ |
| 17543 | | -#define OP_OpenWrite 114 /* synopsis: root=P2 iDb=P3 */ |
| 17542 | +#define OP_ReopenIdx 113 /* synopsis: root=P2 iDb=P3 */ |
| 17543 | +#define OP_OpenRead 114 /* synopsis: root=P2 iDb=P3 */ |
| 17544 | 17544 | #define OP_BitNot 115 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ |
| 17545 | | -#define OP_OpenDup 116 |
| 17546 | | -#define OP_OpenAutoindex 117 /* synopsis: nColumn=P2 */ |
| 17545 | +#define OP_OpenWrite 116 /* synopsis: root=P2 iDb=P3 */ |
| 17546 | +#define OP_OpenDup 117 |
| 17547 | 17547 | #define OP_String8 118 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 17548 | | -#define OP_OpenEphemeral 119 /* synopsis: nColumn=P2 */ |
| 17549 | | -#define OP_SorterOpen 120 |
| 17550 | | -#define OP_SequenceTest 121 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 17551 | | -#define OP_OpenPseudo 122 /* synopsis: P3 columns in r[P2] */ |
| 17552 | | -#define OP_Close 123 |
| 17553 | | -#define OP_ColumnsUsed 124 |
| 17554 | | -#define OP_SeekScan 125 /* synopsis: Scan-ahead up to P1 rows */ |
| 17555 | | -#define OP_SeekHit 126 /* synopsis: set P2<=seekHit<=P3 */ |
| 17556 | | -#define OP_Sequence 127 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 17557 | | -#define OP_NewRowid 128 /* synopsis: r[P2]=rowid */ |
| 17558 | | -#define OP_Insert 129 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 17559 | | -#define OP_RowCell 130 |
| 17560 | | -#define OP_Delete 131 |
| 17561 | | -#define OP_ResetCount 132 |
| 17562 | | -#define OP_SorterCompare 133 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 17563 | | -#define OP_SorterData 134 /* synopsis: r[P2]=data */ |
| 17564 | | -#define OP_RowData 135 /* synopsis: r[P2]=data */ |
| 17565 | | -#define OP_Rowid 136 /* synopsis: r[P2]=PX rowid of P1 */ |
| 17566 | | -#define OP_NullRow 137 |
| 17567 | | -#define OP_SeekEnd 138 |
| 17568 | | -#define OP_IdxInsert 139 /* synopsis: key=r[P2] */ |
| 17569 | | -#define OP_SorterInsert 140 /* synopsis: key=r[P2] */ |
| 17570 | | -#define OP_IdxDelete 141 /* synopsis: key=r[P2@P3] */ |
| 17571 | | -#define OP_DeferredSeek 142 /* synopsis: Move P3 to P1.rowid if needed */ |
| 17572 | | -#define OP_IdxRowid 143 /* synopsis: r[P2]=rowid */ |
| 17573 | | -#define OP_FinishSeek 144 |
| 17574 | | -#define OP_Destroy 145 |
| 17575 | | -#define OP_Clear 146 |
| 17576 | | -#define OP_ResetSorter 147 |
| 17577 | | -#define OP_CreateBtree 148 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ |
| 17578 | | -#define OP_SqlExec 149 |
| 17579 | | -#define OP_ParseSchema 150 |
| 17580 | | -#define OP_LoadAnalysis 151 |
| 17581 | | -#define OP_DropTable 152 |
| 17582 | | -#define OP_DropIndex 153 |
| 17548 | +#define OP_OpenAutoindex 119 /* synopsis: nColumn=P2 */ |
| 17549 | +#define OP_OpenEphemeral 120 /* synopsis: nColumn=P2 */ |
| 17550 | +#define OP_SorterOpen 121 |
| 17551 | +#define OP_SequenceTest 122 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 17552 | +#define OP_OpenPseudo 123 /* synopsis: P3 columns in r[P2] */ |
| 17553 | +#define OP_Close 124 |
| 17554 | +#define OP_ColumnsUsed 125 |
| 17555 | +#define OP_SeekScan 126 /* synopsis: Scan-ahead up to P1 rows */ |
| 17556 | +#define OP_SeekHit 127 /* synopsis: set P2<=seekHit<=P3 */ |
| 17557 | +#define OP_Sequence 128 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 17558 | +#define OP_NewRowid 129 /* synopsis: r[P2]=rowid */ |
| 17559 | +#define OP_Insert 130 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 17560 | +#define OP_RowCell 131 |
| 17561 | +#define OP_Delete 132 |
| 17562 | +#define OP_ResetCount 133 |
| 17563 | +#define OP_SorterCompare 134 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 17564 | +#define OP_SorterData 135 /* synopsis: r[P2]=data */ |
| 17565 | +#define OP_RowData 136 /* synopsis: r[P2]=data */ |
| 17566 | +#define OP_Rowid 137 /* synopsis: r[P2]=PX rowid of P1 */ |
| 17567 | +#define OP_NullRow 138 |
| 17568 | +#define OP_SeekEnd 139 |
| 17569 | +#define OP_IdxInsert 140 /* synopsis: key=r[P2] */ |
| 17570 | +#define OP_SorterInsert 141 /* synopsis: key=r[P2] */ |
| 17571 | +#define OP_IdxDelete 142 /* synopsis: key=r[P2@P3] */ |
| 17572 | +#define OP_DeferredSeek 143 /* synopsis: Move P3 to P1.rowid if needed */ |
| 17573 | +#define OP_IdxRowid 144 /* synopsis: r[P2]=rowid */ |
| 17574 | +#define OP_FinishSeek 145 |
| 17575 | +#define OP_Destroy 146 |
| 17576 | +#define OP_Clear 147 |
| 17577 | +#define OP_ResetSorter 148 |
| 17578 | +#define OP_CreateBtree 149 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ |
| 17579 | +#define OP_SqlExec 150 |
| 17580 | +#define OP_ParseSchema 151 |
| 17581 | +#define OP_LoadAnalysis 152 |
| 17582 | +#define OP_DropTable 153 |
| 17583 | 17583 | #define OP_Real 154 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 17584 | | -#define OP_DropTrigger 155 |
| 17585 | | -#define OP_IntegrityCk 156 |
| 17586 | | -#define OP_RowSetAdd 157 /* synopsis: rowset(P1)=r[P2] */ |
| 17587 | | -#define OP_Param 158 |
| 17588 | | -#define OP_FkCounter 159 /* synopsis: fkctr[P1]+=P2 */ |
| 17589 | | -#define OP_MemMax 160 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 17590 | | -#define OP_OffsetLimit 161 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 17591 | | -#define OP_AggInverse 162 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ |
| 17592 | | -#define OP_AggStep 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 17593 | | -#define OP_AggStep1 164 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 17594 | | -#define OP_AggValue 165 /* synopsis: r[P3]=value N=P2 */ |
| 17595 | | -#define OP_AggFinal 166 /* synopsis: accum=r[P1] N=P2 */ |
| 17596 | | -#define OP_Expire 167 |
| 17597 | | -#define OP_CursorLock 168 |
| 17598 | | -#define OP_CursorUnlock 169 |
| 17599 | | -#define OP_TableLock 170 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 17600 | | -#define OP_VBegin 171 |
| 17601 | | -#define OP_VCreate 172 |
| 17602 | | -#define OP_VDestroy 173 |
| 17603 | | -#define OP_VOpen 174 |
| 17604 | | -#define OP_VCheck 175 |
| 17605 | | -#define OP_VInitIn 176 /* synopsis: r[P2]=ValueList(P1,P3) */ |
| 17606 | | -#define OP_VColumn 177 /* synopsis: r[P3]=vcolumn(P2) */ |
| 17607 | | -#define OP_VRename 178 |
| 17608 | | -#define OP_Pagecount 179 |
| 17609 | | -#define OP_MaxPgcnt 180 |
| 17610 | | -#define OP_ClrSubtype 181 /* synopsis: r[P1].subtype = 0 */ |
| 17611 | | -#define OP_GetSubtype 182 /* synopsis: r[P2] = r[P1].subtype */ |
| 17612 | | -#define OP_SetSubtype 183 /* synopsis: r[P2].subtype = r[P1] */ |
| 17613 | | -#define OP_FilterAdd 184 /* synopsis: filter(P1) += key(P3@P4) */ |
| 17614 | | -#define OP_Trace 185 |
| 17615 | | -#define OP_CursorHint 186 |
| 17616 | | -#define OP_ReleaseReg 187 /* synopsis: release r[P1@P2] mask P3 */ |
| 17617 | | -#define OP_Noop 188 |
| 17618 | | -#define OP_Explain 189 |
| 17619 | | -#define OP_Abortable 190 |
| 17584 | +#define OP_DropIndex 155 |
| 17585 | +#define OP_DropTrigger 156 |
| 17586 | +#define OP_IntegrityCk 157 |
| 17587 | +#define OP_RowSetAdd 158 /* synopsis: rowset(P1)=r[P2] */ |
| 17588 | +#define OP_Param 159 |
| 17589 | +#define OP_FkCounter 160 /* synopsis: fkctr[P1]+=P2 */ |
| 17590 | +#define OP_MemMax 161 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 17591 | +#define OP_OffsetLimit 162 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 17592 | +#define OP_AggInverse 163 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ |
| 17593 | +#define OP_AggStep 164 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 17594 | +#define OP_AggStep1 165 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 17595 | +#define OP_AggValue 166 /* synopsis: r[P3]=value N=P2 */ |
| 17596 | +#define OP_AggFinal 167 /* synopsis: accum=r[P1] N=P2 */ |
| 17597 | +#define OP_Expire 168 |
| 17598 | +#define OP_CursorLock 169 |
| 17599 | +#define OP_CursorUnlock 170 |
| 17600 | +#define OP_TableLock 171 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 17601 | +#define OP_VBegin 172 |
| 17602 | +#define OP_VCreate 173 |
| 17603 | +#define OP_VDestroy 174 |
| 17604 | +#define OP_VOpen 175 |
| 17605 | +#define OP_VCheck 176 |
| 17606 | +#define OP_VInitIn 177 /* synopsis: r[P2]=ValueList(P1,P3) */ |
| 17607 | +#define OP_VColumn 178 /* synopsis: r[P3]=vcolumn(P2) */ |
| 17608 | +#define OP_VRename 179 |
| 17609 | +#define OP_Pagecount 180 |
| 17610 | +#define OP_MaxPgcnt 181 |
| 17611 | +#define OP_ClrSubtype 182 /* synopsis: r[P1].subtype = 0 */ |
| 17612 | +#define OP_GetSubtype 183 /* synopsis: r[P2] = r[P1].subtype */ |
| 17613 | +#define OP_SetSubtype 184 /* synopsis: r[P2].subtype = r[P1] */ |
| 17614 | +#define OP_FilterAdd 185 /* synopsis: filter(P1) += key(P3@P4) */ |
| 17615 | +#define OP_Trace 186 |
| 17616 | +#define OP_CursorHint 187 |
| 17617 | +#define OP_ReleaseReg 188 /* synopsis: release r[P1@P2] mask P3 */ |
| 17618 | +#define OP_Noop 189 |
| 17619 | +#define OP_Explain 190 |
| 17620 | +#define OP_Abortable 191 |
| 17620 | 17621 | |
| 17621 | 17622 | /* Properties such as "out2" or "jump" that are specified in |
| 17622 | 17623 | ** comments following the "case" for each opcode in the vdbe.c |
| 17623 | 17624 | ** are encoded into bitvectors as follows: |
| 17624 | 17625 | */ |
| | @@ -17634,37 +17635,38 @@ |
| 17634 | 17635 | /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\ |
| 17635 | 17636 | /* 8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\ |
| 17636 | 17637 | /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\ |
| 17637 | 17638 | /* 24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\ |
| 17638 | 17639 | /* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x01, 0x41,\ |
| 17639 | | -/* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x41, 0x23,\ |
| 17640 | | -/* 48 */ 0x0b, 0x81, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\ |
| 17641 | | -/* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01,\ |
| 17642 | | -/* 64 */ 0x41, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00,\ |
| 17643 | | -/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\ |
| 17644 | | -/* 80 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02,\ |
| 17645 | | -/* 88 */ 0x02, 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40,\ |
| 17646 | | -/* 96 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x26,\ |
| 17640 | +/* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x41, 0x09,\ |
| 17641 | +/* 48 */ 0x23, 0x0b, 0x81, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\ |
| 17642 | +/* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x01, 0x03, 0x03, 0x03,\ |
| 17643 | +/* 64 */ 0x01, 0x41, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08,\ |
| 17644 | +/* 72 */ 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10,\ |
| 17645 | +/* 80 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\ |
| 17646 | +/* 88 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20,\ |
| 17647 | +/* 96 */ 0x40, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x26,\ |
| 17647 | 17648 | /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 17648 | | -/* 112 */ 0x26, 0x40, 0x00, 0x12, 0x40, 0x40, 0x10, 0x40,\ |
| 17649 | | -/* 120 */ 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10,\ |
| 17650 | | -/* 128 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,\ |
| 17651 | | -/* 136 */ 0x50, 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50,\ |
| 17652 | | -/* 144 */ 0x40, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\ |
| 17653 | | -/* 152 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00,\ |
| 17654 | | -/* 160 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 17655 | | -/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10,\ |
| 17656 | | -/* 176 */ 0x50, 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12,\ |
| 17657 | | -/* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,} |
| 17649 | +/* 112 */ 0x26, 0x40, 0x40, 0x12, 0x00, 0x40, 0x10, 0x40,\ |
| 17650 | +/* 120 */ 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40,\ |
| 17651 | +/* 128 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,\ |
| 17652 | +/* 136 */ 0x00, 0x50, 0x00, 0x40, 0x04, 0x04, 0x00, 0x40,\ |
| 17653 | +/* 144 */ 0x50, 0x40, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00,\ |
| 17654 | +/* 152 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x06, 0x10,\ |
| 17655 | +/* 160 */ 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 17656 | +/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,\ |
| 17657 | +/* 176 */ 0x10, 0x50, 0x40, 0x00, 0x10, 0x10, 0x02, 0x12,\ |
| 17658 | +/* 184 */ 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 17659 | +} |
| 17658 | 17660 | |
| 17659 | 17661 | /* The resolve3P2Values() routine is able to run faster if it knows |
| 17660 | 17662 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 17661 | 17663 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 17662 | 17664 | ** generated this include file strives to group all JUMP opcodes |
| 17663 | 17665 | ** together near the beginning of the list. |
| 17664 | 17666 | */ |
| 17665 | | -#define SQLITE_MX_JUMP_OPCODE 65 /* Maximum JUMP opcode */ |
| 17667 | +#define SQLITE_MX_JUMP_OPCODE 66 /* Maximum JUMP opcode */ |
| 17666 | 17668 | |
| 17667 | 17669 | /************** End of opcodes.h *********************************************/ |
| 17668 | 17670 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 17669 | 17671 | |
| 17670 | 17672 | /* |
| | @@ -24682,10 +24684,11 @@ |
| 24682 | 24684 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 24683 | 24685 | SQLITE_PRIVATE void sqlite3VdbePreUpdateHook( |
| 24684 | 24686 | Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int,int); |
| 24685 | 24687 | #endif |
| 24686 | 24688 | SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p); |
| 24689 | +SQLITE_PRIVATE int sqlite3VdbeFindIndexKey(BtCursor*, Index*, UnpackedRecord*, int*, int); |
| 24687 | 24690 | |
| 24688 | 24691 | SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *); |
| 24689 | 24692 | SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *); |
| 24690 | 24693 | SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *); |
| 24691 | 24694 | SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *); |
| | @@ -35367,10 +35370,11 @@ |
| 35367 | 35370 | }else{ |
| 35368 | 35371 | assert( p->id!=0 && p->id!=GetCurrentThreadId() ); |
| 35369 | 35372 | rc = sqlite3Win32Wait((HANDLE)p->tid); |
| 35370 | 35373 | assert( rc!=WAIT_IO_COMPLETION ); |
| 35371 | 35374 | bRc = CloseHandle((HANDLE)p->tid); |
| 35375 | + (void)bRc; /* Prevent warning when assert() is a no-op */ |
| 35372 | 35376 | assert( bRc ); |
| 35373 | 35377 | } |
| 35374 | 35378 | if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult; |
| 35375 | 35379 | sqlite3_free(p); |
| 35376 | 35380 | return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR; |
| | @@ -36507,32 +36511,72 @@ |
| 36507 | 36511 | } |
| 36508 | 36512 | return h; |
| 36509 | 36513 | } |
| 36510 | 36514 | |
| 36511 | 36515 | /* |
| 36512 | | -** Two inputs are multiplied to get a 128-bit result. Return |
| 36513 | | -** the high-order 64 bits of that result. |
| 36516 | +** Two inputs are multiplied to get a 128-bit result. Write the |
| 36517 | +** lower 64-bits of the result into *pLo, and return the high-order |
| 36518 | +** 64 bits. |
| 36514 | 36519 | */ |
| 36515 | | -static u64 sqlite3Multiply128(u64 a, u64 b){ |
| 36520 | +static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){ |
| 36516 | 36521 | #if (defined(__GNUC__) || defined(__clang__)) \ |
| 36517 | 36522 | && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) |
| 36518 | | - return ((__uint128_t)a * b) >> 64; |
| 36523 | + __uint128_t r = (__uint128_t)a * b; |
| 36524 | + *pLo = (u64)r; |
| 36525 | + return (u64)(r>>64); |
| 36519 | 36526 | #elif defined(_MSC_VER) && defined(_M_X64) |
| 36527 | + *pLo = a*b; |
| 36520 | 36528 | return __umulh(a, b); |
| 36521 | 36529 | #else |
| 36522 | | - u64 a1 = (u32)a; |
| 36523 | | - u64 a2 = a >> 32; |
| 36524 | | - u64 b1 = (u32)b; |
| 36525 | | - u64 b2 = b >> 32; |
| 36526 | | - u64 p0 = a1 * b1; |
| 36527 | | - u64 p1 = a1 * b2; |
| 36528 | | - u64 p2 = a2 * b1; |
| 36529 | | - u64 p3 = a2 * b2; |
| 36530 | | - u64 carry = ((p0 >> 32) + (u32)p1 + (u32)p2) >> 32; |
| 36531 | | - return p3 + (p1 >> 32) + (p2 >> 32) + carry; |
| 36530 | + u64 a0 = (u32)a; |
| 36531 | + u64 a1 = a >> 32; |
| 36532 | + u64 b0 = (u32)b; |
| 36533 | + u64 b1 = b >> 32; |
| 36534 | + u64 a0b0 = a0 * b0; |
| 36535 | + u64 a1b1 = a1 * b1; |
| 36536 | + u64 a0b1 = a0 * b1; |
| 36537 | + u64 a1b0 = a1 * b0; |
| 36538 | + u64 t = (a0b0 >> 32) + (u32)a0b1 + (u32)a1b0; |
| 36539 | + *pLo = (a0b0 & UINT64_C(0xffffffff)) | (t << 32); |
| 36540 | + return a1b1 + (a0b1>>32) + (a1b0>>32) + (t>>32); |
| 36532 | 36541 | #endif |
| 36533 | 36542 | } |
| 36543 | + |
| 36544 | +/* |
| 36545 | +** A is an unsigned 96-bit integer formed by (a<<32)+aLo. |
| 36546 | +** B is an unsigned 64-bit integer. |
| 36547 | +** |
| 36548 | +** Compute the upper 96 bits of 160-bit result of A*B. |
| 36549 | +** |
| 36550 | +** Write ((A*B)>>64 & 0xffffffff) (the middle 32 bits of A*B) |
| 36551 | +** into *pLo. Return the upper 64 bits of A*B. |
| 36552 | +** |
| 36553 | +** The lower 64 bits of A*B are discarded. |
| 36554 | +*/ |
| 36555 | +static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){ |
| 36556 | + u64 x2 = a>>32; |
| 36557 | + u64 x1 = a&0xffffffff; |
| 36558 | + u64 x0 = aLo; |
| 36559 | + u64 y1 = b>>32; |
| 36560 | + u64 y0 = b&0xffffffff; |
| 36561 | + u64 x2y1 = x2*y1; |
| 36562 | + u64 r4 = x2y1>>32; |
| 36563 | + u64 x2y0 = x2*y0; |
| 36564 | + u64 x1y1 = x1*y1; |
| 36565 | + u64 r3 = (x2y1 & 0xffffffff) + (x2y0 >>32) + (x1y1 >>32); |
| 36566 | + u64 x1y0 = x1*y0; |
| 36567 | + u64 x0y1 = x0*y1; |
| 36568 | + u64 r2 = (x2y0 & 0xffffffff) + (x1y1 & 0xffffffff) + |
| 36569 | + (x1y0 >>32) + (x0y1>>32); |
| 36570 | + u64 x0y0 = x0*y0; |
| 36571 | + u64 r1 = (x1y0 & 0xffffffff) + (x0y1 & 0xffffffff) + |
| 36572 | + (x0y0 >>32); |
| 36573 | + r2 += r1>>32; |
| 36574 | + r3 += r2>>32; |
| 36575 | + *pLo = r2&0xffffffff; |
| 36576 | + return (r4<<32) + r3; |
| 36577 | +} |
| 36534 | 36578 | |
| 36535 | 36579 | /* |
| 36536 | 36580 | ** Return a u64 with the N-th bit set. |
| 36537 | 36581 | */ |
| 36538 | 36582 | #define U64_BIT(N) (((u64)1)<<(N)) |
| | @@ -36552,102 +36596,145 @@ |
| 36552 | 36596 | ** Or, in other words, for any p in range, return the most significant |
| 36553 | 36597 | ** 64 bits of pow(10,p). The pow(10,p) value is shifted left or right, |
| 36554 | 36598 | ** as appropriate so the most significant 64 bits fit exactly into a |
| 36555 | 36599 | ** 64-bit unsigned integer. |
| 36556 | 36600 | ** |
| 36601 | +** Write into *pLo the next 32 significant bits of the answer after |
| 36602 | +** the first 64. |
| 36603 | +** |
| 36557 | 36604 | ** Algorithm: |
| 36558 | 36605 | ** |
| 36559 | 36606 | ** (1) For p between 0 and 26, return the value directly from the aBase[] |
| 36560 | 36607 | ** lookup table. |
| 36561 | 36608 | ** |
| 36562 | 36609 | ** (2) For p outside the range 0 to 26, use aScale[] for the initial value |
| 36563 | 36610 | ** then refine that result (if necessary) by a single multiplication |
| 36564 | 36611 | ** against aBase[]. |
| 36612 | +** |
| 36613 | +** The constant tables aBase[], aScale[], and aScaleLo[] are generated |
| 36614 | +** by the C program at ../tool/mkfptab.c run with the --round option. |
| 36565 | 36615 | */ |
| 36566 | | -static u64 powerOfTen(int p){ |
| 36616 | +static u64 powerOfTen(int p, u32 *pLo){ |
| 36567 | 36617 | static const u64 aBase[] = { |
| 36568 | | - 0x8000000000000000LLU, /* 0: 1.0e+0 << 63 */ |
| 36569 | | - 0xa000000000000000LLU, /* 1: 1.0e+1 << 60 */ |
| 36570 | | - 0xc800000000000000LLU, /* 2: 1.0e+2 << 57 */ |
| 36571 | | - 0xfa00000000000000LLU, /* 3: 1.0e+3 << 54 */ |
| 36572 | | - 0x9c40000000000000LLU, /* 4: 1.0e+4 << 50 */ |
| 36573 | | - 0xc350000000000000LLU, /* 5: 1.0e+5 << 47 */ |
| 36574 | | - 0xf424000000000000LLU, /* 6: 1.0e+6 << 44 */ |
| 36575 | | - 0x9896800000000000LLU, /* 7: 1.0e+7 << 40 */ |
| 36576 | | - 0xbebc200000000000LLU, /* 8: 1.0e+8 << 37 */ |
| 36577 | | - 0xee6b280000000000LLU, /* 9: 1.0e+9 << 34 */ |
| 36578 | | - 0x9502f90000000000LLU, /* 10: 1.0e+10 << 30 */ |
| 36579 | | - 0xba43b74000000000LLU, /* 11: 1.0e+11 << 27 */ |
| 36580 | | - 0xe8d4a51000000000LLU, /* 12: 1.0e+12 << 24 */ |
| 36581 | | - 0x9184e72a00000000LLU, /* 13: 1.0e+13 << 20 */ |
| 36582 | | - 0xb5e620f480000000LLU, /* 14: 1.0e+14 << 17 */ |
| 36583 | | - 0xe35fa931a0000000LLU, /* 15: 1.0e+15 << 14 */ |
| 36584 | | - 0x8e1bc9bf04000000LLU, /* 16: 1.0e+16 << 10 */ |
| 36585 | | - 0xb1a2bc2ec5000000LLU, /* 17: 1.0e+17 << 7 */ |
| 36586 | | - 0xde0b6b3a76400000LLU, /* 18: 1.0e+18 << 4 */ |
| 36587 | | - 0x8ac7230489e80000LLU, /* 19: 1.0e+19 >> 0 */ |
| 36588 | | - 0xad78ebc5ac620000LLU, /* 20: 1.0e+20 >> 3 */ |
| 36589 | | - 0xd8d726b7177a8000LLU, /* 21: 1.0e+21 >> 6 */ |
| 36590 | | - 0x878678326eac9000LLU, /* 22: 1.0e+22 >> 10 */ |
| 36591 | | - 0xa968163f0a57b400LLU, /* 23: 1.0e+23 >> 13 */ |
| 36592 | | - 0xd3c21bcecceda100LLU, /* 24: 1.0e+24 >> 16 */ |
| 36593 | | - 0x84595161401484a0LLU, /* 25: 1.0e+25 >> 20 */ |
| 36594 | | - 0xa56fa5b99019a5c8LLU, /* 26: 1.0e+26 >> 23 */ |
| 36618 | + UINT64_C(0x8000000000000000), /* 0: 1.0e+0 << 63 */ |
| 36619 | + UINT64_C(0xa000000000000000), /* 1: 1.0e+1 << 60 */ |
| 36620 | + UINT64_C(0xc800000000000000), /* 2: 1.0e+2 << 57 */ |
| 36621 | + UINT64_C(0xfa00000000000000), /* 3: 1.0e+3 << 54 */ |
| 36622 | + UINT64_C(0x9c40000000000000), /* 4: 1.0e+4 << 50 */ |
| 36623 | + UINT64_C(0xc350000000000000), /* 5: 1.0e+5 << 47 */ |
| 36624 | + UINT64_C(0xf424000000000000), /* 6: 1.0e+6 << 44 */ |
| 36625 | + UINT64_C(0x9896800000000000), /* 7: 1.0e+7 << 40 */ |
| 36626 | + UINT64_C(0xbebc200000000000), /* 8: 1.0e+8 << 37 */ |
| 36627 | + UINT64_C(0xee6b280000000000), /* 9: 1.0e+9 << 34 */ |
| 36628 | + UINT64_C(0x9502f90000000000), /* 10: 1.0e+10 << 30 */ |
| 36629 | + UINT64_C(0xba43b74000000000), /* 11: 1.0e+11 << 27 */ |
| 36630 | + UINT64_C(0xe8d4a51000000000), /* 12: 1.0e+12 << 24 */ |
| 36631 | + UINT64_C(0x9184e72a00000000), /* 13: 1.0e+13 << 20 */ |
| 36632 | + UINT64_C(0xb5e620f480000000), /* 14: 1.0e+14 << 17 */ |
| 36633 | + UINT64_C(0xe35fa931a0000000), /* 15: 1.0e+15 << 14 */ |
| 36634 | + UINT64_C(0x8e1bc9bf04000000), /* 16: 1.0e+16 << 10 */ |
| 36635 | + UINT64_C(0xb1a2bc2ec5000000), /* 17: 1.0e+17 << 7 */ |
| 36636 | + UINT64_C(0xde0b6b3a76400000), /* 18: 1.0e+18 << 4 */ |
| 36637 | + UINT64_C(0x8ac7230489e80000), /* 19: 1.0e+19 >> 0 */ |
| 36638 | + UINT64_C(0xad78ebc5ac620000), /* 20: 1.0e+20 >> 3 */ |
| 36639 | + UINT64_C(0xd8d726b7177a8000), /* 21: 1.0e+21 >> 6 */ |
| 36640 | + UINT64_C(0x878678326eac9000), /* 22: 1.0e+22 >> 10 */ |
| 36641 | + UINT64_C(0xa968163f0a57b400), /* 23: 1.0e+23 >> 13 */ |
| 36642 | + UINT64_C(0xd3c21bcecceda100), /* 24: 1.0e+24 >> 16 */ |
| 36643 | + UINT64_C(0x84595161401484a0), /* 25: 1.0e+25 >> 20 */ |
| 36644 | + UINT64_C(0xa56fa5b99019a5c8), /* 26: 1.0e+26 >> 23 */ |
| 36595 | 36645 | }; |
| 36596 | 36646 | static const u64 aScale[] = { |
| 36597 | | - 0x8049a4ac0c5811aeLLU, /* 0: 1.0e-351 << 1229 */ |
| 36598 | | - 0xcf42894a5dce35eaLLU, /* 1: 1.0e-324 << 1140 */ |
| 36599 | | - 0xa76c582338ed2622LLU, /* 2: 1.0e-297 << 1050 */ |
| 36600 | | - 0x873e4f75e2224e68LLU, /* 3: 1.0e-270 << 960 */ |
| 36601 | | - 0xda7f5bf590966849LLU, /* 4: 1.0e-243 << 871 */ |
| 36602 | | - 0xb080392cc4349dedLLU, /* 5: 1.0e-216 << 781 */ |
| 36603 | | - 0x8e938662882af53eLLU, /* 6: 1.0e-189 << 691 */ |
| 36604 | | - 0xe65829b3046b0afaLLU, /* 7: 1.0e-162 << 602 */ |
| 36605 | | - 0xba121a4650e4ddecLLU, /* 8: 1.0e-135 << 512 */ |
| 36606 | | - 0x964e858c91ba2655LLU, /* 9: 1.0e-108 << 422 */ |
| 36607 | | - 0xf2d56790ab41c2a3LLU, /* 10: 1.0e-81 << 333 */ |
| 36608 | | - 0xc428d05aa4751e4dLLU, /* 11: 1.0e-54 << 243 */ |
| 36609 | | - 0x9e74d1b791e07e48LLU, /* 12: 1.0e-27 << 153 */ |
| 36610 | | - 0x8000000000000000LLU, /* 13: 1.0e+0 << 63 */ |
| 36611 | | - 0xcecb8f27f4200f3aLLU, /* 14: 1.0e+27 >> 26 */ |
| 36612 | | - 0xa70c3c40a64e6c52LLU, /* 15: 1.0e+54 >> 116 */ |
| 36613 | | - 0x86f0ac99b4e8dafdLLU, /* 16: 1.0e+81 >> 206 */ |
| 36614 | | - 0xda01ee641a708deaLLU, /* 17: 1.0e+108 >> 295 */ |
| 36615 | | - 0xb01ae745b101e9e4LLU, /* 18: 1.0e+135 >> 385 */ |
| 36616 | | - 0x8e41ade9fbebc27dLLU, /* 19: 1.0e+162 >> 475 */ |
| 36617 | | - 0xe5d3ef282a242e82LLU, /* 20: 1.0e+189 >> 564 */ |
| 36618 | | - 0xb9a74a0637ce2ee1LLU, /* 21: 1.0e+216 >> 654 */ |
| 36619 | | - 0x95f83d0a1fb69cd9LLU, /* 22: 1.0e+243 >> 744 */ |
| 36620 | | - 0xf24a01a73cf2dcd0LLU, /* 23: 1.0e+270 >> 833 */ |
| 36621 | | - 0xc3b8358109e84f07LLU, /* 24: 1.0e+297 >> 923 */ |
| 36622 | | - 0x9e19db92b4e31ba9LLU, /* 25: 1.0e+324 >> 1013 */ |
| 36647 | + UINT64_C(0x8049a4ac0c5811ae), /* 0: 1.0e-351 << 1229 */ |
| 36648 | + UINT64_C(0xcf42894a5dce35ea), /* 1: 1.0e-324 << 1140 */ |
| 36649 | + UINT64_C(0xa76c582338ed2621), /* 2: 1.0e-297 << 1050 */ |
| 36650 | + UINT64_C(0x873e4f75e2224e68), /* 3: 1.0e-270 << 960 */ |
| 36651 | + UINT64_C(0xda7f5bf590966848), /* 4: 1.0e-243 << 871 */ |
| 36652 | + UINT64_C(0xb080392cc4349dec), /* 5: 1.0e-216 << 781 */ |
| 36653 | + UINT64_C(0x8e938662882af53e), /* 6: 1.0e-189 << 691 */ |
| 36654 | + UINT64_C(0xe65829b3046b0afa), /* 7: 1.0e-162 << 602 */ |
| 36655 | + UINT64_C(0xba121a4650e4ddeb), /* 8: 1.0e-135 << 512 */ |
| 36656 | + UINT64_C(0x964e858c91ba2655), /* 9: 1.0e-108 << 422 */ |
| 36657 | + UINT64_C(0xf2d56790ab41c2a2), /* 10: 1.0e-81 << 333 */ |
| 36658 | + UINT64_C(0xc428d05aa4751e4c), /* 11: 1.0e-54 << 243 */ |
| 36659 | + UINT64_C(0x9e74d1b791e07e48), /* 12: 1.0e-27 << 153 */ |
| 36660 | + UINT64_C(0xcccccccccccccccc), /* 13: 1.0e-1 << 67 (special case) */ |
| 36661 | + UINT64_C(0xcecb8f27f4200f3a), /* 14: 1.0e+27 >> 26 */ |
| 36662 | + UINT64_C(0xa70c3c40a64e6c51), /* 15: 1.0e+54 >> 116 */ |
| 36663 | + UINT64_C(0x86f0ac99b4e8dafd), /* 16: 1.0e+81 >> 206 */ |
| 36664 | + UINT64_C(0xda01ee641a708de9), /* 17: 1.0e+108 >> 295 */ |
| 36665 | + UINT64_C(0xb01ae745b101e9e4), /* 18: 1.0e+135 >> 385 */ |
| 36666 | + UINT64_C(0x8e41ade9fbebc27d), /* 19: 1.0e+162 >> 475 */ |
| 36667 | + UINT64_C(0xe5d3ef282a242e81), /* 20: 1.0e+189 >> 564 */ |
| 36668 | + UINT64_C(0xb9a74a0637ce2ee1), /* 21: 1.0e+216 >> 654 */ |
| 36669 | + UINT64_C(0x95f83d0a1fb69cd9), /* 22: 1.0e+243 >> 744 */ |
| 36670 | + UINT64_C(0xf24a01a73cf2dccf), /* 23: 1.0e+270 >> 833 */ |
| 36671 | + UINT64_C(0xc3b8358109e84f07), /* 24: 1.0e+297 >> 923 */ |
| 36672 | + UINT64_C(0x9e19db92b4e31ba9), /* 25: 1.0e+324 >> 1013 */ |
| 36673 | + }; |
| 36674 | + static const unsigned int aScaleLo[] = { |
| 36675 | + 0x205b896d, /* 0: 1.0e-351 << 1229 */ |
| 36676 | + 0x52064cad, /* 1: 1.0e-324 << 1140 */ |
| 36677 | + 0xaf2af2b8, /* 2: 1.0e-297 << 1050 */ |
| 36678 | + 0x5a7744a7, /* 3: 1.0e-270 << 960 */ |
| 36679 | + 0xaf39a475, /* 4: 1.0e-243 << 871 */ |
| 36680 | + 0xbd8d794e, /* 5: 1.0e-216 << 781 */ |
| 36681 | + 0x547eb47b, /* 6: 1.0e-189 << 691 */ |
| 36682 | + 0x0cb4a5a3, /* 7: 1.0e-162 << 602 */ |
| 36683 | + 0x92f34d62, /* 8: 1.0e-135 << 512 */ |
| 36684 | + 0x3a6a07f9, /* 9: 1.0e-108 << 422 */ |
| 36685 | + 0xfae27299, /* 10: 1.0e-81 << 333 */ |
| 36686 | + 0xaa97e14c, /* 11: 1.0e-54 << 243 */ |
| 36687 | + 0x775ea265, /* 12: 1.0e-27 << 153 */ |
| 36688 | + 0xcccccccc, /* 13: 1.0e-1 << 67 (special case) */ |
| 36689 | + 0x00000000, /* 14: 1.0e+27 >> 26 */ |
| 36690 | + 0x999090b6, /* 15: 1.0e+54 >> 116 */ |
| 36691 | + 0x69a028bb, /* 16: 1.0e+81 >> 206 */ |
| 36692 | + 0xe80e6f48, /* 17: 1.0e+108 >> 295 */ |
| 36693 | + 0x5ec05dd0, /* 18: 1.0e+135 >> 385 */ |
| 36694 | + 0x14588f14, /* 19: 1.0e+162 >> 475 */ |
| 36695 | + 0x8f1668c9, /* 20: 1.0e+189 >> 564 */ |
| 36696 | + 0x6d953e2c, /* 21: 1.0e+216 >> 654 */ |
| 36697 | + 0x4abdaf10, /* 22: 1.0e+243 >> 744 */ |
| 36698 | + 0xbc633b39, /* 23: 1.0e+270 >> 833 */ |
| 36699 | + 0x0a862f81, /* 24: 1.0e+297 >> 923 */ |
| 36700 | + 0x6c07a2c2, /* 25: 1.0e+324 >> 1013 */ |
| 36623 | 36701 | }; |
| 36624 | 36702 | int g, n; |
| 36625 | | - u64 x, y; |
| 36703 | + u64 s, x; |
| 36704 | + u32 lo; |
| 36626 | 36705 | |
| 36627 | 36706 | assert( p>=POWERSOF10_FIRST && p<=POWERSOF10_LAST ); |
| 36628 | 36707 | if( p<0 ){ |
| 36708 | + if( p==(-1) ){ |
| 36709 | + *pLo = aScaleLo[13]; |
| 36710 | + return aScale[13]; |
| 36711 | + } |
| 36629 | 36712 | g = p/27; |
| 36630 | 36713 | n = p%27; |
| 36631 | 36714 | if( n ){ |
| 36632 | 36715 | g--; |
| 36633 | 36716 | n += 27; |
| 36634 | 36717 | } |
| 36635 | 36718 | }else if( p<27 ){ |
| 36719 | + *pLo = 0; |
| 36636 | 36720 | return aBase[p]; |
| 36637 | 36721 | }else{ |
| 36638 | 36722 | g = p/27; |
| 36639 | 36723 | n = p%27; |
| 36640 | 36724 | } |
| 36641 | | - y = aScale[g+13]; |
| 36725 | + s = aScale[g+13]; |
| 36642 | 36726 | if( n==0 ){ |
| 36643 | | - return y; |
| 36727 | + *pLo = aScaleLo[g+13]; |
| 36728 | + return s; |
| 36644 | 36729 | } |
| 36645 | | - x = sqlite3Multiply128(aBase[n],y); |
| 36730 | + x = sqlite3Multiply160(s,aScaleLo[g+13],aBase[n],&lo); |
| 36646 | 36731 | if( (U64_BIT(63) & x)==0 ){ |
| 36647 | | - x = (x<<1)|1; |
| 36732 | + x = x<<1 | ((lo>>31)&1); |
| 36733 | + lo = (lo<<1) | 1; |
| 36648 | 36734 | } |
| 36735 | + *pLo = lo; |
| 36649 | 36736 | return x; |
| 36650 | 36737 | } |
| 36651 | 36738 | |
| 36652 | 36739 | /* |
| 36653 | 36740 | ** pow10to2(x) computes floor(log2(pow(10,x))). |
| | @@ -36696,14 +36783,15 @@ |
| 36696 | 36783 | ** The input m is required to have its highest bit set. In other words, |
| 36697 | 36784 | ** m should be left-shifted, and e decremented, to maximize the value of m. |
| 36698 | 36785 | */ |
| 36699 | 36786 | static void sqlite3Fp2Convert10(u64 m, int e, int n, u64 *pD, int *pP){ |
| 36700 | 36787 | int p; |
| 36701 | | - u64 h; |
| 36788 | + u64 h, d1; |
| 36789 | + u32 d2; |
| 36702 | 36790 | assert( n>=1 && n<=18 ); |
| 36703 | 36791 | p = n - 1 - pwr2to10(e+63); |
| 36704 | | - h = sqlite3Multiply128(m, powerOfTen(p)); |
| 36792 | + h = sqlite3Multiply128(m, powerOfTen(p,&d2), &d1); |
| 36705 | 36793 | assert( -(e + pwr10to2(p) + 2) >= 0 ); |
| 36706 | 36794 | assert( -(e + pwr10to2(p) + 1) <= 63 ); |
| 36707 | 36795 | if( n==18 ){ |
| 36708 | 36796 | h >>= -(e + pwr10to2(p) + 2); |
| 36709 | 36797 | *pD = (h + ((h<<1)&2))>>1; |
| | @@ -36715,49 +36803,50 @@ |
| 36715 | 36803 | |
| 36716 | 36804 | /* |
| 36717 | 36805 | ** Return an IEEE754 floating point value that approximates d*pow(10,p). |
| 36718 | 36806 | */ |
| 36719 | 36807 | static double sqlite3Fp10Convert2(u64 d, int p){ |
| 36720 | | - u64 out; |
| 36721 | | - int e1; |
| 36722 | | - int lz; |
| 36723 | | - int lp; |
| 36724 | | - int x; |
| 36725 | | - u64 h; |
| 36808 | + int b, lp, e, adj, s; |
| 36809 | + u32 pwr10l, mid1; |
| 36810 | + u64 pwr10h, x, hi, lo, sticky, u, m; |
| 36726 | 36811 | double r; |
| 36727 | | - assert( (d & U64_BIT(63))==0 ); |
| 36728 | | - assert( d!=0 ); |
| 36729 | | - if( p<POWERSOF10_FIRST ){ |
| 36730 | | - return 0.0; |
| 36731 | | - } |
| 36732 | | - if( p>POWERSOF10_LAST ){ |
| 36733 | | - return INFINITY; |
| 36734 | | - } |
| 36735 | | - lz = countLeadingZeros(d); |
| 36812 | + if( p<POWERSOF10_FIRST ) return 0.0; |
| 36813 | + if( p>POWERSOF10_LAST ) return INFINITY; |
| 36814 | + b = 64 - countLeadingZeros(d); |
| 36736 | 36815 | lp = pwr10to2(p); |
| 36737 | | - e1 = lz - (lp + 11); |
| 36738 | | - if( e1>1074 ){ |
| 36739 | | - if( e1>=1130 ) return 0.0; |
| 36740 | | - e1 = 1074; |
| 36741 | | - } |
| 36742 | | - h = sqlite3Multiply128(d<<lz, powerOfTen(p)); |
| 36743 | | - x = lz - (e1 + lp + 3); |
| 36744 | | - assert( x >= 0 ); |
| 36745 | | - assert( x <= 63 ); |
| 36746 | | - out = h >> x; |
| 36747 | | - if( out >= U64_BIT(55)-2 ){ |
| 36748 | | - out >>= 1; |
| 36749 | | - e1--; |
| 36750 | | - } |
| 36751 | | - if( e1<=(-972) ){ |
| 36752 | | - return INFINITY; |
| 36753 | | - } |
| 36754 | | - out = (out + 2) >> 2; |
| 36755 | | - if( (out & U64_BIT(52))!=0 ){ |
| 36756 | | - out = (out & ~U64_BIT(52)) | ((u64)(1075-e1)<<52); |
| 36757 | | - } |
| 36758 | | - memcpy(&r, &out, 8); |
| 36816 | + e = 53 - b - lp; |
| 36817 | + if( e > 1074 ){ |
| 36818 | + if( e>=1130 ) return 0.0; |
| 36819 | + e = 1074; |
| 36820 | + } |
| 36821 | + s = -(e-(64-b) + lp + 3); |
| 36822 | + pwr10h = powerOfTen(p, &pwr10l); |
| 36823 | + if( pwr10l!=0 ){ |
| 36824 | + pwr10h++; |
| 36825 | + pwr10l = ~pwr10l; |
| 36826 | + } |
| 36827 | + x = d<<(64-b); |
| 36828 | + hi = sqlite3Multiply128(x,pwr10h,&lo); |
| 36829 | + mid1 = lo>>32; |
| 36830 | + sticky = 1; |
| 36831 | + if( (hi & (U64_BIT(s)-1))==0 ) { |
| 36832 | + u32 mid2 = sqlite3Multiply128(x,((u64)pwr10l)<<32,&lo)>>32; |
| 36833 | + sticky = (mid1-mid2 > 1); |
| 36834 | + hi -= mid1 < mid2; |
| 36835 | + } |
| 36836 | + u = (hi>>s) | sticky; |
| 36837 | + adj = (u >= U64_BIT(55)-2); |
| 36838 | + if( adj ){ |
| 36839 | + u = (u>>adj) | (u&1); |
| 36840 | + e -= adj; |
| 36841 | + } |
| 36842 | + m = (u + 1 + ((u>>2)&1)) >> 2; |
| 36843 | + if( e<=(-972) ) return INFINITY; |
| 36844 | + if((m & U64_BIT(52)) != 0){ |
| 36845 | + m = (m & ~U64_BIT(52)) | ((u64)(1075-e)<<52); |
| 36846 | + } |
| 36847 | + memcpy(&r,&m,8); |
| 36759 | 36848 | return r; |
| 36760 | 36849 | } |
| 36761 | 36850 | |
| 36762 | 36851 | /* |
| 36763 | 36852 | ** The string z[] is an text representation of a real number. |
| | @@ -38424,66 +38513,66 @@ |
| 38424 | 38513 | /* 42 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 38425 | 38514 | /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 38426 | 38515 | /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 38427 | 38516 | /* 45 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 38428 | 38517 | /* 46 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 38429 | | - /* 47 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 38430 | | - /* 48 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 38431 | | - /* 49 */ "Program" OpHelp(""), |
| 38432 | | - /* 50 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 38518 | + /* 47 */ "IFindKey" OpHelp(""), |
| 38519 | + /* 48 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 38520 | + /* 49 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 38521 | + /* 50 */ "Program" OpHelp(""), |
| 38433 | 38522 | /* 51 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 38434 | 38523 | /* 52 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 38435 | 38524 | /* 53 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| 38436 | 38525 | /* 54 */ "Eq" OpHelp("IF r[P3]==r[P1]"), |
| 38437 | 38526 | /* 55 */ "Gt" OpHelp("IF r[P3]>r[P1]"), |
| 38438 | 38527 | /* 56 */ "Le" OpHelp("IF r[P3]<=r[P1]"), |
| 38439 | 38528 | /* 57 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 38440 | 38529 | /* 58 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 38441 | 38530 | /* 59 */ "ElseEq" OpHelp(""), |
| 38442 | | - /* 60 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 38443 | | - /* 61 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 38444 | | - /* 62 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 38445 | | - /* 63 */ "IncrVacuum" OpHelp(""), |
| 38446 | | - /* 64 */ "VNext" OpHelp(""), |
| 38447 | | - /* 65 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"), |
| 38448 | | - /* 66 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"), |
| 38449 | | - /* 67 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"), |
| 38450 | | - /* 68 */ "Return" OpHelp(""), |
| 38451 | | - /* 69 */ "EndCoroutine" OpHelp(""), |
| 38452 | | - /* 70 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 38453 | | - /* 71 */ "Halt" OpHelp(""), |
| 38454 | | - /* 72 */ "Integer" OpHelp("r[P2]=P1"), |
| 38455 | | - /* 73 */ "Int64" OpHelp("r[P2]=P4"), |
| 38456 | | - /* 74 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 38457 | | - /* 75 */ "BeginSubrtn" OpHelp("r[P2]=NULL"), |
| 38458 | | - /* 76 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 38459 | | - /* 77 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 38460 | | - /* 78 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 38461 | | - /* 79 */ "Variable" OpHelp("r[P2]=parameter(P1)"), |
| 38462 | | - /* 80 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 38463 | | - /* 81 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 38464 | | - /* 82 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 38465 | | - /* 83 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 38466 | | - /* 84 */ "FkCheck" OpHelp(""), |
| 38467 | | - /* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 38468 | | - /* 86 */ "CollSeq" OpHelp(""), |
| 38469 | | - /* 87 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 38470 | | - /* 88 */ "RealAffinity" OpHelp(""), |
| 38471 | | - /* 89 */ "Cast" OpHelp("affinity(r[P1])"), |
| 38472 | | - /* 90 */ "Permutation" OpHelp(""), |
| 38473 | | - /* 91 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 38474 | | - /* 92 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), |
| 38475 | | - /* 93 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"), |
| 38476 | | - /* 94 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), |
| 38477 | | - /* 95 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"), |
| 38478 | | - /* 96 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"), |
| 38479 | | - /* 97 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 38480 | | - /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 38481 | | - /* 99 */ "Count" OpHelp("r[P2]=count()"), |
| 38482 | | - /* 100 */ "ReadCookie" OpHelp(""), |
| 38483 | | - /* 101 */ "SetCookie" OpHelp(""), |
| 38484 | | - /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 38531 | + /* 60 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 38532 | + /* 61 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 38533 | + /* 62 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 38534 | + /* 63 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 38535 | + /* 64 */ "IncrVacuum" OpHelp(""), |
| 38536 | + /* 65 */ "VNext" OpHelp(""), |
| 38537 | + /* 66 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"), |
| 38538 | + /* 67 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"), |
| 38539 | + /* 68 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"), |
| 38540 | + /* 69 */ "Return" OpHelp(""), |
| 38541 | + /* 70 */ "EndCoroutine" OpHelp(""), |
| 38542 | + /* 71 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 38543 | + /* 72 */ "Halt" OpHelp(""), |
| 38544 | + /* 73 */ "Integer" OpHelp("r[P2]=P1"), |
| 38545 | + /* 74 */ "Int64" OpHelp("r[P2]=P4"), |
| 38546 | + /* 75 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 38547 | + /* 76 */ "BeginSubrtn" OpHelp("r[P2]=NULL"), |
| 38548 | + /* 77 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 38549 | + /* 78 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 38550 | + /* 79 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 38551 | + /* 80 */ "Variable" OpHelp("r[P2]=parameter(P1)"), |
| 38552 | + /* 81 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 38553 | + /* 82 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 38554 | + /* 83 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 38555 | + /* 84 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 38556 | + /* 85 */ "FkCheck" OpHelp(""), |
| 38557 | + /* 86 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 38558 | + /* 87 */ "CollSeq" OpHelp(""), |
| 38559 | + /* 88 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 38560 | + /* 89 */ "RealAffinity" OpHelp(""), |
| 38561 | + /* 90 */ "Cast" OpHelp("affinity(r[P1])"), |
| 38562 | + /* 91 */ "Permutation" OpHelp(""), |
| 38563 | + /* 92 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 38564 | + /* 93 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), |
| 38565 | + /* 94 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"), |
| 38566 | + /* 95 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), |
| 38567 | + /* 96 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"), |
| 38568 | + /* 97 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"), |
| 38569 | + /* 98 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 38570 | + /* 99 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 38571 | + /* 100 */ "Count" OpHelp("r[P2]=count()"), |
| 38572 | + /* 101 */ "ReadCookie" OpHelp(""), |
| 38573 | + /* 102 */ "SetCookie" OpHelp(""), |
| 38485 | 38574 | /* 103 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 38486 | 38575 | /* 104 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 38487 | 38576 | /* 105 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 38488 | 38577 | /* 106 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 38489 | 38578 | /* 107 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| | @@ -38490,88 +38579,89 @@ |
| 38490 | 38579 | /* 108 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 38491 | 38580 | /* 109 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 38492 | 38581 | /* 110 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 38493 | 38582 | /* 111 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 38494 | 38583 | /* 112 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 38495 | | - /* 113 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 38496 | | - /* 114 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 38584 | + /* 113 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 38585 | + /* 114 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 38497 | 38586 | /* 115 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), |
| 38498 | | - /* 116 */ "OpenDup" OpHelp(""), |
| 38499 | | - /* 117 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 38587 | + /* 116 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 38588 | + /* 117 */ "OpenDup" OpHelp(""), |
| 38500 | 38589 | /* 118 */ "String8" OpHelp("r[P2]='P4'"), |
| 38501 | | - /* 119 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 38502 | | - /* 120 */ "SorterOpen" OpHelp(""), |
| 38503 | | - /* 121 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 38504 | | - /* 122 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 38505 | | - /* 123 */ "Close" OpHelp(""), |
| 38506 | | - /* 124 */ "ColumnsUsed" OpHelp(""), |
| 38507 | | - /* 125 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"), |
| 38508 | | - /* 126 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"), |
| 38509 | | - /* 127 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 38510 | | - /* 128 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 38511 | | - /* 129 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 38512 | | - /* 130 */ "RowCell" OpHelp(""), |
| 38513 | | - /* 131 */ "Delete" OpHelp(""), |
| 38514 | | - /* 132 */ "ResetCount" OpHelp(""), |
| 38515 | | - /* 133 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 38516 | | - /* 134 */ "SorterData" OpHelp("r[P2]=data"), |
| 38517 | | - /* 135 */ "RowData" OpHelp("r[P2]=data"), |
| 38518 | | - /* 136 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"), |
| 38519 | | - /* 137 */ "NullRow" OpHelp(""), |
| 38520 | | - /* 138 */ "SeekEnd" OpHelp(""), |
| 38521 | | - /* 139 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 38522 | | - /* 140 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 38523 | | - /* 141 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 38524 | | - /* 142 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), |
| 38525 | | - /* 143 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 38526 | | - /* 144 */ "FinishSeek" OpHelp(""), |
| 38527 | | - /* 145 */ "Destroy" OpHelp(""), |
| 38528 | | - /* 146 */ "Clear" OpHelp(""), |
| 38529 | | - /* 147 */ "ResetSorter" OpHelp(""), |
| 38530 | | - /* 148 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), |
| 38531 | | - /* 149 */ "SqlExec" OpHelp(""), |
| 38532 | | - /* 150 */ "ParseSchema" OpHelp(""), |
| 38533 | | - /* 151 */ "LoadAnalysis" OpHelp(""), |
| 38534 | | - /* 152 */ "DropTable" OpHelp(""), |
| 38535 | | - /* 153 */ "DropIndex" OpHelp(""), |
| 38590 | + /* 119 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 38591 | + /* 120 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 38592 | + /* 121 */ "SorterOpen" OpHelp(""), |
| 38593 | + /* 122 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 38594 | + /* 123 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 38595 | + /* 124 */ "Close" OpHelp(""), |
| 38596 | + /* 125 */ "ColumnsUsed" OpHelp(""), |
| 38597 | + /* 126 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"), |
| 38598 | + /* 127 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"), |
| 38599 | + /* 128 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 38600 | + /* 129 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 38601 | + /* 130 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 38602 | + /* 131 */ "RowCell" OpHelp(""), |
| 38603 | + /* 132 */ "Delete" OpHelp(""), |
| 38604 | + /* 133 */ "ResetCount" OpHelp(""), |
| 38605 | + /* 134 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 38606 | + /* 135 */ "SorterData" OpHelp("r[P2]=data"), |
| 38607 | + /* 136 */ "RowData" OpHelp("r[P2]=data"), |
| 38608 | + /* 137 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"), |
| 38609 | + /* 138 */ "NullRow" OpHelp(""), |
| 38610 | + /* 139 */ "SeekEnd" OpHelp(""), |
| 38611 | + /* 140 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 38612 | + /* 141 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 38613 | + /* 142 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 38614 | + /* 143 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), |
| 38615 | + /* 144 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 38616 | + /* 145 */ "FinishSeek" OpHelp(""), |
| 38617 | + /* 146 */ "Destroy" OpHelp(""), |
| 38618 | + /* 147 */ "Clear" OpHelp(""), |
| 38619 | + /* 148 */ "ResetSorter" OpHelp(""), |
| 38620 | + /* 149 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), |
| 38621 | + /* 150 */ "SqlExec" OpHelp(""), |
| 38622 | + /* 151 */ "ParseSchema" OpHelp(""), |
| 38623 | + /* 152 */ "LoadAnalysis" OpHelp(""), |
| 38624 | + /* 153 */ "DropTable" OpHelp(""), |
| 38536 | 38625 | /* 154 */ "Real" OpHelp("r[P2]=P4"), |
| 38537 | | - /* 155 */ "DropTrigger" OpHelp(""), |
| 38538 | | - /* 156 */ "IntegrityCk" OpHelp(""), |
| 38539 | | - /* 157 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 38540 | | - /* 158 */ "Param" OpHelp(""), |
| 38541 | | - /* 159 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 38542 | | - /* 160 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 38543 | | - /* 161 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 38544 | | - /* 162 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), |
| 38545 | | - /* 163 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 38546 | | - /* 164 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 38547 | | - /* 165 */ "AggValue" OpHelp("r[P3]=value N=P2"), |
| 38548 | | - /* 166 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 38549 | | - /* 167 */ "Expire" OpHelp(""), |
| 38550 | | - /* 168 */ "CursorLock" OpHelp(""), |
| 38551 | | - /* 169 */ "CursorUnlock" OpHelp(""), |
| 38552 | | - /* 170 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 38553 | | - /* 171 */ "VBegin" OpHelp(""), |
| 38554 | | - /* 172 */ "VCreate" OpHelp(""), |
| 38555 | | - /* 173 */ "VDestroy" OpHelp(""), |
| 38556 | | - /* 174 */ "VOpen" OpHelp(""), |
| 38557 | | - /* 175 */ "VCheck" OpHelp(""), |
| 38558 | | - /* 176 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), |
| 38559 | | - /* 177 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 38560 | | - /* 178 */ "VRename" OpHelp(""), |
| 38561 | | - /* 179 */ "Pagecount" OpHelp(""), |
| 38562 | | - /* 180 */ "MaxPgcnt" OpHelp(""), |
| 38563 | | - /* 181 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), |
| 38564 | | - /* 182 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"), |
| 38565 | | - /* 183 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"), |
| 38566 | | - /* 184 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), |
| 38567 | | - /* 185 */ "Trace" OpHelp(""), |
| 38568 | | - /* 186 */ "CursorHint" OpHelp(""), |
| 38569 | | - /* 187 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 38570 | | - /* 188 */ "Noop" OpHelp(""), |
| 38571 | | - /* 189 */ "Explain" OpHelp(""), |
| 38572 | | - /* 190 */ "Abortable" OpHelp(""), |
| 38626 | + /* 155 */ "DropIndex" OpHelp(""), |
| 38627 | + /* 156 */ "DropTrigger" OpHelp(""), |
| 38628 | + /* 157 */ "IntegrityCk" OpHelp(""), |
| 38629 | + /* 158 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 38630 | + /* 159 */ "Param" OpHelp(""), |
| 38631 | + /* 160 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 38632 | + /* 161 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 38633 | + /* 162 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 38634 | + /* 163 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), |
| 38635 | + /* 164 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 38636 | + /* 165 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 38637 | + /* 166 */ "AggValue" OpHelp("r[P3]=value N=P2"), |
| 38638 | + /* 167 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 38639 | + /* 168 */ "Expire" OpHelp(""), |
| 38640 | + /* 169 */ "CursorLock" OpHelp(""), |
| 38641 | + /* 170 */ "CursorUnlock" OpHelp(""), |
| 38642 | + /* 171 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 38643 | + /* 172 */ "VBegin" OpHelp(""), |
| 38644 | + /* 173 */ "VCreate" OpHelp(""), |
| 38645 | + /* 174 */ "VDestroy" OpHelp(""), |
| 38646 | + /* 175 */ "VOpen" OpHelp(""), |
| 38647 | + /* 176 */ "VCheck" OpHelp(""), |
| 38648 | + /* 177 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), |
| 38649 | + /* 178 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 38650 | + /* 179 */ "VRename" OpHelp(""), |
| 38651 | + /* 180 */ "Pagecount" OpHelp(""), |
| 38652 | + /* 181 */ "MaxPgcnt" OpHelp(""), |
| 38653 | + /* 182 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), |
| 38654 | + /* 183 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"), |
| 38655 | + /* 184 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"), |
| 38656 | + /* 185 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), |
| 38657 | + /* 186 */ "Trace" OpHelp(""), |
| 38658 | + /* 187 */ "CursorHint" OpHelp(""), |
| 38659 | + /* 188 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 38660 | + /* 189 */ "Noop" OpHelp(""), |
| 38661 | + /* 190 */ "Explain" OpHelp(""), |
| 38662 | + /* 191 */ "Abortable" OpHelp(""), |
| 38573 | 38663 | }; |
| 38574 | 38664 | return azName[i]; |
| 38575 | 38665 | } |
| 38576 | 38666 | #endif |
| 38577 | 38667 | |
| | @@ -73855,11 +73945,11 @@ |
| 73855 | 73945 | MemPage *pPage, /* Page containing the cell */ |
| 73856 | 73946 | u8 *pCell, /* Pointer to the cell text. */ |
| 73857 | 73947 | CellInfo *pInfo /* Fill in this structure */ |
| 73858 | 73948 | ){ |
| 73859 | 73949 | u8 *pIter; /* For scanning through pCell */ |
| 73860 | | - u32 nPayload; /* Number of bytes of cell payload */ |
| 73950 | + u64 nPayload; /* Number of bytes of cell payload */ |
| 73861 | 73951 | u64 iKey; /* Extracted Key value */ |
| 73862 | 73952 | |
| 73863 | 73953 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); |
| 73864 | 73954 | assert( pPage->leaf==0 || pPage->leaf==1 ); |
| 73865 | 73955 | assert( pPage->intKeyLeaf ); |
| | @@ -73877,10 +73967,11 @@ |
| 73877 | 73967 | u8 *pEnd = &pIter[8]; |
| 73878 | 73968 | nPayload &= 0x7f; |
| 73879 | 73969 | do{ |
| 73880 | 73970 | nPayload = (nPayload<<7) | (*++pIter & 0x7f); |
| 73881 | 73971 | }while( (*pIter)>=0x80 && pIter<pEnd ); |
| 73972 | + nPayload &= 0xffffffff; |
| 73882 | 73973 | } |
| 73883 | 73974 | pIter++; |
| 73884 | 73975 | |
| 73885 | 73976 | /* The next block of code is equivalent to: |
| 73886 | 73977 | ** |
| | @@ -73920,15 +74011,14 @@ |
| 73920 | 74011 | } |
| 73921 | 74012 | } |
| 73922 | 74013 | pIter++; |
| 73923 | 74014 | |
| 73924 | 74015 | pInfo->nKey = *(i64*)&iKey; |
| 73925 | | - pInfo->nPayload = nPayload; |
| 74016 | + pInfo->nPayload = (u32)nPayload; |
| 73926 | 74017 | pInfo->pPayload = pIter; |
| 73927 | 74018 | testcase( nPayload==pPage->maxLocal ); |
| 73928 | 74019 | testcase( nPayload==(u32)pPage->maxLocal+1 ); |
| 73929 | | - assert( nPayload>=0 ); |
| 73930 | 74020 | assert( pPage->maxLocal <= BT_MAX_LOCAL ); |
| 73931 | 74021 | if( nPayload<=pPage->maxLocal ){ |
| 73932 | 74022 | /* This is the (easy) common case where the entire payload fits |
| 73933 | 74023 | ** on the local page. No overflow is required. |
| 73934 | 74024 | */ |
| | @@ -89149,10 +89239,14 @@ |
| 89149 | 89239 | break; |
| 89150 | 89240 | } |
| 89151 | 89241 | case P4_TABLE: { |
| 89152 | 89242 | zP4 = pOp->p4.pTab->zName; |
| 89153 | 89243 | break; |
| 89244 | + } |
| 89245 | + case P4_INDEX: { |
| 89246 | + zP4 = pOp->p4.pIdx->zName; |
| 89247 | + break; |
| 89154 | 89248 | } |
| 89155 | 89249 | case P4_SUBRTNSIG: { |
| 89156 | 89250 | SubrtnSig *pSig = pOp->p4.pSubrtnSig; |
| 89157 | 89251 | sqlite3_str_appendf(&x, "subrtnsig:%d,%s", pSig->selId, pSig->zAff); |
| 89158 | 89252 | break; |
| | @@ -92539,10 +92633,227 @@ |
| 92539 | 92633 | v->expmask |= 0x80000000; |
| 92540 | 92634 | }else{ |
| 92541 | 92635 | v->expmask |= ((u32)1 << (iVar-1)); |
| 92542 | 92636 | } |
| 92543 | 92637 | } |
| 92638 | + |
| 92639 | +/* |
| 92640 | +** Helper function for vdbeIsMatchingIndexKey(). Return true if column |
| 92641 | +** iCol should be ignored when comparing a record with a record from |
| 92642 | +** an index on disk. The field should be ignored if: |
| 92643 | +** |
| 92644 | +** * the corresponding bit in mask is set, and |
| 92645 | +** * either: |
| 92646 | +** - bIntegrity is false, or |
| 92647 | +** - the two Mem values are both real values that differ by |
| 92648 | +** BTREE_ULPDISTORTION or fewer ULPs. |
| 92649 | +*/ |
| 92650 | +static int vdbeSkipField( |
| 92651 | + Bitmask mask, /* Mask of indexed expression fields */ |
| 92652 | + int iCol, /* Column of index being considered */ |
| 92653 | + Mem *pMem1, /* Expected index value */ |
| 92654 | + Mem *pMem2, /* Actual indexed value */ |
| 92655 | + int bIntegrity /* True if running PRAGMA integrity_check */ |
| 92656 | +){ |
| 92657 | +#define BTREE_ULPDISTORTION 2 |
| 92658 | + if( iCol>=BMS || (mask & MASKBIT(iCol))==0 ) return 0; |
| 92659 | + if( bIntegrity==0 ) return 1; |
| 92660 | + if( (pMem1->flags & MEM_Real) && (pMem2->flags & MEM_Real) ){ |
| 92661 | + u64 m1, m2; |
| 92662 | + memcpy(&m1,&pMem1->u.r,8); |
| 92663 | + memcpy(&m2,&pMem2->u.r,8); |
| 92664 | + if( (m1<m2 ? m2-m1 : m1-m2) <= BTREE_ULPDISTORTION ){ |
| 92665 | + return 1; |
| 92666 | + } |
| 92667 | + } |
| 92668 | + return 0; |
| 92669 | +} |
| 92670 | + |
| 92671 | +/* |
| 92672 | +** This function compares the unpacked record with the current key that |
| 92673 | +** cursor pCur points to. If bInt is false, all fields for which the |
| 92674 | +** corresponding bit in parameter "mask" is set are ignored. Or, if |
| 92675 | +** bInt is true, then a difference of BTREE_ULPDISTORTION or fewer ULPs |
| 92676 | +** in real values is overlooked for fields with the corresponding bit |
| 92677 | +** set in mask. |
| 92678 | +** |
| 92679 | +** Return the usual less than zero, zero, or greater than zero if the |
| 92680 | +** remaining fields of the cursor cursor key are less than, equal to or |
| 92681 | +** greater than those in (*p). |
| 92682 | +*/ |
| 92683 | +static int vdbeIsMatchingIndexKey( |
| 92684 | + BtCursor *pCur, /* Cursor open on index */ |
| 92685 | + int bInt, /* True for integrity_check-style search */ |
| 92686 | + Bitmask mask, /* Mask of columns to skip */ |
| 92687 | + UnpackedRecord *p, /* Index key being deleted */ |
| 92688 | + int *piRes /* 0 for a match, non-zero for not a match */ |
| 92689 | +){ |
| 92690 | + u8 *aRec = 0; |
| 92691 | + u32 nRec = 0; |
| 92692 | + Mem mem; |
| 92693 | + int rc = SQLITE_OK; |
| 92694 | + |
| 92695 | + memset(&mem, 0, sizeof(mem)); |
| 92696 | + mem.enc = p->pKeyInfo->enc; |
| 92697 | + mem.db = p->pKeyInfo->db; |
| 92698 | + nRec = sqlite3BtreePayloadSize(pCur); |
| 92699 | + if( nRec>0x7fffffff ){ |
| 92700 | + return SQLITE_CORRUPT_BKPT; |
| 92701 | + } |
| 92702 | + |
| 92703 | + /* Allocate 5 extra bytes at the end of the buffer. This allows the |
| 92704 | + ** getVarint32() call below to read slightly past the end of the buffer |
| 92705 | + ** if the record is corrupt. */ |
| 92706 | + aRec = sqlite3MallocZero(nRec+5); |
| 92707 | + if( aRec==0 ){ |
| 92708 | + rc = SQLITE_NOMEM_BKPT; |
| 92709 | + }else{ |
| 92710 | + rc = sqlite3BtreePayload(pCur, 0, nRec, aRec); |
| 92711 | + } |
| 92712 | + |
| 92713 | + if( rc==SQLITE_OK ){ |
| 92714 | + u32 szHdr = 0; /* Size of record header in bytes */ |
| 92715 | + u32 idxHdr = 0; /* Current index in header */ |
| 92716 | + |
| 92717 | + idxHdr = getVarint32(aRec, szHdr); |
| 92718 | + if( szHdr>98307 ){ |
| 92719 | + rc = SQLITE_CORRUPT; |
| 92720 | + }else{ |
| 92721 | + int res = 0; /* Result of this function call */ |
| 92722 | + u32 idxRec = szHdr; /* Index of next field in record body */ |
| 92723 | + int ii = 0; /* Iterator variable */ |
| 92724 | + |
| 92725 | + int nCol = p->pKeyInfo->nAllField; |
| 92726 | + for(ii=0; ii<nCol && rc==SQLITE_OK; ii++){ |
| 92727 | + u32 iSerial = 0; |
| 92728 | + int nSerial = 0; |
| 92729 | + |
| 92730 | + if( idxHdr>=szHdr ){ |
| 92731 | + rc = SQLITE_CORRUPT_BKPT; |
| 92732 | + break; |
| 92733 | + } |
| 92734 | + idxHdr += getVarint32(&aRec[idxHdr], iSerial); |
| 92735 | + nSerial = sqlite3VdbeSerialTypeLen(iSerial); |
| 92736 | + if( (idxRec+nSerial)>nRec ){ |
| 92737 | + rc = SQLITE_CORRUPT_BKPT; |
| 92738 | + }else{ |
| 92739 | + sqlite3VdbeSerialGet(&aRec[idxRec], iSerial, &mem); |
| 92740 | + if( vdbeSkipField(mask, ii, &p->aMem[ii], &mem, bInt)==0 ){ |
| 92741 | + res = sqlite3MemCompare(&mem, &p->aMem[ii], p->pKeyInfo->aColl[ii]); |
| 92742 | + if( res!=0 ) break; |
| 92743 | + } |
| 92744 | + } |
| 92745 | + idxRec += sqlite3VdbeSerialTypeLen(iSerial); |
| 92746 | + } |
| 92747 | + |
| 92748 | + *piRes = res; |
| 92749 | + } |
| 92750 | + } |
| 92751 | + |
| 92752 | + sqlite3_free(aRec); |
| 92753 | + return rc; |
| 92754 | +} |
| 92755 | + |
| 92756 | +/* |
| 92757 | +** This is called when the record in (*p) should be found in the index |
| 92758 | +** opened by cursor pCur, but was not. This may happen as part of a DELETE |
| 92759 | +** operation or an integrity check. |
| 92760 | +** |
| 92761 | +** One reason that an exact match was not found may be the EIIB bug - that |
| 92762 | +** a text-to-float conversion may have caused a real value in record (*p) |
| 92763 | +** to be slightly different from its counterpart on disk. This function |
| 92764 | +** attempts to find the right index record. If it does find the right |
| 92765 | +** record, it leaves *pCur pointing to it and sets (*pRes) to 0 before |
| 92766 | +** returning. Otherwise, (*pRes) is set to non-zero and an SQLite error |
| 92767 | +** code returned. |
| 92768 | +** |
| 92769 | +** The algorithm used to find the correct record is: |
| 92770 | +** |
| 92771 | +** * Scan up to BTREE_FDK_RANGE entries either side of the current entry. |
| 92772 | +** If parameter bIntegrity is false, then all fields that are indexed |
| 92773 | +** expressions or virtual table columns are omitted from the comparison. |
| 92774 | +** If bIntegrity is true, then small differences in real values in |
| 92775 | +** such fields are overlooked, but they are not omitted from the comparison |
| 92776 | +** altogether. |
| 92777 | +** |
| 92778 | +** * If the above fails to find an entry and bIntegrity is false, search |
| 92779 | +** the entire index. |
| 92780 | +*/ |
| 92781 | +SQLITE_PRIVATE int sqlite3VdbeFindIndexKey( |
| 92782 | + BtCursor *pCur, |
| 92783 | + Index *pIdx, |
| 92784 | + UnpackedRecord *p, |
| 92785 | + int *pRes, |
| 92786 | + int bIntegrity |
| 92787 | +){ |
| 92788 | +#define BTREE_FDK_RANGE 10 |
| 92789 | + int nStep = 0; |
| 92790 | + int res = 1; |
| 92791 | + int rc = SQLITE_OK; |
| 92792 | + int ii = 0; |
| 92793 | + |
| 92794 | + /* Calculate a mask based on the first 64 columns of the index. The mask |
| 92795 | + ** bit is set if the corresponding index field is either an expression |
| 92796 | + ** or a virtual column of the table. */ |
| 92797 | + Bitmask mask = 0; |
| 92798 | + for(ii=0; ii<MIN(pIdx->nColumn, BMS); ii++){ |
| 92799 | + int iCol = pIdx->aiColumn[ii]; |
| 92800 | + if( (iCol==XN_EXPR) |
| 92801 | + || (iCol>=0 && (pIdx->pTable->aCol[iCol].colFlags & COLFLAG_VIRTUAL)) |
| 92802 | + ){ |
| 92803 | + mask |= MASKBIT(ii); |
| 92804 | + } |
| 92805 | + } |
| 92806 | + |
| 92807 | + /* If the mask is 0 at this point, then the index contains no expressions |
| 92808 | + ** or virtual columns. So do not search for a match - return so that the |
| 92809 | + ** caller may declare the db corrupt immediately. Or, if mask is non-zero, |
| 92810 | + ** proceed. */ |
| 92811 | + if( mask!=0 ){ |
| 92812 | + |
| 92813 | + /* Move the cursor back BTREE_FDK_RANGE entries. If this hits an EOF, |
| 92814 | + ** position the cursor at the first entry in the index and set nStep |
| 92815 | + ** to -1 so that the first loop below scans the entire index. Otherwise, |
| 92816 | + ** set nStep to BTREE_FDK_RANGE*2 so that the first loop below scans |
| 92817 | + ** just that many entries. */ |
| 92818 | + for(ii=0; sqlite3BtreeEof(pCur)==0 && ii<BTREE_FDK_RANGE; ii++){ |
| 92819 | + rc = sqlite3BtreePrevious(pCur, 0); |
| 92820 | + } |
| 92821 | + if( rc==SQLITE_DONE ){ |
| 92822 | + rc = sqlite3BtreeFirst(pCur, &res); |
| 92823 | + nStep = -1; |
| 92824 | + }else{ |
| 92825 | + nStep = BTREE_FDK_RANGE*2; |
| 92826 | + } |
| 92827 | + |
| 92828 | + /* This loop runs at most twice to search for a key with matching PK |
| 92829 | + ** fields in the index. The second iteration always searches the entire |
| 92830 | + ** index. The first iteration searches nStep entries starting with the |
| 92831 | + ** current cursor entry if (nStep>=0), or the entire index if (nStep<0). */ |
| 92832 | + while( sqlite3BtreeCursorIsValidNN(pCur) ){ |
| 92833 | + for(ii=0; rc==SQLITE_OK && (ii<nStep || nStep<0); ii++){ |
| 92834 | + rc = vdbeIsMatchingIndexKey(pCur, bIntegrity, mask, p, &res); |
| 92835 | + if( res==0 || rc!=SQLITE_OK ) break; |
| 92836 | + rc = sqlite3BtreeNext(pCur, 0); |
| 92837 | + } |
| 92838 | + if( rc==SQLITE_DONE ){ |
| 92839 | + rc = SQLITE_OK; |
| 92840 | + assert( res!=0 ); |
| 92841 | + } |
| 92842 | + if( nStep<0 || rc!=SQLITE_OK || res==0 || bIntegrity ) break; |
| 92843 | + |
| 92844 | + /* The first, non-exhaustive, search failed to find an entry with |
| 92845 | + ** matching PK fields. So restart for an exhaustive search of the |
| 92846 | + ** entire index. */ |
| 92847 | + nStep = -1; |
| 92848 | + rc = sqlite3BtreeFirst(pCur, &res); |
| 92849 | + } |
| 92850 | + } |
| 92851 | + |
| 92852 | + *pRes = res; |
| 92853 | + return rc; |
| 92854 | +} |
| 92544 | 92855 | |
| 92545 | 92856 | #ifndef SQLITE_OMIT_DATETIME_FUNCS |
| 92546 | 92857 | /* |
| 92547 | 92858 | ** Cause a function to throw an error if it was call from OP_PureFunc |
| 92548 | 92859 | ** rather than OP_Function. |
| | @@ -102274,16 +102585,18 @@ |
| 102274 | 102585 | rc = sqlite3VdbeSorterWrite(pC, pIn2); |
| 102275 | 102586 | if( rc) goto abort_due_to_error; |
| 102276 | 102587 | break; |
| 102277 | 102588 | } |
| 102278 | 102589 | |
| 102279 | | -/* Opcode: IdxDelete P1 P2 P3 * * |
| 102590 | +/* Opcode: IdxDelete P1 P2 P3 P4 * |
| 102280 | 102591 | ** Synopsis: key=r[P2@P3] |
| 102281 | 102592 | ** |
| 102282 | 102593 | ** The content of P3 registers starting at register P2 form |
| 102283 | 102594 | ** an unpacked index key. This opcode removes that entry from the |
| 102284 | 102595 | ** index opened by cursor P1. |
| 102596 | +** |
| 102597 | +** P4 is a pointer to an Index structure. |
| 102285 | 102598 | ** |
| 102286 | 102599 | ** Raise an SQLITE_CORRUPT_INDEX error if no matching index entry is found |
| 102287 | 102600 | ** and not in writable_schema mode. |
| 102288 | 102601 | */ |
| 102289 | 102602 | case OP_IdxDelete: { |
| | @@ -102305,17 +102618,26 @@ |
| 102305 | 102618 | r.nField = (u16)pOp->p3; |
| 102306 | 102619 | r.default_rc = 0; |
| 102307 | 102620 | r.aMem = &aMem[pOp->p2]; |
| 102308 | 102621 | rc = sqlite3BtreeIndexMoveto(pCrsr, &r, &res); |
| 102309 | 102622 | if( rc ) goto abort_due_to_error; |
| 102310 | | - if( res==0 ){ |
| 102311 | | - rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE); |
| 102312 | | - if( rc ) goto abort_due_to_error; |
| 102313 | | - }else if( !sqlite3WritableSchema(db) ){ |
| 102314 | | - rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption"); |
| 102315 | | - goto abort_due_to_error; |
| 102623 | + if( res!=0 ){ |
| 102624 | + rc = sqlite3VdbeFindIndexKey(pCrsr, pOp->p4.pIdx, &r, &res, 0); |
| 102625 | + if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 102626 | + if( res!=0 ){ |
| 102627 | + if( !sqlite3WritableSchema(db) ){ |
| 102628 | + rc = sqlite3ReportError( |
| 102629 | + SQLITE_CORRUPT_INDEX, __LINE__, "index corruption"); |
| 102630 | + goto abort_due_to_error; |
| 102631 | + } |
| 102632 | + pC->cacheStatus = CACHE_STALE; |
| 102633 | + pC->seekResult = 0; |
| 102634 | + break; |
| 102635 | + } |
| 102316 | 102636 | } |
| 102637 | + rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE); |
| 102638 | + if( rc ) goto abort_due_to_error; |
| 102317 | 102639 | assert( pC->deferredMoveto==0 ); |
| 102318 | 102640 | pC->cacheStatus = CACHE_STALE; |
| 102319 | 102641 | pC->seekResult = 0; |
| 102320 | 102642 | break; |
| 102321 | 102643 | } |
| | @@ -102938,10 +103260,62 @@ |
| 102938 | 103260 | } |
| 102939 | 103261 | UPDATE_MAX_BLOBSIZE(pIn1); |
| 102940 | 103262 | sqlite3VdbeChangeEncoding(pIn1, encoding); |
| 102941 | 103263 | goto check_for_interrupt; |
| 102942 | 103264 | } |
| 103265 | + |
| 103266 | +/* Opcode: IFindKey P1 P2 P3 P4 * |
| 103267 | +** |
| 103268 | +** This instruction always follows an OP_Found with the same P1, P2 and P3 |
| 103269 | +** values as this instruction and a non-zero P4 value. The P4 value to |
| 103270 | +** this opcode is of type P4_INDEX and contains a pointer to the Index |
| 103271 | +** object of for the index being searched. |
| 103272 | +** |
| 103273 | +** This opcode uses sqlite3VdbeFindIndexKey() to search around the current |
| 103274 | +** cursor location for an index key that exactly matches all fields that |
| 103275 | +** are not indexed expressions or references to VIRTUAL generated columns, |
| 103276 | +** and either exactly match or are real numbers that are within 2 ULPs of |
| 103277 | +** each other if the don't match. |
| 103278 | +** |
| 103279 | +** To put it another way, this opcode looks for nearby index entries that |
| 103280 | +** are very close to the search key, but which might have small differences |
| 103281 | +** in floating-point values that come via an expression. |
| 103282 | +** |
| 103283 | +** If no nearby alternative entry is found in cursor P1, then jump to P2. |
| 103284 | +** But if a close match is found, fall through. |
| 103285 | +** |
| 103286 | +** This opcode is used by PRAGMA integrity_check to help distinguish |
| 103287 | +** between truely corrupt indexes and expression indexes that are holding |
| 103288 | +** floating-point values that are off by one or two ULPs. |
| 103289 | +*/ |
| 103290 | +case OP_IFindKey: { /* jump, in3 */ |
| 103291 | + VdbeCursor *pC; |
| 103292 | + int res; |
| 103293 | + UnpackedRecord r; |
| 103294 | + |
| 103295 | + assert( pOp[-1].opcode==OP_Found ); |
| 103296 | + assert( pOp[-1].p1==pOp->p1 ); |
| 103297 | + assert( pOp[-1].p3==pOp->p3 ); |
| 103298 | + pC = p->apCsr[pOp->p1]; |
| 103299 | + assert( pOp->p4type==P4_INDEX ); |
| 103300 | + assert( pC->eCurType==CURTYPE_BTREE ); |
| 103301 | + assert( pC->uc.pCursor!=0 ); |
| 103302 | + assert( pC->isTable==0 ); |
| 103303 | + |
| 103304 | + memset(&r, 0, sizeof(r)); |
| 103305 | + r.aMem = &aMem[pOp->p3]; |
| 103306 | + r.nField = pOp->p4.pIdx->nColumn; |
| 103307 | + r.pKeyInfo = pC->pKeyInfo; |
| 103308 | + |
| 103309 | + rc = sqlite3VdbeFindIndexKey(pC->uc.pCursor, pOp->p4.pIdx, &r, &res, 1); |
| 103310 | + if( rc || res!=0 ){ |
| 103311 | + rc = SQLITE_OK; |
| 103312 | + goto jump_to_p2; |
| 103313 | + } |
| 103314 | + pC->nullRow = 0; |
| 103315 | + break; |
| 103316 | +}; |
| 102943 | 103317 | #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ |
| 102944 | 103318 | |
| 102945 | 103319 | /* Opcode: RowSetAdd P1 P2 * * * |
| 102946 | 103320 | ** Synopsis: rowset(P1)=r[P2] |
| 102947 | 103321 | ** |
| | @@ -116950,11 +117324,11 @@ |
| 116950 | 117324 | #endif /* SQLITE_OMIT_CAST */ |
| 116951 | 117325 | case TK_IS: |
| 116952 | 117326 | case TK_ISNOT: |
| 116953 | 117327 | op = (op==TK_IS) ? TK_EQ : TK_NE; |
| 116954 | 117328 | p5 = SQLITE_NULLEQ; |
| 116955 | | - /* fall-through */ |
| 117329 | + /* no break */ deliberate_fall_through |
| 116956 | 117330 | case TK_LT: |
| 116957 | 117331 | case TK_LE: |
| 116958 | 117332 | case TK_GT: |
| 116959 | 117333 | case TK_GE: |
| 116960 | 117334 | case TK_NE: |
| | @@ -132751,11 +133125,13 @@ |
| 132751 | 133125 | if( iIdxCur+i==iIdxNoSeek ) continue; |
| 132752 | 133126 | VdbeModuleComment((v, "GenRowIdxDel for %s", pIdx->zName)); |
| 132753 | 133127 | r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1, |
| 132754 | 133128 | &iPartIdxLabel, pPrior, r1); |
| 132755 | 133129 | sqlite3VdbeAddOp3(v, OP_IdxDelete, iIdxCur+i, r1, |
| 132756 | | - pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn); |
| 133130 | + pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn |
| 133131 | + ); |
| 133132 | + sqlite3VdbeChangeP4(v, -1, (const char*)pIdx, P4_INDEX); |
| 132757 | 133133 | sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel); |
| 132758 | 133134 | pPrior = pIdx; |
| 132759 | 133135 | } |
| 132760 | 133136 | } |
| 132761 | 133137 | |
| | @@ -137652,11 +138028,10 @@ |
| 137652 | 138028 | |
| 137653 | 138029 | zFrom = pFKey->pFrom->zName; |
| 137654 | 138030 | nFrom = sqlite3Strlen30(zFrom); |
| 137655 | 138031 | |
| 137656 | 138032 | if( action==OE_Restrict ){ |
| 137657 | | - int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 137658 | 138033 | SrcList *pSrc; |
| 137659 | 138034 | Expr *pRaise; |
| 137660 | 138035 | |
| 137661 | 138036 | pRaise = sqlite3Expr(db, TK_STRING, "FOREIGN KEY constraint failed"), |
| 137662 | 138037 | pRaise = sqlite3PExpr(pParse, TK_RAISE, pRaise, 0); |
| | @@ -137663,14 +138038,14 @@ |
| 137663 | 138038 | if( pRaise ){ |
| 137664 | 138039 | pRaise->affExpr = OE_Abort; |
| 137665 | 138040 | } |
| 137666 | 138041 | pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); |
| 137667 | 138042 | if( pSrc ){ |
| 137668 | | - assert( pSrc->nSrc==1 ); |
| 137669 | | - pSrc->a[0].zName = sqlite3DbStrDup(db, zFrom); |
| 137670 | | - assert( pSrc->a[0].fg.fixedSchema==0 && pSrc->a[0].fg.isSubquery==0 ); |
| 137671 | | - pSrc->a[0].u4.zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName); |
| 138043 | + SrcItem *pItem = &pSrc->a[0]; |
| 138044 | + pItem->zName = sqlite3DbStrDup(db, zFrom); |
| 138045 | + pItem->fg.fixedSchema = 1; |
| 138046 | + pItem->u4.pSchema = pTab->pSchema; |
| 137672 | 138047 | } |
| 137673 | 138048 | pSelect = sqlite3SelectNew(pParse, |
| 137674 | 138049 | sqlite3ExprListAppend(pParse, 0, pRaise), |
| 137675 | 138050 | pSrc, |
| 137676 | 138051 | pWhere, |
| | @@ -137688,11 +138063,14 @@ |
| 137688 | 138063 | ); |
| 137689 | 138064 | if( pTrigger ){ |
| 137690 | 138065 | pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1]; |
| 137691 | 138066 | pStep->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); |
| 137692 | 138067 | if( pStep->pSrc ){ |
| 137693 | | - pStep->pSrc->a[0].zName = sqlite3DbStrNDup(db, zFrom, nFrom); |
| 138068 | + SrcItem *pItem = &pStep->pSrc->a[0]; |
| 138069 | + pItem->zName = sqlite3DbStrNDup(db, zFrom, nFrom); |
| 138070 | + pItem->u4.pSchema = pTab->pSchema; |
| 138071 | + pItem->fg.fixedSchema = 1; |
| 137694 | 138072 | } |
| 137695 | 138073 | pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE); |
| 137696 | 138074 | pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE); |
| 137697 | 138075 | pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); |
| 137698 | 138076 | if( pWhen ){ |
| | @@ -145777,20 +146155,32 @@ |
| 145777 | 146155 | r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3, |
| 145778 | 146156 | pPrior, r1); |
| 145779 | 146157 | pPrior = pIdx; |
| 145780 | 146158 | sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1);/* increment entry count */ |
| 145781 | 146159 | /* Verify that an index entry exists for the current table row */ |
| 145782 | | - jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1, |
| 146160 | + sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1, |
| 145783 | 146161 | pIdx->nColumn); VdbeCoverage(v); |
| 146162 | + jmp2 = sqlite3VdbeAddOp3(v, OP_IFindKey, iIdxCur+j, ckUniq, r1); |
| 146163 | + VdbeCoverage(v); |
| 146164 | + sqlite3VdbeChangeP4(v, -1, (const char*)pIdx, P4_INDEX); |
| 146165 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, |
| 146166 | + sqlite3MPrintf(db, "index %s stores an imprecise floating-point " |
| 146167 | + "value for row ", pIdx->zName), |
| 146168 | + P4_DYNAMIC); |
| 146169 | + sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3); |
| 146170 | + integrityCheckResultRow(v); |
| 146171 | + sqlite3VdbeAddOp2(v, OP_Goto, 0, ckUniq); |
| 146172 | + |
| 146173 | + sqlite3VdbeJumpHere(v, jmp2); |
| 145784 | 146174 | sqlite3VdbeLoadString(v, 3, "row "); |
| 145785 | 146175 | sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3); |
| 145786 | 146176 | sqlite3VdbeLoadString(v, 4, " missing from index "); |
| 145787 | 146177 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 145788 | 146178 | jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName); |
| 145789 | 146179 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 145790 | 146180 | jmp4 = integrityCheckResultRow(v); |
| 145791 | | - sqlite3VdbeJumpHere(v, jmp2); |
| 146181 | + sqlite3VdbeResolveLabel(v, ckUniq); |
| 145792 | 146182 | |
| 145793 | 146183 | /* The OP_IdxRowid opcode is an optimized version of OP_Column |
| 145794 | 146184 | ** that extracts the rowid off the end of the index record. |
| 145795 | 146185 | ** But it only works correctly if index record does not have |
| 145796 | 146186 | ** any extra bytes at the end. Verify that this is the case. */ |
| | @@ -165710,10 +166100,19 @@ |
| 165710 | 166100 | if( ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) ) continue; |
| 165711 | 166101 | pSubWhere = sqlite3ExprAnd(pParse, pSubWhere, |
| 165712 | 166102 | sqlite3ExprDup(pParse->db, pTerm->pExpr, 0)); |
| 165713 | 166103 | } |
| 165714 | 166104 | } |
| 166105 | + if( pLevel->iIdxCur ){ |
| 166106 | + /* pSubWhere may contain expressions that read from an index on the |
| 166107 | + ** table on the RHS of the right join. All such expressions first test |
| 166108 | + ** if the index is pointing at a NULL row, and if so, read from the |
| 166109 | + ** table cursor instead. So ensure that the index cursor really is |
| 166110 | + ** pointing at a NULL row here, so that no values are read from it during |
| 166111 | + ** the scan of the RHS of the RIGHT join below. */ |
| 166112 | + sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur); |
| 166113 | + } |
| 165715 | 166114 | pFrom = &uSrc.sSrc; |
| 165716 | 166115 | pFrom->nSrc = 1; |
| 165717 | 166116 | pFrom->nAlloc = 1; |
| 165718 | 166117 | memcpy(&pFrom->a[0], pTabItem, sizeof(SrcItem)); |
| 165719 | 166118 | pFrom->a[0].fg.jointype = 0; |
| | @@ -170153,15 +170552,20 @@ |
| 170153 | 170552 | ** 1.002.001 t2.t2xy 2 f 010241 N 2 cost 0,56,31 |
| 170154 | 170553 | */ |
| 170155 | 170554 | SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){ |
| 170156 | 170555 | WhereInfo *pWInfo; |
| 170157 | 170556 | if( pWC ){ |
| 170557 | + int nb; |
| 170558 | + SrcItem *pItem; |
| 170559 | + Table *pTab; |
| 170560 | + Bitmask mAll; |
| 170561 | + |
| 170158 | 170562 | pWInfo = pWC->pWInfo; |
| 170159 | | - int nb = 1+(pWInfo->pTabList->nSrc+3)/4; |
| 170160 | | - SrcItem *pItem = pWInfo->pTabList->a + p->iTab; |
| 170161 | | - Table *pTab = pItem->pSTab; |
| 170162 | | - Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1; |
| 170563 | + nb = 1+(pWInfo->pTabList->nSrc+3)/4; |
| 170564 | + pItem = pWInfo->pTabList->a + p->iTab; |
| 170565 | + pTab = pItem->pSTab; |
| 170566 | + mAll = (((Bitmask)1)<<(nb*4)) - 1; |
| 170163 | 170567 | sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId, |
| 170164 | 170568 | p->iTab, nb, p->maskSelf, nb, p->prereq & mAll); |
| 170165 | 170569 | sqlite3DebugPrintf(" %12s", |
| 170166 | 170570 | pItem->zAlias ? pItem->zAlias : pTab->zName); |
| 170167 | 170571 | }else{ |
| | @@ -175258,19 +175662,26 @@ |
| 175258 | 175662 | && (n = pLoop->u.btree.nDistinctCol)>0 |
| 175259 | 175663 | && pIdx->aiRowLogEst[n]>=36 |
| 175260 | 175664 | ){ |
| 175261 | 175665 | int r1 = pParse->nMem+1; |
| 175262 | 175666 | int j, op; |
| 175667 | + int addrIfNull = 0; /* Init to avoid false-positive compiler warning */ |
| 175668 | + if( pLevel->iLeftJoin ){ |
| 175669 | + addrIfNull = sqlite3VdbeAddOp2(v, OP_IfNullRow, pLevel->iIdxCur, r1); |
| 175670 | + } |
| 175263 | 175671 | for(j=0; j<n; j++){ |
| 175264 | 175672 | sqlite3VdbeAddOp3(v, OP_Column, pLevel->iIdxCur, j, r1+j); |
| 175265 | 175673 | } |
| 175266 | 175674 | pParse->nMem += n+1; |
| 175267 | 175675 | op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT; |
| 175268 | 175676 | addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n); |
| 175269 | 175677 | VdbeCoverageIf(v, op==OP_SeekLT); |
| 175270 | 175678 | VdbeCoverageIf(v, op==OP_SeekGT); |
| 175271 | 175679 | sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2); |
| 175680 | + if( pLevel->iLeftJoin ){ |
| 175681 | + sqlite3VdbeJumpHere(v, addrIfNull); |
| 175682 | + } |
| 175272 | 175683 | } |
| 175273 | 175684 | #endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */ |
| 175274 | 175685 | } |
| 175275 | 175686 | if( pTabList->a[pLevel->iFrom].fg.fromExists |
| 175276 | 175687 | && (i==pWInfo->nLevel-1 |
| | @@ -185745,11 +186156,11 @@ |
| 185745 | 186156 | case TK_NULL: { |
| 185746 | 186157 | if( prevType==TK_IS || prevType==TK_NOT ){ |
| 185747 | 186158 | sqlite3_str_append(pStr, " NULL", 5); |
| 185748 | 186159 | break; |
| 185749 | 186160 | } |
| 185750 | | - /* Fall through */ |
| 186161 | + /* no break */ deliberate_fall_through |
| 185751 | 186162 | } |
| 185752 | 186163 | case TK_STRING: |
| 185753 | 186164 | case TK_INTEGER: |
| 185754 | 186165 | case TK_FLOAT: |
| 185755 | 186166 | case TK_VARIABLE: |
| | @@ -185809,11 +186220,11 @@ |
| 185809 | 186220 | } |
| 185810 | 186221 | break; |
| 185811 | 186222 | } |
| 185812 | 186223 | case TK_SELECT: { |
| 185813 | 186224 | iStartIN = 0; |
| 185814 | | - /* fall through */ |
| 186225 | + /* no break */ deliberate_fall_through |
| 185815 | 186226 | } |
| 185816 | 186227 | default: { |
| 185817 | 186228 | if( sqlite3IsIdChar(zSql[i]) ) addSpaceSeparator(pStr); |
| 185818 | 186229 | j = pStr->nChar; |
| 185819 | 186230 | sqlite3_str_append(pStr, zSql+i, n); |
| | @@ -192525,11 +192936,20 @@ |
| 192525 | 192936 | #endif |
| 192526 | 192937 | |
| 192527 | 192938 | #define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) |
| 192528 | 192939 | #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) |
| 192529 | 192940 | |
| 192530 | | -#define deliberate_fall_through |
| 192941 | +#if !defined(deliberate_fall_through) |
| 192942 | +# if defined(__has_attribute) |
| 192943 | +# if __has_attribute(fallthrough) |
| 192944 | +# define deliberate_fall_through __attribute__((fallthrough)); |
| 192945 | +# endif |
| 192946 | +# endif |
| 192947 | +#endif |
| 192948 | +#if !defined(deliberate_fall_through) |
| 192949 | +# define deliberate_fall_through |
| 192950 | +#endif |
| 192531 | 192951 | |
| 192532 | 192952 | /* |
| 192533 | 192953 | ** Macros needed to provide flexible arrays in a portable way |
| 192534 | 192954 | */ |
| 192535 | 192955 | #ifndef offsetof |
| | @@ -199254,11 +199674,11 @@ |
| 199254 | 199674 | assert( iCol==0 ); |
| 199255 | 199675 | if( v>1 ){ |
| 199256 | 199676 | pCsr->aStat[1].nDoc++; |
| 199257 | 199677 | } |
| 199258 | 199678 | eState = 2; |
| 199259 | | - /* fall through */ |
| 199679 | + /* no break */ deliberate_fall_through |
| 199260 | 199680 | |
| 199261 | 199681 | case 2: |
| 199262 | 199682 | if( v==0 ){ /* 0x00. Next integer will be a docid. */ |
| 199263 | 199683 | eState = 0; |
| 199264 | 199684 | }else if( v==1 ){ /* 0x01. Next integer will be a column number. */ |
| | @@ -212711,15 +213131,15 @@ |
| 212711 | 213131 | } |
| 212712 | 213132 | |
| 212713 | 213133 | /* Slow version of jsonBlobAppendNode() that first resizes the |
| 212714 | 213134 | ** pParse->aBlob structure. |
| 212715 | 213135 | */ |
| 212716 | | -static void jsonBlobAppendNode(JsonParse*,u8,u32,const void*); |
| 213136 | +static void jsonBlobAppendNode(JsonParse*,u8,u64,const void*); |
| 212717 | 213137 | static SQLITE_NOINLINE void jsonBlobExpandAndAppendNode( |
| 212718 | 213138 | JsonParse *pParse, |
| 212719 | 213139 | u8 eType, |
| 212720 | | - u32 szPayload, |
| 213140 | + u64 szPayload, |
| 212721 | 213141 | const void *aPayload |
| 212722 | 213142 | ){ |
| 212723 | 213143 | if( jsonBlobExpand(pParse, pParse->nBlob+szPayload+9) ) return; |
| 212724 | 213144 | jsonBlobAppendNode(pParse, eType, szPayload, aPayload); |
| 212725 | 213145 | } |
| | @@ -212735,11 +213155,11 @@ |
| 212735 | 213155 | ** pointing to where the first byte of payload will eventually be. |
| 212736 | 213156 | */ |
| 212737 | 213157 | static void jsonBlobAppendNode( |
| 212738 | 213158 | JsonParse *pParse, /* The JsonParse object under construction */ |
| 212739 | 213159 | u8 eType, /* Node type. One of JSONB_* */ |
| 212740 | | - u32 szPayload, /* Number of bytes of payload */ |
| 213160 | + u64 szPayload, /* Number of bytes of payload */ |
| 212741 | 213161 | const void *aPayload /* The payload. Might be NULL */ |
| 212742 | 213162 | ){ |
| 212743 | 213163 | u8 *a; |
| 212744 | 213164 | if( pParse->nBlob+szPayload+9 > pParse->nBlobAlloc ){ |
| 212745 | 213165 | jsonBlobExpandAndAppendNode(pParse,eType,szPayload,aPayload); |
| | @@ -214135,10 +214555,11 @@ |
| 214135 | 214555 | u32 nDel, /* Number of bytes to remove */ |
| 214136 | 214556 | const u8 *aIns, /* Content to insert */ |
| 214137 | 214557 | u32 nIns /* Bytes of content to insert */ |
| 214138 | 214558 | ){ |
| 214139 | 214559 | i64 d = (i64)nIns - (i64)nDel; |
| 214560 | + assert( pParse->nBlob >= (u64)iDel + (u64)nDel ); |
| 214140 | 214561 | if( d<0 && d>=(-8) && aIns!=0 |
| 214141 | 214562 | && jsonBlobOverwrite(&pParse->aBlob[iDel], aIns, nIns, (int)-d) |
| 214142 | 214563 | ){ |
| 214143 | 214564 | return; |
| 214144 | 214565 | } |
| | @@ -218177,11 +218598,21 @@ |
| 218177 | 218598 | pRtree->nBusy--; |
| 218178 | 218599 | if( pRtree->nBusy==0 ){ |
| 218179 | 218600 | pRtree->inWrTrans = 0; |
| 218180 | 218601 | assert( pRtree->nCursor==0 ); |
| 218181 | 218602 | nodeBlobReset(pRtree); |
| 218182 | | - assert( pRtree->nNodeRef==0 || pRtree->bCorrupt ); |
| 218603 | + if( pRtree->nNodeRef ){ |
| 218604 | + int i; |
| 218605 | + assert( pRtree->bCorrupt ); |
| 218606 | + for(i=0; i<HASHSIZE; i++){ |
| 218607 | + while( pRtree->aHash[i] ){ |
| 218608 | + RtreeNode *pNext = pRtree->aHash[i]->pNext; |
| 218609 | + sqlite3_free(pRtree->aHash[i]); |
| 218610 | + pRtree->aHash[i] = pNext; |
| 218611 | + } |
| 218612 | + } |
| 218613 | + } |
| 218183 | 218614 | sqlite3_finalize(pRtree->pWriteNode); |
| 218184 | 218615 | sqlite3_finalize(pRtree->pDeleteNode); |
| 218185 | 218616 | sqlite3_finalize(pRtree->pReadRowid); |
| 218186 | 218617 | sqlite3_finalize(pRtree->pWriteRowid); |
| 218187 | 218618 | sqlite3_finalize(pRtree->pDeleteRowid); |
| | @@ -219469,11 +219900,11 @@ |
| 219469 | 219900 | RtreeNode *pParent = p->pParent; |
| 219470 | 219901 | RtreeCell cell; |
| 219471 | 219902 | int iCell; |
| 219472 | 219903 | |
| 219473 | 219904 | cnt++; |
| 219474 | | - if( NEVER(cnt>100) ){ |
| 219905 | + if( cnt>100 ){ |
| 219475 | 219906 | RTREE_IS_CORRUPT(pRtree); |
| 219476 | 219907 | return SQLITE_CORRUPT_VTAB; |
| 219477 | 219908 | } |
| 219478 | 219909 | rc = nodeParentIndex(pRtree, p, &iCell); |
| 219479 | 219910 | if( NEVER(rc!=SQLITE_OK) ){ |
| | @@ -219827,19 +220258,10 @@ |
| 219827 | 220258 | } |
| 219828 | 220259 | }else if( newCellIsRight==0 ){ |
| 219829 | 220260 | rc = updateMapping(pRtree, pCell->iRowid, pLeft, iHeight); |
| 219830 | 220261 | } |
| 219831 | 220262 | |
| 219832 | | - if( rc==SQLITE_OK ){ |
| 219833 | | - rc = nodeRelease(pRtree, pRight); |
| 219834 | | - pRight = 0; |
| 219835 | | - } |
| 219836 | | - if( rc==SQLITE_OK ){ |
| 219837 | | - rc = nodeRelease(pRtree, pLeft); |
| 219838 | | - pLeft = 0; |
| 219839 | | - } |
| 219840 | | - |
| 219841 | 220263 | splitnode_out: |
| 219842 | 220264 | nodeRelease(pRtree, pRight); |
| 219843 | 220265 | nodeRelease(pRtree, pLeft); |
| 219844 | 220266 | sqlite3_free(aCell); |
| 219845 | 220267 | return rc; |
| | @@ -220020,11 +220442,11 @@ |
| 220020 | 220442 | } |
| 220021 | 220443 | if( nodeInsertCell(pRtree, pNode, pCell) ){ |
| 220022 | 220444 | rc = SplitNode(pRtree, pNode, pCell, iHeight); |
| 220023 | 220445 | }else{ |
| 220024 | 220446 | rc = AdjustTree(pRtree, pNode, pCell); |
| 220025 | | - if( ALWAYS(rc==SQLITE_OK) ){ |
| 220447 | + if( rc==SQLITE_OK ){ |
| 220026 | 220448 | if( iHeight==0 ){ |
| 220027 | 220449 | rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode); |
| 220028 | 220450 | }else{ |
| 220029 | 220451 | rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode); |
| 220030 | 220452 | } |
| | @@ -261855,11 +262277,11 @@ |
| 261855 | 262277 | int nArg, /* Number of args */ |
| 261856 | 262278 | sqlite3_value **apUnused /* Function arguments */ |
| 261857 | 262279 | ){ |
| 261858 | 262280 | assert( nArg==0 ); |
| 261859 | 262281 | UNUSED_PARAM2(nArg, apUnused); |
| 261860 | | - sqlite3_result_text(pCtx, "fts5: 2026-03-06 16:01:44 557aeb43869d3585137b17690cb3b64f7de6921774daae9e56403c3717dceab6", -1, SQLITE_TRANSIENT); |
| 262282 | + sqlite3_result_text(pCtx, "fts5: 2026-03-18 15:40:26 971aa34b3fd86ba30fe170886d9f83c17159b1638c4bd4fb6cdef79b1c9a88e2", -1, SQLITE_TRANSIENT); |
| 261861 | 262283 | } |
| 261862 | 262284 | |
| 261863 | 262285 | /* |
| 261864 | 262286 | ** Implementation of fts5_locale(LOCALE, TEXT) function. |
| 261865 | 262287 | ** |
| 261866 | 262288 | |