Fossil SCM

Update the built-in SQLite to the latest trunk version that includes various performance enhancements. The purpose here is to test the recent SQLite enhancements in a real-world application.

drh 2022-03-02 02:00 trunk
Commit ad744440dc89d439fef4b7988fbc7d00a5c51ce74242ad2f907afbedd797305b
2 files changed +388 -298 +4 -4
+388 -298
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.38.0. By combining all the individual C code files into this
3
+** version 3.39.0. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -450,13 +450,13 @@
450450
**
451451
** See also: [sqlite3_libversion()],
452452
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453453
** [sqlite_version()] and [sqlite_source_id()].
454454
*/
455
-#define SQLITE_VERSION "3.38.0"
456
-#define SQLITE_VERSION_NUMBER 3038000
457
-#define SQLITE_SOURCE_ID "2022-02-22 18:58:40 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968a1bab"
455
+#define SQLITE_VERSION "3.39.0"
456
+#define SQLITE_VERSION_NUMBER 3039000
457
+#define SQLITE_SOURCE_ID "2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b"
458458
459459
/*
460460
** CAPI3REF: Run-Time Library Version Numbers
461461
** KEYWORDS: sqlite3_version sqlite3_sourceid
462462
**
@@ -10071,11 +10071,11 @@
1007110071
** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
1007210072
** and remains valid for the duration of the xBestIndex method call.
1007310073
** ^When xBestIndex returns, the sqlite3_value object returned by
1007410074
** sqlite3_vtab_rhs_value() is automatically deallocated.
1007510075
**
10076
-** The "_rhs_" in the name of this routine is an appreviation for
10076
+** The "_rhs_" in the name of this routine is an abbreviation for
1007710077
** "Right-Hand Side".
1007810078
*/
1007910079
SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
1008010080
1008110081
/*
@@ -14709,18 +14709,19 @@
1470914709
** Handle type for pages.
1471014710
*/
1471114711
typedef struct PgHdr DbPage;
1471214712
1471314713
/*
14714
-** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
14714
+** Page number PAGER_SJ_PGNO is never used in an SQLite database (it is
1471514715
** reserved for working around a windows/posix incompatibility). It is
1471614716
** used in the journal to signify that the remainder of the journal file
1471714717
** is devoted to storing a super-journal name - there are no more pages to
1471814718
** roll back. See comments for function writeSuperJournal() in pager.c
1471914719
** for details.
1472014720
*/
14721
-#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))
14721
+#define PAGER_SJ_PGNO_COMPUTED(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))
14722
+#define PAGER_SJ_PGNO(x) ((x)->lckPgno)
1472214723
1472314724
/*
1472414725
** Allowed values for the flags parameter to sqlite3PagerOpen().
1472514726
**
1472614727
** NOTE: These values must match the corresponding BTREE_ values in btree.h.
@@ -15393,11 +15394,10 @@
1539315394
SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
1539415395
Table *pTab; /* Used when p4type is P4_TABLE */
1539515396
#ifdef SQLITE_ENABLE_CURSOR_HINTS
1539615397
Expr *pExpr; /* Used when p4type is P4_EXPR */
1539715398
#endif
15398
- int (*xAdvance)(BtCursor *, int);
1539915399
} p4;
1540015400
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
1540115401
char *zComment; /* Comment to improve readability */
1540215402
#endif
1540315403
#ifdef VDBE_PROFILE
@@ -15444,25 +15444,23 @@
1544415444
#define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
1544515445
#define P4_STATIC (-1) /* Pointer to a static string */
1544615446
#define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */
1544715447
#define P4_INT32 (-3) /* P4 is a 32-bit signed integer */
1544815448
#define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */
15449
-#define P4_ADVANCE (-5) /* P4 is a pointer to BtreeNext() or BtreePrev() */
15450
-#define P4_TABLE (-6) /* P4 is a pointer to a Table structure */
15449
+#define P4_TABLE (-5) /* P4 is a pointer to a Table structure */
1545115450
/* Above do not own any resources. Must free those below */
15452
-#define P4_FREE_IF_LE (-7)
15453
-#define P4_DYNAMIC (-7) /* Pointer to memory from sqliteMalloc() */
15454
-#define P4_FUNCDEF (-8) /* P4 is a pointer to a FuncDef structure */
15455
-#define P4_KEYINFO (-9) /* P4 is a pointer to a KeyInfo structure */
15456
-#define P4_EXPR (-10) /* P4 is a pointer to an Expr tree */
15457
-#define P4_MEM (-11) /* P4 is a pointer to a Mem* structure */
15458
-#define P4_VTAB (-12) /* P4 is a pointer to an sqlite3_vtab structure */
15459
-#define P4_REAL (-13) /* P4 is a 64-bit floating point value */
15460
-#define P4_INT64 (-14) /* P4 is a 64-bit signed integer */
15461
-#define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
15462
-#define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */
15463
-#define P4_DYNBLOB (-17) /* Pointer to memory from sqliteMalloc() */
15451
+#define P4_FREE_IF_LE (-6)
15452
+#define P4_DYNAMIC (-6) /* Pointer to memory from sqliteMalloc() */
15453
+#define P4_FUNCDEF (-7) /* P4 is a pointer to a FuncDef structure */
15454
+#define P4_KEYINFO (-8) /* P4 is a pointer to a KeyInfo structure */
15455
+#define P4_EXPR (-9) /* P4 is a pointer to an Expr tree */
15456
+#define P4_MEM (-10) /* P4 is a pointer to a Mem* structure */
15457
+#define P4_VTAB (-11) /* P4 is a pointer to an sqlite3_vtab structure */
15458
+#define P4_REAL (-12) /* P4 is a 64-bit floating point value */
15459
+#define P4_INT64 (-13) /* P4 is a 64-bit signed integer */
15460
+#define P4_INTARRAY (-14) /* P4 is a vector of 32-bit integers */
15461
+#define P4_FUNCCTX (-15) /* P4 is a pointer to an sqlite3_context object */
1546415462
1546515463
/* Error message codes for OP_Halt */
1546615464
#define P5_ConstraintNotNull 1
1546715465
#define P5_ConstraintUnique 2
1546815466
#define P5_ConstraintCheck 3
@@ -15503,46 +15501,46 @@
1550315501
/* Automatically generated. Do not edit */
1550415502
/* See the tool/mkopcodeh.tcl script for details */
1550515503
#define OP_Savepoint 0
1550615504
#define OP_AutoCommit 1
1550715505
#define OP_Transaction 2
15508
-#define OP_SorterNext 3 /* jump */
15509
-#define OP_Prev 4 /* jump */
15510
-#define OP_Next 5 /* jump */
15511
-#define OP_Checkpoint 6
15512
-#define OP_JournalMode 7
15513
-#define OP_Vacuum 8
15514
-#define OP_VFilter 9 /* jump, synopsis: iplan=r[P3] zplan='P4' */
15515
-#define OP_VUpdate 10 /* synopsis: data=r[P3@P2] */
15516
-#define OP_Goto 11 /* jump */
15517
-#define OP_Gosub 12 /* jump */
15518
-#define OP_InitCoroutine 13 /* jump */
15519
-#define OP_Yield 14 /* jump */
15520
-#define OP_MustBeInt 15 /* jump */
15521
-#define OP_Jump 16 /* jump */
15522
-#define OP_Once 17 /* jump */
15523
-#define OP_If 18 /* jump */
15506
+#define OP_Checkpoint 3
15507
+#define OP_JournalMode 4
15508
+#define OP_Vacuum 5
15509
+#define OP_VFilter 6 /* jump, synopsis: iplan=r[P3] zplan='P4' */
15510
+#define OP_VUpdate 7 /* synopsis: data=r[P3@P2] */
15511
+#define OP_Goto 8 /* jump */
15512
+#define OP_Gosub 9 /* jump */
15513
+#define OP_InitCoroutine 10 /* jump */
15514
+#define OP_Yield 11 /* jump */
15515
+#define OP_MustBeInt 12 /* jump */
15516
+#define OP_Jump 13 /* jump */
15517
+#define OP_Once 14 /* jump */
15518
+#define OP_If 15 /* jump */
15519
+#define OP_IfNot 16 /* jump */
15520
+#define OP_IsNullOrType 17 /* jump, synopsis: if typeof(r[P1]) IN (P3,5) goto P2 */
15521
+#define OP_IfNullRow 18 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
1552415522
#define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */
15525
-#define OP_IfNot 20 /* jump */
15526
-#define OP_IsNullOrType 21 /* jump, synopsis: if typeof(r[P1]) IN (P3,5) goto P2 */
15527
-#define OP_IfNullRow 22 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
15528
-#define OP_SeekLT 23 /* jump, synopsis: key=r[P3@P4] */
15529
-#define OP_SeekLE 24 /* jump, synopsis: key=r[P3@P4] */
15530
-#define OP_SeekGE 25 /* jump, synopsis: key=r[P3@P4] */
15531
-#define OP_SeekGT 26 /* jump, synopsis: key=r[P3@P4] */
15532
-#define OP_IfNotOpen 27 /* jump, synopsis: if( !csr[P1] ) goto P2 */
15533
-#define OP_IfNoHope 28 /* jump, synopsis: key=r[P3@P4] */
15534
-#define OP_NoConflict 29 /* jump, synopsis: key=r[P3@P4] */
15535
-#define OP_NotFound 30 /* jump, synopsis: key=r[P3@P4] */
15536
-#define OP_Found 31 /* jump, synopsis: key=r[P3@P4] */
15537
-#define OP_SeekRowid 32 /* jump, synopsis: intkey=r[P3] */
15538
-#define OP_NotExists 33 /* jump, synopsis: intkey=r[P3] */
15539
-#define OP_Last 34 /* jump */
15540
-#define OP_IfSmaller 35 /* jump */
15541
-#define OP_SorterSort 36 /* jump */
15542
-#define OP_Sort 37 /* jump */
15543
-#define OP_Rewind 38 /* jump */
15523
+#define OP_SeekLT 20 /* jump, synopsis: key=r[P3@P4] */
15524
+#define OP_SeekLE 21 /* jump, synopsis: key=r[P3@P4] */
15525
+#define OP_SeekGE 22 /* jump, synopsis: key=r[P3@P4] */
15526
+#define OP_SeekGT 23 /* jump, synopsis: key=r[P3@P4] */
15527
+#define OP_IfNotOpen 24 /* jump, synopsis: if( !csr[P1] ) goto P2 */
15528
+#define OP_IfNoHope 25 /* jump, synopsis: key=r[P3@P4] */
15529
+#define OP_NoConflict 26 /* jump, synopsis: key=r[P3@P4] */
15530
+#define OP_NotFound 27 /* jump, synopsis: key=r[P3@P4] */
15531
+#define OP_Found 28 /* jump, synopsis: key=r[P3@P4] */
15532
+#define OP_SeekRowid 29 /* jump, synopsis: intkey=r[P3] */
15533
+#define OP_NotExists 30 /* jump, synopsis: intkey=r[P3] */
15534
+#define OP_Last 31 /* jump */
15535
+#define OP_IfSmaller 32 /* jump */
15536
+#define OP_SorterSort 33 /* jump */
15537
+#define OP_Sort 34 /* jump */
15538
+#define OP_Rewind 35 /* jump */
15539
+#define OP_SorterNext 36 /* jump */
15540
+#define OP_Prev 37 /* jump */
15541
+#define OP_Next 38 /* jump */
1554415542
#define OP_IdxLE 39 /* jump, synopsis: key=r[P3@P4] */
1554515543
#define OP_IdxGT 40 /* jump, synopsis: key=r[P3@P4] */
1554615544
#define OP_IdxLT 41 /* jump, synopsis: key=r[P3@P4] */
1554715545
#define OP_IdxGE 42 /* jump, synopsis: key=r[P3@P4] */
1554815546
#define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
@@ -15697,15 +15695,15 @@
1569715695
#define OPFLG_IN2 0x04 /* in2: P2 is an input */
1569815696
#define OPFLG_IN3 0x08 /* in3: P3 is an input */
1569915697
#define OPFLG_OUT2 0x10 /* out2: P2 is an output */
1570015698
#define OPFLG_OUT3 0x20 /* out3: P3 is an output */
1570115699
#define OPFLG_INITIALIZER {\
15702
-/* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\
15703
-/* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\
15704
-/* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x03, 0x01, 0x09,\
15705
-/* 24 */ 0x09, 0x09, 0x09, 0x01, 0x09, 0x09, 0x09, 0x09,\
15706
-/* 32 */ 0x09, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
15700
+/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00,\
15701
+/* 8 */ 0x01, 0x01, 0x01, 0x03, 0x03, 0x01, 0x01, 0x03,\
15702
+/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x09, 0x09, 0x09, 0x09,\
15703
+/* 24 */ 0x01, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x01,\
15704
+/* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
1570715705
/* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\
1570815706
/* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
1570915707
/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\
1571015708
/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
1571115709
/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,\
@@ -17778,10 +17776,15 @@
1777817776
** b-tree.
1777917777
*/
1778017778
struct UnpackedRecord {
1778117779
KeyInfo *pKeyInfo; /* Collation and sort-order information */
1778217780
Mem *aMem; /* Values */
17781
+ union {
17782
+ char *z; /* Cache of aMem[0].z for vdbeRecordCompareString() */
17783
+ i64 i; /* Cache of aMem[0].u.i for vdbeRecordCompareInt() */
17784
+ } u;
17785
+ int n; /* Cache of aMem[0].n used by vdbeRecordCompareString() */
1778317786
u16 nField; /* Number of entries in apMem[] */
1778417787
i8 default_rc; /* Comparison result if keys are equal */
1778517788
u8 errCode; /* Error detected by xRecordCompare (CORRUPT or NOMEM) */
1778617789
i8 r1; /* Value to return if (lhs < rhs) */
1778717790
i8 r2; /* Value to return if (lhs > rhs) */
@@ -22225,20 +22228,20 @@
2222522228
i64 i; /* Integer value used when MEM_Int is set in flags */
2222622229
int nZero; /* Extra zero bytes when MEM_Zero and MEM_Blob set */
2222722230
const char *zPType; /* Pointer type when MEM_Term|MEM_Subtype|MEM_Null */
2222822231
FuncDef *pDef; /* Used only when flags==MEM_Agg */
2222922232
} u;
22233
+ char *z; /* String or BLOB value */
22234
+ int n; /* Number of characters in string value, excluding '\0' */
2223022235
u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
2223122236
u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
2223222237
u8 eSubtype; /* Subtype for this value */
22233
- int n; /* Number of characters in string value, excluding '\0' */
22234
- char *z; /* String or BLOB value */
2223522238
/* ShallowCopy only needs to copy the information above */
22236
- char *zMalloc; /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */
22239
+ sqlite3 *db; /* The associated database connection */
2223722240
int szMalloc; /* Size of the zMalloc allocation */
2223822241
u32 uTemp; /* Transient storage for serial_type in OP_MakeRecord */
22239
- sqlite3 *db; /* The associated database connection */
22242
+ char *zMalloc; /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */
2224022243
void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
2224122244
#ifdef SQLITE_DEBUG
2224222245
Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
2224322246
u16 mScopyFlags; /* flags value immediately after the shallow copy */
2224422247
#endif
@@ -22246,15 +22249,47 @@
2224622249
2224722250
/*
2224822251
** Size of struct Mem not including the Mem.zMalloc member or anything that
2224922252
** follows.
2225022253
*/
22251
-#define MEMCELLSIZE offsetof(Mem,zMalloc)
22254
+#define MEMCELLSIZE offsetof(Mem,db)
2225222255
22253
-/* One or more of the following flags are set to indicate the validOK
22256
+/* One or more of the following flags are set to indicate the
2225422257
** representations of the value stored in the Mem struct.
2225522258
**
22259
+** * MEM_Null An SQL NULL value
22260
+**
22261
+** * MEM_Null|MEM_Zero An SQL NULL with the virtual table
22262
+** UPDATE no-change flag set
22263
+**
22264
+** * MEM_Null|MEM_Term| An SQL NULL, but also contains a
22265
+** MEM_Subtype pointer accessible using
22266
+** sqlite3_value_pointer().
22267
+**
22268
+** * MEM_Null|MEM_Cleared Special SQL NULL that compares non-equal
22269
+** to other NULLs even using the IS operator.
22270
+**
22271
+** * MEM_Str A string, stored in Mem.z with
22272
+** length Mem.n. Zero-terminated if
22273
+** MEM_Term is set. This flag is
22274
+** incompatible with MEM_Blob and
22275
+** MEM_Null, but can appear with MEM_Int,
22276
+** MEM_Real, and MEM_IntReal.
22277
+**
22278
+** * MEM_Blob A blob, stored in Mem.z length Mem.n.
22279
+** Incompatible with MEM_Str, MEM_Null,
22280
+** MEM_Int, MEM_Real, and MEM_IntReal.
22281
+**
22282
+** * MEM_Blob|MEM_Zero A blob in Mem.z of length Mem.n plus
22283
+** MEM.u.i extra 0x00 bytes at the end.
22284
+**
22285
+** * MEM_Int Integer stored in Mem.u.i.
22286
+**
22287
+** * MEM_Real Real stored in Mem.u.r.
22288
+**
22289
+** * MEM_IntReal Real stored as an integer in Mem.u.i.
22290
+**
2225622291
** If the MEM_Null flag is set, then the value is an SQL NULL value.
2225722292
** For a pointer type created using sqlite3_bind_pointer() or
2225822293
** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set.
2225922294
**
2226022295
** If the MEM_Str flag is set then Mem.z points at a string representation.
@@ -22261,39 +22296,36 @@
2226122296
** Usually this is encoded in the same unicode encoding as the main
2226222297
** database (see below for exceptions). If the MEM_Term flag is also
2226322298
** set, then the string is nul terminated. The MEM_Int and MEM_Real
2226422299
** flags may coexist with the MEM_Str flag.
2226522300
*/
22301
+#define MEM_Undefined 0x0000 /* Value is undefined */
2226622302
#define MEM_Null 0x0001 /* Value is NULL (or a pointer) */
2226722303
#define MEM_Str 0x0002 /* Value is a string */
2226822304
#define MEM_Int 0x0004 /* Value is an integer */
2226922305
#define MEM_Real 0x0008 /* Value is a real number */
2227022306
#define MEM_Blob 0x0010 /* Value is a BLOB */
2227122307
#define MEM_IntReal 0x0020 /* MEM_Int that stringifies like MEM_Real */
2227222308
#define MEM_AffMask 0x003f /* Mask of affinity bits */
22309
+
22310
+/* Extra bits that modify the meanings of the core datatypes above
22311
+*/
2227322312
#define MEM_FromBind 0x0040 /* Value originates from sqlite3_bind() */
22274
-#define MEM_Undefined 0x0080 /* Value is undefined */
22313
+ /* 0x0080 // Available */
2227522314
#define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
22276
-#define MEM_TypeMask 0xc1bf /* Mask of type bits */
22277
-
22278
-
22279
-/* Whenever Mem contains a valid string or blob representation, one of
22280
-** the following flags must be set to determine the memory management
22281
-** policy for Mem.z. The MEM_Term flag tells us whether or not the
22282
-** string is \000 or \u0000 terminated
22283
-*/
2228422315
#define MEM_Term 0x0200 /* String in Mem.z is zero terminated */
22285
-#define MEM_Dyn 0x0400 /* Need to call Mem.xDel() on Mem.z */
22286
-#define MEM_Static 0x0800 /* Mem.z points to a static string */
22287
-#define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */
22288
-#define MEM_Agg 0x2000 /* Mem.z points to an agg function context */
22289
-#define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */
22290
-#define MEM_Subtype 0x8000 /* Mem.eSubtype is valid */
22291
-#ifdef SQLITE_OMIT_INCRBLOB
22292
- #undef MEM_Zero
22293
- #define MEM_Zero 0x0000
22294
-#endif
22316
+#define MEM_Zero 0x0400 /* Mem.i contains count of 0s appended to blob */
22317
+#define MEM_Subtype 0x0800 /* Mem.eSubtype is valid */
22318
+#define MEM_TypeMask 0x0dbf /* Mask of type bits */
22319
+
22320
+/* Bits that determine the storage for Mem.z for a string or blob or
22321
+** aggregate accumulator.
22322
+*/
22323
+#define MEM_Dyn 0x1000 /* Need to call Mem.xDel() on Mem.z */
22324
+#define MEM_Static 0x2000 /* Mem.z points to a static string */
22325
+#define MEM_Ephem 0x4000 /* Mem.z points to an ephemeral string */
22326
+#define MEM_Agg 0x8000 /* Mem.z points to an agg function context */
2229522327
2229622328
/* Return TRUE if Mem X contains dynamically allocated content - anything
2229722329
** that needs to be deallocated to avoid a leak.
2229822330
*/
2229922331
#define VdbeMemDynamic(X) \
@@ -22311,15 +22343,19 @@
2231122343
#define MemNullNochng(X) \
2231222344
(((X)->flags&MEM_TypeMask)==(MEM_Null|MEM_Zero) \
2231322345
&& (X)->n==0 && (X)->u.nZero==0)
2231422346
2231522347
/*
22316
-** Return true if a memory cell is not marked as invalid. This macro
22348
+** Return true if a memory cell has been initialized and is valid.
2231722349
** is for use inside assert() statements only.
22350
+**
22351
+** A Memory cell is initialized if at least one of the
22352
+** MEM_Null, MEM_Str, MEM_Int, MEM_Real, MEM_Blob, or MEM_IntReal bits
22353
+** is set. It is "undefined" if all those bits are zero.
2231822354
*/
2231922355
#ifdef SQLITE_DEBUG
22320
-#define memIsValid(M) ((M)->flags & MEM_Undefined)==0
22356
+#define memIsValid(M) ((M)->flags & MEM_AffMask)!=0
2232122357
#endif
2232222358
2232322359
/*
2232422360
** Each auxiliary data pointer stored by a user defined function
2232522361
** implementation calling sqlite3_set_auxdata() is stored in an instance
@@ -22523,12 +22559,12 @@
2252322559
** Function prototypes
2252422560
*/
2252522561
SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...);
2252622562
SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);
2252722563
void sqliteVdbePopStack(Vdbe*,int);
22564
+SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeHandleMovedCursor(VdbeCursor *p);
2252822565
SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeFinishMoveto(VdbeCursor*);
22529
-SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, u32*);
2253022566
SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
2253122567
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
2253222568
SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
2253322569
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
2253422570
SQLITE_PRIVATE void sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
@@ -34579,46 +34615,46 @@
3457934615
SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
3458034616
static const char *const azName[] = {
3458134617
/* 0 */ "Savepoint" OpHelp(""),
3458234618
/* 1 */ "AutoCommit" OpHelp(""),
3458334619
/* 2 */ "Transaction" OpHelp(""),
34584
- /* 3 */ "SorterNext" OpHelp(""),
34585
- /* 4 */ "Prev" OpHelp(""),
34586
- /* 5 */ "Next" OpHelp(""),
34587
- /* 6 */ "Checkpoint" OpHelp(""),
34588
- /* 7 */ "JournalMode" OpHelp(""),
34589
- /* 8 */ "Vacuum" OpHelp(""),
34590
- /* 9 */ "VFilter" OpHelp("iplan=r[P3] zplan='P4'"),
34591
- /* 10 */ "VUpdate" OpHelp("data=r[P3@P2]"),
34592
- /* 11 */ "Goto" OpHelp(""),
34593
- /* 12 */ "Gosub" OpHelp(""),
34594
- /* 13 */ "InitCoroutine" OpHelp(""),
34595
- /* 14 */ "Yield" OpHelp(""),
34596
- /* 15 */ "MustBeInt" OpHelp(""),
34597
- /* 16 */ "Jump" OpHelp(""),
34598
- /* 17 */ "Once" OpHelp(""),
34599
- /* 18 */ "If" OpHelp(""),
34620
+ /* 3 */ "Checkpoint" OpHelp(""),
34621
+ /* 4 */ "JournalMode" OpHelp(""),
34622
+ /* 5 */ "Vacuum" OpHelp(""),
34623
+ /* 6 */ "VFilter" OpHelp("iplan=r[P3] zplan='P4'"),
34624
+ /* 7 */ "VUpdate" OpHelp("data=r[P3@P2]"),
34625
+ /* 8 */ "Goto" OpHelp(""),
34626
+ /* 9 */ "Gosub" OpHelp(""),
34627
+ /* 10 */ "InitCoroutine" OpHelp(""),
34628
+ /* 11 */ "Yield" OpHelp(""),
34629
+ /* 12 */ "MustBeInt" OpHelp(""),
34630
+ /* 13 */ "Jump" OpHelp(""),
34631
+ /* 14 */ "Once" OpHelp(""),
34632
+ /* 15 */ "If" OpHelp(""),
34633
+ /* 16 */ "IfNot" OpHelp(""),
34634
+ /* 17 */ "IsNullOrType" OpHelp("if typeof(r[P1]) IN (P3,5) goto P2"),
34635
+ /* 18 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"),
3460034636
/* 19 */ "Not" OpHelp("r[P2]= !r[P1]"),
34601
- /* 20 */ "IfNot" OpHelp(""),
34602
- /* 21 */ "IsNullOrType" OpHelp("if typeof(r[P1]) IN (P3,5) goto P2"),
34603
- /* 22 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"),
34604
- /* 23 */ "SeekLT" OpHelp("key=r[P3@P4]"),
34605
- /* 24 */ "SeekLE" OpHelp("key=r[P3@P4]"),
34606
- /* 25 */ "SeekGE" OpHelp("key=r[P3@P4]"),
34607
- /* 26 */ "SeekGT" OpHelp("key=r[P3@P4]"),
34608
- /* 27 */ "IfNotOpen" OpHelp("if( !csr[P1] ) goto P2"),
34609
- /* 28 */ "IfNoHope" OpHelp("key=r[P3@P4]"),
34610
- /* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"),
34611
- /* 30 */ "NotFound" OpHelp("key=r[P3@P4]"),
34612
- /* 31 */ "Found" OpHelp("key=r[P3@P4]"),
34613
- /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"),
34614
- /* 33 */ "NotExists" OpHelp("intkey=r[P3]"),
34615
- /* 34 */ "Last" OpHelp(""),
34616
- /* 35 */ "IfSmaller" OpHelp(""),
34617
- /* 36 */ "SorterSort" OpHelp(""),
34618
- /* 37 */ "Sort" OpHelp(""),
34619
- /* 38 */ "Rewind" OpHelp(""),
34637
+ /* 20 */ "SeekLT" OpHelp("key=r[P3@P4]"),
34638
+ /* 21 */ "SeekLE" OpHelp("key=r[P3@P4]"),
34639
+ /* 22 */ "SeekGE" OpHelp("key=r[P3@P4]"),
34640
+ /* 23 */ "SeekGT" OpHelp("key=r[P3@P4]"),
34641
+ /* 24 */ "IfNotOpen" OpHelp("if( !csr[P1] ) goto P2"),
34642
+ /* 25 */ "IfNoHope" OpHelp("key=r[P3@P4]"),
34643
+ /* 26 */ "NoConflict" OpHelp("key=r[P3@P4]"),
34644
+ /* 27 */ "NotFound" OpHelp("key=r[P3@P4]"),
34645
+ /* 28 */ "Found" OpHelp("key=r[P3@P4]"),
34646
+ /* 29 */ "SeekRowid" OpHelp("intkey=r[P3]"),
34647
+ /* 30 */ "NotExists" OpHelp("intkey=r[P3]"),
34648
+ /* 31 */ "Last" OpHelp(""),
34649
+ /* 32 */ "IfSmaller" OpHelp(""),
34650
+ /* 33 */ "SorterSort" OpHelp(""),
34651
+ /* 34 */ "Sort" OpHelp(""),
34652
+ /* 35 */ "Rewind" OpHelp(""),
34653
+ /* 36 */ "SorterNext" OpHelp(""),
34654
+ /* 37 */ "Prev" OpHelp(""),
34655
+ /* 38 */ "Next" OpHelp(""),
3462034656
/* 39 */ "IdxLE" OpHelp("key=r[P3@P4]"),
3462134657
/* 40 */ "IdxGT" OpHelp("key=r[P3@P4]"),
3462234658
/* 41 */ "IdxLT" OpHelp("key=r[P3@P4]"),
3462334659
/* 42 */ "IdxGE" OpHelp("key=r[P3@P4]"),
3462434660
/* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
@@ -50905,11 +50941,12 @@
5090550941
/*
5090650942
** Make sure the page is marked as dirty. If it isn't dirty already,
5090750943
** make it so.
5090850944
*/
5090950945
SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){
50910
- assert( p->nRef>0 );
50946
+ assert( p->nRef>0 || p->pCache->bPurgeable==0 );
50947
+ testcase( p->nRef==0 );
5091150948
assert( sqlite3PcachePageSanity(p) );
5091250949
if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ /*OPTIMIZATION-IF-FALSE*/
5091350950
p->flags &= ~PGHDR_DONT_WRITE;
5091450951
if( p->flags & PGHDR_CLEAN ){
5091550952
p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN);
@@ -53874,10 +53911,11 @@
5387453911
u16 nExtra; /* Add this many bytes to each in-memory page */
5387553912
i16 nReserve; /* Number of unused bytes at end of each page */
5387653913
u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */
5387753914
u32 sectorSize; /* Assumed sector size during rollback */
5387853915
Pgno mxPgno; /* Maximum allowed size of the database */
53916
+ Pgno lckPgno; /* Page number for the locking page */
5387953917
i64 pageSize; /* Number of bytes in a page */
5388053918
i64 journalSizeLimit; /* Size limit for persistent journal files */
5388153919
char *zFilename; /* Name of the database file */
5388253920
char *zJournal; /* Name of the journal file */
5388353921
int (*xBusyHandler)(void*); /* Function to call when busy */
@@ -54860,11 +54898,11 @@
5486054898
** pPager at the current location. The super-journal name must be the last
5486154899
** thing written to a journal file. If the pager is in full-sync mode, the
5486254900
** journal file descriptor is advanced to the next sector boundary before
5486354901
** anything is written. The format is:
5486454902
**
54865
-** + 4 bytes: PAGER_MJ_PGNO.
54903
+** + 4 bytes: PAGER_SJ_PGNO.
5486654904
** + N bytes: super-journal filename in utf-8.
5486754905
** + 4 bytes: N (length of super-journal name in bytes, no nul-terminator).
5486854906
** + 4 bytes: super-journal name checksum.
5486954907
** + 8 bytes: aJournalMagic[].
5487054908
**
@@ -54908,11 +54946,11 @@
5490854946
iHdrOff = pPager->journalOff;
5490954947
5491054948
/* Write the super-journal data to the end of the journal file. If
5491154949
** an error occurs, return the error code to the caller.
5491254950
*/
54913
- if( (0 != (rc = write32bits(pPager->jfd, iHdrOff, PAGER_MJ_PGNO(pPager))))
54951
+ if( (0 != (rc = write32bits(pPager->jfd, iHdrOff, PAGER_SJ_PGNO(pPager))))
5491454952
|| (0 != (rc = sqlite3OsWrite(pPager->jfd, zSuper, nSuper, iHdrOff+4)))
5491554953
|| (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nSuper, nSuper)))
5491654954
|| (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nSuper+4, cksum)))
5491754955
|| (0 != (rc = sqlite3OsWrite(pPager->jfd, aJournalMagic, 8,
5491854956
iHdrOff+4+nSuper+8)))
@@ -55418,11 +55456,11 @@
5541855456
** to the database file, then the IO error code is returned. If data
5541955457
** is successfully read from the (sub-)journal file but appears to be
5542055458
** corrupted, SQLITE_DONE is returned. Data is considered corrupted in
5542155459
** two circumstances:
5542255460
**
55423
-** * If the record page-number is illegal (0 or PAGER_MJ_PGNO), or
55461
+** * If the record page-number is illegal (0 or PAGER_SJ_PGNO), or
5542455462
** * If the record is being rolled back from the main journal file
5542555463
** and the checksum field does not match the record content.
5542655464
**
5542755465
** Neither of these two scenarios are possible during a savepoint rollback.
5542855466
**
@@ -55478,11 +55516,11 @@
5547855516
/* Sanity checking on the page. This is more important that I originally
5547955517
** thought. If a power failure occurs while the journal is being written,
5548055518
** it could cause invalid data to be written into the journal. We need to
5548155519
** detect this invalid data (with high probability) and ignore it.
5548255520
*/
55483
- if( pgno==0 || pgno==PAGER_MJ_PGNO(pPager) ){
55521
+ if( pgno==0 || pgno==PAGER_SJ_PGNO(pPager) ){
5548455522
assert( !isSavepnt );
5548555523
return SQLITE_DONE;
5548655524
}
5548755525
if( pgno>(Pgno)pPager->dbSize || sqlite3BitvecTest(pDone, pgno) ){
5548855526
return SQLITE_OK;
@@ -56037,10 +56075,13 @@
5603756075
rc = pager_truncate(pPager, mxPg);
5603856076
if( rc!=SQLITE_OK ){
5603956077
goto end_playback;
5604056078
}
5604156079
pPager->dbSize = mxPg;
56080
+ if( pPager->mxPgno<mxPg ){
56081
+ pPager->mxPgno = mxPg;
56082
+ }
5604256083
}
5604356084
5604456085
/* Copy original pages out of the journal and back into the
5604556086
** database file and/or page cache.
5604656087
*/
@@ -56933,10 +56974,11 @@
5693356974
if( rc==SQLITE_OK ){
5693456975
sqlite3PageFree(pPager->pTmpSpace);
5693556976
pPager->pTmpSpace = pNew;
5693656977
pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);
5693756978
pPager->pageSize = pageSize;
56979
+ pPager->lckPgno = (Pgno)(PENDING_BYTE/pageSize) + 1;
5693856980
}else{
5693956981
sqlite3PageFree(pNew);
5694056982
}
5694156983
}
5694256984
@@ -58682,11 +58724,10 @@
5868258724
assert( pPager->errCode==SQLITE_OK );
5868358725
assert( pPager->eState>=PAGER_READER );
5868458726
assert( assert_pager_state(pPager) );
5868558727
assert( pPager->hasHeldSharedLock==1 );
5868658728
58687
- if( pgno==0 ) return SQLITE_CORRUPT_BKPT;
5868858729
pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
5868958730
if( pBase==0 ){
5869058731
pPg = 0;
5869158732
rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
5869258733
if( rc!=SQLITE_OK ) goto pager_acquire_err;
@@ -58702,22 +58743,22 @@
5870258743
5870358744
noContent = (flags & PAGER_GET_NOCONTENT)!=0;
5870458745
if( pPg->pPager && !noContent ){
5870558746
/* In this case the pcache already contains an initialized copy of
5870658747
** the page. Return without further ado. */
58707
- assert( pgno!=PAGER_MJ_PGNO(pPager) );
58748
+ assert( pgno!=PAGER_SJ_PGNO(pPager) );
5870858749
pPager->aStat[PAGER_STAT_HIT]++;
5870958750
return SQLITE_OK;
5871058751
5871158752
}else{
5871258753
/* The pager cache has created a new page. Its content needs to
5871358754
** be initialized. But first some error checks:
5871458755
**
58715
- ** (*) obsolete. Was: maximum page number is 2^31
58716
- ** (2) Never try to fetch the locking page
58756
+ ** (1) Never try to fetch the locking page
58757
+ ** (2) Never try to fetch page 0, which does not exist
5871758758
*/
58718
- if( pgno==PAGER_MJ_PGNO(pPager) ){
58759
+ if( pgno==PAGER_SJ_PGNO(pPager) || pgno==0 ){
5871958760
rc = SQLITE_CORRUPT_BKPT;
5872058761
goto pager_acquire_err;
5872158762
}
5872258763
5872358764
pPg->pPager = pPager;
@@ -59112,11 +59153,11 @@
5911259153
i64 iOff = pPager->journalOff;
5911359154
5911459155
/* We should never write to the journal file the page that
5911559156
** contains the database locks. The following assert verifies
5911659157
** that we do not. */
59117
- assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) );
59158
+ assert( pPg->pgno!=PAGER_SJ_PGNO(pPager) );
5911859159
5911959160
assert( pPager->journalHdr<=pPager->journalOff );
5912059161
pData2 = pPg->pData;
5912159162
cksum = pager_cksum(pPager, (u8*)pData2);
5912259163
@@ -59291,11 +59332,11 @@
5929159332
5929259333
for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){
5929359334
Pgno pg = pg1+ii;
5929459335
PgHdr *pPage;
5929559336
if( pg==pPg->pgno || !sqlite3BitvecTest(pPager->pInJournal, pg) ){
59296
- if( pg!=PAGER_MJ_PGNO(pPager) ){
59337
+ if( pg!=PAGER_SJ_PGNO(pPager) ){
5929759338
rc = sqlite3PagerGet(pPager, pg, &pPage, 0);
5929859339
if( rc==SQLITE_OK ){
5929959340
rc = pager_write(pPage);
5930059341
if( pPage->flags&PGHDR_NEED_SYNC ){
5930159342
needSync = 1;
@@ -59769,11 +59810,11 @@
5976959810
** image was extended as part of the current transaction and then the
5977059811
** last page in the db image moved to the free-list. In this case the
5977159812
** last page is never written out to disk, leaving the database file
5977259813
** undersized. Fix this now if it is the case. */
5977359814
if( pPager->dbSize>pPager->dbFileSize ){
59774
- Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_MJ_PGNO(pPager));
59815
+ Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_SJ_PGNO(pPager));
5977559816
assert( pPager->eState==PAGER_WRITER_DBMOD );
5977659817
rc = pager_truncate(pPager, nNew);
5977759818
if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
5977859819
}
5977959820
@@ -65396,11 +65437,13 @@
6539665437
u16 aiOvfl[4]; /* Insert the i-th overflow cell before the aiOvfl-th
6539765438
** non-overflow cell */
6539865439
u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
6539965440
BtShared *pBt; /* Pointer to BtShared that this page is part of */
6540065441
u8 *aData; /* Pointer to disk image of the page data */
65401
- u8 *aDataEnd; /* One byte past the end of usable data */
65442
+ u8 *aDataEnd; /* One byte past the end of the entire page - not just
65443
+ ** the usable space, the entire page. Used to prevent
65444
+ ** corruption-induced of buffer overflow. */
6540265445
u8 *aCellIdx; /* The cell index area */
6540365446
u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
6540465447
DbPage *pDbPage; /* Pager page handle */
6540565448
u16 (*xCellSize)(MemPage*,u8*); /* cellSizePtr method */
6540665449
void (*xParseCell)(MemPage*,u8*,CellInfo*); /* btreeParseCell method */
@@ -65701,11 +65744,11 @@
6570165744
#define CURSOR_FAULT 4
6570265745
6570365746
/*
6570465747
** The database page the PENDING_BYTE occupies. This page is never used.
6570565748
*/
65706
-# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt)
65749
+#define PENDING_BYTE_PAGE(pBt) ((Pgno)((PENDING_BYTE/((pBt)->pageSize))+1))
6570765750
6570865751
/*
6570965752
** These macros define the location of the pointer-map entry for a
6571065753
** database page. The first argument to each is the number of usable
6571165754
** bytes on each page of the database (often 1024). The second is the
@@ -67455,10 +67498,11 @@
6745567498
** data area of the btree-page. The return number includes the cell
6745667499
** data header and the local payload, but not any overflow page or
6745767500
** the space used by the cell pointer.
6745867501
**
6745967502
** cellSizePtrNoPayload() => table internal nodes
67503
+** cellSizePtrTableLeaf() => table leaf nodes
6746067504
** cellSizePtr() => all index nodes & table leaf nodes
6746167505
*/
6746267506
static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
6746367507
u8 *pIter = pCell + pPage->childPtrSize; /* For looping over bytes of pCell */
6746467508
u8 *pEnd; /* End mark for a varint */
@@ -67480,17 +67524,10 @@
6748067524
do{
6748167525
nSize = (nSize<<7) | (*++pIter & 0x7f);
6748267526
}while( *(pIter)>=0x80 && pIter<pEnd );
6748367527
}
6748467528
pIter++;
67485
- if( pPage->intKey ){
67486
- /* pIter now points at the 64-bit integer key value, a variable length
67487
- ** integer. The following block moves pIter to point at the first byte
67488
- ** past the end of the key value. */
67489
- pEnd = &pIter[9];
67490
- while( (*pIter++)&0x80 && pIter<pEnd );
67491
- }
6749267529
testcase( nSize==pPage->maxLocal );
6749367530
testcase( nSize==(u32)pPage->maxLocal+1 );
6749467531
if( nSize<=pPage->maxLocal ){
6749567532
nSize += (u32)(pIter - pCell);
6749667533
if( nSize<4 ) nSize = 4;
@@ -67526,10 +67563,62 @@
6752667563
pEnd = pIter + 9;
6752767564
while( (*pIter++)&0x80 && pIter<pEnd );
6752867565
assert( debuginfo.nSize==(u16)(pIter - pCell) || CORRUPT_DB );
6752967566
return (u16)(pIter - pCell);
6753067567
}
67568
+static u16 cellSizePtrTableLeaf(MemPage *pPage, u8 *pCell){
67569
+ u8 *pIter = pCell; /* For looping over bytes of pCell */
67570
+ u8 *pEnd; /* End mark for a varint */
67571
+ u32 nSize; /* Size value to return */
67572
+
67573
+#ifdef SQLITE_DEBUG
67574
+ /* The value returned by this function should always be the same as
67575
+ ** the (CellInfo.nSize) value found by doing a full parse of the
67576
+ ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of
67577
+ ** this function verifies that this invariant is not violated. */
67578
+ CellInfo debuginfo;
67579
+ pPage->xParseCell(pPage, pCell, &debuginfo);
67580
+#endif
67581
+
67582
+ nSize = *pIter;
67583
+ if( nSize>=0x80 ){
67584
+ pEnd = &pIter[8];
67585
+ nSize &= 0x7f;
67586
+ do{
67587
+ nSize = (nSize<<7) | (*++pIter & 0x7f);
67588
+ }while( *(pIter)>=0x80 && pIter<pEnd );
67589
+ }
67590
+ pIter++;
67591
+ /* pIter now points at the 64-bit integer key value, a variable length
67592
+ ** integer. The following block moves pIter to point at the first byte
67593
+ ** past the end of the key value. */
67594
+ if( (*pIter++)&0x80
67595
+ && (*pIter++)&0x80
67596
+ && (*pIter++)&0x80
67597
+ && (*pIter++)&0x80
67598
+ && (*pIter++)&0x80
67599
+ && (*pIter++)&0x80
67600
+ && (*pIter++)&0x80
67601
+ && (*pIter++)&0x80 ){ pIter++; }
67602
+ testcase( nSize==pPage->maxLocal );
67603
+ testcase( nSize==(u32)pPage->maxLocal+1 );
67604
+ if( nSize<=pPage->maxLocal ){
67605
+ nSize += (u32)(pIter - pCell);
67606
+ if( nSize<4 ) nSize = 4;
67607
+ }else{
67608
+ int minLocal = pPage->minLocal;
67609
+ nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);
67610
+ testcase( nSize==pPage->maxLocal );
67611
+ testcase( nSize==(u32)pPage->maxLocal+1 );
67612
+ if( nSize>pPage->maxLocal ){
67613
+ nSize = minLocal;
67614
+ }
67615
+ nSize += 4 + (u16)(pIter - pCell);
67616
+ }
67617
+ assert( nSize==debuginfo.nSize || CORRUPT_DB );
67618
+ return (u16)nSize;
67619
+}
6753167620
6753267621
6753367622
#ifdef SQLITE_DEBUG
6753467623
/* This variation on cellSizePtr() is used inside of assert() statements
6753567624
** only. */
@@ -67539,11 +67628,11 @@
6753967628
#endif
6754067629
6754167630
#ifndef SQLITE_OMIT_AUTOVACUUM
6754267631
/*
6754367632
** The cell pCell is currently part of page pSrc but will ultimately be part
67544
-** of pPage. (pSrc and pPager are often the same.) If pCell contains a
67633
+** of pPage. (pSrc and pPage are often the same.) If pCell contains a
6754567634
** pointer to an overflow page, insert an entry into the pointer-map for
6754667635
** the overflow page that will be valid after pCell has been moved to pPage.
6754767636
*/
6754867637
static void ptrmapPutOvflPtr(MemPage *pPage, MemPage *pSrc, u8 *pCell,int *pRC){
6754967638
CellInfo info;
@@ -67714,21 +67803,23 @@
6771467803
*/
6771567804
static u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc){
6771667805
const int hdr = pPg->hdrOffset; /* Offset to page header */
6771767806
u8 * const aData = pPg->aData; /* Page data */
6771867807
int iAddr = hdr + 1; /* Address of ptr to pc */
67719
- int pc = get2byte(&aData[iAddr]); /* Address of a free slot */
67808
+ u8 *pTmp = &aData[iAddr]; /* Temporary ptr into aData[] */
67809
+ int pc = get2byte(pTmp); /* Address of a free slot */
6772067810
int x; /* Excess size of the slot */
6772167811
int maxPC = pPg->pBt->usableSize - nByte; /* Max address for a usable slot */
6772267812
int size; /* Size of the free slot */
6772367813
6772467814
assert( pc>0 );
6772567815
while( pc<=maxPC ){
6772667816
/* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each
6772767817
** freeblock form a big-endian integer which is the size of the freeblock
6772867818
** in bytes, including the 4-byte header. */
67729
- size = get2byte(&aData[pc+2]);
67819
+ pTmp = &aData[pc+2];
67820
+ size = get2byte(pTmp);
6773067821
if( (x = size - nByte)>=0 ){
6773167822
testcase( x==4 );
6773267823
testcase( x==3 );
6773367824
if( x<4 ){
6773467825
/* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total
@@ -67749,11 +67840,12 @@
6774967840
put2byte(&aData[pc+2], x);
6775067841
}
6775167842
return &aData[pc + x];
6775267843
}
6775367844
iAddr = pc;
67754
- pc = get2byte(&aData[pc]);
67845
+ pTmp = &aData[pc];
67846
+ pc = get2byte(pTmp);
6775567847
if( pc<=iAddr+size ){
6775667848
if( pc ){
6775767849
/* The next slot in the chain is not past the end of the current slot */
6775867850
*pRc = SQLITE_CORRUPT_PAGE(pPg);
6775967851
}
@@ -67783,10 +67875,11 @@
6778367875
static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
6778467876
const int hdr = pPage->hdrOffset; /* Local cache of pPage->hdrOffset */
6778567877
u8 * const data = pPage->aData; /* Local cache of pPage->aData */
6778667878
int top; /* First byte of cell content area */
6778767879
int rc = SQLITE_OK; /* Integer return code */
67880
+ u8 *pTmp; /* Temp ptr into data[] */
6778867881
int gap; /* First byte of gap between cell pointers and cell content */
6778967882
6779067883
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
6779167884
assert( pPage->pBt );
6779267885
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
@@ -67801,11 +67894,12 @@
6780167894
/* EVIDENCE-OF: R-29356-02391 If the database uses a 65536-byte page size
6780267895
** and the reserved space is zero (the usual value for reserved space)
6780367896
** then the cell content offset of an empty page wants to be 65536.
6780467897
** However, that integer is too large to be stored in a 2-byte unsigned
6780567898
** integer, so a value of 0 is used in its place. */
67806
- top = get2byte(&data[hdr+5]);
67899
+ pTmp = &data[hdr+5];
67900
+ top = get2byte(pTmp);
6780767901
assert( top<=(int)pPage->pBt->usableSize ); /* by btreeComputeFreeSpace() */
6780867902
if( gap>top ){
6780967903
if( top==0 && pPage->pBt->usableSize==65536 ){
6781067904
top = 65536;
6781167905
}else{
@@ -67883,10 +67977,11 @@
6788367977
u8 nFrag = 0; /* Reduction in fragmentation */
6788467978
u16 iOrigSize = iSize; /* Original value of iSize */
6788567979
u16 x; /* Offset to cell content area */
6788667980
u32 iEnd = iStart + iSize; /* First byte past the iStart buffer */
6788767981
unsigned char *data = pPage->aData; /* Page content */
67982
+ u8 *pTmp; /* Temporary ptr into data[] */
6788867983
6788967984
assert( pPage->pBt!=0 );
6789067985
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
6789167986
assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
6789267987
assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );
@@ -67945,11 +68040,12 @@
6794568040
}
6794668041
}
6794768042
if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PAGE(pPage);
6794868043
data[hdr+7] -= nFrag;
6794968044
}
67950
- x = get2byte(&data[hdr+5]);
68045
+ pTmp = &data[hdr+5];
68046
+ x = get2byte(pTmp);
6795168047
if( iStart<=x ){
6795268048
/* The new freeblock is at the beginning of the cell content area,
6795368049
** so just extend the cell content area rather than create another
6795468050
** freelist entry */
6795568051
if( iStart<x ) return SQLITE_CORRUPT_PAGE(pPage);
@@ -68001,10 +68097,11 @@
6800168097
** leaf table b-tree page. */
6800268098
assert( (PTF_LEAFDATA|PTF_INTKEY|PTF_LEAF)==13 );
6800368099
pPage->intKey = 1;
6800468100
if( pPage->leaf ){
6800568101
pPage->intKeyLeaf = 1;
68102
+ pPage->xCellSize = cellSizePtrTableLeaf;
6800668103
pPage->xParseCell = btreeParseCellPtr;
6800768104
}else{
6800868105
pPage->intKeyLeaf = 0;
6800968106
pPage->xCellSize = cellSizePtrNoPayload;
6801068107
pPage->xParseCell = btreeParseCellPtrNoPayload;
@@ -68181,11 +68278,11 @@
6818168278
assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
6818268279
pPage->maskPage = (u16)(pBt->pageSize - 1);
6818368280
pPage->nOverflow = 0;
6818468281
pPage->cellOffset = pPage->hdrOffset + 8 + pPage->childPtrSize;
6818568282
pPage->aCellIdx = data + pPage->childPtrSize + 8;
68186
- pPage->aDataEnd = pPage->aData + pBt->usableSize;
68283
+ pPage->aDataEnd = pPage->aData + pBt->pageSize;
6818768284
pPage->aDataOfst = pPage->aData + pPage->childPtrSize;
6818868285
/* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
6818968286
** number of cells on the page. */
6819068287
pPage->nCell = get2byte(&data[3]);
6819168288
if( pPage->nCell>MX_CELL(pBt) ){
@@ -68216,11 +68313,11 @@
6821668313
unsigned char *data = pPage->aData;
6821768314
BtShared *pBt = pPage->pBt;
6821868315
u8 hdr = pPage->hdrOffset;
6821968316
u16 first;
6822068317
68221
- assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );
68318
+ assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno || CORRUPT_DB );
6822268319
assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
6822368320
assert( sqlite3PagerGetData(pPage->pDbPage) == data );
6822468321
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
6822568322
assert( sqlite3_mutex_held(pBt->mutex) );
6822668323
if( pBt->btsFlags & BTS_FAST_SECURE ){
@@ -68232,11 +68329,11 @@
6823268329
data[hdr+7] = 0;
6823368330
put2byte(&data[hdr+5], pBt->usableSize);
6823468331
pPage->nFree = (u16)(pBt->usableSize - first);
6823568332
decodeFlags(pPage, flags);
6823668333
pPage->cellOffset = first;
68237
- pPage->aDataEnd = &data[pBt->usableSize];
68334
+ pPage->aDataEnd = &data[pBt->pageSize];
6823868335
pPage->aCellIdx = &data[first];
6823968336
pPage->aDataOfst = &data[pPage->childPtrSize];
6824068337
pPage->nOverflow = 0;
6824168338
assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
6824268339
pPage->maskPage = (u16)(pBt->pageSize - 1);
@@ -68358,11 +68455,11 @@
6835868455
rc = btreeInitPage(*ppPage);
6835968456
if( rc!=SQLITE_OK ){
6836068457
goto getAndInitPage_error2;
6836168458
}
6836268459
}
68363
- assert( (*ppPage)->pgno==pgno );
68460
+ assert( (*ppPage)->pgno==pgno || CORRUPT_DB );
6836468461
assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );
6836568462
6836668463
/* If obtaining a child page for a cursor, we must verify that the page is
6836768464
** compatible with the root page. */
6836868465
if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){
@@ -68377,11 +68474,13 @@
6837768474
if( pCur ){
6837868475
pCur->iPage--;
6837968476
pCur->pPage = pCur->apPage[pCur->iPage];
6838068477
}
6838168478
testcase( pgno==0 );
68382
- assert( pgno!=0 || rc==SQLITE_CORRUPT );
68479
+ assert( pgno!=0 || rc==SQLITE_CORRUPT
68480
+ || rc==SQLITE_IOERR_NOMEM
68481
+ || rc==SQLITE_NOMEM );
6838368482
return rc;
6838468483
}
6838568484
6838668485
/*
6838768486
** Release a MemPage. This should be called once for each prior
@@ -75113,11 +75212,11 @@
7511375212
7511475213
pPage = pCur->pPage;
7511575214
assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
7511675215
assert( pPage->leaf || !pPage->intKey );
7511775216
if( pPage->nFree<0 ){
75118
- if( NEVER(pCur->eState>CURSOR_INVALID) ){
75217
+ if( pCur->eState>CURSOR_INVALID ){
7511975218
rc = SQLITE_CORRUPT_BKPT;
7512075219
}else{
7512175220
rc = btreeComputeFreeSpace(pPage);
7512275221
}
7512375222
if( rc ) return rc;
@@ -75431,11 +75530,11 @@
7543175530
** bPreserve==2 Cursor won't move. Set CURSOR_SKIPNEXT.
7543275531
*/
7543375532
bPreserve = (flags & BTREE_SAVEPOSITION)!=0;
7543475533
if( bPreserve ){
7543575534
if( !pPage->leaf
75436
- || (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
75535
+ || (pPage->nFree+pPage->xCellSize(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
7543775536
|| pPage->nCell==1 /* See dbfuzz001.test for a test case */
7543875537
){
7543975538
/* A b-tree rebalance will be required after deleting this entry.
7544075539
** Save the cursor key. */
7544175540
rc = saveCursorKey(pCur);
@@ -80545,11 +80644,11 @@
8054580644
** and store that value in *pMaxFuncArgs.
8054680645
**
8054780646
** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately
8054880647
** indicate what the prepared statement actually does.
8054980648
**
80550
-** (4) Initialize the p4.xAdvance pointer on opcodes that use it.
80649
+** (4) (discontinued)
8055180650
**
8055280651
** (5) Reclaim the memory allocated for storing labels.
8055380652
**
8055480653
** This routine will only function correctly if the mkopcodeh.tcl generator
8055580654
** script numbers the opcodes correctly. Changes to this routine must be
@@ -80591,29 +80690,10 @@
8059180690
case OP_JournalMode: {
8059280691
p->readOnly = 0;
8059380692
p->bIsReader = 1;
8059480693
break;
8059580694
}
80596
- case OP_Next:
80597
- case OP_SorterNext: {
80598
- pOp->p4.xAdvance = sqlite3BtreeNext;
80599
- pOp->p4type = P4_ADVANCE;
80600
- /* The code generator never codes any of these opcodes as a jump
80601
- ** to a label. They are always coded as a jump backwards to a
80602
- ** known address */
80603
- assert( pOp->p2>=0 );
80604
- break;
80605
- }
80606
- case OP_Prev: {
80607
- pOp->p4.xAdvance = sqlite3BtreePrevious;
80608
- pOp->p4type = P4_ADVANCE;
80609
- /* The code generator never codes any of these opcodes as a jump
80610
- ** to a label. They are always coded as a jump backwards to a
80611
- ** known address */
80612
- assert( pOp->p2>=0 );
80613
- break;
80614
- }
8061580695
#ifndef SQLITE_OMIT_VIRTUALTABLE
8061680696
case OP_VUpdate: {
8061780697
if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
8061880698
break;
8061980699
}
@@ -80893,11 +80973,10 @@
8089380973
break;
8089480974
}
8089580975
case P4_REAL:
8089680976
case P4_INT64:
8089780977
case P4_DYNAMIC:
80898
- case P4_DYNBLOB:
8089980978
case P4_INTARRAY: {
8090080979
sqlite3DbFree(db, p4);
8090180980
break;
8090280981
}
8090380982
case P4_KEYINFO: {
@@ -81490,14 +81569,10 @@
8149081569
}
8149181570
case P4_SUBPROGRAM: {
8149281571
zP4 = "program";
8149381572
break;
8149481573
}
81495
- case P4_DYNBLOB:
81496
- case P4_ADVANCE: {
81497
- break;
81498
- }
8149981574
case P4_TABLE: {
8150081575
zP4 = pOp->p4.pTab->zName;
8150181576
break;
8150281577
}
8150381578
default: {
@@ -81625,20 +81700,34 @@
8162581700
}
8162681701
#endif
8162781702
8162881703
/*
8162981704
** Initialize an array of N Mem element.
81705
+**
81706
+** This is a high-runner, so only those fields that really do need to
81707
+** be initialized are set. The Mem structure is organized so that
81708
+** the fields that get initialized are nearby and hopefully on the same
81709
+** cache line.
81710
+**
81711
+** Mem.flags = flags
81712
+** Mem.db = db
81713
+** Mem.szMalloc = 0
81714
+**
81715
+** All other fields of Mem can safely remain uninitialized for now. They
81716
+** will be initialized before use.
8163081717
*/
8163181718
static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){
81632
- while( (N--)>0 ){
81633
- p->db = db;
81634
- p->flags = flags;
81635
- p->szMalloc = 0;
81719
+ if( N>0 ){
81720
+ do{
81721
+ p->flags = flags;
81722
+ p->db = db;
81723
+ p->szMalloc = 0;
8163681724
#ifdef SQLITE_DEBUG
81637
- p->pScopyFrom = 0;
81725
+ p->pScopyFrom = 0;
8163881726
#endif
81639
- p++;
81727
+ p++;
81728
+ }while( (--N)>0 );
8164081729
}
8164181730
}
8164281731
8164381732
/*
8164481733
** Release an array of N Mem elements
@@ -83292,11 +83381,11 @@
8329283381
** pointed to was deleted out from under it. Or maybe the btree was
8329383382
** rebalanced. Whatever the cause, try to restore "p" to the place it
8329483383
** is supposed to be pointing. If the row was deleted out from under the
8329583384
** cursor, set the cursor to point to a NULL row.
8329683385
*/
83297
-static int SQLITE_NOINLINE handleMovedCursor(VdbeCursor *p){
83386
+SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeHandleMovedCursor(VdbeCursor *p){
8329883387
int isDifferentRow, rc;
8329983388
assert( p->eCurType==CURTYPE_BTREE );
8330083389
assert( p->uc.pCursor!=0 );
8330183390
assert( sqlite3BtreeCursorHasMoved(p->uc.pCursor) );
8330283391
rc = sqlite3BtreeCursorRestore(p->uc.pCursor, &isDifferentRow);
@@ -83310,43 +83399,11 @@
8331083399
** if need be. Return any I/O error from the restore operation.
8331183400
*/
8331283401
SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor *p){
8331383402
assert( p->eCurType==CURTYPE_BTREE );
8331483403
if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){
83315
- return handleMovedCursor(p);
83316
- }
83317
- return SQLITE_OK;
83318
-}
83319
-
83320
-/*
83321
-** Make sure the cursor p is ready to read or write the row to which it
83322
-** was last positioned. Return an error code if an OOM fault or I/O error
83323
-** prevents us from positioning the cursor to its correct position.
83324
-**
83325
-** If a MoveTo operation is pending on the given cursor, then do that
83326
-** MoveTo now. If no move is pending, check to see if the row has been
83327
-** deleted out from under the cursor and if it has, mark the row as
83328
-** a NULL row.
83329
-**
83330
-** If the cursor is already pointing to the correct row and that row has
83331
-** not been deleted out from under the cursor, then this routine is a no-op.
83332
-*/
83333
-SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, u32 *piCol){
83334
- VdbeCursor *p = *pp;
83335
- assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO );
83336
- if( p->deferredMoveto ){
83337
- u32 iMap;
83338
- assert( !p->isEphemeral );
83339
- if( p->ub.aAltMap && (iMap = p->ub.aAltMap[1+*piCol])>0 && !p->nullRow ){
83340
- *pp = p->pAltCursor;
83341
- *piCol = iMap - 1;
83342
- return SQLITE_OK;
83343
- }
83344
- return sqlite3VdbeFinishMoveto(p);
83345
- }
83346
- if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){
83347
- return handleMovedCursor(p);
83404
+ return sqlite3VdbeHandleMovedCursor(p);
8334883405
}
8334983406
return SQLITE_OK;
8335083407
}
8335183408
8335283409
/*
@@ -84529,11 +84586,12 @@
8452984586
8453084587
default:
8453184588
return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);
8453284589
}
8453384590
84534
- v = pPKey2->aMem[0].u.i;
84591
+ assert( pPKey2->u.i == pPKey2->aMem[0].u.i );
84592
+ v = pPKey2->u.i;
8453584593
if( v>lhs ){
8453684594
res = pPKey2->r1;
8453784595
}else if( v<lhs ){
8453884596
res = pPKey2->r2;
8453984597
}else if( pPKey2->nField>1 ){
@@ -84564,16 +84622,22 @@
8456484622
const u8 *aKey1 = (const u8*)pKey1;
8456584623
int serial_type;
8456684624
int res;
8456784625
8456884626
assert( pPKey2->aMem[0].flags & MEM_Str );
84627
+ assert( pPKey2->aMem[0].n == pPKey2->n );
84628
+ assert( pPKey2->aMem[0].z == pPKey2->u.z );
8456984629
vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);
84570
- serial_type = (u8)(aKey1[1]);
84571
- if( serial_type >= 0x80 ){
84572
- sqlite3GetVarint32(&aKey1[1], (u32*)&serial_type);
84573
- }
84630
+ serial_type = (signed char)(aKey1[1]);
84631
+
84632
+vrcs_restart:
8457484633
if( serial_type<12 ){
84634
+ if( serial_type<0 ){
84635
+ sqlite3GetVarint32(&aKey1[1], (u32*)&serial_type);
84636
+ if( serial_type>=12 ) goto vrcs_restart;
84637
+ assert( CORRUPT_DB );
84638
+ }
8457584639
res = pPKey2->r1; /* (pKey1/nKey1) is a number or a null */
8457684640
}else if( !(serial_type & 0x01) ){
8457784641
res = pPKey2->r2; /* (pKey1/nKey1) is a blob */
8457884642
}else{
8457984643
int nCmp;
@@ -84583,19 +84647,19 @@
8458384647
nStr = (serial_type-12) / 2;
8458484648
if( (szHdr + nStr) > nKey1 ){
8458584649
pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
8458684650
return 0; /* Corruption */
8458784651
}
84588
- nCmp = MIN( pPKey2->aMem[0].n, nStr );
84589
- res = memcmp(&aKey1[szHdr], pPKey2->aMem[0].z, nCmp);
84652
+ nCmp = MIN( pPKey2->n, nStr );
84653
+ res = memcmp(&aKey1[szHdr], pPKey2->u.z, nCmp);
8459084654
8459184655
if( res>0 ){
8459284656
res = pPKey2->r2;
8459384657
}else if( res<0 ){
8459484658
res = pPKey2->r1;
8459584659
}else{
84596
- res = nStr - pPKey2->aMem[0].n;
84660
+ res = nStr - pPKey2->n;
8459784661
if( res==0 ){
8459884662
if( pPKey2->nField>1 ){
8459984663
res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
8460084664
}else{
8460184665
res = pPKey2->default_rc;
@@ -84646,19 +84710,22 @@
8464684710
}else{
8464784711
p->r1 = -1;
8464884712
p->r2 = 1;
8464984713
}
8465084714
if( (flags & MEM_Int) ){
84715
+ p->u.i = p->aMem[0].u.i;
8465184716
return vdbeRecordCompareInt;
8465284717
}
8465384718
testcase( flags & MEM_Real );
8465484719
testcase( flags & MEM_Null );
8465584720
testcase( flags & MEM_Blob );
8465684721
if( (flags & (MEM_Real|MEM_IntReal|MEM_Null|MEM_Blob))==0
8465784722
&& p->pKeyInfo->aColl[0]==0
8465884723
){
8465984724
assert( flags & MEM_Str );
84725
+ p->u.z = p->aMem[0].z;
84726
+ p->n = p->aMem[0].n;
8466084727
return vdbeRecordCompareString;
8466184728
}
8466284729
}
8466384730
8466484731
return sqlite3VdbeRecordCompare;
@@ -86129,19 +86196,19 @@
8612986196
#if defined(SQLITE_DEBUG) && defined(__GNUC__)
8613086197
__attribute__((aligned(8)))
8613186198
#endif
8613286199
= {
8613386200
/* .u = */ {0},
86201
+ /* .z = */ (char*)0,
86202
+ /* .n = */ (int)0,
8613486203
/* .flags = */ (u16)MEM_Null,
8613586204
/* .enc = */ (u8)0,
8613686205
/* .eSubtype = */ (u8)0,
86137
- /* .n = */ (int)0,
86138
- /* .z = */ (char*)0,
86139
- /* .zMalloc = */ (char*)0,
86206
+ /* .db = */ (sqlite3*)0,
8614086207
/* .szMalloc = */ (int)0,
8614186208
/* .uTemp = */ (u32)0,
86142
- /* .db = */ (sqlite3*)0,
86209
+ /* .zMalloc = */ (char*)0,
8614386210
/* .xDel = */ (void(*)(void*))0,
8614486211
#ifdef SQLITE_DEBUG
8614586212
/* .pScopyFrom = */ (Mem*)0,
8614686213
/* .mScopyFlags= */ 0,
8614786214
#endif
@@ -90020,11 +90087,11 @@
9002090087
** skipped for length() and all content loading can be skipped for typeof().
9002190088
*/
9002290089
case OP_Column: {
9002390090
u32 p2; /* column number to retrieve */
9002490091
VdbeCursor *pC; /* The VDBE cursor */
90025
- BtCursor *pCrsr; /* The BTree cursor */
90092
+ BtCursor *pCrsr; /* The B-Tree cursor corresponding to pC */
9002690093
u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */
9002790094
int len; /* The length of the serialized data for the column */
9002890095
int i; /* Loop counter */
9002990096
Mem *pDest; /* Where to write the extracted value */
9003090097
Mem sMem; /* For storing the record being decoded */
@@ -90034,23 +90101,15 @@
9003490101
u64 offset64; /* 64-bit offset */
9003590102
u32 t; /* A type code from the record header */
9003690103
Mem *pReg; /* PseudoTable input register */
9003790104
9003890105
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
90106
+ assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
9003990107
pC = p->apCsr[pOp->p1];
90040
- assert( pC!=0 );
9004190108
p2 = (u32)pOp->p2;
9004290109
90043
- /* If the cursor cache is stale (meaning it is not currently point at
90044
- ** the correct row) then bring it up-to-date by doing the necessary
90045
- ** B-Tree seek. */
90046
- rc = sqlite3VdbeCursorMoveto(&pC, &p2);
90047
- if( rc ) goto abort_due_to_error;
90048
-
90049
- assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
90050
- pDest = &aMem[pOp->p3];
90051
- memAboutToChange(p, pDest);
90110
+op_column_restart:
9005290111
assert( pC!=0 );
9005390112
assert( p2<(u32)pC->nField );
9005490113
aOffset = pC->aOffset;
9005590114
assert( aOffset==pC->aType+pC->nField );
9005690115
assert( pC->eCurType!=CURTYPE_VTAB );
@@ -90067,30 +90126,43 @@
9006790126
assert( pReg->flags & MEM_Blob );
9006890127
assert( memIsValid(pReg) );
9006990128
pC->payloadSize = pC->szRow = pReg->n;
9007090129
pC->aRow = (u8*)pReg->z;
9007190130
}else{
90131
+ pDest = &aMem[pOp->p3];
90132
+ memAboutToChange(p, pDest);
9007290133
sqlite3VdbeMemSetNull(pDest);
9007390134
goto op_column_out;
9007490135
}
9007590136
}else{
9007690137
pCrsr = pC->uc.pCursor;
90138
+ if( pC->deferredMoveto ){
90139
+ u32 iMap;
90140
+ assert( !pC->isEphemeral );
90141
+ if( pC->ub.aAltMap && (iMap = pC->ub.aAltMap[1+p2])>0 ){
90142
+ pC = pC->pAltCursor;
90143
+ p2 = iMap - 1;
90144
+ goto op_column_restart;
90145
+ }
90146
+ rc = sqlite3VdbeFinishMoveto(pC);
90147
+ if( rc ) goto abort_due_to_error;
90148
+ }else if( sqlite3BtreeCursorHasMoved(pCrsr) ){
90149
+ rc = sqlite3VdbeHandleMovedCursor(pC);
90150
+ if( rc ) goto abort_due_to_error;
90151
+ goto op_column_restart;
90152
+ }
9007790153
assert( pC->eCurType==CURTYPE_BTREE );
9007890154
assert( pCrsr );
9007990155
assert( sqlite3BtreeCursorIsValid(pCrsr) );
9008090156
pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);
9008190157
pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &pC->szRow);
9008290158
assert( pC->szRow<=pC->payloadSize );
9008390159
assert( pC->szRow<=65536 ); /* Maximum page size is 64KiB */
90084
- if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
90085
- goto too_big;
90086
- }
9008790160
}
9008890161
pC->cacheStatus = p->cacheCtr;
9008990162
pC->iHdrOffset = getVarint32(pC->aRow, aOffset[0]);
9009090163
pC->nHdrParsed = 0;
90091
-
9009290164
9009390165
if( pC->szRow<aOffset[0] ){ /*OPTIMIZATION-IF-FALSE*/
9009490166
/* pC->aRow does not have to hold the entire row, but it does at least
9009590167
** need to cover the header of the record. If pC->aRow does not contain
9009690168
** the complete header, then set it to zero, forcing the header to be
@@ -90127,10 +90199,14 @@
9012790199
zData = pC->aRow;
9012890200
assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */
9012990201
testcase( aOffset[0]==0 );
9013090202
goto op_column_read_header;
9013190203
}
90204
+ }else if( sqlite3BtreeCursorHasMoved(pC->uc.pCursor) ){
90205
+ rc = sqlite3VdbeHandleMovedCursor(pC);
90206
+ if( rc ) goto abort_due_to_error;
90207
+ goto op_column_restart;
9013290208
}
9013390209
9013490210
/* Make sure at least the first p2+1 entries of the header have been
9013590211
** parsed and valid information is in aOffset[] and pC->aType[].
9013690212
*/
@@ -90195,10 +90271,12 @@
9019590271
/* If after trying to extract new entries from the header, nHdrParsed is
9019690272
** still not up to p2, that means that the record has fewer than p2
9019790273
** columns. So the result will be either the default value or a NULL.
9019890274
*/
9019990275
if( pC->nHdrParsed<=p2 ){
90276
+ pDest = &aMem[pOp->p3];
90277
+ memAboutToChange(p, pDest);
9020090278
if( pOp->p4type==P4_MEM ){
9020190279
sqlite3VdbeMemShallowCopy(pDest, pOp->p4.pMem, MEM_Static);
9020290280
}else{
9020390281
sqlite3VdbeMemSetNull(pDest);
9020490282
}
@@ -90212,10 +90290,12 @@
9021290290
** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are
9021390291
** all valid.
9021490292
*/
9021590293
assert( p2<pC->nHdrParsed );
9021690294
assert( rc==SQLITE_OK );
90295
+ pDest = &aMem[pOp->p3];
90296
+ memAboutToChange(p, pDest);
9021790297
assert( sqlite3VdbeCheckMemInvariants(pDest) );
9021890298
if( VdbeMemDynamic(pDest) ){
9021990299
sqlite3VdbeMemSetNull(pDest);
9022090300
}
9022190301
assert( t==pC->aType[p2] );
@@ -90232,10 +90312,11 @@
9023290312
*/
9023390313
static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };
9023490314
pDest->n = len = (t-12)/2;
9023590315
pDest->enc = encoding;
9023690316
if( pDest->szMalloc < len+2 ){
90317
+ if( len>db->aLimit[SQLITE_LIMIT_LENGTH] ) goto too_big;
9023790318
pDest->flags = MEM_Null;
9023890319
if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;
9023990320
}else{
9024090321
pDest->z = pDest->zMalloc;
9024190322
}
@@ -90264,10 +90345,11 @@
9026490345
** as that array is 256 bytes long (plenty for VdbeMemPrettyPrint())
9026590346
** and it begins with a bunch of zeros.
9026690347
*/
9026790348
sqlite3VdbeSerialGet((u8*)sqlite3CtypeMap, t, pDest);
9026890349
}else{
90350
+ if( len>db->aLimit[SQLITE_LIMIT_LENGTH] ) goto too_big;
9026990351
rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);
9027090352
if( rc!=SQLITE_OK ) goto abort_due_to_error;
9027190353
sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
9027290354
pDest->flags &= ~MEM_Ephem;
9027390355
}
@@ -90476,11 +90558,10 @@
9047690558
u32 serial_type; /* Type field */
9047790559
Mem *pData0; /* First field to be combined into the record */
9047890560
Mem *pLast; /* Last field of the record */
9047990561
int nField; /* Number of fields in the record */
9048090562
char *zAffinity; /* The affinity string for the record */
90481
- int file_format; /* File format to use for encoding */
9048290563
u32 len; /* Length of a field */
9048390564
u8 *zHdr; /* Where to write next byte of the header */
9048490565
u8 *zPayload; /* Where to write next byte of the payload */
9048590566
9048690567
/* Assuming the record contains N fields, the record format looks
@@ -90505,11 +90586,10 @@
9050590586
zAffinity = pOp->p4.z;
9050690587
assert( nField>0 && pOp->p2>0 && pOp->p2+nField<=(p->nMem+1 - p->nCursor)+1 );
9050790588
pData0 = &aMem[nField];
9050890589
nField = pOp->p2;
9050990590
pLast = &pData0[nField-1];
90510
- file_format = p->minWriteFileFormat;
9051190591
9051290592
/* Identify the output register */
9051390593
assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 );
9051490594
pOut = &aMem[pOp->p3];
9051590595
memAboutToChange(p, pOut);
@@ -90607,11 +90687,11 @@
9060790687
testcase( uu==32767 ); testcase( uu==32768 );
9060890688
testcase( uu==8388607 ); testcase( uu==8388608 );
9060990689
testcase( uu==2147483647 ); testcase( uu==2147483648LL );
9061090690
testcase( uu==140737488355327LL ); testcase( uu==140737488355328LL );
9061190691
if( uu<=127 ){
90612
- if( (i&1)==i && file_format>=4 ){
90692
+ if( (i&1)==i && p->minWriteFileFormat>=4 ){
9061390693
pRec->uTemp = 8+(u32)uu;
9061490694
}else{
9061590695
nData++;
9061690696
pRec->uTemp = 1;
9061790697
}
@@ -93070,10 +93150,14 @@
9307093150
/* Opcode: NullRow P1 * * * *
9307193151
**
9307293152
** Move the cursor P1 to a null row. Any OP_Column operations
9307393153
** that occur while the cursor is on the null row will always
9307493154
** write a NULL.
93155
+**
93156
+** Or, if P1 is a Pseudo-Cursor (a cursor opened using OP_OpenPseudo)
93157
+** just reset the cache for that cursor. This causes the row of
93158
+** content held by the pseudo-cursor to be reparsed.
9307593159
*/
9307693160
case OP_NullRow: {
9307793161
VdbeCursor *pC;
9307893162
9307993163
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -93249,11 +93333,11 @@
9324993333
VdbeBranchTaken(res!=0,2);
9325093334
if( res ) goto jump_to_p2;
9325193335
break;
9325293336
}
9325393337
93254
-/* Opcode: Next P1 P2 P3 P4 P5
93338
+/* Opcode: Next P1 P2 P3 * P5
9325593339
**
9325693340
** Advance cursor P1 so that it points to the next key/data pair in its
9325793341
** table or index. If there are no more key/value pairs then fall through
9325893342
** to the following instruction. But if the cursor advance was successful,
9325993343
** jump immediately to P2.
@@ -93268,19 +93352,16 @@
9326893352
** The P3 value is a hint to the btree implementation. If P3==1, that
9326993353
** means P1 is an SQL index and that this instruction could have been
9327093354
** omitted if that index had been unique. P3 is usually 0. P3 is
9327193355
** always either 0 or 1.
9327293356
**
93273
-** P4 is always of type P4_ADVANCE. The function pointer points to
93274
-** sqlite3BtreeNext().
93275
-**
9327693357
** If P5 is positive and the jump is taken, then event counter
9327793358
** number P5-1 in the prepared statement is incremented.
9327893359
**
9327993360
** See also: Prev
9328093361
*/
93281
-/* Opcode: Prev P1 P2 P3 P4 P5
93362
+/* Opcode: Prev P1 P2 P3 * P5
9328293363
**
9328393364
** Back up cursor P1 so that it points to the previous key/data pair in its
9328493365
** table or index. If there is no previous key/value pairs then fall through
9328593366
** to the following instruction. But if the cursor backup was successful,
9328693367
** jump immediately to P2.
@@ -93296,13 +93377,10 @@
9329693377
** The P3 value is a hint to the btree implementation. If P3==1, that
9329793378
** means P1 is an SQL index and that this instruction could have been
9329893379
** omitted if that index had been unique. P3 is usually 0. P3 is
9329993380
** always either 0 or 1.
9330093381
**
93301
-** P4 is always of type P4_ADVANCE. The function pointer points to
93302
-** sqlite3BtreePrevious().
93303
-**
9330493382
** If P5 is positive and the jump is taken, then event counter
9330593383
** number P5-1 in the prepared statement is incremented.
9330693384
*/
9330793385
/* Opcode: SorterNext P1 P2 * * P5
9330893386
**
@@ -93316,34 +93394,37 @@
9331693394
9331793395
pC = p->apCsr[pOp->p1];
9331893396
assert( isSorter(pC) );
9331993397
rc = sqlite3VdbeSorterNext(db, pC);
9332093398
goto next_tail;
93399
+
9332193400
case OP_Prev: /* jump */
93401
+ assert( pOp->p1>=0 && pOp->p1<p->nCursor );
93402
+ assert( pOp->p5<ArraySize(p->aCounter) );
93403
+ pC = p->apCsr[pOp->p1];
93404
+ assert( pC!=0 );
93405
+ assert( pC->deferredMoveto==0 );
93406
+ assert( pC->eCurType==CURTYPE_BTREE );
93407
+ assert( pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
93408
+ || pC->seekOp==OP_Last || pC->seekOp==OP_IfNoHope
93409
+ || pC->seekOp==OP_NullRow);
93410
+ rc = sqlite3BtreePrevious(pC->uc.pCursor, pOp->p3);
93411
+ goto next_tail;
93412
+
9332293413
case OP_Next: /* jump */
9332393414
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
9332493415
assert( pOp->p5<ArraySize(p->aCounter) );
9332593416
pC = p->apCsr[pOp->p1];
9332693417
assert( pC!=0 );
9332793418
assert( pC->deferredMoveto==0 );
9332893419
assert( pC->eCurType==CURTYPE_BTREE );
93329
- assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
93330
- assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );
93331
-
93332
- /* The Next opcode is only used after SeekGT, SeekGE, Rewind, and Found.
93333
- ** The Prev opcode is only used after SeekLT, SeekLE, and Last. */
93334
- assert( pOp->opcode!=OP_Next
93335
- || pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
93420
+ assert( pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
9333693421
|| pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
9333793422
|| pC->seekOp==OP_NullRow|| pC->seekOp==OP_SeekRowid
9333893423
|| pC->seekOp==OP_IfNoHope);
93339
- assert( pOp->opcode!=OP_Prev
93340
- || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
93341
- || pC->seekOp==OP_Last || pC->seekOp==OP_IfNoHope
93342
- || pC->seekOp==OP_NullRow);
93424
+ rc = sqlite3BtreeNext(pC->uc.pCursor, pOp->p3);
9334393425
93344
- rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
9334593426
next_tail:
9334693427
pC->cacheStatus = CACHE_STALE;
9334793428
VdbeBranchTaken(rc==SQLITE_OK,2);
9334893429
if( rc==SQLITE_OK ){
9334993430
pC->nullRow = 0;
@@ -93557,10 +93638,11 @@
9355793638
assert( pTabCur->uc.pCursor!=0 );
9355893639
assert( pTabCur->isTable );
9355993640
pTabCur->nullRow = 0;
9356093641
pTabCur->movetoTarget = rowid;
9356193642
pTabCur->deferredMoveto = 1;
93643
+ pTabCur->cacheStatus = CACHE_STALE;
9356293644
assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );
9356393645
assert( !pTabCur->isEphemeral );
9356493646
pTabCur->ub.aAltMap = pOp->p4.ai;
9356593647
assert( !pC->isEphemeral );
9356693648
pTabCur->pAltCursor = pC;
@@ -112069,11 +112151,11 @@
112069112151
if( pStat1==0 ) return;
112070112152
pStat1->zName = (char*)&pStat1[1];
112071112153
memcpy(pStat1->zName, "sqlite_stat1", 13);
112072112154
pStat1->nCol = 3;
112073112155
pStat1->iPKey = -1;
112074
- sqlite3VdbeAddOp4(pParse->pVdbe, OP_Noop, 0, 0, 0,(char*)pStat1,P4_DYNBLOB);
112156
+ sqlite3VdbeAddOp4(pParse->pVdbe, OP_Noop, 0, 0, 0,(char*)pStat1,P4_DYNAMIC);
112075112157
}
112076112158
#endif
112077112159
112078112160
/* Establish a read-lock on the table at the shared-cache level.
112079112161
** Open a read-only cursor on the table. Also allocate a cursor number
@@ -125675,11 +125757,15 @@
125675125757
** Then special optimizations can be applied that make the transfer
125676125758
** very fast and which reduce fragmentation of indices.
125677125759
**
125678125760
** This is the 2nd template.
125679125761
*/
125680
- if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
125762
+ if( pColumn==0
125763
+ && pSelect!=0
125764
+ && pTrigger==0
125765
+ && xferOptimization(pParse, pTab, pSelect, onError, iDb)
125766
+ ){
125681125767
assert( !pTrigger );
125682125768
assert( pList==0 );
125683125769
goto insert_end;
125684125770
}
125685125771
#endif /* SQLITE_OMIT_XFER_OPT */
@@ -127646,22 +127732,17 @@
127646127732
Vdbe *v; /* The VDBE we are building */
127647127733
int regAutoinc; /* Memory register used by AUTOINC */
127648127734
int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
127649127735
int regData, regRowid; /* Registers holding data and rowid */
127650127736
127651
- if( pSelect==0 ){
127652
- return 0; /* Must be of the form INSERT INTO ... SELECT ... */
127653
- }
127737
+ assert( pSelect!=0 );
127654127738
if( pParse->pWith || pSelect->pWith ){
127655127739
/* Do not attempt to process this query if there are an WITH clauses
127656127740
** attached to it. Proceeding may generate a false "no such table: xxx"
127657127741
** error if pSelect reads from a CTE named "xxx". */
127658127742
return 0;
127659127743
}
127660
- if( sqlite3TriggerList(pParse, pDest) ){
127661
- return 0; /* tab1 must not have triggers */
127662
- }
127663127744
#ifndef SQLITE_OMIT_VIRTUALTABLE
127664127745
if( IsVirtual(pDest) ){
127665127746
return 0; /* tab1 must not be a virtual table */
127666127747
}
127667127748
#endif
@@ -130011,11 +130092,11 @@
130011130092
/* iArg: */ BTREE_DATA_VERSION },
130012130093
#endif
130013130094
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
130014130095
{/* zName: */ "database_list",
130015130096
/* ePragTyp: */ PragTyp_DATABASE_LIST,
130016
- /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
130097
+ /* ePragFlg: */ PragFlg_Result0,
130017130098
/* ColNames: */ 47, 3,
130018130099
/* iArg: */ 0 },
130019130100
#endif
130020130101
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
130021130102
{/* zName: */ "default_cache_size",
@@ -130699,19 +130780,20 @@
130699130780
Vdbe *v, /* The prepared statement being created */
130700130781
FuncDef *p, /* A particular function definition */
130701130782
int isBuiltin, /* True if this is a built-in function */
130702130783
int showInternFuncs /* True if showing internal functions */
130703130784
){
130785
+ u32 mask =
130786
+ SQLITE_DETERMINISTIC |
130787
+ SQLITE_DIRECTONLY |
130788
+ SQLITE_SUBTYPE |
130789
+ SQLITE_INNOCUOUS |
130790
+ SQLITE_FUNC_INTERNAL
130791
+ ;
130792
+ if( showInternFuncs ) mask = 0xffffffff;
130704130793
for(; p; p=p->pNext){
130705130794
const char *zType;
130706
- static const u32 mask =
130707
- SQLITE_DETERMINISTIC |
130708
- SQLITE_DIRECTONLY |
130709
- SQLITE_SUBTYPE |
130710
- SQLITE_INNOCUOUS |
130711
- SQLITE_FUNC_INTERNAL
130712
- ;
130713130795
static const char *azEnc[] = { 0, "utf8", "utf16le", "utf16be" };
130714130796
130715130797
assert( SQLITE_FUNC_ENCMASK==0x3 );
130716130798
assert( strcmp(azEnc[SQLITE_UTF8],"utf8")==0 );
130717130799
assert( strcmp(azEnc[SQLITE_UTF16LE],"utf16le")==0 );
@@ -148508,18 +148590,26 @@
148508148590
** rowid stored in register iRowid.
148509148591
**
148510148592
** Normally, this is just:
148511148593
**
148512148594
** OP_DeferredSeek $iCur $iRowid
148595
+**
148596
+** Which causes a seek on $iCur to the row with rowid $iRowid.
148513148597
**
148514148598
** However, if the scan currently being coded is a branch of an OR-loop and
148515
-** the statement currently being coded is a SELECT, then P3 of OP_DeferredSeek
148516
-** is set to iIdxCur and P4 is set to point to an array of integers
148517
-** containing one entry for each column of the table cursor iCur is open
148518
-** on. For each table column, if the column is the i'th column of the
148519
-** index, then the corresponding array entry is set to (i+1). If the column
148520
-** does not appear in the index at all, the array entry is set to 0.
148599
+** the statement currently being coded is a SELECT, then additional information
148600
+** is added that might allow OP_Column to omit the seek and instead do its
148601
+** lookup on the index, thus avoiding an expensive seek operation. To
148602
+** enable this optimization, the P3 of OP_DeferredSeek is set to iIdxCur
148603
+** and P4 is set to an array of integers containing one entry for each column
148604
+** in the table. For each table column, if the column is the i'th
148605
+** column of the index, then the corresponding array entry is set to (i+1).
148606
+** If the column does not appear in the index at all, the array entry is set
148607
+** to 0. The OP_Column opcode can check this array to see if the column it
148608
+** wants is in the index and if it is, it will substitute the index cursor
148609
+** and column number and continue with those new values, rather than seeking
148610
+** the table cursor.
148521148611
*/
148522148612
static void codeDeferredSeek(
148523148613
WhereInfo *pWInfo, /* Where clause context */
148524148614
Index *pIdx, /* Index scan is using */
148525148615
int iCur, /* Cursor for IPK b-tree */
@@ -234298,11 +234388,11 @@
234298234388
int nArg, /* Number of args */
234299234389
sqlite3_value **apUnused /* Function arguments */
234300234390
){
234301234391
assert( nArg==0 );
234302234392
UNUSED_PARAM2(nArg, apUnused);
234303
- sqlite3_result_text(pCtx, "fts5: 2022-02-22 18:58:40 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968a1bab", -1, SQLITE_TRANSIENT);
234393
+ sqlite3_result_text(pCtx, "fts5: 2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b", -1, SQLITE_TRANSIENT);
234304234394
}
234305234395
234306234396
/*
234307234397
** Return true if zName is the extension on one of the shadow tables used
234308234398
** by this module.
234309234399
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.38.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -450,13 +450,13 @@
450 **
451 ** See also: [sqlite3_libversion()],
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.38.0"
456 #define SQLITE_VERSION_NUMBER 3038000
457 #define SQLITE_SOURCE_ID "2022-02-22 18:58:40 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968a1bab"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -10071,11 +10071,11 @@
10071 ** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
10072 ** and remains valid for the duration of the xBestIndex method call.
10073 ** ^When xBestIndex returns, the sqlite3_value object returned by
10074 ** sqlite3_vtab_rhs_value() is automatically deallocated.
10075 **
10076 ** The "_rhs_" in the name of this routine is an appreviation for
10077 ** "Right-Hand Side".
10078 */
10079 SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
10080
10081 /*
@@ -14709,18 +14709,19 @@
14709 ** Handle type for pages.
14710 */
14711 typedef struct PgHdr DbPage;
14712
14713 /*
14714 ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
14715 ** reserved for working around a windows/posix incompatibility). It is
14716 ** used in the journal to signify that the remainder of the journal file
14717 ** is devoted to storing a super-journal name - there are no more pages to
14718 ** roll back. See comments for function writeSuperJournal() in pager.c
14719 ** for details.
14720 */
14721 #define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))
 
14722
14723 /*
14724 ** Allowed values for the flags parameter to sqlite3PagerOpen().
14725 **
14726 ** NOTE: These values must match the corresponding BTREE_ values in btree.h.
@@ -15393,11 +15394,10 @@
15393 SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
15394 Table *pTab; /* Used when p4type is P4_TABLE */
15395 #ifdef SQLITE_ENABLE_CURSOR_HINTS
15396 Expr *pExpr; /* Used when p4type is P4_EXPR */
15397 #endif
15398 int (*xAdvance)(BtCursor *, int);
15399 } p4;
15400 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
15401 char *zComment; /* Comment to improve readability */
15402 #endif
15403 #ifdef VDBE_PROFILE
@@ -15444,25 +15444,23 @@
15444 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
15445 #define P4_STATIC (-1) /* Pointer to a static string */
15446 #define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */
15447 #define P4_INT32 (-3) /* P4 is a 32-bit signed integer */
15448 #define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */
15449 #define P4_ADVANCE (-5) /* P4 is a pointer to BtreeNext() or BtreePrev() */
15450 #define P4_TABLE (-6) /* P4 is a pointer to a Table structure */
15451 /* Above do not own any resources. Must free those below */
15452 #define P4_FREE_IF_LE (-7)
15453 #define P4_DYNAMIC (-7) /* Pointer to memory from sqliteMalloc() */
15454 #define P4_FUNCDEF (-8) /* P4 is a pointer to a FuncDef structure */
15455 #define P4_KEYINFO (-9) /* P4 is a pointer to a KeyInfo structure */
15456 #define P4_EXPR (-10) /* P4 is a pointer to an Expr tree */
15457 #define P4_MEM (-11) /* P4 is a pointer to a Mem* structure */
15458 #define P4_VTAB (-12) /* P4 is a pointer to an sqlite3_vtab structure */
15459 #define P4_REAL (-13) /* P4 is a 64-bit floating point value */
15460 #define P4_INT64 (-14) /* P4 is a 64-bit signed integer */
15461 #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
15462 #define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */
15463 #define P4_DYNBLOB (-17) /* Pointer to memory from sqliteMalloc() */
15464
15465 /* Error message codes for OP_Halt */
15466 #define P5_ConstraintNotNull 1
15467 #define P5_ConstraintUnique 2
15468 #define P5_ConstraintCheck 3
@@ -15503,46 +15501,46 @@
15503 /* Automatically generated. Do not edit */
15504 /* See the tool/mkopcodeh.tcl script for details */
15505 #define OP_Savepoint 0
15506 #define OP_AutoCommit 1
15507 #define OP_Transaction 2
15508 #define OP_SorterNext 3 /* jump */
15509 #define OP_Prev 4 /* jump */
15510 #define OP_Next 5 /* jump */
15511 #define OP_Checkpoint 6
15512 #define OP_JournalMode 7
15513 #define OP_Vacuum 8
15514 #define OP_VFilter 9 /* jump, synopsis: iplan=r[P3] zplan='P4' */
15515 #define OP_VUpdate 10 /* synopsis: data=r[P3@P2] */
15516 #define OP_Goto 11 /* jump */
15517 #define OP_Gosub 12 /* jump */
15518 #define OP_InitCoroutine 13 /* jump */
15519 #define OP_Yield 14 /* jump */
15520 #define OP_MustBeInt 15 /* jump */
15521 #define OP_Jump 16 /* jump */
15522 #define OP_Once 17 /* jump */
15523 #define OP_If 18 /* jump */
15524 #define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */
15525 #define OP_IfNot 20 /* jump */
15526 #define OP_IsNullOrType 21 /* jump, synopsis: if typeof(r[P1]) IN (P3,5) goto P2 */
15527 #define OP_IfNullRow 22 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
15528 #define OP_SeekLT 23 /* jump, synopsis: key=r[P3@P4] */
15529 #define OP_SeekLE 24 /* jump, synopsis: key=r[P3@P4] */
15530 #define OP_SeekGE 25 /* jump, synopsis: key=r[P3@P4] */
15531 #define OP_SeekGT 26 /* jump, synopsis: key=r[P3@P4] */
15532 #define OP_IfNotOpen 27 /* jump, synopsis: if( !csr[P1] ) goto P2 */
15533 #define OP_IfNoHope 28 /* jump, synopsis: key=r[P3@P4] */
15534 #define OP_NoConflict 29 /* jump, synopsis: key=r[P3@P4] */
15535 #define OP_NotFound 30 /* jump, synopsis: key=r[P3@P4] */
15536 #define OP_Found 31 /* jump, synopsis: key=r[P3@P4] */
15537 #define OP_SeekRowid 32 /* jump, synopsis: intkey=r[P3] */
15538 #define OP_NotExists 33 /* jump, synopsis: intkey=r[P3] */
15539 #define OP_Last 34 /* jump */
15540 #define OP_IfSmaller 35 /* jump */
15541 #define OP_SorterSort 36 /* jump */
15542 #define OP_Sort 37 /* jump */
15543 #define OP_Rewind 38 /* jump */
15544 #define OP_IdxLE 39 /* jump, synopsis: key=r[P3@P4] */
15545 #define OP_IdxGT 40 /* jump, synopsis: key=r[P3@P4] */
15546 #define OP_IdxLT 41 /* jump, synopsis: key=r[P3@P4] */
15547 #define OP_IdxGE 42 /* jump, synopsis: key=r[P3@P4] */
15548 #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
@@ -15697,15 +15695,15 @@
15697 #define OPFLG_IN2 0x04 /* in2: P2 is an input */
15698 #define OPFLG_IN3 0x08 /* in3: P3 is an input */
15699 #define OPFLG_OUT2 0x10 /* out2: P2 is an output */
15700 #define OPFLG_OUT3 0x20 /* out3: P3 is an output */
15701 #define OPFLG_INITIALIZER {\
15702 /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\
15703 /* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\
15704 /* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x03, 0x01, 0x09,\
15705 /* 24 */ 0x09, 0x09, 0x09, 0x01, 0x09, 0x09, 0x09, 0x09,\
15706 /* 32 */ 0x09, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
15707 /* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\
15708 /* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
15709 /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\
15710 /* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
15711 /* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,\
@@ -17778,10 +17776,15 @@
17778 ** b-tree.
17779 */
17780 struct UnpackedRecord {
17781 KeyInfo *pKeyInfo; /* Collation and sort-order information */
17782 Mem *aMem; /* Values */
 
 
 
 
 
17783 u16 nField; /* Number of entries in apMem[] */
17784 i8 default_rc; /* Comparison result if keys are equal */
17785 u8 errCode; /* Error detected by xRecordCompare (CORRUPT or NOMEM) */
17786 i8 r1; /* Value to return if (lhs < rhs) */
17787 i8 r2; /* Value to return if (lhs > rhs) */
@@ -22225,20 +22228,20 @@
22225 i64 i; /* Integer value used when MEM_Int is set in flags */
22226 int nZero; /* Extra zero bytes when MEM_Zero and MEM_Blob set */
22227 const char *zPType; /* Pointer type when MEM_Term|MEM_Subtype|MEM_Null */
22228 FuncDef *pDef; /* Used only when flags==MEM_Agg */
22229 } u;
 
 
22230 u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
22231 u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
22232 u8 eSubtype; /* Subtype for this value */
22233 int n; /* Number of characters in string value, excluding '\0' */
22234 char *z; /* String or BLOB value */
22235 /* ShallowCopy only needs to copy the information above */
22236 char *zMalloc; /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */
22237 int szMalloc; /* Size of the zMalloc allocation */
22238 u32 uTemp; /* Transient storage for serial_type in OP_MakeRecord */
22239 sqlite3 *db; /* The associated database connection */
22240 void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
22241 #ifdef SQLITE_DEBUG
22242 Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
22243 u16 mScopyFlags; /* flags value immediately after the shallow copy */
22244 #endif
@@ -22246,15 +22249,47 @@
22246
22247 /*
22248 ** Size of struct Mem not including the Mem.zMalloc member or anything that
22249 ** follows.
22250 */
22251 #define MEMCELLSIZE offsetof(Mem,zMalloc)
22252
22253 /* One or more of the following flags are set to indicate the validOK
22254 ** representations of the value stored in the Mem struct.
22255 **
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22256 ** If the MEM_Null flag is set, then the value is an SQL NULL value.
22257 ** For a pointer type created using sqlite3_bind_pointer() or
22258 ** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set.
22259 **
22260 ** If the MEM_Str flag is set then Mem.z points at a string representation.
@@ -22261,39 +22296,36 @@
22261 ** Usually this is encoded in the same unicode encoding as the main
22262 ** database (see below for exceptions). If the MEM_Term flag is also
22263 ** set, then the string is nul terminated. The MEM_Int and MEM_Real
22264 ** flags may coexist with the MEM_Str flag.
22265 */
 
22266 #define MEM_Null 0x0001 /* Value is NULL (or a pointer) */
22267 #define MEM_Str 0x0002 /* Value is a string */
22268 #define MEM_Int 0x0004 /* Value is an integer */
22269 #define MEM_Real 0x0008 /* Value is a real number */
22270 #define MEM_Blob 0x0010 /* Value is a BLOB */
22271 #define MEM_IntReal 0x0020 /* MEM_Int that stringifies like MEM_Real */
22272 #define MEM_AffMask 0x003f /* Mask of affinity bits */
 
 
 
22273 #define MEM_FromBind 0x0040 /* Value originates from sqlite3_bind() */
22274 #define MEM_Undefined 0x0080 /* Value is undefined */
22275 #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
22276 #define MEM_TypeMask 0xc1bf /* Mask of type bits */
22277
22278
22279 /* Whenever Mem contains a valid string or blob representation, one of
22280 ** the following flags must be set to determine the memory management
22281 ** policy for Mem.z. The MEM_Term flag tells us whether or not the
22282 ** string is \000 or \u0000 terminated
22283 */
22284 #define MEM_Term 0x0200 /* String in Mem.z is zero terminated */
22285 #define MEM_Dyn 0x0400 /* Need to call Mem.xDel() on Mem.z */
22286 #define MEM_Static 0x0800 /* Mem.z points to a static string */
22287 #define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */
22288 #define MEM_Agg 0x2000 /* Mem.z points to an agg function context */
22289 #define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */
22290 #define MEM_Subtype 0x8000 /* Mem.eSubtype is valid */
22291 #ifdef SQLITE_OMIT_INCRBLOB
22292 #undef MEM_Zero
22293 #define MEM_Zero 0x0000
22294 #endif
 
22295
22296 /* Return TRUE if Mem X contains dynamically allocated content - anything
22297 ** that needs to be deallocated to avoid a leak.
22298 */
22299 #define VdbeMemDynamic(X) \
@@ -22311,15 +22343,19 @@
22311 #define MemNullNochng(X) \
22312 (((X)->flags&MEM_TypeMask)==(MEM_Null|MEM_Zero) \
22313 && (X)->n==0 && (X)->u.nZero==0)
22314
22315 /*
22316 ** Return true if a memory cell is not marked as invalid. This macro
22317 ** is for use inside assert() statements only.
 
 
 
 
22318 */
22319 #ifdef SQLITE_DEBUG
22320 #define memIsValid(M) ((M)->flags & MEM_Undefined)==0
22321 #endif
22322
22323 /*
22324 ** Each auxiliary data pointer stored by a user defined function
22325 ** implementation calling sqlite3_set_auxdata() is stored in an instance
@@ -22523,12 +22559,12 @@
22523 ** Function prototypes
22524 */
22525 SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...);
22526 SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);
22527 void sqliteVdbePopStack(Vdbe*,int);
 
22528 SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeFinishMoveto(VdbeCursor*);
22529 SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, u32*);
22530 SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
22531 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
22532 SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
22533 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
22534 SQLITE_PRIVATE void sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
@@ -34579,46 +34615,46 @@
34579 SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
34580 static const char *const azName[] = {
34581 /* 0 */ "Savepoint" OpHelp(""),
34582 /* 1 */ "AutoCommit" OpHelp(""),
34583 /* 2 */ "Transaction" OpHelp(""),
34584 /* 3 */ "SorterNext" OpHelp(""),
34585 /* 4 */ "Prev" OpHelp(""),
34586 /* 5 */ "Next" OpHelp(""),
34587 /* 6 */ "Checkpoint" OpHelp(""),
34588 /* 7 */ "JournalMode" OpHelp(""),
34589 /* 8 */ "Vacuum" OpHelp(""),
34590 /* 9 */ "VFilter" OpHelp("iplan=r[P3] zplan='P4'"),
34591 /* 10 */ "VUpdate" OpHelp("data=r[P3@P2]"),
34592 /* 11 */ "Goto" OpHelp(""),
34593 /* 12 */ "Gosub" OpHelp(""),
34594 /* 13 */ "InitCoroutine" OpHelp(""),
34595 /* 14 */ "Yield" OpHelp(""),
34596 /* 15 */ "MustBeInt" OpHelp(""),
34597 /* 16 */ "Jump" OpHelp(""),
34598 /* 17 */ "Once" OpHelp(""),
34599 /* 18 */ "If" OpHelp(""),
34600 /* 19 */ "Not" OpHelp("r[P2]= !r[P1]"),
34601 /* 20 */ "IfNot" OpHelp(""),
34602 /* 21 */ "IsNullOrType" OpHelp("if typeof(r[P1]) IN (P3,5) goto P2"),
34603 /* 22 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"),
34604 /* 23 */ "SeekLT" OpHelp("key=r[P3@P4]"),
34605 /* 24 */ "SeekLE" OpHelp("key=r[P3@P4]"),
34606 /* 25 */ "SeekGE" OpHelp("key=r[P3@P4]"),
34607 /* 26 */ "SeekGT" OpHelp("key=r[P3@P4]"),
34608 /* 27 */ "IfNotOpen" OpHelp("if( !csr[P1] ) goto P2"),
34609 /* 28 */ "IfNoHope" OpHelp("key=r[P3@P4]"),
34610 /* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"),
34611 /* 30 */ "NotFound" OpHelp("key=r[P3@P4]"),
34612 /* 31 */ "Found" OpHelp("key=r[P3@P4]"),
34613 /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"),
34614 /* 33 */ "NotExists" OpHelp("intkey=r[P3]"),
34615 /* 34 */ "Last" OpHelp(""),
34616 /* 35 */ "IfSmaller" OpHelp(""),
34617 /* 36 */ "SorterSort" OpHelp(""),
34618 /* 37 */ "Sort" OpHelp(""),
34619 /* 38 */ "Rewind" OpHelp(""),
34620 /* 39 */ "IdxLE" OpHelp("key=r[P3@P4]"),
34621 /* 40 */ "IdxGT" OpHelp("key=r[P3@P4]"),
34622 /* 41 */ "IdxLT" OpHelp("key=r[P3@P4]"),
34623 /* 42 */ "IdxGE" OpHelp("key=r[P3@P4]"),
34624 /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
@@ -50905,11 +50941,12 @@
50905 /*
50906 ** Make sure the page is marked as dirty. If it isn't dirty already,
50907 ** make it so.
50908 */
50909 SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){
50910 assert( p->nRef>0 );
 
50911 assert( sqlite3PcachePageSanity(p) );
50912 if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ /*OPTIMIZATION-IF-FALSE*/
50913 p->flags &= ~PGHDR_DONT_WRITE;
50914 if( p->flags & PGHDR_CLEAN ){
50915 p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN);
@@ -53874,10 +53911,11 @@
53874 u16 nExtra; /* Add this many bytes to each in-memory page */
53875 i16 nReserve; /* Number of unused bytes at end of each page */
53876 u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */
53877 u32 sectorSize; /* Assumed sector size during rollback */
53878 Pgno mxPgno; /* Maximum allowed size of the database */
 
53879 i64 pageSize; /* Number of bytes in a page */
53880 i64 journalSizeLimit; /* Size limit for persistent journal files */
53881 char *zFilename; /* Name of the database file */
53882 char *zJournal; /* Name of the journal file */
53883 int (*xBusyHandler)(void*); /* Function to call when busy */
@@ -54860,11 +54898,11 @@
54860 ** pPager at the current location. The super-journal name must be the last
54861 ** thing written to a journal file. If the pager is in full-sync mode, the
54862 ** journal file descriptor is advanced to the next sector boundary before
54863 ** anything is written. The format is:
54864 **
54865 ** + 4 bytes: PAGER_MJ_PGNO.
54866 ** + N bytes: super-journal filename in utf-8.
54867 ** + 4 bytes: N (length of super-journal name in bytes, no nul-terminator).
54868 ** + 4 bytes: super-journal name checksum.
54869 ** + 8 bytes: aJournalMagic[].
54870 **
@@ -54908,11 +54946,11 @@
54908 iHdrOff = pPager->journalOff;
54909
54910 /* Write the super-journal data to the end of the journal file. If
54911 ** an error occurs, return the error code to the caller.
54912 */
54913 if( (0 != (rc = write32bits(pPager->jfd, iHdrOff, PAGER_MJ_PGNO(pPager))))
54914 || (0 != (rc = sqlite3OsWrite(pPager->jfd, zSuper, nSuper, iHdrOff+4)))
54915 || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nSuper, nSuper)))
54916 || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nSuper+4, cksum)))
54917 || (0 != (rc = sqlite3OsWrite(pPager->jfd, aJournalMagic, 8,
54918 iHdrOff+4+nSuper+8)))
@@ -55418,11 +55456,11 @@
55418 ** to the database file, then the IO error code is returned. If data
55419 ** is successfully read from the (sub-)journal file but appears to be
55420 ** corrupted, SQLITE_DONE is returned. Data is considered corrupted in
55421 ** two circumstances:
55422 **
55423 ** * If the record page-number is illegal (0 or PAGER_MJ_PGNO), or
55424 ** * If the record is being rolled back from the main journal file
55425 ** and the checksum field does not match the record content.
55426 **
55427 ** Neither of these two scenarios are possible during a savepoint rollback.
55428 **
@@ -55478,11 +55516,11 @@
55478 /* Sanity checking on the page. This is more important that I originally
55479 ** thought. If a power failure occurs while the journal is being written,
55480 ** it could cause invalid data to be written into the journal. We need to
55481 ** detect this invalid data (with high probability) and ignore it.
55482 */
55483 if( pgno==0 || pgno==PAGER_MJ_PGNO(pPager) ){
55484 assert( !isSavepnt );
55485 return SQLITE_DONE;
55486 }
55487 if( pgno>(Pgno)pPager->dbSize || sqlite3BitvecTest(pDone, pgno) ){
55488 return SQLITE_OK;
@@ -56037,10 +56075,13 @@
56037 rc = pager_truncate(pPager, mxPg);
56038 if( rc!=SQLITE_OK ){
56039 goto end_playback;
56040 }
56041 pPager->dbSize = mxPg;
 
 
 
56042 }
56043
56044 /* Copy original pages out of the journal and back into the
56045 ** database file and/or page cache.
56046 */
@@ -56933,10 +56974,11 @@
56933 if( rc==SQLITE_OK ){
56934 sqlite3PageFree(pPager->pTmpSpace);
56935 pPager->pTmpSpace = pNew;
56936 pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);
56937 pPager->pageSize = pageSize;
 
56938 }else{
56939 sqlite3PageFree(pNew);
56940 }
56941 }
56942
@@ -58682,11 +58724,10 @@
58682 assert( pPager->errCode==SQLITE_OK );
58683 assert( pPager->eState>=PAGER_READER );
58684 assert( assert_pager_state(pPager) );
58685 assert( pPager->hasHeldSharedLock==1 );
58686
58687 if( pgno==0 ) return SQLITE_CORRUPT_BKPT;
58688 pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
58689 if( pBase==0 ){
58690 pPg = 0;
58691 rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
58692 if( rc!=SQLITE_OK ) goto pager_acquire_err;
@@ -58702,22 +58743,22 @@
58702
58703 noContent = (flags & PAGER_GET_NOCONTENT)!=0;
58704 if( pPg->pPager && !noContent ){
58705 /* In this case the pcache already contains an initialized copy of
58706 ** the page. Return without further ado. */
58707 assert( pgno!=PAGER_MJ_PGNO(pPager) );
58708 pPager->aStat[PAGER_STAT_HIT]++;
58709 return SQLITE_OK;
58710
58711 }else{
58712 /* The pager cache has created a new page. Its content needs to
58713 ** be initialized. But first some error checks:
58714 **
58715 ** (*) obsolete. Was: maximum page number is 2^31
58716 ** (2) Never try to fetch the locking page
58717 */
58718 if( pgno==PAGER_MJ_PGNO(pPager) ){
58719 rc = SQLITE_CORRUPT_BKPT;
58720 goto pager_acquire_err;
58721 }
58722
58723 pPg->pPager = pPager;
@@ -59112,11 +59153,11 @@
59112 i64 iOff = pPager->journalOff;
59113
59114 /* We should never write to the journal file the page that
59115 ** contains the database locks. The following assert verifies
59116 ** that we do not. */
59117 assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) );
59118
59119 assert( pPager->journalHdr<=pPager->journalOff );
59120 pData2 = pPg->pData;
59121 cksum = pager_cksum(pPager, (u8*)pData2);
59122
@@ -59291,11 +59332,11 @@
59291
59292 for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){
59293 Pgno pg = pg1+ii;
59294 PgHdr *pPage;
59295 if( pg==pPg->pgno || !sqlite3BitvecTest(pPager->pInJournal, pg) ){
59296 if( pg!=PAGER_MJ_PGNO(pPager) ){
59297 rc = sqlite3PagerGet(pPager, pg, &pPage, 0);
59298 if( rc==SQLITE_OK ){
59299 rc = pager_write(pPage);
59300 if( pPage->flags&PGHDR_NEED_SYNC ){
59301 needSync = 1;
@@ -59769,11 +59810,11 @@
59769 ** image was extended as part of the current transaction and then the
59770 ** last page in the db image moved to the free-list. In this case the
59771 ** last page is never written out to disk, leaving the database file
59772 ** undersized. Fix this now if it is the case. */
59773 if( pPager->dbSize>pPager->dbFileSize ){
59774 Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_MJ_PGNO(pPager));
59775 assert( pPager->eState==PAGER_WRITER_DBMOD );
59776 rc = pager_truncate(pPager, nNew);
59777 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
59778 }
59779
@@ -65396,11 +65437,13 @@
65396 u16 aiOvfl[4]; /* Insert the i-th overflow cell before the aiOvfl-th
65397 ** non-overflow cell */
65398 u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
65399 BtShared *pBt; /* Pointer to BtShared that this page is part of */
65400 u8 *aData; /* Pointer to disk image of the page data */
65401 u8 *aDataEnd; /* One byte past the end of usable data */
 
 
65402 u8 *aCellIdx; /* The cell index area */
65403 u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
65404 DbPage *pDbPage; /* Pager page handle */
65405 u16 (*xCellSize)(MemPage*,u8*); /* cellSizePtr method */
65406 void (*xParseCell)(MemPage*,u8*,CellInfo*); /* btreeParseCell method */
@@ -65701,11 +65744,11 @@
65701 #define CURSOR_FAULT 4
65702
65703 /*
65704 ** The database page the PENDING_BYTE occupies. This page is never used.
65705 */
65706 # define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt)
65707
65708 /*
65709 ** These macros define the location of the pointer-map entry for a
65710 ** database page. The first argument to each is the number of usable
65711 ** bytes on each page of the database (often 1024). The second is the
@@ -67455,10 +67498,11 @@
67455 ** data area of the btree-page. The return number includes the cell
67456 ** data header and the local payload, but not any overflow page or
67457 ** the space used by the cell pointer.
67458 **
67459 ** cellSizePtrNoPayload() => table internal nodes
 
67460 ** cellSizePtr() => all index nodes & table leaf nodes
67461 */
67462 static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
67463 u8 *pIter = pCell + pPage->childPtrSize; /* For looping over bytes of pCell */
67464 u8 *pEnd; /* End mark for a varint */
@@ -67480,17 +67524,10 @@
67480 do{
67481 nSize = (nSize<<7) | (*++pIter & 0x7f);
67482 }while( *(pIter)>=0x80 && pIter<pEnd );
67483 }
67484 pIter++;
67485 if( pPage->intKey ){
67486 /* pIter now points at the 64-bit integer key value, a variable length
67487 ** integer. The following block moves pIter to point at the first byte
67488 ** past the end of the key value. */
67489 pEnd = &pIter[9];
67490 while( (*pIter++)&0x80 && pIter<pEnd );
67491 }
67492 testcase( nSize==pPage->maxLocal );
67493 testcase( nSize==(u32)pPage->maxLocal+1 );
67494 if( nSize<=pPage->maxLocal ){
67495 nSize += (u32)(pIter - pCell);
67496 if( nSize<4 ) nSize = 4;
@@ -67526,10 +67563,62 @@
67526 pEnd = pIter + 9;
67527 while( (*pIter++)&0x80 && pIter<pEnd );
67528 assert( debuginfo.nSize==(u16)(pIter - pCell) || CORRUPT_DB );
67529 return (u16)(pIter - pCell);
67530 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67531
67532
67533 #ifdef SQLITE_DEBUG
67534 /* This variation on cellSizePtr() is used inside of assert() statements
67535 ** only. */
@@ -67539,11 +67628,11 @@
67539 #endif
67540
67541 #ifndef SQLITE_OMIT_AUTOVACUUM
67542 /*
67543 ** The cell pCell is currently part of page pSrc but will ultimately be part
67544 ** of pPage. (pSrc and pPager are often the same.) If pCell contains a
67545 ** pointer to an overflow page, insert an entry into the pointer-map for
67546 ** the overflow page that will be valid after pCell has been moved to pPage.
67547 */
67548 static void ptrmapPutOvflPtr(MemPage *pPage, MemPage *pSrc, u8 *pCell,int *pRC){
67549 CellInfo info;
@@ -67714,21 +67803,23 @@
67714 */
67715 static u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc){
67716 const int hdr = pPg->hdrOffset; /* Offset to page header */
67717 u8 * const aData = pPg->aData; /* Page data */
67718 int iAddr = hdr + 1; /* Address of ptr to pc */
67719 int pc = get2byte(&aData[iAddr]); /* Address of a free slot */
 
67720 int x; /* Excess size of the slot */
67721 int maxPC = pPg->pBt->usableSize - nByte; /* Max address for a usable slot */
67722 int size; /* Size of the free slot */
67723
67724 assert( pc>0 );
67725 while( pc<=maxPC ){
67726 /* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each
67727 ** freeblock form a big-endian integer which is the size of the freeblock
67728 ** in bytes, including the 4-byte header. */
67729 size = get2byte(&aData[pc+2]);
 
67730 if( (x = size - nByte)>=0 ){
67731 testcase( x==4 );
67732 testcase( x==3 );
67733 if( x<4 ){
67734 /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total
@@ -67749,11 +67840,12 @@
67749 put2byte(&aData[pc+2], x);
67750 }
67751 return &aData[pc + x];
67752 }
67753 iAddr = pc;
67754 pc = get2byte(&aData[pc]);
 
67755 if( pc<=iAddr+size ){
67756 if( pc ){
67757 /* The next slot in the chain is not past the end of the current slot */
67758 *pRc = SQLITE_CORRUPT_PAGE(pPg);
67759 }
@@ -67783,10 +67875,11 @@
67783 static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
67784 const int hdr = pPage->hdrOffset; /* Local cache of pPage->hdrOffset */
67785 u8 * const data = pPage->aData; /* Local cache of pPage->aData */
67786 int top; /* First byte of cell content area */
67787 int rc = SQLITE_OK; /* Integer return code */
 
67788 int gap; /* First byte of gap between cell pointers and cell content */
67789
67790 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
67791 assert( pPage->pBt );
67792 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
@@ -67801,11 +67894,12 @@
67801 /* EVIDENCE-OF: R-29356-02391 If the database uses a 65536-byte page size
67802 ** and the reserved space is zero (the usual value for reserved space)
67803 ** then the cell content offset of an empty page wants to be 65536.
67804 ** However, that integer is too large to be stored in a 2-byte unsigned
67805 ** integer, so a value of 0 is used in its place. */
67806 top = get2byte(&data[hdr+5]);
 
67807 assert( top<=(int)pPage->pBt->usableSize ); /* by btreeComputeFreeSpace() */
67808 if( gap>top ){
67809 if( top==0 && pPage->pBt->usableSize==65536 ){
67810 top = 65536;
67811 }else{
@@ -67883,10 +67977,11 @@
67883 u8 nFrag = 0; /* Reduction in fragmentation */
67884 u16 iOrigSize = iSize; /* Original value of iSize */
67885 u16 x; /* Offset to cell content area */
67886 u32 iEnd = iStart + iSize; /* First byte past the iStart buffer */
67887 unsigned char *data = pPage->aData; /* Page content */
 
67888
67889 assert( pPage->pBt!=0 );
67890 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
67891 assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
67892 assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );
@@ -67945,11 +68040,12 @@
67945 }
67946 }
67947 if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PAGE(pPage);
67948 data[hdr+7] -= nFrag;
67949 }
67950 x = get2byte(&data[hdr+5]);
 
67951 if( iStart<=x ){
67952 /* The new freeblock is at the beginning of the cell content area,
67953 ** so just extend the cell content area rather than create another
67954 ** freelist entry */
67955 if( iStart<x ) return SQLITE_CORRUPT_PAGE(pPage);
@@ -68001,10 +68097,11 @@
68001 ** leaf table b-tree page. */
68002 assert( (PTF_LEAFDATA|PTF_INTKEY|PTF_LEAF)==13 );
68003 pPage->intKey = 1;
68004 if( pPage->leaf ){
68005 pPage->intKeyLeaf = 1;
 
68006 pPage->xParseCell = btreeParseCellPtr;
68007 }else{
68008 pPage->intKeyLeaf = 0;
68009 pPage->xCellSize = cellSizePtrNoPayload;
68010 pPage->xParseCell = btreeParseCellPtrNoPayload;
@@ -68181,11 +68278,11 @@
68181 assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
68182 pPage->maskPage = (u16)(pBt->pageSize - 1);
68183 pPage->nOverflow = 0;
68184 pPage->cellOffset = pPage->hdrOffset + 8 + pPage->childPtrSize;
68185 pPage->aCellIdx = data + pPage->childPtrSize + 8;
68186 pPage->aDataEnd = pPage->aData + pBt->usableSize;
68187 pPage->aDataOfst = pPage->aData + pPage->childPtrSize;
68188 /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
68189 ** number of cells on the page. */
68190 pPage->nCell = get2byte(&data[3]);
68191 if( pPage->nCell>MX_CELL(pBt) ){
@@ -68216,11 +68313,11 @@
68216 unsigned char *data = pPage->aData;
68217 BtShared *pBt = pPage->pBt;
68218 u8 hdr = pPage->hdrOffset;
68219 u16 first;
68220
68221 assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );
68222 assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
68223 assert( sqlite3PagerGetData(pPage->pDbPage) == data );
68224 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
68225 assert( sqlite3_mutex_held(pBt->mutex) );
68226 if( pBt->btsFlags & BTS_FAST_SECURE ){
@@ -68232,11 +68329,11 @@
68232 data[hdr+7] = 0;
68233 put2byte(&data[hdr+5], pBt->usableSize);
68234 pPage->nFree = (u16)(pBt->usableSize - first);
68235 decodeFlags(pPage, flags);
68236 pPage->cellOffset = first;
68237 pPage->aDataEnd = &data[pBt->usableSize];
68238 pPage->aCellIdx = &data[first];
68239 pPage->aDataOfst = &data[pPage->childPtrSize];
68240 pPage->nOverflow = 0;
68241 assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
68242 pPage->maskPage = (u16)(pBt->pageSize - 1);
@@ -68358,11 +68455,11 @@
68358 rc = btreeInitPage(*ppPage);
68359 if( rc!=SQLITE_OK ){
68360 goto getAndInitPage_error2;
68361 }
68362 }
68363 assert( (*ppPage)->pgno==pgno );
68364 assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );
68365
68366 /* If obtaining a child page for a cursor, we must verify that the page is
68367 ** compatible with the root page. */
68368 if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){
@@ -68377,11 +68474,13 @@
68377 if( pCur ){
68378 pCur->iPage--;
68379 pCur->pPage = pCur->apPage[pCur->iPage];
68380 }
68381 testcase( pgno==0 );
68382 assert( pgno!=0 || rc==SQLITE_CORRUPT );
 
 
68383 return rc;
68384 }
68385
68386 /*
68387 ** Release a MemPage. This should be called once for each prior
@@ -75113,11 +75212,11 @@
75113
75114 pPage = pCur->pPage;
75115 assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
75116 assert( pPage->leaf || !pPage->intKey );
75117 if( pPage->nFree<0 ){
75118 if( NEVER(pCur->eState>CURSOR_INVALID) ){
75119 rc = SQLITE_CORRUPT_BKPT;
75120 }else{
75121 rc = btreeComputeFreeSpace(pPage);
75122 }
75123 if( rc ) return rc;
@@ -75431,11 +75530,11 @@
75431 ** bPreserve==2 Cursor won't move. Set CURSOR_SKIPNEXT.
75432 */
75433 bPreserve = (flags & BTREE_SAVEPOSITION)!=0;
75434 if( bPreserve ){
75435 if( !pPage->leaf
75436 || (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
75437 || pPage->nCell==1 /* See dbfuzz001.test for a test case */
75438 ){
75439 /* A b-tree rebalance will be required after deleting this entry.
75440 ** Save the cursor key. */
75441 rc = saveCursorKey(pCur);
@@ -80545,11 +80644,11 @@
80545 ** and store that value in *pMaxFuncArgs.
80546 **
80547 ** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately
80548 ** indicate what the prepared statement actually does.
80549 **
80550 ** (4) Initialize the p4.xAdvance pointer on opcodes that use it.
80551 **
80552 ** (5) Reclaim the memory allocated for storing labels.
80553 **
80554 ** This routine will only function correctly if the mkopcodeh.tcl generator
80555 ** script numbers the opcodes correctly. Changes to this routine must be
@@ -80591,29 +80690,10 @@
80591 case OP_JournalMode: {
80592 p->readOnly = 0;
80593 p->bIsReader = 1;
80594 break;
80595 }
80596 case OP_Next:
80597 case OP_SorterNext: {
80598 pOp->p4.xAdvance = sqlite3BtreeNext;
80599 pOp->p4type = P4_ADVANCE;
80600 /* The code generator never codes any of these opcodes as a jump
80601 ** to a label. They are always coded as a jump backwards to a
80602 ** known address */
80603 assert( pOp->p2>=0 );
80604 break;
80605 }
80606 case OP_Prev: {
80607 pOp->p4.xAdvance = sqlite3BtreePrevious;
80608 pOp->p4type = P4_ADVANCE;
80609 /* The code generator never codes any of these opcodes as a jump
80610 ** to a label. They are always coded as a jump backwards to a
80611 ** known address */
80612 assert( pOp->p2>=0 );
80613 break;
80614 }
80615 #ifndef SQLITE_OMIT_VIRTUALTABLE
80616 case OP_VUpdate: {
80617 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
80618 break;
80619 }
@@ -80893,11 +80973,10 @@
80893 break;
80894 }
80895 case P4_REAL:
80896 case P4_INT64:
80897 case P4_DYNAMIC:
80898 case P4_DYNBLOB:
80899 case P4_INTARRAY: {
80900 sqlite3DbFree(db, p4);
80901 break;
80902 }
80903 case P4_KEYINFO: {
@@ -81490,14 +81569,10 @@
81490 }
81491 case P4_SUBPROGRAM: {
81492 zP4 = "program";
81493 break;
81494 }
81495 case P4_DYNBLOB:
81496 case P4_ADVANCE: {
81497 break;
81498 }
81499 case P4_TABLE: {
81500 zP4 = pOp->p4.pTab->zName;
81501 break;
81502 }
81503 default: {
@@ -81625,20 +81700,34 @@
81625 }
81626 #endif
81627
81628 /*
81629 ** Initialize an array of N Mem element.
 
 
 
 
 
 
 
 
 
 
 
 
81630 */
81631 static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){
81632 while( (N--)>0 ){
81633 p->db = db;
81634 p->flags = flags;
81635 p->szMalloc = 0;
 
81636 #ifdef SQLITE_DEBUG
81637 p->pScopyFrom = 0;
81638 #endif
81639 p++;
 
81640 }
81641 }
81642
81643 /*
81644 ** Release an array of N Mem elements
@@ -83292,11 +83381,11 @@
83292 ** pointed to was deleted out from under it. Or maybe the btree was
83293 ** rebalanced. Whatever the cause, try to restore "p" to the place it
83294 ** is supposed to be pointing. If the row was deleted out from under the
83295 ** cursor, set the cursor to point to a NULL row.
83296 */
83297 static int SQLITE_NOINLINE handleMovedCursor(VdbeCursor *p){
83298 int isDifferentRow, rc;
83299 assert( p->eCurType==CURTYPE_BTREE );
83300 assert( p->uc.pCursor!=0 );
83301 assert( sqlite3BtreeCursorHasMoved(p->uc.pCursor) );
83302 rc = sqlite3BtreeCursorRestore(p->uc.pCursor, &isDifferentRow);
@@ -83310,43 +83399,11 @@
83310 ** if need be. Return any I/O error from the restore operation.
83311 */
83312 SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor *p){
83313 assert( p->eCurType==CURTYPE_BTREE );
83314 if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){
83315 return handleMovedCursor(p);
83316 }
83317 return SQLITE_OK;
83318 }
83319
83320 /*
83321 ** Make sure the cursor p is ready to read or write the row to which it
83322 ** was last positioned. Return an error code if an OOM fault or I/O error
83323 ** prevents us from positioning the cursor to its correct position.
83324 **
83325 ** If a MoveTo operation is pending on the given cursor, then do that
83326 ** MoveTo now. If no move is pending, check to see if the row has been
83327 ** deleted out from under the cursor and if it has, mark the row as
83328 ** a NULL row.
83329 **
83330 ** If the cursor is already pointing to the correct row and that row has
83331 ** not been deleted out from under the cursor, then this routine is a no-op.
83332 */
83333 SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, u32 *piCol){
83334 VdbeCursor *p = *pp;
83335 assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO );
83336 if( p->deferredMoveto ){
83337 u32 iMap;
83338 assert( !p->isEphemeral );
83339 if( p->ub.aAltMap && (iMap = p->ub.aAltMap[1+*piCol])>0 && !p->nullRow ){
83340 *pp = p->pAltCursor;
83341 *piCol = iMap - 1;
83342 return SQLITE_OK;
83343 }
83344 return sqlite3VdbeFinishMoveto(p);
83345 }
83346 if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){
83347 return handleMovedCursor(p);
83348 }
83349 return SQLITE_OK;
83350 }
83351
83352 /*
@@ -84529,11 +84586,12 @@
84529
84530 default:
84531 return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);
84532 }
84533
84534 v = pPKey2->aMem[0].u.i;
 
84535 if( v>lhs ){
84536 res = pPKey2->r1;
84537 }else if( v<lhs ){
84538 res = pPKey2->r2;
84539 }else if( pPKey2->nField>1 ){
@@ -84564,16 +84622,22 @@
84564 const u8 *aKey1 = (const u8*)pKey1;
84565 int serial_type;
84566 int res;
84567
84568 assert( pPKey2->aMem[0].flags & MEM_Str );
 
 
84569 vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);
84570 serial_type = (u8)(aKey1[1]);
84571 if( serial_type >= 0x80 ){
84572 sqlite3GetVarint32(&aKey1[1], (u32*)&serial_type);
84573 }
84574 if( serial_type<12 ){
 
 
 
 
 
84575 res = pPKey2->r1; /* (pKey1/nKey1) is a number or a null */
84576 }else if( !(serial_type & 0x01) ){
84577 res = pPKey2->r2; /* (pKey1/nKey1) is a blob */
84578 }else{
84579 int nCmp;
@@ -84583,19 +84647,19 @@
84583 nStr = (serial_type-12) / 2;
84584 if( (szHdr + nStr) > nKey1 ){
84585 pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
84586 return 0; /* Corruption */
84587 }
84588 nCmp = MIN( pPKey2->aMem[0].n, nStr );
84589 res = memcmp(&aKey1[szHdr], pPKey2->aMem[0].z, nCmp);
84590
84591 if( res>0 ){
84592 res = pPKey2->r2;
84593 }else if( res<0 ){
84594 res = pPKey2->r1;
84595 }else{
84596 res = nStr - pPKey2->aMem[0].n;
84597 if( res==0 ){
84598 if( pPKey2->nField>1 ){
84599 res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
84600 }else{
84601 res = pPKey2->default_rc;
@@ -84646,19 +84710,22 @@
84646 }else{
84647 p->r1 = -1;
84648 p->r2 = 1;
84649 }
84650 if( (flags & MEM_Int) ){
 
84651 return vdbeRecordCompareInt;
84652 }
84653 testcase( flags & MEM_Real );
84654 testcase( flags & MEM_Null );
84655 testcase( flags & MEM_Blob );
84656 if( (flags & (MEM_Real|MEM_IntReal|MEM_Null|MEM_Blob))==0
84657 && p->pKeyInfo->aColl[0]==0
84658 ){
84659 assert( flags & MEM_Str );
 
 
84660 return vdbeRecordCompareString;
84661 }
84662 }
84663
84664 return sqlite3VdbeRecordCompare;
@@ -86129,19 +86196,19 @@
86129 #if defined(SQLITE_DEBUG) && defined(__GNUC__)
86130 __attribute__((aligned(8)))
86131 #endif
86132 = {
86133 /* .u = */ {0},
 
 
86134 /* .flags = */ (u16)MEM_Null,
86135 /* .enc = */ (u8)0,
86136 /* .eSubtype = */ (u8)0,
86137 /* .n = */ (int)0,
86138 /* .z = */ (char*)0,
86139 /* .zMalloc = */ (char*)0,
86140 /* .szMalloc = */ (int)0,
86141 /* .uTemp = */ (u32)0,
86142 /* .db = */ (sqlite3*)0,
86143 /* .xDel = */ (void(*)(void*))0,
86144 #ifdef SQLITE_DEBUG
86145 /* .pScopyFrom = */ (Mem*)0,
86146 /* .mScopyFlags= */ 0,
86147 #endif
@@ -90020,11 +90087,11 @@
90020 ** skipped for length() and all content loading can be skipped for typeof().
90021 */
90022 case OP_Column: {
90023 u32 p2; /* column number to retrieve */
90024 VdbeCursor *pC; /* The VDBE cursor */
90025 BtCursor *pCrsr; /* The BTree cursor */
90026 u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */
90027 int len; /* The length of the serialized data for the column */
90028 int i; /* Loop counter */
90029 Mem *pDest; /* Where to write the extracted value */
90030 Mem sMem; /* For storing the record being decoded */
@@ -90034,23 +90101,15 @@
90034 u64 offset64; /* 64-bit offset */
90035 u32 t; /* A type code from the record header */
90036 Mem *pReg; /* PseudoTable input register */
90037
90038 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
 
90039 pC = p->apCsr[pOp->p1];
90040 assert( pC!=0 );
90041 p2 = (u32)pOp->p2;
90042
90043 /* If the cursor cache is stale (meaning it is not currently point at
90044 ** the correct row) then bring it up-to-date by doing the necessary
90045 ** B-Tree seek. */
90046 rc = sqlite3VdbeCursorMoveto(&pC, &p2);
90047 if( rc ) goto abort_due_to_error;
90048
90049 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
90050 pDest = &aMem[pOp->p3];
90051 memAboutToChange(p, pDest);
90052 assert( pC!=0 );
90053 assert( p2<(u32)pC->nField );
90054 aOffset = pC->aOffset;
90055 assert( aOffset==pC->aType+pC->nField );
90056 assert( pC->eCurType!=CURTYPE_VTAB );
@@ -90067,30 +90126,43 @@
90067 assert( pReg->flags & MEM_Blob );
90068 assert( memIsValid(pReg) );
90069 pC->payloadSize = pC->szRow = pReg->n;
90070 pC->aRow = (u8*)pReg->z;
90071 }else{
 
 
90072 sqlite3VdbeMemSetNull(pDest);
90073 goto op_column_out;
90074 }
90075 }else{
90076 pCrsr = pC->uc.pCursor;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90077 assert( pC->eCurType==CURTYPE_BTREE );
90078 assert( pCrsr );
90079 assert( sqlite3BtreeCursorIsValid(pCrsr) );
90080 pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);
90081 pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &pC->szRow);
90082 assert( pC->szRow<=pC->payloadSize );
90083 assert( pC->szRow<=65536 ); /* Maximum page size is 64KiB */
90084 if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
90085 goto too_big;
90086 }
90087 }
90088 pC->cacheStatus = p->cacheCtr;
90089 pC->iHdrOffset = getVarint32(pC->aRow, aOffset[0]);
90090 pC->nHdrParsed = 0;
90091
90092
90093 if( pC->szRow<aOffset[0] ){ /*OPTIMIZATION-IF-FALSE*/
90094 /* pC->aRow does not have to hold the entire row, but it does at least
90095 ** need to cover the header of the record. If pC->aRow does not contain
90096 ** the complete header, then set it to zero, forcing the header to be
@@ -90127,10 +90199,14 @@
90127 zData = pC->aRow;
90128 assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */
90129 testcase( aOffset[0]==0 );
90130 goto op_column_read_header;
90131 }
 
 
 
 
90132 }
90133
90134 /* Make sure at least the first p2+1 entries of the header have been
90135 ** parsed and valid information is in aOffset[] and pC->aType[].
90136 */
@@ -90195,10 +90271,12 @@
90195 /* If after trying to extract new entries from the header, nHdrParsed is
90196 ** still not up to p2, that means that the record has fewer than p2
90197 ** columns. So the result will be either the default value or a NULL.
90198 */
90199 if( pC->nHdrParsed<=p2 ){
 
 
90200 if( pOp->p4type==P4_MEM ){
90201 sqlite3VdbeMemShallowCopy(pDest, pOp->p4.pMem, MEM_Static);
90202 }else{
90203 sqlite3VdbeMemSetNull(pDest);
90204 }
@@ -90212,10 +90290,12 @@
90212 ** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are
90213 ** all valid.
90214 */
90215 assert( p2<pC->nHdrParsed );
90216 assert( rc==SQLITE_OK );
 
 
90217 assert( sqlite3VdbeCheckMemInvariants(pDest) );
90218 if( VdbeMemDynamic(pDest) ){
90219 sqlite3VdbeMemSetNull(pDest);
90220 }
90221 assert( t==pC->aType[p2] );
@@ -90232,10 +90312,11 @@
90232 */
90233 static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };
90234 pDest->n = len = (t-12)/2;
90235 pDest->enc = encoding;
90236 if( pDest->szMalloc < len+2 ){
 
90237 pDest->flags = MEM_Null;
90238 if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;
90239 }else{
90240 pDest->z = pDest->zMalloc;
90241 }
@@ -90264,10 +90345,11 @@
90264 ** as that array is 256 bytes long (plenty for VdbeMemPrettyPrint())
90265 ** and it begins with a bunch of zeros.
90266 */
90267 sqlite3VdbeSerialGet((u8*)sqlite3CtypeMap, t, pDest);
90268 }else{
 
90269 rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);
90270 if( rc!=SQLITE_OK ) goto abort_due_to_error;
90271 sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
90272 pDest->flags &= ~MEM_Ephem;
90273 }
@@ -90476,11 +90558,10 @@
90476 u32 serial_type; /* Type field */
90477 Mem *pData0; /* First field to be combined into the record */
90478 Mem *pLast; /* Last field of the record */
90479 int nField; /* Number of fields in the record */
90480 char *zAffinity; /* The affinity string for the record */
90481 int file_format; /* File format to use for encoding */
90482 u32 len; /* Length of a field */
90483 u8 *zHdr; /* Where to write next byte of the header */
90484 u8 *zPayload; /* Where to write next byte of the payload */
90485
90486 /* Assuming the record contains N fields, the record format looks
@@ -90505,11 +90586,10 @@
90505 zAffinity = pOp->p4.z;
90506 assert( nField>0 && pOp->p2>0 && pOp->p2+nField<=(p->nMem+1 - p->nCursor)+1 );
90507 pData0 = &aMem[nField];
90508 nField = pOp->p2;
90509 pLast = &pData0[nField-1];
90510 file_format = p->minWriteFileFormat;
90511
90512 /* Identify the output register */
90513 assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 );
90514 pOut = &aMem[pOp->p3];
90515 memAboutToChange(p, pOut);
@@ -90607,11 +90687,11 @@
90607 testcase( uu==32767 ); testcase( uu==32768 );
90608 testcase( uu==8388607 ); testcase( uu==8388608 );
90609 testcase( uu==2147483647 ); testcase( uu==2147483648LL );
90610 testcase( uu==140737488355327LL ); testcase( uu==140737488355328LL );
90611 if( uu<=127 ){
90612 if( (i&1)==i && file_format>=4 ){
90613 pRec->uTemp = 8+(u32)uu;
90614 }else{
90615 nData++;
90616 pRec->uTemp = 1;
90617 }
@@ -93070,10 +93150,14 @@
93070 /* Opcode: NullRow P1 * * * *
93071 **
93072 ** Move the cursor P1 to a null row. Any OP_Column operations
93073 ** that occur while the cursor is on the null row will always
93074 ** write a NULL.
 
 
 
 
93075 */
93076 case OP_NullRow: {
93077 VdbeCursor *pC;
93078
93079 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -93249,11 +93333,11 @@
93249 VdbeBranchTaken(res!=0,2);
93250 if( res ) goto jump_to_p2;
93251 break;
93252 }
93253
93254 /* Opcode: Next P1 P2 P3 P4 P5
93255 **
93256 ** Advance cursor P1 so that it points to the next key/data pair in its
93257 ** table or index. If there are no more key/value pairs then fall through
93258 ** to the following instruction. But if the cursor advance was successful,
93259 ** jump immediately to P2.
@@ -93268,19 +93352,16 @@
93268 ** The P3 value is a hint to the btree implementation. If P3==1, that
93269 ** means P1 is an SQL index and that this instruction could have been
93270 ** omitted if that index had been unique. P3 is usually 0. P3 is
93271 ** always either 0 or 1.
93272 **
93273 ** P4 is always of type P4_ADVANCE. The function pointer points to
93274 ** sqlite3BtreeNext().
93275 **
93276 ** If P5 is positive and the jump is taken, then event counter
93277 ** number P5-1 in the prepared statement is incremented.
93278 **
93279 ** See also: Prev
93280 */
93281 /* Opcode: Prev P1 P2 P3 P4 P5
93282 **
93283 ** Back up cursor P1 so that it points to the previous key/data pair in its
93284 ** table or index. If there is no previous key/value pairs then fall through
93285 ** to the following instruction. But if the cursor backup was successful,
93286 ** jump immediately to P2.
@@ -93296,13 +93377,10 @@
93296 ** The P3 value is a hint to the btree implementation. If P3==1, that
93297 ** means P1 is an SQL index and that this instruction could have been
93298 ** omitted if that index had been unique. P3 is usually 0. P3 is
93299 ** always either 0 or 1.
93300 **
93301 ** P4 is always of type P4_ADVANCE. The function pointer points to
93302 ** sqlite3BtreePrevious().
93303 **
93304 ** If P5 is positive and the jump is taken, then event counter
93305 ** number P5-1 in the prepared statement is incremented.
93306 */
93307 /* Opcode: SorterNext P1 P2 * * P5
93308 **
@@ -93316,34 +93394,37 @@
93316
93317 pC = p->apCsr[pOp->p1];
93318 assert( isSorter(pC) );
93319 rc = sqlite3VdbeSorterNext(db, pC);
93320 goto next_tail;
 
93321 case OP_Prev: /* jump */
 
 
 
 
 
 
 
 
 
 
 
 
93322 case OP_Next: /* jump */
93323 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
93324 assert( pOp->p5<ArraySize(p->aCounter) );
93325 pC = p->apCsr[pOp->p1];
93326 assert( pC!=0 );
93327 assert( pC->deferredMoveto==0 );
93328 assert( pC->eCurType==CURTYPE_BTREE );
93329 assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
93330 assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );
93331
93332 /* The Next opcode is only used after SeekGT, SeekGE, Rewind, and Found.
93333 ** The Prev opcode is only used after SeekLT, SeekLE, and Last. */
93334 assert( pOp->opcode!=OP_Next
93335 || pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
93336 || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
93337 || pC->seekOp==OP_NullRow|| pC->seekOp==OP_SeekRowid
93338 || pC->seekOp==OP_IfNoHope);
93339 assert( pOp->opcode!=OP_Prev
93340 || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
93341 || pC->seekOp==OP_Last || pC->seekOp==OP_IfNoHope
93342 || pC->seekOp==OP_NullRow);
93343
93344 rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);
93345 next_tail:
93346 pC->cacheStatus = CACHE_STALE;
93347 VdbeBranchTaken(rc==SQLITE_OK,2);
93348 if( rc==SQLITE_OK ){
93349 pC->nullRow = 0;
@@ -93557,10 +93638,11 @@
93557 assert( pTabCur->uc.pCursor!=0 );
93558 assert( pTabCur->isTable );
93559 pTabCur->nullRow = 0;
93560 pTabCur->movetoTarget = rowid;
93561 pTabCur->deferredMoveto = 1;
 
93562 assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );
93563 assert( !pTabCur->isEphemeral );
93564 pTabCur->ub.aAltMap = pOp->p4.ai;
93565 assert( !pC->isEphemeral );
93566 pTabCur->pAltCursor = pC;
@@ -112069,11 +112151,11 @@
112069 if( pStat1==0 ) return;
112070 pStat1->zName = (char*)&pStat1[1];
112071 memcpy(pStat1->zName, "sqlite_stat1", 13);
112072 pStat1->nCol = 3;
112073 pStat1->iPKey = -1;
112074 sqlite3VdbeAddOp4(pParse->pVdbe, OP_Noop, 0, 0, 0,(char*)pStat1,P4_DYNBLOB);
112075 }
112076 #endif
112077
112078 /* Establish a read-lock on the table at the shared-cache level.
112079 ** Open a read-only cursor on the table. Also allocate a cursor number
@@ -125675,11 +125757,15 @@
125675 ** Then special optimizations can be applied that make the transfer
125676 ** very fast and which reduce fragmentation of indices.
125677 **
125678 ** This is the 2nd template.
125679 */
125680 if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
 
 
 
 
125681 assert( !pTrigger );
125682 assert( pList==0 );
125683 goto insert_end;
125684 }
125685 #endif /* SQLITE_OMIT_XFER_OPT */
@@ -127646,22 +127732,17 @@
127646 Vdbe *v; /* The VDBE we are building */
127647 int regAutoinc; /* Memory register used by AUTOINC */
127648 int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
127649 int regData, regRowid; /* Registers holding data and rowid */
127650
127651 if( pSelect==0 ){
127652 return 0; /* Must be of the form INSERT INTO ... SELECT ... */
127653 }
127654 if( pParse->pWith || pSelect->pWith ){
127655 /* Do not attempt to process this query if there are an WITH clauses
127656 ** attached to it. Proceeding may generate a false "no such table: xxx"
127657 ** error if pSelect reads from a CTE named "xxx". */
127658 return 0;
127659 }
127660 if( sqlite3TriggerList(pParse, pDest) ){
127661 return 0; /* tab1 must not have triggers */
127662 }
127663 #ifndef SQLITE_OMIT_VIRTUALTABLE
127664 if( IsVirtual(pDest) ){
127665 return 0; /* tab1 must not be a virtual table */
127666 }
127667 #endif
@@ -130011,11 +130092,11 @@
130011 /* iArg: */ BTREE_DATA_VERSION },
130012 #endif
130013 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
130014 {/* zName: */ "database_list",
130015 /* ePragTyp: */ PragTyp_DATABASE_LIST,
130016 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
130017 /* ColNames: */ 47, 3,
130018 /* iArg: */ 0 },
130019 #endif
130020 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
130021 {/* zName: */ "default_cache_size",
@@ -130699,19 +130780,20 @@
130699 Vdbe *v, /* The prepared statement being created */
130700 FuncDef *p, /* A particular function definition */
130701 int isBuiltin, /* True if this is a built-in function */
130702 int showInternFuncs /* True if showing internal functions */
130703 ){
 
 
 
 
 
 
 
 
130704 for(; p; p=p->pNext){
130705 const char *zType;
130706 static const u32 mask =
130707 SQLITE_DETERMINISTIC |
130708 SQLITE_DIRECTONLY |
130709 SQLITE_SUBTYPE |
130710 SQLITE_INNOCUOUS |
130711 SQLITE_FUNC_INTERNAL
130712 ;
130713 static const char *azEnc[] = { 0, "utf8", "utf16le", "utf16be" };
130714
130715 assert( SQLITE_FUNC_ENCMASK==0x3 );
130716 assert( strcmp(azEnc[SQLITE_UTF8],"utf8")==0 );
130717 assert( strcmp(azEnc[SQLITE_UTF16LE],"utf16le")==0 );
@@ -148508,18 +148590,26 @@
148508 ** rowid stored in register iRowid.
148509 **
148510 ** Normally, this is just:
148511 **
148512 ** OP_DeferredSeek $iCur $iRowid
 
 
148513 **
148514 ** However, if the scan currently being coded is a branch of an OR-loop and
148515 ** the statement currently being coded is a SELECT, then P3 of OP_DeferredSeek
148516 ** is set to iIdxCur and P4 is set to point to an array of integers
148517 ** containing one entry for each column of the table cursor iCur is open
148518 ** on. For each table column, if the column is the i'th column of the
148519 ** index, then the corresponding array entry is set to (i+1). If the column
148520 ** does not appear in the index at all, the array entry is set to 0.
 
 
 
 
 
 
148521 */
148522 static void codeDeferredSeek(
148523 WhereInfo *pWInfo, /* Where clause context */
148524 Index *pIdx, /* Index scan is using */
148525 int iCur, /* Cursor for IPK b-tree */
@@ -234298,11 +234388,11 @@
234298 int nArg, /* Number of args */
234299 sqlite3_value **apUnused /* Function arguments */
234300 ){
234301 assert( nArg==0 );
234302 UNUSED_PARAM2(nArg, apUnused);
234303 sqlite3_result_text(pCtx, "fts5: 2022-02-22 18:58:40 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968a1bab", -1, SQLITE_TRANSIENT);
234304 }
234305
234306 /*
234307 ** Return true if zName is the extension on one of the shadow tables used
234308 ** by this module.
234309
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.39.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -450,13 +450,13 @@
450 **
451 ** See also: [sqlite3_libversion()],
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.39.0"
456 #define SQLITE_VERSION_NUMBER 3039000
457 #define SQLITE_SOURCE_ID "2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -10071,11 +10071,11 @@
10071 ** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
10072 ** and remains valid for the duration of the xBestIndex method call.
10073 ** ^When xBestIndex returns, the sqlite3_value object returned by
10074 ** sqlite3_vtab_rhs_value() is automatically deallocated.
10075 **
10076 ** The "_rhs_" in the name of this routine is an abbreviation for
10077 ** "Right-Hand Side".
10078 */
10079 SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
10080
10081 /*
@@ -14709,18 +14709,19 @@
14709 ** Handle type for pages.
14710 */
14711 typedef struct PgHdr DbPage;
14712
14713 /*
14714 ** Page number PAGER_SJ_PGNO is never used in an SQLite database (it is
14715 ** reserved for working around a windows/posix incompatibility). It is
14716 ** used in the journal to signify that the remainder of the journal file
14717 ** is devoted to storing a super-journal name - there are no more pages to
14718 ** roll back. See comments for function writeSuperJournal() in pager.c
14719 ** for details.
14720 */
14721 #define PAGER_SJ_PGNO_COMPUTED(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))
14722 #define PAGER_SJ_PGNO(x) ((x)->lckPgno)
14723
14724 /*
14725 ** Allowed values for the flags parameter to sqlite3PagerOpen().
14726 **
14727 ** NOTE: These values must match the corresponding BTREE_ values in btree.h.
@@ -15393,11 +15394,10 @@
15394 SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
15395 Table *pTab; /* Used when p4type is P4_TABLE */
15396 #ifdef SQLITE_ENABLE_CURSOR_HINTS
15397 Expr *pExpr; /* Used when p4type is P4_EXPR */
15398 #endif
 
15399 } p4;
15400 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
15401 char *zComment; /* Comment to improve readability */
15402 #endif
15403 #ifdef VDBE_PROFILE
@@ -15444,25 +15444,23 @@
15444 #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */
15445 #define P4_STATIC (-1) /* Pointer to a static string */
15446 #define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */
15447 #define P4_INT32 (-3) /* P4 is a 32-bit signed integer */
15448 #define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */
15449 #define P4_TABLE (-5) /* P4 is a pointer to a Table structure */
 
15450 /* Above do not own any resources. Must free those below */
15451 #define P4_FREE_IF_LE (-6)
15452 #define P4_DYNAMIC (-6) /* Pointer to memory from sqliteMalloc() */
15453 #define P4_FUNCDEF (-7) /* P4 is a pointer to a FuncDef structure */
15454 #define P4_KEYINFO (-8) /* P4 is a pointer to a KeyInfo structure */
15455 #define P4_EXPR (-9) /* P4 is a pointer to an Expr tree */
15456 #define P4_MEM (-10) /* P4 is a pointer to a Mem* structure */
15457 #define P4_VTAB (-11) /* P4 is a pointer to an sqlite3_vtab structure */
15458 #define P4_REAL (-12) /* P4 is a 64-bit floating point value */
15459 #define P4_INT64 (-13) /* P4 is a 64-bit signed integer */
15460 #define P4_INTARRAY (-14) /* P4 is a vector of 32-bit integers */
15461 #define P4_FUNCCTX (-15) /* P4 is a pointer to an sqlite3_context object */
 
15462
15463 /* Error message codes for OP_Halt */
15464 #define P5_ConstraintNotNull 1
15465 #define P5_ConstraintUnique 2
15466 #define P5_ConstraintCheck 3
@@ -15503,46 +15501,46 @@
15501 /* Automatically generated. Do not edit */
15502 /* See the tool/mkopcodeh.tcl script for details */
15503 #define OP_Savepoint 0
15504 #define OP_AutoCommit 1
15505 #define OP_Transaction 2
15506 #define OP_Checkpoint 3
15507 #define OP_JournalMode 4
15508 #define OP_Vacuum 5
15509 #define OP_VFilter 6 /* jump, synopsis: iplan=r[P3] zplan='P4' */
15510 #define OP_VUpdate 7 /* synopsis: data=r[P3@P2] */
15511 #define OP_Goto 8 /* jump */
15512 #define OP_Gosub 9 /* jump */
15513 #define OP_InitCoroutine 10 /* jump */
15514 #define OP_Yield 11 /* jump */
15515 #define OP_MustBeInt 12 /* jump */
15516 #define OP_Jump 13 /* jump */
15517 #define OP_Once 14 /* jump */
15518 #define OP_If 15 /* jump */
15519 #define OP_IfNot 16 /* jump */
15520 #define OP_IsNullOrType 17 /* jump, synopsis: if typeof(r[P1]) IN (P3,5) goto P2 */
15521 #define OP_IfNullRow 18 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
15522 #define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */
15523 #define OP_SeekLT 20 /* jump, synopsis: key=r[P3@P4] */
15524 #define OP_SeekLE 21 /* jump, synopsis: key=r[P3@P4] */
15525 #define OP_SeekGE 22 /* jump, synopsis: key=r[P3@P4] */
15526 #define OP_SeekGT 23 /* jump, synopsis: key=r[P3@P4] */
15527 #define OP_IfNotOpen 24 /* jump, synopsis: if( !csr[P1] ) goto P2 */
15528 #define OP_IfNoHope 25 /* jump, synopsis: key=r[P3@P4] */
15529 #define OP_NoConflict 26 /* jump, synopsis: key=r[P3@P4] */
15530 #define OP_NotFound 27 /* jump, synopsis: key=r[P3@P4] */
15531 #define OP_Found 28 /* jump, synopsis: key=r[P3@P4] */
15532 #define OP_SeekRowid 29 /* jump, synopsis: intkey=r[P3] */
15533 #define OP_NotExists 30 /* jump, synopsis: intkey=r[P3] */
15534 #define OP_Last 31 /* jump */
15535 #define OP_IfSmaller 32 /* jump */
15536 #define OP_SorterSort 33 /* jump */
15537 #define OP_Sort 34 /* jump */
15538 #define OP_Rewind 35 /* jump */
15539 #define OP_SorterNext 36 /* jump */
15540 #define OP_Prev 37 /* jump */
15541 #define OP_Next 38 /* jump */
15542 #define OP_IdxLE 39 /* jump, synopsis: key=r[P3@P4] */
15543 #define OP_IdxGT 40 /* jump, synopsis: key=r[P3@P4] */
15544 #define OP_IdxLT 41 /* jump, synopsis: key=r[P3@P4] */
15545 #define OP_IdxGE 42 /* jump, synopsis: key=r[P3@P4] */
15546 #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
@@ -15697,15 +15695,15 @@
15695 #define OPFLG_IN2 0x04 /* in2: P2 is an input */
15696 #define OPFLG_IN3 0x08 /* in3: P3 is an input */
15697 #define OPFLG_OUT2 0x10 /* out2: P2 is an output */
15698 #define OPFLG_OUT3 0x20 /* out3: P3 is an output */
15699 #define OPFLG_INITIALIZER {\
15700 /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00,\
15701 /* 8 */ 0x01, 0x01, 0x01, 0x03, 0x03, 0x01, 0x01, 0x03,\
15702 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x09, 0x09, 0x09, 0x09,\
15703 /* 24 */ 0x01, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x01,\
15704 /* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
15705 /* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\
15706 /* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
15707 /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\
15708 /* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
15709 /* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,\
@@ -17778,10 +17776,15 @@
17776 ** b-tree.
17777 */
17778 struct UnpackedRecord {
17779 KeyInfo *pKeyInfo; /* Collation and sort-order information */
17780 Mem *aMem; /* Values */
17781 union {
17782 char *z; /* Cache of aMem[0].z for vdbeRecordCompareString() */
17783 i64 i; /* Cache of aMem[0].u.i for vdbeRecordCompareInt() */
17784 } u;
17785 int n; /* Cache of aMem[0].n used by vdbeRecordCompareString() */
17786 u16 nField; /* Number of entries in apMem[] */
17787 i8 default_rc; /* Comparison result if keys are equal */
17788 u8 errCode; /* Error detected by xRecordCompare (CORRUPT or NOMEM) */
17789 i8 r1; /* Value to return if (lhs < rhs) */
17790 i8 r2; /* Value to return if (lhs > rhs) */
@@ -22225,20 +22228,20 @@
22228 i64 i; /* Integer value used when MEM_Int is set in flags */
22229 int nZero; /* Extra zero bytes when MEM_Zero and MEM_Blob set */
22230 const char *zPType; /* Pointer type when MEM_Term|MEM_Subtype|MEM_Null */
22231 FuncDef *pDef; /* Used only when flags==MEM_Agg */
22232 } u;
22233 char *z; /* String or BLOB value */
22234 int n; /* Number of characters in string value, excluding '\0' */
22235 u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
22236 u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
22237 u8 eSubtype; /* Subtype for this value */
 
 
22238 /* ShallowCopy only needs to copy the information above */
22239 sqlite3 *db; /* The associated database connection */
22240 int szMalloc; /* Size of the zMalloc allocation */
22241 u32 uTemp; /* Transient storage for serial_type in OP_MakeRecord */
22242 char *zMalloc; /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */
22243 void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
22244 #ifdef SQLITE_DEBUG
22245 Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
22246 u16 mScopyFlags; /* flags value immediately after the shallow copy */
22247 #endif
@@ -22246,15 +22249,47 @@
22249
22250 /*
22251 ** Size of struct Mem not including the Mem.zMalloc member or anything that
22252 ** follows.
22253 */
22254 #define MEMCELLSIZE offsetof(Mem,db)
22255
22256 /* One or more of the following flags are set to indicate the
22257 ** representations of the value stored in the Mem struct.
22258 **
22259 ** * MEM_Null An SQL NULL value
22260 **
22261 ** * MEM_Null|MEM_Zero An SQL NULL with the virtual table
22262 ** UPDATE no-change flag set
22263 **
22264 ** * MEM_Null|MEM_Term| An SQL NULL, but also contains a
22265 ** MEM_Subtype pointer accessible using
22266 ** sqlite3_value_pointer().
22267 **
22268 ** * MEM_Null|MEM_Cleared Special SQL NULL that compares non-equal
22269 ** to other NULLs even using the IS operator.
22270 **
22271 ** * MEM_Str A string, stored in Mem.z with
22272 ** length Mem.n. Zero-terminated if
22273 ** MEM_Term is set. This flag is
22274 ** incompatible with MEM_Blob and
22275 ** MEM_Null, but can appear with MEM_Int,
22276 ** MEM_Real, and MEM_IntReal.
22277 **
22278 ** * MEM_Blob A blob, stored in Mem.z length Mem.n.
22279 ** Incompatible with MEM_Str, MEM_Null,
22280 ** MEM_Int, MEM_Real, and MEM_IntReal.
22281 **
22282 ** * MEM_Blob|MEM_Zero A blob in Mem.z of length Mem.n plus
22283 ** MEM.u.i extra 0x00 bytes at the end.
22284 **
22285 ** * MEM_Int Integer stored in Mem.u.i.
22286 **
22287 ** * MEM_Real Real stored in Mem.u.r.
22288 **
22289 ** * MEM_IntReal Real stored as an integer in Mem.u.i.
22290 **
22291 ** If the MEM_Null flag is set, then the value is an SQL NULL value.
22292 ** For a pointer type created using sqlite3_bind_pointer() or
22293 ** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set.
22294 **
22295 ** If the MEM_Str flag is set then Mem.z points at a string representation.
@@ -22261,39 +22296,36 @@
22296 ** Usually this is encoded in the same unicode encoding as the main
22297 ** database (see below for exceptions). If the MEM_Term flag is also
22298 ** set, then the string is nul terminated. The MEM_Int and MEM_Real
22299 ** flags may coexist with the MEM_Str flag.
22300 */
22301 #define MEM_Undefined 0x0000 /* Value is undefined */
22302 #define MEM_Null 0x0001 /* Value is NULL (or a pointer) */
22303 #define MEM_Str 0x0002 /* Value is a string */
22304 #define MEM_Int 0x0004 /* Value is an integer */
22305 #define MEM_Real 0x0008 /* Value is a real number */
22306 #define MEM_Blob 0x0010 /* Value is a BLOB */
22307 #define MEM_IntReal 0x0020 /* MEM_Int that stringifies like MEM_Real */
22308 #define MEM_AffMask 0x003f /* Mask of affinity bits */
22309
22310 /* Extra bits that modify the meanings of the core datatypes above
22311 */
22312 #define MEM_FromBind 0x0040 /* Value originates from sqlite3_bind() */
22313 /* 0x0080 // Available */
22314 #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
 
 
 
 
 
 
 
 
22315 #define MEM_Term 0x0200 /* String in Mem.z is zero terminated */
22316 #define MEM_Zero 0x0400 /* Mem.i contains count of 0s appended to blob */
22317 #define MEM_Subtype 0x0800 /* Mem.eSubtype is valid */
22318 #define MEM_TypeMask 0x0dbf /* Mask of type bits */
22319
22320 /* Bits that determine the storage for Mem.z for a string or blob or
22321 ** aggregate accumulator.
22322 */
22323 #define MEM_Dyn 0x1000 /* Need to call Mem.xDel() on Mem.z */
22324 #define MEM_Static 0x2000 /* Mem.z points to a static string */
22325 #define MEM_Ephem 0x4000 /* Mem.z points to an ephemeral string */
22326 #define MEM_Agg 0x8000 /* Mem.z points to an agg function context */
22327
22328 /* Return TRUE if Mem X contains dynamically allocated content - anything
22329 ** that needs to be deallocated to avoid a leak.
22330 */
22331 #define VdbeMemDynamic(X) \
@@ -22311,15 +22343,19 @@
22343 #define MemNullNochng(X) \
22344 (((X)->flags&MEM_TypeMask)==(MEM_Null|MEM_Zero) \
22345 && (X)->n==0 && (X)->u.nZero==0)
22346
22347 /*
22348 ** Return true if a memory cell has been initialized and is valid.
22349 ** is for use inside assert() statements only.
22350 **
22351 ** A Memory cell is initialized if at least one of the
22352 ** MEM_Null, MEM_Str, MEM_Int, MEM_Real, MEM_Blob, or MEM_IntReal bits
22353 ** is set. It is "undefined" if all those bits are zero.
22354 */
22355 #ifdef SQLITE_DEBUG
22356 #define memIsValid(M) ((M)->flags & MEM_AffMask)!=0
22357 #endif
22358
22359 /*
22360 ** Each auxiliary data pointer stored by a user defined function
22361 ** implementation calling sqlite3_set_auxdata() is stored in an instance
@@ -22523,12 +22559,12 @@
22559 ** Function prototypes
22560 */
22561 SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...);
22562 SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);
22563 void sqliteVdbePopStack(Vdbe*,int);
22564 SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeHandleMovedCursor(VdbeCursor *p);
22565 SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeFinishMoveto(VdbeCursor*);
 
22566 SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
22567 SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
22568 SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
22569 SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
22570 SQLITE_PRIVATE void sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
@@ -34579,46 +34615,46 @@
34615 SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
34616 static const char *const azName[] = {
34617 /* 0 */ "Savepoint" OpHelp(""),
34618 /* 1 */ "AutoCommit" OpHelp(""),
34619 /* 2 */ "Transaction" OpHelp(""),
34620 /* 3 */ "Checkpoint" OpHelp(""),
34621 /* 4 */ "JournalMode" OpHelp(""),
34622 /* 5 */ "Vacuum" OpHelp(""),
34623 /* 6 */ "VFilter" OpHelp("iplan=r[P3] zplan='P4'"),
34624 /* 7 */ "VUpdate" OpHelp("data=r[P3@P2]"),
34625 /* 8 */ "Goto" OpHelp(""),
34626 /* 9 */ "Gosub" OpHelp(""),
34627 /* 10 */ "InitCoroutine" OpHelp(""),
34628 /* 11 */ "Yield" OpHelp(""),
34629 /* 12 */ "MustBeInt" OpHelp(""),
34630 /* 13 */ "Jump" OpHelp(""),
34631 /* 14 */ "Once" OpHelp(""),
34632 /* 15 */ "If" OpHelp(""),
34633 /* 16 */ "IfNot" OpHelp(""),
34634 /* 17 */ "IsNullOrType" OpHelp("if typeof(r[P1]) IN (P3,5) goto P2"),
34635 /* 18 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"),
34636 /* 19 */ "Not" OpHelp("r[P2]= !r[P1]"),
34637 /* 20 */ "SeekLT" OpHelp("key=r[P3@P4]"),
34638 /* 21 */ "SeekLE" OpHelp("key=r[P3@P4]"),
34639 /* 22 */ "SeekGE" OpHelp("key=r[P3@P4]"),
34640 /* 23 */ "SeekGT" OpHelp("key=r[P3@P4]"),
34641 /* 24 */ "IfNotOpen" OpHelp("if( !csr[P1] ) goto P2"),
34642 /* 25 */ "IfNoHope" OpHelp("key=r[P3@P4]"),
34643 /* 26 */ "NoConflict" OpHelp("key=r[P3@P4]"),
34644 /* 27 */ "NotFound" OpHelp("key=r[P3@P4]"),
34645 /* 28 */ "Found" OpHelp("key=r[P3@P4]"),
34646 /* 29 */ "SeekRowid" OpHelp("intkey=r[P3]"),
34647 /* 30 */ "NotExists" OpHelp("intkey=r[P3]"),
34648 /* 31 */ "Last" OpHelp(""),
34649 /* 32 */ "IfSmaller" OpHelp(""),
34650 /* 33 */ "SorterSort" OpHelp(""),
34651 /* 34 */ "Sort" OpHelp(""),
34652 /* 35 */ "Rewind" OpHelp(""),
34653 /* 36 */ "SorterNext" OpHelp(""),
34654 /* 37 */ "Prev" OpHelp(""),
34655 /* 38 */ "Next" OpHelp(""),
34656 /* 39 */ "IdxLE" OpHelp("key=r[P3@P4]"),
34657 /* 40 */ "IdxGT" OpHelp("key=r[P3@P4]"),
34658 /* 41 */ "IdxLT" OpHelp("key=r[P3@P4]"),
34659 /* 42 */ "IdxGE" OpHelp("key=r[P3@P4]"),
34660 /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
@@ -50905,11 +50941,12 @@
50941 /*
50942 ** Make sure the page is marked as dirty. If it isn't dirty already,
50943 ** make it so.
50944 */
50945 SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){
50946 assert( p->nRef>0 || p->pCache->bPurgeable==0 );
50947 testcase( p->nRef==0 );
50948 assert( sqlite3PcachePageSanity(p) );
50949 if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ /*OPTIMIZATION-IF-FALSE*/
50950 p->flags &= ~PGHDR_DONT_WRITE;
50951 if( p->flags & PGHDR_CLEAN ){
50952 p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN);
@@ -53874,10 +53911,11 @@
53911 u16 nExtra; /* Add this many bytes to each in-memory page */
53912 i16 nReserve; /* Number of unused bytes at end of each page */
53913 u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */
53914 u32 sectorSize; /* Assumed sector size during rollback */
53915 Pgno mxPgno; /* Maximum allowed size of the database */
53916 Pgno lckPgno; /* Page number for the locking page */
53917 i64 pageSize; /* Number of bytes in a page */
53918 i64 journalSizeLimit; /* Size limit for persistent journal files */
53919 char *zFilename; /* Name of the database file */
53920 char *zJournal; /* Name of the journal file */
53921 int (*xBusyHandler)(void*); /* Function to call when busy */
@@ -54860,11 +54898,11 @@
54898 ** pPager at the current location. The super-journal name must be the last
54899 ** thing written to a journal file. If the pager is in full-sync mode, the
54900 ** journal file descriptor is advanced to the next sector boundary before
54901 ** anything is written. The format is:
54902 **
54903 ** + 4 bytes: PAGER_SJ_PGNO.
54904 ** + N bytes: super-journal filename in utf-8.
54905 ** + 4 bytes: N (length of super-journal name in bytes, no nul-terminator).
54906 ** + 4 bytes: super-journal name checksum.
54907 ** + 8 bytes: aJournalMagic[].
54908 **
@@ -54908,11 +54946,11 @@
54946 iHdrOff = pPager->journalOff;
54947
54948 /* Write the super-journal data to the end of the journal file. If
54949 ** an error occurs, return the error code to the caller.
54950 */
54951 if( (0 != (rc = write32bits(pPager->jfd, iHdrOff, PAGER_SJ_PGNO(pPager))))
54952 || (0 != (rc = sqlite3OsWrite(pPager->jfd, zSuper, nSuper, iHdrOff+4)))
54953 || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nSuper, nSuper)))
54954 || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nSuper+4, cksum)))
54955 || (0 != (rc = sqlite3OsWrite(pPager->jfd, aJournalMagic, 8,
54956 iHdrOff+4+nSuper+8)))
@@ -55418,11 +55456,11 @@
55456 ** to the database file, then the IO error code is returned. If data
55457 ** is successfully read from the (sub-)journal file but appears to be
55458 ** corrupted, SQLITE_DONE is returned. Data is considered corrupted in
55459 ** two circumstances:
55460 **
55461 ** * If the record page-number is illegal (0 or PAGER_SJ_PGNO), or
55462 ** * If the record is being rolled back from the main journal file
55463 ** and the checksum field does not match the record content.
55464 **
55465 ** Neither of these two scenarios are possible during a savepoint rollback.
55466 **
@@ -55478,11 +55516,11 @@
55516 /* Sanity checking on the page. This is more important that I originally
55517 ** thought. If a power failure occurs while the journal is being written,
55518 ** it could cause invalid data to be written into the journal. We need to
55519 ** detect this invalid data (with high probability) and ignore it.
55520 */
55521 if( pgno==0 || pgno==PAGER_SJ_PGNO(pPager) ){
55522 assert( !isSavepnt );
55523 return SQLITE_DONE;
55524 }
55525 if( pgno>(Pgno)pPager->dbSize || sqlite3BitvecTest(pDone, pgno) ){
55526 return SQLITE_OK;
@@ -56037,10 +56075,13 @@
56075 rc = pager_truncate(pPager, mxPg);
56076 if( rc!=SQLITE_OK ){
56077 goto end_playback;
56078 }
56079 pPager->dbSize = mxPg;
56080 if( pPager->mxPgno<mxPg ){
56081 pPager->mxPgno = mxPg;
56082 }
56083 }
56084
56085 /* Copy original pages out of the journal and back into the
56086 ** database file and/or page cache.
56087 */
@@ -56933,10 +56974,11 @@
56974 if( rc==SQLITE_OK ){
56975 sqlite3PageFree(pPager->pTmpSpace);
56976 pPager->pTmpSpace = pNew;
56977 pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);
56978 pPager->pageSize = pageSize;
56979 pPager->lckPgno = (Pgno)(PENDING_BYTE/pageSize) + 1;
56980 }else{
56981 sqlite3PageFree(pNew);
56982 }
56983 }
56984
@@ -58682,11 +58724,10 @@
58724 assert( pPager->errCode==SQLITE_OK );
58725 assert( pPager->eState>=PAGER_READER );
58726 assert( assert_pager_state(pPager) );
58727 assert( pPager->hasHeldSharedLock==1 );
58728
 
58729 pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
58730 if( pBase==0 ){
58731 pPg = 0;
58732 rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
58733 if( rc!=SQLITE_OK ) goto pager_acquire_err;
@@ -58702,22 +58743,22 @@
58743
58744 noContent = (flags & PAGER_GET_NOCONTENT)!=0;
58745 if( pPg->pPager && !noContent ){
58746 /* In this case the pcache already contains an initialized copy of
58747 ** the page. Return without further ado. */
58748 assert( pgno!=PAGER_SJ_PGNO(pPager) );
58749 pPager->aStat[PAGER_STAT_HIT]++;
58750 return SQLITE_OK;
58751
58752 }else{
58753 /* The pager cache has created a new page. Its content needs to
58754 ** be initialized. But first some error checks:
58755 **
58756 ** (1) Never try to fetch the locking page
58757 ** (2) Never try to fetch page 0, which does not exist
58758 */
58759 if( pgno==PAGER_SJ_PGNO(pPager) || pgno==0 ){
58760 rc = SQLITE_CORRUPT_BKPT;
58761 goto pager_acquire_err;
58762 }
58763
58764 pPg->pPager = pPager;
@@ -59112,11 +59153,11 @@
59153 i64 iOff = pPager->journalOff;
59154
59155 /* We should never write to the journal file the page that
59156 ** contains the database locks. The following assert verifies
59157 ** that we do not. */
59158 assert( pPg->pgno!=PAGER_SJ_PGNO(pPager) );
59159
59160 assert( pPager->journalHdr<=pPager->journalOff );
59161 pData2 = pPg->pData;
59162 cksum = pager_cksum(pPager, (u8*)pData2);
59163
@@ -59291,11 +59332,11 @@
59332
59333 for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){
59334 Pgno pg = pg1+ii;
59335 PgHdr *pPage;
59336 if( pg==pPg->pgno || !sqlite3BitvecTest(pPager->pInJournal, pg) ){
59337 if( pg!=PAGER_SJ_PGNO(pPager) ){
59338 rc = sqlite3PagerGet(pPager, pg, &pPage, 0);
59339 if( rc==SQLITE_OK ){
59340 rc = pager_write(pPage);
59341 if( pPage->flags&PGHDR_NEED_SYNC ){
59342 needSync = 1;
@@ -59769,11 +59810,11 @@
59810 ** image was extended as part of the current transaction and then the
59811 ** last page in the db image moved to the free-list. In this case the
59812 ** last page is never written out to disk, leaving the database file
59813 ** undersized. Fix this now if it is the case. */
59814 if( pPager->dbSize>pPager->dbFileSize ){
59815 Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_SJ_PGNO(pPager));
59816 assert( pPager->eState==PAGER_WRITER_DBMOD );
59817 rc = pager_truncate(pPager, nNew);
59818 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
59819 }
59820
@@ -65396,11 +65437,13 @@
65437 u16 aiOvfl[4]; /* Insert the i-th overflow cell before the aiOvfl-th
65438 ** non-overflow cell */
65439 u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
65440 BtShared *pBt; /* Pointer to BtShared that this page is part of */
65441 u8 *aData; /* Pointer to disk image of the page data */
65442 u8 *aDataEnd; /* One byte past the end of the entire page - not just
65443 ** the usable space, the entire page. Used to prevent
65444 ** corruption-induced of buffer overflow. */
65445 u8 *aCellIdx; /* The cell index area */
65446 u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
65447 DbPage *pDbPage; /* Pager page handle */
65448 u16 (*xCellSize)(MemPage*,u8*); /* cellSizePtr method */
65449 void (*xParseCell)(MemPage*,u8*,CellInfo*); /* btreeParseCell method */
@@ -65701,11 +65744,11 @@
65744 #define CURSOR_FAULT 4
65745
65746 /*
65747 ** The database page the PENDING_BYTE occupies. This page is never used.
65748 */
65749 #define PENDING_BYTE_PAGE(pBt) ((Pgno)((PENDING_BYTE/((pBt)->pageSize))+1))
65750
65751 /*
65752 ** These macros define the location of the pointer-map entry for a
65753 ** database page. The first argument to each is the number of usable
65754 ** bytes on each page of the database (often 1024). The second is the
@@ -67455,10 +67498,11 @@
67498 ** data area of the btree-page. The return number includes the cell
67499 ** data header and the local payload, but not any overflow page or
67500 ** the space used by the cell pointer.
67501 **
67502 ** cellSizePtrNoPayload() => table internal nodes
67503 ** cellSizePtrTableLeaf() => table leaf nodes
67504 ** cellSizePtr() => all index nodes & table leaf nodes
67505 */
67506 static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
67507 u8 *pIter = pCell + pPage->childPtrSize; /* For looping over bytes of pCell */
67508 u8 *pEnd; /* End mark for a varint */
@@ -67480,17 +67524,10 @@
67524 do{
67525 nSize = (nSize<<7) | (*++pIter & 0x7f);
67526 }while( *(pIter)>=0x80 && pIter<pEnd );
67527 }
67528 pIter++;
 
 
 
 
 
 
 
67529 testcase( nSize==pPage->maxLocal );
67530 testcase( nSize==(u32)pPage->maxLocal+1 );
67531 if( nSize<=pPage->maxLocal ){
67532 nSize += (u32)(pIter - pCell);
67533 if( nSize<4 ) nSize = 4;
@@ -67526,10 +67563,62 @@
67563 pEnd = pIter + 9;
67564 while( (*pIter++)&0x80 && pIter<pEnd );
67565 assert( debuginfo.nSize==(u16)(pIter - pCell) || CORRUPT_DB );
67566 return (u16)(pIter - pCell);
67567 }
67568 static u16 cellSizePtrTableLeaf(MemPage *pPage, u8 *pCell){
67569 u8 *pIter = pCell; /* For looping over bytes of pCell */
67570 u8 *pEnd; /* End mark for a varint */
67571 u32 nSize; /* Size value to return */
67572
67573 #ifdef SQLITE_DEBUG
67574 /* The value returned by this function should always be the same as
67575 ** the (CellInfo.nSize) value found by doing a full parse of the
67576 ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of
67577 ** this function verifies that this invariant is not violated. */
67578 CellInfo debuginfo;
67579 pPage->xParseCell(pPage, pCell, &debuginfo);
67580 #endif
67581
67582 nSize = *pIter;
67583 if( nSize>=0x80 ){
67584 pEnd = &pIter[8];
67585 nSize &= 0x7f;
67586 do{
67587 nSize = (nSize<<7) | (*++pIter & 0x7f);
67588 }while( *(pIter)>=0x80 && pIter<pEnd );
67589 }
67590 pIter++;
67591 /* pIter now points at the 64-bit integer key value, a variable length
67592 ** integer. The following block moves pIter to point at the first byte
67593 ** past the end of the key value. */
67594 if( (*pIter++)&0x80
67595 && (*pIter++)&0x80
67596 && (*pIter++)&0x80
67597 && (*pIter++)&0x80
67598 && (*pIter++)&0x80
67599 && (*pIter++)&0x80
67600 && (*pIter++)&0x80
67601 && (*pIter++)&0x80 ){ pIter++; }
67602 testcase( nSize==pPage->maxLocal );
67603 testcase( nSize==(u32)pPage->maxLocal+1 );
67604 if( nSize<=pPage->maxLocal ){
67605 nSize += (u32)(pIter - pCell);
67606 if( nSize<4 ) nSize = 4;
67607 }else{
67608 int minLocal = pPage->minLocal;
67609 nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);
67610 testcase( nSize==pPage->maxLocal );
67611 testcase( nSize==(u32)pPage->maxLocal+1 );
67612 if( nSize>pPage->maxLocal ){
67613 nSize = minLocal;
67614 }
67615 nSize += 4 + (u16)(pIter - pCell);
67616 }
67617 assert( nSize==debuginfo.nSize || CORRUPT_DB );
67618 return (u16)nSize;
67619 }
67620
67621
67622 #ifdef SQLITE_DEBUG
67623 /* This variation on cellSizePtr() is used inside of assert() statements
67624 ** only. */
@@ -67539,11 +67628,11 @@
67628 #endif
67629
67630 #ifndef SQLITE_OMIT_AUTOVACUUM
67631 /*
67632 ** The cell pCell is currently part of page pSrc but will ultimately be part
67633 ** of pPage. (pSrc and pPage are often the same.) If pCell contains a
67634 ** pointer to an overflow page, insert an entry into the pointer-map for
67635 ** the overflow page that will be valid after pCell has been moved to pPage.
67636 */
67637 static void ptrmapPutOvflPtr(MemPage *pPage, MemPage *pSrc, u8 *pCell,int *pRC){
67638 CellInfo info;
@@ -67714,21 +67803,23 @@
67803 */
67804 static u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc){
67805 const int hdr = pPg->hdrOffset; /* Offset to page header */
67806 u8 * const aData = pPg->aData; /* Page data */
67807 int iAddr = hdr + 1; /* Address of ptr to pc */
67808 u8 *pTmp = &aData[iAddr]; /* Temporary ptr into aData[] */
67809 int pc = get2byte(pTmp); /* Address of a free slot */
67810 int x; /* Excess size of the slot */
67811 int maxPC = pPg->pBt->usableSize - nByte; /* Max address for a usable slot */
67812 int size; /* Size of the free slot */
67813
67814 assert( pc>0 );
67815 while( pc<=maxPC ){
67816 /* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each
67817 ** freeblock form a big-endian integer which is the size of the freeblock
67818 ** in bytes, including the 4-byte header. */
67819 pTmp = &aData[pc+2];
67820 size = get2byte(pTmp);
67821 if( (x = size - nByte)>=0 ){
67822 testcase( x==4 );
67823 testcase( x==3 );
67824 if( x<4 ){
67825 /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total
@@ -67749,11 +67840,12 @@
67840 put2byte(&aData[pc+2], x);
67841 }
67842 return &aData[pc + x];
67843 }
67844 iAddr = pc;
67845 pTmp = &aData[pc];
67846 pc = get2byte(pTmp);
67847 if( pc<=iAddr+size ){
67848 if( pc ){
67849 /* The next slot in the chain is not past the end of the current slot */
67850 *pRc = SQLITE_CORRUPT_PAGE(pPg);
67851 }
@@ -67783,10 +67875,11 @@
67875 static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
67876 const int hdr = pPage->hdrOffset; /* Local cache of pPage->hdrOffset */
67877 u8 * const data = pPage->aData; /* Local cache of pPage->aData */
67878 int top; /* First byte of cell content area */
67879 int rc = SQLITE_OK; /* Integer return code */
67880 u8 *pTmp; /* Temp ptr into data[] */
67881 int gap; /* First byte of gap between cell pointers and cell content */
67882
67883 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
67884 assert( pPage->pBt );
67885 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
@@ -67801,11 +67894,12 @@
67894 /* EVIDENCE-OF: R-29356-02391 If the database uses a 65536-byte page size
67895 ** and the reserved space is zero (the usual value for reserved space)
67896 ** then the cell content offset of an empty page wants to be 65536.
67897 ** However, that integer is too large to be stored in a 2-byte unsigned
67898 ** integer, so a value of 0 is used in its place. */
67899 pTmp = &data[hdr+5];
67900 top = get2byte(pTmp);
67901 assert( top<=(int)pPage->pBt->usableSize ); /* by btreeComputeFreeSpace() */
67902 if( gap>top ){
67903 if( top==0 && pPage->pBt->usableSize==65536 ){
67904 top = 65536;
67905 }else{
@@ -67883,10 +67977,11 @@
67977 u8 nFrag = 0; /* Reduction in fragmentation */
67978 u16 iOrigSize = iSize; /* Original value of iSize */
67979 u16 x; /* Offset to cell content area */
67980 u32 iEnd = iStart + iSize; /* First byte past the iStart buffer */
67981 unsigned char *data = pPage->aData; /* Page content */
67982 u8 *pTmp; /* Temporary ptr into data[] */
67983
67984 assert( pPage->pBt!=0 );
67985 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
67986 assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
67987 assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );
@@ -67945,11 +68040,12 @@
68040 }
68041 }
68042 if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PAGE(pPage);
68043 data[hdr+7] -= nFrag;
68044 }
68045 pTmp = &data[hdr+5];
68046 x = get2byte(pTmp);
68047 if( iStart<=x ){
68048 /* The new freeblock is at the beginning of the cell content area,
68049 ** so just extend the cell content area rather than create another
68050 ** freelist entry */
68051 if( iStart<x ) return SQLITE_CORRUPT_PAGE(pPage);
@@ -68001,10 +68097,11 @@
68097 ** leaf table b-tree page. */
68098 assert( (PTF_LEAFDATA|PTF_INTKEY|PTF_LEAF)==13 );
68099 pPage->intKey = 1;
68100 if( pPage->leaf ){
68101 pPage->intKeyLeaf = 1;
68102 pPage->xCellSize = cellSizePtrTableLeaf;
68103 pPage->xParseCell = btreeParseCellPtr;
68104 }else{
68105 pPage->intKeyLeaf = 0;
68106 pPage->xCellSize = cellSizePtrNoPayload;
68107 pPage->xParseCell = btreeParseCellPtrNoPayload;
@@ -68181,11 +68278,11 @@
68278 assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
68279 pPage->maskPage = (u16)(pBt->pageSize - 1);
68280 pPage->nOverflow = 0;
68281 pPage->cellOffset = pPage->hdrOffset + 8 + pPage->childPtrSize;
68282 pPage->aCellIdx = data + pPage->childPtrSize + 8;
68283 pPage->aDataEnd = pPage->aData + pBt->pageSize;
68284 pPage->aDataOfst = pPage->aData + pPage->childPtrSize;
68285 /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
68286 ** number of cells on the page. */
68287 pPage->nCell = get2byte(&data[3]);
68288 if( pPage->nCell>MX_CELL(pBt) ){
@@ -68216,11 +68313,11 @@
68313 unsigned char *data = pPage->aData;
68314 BtShared *pBt = pPage->pBt;
68315 u8 hdr = pPage->hdrOffset;
68316 u16 first;
68317
68318 assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno || CORRUPT_DB );
68319 assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
68320 assert( sqlite3PagerGetData(pPage->pDbPage) == data );
68321 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
68322 assert( sqlite3_mutex_held(pBt->mutex) );
68323 if( pBt->btsFlags & BTS_FAST_SECURE ){
@@ -68232,11 +68329,11 @@
68329 data[hdr+7] = 0;
68330 put2byte(&data[hdr+5], pBt->usableSize);
68331 pPage->nFree = (u16)(pBt->usableSize - first);
68332 decodeFlags(pPage, flags);
68333 pPage->cellOffset = first;
68334 pPage->aDataEnd = &data[pBt->pageSize];
68335 pPage->aCellIdx = &data[first];
68336 pPage->aDataOfst = &data[pPage->childPtrSize];
68337 pPage->nOverflow = 0;
68338 assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
68339 pPage->maskPage = (u16)(pBt->pageSize - 1);
@@ -68358,11 +68455,11 @@
68455 rc = btreeInitPage(*ppPage);
68456 if( rc!=SQLITE_OK ){
68457 goto getAndInitPage_error2;
68458 }
68459 }
68460 assert( (*ppPage)->pgno==pgno || CORRUPT_DB );
68461 assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );
68462
68463 /* If obtaining a child page for a cursor, we must verify that the page is
68464 ** compatible with the root page. */
68465 if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){
@@ -68377,11 +68474,13 @@
68474 if( pCur ){
68475 pCur->iPage--;
68476 pCur->pPage = pCur->apPage[pCur->iPage];
68477 }
68478 testcase( pgno==0 );
68479 assert( pgno!=0 || rc==SQLITE_CORRUPT
68480 || rc==SQLITE_IOERR_NOMEM
68481 || rc==SQLITE_NOMEM );
68482 return rc;
68483 }
68484
68485 /*
68486 ** Release a MemPage. This should be called once for each prior
@@ -75113,11 +75212,11 @@
75212
75213 pPage = pCur->pPage;
75214 assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
75215 assert( pPage->leaf || !pPage->intKey );
75216 if( pPage->nFree<0 ){
75217 if( pCur->eState>CURSOR_INVALID ){
75218 rc = SQLITE_CORRUPT_BKPT;
75219 }else{
75220 rc = btreeComputeFreeSpace(pPage);
75221 }
75222 if( rc ) return rc;
@@ -75431,11 +75530,11 @@
75530 ** bPreserve==2 Cursor won't move. Set CURSOR_SKIPNEXT.
75531 */
75532 bPreserve = (flags & BTREE_SAVEPOSITION)!=0;
75533 if( bPreserve ){
75534 if( !pPage->leaf
75535 || (pPage->nFree+pPage->xCellSize(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
75536 || pPage->nCell==1 /* See dbfuzz001.test for a test case */
75537 ){
75538 /* A b-tree rebalance will be required after deleting this entry.
75539 ** Save the cursor key. */
75540 rc = saveCursorKey(pCur);
@@ -80545,11 +80644,11 @@
80644 ** and store that value in *pMaxFuncArgs.
80645 **
80646 ** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately
80647 ** indicate what the prepared statement actually does.
80648 **
80649 ** (4) (discontinued)
80650 **
80651 ** (5) Reclaim the memory allocated for storing labels.
80652 **
80653 ** This routine will only function correctly if the mkopcodeh.tcl generator
80654 ** script numbers the opcodes correctly. Changes to this routine must be
@@ -80591,29 +80690,10 @@
80690 case OP_JournalMode: {
80691 p->readOnly = 0;
80692 p->bIsReader = 1;
80693 break;
80694 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80695 #ifndef SQLITE_OMIT_VIRTUALTABLE
80696 case OP_VUpdate: {
80697 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
80698 break;
80699 }
@@ -80893,11 +80973,10 @@
80973 break;
80974 }
80975 case P4_REAL:
80976 case P4_INT64:
80977 case P4_DYNAMIC:
 
80978 case P4_INTARRAY: {
80979 sqlite3DbFree(db, p4);
80980 break;
80981 }
80982 case P4_KEYINFO: {
@@ -81490,14 +81569,10 @@
81569 }
81570 case P4_SUBPROGRAM: {
81571 zP4 = "program";
81572 break;
81573 }
 
 
 
 
81574 case P4_TABLE: {
81575 zP4 = pOp->p4.pTab->zName;
81576 break;
81577 }
81578 default: {
@@ -81625,20 +81700,34 @@
81700 }
81701 #endif
81702
81703 /*
81704 ** Initialize an array of N Mem element.
81705 **
81706 ** This is a high-runner, so only those fields that really do need to
81707 ** be initialized are set. The Mem structure is organized so that
81708 ** the fields that get initialized are nearby and hopefully on the same
81709 ** cache line.
81710 **
81711 ** Mem.flags = flags
81712 ** Mem.db = db
81713 ** Mem.szMalloc = 0
81714 **
81715 ** All other fields of Mem can safely remain uninitialized for now. They
81716 ** will be initialized before use.
81717 */
81718 static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){
81719 if( N>0 ){
81720 do{
81721 p->flags = flags;
81722 p->db = db;
81723 p->szMalloc = 0;
81724 #ifdef SQLITE_DEBUG
81725 p->pScopyFrom = 0;
81726 #endif
81727 p++;
81728 }while( (--N)>0 );
81729 }
81730 }
81731
81732 /*
81733 ** Release an array of N Mem elements
@@ -83292,11 +83381,11 @@
83381 ** pointed to was deleted out from under it. Or maybe the btree was
83382 ** rebalanced. Whatever the cause, try to restore "p" to the place it
83383 ** is supposed to be pointing. If the row was deleted out from under the
83384 ** cursor, set the cursor to point to a NULL row.
83385 */
83386 SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeHandleMovedCursor(VdbeCursor *p){
83387 int isDifferentRow, rc;
83388 assert( p->eCurType==CURTYPE_BTREE );
83389 assert( p->uc.pCursor!=0 );
83390 assert( sqlite3BtreeCursorHasMoved(p->uc.pCursor) );
83391 rc = sqlite3BtreeCursorRestore(p->uc.pCursor, &isDifferentRow);
@@ -83310,43 +83399,11 @@
83399 ** if need be. Return any I/O error from the restore operation.
83400 */
83401 SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor *p){
83402 assert( p->eCurType==CURTYPE_BTREE );
83403 if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){
83404 return sqlite3VdbeHandleMovedCursor(p);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83405 }
83406 return SQLITE_OK;
83407 }
83408
83409 /*
@@ -84529,11 +84586,12 @@
84586
84587 default:
84588 return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);
84589 }
84590
84591 assert( pPKey2->u.i == pPKey2->aMem[0].u.i );
84592 v = pPKey2->u.i;
84593 if( v>lhs ){
84594 res = pPKey2->r1;
84595 }else if( v<lhs ){
84596 res = pPKey2->r2;
84597 }else if( pPKey2->nField>1 ){
@@ -84564,16 +84622,22 @@
84622 const u8 *aKey1 = (const u8*)pKey1;
84623 int serial_type;
84624 int res;
84625
84626 assert( pPKey2->aMem[0].flags & MEM_Str );
84627 assert( pPKey2->aMem[0].n == pPKey2->n );
84628 assert( pPKey2->aMem[0].z == pPKey2->u.z );
84629 vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);
84630 serial_type = (signed char)(aKey1[1]);
84631
84632 vrcs_restart:
 
84633 if( serial_type<12 ){
84634 if( serial_type<0 ){
84635 sqlite3GetVarint32(&aKey1[1], (u32*)&serial_type);
84636 if( serial_type>=12 ) goto vrcs_restart;
84637 assert( CORRUPT_DB );
84638 }
84639 res = pPKey2->r1; /* (pKey1/nKey1) is a number or a null */
84640 }else if( !(serial_type & 0x01) ){
84641 res = pPKey2->r2; /* (pKey1/nKey1) is a blob */
84642 }else{
84643 int nCmp;
@@ -84583,19 +84647,19 @@
84647 nStr = (serial_type-12) / 2;
84648 if( (szHdr + nStr) > nKey1 ){
84649 pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
84650 return 0; /* Corruption */
84651 }
84652 nCmp = MIN( pPKey2->n, nStr );
84653 res = memcmp(&aKey1[szHdr], pPKey2->u.z, nCmp);
84654
84655 if( res>0 ){
84656 res = pPKey2->r2;
84657 }else if( res<0 ){
84658 res = pPKey2->r1;
84659 }else{
84660 res = nStr - pPKey2->n;
84661 if( res==0 ){
84662 if( pPKey2->nField>1 ){
84663 res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
84664 }else{
84665 res = pPKey2->default_rc;
@@ -84646,19 +84710,22 @@
84710 }else{
84711 p->r1 = -1;
84712 p->r2 = 1;
84713 }
84714 if( (flags & MEM_Int) ){
84715 p->u.i = p->aMem[0].u.i;
84716 return vdbeRecordCompareInt;
84717 }
84718 testcase( flags & MEM_Real );
84719 testcase( flags & MEM_Null );
84720 testcase( flags & MEM_Blob );
84721 if( (flags & (MEM_Real|MEM_IntReal|MEM_Null|MEM_Blob))==0
84722 && p->pKeyInfo->aColl[0]==0
84723 ){
84724 assert( flags & MEM_Str );
84725 p->u.z = p->aMem[0].z;
84726 p->n = p->aMem[0].n;
84727 return vdbeRecordCompareString;
84728 }
84729 }
84730
84731 return sqlite3VdbeRecordCompare;
@@ -86129,19 +86196,19 @@
86196 #if defined(SQLITE_DEBUG) && defined(__GNUC__)
86197 __attribute__((aligned(8)))
86198 #endif
86199 = {
86200 /* .u = */ {0},
86201 /* .z = */ (char*)0,
86202 /* .n = */ (int)0,
86203 /* .flags = */ (u16)MEM_Null,
86204 /* .enc = */ (u8)0,
86205 /* .eSubtype = */ (u8)0,
86206 /* .db = */ (sqlite3*)0,
 
 
86207 /* .szMalloc = */ (int)0,
86208 /* .uTemp = */ (u32)0,
86209 /* .zMalloc = */ (char*)0,
86210 /* .xDel = */ (void(*)(void*))0,
86211 #ifdef SQLITE_DEBUG
86212 /* .pScopyFrom = */ (Mem*)0,
86213 /* .mScopyFlags= */ 0,
86214 #endif
@@ -90020,11 +90087,11 @@
90087 ** skipped for length() and all content loading can be skipped for typeof().
90088 */
90089 case OP_Column: {
90090 u32 p2; /* column number to retrieve */
90091 VdbeCursor *pC; /* The VDBE cursor */
90092 BtCursor *pCrsr; /* The B-Tree cursor corresponding to pC */
90093 u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */
90094 int len; /* The length of the serialized data for the column */
90095 int i; /* Loop counter */
90096 Mem *pDest; /* Where to write the extracted value */
90097 Mem sMem; /* For storing the record being decoded */
@@ -90034,23 +90101,15 @@
90101 u64 offset64; /* 64-bit offset */
90102 u32 t; /* A type code from the record header */
90103 Mem *pReg; /* PseudoTable input register */
90104
90105 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
90106 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
90107 pC = p->apCsr[pOp->p1];
 
90108 p2 = (u32)pOp->p2;
90109
90110 op_column_restart:
 
 
 
 
 
 
 
 
90111 assert( pC!=0 );
90112 assert( p2<(u32)pC->nField );
90113 aOffset = pC->aOffset;
90114 assert( aOffset==pC->aType+pC->nField );
90115 assert( pC->eCurType!=CURTYPE_VTAB );
@@ -90067,30 +90126,43 @@
90126 assert( pReg->flags & MEM_Blob );
90127 assert( memIsValid(pReg) );
90128 pC->payloadSize = pC->szRow = pReg->n;
90129 pC->aRow = (u8*)pReg->z;
90130 }else{
90131 pDest = &aMem[pOp->p3];
90132 memAboutToChange(p, pDest);
90133 sqlite3VdbeMemSetNull(pDest);
90134 goto op_column_out;
90135 }
90136 }else{
90137 pCrsr = pC->uc.pCursor;
90138 if( pC->deferredMoveto ){
90139 u32 iMap;
90140 assert( !pC->isEphemeral );
90141 if( pC->ub.aAltMap && (iMap = pC->ub.aAltMap[1+p2])>0 ){
90142 pC = pC->pAltCursor;
90143 p2 = iMap - 1;
90144 goto op_column_restart;
90145 }
90146 rc = sqlite3VdbeFinishMoveto(pC);
90147 if( rc ) goto abort_due_to_error;
90148 }else if( sqlite3BtreeCursorHasMoved(pCrsr) ){
90149 rc = sqlite3VdbeHandleMovedCursor(pC);
90150 if( rc ) goto abort_due_to_error;
90151 goto op_column_restart;
90152 }
90153 assert( pC->eCurType==CURTYPE_BTREE );
90154 assert( pCrsr );
90155 assert( sqlite3BtreeCursorIsValid(pCrsr) );
90156 pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);
90157 pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &pC->szRow);
90158 assert( pC->szRow<=pC->payloadSize );
90159 assert( pC->szRow<=65536 ); /* Maximum page size is 64KiB */
 
 
 
90160 }
90161 pC->cacheStatus = p->cacheCtr;
90162 pC->iHdrOffset = getVarint32(pC->aRow, aOffset[0]);
90163 pC->nHdrParsed = 0;
 
90164
90165 if( pC->szRow<aOffset[0] ){ /*OPTIMIZATION-IF-FALSE*/
90166 /* pC->aRow does not have to hold the entire row, but it does at least
90167 ** need to cover the header of the record. If pC->aRow does not contain
90168 ** the complete header, then set it to zero, forcing the header to be
@@ -90127,10 +90199,14 @@
90199 zData = pC->aRow;
90200 assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */
90201 testcase( aOffset[0]==0 );
90202 goto op_column_read_header;
90203 }
90204 }else if( sqlite3BtreeCursorHasMoved(pC->uc.pCursor) ){
90205 rc = sqlite3VdbeHandleMovedCursor(pC);
90206 if( rc ) goto abort_due_to_error;
90207 goto op_column_restart;
90208 }
90209
90210 /* Make sure at least the first p2+1 entries of the header have been
90211 ** parsed and valid information is in aOffset[] and pC->aType[].
90212 */
@@ -90195,10 +90271,12 @@
90271 /* If after trying to extract new entries from the header, nHdrParsed is
90272 ** still not up to p2, that means that the record has fewer than p2
90273 ** columns. So the result will be either the default value or a NULL.
90274 */
90275 if( pC->nHdrParsed<=p2 ){
90276 pDest = &aMem[pOp->p3];
90277 memAboutToChange(p, pDest);
90278 if( pOp->p4type==P4_MEM ){
90279 sqlite3VdbeMemShallowCopy(pDest, pOp->p4.pMem, MEM_Static);
90280 }else{
90281 sqlite3VdbeMemSetNull(pDest);
90282 }
@@ -90212,10 +90290,12 @@
90290 ** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are
90291 ** all valid.
90292 */
90293 assert( p2<pC->nHdrParsed );
90294 assert( rc==SQLITE_OK );
90295 pDest = &aMem[pOp->p3];
90296 memAboutToChange(p, pDest);
90297 assert( sqlite3VdbeCheckMemInvariants(pDest) );
90298 if( VdbeMemDynamic(pDest) ){
90299 sqlite3VdbeMemSetNull(pDest);
90300 }
90301 assert( t==pC->aType[p2] );
@@ -90232,10 +90312,11 @@
90312 */
90313 static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };
90314 pDest->n = len = (t-12)/2;
90315 pDest->enc = encoding;
90316 if( pDest->szMalloc < len+2 ){
90317 if( len>db->aLimit[SQLITE_LIMIT_LENGTH] ) goto too_big;
90318 pDest->flags = MEM_Null;
90319 if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;
90320 }else{
90321 pDest->z = pDest->zMalloc;
90322 }
@@ -90264,10 +90345,11 @@
90345 ** as that array is 256 bytes long (plenty for VdbeMemPrettyPrint())
90346 ** and it begins with a bunch of zeros.
90347 */
90348 sqlite3VdbeSerialGet((u8*)sqlite3CtypeMap, t, pDest);
90349 }else{
90350 if( len>db->aLimit[SQLITE_LIMIT_LENGTH] ) goto too_big;
90351 rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);
90352 if( rc!=SQLITE_OK ) goto abort_due_to_error;
90353 sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
90354 pDest->flags &= ~MEM_Ephem;
90355 }
@@ -90476,11 +90558,10 @@
90558 u32 serial_type; /* Type field */
90559 Mem *pData0; /* First field to be combined into the record */
90560 Mem *pLast; /* Last field of the record */
90561 int nField; /* Number of fields in the record */
90562 char *zAffinity; /* The affinity string for the record */
 
90563 u32 len; /* Length of a field */
90564 u8 *zHdr; /* Where to write next byte of the header */
90565 u8 *zPayload; /* Where to write next byte of the payload */
90566
90567 /* Assuming the record contains N fields, the record format looks
@@ -90505,11 +90586,10 @@
90586 zAffinity = pOp->p4.z;
90587 assert( nField>0 && pOp->p2>0 && pOp->p2+nField<=(p->nMem+1 - p->nCursor)+1 );
90588 pData0 = &aMem[nField];
90589 nField = pOp->p2;
90590 pLast = &pData0[nField-1];
 
90591
90592 /* Identify the output register */
90593 assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 );
90594 pOut = &aMem[pOp->p3];
90595 memAboutToChange(p, pOut);
@@ -90607,11 +90687,11 @@
90687 testcase( uu==32767 ); testcase( uu==32768 );
90688 testcase( uu==8388607 ); testcase( uu==8388608 );
90689 testcase( uu==2147483647 ); testcase( uu==2147483648LL );
90690 testcase( uu==140737488355327LL ); testcase( uu==140737488355328LL );
90691 if( uu<=127 ){
90692 if( (i&1)==i && p->minWriteFileFormat>=4 ){
90693 pRec->uTemp = 8+(u32)uu;
90694 }else{
90695 nData++;
90696 pRec->uTemp = 1;
90697 }
@@ -93070,10 +93150,14 @@
93150 /* Opcode: NullRow P1 * * * *
93151 **
93152 ** Move the cursor P1 to a null row. Any OP_Column operations
93153 ** that occur while the cursor is on the null row will always
93154 ** write a NULL.
93155 **
93156 ** Or, if P1 is a Pseudo-Cursor (a cursor opened using OP_OpenPseudo)
93157 ** just reset the cache for that cursor. This causes the row of
93158 ** content held by the pseudo-cursor to be reparsed.
93159 */
93160 case OP_NullRow: {
93161 VdbeCursor *pC;
93162
93163 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -93249,11 +93333,11 @@
93333 VdbeBranchTaken(res!=0,2);
93334 if( res ) goto jump_to_p2;
93335 break;
93336 }
93337
93338 /* Opcode: Next P1 P2 P3 * P5
93339 **
93340 ** Advance cursor P1 so that it points to the next key/data pair in its
93341 ** table or index. If there are no more key/value pairs then fall through
93342 ** to the following instruction. But if the cursor advance was successful,
93343 ** jump immediately to P2.
@@ -93268,19 +93352,16 @@
93352 ** The P3 value is a hint to the btree implementation. If P3==1, that
93353 ** means P1 is an SQL index and that this instruction could have been
93354 ** omitted if that index had been unique. P3 is usually 0. P3 is
93355 ** always either 0 or 1.
93356 **
 
 
 
93357 ** If P5 is positive and the jump is taken, then event counter
93358 ** number P5-1 in the prepared statement is incremented.
93359 **
93360 ** See also: Prev
93361 */
93362 /* Opcode: Prev P1 P2 P3 * P5
93363 **
93364 ** Back up cursor P1 so that it points to the previous key/data pair in its
93365 ** table or index. If there is no previous key/value pairs then fall through
93366 ** to the following instruction. But if the cursor backup was successful,
93367 ** jump immediately to P2.
@@ -93296,13 +93377,10 @@
93377 ** The P3 value is a hint to the btree implementation. If P3==1, that
93378 ** means P1 is an SQL index and that this instruction could have been
93379 ** omitted if that index had been unique. P3 is usually 0. P3 is
93380 ** always either 0 or 1.
93381 **
 
 
 
93382 ** If P5 is positive and the jump is taken, then event counter
93383 ** number P5-1 in the prepared statement is incremented.
93384 */
93385 /* Opcode: SorterNext P1 P2 * * P5
93386 **
@@ -93316,34 +93394,37 @@
93394
93395 pC = p->apCsr[pOp->p1];
93396 assert( isSorter(pC) );
93397 rc = sqlite3VdbeSorterNext(db, pC);
93398 goto next_tail;
93399
93400 case OP_Prev: /* jump */
93401 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
93402 assert( pOp->p5<ArraySize(p->aCounter) );
93403 pC = p->apCsr[pOp->p1];
93404 assert( pC!=0 );
93405 assert( pC->deferredMoveto==0 );
93406 assert( pC->eCurType==CURTYPE_BTREE );
93407 assert( pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
93408 || pC->seekOp==OP_Last || pC->seekOp==OP_IfNoHope
93409 || pC->seekOp==OP_NullRow);
93410 rc = sqlite3BtreePrevious(pC->uc.pCursor, pOp->p3);
93411 goto next_tail;
93412
93413 case OP_Next: /* jump */
93414 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
93415 assert( pOp->p5<ArraySize(p->aCounter) );
93416 pC = p->apCsr[pOp->p1];
93417 assert( pC!=0 );
93418 assert( pC->deferredMoveto==0 );
93419 assert( pC->eCurType==CURTYPE_BTREE );
93420 assert( pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
 
 
 
 
 
 
93421 || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
93422 || pC->seekOp==OP_NullRow|| pC->seekOp==OP_SeekRowid
93423 || pC->seekOp==OP_IfNoHope);
93424 rc = sqlite3BtreeNext(pC->uc.pCursor, pOp->p3);
 
 
 
93425
 
93426 next_tail:
93427 pC->cacheStatus = CACHE_STALE;
93428 VdbeBranchTaken(rc==SQLITE_OK,2);
93429 if( rc==SQLITE_OK ){
93430 pC->nullRow = 0;
@@ -93557,10 +93638,11 @@
93638 assert( pTabCur->uc.pCursor!=0 );
93639 assert( pTabCur->isTable );
93640 pTabCur->nullRow = 0;
93641 pTabCur->movetoTarget = rowid;
93642 pTabCur->deferredMoveto = 1;
93643 pTabCur->cacheStatus = CACHE_STALE;
93644 assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );
93645 assert( !pTabCur->isEphemeral );
93646 pTabCur->ub.aAltMap = pOp->p4.ai;
93647 assert( !pC->isEphemeral );
93648 pTabCur->pAltCursor = pC;
@@ -112069,11 +112151,11 @@
112151 if( pStat1==0 ) return;
112152 pStat1->zName = (char*)&pStat1[1];
112153 memcpy(pStat1->zName, "sqlite_stat1", 13);
112154 pStat1->nCol = 3;
112155 pStat1->iPKey = -1;
112156 sqlite3VdbeAddOp4(pParse->pVdbe, OP_Noop, 0, 0, 0,(char*)pStat1,P4_DYNAMIC);
112157 }
112158 #endif
112159
112160 /* Establish a read-lock on the table at the shared-cache level.
112161 ** Open a read-only cursor on the table. Also allocate a cursor number
@@ -125675,11 +125757,15 @@
125757 ** Then special optimizations can be applied that make the transfer
125758 ** very fast and which reduce fragmentation of indices.
125759 **
125760 ** This is the 2nd template.
125761 */
125762 if( pColumn==0
125763 && pSelect!=0
125764 && pTrigger==0
125765 && xferOptimization(pParse, pTab, pSelect, onError, iDb)
125766 ){
125767 assert( !pTrigger );
125768 assert( pList==0 );
125769 goto insert_end;
125770 }
125771 #endif /* SQLITE_OMIT_XFER_OPT */
@@ -127646,22 +127732,17 @@
127732 Vdbe *v; /* The VDBE we are building */
127733 int regAutoinc; /* Memory register used by AUTOINC */
127734 int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
127735 int regData, regRowid; /* Registers holding data and rowid */
127736
127737 assert( pSelect!=0 );
 
 
127738 if( pParse->pWith || pSelect->pWith ){
127739 /* Do not attempt to process this query if there are an WITH clauses
127740 ** attached to it. Proceeding may generate a false "no such table: xxx"
127741 ** error if pSelect reads from a CTE named "xxx". */
127742 return 0;
127743 }
 
 
 
127744 #ifndef SQLITE_OMIT_VIRTUALTABLE
127745 if( IsVirtual(pDest) ){
127746 return 0; /* tab1 must not be a virtual table */
127747 }
127748 #endif
@@ -130011,11 +130092,11 @@
130092 /* iArg: */ BTREE_DATA_VERSION },
130093 #endif
130094 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
130095 {/* zName: */ "database_list",
130096 /* ePragTyp: */ PragTyp_DATABASE_LIST,
130097 /* ePragFlg: */ PragFlg_Result0,
130098 /* ColNames: */ 47, 3,
130099 /* iArg: */ 0 },
130100 #endif
130101 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
130102 {/* zName: */ "default_cache_size",
@@ -130699,19 +130780,20 @@
130780 Vdbe *v, /* The prepared statement being created */
130781 FuncDef *p, /* A particular function definition */
130782 int isBuiltin, /* True if this is a built-in function */
130783 int showInternFuncs /* True if showing internal functions */
130784 ){
130785 u32 mask =
130786 SQLITE_DETERMINISTIC |
130787 SQLITE_DIRECTONLY |
130788 SQLITE_SUBTYPE |
130789 SQLITE_INNOCUOUS |
130790 SQLITE_FUNC_INTERNAL
130791 ;
130792 if( showInternFuncs ) mask = 0xffffffff;
130793 for(; p; p=p->pNext){
130794 const char *zType;
 
 
 
 
 
 
 
130795 static const char *azEnc[] = { 0, "utf8", "utf16le", "utf16be" };
130796
130797 assert( SQLITE_FUNC_ENCMASK==0x3 );
130798 assert( strcmp(azEnc[SQLITE_UTF8],"utf8")==0 );
130799 assert( strcmp(azEnc[SQLITE_UTF16LE],"utf16le")==0 );
@@ -148508,18 +148590,26 @@
148590 ** rowid stored in register iRowid.
148591 **
148592 ** Normally, this is just:
148593 **
148594 ** OP_DeferredSeek $iCur $iRowid
148595 **
148596 ** Which causes a seek on $iCur to the row with rowid $iRowid.
148597 **
148598 ** However, if the scan currently being coded is a branch of an OR-loop and
148599 ** the statement currently being coded is a SELECT, then additional information
148600 ** is added that might allow OP_Column to omit the seek and instead do its
148601 ** lookup on the index, thus avoiding an expensive seek operation. To
148602 ** enable this optimization, the P3 of OP_DeferredSeek is set to iIdxCur
148603 ** and P4 is set to an array of integers containing one entry for each column
148604 ** in the table. For each table column, if the column is the i'th
148605 ** column of the index, then the corresponding array entry is set to (i+1).
148606 ** If the column does not appear in the index at all, the array entry is set
148607 ** to 0. The OP_Column opcode can check this array to see if the column it
148608 ** wants is in the index and if it is, it will substitute the index cursor
148609 ** and column number and continue with those new values, rather than seeking
148610 ** the table cursor.
148611 */
148612 static void codeDeferredSeek(
148613 WhereInfo *pWInfo, /* Where clause context */
148614 Index *pIdx, /* Index scan is using */
148615 int iCur, /* Cursor for IPK b-tree */
@@ -234298,11 +234388,11 @@
234388 int nArg, /* Number of args */
234389 sqlite3_value **apUnused /* Function arguments */
234390 ){
234391 assert( nArg==0 );
234392 UNUSED_PARAM2(nArg, apUnused);
234393 sqlite3_result_text(pCtx, "fts5: 2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b", -1, SQLITE_TRANSIENT);
234394 }
234395
234396 /*
234397 ** Return true if zName is the extension on one of the shadow tables used
234398 ** by this module.
234399
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,13 +144,13 @@
144144
**
145145
** See also: [sqlite3_libversion()],
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149
-#define SQLITE_VERSION "3.38.0"
150
-#define SQLITE_VERSION_NUMBER 3038000
151
-#define SQLITE_SOURCE_ID "2022-02-22 18:58:40 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968a1bab"
149
+#define SQLITE_VERSION "3.39.0"
150
+#define SQLITE_VERSION_NUMBER 3039000
151
+#define SQLITE_SOURCE_ID "2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -9765,11 +9765,11 @@
97659765
** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
97669766
** and remains valid for the duration of the xBestIndex method call.
97679767
** ^When xBestIndex returns, the sqlite3_value object returned by
97689768
** sqlite3_vtab_rhs_value() is automatically deallocated.
97699769
**
9770
-** The "_rhs_" in the name of this routine is an appreviation for
9770
+** The "_rhs_" in the name of this routine is an abbreviation for
97719771
** "Right-Hand Side".
97729772
*/
97739773
SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
97749774
97759775
/*
97769776
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,13 +144,13 @@
144 **
145 ** See also: [sqlite3_libversion()],
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.38.0"
150 #define SQLITE_VERSION_NUMBER 3038000
151 #define SQLITE_SOURCE_ID "2022-02-22 18:58:40 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968a1bab"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -9765,11 +9765,11 @@
9765 ** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
9766 ** and remains valid for the duration of the xBestIndex method call.
9767 ** ^When xBestIndex returns, the sqlite3_value object returned by
9768 ** sqlite3_vtab_rhs_value() is automatically deallocated.
9769 **
9770 ** The "_rhs_" in the name of this routine is an appreviation for
9771 ** "Right-Hand Side".
9772 */
9773 SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
9774
9775 /*
9776
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,13 +144,13 @@
144 **
145 ** See also: [sqlite3_libversion()],
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.39.0"
150 #define SQLITE_VERSION_NUMBER 3039000
151 #define SQLITE_SOURCE_ID "2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -9765,11 +9765,11 @@
9765 ** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
9766 ** and remains valid for the duration of the xBestIndex method call.
9767 ** ^When xBestIndex returns, the sqlite3_value object returned by
9768 ** sqlite3_vtab_rhs_value() is automatically deallocated.
9769 **
9770 ** The "_rhs_" in the name of this routine is an abbreviation for
9771 ** "Right-Hand Side".
9772 */
9773 SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
9774
9775 /*
9776

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button