Fossil SCM

Use an experimental SQLite (the latest from the empty-table-optimizations branch that includes the EXISTS-to-JOIN optimization), to see how the new SQLite performs under real-world load.

drh 2025-07-04 22:21 trunk
Commit ec10b57f0a109744e599e1f97d506057a58dc05e4fa3ac2b3edc1bf5b52eaa88
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -31838,10 +31838,11 @@
3183831838
{ 0x02000000, 1, "Coroutines" },
3183931839
{ 0x04000000, 1, "NullUnusedCols" },
3184031840
{ 0x08000000, 1, "OnePass" },
3184131841
{ 0x10000000, 1, "OrderBySubq" },
3184231842
{ 0x20000000, 1, "StarQuery" },
31843
+ { 0x40000000, 1, "ExistsToJoin" },
3184331844
{ 0xffffffff, 0, "All" },
3184431845
};
3184531846
unsigned int curOpt;
3184631847
unsigned int newOpt;
3184731848
unsigned int m;
3184831849
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -31838,10 +31838,11 @@
31838 { 0x02000000, 1, "Coroutines" },
31839 { 0x04000000, 1, "NullUnusedCols" },
31840 { 0x08000000, 1, "OnePass" },
31841 { 0x10000000, 1, "OrderBySubq" },
31842 { 0x20000000, 1, "StarQuery" },
 
31843 { 0xffffffff, 0, "All" },
31844 };
31845 unsigned int curOpt;
31846 unsigned int newOpt;
31847 unsigned int m;
31848
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -31838,10 +31838,11 @@
31838 { 0x02000000, 1, "Coroutines" },
31839 { 0x04000000, 1, "NullUnusedCols" },
31840 { 0x08000000, 1, "OnePass" },
31841 { 0x10000000, 1, "OrderBySubq" },
31842 { 0x20000000, 1, "StarQuery" },
31843 { 0x40000000, 1, "ExistsToJoin" },
31844 { 0xffffffff, 0, "All" },
31845 };
31846 unsigned int curOpt;
31847 unsigned int newOpt;
31848 unsigned int m;
31849
+577 -351
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** 0083d5169a46104a25355bdd9d5a2f4027b0 with changes in files:
21
+** 6f98b16d210a9f5b6ca4b4599e3dab3263ed with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465465
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466466
** [sqlite_version()] and [sqlite_source_id()].
467467
*/
468468
#define SQLITE_VERSION "3.51.0"
469469
#define SQLITE_VERSION_NUMBER 3051000
470
-#define SQLITE_SOURCE_ID "2025-06-30 16:41:40 0083d5169a46104a25355bdd9d5a2f4027b049191ebda571dd228477ec217296"
470
+#define SQLITE_SOURCE_ID "2025-07-04 14:24:18 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b"
471471
472472
/*
473473
** CAPI3REF: Run-Time Library Version Numbers
474474
** KEYWORDS: sqlite3_version sqlite3_sourceid
475475
**
@@ -15565,10 +15565,11 @@
1556515565
** 0x00010000 Beginning of DELETE/INSERT/UPDATE processing
1556615566
** 0x00020000 Transform DISTINCT into GROUP BY
1556715567
** 0x00040000 SELECT tree dump after all code has been generated
1556815568
** 0x00080000 NOT NULL strength reduction
1556915569
** 0x00100000 Pointers are all shown as zero
15570
+** 0x00200000 EXISTS-to-JOIN optimization
1557015571
*/
1557115572
1557215573
/*
1557315574
** Macros for "wheretrace"
1557415575
*/
@@ -16750,10 +16751,11 @@
1675016751
};
1675116752
1675216753
SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
1675316754
int flags, int seekResult);
1675416755
SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
16756
+SQLITE_PRIVATE int sqlite3BtreeIsEmpty(BtCursor *pCur, int *pRes);
1675516757
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
1675616758
SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
1675716759
SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
1675816760
SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
1675916761
SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
@@ -17083,76 +17085,76 @@
1708317085
#define OP_Last 32 /* jump0 */
1708417086
#define OP_IfSizeBetween 33 /* jump */
1708517087
#define OP_SorterSort 34 /* jump */
1708617088
#define OP_Sort 35 /* jump */
1708717089
#define OP_Rewind 36 /* jump0 */
17088
-#define OP_SorterNext 37 /* jump */
17089
-#define OP_Prev 38 /* jump */
17090
-#define OP_Next 39 /* jump */
17091
-#define OP_IdxLE 40 /* jump, synopsis: key=r[P3@P4] */
17092
-#define OP_IdxGT 41 /* jump, synopsis: key=r[P3@P4] */
17093
-#define OP_IdxLT 42 /* jump, synopsis: key=r[P3@P4] */
17090
+#define OP_IfEmpty 37 /* jump, synopsis: if( empty(P1) ) goto P2 */
17091
+#define OP_SorterNext 38 /* jump */
17092
+#define OP_Prev 39 /* jump */
17093
+#define OP_Next 40 /* jump */
17094
+#define OP_IdxLE 41 /* jump, synopsis: key=r[P3@P4] */
17095
+#define OP_IdxGT 42 /* jump, synopsis: key=r[P3@P4] */
1709417096
#define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
1709517097
#define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
17096
-#define OP_IdxGE 45 /* jump, synopsis: key=r[P3@P4] */
17097
-#define OP_RowSetRead 46 /* jump, synopsis: r[P3]=rowset(P1) */
17098
-#define OP_RowSetTest 47 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
17099
-#define OP_Program 48 /* jump0 */
17100
-#define OP_FkIfZero 49 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
17101
-#define OP_IfPos 50 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
17098
+#define OP_IdxLT 45 /* jump, synopsis: key=r[P3@P4] */
17099
+#define OP_IdxGE 46 /* jump, synopsis: key=r[P3@P4] */
17100
+#define OP_RowSetRead 47 /* jump, synopsis: r[P3]=rowset(P1) */
17101
+#define OP_RowSetTest 48 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
17102
+#define OP_Program 49 /* jump0 */
17103
+#define OP_FkIfZero 50 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
1710217104
#define OP_IsNull 51 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
1710317105
#define OP_NotNull 52 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
1710417106
#define OP_Ne 53 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
1710517107
#define OP_Eq 54 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
1710617108
#define OP_Gt 55 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
1710717109
#define OP_Le 56 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
1710817110
#define OP_Lt 57 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
1710917111
#define OP_Ge 58 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
1711017112
#define OP_ElseEq 59 /* jump, same as TK_ESCAPE */
17111
-#define OP_IfNotZero 60 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
17112
-#define OP_DecrJumpZero 61 /* jump, synopsis: if (--r[P1])==0 goto P2 */
17113
-#define OP_IncrVacuum 62 /* jump */
17114
-#define OP_VNext 63 /* jump */
17115
-#define OP_Filter 64 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
17116
-#define OP_PureFunc 65 /* synopsis: r[P3]=func(r[P2@NP]) */
17117
-#define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */
17118
-#define OP_Return 67
17119
-#define OP_EndCoroutine 68
17120
-#define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */
17121
-#define OP_Halt 70
17122
-#define OP_Integer 71 /* synopsis: r[P2]=P1 */
17123
-#define OP_Int64 72 /* synopsis: r[P2]=P4 */
17124
-#define OP_String 73 /* synopsis: r[P2]='P4' (len=P1) */
17125
-#define OP_BeginSubrtn 74 /* synopsis: r[P2]=NULL */
17126
-#define OP_Null 75 /* synopsis: r[P2..P3]=NULL */
17127
-#define OP_SoftNull 76 /* synopsis: r[P1]=NULL */
17128
-#define OP_Blob 77 /* synopsis: r[P2]=P4 (len=P1) */
17129
-#define OP_Variable 78 /* synopsis: r[P2]=parameter(P1) */
17130
-#define OP_Move 79 /* synopsis: r[P2@P3]=r[P1@P3] */
17131
-#define OP_Copy 80 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
17132
-#define OP_SCopy 81 /* synopsis: r[P2]=r[P1] */
17133
-#define OP_IntCopy 82 /* synopsis: r[P2]=r[P1] */
17134
-#define OP_FkCheck 83
17135
-#define OP_ResultRow 84 /* synopsis: output=r[P1@P2] */
17136
-#define OP_CollSeq 85
17137
-#define OP_AddImm 86 /* synopsis: r[P1]=r[P1]+P2 */
17138
-#define OP_RealAffinity 87
17139
-#define OP_Cast 88 /* synopsis: affinity(r[P1]) */
17140
-#define OP_Permutation 89
17141
-#define OP_Compare 90 /* synopsis: r[P1@P3] <-> r[P2@P3] */
17142
-#define OP_IsTrue 91 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
17143
-#define OP_ZeroOrNull 92 /* synopsis: r[P2] = 0 OR NULL */
17144
-#define OP_Offset 93 /* synopsis: r[P3] = sqlite_offset(P1) */
17145
-#define OP_Column 94 /* synopsis: r[P3]=PX cursor P1 column P2 */
17146
-#define OP_TypeCheck 95 /* synopsis: typecheck(r[P1@P2]) */
17147
-#define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */
17148
-#define OP_MakeRecord 97 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
17149
-#define OP_Count 98 /* synopsis: r[P2]=count() */
17150
-#define OP_ReadCookie 99
17151
-#define OP_SetCookie 100
17152
-#define OP_ReopenIdx 101 /* synopsis: root=P2 iDb=P3 */
17153
-#define OP_OpenRead 102 /* synopsis: root=P2 iDb=P3 */
17113
+#define OP_IfPos 60 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
17114
+#define OP_IfNotZero 61 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
17115
+#define OP_DecrJumpZero 62 /* jump, synopsis: if (--r[P1])==0 goto P2 */
17116
+#define OP_IncrVacuum 63 /* jump */
17117
+#define OP_VNext 64 /* jump */
17118
+#define OP_Filter 65 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
17119
+#define OP_PureFunc 66 /* synopsis: r[P3]=func(r[P2@NP]) */
17120
+#define OP_Function 67 /* synopsis: r[P3]=func(r[P2@NP]) */
17121
+#define OP_Return 68
17122
+#define OP_EndCoroutine 69
17123
+#define OP_HaltIfNull 70 /* synopsis: if r[P3]=null halt */
17124
+#define OP_Halt 71
17125
+#define OP_Integer 72 /* synopsis: r[P2]=P1 */
17126
+#define OP_Int64 73 /* synopsis: r[P2]=P4 */
17127
+#define OP_String 74 /* synopsis: r[P2]='P4' (len=P1) */
17128
+#define OP_BeginSubrtn 75 /* synopsis: r[P2]=NULL */
17129
+#define OP_Null 76 /* synopsis: r[P2..P3]=NULL */
17130
+#define OP_SoftNull 77 /* synopsis: r[P1]=NULL */
17131
+#define OP_Blob 78 /* synopsis: r[P2]=P4 (len=P1) */
17132
+#define OP_Variable 79 /* synopsis: r[P2]=parameter(P1) */
17133
+#define OP_Move 80 /* synopsis: r[P2@P3]=r[P1@P3] */
17134
+#define OP_Copy 81 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
17135
+#define OP_SCopy 82 /* synopsis: r[P2]=r[P1] */
17136
+#define OP_IntCopy 83 /* synopsis: r[P2]=r[P1] */
17137
+#define OP_FkCheck 84
17138
+#define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */
17139
+#define OP_CollSeq 86
17140
+#define OP_AddImm 87 /* synopsis: r[P1]=r[P1]+P2 */
17141
+#define OP_RealAffinity 88
17142
+#define OP_Cast 89 /* synopsis: affinity(r[P1]) */
17143
+#define OP_Permutation 90
17144
+#define OP_Compare 91 /* synopsis: r[P1@P3] <-> r[P2@P3] */
17145
+#define OP_IsTrue 92 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
17146
+#define OP_ZeroOrNull 93 /* synopsis: r[P2] = 0 OR NULL */
17147
+#define OP_Offset 94 /* synopsis: r[P3] = sqlite_offset(P1) */
17148
+#define OP_Column 95 /* synopsis: r[P3]=PX cursor P1 column P2 */
17149
+#define OP_TypeCheck 96 /* synopsis: typecheck(r[P1@P2]) */
17150
+#define OP_Affinity 97 /* synopsis: affinity(r[P1@P2]) */
17151
+#define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
17152
+#define OP_Count 99 /* synopsis: r[P2]=count() */
17153
+#define OP_ReadCookie 100
17154
+#define OP_SetCookie 101
17155
+#define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
1715417156
#define OP_BitAnd 103 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
1715517157
#define OP_BitOr 104 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
1715617158
#define OP_ShiftLeft 105 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
1715717159
#define OP_ShiftRight 106 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
1715817160
#define OP_Add 107 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -17159,87 +17161,88 @@
1715917161
#define OP_Subtract 108 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
1716017162
#define OP_Multiply 109 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
1716117163
#define OP_Divide 110 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
1716217164
#define OP_Remainder 111 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
1716317165
#define OP_Concat 112 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
17164
-#define OP_OpenWrite 113 /* synopsis: root=P2 iDb=P3 */
17165
-#define OP_OpenDup 114
17166
+#define OP_OpenRead 113 /* synopsis: root=P2 iDb=P3 */
17167
+#define OP_OpenWrite 114 /* synopsis: root=P2 iDb=P3 */
1716617168
#define OP_BitNot 115 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
17167
-#define OP_OpenAutoindex 116 /* synopsis: nColumn=P2 */
17168
-#define OP_OpenEphemeral 117 /* synopsis: nColumn=P2 */
17169
+#define OP_OpenDup 116
17170
+#define OP_OpenAutoindex 117 /* synopsis: nColumn=P2 */
1716917171
#define OP_String8 118 /* same as TK_STRING, synopsis: r[P2]='P4' */
17170
-#define OP_SorterOpen 119
17171
-#define OP_SequenceTest 120 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
17172
-#define OP_OpenPseudo 121 /* synopsis: P3 columns in r[P2] */
17173
-#define OP_Close 122
17174
-#define OP_ColumnsUsed 123
17175
-#define OP_SeekScan 124 /* synopsis: Scan-ahead up to P1 rows */
17176
-#define OP_SeekHit 125 /* synopsis: set P2<=seekHit<=P3 */
17177
-#define OP_Sequence 126 /* synopsis: r[P2]=cursor[P1].ctr++ */
17178
-#define OP_NewRowid 127 /* synopsis: r[P2]=rowid */
17179
-#define OP_Insert 128 /* synopsis: intkey=r[P3] data=r[P2] */
17180
-#define OP_RowCell 129
17181
-#define OP_Delete 130
17182
-#define OP_ResetCount 131
17183
-#define OP_SorterCompare 132 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
17184
-#define OP_SorterData 133 /* synopsis: r[P2]=data */
17185
-#define OP_RowData 134 /* synopsis: r[P2]=data */
17186
-#define OP_Rowid 135 /* synopsis: r[P2]=PX rowid of P1 */
17187
-#define OP_NullRow 136
17188
-#define OP_SeekEnd 137
17189
-#define OP_IdxInsert 138 /* synopsis: key=r[P2] */
17190
-#define OP_SorterInsert 139 /* synopsis: key=r[P2] */
17191
-#define OP_IdxDelete 140 /* synopsis: key=r[P2@P3] */
17192
-#define OP_DeferredSeek 141 /* synopsis: Move P3 to P1.rowid if needed */
17193
-#define OP_IdxRowid 142 /* synopsis: r[P2]=rowid */
17194
-#define OP_FinishSeek 143
17195
-#define OP_Destroy 144
17196
-#define OP_Clear 145
17197
-#define OP_ResetSorter 146
17198
-#define OP_CreateBtree 147 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
17199
-#define OP_SqlExec 148
17200
-#define OP_ParseSchema 149
17201
-#define OP_LoadAnalysis 150
17202
-#define OP_DropTable 151
17203
-#define OP_DropIndex 152
17204
-#define OP_DropTrigger 153
17172
+#define OP_OpenEphemeral 119 /* synopsis: nColumn=P2 */
17173
+#define OP_SorterOpen 120
17174
+#define OP_SequenceTest 121 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
17175
+#define OP_OpenPseudo 122 /* synopsis: P3 columns in r[P2] */
17176
+#define OP_Close 123
17177
+#define OP_ColumnsUsed 124
17178
+#define OP_SeekScan 125 /* synopsis: Scan-ahead up to P1 rows */
17179
+#define OP_SeekHit 126 /* synopsis: set P2<=seekHit<=P3 */
17180
+#define OP_Sequence 127 /* synopsis: r[P2]=cursor[P1].ctr++ */
17181
+#define OP_NewRowid 128 /* synopsis: r[P2]=rowid */
17182
+#define OP_Insert 129 /* synopsis: intkey=r[P3] data=r[P2] */
17183
+#define OP_RowCell 130
17184
+#define OP_Delete 131
17185
+#define OP_ResetCount 132
17186
+#define OP_SorterCompare 133 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
17187
+#define OP_SorterData 134 /* synopsis: r[P2]=data */
17188
+#define OP_RowData 135 /* synopsis: r[P2]=data */
17189
+#define OP_Rowid 136 /* synopsis: r[P2]=PX rowid of P1 */
17190
+#define OP_NullRow 137
17191
+#define OP_SeekEnd 138
17192
+#define OP_IdxInsert 139 /* synopsis: key=r[P2] */
17193
+#define OP_SorterInsert 140 /* synopsis: key=r[P2] */
17194
+#define OP_IdxDelete 141 /* synopsis: key=r[P2@P3] */
17195
+#define OP_DeferredSeek 142 /* synopsis: Move P3 to P1.rowid if needed */
17196
+#define OP_IdxRowid 143 /* synopsis: r[P2]=rowid */
17197
+#define OP_FinishSeek 144
17198
+#define OP_Destroy 145
17199
+#define OP_Clear 146
17200
+#define OP_ResetSorter 147
17201
+#define OP_CreateBtree 148 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
17202
+#define OP_SqlExec 149
17203
+#define OP_ParseSchema 150
17204
+#define OP_LoadAnalysis 151
17205
+#define OP_DropTable 152
17206
+#define OP_DropIndex 153
1720517207
#define OP_Real 154 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
17206
-#define OP_IntegrityCk 155
17207
-#define OP_RowSetAdd 156 /* synopsis: rowset(P1)=r[P2] */
17208
-#define OP_Param 157
17209
-#define OP_FkCounter 158 /* synopsis: fkctr[P1]+=P2 */
17210
-#define OP_MemMax 159 /* synopsis: r[P1]=max(r[P1],r[P2]) */
17211
-#define OP_OffsetLimit 160 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
17212
-#define OP_AggInverse 161 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
17213
-#define OP_AggStep 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17214
-#define OP_AggStep1 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17215
-#define OP_AggValue 164 /* synopsis: r[P3]=value N=P2 */
17216
-#define OP_AggFinal 165 /* synopsis: accum=r[P1] N=P2 */
17217
-#define OP_Expire 166
17218
-#define OP_CursorLock 167
17219
-#define OP_CursorUnlock 168
17220
-#define OP_TableLock 169 /* synopsis: iDb=P1 root=P2 write=P3 */
17221
-#define OP_VBegin 170
17222
-#define OP_VCreate 171
17223
-#define OP_VDestroy 172
17224
-#define OP_VOpen 173
17225
-#define OP_VCheck 174
17226
-#define OP_VInitIn 175 /* synopsis: r[P2]=ValueList(P1,P3) */
17227
-#define OP_VColumn 176 /* synopsis: r[P3]=vcolumn(P2) */
17228
-#define OP_VRename 177
17229
-#define OP_Pagecount 178
17230
-#define OP_MaxPgcnt 179
17231
-#define OP_ClrSubtype 180 /* synopsis: r[P1].subtype = 0 */
17232
-#define OP_GetSubtype 181 /* synopsis: r[P2] = r[P1].subtype */
17233
-#define OP_SetSubtype 182 /* synopsis: r[P2].subtype = r[P1] */
17234
-#define OP_FilterAdd 183 /* synopsis: filter(P1) += key(P3@P4) */
17235
-#define OP_Trace 184
17236
-#define OP_CursorHint 185
17237
-#define OP_ReleaseReg 186 /* synopsis: release r[P1@P2] mask P3 */
17238
-#define OP_Noop 187
17239
-#define OP_Explain 188
17240
-#define OP_Abortable 189
17208
+#define OP_DropTrigger 155
17209
+#define OP_IntegrityCk 156
17210
+#define OP_RowSetAdd 157 /* synopsis: rowset(P1)=r[P2] */
17211
+#define OP_Param 158
17212
+#define OP_FkCounter 159 /* synopsis: fkctr[P1]+=P2 */
17213
+#define OP_MemMax 160 /* synopsis: r[P1]=max(r[P1],r[P2]) */
17214
+#define OP_OffsetLimit 161 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
17215
+#define OP_AggInverse 162 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
17216
+#define OP_AggStep 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17217
+#define OP_AggStep1 164 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17218
+#define OP_AggValue 165 /* synopsis: r[P3]=value N=P2 */
17219
+#define OP_AggFinal 166 /* synopsis: accum=r[P1] N=P2 */
17220
+#define OP_Expire 167
17221
+#define OP_CursorLock 168
17222
+#define OP_CursorUnlock 169
17223
+#define OP_TableLock 170 /* synopsis: iDb=P1 root=P2 write=P3 */
17224
+#define OP_VBegin 171
17225
+#define OP_VCreate 172
17226
+#define OP_VDestroy 173
17227
+#define OP_VOpen 174
17228
+#define OP_VCheck 175
17229
+#define OP_VInitIn 176 /* synopsis: r[P2]=ValueList(P1,P3) */
17230
+#define OP_VColumn 177 /* synopsis: r[P3]=vcolumn(P2) */
17231
+#define OP_VRename 178
17232
+#define OP_Pagecount 179
17233
+#define OP_MaxPgcnt 180
17234
+#define OP_ClrSubtype 181 /* synopsis: r[P1].subtype = 0 */
17235
+#define OP_GetSubtype 182 /* synopsis: r[P2] = r[P1].subtype */
17236
+#define OP_SetSubtype 183 /* synopsis: r[P2].subtype = r[P1] */
17237
+#define OP_FilterAdd 184 /* synopsis: filter(P1) += key(P3@P4) */
17238
+#define OP_Trace 185
17239
+#define OP_CursorHint 186
17240
+#define OP_ReleaseReg 187 /* synopsis: release r[P1@P2] mask P3 */
17241
+#define OP_Noop 188
17242
+#define OP_Explain 189
17243
+#define OP_Abortable 190
1724117244
1724217245
/* Properties such as "out2" or "jump" that are specified in
1724317246
** comments following the "case" for each opcode in the vdbe.c
1724417247
** are encoded into bitvectors as follows:
1724517248
*/
@@ -17254,38 +17257,38 @@
1725417257
#define OPFLG_INITIALIZER {\
1725517258
/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\
1725617259
/* 8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\
1725717260
/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\
1725817261
/* 24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\
17259
-/* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x41, 0x41,\
17260
-/* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x23, 0x0b,\
17261
-/* 48 */ 0x81, 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\
17262
-/* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x41,\
17263
-/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
17264
-/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00,\
17265
-/* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02,\
17266
-/* 88 */ 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40, 0x00,\
17267
-/* 96 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x40, 0x26,\
17262
+/* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x01, 0x41,\
17263
+/* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x41, 0x23,\
17264
+/* 48 */ 0x0b, 0x81, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\
17265
+/* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01,\
17266
+/* 64 */ 0x41, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00,\
17267
+/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\
17268
+/* 80 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02,\
17269
+/* 88 */ 0x02, 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40,\
17270
+/* 96 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x26,\
1726817271
/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
17269
-/* 112 */ 0x26, 0x00, 0x40, 0x12, 0x40, 0x40, 0x10, 0x00,\
17270
-/* 120 */ 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10, 0x10,\
17271
-/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x50,\
17272
-/* 136 */ 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50, 0x40,\
17273
-/* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
17274
-/* 152 */ 0x00, 0x00, 0x10, 0x00, 0x06, 0x10, 0x00, 0x04,\
17275
-/* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
17276
-/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x50,\
17277
-/* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12, 0x00,\
17278
-/* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}
17272
+/* 112 */ 0x26, 0x40, 0x00, 0x12, 0x40, 0x40, 0x10, 0x40,\
17273
+/* 120 */ 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10,\
17274
+/* 128 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,\
17275
+/* 136 */ 0x50, 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50,\
17276
+/* 144 */ 0x40, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\
17277
+/* 152 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00,\
17278
+/* 160 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
17279
+/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10,\
17280
+/* 176 */ 0x50, 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12,\
17281
+/* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}
1727917282
1728017283
/* The resolve3P2Values() routine is able to run faster if it knows
1728117284
** the value of the largest JUMP opcode. The smaller the maximum
1728217285
** JUMP opcode the better, so the mkopcodeh.tcl script that
1728317286
** generated this include file strives to group all JUMP opcodes
1728417287
** together near the beginning of the list.
1728517288
*/
17286
-#define SQLITE_MX_JUMP_OPCODE 64 /* Maximum JUMP opcode */
17289
+#define SQLITE_MX_JUMP_OPCODE 65 /* Maximum JUMP opcode */
1728717290
1728817291
/************** End of opcodes.h *********************************************/
1728917292
/************** Continuing where we left off in vdbe.h ***********************/
1729017293
1729117294
/*
@@ -18300,10 +18303,11 @@
1830018303
#define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */
1830118304
#define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */
1830218305
#define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */
1830318306
#define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */
1830418307
#define SQLITE_StarQuery 0x20000000 /* Heurists for star queries */
18308
+#define SQLITE_ExistsToJoin 0x40000000 /* The EXISTS-to-JOIN optimization */
1830518309
#define SQLITE_AllOpts 0xffffffff /* All optimizations */
1830618310
1830718311
/*
1830818312
** Macros for testing whether or not optimizations are enabled or disabled.
1830918313
*/
@@ -19744,10 +19748,11 @@
1974419748
unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */
1974519749
unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */
1974619750
unsigned rowidUsed :1; /* The ROWID of this table is referenced */
1974719751
unsigned fixedSchema :1; /* Uses u4.pSchema, not u4.zDatabase */
1974819752
unsigned hadSchema :1; /* Had u4.zDatabase before u4.pSchema */
19753
+ unsigned fromExists :1; /* Comes from WHERE EXISTS(...) */
1974919754
} fg;
1975019755
int iCursor; /* The VDBE cursor number used to access this table */
1975119756
Bitmask colUsed; /* Bit N set if column N used. Details above for N>62 */
1975219757
union {
1975319758
char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */
@@ -20274,10 +20279,11 @@
2027420279
u8 mayAbort; /* True if statement may throw an ABORT exception */
2027520280
u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
2027620281
u8 disableLookaside; /* Number of times lookaside has been disabled */
2027720282
u8 prepFlags; /* SQLITE_PREPARE_* flags */
2027820283
u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */
20284
+ u8 bHasExists; /* Has a correlated "EXISTS (SELECT ....)" expression */
2027920285
u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */
2028020286
u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
2028120287
u8 bReturning; /* Coding a RETURNING trigger */
2028220288
u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
2028320289
u8 disableTriggers; /* True to disable triggers */
@@ -37721,76 +37727,76 @@
3772137727
/* 32 */ "Last" OpHelp(""),
3772237728
/* 33 */ "IfSizeBetween" OpHelp(""),
3772337729
/* 34 */ "SorterSort" OpHelp(""),
3772437730
/* 35 */ "Sort" OpHelp(""),
3772537731
/* 36 */ "Rewind" OpHelp(""),
37726
- /* 37 */ "SorterNext" OpHelp(""),
37727
- /* 38 */ "Prev" OpHelp(""),
37728
- /* 39 */ "Next" OpHelp(""),
37729
- /* 40 */ "IdxLE" OpHelp("key=r[P3@P4]"),
37730
- /* 41 */ "IdxGT" OpHelp("key=r[P3@P4]"),
37731
- /* 42 */ "IdxLT" OpHelp("key=r[P3@P4]"),
37732
+ /* 37 */ "IfEmpty" OpHelp("if( empty(P1) ) goto P2"),
37733
+ /* 38 */ "SorterNext" OpHelp(""),
37734
+ /* 39 */ "Prev" OpHelp(""),
37735
+ /* 40 */ "Next" OpHelp(""),
37736
+ /* 41 */ "IdxLE" OpHelp("key=r[P3@P4]"),
37737
+ /* 42 */ "IdxGT" OpHelp("key=r[P3@P4]"),
3773237738
/* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
3773337739
/* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
37734
- /* 45 */ "IdxGE" OpHelp("key=r[P3@P4]"),
37735
- /* 46 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
37736
- /* 47 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
37737
- /* 48 */ "Program" OpHelp(""),
37738
- /* 49 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
37739
- /* 50 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
37740
+ /* 45 */ "IdxLT" OpHelp("key=r[P3@P4]"),
37741
+ /* 46 */ "IdxGE" OpHelp("key=r[P3@P4]"),
37742
+ /* 47 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
37743
+ /* 48 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
37744
+ /* 49 */ "Program" OpHelp(""),
37745
+ /* 50 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
3774037746
/* 51 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
3774137747
/* 52 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
3774237748
/* 53 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
3774337749
/* 54 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
3774437750
/* 55 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
3774537751
/* 56 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
3774637752
/* 57 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
3774737753
/* 58 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
3774837754
/* 59 */ "ElseEq" OpHelp(""),
37749
- /* 60 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
37750
- /* 61 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
37751
- /* 62 */ "IncrVacuum" OpHelp(""),
37752
- /* 63 */ "VNext" OpHelp(""),
37753
- /* 64 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
37754
- /* 65 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
37755
- /* 66 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
37756
- /* 67 */ "Return" OpHelp(""),
37757
- /* 68 */ "EndCoroutine" OpHelp(""),
37758
- /* 69 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
37759
- /* 70 */ "Halt" OpHelp(""),
37760
- /* 71 */ "Integer" OpHelp("r[P2]=P1"),
37761
- /* 72 */ "Int64" OpHelp("r[P2]=P4"),
37762
- /* 73 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
37763
- /* 74 */ "BeginSubrtn" OpHelp("r[P2]=NULL"),
37764
- /* 75 */ "Null" OpHelp("r[P2..P3]=NULL"),
37765
- /* 76 */ "SoftNull" OpHelp("r[P1]=NULL"),
37766
- /* 77 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
37767
- /* 78 */ "Variable" OpHelp("r[P2]=parameter(P1)"),
37768
- /* 79 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
37769
- /* 80 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
37770
- /* 81 */ "SCopy" OpHelp("r[P2]=r[P1]"),
37771
- /* 82 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
37772
- /* 83 */ "FkCheck" OpHelp(""),
37773
- /* 84 */ "ResultRow" OpHelp("output=r[P1@P2]"),
37774
- /* 85 */ "CollSeq" OpHelp(""),
37775
- /* 86 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
37776
- /* 87 */ "RealAffinity" OpHelp(""),
37777
- /* 88 */ "Cast" OpHelp("affinity(r[P1])"),
37778
- /* 89 */ "Permutation" OpHelp(""),
37779
- /* 90 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
37780
- /* 91 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
37781
- /* 92 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
37782
- /* 93 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
37783
- /* 94 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"),
37784
- /* 95 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
37785
- /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
37786
- /* 97 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
37787
- /* 98 */ "Count" OpHelp("r[P2]=count()"),
37788
- /* 99 */ "ReadCookie" OpHelp(""),
37789
- /* 100 */ "SetCookie" OpHelp(""),
37790
- /* 101 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
37791
- /* 102 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
37755
+ /* 60 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
37756
+ /* 61 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
37757
+ /* 62 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
37758
+ /* 63 */ "IncrVacuum" OpHelp(""),
37759
+ /* 64 */ "VNext" OpHelp(""),
37760
+ /* 65 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
37761
+ /* 66 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
37762
+ /* 67 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
37763
+ /* 68 */ "Return" OpHelp(""),
37764
+ /* 69 */ "EndCoroutine" OpHelp(""),
37765
+ /* 70 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
37766
+ /* 71 */ "Halt" OpHelp(""),
37767
+ /* 72 */ "Integer" OpHelp("r[P2]=P1"),
37768
+ /* 73 */ "Int64" OpHelp("r[P2]=P4"),
37769
+ /* 74 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
37770
+ /* 75 */ "BeginSubrtn" OpHelp("r[P2]=NULL"),
37771
+ /* 76 */ "Null" OpHelp("r[P2..P3]=NULL"),
37772
+ /* 77 */ "SoftNull" OpHelp("r[P1]=NULL"),
37773
+ /* 78 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
37774
+ /* 79 */ "Variable" OpHelp("r[P2]=parameter(P1)"),
37775
+ /* 80 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
37776
+ /* 81 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
37777
+ /* 82 */ "SCopy" OpHelp("r[P2]=r[P1]"),
37778
+ /* 83 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
37779
+ /* 84 */ "FkCheck" OpHelp(""),
37780
+ /* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"),
37781
+ /* 86 */ "CollSeq" OpHelp(""),
37782
+ /* 87 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
37783
+ /* 88 */ "RealAffinity" OpHelp(""),
37784
+ /* 89 */ "Cast" OpHelp("affinity(r[P1])"),
37785
+ /* 90 */ "Permutation" OpHelp(""),
37786
+ /* 91 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
37787
+ /* 92 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
37788
+ /* 93 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
37789
+ /* 94 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
37790
+ /* 95 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"),
37791
+ /* 96 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
37792
+ /* 97 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
37793
+ /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
37794
+ /* 99 */ "Count" OpHelp("r[P2]=count()"),
37795
+ /* 100 */ "ReadCookie" OpHelp(""),
37796
+ /* 101 */ "SetCookie" OpHelp(""),
37797
+ /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
3779237798
/* 103 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
3779337799
/* 104 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
3779437800
/* 105 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
3779537801
/* 106 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
3779637802
/* 107 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -37797,87 +37803,88 @@
3779737803
/* 108 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
3779837804
/* 109 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
3779937805
/* 110 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
3780037806
/* 111 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
3780137807
/* 112 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
37802
- /* 113 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
37803
- /* 114 */ "OpenDup" OpHelp(""),
37808
+ /* 113 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
37809
+ /* 114 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
3780437810
/* 115 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
37805
- /* 116 */ "OpenAutoindex" OpHelp("nColumn=P2"),
37806
- /* 117 */ "OpenEphemeral" OpHelp("nColumn=P2"),
37811
+ /* 116 */ "OpenDup" OpHelp(""),
37812
+ /* 117 */ "OpenAutoindex" OpHelp("nColumn=P2"),
3780737813
/* 118 */ "String8" OpHelp("r[P2]='P4'"),
37808
- /* 119 */ "SorterOpen" OpHelp(""),
37809
- /* 120 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
37810
- /* 121 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
37811
- /* 122 */ "Close" OpHelp(""),
37812
- /* 123 */ "ColumnsUsed" OpHelp(""),
37813
- /* 124 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
37814
- /* 125 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
37815
- /* 126 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
37816
- /* 127 */ "NewRowid" OpHelp("r[P2]=rowid"),
37817
- /* 128 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
37818
- /* 129 */ "RowCell" OpHelp(""),
37819
- /* 130 */ "Delete" OpHelp(""),
37820
- /* 131 */ "ResetCount" OpHelp(""),
37821
- /* 132 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
37822
- /* 133 */ "SorterData" OpHelp("r[P2]=data"),
37823
- /* 134 */ "RowData" OpHelp("r[P2]=data"),
37824
- /* 135 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"),
37825
- /* 136 */ "NullRow" OpHelp(""),
37826
- /* 137 */ "SeekEnd" OpHelp(""),
37827
- /* 138 */ "IdxInsert" OpHelp("key=r[P2]"),
37828
- /* 139 */ "SorterInsert" OpHelp("key=r[P2]"),
37829
- /* 140 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
37830
- /* 141 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
37831
- /* 142 */ "IdxRowid" OpHelp("r[P2]=rowid"),
37832
- /* 143 */ "FinishSeek" OpHelp(""),
37833
- /* 144 */ "Destroy" OpHelp(""),
37834
- /* 145 */ "Clear" OpHelp(""),
37835
- /* 146 */ "ResetSorter" OpHelp(""),
37836
- /* 147 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
37837
- /* 148 */ "SqlExec" OpHelp(""),
37838
- /* 149 */ "ParseSchema" OpHelp(""),
37839
- /* 150 */ "LoadAnalysis" OpHelp(""),
37840
- /* 151 */ "DropTable" OpHelp(""),
37841
- /* 152 */ "DropIndex" OpHelp(""),
37842
- /* 153 */ "DropTrigger" OpHelp(""),
37814
+ /* 119 */ "OpenEphemeral" OpHelp("nColumn=P2"),
37815
+ /* 120 */ "SorterOpen" OpHelp(""),
37816
+ /* 121 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
37817
+ /* 122 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
37818
+ /* 123 */ "Close" OpHelp(""),
37819
+ /* 124 */ "ColumnsUsed" OpHelp(""),
37820
+ /* 125 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
37821
+ /* 126 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
37822
+ /* 127 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
37823
+ /* 128 */ "NewRowid" OpHelp("r[P2]=rowid"),
37824
+ /* 129 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
37825
+ /* 130 */ "RowCell" OpHelp(""),
37826
+ /* 131 */ "Delete" OpHelp(""),
37827
+ /* 132 */ "ResetCount" OpHelp(""),
37828
+ /* 133 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
37829
+ /* 134 */ "SorterData" OpHelp("r[P2]=data"),
37830
+ /* 135 */ "RowData" OpHelp("r[P2]=data"),
37831
+ /* 136 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"),
37832
+ /* 137 */ "NullRow" OpHelp(""),
37833
+ /* 138 */ "SeekEnd" OpHelp(""),
37834
+ /* 139 */ "IdxInsert" OpHelp("key=r[P2]"),
37835
+ /* 140 */ "SorterInsert" OpHelp("key=r[P2]"),
37836
+ /* 141 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
37837
+ /* 142 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
37838
+ /* 143 */ "IdxRowid" OpHelp("r[P2]=rowid"),
37839
+ /* 144 */ "FinishSeek" OpHelp(""),
37840
+ /* 145 */ "Destroy" OpHelp(""),
37841
+ /* 146 */ "Clear" OpHelp(""),
37842
+ /* 147 */ "ResetSorter" OpHelp(""),
37843
+ /* 148 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
37844
+ /* 149 */ "SqlExec" OpHelp(""),
37845
+ /* 150 */ "ParseSchema" OpHelp(""),
37846
+ /* 151 */ "LoadAnalysis" OpHelp(""),
37847
+ /* 152 */ "DropTable" OpHelp(""),
37848
+ /* 153 */ "DropIndex" OpHelp(""),
3784337849
/* 154 */ "Real" OpHelp("r[P2]=P4"),
37844
- /* 155 */ "IntegrityCk" OpHelp(""),
37845
- /* 156 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
37846
- /* 157 */ "Param" OpHelp(""),
37847
- /* 158 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
37848
- /* 159 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
37849
- /* 160 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
37850
- /* 161 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
37851
- /* 162 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
37852
- /* 163 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
37853
- /* 164 */ "AggValue" OpHelp("r[P3]=value N=P2"),
37854
- /* 165 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
37855
- /* 166 */ "Expire" OpHelp(""),
37856
- /* 167 */ "CursorLock" OpHelp(""),
37857
- /* 168 */ "CursorUnlock" OpHelp(""),
37858
- /* 169 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
37859
- /* 170 */ "VBegin" OpHelp(""),
37860
- /* 171 */ "VCreate" OpHelp(""),
37861
- /* 172 */ "VDestroy" OpHelp(""),
37862
- /* 173 */ "VOpen" OpHelp(""),
37863
- /* 174 */ "VCheck" OpHelp(""),
37864
- /* 175 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
37865
- /* 176 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
37866
- /* 177 */ "VRename" OpHelp(""),
37867
- /* 178 */ "Pagecount" OpHelp(""),
37868
- /* 179 */ "MaxPgcnt" OpHelp(""),
37869
- /* 180 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"),
37870
- /* 181 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"),
37871
- /* 182 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"),
37872
- /* 183 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
37873
- /* 184 */ "Trace" OpHelp(""),
37874
- /* 185 */ "CursorHint" OpHelp(""),
37875
- /* 186 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
37876
- /* 187 */ "Noop" OpHelp(""),
37877
- /* 188 */ "Explain" OpHelp(""),
37878
- /* 189 */ "Abortable" OpHelp(""),
37850
+ /* 155 */ "DropTrigger" OpHelp(""),
37851
+ /* 156 */ "IntegrityCk" OpHelp(""),
37852
+ /* 157 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
37853
+ /* 158 */ "Param" OpHelp(""),
37854
+ /* 159 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
37855
+ /* 160 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
37856
+ /* 161 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
37857
+ /* 162 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
37858
+ /* 163 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
37859
+ /* 164 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
37860
+ /* 165 */ "AggValue" OpHelp("r[P3]=value N=P2"),
37861
+ /* 166 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
37862
+ /* 167 */ "Expire" OpHelp(""),
37863
+ /* 168 */ "CursorLock" OpHelp(""),
37864
+ /* 169 */ "CursorUnlock" OpHelp(""),
37865
+ /* 170 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
37866
+ /* 171 */ "VBegin" OpHelp(""),
37867
+ /* 172 */ "VCreate" OpHelp(""),
37868
+ /* 173 */ "VDestroy" OpHelp(""),
37869
+ /* 174 */ "VOpen" OpHelp(""),
37870
+ /* 175 */ "VCheck" OpHelp(""),
37871
+ /* 176 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
37872
+ /* 177 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
37873
+ /* 178 */ "VRename" OpHelp(""),
37874
+ /* 179 */ "Pagecount" OpHelp(""),
37875
+ /* 180 */ "MaxPgcnt" OpHelp(""),
37876
+ /* 181 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"),
37877
+ /* 182 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"),
37878
+ /* 183 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"),
37879
+ /* 184 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
37880
+ /* 185 */ "Trace" OpHelp(""),
37881
+ /* 186 */ "CursorHint" OpHelp(""),
37882
+ /* 187 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
37883
+ /* 188 */ "Noop" OpHelp(""),
37884
+ /* 189 */ "Explain" OpHelp(""),
37885
+ /* 190 */ "Abortable" OpHelp(""),
3787937886
};
3788037887
return azName[i];
3788137888
}
3788237889
#endif
3788337890
@@ -73586,14 +73593,14 @@
7358673593
u8 *pTmp; /* Temporary ptr into data[] */
7358773594
7358873595
assert( pPage->pBt!=0 );
7358973596
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
7359073597
assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
73591
- assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );
73598
+ assert( CORRUPT_DB || iEnd <= (int)pPage->pBt->usableSize );
7359273599
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
7359373600
assert( iSize>=4 ); /* Minimum cell size is 4 */
73594
- assert( CORRUPT_DB || iStart<=pPage->pBt->usableSize-4 );
73601
+ assert( CORRUPT_DB || iStart<=(int)pPage->pBt->usableSize-4 );
7359573602
7359673603
/* The list of freeblocks must be in ascending order. Find the
7359773604
** spot on the list where iStart should be inserted.
7359873605
*/
7359973606
hdr = pPage->hdrOffset;
@@ -77323,10 +77330,34 @@
7732377330
*pRes = 1;
7732477331
rc = SQLITE_OK;
7732577332
}
7732677333
return rc;
7732777334
}
77335
+
77336
+/* Set *pRes to 1 (true) if the BTree pointed to by cursor pCur contains zero
77337
+** rows of content. Set *pRes to 0 (false) if the table contains content.
77338
+** Return SQLITE_OK on success or some error code (ex: SQLITE_NOMEM) if
77339
+** something goes wrong.
77340
+*/
77341
+SQLITE_PRIVATE int sqlite3BtreeIsEmpty(BtCursor *pCur, int *pRes){
77342
+ int rc;
77343
+
77344
+ assert( cursorOwnsBtShared(pCur) );
77345
+ assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
77346
+ if( pCur->eState==CURSOR_VALID ){
77347
+ *pRes = 0;
77348
+ return SQLITE_OK;
77349
+ }
77350
+ rc = moveToRoot(pCur);
77351
+ if( rc==SQLITE_EMPTY ){
77352
+ *pRes = 1;
77353
+ rc = SQLITE_OK;
77354
+ }else{
77355
+ *pRes = 0;
77356
+ }
77357
+ return rc;
77358
+}
7732877359
7732977360
#ifdef SQLITE_DEBUG
7733077361
/* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that
7733177362
** this flags are true for a consistent database.
7733277363
**
@@ -100850,10 +100881,36 @@
100850100881
VdbeBranchTaken(res!=0,2);
100851100882
if( res ) goto jump_to_p2;
100852100883
}
100853100884
break;
100854100885
}
100886
+
100887
+/* Opcode: IfEmpty P1 P2 * * *
100888
+** Synopsis: if( empty(P1) ) goto P2
100889
+**
100890
+** Check to see if the b-tree table that cursor P1 references is empty
100891
+** and jump to P2 if it is.
100892
+*/
100893
+case OP_IfEmpty: { /* jump */
100894
+ VdbeCursor *pC;
100895
+ BtCursor *pCrsr;
100896
+ int res;
100897
+
100898
+ assert( pOp->p1>=0 && pOp->p1<p->nCursor );
100899
+ assert( pOp->p2>=0 && pOp->p2<p->nOp );
100900
+
100901
+ pC = p->apCsr[pOp->p1];
100902
+ assert( pC!=0 );
100903
+ assert( pC->eCurType==CURTYPE_BTREE );
100904
+ pCrsr = pC->uc.pCursor;
100905
+ assert( pCrsr );
100906
+ rc = sqlite3BtreeIsEmpty(pCrsr, &res);
100907
+ if( rc ) goto abort_due_to_error;
100908
+ VdbeBranchTaken(res!=0,2);
100909
+ if( res ) goto jump_to_p2;
100910
+ break;
100911
+}
100855100912
100856100913
/* Opcode: Next P1 P2 P3 * P5
100857100914
**
100858100915
** Advance cursor P1 so that it points to the next key/data pair in its
100859100916
** table or index. If there are no more key/value pairs then fall through
@@ -102722,11 +102779,18 @@
102722102779
sqlite3_vtab_cursor *pVCur;
102723102780
sqlite3_vtab *pVtab;
102724102781
const sqlite3_module *pModule;
102725102782
102726102783
assert( p->bIsReader );
102727
- pCur = 0;
102784
+ pCur = p->apCsr[pOp->p1];
102785
+ if( pCur!=0
102786
+ && ALWAYS( pCur->eCurType==CURTYPE_VTAB )
102787
+ && ALWAYS( pCur->uc.pVCur->pVtab==pOp->p4.pVtab->pVtab )
102788
+ ){
102789
+ /* This opcode is a no-op if the cursor is already open */
102790
+ break;
102791
+ }
102728102792
pVCur = 0;
102729102793
pVtab = pOp->p4.pVtab->pVtab;
102730102794
if( pVtab==0 || NEVER(pVtab->pModule==0) ){
102731102795
rc = SQLITE_LOCKED;
102732102796
goto abort_due_to_error;
@@ -109563,15 +109627,20 @@
109563109627
** type of the function
109564109628
*/
109565109629
return WRC_Prune;
109566109630
}
109567109631
#ifndef SQLITE_OMIT_SUBQUERY
109632
+ case TK_EXISTS:
109633
+ assert( ExprUseXSelect(pExpr) );
109634
+ pParse->bHasExists = 1;
109635
+ /* no break */ deliberate_fall_through
109568109636
case TK_SELECT:
109569
- case TK_EXISTS: testcase( pExpr->op==TK_EXISTS );
109570109637
#endif
109571109638
case TK_IN: {
109572109639
testcase( pExpr->op==TK_IN );
109640
+ testcase( pExpr->op==TK_EXISTS );
109641
+ testcase( pExpr->op==TK_SELECT );
109573109642
if( ExprUseXSelect(pExpr) ){
109574109643
int nRef = pNC->nRef;
109575109644
testcase( pNC->ncFlags & NC_IsCheck );
109576109645
testcase( pNC->ncFlags & NC_PartIdx );
109577109646
testcase( pNC->ncFlags & NC_IdxExpr );
@@ -111660,11 +111729,11 @@
111660111729
return pRight;
111661111730
}else if( pRight==0 ){
111662111731
return pLeft;
111663111732
}else{
111664111733
u32 f = pLeft->flags | pRight->flags;
111665
- if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse))==EP_IsFalse
111734
+ if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse|EP_HasFunc))==EP_IsFalse
111666111735
&& !IN_RENAME_OBJECT
111667111736
){
111668111737
sqlite3ExprDeferredDelete(pParse, pLeft);
111669111738
sqlite3ExprDeferredDelete(pParse, pRight);
111670111739
return sqlite3Expr(db, TK_INTEGER, "0");
@@ -112940,12 +113009,15 @@
112940113009
** then compute the right operand first and do an IsNull jump if the
112941113010
** right operand evalutes to NULL.
112942113011
*/
112943113012
if( exprEvalRhsFirst(pExpr) && sqlite3ExprCanBeNull(pExpr->pRight) ){
112944113013
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2);
112945
- addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r2); VdbeCoverage(v);
113014
+ addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r2);
113015
+ VdbeComment((v, "skip left operand"));
113016
+ VdbeCoverage(v);
112946113017
}else{
113018
+ r2 = 0; /* Silence a false-positive uninit-var warning in MSVC */
112947113019
addrIsNull = 0;
112948113020
}
112949113021
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, pFree1);
112950113022
if( addrIsNull==0 ){
112951113023
/*
@@ -112955,11 +113027,13 @@
112955113027
** operand.
112956113028
*/
112957113029
if( ExprHasProperty(pExpr->pRight, EP_Subquery)
112958113030
&& sqlite3ExprCanBeNull(pExpr->pLeft)
112959113031
){
112960
- addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r1); VdbeCoverage(v);
113032
+ addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r1);
113033
+ VdbeComment((v, "skip right operand"));
113034
+ VdbeCoverage(v);
112961113035
}
112962113036
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2);
112963113037
}
112964113038
*pR1 = r1;
112965113039
*pR2 = r2;
@@ -114408,21 +114482,27 @@
114408114482
dest.eDest = SRT_Exists;
114409114483
sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
114410114484
VdbeComment((v, "Init EXISTS result"));
114411114485
}
114412114486
if( pSel->pLimit ){
114413
- /* The subquery already has a limit. If the pre-existing limit is X
114414
- ** then make the new limit X<>0 so that the new limit is either 1 or 0 */
114415
- sqlite3 *db = pParse->db;
114416
- pLimit = sqlite3Expr(db, TK_INTEGER, "0");
114417
- if( pLimit ){
114418
- pLimit->affExpr = SQLITE_AFF_NUMERIC;
114419
- pLimit = sqlite3PExpr(pParse, TK_NE,
114420
- sqlite3ExprDup(db, pSel->pLimit->pLeft, 0), pLimit);
114421
- }
114422
- sqlite3ExprDeferredDelete(pParse, pSel->pLimit->pLeft);
114423
- pSel->pLimit->pLeft = pLimit;
114487
+ /* The subquery already has a limit. If the pre-existing limit X is
114488
+ ** not already integer value 1 or 0, then make the new limit X<>0 so that
114489
+ ** the new limit is either 1 or 0 */
114490
+ Expr *pLeft = pSel->pLimit->pLeft;
114491
+ if( ExprHasProperty(pLeft, EP_IntValue)==0
114492
+ || (pLeft->u.iValue!=1 && pLeft->u.iValue!=0)
114493
+ ){
114494
+ sqlite3 *db = pParse->db;
114495
+ pLimit = sqlite3Expr(db, TK_INTEGER, "0");
114496
+ if( pLimit ){
114497
+ pLimit->affExpr = SQLITE_AFF_NUMERIC;
114498
+ pLimit = sqlite3PExpr(pParse, TK_NE,
114499
+ sqlite3ExprDup(db, pLeft, 0), pLimit);
114500
+ }
114501
+ sqlite3ExprDeferredDelete(pParse, pLeft);
114502
+ pSel->pLimit->pLeft = pLimit;
114503
+ }
114424114504
}else{
114425114505
/* If there is no pre-existing limit add a limit of 1 */
114426114506
pLimit = sqlite3Expr(pParse->db, TK_INTEGER, "1");
114427114507
pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
114428114508
}
@@ -115628,10 +115708,11 @@
115628115708
testcase( regFree2==0 );
115629115709
if( addrIsNull ){
115630115710
sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
115631115711
sqlite3VdbeJumpHere(v, addrIsNull);
115632115712
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
115713
+ VdbeComment((v, "short-circut value"));
115633115714
}
115634115715
break;
115635115716
}
115636115717
case TK_UMINUS: {
115637115718
Expr *pLeft = pExpr->pLeft;
@@ -128437,18 +128518,21 @@
128437128518
** Append the contents of SrcList p2 to SrcList p1 and return the resulting
128438128519
** SrcList. Or, if an error occurs, return NULL. In all cases, p1 and p2
128439128520
** are deleted by this function.
128440128521
*/
128441128522
SQLITE_PRIVATE SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, SrcList *p2){
128442
- assert( p1 && p1->nSrc==1 );
128523
+ assert( p1 );
128443128524
if( p2 ){
128444
- SrcList *pNew = sqlite3SrcListEnlarge(pParse, p1, p2->nSrc, 1);
128525
+ int nOld = p1->nSrc;
128526
+ SrcList *pNew = sqlite3SrcListEnlarge(pParse, p1, p2->nSrc, nOld);
128445128527
if( pNew==0 ){
128446128528
sqlite3SrcListDelete(pParse->db, p2);
128447128529
}else{
128448128530
p1 = pNew;
128449
- memcpy(&p1->a[1], p2->a, p2->nSrc*sizeof(SrcItem));
128531
+ memcpy(&p1->a[nOld], p2->a, p2->nSrc*sizeof(SrcItem));
128532
+ assert( nOld==1 || (p2->nSrc==1 && (p2->a[0].fg.jointype&JT_LTORJ)==0) );
128533
+ assert( p1->nSrc>=2 );
128450128534
sqlite3DbFree(pParse->db, p2);
128451128535
p1->a[0].fg.jointype |= (JT_LTORJ & p1->a[1].fg.jointype);
128452128536
}
128453128537
}
128454128538
return p1;
@@ -145523,11 +145607,11 @@
145523145607
SrcList *pSrc, /* Array of tables to search */
145524145608
int iStart, /* First member of pSrc->a[] to check */
145525145609
int iEnd, /* Last member of pSrc->a[] to check */
145526145610
const char *zCol, /* Name of the column we are looking for */
145527145611
int *piTab, /* Write index of pSrc->a[] here */
145528
- int *piCol, /* Write index of pSrc->a[*piTab].pTab->aCol[] here */
145612
+ int *piCol, /* Write index of pSrc->a[*piTab].pSTab->aCol[] here */
145529145613
int bIgnoreHidden /* Ignore hidden columns */
145530145614
){
145531145615
int i; /* For looping over tables in pSrc */
145532145616
int iCol; /* Index of column matching zCol */
145533145617
@@ -148175,11 +148259,13 @@
148175148259
int unionTab; /* Cursor number of the temp table holding result */
148176148260
u8 op = 0; /* One of the SRT_ operations to apply to self */
148177148261
int priorOp; /* The SRT_ operation to apply to prior selects */
148178148262
Expr *pLimit; /* Saved values of p->nLimit */
148179148263
int addr;
148264
+ int emptyBypass = 0; /* IfEmpty opcode to bypass RHS */
148180148265
SelectDest uniondest;
148266
+
148181148267
148182148268
testcase( p->op==TK_EXCEPT );
148183148269
testcase( p->op==TK_UNION );
148184148270
priorOp = SRT_Union;
148185148271
if( dest.eDest==priorOp ){
@@ -148214,10 +148300,12 @@
148214148300
148215148301
/* Code the current SELECT statement
148216148302
*/
148217148303
if( p->op==TK_EXCEPT ){
148218148304
op = SRT_Except;
148305
+ emptyBypass = sqlite3VdbeAddOp1(v, OP_IfEmpty, unionTab);
148306
+ VdbeCoverage(v);
148219148307
}else{
148220148308
assert( p->op==TK_UNION );
148221148309
op = SRT_Union;
148222148310
}
148223148311
p->pPrior = 0;
@@ -148234,10 +148322,11 @@
148234148322
p->pPrior = pPrior;
148235148323
p->pOrderBy = 0;
148236148324
if( p->op==TK_UNION ){
148237148325
p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
148238148326
}
148327
+ if( emptyBypass ) sqlite3VdbeJumpHere(v, emptyBypass);
148239148328
sqlite3ExprDelete(db, p->pLimit);
148240148329
p->pLimit = pLimit;
148241148330
p->iLimit = 0;
148242148331
p->iOffset = 0;
148243148332
@@ -148267,10 +148356,11 @@
148267148356
int iCont, iBreak, iStart;
148268148357
Expr *pLimit;
148269148358
int addr;
148270148359
SelectDest intersectdest;
148271148360
int r1;
148361
+ int emptyBypass;
148272148362
148273148363
/* INTERSECT is different from the others since it requires
148274148364
** two temporary tables. Hence it has its own case. Begin
148275148365
** by allocating the tables we will need.
148276148366
*/
@@ -148290,10 +148380,11 @@
148290148380
TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT left...\n"));
148291148381
rc = sqlite3Select(pParse, pPrior, &intersectdest);
148292148382
if( rc ){
148293148383
goto multi_select_end;
148294148384
}
148385
+ emptyBypass = sqlite3VdbeAddOp1(v, OP_IfEmpty, tab1); VdbeCoverage(v);
148295148386
148296148387
/* Code the current SELECT into temporary table "tab2"
148297148388
*/
148298148389
addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
148299148390
assert( p->addrOpenEphm[1] == -1 );
@@ -148321,11 +148412,11 @@
148321148412
if( rc ) break;
148322148413
assert( p->pEList );
148323148414
iBreak = sqlite3VdbeMakeLabel(pParse);
148324148415
iCont = sqlite3VdbeMakeLabel(pParse);
148325148416
computeLimitRegisters(pParse, p, iBreak);
148326
- sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);
148417
+ sqlite3VdbeAddOp1(v, OP_Rewind, tab1);
148327148418
r1 = sqlite3GetTempReg(pParse);
148328148419
iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
148329148420
sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
148330148421
VdbeCoverage(v);
148331148422
sqlite3ReleaseTempReg(pParse, r1);
@@ -148333,10 +148424,11 @@
148333148424
0, 0, &dest, iCont, iBreak);
148334148425
sqlite3VdbeResolveLabel(v, iCont);
148335148426
sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);
148336148427
sqlite3VdbeResolveLabel(v, iBreak);
148337148428
sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);
148429
+ sqlite3VdbeJumpHere(v, emptyBypass);
148338148430
sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);
148339148431
break;
148340148432
}
148341148433
}
148342148434
@@ -149011,10 +149103,11 @@
149011149103
typedef struct SubstContext {
149012149104
Parse *pParse; /* The parsing context */
149013149105
int iTable; /* Replace references to this table */
149014149106
int iNewTable; /* New table number */
149015149107
int isOuterJoin; /* Add TK_IF_NULL_ROW opcodes on each replacement */
149108
+ int nSelDepth; /* Depth of sub-query recursion. Top==1 */
149016149109
ExprList *pEList; /* Replacement expressions */
149017149110
ExprList *pCList; /* Collation sequences for replacement expr */
149018149111
} SubstContext;
149019149112
149020149113
/* Forward Declarations */
@@ -149117,10 +149210,13 @@
149117149210
}
149118149211
}
149119149212
}else{
149120149213
if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
149121149214
pExpr->iTable = pSubst->iNewTable;
149215
+ }
149216
+ if( pExpr->op==TK_AGG_FUNCTION && pExpr->op2>=pSubst->nSelDepth ){
149217
+ pExpr->op2--;
149122149218
}
149123149219
pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);
149124149220
pExpr->pRight = substExpr(pSubst, pExpr->pRight);
149125149221
if( ExprUseXSelect(pExpr) ){
149126149222
substSelect(pSubst, pExpr->x.pSelect, 1);
@@ -149155,10 +149251,11 @@
149155149251
){
149156149252
SrcList *pSrc;
149157149253
SrcItem *pItem;
149158149254
int i;
149159149255
if( !p ) return;
149256
+ pSubst->nSelDepth++;
149160149257
do{
149161149258
substExprList(pSubst, p->pEList);
149162149259
substExprList(pSubst, p->pGroupBy);
149163149260
substExprList(pSubst, p->pOrderBy);
149164149261
p->pHaving = substExpr(pSubst, p->pHaving);
@@ -149172,10 +149269,11 @@
149172149269
if( pItem->fg.isTabFunc ){
149173149270
substExprList(pSubst, pItem->u1.pFuncArg);
149174149271
}
149175149272
}
149176149273
}while( doPrior && (p = p->pPrior)!=0 );
149274
+ pSubst->nSelDepth--;
149177149275
}
149178149276
#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
149179149277
149180149278
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
149181149279
/*
@@ -149783,11 +149881,11 @@
149783149881
/* Defer deleting the Table object associated with the
149784149882
** subquery until code generation is
149785149883
** complete, since there may still exist Expr.pTab entries that
149786149884
** refer to the subquery even after flattening. Ticket #3346.
149787149885
**
149788
- ** pSubitem->pTab is always non-NULL by test restrictions and tests above.
149886
+ ** pSubitem->pSTab is always non-NULL by test restrictions and tests above.
149789149887
*/
149790149888
if( ALWAYS(pSubitem->pSTab!=0) ){
149791149889
Table *pTabToDel = pSubitem->pSTab;
149792149890
if( pTabToDel->nTabRef==1 ){
149793149891
Parse *pToplevel = sqlite3ParseToplevel(pParse);
@@ -149913,10 +150011,11 @@
149913150011
SubstContext x;
149914150012
x.pParse = pParse;
149915150013
x.iTable = iParent;
149916150014
x.iNewTable = iNewParent;
149917150015
x.isOuterJoin = isOuterJoin;
150016
+ x.nSelDepth = 0;
149918150017
x.pEList = pSub->pEList;
149919150018
x.pCList = findLeftmostExprlist(pSub);
149920150019
substSelect(&x, pParent, 0);
149921150020
}
149922150021
@@ -150498,10 +150597,11 @@
150498150597
unsetJoinExpr(pNew, -1, 1);
150499150598
x.pParse = pParse;
150500150599
x.iTable = pSrc->iCursor;
150501150600
x.iNewTable = pSrc->iCursor;
150502150601
x.isOuterJoin = 0;
150602
+ x.nSelDepth = 0;
150503150603
x.pEList = pSubq->pEList;
150504150604
x.pCList = findLeftmostExprlist(pSubq);
150505150605
pNew = substExpr(&x, pNew);
150506150606
#ifndef SQLITE_OMIT_WINDOWFUNC
150507150607
if( pSubq->pWin && 0==pushDownWindowCheck(pParse, pSubq, pNew) ){
@@ -150895,11 +150995,11 @@
150895150995
** a WITH clause on the stack currently maintained by the parser (on the
150896150996
** pParse->pWith linked list). And if currently processing a CTE
150897150997
** CTE expression, through routine checks to see if the reference is
150898150998
** a recursive reference to the CTE.
150899150999
**
150900
-** If pFrom matches a CTE according to either of these two above, pFrom->pTab
151000
+** If pFrom matches a CTE according to either of these two above, pFrom->pSTab
150901151001
** and other fields are populated accordingly.
150902151002
**
150903151003
** Return 0 if no match is found.
150904151004
** Return 1 if a match is found.
150905151005
** Return 2 if an error condition is detected.
@@ -152521,10 +152621,79 @@
152521152621
pItem--;
152522152622
if( pItem->fg.isSubquery ) return 0; /* (1c-i) */
152523152623
}
152524152624
return 1;
152525152625
}
152626
+
152627
+/*
152628
+** Argument pWhere is the WHERE clause belonging to SELECT statement p. This
152629
+** function attempts to transform expressions of the form:
152630
+**
152631
+** EXISTS (SELECT ...)
152632
+**
152633
+** into joins. For example, given
152634
+**
152635
+** CREATE TABLE sailors(sid INTEGER PRIMARY KEY, name TEXT);
152636
+** CREATE TABLE reserves(sid INT, day DATE, PRIMARY KEY(sid, day));
152637
+**
152638
+** SELECT name FROM sailors AS S WHERE EXISTS (
152639
+** SELECT * FROM reserves AS R WHERE S.sid = R.sid AND R.day = '2022-10-25'
152640
+** );
152641
+**
152642
+** the SELECT statement may be transformed as follows:
152643
+**
152644
+** SELECT name FROM sailors AS S, reserves AS R
152645
+** WHERE S.sid = R.sid AND R.day = '2022-10-25';
152646
+*/
152647
+static SQLITE_NOINLINE void existsToJoin(
152648
+ Parse *pParse,
152649
+ Select *p,
152650
+ Expr *pWhere
152651
+){
152652
+ if( pWhere
152653
+ && !ExprHasProperty(pWhere, EP_OuterON|EP_InnerON)
152654
+ && p->pSrc->nSrc>0
152655
+ && p->pSrc->nSrc<BMS
152656
+ && pParse->db->mallocFailed==0
152657
+ ){
152658
+ if( pWhere->op==TK_AND ){
152659
+ Expr *pRight = pWhere->pRight;
152660
+ existsToJoin(pParse, p, pWhere->pLeft);
152661
+ existsToJoin(pParse, p, pRight);
152662
+ }
152663
+ else if( pWhere->op==TK_EXISTS ){
152664
+ Select *pSub = pWhere->x.pSelect;
152665
+ if( pSub->pSrc->nSrc==1
152666
+ && (pSub->selFlags & SF_Aggregate)==0
152667
+ && pSub->pWhere
152668
+ && !pSub->pSrc->a[0].fg.isSubquery
152669
+ ){
152670
+ memset(pWhere, 0, sizeof(*pWhere));
152671
+ pWhere->op = TK_INTEGER;
152672
+ pWhere->u.iValue = 1;
152673
+ ExprSetProperty(pWhere, EP_IntValue);
152674
+
152675
+ assert( p->pWhere!=0 );
152676
+ pSub->pSrc->a[0].fg.fromExists = 1;
152677
+ pSub->pSrc->a[0].fg.jointype |= JT_CROSS;
152678
+ p->pSrc = sqlite3SrcListAppendList(pParse, p->pSrc, pSub->pSrc);
152679
+ p->pWhere = sqlite3PExpr(pParse, TK_AND, p->pWhere, pSub->pWhere);
152680
+
152681
+ pSub->pWhere = 0;
152682
+ pSub->pSrc = 0;
152683
+ sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pSub);
152684
+#if TREETRACE_ENABLED
152685
+ if( sqlite3TreeTrace & 0x100000 ){
152686
+ TREETRACE(0x100000,pParse,p,
152687
+ ("After EXISTS-to-JOIN optimization:\n"));
152688
+ sqlite3TreeViewSelect(0, p, 0);
152689
+ }
152690
+#endif
152691
+ }
152692
+ }
152693
+ }
152694
+}
152526152695
152527152696
/*
152528152697
** Generate byte-code for the SELECT statement given in the p argument.
152529152698
**
152530152699
** The results are returned according to the SelectDest structure.
@@ -152889,10 +153058,17 @@
152889153058
#endif
152890153059
if( p->pNext==0 ) ExplainQueryPlanPop(pParse);
152891153060
return rc;
152892153061
}
152893153062
#endif
153063
+
153064
+ /* If there may be an "EXISTS (SELECT ...)" in the WHERE clause, attempt
153065
+ ** to change it into a join. */
153066
+ if( pParse->bHasExists && OptimizationEnabled(db,SQLITE_ExistsToJoin) ){
153067
+ existsToJoin(pParse, p, p->pWhere);
153068
+ pTabList = p->pSrc;
153069
+ }
152894153070
152895153071
/* Do the WHERE-clause constant propagation optimization if this is
152896153072
** a join. No need to spend time on this operation for non-join queries
152897153073
** as the equivalent optimization will be handled by query planner in
152898153074
** sqlite3WhereBegin(). tag-select-0330
@@ -153676,24 +153852,24 @@
153676153852
** over to a0,a1,a2. It then calls the output subroutine
153677153853
** and resets the aggregate accumulator registers in preparation
153678153854
** for the next GROUP BY batch.
153679153855
*/
153680153856
sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
153681
- VdbeComment((v, "output one row"));
153857
+ VdbeComment((v, "output one row of %d", p->selId));
153682153858
sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr);
153683153859
sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); VdbeCoverage(v);
153684153860
VdbeComment((v, "check abort flag"));
153685153861
sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
153686
- VdbeComment((v, "reset accumulator"));
153862
+ VdbeComment((v, "reset accumulator %d", p->selId));
153687153863
153688153864
/* Update the aggregate accumulators based on the content of
153689153865
** the current row
153690153866
*/
153691153867
sqlite3VdbeJumpHere(v, addr1);
153692153868
updateAccumulator(pParse, iUseFlag, pAggInfo, eDist);
153693153869
sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);
153694
- VdbeComment((v, "indicate data in accumulator"));
153870
+ VdbeComment((v, "indicate data in accumulator %d", p->selId));
153695153871
153696153872
/* End of the loop
153697153873
*/
153698153874
if( groupBySort ){
153699153875
sqlite3VdbeAddOp2(v, OP_SorterNext, pAggInfo->sortingIdx,addrTopOfLoop);
@@ -153706,11 +153882,11 @@
153706153882
sqlite3ExprListDelete(db, pDistinct);
153707153883
153708153884
/* Output the final row of result
153709153885
*/
153710153886
sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
153711
- VdbeComment((v, "output final row"));
153887
+ VdbeComment((v, "output final row of %d", p->selId));
153712153888
153713153889
/* Jump over the subroutines
153714153890
*/
153715153891
sqlite3VdbeGoto(v, addrEnd);
153716153892
@@ -153727,26 +153903,26 @@
153727153903
sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
153728153904
sqlite3VdbeResolveLabel(v, addrOutputRow);
153729153905
addrOutputRow = sqlite3VdbeCurrentAddr(v);
153730153906
sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow+2);
153731153907
VdbeCoverage(v);
153732
- VdbeComment((v, "Groupby result generator entry point"));
153908
+ VdbeComment((v, "Groupby result generator entry point %d", p->selId));
153733153909
sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
153734153910
finalizeAggFunctions(pParse, pAggInfo);
153735153911
sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);
153736153912
selectInnerLoop(pParse, p, -1, &sSort,
153737153913
&sDistinct, pDest,
153738153914
addrOutputRow+1, addrSetAbort);
153739153915
sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
153740
- VdbeComment((v, "end groupby result generator"));
153916
+ VdbeComment((v, "end groupby result generator %d", p->selId));
153741153917
153742153918
/* Generate a subroutine that will reset the group-by accumulator
153743153919
*/
153744153920
sqlite3VdbeResolveLabel(v, addrReset);
153745153921
resetAccumulator(pParse, pAggInfo);
153746153922
sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);
153747
- VdbeComment((v, "indicate accumulator empty"));
153923
+ VdbeComment((v, "indicate accumulator %d empty", p->selId));
153748153924
sqlite3VdbeAddOp1(v, OP_Return, regReset);
153749153925
153750153926
if( distFlag!=0 && eDist!=WHERE_DISTINCT_NOOP ){
153751153927
struct AggInfo_func *pF = &pAggInfo->aFunc[0];
153752153928
fixDistinctOpenEph(pParse, eDist, pF->iDistinct, pF->iDistAddr);
@@ -159334,10 +159510,11 @@
159334159510
struct WhereLevel {
159335159511
int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
159336159512
int iTabCur; /* The VDBE cursor used to access the table */
159337159513
int iIdxCur; /* The VDBE cursor used to access pIdx */
159338159514
int addrBrk; /* Jump here to break out of the loop */
159515
+ int addrHalt; /* Abort the query due to empty table or similar */
159339159516
int addrNxt; /* Jump here to start the next IN combination */
159340159517
int addrSkip; /* Jump here for next iteration of skip-scan */
159341159518
int addrCont; /* Jump here to continue with the next loop cycle */
159342159519
int addrFirst; /* First instruction of interior of the loop */
159343159520
int addrBody; /* Beginning of the body of this loop */
@@ -160043,10 +160220,11 @@
160043160220
WhereLoop *pLoop; /* The controlling WhereLoop object */
160044160221
u32 flags; /* Flags that describe this loop */
160045160222
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)
160046160223
char *zMsg; /* Text to add to EQP output */
160047160224
#endif
160225
+ const char *zFormat;
160048160226
StrAccum str; /* EQP output string */
160049160227
char zBuf[100]; /* Initial space for EQP output string */
160050160228
160051160229
if( db->mallocFailed ) return;
160052160230
@@ -160057,11 +160235,18 @@
160057160235
|| ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
160058160236
|| (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
160059160237
160060160238
sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
160061160239
str.printfFlags = SQLITE_PRINTF_INTERNAL;
160062
- sqlite3_str_appendf(&str, "%s %S", isSearch ? "SEARCH" : "SCAN", pItem);
160240
+ if( pItem->fg.fromExists ){
160241
+ zFormat = "SINGLETON %S";
160242
+ }else if( isSearch ){
160243
+ zFormat = "SEARCH %S";
160244
+ }else{
160245
+ zFormat = "SCAN %S";
160246
+ }
160247
+ sqlite3_str_appendf(&str, zFormat, pItem);
160063160248
if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){
160064160249
const char *zFmt = 0;
160065160250
Index *pIdx;
160066160251
160067160252
assert( pLoop->u.btree.pIndex!=0 );
@@ -161308,19 +161493,20 @@
161308161493
WhereInfo *pWInfo, /* Complete information about the WHERE clause */
161309161494
int iLevel, /* Which level of pWInfo->a[] should be coded */
161310161495
int addrNxt, /* Jump here to bypass inner loops */
161311161496
Bitmask notReady /* Loops that are not ready */
161312161497
){
161498
+ int saved_addrBrk;
161313161499
while( ++iLevel < pWInfo->nLevel ){
161314161500
WhereLevel *pLevel = &pWInfo->a[iLevel];
161315161501
WhereLoop *pLoop = pLevel->pWLoop;
161316161502
if( pLevel->regFilter==0 ) continue;
161317161503
if( pLevel->pWLoop->nSkip ) continue;
161318161504
/* ,--- Because sqlite3ConstructBloomFilter() has will not have set
161319161505
** vvvvv--' pLevel->regFilter if this were true. */
161320161506
if( NEVER(pLoop->prereq & notReady) ) continue;
161321
- assert( pLevel->addrBrk==0 );
161507
+ saved_addrBrk = pLevel->addrBrk;
161322161508
pLevel->addrBrk = addrNxt;
161323161509
if( pLoop->wsFlags & WHERE_IPK ){
161324161510
WhereTerm *pTerm = pLoop->aLTerm[0];
161325161511
int regRowid;
161326161512
assert( pTerm!=0 );
@@ -161346,11 +161532,11 @@
161346161532
sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
161347161533
addrNxt, r1, nEq);
161348161534
VdbeCoverage(pParse->pVdbe);
161349161535
}
161350161536
pLevel->regFilter = 0;
161351
- pLevel->addrBrk = 0;
161537
+ pLevel->addrBrk = saved_addrBrk;
161352161538
}
161353161539
}
161354161540
161355161541
/*
161356161542
** Loop pLoop is a WHERE_INDEXED level that uses at least one IN(...)
@@ -161393,11 +161579,10 @@
161393161579
WhereClause *pWC; /* Decomposition of the entire WHERE clause */
161394161580
WhereTerm *pTerm; /* A WHERE clause term */
161395161581
sqlite3 *db; /* Database connection */
161396161582
SrcItem *pTabItem; /* FROM clause term being coded */
161397161583
int addrBrk; /* Jump here to break out of the loop */
161398
- int addrHalt; /* addrBrk for the outermost loop */
161399161584
int addrCont; /* Jump here to continue with next cycle */
161400161585
int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
161401161586
int iReleaseReg = 0; /* Temp register to free before returning */
161402161587
Index *pIdx = 0; /* Index used by loop (if any) */
161403161588
int iLoop; /* Iteration of constraint generator loop */
@@ -161437,11 +161622,11 @@
161437161622
** When there is an IN operator, we also have a "addrNxt" label that
161438161623
** means to continue with the next IN value combination. When
161439161624
** there are no IN operators in the constraints, the "addrNxt" label
161440161625
** is the same as "addrBrk".
161441161626
*/
161442
- addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
161627
+ addrBrk = pLevel->addrNxt = pLevel->addrBrk;
161443161628
addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(pParse);
161444161629
161445161630
/* If this is the right table of a LEFT OUTER JOIN, allocate and
161446161631
** initialize a memory cell that records if this table matches any
161447161632
** row of the left table of the join.
@@ -161453,18 +161638,10 @@
161453161638
pLevel->iLeftJoin = ++pParse->nMem;
161454161639
sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
161455161640
VdbeComment((v, "init LEFT JOIN match flag"));
161456161641
}
161457161642
161458
- /* Compute a safe address to jump to if we discover that the table for
161459
- ** this loop is empty and can never contribute content. */
161460
- for(j=iLevel; j>0; j--){
161461
- if( pWInfo->a[j].iLeftJoin ) break;
161462
- if( pWInfo->a[j].pRJ ) break;
161463
- }
161464
- addrHalt = pWInfo->a[j].addrBrk;
161465
-
161466161643
/* Special case of a FROM clause subquery implemented as a co-routine */
161467161644
if( pTabItem->fg.viaCoroutine ){
161468161645
int regYield;
161469161646
Subquery *pSubq;
161470161647
assert( pTabItem->fg.isSubquery && pTabItem->u4.pSubq!=0 );
@@ -161699,11 +161876,11 @@
161699161876
VdbeCoverageIf(v, pX->op==TK_LE);
161700161877
VdbeCoverageIf(v, pX->op==TK_LT);
161701161878
VdbeCoverageIf(v, pX->op==TK_GE);
161702161879
sqlite3ReleaseTempReg(pParse, rTemp);
161703161880
}else{
161704
- sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt);
161881
+ sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, pLevel->addrHalt);
161705161882
VdbeCoverageIf(v, bRev==0);
161706161883
VdbeCoverageIf(v, bRev!=0);
161707161884
}
161708161885
if( pEnd ){
161709161886
Expr *pX;
@@ -162494,11 +162671,11 @@
162494162671
pLevel->op = OP_Noop;
162495162672
}else{
162496162673
codeCursorHint(pTabItem, pWInfo, pLevel, 0);
162497162674
pLevel->op = aStep[bRev];
162498162675
pLevel->p1 = iCur;
162499
- pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrHalt);
162676
+ pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev],iCur,pLevel->addrHalt);
162500162677
VdbeCoverageIf(v, bRev==0);
162501162678
VdbeCoverageIf(v, bRev!=0);
162502162679
pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
162503162680
}
162504162681
}
@@ -164509,11 +164686,11 @@
164509164686
** SELECT statement passed as the second argument. These terms are only
164510164687
** added if:
164511164688
**
164512164689
** 1. The SELECT statement has a LIMIT clause, and
164513164690
** 2. The SELECT statement is not an aggregate or DISTINCT query, and
164514
-** 3. The SELECT statement has exactly one object in its from clause, and
164691
+** 3. The SELECT statement has exactly one object in its FROM clause, and
164515164692
** that object is a virtual table, and
164516164693
** 4. There are no terms in the WHERE clause that will not be passed
164517164694
** to the virtual table xBestIndex method.
164518164695
** 5. The ORDER BY clause, if any, will be made available to the xBestIndex
164519164696
** method.
@@ -164546,12 +164723,26 @@
164546164723
** pWC->a[] array. So this term can be ignored, as a LIMIT clause
164547164724
** will only be added if each of the child terms passes the
164548164725
** (leftCursor==iCsr) test below. */
164549164726
continue;
164550164727
}
164551
- if( pWC->a[ii].leftCursor!=iCsr ) return;
164552
- if( pWC->a[ii].prereqRight!=0 ) return;
164728
+ if( pWC->a[ii].leftCursor==iCsr && pWC->a[ii].prereqRight==0 ) continue;
164729
+
164730
+ /* If this term has a parent with exactly one child, and the parent will
164731
+ ** be passed through to xBestIndex, then this term can be ignored. */
164732
+ if( pWC->a[ii].iParent>=0 ){
164733
+ WhereTerm *pParent = &pWC->a[ pWC->a[ii].iParent ];
164734
+ if( pParent->leftCursor==iCsr
164735
+ && pParent->prereqRight==0
164736
+ && pParent->nChild==1
164737
+ ){
164738
+ continue;
164739
+ }
164740
+ }
164741
+
164742
+ /* This term will not be passed through. Do not add a LIMIT clause. */
164743
+ return;
164553164744
}
164554164745
164555164746
/* Check condition (5). Return early if it is not met. */
164556164747
if( pOrderBy ){
164557164748
for(ii=0; ii<pOrderBy->nExpr; ii++){
@@ -165986,11 +166177,13 @@
165986166177
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSubq->addrFillSub);
165987166178
addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield);
165988166179
VdbeCoverage(v);
165989166180
VdbeComment((v, "next row of %s", pSrc->pSTab->zName));
165990166181
}else{
165991
- addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);
166182
+ assert( pLevel->addrHalt );
166183
+ addrTop = sqlite3VdbeAddOp2(v, OP_Rewind,pLevel->iTabCur,pLevel->addrHalt);
166184
+ VdbeCoverage(v);
165992166185
}
165993166186
if( pPartial ){
165994166187
iContinue = sqlite3VdbeMakeLabel(pParse);
165995166188
sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);
165996166189
pLoop->wsFlags |= WHERE_PARTIALIDX;
@@ -166014,15 +166207,18 @@
166014166207
assert( pLevel->iIdxCur>0 );
166015166208
translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
166016166209
pSrc->u4.pSubq->regResult, pLevel->iIdxCur);
166017166210
sqlite3VdbeGoto(v, addrTop);
166018166211
pSrc->fg.viaCoroutine = 0;
166212
+ sqlite3VdbeJumpHere(v, addrTop);
166019166213
}else{
166020166214
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
166021166215
sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
166216
+ if( (pSrc->fg.jointype & JT_LEFT)!=0 ){
166217
+ sqlite3VdbeJumpHere(v, addrTop);
166218
+ }
166022166219
}
166023
- sqlite3VdbeJumpHere(v, addrTop);
166024166220
sqlite3ReleaseTempReg(pParse, regRecord);
166025166221
166026166222
/* Jump here when skipping the initialization */
166027166223
sqlite3VdbeJumpHere(v, addrInit);
166028166224
sqlite3VdbeScanStatusRange(v, addrExp, addrExp, -1);
@@ -168298,10 +168494,11 @@
168298168494
&& saved_nEq==pNew->nLTerm
168299168495
&& pProbe->noSkipScan==0
168300168496
&& pProbe->hasStat1!=0
168301168497
&& OptimizationEnabled(db, SQLITE_SkipScan)
168302168498
&& pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
168499
+ && pSrc->fg.fromExists==0
168303168500
&& (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
168304168501
){
168305168502
LogEst nIter;
168306168503
pNew->u.btree.nEq++;
168307168504
pNew->nSkip++;
@@ -171855,10 +172052,18 @@
171855172052
171856172053
pTabItem = &pTabList->a[pLevel->iFrom];
171857172054
pTab = pTabItem->pSTab;
171858172055
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
171859172056
pLoop = pLevel->pWLoop;
172057
+ pLevel->addrBrk = sqlite3VdbeMakeLabel(pParse);
172058
+ if( ii==0 || (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
172059
+ pLevel->addrHalt = pLevel->addrBrk;
172060
+ }else if( pWInfo->a[ii-1].pRJ ){
172061
+ pLevel->addrHalt = pWInfo->a[ii-1].addrBrk;
172062
+ }else{
172063
+ pLevel->addrHalt = pWInfo->a[ii-1].addrHalt;
172064
+ }
171860172065
if( (pTab->tabFlags & TF_Ephemeral)!=0 || IsView(pTab) ){
171861172066
/* Do nothing */
171862172067
}else
171863172068
#ifndef SQLITE_OMIT_VIRTUALTABLE
171864172069
if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){
@@ -171906,10 +172111,17 @@
171906172111
}
171907172112
#ifdef SQLITE_ENABLE_COLUMN_USED_MASK
171908172113
sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, pTabItem->iCursor, 0, 0,
171909172114
(const u8*)&pTabItem->colUsed, P4_INT64);
171910172115
#endif
172116
+ if( ii>=2
172117
+ && (pTabItem[0].fg.jointype & (JT_LTORJ|JT_LEFT))==0
172118
+ && pLevel->addrHalt==pWInfo->a[0].addrHalt
172119
+ ){
172120
+ sqlite3VdbeAddOp2(v, OP_IfEmpty, pTabItem->iCursor, pWInfo->iBreak);
172121
+ VdbeCoverage(v);
172122
+ }
171911172123
}else{
171912172124
sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
171913172125
}
171914172126
if( pLoop->wsFlags & WHERE_INDEXED ){
171915172127
Index *pIx = pLoop->u.btree.pIndex;
@@ -172162,10 +172374,13 @@
172162172374
VdbeCoverageIf(v, op==OP_SeekLT);
172163172375
VdbeCoverageIf(v, op==OP_SeekGT);
172164172376
sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);
172165172377
}
172166172378
#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
172379
+ if( pTabList->a[pLevel->iFrom].fg.fromExists ){
172380
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
172381
+ }
172167172382
/* The common case: Advance to the next row */
172168172383
if( pLevel->addrCont ) sqlite3VdbeResolveLabel(v, pLevel->addrCont);
172169172384
sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3);
172170172385
sqlite3VdbeChangeP5(v, pLevel->p5);
172171172386
VdbeCoverage(v);
@@ -180234,16 +180449,25 @@
180234180449
/* Expressions of the form
180235180450
**
180236180451
** expr1 IN ()
180237180452
** expr1 NOT IN ()
180238180453
**
180239
- ** simplify to constants 0 (false) and 1 (true), respectively,
180240
- ** regardless of the value of expr1.
180454
+ ** simplify to constants 0 (false) and 1 (true), respectively.
180455
+ **
180456
+ ** Except, do not apply this optimization if expr1 contains a function
180457
+ ** because that function might be an aggregate (we don't know yet whether
180458
+ ** it is or not) and if it is an aggregate, that could change the meaning
180459
+ ** of the whole query.
180241180460
*/
180242
- sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy590);
180243
- yymsp[-4].minor.yy590 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy502 ? "true" : "false");
180244
- if( yymsp[-4].minor.yy590 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy590);
180461
+ Expr *pB = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy502 ? "true" : "false");
180462
+ if( pB ) sqlite3ExprIdToTrueFalse(pB);
180463
+ if( !ExprHasProperty(yymsp[-4].minor.yy590, EP_HasFunc) ){
180464
+ sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy590);
180465
+ yymsp[-4].minor.yy590 = pB;
180466
+ }else{
180467
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_OR : TK_AND, pB, yymsp[-4].minor.yy590);
180468
+ }
180245180469
}else{
180246180470
Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
180247180471
if( yymsp[-1].minor.yy402->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy590->op!=TK_VECTOR ){
180248180472
yymsp[-1].minor.yy402->a[0].pExpr = 0;
180249180473
sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
@@ -247032,22 +247256,24 @@
247032247256
if( pLast ){
247033247257
int iOff;
247034247258
fts5DataRelease(pIter->pLeaf);
247035247259
pIter->pLeaf = pLast;
247036247260
pIter->iLeafPgno = pgnoLast;
247037
- iOff = fts5LeafFirstRowidOff(pLast);
247038
- if( iOff>pLast->szLeaf ){
247039
- FTS5_CORRUPT_ITER(p, pIter);
247040
- return;
247041
- }
247042
- iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid);
247043
- pIter->iLeafOffset = iOff;
247044
-
247045
- if( fts5LeafIsTermless(pLast) ){
247046
- pIter->iEndofDoclist = pLast->nn+1;
247047
- }else{
247048
- pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast);
247261
+ if( p->rc==SQLITE_OK ){
247262
+ iOff = fts5LeafFirstRowidOff(pLast);
247263
+ if( iOff>pLast->szLeaf ){
247264
+ FTS5_CORRUPT_ITER(p, pIter);
247265
+ return;
247266
+ }
247267
+ iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid);
247268
+ pIter->iLeafOffset = iOff;
247269
+
247270
+ if( fts5LeafIsTermless(pLast) ){
247271
+ pIter->iEndofDoclist = pLast->nn+1;
247272
+ }else{
247273
+ pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast);
247274
+ }
247049247275
}
247050247276
}
247051247277
247052247278
fts5SegIterReverseInitPage(p, pIter);
247053247279
}
@@ -250396,11 +250622,11 @@
250396250622
}
250397250623
assert( pStruct->aLevel[i].nMerge<=nThis );
250398250624
}
250399250625
250400250626
nByte += (((i64)pStruct->nLevel)+1) * sizeof(Fts5StructureLevel);
250401
- assert( nByte==SZ_FTS5STRUCTURE(pStruct->nLevel+2) );
250627
+ assert( nByte==(i64)SZ_FTS5STRUCTURE(pStruct->nLevel+2) );
250402250628
pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);
250403250629
250404250630
if( pNew ){
250405250631
Fts5StructureLevel *pLvl;
250406250632
nByte = nSeg * sizeof(Fts5StructureSegment);
@@ -257648,11 +257874,11 @@
257648257874
int nArg, /* Number of args */
257649257875
sqlite3_value **apUnused /* Function arguments */
257650257876
){
257651257877
assert( nArg==0 );
257652257878
UNUSED_PARAM2(nArg, apUnused);
257653
- sqlite3_result_text(pCtx, "fts5: 2025-06-30 16:41:40 0083d5169a46104a25355bdd9d5a2f4027b049191ebda571dd228477ec217296", -1, SQLITE_TRANSIENT);
257879
+ sqlite3_result_text(pCtx, "fts5: 2025-07-04 14:24:18 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b", -1, SQLITE_TRANSIENT);
257654257880
}
257655257881
257656257882
/*
257657257883
** Implementation of fts5_locale(LOCALE, TEXT) function.
257658257884
**
257659257885
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 0083d5169a46104a25355bdd9d5a2f4027b0 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466 ** [sqlite_version()] and [sqlite_source_id()].
467 */
468 #define SQLITE_VERSION "3.51.0"
469 #define SQLITE_VERSION_NUMBER 3051000
470 #define SQLITE_SOURCE_ID "2025-06-30 16:41:40 0083d5169a46104a25355bdd9d5a2f4027b049191ebda571dd228477ec217296"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -15565,10 +15565,11 @@
15565 ** 0x00010000 Beginning of DELETE/INSERT/UPDATE processing
15566 ** 0x00020000 Transform DISTINCT into GROUP BY
15567 ** 0x00040000 SELECT tree dump after all code has been generated
15568 ** 0x00080000 NOT NULL strength reduction
15569 ** 0x00100000 Pointers are all shown as zero
 
15570 */
15571
15572 /*
15573 ** Macros for "wheretrace"
15574 */
@@ -16750,10 +16751,11 @@
16750 };
16751
16752 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
16753 int flags, int seekResult);
16754 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
 
16755 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
16756 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
16757 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
16758 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
16759 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
@@ -17083,76 +17085,76 @@
17083 #define OP_Last 32 /* jump0 */
17084 #define OP_IfSizeBetween 33 /* jump */
17085 #define OP_SorterSort 34 /* jump */
17086 #define OP_Sort 35 /* jump */
17087 #define OP_Rewind 36 /* jump0 */
17088 #define OP_SorterNext 37 /* jump */
17089 #define OP_Prev 38 /* jump */
17090 #define OP_Next 39 /* jump */
17091 #define OP_IdxLE 40 /* jump, synopsis: key=r[P3@P4] */
17092 #define OP_IdxGT 41 /* jump, synopsis: key=r[P3@P4] */
17093 #define OP_IdxLT 42 /* jump, synopsis: key=r[P3@P4] */
17094 #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
17095 #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
17096 #define OP_IdxGE 45 /* jump, synopsis: key=r[P3@P4] */
17097 #define OP_RowSetRead 46 /* jump, synopsis: r[P3]=rowset(P1) */
17098 #define OP_RowSetTest 47 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
17099 #define OP_Program 48 /* jump0 */
17100 #define OP_FkIfZero 49 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
17101 #define OP_IfPos 50 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
17102 #define OP_IsNull 51 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
17103 #define OP_NotNull 52 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
17104 #define OP_Ne 53 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
17105 #define OP_Eq 54 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
17106 #define OP_Gt 55 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
17107 #define OP_Le 56 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
17108 #define OP_Lt 57 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
17109 #define OP_Ge 58 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
17110 #define OP_ElseEq 59 /* jump, same as TK_ESCAPE */
17111 #define OP_IfNotZero 60 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
17112 #define OP_DecrJumpZero 61 /* jump, synopsis: if (--r[P1])==0 goto P2 */
17113 #define OP_IncrVacuum 62 /* jump */
17114 #define OP_VNext 63 /* jump */
17115 #define OP_Filter 64 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
17116 #define OP_PureFunc 65 /* synopsis: r[P3]=func(r[P2@NP]) */
17117 #define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */
17118 #define OP_Return 67
17119 #define OP_EndCoroutine 68
17120 #define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */
17121 #define OP_Halt 70
17122 #define OP_Integer 71 /* synopsis: r[P2]=P1 */
17123 #define OP_Int64 72 /* synopsis: r[P2]=P4 */
17124 #define OP_String 73 /* synopsis: r[P2]='P4' (len=P1) */
17125 #define OP_BeginSubrtn 74 /* synopsis: r[P2]=NULL */
17126 #define OP_Null 75 /* synopsis: r[P2..P3]=NULL */
17127 #define OP_SoftNull 76 /* synopsis: r[P1]=NULL */
17128 #define OP_Blob 77 /* synopsis: r[P2]=P4 (len=P1) */
17129 #define OP_Variable 78 /* synopsis: r[P2]=parameter(P1) */
17130 #define OP_Move 79 /* synopsis: r[P2@P3]=r[P1@P3] */
17131 #define OP_Copy 80 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
17132 #define OP_SCopy 81 /* synopsis: r[P2]=r[P1] */
17133 #define OP_IntCopy 82 /* synopsis: r[P2]=r[P1] */
17134 #define OP_FkCheck 83
17135 #define OP_ResultRow 84 /* synopsis: output=r[P1@P2] */
17136 #define OP_CollSeq 85
17137 #define OP_AddImm 86 /* synopsis: r[P1]=r[P1]+P2 */
17138 #define OP_RealAffinity 87
17139 #define OP_Cast 88 /* synopsis: affinity(r[P1]) */
17140 #define OP_Permutation 89
17141 #define OP_Compare 90 /* synopsis: r[P1@P3] <-> r[P2@P3] */
17142 #define OP_IsTrue 91 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
17143 #define OP_ZeroOrNull 92 /* synopsis: r[P2] = 0 OR NULL */
17144 #define OP_Offset 93 /* synopsis: r[P3] = sqlite_offset(P1) */
17145 #define OP_Column 94 /* synopsis: r[P3]=PX cursor P1 column P2 */
17146 #define OP_TypeCheck 95 /* synopsis: typecheck(r[P1@P2]) */
17147 #define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */
17148 #define OP_MakeRecord 97 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
17149 #define OP_Count 98 /* synopsis: r[P2]=count() */
17150 #define OP_ReadCookie 99
17151 #define OP_SetCookie 100
17152 #define OP_ReopenIdx 101 /* synopsis: root=P2 iDb=P3 */
17153 #define OP_OpenRead 102 /* synopsis: root=P2 iDb=P3 */
17154 #define OP_BitAnd 103 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
17155 #define OP_BitOr 104 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
17156 #define OP_ShiftLeft 105 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
17157 #define OP_ShiftRight 106 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
17158 #define OP_Add 107 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -17159,87 +17161,88 @@
17159 #define OP_Subtract 108 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
17160 #define OP_Multiply 109 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
17161 #define OP_Divide 110 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
17162 #define OP_Remainder 111 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
17163 #define OP_Concat 112 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
17164 #define OP_OpenWrite 113 /* synopsis: root=P2 iDb=P3 */
17165 #define OP_OpenDup 114
17166 #define OP_BitNot 115 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
17167 #define OP_OpenAutoindex 116 /* synopsis: nColumn=P2 */
17168 #define OP_OpenEphemeral 117 /* synopsis: nColumn=P2 */
17169 #define OP_String8 118 /* same as TK_STRING, synopsis: r[P2]='P4' */
17170 #define OP_SorterOpen 119
17171 #define OP_SequenceTest 120 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
17172 #define OP_OpenPseudo 121 /* synopsis: P3 columns in r[P2] */
17173 #define OP_Close 122
17174 #define OP_ColumnsUsed 123
17175 #define OP_SeekScan 124 /* synopsis: Scan-ahead up to P1 rows */
17176 #define OP_SeekHit 125 /* synopsis: set P2<=seekHit<=P3 */
17177 #define OP_Sequence 126 /* synopsis: r[P2]=cursor[P1].ctr++ */
17178 #define OP_NewRowid 127 /* synopsis: r[P2]=rowid */
17179 #define OP_Insert 128 /* synopsis: intkey=r[P3] data=r[P2] */
17180 #define OP_RowCell 129
17181 #define OP_Delete 130
17182 #define OP_ResetCount 131
17183 #define OP_SorterCompare 132 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
17184 #define OP_SorterData 133 /* synopsis: r[P2]=data */
17185 #define OP_RowData 134 /* synopsis: r[P2]=data */
17186 #define OP_Rowid 135 /* synopsis: r[P2]=PX rowid of P1 */
17187 #define OP_NullRow 136
17188 #define OP_SeekEnd 137
17189 #define OP_IdxInsert 138 /* synopsis: key=r[P2] */
17190 #define OP_SorterInsert 139 /* synopsis: key=r[P2] */
17191 #define OP_IdxDelete 140 /* synopsis: key=r[P2@P3] */
17192 #define OP_DeferredSeek 141 /* synopsis: Move P3 to P1.rowid if needed */
17193 #define OP_IdxRowid 142 /* synopsis: r[P2]=rowid */
17194 #define OP_FinishSeek 143
17195 #define OP_Destroy 144
17196 #define OP_Clear 145
17197 #define OP_ResetSorter 146
17198 #define OP_CreateBtree 147 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
17199 #define OP_SqlExec 148
17200 #define OP_ParseSchema 149
17201 #define OP_LoadAnalysis 150
17202 #define OP_DropTable 151
17203 #define OP_DropIndex 152
17204 #define OP_DropTrigger 153
17205 #define OP_Real 154 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
17206 #define OP_IntegrityCk 155
17207 #define OP_RowSetAdd 156 /* synopsis: rowset(P1)=r[P2] */
17208 #define OP_Param 157
17209 #define OP_FkCounter 158 /* synopsis: fkctr[P1]+=P2 */
17210 #define OP_MemMax 159 /* synopsis: r[P1]=max(r[P1],r[P2]) */
17211 #define OP_OffsetLimit 160 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
17212 #define OP_AggInverse 161 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
17213 #define OP_AggStep 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17214 #define OP_AggStep1 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17215 #define OP_AggValue 164 /* synopsis: r[P3]=value N=P2 */
17216 #define OP_AggFinal 165 /* synopsis: accum=r[P1] N=P2 */
17217 #define OP_Expire 166
17218 #define OP_CursorLock 167
17219 #define OP_CursorUnlock 168
17220 #define OP_TableLock 169 /* synopsis: iDb=P1 root=P2 write=P3 */
17221 #define OP_VBegin 170
17222 #define OP_VCreate 171
17223 #define OP_VDestroy 172
17224 #define OP_VOpen 173
17225 #define OP_VCheck 174
17226 #define OP_VInitIn 175 /* synopsis: r[P2]=ValueList(P1,P3) */
17227 #define OP_VColumn 176 /* synopsis: r[P3]=vcolumn(P2) */
17228 #define OP_VRename 177
17229 #define OP_Pagecount 178
17230 #define OP_MaxPgcnt 179
17231 #define OP_ClrSubtype 180 /* synopsis: r[P1].subtype = 0 */
17232 #define OP_GetSubtype 181 /* synopsis: r[P2] = r[P1].subtype */
17233 #define OP_SetSubtype 182 /* synopsis: r[P2].subtype = r[P1] */
17234 #define OP_FilterAdd 183 /* synopsis: filter(P1) += key(P3@P4) */
17235 #define OP_Trace 184
17236 #define OP_CursorHint 185
17237 #define OP_ReleaseReg 186 /* synopsis: release r[P1@P2] mask P3 */
17238 #define OP_Noop 187
17239 #define OP_Explain 188
17240 #define OP_Abortable 189
 
17241
17242 /* Properties such as "out2" or "jump" that are specified in
17243 ** comments following the "case" for each opcode in the vdbe.c
17244 ** are encoded into bitvectors as follows:
17245 */
@@ -17254,38 +17257,38 @@
17254 #define OPFLG_INITIALIZER {\
17255 /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\
17256 /* 8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\
17257 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\
17258 /* 24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\
17259 /* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x41, 0x41,\
17260 /* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x23, 0x0b,\
17261 /* 48 */ 0x81, 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\
17262 /* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x41,\
17263 /* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
17264 /* 72 */ 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00,\
17265 /* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02,\
17266 /* 88 */ 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40, 0x00,\
17267 /* 96 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x40, 0x26,\
17268 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
17269 /* 112 */ 0x26, 0x00, 0x40, 0x12, 0x40, 0x40, 0x10, 0x00,\
17270 /* 120 */ 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10, 0x10,\
17271 /* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x50,\
17272 /* 136 */ 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50, 0x40,\
17273 /* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
17274 /* 152 */ 0x00, 0x00, 0x10, 0x00, 0x06, 0x10, 0x00, 0x04,\
17275 /* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
17276 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x50,\
17277 /* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12, 0x00,\
17278 /* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}
17279
17280 /* The resolve3P2Values() routine is able to run faster if it knows
17281 ** the value of the largest JUMP opcode. The smaller the maximum
17282 ** JUMP opcode the better, so the mkopcodeh.tcl script that
17283 ** generated this include file strives to group all JUMP opcodes
17284 ** together near the beginning of the list.
17285 */
17286 #define SQLITE_MX_JUMP_OPCODE 64 /* Maximum JUMP opcode */
17287
17288 /************** End of opcodes.h *********************************************/
17289 /************** Continuing where we left off in vdbe.h ***********************/
17290
17291 /*
@@ -18300,10 +18303,11 @@
18300 #define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */
18301 #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */
18302 #define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */
18303 #define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */
18304 #define SQLITE_StarQuery 0x20000000 /* Heurists for star queries */
 
18305 #define SQLITE_AllOpts 0xffffffff /* All optimizations */
18306
18307 /*
18308 ** Macros for testing whether or not optimizations are enabled or disabled.
18309 */
@@ -19744,10 +19748,11 @@
19744 unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */
19745 unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */
19746 unsigned rowidUsed :1; /* The ROWID of this table is referenced */
19747 unsigned fixedSchema :1; /* Uses u4.pSchema, not u4.zDatabase */
19748 unsigned hadSchema :1; /* Had u4.zDatabase before u4.pSchema */
 
19749 } fg;
19750 int iCursor; /* The VDBE cursor number used to access this table */
19751 Bitmask colUsed; /* Bit N set if column N used. Details above for N>62 */
19752 union {
19753 char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */
@@ -20274,10 +20279,11 @@
20274 u8 mayAbort; /* True if statement may throw an ABORT exception */
20275 u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
20276 u8 disableLookaside; /* Number of times lookaside has been disabled */
20277 u8 prepFlags; /* SQLITE_PREPARE_* flags */
20278 u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */
 
20279 u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */
20280 u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
20281 u8 bReturning; /* Coding a RETURNING trigger */
20282 u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
20283 u8 disableTriggers; /* True to disable triggers */
@@ -37721,76 +37727,76 @@
37721 /* 32 */ "Last" OpHelp(""),
37722 /* 33 */ "IfSizeBetween" OpHelp(""),
37723 /* 34 */ "SorterSort" OpHelp(""),
37724 /* 35 */ "Sort" OpHelp(""),
37725 /* 36 */ "Rewind" OpHelp(""),
37726 /* 37 */ "SorterNext" OpHelp(""),
37727 /* 38 */ "Prev" OpHelp(""),
37728 /* 39 */ "Next" OpHelp(""),
37729 /* 40 */ "IdxLE" OpHelp("key=r[P3@P4]"),
37730 /* 41 */ "IdxGT" OpHelp("key=r[P3@P4]"),
37731 /* 42 */ "IdxLT" OpHelp("key=r[P3@P4]"),
37732 /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
37733 /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
37734 /* 45 */ "IdxGE" OpHelp("key=r[P3@P4]"),
37735 /* 46 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
37736 /* 47 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
37737 /* 48 */ "Program" OpHelp(""),
37738 /* 49 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
37739 /* 50 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
37740 /* 51 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
37741 /* 52 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
37742 /* 53 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
37743 /* 54 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
37744 /* 55 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
37745 /* 56 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
37746 /* 57 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
37747 /* 58 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
37748 /* 59 */ "ElseEq" OpHelp(""),
37749 /* 60 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
37750 /* 61 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
37751 /* 62 */ "IncrVacuum" OpHelp(""),
37752 /* 63 */ "VNext" OpHelp(""),
37753 /* 64 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
37754 /* 65 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
37755 /* 66 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
37756 /* 67 */ "Return" OpHelp(""),
37757 /* 68 */ "EndCoroutine" OpHelp(""),
37758 /* 69 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
37759 /* 70 */ "Halt" OpHelp(""),
37760 /* 71 */ "Integer" OpHelp("r[P2]=P1"),
37761 /* 72 */ "Int64" OpHelp("r[P2]=P4"),
37762 /* 73 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
37763 /* 74 */ "BeginSubrtn" OpHelp("r[P2]=NULL"),
37764 /* 75 */ "Null" OpHelp("r[P2..P3]=NULL"),
37765 /* 76 */ "SoftNull" OpHelp("r[P1]=NULL"),
37766 /* 77 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
37767 /* 78 */ "Variable" OpHelp("r[P2]=parameter(P1)"),
37768 /* 79 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
37769 /* 80 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
37770 /* 81 */ "SCopy" OpHelp("r[P2]=r[P1]"),
37771 /* 82 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
37772 /* 83 */ "FkCheck" OpHelp(""),
37773 /* 84 */ "ResultRow" OpHelp("output=r[P1@P2]"),
37774 /* 85 */ "CollSeq" OpHelp(""),
37775 /* 86 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
37776 /* 87 */ "RealAffinity" OpHelp(""),
37777 /* 88 */ "Cast" OpHelp("affinity(r[P1])"),
37778 /* 89 */ "Permutation" OpHelp(""),
37779 /* 90 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
37780 /* 91 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
37781 /* 92 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
37782 /* 93 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
37783 /* 94 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"),
37784 /* 95 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
37785 /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
37786 /* 97 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
37787 /* 98 */ "Count" OpHelp("r[P2]=count()"),
37788 /* 99 */ "ReadCookie" OpHelp(""),
37789 /* 100 */ "SetCookie" OpHelp(""),
37790 /* 101 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
37791 /* 102 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
37792 /* 103 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
37793 /* 104 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
37794 /* 105 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
37795 /* 106 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
37796 /* 107 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -37797,87 +37803,88 @@
37797 /* 108 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
37798 /* 109 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
37799 /* 110 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
37800 /* 111 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
37801 /* 112 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
37802 /* 113 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
37803 /* 114 */ "OpenDup" OpHelp(""),
37804 /* 115 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
37805 /* 116 */ "OpenAutoindex" OpHelp("nColumn=P2"),
37806 /* 117 */ "OpenEphemeral" OpHelp("nColumn=P2"),
37807 /* 118 */ "String8" OpHelp("r[P2]='P4'"),
37808 /* 119 */ "SorterOpen" OpHelp(""),
37809 /* 120 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
37810 /* 121 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
37811 /* 122 */ "Close" OpHelp(""),
37812 /* 123 */ "ColumnsUsed" OpHelp(""),
37813 /* 124 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
37814 /* 125 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
37815 /* 126 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
37816 /* 127 */ "NewRowid" OpHelp("r[P2]=rowid"),
37817 /* 128 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
37818 /* 129 */ "RowCell" OpHelp(""),
37819 /* 130 */ "Delete" OpHelp(""),
37820 /* 131 */ "ResetCount" OpHelp(""),
37821 /* 132 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
37822 /* 133 */ "SorterData" OpHelp("r[P2]=data"),
37823 /* 134 */ "RowData" OpHelp("r[P2]=data"),
37824 /* 135 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"),
37825 /* 136 */ "NullRow" OpHelp(""),
37826 /* 137 */ "SeekEnd" OpHelp(""),
37827 /* 138 */ "IdxInsert" OpHelp("key=r[P2]"),
37828 /* 139 */ "SorterInsert" OpHelp("key=r[P2]"),
37829 /* 140 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
37830 /* 141 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
37831 /* 142 */ "IdxRowid" OpHelp("r[P2]=rowid"),
37832 /* 143 */ "FinishSeek" OpHelp(""),
37833 /* 144 */ "Destroy" OpHelp(""),
37834 /* 145 */ "Clear" OpHelp(""),
37835 /* 146 */ "ResetSorter" OpHelp(""),
37836 /* 147 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
37837 /* 148 */ "SqlExec" OpHelp(""),
37838 /* 149 */ "ParseSchema" OpHelp(""),
37839 /* 150 */ "LoadAnalysis" OpHelp(""),
37840 /* 151 */ "DropTable" OpHelp(""),
37841 /* 152 */ "DropIndex" OpHelp(""),
37842 /* 153 */ "DropTrigger" OpHelp(""),
37843 /* 154 */ "Real" OpHelp("r[P2]=P4"),
37844 /* 155 */ "IntegrityCk" OpHelp(""),
37845 /* 156 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
37846 /* 157 */ "Param" OpHelp(""),
37847 /* 158 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
37848 /* 159 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
37849 /* 160 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
37850 /* 161 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
37851 /* 162 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
37852 /* 163 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
37853 /* 164 */ "AggValue" OpHelp("r[P3]=value N=P2"),
37854 /* 165 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
37855 /* 166 */ "Expire" OpHelp(""),
37856 /* 167 */ "CursorLock" OpHelp(""),
37857 /* 168 */ "CursorUnlock" OpHelp(""),
37858 /* 169 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
37859 /* 170 */ "VBegin" OpHelp(""),
37860 /* 171 */ "VCreate" OpHelp(""),
37861 /* 172 */ "VDestroy" OpHelp(""),
37862 /* 173 */ "VOpen" OpHelp(""),
37863 /* 174 */ "VCheck" OpHelp(""),
37864 /* 175 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
37865 /* 176 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
37866 /* 177 */ "VRename" OpHelp(""),
37867 /* 178 */ "Pagecount" OpHelp(""),
37868 /* 179 */ "MaxPgcnt" OpHelp(""),
37869 /* 180 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"),
37870 /* 181 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"),
37871 /* 182 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"),
37872 /* 183 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
37873 /* 184 */ "Trace" OpHelp(""),
37874 /* 185 */ "CursorHint" OpHelp(""),
37875 /* 186 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
37876 /* 187 */ "Noop" OpHelp(""),
37877 /* 188 */ "Explain" OpHelp(""),
37878 /* 189 */ "Abortable" OpHelp(""),
 
37879 };
37880 return azName[i];
37881 }
37882 #endif
37883
@@ -73586,14 +73593,14 @@
73586 u8 *pTmp; /* Temporary ptr into data[] */
73587
73588 assert( pPage->pBt!=0 );
73589 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
73590 assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
73591 assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );
73592 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
73593 assert( iSize>=4 ); /* Minimum cell size is 4 */
73594 assert( CORRUPT_DB || iStart<=pPage->pBt->usableSize-4 );
73595
73596 /* The list of freeblocks must be in ascending order. Find the
73597 ** spot on the list where iStart should be inserted.
73598 */
73599 hdr = pPage->hdrOffset;
@@ -77323,10 +77330,34 @@
77323 *pRes = 1;
77324 rc = SQLITE_OK;
77325 }
77326 return rc;
77327 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77328
77329 #ifdef SQLITE_DEBUG
77330 /* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that
77331 ** this flags are true for a consistent database.
77332 **
@@ -100850,10 +100881,36 @@
100850 VdbeBranchTaken(res!=0,2);
100851 if( res ) goto jump_to_p2;
100852 }
100853 break;
100854 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100855
100856 /* Opcode: Next P1 P2 P3 * P5
100857 **
100858 ** Advance cursor P1 so that it points to the next key/data pair in its
100859 ** table or index. If there are no more key/value pairs then fall through
@@ -102722,11 +102779,18 @@
102722 sqlite3_vtab_cursor *pVCur;
102723 sqlite3_vtab *pVtab;
102724 const sqlite3_module *pModule;
102725
102726 assert( p->bIsReader );
102727 pCur = 0;
 
 
 
 
 
 
 
102728 pVCur = 0;
102729 pVtab = pOp->p4.pVtab->pVtab;
102730 if( pVtab==0 || NEVER(pVtab->pModule==0) ){
102731 rc = SQLITE_LOCKED;
102732 goto abort_due_to_error;
@@ -109563,15 +109627,20 @@
109563 ** type of the function
109564 */
109565 return WRC_Prune;
109566 }
109567 #ifndef SQLITE_OMIT_SUBQUERY
 
 
 
 
109568 case TK_SELECT:
109569 case TK_EXISTS: testcase( pExpr->op==TK_EXISTS );
109570 #endif
109571 case TK_IN: {
109572 testcase( pExpr->op==TK_IN );
 
 
109573 if( ExprUseXSelect(pExpr) ){
109574 int nRef = pNC->nRef;
109575 testcase( pNC->ncFlags & NC_IsCheck );
109576 testcase( pNC->ncFlags & NC_PartIdx );
109577 testcase( pNC->ncFlags & NC_IdxExpr );
@@ -111660,11 +111729,11 @@
111660 return pRight;
111661 }else if( pRight==0 ){
111662 return pLeft;
111663 }else{
111664 u32 f = pLeft->flags | pRight->flags;
111665 if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse))==EP_IsFalse
111666 && !IN_RENAME_OBJECT
111667 ){
111668 sqlite3ExprDeferredDelete(pParse, pLeft);
111669 sqlite3ExprDeferredDelete(pParse, pRight);
111670 return sqlite3Expr(db, TK_INTEGER, "0");
@@ -112940,12 +113009,15 @@
112940 ** then compute the right operand first and do an IsNull jump if the
112941 ** right operand evalutes to NULL.
112942 */
112943 if( exprEvalRhsFirst(pExpr) && sqlite3ExprCanBeNull(pExpr->pRight) ){
112944 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2);
112945 addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r2); VdbeCoverage(v);
 
 
112946 }else{
 
112947 addrIsNull = 0;
112948 }
112949 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, pFree1);
112950 if( addrIsNull==0 ){
112951 /*
@@ -112955,11 +113027,13 @@
112955 ** operand.
112956 */
112957 if( ExprHasProperty(pExpr->pRight, EP_Subquery)
112958 && sqlite3ExprCanBeNull(pExpr->pLeft)
112959 ){
112960 addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r1); VdbeCoverage(v);
 
 
112961 }
112962 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2);
112963 }
112964 *pR1 = r1;
112965 *pR2 = r2;
@@ -114408,21 +114482,27 @@
114408 dest.eDest = SRT_Exists;
114409 sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
114410 VdbeComment((v, "Init EXISTS result"));
114411 }
114412 if( pSel->pLimit ){
114413 /* The subquery already has a limit. If the pre-existing limit is X
114414 ** then make the new limit X<>0 so that the new limit is either 1 or 0 */
114415 sqlite3 *db = pParse->db;
114416 pLimit = sqlite3Expr(db, TK_INTEGER, "0");
114417 if( pLimit ){
114418 pLimit->affExpr = SQLITE_AFF_NUMERIC;
114419 pLimit = sqlite3PExpr(pParse, TK_NE,
114420 sqlite3ExprDup(db, pSel->pLimit->pLeft, 0), pLimit);
114421 }
114422 sqlite3ExprDeferredDelete(pParse, pSel->pLimit->pLeft);
114423 pSel->pLimit->pLeft = pLimit;
 
 
 
 
 
 
114424 }else{
114425 /* If there is no pre-existing limit add a limit of 1 */
114426 pLimit = sqlite3Expr(pParse->db, TK_INTEGER, "1");
114427 pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
114428 }
@@ -115628,10 +115708,11 @@
115628 testcase( regFree2==0 );
115629 if( addrIsNull ){
115630 sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
115631 sqlite3VdbeJumpHere(v, addrIsNull);
115632 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
 
115633 }
115634 break;
115635 }
115636 case TK_UMINUS: {
115637 Expr *pLeft = pExpr->pLeft;
@@ -128437,18 +128518,21 @@
128437 ** Append the contents of SrcList p2 to SrcList p1 and return the resulting
128438 ** SrcList. Or, if an error occurs, return NULL. In all cases, p1 and p2
128439 ** are deleted by this function.
128440 */
128441 SQLITE_PRIVATE SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, SrcList *p2){
128442 assert( p1 && p1->nSrc==1 );
128443 if( p2 ){
128444 SrcList *pNew = sqlite3SrcListEnlarge(pParse, p1, p2->nSrc, 1);
 
128445 if( pNew==0 ){
128446 sqlite3SrcListDelete(pParse->db, p2);
128447 }else{
128448 p1 = pNew;
128449 memcpy(&p1->a[1], p2->a, p2->nSrc*sizeof(SrcItem));
 
 
128450 sqlite3DbFree(pParse->db, p2);
128451 p1->a[0].fg.jointype |= (JT_LTORJ & p1->a[1].fg.jointype);
128452 }
128453 }
128454 return p1;
@@ -145523,11 +145607,11 @@
145523 SrcList *pSrc, /* Array of tables to search */
145524 int iStart, /* First member of pSrc->a[] to check */
145525 int iEnd, /* Last member of pSrc->a[] to check */
145526 const char *zCol, /* Name of the column we are looking for */
145527 int *piTab, /* Write index of pSrc->a[] here */
145528 int *piCol, /* Write index of pSrc->a[*piTab].pTab->aCol[] here */
145529 int bIgnoreHidden /* Ignore hidden columns */
145530 ){
145531 int i; /* For looping over tables in pSrc */
145532 int iCol; /* Index of column matching zCol */
145533
@@ -148175,11 +148259,13 @@
148175 int unionTab; /* Cursor number of the temp table holding result */
148176 u8 op = 0; /* One of the SRT_ operations to apply to self */
148177 int priorOp; /* The SRT_ operation to apply to prior selects */
148178 Expr *pLimit; /* Saved values of p->nLimit */
148179 int addr;
 
148180 SelectDest uniondest;
 
148181
148182 testcase( p->op==TK_EXCEPT );
148183 testcase( p->op==TK_UNION );
148184 priorOp = SRT_Union;
148185 if( dest.eDest==priorOp ){
@@ -148214,10 +148300,12 @@
148214
148215 /* Code the current SELECT statement
148216 */
148217 if( p->op==TK_EXCEPT ){
148218 op = SRT_Except;
 
 
148219 }else{
148220 assert( p->op==TK_UNION );
148221 op = SRT_Union;
148222 }
148223 p->pPrior = 0;
@@ -148234,10 +148322,11 @@
148234 p->pPrior = pPrior;
148235 p->pOrderBy = 0;
148236 if( p->op==TK_UNION ){
148237 p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
148238 }
 
148239 sqlite3ExprDelete(db, p->pLimit);
148240 p->pLimit = pLimit;
148241 p->iLimit = 0;
148242 p->iOffset = 0;
148243
@@ -148267,10 +148356,11 @@
148267 int iCont, iBreak, iStart;
148268 Expr *pLimit;
148269 int addr;
148270 SelectDest intersectdest;
148271 int r1;
 
148272
148273 /* INTERSECT is different from the others since it requires
148274 ** two temporary tables. Hence it has its own case. Begin
148275 ** by allocating the tables we will need.
148276 */
@@ -148290,10 +148380,11 @@
148290 TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT left...\n"));
148291 rc = sqlite3Select(pParse, pPrior, &intersectdest);
148292 if( rc ){
148293 goto multi_select_end;
148294 }
 
148295
148296 /* Code the current SELECT into temporary table "tab2"
148297 */
148298 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
148299 assert( p->addrOpenEphm[1] == -1 );
@@ -148321,11 +148412,11 @@
148321 if( rc ) break;
148322 assert( p->pEList );
148323 iBreak = sqlite3VdbeMakeLabel(pParse);
148324 iCont = sqlite3VdbeMakeLabel(pParse);
148325 computeLimitRegisters(pParse, p, iBreak);
148326 sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);
148327 r1 = sqlite3GetTempReg(pParse);
148328 iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
148329 sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
148330 VdbeCoverage(v);
148331 sqlite3ReleaseTempReg(pParse, r1);
@@ -148333,10 +148424,11 @@
148333 0, 0, &dest, iCont, iBreak);
148334 sqlite3VdbeResolveLabel(v, iCont);
148335 sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);
148336 sqlite3VdbeResolveLabel(v, iBreak);
148337 sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);
 
148338 sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);
148339 break;
148340 }
148341 }
148342
@@ -149011,10 +149103,11 @@
149011 typedef struct SubstContext {
149012 Parse *pParse; /* The parsing context */
149013 int iTable; /* Replace references to this table */
149014 int iNewTable; /* New table number */
149015 int isOuterJoin; /* Add TK_IF_NULL_ROW opcodes on each replacement */
 
149016 ExprList *pEList; /* Replacement expressions */
149017 ExprList *pCList; /* Collation sequences for replacement expr */
149018 } SubstContext;
149019
149020 /* Forward Declarations */
@@ -149117,10 +149210,13 @@
149117 }
149118 }
149119 }else{
149120 if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
149121 pExpr->iTable = pSubst->iNewTable;
 
 
 
149122 }
149123 pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);
149124 pExpr->pRight = substExpr(pSubst, pExpr->pRight);
149125 if( ExprUseXSelect(pExpr) ){
149126 substSelect(pSubst, pExpr->x.pSelect, 1);
@@ -149155,10 +149251,11 @@
149155 ){
149156 SrcList *pSrc;
149157 SrcItem *pItem;
149158 int i;
149159 if( !p ) return;
 
149160 do{
149161 substExprList(pSubst, p->pEList);
149162 substExprList(pSubst, p->pGroupBy);
149163 substExprList(pSubst, p->pOrderBy);
149164 p->pHaving = substExpr(pSubst, p->pHaving);
@@ -149172,10 +149269,11 @@
149172 if( pItem->fg.isTabFunc ){
149173 substExprList(pSubst, pItem->u1.pFuncArg);
149174 }
149175 }
149176 }while( doPrior && (p = p->pPrior)!=0 );
 
149177 }
149178 #endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
149179
149180 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
149181 /*
@@ -149783,11 +149881,11 @@
149783 /* Defer deleting the Table object associated with the
149784 ** subquery until code generation is
149785 ** complete, since there may still exist Expr.pTab entries that
149786 ** refer to the subquery even after flattening. Ticket #3346.
149787 **
149788 ** pSubitem->pTab is always non-NULL by test restrictions and tests above.
149789 */
149790 if( ALWAYS(pSubitem->pSTab!=0) ){
149791 Table *pTabToDel = pSubitem->pSTab;
149792 if( pTabToDel->nTabRef==1 ){
149793 Parse *pToplevel = sqlite3ParseToplevel(pParse);
@@ -149913,10 +150011,11 @@
149913 SubstContext x;
149914 x.pParse = pParse;
149915 x.iTable = iParent;
149916 x.iNewTable = iNewParent;
149917 x.isOuterJoin = isOuterJoin;
 
149918 x.pEList = pSub->pEList;
149919 x.pCList = findLeftmostExprlist(pSub);
149920 substSelect(&x, pParent, 0);
149921 }
149922
@@ -150498,10 +150597,11 @@
150498 unsetJoinExpr(pNew, -1, 1);
150499 x.pParse = pParse;
150500 x.iTable = pSrc->iCursor;
150501 x.iNewTable = pSrc->iCursor;
150502 x.isOuterJoin = 0;
 
150503 x.pEList = pSubq->pEList;
150504 x.pCList = findLeftmostExprlist(pSubq);
150505 pNew = substExpr(&x, pNew);
150506 #ifndef SQLITE_OMIT_WINDOWFUNC
150507 if( pSubq->pWin && 0==pushDownWindowCheck(pParse, pSubq, pNew) ){
@@ -150895,11 +150995,11 @@
150895 ** a WITH clause on the stack currently maintained by the parser (on the
150896 ** pParse->pWith linked list). And if currently processing a CTE
150897 ** CTE expression, through routine checks to see if the reference is
150898 ** a recursive reference to the CTE.
150899 **
150900 ** If pFrom matches a CTE according to either of these two above, pFrom->pTab
150901 ** and other fields are populated accordingly.
150902 **
150903 ** Return 0 if no match is found.
150904 ** Return 1 if a match is found.
150905 ** Return 2 if an error condition is detected.
@@ -152521,10 +152621,79 @@
152521 pItem--;
152522 if( pItem->fg.isSubquery ) return 0; /* (1c-i) */
152523 }
152524 return 1;
152525 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152526
152527 /*
152528 ** Generate byte-code for the SELECT statement given in the p argument.
152529 **
152530 ** The results are returned according to the SelectDest structure.
@@ -152889,10 +153058,17 @@
152889 #endif
152890 if( p->pNext==0 ) ExplainQueryPlanPop(pParse);
152891 return rc;
152892 }
152893 #endif
 
 
 
 
 
 
 
152894
152895 /* Do the WHERE-clause constant propagation optimization if this is
152896 ** a join. No need to spend time on this operation for non-join queries
152897 ** as the equivalent optimization will be handled by query planner in
152898 ** sqlite3WhereBegin(). tag-select-0330
@@ -153676,24 +153852,24 @@
153676 ** over to a0,a1,a2. It then calls the output subroutine
153677 ** and resets the aggregate accumulator registers in preparation
153678 ** for the next GROUP BY batch.
153679 */
153680 sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
153681 VdbeComment((v, "output one row"));
153682 sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr);
153683 sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); VdbeCoverage(v);
153684 VdbeComment((v, "check abort flag"));
153685 sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
153686 VdbeComment((v, "reset accumulator"));
153687
153688 /* Update the aggregate accumulators based on the content of
153689 ** the current row
153690 */
153691 sqlite3VdbeJumpHere(v, addr1);
153692 updateAccumulator(pParse, iUseFlag, pAggInfo, eDist);
153693 sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);
153694 VdbeComment((v, "indicate data in accumulator"));
153695
153696 /* End of the loop
153697 */
153698 if( groupBySort ){
153699 sqlite3VdbeAddOp2(v, OP_SorterNext, pAggInfo->sortingIdx,addrTopOfLoop);
@@ -153706,11 +153882,11 @@
153706 sqlite3ExprListDelete(db, pDistinct);
153707
153708 /* Output the final row of result
153709 */
153710 sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
153711 VdbeComment((v, "output final row"));
153712
153713 /* Jump over the subroutines
153714 */
153715 sqlite3VdbeGoto(v, addrEnd);
153716
@@ -153727,26 +153903,26 @@
153727 sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
153728 sqlite3VdbeResolveLabel(v, addrOutputRow);
153729 addrOutputRow = sqlite3VdbeCurrentAddr(v);
153730 sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow+2);
153731 VdbeCoverage(v);
153732 VdbeComment((v, "Groupby result generator entry point"));
153733 sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
153734 finalizeAggFunctions(pParse, pAggInfo);
153735 sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);
153736 selectInnerLoop(pParse, p, -1, &sSort,
153737 &sDistinct, pDest,
153738 addrOutputRow+1, addrSetAbort);
153739 sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
153740 VdbeComment((v, "end groupby result generator"));
153741
153742 /* Generate a subroutine that will reset the group-by accumulator
153743 */
153744 sqlite3VdbeResolveLabel(v, addrReset);
153745 resetAccumulator(pParse, pAggInfo);
153746 sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);
153747 VdbeComment((v, "indicate accumulator empty"));
153748 sqlite3VdbeAddOp1(v, OP_Return, regReset);
153749
153750 if( distFlag!=0 && eDist!=WHERE_DISTINCT_NOOP ){
153751 struct AggInfo_func *pF = &pAggInfo->aFunc[0];
153752 fixDistinctOpenEph(pParse, eDist, pF->iDistinct, pF->iDistAddr);
@@ -159334,10 +159510,11 @@
159334 struct WhereLevel {
159335 int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
159336 int iTabCur; /* The VDBE cursor used to access the table */
159337 int iIdxCur; /* The VDBE cursor used to access pIdx */
159338 int addrBrk; /* Jump here to break out of the loop */
 
159339 int addrNxt; /* Jump here to start the next IN combination */
159340 int addrSkip; /* Jump here for next iteration of skip-scan */
159341 int addrCont; /* Jump here to continue with the next loop cycle */
159342 int addrFirst; /* First instruction of interior of the loop */
159343 int addrBody; /* Beginning of the body of this loop */
@@ -160043,10 +160220,11 @@
160043 WhereLoop *pLoop; /* The controlling WhereLoop object */
160044 u32 flags; /* Flags that describe this loop */
160045 #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)
160046 char *zMsg; /* Text to add to EQP output */
160047 #endif
 
160048 StrAccum str; /* EQP output string */
160049 char zBuf[100]; /* Initial space for EQP output string */
160050
160051 if( db->mallocFailed ) return;
160052
@@ -160057,11 +160235,18 @@
160057 || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
160058 || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
160059
160060 sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
160061 str.printfFlags = SQLITE_PRINTF_INTERNAL;
160062 sqlite3_str_appendf(&str, "%s %S", isSearch ? "SEARCH" : "SCAN", pItem);
 
 
 
 
 
 
 
160063 if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){
160064 const char *zFmt = 0;
160065 Index *pIdx;
160066
160067 assert( pLoop->u.btree.pIndex!=0 );
@@ -161308,19 +161493,20 @@
161308 WhereInfo *pWInfo, /* Complete information about the WHERE clause */
161309 int iLevel, /* Which level of pWInfo->a[] should be coded */
161310 int addrNxt, /* Jump here to bypass inner loops */
161311 Bitmask notReady /* Loops that are not ready */
161312 ){
 
161313 while( ++iLevel < pWInfo->nLevel ){
161314 WhereLevel *pLevel = &pWInfo->a[iLevel];
161315 WhereLoop *pLoop = pLevel->pWLoop;
161316 if( pLevel->regFilter==0 ) continue;
161317 if( pLevel->pWLoop->nSkip ) continue;
161318 /* ,--- Because sqlite3ConstructBloomFilter() has will not have set
161319 ** vvvvv--' pLevel->regFilter if this were true. */
161320 if( NEVER(pLoop->prereq & notReady) ) continue;
161321 assert( pLevel->addrBrk==0 );
161322 pLevel->addrBrk = addrNxt;
161323 if( pLoop->wsFlags & WHERE_IPK ){
161324 WhereTerm *pTerm = pLoop->aLTerm[0];
161325 int regRowid;
161326 assert( pTerm!=0 );
@@ -161346,11 +161532,11 @@
161346 sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
161347 addrNxt, r1, nEq);
161348 VdbeCoverage(pParse->pVdbe);
161349 }
161350 pLevel->regFilter = 0;
161351 pLevel->addrBrk = 0;
161352 }
161353 }
161354
161355 /*
161356 ** Loop pLoop is a WHERE_INDEXED level that uses at least one IN(...)
@@ -161393,11 +161579,10 @@
161393 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
161394 WhereTerm *pTerm; /* A WHERE clause term */
161395 sqlite3 *db; /* Database connection */
161396 SrcItem *pTabItem; /* FROM clause term being coded */
161397 int addrBrk; /* Jump here to break out of the loop */
161398 int addrHalt; /* addrBrk for the outermost loop */
161399 int addrCont; /* Jump here to continue with next cycle */
161400 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
161401 int iReleaseReg = 0; /* Temp register to free before returning */
161402 Index *pIdx = 0; /* Index used by loop (if any) */
161403 int iLoop; /* Iteration of constraint generator loop */
@@ -161437,11 +161622,11 @@
161437 ** When there is an IN operator, we also have a "addrNxt" label that
161438 ** means to continue with the next IN value combination. When
161439 ** there are no IN operators in the constraints, the "addrNxt" label
161440 ** is the same as "addrBrk".
161441 */
161442 addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
161443 addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(pParse);
161444
161445 /* If this is the right table of a LEFT OUTER JOIN, allocate and
161446 ** initialize a memory cell that records if this table matches any
161447 ** row of the left table of the join.
@@ -161453,18 +161638,10 @@
161453 pLevel->iLeftJoin = ++pParse->nMem;
161454 sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
161455 VdbeComment((v, "init LEFT JOIN match flag"));
161456 }
161457
161458 /* Compute a safe address to jump to if we discover that the table for
161459 ** this loop is empty and can never contribute content. */
161460 for(j=iLevel; j>0; j--){
161461 if( pWInfo->a[j].iLeftJoin ) break;
161462 if( pWInfo->a[j].pRJ ) break;
161463 }
161464 addrHalt = pWInfo->a[j].addrBrk;
161465
161466 /* Special case of a FROM clause subquery implemented as a co-routine */
161467 if( pTabItem->fg.viaCoroutine ){
161468 int regYield;
161469 Subquery *pSubq;
161470 assert( pTabItem->fg.isSubquery && pTabItem->u4.pSubq!=0 );
@@ -161699,11 +161876,11 @@
161699 VdbeCoverageIf(v, pX->op==TK_LE);
161700 VdbeCoverageIf(v, pX->op==TK_LT);
161701 VdbeCoverageIf(v, pX->op==TK_GE);
161702 sqlite3ReleaseTempReg(pParse, rTemp);
161703 }else{
161704 sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt);
161705 VdbeCoverageIf(v, bRev==0);
161706 VdbeCoverageIf(v, bRev!=0);
161707 }
161708 if( pEnd ){
161709 Expr *pX;
@@ -162494,11 +162671,11 @@
162494 pLevel->op = OP_Noop;
162495 }else{
162496 codeCursorHint(pTabItem, pWInfo, pLevel, 0);
162497 pLevel->op = aStep[bRev];
162498 pLevel->p1 = iCur;
162499 pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrHalt);
162500 VdbeCoverageIf(v, bRev==0);
162501 VdbeCoverageIf(v, bRev!=0);
162502 pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
162503 }
162504 }
@@ -164509,11 +164686,11 @@
164509 ** SELECT statement passed as the second argument. These terms are only
164510 ** added if:
164511 **
164512 ** 1. The SELECT statement has a LIMIT clause, and
164513 ** 2. The SELECT statement is not an aggregate or DISTINCT query, and
164514 ** 3. The SELECT statement has exactly one object in its from clause, and
164515 ** that object is a virtual table, and
164516 ** 4. There are no terms in the WHERE clause that will not be passed
164517 ** to the virtual table xBestIndex method.
164518 ** 5. The ORDER BY clause, if any, will be made available to the xBestIndex
164519 ** method.
@@ -164546,12 +164723,26 @@
164546 ** pWC->a[] array. So this term can be ignored, as a LIMIT clause
164547 ** will only be added if each of the child terms passes the
164548 ** (leftCursor==iCsr) test below. */
164549 continue;
164550 }
164551 if( pWC->a[ii].leftCursor!=iCsr ) return;
164552 if( pWC->a[ii].prereqRight!=0 ) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164553 }
164554
164555 /* Check condition (5). Return early if it is not met. */
164556 if( pOrderBy ){
164557 for(ii=0; ii<pOrderBy->nExpr; ii++){
@@ -165986,11 +166177,13 @@
165986 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSubq->addrFillSub);
165987 addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield);
165988 VdbeCoverage(v);
165989 VdbeComment((v, "next row of %s", pSrc->pSTab->zName));
165990 }else{
165991 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);
 
 
165992 }
165993 if( pPartial ){
165994 iContinue = sqlite3VdbeMakeLabel(pParse);
165995 sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);
165996 pLoop->wsFlags |= WHERE_PARTIALIDX;
@@ -166014,15 +166207,18 @@
166014 assert( pLevel->iIdxCur>0 );
166015 translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
166016 pSrc->u4.pSubq->regResult, pLevel->iIdxCur);
166017 sqlite3VdbeGoto(v, addrTop);
166018 pSrc->fg.viaCoroutine = 0;
 
166019 }else{
166020 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
166021 sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
 
 
 
166022 }
166023 sqlite3VdbeJumpHere(v, addrTop);
166024 sqlite3ReleaseTempReg(pParse, regRecord);
166025
166026 /* Jump here when skipping the initialization */
166027 sqlite3VdbeJumpHere(v, addrInit);
166028 sqlite3VdbeScanStatusRange(v, addrExp, addrExp, -1);
@@ -168298,10 +168494,11 @@
168298 && saved_nEq==pNew->nLTerm
168299 && pProbe->noSkipScan==0
168300 && pProbe->hasStat1!=0
168301 && OptimizationEnabled(db, SQLITE_SkipScan)
168302 && pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
 
168303 && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
168304 ){
168305 LogEst nIter;
168306 pNew->u.btree.nEq++;
168307 pNew->nSkip++;
@@ -171855,10 +172052,18 @@
171855
171856 pTabItem = &pTabList->a[pLevel->iFrom];
171857 pTab = pTabItem->pSTab;
171858 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
171859 pLoop = pLevel->pWLoop;
 
 
 
 
 
 
 
 
171860 if( (pTab->tabFlags & TF_Ephemeral)!=0 || IsView(pTab) ){
171861 /* Do nothing */
171862 }else
171863 #ifndef SQLITE_OMIT_VIRTUALTABLE
171864 if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){
@@ -171906,10 +172111,17 @@
171906 }
171907 #ifdef SQLITE_ENABLE_COLUMN_USED_MASK
171908 sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, pTabItem->iCursor, 0, 0,
171909 (const u8*)&pTabItem->colUsed, P4_INT64);
171910 #endif
 
 
 
 
 
 
 
171911 }else{
171912 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
171913 }
171914 if( pLoop->wsFlags & WHERE_INDEXED ){
171915 Index *pIx = pLoop->u.btree.pIndex;
@@ -172162,10 +172374,13 @@
172162 VdbeCoverageIf(v, op==OP_SeekLT);
172163 VdbeCoverageIf(v, op==OP_SeekGT);
172164 sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);
172165 }
172166 #endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
 
 
 
172167 /* The common case: Advance to the next row */
172168 if( pLevel->addrCont ) sqlite3VdbeResolveLabel(v, pLevel->addrCont);
172169 sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3);
172170 sqlite3VdbeChangeP5(v, pLevel->p5);
172171 VdbeCoverage(v);
@@ -180234,16 +180449,25 @@
180234 /* Expressions of the form
180235 **
180236 ** expr1 IN ()
180237 ** expr1 NOT IN ()
180238 **
180239 ** simplify to constants 0 (false) and 1 (true), respectively,
180240 ** regardless of the value of expr1.
 
 
 
 
180241 */
180242 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy590);
180243 yymsp[-4].minor.yy590 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy502 ? "true" : "false");
180244 if( yymsp[-4].minor.yy590 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy590);
 
 
 
 
 
180245 }else{
180246 Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
180247 if( yymsp[-1].minor.yy402->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy590->op!=TK_VECTOR ){
180248 yymsp[-1].minor.yy402->a[0].pExpr = 0;
180249 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
@@ -247032,22 +247256,24 @@
247032 if( pLast ){
247033 int iOff;
247034 fts5DataRelease(pIter->pLeaf);
247035 pIter->pLeaf = pLast;
247036 pIter->iLeafPgno = pgnoLast;
247037 iOff = fts5LeafFirstRowidOff(pLast);
247038 if( iOff>pLast->szLeaf ){
247039 FTS5_CORRUPT_ITER(p, pIter);
247040 return;
247041 }
247042 iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid);
247043 pIter->iLeafOffset = iOff;
247044
247045 if( fts5LeafIsTermless(pLast) ){
247046 pIter->iEndofDoclist = pLast->nn+1;
247047 }else{
247048 pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast);
 
 
247049 }
247050 }
247051
247052 fts5SegIterReverseInitPage(p, pIter);
247053 }
@@ -250396,11 +250622,11 @@
250396 }
250397 assert( pStruct->aLevel[i].nMerge<=nThis );
250398 }
250399
250400 nByte += (((i64)pStruct->nLevel)+1) * sizeof(Fts5StructureLevel);
250401 assert( nByte==SZ_FTS5STRUCTURE(pStruct->nLevel+2) );
250402 pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);
250403
250404 if( pNew ){
250405 Fts5StructureLevel *pLvl;
250406 nByte = nSeg * sizeof(Fts5StructureSegment);
@@ -257648,11 +257874,11 @@
257648 int nArg, /* Number of args */
257649 sqlite3_value **apUnused /* Function arguments */
257650 ){
257651 assert( nArg==0 );
257652 UNUSED_PARAM2(nArg, apUnused);
257653 sqlite3_result_text(pCtx, "fts5: 2025-06-30 16:41:40 0083d5169a46104a25355bdd9d5a2f4027b049191ebda571dd228477ec217296", -1, SQLITE_TRANSIENT);
257654 }
257655
257656 /*
257657 ** Implementation of fts5_locale(LOCALE, TEXT) function.
257658 **
257659
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 6f98b16d210a9f5b6ca4b4599e3dab3263ed with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466 ** [sqlite_version()] and [sqlite_source_id()].
467 */
468 #define SQLITE_VERSION "3.51.0"
469 #define SQLITE_VERSION_NUMBER 3051000
470 #define SQLITE_SOURCE_ID "2025-07-04 14:24:18 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -15565,10 +15565,11 @@
15565 ** 0x00010000 Beginning of DELETE/INSERT/UPDATE processing
15566 ** 0x00020000 Transform DISTINCT into GROUP BY
15567 ** 0x00040000 SELECT tree dump after all code has been generated
15568 ** 0x00080000 NOT NULL strength reduction
15569 ** 0x00100000 Pointers are all shown as zero
15570 ** 0x00200000 EXISTS-to-JOIN optimization
15571 */
15572
15573 /*
15574 ** Macros for "wheretrace"
15575 */
@@ -16750,10 +16751,11 @@
16751 };
16752
16753 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
16754 int flags, int seekResult);
16755 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
16756 SQLITE_PRIVATE int sqlite3BtreeIsEmpty(BtCursor *pCur, int *pRes);
16757 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
16758 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
16759 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
16760 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
16761 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
@@ -17083,76 +17085,76 @@
17085 #define OP_Last 32 /* jump0 */
17086 #define OP_IfSizeBetween 33 /* jump */
17087 #define OP_SorterSort 34 /* jump */
17088 #define OP_Sort 35 /* jump */
17089 #define OP_Rewind 36 /* jump0 */
17090 #define OP_IfEmpty 37 /* jump, synopsis: if( empty(P1) ) goto P2 */
17091 #define OP_SorterNext 38 /* jump */
17092 #define OP_Prev 39 /* jump */
17093 #define OP_Next 40 /* jump */
17094 #define OP_IdxLE 41 /* jump, synopsis: key=r[P3@P4] */
17095 #define OP_IdxGT 42 /* jump, synopsis: key=r[P3@P4] */
17096 #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
17097 #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
17098 #define OP_IdxLT 45 /* jump, synopsis: key=r[P3@P4] */
17099 #define OP_IdxGE 46 /* jump, synopsis: key=r[P3@P4] */
17100 #define OP_RowSetRead 47 /* jump, synopsis: r[P3]=rowset(P1) */
17101 #define OP_RowSetTest 48 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
17102 #define OP_Program 49 /* jump0 */
17103 #define OP_FkIfZero 50 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
17104 #define OP_IsNull 51 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
17105 #define OP_NotNull 52 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
17106 #define OP_Ne 53 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
17107 #define OP_Eq 54 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
17108 #define OP_Gt 55 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
17109 #define OP_Le 56 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
17110 #define OP_Lt 57 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
17111 #define OP_Ge 58 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
17112 #define OP_ElseEq 59 /* jump, same as TK_ESCAPE */
17113 #define OP_IfPos 60 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
17114 #define OP_IfNotZero 61 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
17115 #define OP_DecrJumpZero 62 /* jump, synopsis: if (--r[P1])==0 goto P2 */
17116 #define OP_IncrVacuum 63 /* jump */
17117 #define OP_VNext 64 /* jump */
17118 #define OP_Filter 65 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
17119 #define OP_PureFunc 66 /* synopsis: r[P3]=func(r[P2@NP]) */
17120 #define OP_Function 67 /* synopsis: r[P3]=func(r[P2@NP]) */
17121 #define OP_Return 68
17122 #define OP_EndCoroutine 69
17123 #define OP_HaltIfNull 70 /* synopsis: if r[P3]=null halt */
17124 #define OP_Halt 71
17125 #define OP_Integer 72 /* synopsis: r[P2]=P1 */
17126 #define OP_Int64 73 /* synopsis: r[P2]=P4 */
17127 #define OP_String 74 /* synopsis: r[P2]='P4' (len=P1) */
17128 #define OP_BeginSubrtn 75 /* synopsis: r[P2]=NULL */
17129 #define OP_Null 76 /* synopsis: r[P2..P3]=NULL */
17130 #define OP_SoftNull 77 /* synopsis: r[P1]=NULL */
17131 #define OP_Blob 78 /* synopsis: r[P2]=P4 (len=P1) */
17132 #define OP_Variable 79 /* synopsis: r[P2]=parameter(P1) */
17133 #define OP_Move 80 /* synopsis: r[P2@P3]=r[P1@P3] */
17134 #define OP_Copy 81 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
17135 #define OP_SCopy 82 /* synopsis: r[P2]=r[P1] */
17136 #define OP_IntCopy 83 /* synopsis: r[P2]=r[P1] */
17137 #define OP_FkCheck 84
17138 #define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */
17139 #define OP_CollSeq 86
17140 #define OP_AddImm 87 /* synopsis: r[P1]=r[P1]+P2 */
17141 #define OP_RealAffinity 88
17142 #define OP_Cast 89 /* synopsis: affinity(r[P1]) */
17143 #define OP_Permutation 90
17144 #define OP_Compare 91 /* synopsis: r[P1@P3] <-> r[P2@P3] */
17145 #define OP_IsTrue 92 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
17146 #define OP_ZeroOrNull 93 /* synopsis: r[P2] = 0 OR NULL */
17147 #define OP_Offset 94 /* synopsis: r[P3] = sqlite_offset(P1) */
17148 #define OP_Column 95 /* synopsis: r[P3]=PX cursor P1 column P2 */
17149 #define OP_TypeCheck 96 /* synopsis: typecheck(r[P1@P2]) */
17150 #define OP_Affinity 97 /* synopsis: affinity(r[P1@P2]) */
17151 #define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
17152 #define OP_Count 99 /* synopsis: r[P2]=count() */
17153 #define OP_ReadCookie 100
17154 #define OP_SetCookie 101
17155 #define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
17156 #define OP_BitAnd 103 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
17157 #define OP_BitOr 104 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
17158 #define OP_ShiftLeft 105 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
17159 #define OP_ShiftRight 106 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
17160 #define OP_Add 107 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -17159,87 +17161,88 @@
17161 #define OP_Subtract 108 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
17162 #define OP_Multiply 109 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
17163 #define OP_Divide 110 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
17164 #define OP_Remainder 111 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
17165 #define OP_Concat 112 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
17166 #define OP_OpenRead 113 /* synopsis: root=P2 iDb=P3 */
17167 #define OP_OpenWrite 114 /* synopsis: root=P2 iDb=P3 */
17168 #define OP_BitNot 115 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
17169 #define OP_OpenDup 116
17170 #define OP_OpenAutoindex 117 /* synopsis: nColumn=P2 */
17171 #define OP_String8 118 /* same as TK_STRING, synopsis: r[P2]='P4' */
17172 #define OP_OpenEphemeral 119 /* synopsis: nColumn=P2 */
17173 #define OP_SorterOpen 120
17174 #define OP_SequenceTest 121 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
17175 #define OP_OpenPseudo 122 /* synopsis: P3 columns in r[P2] */
17176 #define OP_Close 123
17177 #define OP_ColumnsUsed 124
17178 #define OP_SeekScan 125 /* synopsis: Scan-ahead up to P1 rows */
17179 #define OP_SeekHit 126 /* synopsis: set P2<=seekHit<=P3 */
17180 #define OP_Sequence 127 /* synopsis: r[P2]=cursor[P1].ctr++ */
17181 #define OP_NewRowid 128 /* synopsis: r[P2]=rowid */
17182 #define OP_Insert 129 /* synopsis: intkey=r[P3] data=r[P2] */
17183 #define OP_RowCell 130
17184 #define OP_Delete 131
17185 #define OP_ResetCount 132
17186 #define OP_SorterCompare 133 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
17187 #define OP_SorterData 134 /* synopsis: r[P2]=data */
17188 #define OP_RowData 135 /* synopsis: r[P2]=data */
17189 #define OP_Rowid 136 /* synopsis: r[P2]=PX rowid of P1 */
17190 #define OP_NullRow 137
17191 #define OP_SeekEnd 138
17192 #define OP_IdxInsert 139 /* synopsis: key=r[P2] */
17193 #define OP_SorterInsert 140 /* synopsis: key=r[P2] */
17194 #define OP_IdxDelete 141 /* synopsis: key=r[P2@P3] */
17195 #define OP_DeferredSeek 142 /* synopsis: Move P3 to P1.rowid if needed */
17196 #define OP_IdxRowid 143 /* synopsis: r[P2]=rowid */
17197 #define OP_FinishSeek 144
17198 #define OP_Destroy 145
17199 #define OP_Clear 146
17200 #define OP_ResetSorter 147
17201 #define OP_CreateBtree 148 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
17202 #define OP_SqlExec 149
17203 #define OP_ParseSchema 150
17204 #define OP_LoadAnalysis 151
17205 #define OP_DropTable 152
17206 #define OP_DropIndex 153
17207 #define OP_Real 154 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
17208 #define OP_DropTrigger 155
17209 #define OP_IntegrityCk 156
17210 #define OP_RowSetAdd 157 /* synopsis: rowset(P1)=r[P2] */
17211 #define OP_Param 158
17212 #define OP_FkCounter 159 /* synopsis: fkctr[P1]+=P2 */
17213 #define OP_MemMax 160 /* synopsis: r[P1]=max(r[P1],r[P2]) */
17214 #define OP_OffsetLimit 161 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
17215 #define OP_AggInverse 162 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
17216 #define OP_AggStep 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17217 #define OP_AggStep1 164 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17218 #define OP_AggValue 165 /* synopsis: r[P3]=value N=P2 */
17219 #define OP_AggFinal 166 /* synopsis: accum=r[P1] N=P2 */
17220 #define OP_Expire 167
17221 #define OP_CursorLock 168
17222 #define OP_CursorUnlock 169
17223 #define OP_TableLock 170 /* synopsis: iDb=P1 root=P2 write=P3 */
17224 #define OP_VBegin 171
17225 #define OP_VCreate 172
17226 #define OP_VDestroy 173
17227 #define OP_VOpen 174
17228 #define OP_VCheck 175
17229 #define OP_VInitIn 176 /* synopsis: r[P2]=ValueList(P1,P3) */
17230 #define OP_VColumn 177 /* synopsis: r[P3]=vcolumn(P2) */
17231 #define OP_VRename 178
17232 #define OP_Pagecount 179
17233 #define OP_MaxPgcnt 180
17234 #define OP_ClrSubtype 181 /* synopsis: r[P1].subtype = 0 */
17235 #define OP_GetSubtype 182 /* synopsis: r[P2] = r[P1].subtype */
17236 #define OP_SetSubtype 183 /* synopsis: r[P2].subtype = r[P1] */
17237 #define OP_FilterAdd 184 /* synopsis: filter(P1) += key(P3@P4) */
17238 #define OP_Trace 185
17239 #define OP_CursorHint 186
17240 #define OP_ReleaseReg 187 /* synopsis: release r[P1@P2] mask P3 */
17241 #define OP_Noop 188
17242 #define OP_Explain 189
17243 #define OP_Abortable 190
17244
17245 /* Properties such as "out2" or "jump" that are specified in
17246 ** comments following the "case" for each opcode in the vdbe.c
17247 ** are encoded into bitvectors as follows:
17248 */
@@ -17254,38 +17257,38 @@
17257 #define OPFLG_INITIALIZER {\
17258 /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\
17259 /* 8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\
17260 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\
17261 /* 24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\
17262 /* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x01, 0x41,\
17263 /* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x41, 0x23,\
17264 /* 48 */ 0x0b, 0x81, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\
17265 /* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01,\
17266 /* 64 */ 0x41, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00,\
17267 /* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\
17268 /* 80 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02,\
17269 /* 88 */ 0x02, 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40,\
17270 /* 96 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x26,\
17271 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
17272 /* 112 */ 0x26, 0x40, 0x00, 0x12, 0x40, 0x40, 0x10, 0x40,\
17273 /* 120 */ 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10,\
17274 /* 128 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,\
17275 /* 136 */ 0x50, 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50,\
17276 /* 144 */ 0x40, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\
17277 /* 152 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00,\
17278 /* 160 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
17279 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10,\
17280 /* 176 */ 0x50, 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12,\
17281 /* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}
17282
17283 /* The resolve3P2Values() routine is able to run faster if it knows
17284 ** the value of the largest JUMP opcode. The smaller the maximum
17285 ** JUMP opcode the better, so the mkopcodeh.tcl script that
17286 ** generated this include file strives to group all JUMP opcodes
17287 ** together near the beginning of the list.
17288 */
17289 #define SQLITE_MX_JUMP_OPCODE 65 /* Maximum JUMP opcode */
17290
17291 /************** End of opcodes.h *********************************************/
17292 /************** Continuing where we left off in vdbe.h ***********************/
17293
17294 /*
@@ -18300,10 +18303,11 @@
18303 #define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */
18304 #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */
18305 #define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */
18306 #define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */
18307 #define SQLITE_StarQuery 0x20000000 /* Heurists for star queries */
18308 #define SQLITE_ExistsToJoin 0x40000000 /* The EXISTS-to-JOIN optimization */
18309 #define SQLITE_AllOpts 0xffffffff /* All optimizations */
18310
18311 /*
18312 ** Macros for testing whether or not optimizations are enabled or disabled.
18313 */
@@ -19744,10 +19748,11 @@
19748 unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */
19749 unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */
19750 unsigned rowidUsed :1; /* The ROWID of this table is referenced */
19751 unsigned fixedSchema :1; /* Uses u4.pSchema, not u4.zDatabase */
19752 unsigned hadSchema :1; /* Had u4.zDatabase before u4.pSchema */
19753 unsigned fromExists :1; /* Comes from WHERE EXISTS(...) */
19754 } fg;
19755 int iCursor; /* The VDBE cursor number used to access this table */
19756 Bitmask colUsed; /* Bit N set if column N used. Details above for N>62 */
19757 union {
19758 char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */
@@ -20274,10 +20279,11 @@
20279 u8 mayAbort; /* True if statement may throw an ABORT exception */
20280 u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
20281 u8 disableLookaside; /* Number of times lookaside has been disabled */
20282 u8 prepFlags; /* SQLITE_PREPARE_* flags */
20283 u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */
20284 u8 bHasExists; /* Has a correlated "EXISTS (SELECT ....)" expression */
20285 u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */
20286 u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
20287 u8 bReturning; /* Coding a RETURNING trigger */
20288 u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
20289 u8 disableTriggers; /* True to disable triggers */
@@ -37721,76 +37727,76 @@
37727 /* 32 */ "Last" OpHelp(""),
37728 /* 33 */ "IfSizeBetween" OpHelp(""),
37729 /* 34 */ "SorterSort" OpHelp(""),
37730 /* 35 */ "Sort" OpHelp(""),
37731 /* 36 */ "Rewind" OpHelp(""),
37732 /* 37 */ "IfEmpty" OpHelp("if( empty(P1) ) goto P2"),
37733 /* 38 */ "SorterNext" OpHelp(""),
37734 /* 39 */ "Prev" OpHelp(""),
37735 /* 40 */ "Next" OpHelp(""),
37736 /* 41 */ "IdxLE" OpHelp("key=r[P3@P4]"),
37737 /* 42 */ "IdxGT" OpHelp("key=r[P3@P4]"),
37738 /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
37739 /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
37740 /* 45 */ "IdxLT" OpHelp("key=r[P3@P4]"),
37741 /* 46 */ "IdxGE" OpHelp("key=r[P3@P4]"),
37742 /* 47 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
37743 /* 48 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
37744 /* 49 */ "Program" OpHelp(""),
37745 /* 50 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
37746 /* 51 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
37747 /* 52 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
37748 /* 53 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
37749 /* 54 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
37750 /* 55 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
37751 /* 56 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
37752 /* 57 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
37753 /* 58 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
37754 /* 59 */ "ElseEq" OpHelp(""),
37755 /* 60 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
37756 /* 61 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
37757 /* 62 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
37758 /* 63 */ "IncrVacuum" OpHelp(""),
37759 /* 64 */ "VNext" OpHelp(""),
37760 /* 65 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
37761 /* 66 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
37762 /* 67 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
37763 /* 68 */ "Return" OpHelp(""),
37764 /* 69 */ "EndCoroutine" OpHelp(""),
37765 /* 70 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
37766 /* 71 */ "Halt" OpHelp(""),
37767 /* 72 */ "Integer" OpHelp("r[P2]=P1"),
37768 /* 73 */ "Int64" OpHelp("r[P2]=P4"),
37769 /* 74 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
37770 /* 75 */ "BeginSubrtn" OpHelp("r[P2]=NULL"),
37771 /* 76 */ "Null" OpHelp("r[P2..P3]=NULL"),
37772 /* 77 */ "SoftNull" OpHelp("r[P1]=NULL"),
37773 /* 78 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
37774 /* 79 */ "Variable" OpHelp("r[P2]=parameter(P1)"),
37775 /* 80 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
37776 /* 81 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
37777 /* 82 */ "SCopy" OpHelp("r[P2]=r[P1]"),
37778 /* 83 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
37779 /* 84 */ "FkCheck" OpHelp(""),
37780 /* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"),
37781 /* 86 */ "CollSeq" OpHelp(""),
37782 /* 87 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
37783 /* 88 */ "RealAffinity" OpHelp(""),
37784 /* 89 */ "Cast" OpHelp("affinity(r[P1])"),
37785 /* 90 */ "Permutation" OpHelp(""),
37786 /* 91 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
37787 /* 92 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
37788 /* 93 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
37789 /* 94 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
37790 /* 95 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"),
37791 /* 96 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
37792 /* 97 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
37793 /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
37794 /* 99 */ "Count" OpHelp("r[P2]=count()"),
37795 /* 100 */ "ReadCookie" OpHelp(""),
37796 /* 101 */ "SetCookie" OpHelp(""),
37797 /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
37798 /* 103 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
37799 /* 104 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
37800 /* 105 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
37801 /* 106 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
37802 /* 107 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -37797,87 +37803,88 @@
37803 /* 108 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
37804 /* 109 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
37805 /* 110 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
37806 /* 111 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
37807 /* 112 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
37808 /* 113 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
37809 /* 114 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
37810 /* 115 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
37811 /* 116 */ "OpenDup" OpHelp(""),
37812 /* 117 */ "OpenAutoindex" OpHelp("nColumn=P2"),
37813 /* 118 */ "String8" OpHelp("r[P2]='P4'"),
37814 /* 119 */ "OpenEphemeral" OpHelp("nColumn=P2"),
37815 /* 120 */ "SorterOpen" OpHelp(""),
37816 /* 121 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
37817 /* 122 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
37818 /* 123 */ "Close" OpHelp(""),
37819 /* 124 */ "ColumnsUsed" OpHelp(""),
37820 /* 125 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
37821 /* 126 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
37822 /* 127 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
37823 /* 128 */ "NewRowid" OpHelp("r[P2]=rowid"),
37824 /* 129 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
37825 /* 130 */ "RowCell" OpHelp(""),
37826 /* 131 */ "Delete" OpHelp(""),
37827 /* 132 */ "ResetCount" OpHelp(""),
37828 /* 133 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
37829 /* 134 */ "SorterData" OpHelp("r[P2]=data"),
37830 /* 135 */ "RowData" OpHelp("r[P2]=data"),
37831 /* 136 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"),
37832 /* 137 */ "NullRow" OpHelp(""),
37833 /* 138 */ "SeekEnd" OpHelp(""),
37834 /* 139 */ "IdxInsert" OpHelp("key=r[P2]"),
37835 /* 140 */ "SorterInsert" OpHelp("key=r[P2]"),
37836 /* 141 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
37837 /* 142 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
37838 /* 143 */ "IdxRowid" OpHelp("r[P2]=rowid"),
37839 /* 144 */ "FinishSeek" OpHelp(""),
37840 /* 145 */ "Destroy" OpHelp(""),
37841 /* 146 */ "Clear" OpHelp(""),
37842 /* 147 */ "ResetSorter" OpHelp(""),
37843 /* 148 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
37844 /* 149 */ "SqlExec" OpHelp(""),
37845 /* 150 */ "ParseSchema" OpHelp(""),
37846 /* 151 */ "LoadAnalysis" OpHelp(""),
37847 /* 152 */ "DropTable" OpHelp(""),
37848 /* 153 */ "DropIndex" OpHelp(""),
37849 /* 154 */ "Real" OpHelp("r[P2]=P4"),
37850 /* 155 */ "DropTrigger" OpHelp(""),
37851 /* 156 */ "IntegrityCk" OpHelp(""),
37852 /* 157 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
37853 /* 158 */ "Param" OpHelp(""),
37854 /* 159 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
37855 /* 160 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
37856 /* 161 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
37857 /* 162 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
37858 /* 163 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
37859 /* 164 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
37860 /* 165 */ "AggValue" OpHelp("r[P3]=value N=P2"),
37861 /* 166 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
37862 /* 167 */ "Expire" OpHelp(""),
37863 /* 168 */ "CursorLock" OpHelp(""),
37864 /* 169 */ "CursorUnlock" OpHelp(""),
37865 /* 170 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
37866 /* 171 */ "VBegin" OpHelp(""),
37867 /* 172 */ "VCreate" OpHelp(""),
37868 /* 173 */ "VDestroy" OpHelp(""),
37869 /* 174 */ "VOpen" OpHelp(""),
37870 /* 175 */ "VCheck" OpHelp(""),
37871 /* 176 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
37872 /* 177 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
37873 /* 178 */ "VRename" OpHelp(""),
37874 /* 179 */ "Pagecount" OpHelp(""),
37875 /* 180 */ "MaxPgcnt" OpHelp(""),
37876 /* 181 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"),
37877 /* 182 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"),
37878 /* 183 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"),
37879 /* 184 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
37880 /* 185 */ "Trace" OpHelp(""),
37881 /* 186 */ "CursorHint" OpHelp(""),
37882 /* 187 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
37883 /* 188 */ "Noop" OpHelp(""),
37884 /* 189 */ "Explain" OpHelp(""),
37885 /* 190 */ "Abortable" OpHelp(""),
37886 };
37887 return azName[i];
37888 }
37889 #endif
37890
@@ -73586,14 +73593,14 @@
73593 u8 *pTmp; /* Temporary ptr into data[] */
73594
73595 assert( pPage->pBt!=0 );
73596 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
73597 assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
73598 assert( CORRUPT_DB || iEnd <= (int)pPage->pBt->usableSize );
73599 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
73600 assert( iSize>=4 ); /* Minimum cell size is 4 */
73601 assert( CORRUPT_DB || iStart<=(int)pPage->pBt->usableSize-4 );
73602
73603 /* The list of freeblocks must be in ascending order. Find the
73604 ** spot on the list where iStart should be inserted.
73605 */
73606 hdr = pPage->hdrOffset;
@@ -77323,10 +77330,34 @@
77330 *pRes = 1;
77331 rc = SQLITE_OK;
77332 }
77333 return rc;
77334 }
77335
77336 /* Set *pRes to 1 (true) if the BTree pointed to by cursor pCur contains zero
77337 ** rows of content. Set *pRes to 0 (false) if the table contains content.
77338 ** Return SQLITE_OK on success or some error code (ex: SQLITE_NOMEM) if
77339 ** something goes wrong.
77340 */
77341 SQLITE_PRIVATE int sqlite3BtreeIsEmpty(BtCursor *pCur, int *pRes){
77342 int rc;
77343
77344 assert( cursorOwnsBtShared(pCur) );
77345 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
77346 if( pCur->eState==CURSOR_VALID ){
77347 *pRes = 0;
77348 return SQLITE_OK;
77349 }
77350 rc = moveToRoot(pCur);
77351 if( rc==SQLITE_EMPTY ){
77352 *pRes = 1;
77353 rc = SQLITE_OK;
77354 }else{
77355 *pRes = 0;
77356 }
77357 return rc;
77358 }
77359
77360 #ifdef SQLITE_DEBUG
77361 /* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that
77362 ** this flags are true for a consistent database.
77363 **
@@ -100850,10 +100881,36 @@
100881 VdbeBranchTaken(res!=0,2);
100882 if( res ) goto jump_to_p2;
100883 }
100884 break;
100885 }
100886
100887 /* Opcode: IfEmpty P1 P2 * * *
100888 ** Synopsis: if( empty(P1) ) goto P2
100889 **
100890 ** Check to see if the b-tree table that cursor P1 references is empty
100891 ** and jump to P2 if it is.
100892 */
100893 case OP_IfEmpty: { /* jump */
100894 VdbeCursor *pC;
100895 BtCursor *pCrsr;
100896 int res;
100897
100898 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
100899 assert( pOp->p2>=0 && pOp->p2<p->nOp );
100900
100901 pC = p->apCsr[pOp->p1];
100902 assert( pC!=0 );
100903 assert( pC->eCurType==CURTYPE_BTREE );
100904 pCrsr = pC->uc.pCursor;
100905 assert( pCrsr );
100906 rc = sqlite3BtreeIsEmpty(pCrsr, &res);
100907 if( rc ) goto abort_due_to_error;
100908 VdbeBranchTaken(res!=0,2);
100909 if( res ) goto jump_to_p2;
100910 break;
100911 }
100912
100913 /* Opcode: Next P1 P2 P3 * P5
100914 **
100915 ** Advance cursor P1 so that it points to the next key/data pair in its
100916 ** table or index. If there are no more key/value pairs then fall through
@@ -102722,11 +102779,18 @@
102779 sqlite3_vtab_cursor *pVCur;
102780 sqlite3_vtab *pVtab;
102781 const sqlite3_module *pModule;
102782
102783 assert( p->bIsReader );
102784 pCur = p->apCsr[pOp->p1];
102785 if( pCur!=0
102786 && ALWAYS( pCur->eCurType==CURTYPE_VTAB )
102787 && ALWAYS( pCur->uc.pVCur->pVtab==pOp->p4.pVtab->pVtab )
102788 ){
102789 /* This opcode is a no-op if the cursor is already open */
102790 break;
102791 }
102792 pVCur = 0;
102793 pVtab = pOp->p4.pVtab->pVtab;
102794 if( pVtab==0 || NEVER(pVtab->pModule==0) ){
102795 rc = SQLITE_LOCKED;
102796 goto abort_due_to_error;
@@ -109563,15 +109627,20 @@
109627 ** type of the function
109628 */
109629 return WRC_Prune;
109630 }
109631 #ifndef SQLITE_OMIT_SUBQUERY
109632 case TK_EXISTS:
109633 assert( ExprUseXSelect(pExpr) );
109634 pParse->bHasExists = 1;
109635 /* no break */ deliberate_fall_through
109636 case TK_SELECT:
 
109637 #endif
109638 case TK_IN: {
109639 testcase( pExpr->op==TK_IN );
109640 testcase( pExpr->op==TK_EXISTS );
109641 testcase( pExpr->op==TK_SELECT );
109642 if( ExprUseXSelect(pExpr) ){
109643 int nRef = pNC->nRef;
109644 testcase( pNC->ncFlags & NC_IsCheck );
109645 testcase( pNC->ncFlags & NC_PartIdx );
109646 testcase( pNC->ncFlags & NC_IdxExpr );
@@ -111660,11 +111729,11 @@
111729 return pRight;
111730 }else if( pRight==0 ){
111731 return pLeft;
111732 }else{
111733 u32 f = pLeft->flags | pRight->flags;
111734 if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse|EP_HasFunc))==EP_IsFalse
111735 && !IN_RENAME_OBJECT
111736 ){
111737 sqlite3ExprDeferredDelete(pParse, pLeft);
111738 sqlite3ExprDeferredDelete(pParse, pRight);
111739 return sqlite3Expr(db, TK_INTEGER, "0");
@@ -112940,12 +113009,15 @@
113009 ** then compute the right operand first and do an IsNull jump if the
113010 ** right operand evalutes to NULL.
113011 */
113012 if( exprEvalRhsFirst(pExpr) && sqlite3ExprCanBeNull(pExpr->pRight) ){
113013 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2);
113014 addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r2);
113015 VdbeComment((v, "skip left operand"));
113016 VdbeCoverage(v);
113017 }else{
113018 r2 = 0; /* Silence a false-positive uninit-var warning in MSVC */
113019 addrIsNull = 0;
113020 }
113021 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, pFree1);
113022 if( addrIsNull==0 ){
113023 /*
@@ -112955,11 +113027,13 @@
113027 ** operand.
113028 */
113029 if( ExprHasProperty(pExpr->pRight, EP_Subquery)
113030 && sqlite3ExprCanBeNull(pExpr->pLeft)
113031 ){
113032 addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r1);
113033 VdbeComment((v, "skip right operand"));
113034 VdbeCoverage(v);
113035 }
113036 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2);
113037 }
113038 *pR1 = r1;
113039 *pR2 = r2;
@@ -114408,21 +114482,27 @@
114482 dest.eDest = SRT_Exists;
114483 sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
114484 VdbeComment((v, "Init EXISTS result"));
114485 }
114486 if( pSel->pLimit ){
114487 /* The subquery already has a limit. If the pre-existing limit X is
114488 ** not already integer value 1 or 0, then make the new limit X<>0 so that
114489 ** the new limit is either 1 or 0 */
114490 Expr *pLeft = pSel->pLimit->pLeft;
114491 if( ExprHasProperty(pLeft, EP_IntValue)==0
114492 || (pLeft->u.iValue!=1 && pLeft->u.iValue!=0)
114493 ){
114494 sqlite3 *db = pParse->db;
114495 pLimit = sqlite3Expr(db, TK_INTEGER, "0");
114496 if( pLimit ){
114497 pLimit->affExpr = SQLITE_AFF_NUMERIC;
114498 pLimit = sqlite3PExpr(pParse, TK_NE,
114499 sqlite3ExprDup(db, pLeft, 0), pLimit);
114500 }
114501 sqlite3ExprDeferredDelete(pParse, pLeft);
114502 pSel->pLimit->pLeft = pLimit;
114503 }
114504 }else{
114505 /* If there is no pre-existing limit add a limit of 1 */
114506 pLimit = sqlite3Expr(pParse->db, TK_INTEGER, "1");
114507 pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
114508 }
@@ -115628,10 +115708,11 @@
115708 testcase( regFree2==0 );
115709 if( addrIsNull ){
115710 sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
115711 sqlite3VdbeJumpHere(v, addrIsNull);
115712 sqlite3VdbeAddOp2(v, OP_Null, 0, target);
115713 VdbeComment((v, "short-circut value"));
115714 }
115715 break;
115716 }
115717 case TK_UMINUS: {
115718 Expr *pLeft = pExpr->pLeft;
@@ -128437,18 +128518,21 @@
128518 ** Append the contents of SrcList p2 to SrcList p1 and return the resulting
128519 ** SrcList. Or, if an error occurs, return NULL. In all cases, p1 and p2
128520 ** are deleted by this function.
128521 */
128522 SQLITE_PRIVATE SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, SrcList *p2){
128523 assert( p1 );
128524 if( p2 ){
128525 int nOld = p1->nSrc;
128526 SrcList *pNew = sqlite3SrcListEnlarge(pParse, p1, p2->nSrc, nOld);
128527 if( pNew==0 ){
128528 sqlite3SrcListDelete(pParse->db, p2);
128529 }else{
128530 p1 = pNew;
128531 memcpy(&p1->a[nOld], p2->a, p2->nSrc*sizeof(SrcItem));
128532 assert( nOld==1 || (p2->nSrc==1 && (p2->a[0].fg.jointype&JT_LTORJ)==0) );
128533 assert( p1->nSrc>=2 );
128534 sqlite3DbFree(pParse->db, p2);
128535 p1->a[0].fg.jointype |= (JT_LTORJ & p1->a[1].fg.jointype);
128536 }
128537 }
128538 return p1;
@@ -145523,11 +145607,11 @@
145607 SrcList *pSrc, /* Array of tables to search */
145608 int iStart, /* First member of pSrc->a[] to check */
145609 int iEnd, /* Last member of pSrc->a[] to check */
145610 const char *zCol, /* Name of the column we are looking for */
145611 int *piTab, /* Write index of pSrc->a[] here */
145612 int *piCol, /* Write index of pSrc->a[*piTab].pSTab->aCol[] here */
145613 int bIgnoreHidden /* Ignore hidden columns */
145614 ){
145615 int i; /* For looping over tables in pSrc */
145616 int iCol; /* Index of column matching zCol */
145617
@@ -148175,11 +148259,13 @@
148259 int unionTab; /* Cursor number of the temp table holding result */
148260 u8 op = 0; /* One of the SRT_ operations to apply to self */
148261 int priorOp; /* The SRT_ operation to apply to prior selects */
148262 Expr *pLimit; /* Saved values of p->nLimit */
148263 int addr;
148264 int emptyBypass = 0; /* IfEmpty opcode to bypass RHS */
148265 SelectDest uniondest;
148266
148267
148268 testcase( p->op==TK_EXCEPT );
148269 testcase( p->op==TK_UNION );
148270 priorOp = SRT_Union;
148271 if( dest.eDest==priorOp ){
@@ -148214,10 +148300,12 @@
148300
148301 /* Code the current SELECT statement
148302 */
148303 if( p->op==TK_EXCEPT ){
148304 op = SRT_Except;
148305 emptyBypass = sqlite3VdbeAddOp1(v, OP_IfEmpty, unionTab);
148306 VdbeCoverage(v);
148307 }else{
148308 assert( p->op==TK_UNION );
148309 op = SRT_Union;
148310 }
148311 p->pPrior = 0;
@@ -148234,10 +148322,11 @@
148322 p->pPrior = pPrior;
148323 p->pOrderBy = 0;
148324 if( p->op==TK_UNION ){
148325 p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
148326 }
148327 if( emptyBypass ) sqlite3VdbeJumpHere(v, emptyBypass);
148328 sqlite3ExprDelete(db, p->pLimit);
148329 p->pLimit = pLimit;
148330 p->iLimit = 0;
148331 p->iOffset = 0;
148332
@@ -148267,10 +148356,11 @@
148356 int iCont, iBreak, iStart;
148357 Expr *pLimit;
148358 int addr;
148359 SelectDest intersectdest;
148360 int r1;
148361 int emptyBypass;
148362
148363 /* INTERSECT is different from the others since it requires
148364 ** two temporary tables. Hence it has its own case. Begin
148365 ** by allocating the tables we will need.
148366 */
@@ -148290,10 +148380,11 @@
148380 TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT left...\n"));
148381 rc = sqlite3Select(pParse, pPrior, &intersectdest);
148382 if( rc ){
148383 goto multi_select_end;
148384 }
148385 emptyBypass = sqlite3VdbeAddOp1(v, OP_IfEmpty, tab1); VdbeCoverage(v);
148386
148387 /* Code the current SELECT into temporary table "tab2"
148388 */
148389 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
148390 assert( p->addrOpenEphm[1] == -1 );
@@ -148321,11 +148412,11 @@
148412 if( rc ) break;
148413 assert( p->pEList );
148414 iBreak = sqlite3VdbeMakeLabel(pParse);
148415 iCont = sqlite3VdbeMakeLabel(pParse);
148416 computeLimitRegisters(pParse, p, iBreak);
148417 sqlite3VdbeAddOp1(v, OP_Rewind, tab1);
148418 r1 = sqlite3GetTempReg(pParse);
148419 iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
148420 sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
148421 VdbeCoverage(v);
148422 sqlite3ReleaseTempReg(pParse, r1);
@@ -148333,10 +148424,11 @@
148424 0, 0, &dest, iCont, iBreak);
148425 sqlite3VdbeResolveLabel(v, iCont);
148426 sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);
148427 sqlite3VdbeResolveLabel(v, iBreak);
148428 sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);
148429 sqlite3VdbeJumpHere(v, emptyBypass);
148430 sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);
148431 break;
148432 }
148433 }
148434
@@ -149011,10 +149103,11 @@
149103 typedef struct SubstContext {
149104 Parse *pParse; /* The parsing context */
149105 int iTable; /* Replace references to this table */
149106 int iNewTable; /* New table number */
149107 int isOuterJoin; /* Add TK_IF_NULL_ROW opcodes on each replacement */
149108 int nSelDepth; /* Depth of sub-query recursion. Top==1 */
149109 ExprList *pEList; /* Replacement expressions */
149110 ExprList *pCList; /* Collation sequences for replacement expr */
149111 } SubstContext;
149112
149113 /* Forward Declarations */
@@ -149117,10 +149210,13 @@
149210 }
149211 }
149212 }else{
149213 if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
149214 pExpr->iTable = pSubst->iNewTable;
149215 }
149216 if( pExpr->op==TK_AGG_FUNCTION && pExpr->op2>=pSubst->nSelDepth ){
149217 pExpr->op2--;
149218 }
149219 pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);
149220 pExpr->pRight = substExpr(pSubst, pExpr->pRight);
149221 if( ExprUseXSelect(pExpr) ){
149222 substSelect(pSubst, pExpr->x.pSelect, 1);
@@ -149155,10 +149251,11 @@
149251 ){
149252 SrcList *pSrc;
149253 SrcItem *pItem;
149254 int i;
149255 if( !p ) return;
149256 pSubst->nSelDepth++;
149257 do{
149258 substExprList(pSubst, p->pEList);
149259 substExprList(pSubst, p->pGroupBy);
149260 substExprList(pSubst, p->pOrderBy);
149261 p->pHaving = substExpr(pSubst, p->pHaving);
@@ -149172,10 +149269,11 @@
149269 if( pItem->fg.isTabFunc ){
149270 substExprList(pSubst, pItem->u1.pFuncArg);
149271 }
149272 }
149273 }while( doPrior && (p = p->pPrior)!=0 );
149274 pSubst->nSelDepth--;
149275 }
149276 #endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
149277
149278 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
149279 /*
@@ -149783,11 +149881,11 @@
149881 /* Defer deleting the Table object associated with the
149882 ** subquery until code generation is
149883 ** complete, since there may still exist Expr.pTab entries that
149884 ** refer to the subquery even after flattening. Ticket #3346.
149885 **
149886 ** pSubitem->pSTab is always non-NULL by test restrictions and tests above.
149887 */
149888 if( ALWAYS(pSubitem->pSTab!=0) ){
149889 Table *pTabToDel = pSubitem->pSTab;
149890 if( pTabToDel->nTabRef==1 ){
149891 Parse *pToplevel = sqlite3ParseToplevel(pParse);
@@ -149913,10 +150011,11 @@
150011 SubstContext x;
150012 x.pParse = pParse;
150013 x.iTable = iParent;
150014 x.iNewTable = iNewParent;
150015 x.isOuterJoin = isOuterJoin;
150016 x.nSelDepth = 0;
150017 x.pEList = pSub->pEList;
150018 x.pCList = findLeftmostExprlist(pSub);
150019 substSelect(&x, pParent, 0);
150020 }
150021
@@ -150498,10 +150597,11 @@
150597 unsetJoinExpr(pNew, -1, 1);
150598 x.pParse = pParse;
150599 x.iTable = pSrc->iCursor;
150600 x.iNewTable = pSrc->iCursor;
150601 x.isOuterJoin = 0;
150602 x.nSelDepth = 0;
150603 x.pEList = pSubq->pEList;
150604 x.pCList = findLeftmostExprlist(pSubq);
150605 pNew = substExpr(&x, pNew);
150606 #ifndef SQLITE_OMIT_WINDOWFUNC
150607 if( pSubq->pWin && 0==pushDownWindowCheck(pParse, pSubq, pNew) ){
@@ -150895,11 +150995,11 @@
150995 ** a WITH clause on the stack currently maintained by the parser (on the
150996 ** pParse->pWith linked list). And if currently processing a CTE
150997 ** CTE expression, through routine checks to see if the reference is
150998 ** a recursive reference to the CTE.
150999 **
151000 ** If pFrom matches a CTE according to either of these two above, pFrom->pSTab
151001 ** and other fields are populated accordingly.
151002 **
151003 ** Return 0 if no match is found.
151004 ** Return 1 if a match is found.
151005 ** Return 2 if an error condition is detected.
@@ -152521,10 +152621,79 @@
152621 pItem--;
152622 if( pItem->fg.isSubquery ) return 0; /* (1c-i) */
152623 }
152624 return 1;
152625 }
152626
152627 /*
152628 ** Argument pWhere is the WHERE clause belonging to SELECT statement p. This
152629 ** function attempts to transform expressions of the form:
152630 **
152631 ** EXISTS (SELECT ...)
152632 **
152633 ** into joins. For example, given
152634 **
152635 ** CREATE TABLE sailors(sid INTEGER PRIMARY KEY, name TEXT);
152636 ** CREATE TABLE reserves(sid INT, day DATE, PRIMARY KEY(sid, day));
152637 **
152638 ** SELECT name FROM sailors AS S WHERE EXISTS (
152639 ** SELECT * FROM reserves AS R WHERE S.sid = R.sid AND R.day = '2022-10-25'
152640 ** );
152641 **
152642 ** the SELECT statement may be transformed as follows:
152643 **
152644 ** SELECT name FROM sailors AS S, reserves AS R
152645 ** WHERE S.sid = R.sid AND R.day = '2022-10-25';
152646 */
152647 static SQLITE_NOINLINE void existsToJoin(
152648 Parse *pParse,
152649 Select *p,
152650 Expr *pWhere
152651 ){
152652 if( pWhere
152653 && !ExprHasProperty(pWhere, EP_OuterON|EP_InnerON)
152654 && p->pSrc->nSrc>0
152655 && p->pSrc->nSrc<BMS
152656 && pParse->db->mallocFailed==0
152657 ){
152658 if( pWhere->op==TK_AND ){
152659 Expr *pRight = pWhere->pRight;
152660 existsToJoin(pParse, p, pWhere->pLeft);
152661 existsToJoin(pParse, p, pRight);
152662 }
152663 else if( pWhere->op==TK_EXISTS ){
152664 Select *pSub = pWhere->x.pSelect;
152665 if( pSub->pSrc->nSrc==1
152666 && (pSub->selFlags & SF_Aggregate)==0
152667 && pSub->pWhere
152668 && !pSub->pSrc->a[0].fg.isSubquery
152669 ){
152670 memset(pWhere, 0, sizeof(*pWhere));
152671 pWhere->op = TK_INTEGER;
152672 pWhere->u.iValue = 1;
152673 ExprSetProperty(pWhere, EP_IntValue);
152674
152675 assert( p->pWhere!=0 );
152676 pSub->pSrc->a[0].fg.fromExists = 1;
152677 pSub->pSrc->a[0].fg.jointype |= JT_CROSS;
152678 p->pSrc = sqlite3SrcListAppendList(pParse, p->pSrc, pSub->pSrc);
152679 p->pWhere = sqlite3PExpr(pParse, TK_AND, p->pWhere, pSub->pWhere);
152680
152681 pSub->pWhere = 0;
152682 pSub->pSrc = 0;
152683 sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pSub);
152684 #if TREETRACE_ENABLED
152685 if( sqlite3TreeTrace & 0x100000 ){
152686 TREETRACE(0x100000,pParse,p,
152687 ("After EXISTS-to-JOIN optimization:\n"));
152688 sqlite3TreeViewSelect(0, p, 0);
152689 }
152690 #endif
152691 }
152692 }
152693 }
152694 }
152695
152696 /*
152697 ** Generate byte-code for the SELECT statement given in the p argument.
152698 **
152699 ** The results are returned according to the SelectDest structure.
@@ -152889,10 +153058,17 @@
153058 #endif
153059 if( p->pNext==0 ) ExplainQueryPlanPop(pParse);
153060 return rc;
153061 }
153062 #endif
153063
153064 /* If there may be an "EXISTS (SELECT ...)" in the WHERE clause, attempt
153065 ** to change it into a join. */
153066 if( pParse->bHasExists && OptimizationEnabled(db,SQLITE_ExistsToJoin) ){
153067 existsToJoin(pParse, p, p->pWhere);
153068 pTabList = p->pSrc;
153069 }
153070
153071 /* Do the WHERE-clause constant propagation optimization if this is
153072 ** a join. No need to spend time on this operation for non-join queries
153073 ** as the equivalent optimization will be handled by query planner in
153074 ** sqlite3WhereBegin(). tag-select-0330
@@ -153676,24 +153852,24 @@
153852 ** over to a0,a1,a2. It then calls the output subroutine
153853 ** and resets the aggregate accumulator registers in preparation
153854 ** for the next GROUP BY batch.
153855 */
153856 sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
153857 VdbeComment((v, "output one row of %d", p->selId));
153858 sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr);
153859 sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); VdbeCoverage(v);
153860 VdbeComment((v, "check abort flag"));
153861 sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
153862 VdbeComment((v, "reset accumulator %d", p->selId));
153863
153864 /* Update the aggregate accumulators based on the content of
153865 ** the current row
153866 */
153867 sqlite3VdbeJumpHere(v, addr1);
153868 updateAccumulator(pParse, iUseFlag, pAggInfo, eDist);
153869 sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);
153870 VdbeComment((v, "indicate data in accumulator %d", p->selId));
153871
153872 /* End of the loop
153873 */
153874 if( groupBySort ){
153875 sqlite3VdbeAddOp2(v, OP_SorterNext, pAggInfo->sortingIdx,addrTopOfLoop);
@@ -153706,11 +153882,11 @@
153882 sqlite3ExprListDelete(db, pDistinct);
153883
153884 /* Output the final row of result
153885 */
153886 sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
153887 VdbeComment((v, "output final row of %d", p->selId));
153888
153889 /* Jump over the subroutines
153890 */
153891 sqlite3VdbeGoto(v, addrEnd);
153892
@@ -153727,26 +153903,26 @@
153903 sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
153904 sqlite3VdbeResolveLabel(v, addrOutputRow);
153905 addrOutputRow = sqlite3VdbeCurrentAddr(v);
153906 sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow+2);
153907 VdbeCoverage(v);
153908 VdbeComment((v, "Groupby result generator entry point %d", p->selId));
153909 sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
153910 finalizeAggFunctions(pParse, pAggInfo);
153911 sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);
153912 selectInnerLoop(pParse, p, -1, &sSort,
153913 &sDistinct, pDest,
153914 addrOutputRow+1, addrSetAbort);
153915 sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
153916 VdbeComment((v, "end groupby result generator %d", p->selId));
153917
153918 /* Generate a subroutine that will reset the group-by accumulator
153919 */
153920 sqlite3VdbeResolveLabel(v, addrReset);
153921 resetAccumulator(pParse, pAggInfo);
153922 sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);
153923 VdbeComment((v, "indicate accumulator %d empty", p->selId));
153924 sqlite3VdbeAddOp1(v, OP_Return, regReset);
153925
153926 if( distFlag!=0 && eDist!=WHERE_DISTINCT_NOOP ){
153927 struct AggInfo_func *pF = &pAggInfo->aFunc[0];
153928 fixDistinctOpenEph(pParse, eDist, pF->iDistinct, pF->iDistAddr);
@@ -159334,10 +159510,11 @@
159510 struct WhereLevel {
159511 int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
159512 int iTabCur; /* The VDBE cursor used to access the table */
159513 int iIdxCur; /* The VDBE cursor used to access pIdx */
159514 int addrBrk; /* Jump here to break out of the loop */
159515 int addrHalt; /* Abort the query due to empty table or similar */
159516 int addrNxt; /* Jump here to start the next IN combination */
159517 int addrSkip; /* Jump here for next iteration of skip-scan */
159518 int addrCont; /* Jump here to continue with the next loop cycle */
159519 int addrFirst; /* First instruction of interior of the loop */
159520 int addrBody; /* Beginning of the body of this loop */
@@ -160043,10 +160220,11 @@
160220 WhereLoop *pLoop; /* The controlling WhereLoop object */
160221 u32 flags; /* Flags that describe this loop */
160222 #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)
160223 char *zMsg; /* Text to add to EQP output */
160224 #endif
160225 const char *zFormat;
160226 StrAccum str; /* EQP output string */
160227 char zBuf[100]; /* Initial space for EQP output string */
160228
160229 if( db->mallocFailed ) return;
160230
@@ -160057,11 +160235,18 @@
160235 || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
160236 || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
160237
160238 sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
160239 str.printfFlags = SQLITE_PRINTF_INTERNAL;
160240 if( pItem->fg.fromExists ){
160241 zFormat = "SINGLETON %S";
160242 }else if( isSearch ){
160243 zFormat = "SEARCH %S";
160244 }else{
160245 zFormat = "SCAN %S";
160246 }
160247 sqlite3_str_appendf(&str, zFormat, pItem);
160248 if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){
160249 const char *zFmt = 0;
160250 Index *pIdx;
160251
160252 assert( pLoop->u.btree.pIndex!=0 );
@@ -161308,19 +161493,20 @@
161493 WhereInfo *pWInfo, /* Complete information about the WHERE clause */
161494 int iLevel, /* Which level of pWInfo->a[] should be coded */
161495 int addrNxt, /* Jump here to bypass inner loops */
161496 Bitmask notReady /* Loops that are not ready */
161497 ){
161498 int saved_addrBrk;
161499 while( ++iLevel < pWInfo->nLevel ){
161500 WhereLevel *pLevel = &pWInfo->a[iLevel];
161501 WhereLoop *pLoop = pLevel->pWLoop;
161502 if( pLevel->regFilter==0 ) continue;
161503 if( pLevel->pWLoop->nSkip ) continue;
161504 /* ,--- Because sqlite3ConstructBloomFilter() has will not have set
161505 ** vvvvv--' pLevel->regFilter if this were true. */
161506 if( NEVER(pLoop->prereq & notReady) ) continue;
161507 saved_addrBrk = pLevel->addrBrk;
161508 pLevel->addrBrk = addrNxt;
161509 if( pLoop->wsFlags & WHERE_IPK ){
161510 WhereTerm *pTerm = pLoop->aLTerm[0];
161511 int regRowid;
161512 assert( pTerm!=0 );
@@ -161346,11 +161532,11 @@
161532 sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
161533 addrNxt, r1, nEq);
161534 VdbeCoverage(pParse->pVdbe);
161535 }
161536 pLevel->regFilter = 0;
161537 pLevel->addrBrk = saved_addrBrk;
161538 }
161539 }
161540
161541 /*
161542 ** Loop pLoop is a WHERE_INDEXED level that uses at least one IN(...)
@@ -161393,11 +161579,10 @@
161579 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
161580 WhereTerm *pTerm; /* A WHERE clause term */
161581 sqlite3 *db; /* Database connection */
161582 SrcItem *pTabItem; /* FROM clause term being coded */
161583 int addrBrk; /* Jump here to break out of the loop */
 
161584 int addrCont; /* Jump here to continue with next cycle */
161585 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
161586 int iReleaseReg = 0; /* Temp register to free before returning */
161587 Index *pIdx = 0; /* Index used by loop (if any) */
161588 int iLoop; /* Iteration of constraint generator loop */
@@ -161437,11 +161622,11 @@
161622 ** When there is an IN operator, we also have a "addrNxt" label that
161623 ** means to continue with the next IN value combination. When
161624 ** there are no IN operators in the constraints, the "addrNxt" label
161625 ** is the same as "addrBrk".
161626 */
161627 addrBrk = pLevel->addrNxt = pLevel->addrBrk;
161628 addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(pParse);
161629
161630 /* If this is the right table of a LEFT OUTER JOIN, allocate and
161631 ** initialize a memory cell that records if this table matches any
161632 ** row of the left table of the join.
@@ -161453,18 +161638,10 @@
161638 pLevel->iLeftJoin = ++pParse->nMem;
161639 sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
161640 VdbeComment((v, "init LEFT JOIN match flag"));
161641 }
161642
 
 
 
 
 
 
 
 
161643 /* Special case of a FROM clause subquery implemented as a co-routine */
161644 if( pTabItem->fg.viaCoroutine ){
161645 int regYield;
161646 Subquery *pSubq;
161647 assert( pTabItem->fg.isSubquery && pTabItem->u4.pSubq!=0 );
@@ -161699,11 +161876,11 @@
161876 VdbeCoverageIf(v, pX->op==TK_LE);
161877 VdbeCoverageIf(v, pX->op==TK_LT);
161878 VdbeCoverageIf(v, pX->op==TK_GE);
161879 sqlite3ReleaseTempReg(pParse, rTemp);
161880 }else{
161881 sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, pLevel->addrHalt);
161882 VdbeCoverageIf(v, bRev==0);
161883 VdbeCoverageIf(v, bRev!=0);
161884 }
161885 if( pEnd ){
161886 Expr *pX;
@@ -162494,11 +162671,11 @@
162671 pLevel->op = OP_Noop;
162672 }else{
162673 codeCursorHint(pTabItem, pWInfo, pLevel, 0);
162674 pLevel->op = aStep[bRev];
162675 pLevel->p1 = iCur;
162676 pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev],iCur,pLevel->addrHalt);
162677 VdbeCoverageIf(v, bRev==0);
162678 VdbeCoverageIf(v, bRev!=0);
162679 pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
162680 }
162681 }
@@ -164509,11 +164686,11 @@
164686 ** SELECT statement passed as the second argument. These terms are only
164687 ** added if:
164688 **
164689 ** 1. The SELECT statement has a LIMIT clause, and
164690 ** 2. The SELECT statement is not an aggregate or DISTINCT query, and
164691 ** 3. The SELECT statement has exactly one object in its FROM clause, and
164692 ** that object is a virtual table, and
164693 ** 4. There are no terms in the WHERE clause that will not be passed
164694 ** to the virtual table xBestIndex method.
164695 ** 5. The ORDER BY clause, if any, will be made available to the xBestIndex
164696 ** method.
@@ -164546,12 +164723,26 @@
164723 ** pWC->a[] array. So this term can be ignored, as a LIMIT clause
164724 ** will only be added if each of the child terms passes the
164725 ** (leftCursor==iCsr) test below. */
164726 continue;
164727 }
164728 if( pWC->a[ii].leftCursor==iCsr && pWC->a[ii].prereqRight==0 ) continue;
164729
164730 /* If this term has a parent with exactly one child, and the parent will
164731 ** be passed through to xBestIndex, then this term can be ignored. */
164732 if( pWC->a[ii].iParent>=0 ){
164733 WhereTerm *pParent = &pWC->a[ pWC->a[ii].iParent ];
164734 if( pParent->leftCursor==iCsr
164735 && pParent->prereqRight==0
164736 && pParent->nChild==1
164737 ){
164738 continue;
164739 }
164740 }
164741
164742 /* This term will not be passed through. Do not add a LIMIT clause. */
164743 return;
164744 }
164745
164746 /* Check condition (5). Return early if it is not met. */
164747 if( pOrderBy ){
164748 for(ii=0; ii<pOrderBy->nExpr; ii++){
@@ -165986,11 +166177,13 @@
166177 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSubq->addrFillSub);
166178 addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield);
166179 VdbeCoverage(v);
166180 VdbeComment((v, "next row of %s", pSrc->pSTab->zName));
166181 }else{
166182 assert( pLevel->addrHalt );
166183 addrTop = sqlite3VdbeAddOp2(v, OP_Rewind,pLevel->iTabCur,pLevel->addrHalt);
166184 VdbeCoverage(v);
166185 }
166186 if( pPartial ){
166187 iContinue = sqlite3VdbeMakeLabel(pParse);
166188 sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);
166189 pLoop->wsFlags |= WHERE_PARTIALIDX;
@@ -166014,15 +166207,18 @@
166207 assert( pLevel->iIdxCur>0 );
166208 translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
166209 pSrc->u4.pSubq->regResult, pLevel->iIdxCur);
166210 sqlite3VdbeGoto(v, addrTop);
166211 pSrc->fg.viaCoroutine = 0;
166212 sqlite3VdbeJumpHere(v, addrTop);
166213 }else{
166214 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
166215 sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
166216 if( (pSrc->fg.jointype & JT_LEFT)!=0 ){
166217 sqlite3VdbeJumpHere(v, addrTop);
166218 }
166219 }
 
166220 sqlite3ReleaseTempReg(pParse, regRecord);
166221
166222 /* Jump here when skipping the initialization */
166223 sqlite3VdbeJumpHere(v, addrInit);
166224 sqlite3VdbeScanStatusRange(v, addrExp, addrExp, -1);
@@ -168298,10 +168494,11 @@
168494 && saved_nEq==pNew->nLTerm
168495 && pProbe->noSkipScan==0
168496 && pProbe->hasStat1!=0
168497 && OptimizationEnabled(db, SQLITE_SkipScan)
168498 && pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
168499 && pSrc->fg.fromExists==0
168500 && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
168501 ){
168502 LogEst nIter;
168503 pNew->u.btree.nEq++;
168504 pNew->nSkip++;
@@ -171855,10 +172052,18 @@
172052
172053 pTabItem = &pTabList->a[pLevel->iFrom];
172054 pTab = pTabItem->pSTab;
172055 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
172056 pLoop = pLevel->pWLoop;
172057 pLevel->addrBrk = sqlite3VdbeMakeLabel(pParse);
172058 if( ii==0 || (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
172059 pLevel->addrHalt = pLevel->addrBrk;
172060 }else if( pWInfo->a[ii-1].pRJ ){
172061 pLevel->addrHalt = pWInfo->a[ii-1].addrBrk;
172062 }else{
172063 pLevel->addrHalt = pWInfo->a[ii-1].addrHalt;
172064 }
172065 if( (pTab->tabFlags & TF_Ephemeral)!=0 || IsView(pTab) ){
172066 /* Do nothing */
172067 }else
172068 #ifndef SQLITE_OMIT_VIRTUALTABLE
172069 if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){
@@ -171906,10 +172111,17 @@
172111 }
172112 #ifdef SQLITE_ENABLE_COLUMN_USED_MASK
172113 sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, pTabItem->iCursor, 0, 0,
172114 (const u8*)&pTabItem->colUsed, P4_INT64);
172115 #endif
172116 if( ii>=2
172117 && (pTabItem[0].fg.jointype & (JT_LTORJ|JT_LEFT))==0
172118 && pLevel->addrHalt==pWInfo->a[0].addrHalt
172119 ){
172120 sqlite3VdbeAddOp2(v, OP_IfEmpty, pTabItem->iCursor, pWInfo->iBreak);
172121 VdbeCoverage(v);
172122 }
172123 }else{
172124 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
172125 }
172126 if( pLoop->wsFlags & WHERE_INDEXED ){
172127 Index *pIx = pLoop->u.btree.pIndex;
@@ -172162,10 +172374,13 @@
172374 VdbeCoverageIf(v, op==OP_SeekLT);
172375 VdbeCoverageIf(v, op==OP_SeekGT);
172376 sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);
172377 }
172378 #endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
172379 if( pTabList->a[pLevel->iFrom].fg.fromExists ){
172380 sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
172381 }
172382 /* The common case: Advance to the next row */
172383 if( pLevel->addrCont ) sqlite3VdbeResolveLabel(v, pLevel->addrCont);
172384 sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3);
172385 sqlite3VdbeChangeP5(v, pLevel->p5);
172386 VdbeCoverage(v);
@@ -180234,16 +180449,25 @@
180449 /* Expressions of the form
180450 **
180451 ** expr1 IN ()
180452 ** expr1 NOT IN ()
180453 **
180454 ** simplify to constants 0 (false) and 1 (true), respectively.
180455 **
180456 ** Except, do not apply this optimization if expr1 contains a function
180457 ** because that function might be an aggregate (we don't know yet whether
180458 ** it is or not) and if it is an aggregate, that could change the meaning
180459 ** of the whole query.
180460 */
180461 Expr *pB = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy502 ? "true" : "false");
180462 if( pB ) sqlite3ExprIdToTrueFalse(pB);
180463 if( !ExprHasProperty(yymsp[-4].minor.yy590, EP_HasFunc) ){
180464 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy590);
180465 yymsp[-4].minor.yy590 = pB;
180466 }else{
180467 yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_OR : TK_AND, pB, yymsp[-4].minor.yy590);
180468 }
180469 }else{
180470 Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
180471 if( yymsp[-1].minor.yy402->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy590->op!=TK_VECTOR ){
180472 yymsp[-1].minor.yy402->a[0].pExpr = 0;
180473 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
@@ -247032,22 +247256,24 @@
247256 if( pLast ){
247257 int iOff;
247258 fts5DataRelease(pIter->pLeaf);
247259 pIter->pLeaf = pLast;
247260 pIter->iLeafPgno = pgnoLast;
247261 if( p->rc==SQLITE_OK ){
247262 iOff = fts5LeafFirstRowidOff(pLast);
247263 if( iOff>pLast->szLeaf ){
247264 FTS5_CORRUPT_ITER(p, pIter);
247265 return;
247266 }
247267 iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid);
247268 pIter->iLeafOffset = iOff;
247269
247270 if( fts5LeafIsTermless(pLast) ){
247271 pIter->iEndofDoclist = pLast->nn+1;
247272 }else{
247273 pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast);
247274 }
247275 }
247276 }
247277
247278 fts5SegIterReverseInitPage(p, pIter);
247279 }
@@ -250396,11 +250622,11 @@
250622 }
250623 assert( pStruct->aLevel[i].nMerge<=nThis );
250624 }
250625
250626 nByte += (((i64)pStruct->nLevel)+1) * sizeof(Fts5StructureLevel);
250627 assert( nByte==(i64)SZ_FTS5STRUCTURE(pStruct->nLevel+2) );
250628 pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);
250629
250630 if( pNew ){
250631 Fts5StructureLevel *pLvl;
250632 nByte = nSeg * sizeof(Fts5StructureSegment);
@@ -257648,11 +257874,11 @@
257874 int nArg, /* Number of args */
257875 sqlite3_value **apUnused /* Function arguments */
257876 ){
257877 assert( nArg==0 );
257878 UNUSED_PARAM2(nArg, apUnused);
257879 sqlite3_result_text(pCtx, "fts5: 2025-07-04 14:24:18 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b", -1, SQLITE_TRANSIENT);
257880 }
257881
257882 /*
257883 ** Implementation of fts5_locale(LOCALE, TEXT) function.
257884 **
257885
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.51.0"
150150
#define SQLITE_VERSION_NUMBER 3051000
151
-#define SQLITE_SOURCE_ID "2025-06-30 16:41:40 0083d5169a46104a25355bdd9d5a2f4027b049191ebda571dd228477ec217296"
151
+#define SQLITE_SOURCE_ID "2025-07-04 14:24:18 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
157157
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.51.0"
150 #define SQLITE_VERSION_NUMBER 3051000
151 #define SQLITE_SOURCE_ID "2025-06-30 16:41:40 0083d5169a46104a25355bdd9d5a2f4027b049191ebda571dd228477ec217296"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.51.0"
150 #define SQLITE_VERSION_NUMBER 3051000
151 #define SQLITE_SOURCE_ID "2025-07-04 14:24:18 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157

Keyboard Shortcuts

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