Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | 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. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | experimental-sqlite |
| Files: | files | file ages | folders |
| SHA3-256: |
ec10b57f0a109744e599e1f97d506057 |
| User & Date: | drh 2025-07-04 22:21:38.238 |
Context
|
2025-07-04
| ||
| 22:21 | 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. Closed-Leaf check-in: ec10b57f0a user: drh tags: experimental-sqlite | |
|
2025-07-03
| ||
| 16:33 | Squished a stray character accidentally left behind by [1fd407f61a], noted [https://fossil-scm.org/forum/forumpost/871da8539f | on the forum]. check-in: 2b4a8b4c73 user: wyoung tags: trunk | |
Changes
Changes to extsrc/shell.c.
| ︙ | ︙ | |||
31836 31837 31838 31839 31840 31841 31842 31843 31844 31845 31846 31847 31848 31849 |
{ 0x00800000, 1, "FlttnUnionAll" },
{ 0x01000000, 1, "IndexedEXpr" },
{ 0x02000000, 1, "Coroutines" },
{ 0x04000000, 1, "NullUnusedCols" },
{ 0x08000000, 1, "OnePass" },
{ 0x10000000, 1, "OrderBySubq" },
{ 0x20000000, 1, "StarQuery" },
{ 0xffffffff, 0, "All" },
};
unsigned int curOpt;
unsigned int newOpt;
unsigned int m;
int ii;
int nOff;
| > | 31836 31837 31838 31839 31840 31841 31842 31843 31844 31845 31846 31847 31848 31849 31850 |
{ 0x00800000, 1, "FlttnUnionAll" },
{ 0x01000000, 1, "IndexedEXpr" },
{ 0x02000000, 1, "Coroutines" },
{ 0x04000000, 1, "NullUnusedCols" },
{ 0x08000000, 1, "OnePass" },
{ 0x10000000, 1, "OrderBySubq" },
{ 0x20000000, 1, "StarQuery" },
{ 0x40000000, 1, "ExistsToJoin" },
{ 0xffffffff, 0, "All" },
};
unsigned int curOpt;
unsigned int newOpt;
unsigned int m;
int ii;
int nOff;
|
| ︙ | ︙ |
Changes to extsrc/sqlite3.c.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 | ** the text of this file. Search for "Begin file sqlite3.h" to find the start ** of the embedded sqlite3.h header file.) Additional code files may be needed ** if you want a wrapper to interface SQLite with your choice of programming ** language. The code for the "sqlite3" command-line shell is also in a ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ** the text of this file. Search for "Begin file sqlite3.h" to find the start ** of the embedded sqlite3.h header file.) Additional code files may be needed ** if you want a wrapper to interface SQLite with your choice of programming ** language. The code for the "sqlite3" command-line shell is also in a ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in ** 6f98b16d210a9f5b6ca4b4599e3dab3263ed with changes in files: ** ** */ #ifndef SQLITE_AMALGAMATION #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 #ifndef SQLITE_PRIVATE |
| ︙ | ︙ | |||
463 464 465 466 467 468 469 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.51.0" #define SQLITE_VERSION_NUMBER 3051000 | | | 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.51.0" #define SQLITE_VERSION_NUMBER 3051000 #define SQLITE_SOURCE_ID "2025-07-04 14:24:18 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ | |||
15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 | ** 0x00004000 Push-down optimization ** 0x00008000 After all FROM-clause analysis ** 0x00010000 Beginning of DELETE/INSERT/UPDATE processing ** 0x00020000 Transform DISTINCT into GROUP BY ** 0x00040000 SELECT tree dump after all code has been generated ** 0x00080000 NOT NULL strength reduction ** 0x00100000 Pointers are all shown as zero */ /* ** Macros for "wheretrace" */ SQLITE_PRIVATE u32 sqlite3WhereTrace; #if defined(SQLITE_DEBUG) \ | > | 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 | ** 0x00004000 Push-down optimization ** 0x00008000 After all FROM-clause analysis ** 0x00010000 Beginning of DELETE/INSERT/UPDATE processing ** 0x00020000 Transform DISTINCT into GROUP BY ** 0x00040000 SELECT tree dump after all code has been generated ** 0x00080000 NOT NULL strength reduction ** 0x00100000 Pointers are all shown as zero ** 0x00200000 EXISTS-to-JOIN optimization */ /* ** Macros for "wheretrace" */ SQLITE_PRIVATE u32 sqlite3WhereTrace; #if defined(SQLITE_DEBUG) \ |
| ︙ | ︙ | |||
16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 |
int nData; /* Size of pData. 0 if none. */
int nZero; /* Extra zero data appended after pData,nData */
};
SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
int flags, int seekResult);
SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
SQLITE_PRIVATE void sqlite3BtreeCursorPin(BtCursor*);
SQLITE_PRIVATE void sqlite3BtreeCursorUnpin(BtCursor*);
| > | 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 |
int nData; /* Size of pData. 0 if none. */
int nZero; /* Extra zero data appended after pData,nData */
};
SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
int flags, int seekResult);
SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
SQLITE_PRIVATE int sqlite3BtreeIsEmpty(BtCursor *pCur, int *pRes);
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
SQLITE_PRIVATE void sqlite3BtreeCursorPin(BtCursor*);
SQLITE_PRIVATE void sqlite3BtreeCursorUnpin(BtCursor*);
|
| ︙ | ︙ | |||
17081 17082 17083 17084 17085 17086 17087 | #define OP_SeekRowid 30 /* jump0, synopsis: intkey=r[P3] */ #define OP_NotExists 31 /* jump, synopsis: intkey=r[P3] */ #define OP_Last 32 /* jump0 */ #define OP_IfSizeBetween 33 /* jump */ #define OP_SorterSort 34 /* jump */ #define OP_Sort 35 /* jump */ #define OP_Rewind 36 /* jump0 */ | > | | | < | | | > | | | | < > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 |
#define OP_SeekRowid 30 /* jump0, synopsis: intkey=r[P3] */
#define OP_NotExists 31 /* jump, synopsis: intkey=r[P3] */
#define OP_Last 32 /* jump0 */
#define OP_IfSizeBetween 33 /* jump */
#define OP_SorterSort 34 /* jump */
#define OP_Sort 35 /* jump */
#define OP_Rewind 36 /* jump0 */
#define OP_IfEmpty 37 /* jump, synopsis: if( empty(P1) ) goto P2 */
#define OP_SorterNext 38 /* jump */
#define OP_Prev 39 /* jump */
#define OP_Next 40 /* jump */
#define OP_IdxLE 41 /* jump, synopsis: key=r[P3@P4] */
#define OP_IdxGT 42 /* jump, synopsis: key=r[P3@P4] */
#define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
#define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
#define OP_IdxLT 45 /* jump, synopsis: key=r[P3@P4] */
#define OP_IdxGE 46 /* jump, synopsis: key=r[P3@P4] */
#define OP_RowSetRead 47 /* jump, synopsis: r[P3]=rowset(P1) */
#define OP_RowSetTest 48 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
#define OP_Program 49 /* jump0 */
#define OP_FkIfZero 50 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
#define OP_IsNull 51 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
#define OP_NotNull 52 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
#define OP_Ne 53 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
#define OP_Eq 54 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
#define OP_Gt 55 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
#define OP_Le 56 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
#define OP_Lt 57 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
#define OP_Ge 58 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
#define OP_ElseEq 59 /* jump, same as TK_ESCAPE */
#define OP_IfPos 60 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
#define OP_IfNotZero 61 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
#define OP_DecrJumpZero 62 /* jump, synopsis: if (--r[P1])==0 goto P2 */
#define OP_IncrVacuum 63 /* jump */
#define OP_VNext 64 /* jump */
#define OP_Filter 65 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
#define OP_PureFunc 66 /* synopsis: r[P3]=func(r[P2@NP]) */
#define OP_Function 67 /* synopsis: r[P3]=func(r[P2@NP]) */
#define OP_Return 68
#define OP_EndCoroutine 69
#define OP_HaltIfNull 70 /* synopsis: if r[P3]=null halt */
#define OP_Halt 71
#define OP_Integer 72 /* synopsis: r[P2]=P1 */
#define OP_Int64 73 /* synopsis: r[P2]=P4 */
#define OP_String 74 /* synopsis: r[P2]='P4' (len=P1) */
#define OP_BeginSubrtn 75 /* synopsis: r[P2]=NULL */
#define OP_Null 76 /* synopsis: r[P2..P3]=NULL */
#define OP_SoftNull 77 /* synopsis: r[P1]=NULL */
#define OP_Blob 78 /* synopsis: r[P2]=P4 (len=P1) */
#define OP_Variable 79 /* synopsis: r[P2]=parameter(P1) */
#define OP_Move 80 /* synopsis: r[P2@P3]=r[P1@P3] */
#define OP_Copy 81 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
#define OP_SCopy 82 /* synopsis: r[P2]=r[P1] */
#define OP_IntCopy 83 /* synopsis: r[P2]=r[P1] */
#define OP_FkCheck 84
#define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */
#define OP_CollSeq 86
#define OP_AddImm 87 /* synopsis: r[P1]=r[P1]+P2 */
#define OP_RealAffinity 88
#define OP_Cast 89 /* synopsis: affinity(r[P1]) */
#define OP_Permutation 90
#define OP_Compare 91 /* synopsis: r[P1@P3] <-> r[P2@P3] */
#define OP_IsTrue 92 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
#define OP_ZeroOrNull 93 /* synopsis: r[P2] = 0 OR NULL */
#define OP_Offset 94 /* synopsis: r[P3] = sqlite_offset(P1) */
#define OP_Column 95 /* synopsis: r[P3]=PX cursor P1 column P2 */
#define OP_TypeCheck 96 /* synopsis: typecheck(r[P1@P2]) */
#define OP_Affinity 97 /* synopsis: affinity(r[P1@P2]) */
#define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
#define OP_Count 99 /* synopsis: r[P2]=count() */
#define OP_ReadCookie 100
#define OP_SetCookie 101
#define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
#define OP_BitAnd 103 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
#define OP_BitOr 104 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
#define OP_ShiftLeft 105 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
#define OP_ShiftRight 106 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
#define OP_Add 107 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
#define OP_Subtract 108 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
#define OP_Multiply 109 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
#define OP_Divide 110 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
#define OP_Remainder 111 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
#define OP_Concat 112 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
#define OP_OpenRead 113 /* synopsis: root=P2 iDb=P3 */
#define OP_OpenWrite 114 /* synopsis: root=P2 iDb=P3 */
#define OP_BitNot 115 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
#define OP_OpenDup 116
#define OP_OpenAutoindex 117 /* synopsis: nColumn=P2 */
#define OP_String8 118 /* same as TK_STRING, synopsis: r[P2]='P4' */
#define OP_OpenEphemeral 119 /* synopsis: nColumn=P2 */
#define OP_SorterOpen 120
#define OP_SequenceTest 121 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
#define OP_OpenPseudo 122 /* synopsis: P3 columns in r[P2] */
#define OP_Close 123
#define OP_ColumnsUsed 124
#define OP_SeekScan 125 /* synopsis: Scan-ahead up to P1 rows */
#define OP_SeekHit 126 /* synopsis: set P2<=seekHit<=P3 */
#define OP_Sequence 127 /* synopsis: r[P2]=cursor[P1].ctr++ */
#define OP_NewRowid 128 /* synopsis: r[P2]=rowid */
#define OP_Insert 129 /* synopsis: intkey=r[P3] data=r[P2] */
#define OP_RowCell 130
#define OP_Delete 131
#define OP_ResetCount 132
#define OP_SorterCompare 133 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
#define OP_SorterData 134 /* synopsis: r[P2]=data */
#define OP_RowData 135 /* synopsis: r[P2]=data */
#define OP_Rowid 136 /* synopsis: r[P2]=PX rowid of P1 */
#define OP_NullRow 137
#define OP_SeekEnd 138
#define OP_IdxInsert 139 /* synopsis: key=r[P2] */
#define OP_SorterInsert 140 /* synopsis: key=r[P2] */
#define OP_IdxDelete 141 /* synopsis: key=r[P2@P3] */
#define OP_DeferredSeek 142 /* synopsis: Move P3 to P1.rowid if needed */
#define OP_IdxRowid 143 /* synopsis: r[P2]=rowid */
#define OP_FinishSeek 144
#define OP_Destroy 145
#define OP_Clear 146
#define OP_ResetSorter 147
#define OP_CreateBtree 148 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
#define OP_SqlExec 149
#define OP_ParseSchema 150
#define OP_LoadAnalysis 151
#define OP_DropTable 152
#define OP_DropIndex 153
#define OP_Real 154 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
#define OP_DropTrigger 155
#define OP_IntegrityCk 156
#define OP_RowSetAdd 157 /* synopsis: rowset(P1)=r[P2] */
#define OP_Param 158
#define OP_FkCounter 159 /* synopsis: fkctr[P1]+=P2 */
#define OP_MemMax 160 /* synopsis: r[P1]=max(r[P1],r[P2]) */
#define OP_OffsetLimit 161 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
#define OP_AggInverse 162 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
#define OP_AggStep 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */
#define OP_AggStep1 164 /* synopsis: accum=r[P3] step(r[P2@P5]) */
#define OP_AggValue 165 /* synopsis: r[P3]=value N=P2 */
#define OP_AggFinal 166 /* synopsis: accum=r[P1] N=P2 */
#define OP_Expire 167
#define OP_CursorLock 168
#define OP_CursorUnlock 169
#define OP_TableLock 170 /* synopsis: iDb=P1 root=P2 write=P3 */
#define OP_VBegin 171
#define OP_VCreate 172
#define OP_VDestroy 173
#define OP_VOpen 174
#define OP_VCheck 175
#define OP_VInitIn 176 /* synopsis: r[P2]=ValueList(P1,P3) */
#define OP_VColumn 177 /* synopsis: r[P3]=vcolumn(P2) */
#define OP_VRename 178
#define OP_Pagecount 179
#define OP_MaxPgcnt 180
#define OP_ClrSubtype 181 /* synopsis: r[P1].subtype = 0 */
#define OP_GetSubtype 182 /* synopsis: r[P2] = r[P1].subtype */
#define OP_SetSubtype 183 /* synopsis: r[P2].subtype = r[P1] */
#define OP_FilterAdd 184 /* synopsis: filter(P1) += key(P3@P4) */
#define OP_Trace 185
#define OP_CursorHint 186
#define OP_ReleaseReg 187 /* synopsis: release r[P1@P2] mask P3 */
#define OP_Noop 188
#define OP_Explain 189
#define OP_Abortable 190
/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
** are encoded into bitvectors as follows:
*/
#define OPFLG_JUMP 0x01 /* jump: P2 holds jmp target */
#define OPFLG_IN1 0x02 /* in1: P1 is an input */
#define OPFLG_IN2 0x04 /* in2: P2 is an input */
#define OPFLG_IN3 0x08 /* in3: P3 is an input */
#define OPFLG_OUT2 0x10 /* out2: P2 is an output */
#define OPFLG_OUT3 0x20 /* out3: P3 is an output */
#define OPFLG_NCYCLE 0x40 /* ncycle:Cycles count against P1 */
#define OPFLG_JUMP0 0x80 /* jump0: P2 might be zero */
#define OPFLG_INITIALIZER {\
/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\
/* 8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\
/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\
/* 24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\
/* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x01, 0x41,\
/* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x41, 0x23,\
/* 48 */ 0x0b, 0x81, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\
/* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01,\
/* 64 */ 0x41, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00,\
/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\
/* 80 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02,\
/* 88 */ 0x02, 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40,\
/* 96 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x26,\
/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
/* 112 */ 0x26, 0x40, 0x00, 0x12, 0x40, 0x40, 0x10, 0x40,\
/* 120 */ 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10,\
/* 128 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,\
/* 136 */ 0x50, 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50,\
/* 144 */ 0x40, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\
/* 152 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00,\
/* 160 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10,\
/* 176 */ 0x50, 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12,\
/* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}
/* The resolve3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode. The smaller the maximum
** JUMP opcode the better, so the mkopcodeh.tcl script that
** generated this include file strives to group all JUMP opcodes
** together near the beginning of the list.
*/
#define SQLITE_MX_JUMP_OPCODE 65 /* Maximum JUMP opcode */
/************** End of opcodes.h *********************************************/
/************** Continuing where we left off in vdbe.h ***********************/
/*
** Additional non-public SQLITE_PREPARE_* flags
*/
|
| ︙ | ︙ | |||
18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 | /* TH3 expects this value ^^^^^^^^^^ See flatten04.test */ #define SQLITE_IndexedExpr 0x01000000 /* Pull exprs from index when able */ #define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */ #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */ #define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */ #define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */ #define SQLITE_StarQuery 0x20000000 /* Heurists for star queries */ #define SQLITE_AllOpts 0xffffffff /* All optimizations */ /* ** Macros for testing whether or not optimizations are enabled or disabled. */ #define OptimizationDisabled(db, mask) (((db)->dbOptFlags&(mask))!=0) #define OptimizationEnabled(db, mask) (((db)->dbOptFlags&(mask))==0) | > | 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 | /* TH3 expects this value ^^^^^^^^^^ See flatten04.test */ #define SQLITE_IndexedExpr 0x01000000 /* Pull exprs from index when able */ #define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */ #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */ #define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */ #define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */ #define SQLITE_StarQuery 0x20000000 /* Heurists for star queries */ #define SQLITE_ExistsToJoin 0x40000000 /* The EXISTS-to-JOIN optimization */ #define SQLITE_AllOpts 0xffffffff /* All optimizations */ /* ** Macros for testing whether or not optimizations are enabled or disabled. */ #define OptimizationDisabled(db, mask) (((db)->dbOptFlags&(mask))!=0) #define OptimizationEnabled(db, mask) (((db)->dbOptFlags&(mask))==0) |
| ︙ | ︙ | |||
19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 |
unsigned isUsing :1; /* u3.pUsing is valid */
unsigned isOn :1; /* u3.pOn was once valid and non-NULL */
unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */
unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */
unsigned rowidUsed :1; /* The ROWID of this table is referenced */
unsigned fixedSchema :1; /* Uses u4.pSchema, not u4.zDatabase */
unsigned hadSchema :1; /* Had u4.zDatabase before u4.pSchema */
} fg;
int iCursor; /* The VDBE cursor number used to access this table */
Bitmask colUsed; /* Bit N set if column N used. Details above for N>62 */
union {
char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */
ExprList *pFuncArg; /* Arguments to table-valued-function */
u32 nRow; /* Number of rows in a VALUES clause */
| > | 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 |
unsigned isUsing :1; /* u3.pUsing is valid */
unsigned isOn :1; /* u3.pOn was once valid and non-NULL */
unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */
unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */
unsigned rowidUsed :1; /* The ROWID of this table is referenced */
unsigned fixedSchema :1; /* Uses u4.pSchema, not u4.zDatabase */
unsigned hadSchema :1; /* Had u4.zDatabase before u4.pSchema */
unsigned fromExists :1; /* Comes from WHERE EXISTS(...) */
} fg;
int iCursor; /* The VDBE cursor number used to access this table */
Bitmask colUsed; /* Bit N set if column N used. Details above for N>62 */
union {
char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */
ExprList *pFuncArg; /* Arguments to table-valued-function */
u32 nRow; /* Number of rows in a VALUES clause */
|
| ︙ | ︙ | |||
20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 | u8 nTempReg; /* Number of temporary registers in aTempReg[] */ u8 isMultiWrite; /* True if statement may modify/insert multiple rows */ u8 mayAbort; /* True if statement may throw an ABORT exception */ u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */ u8 disableLookaside; /* Number of times lookaside has been disabled */ u8 prepFlags; /* SQLITE_PREPARE_* flags */ u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */ u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */ u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ u8 bReturning; /* Coding a RETURNING trigger */ u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ u8 disableTriggers; /* True to disable triggers */ #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */ | > | 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 | u8 nTempReg; /* Number of temporary registers in aTempReg[] */ u8 isMultiWrite; /* True if statement may modify/insert multiple rows */ u8 mayAbort; /* True if statement may throw an ABORT exception */ u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */ u8 disableLookaside; /* Number of times lookaside has been disabled */ u8 prepFlags; /* SQLITE_PREPARE_* flags */ u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */ u8 bHasExists; /* Has a correlated "EXISTS (SELECT ....)" expression */ u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */ u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ u8 bReturning; /* Coding a RETURNING trigger */ u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ u8 disableTriggers; /* True to disable triggers */ #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */ |
| ︙ | ︙ | |||
37719 37720 37721 37722 37723 37724 37725 |
/* 30 */ "SeekRowid" OpHelp("intkey=r[P3]"),
/* 31 */ "NotExists" OpHelp("intkey=r[P3]"),
/* 32 */ "Last" OpHelp(""),
/* 33 */ "IfSizeBetween" OpHelp(""),
/* 34 */ "SorterSort" OpHelp(""),
/* 35 */ "Sort" OpHelp(""),
/* 36 */ "Rewind" OpHelp(""),
| > | | | | | < > | | | | | < > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < > | < > | < > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 37725 37726 37727 37728 37729 37730 37731 37732 37733 37734 37735 37736 37737 37738 37739 37740 37741 37742 37743 37744 37745 37746 37747 37748 37749 37750 37751 37752 37753 37754 37755 37756 37757 37758 37759 37760 37761 37762 37763 37764 37765 37766 37767 37768 37769 37770 37771 37772 37773 37774 37775 37776 37777 37778 37779 37780 37781 37782 37783 37784 37785 37786 37787 37788 37789 37790 37791 37792 37793 37794 37795 37796 37797 37798 37799 37800 37801 37802 37803 37804 37805 37806 37807 37808 37809 37810 37811 37812 37813 37814 37815 37816 37817 37818 37819 37820 37821 37822 37823 37824 37825 37826 37827 37828 37829 37830 37831 37832 37833 37834 37835 37836 37837 37838 37839 37840 37841 37842 37843 37844 37845 37846 37847 37848 37849 37850 37851 37852 37853 37854 37855 37856 37857 37858 37859 37860 37861 37862 37863 37864 37865 37866 37867 37868 37869 37870 37871 37872 37873 37874 37875 37876 37877 37878 37879 37880 37881 37882 37883 37884 37885 37886 37887 37888 37889 37890 37891 37892 |
/* 30 */ "SeekRowid" OpHelp("intkey=r[P3]"),
/* 31 */ "NotExists" OpHelp("intkey=r[P3]"),
/* 32 */ "Last" OpHelp(""),
/* 33 */ "IfSizeBetween" OpHelp(""),
/* 34 */ "SorterSort" OpHelp(""),
/* 35 */ "Sort" OpHelp(""),
/* 36 */ "Rewind" OpHelp(""),
/* 37 */ "IfEmpty" OpHelp("if( empty(P1) ) goto P2"),
/* 38 */ "SorterNext" OpHelp(""),
/* 39 */ "Prev" OpHelp(""),
/* 40 */ "Next" OpHelp(""),
/* 41 */ "IdxLE" OpHelp("key=r[P3@P4]"),
/* 42 */ "IdxGT" OpHelp("key=r[P3@P4]"),
/* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
/* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
/* 45 */ "IdxLT" OpHelp("key=r[P3@P4]"),
/* 46 */ "IdxGE" OpHelp("key=r[P3@P4]"),
/* 47 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
/* 48 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
/* 49 */ "Program" OpHelp(""),
/* 50 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
/* 51 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
/* 52 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
/* 53 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
/* 54 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
/* 55 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
/* 56 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
/* 57 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
/* 58 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
/* 59 */ "ElseEq" OpHelp(""),
/* 60 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
/* 61 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
/* 62 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
/* 63 */ "IncrVacuum" OpHelp(""),
/* 64 */ "VNext" OpHelp(""),
/* 65 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
/* 66 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
/* 67 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
/* 68 */ "Return" OpHelp(""),
/* 69 */ "EndCoroutine" OpHelp(""),
/* 70 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
/* 71 */ "Halt" OpHelp(""),
/* 72 */ "Integer" OpHelp("r[P2]=P1"),
/* 73 */ "Int64" OpHelp("r[P2]=P4"),
/* 74 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
/* 75 */ "BeginSubrtn" OpHelp("r[P2]=NULL"),
/* 76 */ "Null" OpHelp("r[P2..P3]=NULL"),
/* 77 */ "SoftNull" OpHelp("r[P1]=NULL"),
/* 78 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
/* 79 */ "Variable" OpHelp("r[P2]=parameter(P1)"),
/* 80 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
/* 81 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
/* 82 */ "SCopy" OpHelp("r[P2]=r[P1]"),
/* 83 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
/* 84 */ "FkCheck" OpHelp(""),
/* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"),
/* 86 */ "CollSeq" OpHelp(""),
/* 87 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
/* 88 */ "RealAffinity" OpHelp(""),
/* 89 */ "Cast" OpHelp("affinity(r[P1])"),
/* 90 */ "Permutation" OpHelp(""),
/* 91 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
/* 92 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
/* 93 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
/* 94 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
/* 95 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"),
/* 96 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
/* 97 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
/* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
/* 99 */ "Count" OpHelp("r[P2]=count()"),
/* 100 */ "ReadCookie" OpHelp(""),
/* 101 */ "SetCookie" OpHelp(""),
/* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
/* 103 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
/* 104 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
/* 105 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
/* 106 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
/* 107 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
/* 108 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
/* 109 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
/* 110 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
/* 111 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
/* 112 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
/* 113 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
/* 114 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
/* 115 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
/* 116 */ "OpenDup" OpHelp(""),
/* 117 */ "OpenAutoindex" OpHelp("nColumn=P2"),
/* 118 */ "String8" OpHelp("r[P2]='P4'"),
/* 119 */ "OpenEphemeral" OpHelp("nColumn=P2"),
/* 120 */ "SorterOpen" OpHelp(""),
/* 121 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
/* 122 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
/* 123 */ "Close" OpHelp(""),
/* 124 */ "ColumnsUsed" OpHelp(""),
/* 125 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
/* 126 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
/* 127 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
/* 128 */ "NewRowid" OpHelp("r[P2]=rowid"),
/* 129 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
/* 130 */ "RowCell" OpHelp(""),
/* 131 */ "Delete" OpHelp(""),
/* 132 */ "ResetCount" OpHelp(""),
/* 133 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
/* 134 */ "SorterData" OpHelp("r[P2]=data"),
/* 135 */ "RowData" OpHelp("r[P2]=data"),
/* 136 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"),
/* 137 */ "NullRow" OpHelp(""),
/* 138 */ "SeekEnd" OpHelp(""),
/* 139 */ "IdxInsert" OpHelp("key=r[P2]"),
/* 140 */ "SorterInsert" OpHelp("key=r[P2]"),
/* 141 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
/* 142 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
/* 143 */ "IdxRowid" OpHelp("r[P2]=rowid"),
/* 144 */ "FinishSeek" OpHelp(""),
/* 145 */ "Destroy" OpHelp(""),
/* 146 */ "Clear" OpHelp(""),
/* 147 */ "ResetSorter" OpHelp(""),
/* 148 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
/* 149 */ "SqlExec" OpHelp(""),
/* 150 */ "ParseSchema" OpHelp(""),
/* 151 */ "LoadAnalysis" OpHelp(""),
/* 152 */ "DropTable" OpHelp(""),
/* 153 */ "DropIndex" OpHelp(""),
/* 154 */ "Real" OpHelp("r[P2]=P4"),
/* 155 */ "DropTrigger" OpHelp(""),
/* 156 */ "IntegrityCk" OpHelp(""),
/* 157 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
/* 158 */ "Param" OpHelp(""),
/* 159 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
/* 160 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
/* 161 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
/* 162 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
/* 163 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
/* 164 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
/* 165 */ "AggValue" OpHelp("r[P3]=value N=P2"),
/* 166 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
/* 167 */ "Expire" OpHelp(""),
/* 168 */ "CursorLock" OpHelp(""),
/* 169 */ "CursorUnlock" OpHelp(""),
/* 170 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
/* 171 */ "VBegin" OpHelp(""),
/* 172 */ "VCreate" OpHelp(""),
/* 173 */ "VDestroy" OpHelp(""),
/* 174 */ "VOpen" OpHelp(""),
/* 175 */ "VCheck" OpHelp(""),
/* 176 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
/* 177 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
/* 178 */ "VRename" OpHelp(""),
/* 179 */ "Pagecount" OpHelp(""),
/* 180 */ "MaxPgcnt" OpHelp(""),
/* 181 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"),
/* 182 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"),
/* 183 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"),
/* 184 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
/* 185 */ "Trace" OpHelp(""),
/* 186 */ "CursorHint" OpHelp(""),
/* 187 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
/* 188 */ "Noop" OpHelp(""),
/* 189 */ "Explain" OpHelp(""),
/* 190 */ "Abortable" OpHelp(""),
};
return azName[i];
}
#endif
/************** End of opcodes.c *********************************************/
/************** Begin file os_kv.c *******************************************/
|
| ︙ | ︙ | |||
73584 73585 73586 73587 73588 73589 73590 | int iEnd = iStart + iSize; /* First byte past the iStart buffer */ unsigned char *data = pPage->aData; /* Page content */ u8 *pTmp; /* Temporary ptr into data[] */ assert( pPage->pBt!=0 ); assert( sqlite3PagerIswriteable(pPage->pDbPage) ); assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize ); | | | | 73591 73592 73593 73594 73595 73596 73597 73598 73599 73600 73601 73602 73603 73604 73605 73606 73607 73608 |
int iEnd = iStart + iSize; /* First byte past the iStart buffer */
unsigned char *data = pPage->aData; /* Page content */
u8 *pTmp; /* Temporary ptr into data[] */
assert( pPage->pBt!=0 );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
assert( CORRUPT_DB || iEnd <= (int)pPage->pBt->usableSize );
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
assert( iSize>=4 ); /* Minimum cell size is 4 */
assert( CORRUPT_DB || iStart<=(int)pPage->pBt->usableSize-4 );
/* The list of freeblocks must be in ascending order. Find the
** spot on the list where iStart should be inserted.
*/
hdr = pPage->hdrOffset;
iPtr = hdr + 1;
if( data[iPtr+1]==0 && data[iPtr]==0 ){
|
| ︙ | ︙ | |||
77321 77322 77323 77324 77325 77326 77327 77328 77329 77330 77331 77332 77333 77334 |
}else if( rc==SQLITE_EMPTY ){
assert( pCur->pgnoRoot==0 || (pCur->pPage!=0 && pCur->pPage->nCell==0) );
*pRes = 1;
rc = SQLITE_OK;
}
return rc;
}
#ifdef SQLITE_DEBUG
/* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that
** this flags are true for a consistent database.
**
** This routine is is called from within assert() statements only.
** It is an internal verification routine and does not appear in production
| > > > > > > > > > > > > > > > > > > > > > > > > | 77328 77329 77330 77331 77332 77333 77334 77335 77336 77337 77338 77339 77340 77341 77342 77343 77344 77345 77346 77347 77348 77349 77350 77351 77352 77353 77354 77355 77356 77357 77358 77359 77360 77361 77362 77363 77364 77365 |
}else if( rc==SQLITE_EMPTY ){
assert( pCur->pgnoRoot==0 || (pCur->pPage!=0 && pCur->pPage->nCell==0) );
*pRes = 1;
rc = SQLITE_OK;
}
return rc;
}
/* Set *pRes to 1 (true) if the BTree pointed to by cursor pCur contains zero
** rows of content. Set *pRes to 0 (false) if the table contains content.
** Return SQLITE_OK on success or some error code (ex: SQLITE_NOMEM) if
** something goes wrong.
*/
SQLITE_PRIVATE int sqlite3BtreeIsEmpty(BtCursor *pCur, int *pRes){
int rc;
assert( cursorOwnsBtShared(pCur) );
assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
if( pCur->eState==CURSOR_VALID ){
*pRes = 0;
return SQLITE_OK;
}
rc = moveToRoot(pCur);
if( rc==SQLITE_EMPTY ){
*pRes = 1;
rc = SQLITE_OK;
}else{
*pRes = 0;
}
return rc;
}
#ifdef SQLITE_DEBUG
/* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that
** this flags are true for a consistent database.
**
** This routine is is called from within assert() statements only.
** It is an internal verification routine and does not appear in production
|
| ︙ | ︙ | |||
100848 100849 100850 100851 100852 100853 100854 100855 100856 100857 100858 100859 100860 100861 |
pC->nullRow = (u8)res;
if( pOp->p2>0 ){
VdbeBranchTaken(res!=0,2);
if( res ) goto jump_to_p2;
}
break;
}
/* Opcode: Next P1 P2 P3 * P5
**
** Advance cursor P1 so that it points to the next key/data pair in its
** table or index. If there are no more key/value pairs then fall through
** to the following instruction. But if the cursor advance was successful,
** jump immediately to P2.
| > > > > > > > > > > > > > > > > > > > > > > > > > > | 100879 100880 100881 100882 100883 100884 100885 100886 100887 100888 100889 100890 100891 100892 100893 100894 100895 100896 100897 100898 100899 100900 100901 100902 100903 100904 100905 100906 100907 100908 100909 100910 100911 100912 100913 100914 100915 100916 100917 100918 |
pC->nullRow = (u8)res;
if( pOp->p2>0 ){
VdbeBranchTaken(res!=0,2);
if( res ) goto jump_to_p2;
}
break;
}
/* Opcode: IfEmpty P1 P2 * * *
** Synopsis: if( empty(P1) ) goto P2
**
** Check to see if the b-tree table that cursor P1 references is empty
** and jump to P2 if it is.
*/
case OP_IfEmpty: { /* jump */
VdbeCursor *pC;
BtCursor *pCrsr;
int res;
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
assert( pOp->p2>=0 && pOp->p2<p->nOp );
pC = p->apCsr[pOp->p1];
assert( pC!=0 );
assert( pC->eCurType==CURTYPE_BTREE );
pCrsr = pC->uc.pCursor;
assert( pCrsr );
rc = sqlite3BtreeIsEmpty(pCrsr, &res);
if( rc ) goto abort_due_to_error;
VdbeBranchTaken(res!=0,2);
if( res ) goto jump_to_p2;
break;
}
/* Opcode: Next P1 P2 P3 * P5
**
** Advance cursor P1 so that it points to the next key/data pair in its
** table or index. If there are no more key/value pairs then fall through
** to the following instruction. But if the cursor advance was successful,
** jump immediately to P2.
|
| ︙ | ︙ | |||
102720 102721 102722 102723 102724 102725 102726 |
case OP_VOpen: { /* ncycle */
VdbeCursor *pCur;
sqlite3_vtab_cursor *pVCur;
sqlite3_vtab *pVtab;
const sqlite3_module *pModule;
assert( p->bIsReader );
| | > > > > > > > | 102777 102778 102779 102780 102781 102782 102783 102784 102785 102786 102787 102788 102789 102790 102791 102792 102793 102794 102795 102796 102797 102798 |
case OP_VOpen: { /* ncycle */
VdbeCursor *pCur;
sqlite3_vtab_cursor *pVCur;
sqlite3_vtab *pVtab;
const sqlite3_module *pModule;
assert( p->bIsReader );
pCur = p->apCsr[pOp->p1];
if( pCur!=0
&& ALWAYS( pCur->eCurType==CURTYPE_VTAB )
&& ALWAYS( pCur->uc.pVCur->pVtab==pOp->p4.pVtab->pVtab )
){
/* This opcode is a no-op if the cursor is already open */
break;
}
pVCur = 0;
pVtab = pOp->p4.pVtab->pVtab;
if( pVtab==0 || NEVER(pVtab->pModule==0) ){
rc = SQLITE_LOCKED;
goto abort_due_to_error;
}
pModule = pVtab->pModule;
|
| ︙ | ︙ | |||
109561 109562 109563 109564 109565 109566 109567 |
}
/* FIX ME: Compute pExpr->affinity based on the expected return
** type of the function
*/
return WRC_Prune;
}
#ifndef SQLITE_OMIT_SUBQUERY
| | > > > | > > | 109625 109626 109627 109628 109629 109630 109631 109632 109633 109634 109635 109636 109637 109638 109639 109640 109641 109642 109643 109644 109645 109646 109647 109648 |
}
/* FIX ME: Compute pExpr->affinity based on the expected return
** type of the function
*/
return WRC_Prune;
}
#ifndef SQLITE_OMIT_SUBQUERY
case TK_EXISTS:
assert( ExprUseXSelect(pExpr) );
pParse->bHasExists = 1;
/* no break */ deliberate_fall_through
case TK_SELECT:
#endif
case TK_IN: {
testcase( pExpr->op==TK_IN );
testcase( pExpr->op==TK_EXISTS );
testcase( pExpr->op==TK_SELECT );
if( ExprUseXSelect(pExpr) ){
int nRef = pNC->nRef;
testcase( pNC->ncFlags & NC_IsCheck );
testcase( pNC->ncFlags & NC_PartIdx );
testcase( pNC->ncFlags & NC_IdxExpr );
testcase( pNC->ncFlags & NC_GenCol );
assert( pExpr->x.pSelect );
|
| ︙ | ︙ | |||
111658 111659 111660 111661 111662 111663 111664 |
sqlite3 *db = pParse->db;
if( pLeft==0 ){
return pRight;
}else if( pRight==0 ){
return pLeft;
}else{
u32 f = pLeft->flags | pRight->flags;
| | | 111727 111728 111729 111730 111731 111732 111733 111734 111735 111736 111737 111738 111739 111740 111741 |
sqlite3 *db = pParse->db;
if( pLeft==0 ){
return pRight;
}else if( pRight==0 ){
return pLeft;
}else{
u32 f = pLeft->flags | pRight->flags;
if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse|EP_HasFunc))==EP_IsFalse
&& !IN_RENAME_OBJECT
){
sqlite3ExprDeferredDelete(pParse, pLeft);
sqlite3ExprDeferredDelete(pParse, pRight);
return sqlite3Expr(db, TK_INTEGER, "0");
}else{
return sqlite3PExpr(pParse, TK_AND, pLeft, pRight);
|
| ︙ | ︙ | |||
112938 112939 112940 112941 112942 112943 112944 |
** If the left operand contains a (possibly expensive) subquery and the
** right operand does not and the right operation might be NULL,
** then compute the right operand first and do an IsNull jump if the
** right operand evalutes to NULL.
*/
if( exprEvalRhsFirst(pExpr) && sqlite3ExprCanBeNull(pExpr->pRight) ){
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2);
| | > > > | > > | 113007 113008 113009 113010 113011 113012 113013 113014 113015 113016 113017 113018 113019 113020 113021 113022 113023 113024 113025 113026 113027 113028 113029 113030 113031 113032 113033 113034 113035 113036 113037 113038 113039 113040 113041 |
** If the left operand contains a (possibly expensive) subquery and the
** right operand does not and the right operation might be NULL,
** then compute the right operand first and do an IsNull jump if the
** right operand evalutes to NULL.
*/
if( exprEvalRhsFirst(pExpr) && sqlite3ExprCanBeNull(pExpr->pRight) ){
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2);
addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r2);
VdbeComment((v, "skip left operand"));
VdbeCoverage(v);
}else{
r2 = 0; /* Silence a false-positive uninit-var warning in MSVC */
addrIsNull = 0;
}
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, pFree1);
if( addrIsNull==0 ){
/*
** If the right operand contains a subquery and the left operand does not
** and the left operand might be NULL, then check the left operand do
** an IsNull check on the left operand before computing the right
** operand.
*/
if( ExprHasProperty(pExpr->pRight, EP_Subquery)
&& sqlite3ExprCanBeNull(pExpr->pLeft)
){
addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r1);
VdbeComment((v, "skip right operand"));
VdbeCoverage(v);
}
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2);
}
*pR1 = r1;
*pR2 = r2;
return addrIsNull;
}
|
| ︙ | ︙ | |||
114406 114407 114408 114409 114410 114411 114412 |
VdbeComment((v, "Init subquery result"));
}else{
dest.eDest = SRT_Exists;
sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
VdbeComment((v, "Init EXISTS result"));
}
if( pSel->pLimit ){
| | > | > > > > | | | | | | | | | > | 114480 114481 114482 114483 114484 114485 114486 114487 114488 114489 114490 114491 114492 114493 114494 114495 114496 114497 114498 114499 114500 114501 114502 114503 114504 114505 114506 114507 114508 114509 114510 |
VdbeComment((v, "Init subquery result"));
}else{
dest.eDest = SRT_Exists;
sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
VdbeComment((v, "Init EXISTS result"));
}
if( pSel->pLimit ){
/* The subquery already has a limit. If the pre-existing limit X is
** not already integer value 1 or 0, then make the new limit X<>0 so that
** the new limit is either 1 or 0 */
Expr *pLeft = pSel->pLimit->pLeft;
if( ExprHasProperty(pLeft, EP_IntValue)==0
|| (pLeft->u.iValue!=1 && pLeft->u.iValue!=0)
){
sqlite3 *db = pParse->db;
pLimit = sqlite3Expr(db, TK_INTEGER, "0");
if( pLimit ){
pLimit->affExpr = SQLITE_AFF_NUMERIC;
pLimit = sqlite3PExpr(pParse, TK_NE,
sqlite3ExprDup(db, pLeft, 0), pLimit);
}
sqlite3ExprDeferredDelete(pParse, pLeft);
pSel->pLimit->pLeft = pLimit;
}
}else{
/* If there is no pre-existing limit add a limit of 1 */
pLimit = sqlite3Expr(pParse->db, TK_INTEGER, "1");
pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
}
pSel->iLimit = 0;
if( sqlite3Select(pParse, pSel, &dest) ){
|
| ︙ | ︙ | |||
115626 115627 115628 115629 115630 115631 115632 115633 115634 115635 115636 115637 115638 115639 |
sqlite3VdbeAddOp3(v, op, r2, r1, target);
testcase( regFree1==0 );
testcase( regFree2==0 );
if( addrIsNull ){
sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
sqlite3VdbeJumpHere(v, addrIsNull);
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
}
break;
}
case TK_UMINUS: {
Expr *pLeft = pExpr->pLeft;
assert( pLeft );
if( pLeft->op==TK_INTEGER ){
| > | 115706 115707 115708 115709 115710 115711 115712 115713 115714 115715 115716 115717 115718 115719 115720 |
sqlite3VdbeAddOp3(v, op, r2, r1, target);
testcase( regFree1==0 );
testcase( regFree2==0 );
if( addrIsNull ){
sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
sqlite3VdbeJumpHere(v, addrIsNull);
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
VdbeComment((v, "short-circut value"));
}
break;
}
case TK_UMINUS: {
Expr *pLeft = pExpr->pLeft;
assert( pLeft );
if( pLeft->op==TK_INTEGER ){
|
| ︙ | ︙ | |||
128435 128436 128437 128438 128439 128440 128441 |
/*
** Append the contents of SrcList p2 to SrcList p1 and return the resulting
** SrcList. Or, if an error occurs, return NULL. In all cases, p1 and p2
** are deleted by this function.
*/
SQLITE_PRIVATE SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, SrcList *p2){
| | > | | > > | 128516 128517 128518 128519 128520 128521 128522 128523 128524 128525 128526 128527 128528 128529 128530 128531 128532 128533 128534 128535 128536 128537 128538 128539 128540 |
/*
** Append the contents of SrcList p2 to SrcList p1 and return the resulting
** SrcList. Or, if an error occurs, return NULL. In all cases, p1 and p2
** are deleted by this function.
*/
SQLITE_PRIVATE SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, SrcList *p2){
assert( p1 );
if( p2 ){
int nOld = p1->nSrc;
SrcList *pNew = sqlite3SrcListEnlarge(pParse, p1, p2->nSrc, nOld);
if( pNew==0 ){
sqlite3SrcListDelete(pParse->db, p2);
}else{
p1 = pNew;
memcpy(&p1->a[nOld], p2->a, p2->nSrc*sizeof(SrcItem));
assert( nOld==1 || (p2->nSrc==1 && (p2->a[0].fg.jointype&JT_LTORJ)==0) );
assert( p1->nSrc>=2 );
sqlite3DbFree(pParse->db, p2);
p1->a[0].fg.jointype |= (JT_LTORJ & p1->a[1].fg.jointype);
}
}
return p1;
}
|
| ︙ | ︙ | |||
145521 145522 145523 145524 145525 145526 145527 | */ static int tableAndColumnIndex( SrcList *pSrc, /* Array of tables to search */ int iStart, /* First member of pSrc->a[] to check */ int iEnd, /* Last member of pSrc->a[] to check */ const char *zCol, /* Name of the column we are looking for */ int *piTab, /* Write index of pSrc->a[] here */ | | | 145605 145606 145607 145608 145609 145610 145611 145612 145613 145614 145615 145616 145617 145618 145619 |
*/
static int tableAndColumnIndex(
SrcList *pSrc, /* Array of tables to search */
int iStart, /* First member of pSrc->a[] to check */
int iEnd, /* Last member of pSrc->a[] to check */
const char *zCol, /* Name of the column we are looking for */
int *piTab, /* Write index of pSrc->a[] here */
int *piCol, /* Write index of pSrc->a[*piTab].pSTab->aCol[] here */
int bIgnoreHidden /* Ignore hidden columns */
){
int i; /* For looping over tables in pSrc */
int iCol; /* Index of column matching zCol */
assert( iEnd<pSrc->nSrc );
assert( iStart>=0 );
|
| ︙ | ︙ | |||
148173 148174 148175 148176 148177 148178 148179 148180 148181 148182 148183 148184 148185 148186 148187 |
case TK_EXCEPT:
case TK_UNION: {
int unionTab; /* Cursor number of the temp table holding result */
u8 op = 0; /* One of the SRT_ operations to apply to self */
int priorOp; /* The SRT_ operation to apply to prior selects */
Expr *pLimit; /* Saved values of p->nLimit */
int addr;
SelectDest uniondest;
testcase( p->op==TK_EXCEPT );
testcase( p->op==TK_UNION );
priorOp = SRT_Union;
if( dest.eDest==priorOp ){
/* We can reuse a temporary table generated by a SELECT to our
** right.
| > > | 148257 148258 148259 148260 148261 148262 148263 148264 148265 148266 148267 148268 148269 148270 148271 148272 148273 |
case TK_EXCEPT:
case TK_UNION: {
int unionTab; /* Cursor number of the temp table holding result */
u8 op = 0; /* One of the SRT_ operations to apply to self */
int priorOp; /* The SRT_ operation to apply to prior selects */
Expr *pLimit; /* Saved values of p->nLimit */
int addr;
int emptyBypass = 0; /* IfEmpty opcode to bypass RHS */
SelectDest uniondest;
testcase( p->op==TK_EXCEPT );
testcase( p->op==TK_UNION );
priorOp = SRT_Union;
if( dest.eDest==priorOp ){
/* We can reuse a temporary table generated by a SELECT to our
** right.
|
| ︙ | ︙ | |||
148212 148213 148214 148215 148216 148217 148218 148219 148220 148221 148222 148223 148224 148225 148226 148227 148228 148229 148230 148231 148232 148233 148234 148235 148236 148237 148238 148239 148240 148241 148242 148243 148244 148245 |
goto multi_select_end;
}
/* Code the current SELECT statement
*/
if( p->op==TK_EXCEPT ){
op = SRT_Except;
}else{
assert( p->op==TK_UNION );
op = SRT_Union;
}
p->pPrior = 0;
pLimit = p->pLimit;
p->pLimit = 0;
uniondest.eDest = op;
ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
sqlite3SelectOpName(p->op)));
TREETRACE(0x200, pParse, p, ("multiSelect EXCEPT/UNION right...\n"));
rc = sqlite3Select(pParse, p, &uniondest);
testcase( rc!=SQLITE_OK );
assert( p->pOrderBy==0 );
pDelete = p->pPrior;
p->pPrior = pPrior;
p->pOrderBy = 0;
if( p->op==TK_UNION ){
p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
}
sqlite3ExprDelete(db, p->pLimit);
p->pLimit = pLimit;
p->iLimit = 0;
p->iOffset = 0;
/* Convert the data in the temporary table into whatever form
** it is that we currently need.
| > > > | 148298 148299 148300 148301 148302 148303 148304 148305 148306 148307 148308 148309 148310 148311 148312 148313 148314 148315 148316 148317 148318 148319 148320 148321 148322 148323 148324 148325 148326 148327 148328 148329 148330 148331 148332 148333 148334 |
goto multi_select_end;
}
/* Code the current SELECT statement
*/
if( p->op==TK_EXCEPT ){
op = SRT_Except;
emptyBypass = sqlite3VdbeAddOp1(v, OP_IfEmpty, unionTab);
VdbeCoverage(v);
}else{
assert( p->op==TK_UNION );
op = SRT_Union;
}
p->pPrior = 0;
pLimit = p->pLimit;
p->pLimit = 0;
uniondest.eDest = op;
ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
sqlite3SelectOpName(p->op)));
TREETRACE(0x200, pParse, p, ("multiSelect EXCEPT/UNION right...\n"));
rc = sqlite3Select(pParse, p, &uniondest);
testcase( rc!=SQLITE_OK );
assert( p->pOrderBy==0 );
pDelete = p->pPrior;
p->pPrior = pPrior;
p->pOrderBy = 0;
if( p->op==TK_UNION ){
p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);
}
if( emptyBypass ) sqlite3VdbeJumpHere(v, emptyBypass);
sqlite3ExprDelete(db, p->pLimit);
p->pLimit = pLimit;
p->iLimit = 0;
p->iOffset = 0;
/* Convert the data in the temporary table into whatever form
** it is that we currently need.
|
| ︙ | ︙ | |||
148265 148266 148267 148268 148269 148270 148271 148272 148273 148274 148275 148276 148277 148278 |
default: assert( p->op==TK_INTERSECT ); {
int tab1, tab2;
int iCont, iBreak, iStart;
Expr *pLimit;
int addr;
SelectDest intersectdest;
int r1;
/* INTERSECT is different from the others since it requires
** two temporary tables. Hence it has its own case. Begin
** by allocating the tables we will need.
*/
tab1 = pParse->nTab++;
tab2 = pParse->nTab++;
| > | 148354 148355 148356 148357 148358 148359 148360 148361 148362 148363 148364 148365 148366 148367 148368 |
default: assert( p->op==TK_INTERSECT ); {
int tab1, tab2;
int iCont, iBreak, iStart;
Expr *pLimit;
int addr;
SelectDest intersectdest;
int r1;
int emptyBypass;
/* INTERSECT is different from the others since it requires
** two temporary tables. Hence it has its own case. Begin
** by allocating the tables we will need.
*/
tab1 = pParse->nTab++;
tab2 = pParse->nTab++;
|
| ︙ | ︙ | |||
148288 148289 148290 148291 148292 148293 148294 148295 148296 148297 148298 148299 148300 148301 |
*/
sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);
TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT left...\n"));
rc = sqlite3Select(pParse, pPrior, &intersectdest);
if( rc ){
goto multi_select_end;
}
/* Code the current SELECT into temporary table "tab2"
*/
addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
assert( p->addrOpenEphm[1] == -1 );
p->addrOpenEphm[1] = addr;
p->pPrior = 0;
| > | 148378 148379 148380 148381 148382 148383 148384 148385 148386 148387 148388 148389 148390 148391 148392 |
*/
sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);
TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT left...\n"));
rc = sqlite3Select(pParse, pPrior, &intersectdest);
if( rc ){
goto multi_select_end;
}
emptyBypass = sqlite3VdbeAddOp1(v, OP_IfEmpty, tab1); VdbeCoverage(v);
/* Code the current SELECT into temporary table "tab2"
*/
addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
assert( p->addrOpenEphm[1] == -1 );
p->addrOpenEphm[1] = addr;
p->pPrior = 0;
|
| ︙ | ︙ | |||
148319 148320 148321 148322 148323 148324 148325 |
** tables.
*/
if( rc ) break;
assert( p->pEList );
iBreak = sqlite3VdbeMakeLabel(pParse);
iCont = sqlite3VdbeMakeLabel(pParse);
computeLimitRegisters(pParse, p, iBreak);
| | > | 148410 148411 148412 148413 148414 148415 148416 148417 148418 148419 148420 148421 148422 148423 148424 148425 148426 148427 148428 148429 148430 148431 148432 148433 148434 148435 148436 |
** tables.
*/
if( rc ) break;
assert( p->pEList );
iBreak = sqlite3VdbeMakeLabel(pParse);
iCont = sqlite3VdbeMakeLabel(pParse);
computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp1(v, OP_Rewind, tab1);
r1 = sqlite3GetTempReg(pParse);
iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
VdbeCoverage(v);
sqlite3ReleaseTempReg(pParse, r1);
selectInnerLoop(pParse, p, tab1,
0, 0, &dest, iCont, iBreak);
sqlite3VdbeResolveLabel(v, iCont);
sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);
sqlite3VdbeResolveLabel(v, iBreak);
sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);
sqlite3VdbeJumpHere(v, emptyBypass);
sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);
break;
}
}
#ifndef SQLITE_OMIT_EXPLAIN
if( p->pNext==0 ){
|
| ︙ | ︙ | |||
149009 149010 149011 149012 149013 149014 149015 149016 149017 149018 149019 149020 149021 149022 |
** when processing a non-matched row of the left.
*/
typedef struct SubstContext {
Parse *pParse; /* The parsing context */
int iTable; /* Replace references to this table */
int iNewTable; /* New table number */
int isOuterJoin; /* Add TK_IF_NULL_ROW opcodes on each replacement */
ExprList *pEList; /* Replacement expressions */
ExprList *pCList; /* Collation sequences for replacement expr */
} SubstContext;
/* Forward Declarations */
static void substExprList(SubstContext*, ExprList*);
static void substSelect(SubstContext*, Select*, int);
| > | 149101 149102 149103 149104 149105 149106 149107 149108 149109 149110 149111 149112 149113 149114 149115 |
** when processing a non-matched row of the left.
*/
typedef struct SubstContext {
Parse *pParse; /* The parsing context */
int iTable; /* Replace references to this table */
int iNewTable; /* New table number */
int isOuterJoin; /* Add TK_IF_NULL_ROW opcodes on each replacement */
int nSelDepth; /* Depth of sub-query recursion. Top==1 */
ExprList *pEList; /* Replacement expressions */
ExprList *pCList; /* Collation sequences for replacement expr */
} SubstContext;
/* Forward Declarations */
static void substExprList(SubstContext*, ExprList*);
static void substSelect(SubstContext*, Select*, int);
|
| ︙ | ︙ | |||
149115 149116 149117 149118 149119 149120 149121 149122 149123 149124 149125 149126 149127 149128 |
sqlite3ExprDelete(db, pExpr);
pExpr = pNew;
}
}
}else{
if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
pExpr->iTable = pSubst->iNewTable;
}
pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);
pExpr->pRight = substExpr(pSubst, pExpr->pRight);
if( ExprUseXSelect(pExpr) ){
substSelect(pSubst, pExpr->x.pSelect, 1);
}else{
substExprList(pSubst, pExpr->x.pList);
| > > > | 149208 149209 149210 149211 149212 149213 149214 149215 149216 149217 149218 149219 149220 149221 149222 149223 149224 |
sqlite3ExprDelete(db, pExpr);
pExpr = pNew;
}
}
}else{
if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
pExpr->iTable = pSubst->iNewTable;
}
if( pExpr->op==TK_AGG_FUNCTION && pExpr->op2>=pSubst->nSelDepth ){
pExpr->op2--;
}
pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);
pExpr->pRight = substExpr(pSubst, pExpr->pRight);
if( ExprUseXSelect(pExpr) ){
substSelect(pSubst, pExpr->x.pSelect, 1);
}else{
substExprList(pSubst, pExpr->x.pList);
|
| ︙ | ︙ | |||
149153 149154 149155 149156 149157 149158 149159 149160 149161 149162 149163 149164 149165 149166 149167 149168 149169 149170 149171 149172 149173 149174 149175 149176 149177 149178 149179 149180 149181 149182 149183 |
Select *p, /* SELECT statement in which to make substitutions */
int doPrior /* Do substitutes on p->pPrior too */
){
SrcList *pSrc;
SrcItem *pItem;
int i;
if( !p ) return;
do{
substExprList(pSubst, p->pEList);
substExprList(pSubst, p->pGroupBy);
substExprList(pSubst, p->pOrderBy);
p->pHaving = substExpr(pSubst, p->pHaving);
p->pWhere = substExpr(pSubst, p->pWhere);
pSrc = p->pSrc;
assert( pSrc!=0 );
for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){
if( pItem->fg.isSubquery ){
substSelect(pSubst, pItem->u4.pSubq->pSelect, 1);
}
if( pItem->fg.isTabFunc ){
substExprList(pSubst, pItem->u1.pFuncArg);
}
}
}while( doPrior && (p = p->pPrior)!=0 );
}
#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
/*
** pSelect is a SELECT statement and pSrcItem is one item in the FROM
** clause of that SELECT.
| > > | 149249 149250 149251 149252 149253 149254 149255 149256 149257 149258 149259 149260 149261 149262 149263 149264 149265 149266 149267 149268 149269 149270 149271 149272 149273 149274 149275 149276 149277 149278 149279 149280 149281 |
Select *p, /* SELECT statement in which to make substitutions */
int doPrior /* Do substitutes on p->pPrior too */
){
SrcList *pSrc;
SrcItem *pItem;
int i;
if( !p ) return;
pSubst->nSelDepth++;
do{
substExprList(pSubst, p->pEList);
substExprList(pSubst, p->pGroupBy);
substExprList(pSubst, p->pOrderBy);
p->pHaving = substExpr(pSubst, p->pHaving);
p->pWhere = substExpr(pSubst, p->pWhere);
pSrc = p->pSrc;
assert( pSrc!=0 );
for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){
if( pItem->fg.isSubquery ){
substSelect(pSubst, pItem->u4.pSubq->pSelect, 1);
}
if( pItem->fg.isTabFunc ){
substExprList(pSubst, pItem->u1.pFuncArg);
}
}
}while( doPrior && (p = p->pPrior)!=0 );
pSubst->nSelDepth--;
}
#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
/*
** pSelect is a SELECT statement and pSrcItem is one item in the FROM
** clause of that SELECT.
|
| ︙ | ︙ | |||
149781 149782 149783 149784 149785 149786 149787 | } /* Defer deleting the Table object associated with the ** subquery until code generation is ** complete, since there may still exist Expr.pTab entries that ** refer to the subquery even after flattening. Ticket #3346. ** | | | 149879 149880 149881 149882 149883 149884 149885 149886 149887 149888 149889 149890 149891 149892 149893 |
}
/* Defer deleting the Table object associated with the
** subquery until code generation is
** complete, since there may still exist Expr.pTab entries that
** refer to the subquery even after flattening. Ticket #3346.
**
** pSubitem->pSTab is always non-NULL by test restrictions and tests above.
*/
if( ALWAYS(pSubitem->pSTab!=0) ){
Table *pTabToDel = pSubitem->pSTab;
if( pTabToDel->nTabRef==1 ){
Parse *pToplevel = sqlite3ParseToplevel(pParse);
sqlite3ParserAddCleanup(pToplevel, sqlite3DeleteTableGeneric, pTabToDel);
testcase( pToplevel->earlyCleanup );
|
| ︙ | ︙ | |||
149911 149912 149913 149914 149915 149916 149917 149918 149919 149920 149921 149922 149923 149924 |
}
if( db->mallocFailed==0 ){
SubstContext x;
x.pParse = pParse;
x.iTable = iParent;
x.iNewTable = iNewParent;
x.isOuterJoin = isOuterJoin;
x.pEList = pSub->pEList;
x.pCList = findLeftmostExprlist(pSub);
substSelect(&x, pParent, 0);
}
/* The flattened query is a compound if either the inner or the
** outer query is a compound. */
| > | 150009 150010 150011 150012 150013 150014 150015 150016 150017 150018 150019 150020 150021 150022 150023 |
}
if( db->mallocFailed==0 ){
SubstContext x;
x.pParse = pParse;
x.iTable = iParent;
x.iNewTable = iNewParent;
x.isOuterJoin = isOuterJoin;
x.nSelDepth = 0;
x.pEList = pSub->pEList;
x.pCList = findLeftmostExprlist(pSub);
substSelect(&x, pParent, 0);
}
/* The flattened query is a compound if either the inner or the
** outer query is a compound. */
|
| ︙ | ︙ | |||
150496 150497 150498 150499 150500 150501 150502 150503 150504 150505 150506 150507 150508 150509 |
SubstContext x;
pNew = sqlite3ExprDup(pParse->db, pWhere, 0);
unsetJoinExpr(pNew, -1, 1);
x.pParse = pParse;
x.iTable = pSrc->iCursor;
x.iNewTable = pSrc->iCursor;
x.isOuterJoin = 0;
x.pEList = pSubq->pEList;
x.pCList = findLeftmostExprlist(pSubq);
pNew = substExpr(&x, pNew);
#ifndef SQLITE_OMIT_WINDOWFUNC
if( pSubq->pWin && 0==pushDownWindowCheck(pParse, pSubq, pNew) ){
/* Restriction 6c has prevented push-down in this case */
sqlite3ExprDelete(pParse->db, pNew);
| > | 150595 150596 150597 150598 150599 150600 150601 150602 150603 150604 150605 150606 150607 150608 150609 |
SubstContext x;
pNew = sqlite3ExprDup(pParse->db, pWhere, 0);
unsetJoinExpr(pNew, -1, 1);
x.pParse = pParse;
x.iTable = pSrc->iCursor;
x.iNewTable = pSrc->iCursor;
x.isOuterJoin = 0;
x.nSelDepth = 0;
x.pEList = pSubq->pEList;
x.pCList = findLeftmostExprlist(pSubq);
pNew = substExpr(&x, pNew);
#ifndef SQLITE_OMIT_WINDOWFUNC
if( pSubq->pWin && 0==pushDownWindowCheck(pParse, pSubq, pNew) ){
/* Restriction 6c has prevented push-down in this case */
sqlite3ExprDelete(pParse->db, pNew);
|
| ︙ | ︙ | |||
150893 150894 150895 150896 150897 150898 150899 | /* ** This function checks if argument pFrom refers to a CTE declared by ** a WITH clause on the stack currently maintained by the parser (on the ** pParse->pWith linked list). And if currently processing a CTE ** CTE expression, through routine checks to see if the reference is ** a recursive reference to the CTE. ** | | | 150993 150994 150995 150996 150997 150998 150999 151000 151001 151002 151003 151004 151005 151006 151007 | /* ** This function checks if argument pFrom refers to a CTE declared by ** a WITH clause on the stack currently maintained by the parser (on the ** pParse->pWith linked list). And if currently processing a CTE ** CTE expression, through routine checks to see if the reference is ** a recursive reference to the CTE. ** ** If pFrom matches a CTE according to either of these two above, pFrom->pSTab ** and other fields are populated accordingly. ** ** Return 0 if no match is found. ** Return 1 if a match is found. ** Return 2 if an error condition is detected. */ static int resolveFromTermToCte( |
| ︙ | ︙ | |||
152519 152520 152521 152522 152523 152524 152525 152526 152527 152528 152529 152530 152531 152532 |
if( i==0 ) break;
i--;
pItem--;
if( pItem->fg.isSubquery ) return 0; /* (1c-i) */
}
return 1;
}
/*
** Generate byte-code for the SELECT statement given in the p argument.
**
** The results are returned according to the SelectDest structure.
** See comments in sqliteInt.h for further information.
**
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 152619 152620 152621 152622 152623 152624 152625 152626 152627 152628 152629 152630 152631 152632 152633 152634 152635 152636 152637 152638 152639 152640 152641 152642 152643 152644 152645 152646 152647 152648 152649 152650 152651 152652 152653 152654 152655 152656 152657 152658 152659 152660 152661 152662 152663 152664 152665 152666 152667 152668 152669 152670 152671 152672 152673 152674 152675 152676 152677 152678 152679 152680 152681 152682 152683 152684 152685 152686 152687 152688 152689 152690 152691 152692 152693 152694 152695 152696 152697 152698 152699 152700 152701 |
if( i==0 ) break;
i--;
pItem--;
if( pItem->fg.isSubquery ) return 0; /* (1c-i) */
}
return 1;
}
/*
** Argument pWhere is the WHERE clause belonging to SELECT statement p. This
** function attempts to transform expressions of the form:
**
** EXISTS (SELECT ...)
**
** into joins. For example, given
**
** CREATE TABLE sailors(sid INTEGER PRIMARY KEY, name TEXT);
** CREATE TABLE reserves(sid INT, day DATE, PRIMARY KEY(sid, day));
**
** SELECT name FROM sailors AS S WHERE EXISTS (
** SELECT * FROM reserves AS R WHERE S.sid = R.sid AND R.day = '2022-10-25'
** );
**
** the SELECT statement may be transformed as follows:
**
** SELECT name FROM sailors AS S, reserves AS R
** WHERE S.sid = R.sid AND R.day = '2022-10-25';
*/
static SQLITE_NOINLINE void existsToJoin(
Parse *pParse,
Select *p,
Expr *pWhere
){
if( pWhere
&& !ExprHasProperty(pWhere, EP_OuterON|EP_InnerON)
&& p->pSrc->nSrc>0
&& p->pSrc->nSrc<BMS
&& pParse->db->mallocFailed==0
){
if( pWhere->op==TK_AND ){
Expr *pRight = pWhere->pRight;
existsToJoin(pParse, p, pWhere->pLeft);
existsToJoin(pParse, p, pRight);
}
else if( pWhere->op==TK_EXISTS ){
Select *pSub = pWhere->x.pSelect;
if( pSub->pSrc->nSrc==1
&& (pSub->selFlags & SF_Aggregate)==0
&& pSub->pWhere
&& !pSub->pSrc->a[0].fg.isSubquery
){
memset(pWhere, 0, sizeof(*pWhere));
pWhere->op = TK_INTEGER;
pWhere->u.iValue = 1;
ExprSetProperty(pWhere, EP_IntValue);
assert( p->pWhere!=0 );
pSub->pSrc->a[0].fg.fromExists = 1;
pSub->pSrc->a[0].fg.jointype |= JT_CROSS;
p->pSrc = sqlite3SrcListAppendList(pParse, p->pSrc, pSub->pSrc);
p->pWhere = sqlite3PExpr(pParse, TK_AND, p->pWhere, pSub->pWhere);
pSub->pWhere = 0;
pSub->pSrc = 0;
sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pSub);
#if TREETRACE_ENABLED
if( sqlite3TreeTrace & 0x100000 ){
TREETRACE(0x100000,pParse,p,
("After EXISTS-to-JOIN optimization:\n"));
sqlite3TreeViewSelect(0, p, 0);
}
#endif
}
}
}
}
/*
** Generate byte-code for the SELECT statement given in the p argument.
**
** The results are returned according to the SelectDest structure.
** See comments in sqliteInt.h for further information.
**
|
| ︙ | ︙ | |||
152887 152888 152889 152890 152891 152892 152893 152894 152895 152896 152897 152898 152899 152900 |
sqlite3TreeViewSelect(0, p, 0);
}
#endif
if( p->pNext==0 ) ExplainQueryPlanPop(pParse);
return rc;
}
#endif
/* Do the WHERE-clause constant propagation optimization if this is
** a join. No need to spend time on this operation for non-join queries
** as the equivalent optimization will be handled by query planner in
** sqlite3WhereBegin(). tag-select-0330
*/
if( p->pWhere!=0
| > > > > > > > | 153056 153057 153058 153059 153060 153061 153062 153063 153064 153065 153066 153067 153068 153069 153070 153071 153072 153073 153074 153075 153076 |
sqlite3TreeViewSelect(0, p, 0);
}
#endif
if( p->pNext==0 ) ExplainQueryPlanPop(pParse);
return rc;
}
#endif
/* If there may be an "EXISTS (SELECT ...)" in the WHERE clause, attempt
** to change it into a join. */
if( pParse->bHasExists && OptimizationEnabled(db,SQLITE_ExistsToJoin) ){
existsToJoin(pParse, p, p->pWhere);
pTabList = p->pSrc;
}
/* Do the WHERE-clause constant propagation optimization if this is
** a join. No need to spend time on this operation for non-join queries
** as the equivalent optimization will be handled by query planner in
** sqlite3WhereBegin(). tag-select-0330
*/
if( p->pWhere!=0
|
| ︙ | ︙ | |||
153674 153675 153676 153677 153678 153679 153680 |
**
** This code copies current group by terms in b0,b1,b2,...
** over to a0,a1,a2. It then calls the output subroutine
** and resets the aggregate accumulator registers in preparation
** for the next GROUP BY batch.
*/
sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
| | | | | | | | | 153850 153851 153852 153853 153854 153855 153856 153857 153858 153859 153860 153861 153862 153863 153864 153865 153866 153867 153868 153869 153870 153871 153872 153873 153874 153875 153876 153877 153878 153879 153880 153881 153882 153883 153884 153885 153886 153887 153888 153889 153890 153891 153892 153893 153894 153895 153896 153897 153898 153899 153900 153901 153902 153903 153904 153905 153906 153907 153908 153909 153910 153911 153912 153913 153914 153915 153916 153917 153918 153919 153920 153921 153922 153923 153924 153925 153926 153927 153928 153929 153930 |
**
** This code copies current group by terms in b0,b1,b2,...
** over to a0,a1,a2. It then calls the output subroutine
** and resets the aggregate accumulator registers in preparation
** for the next GROUP BY batch.
*/
sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
VdbeComment((v, "output one row of %d", p->selId));
sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr);
sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); VdbeCoverage(v);
VdbeComment((v, "check abort flag"));
sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
VdbeComment((v, "reset accumulator %d", p->selId));
/* Update the aggregate accumulators based on the content of
** the current row
*/
sqlite3VdbeJumpHere(v, addr1);
updateAccumulator(pParse, iUseFlag, pAggInfo, eDist);
sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);
VdbeComment((v, "indicate data in accumulator %d", p->selId));
/* End of the loop
*/
if( groupBySort ){
sqlite3VdbeAddOp2(v, OP_SorterNext, pAggInfo->sortingIdx,addrTopOfLoop);
VdbeCoverage(v);
}else{
TREETRACE(0x2,pParse,p,("WhereEnd\n"));
sqlite3WhereEnd(pWInfo);
sqlite3VdbeChangeToNoop(v, addrSortingIdx);
}
sqlite3ExprListDelete(db, pDistinct);
/* Output the final row of result
*/
sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);
VdbeComment((v, "output final row of %d", p->selId));
/* Jump over the subroutines
*/
sqlite3VdbeGoto(v, addrEnd);
/* Generate a subroutine that outputs a single row of the result
** set. This subroutine first looks at the iUseFlag. If iUseFlag
** is less than or equal to zero, the subroutine is a no-op. If
** the processing calls for the query to abort, this subroutine
** increments the iAbortFlag memory location before returning in
** order to signal the caller to abort.
*/
addrSetAbort = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_Integer, 1, iAbortFlag);
VdbeComment((v, "set abort flag"));
sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
sqlite3VdbeResolveLabel(v, addrOutputRow);
addrOutputRow = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow+2);
VdbeCoverage(v);
VdbeComment((v, "Groupby result generator entry point %d", p->selId));
sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
finalizeAggFunctions(pParse, pAggInfo);
sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);
selectInnerLoop(pParse, p, -1, &sSort,
&sDistinct, pDest,
addrOutputRow+1, addrSetAbort);
sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
VdbeComment((v, "end groupby result generator %d", p->selId));
/* Generate a subroutine that will reset the group-by accumulator
*/
sqlite3VdbeResolveLabel(v, addrReset);
resetAccumulator(pParse, pAggInfo);
sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);
VdbeComment((v, "indicate accumulator %d empty", p->selId));
sqlite3VdbeAddOp1(v, OP_Return, regReset);
if( distFlag!=0 && eDist!=WHERE_DISTINCT_NOOP ){
struct AggInfo_func *pF = &pAggInfo->aFunc[0];
fixDistinctOpenEph(pParse, eDist, pF->iDistinct, pF->iDistAddr);
}
} /* endif pGroupBy. Begin aggregate queries without GROUP BY: */
|
| ︙ | ︙ | |||
159332 159333 159334 159335 159336 159337 159338 159339 159340 159341 159342 159343 159344 159345 |
** WhereInfo.a[WhereInfo.nLevel-1] being the inner loop.
*/
struct WhereLevel {
int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
int iTabCur; /* The VDBE cursor used to access the table */
int iIdxCur; /* The VDBE cursor used to access pIdx */
int addrBrk; /* Jump here to break out of the loop */
int addrNxt; /* Jump here to start the next IN combination */
int addrSkip; /* Jump here for next iteration of skip-scan */
int addrCont; /* Jump here to continue with the next loop cycle */
int addrFirst; /* First instruction of interior of the loop */
int addrBody; /* Beginning of the body of this loop */
int regBignull; /* big-null flag reg. True if a NULL-scan is needed */
int addrBignull; /* Jump here for next part of big-null scan */
| > | 159508 159509 159510 159511 159512 159513 159514 159515 159516 159517 159518 159519 159520 159521 159522 |
** WhereInfo.a[WhereInfo.nLevel-1] being the inner loop.
*/
struct WhereLevel {
int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
int iTabCur; /* The VDBE cursor used to access the table */
int iIdxCur; /* The VDBE cursor used to access pIdx */
int addrBrk; /* Jump here to break out of the loop */
int addrHalt; /* Abort the query due to empty table or similar */
int addrNxt; /* Jump here to start the next IN combination */
int addrSkip; /* Jump here for next iteration of skip-scan */
int addrCont; /* Jump here to continue with the next loop cycle */
int addrFirst; /* First instruction of interior of the loop */
int addrBody; /* Beginning of the body of this loop */
int regBignull; /* big-null flag reg. True if a NULL-scan is needed */
int addrBignull; /* Jump here for next part of big-null scan */
|
| ︙ | ︙ | |||
160041 160042 160043 160044 160045 160046 160047 160048 160049 160050 160051 160052 160053 160054 160055 160056 160057 160058 160059 160060 160061 |
sqlite3 *db = pParse->db; /* Database handle */
int isSearch; /* True for a SEARCH. False for SCAN. */
WhereLoop *pLoop; /* The controlling WhereLoop object */
u32 flags; /* Flags that describe this loop */
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)
char *zMsg; /* Text to add to EQP output */
#endif
StrAccum str; /* EQP output string */
char zBuf[100]; /* Initial space for EQP output string */
if( db->mallocFailed ) return;
pLoop = pLevel->pWLoop;
flags = pLoop->wsFlags;
isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
|| ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
|| (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
str.printfFlags = SQLITE_PRINTF_INTERNAL;
| > > > > > > > > | | 160218 160219 160220 160221 160222 160223 160224 160225 160226 160227 160228 160229 160230 160231 160232 160233 160234 160235 160236 160237 160238 160239 160240 160241 160242 160243 160244 160245 160246 160247 160248 160249 160250 160251 160252 160253 160254 |
sqlite3 *db = pParse->db; /* Database handle */
int isSearch; /* True for a SEARCH. False for SCAN. */
WhereLoop *pLoop; /* The controlling WhereLoop object */
u32 flags; /* Flags that describe this loop */
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)
char *zMsg; /* Text to add to EQP output */
#endif
const char *zFormat;
StrAccum str; /* EQP output string */
char zBuf[100]; /* Initial space for EQP output string */
if( db->mallocFailed ) return;
pLoop = pLevel->pWLoop;
flags = pLoop->wsFlags;
isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
|| ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
|| (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
str.printfFlags = SQLITE_PRINTF_INTERNAL;
if( pItem->fg.fromExists ){
zFormat = "SINGLETON %S";
}else if( isSearch ){
zFormat = "SEARCH %S";
}else{
zFormat = "SCAN %S";
}
sqlite3_str_appendf(&str, zFormat, pItem);
if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){
const char *zFmt = 0;
Index *pIdx;
assert( pLoop->u.btree.pIndex!=0 );
pIdx = pLoop->u.btree.pIndex;
assert( !(flags&WHERE_AUTO_INDEX) || (flags&WHERE_IDX_ONLY) );
|
| ︙ | ︙ | |||
161306 161307 161308 161309 161310 161311 161312 161313 161314 161315 161316 161317 161318 161319 161320 |
static SQLITE_NOINLINE void filterPullDown(
Parse *pParse, /* Parsing context */
WhereInfo *pWInfo, /* Complete information about the WHERE clause */
int iLevel, /* Which level of pWInfo->a[] should be coded */
int addrNxt, /* Jump here to bypass inner loops */
Bitmask notReady /* Loops that are not ready */
){
while( ++iLevel < pWInfo->nLevel ){
WhereLevel *pLevel = &pWInfo->a[iLevel];
WhereLoop *pLoop = pLevel->pWLoop;
if( pLevel->regFilter==0 ) continue;
if( pLevel->pWLoop->nSkip ) continue;
/* ,--- Because sqlite3ConstructBloomFilter() has will not have set
** vvvvv--' pLevel->regFilter if this were true. */
if( NEVER(pLoop->prereq & notReady) ) continue;
| > | | 161491 161492 161493 161494 161495 161496 161497 161498 161499 161500 161501 161502 161503 161504 161505 161506 161507 161508 161509 161510 161511 161512 161513 161514 |
static SQLITE_NOINLINE void filterPullDown(
Parse *pParse, /* Parsing context */
WhereInfo *pWInfo, /* Complete information about the WHERE clause */
int iLevel, /* Which level of pWInfo->a[] should be coded */
int addrNxt, /* Jump here to bypass inner loops */
Bitmask notReady /* Loops that are not ready */
){
int saved_addrBrk;
while( ++iLevel < pWInfo->nLevel ){
WhereLevel *pLevel = &pWInfo->a[iLevel];
WhereLoop *pLoop = pLevel->pWLoop;
if( pLevel->regFilter==0 ) continue;
if( pLevel->pWLoop->nSkip ) continue;
/* ,--- Because sqlite3ConstructBloomFilter() has will not have set
** vvvvv--' pLevel->regFilter if this were true. */
if( NEVER(pLoop->prereq & notReady) ) continue;
saved_addrBrk = pLevel->addrBrk;
pLevel->addrBrk = addrNxt;
if( pLoop->wsFlags & WHERE_IPK ){
WhereTerm *pTerm = pLoop->aLTerm[0];
int regRowid;
assert( pTerm!=0 );
assert( pTerm->pExpr!=0 );
testcase( pTerm->wtFlags & TERM_VIRTUAL );
|
| ︙ | ︙ | |||
161344 161345 161346 161347 161348 161349 161350 |
codeApplyAffinity(pParse, r1, nEq, zStartAff);
sqlite3DbFree(pParse->db, zStartAff);
sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
addrNxt, r1, nEq);
VdbeCoverage(pParse->pVdbe);
}
pLevel->regFilter = 0;
| | | 161530 161531 161532 161533 161534 161535 161536 161537 161538 161539 161540 161541 161542 161543 161544 |
codeApplyAffinity(pParse, r1, nEq, zStartAff);
sqlite3DbFree(pParse->db, zStartAff);
sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
addrNxt, r1, nEq);
VdbeCoverage(pParse->pVdbe);
}
pLevel->regFilter = 0;
pLevel->addrBrk = saved_addrBrk;
}
}
/*
** Loop pLoop is a WHERE_INDEXED level that uses at least one IN(...)
** operator. Return true if level pLoop is guaranteed to visit only one
** row for each key generated for the index.
|
| ︙ | ︙ | |||
161391 161392 161393 161394 161395 161396 161397 | int bRev; /* True if we need to scan in reverse order */ WhereLoop *pLoop; /* The WhereLoop object being coded */ WhereClause *pWC; /* Decomposition of the entire WHERE clause */ WhereTerm *pTerm; /* A WHERE clause term */ sqlite3 *db; /* Database connection */ SrcItem *pTabItem; /* FROM clause term being coded */ int addrBrk; /* Jump here to break out of the loop */ | < | 161577 161578 161579 161580 161581 161582 161583 161584 161585 161586 161587 161588 161589 161590 | int bRev; /* True if we need to scan in reverse order */ WhereLoop *pLoop; /* The WhereLoop object being coded */ WhereClause *pWC; /* Decomposition of the entire WHERE clause */ WhereTerm *pTerm; /* A WHERE clause term */ sqlite3 *db; /* Database connection */ SrcItem *pTabItem; /* FROM clause term being coded */ int addrBrk; /* Jump here to break out of the loop */ int addrCont; /* Jump here to continue with next cycle */ int iRowidReg = 0; /* Rowid is stored in this register, if not zero */ int iReleaseReg = 0; /* Temp register to free before returning */ Index *pIdx = 0; /* Index used by loop (if any) */ int iLoop; /* Iteration of constraint generator loop */ pWC = &pWInfo->sWC; |
| ︙ | ︙ | |||
161435 161436 161437 161438 161439 161440 161441 | ** loop. ** ** When there is an IN operator, we also have a "addrNxt" label that ** means to continue with the next IN value combination. When ** there are no IN operators in the constraints, the "addrNxt" label ** is the same as "addrBrk". */ | | < < < < < < < < | 161620 161621 161622 161623 161624 161625 161626 161627 161628 161629 161630 161631 161632 161633 161634 161635 161636 161637 161638 161639 161640 161641 161642 161643 161644 161645 161646 161647 161648 161649 |
** loop.
**
** When there is an IN operator, we also have a "addrNxt" label that
** means to continue with the next IN value combination. When
** there are no IN operators in the constraints, the "addrNxt" label
** is the same as "addrBrk".
*/
addrBrk = pLevel->addrNxt = pLevel->addrBrk;
addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(pParse);
/* If this is the right table of a LEFT OUTER JOIN, allocate and
** initialize a memory cell that records if this table matches any
** row of the left table of the join.
*/
assert( (pWInfo->wctrlFlags & (WHERE_OR_SUBCLAUSE|WHERE_RIGHT_JOIN))
|| pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0
);
if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
pLevel->iLeftJoin = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
VdbeComment((v, "init LEFT JOIN match flag"));
}
/* Special case of a FROM clause subquery implemented as a co-routine */
if( pTabItem->fg.viaCoroutine ){
int regYield;
Subquery *pSubq;
assert( pTabItem->fg.isSubquery && pTabItem->u4.pSubq!=0 );
pSubq = pTabItem->u4.pSubq;
regYield = pSubq->regReturn;
|
| ︙ | ︙ | |||
161697 161698 161699 161700 161701 161702 161703 |
VdbeComment((v, "pk"));
VdbeCoverageIf(v, pX->op==TK_GT);
VdbeCoverageIf(v, pX->op==TK_LE);
VdbeCoverageIf(v, pX->op==TK_LT);
VdbeCoverageIf(v, pX->op==TK_GE);
sqlite3ReleaseTempReg(pParse, rTemp);
}else{
| | | 161874 161875 161876 161877 161878 161879 161880 161881 161882 161883 161884 161885 161886 161887 161888 |
VdbeComment((v, "pk"));
VdbeCoverageIf(v, pX->op==TK_GT);
VdbeCoverageIf(v, pX->op==TK_LE);
VdbeCoverageIf(v, pX->op==TK_LT);
VdbeCoverageIf(v, pX->op==TK_GE);
sqlite3ReleaseTempReg(pParse, rTemp);
}else{
sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, pLevel->addrHalt);
VdbeCoverageIf(v, bRev==0);
VdbeCoverageIf(v, bRev!=0);
}
if( pEnd ){
Expr *pX;
pX = pEnd->pExpr;
assert( pX!=0 );
|
| ︙ | ︙ | |||
162492 162493 162494 162495 162496 162497 162498 |
/* Tables marked isRecursive have only a single row that is stored in
** a pseudo-cursor. No need to Rewind or Next such cursors. */
pLevel->op = OP_Noop;
}else{
codeCursorHint(pTabItem, pWInfo, pLevel, 0);
pLevel->op = aStep[bRev];
pLevel->p1 = iCur;
| | | 162669 162670 162671 162672 162673 162674 162675 162676 162677 162678 162679 162680 162681 162682 162683 |
/* Tables marked isRecursive have only a single row that is stored in
** a pseudo-cursor. No need to Rewind or Next such cursors. */
pLevel->op = OP_Noop;
}else{
codeCursorHint(pTabItem, pWInfo, pLevel, 0);
pLevel->op = aStep[bRev];
pLevel->p1 = iCur;
pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev],iCur,pLevel->addrHalt);
VdbeCoverageIf(v, bRev==0);
VdbeCoverageIf(v, bRev!=0);
pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
}
}
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
|
| ︙ | ︙ | |||
164507 164508 164509 164510 164511 164512 164513 | /* ** Possibly add terms corresponding to the LIMIT and OFFSET clauses of the ** SELECT statement passed as the second argument. These terms are only ** added if: ** ** 1. The SELECT statement has a LIMIT clause, and ** 2. The SELECT statement is not an aggregate or DISTINCT query, and | | | 164684 164685 164686 164687 164688 164689 164690 164691 164692 164693 164694 164695 164696 164697 164698 | /* ** Possibly add terms corresponding to the LIMIT and OFFSET clauses of the ** SELECT statement passed as the second argument. These terms are only ** added if: ** ** 1. The SELECT statement has a LIMIT clause, and ** 2. The SELECT statement is not an aggregate or DISTINCT query, and ** 3. The SELECT statement has exactly one object in its FROM clause, and ** that object is a virtual table, and ** 4. There are no terms in the WHERE clause that will not be passed ** to the virtual table xBestIndex method. ** 5. The ORDER BY clause, if any, will be made available to the xBestIndex ** method. ** ** LIMIT and OFFSET terms are ignored by most of the planner code. They |
| ︙ | ︙ | |||
164544 164545 164546 164547 164548 164549 164550 |
if( pWC->a[ii].nChild ){
/* If this term has child terms, then they are also part of the
** pWC->a[] array. So this term can be ignored, as a LIMIT clause
** will only be added if each of the child terms passes the
** (leftCursor==iCsr) test below. */
continue;
}
| | > > > | > > > > > > > > > > > | 164721 164722 164723 164724 164725 164726 164727 164728 164729 164730 164731 164732 164733 164734 164735 164736 164737 164738 164739 164740 164741 164742 164743 164744 164745 164746 164747 164748 164749 164750 |
if( pWC->a[ii].nChild ){
/* If this term has child terms, then they are also part of the
** pWC->a[] array. So this term can be ignored, as a LIMIT clause
** will only be added if each of the child terms passes the
** (leftCursor==iCsr) test below. */
continue;
}
if( pWC->a[ii].leftCursor==iCsr && pWC->a[ii].prereqRight==0 ) continue;
/* If this term has a parent with exactly one child, and the parent will
** be passed through to xBestIndex, then this term can be ignored. */
if( pWC->a[ii].iParent>=0 ){
WhereTerm *pParent = &pWC->a[ pWC->a[ii].iParent ];
if( pParent->leftCursor==iCsr
&& pParent->prereqRight==0
&& pParent->nChild==1
){
continue;
}
}
/* This term will not be passed through. Do not add a LIMIT clause. */
return;
}
/* Check condition (5). Return early if it is not met. */
if( pOrderBy ){
for(ii=0; ii<pOrderBy->nExpr; ii++){
Expr *pExpr = pOrderBy->a[ii].pExpr;
if( pExpr->op!=TK_COLUMN ) return;
|
| ︙ | ︙ | |||
165984 165985 165986 165987 165988 165989 165990 |
regYield = pSubq->regReturn;
addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSubq->addrFillSub);
addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield);
VdbeCoverage(v);
VdbeComment((v, "next row of %s", pSrc->pSTab->zName));
}else{
| > > | | 166175 166176 166177 166178 166179 166180 166181 166182 166183 166184 166185 166186 166187 166188 166189 166190 166191 |
regYield = pSubq->regReturn;
addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pSubq->addrFillSub);
addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield);
VdbeCoverage(v);
VdbeComment((v, "next row of %s", pSrc->pSTab->zName));
}else{
assert( pLevel->addrHalt );
addrTop = sqlite3VdbeAddOp2(v, OP_Rewind,pLevel->iTabCur,pLevel->addrHalt);
VdbeCoverage(v);
}
if( pPartial ){
iContinue = sqlite3VdbeMakeLabel(pParse);
sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);
pLoop->wsFlags |= WHERE_PARTIALIDX;
}
regRecord = sqlite3GetTempReg(pParse);
|
| ︙ | ︙ | |||
166012 166013 166014 166015 166016 166017 166018 166019 166020 166021 |
sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
testcase( pParse->db->mallocFailed );
assert( pLevel->iIdxCur>0 );
translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
pSrc->u4.pSubq->regResult, pLevel->iIdxCur);
sqlite3VdbeGoto(v, addrTop);
pSrc->fg.viaCoroutine = 0;
}else{
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
| > < > | > > | 166205 166206 166207 166208 166209 166210 166211 166212 166213 166214 166215 166216 166217 166218 166219 166220 166221 166222 166223 166224 166225 166226 |
sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
testcase( pParse->db->mallocFailed );
assert( pLevel->iIdxCur>0 );
translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
pSrc->u4.pSubq->regResult, pLevel->iIdxCur);
sqlite3VdbeGoto(v, addrTop);
pSrc->fg.viaCoroutine = 0;
sqlite3VdbeJumpHere(v, addrTop);
}else{
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
if( (pSrc->fg.jointype & JT_LEFT)!=0 ){
sqlite3VdbeJumpHere(v, addrTop);
}
}
sqlite3ReleaseTempReg(pParse, regRecord);
/* Jump here when skipping the initialization */
sqlite3VdbeJumpHere(v, addrInit);
sqlite3VdbeScanStatusRange(v, addrExp, addrExp, -1);
end_auto_index_create:
|
| ︙ | ︙ | |||
168296 168297 168298 168299 168300 168301 168302 168303 168304 168305 168306 168307 168308 168309 |
if( saved_nEq==saved_nSkip
&& saved_nEq+1<pProbe->nKeyCol
&& saved_nEq==pNew->nLTerm
&& pProbe->noSkipScan==0
&& pProbe->hasStat1!=0
&& OptimizationEnabled(db, SQLITE_SkipScan)
&& pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
&& (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
){
LogEst nIter;
pNew->u.btree.nEq++;
pNew->nSkip++;
pNew->aLTerm[pNew->nLTerm++] = 0;
pNew->wsFlags |= WHERE_SKIPSCAN;
| > | 168492 168493 168494 168495 168496 168497 168498 168499 168500 168501 168502 168503 168504 168505 168506 |
if( saved_nEq==saved_nSkip
&& saved_nEq+1<pProbe->nKeyCol
&& saved_nEq==pNew->nLTerm
&& pProbe->noSkipScan==0
&& pProbe->hasStat1!=0
&& OptimizationEnabled(db, SQLITE_SkipScan)
&& pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
&& pSrc->fg.fromExists==0
&& (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
){
LogEst nIter;
pNew->u.btree.nEq++;
pNew->nSkip++;
pNew->aLTerm[pNew->nLTerm++] = 0;
pNew->wsFlags |= WHERE_SKIPSCAN;
|
| ︙ | ︙ | |||
171853 171854 171855 171856 171857 171858 171859 171860 171861 171862 171863 171864 171865 171866 |
int iDb; /* Index of database containing table/index */
SrcItem *pTabItem;
pTabItem = &pTabList->a[pLevel->iFrom];
pTab = pTabItem->pSTab;
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
pLoop = pLevel->pWLoop;
if( (pTab->tabFlags & TF_Ephemeral)!=0 || IsView(pTab) ){
/* Do nothing */
}else
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){
const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);
int iCur = pTabItem->iCursor;
| > > > > > > > > | 172050 172051 172052 172053 172054 172055 172056 172057 172058 172059 172060 172061 172062 172063 172064 172065 172066 172067 172068 172069 172070 172071 |
int iDb; /* Index of database containing table/index */
SrcItem *pTabItem;
pTabItem = &pTabList->a[pLevel->iFrom];
pTab = pTabItem->pSTab;
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
pLoop = pLevel->pWLoop;
pLevel->addrBrk = sqlite3VdbeMakeLabel(pParse);
if( ii==0 || (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
pLevel->addrHalt = pLevel->addrBrk;
}else if( pWInfo->a[ii-1].pRJ ){
pLevel->addrHalt = pWInfo->a[ii-1].addrBrk;
}else{
pLevel->addrHalt = pWInfo->a[ii-1].addrHalt;
}
if( (pTab->tabFlags & TF_Ephemeral)!=0 || IsView(pTab) ){
/* Do nothing */
}else
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){
const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);
int iCur = pTabItem->iCursor;
|
| ︙ | ︙ | |||
171904 171905 171906 171907 171908 171909 171910 171911 171912 171913 171914 171915 171916 171917 |
{
sqlite3VdbeChangeP5(v, bFordelete);
}
#ifdef SQLITE_ENABLE_COLUMN_USED_MASK
sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, pTabItem->iCursor, 0, 0,
(const u8*)&pTabItem->colUsed, P4_INT64);
#endif
}else{
sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
}
if( pLoop->wsFlags & WHERE_INDEXED ){
Index *pIx = pLoop->u.btree.pIndex;
int iIndexCur;
int op = OP_OpenRead;
| > > > > > > > | 172109 172110 172111 172112 172113 172114 172115 172116 172117 172118 172119 172120 172121 172122 172123 172124 172125 172126 172127 172128 172129 |
{
sqlite3VdbeChangeP5(v, bFordelete);
}
#ifdef SQLITE_ENABLE_COLUMN_USED_MASK
sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, pTabItem->iCursor, 0, 0,
(const u8*)&pTabItem->colUsed, P4_INT64);
#endif
if( ii>=2
&& (pTabItem[0].fg.jointype & (JT_LTORJ|JT_LEFT))==0
&& pLevel->addrHalt==pWInfo->a[0].addrHalt
){
sqlite3VdbeAddOp2(v, OP_IfEmpty, pTabItem->iCursor, pWInfo->iBreak);
VdbeCoverage(v);
}
}else{
sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
}
if( pLoop->wsFlags & WHERE_INDEXED ){
Index *pIx = pLoop->u.btree.pIndex;
int iIndexCur;
int op = OP_OpenRead;
|
| ︙ | ︙ | |||
172160 172161 172162 172163 172164 172165 172166 172167 172168 172169 172170 172171 172172 172173 |
op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT;
addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n);
VdbeCoverageIf(v, op==OP_SeekLT);
VdbeCoverageIf(v, op==OP_SeekGT);
sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);
}
#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
/* The common case: Advance to the next row */
if( pLevel->addrCont ) sqlite3VdbeResolveLabel(v, pLevel->addrCont);
sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3);
sqlite3VdbeChangeP5(v, pLevel->p5);
VdbeCoverage(v);
VdbeCoverageIf(v, pLevel->op==OP_Next);
VdbeCoverageIf(v, pLevel->op==OP_Prev);
| > > > | 172372 172373 172374 172375 172376 172377 172378 172379 172380 172381 172382 172383 172384 172385 172386 172387 172388 |
op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT;
addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n);
VdbeCoverageIf(v, op==OP_SeekLT);
VdbeCoverageIf(v, op==OP_SeekGT);
sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);
}
#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
if( pTabList->a[pLevel->iFrom].fg.fromExists ){
sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2);
}
/* The common case: Advance to the next row */
if( pLevel->addrCont ) sqlite3VdbeResolveLabel(v, pLevel->addrCont);
sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3);
sqlite3VdbeChangeP5(v, pLevel->p5);
VdbeCoverage(v);
VdbeCoverageIf(v, pLevel->op==OP_Next);
VdbeCoverageIf(v, pLevel->op==OP_Prev);
|
| ︙ | ︙ | |||
180232 180233 180234 180235 180236 180237 180238 |
{
if( yymsp[-1].minor.yy402==0 ){
/* Expressions of the form
**
** expr1 IN ()
** expr1 NOT IN ()
**
| | > > > > | > > > | | > | > | 180447 180448 180449 180450 180451 180452 180453 180454 180455 180456 180457 180458 180459 180460 180461 180462 180463 180464 180465 180466 180467 180468 180469 180470 180471 180472 180473 180474 180475 |
{
if( yymsp[-1].minor.yy402==0 ){
/* Expressions of the form
**
** expr1 IN ()
** expr1 NOT IN ()
**
** simplify to constants 0 (false) and 1 (true), respectively.
**
** Except, do not apply this optimization if expr1 contains a function
** because that function might be an aggregate (we don't know yet whether
** it is or not) and if it is an aggregate, that could change the meaning
** of the whole query.
*/
Expr *pB = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy502 ? "true" : "false");
if( pB ) sqlite3ExprIdToTrueFalse(pB);
if( !ExprHasProperty(yymsp[-4].minor.yy590, EP_HasFunc) ){
sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy590);
yymsp[-4].minor.yy590 = pB;
}else{
yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_OR : TK_AND, pB, yymsp[-4].minor.yy590);
}
}else{
Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
if( yymsp[-1].minor.yy402->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy590->op!=TK_VECTOR ){
yymsp[-1].minor.yy402->a[0].pExpr = 0;
sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy590, pRHS);
|
| ︙ | ︙ | |||
247030 247031 247032 247033 247034 247035 247036 |
** first rowid on this page.
*/
if( pLast ){
int iOff;
fts5DataRelease(pIter->pLeaf);
pIter->pLeaf = pLast;
pIter->iLeafPgno = pgnoLast;
| > | | | | | | | | | | | > | 247254 247255 247256 247257 247258 247259 247260 247261 247262 247263 247264 247265 247266 247267 247268 247269 247270 247271 247272 247273 247274 247275 247276 247277 247278 247279 247280 247281 |
** first rowid on this page.
*/
if( pLast ){
int iOff;
fts5DataRelease(pIter->pLeaf);
pIter->pLeaf = pLast;
pIter->iLeafPgno = pgnoLast;
if( p->rc==SQLITE_OK ){
iOff = fts5LeafFirstRowidOff(pLast);
if( iOff>pLast->szLeaf ){
FTS5_CORRUPT_ITER(p, pIter);
return;
}
iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid);
pIter->iLeafOffset = iOff;
if( fts5LeafIsTermless(pLast) ){
pIter->iEndofDoclist = pLast->nn+1;
}else{
pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast);
}
}
}
fts5SegIterReverseInitPage(p, pIter);
}
/*
|
| ︙ | ︙ | |||
250394 250395 250396 250397 250398 250399 250400 |
fts5StructureRef(pStruct);
return pStruct;
}
assert( pStruct->aLevel[i].nMerge<=nThis );
}
nByte += (((i64)pStruct->nLevel)+1) * sizeof(Fts5StructureLevel);
| | | 250620 250621 250622 250623 250624 250625 250626 250627 250628 250629 250630 250631 250632 250633 250634 |
fts5StructureRef(pStruct);
return pStruct;
}
assert( pStruct->aLevel[i].nMerge<=nThis );
}
nByte += (((i64)pStruct->nLevel)+1) * sizeof(Fts5StructureLevel);
assert( nByte==(i64)SZ_FTS5STRUCTURE(pStruct->nLevel+2) );
pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);
if( pNew ){
Fts5StructureLevel *pLvl;
nByte = nSeg * sizeof(Fts5StructureSegment);
pNew->nLevel = MIN(pStruct->nLevel+1, FTS5_MAX_LEVEL);
pNew->nRef = 1;
|
| ︙ | ︙ | |||
257646 257647 257648 257649 257650 257651 257652 |
static void fts5SourceIdFunc(
sqlite3_context *pCtx, /* Function call context */
int nArg, /* Number of args */
sqlite3_value **apUnused /* Function arguments */
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
| | | 257872 257873 257874 257875 257876 257877 257878 257879 257880 257881 257882 257883 257884 257885 257886 |
static void fts5SourceIdFunc(
sqlite3_context *pCtx, /* Function call context */
int nArg, /* Number of args */
sqlite3_value **apUnused /* Function arguments */
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2025-07-04 14:24:18 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b", -1, SQLITE_TRANSIENT);
}
/*
** Implementation of fts5_locale(LOCALE, TEXT) function.
**
** If parameter LOCALE is NULL, or a zero-length string, then a copy of
** TEXT is returned. Otherwise, both LOCALE and TEXT are interpreted as
|
| ︙ | ︙ |
Changes to extsrc/sqlite3.h.
| ︙ | ︙ | |||
144 145 146 147 148 149 150 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.51.0" #define SQLITE_VERSION_NUMBER 3051000 | | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.51.0" #define SQLITE_VERSION_NUMBER 3051000 #define SQLITE_SOURCE_ID "2025-07-04 14:24:18 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ |