| | @@ -452,11 +452,11 @@ |
| 452 | 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | 454 | */ |
| 455 | 455 | #define SQLITE_VERSION "3.39.0" |
| 456 | 456 | #define SQLITE_VERSION_NUMBER 3039000 |
| 457 | | -#define SQLITE_SOURCE_ID "2022-04-01 17:23:17 a7d79560a0efd6221ba59ce84bcb4fa94024a901ac4a45e192ddecc6e1b5c78c" |
| 457 | +#define SQLITE_SOURCE_ID "2022-04-21 19:38:17 f766dff012af0ea3c28a8ce4db850cd0205729a8283bce1e442992aded7c734b" |
| 458 | 458 | |
| 459 | 459 | /* |
| 460 | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 462 | ** |
| | @@ -14363,12 +14363,23 @@ |
| 14363 | 14363 | #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) |
| 14364 | 14364 | |
| 14365 | 14365 | /* |
| 14366 | 14366 | ** Round up a number to the next larger multiple of 8. This is used |
| 14367 | 14367 | ** to force 8-byte alignment on 64-bit architectures. |
| 14368 | +** |
| 14369 | +** ROUND8() always does the rounding, for any argument. |
| 14370 | +** |
| 14371 | +** ROUND8P() assumes that the argument is already an integer number of |
| 14372 | +** pointers in size, and so it is a no-op on systems where the pointer |
| 14373 | +** size is 8. |
| 14368 | 14374 | */ |
| 14369 | 14375 | #define ROUND8(x) (((x)+7)&~7) |
| 14376 | +#if SQLITE_PTRSIZE==8 |
| 14377 | +# define ROUND8P(x) (x) |
| 14378 | +#else |
| 14379 | +# define ROUND8P(x) (((x)+7)&~7) |
| 14380 | +#endif |
| 14370 | 14381 | |
| 14371 | 14382 | /* |
| 14372 | 14383 | ** Round down to the nearest multiple of 8 |
| 14373 | 14384 | */ |
| 14374 | 14385 | #define ROUNDDOWN8(x) ((x)&~7) |
| | @@ -14427,26 +14438,27 @@ |
| 14427 | 14438 | # undef SQLITE_DEFAULT_MMAP_SIZE |
| 14428 | 14439 | # define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE |
| 14429 | 14440 | #endif |
| 14430 | 14441 | |
| 14431 | 14442 | /* |
| 14432 | | -** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not |
| 14433 | | -** the Select query generator tracing logic is turned on. |
| 14443 | +** TREETRACE_ENABLED will be either 1 or 0 depending on whether or not |
| 14444 | +** the Abstract Syntax Tree tracing logic is turned on. |
| 14434 | 14445 | */ |
| 14435 | 14446 | #if !defined(SQLITE_AMALGAMATION) |
| 14436 | | -SQLITE_PRIVATE u32 sqlite3SelectTrace; |
| 14447 | +SQLITE_PRIVATE u32 sqlite3TreeTrace; |
| 14437 | 14448 | #endif |
| 14438 | 14449 | #if defined(SQLITE_DEBUG) \ |
| 14439 | | - && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_SELECTTRACE)) |
| 14440 | | -# define SELECTTRACE_ENABLED 1 |
| 14450 | + && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_SELECTTRACE) \ |
| 14451 | + || defined(SQLITE_ENABLE_TREETRACE)) |
| 14452 | +# define TREETRACE_ENABLED 1 |
| 14441 | 14453 | # define SELECTTRACE(K,P,S,X) \ |
| 14442 | | - if(sqlite3SelectTrace&(K)) \ |
| 14454 | + if(sqlite3TreeTrace&(K)) \ |
| 14443 | 14455 | sqlite3DebugPrintf("%u/%d/%p: ",(S)->selId,(P)->addrExplain,(S)),\ |
| 14444 | 14456 | sqlite3DebugPrintf X |
| 14445 | 14457 | #else |
| 14446 | 14458 | # define SELECTTRACE(K,P,S,X) |
| 14447 | | -# define SELECTTRACE_ENABLED 0 |
| 14459 | +# define TREETRACE_ENABLED 0 |
| 14448 | 14460 | #endif |
| 14449 | 14461 | |
| 14450 | 14462 | /* |
| 14451 | 14463 | ** Macros for "wheretrace" |
| 14452 | 14464 | */ |
| | @@ -14603,10 +14615,11 @@ |
| 14603 | 14615 | typedef struct KeyInfo KeyInfo; |
| 14604 | 14616 | typedef struct Lookaside Lookaside; |
| 14605 | 14617 | typedef struct LookasideSlot LookasideSlot; |
| 14606 | 14618 | typedef struct Module Module; |
| 14607 | 14619 | typedef struct NameContext NameContext; |
| 14620 | +typedef struct OnOrUsing OnOrUsing; |
| 14608 | 14621 | typedef struct Parse Parse; |
| 14609 | 14622 | typedef struct ParseCleanup ParseCleanup; |
| 14610 | 14623 | typedef struct PreUpdate PreUpdate; |
| 14611 | 14624 | typedef struct PrintfArguments PrintfArguments; |
| 14612 | 14625 | typedef struct RenameToken RenameToken; |
| | @@ -15581,14 +15594,14 @@ |
| 15581 | 15594 | #define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */ |
| 15582 | 15595 | #define OP_Return 67 |
| 15583 | 15596 | #define OP_EndCoroutine 68 |
| 15584 | 15597 | #define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */ |
| 15585 | 15598 | #define OP_Halt 70 |
| 15586 | | -#define OP_BeginSubrtn 71 /* synopsis: r[P2]=P1 */ |
| 15587 | | -#define OP_Integer 72 /* synopsis: r[P2]=P1 */ |
| 15588 | | -#define OP_Int64 73 /* synopsis: r[P2]=P4 */ |
| 15589 | | -#define OP_String 74 /* synopsis: r[P2]='P4' (len=P1) */ |
| 15599 | +#define OP_Integer 71 /* synopsis: r[P2]=P1 */ |
| 15600 | +#define OP_Int64 72 /* synopsis: r[P2]=P4 */ |
| 15601 | +#define OP_String 73 /* synopsis: r[P2]='P4' (len=P1) */ |
| 15602 | +#define OP_BeginSubrtn 74 /* synopsis: r[P2]=NULL */ |
| 15590 | 15603 | #define OP_Null 75 /* synopsis: r[P2..P3]=NULL */ |
| 15591 | 15604 | #define OP_SoftNull 76 /* synopsis: r[P1]=NULL */ |
| 15592 | 15605 | #define OP_Blob 77 /* synopsis: r[P2]=P4 (len=P1) */ |
| 15593 | 15606 | #define OP_Variable 78 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 15594 | 15607 | #define OP_Move 79 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| | @@ -15604,11 +15617,11 @@ |
| 15604 | 15617 | #define OP_Permutation 89 |
| 15605 | 15618 | #define OP_Compare 90 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 15606 | 15619 | #define OP_IsTrue 91 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ |
| 15607 | 15620 | #define OP_ZeroOrNull 92 /* synopsis: r[P2] = 0 OR NULL */ |
| 15608 | 15621 | #define OP_Offset 93 /* synopsis: r[P3] = sqlite_offset(P1) */ |
| 15609 | | -#define OP_Column 94 /* synopsis: r[P3]=PX */ |
| 15622 | +#define OP_Column 94 /* synopsis: r[P3]=PX cursor P1 column P2 */ |
| 15610 | 15623 | #define OP_TypeCheck 95 /* synopsis: typecheck(r[P1@P2]) */ |
| 15611 | 15624 | #define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */ |
| 15612 | 15625 | #define OP_MakeRecord 97 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 15613 | 15626 | #define OP_Count 98 /* synopsis: r[P2]=count() */ |
| 15614 | 15627 | #define OP_ReadCookie 99 |
| | @@ -15645,11 +15658,11 @@ |
| 15645 | 15658 | #define OP_Delete 130 |
| 15646 | 15659 | #define OP_ResetCount 131 |
| 15647 | 15660 | #define OP_SorterCompare 132 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 15648 | 15661 | #define OP_SorterData 133 /* synopsis: r[P2]=data */ |
| 15649 | 15662 | #define OP_RowData 134 /* synopsis: r[P2]=data */ |
| 15650 | | -#define OP_Rowid 135 /* synopsis: r[P2]=rowid */ |
| 15663 | +#define OP_Rowid 135 /* synopsis: r[P2]=PX rowid of P1 */ |
| 15651 | 15664 | #define OP_NullRow 136 |
| 15652 | 15665 | #define OP_SeekEnd 137 |
| 15653 | 15666 | #define OP_IdxInsert 138 /* synopsis: key=r[P2] */ |
| 15654 | 15667 | #define OP_SorterInsert 139 /* synopsis: key=r[P2] */ |
| 15655 | 15668 | #define OP_IdxDelete 140 /* synopsis: key=r[P2@P3] */ |
| | @@ -15716,12 +15729,12 @@ |
| 15716 | 15729 | /* 24 */ 0x01, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x01,\ |
| 15717 | 15730 | /* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ |
| 15718 | 15731 | /* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\ |
| 15719 | 15732 | /* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ |
| 15720 | 15733 | /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\ |
| 15721 | | -/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x00,\ |
| 15722 | | -/* 72 */ 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00,\ |
| 15734 | +/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\ |
| 15735 | +/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00,\ |
| 15723 | 15736 | /* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02,\ |
| 15724 | 15737 | /* 88 */ 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x00, 0x00,\ |
| 15725 | 15738 | /* 96 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x26, 0x26,\ |
| 15726 | 15739 | /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 15727 | 15740 | /* 112 */ 0x00, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00,\ |
| | @@ -15823,11 +15836,10 @@ |
| 15823 | 15836 | SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); |
| 15824 | 15837 | SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Parse*); |
| 15825 | 15838 | SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*); |
| 15826 | 15839 | SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe*); |
| 15827 | 15840 | SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*); |
| 15828 | | -SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*); |
| 15829 | 15841 | SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*); |
| 15830 | 15842 | SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*); |
| 15831 | 15843 | SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int); |
| 15832 | 15844 | SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*); |
| 15833 | 15845 | #ifdef SQLITE_DEBUG |
| | @@ -17038,10 +17050,11 @@ |
| 17038 | 17050 | #define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */ |
| 17039 | 17051 | /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */ |
| 17040 | 17052 | #define SQLITE_BloomFilter 0x00080000 /* Use a Bloom filter on searches */ |
| 17041 | 17053 | #define SQLITE_BloomPulldown 0x00100000 /* Run Bloom filters early */ |
| 17042 | 17054 | #define SQLITE_BalancedMerge 0x00200000 /* Balance multi-way merges */ |
| 17055 | +#define SQLITE_ReleaseReg 0x00400000 /* Use OP_ReleaseReg for testing */ |
| 17043 | 17056 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ |
| 17044 | 17057 | |
| 17045 | 17058 | /* |
| 17046 | 17059 | ** Macros for testing whether or not optimizations are enabled or disabled. |
| 17047 | 17060 | */ |
| | @@ -18102,11 +18115,11 @@ |
| 18102 | 18115 | ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. |
| 18103 | 18116 | ** TK_VARIABLE: variable number (always >= 1). |
| 18104 | 18117 | ** TK_SELECT_COLUMN: column of the result vector */ |
| 18105 | 18118 | i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ |
| 18106 | 18119 | union { |
| 18107 | | - int iRightJoinTable; /* If EP_FromJoin, the right table of the join */ |
| 18120 | + int iJoin; /* If EP_FromJoin, the right table of the join */ |
| 18108 | 18121 | int iOfst; /* else: start of token from start of statement */ |
| 18109 | 18122 | } w; |
| 18110 | 18123 | AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ |
| 18111 | 18124 | union { |
| 18112 | 18125 | Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL |
| | @@ -18145,11 +18158,11 @@ |
| 18145 | 18158 | #define EP_IfNullRow 0x020000 /* The TK_IF_NULL_ROW opcode */ |
| 18146 | 18159 | #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */ |
| 18147 | 18160 | #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ |
| 18148 | 18161 | #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */ |
| 18149 | 18162 | #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */ |
| 18150 | | - /* 0x400000 // Available */ |
| 18163 | +#define EP_InnerJoin 0x400000 /* Originates in ON/USING of an inner join */ |
| 18151 | 18164 | #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */ |
| 18152 | 18165 | #define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */ |
| 18153 | 18166 | #define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */ |
| 18154 | 18167 | #define EP_Quoted 0x4000000 /* TK_ID was originally quoted */ |
| 18155 | 18168 | #define EP_Static 0x8000000 /* Held in memory not obtained from malloc() */ |
| | @@ -18262,10 +18275,11 @@ |
| 18262 | 18275 | unsigned eEName :2; /* Meaning of zEName */ |
| 18263 | 18276 | unsigned done :1; /* A flag to indicate when processing is finished */ |
| 18264 | 18277 | unsigned reusable :1; /* Constant expression is reusable */ |
| 18265 | 18278 | unsigned bSorterRef :1; /* Defer evaluation until after sorting */ |
| 18266 | 18279 | unsigned bNulls: 1; /* True if explicit "NULLS FIRST/LAST" */ |
| 18280 | + unsigned bUsed: 1; /* This column used in a SF_NestedFrom subquery */ |
| 18267 | 18281 | union { |
| 18268 | 18282 | struct { /* Used by any ExprList other than Parse.pConsExpr */ |
| 18269 | 18283 | u16 iOrderByCol; /* For ORDER BY, column number in result set */ |
| 18270 | 18284 | u16 iAlias; /* Index into Parse.aAlias[] for zName */ |
| 18271 | 18285 | } x; |
| | @@ -18296,17 +18310,29 @@ |
| 18296 | 18310 | ** INSERT INTO t(a,b,c) ... |
| 18297 | 18311 | ** |
| 18298 | 18312 | ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k. |
| 18299 | 18313 | */ |
| 18300 | 18314 | struct IdList { |
| 18315 | + int nId; /* Number of identifiers on the list */ |
| 18316 | + u8 eU4; /* Which element of a.u4 is valid */ |
| 18301 | 18317 | struct IdList_item { |
| 18302 | 18318 | char *zName; /* Name of the identifier */ |
| 18303 | | - int idx; /* Index in some Table.aCol[] of a column named zName */ |
| 18304 | | - } *a; |
| 18305 | | - int nId; /* Number of identifiers on the list */ |
| 18319 | + union { |
| 18320 | + int idx; /* Index in some Table.aCol[] of a column named zName */ |
| 18321 | + Expr *pExpr; /* Expr to implement a USING variable -- NOT USED */ |
| 18322 | + } u4; |
| 18323 | + } a[1]; |
| 18306 | 18324 | }; |
| 18307 | 18325 | |
| 18326 | +/* |
| 18327 | +** Allowed values for IdList.eType, which determines which value of the a.u4 |
| 18328 | +** is valid. |
| 18329 | +*/ |
| 18330 | +#define EU4_NONE 0 /* Does not use IdList.a.u4 */ |
| 18331 | +#define EU4_IDX 1 /* Uses IdList.a.u4.idx */ |
| 18332 | +#define EU4_EXPR 2 /* Uses IdList.a.u4.pExpr -- NOT CURRENTLY USED */ |
| 18333 | + |
| 18308 | 18334 | /* |
| 18309 | 18335 | ** The SrcItem object represents a single term in the FROM clause of a query. |
| 18310 | 18336 | ** The SrcList object is mostly an array of SrcItems. |
| 18311 | 18337 | ** |
| 18312 | 18338 | ** Union member validity: |
| | @@ -18335,14 +18361,19 @@ |
| 18335 | 18361 | unsigned viaCoroutine :1; /* Implemented as a co-routine */ |
| 18336 | 18362 | unsigned isRecursive :1; /* True for recursive reference in WITH */ |
| 18337 | 18363 | unsigned fromDDL :1; /* Comes from sqlite_schema */ |
| 18338 | 18364 | unsigned isCte :1; /* This is a CTE */ |
| 18339 | 18365 | unsigned notCte :1; /* This item may not match a CTE */ |
| 18366 | + unsigned isUsing :1; /* u3.pUsing is valid */ |
| 18367 | + unsigned isSynthUsing :1; /* u3.pUsing is synthensized from NATURAL */ |
| 18368 | + unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */ |
| 18340 | 18369 | } fg; |
| 18341 | 18370 | int iCursor; /* The VDBE cursor number used to access this table */ |
| 18342 | | - Expr *pOn; /* The ON clause of a join */ |
| 18343 | | - IdList *pUsing; /* The USING clause of a join */ |
| 18371 | + union { |
| 18372 | + Expr *pOn; /* fg.isUsing==0 => The ON clause of a join */ |
| 18373 | + IdList *pUsing; /* fg.isUsing==1 => The USING clause of a join */ |
| 18374 | + } u3; |
| 18344 | 18375 | Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */ |
| 18345 | 18376 | union { |
| 18346 | 18377 | char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */ |
| 18347 | 18378 | ExprList *pFuncArg; /* Arguments to table-valued-function */ |
| 18348 | 18379 | } u1; |
| | @@ -18349,10 +18380,19 @@ |
| 18349 | 18380 | union { |
| 18350 | 18381 | Index *pIBIndex; /* Index structure corresponding to u1.zIndexedBy */ |
| 18351 | 18382 | CteUse *pCteUse; /* CTE Usage info info fg.isCte is true */ |
| 18352 | 18383 | } u2; |
| 18353 | 18384 | }; |
| 18385 | + |
| 18386 | +/* |
| 18387 | +** The OnOrUsing object represents either an ON clause or a USING clause. |
| 18388 | +** It can never be both at the same time, but it can be neither. |
| 18389 | +*/ |
| 18390 | +struct OnOrUsing { |
| 18391 | + Expr *pOn; /* The ON clause of a join */ |
| 18392 | + IdList *pUsing; /* The USING clause of a join */ |
| 18393 | +}; |
| 18354 | 18394 | |
| 18355 | 18395 | /* |
| 18356 | 18396 | ** The following structure describes the FROM clause of a SELECT statement. |
| 18357 | 18397 | ** Each table or subquery in the FROM clause is a separate element of |
| 18358 | 18398 | ** the SrcList.a[] array. |
| | @@ -18378,18 +18418,19 @@ |
| 18378 | 18418 | }; |
| 18379 | 18419 | |
| 18380 | 18420 | /* |
| 18381 | 18421 | ** Permitted values of the SrcList.a.jointype field |
| 18382 | 18422 | */ |
| 18383 | | -#define JT_INNER 0x0001 /* Any kind of inner or cross join */ |
| 18384 | | -#define JT_CROSS 0x0002 /* Explicit use of the CROSS keyword */ |
| 18385 | | -#define JT_NATURAL 0x0004 /* True for a "natural" join */ |
| 18386 | | -#define JT_LEFT 0x0008 /* Left outer join */ |
| 18387 | | -#define JT_RIGHT 0x0010 /* Right outer join */ |
| 18388 | | -#define JT_OUTER 0x0020 /* The "OUTER" keyword is present */ |
| 18389 | | -#define JT_ERROR 0x0040 /* unknown or unsupported join type */ |
| 18390 | | - |
| 18423 | +#define JT_INNER 0x01 /* Any kind of inner or cross join */ |
| 18424 | +#define JT_CROSS 0x02 /* Explicit use of the CROSS keyword */ |
| 18425 | +#define JT_NATURAL 0x04 /* True for a "natural" join */ |
| 18426 | +#define JT_LEFT 0x08 /* Left outer join */ |
| 18427 | +#define JT_RIGHT 0x10 /* Right outer join */ |
| 18428 | +#define JT_OUTER 0x20 /* The "OUTER" keyword is present */ |
| 18429 | +#define JT_LTORJ 0x40 /* One of the LEFT operands of a RIGHT JOIN |
| 18430 | + ** Mnemonic: Left Table Of Right Join */ |
| 18431 | +#define JT_ERROR 0x80 /* unknown or unsupported join type */ |
| 18391 | 18432 | |
| 18392 | 18433 | /* |
| 18393 | 18434 | ** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin() |
| 18394 | 18435 | ** and the WhereInfo.wctrlFlags member. |
| 18395 | 18436 | ** |
| | @@ -18408,11 +18449,11 @@ |
| 18408 | 18449 | #define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */ |
| 18409 | 18450 | #define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */ |
| 18410 | 18451 | #define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */ |
| 18411 | 18452 | #define WHERE_AGG_DISTINCT 0x0400 /* Query is "SELECT agg(DISTINCT ...)" */ |
| 18412 | 18453 | #define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */ |
| 18413 | | - /* 0x1000 not currently used */ |
| 18454 | +#define WHERE_RIGHT_JOIN 0x1000 /* Processing a RIGHT JOIN */ |
| 18414 | 18455 | /* 0x2000 not currently used */ |
| 18415 | 18456 | #define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */ |
| 18416 | 18457 | /* 0x8000 not currently used */ |
| 18417 | 18458 | |
| 18418 | 18459 | /* Allowed return values from sqlite3WhereIsDistinct() |
| | @@ -18604,10 +18645,13 @@ |
| 18604 | 18645 | #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */ |
| 18605 | 18646 | #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */ |
| 18606 | 18647 | #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */ |
| 18607 | 18648 | #define SF_OrderByReqd 0x8000000 /* The ORDER BY clause may not be omitted */ |
| 18608 | 18649 | |
| 18650 | +/* True if S exists and has SF_NestedFrom */ |
| 18651 | +#define IsNestedFrom(S) ((S)!=0 && ((S)->selFlags&SF_NestedFrom)!=0) |
| 18652 | + |
| 18609 | 18653 | /* |
| 18610 | 18654 | ** The results of a SELECT can be distributed in several ways, as defined |
| 18611 | 18655 | ** by one of the following macros. The "SRT" prefix means "SELECT Result |
| 18612 | 18656 | ** Type". |
| 18613 | 18657 | ** |
| | @@ -18815,10 +18859,11 @@ |
| 18815 | 18859 | u8 mayAbort; /* True if statement may throw an ABORT exception */ |
| 18816 | 18860 | u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */ |
| 18817 | 18861 | u8 okConstFactor; /* OK to factor out constants */ |
| 18818 | 18862 | u8 disableLookaside; /* Number of times lookaside has been disabled */ |
| 18819 | 18863 | u8 disableVtab; /* Disable all virtual tables for this parse */ |
| 18864 | + u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */ |
| 18820 | 18865 | #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) |
| 18821 | 18866 | u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */ |
| 18822 | 18867 | #endif |
| 18823 | 18868 | int nRangeReg; /* Size of the temporary register block */ |
| 18824 | 18869 | int iRangeReg; /* First register in temporary register block */ |
| | @@ -18987,24 +19032,24 @@ |
| 18987 | 19032 | #define OPFLAG_AUXDELETE 0x04 /* OP_Delete: index in a DELETE op */ |
| 18988 | 19033 | #define OPFLAG_NOCHNG_MAGIC 0x6d /* OP_MakeRecord: serialtype 10 is ok */ |
| 18989 | 19034 | #define OPFLAG_PREFORMAT 0x80 /* OP_Insert uses preformatted cell */ |
| 18990 | 19035 | |
| 18991 | 19036 | /* |
| 18992 | | - * Each trigger present in the database schema is stored as an instance of |
| 18993 | | - * struct Trigger. |
| 18994 | | - * |
| 18995 | | - * Pointers to instances of struct Trigger are stored in two ways. |
| 18996 | | - * 1. In the "trigHash" hash table (part of the sqlite3* that represents the |
| 18997 | | - * database). This allows Trigger structures to be retrieved by name. |
| 18998 | | - * 2. All triggers associated with a single table form a linked list, using the |
| 18999 | | - * pNext member of struct Trigger. A pointer to the first element of the |
| 19000 | | - * linked list is stored as the "pTrigger" member of the associated |
| 19001 | | - * struct Table. |
| 19002 | | - * |
| 19003 | | - * The "step_list" member points to the first element of a linked list |
| 19004 | | - * containing the SQL statements specified as the trigger program. |
| 19005 | | - */ |
| 19037 | +** Each trigger present in the database schema is stored as an instance of |
| 19038 | +** struct Trigger. |
| 19039 | +** |
| 19040 | +** Pointers to instances of struct Trigger are stored in two ways. |
| 19041 | +** 1. In the "trigHash" hash table (part of the sqlite3* that represents the |
| 19042 | +** database). This allows Trigger structures to be retrieved by name. |
| 19043 | +** 2. All triggers associated with a single table form a linked list, using the |
| 19044 | +** pNext member of struct Trigger. A pointer to the first element of the |
| 19045 | +** linked list is stored as the "pTrigger" member of the associated |
| 19046 | +** struct Table. |
| 19047 | +** |
| 19048 | +** The "step_list" member points to the first element of a linked list |
| 19049 | +** containing the SQL statements specified as the trigger program. |
| 19050 | +*/ |
| 19006 | 19051 | struct Trigger { |
| 19007 | 19052 | char *zName; /* The name of the trigger */ |
| 19008 | 19053 | char *table; /* The table or view to which the trigger applies */ |
| 19009 | 19054 | u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */ |
| 19010 | 19055 | u8 tr_tm; /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ |
| | @@ -19027,47 +19072,52 @@ |
| 19027 | 19072 | */ |
| 19028 | 19073 | #define TRIGGER_BEFORE 1 |
| 19029 | 19074 | #define TRIGGER_AFTER 2 |
| 19030 | 19075 | |
| 19031 | 19076 | /* |
| 19032 | | - * An instance of struct TriggerStep is used to store a single SQL statement |
| 19033 | | - * that is a part of a trigger-program. |
| 19034 | | - * |
| 19035 | | - * Instances of struct TriggerStep are stored in a singly linked list (linked |
| 19036 | | - * using the "pNext" member) referenced by the "step_list" member of the |
| 19037 | | - * associated struct Trigger instance. The first element of the linked list is |
| 19038 | | - * the first step of the trigger-program. |
| 19039 | | - * |
| 19040 | | - * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or |
| 19041 | | - * "SELECT" statement. The meanings of the other members is determined by the |
| 19042 | | - * value of "op" as follows: |
| 19043 | | - * |
| 19044 | | - * (op == TK_INSERT) |
| 19045 | | - * orconf -> stores the ON CONFLICT algorithm |
| 19046 | | - * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then |
| 19047 | | - * this stores a pointer to the SELECT statement. Otherwise NULL. |
| 19048 | | - * zTarget -> Dequoted name of the table to insert into. |
| 19049 | | - * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then |
| 19050 | | - * this stores values to be inserted. Otherwise NULL. |
| 19051 | | - * pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ... |
| 19052 | | - * statement, then this stores the column-names to be |
| 19053 | | - * inserted into. |
| 19054 | | - * |
| 19055 | | - * (op == TK_DELETE) |
| 19056 | | - * zTarget -> Dequoted name of the table to delete from. |
| 19057 | | - * pWhere -> The WHERE clause of the DELETE statement if one is specified. |
| 19058 | | - * Otherwise NULL. |
| 19059 | | - * |
| 19060 | | - * (op == TK_UPDATE) |
| 19061 | | - * zTarget -> Dequoted name of the table to update. |
| 19062 | | - * pWhere -> The WHERE clause of the UPDATE statement if one is specified. |
| 19063 | | - * Otherwise NULL. |
| 19064 | | - * pExprList -> A list of the columns to update and the expressions to update |
| 19065 | | - * them to. See sqlite3Update() documentation of "pChanges" |
| 19066 | | - * argument. |
| 19067 | | - * |
| 19068 | | - */ |
| 19077 | +** An instance of struct TriggerStep is used to store a single SQL statement |
| 19078 | +** that is a part of a trigger-program. |
| 19079 | +** |
| 19080 | +** Instances of struct TriggerStep are stored in a singly linked list (linked |
| 19081 | +** using the "pNext" member) referenced by the "step_list" member of the |
| 19082 | +** associated struct Trigger instance. The first element of the linked list is |
| 19083 | +** the first step of the trigger-program. |
| 19084 | +** |
| 19085 | +** The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or |
| 19086 | +** "SELECT" statement. The meanings of the other members is determined by the |
| 19087 | +** value of "op" as follows: |
| 19088 | +** |
| 19089 | +** (op == TK_INSERT) |
| 19090 | +** orconf -> stores the ON CONFLICT algorithm |
| 19091 | +** pSelect -> The content to be inserted - either a SELECT statement or |
| 19092 | +** a VALUES clause. |
| 19093 | +** zTarget -> Dequoted name of the table to insert into. |
| 19094 | +** pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ... |
| 19095 | +** statement, then this stores the column-names to be |
| 19096 | +** inserted into. |
| 19097 | +** pUpsert -> The ON CONFLICT clauses for an Upsert |
| 19098 | +** |
| 19099 | +** (op == TK_DELETE) |
| 19100 | +** zTarget -> Dequoted name of the table to delete from. |
| 19101 | +** pWhere -> The WHERE clause of the DELETE statement if one is specified. |
| 19102 | +** Otherwise NULL. |
| 19103 | +** |
| 19104 | +** (op == TK_UPDATE) |
| 19105 | +** zTarget -> Dequoted name of the table to update. |
| 19106 | +** pWhere -> The WHERE clause of the UPDATE statement if one is specified. |
| 19107 | +** Otherwise NULL. |
| 19108 | +** pExprList -> A list of the columns to update and the expressions to update |
| 19109 | +** them to. See sqlite3Update() documentation of "pChanges" |
| 19110 | +** argument. |
| 19111 | +** |
| 19112 | +** (op == TK_SELECT) |
| 19113 | +** pSelect -> The SELECT statement |
| 19114 | +** |
| 19115 | +** (op == TK_RETURNING) |
| 19116 | +** pExprList -> The list of expressions that follow the RETURNING keyword. |
| 19117 | +** |
| 19118 | +*/ |
| 19069 | 19119 | struct TriggerStep { |
| 19070 | 19120 | u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT, |
| 19071 | 19121 | ** or TK_RETURNING */ |
| 19072 | 19122 | u8 orconf; /* OE_Rollback etc. */ |
| 19073 | 19123 | Trigger *pTrig; /* The trigger that this step is a part of */ |
| | @@ -19673,22 +19723,54 @@ |
| 19673 | 19723 | #if defined(SQLITE_TEST) |
| 19674 | 19724 | SQLITE_PRIVATE void *sqlite3TestTextToPtr(const char*); |
| 19675 | 19725 | #endif |
| 19676 | 19726 | |
| 19677 | 19727 | #if defined(SQLITE_DEBUG) |
| 19728 | +SQLITE_PRIVATE void sqlite3TreeViewLine(TreeView*, const char *zFormat, ...); |
| 19678 | 19729 | SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8); |
| 19679 | 19730 | SQLITE_PRIVATE void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*); |
| 19680 | 19731 | SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*); |
| 19732 | +SQLITE_PRIVATE void sqlite3TreeViewBareIdList(TreeView*, const IdList*, const char*); |
| 19733 | +SQLITE_PRIVATE void sqlite3TreeViewIdList(TreeView*, const IdList*, u8, const char*); |
| 19681 | 19734 | SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView*, const SrcList*); |
| 19682 | 19735 | SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8); |
| 19683 | 19736 | SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8); |
| 19737 | +SQLITE_PRIVATE void sqlite3TreeViewUpsert(TreeView*, const Upsert*, u8); |
| 19738 | +SQLITE_PRIVATE void sqlite3TreeViewDelete(const With*, const SrcList*, const Expr*, |
| 19739 | + const ExprList*,const Expr*, const Trigger*); |
| 19740 | +SQLITE_PRIVATE void sqlite3TreeViewInsert(const With*, const SrcList*, |
| 19741 | + const IdList*, const Select*, const ExprList*, |
| 19742 | + int, const Upsert*, const Trigger*); |
| 19743 | +SQLITE_PRIVATE void sqlite3TreeViewUpdate(const With*, const SrcList*, const ExprList*, |
| 19744 | + const Expr*, int, const ExprList*, const Expr*, |
| 19745 | + const Upsert*, const Trigger*); |
| 19746 | +#ifndef SQLITE_OMIT_TRIGGER |
| 19747 | +SQLITE_PRIVATE void sqlite3TreeViewTriggerStep(TreeView*, const TriggerStep*, u8, u8); |
| 19748 | +SQLITE_PRIVATE void sqlite3TreeViewTrigger(TreeView*, const Trigger*, u8, u8); |
| 19749 | +#endif |
| 19684 | 19750 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 19685 | 19751 | SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView*, const Window*, u8); |
| 19686 | 19752 | SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8); |
| 19687 | 19753 | #endif |
| 19754 | +SQLITE_PRIVATE void sqlite3ShowExpr(const Expr*); |
| 19755 | +SQLITE_PRIVATE void sqlite3ShowExprList(const ExprList*); |
| 19756 | +SQLITE_PRIVATE void sqlite3ShowIdList(const IdList*); |
| 19757 | +SQLITE_PRIVATE void sqlite3ShowSrcList(const SrcList*); |
| 19758 | +SQLITE_PRIVATE void sqlite3ShowSelect(const Select*); |
| 19759 | +SQLITE_PRIVATE void sqlite3ShowWith(const With*); |
| 19760 | +SQLITE_PRIVATE void sqlite3ShowUpsert(const Upsert*); |
| 19761 | +#ifndef SQLITE_OMIT_TRIGGER |
| 19762 | +SQLITE_PRIVATE void sqlite3ShowTriggerStep(const TriggerStep*); |
| 19763 | +SQLITE_PRIVATE void sqlite3ShowTriggerStepList(const TriggerStep*); |
| 19764 | +SQLITE_PRIVATE void sqlite3ShowTrigger(const Trigger*); |
| 19765 | +SQLITE_PRIVATE void sqlite3ShowTriggerList(const Trigger*); |
| 19688 | 19766 | #endif |
| 19689 | | - |
| 19767 | +#ifndef SQLITE_OMIT_WINDOWFUNC |
| 19768 | +SQLITE_PRIVATE void sqlite3ShowWindow(const Window*); |
| 19769 | +SQLITE_PRIVATE void sqlite3ShowWinFunc(const Window*); |
| 19770 | +#endif |
| 19771 | +#endif |
| 19690 | 19772 | |
| 19691 | 19773 | SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*); |
| 19692 | 19774 | SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...); |
| 19693 | 19775 | SQLITE_PRIVATE int sqlite3ErrorToParser(sqlite3*,int); |
| 19694 | 19776 | SQLITE_PRIVATE void sqlite3Dequote(char*); |
| | @@ -19833,17 +19915,18 @@ |
| 19833 | 19915 | SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*); |
| 19834 | 19916 | SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(Parse*, SrcList*, int, int); |
| 19835 | 19917 | SQLITE_PRIVATE SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, SrcList *p2); |
| 19836 | 19918 | SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(Parse*, SrcList*, Token*, Token*); |
| 19837 | 19919 | SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, |
| 19838 | | - Token*, Select*, Expr*, IdList*); |
| 19920 | + Token*, Select*, OnOrUsing*); |
| 19839 | 19921 | SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *); |
| 19840 | 19922 | SQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*); |
| 19841 | 19923 | SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, SrcItem *); |
| 19842 | | -SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*); |
| 19924 | +SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(Parse*,SrcList*); |
| 19843 | 19925 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*); |
| 19844 | 19926 | SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*); |
| 19927 | +SQLITE_PRIVATE void sqlite3ClearOnOrUsing(sqlite3*, OnOrUsing*); |
| 19845 | 19928 | SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*); |
| 19846 | 19929 | SQLITE_PRIVATE Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**); |
| 19847 | 19930 | SQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
| 19848 | 19931 | Expr*, int, int, u8); |
| 19849 | 19932 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| | @@ -20036,11 +20119,12 @@ |
| 20036 | 20119 | # define sqlite3TriggerStepSrc(A,B) 0 |
| 20037 | 20120 | #endif |
| 20038 | 20121 | |
| 20039 | 20122 | SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*); |
| 20040 | 20123 | SQLITE_PRIVATE int sqlite3ColumnIndex(Table *pTab, const char *zCol); |
| 20041 | | -SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr*,int); |
| 20124 | +SQLITE_PRIVATE void sqlite3SrcItemColumnUsed(SrcItem*,int); |
| 20125 | +SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr*,int,u32); |
| 20042 | 20126 | SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); |
| 20043 | 20127 | SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int); |
| 20044 | 20128 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 20045 | 20129 | SQLITE_PRIVATE void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*); |
| 20046 | 20130 | SQLITE_PRIVATE int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*); |
| | @@ -20382,11 +20466,11 @@ |
| 20382 | 20466 | SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *); |
| 20383 | 20467 | |
| 20384 | 20468 | SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*); |
| 20385 | 20469 | #if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \ |
| 20386 | 20470 | && !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 20387 | | -SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info*); |
| 20471 | +SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info*); |
| 20388 | 20472 | #endif |
| 20389 | 20473 | SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*); |
| 20390 | 20474 | SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); |
| 20391 | 20475 | SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *); |
| 20392 | 20476 | SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*); |
| | @@ -21130,13 +21214,10 @@ |
| 21130 | 21214 | "ENABLE_RBU", |
| 21131 | 21215 | #endif |
| 21132 | 21216 | #ifdef SQLITE_ENABLE_RTREE |
| 21133 | 21217 | "ENABLE_RTREE", |
| 21134 | 21218 | #endif |
| 21135 | | -#ifdef SQLITE_ENABLE_SELECTTRACE |
| 21136 | | - "ENABLE_SELECTTRACE", |
| 21137 | | -#endif |
| 21138 | 21219 | #ifdef SQLITE_ENABLE_SESSION |
| 21139 | 21220 | "ENABLE_SESSION", |
| 21140 | 21221 | #endif |
| 21141 | 21222 | #ifdef SQLITE_ENABLE_SNAPSHOT |
| 21142 | 21223 | "ENABLE_SNAPSHOT", |
| | @@ -21153,10 +21234,13 @@ |
| 21153 | 21234 | #ifdef SQLITE_ENABLE_STMTVTAB |
| 21154 | 21235 | "ENABLE_STMTVTAB", |
| 21155 | 21236 | #endif |
| 21156 | 21237 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 21157 | 21238 | "ENABLE_STMT_SCANSTATUS", |
| 21239 | +#endif |
| 21240 | +#ifdef SQLITE_ENABLE_TREETRACE |
| 21241 | + "ENABLE_TREETRACE", |
| 21158 | 21242 | #endif |
| 21159 | 21243 | #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 21160 | 21244 | "ENABLE_UNKNOWN_SQL_FUNCTION", |
| 21161 | 21245 | #endif |
| 21162 | 21246 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| | @@ -21960,11 +22044,11 @@ |
| 21960 | 22044 | #endif |
| 21961 | 22045 | |
| 21962 | 22046 | /* |
| 21963 | 22047 | ** Tracing flags set by SQLITE_TESTCTRL_TRACEFLAGS. |
| 21964 | 22048 | */ |
| 21965 | | -SQLITE_PRIVATE u32 sqlite3SelectTrace = 0; |
| 22049 | +SQLITE_PRIVATE u32 sqlite3TreeTrace = 0; |
| 21966 | 22050 | SQLITE_PRIVATE u32 sqlite3WhereTrace = 0; |
| 21967 | 22051 | |
| 21968 | 22052 | /* #include "opcodes.h" */ |
| 21969 | 22053 | /* |
| 21970 | 22054 | ** Properties of opcodes. The OPFLG_INITIALIZER macro is |
| | @@ -22175,10 +22259,15 @@ |
| 22175 | 22259 | ** static element declared in the structure. nField total array slots for |
| 22176 | 22260 | ** aType[] and nField+1 array slots for aOffset[] */ |
| 22177 | 22261 | u32 aType[1]; /* Type values record decode. MUST BE LAST */ |
| 22178 | 22262 | }; |
| 22179 | 22263 | |
| 22264 | +/* Return true if P is a null-only cursor |
| 22265 | +*/ |
| 22266 | +#define IsNullCursor(P) \ |
| 22267 | + ((P)->eCurType==CURTYPE_PSEUDO && (P)->nullRow && (P)->seekResult==0) |
| 22268 | + |
| 22180 | 22269 | |
| 22181 | 22270 | /* |
| 22182 | 22271 | ** A value for VdbeCursor.cacheStatus that means the cache is always invalid. |
| 22183 | 22272 | */ |
| 22184 | 22273 | #define CACHE_STALE 0 |
| | @@ -22496,16 +22585,14 @@ |
| 22496 | 22585 | #endif |
| 22497 | 22586 | u16 nResColumn; /* Number of columns in one row of the result set */ |
| 22498 | 22587 | u8 errorAction; /* Recovery action to do in case of an error */ |
| 22499 | 22588 | u8 minWriteFileFormat; /* Minimum file format for writable database files */ |
| 22500 | 22589 | u8 prepFlags; /* SQLITE_PREPARE_* flags */ |
| 22501 | | - u8 doingRerun; /* True if rerunning after an auto-reprepare */ |
| 22502 | 22590 | u8 eVdbeState; /* On of the VDBE_*_STATE values */ |
| 22503 | 22591 | bft expired:2; /* 1: recompile VM immediately 2: when convenient */ |
| 22504 | 22592 | bft explain:2; /* True if EXPLAIN present on SQL command */ |
| 22505 | 22593 | bft changeCntOn:1; /* True to update the change-counter */ |
| 22506 | | - bft runOnlyOnce:1; /* Automatically expire on reset */ |
| 22507 | 22594 | bft usesStmtJournal:1; /* True if uses a statement journal */ |
| 22508 | 22595 | bft readOnly:1; /* True for statements that do not write */ |
| 22509 | 22596 | bft bIsReader:1; /* True for statements that read */ |
| 22510 | 22597 | yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ |
| 22511 | 22598 | yDbMask lockMask; /* Subset of btreeMask that requires a lock */ |
| | @@ -22574,22 +22661,35 @@ |
| 22574 | 22661 | struct ValueList { |
| 22575 | 22662 | BtCursor *pCsr; /* An ephemeral table holding all values */ |
| 22576 | 22663 | sqlite3_value *pOut; /* Register to hold each decoded output value */ |
| 22577 | 22664 | }; |
| 22578 | 22665 | |
| 22666 | +/* Size of content associated with serial types that fit into a |
| 22667 | +** single-byte varint. |
| 22668 | +*/ |
| 22669 | +#ifndef SQLITE_AMALGAMATION |
| 22670 | +SQLITE_PRIVATE const u8 sqlite3SmallTypeSizes[]; |
| 22671 | +#endif |
| 22672 | + |
| 22579 | 22673 | /* |
| 22580 | 22674 | ** Function prototypes |
| 22581 | 22675 | */ |
| 22582 | 22676 | SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...); |
| 22583 | 22677 | SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*); |
| 22678 | +SQLITE_PRIVATE void sqlite3VdbeFreeCursorNN(Vdbe*,VdbeCursor*); |
| 22584 | 22679 | void sqliteVdbePopStack(Vdbe*,int); |
| 22585 | 22680 | SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeHandleMovedCursor(VdbeCursor *p); |
| 22586 | 22681 | SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeFinishMoveto(VdbeCursor*); |
| 22587 | 22682 | SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*); |
| 22588 | 22683 | SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32); |
| 22589 | 22684 | SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8); |
| 22590 | | -SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32); |
| 22685 | +#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT |
| 22686 | +SQLITE_PRIVATE u64 sqlite3FloatSwap(u64 in); |
| 22687 | +# define swapMixedEndianFloat(X) X = sqlite3FloatSwap(X) |
| 22688 | +#else |
| 22689 | +# define swapMixedEndianFloat(X) |
| 22690 | +#endif |
| 22591 | 22691 | SQLITE_PRIVATE void sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*); |
| 22592 | 22692 | SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int); |
| 22593 | 22693 | |
| 22594 | 22694 | int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *); |
| 22595 | 22695 | SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(sqlite3*,VdbeCursor*,UnpackedRecord*,int*); |
| | @@ -23046,12 +23146,11 @@ |
| 23046 | 23146 | struct Vdbe *pVdbe; /* Used to iterate through VMs */ |
| 23047 | 23147 | int nByte = 0; /* Used to accumulate return value */ |
| 23048 | 23148 | |
| 23049 | 23149 | db->pnBytesFreed = &nByte; |
| 23050 | 23150 | for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){ |
| 23051 | | - sqlite3VdbeClearObject(db, pVdbe); |
| 23052 | | - sqlite3DbFree(db, pVdbe); |
| 23151 | + sqlite3VdbeDelete(pVdbe); |
| 23053 | 23152 | } |
| 23054 | 23153 | db->pnBytesFreed = 0; |
| 23055 | 23154 | |
| 23056 | 23155 | *pHighwater = 0; /* IMP: R-64479-57858 */ |
| 23057 | 23156 | *pCurrent = nByte; |
| | @@ -29389,12 +29488,13 @@ |
| 29389 | 29488 | |
| 29390 | 29489 | /* |
| 29391 | 29490 | ** Free any prior content in *pz and replace it with a copy of zNew. |
| 29392 | 29491 | */ |
| 29393 | 29492 | SQLITE_PRIVATE void sqlite3SetString(char **pz, sqlite3 *db, const char *zNew){ |
| 29493 | + char *z = sqlite3DbStrDup(db, zNew); |
| 29394 | 29494 | sqlite3DbFree(db, *pz); |
| 29395 | | - *pz = sqlite3DbStrDup(db, zNew); |
| 29495 | + *pz = z; |
| 29396 | 29496 | } |
| 29397 | 29497 | |
| 29398 | 29498 | /* |
| 29399 | 29499 | ** Call this routine to record the fact that an OOM (out-of-memory) error |
| 29400 | 29500 | ** has happened. This routine will set db->mallocFailed, and also |
| | @@ -30886,37 +30986,41 @@ |
| 30886 | 30986 | |
| 30887 | 30987 | /* |
| 30888 | 30988 | ** Add a new subitem to the tree. The moreToFollow flag indicates that this |
| 30889 | 30989 | ** is not the last item in the tree. |
| 30890 | 30990 | */ |
| 30891 | | -static TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){ |
| 30991 | +static void sqlite3TreeViewPush(TreeView **pp, u8 moreToFollow){ |
| 30992 | + TreeView *p = *pp; |
| 30892 | 30993 | if( p==0 ){ |
| 30893 | | - p = sqlite3_malloc64( sizeof(*p) ); |
| 30894 | | - if( p==0 ) return 0; |
| 30994 | + *pp = p = sqlite3_malloc64( sizeof(*p) ); |
| 30995 | + if( p==0 ) return; |
| 30895 | 30996 | memset(p, 0, sizeof(*p)); |
| 30896 | 30997 | }else{ |
| 30897 | 30998 | p->iLevel++; |
| 30898 | 30999 | } |
| 30899 | 31000 | assert( moreToFollow==0 || moreToFollow==1 ); |
| 30900 | 31001 | if( p->iLevel<(int)sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow; |
| 30901 | | - return p; |
| 30902 | 31002 | } |
| 30903 | 31003 | |
| 30904 | 31004 | /* |
| 30905 | 31005 | ** Finished with one layer of the tree |
| 30906 | 31006 | */ |
| 30907 | | -static void sqlite3TreeViewPop(TreeView *p){ |
| 31007 | +static void sqlite3TreeViewPop(TreeView **pp){ |
| 31008 | + TreeView *p = *pp; |
| 30908 | 31009 | if( p==0 ) return; |
| 30909 | 31010 | p->iLevel--; |
| 30910 | | - if( p->iLevel<0 ) sqlite3_free(p); |
| 31011 | + if( p->iLevel<0 ){ |
| 31012 | + sqlite3_free(p); |
| 31013 | + *pp = 0; |
| 31014 | + } |
| 30911 | 31015 | } |
| 30912 | 31016 | |
| 30913 | 31017 | /* |
| 30914 | 31018 | ** Generate a single line of output for the tree, with a prefix that contains |
| 30915 | 31019 | ** all the appropriate tree lines |
| 30916 | 31020 | */ |
| 30917 | | -static void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){ |
| 31021 | +SQLITE_PRIVATE void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){ |
| 30918 | 31022 | va_list ap; |
| 30919 | 31023 | int i; |
| 30920 | 31024 | StrAccum acc; |
| 30921 | 31025 | char zBuf[500]; |
| 30922 | 31026 | sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); |
| | @@ -30940,11 +31044,11 @@ |
| 30940 | 31044 | |
| 30941 | 31045 | /* |
| 30942 | 31046 | ** Shorthand for starting a new tree item that consists of a single label |
| 30943 | 31047 | */ |
| 30944 | 31048 | static void sqlite3TreeViewItem(TreeView *p, const char *zLabel,u8 moreFollows){ |
| 30945 | | - p = sqlite3TreeViewPush(p, moreFollows); |
| 31049 | + sqlite3TreeViewPush(&p, moreFollows); |
| 30946 | 31050 | sqlite3TreeViewLine(p, "%s", zLabel); |
| 30947 | 31051 | } |
| 30948 | 31052 | |
| 30949 | 31053 | /* |
| 30950 | 31054 | ** Generate a human-readable description of a WITH clause. |
| | @@ -30957,11 +31061,11 @@ |
| 30957 | 31061 | sqlite3TreeViewLine(pView, "WITH (0x%p, pOuter=0x%p)",pWith,pWith->pOuter); |
| 30958 | 31062 | }else{ |
| 30959 | 31063 | sqlite3TreeViewLine(pView, "WITH (0x%p)", pWith); |
| 30960 | 31064 | } |
| 30961 | 31065 | if( pWith->nCte>0 ){ |
| 30962 | | - pView = sqlite3TreeViewPush(pView, 1); |
| 31066 | + sqlite3TreeViewPush(&pView, moreToFollow); |
| 30963 | 31067 | for(i=0; i<pWith->nCte; i++){ |
| 30964 | 31068 | StrAccum x; |
| 30965 | 31069 | char zLine[1000]; |
| 30966 | 31070 | const struct Cte *pCte = &pWith->a[i]; |
| 30967 | 31071 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| | @@ -30980,21 +31084,22 @@ |
| 30980 | 31084 | pCte->pUse->nUse); |
| 30981 | 31085 | } |
| 30982 | 31086 | sqlite3StrAccumFinish(&x); |
| 30983 | 31087 | sqlite3TreeViewItem(pView, zLine, i<pWith->nCte-1); |
| 30984 | 31088 | sqlite3TreeViewSelect(pView, pCte->pSelect, 0); |
| 30985 | | - sqlite3TreeViewPop(pView); |
| 31089 | + sqlite3TreeViewPop(&pView); |
| 30986 | 31090 | } |
| 30987 | | - sqlite3TreeViewPop(pView); |
| 31091 | + sqlite3TreeViewPop(&pView); |
| 30988 | 31092 | } |
| 30989 | 31093 | } |
| 30990 | 31094 | |
| 30991 | 31095 | /* |
| 30992 | 31096 | ** Generate a human-readable description of a SrcList object. |
| 30993 | 31097 | */ |
| 30994 | 31098 | SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ |
| 30995 | 31099 | int i; |
| 31100 | + if( pSrc==0 ) return; |
| 30996 | 31101 | for(i=0; i<pSrc->nSrc; i++){ |
| 30997 | 31102 | const SrcItem *pItem = &pSrc->a[i]; |
| 30998 | 31103 | StrAccum x; |
| 30999 | 31104 | char zLine[100]; |
| 31000 | 31105 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| | @@ -31002,14 +31107,21 @@ |
| 31002 | 31107 | sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem); |
| 31003 | 31108 | if( pItem->pTab ){ |
| 31004 | 31109 | sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx", |
| 31005 | 31110 | pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed); |
| 31006 | 31111 | } |
| 31007 | | - if( pItem->fg.jointype & JT_LEFT ){ |
| 31112 | + if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))==(JT_LEFT|JT_RIGHT) ){ |
| 31113 | + sqlite3_str_appendf(&x, " FULL-OUTER-JOIN"); |
| 31114 | + }else if( pItem->fg.jointype & JT_LEFT ){ |
| 31008 | 31115 | sqlite3_str_appendf(&x, " LEFT-JOIN"); |
| 31116 | + }else if( pItem->fg.jointype & JT_RIGHT ){ |
| 31117 | + sqlite3_str_appendf(&x, " RIGHT-JOIN"); |
| 31009 | 31118 | }else if( pItem->fg.jointype & JT_CROSS ){ |
| 31010 | 31119 | sqlite3_str_appendf(&x, " CROSS-JOIN"); |
| 31120 | + } |
| 31121 | + if( pItem->fg.jointype & JT_LTORJ ){ |
| 31122 | + sqlite3_str_appendf(&x, " LTORJ"); |
| 31011 | 31123 | } |
| 31012 | 31124 | if( pItem->fg.fromDDL ){ |
| 31013 | 31125 | sqlite3_str_appendf(&x, " DDL"); |
| 31014 | 31126 | } |
| 31015 | 31127 | if( pItem->fg.isCte ){ |
| | @@ -31016,16 +31128,17 @@ |
| 31016 | 31128 | sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse); |
| 31017 | 31129 | } |
| 31018 | 31130 | sqlite3StrAccumFinish(&x); |
| 31019 | 31131 | sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1); |
| 31020 | 31132 | if( pItem->pSelect ){ |
| 31133 | + assert( pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) ); |
| 31021 | 31134 | sqlite3TreeViewSelect(pView, pItem->pSelect, 0); |
| 31022 | 31135 | } |
| 31023 | 31136 | if( pItem->fg.isTabFunc ){ |
| 31024 | 31137 | sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:"); |
| 31025 | 31138 | } |
| 31026 | | - sqlite3TreeViewPop(pView); |
| 31139 | + sqlite3TreeViewPop(&pView); |
| 31027 | 31140 | } |
| 31028 | 31141 | } |
| 31029 | 31142 | |
| 31030 | 31143 | /* |
| 31031 | 31144 | ** Generate a human-readable description of a Select object. |
| | @@ -31035,15 +31148,15 @@ |
| 31035 | 31148 | int cnt = 0; |
| 31036 | 31149 | if( p==0 ){ |
| 31037 | 31150 | sqlite3TreeViewLine(pView, "nil-SELECT"); |
| 31038 | 31151 | return; |
| 31039 | 31152 | } |
| 31040 | | - pView = sqlite3TreeViewPush(pView, moreToFollow); |
| 31153 | + sqlite3TreeViewPush(&pView, moreToFollow); |
| 31041 | 31154 | if( p->pWith ){ |
| 31042 | 31155 | sqlite3TreeViewWith(pView, p->pWith, 1); |
| 31043 | 31156 | cnt = 1; |
| 31044 | | - sqlite3TreeViewPush(pView, 1); |
| 31157 | + sqlite3TreeViewPush(&pView, 1); |
| 31045 | 31158 | } |
| 31046 | 31159 | do{ |
| 31047 | 31160 | if( p->selFlags & SF_WhereBegin ){ |
| 31048 | 31161 | sqlite3TreeViewLine(pView, "sqlite3WhereBegin()"); |
| 31049 | 31162 | }else{ |
| | @@ -31053,11 +31166,11 @@ |
| 31053 | 31166 | ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""), |
| 31054 | 31167 | p->selId, p, p->selFlags, |
| 31055 | 31168 | (int)p->nSelectRow |
| 31056 | 31169 | ); |
| 31057 | 31170 | } |
| 31058 | | - if( cnt++ ) sqlite3TreeViewPop(pView); |
| 31171 | + if( cnt++ ) sqlite3TreeViewPop(&pView); |
| 31059 | 31172 | if( p->pPrior ){ |
| 31060 | 31173 | n = 1000; |
| 31061 | 31174 | }else{ |
| 31062 | 31175 | n = 0; |
| 31063 | 31176 | if( p->pSrc && p->pSrc->nSrc ) n++; |
| | @@ -31076,45 +31189,45 @@ |
| 31076 | 31189 | } |
| 31077 | 31190 | n--; |
| 31078 | 31191 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 31079 | 31192 | if( p->pWin ){ |
| 31080 | 31193 | Window *pX; |
| 31081 | | - pView = sqlite3TreeViewPush(pView, (n--)>0); |
| 31194 | + sqlite3TreeViewPush(&pView, (n--)>0); |
| 31082 | 31195 | sqlite3TreeViewLine(pView, "window-functions"); |
| 31083 | 31196 | for(pX=p->pWin; pX; pX=pX->pNextWin){ |
| 31084 | 31197 | sqlite3TreeViewWinFunc(pView, pX, pX->pNextWin!=0); |
| 31085 | 31198 | } |
| 31086 | | - sqlite3TreeViewPop(pView); |
| 31199 | + sqlite3TreeViewPop(&pView); |
| 31087 | 31200 | } |
| 31088 | 31201 | #endif |
| 31089 | 31202 | if( p->pSrc && p->pSrc->nSrc ){ |
| 31090 | | - pView = sqlite3TreeViewPush(pView, (n--)>0); |
| 31203 | + sqlite3TreeViewPush(&pView, (n--)>0); |
| 31091 | 31204 | sqlite3TreeViewLine(pView, "FROM"); |
| 31092 | 31205 | sqlite3TreeViewSrcList(pView, p->pSrc); |
| 31093 | | - sqlite3TreeViewPop(pView); |
| 31206 | + sqlite3TreeViewPop(&pView); |
| 31094 | 31207 | } |
| 31095 | 31208 | if( p->pWhere ){ |
| 31096 | 31209 | sqlite3TreeViewItem(pView, "WHERE", (n--)>0); |
| 31097 | 31210 | sqlite3TreeViewExpr(pView, p->pWhere, 0); |
| 31098 | | - sqlite3TreeViewPop(pView); |
| 31211 | + sqlite3TreeViewPop(&pView); |
| 31099 | 31212 | } |
| 31100 | 31213 | if( p->pGroupBy ){ |
| 31101 | 31214 | sqlite3TreeViewExprList(pView, p->pGroupBy, (n--)>0, "GROUPBY"); |
| 31102 | 31215 | } |
| 31103 | 31216 | if( p->pHaving ){ |
| 31104 | 31217 | sqlite3TreeViewItem(pView, "HAVING", (n--)>0); |
| 31105 | 31218 | sqlite3TreeViewExpr(pView, p->pHaving, 0); |
| 31106 | | - sqlite3TreeViewPop(pView); |
| 31219 | + sqlite3TreeViewPop(&pView); |
| 31107 | 31220 | } |
| 31108 | 31221 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 31109 | 31222 | if( p->pWinDefn ){ |
| 31110 | 31223 | Window *pX; |
| 31111 | 31224 | sqlite3TreeViewItem(pView, "WINDOW", (n--)>0); |
| 31112 | 31225 | for(pX=p->pWinDefn; pX; pX=pX->pNextWin){ |
| 31113 | 31226 | sqlite3TreeViewWindow(pView, pX, pX->pNextWin!=0); |
| 31114 | 31227 | } |
| 31115 | | - sqlite3TreeViewPop(pView); |
| 31228 | + sqlite3TreeViewPop(&pView); |
| 31116 | 31229 | } |
| 31117 | 31230 | #endif |
| 31118 | 31231 | if( p->pOrderBy ){ |
| 31119 | 31232 | sqlite3TreeViewExprList(pView, p->pOrderBy, (n--)>0, "ORDERBY"); |
| 31120 | 31233 | } |
| | @@ -31122,13 +31235,13 @@ |
| 31122 | 31235 | sqlite3TreeViewItem(pView, "LIMIT", (n--)>0); |
| 31123 | 31236 | sqlite3TreeViewExpr(pView, p->pLimit->pLeft, p->pLimit->pRight!=0); |
| 31124 | 31237 | if( p->pLimit->pRight ){ |
| 31125 | 31238 | sqlite3TreeViewItem(pView, "OFFSET", (n--)>0); |
| 31126 | 31239 | sqlite3TreeViewExpr(pView, p->pLimit->pRight, 0); |
| 31127 | | - sqlite3TreeViewPop(pView); |
| 31240 | + sqlite3TreeViewPop(&pView); |
| 31128 | 31241 | } |
| 31129 | | - sqlite3TreeViewPop(pView); |
| 31242 | + sqlite3TreeViewPop(&pView); |
| 31130 | 31243 | } |
| 31131 | 31244 | if( p->pPrior ){ |
| 31132 | 31245 | const char *zOp = "UNION"; |
| 31133 | 31246 | switch( p->op ){ |
| 31134 | 31247 | case TK_ALL: zOp = "UNION ALL"; break; |
| | @@ -31137,11 +31250,11 @@ |
| 31137 | 31250 | } |
| 31138 | 31251 | sqlite3TreeViewItem(pView, zOp, 1); |
| 31139 | 31252 | } |
| 31140 | 31253 | p = p->pPrior; |
| 31141 | 31254 | }while( p!=0 ); |
| 31142 | | - sqlite3TreeViewPop(pView); |
| 31255 | + sqlite3TreeViewPop(&pView); |
| 31143 | 31256 | } |
| 31144 | 31257 | |
| 31145 | 31258 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 31146 | 31259 | /* |
| 31147 | 31260 | ** Generate a description of starting or stopping bounds |
| | @@ -31153,28 +31266,28 @@ |
| 31153 | 31266 | u8 moreToFollow /* True if more to follow */ |
| 31154 | 31267 | ){ |
| 31155 | 31268 | switch( eBound ){ |
| 31156 | 31269 | case TK_UNBOUNDED: { |
| 31157 | 31270 | sqlite3TreeViewItem(pView, "UNBOUNDED", moreToFollow); |
| 31158 | | - sqlite3TreeViewPop(pView); |
| 31271 | + sqlite3TreeViewPop(&pView); |
| 31159 | 31272 | break; |
| 31160 | 31273 | } |
| 31161 | 31274 | case TK_CURRENT: { |
| 31162 | 31275 | sqlite3TreeViewItem(pView, "CURRENT", moreToFollow); |
| 31163 | | - sqlite3TreeViewPop(pView); |
| 31276 | + sqlite3TreeViewPop(&pView); |
| 31164 | 31277 | break; |
| 31165 | 31278 | } |
| 31166 | 31279 | case TK_PRECEDING: { |
| 31167 | 31280 | sqlite3TreeViewItem(pView, "PRECEDING", moreToFollow); |
| 31168 | 31281 | sqlite3TreeViewExpr(pView, pExpr, 0); |
| 31169 | | - sqlite3TreeViewPop(pView); |
| 31282 | + sqlite3TreeViewPop(&pView); |
| 31170 | 31283 | break; |
| 31171 | 31284 | } |
| 31172 | 31285 | case TK_FOLLOWING: { |
| 31173 | 31286 | sqlite3TreeViewItem(pView, "FOLLOWING", moreToFollow); |
| 31174 | 31287 | sqlite3TreeViewExpr(pView, pExpr, 0); |
| 31175 | | - sqlite3TreeViewPop(pView); |
| 31288 | + sqlite3TreeViewPop(&pView); |
| 31176 | 31289 | break; |
| 31177 | 31290 | } |
| 31178 | 31291 | } |
| 31179 | 31292 | } |
| 31180 | 31293 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| | @@ -31186,13 +31299,13 @@ |
| 31186 | 31299 | SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u8 more){ |
| 31187 | 31300 | int nElement = 0; |
| 31188 | 31301 | if( pWin->pFilter ){ |
| 31189 | 31302 | sqlite3TreeViewItem(pView, "FILTER", 1); |
| 31190 | 31303 | sqlite3TreeViewExpr(pView, pWin->pFilter, 0); |
| 31191 | | - sqlite3TreeViewPop(pView); |
| 31304 | + sqlite3TreeViewPop(&pView); |
| 31192 | 31305 | } |
| 31193 | | - pView = sqlite3TreeViewPush(pView, more); |
| 31306 | + sqlite3TreeViewPush(&pView, more); |
| 31194 | 31307 | if( pWin->zName ){ |
| 31195 | 31308 | sqlite3TreeViewLine(pView, "OVER %s (%p)", pWin->zName, pWin); |
| 31196 | 31309 | }else{ |
| 31197 | 31310 | sqlite3TreeViewLine(pView, "OVER (%p)", pWin); |
| 31198 | 31311 | } |
| | @@ -31199,13 +31312,13 @@ |
| 31199 | 31312 | if( pWin->zBase ) nElement++; |
| 31200 | 31313 | if( pWin->pOrderBy ) nElement++; |
| 31201 | 31314 | if( pWin->eFrmType ) nElement++; |
| 31202 | 31315 | if( pWin->eExclude ) nElement++; |
| 31203 | 31316 | if( pWin->zBase ){ |
| 31204 | | - sqlite3TreeViewPush(pView, (--nElement)>0); |
| 31317 | + sqlite3TreeViewPush(&pView, (--nElement)>0); |
| 31205 | 31318 | sqlite3TreeViewLine(pView, "window: %s", pWin->zBase); |
| 31206 | | - sqlite3TreeViewPop(pView); |
| 31319 | + sqlite3TreeViewPop(&pView); |
| 31207 | 31320 | } |
| 31208 | 31321 | if( pWin->pPartition ){ |
| 31209 | 31322 | sqlite3TreeViewExprList(pView, pWin->pPartition, nElement>0,"PARTITION-BY"); |
| 31210 | 31323 | } |
| 31211 | 31324 | if( pWin->pOrderBy ){ |
| | @@ -31219,11 +31332,11 @@ |
| 31219 | 31332 | sqlite3_snprintf(sizeof(zBuf),zBuf,"%s%s",zFrmType, |
| 31220 | 31333 | pWin->bImplicitFrame ? " (implied)" : ""); |
| 31221 | 31334 | sqlite3TreeViewItem(pView, zBuf, (--nElement)>0); |
| 31222 | 31335 | sqlite3TreeViewBound(pView, pWin->eStart, pWin->pStart, 1); |
| 31223 | 31336 | sqlite3TreeViewBound(pView, pWin->eEnd, pWin->pEnd, 0); |
| 31224 | | - sqlite3TreeViewPop(pView); |
| 31337 | + sqlite3TreeViewPop(&pView); |
| 31225 | 31338 | } |
| 31226 | 31339 | if( pWin->eExclude ){ |
| 31227 | 31340 | char zBuf[30]; |
| 31228 | 31341 | const char *zExclude; |
| 31229 | 31342 | switch( pWin->eExclude ){ |
| | @@ -31234,28 +31347,28 @@ |
| 31234 | 31347 | default: |
| 31235 | 31348 | sqlite3_snprintf(sizeof(zBuf),zBuf,"invalid(%d)", pWin->eExclude); |
| 31236 | 31349 | zExclude = zBuf; |
| 31237 | 31350 | break; |
| 31238 | 31351 | } |
| 31239 | | - sqlite3TreeViewPush(pView, 0); |
| 31352 | + sqlite3TreeViewPush(&pView, 0); |
| 31240 | 31353 | sqlite3TreeViewLine(pView, "EXCLUDE %s", zExclude); |
| 31241 | | - sqlite3TreeViewPop(pView); |
| 31354 | + sqlite3TreeViewPop(&pView); |
| 31242 | 31355 | } |
| 31243 | | - sqlite3TreeViewPop(pView); |
| 31356 | + sqlite3TreeViewPop(&pView); |
| 31244 | 31357 | } |
| 31245 | 31358 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 31246 | 31359 | |
| 31247 | 31360 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 31248 | 31361 | /* |
| 31249 | 31362 | ** Generate a human-readable explanation for a Window Function object |
| 31250 | 31363 | */ |
| 31251 | 31364 | SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView *pView, const Window *pWin, u8 more){ |
| 31252 | | - pView = sqlite3TreeViewPush(pView, more); |
| 31365 | + sqlite3TreeViewPush(&pView, more); |
| 31253 | 31366 | sqlite3TreeViewLine(pView, "WINFUNC %s(%d)", |
| 31254 | 31367 | pWin->pWFunc->zName, pWin->pWFunc->nArg); |
| 31255 | 31368 | sqlite3TreeViewWindow(pView, pWin, 0); |
| 31256 | | - sqlite3TreeViewPop(pView); |
| 31369 | + sqlite3TreeViewPop(&pView); |
| 31257 | 31370 | } |
| 31258 | 31371 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 31259 | 31372 | |
| 31260 | 31373 | /* |
| 31261 | 31374 | ** Generate a human-readable explanation of an expression tree. |
| | @@ -31262,23 +31375,23 @@ |
| 31262 | 31375 | */ |
| 31263 | 31376 | SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){ |
| 31264 | 31377 | const char *zBinOp = 0; /* Binary operator */ |
| 31265 | 31378 | const char *zUniOp = 0; /* Unary operator */ |
| 31266 | 31379 | char zFlgs[200]; |
| 31267 | | - pView = sqlite3TreeViewPush(pView, moreToFollow); |
| 31380 | + sqlite3TreeViewPush(&pView, moreToFollow); |
| 31268 | 31381 | if( pExpr==0 ){ |
| 31269 | 31382 | sqlite3TreeViewLine(pView, "nil"); |
| 31270 | | - sqlite3TreeViewPop(pView); |
| 31383 | + sqlite3TreeViewPop(&pView); |
| 31271 | 31384 | return; |
| 31272 | 31385 | } |
| 31273 | 31386 | if( pExpr->flags || pExpr->affExpr || pExpr->vvaFlags ){ |
| 31274 | 31387 | StrAccum x; |
| 31275 | 31388 | sqlite3StrAccumInit(&x, 0, zFlgs, sizeof(zFlgs), 0); |
| 31276 | 31389 | sqlite3_str_appendf(&x, " fg.af=%x.%c", |
| 31277 | 31390 | pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n'); |
| 31278 | 31391 | if( ExprHasProperty(pExpr, EP_FromJoin) ){ |
| 31279 | | - sqlite3_str_appendf(&x, " iRJT=%d", pExpr->w.iRightJoinTable); |
| 31392 | + sqlite3_str_appendf(&x, " iJoin=%d", pExpr->w.iJoin); |
| 31280 | 31393 | } |
| 31281 | 31394 | if( ExprHasProperty(pExpr, EP_FromDDL) ){ |
| 31282 | 31395 | sqlite3_str_appendf(&x, " DDL"); |
| 31283 | 31396 | } |
| 31284 | 31397 | if( ExprHasVVAProperty(pExpr, EP_Immutable) ){ |
| | @@ -31622,11 +31735,11 @@ |
| 31622 | 31735 | sqlite3TreeViewExpr(pView, pExpr->pRight, 0); |
| 31623 | 31736 | }else if( zUniOp ){ |
| 31624 | 31737 | sqlite3TreeViewLine(pView, "%s%s", zUniOp, zFlgs); |
| 31625 | 31738 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 31626 | 31739 | } |
| 31627 | | - sqlite3TreeViewPop(pView); |
| 31740 | + sqlite3TreeViewPop(&pView); |
| 31628 | 31741 | } |
| 31629 | 31742 | |
| 31630 | 31743 | |
| 31631 | 31744 | /* |
| 31632 | 31745 | ** Generate a human-readable explanation of an expression list. |
| | @@ -31644,27 +31757,37 @@ |
| 31644 | 31757 | sqlite3TreeViewLine(pView, "%s", zLabel); |
| 31645 | 31758 | for(i=0; i<pList->nExpr; i++){ |
| 31646 | 31759 | int j = pList->a[i].u.x.iOrderByCol; |
| 31647 | 31760 | char *zName = pList->a[i].zEName; |
| 31648 | 31761 | int moreToFollow = i<pList->nExpr - 1; |
| 31649 | | - if( pList->a[i].eEName!=ENAME_NAME ) zName = 0; |
| 31650 | 31762 | if( j || zName ){ |
| 31651 | | - sqlite3TreeViewPush(pView, moreToFollow); |
| 31763 | + sqlite3TreeViewPush(&pView, moreToFollow); |
| 31652 | 31764 | moreToFollow = 0; |
| 31653 | 31765 | sqlite3TreeViewLine(pView, 0); |
| 31654 | 31766 | if( zName ){ |
| 31655 | | - fprintf(stdout, "AS %s ", zName); |
| 31767 | + switch( pList->a[i].eEName ){ |
| 31768 | + default: |
| 31769 | + fprintf(stdout, "AS %s ", zName); |
| 31770 | + break; |
| 31771 | + case ENAME_TAB: |
| 31772 | + fprintf(stdout, "TABLE-ALIAS-NAME(\"%s\") ", zName); |
| 31773 | + if( pList->a[i].bUsed==0 ) fprintf(stdout, "(unused) "); |
| 31774 | + break; |
| 31775 | + case ENAME_SPAN: |
| 31776 | + fprintf(stdout, "SPAN(\"%s\") ", zName); |
| 31777 | + break; |
| 31778 | + } |
| 31656 | 31779 | } |
| 31657 | 31780 | if( j ){ |
| 31658 | 31781 | fprintf(stdout, "iOrderByCol=%d", j); |
| 31659 | 31782 | } |
| 31660 | 31783 | fprintf(stdout, "\n"); |
| 31661 | 31784 | fflush(stdout); |
| 31662 | 31785 | } |
| 31663 | 31786 | sqlite3TreeViewExpr(pView, pList->a[i].pExpr, moreToFollow); |
| 31664 | 31787 | if( j || zName ){ |
| 31665 | | - sqlite3TreeViewPop(pView); |
| 31788 | + sqlite3TreeViewPop(&pView); |
| 31666 | 31789 | } |
| 31667 | 31790 | } |
| 31668 | 31791 | } |
| 31669 | 31792 | } |
| 31670 | 31793 | SQLITE_PRIVATE void sqlite3TreeViewExprList( |
| | @@ -31671,15 +31794,376 @@ |
| 31671 | 31794 | TreeView *pView, |
| 31672 | 31795 | const ExprList *pList, |
| 31673 | 31796 | u8 moreToFollow, |
| 31674 | 31797 | const char *zLabel |
| 31675 | 31798 | ){ |
| 31676 | | - pView = sqlite3TreeViewPush(pView, moreToFollow); |
| 31799 | + sqlite3TreeViewPush(&pView, moreToFollow); |
| 31677 | 31800 | sqlite3TreeViewBareExprList(pView, pList, zLabel); |
| 31678 | | - sqlite3TreeViewPop(pView); |
| 31801 | + sqlite3TreeViewPop(&pView); |
| 31679 | 31802 | } |
| 31680 | 31803 | |
| 31804 | +/* |
| 31805 | +** Generate a human-readable explanation of an id-list. |
| 31806 | +*/ |
| 31807 | +SQLITE_PRIVATE void sqlite3TreeViewBareIdList( |
| 31808 | + TreeView *pView, |
| 31809 | + const IdList *pList, |
| 31810 | + const char *zLabel |
| 31811 | +){ |
| 31812 | + if( zLabel==0 || zLabel[0]==0 ) zLabel = "LIST"; |
| 31813 | + if( pList==0 ){ |
| 31814 | + sqlite3TreeViewLine(pView, "%s (empty)", zLabel); |
| 31815 | + }else{ |
| 31816 | + int i; |
| 31817 | + sqlite3TreeViewLine(pView, "%s", zLabel); |
| 31818 | + for(i=0; i<pList->nId; i++){ |
| 31819 | + char *zName = pList->a[i].zName; |
| 31820 | + int moreToFollow = i<pList->nId - 1; |
| 31821 | + if( zName==0 ) zName = "(null)"; |
| 31822 | + sqlite3TreeViewPush(&pView, moreToFollow); |
| 31823 | + sqlite3TreeViewLine(pView, 0); |
| 31824 | + if( pList->eU4==EU4_NONE ){ |
| 31825 | + fprintf(stdout, "%s\n", zName); |
| 31826 | + }else if( pList->eU4==EU4_IDX ){ |
| 31827 | + fprintf(stdout, "%s (%d)\n", zName, pList->a[i].u4.idx); |
| 31828 | + }else{ |
| 31829 | + assert( pList->eU4==EU4_EXPR ); |
| 31830 | + if( pList->a[i].u4.pExpr==0 ){ |
| 31831 | + fprintf(stdout, "%s (pExpr=NULL)\n", zName); |
| 31832 | + }else{ |
| 31833 | + fprintf(stdout, "%s\n", zName); |
| 31834 | + sqlite3TreeViewPush(&pView, i<pList->nId-1); |
| 31835 | + sqlite3TreeViewExpr(pView, pList->a[i].u4.pExpr, 0); |
| 31836 | + sqlite3TreeViewPop(&pView); |
| 31837 | + } |
| 31838 | + } |
| 31839 | + sqlite3TreeViewPop(&pView); |
| 31840 | + } |
| 31841 | + } |
| 31842 | +} |
| 31843 | +SQLITE_PRIVATE void sqlite3TreeViewIdList( |
| 31844 | + TreeView *pView, |
| 31845 | + const IdList *pList, |
| 31846 | + u8 moreToFollow, |
| 31847 | + const char *zLabel |
| 31848 | +){ |
| 31849 | + sqlite3TreeViewPush(&pView, moreToFollow); |
| 31850 | + sqlite3TreeViewBareIdList(pView, pList, zLabel); |
| 31851 | + sqlite3TreeViewPop(&pView); |
| 31852 | +} |
| 31853 | + |
| 31854 | +/* |
| 31855 | +** Generate a human-readable explanation of a list of Upsert objects |
| 31856 | +*/ |
| 31857 | +SQLITE_PRIVATE void sqlite3TreeViewUpsert( |
| 31858 | + TreeView *pView, |
| 31859 | + const Upsert *pUpsert, |
| 31860 | + u8 moreToFollow |
| 31861 | +){ |
| 31862 | + if( pUpsert==0 ) return; |
| 31863 | + sqlite3TreeViewPush(&pView, moreToFollow); |
| 31864 | + while( pUpsert ){ |
| 31865 | + int n; |
| 31866 | + sqlite3TreeViewPush(&pView, pUpsert->pNextUpsert!=0 || moreToFollow); |
| 31867 | + sqlite3TreeViewLine(pView, "ON CONFLICT DO %s", |
| 31868 | + pUpsert->isDoUpdate ? "UPDATE" : "NOTHING"); |
| 31869 | + n = (pUpsert->pUpsertSet!=0) + (pUpsert->pUpsertWhere!=0); |
| 31870 | + sqlite3TreeViewExprList(pView, pUpsert->pUpsertTarget, (n--)>0, "TARGET"); |
| 31871 | + sqlite3TreeViewExprList(pView, pUpsert->pUpsertSet, (n--)>0, "SET"); |
| 31872 | + if( pUpsert->pUpsertWhere ){ |
| 31873 | + sqlite3TreeViewItem(pView, "WHERE", (n--)>0); |
| 31874 | + sqlite3TreeViewExpr(pView, pUpsert->pUpsertWhere, 0); |
| 31875 | + sqlite3TreeViewPop(&pView); |
| 31876 | + } |
| 31877 | + sqlite3TreeViewPop(&pView); |
| 31878 | + pUpsert = pUpsert->pNextUpsert; |
| 31879 | + } |
| 31880 | + sqlite3TreeViewPop(&pView); |
| 31881 | +} |
| 31882 | + |
| 31883 | +/* |
| 31884 | +** Generate a human-readable diagram of the data structure that go |
| 31885 | +** into generating an DELETE statement. |
| 31886 | +*/ |
| 31887 | +SQLITE_PRIVATE void sqlite3TreeViewDelete( |
| 31888 | + const With *pWith, |
| 31889 | + const SrcList *pTabList, |
| 31890 | + const Expr *pWhere, |
| 31891 | + const ExprList *pOrderBy, |
| 31892 | + const Expr *pLimit, |
| 31893 | + const Trigger *pTrigger |
| 31894 | +){ |
| 31895 | + int n = 0; |
| 31896 | + TreeView *pView = 0; |
| 31897 | + sqlite3TreeViewPush(&pView, 0); |
| 31898 | + sqlite3TreeViewLine(pView, "DELETE"); |
| 31899 | + if( pWith ) n++; |
| 31900 | + if( pTabList ) n++; |
| 31901 | + if( pWhere ) n++; |
| 31902 | + if( pOrderBy ) n++; |
| 31903 | + if( pLimit ) n++; |
| 31904 | + if( pTrigger ) n++; |
| 31905 | + if( pWith ){ |
| 31906 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 31907 | + sqlite3TreeViewWith(pView, pWith, 0); |
| 31908 | + sqlite3TreeViewPop(&pView); |
| 31909 | + } |
| 31910 | + if( pTabList ){ |
| 31911 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 31912 | + sqlite3TreeViewLine(pView, "FROM"); |
| 31913 | + sqlite3TreeViewSrcList(pView, pTabList); |
| 31914 | + sqlite3TreeViewPop(&pView); |
| 31915 | + } |
| 31916 | + if( pWhere ){ |
| 31917 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 31918 | + sqlite3TreeViewLine(pView, "WHERE"); |
| 31919 | + sqlite3TreeViewExpr(pView, pWhere, 0); |
| 31920 | + sqlite3TreeViewPop(&pView); |
| 31921 | + } |
| 31922 | + if( pOrderBy ){ |
| 31923 | + sqlite3TreeViewExprList(pView, pOrderBy, (--n)>0, "ORDER-BY"); |
| 31924 | + } |
| 31925 | + if( pLimit ){ |
| 31926 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 31927 | + sqlite3TreeViewLine(pView, "LIMIT"); |
| 31928 | + sqlite3TreeViewExpr(pView, pLimit, 0); |
| 31929 | + sqlite3TreeViewPop(&pView); |
| 31930 | + } |
| 31931 | + if( pTrigger ){ |
| 31932 | + sqlite3TreeViewTrigger(pView, pTrigger, (--n)>0, 1); |
| 31933 | + } |
| 31934 | + sqlite3TreeViewPop(&pView); |
| 31935 | +} |
| 31936 | + |
| 31937 | +/* |
| 31938 | +** Generate a human-readable diagram of the data structure that go |
| 31939 | +** into generating an INSERT statement. |
| 31940 | +*/ |
| 31941 | +SQLITE_PRIVATE void sqlite3TreeViewInsert( |
| 31942 | + const With *pWith, |
| 31943 | + const SrcList *pTabList, |
| 31944 | + const IdList *pColumnList, |
| 31945 | + const Select *pSelect, |
| 31946 | + const ExprList *pExprList, |
| 31947 | + int onError, |
| 31948 | + const Upsert *pUpsert, |
| 31949 | + const Trigger *pTrigger |
| 31950 | +){ |
| 31951 | + TreeView *pView = 0; |
| 31952 | + int n = 0; |
| 31953 | + const char *zLabel = "INSERT"; |
| 31954 | + switch( onError ){ |
| 31955 | + case OE_Replace: zLabel = "REPLACE"; break; |
| 31956 | + case OE_Ignore: zLabel = "INSERT OR IGNORE"; break; |
| 31957 | + case OE_Rollback: zLabel = "INSERT OR ROLLBACK"; break; |
| 31958 | + case OE_Abort: zLabel = "INSERT OR ABORT"; break; |
| 31959 | + case OE_Fail: zLabel = "INSERT OR FAIL"; break; |
| 31960 | + } |
| 31961 | + sqlite3TreeViewPush(&pView, 0); |
| 31962 | + sqlite3TreeViewLine(pView, zLabel); |
| 31963 | + if( pWith ) n++; |
| 31964 | + if( pTabList ) n++; |
| 31965 | + if( pColumnList ) n++; |
| 31966 | + if( pSelect ) n++; |
| 31967 | + if( pExprList ) n++; |
| 31968 | + if( pUpsert ) n++; |
| 31969 | + if( pTrigger ) n++; |
| 31970 | + if( pWith ){ |
| 31971 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 31972 | + sqlite3TreeViewWith(pView, pWith, 0); |
| 31973 | + sqlite3TreeViewPop(&pView); |
| 31974 | + } |
| 31975 | + if( pTabList ){ |
| 31976 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 31977 | + sqlite3TreeViewLine(pView, "INTO"); |
| 31978 | + sqlite3TreeViewSrcList(pView, pTabList); |
| 31979 | + sqlite3TreeViewPop(&pView); |
| 31980 | + } |
| 31981 | + if( pColumnList ){ |
| 31982 | + sqlite3TreeViewIdList(pView, pColumnList, (--n)>0, "COLUMNS"); |
| 31983 | + } |
| 31984 | + if( pSelect ){ |
| 31985 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 31986 | + sqlite3TreeViewLine(pView, "DATA-SOURCE"); |
| 31987 | + sqlite3TreeViewSelect(pView, pSelect, 0); |
| 31988 | + sqlite3TreeViewPop(&pView); |
| 31989 | + } |
| 31990 | + if( pExprList ){ |
| 31991 | + sqlite3TreeViewExprList(pView, pExprList, (--n)>0, "VALUES"); |
| 31992 | + } |
| 31993 | + if( pUpsert ){ |
| 31994 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 31995 | + sqlite3TreeViewLine(pView, "UPSERT"); |
| 31996 | + sqlite3TreeViewUpsert(pView, pUpsert, 0); |
| 31997 | + sqlite3TreeViewPop(&pView); |
| 31998 | + } |
| 31999 | + if( pTrigger ){ |
| 32000 | + sqlite3TreeViewTrigger(pView, pTrigger, (--n)>0, 1); |
| 32001 | + } |
| 32002 | + sqlite3TreeViewPop(&pView); |
| 32003 | +} |
| 32004 | + |
| 32005 | +/* |
| 32006 | +** Generate a human-readable diagram of the data structure that go |
| 32007 | +** into generating an UPDATE statement. |
| 32008 | +*/ |
| 32009 | +SQLITE_PRIVATE void sqlite3TreeViewUpdate( |
| 32010 | + const With *pWith, |
| 32011 | + const SrcList *pTabList, |
| 32012 | + const ExprList *pChanges, |
| 32013 | + const Expr *pWhere, |
| 32014 | + int onError, |
| 32015 | + const ExprList *pOrderBy, |
| 32016 | + const Expr *pLimit, |
| 32017 | + const Upsert *pUpsert, |
| 32018 | + const Trigger *pTrigger |
| 32019 | +){ |
| 32020 | + int n = 0; |
| 32021 | + TreeView *pView = 0; |
| 32022 | + const char *zLabel = "UPDATE"; |
| 32023 | + switch( onError ){ |
| 32024 | + case OE_Replace: zLabel = "UPDATE OR REPLACE"; break; |
| 32025 | + case OE_Ignore: zLabel = "UPDATE OR IGNORE"; break; |
| 32026 | + case OE_Rollback: zLabel = "UPDATE OR ROLLBACK"; break; |
| 32027 | + case OE_Abort: zLabel = "UPDATE OR ABORT"; break; |
| 32028 | + case OE_Fail: zLabel = "UPDATE OR FAIL"; break; |
| 32029 | + } |
| 32030 | + sqlite3TreeViewPush(&pView, 0); |
| 32031 | + sqlite3TreeViewLine(pView, zLabel); |
| 32032 | + if( pWith ) n++; |
| 32033 | + if( pTabList ) n++; |
| 32034 | + if( pChanges ) n++; |
| 32035 | + if( pWhere ) n++; |
| 32036 | + if( pOrderBy ) n++; |
| 32037 | + if( pLimit ) n++; |
| 32038 | + if( pUpsert ) n++; |
| 32039 | + if( pTrigger ) n++; |
| 32040 | + if( pWith ){ |
| 32041 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 32042 | + sqlite3TreeViewWith(pView, pWith, 0); |
| 32043 | + sqlite3TreeViewPop(&pView); |
| 32044 | + } |
| 32045 | + if( pTabList ){ |
| 32046 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 32047 | + sqlite3TreeViewLine(pView, "FROM"); |
| 32048 | + sqlite3TreeViewSrcList(pView, pTabList); |
| 32049 | + sqlite3TreeViewPop(&pView); |
| 32050 | + } |
| 32051 | + if( pChanges ){ |
| 32052 | + sqlite3TreeViewExprList(pView, pChanges, (--n)>0, "SET"); |
| 32053 | + } |
| 32054 | + if( pWhere ){ |
| 32055 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 32056 | + sqlite3TreeViewLine(pView, "WHERE"); |
| 32057 | + sqlite3TreeViewExpr(pView, pWhere, 0); |
| 32058 | + sqlite3TreeViewPop(&pView); |
| 32059 | + } |
| 32060 | + if( pOrderBy ){ |
| 32061 | + sqlite3TreeViewExprList(pView, pOrderBy, (--n)>0, "ORDER-BY"); |
| 32062 | + } |
| 32063 | + if( pLimit ){ |
| 32064 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 32065 | + sqlite3TreeViewLine(pView, "LIMIT"); |
| 32066 | + sqlite3TreeViewExpr(pView, pLimit, 0); |
| 32067 | + sqlite3TreeViewPop(&pView); |
| 32068 | + } |
| 32069 | + if( pUpsert ){ |
| 32070 | + sqlite3TreeViewPush(&pView, (--n)>0); |
| 32071 | + sqlite3TreeViewLine(pView, "UPSERT"); |
| 32072 | + sqlite3TreeViewUpsert(pView, pUpsert, 0); |
| 32073 | + sqlite3TreeViewPop(&pView); |
| 32074 | + } |
| 32075 | + if( pTrigger ){ |
| 32076 | + sqlite3TreeViewTrigger(pView, pTrigger, (--n)>0, 1); |
| 32077 | + } |
| 32078 | + sqlite3TreeViewPop(&pView); |
| 32079 | +} |
| 32080 | + |
| 32081 | +#ifndef SQLITE_OMIT_TRIGGER |
| 32082 | +/* |
| 32083 | +** Show a human-readable graph of a TriggerStep |
| 32084 | +*/ |
| 32085 | +SQLITE_PRIVATE void sqlite3TreeViewTriggerStep( |
| 32086 | + TreeView *pView, |
| 32087 | + const TriggerStep *pStep, |
| 32088 | + u8 moreToFollow, |
| 32089 | + u8 showFullList |
| 32090 | +){ |
| 32091 | + int cnt = 0; |
| 32092 | + if( pStep==0 ) return; |
| 32093 | + sqlite3TreeViewPush(&pView, |
| 32094 | + moreToFollow || (showFullList && pStep->pNext!=0)); |
| 32095 | + do{ |
| 32096 | + if( cnt++ && pStep->pNext==0 ){ |
| 32097 | + sqlite3TreeViewPop(&pView); |
| 32098 | + sqlite3TreeViewPush(&pView, 0); |
| 32099 | + } |
| 32100 | + sqlite3TreeViewLine(pView, "%s", pStep->zSpan ? pStep->zSpan : "RETURNING"); |
| 32101 | + }while( showFullList && (pStep = pStep->pNext)!=0 ); |
| 32102 | + sqlite3TreeViewPop(&pView); |
| 32103 | +} |
| 32104 | + |
| 32105 | +/* |
| 32106 | +** Show a human-readable graph of a Trigger |
| 32107 | +*/ |
| 32108 | +SQLITE_PRIVATE void sqlite3TreeViewTrigger( |
| 32109 | + TreeView *pView, |
| 32110 | + const Trigger *pTrigger, |
| 32111 | + u8 moreToFollow, |
| 32112 | + u8 showFullList |
| 32113 | +){ |
| 32114 | + int cnt = 0; |
| 32115 | + if( pTrigger==0 ) return; |
| 32116 | + sqlite3TreeViewPush(&pView, |
| 32117 | + moreToFollow || (showFullList && pTrigger->pNext!=0)); |
| 32118 | + do{ |
| 32119 | + if( cnt++ && pTrigger->pNext==0 ){ |
| 32120 | + sqlite3TreeViewPop(&pView); |
| 32121 | + sqlite3TreeViewPush(&pView, 0); |
| 32122 | + } |
| 32123 | + sqlite3TreeViewLine(pView, "TRIGGER %s", pTrigger->zName); |
| 32124 | + sqlite3TreeViewPush(&pView, 0); |
| 32125 | + sqlite3TreeViewTriggerStep(pView, pTrigger->step_list, 0, 1); |
| 32126 | + sqlite3TreeViewPop(&pView); |
| 32127 | + }while( showFullList && (pTrigger = pTrigger->pNext)!=0 ); |
| 32128 | + sqlite3TreeViewPop(&pView); |
| 32129 | +} |
| 32130 | +#endif /* SQLITE_OMIT_TRIGGER */ |
| 32131 | + |
| 32132 | + |
| 32133 | +/* |
| 32134 | +** These simplified versions of the tree-view routines omit unnecessary |
| 32135 | +** parameters. These variants are intended to be used from a symbolic |
| 32136 | +** debugger, such as "gdb", during interactive debugging sessions. |
| 32137 | +** |
| 32138 | +** This routines are given external linkage so that they will always be |
| 32139 | +** accessible to the debugging, and to avoid warnings about unused |
| 32140 | +** functions. But these routines only exist in debugging builds, so they |
| 32141 | +** do not contaminate the interface. |
| 32142 | +*/ |
| 32143 | +SQLITE_PRIVATE void sqlite3ShowExpr(const Expr *p){ sqlite3TreeViewExpr(0,p,0); } |
| 32144 | +SQLITE_PRIVATE void sqlite3ShowExprList(const ExprList *p){ sqlite3TreeViewExprList(0,p,0,0);} |
| 32145 | +SQLITE_PRIVATE void sqlite3ShowIdList(const IdList *p){ sqlite3TreeViewIdList(0,p,0,0); } |
| 32146 | +SQLITE_PRIVATE void sqlite3ShowSrcList(const SrcList *p){ sqlite3TreeViewSrcList(0,p); } |
| 32147 | +SQLITE_PRIVATE void sqlite3ShowSelect(const Select *p){ sqlite3TreeViewSelect(0,p,0); } |
| 32148 | +SQLITE_PRIVATE void sqlite3ShowWith(const With *p){ sqlite3TreeViewWith(0,p,0); } |
| 32149 | +SQLITE_PRIVATE void sqlite3ShowUpsert(const Upsert *p){ sqlite3TreeViewUpsert(0,p,0); } |
| 32150 | +#ifndef SQLITE_OMIT_TRIGGER |
| 32151 | +SQLITE_PRIVATE void sqlite3ShowTriggerStep(const TriggerStep *p){ |
| 32152 | + sqlite3TreeViewTriggerStep(0,p,0,0); |
| 32153 | +} |
| 32154 | +SQLITE_PRIVATE void sqlite3ShowTriggerStepList(const TriggerStep *p){ |
| 32155 | + sqlite3TreeViewTriggerStep(0,p,0,1); |
| 32156 | +} |
| 32157 | +SQLITE_PRIVATE void sqlite3ShowTrigger(const Trigger *p){ sqlite3TreeViewTrigger(0,p,0,0); } |
| 32158 | +SQLITE_PRIVATE void sqlite3ShowTriggerList(const Trigger *p){ sqlite3TreeViewTrigger(0,p,0,1);} |
| 32159 | +#endif |
| 32160 | +#ifndef SQLITE_OMIT_WINDOWFUNC |
| 32161 | +SQLITE_PRIVATE void sqlite3ShowWindow(const Window *p){ sqlite3TreeViewWindow(0,p,0); } |
| 32162 | +SQLITE_PRIVATE void sqlite3ShowWinFunc(const Window *p){ sqlite3TreeViewWinFunc(0,p,0); } |
| 32163 | +#endif |
| 32164 | + |
| 31681 | 32165 | #endif /* SQLITE_DEBUG */ |
| 31682 | 32166 | |
| 31683 | 32167 | /************** End of treeview.c ********************************************/ |
| 31684 | 32168 | /************** Begin file random.c ******************************************/ |
| 31685 | 32169 | /* |
| | @@ -34710,14 +35194,14 @@ |
| 34710 | 35194 | /* 66 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"), |
| 34711 | 35195 | /* 67 */ "Return" OpHelp(""), |
| 34712 | 35196 | /* 68 */ "EndCoroutine" OpHelp(""), |
| 34713 | 35197 | /* 69 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 34714 | 35198 | /* 70 */ "Halt" OpHelp(""), |
| 34715 | | - /* 71 */ "BeginSubrtn" OpHelp("r[P2]=P1"), |
| 34716 | | - /* 72 */ "Integer" OpHelp("r[P2]=P1"), |
| 34717 | | - /* 73 */ "Int64" OpHelp("r[P2]=P4"), |
| 34718 | | - /* 74 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 35199 | + /* 71 */ "Integer" OpHelp("r[P2]=P1"), |
| 35200 | + /* 72 */ "Int64" OpHelp("r[P2]=P4"), |
| 35201 | + /* 73 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 35202 | + /* 74 */ "BeginSubrtn" OpHelp("r[P2]=NULL"), |
| 34719 | 35203 | /* 75 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 34720 | 35204 | /* 76 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 34721 | 35205 | /* 77 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 34722 | 35206 | /* 78 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 34723 | 35207 | /* 79 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| | @@ -34733,11 +35217,11 @@ |
| 34733 | 35217 | /* 89 */ "Permutation" OpHelp(""), |
| 34734 | 35218 | /* 90 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 34735 | 35219 | /* 91 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), |
| 34736 | 35220 | /* 92 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"), |
| 34737 | 35221 | /* 93 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), |
| 34738 | | - /* 94 */ "Column" OpHelp("r[P3]=PX"), |
| 35222 | + /* 94 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"), |
| 34739 | 35223 | /* 95 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"), |
| 34740 | 35224 | /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 34741 | 35225 | /* 97 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 34742 | 35226 | /* 98 */ "Count" OpHelp("r[P2]=count()"), |
| 34743 | 35227 | /* 99 */ "ReadCookie" OpHelp(""), |
| | @@ -34774,11 +35258,11 @@ |
| 34774 | 35258 | /* 130 */ "Delete" OpHelp(""), |
| 34775 | 35259 | /* 131 */ "ResetCount" OpHelp(""), |
| 34776 | 35260 | /* 132 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 34777 | 35261 | /* 133 */ "SorterData" OpHelp("r[P2]=data"), |
| 34778 | 35262 | /* 134 */ "RowData" OpHelp("r[P2]=data"), |
| 34779 | | - /* 135 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 35263 | + /* 135 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"), |
| 34780 | 35264 | /* 136 */ "NullRow" OpHelp(""), |
| 34781 | 35265 | /* 137 */ "SeekEnd" OpHelp(""), |
| 34782 | 35266 | /* 138 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 34783 | 35267 | /* 139 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 34784 | 35268 | /* 140 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| | @@ -67869,10 +68353,12 @@ |
| 67869 | 68353 | |
| 67870 | 68354 | /* Remove the slot from the free-list. Update the number of |
| 67871 | 68355 | ** fragmented bytes within the page. */ |
| 67872 | 68356 | memcpy(&aData[iAddr], &aData[pc], 2); |
| 67873 | 68357 | aData[hdr+7] += (u8)x; |
| 68358 | + testcase( pc+x>maxPC ); |
| 68359 | + return &aData[pc]; |
| 67874 | 68360 | }else if( x+pc > maxPC ){ |
| 67875 | 68361 | /* This slot extends off the end of the usable part of the page */ |
| 67876 | 68362 | *pRc = SQLITE_CORRUPT_PAGE(pPg); |
| 67877 | 68363 | return 0; |
| 67878 | 68364 | }else{ |
| | @@ -72179,11 +72665,11 @@ |
| 72179 | 72665 | idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2 */ |
| 72180 | 72666 | } |
| 72181 | 72667 | assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) ); |
| 72182 | 72668 | assert( pPage->isInit ); |
| 72183 | 72669 | if( pPage->leaf ){ |
| 72184 | | - assert( pCur->ix<pCur->pPage->nCell ); |
| 72670 | + assert( pCur->ix<pCur->pPage->nCell || CORRUPT_DB ); |
| 72185 | 72671 | pCur->ix = (u16)idx; |
| 72186 | 72672 | *pRes = c; |
| 72187 | 72673 | rc = SQLITE_OK; |
| 72188 | 72674 | goto moveto_index_finish; |
| 72189 | 72675 | } |
| | @@ -74703,11 +75189,11 @@ |
| 74703 | 75189 | } |
| 74704 | 75190 | } |
| 74705 | 75191 | iOvflSpace += sz; |
| 74706 | 75192 | assert( sz<=pBt->maxLocal+23 ); |
| 74707 | 75193 | assert( iOvflSpace <= (int)pBt->pageSize ); |
| 74708 | | - for(k=0; b.ixNx[k]<=i && ALWAYS(k<NB*2); k++){} |
| 75194 | + for(k=0; b.ixNx[k]<=j && ALWAYS(k<NB*2); k++){} |
| 74709 | 75195 | pSrcEnd = b.apEnd[k]; |
| 74710 | 75196 | if( SQLITE_WITHIN(pSrcEnd, pCell, pCell+sz) ){ |
| 74711 | 75197 | rc = SQLITE_CORRUPT_BKPT; |
| 74712 | 75198 | goto balance_cleanup; |
| 74713 | 75199 | } |
| | @@ -75526,11 +76012,15 @@ |
| 75526 | 76012 | const u8 *aIn; /* Pointer to next input buffer */ |
| 75527 | 76013 | u32 nIn; /* Size of input buffer aIn[] */ |
| 75528 | 76014 | u32 nRem; /* Bytes of data still to copy */ |
| 75529 | 76015 | |
| 75530 | 76016 | getCellInfo(pSrc); |
| 75531 | | - aOut += putVarint32(aOut, pSrc->info.nPayload); |
| 76017 | + if( pSrc->info.nPayload<0x80 ){ |
| 76018 | + *(aOut++) = pSrc->info.nPayload; |
| 76019 | + }else{ |
| 76020 | + aOut += sqlite3PutVarint(aOut, pSrc->info.nPayload); |
| 76021 | + } |
| 75532 | 76022 | if( pDest->pKeyInfo==0 ) aOut += putVarint(aOut, iKey); |
| 75533 | 76023 | nIn = pSrc->info.nLocal; |
| 75534 | 76024 | aIn = pSrc->info.pPayload; |
| 75535 | 76025 | if( aIn+nIn>pSrc->pPage->aDataEnd ){ |
| 75536 | 76026 | return SQLITE_CORRUPT_BKPT; |
| | @@ -78539,13 +79029,14 @@ |
| 78539 | 79029 | SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){ |
| 78540 | 79030 | sqlite3_context ctx; |
| 78541 | 79031 | Mem t; |
| 78542 | 79032 | assert( pFunc!=0 ); |
| 78543 | 79033 | assert( pMem!=0 ); |
| 79034 | + assert( pMem->db!=0 ); |
| 78544 | 79035 | assert( pFunc->xFinalize!=0 ); |
| 78545 | 79036 | assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef ); |
| 78546 | | - assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 79037 | + assert( sqlite3_mutex_held(pMem->db->mutex) ); |
| 78547 | 79038 | memset(&ctx, 0, sizeof(ctx)); |
| 78548 | 79039 | memset(&t, 0, sizeof(t)); |
| 78549 | 79040 | t.flags = MEM_Null; |
| 78550 | 79041 | t.db = pMem->db; |
| 78551 | 79042 | ctx.pOut = &t; |
| | @@ -78571,11 +79062,12 @@ |
| 78571 | 79062 | SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem *pAccum, Mem *pOut, FuncDef *pFunc){ |
| 78572 | 79063 | sqlite3_context ctx; |
| 78573 | 79064 | assert( pFunc!=0 ); |
| 78574 | 79065 | assert( pFunc->xValue!=0 ); |
| 78575 | 79066 | assert( (pAccum->flags & MEM_Null)!=0 || pFunc==pAccum->u.pDef ); |
| 78576 | | - assert( pAccum->db==0 || sqlite3_mutex_held(pAccum->db->mutex) ); |
| 79067 | + assert( pAccum->db!=0 ); |
| 79068 | + assert( sqlite3_mutex_held(pAccum->db->mutex) ); |
| 78577 | 79069 | memset(&ctx, 0, sizeof(ctx)); |
| 78578 | 79070 | sqlite3VdbeMemSetNull(pOut); |
| 78579 | 79071 | ctx.pOut = pOut; |
| 78580 | 79072 | ctx.pMem = pAccum; |
| 78581 | 79073 | ctx.pFunc = pFunc; |
| | @@ -80639,18 +81131,24 @@ |
| 80639 | 81131 | |
| 80640 | 81132 | /* |
| 80641 | 81133 | ** Mark the VDBE as one that can only be run one time. |
| 80642 | 81134 | */ |
| 80643 | 81135 | SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){ |
| 80644 | | - p->runOnlyOnce = 1; |
| 81136 | + sqlite3VdbeAddOp2(p, OP_Expire, 1, 1); |
| 80645 | 81137 | } |
| 80646 | 81138 | |
| 80647 | 81139 | /* |
| 80648 | 81140 | ** Mark the VDBE as one that can only be run multiple times. |
| 80649 | 81141 | */ |
| 80650 | 81142 | SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){ |
| 80651 | | - p->runOnlyOnce = 0; |
| 81143 | + int i; |
| 81144 | + for(i=1; ALWAYS(i<p->nOp); i++){ |
| 81145 | + if( ALWAYS(p->aOp[i].opcode==OP_Expire) ){ |
| 81146 | + p->aOp[1].opcode = OP_Noop; |
| 81147 | + break; |
| 81148 | + } |
| 81149 | + } |
| 80652 | 81150 | } |
| 80653 | 81151 | |
| 80654 | 81152 | #ifdef SQLITE_DEBUG /* sqlite3AssertMayAbort() logic */ |
| 80655 | 81153 | |
| 80656 | 81154 | /* |
| | @@ -81276,11 +81774,11 @@ |
| 81276 | 81774 | int iFirst, /* Index of first register to be released */ |
| 81277 | 81775 | int N, /* Number of registers to release */ |
| 81278 | 81776 | u32 mask, /* Mask of registers to NOT release */ |
| 81279 | 81777 | int bUndefine /* If true, mark registers as undefined */ |
| 81280 | 81778 | ){ |
| 81281 | | - if( N==0 ) return; |
| 81779 | + if( N==0 || OptimizationDisabled(pParse->db, SQLITE_ReleaseReg) ) return; |
| 81282 | 81780 | assert( pParse->pVdbe ); |
| 81283 | 81781 | assert( iFirst>=1 ); |
| 81284 | 81782 | assert( iFirst+N-1<=pParse->nMem ); |
| 81285 | 81783 | if( N<=31 && mask!=0 ){ |
| 81286 | 81784 | while( N>0 && (mask&1)!=0 ){ |
| | @@ -81535,12 +82033,17 @@ |
| 81535 | 82033 | if( c=='P' ){ |
| 81536 | 82034 | c = zSynopsis[++ii]; |
| 81537 | 82035 | if( c=='4' ){ |
| 81538 | 82036 | sqlite3_str_appendall(&x, zP4); |
| 81539 | 82037 | }else if( c=='X' ){ |
| 81540 | | - sqlite3_str_appendall(&x, pOp->zComment); |
| 82038 | + if( pOp->zComment && pOp->zComment[0] ){ |
| 82039 | + sqlite3_str_appendall(&x, pOp->zComment); |
| 82040 | + }else{ |
| 82041 | + sqlite3_str_appendall(&x, zSynopsis+1); |
| 82042 | + } |
| 81541 | 82043 | seenCom = 1; |
| 82044 | + break; |
| 81542 | 82045 | }else{ |
| 81543 | 82046 | int v1 = translateP(c, pOp); |
| 81544 | 82047 | int v2; |
| 81545 | 82048 | if( strncmp(zSynopsis+ii+1, "@P", 2)==0 ){ |
| 81546 | 82049 | ii += 3; |
| | @@ -82131,11 +82634,11 @@ |
| 82131 | 82634 | int i; |
| 82132 | 82635 | Mem *aMem = VdbeFrameMem(p); |
| 82133 | 82636 | VdbeCursor **apCsr = (VdbeCursor **)&aMem[p->nChildMem]; |
| 82134 | 82637 | assert( sqlite3VdbeFrameIsValid(p) ); |
| 82135 | 82638 | for(i=0; i<p->nChildCsr; i++){ |
| 82136 | | - sqlite3VdbeFreeCursor(p->v, apCsr[i]); |
| 82639 | + if( apCsr[i] ) sqlite3VdbeFreeCursorNN(p->v, apCsr[i]); |
| 82137 | 82640 | } |
| 82138 | 82641 | releaseMemArray(aMem, p->nChildMem); |
| 82139 | 82642 | sqlite3VdbeDeleteAuxData(p->v->db, &p->pAuxData, -1, 0); |
| 82140 | 82643 | sqlite3DbFree(p->v->db, p); |
| 82141 | 82644 | } |
| | @@ -82325,15 +82828,15 @@ |
| 82325 | 82828 | ** statement. |
| 82326 | 82829 | */ |
| 82327 | 82830 | static void *allocSpace( |
| 82328 | 82831 | struct ReusableSpace *p, /* Bulk memory available for allocation */ |
| 82329 | 82832 | void *pBuf, /* Pointer to a prior allocation */ |
| 82330 | | - sqlite3_int64 nByte /* Bytes of memory needed */ |
| 82833 | + sqlite3_int64 nByte /* Bytes of memory needed. */ |
| 82331 | 82834 | ){ |
| 82332 | 82835 | assert( EIGHT_BYTE_ALIGNMENT(p->pSpace) ); |
| 82333 | 82836 | if( pBuf==0 ){ |
| 82334 | | - nByte = ROUND8(nByte); |
| 82837 | + nByte = ROUND8P(nByte); |
| 82335 | 82838 | if( nByte <= p->nFree ){ |
| 82336 | 82839 | p->nFree -= nByte; |
| 82337 | 82840 | pBuf = &p->pSpace[p->nFree]; |
| 82338 | 82841 | }else{ |
| 82339 | 82842 | p->nNeeded += nByte; |
| | @@ -82437,11 +82940,11 @@ |
| 82437 | 82940 | |
| 82438 | 82941 | /* Figure out how much reusable memory is available at the end of the |
| 82439 | 82942 | ** opcode array. This extra memory will be reallocated for other elements |
| 82440 | 82943 | ** of the prepared statement. |
| 82441 | 82944 | */ |
| 82442 | | - n = ROUND8(sizeof(Op)*p->nOp); /* Bytes of opcode memory used */ |
| 82945 | + n = ROUND8P(sizeof(Op)*p->nOp); /* Bytes of opcode memory used */ |
| 82443 | 82946 | x.pSpace = &((u8*)p->aOp)[n]; /* Unused opcode memory */ |
| 82444 | 82947 | assert( EIGHT_BYTE_ALIGNMENT(x.pSpace) ); |
| 82445 | 82948 | x.nFree = ROUNDDOWN8(pParse->szOpAlloc - n); /* Bytes of unused memory */ |
| 82446 | 82949 | assert( x.nFree>=0 ); |
| 82447 | 82950 | assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) ); |
| | @@ -82525,13 +83028,13 @@ |
| 82525 | 83028 | /* |
| 82526 | 83029 | ** Close a VDBE cursor and release all the resources that cursor |
| 82527 | 83030 | ** happens to hold. |
| 82528 | 83031 | */ |
| 82529 | 83032 | SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){ |
| 82530 | | - if( pCx==0 ){ |
| 82531 | | - return; |
| 82532 | | - } |
| 83033 | + if( pCx ) sqlite3VdbeFreeCursorNN(p,pCx); |
| 83034 | +} |
| 83035 | +SQLITE_PRIVATE void sqlite3VdbeFreeCursorNN(Vdbe *p, VdbeCursor *pCx){ |
| 82533 | 83036 | switch( pCx->eCurType ){ |
| 82534 | 83037 | case CURTYPE_SORTER: { |
| 82535 | 83038 | sqlite3VdbeSorterClose(p->db, pCx); |
| 82536 | 83039 | break; |
| 82537 | 83040 | } |
| | @@ -82559,11 +83062,11 @@ |
| 82559 | 83062 | static void closeCursorsInFrame(Vdbe *p){ |
| 82560 | 83063 | int i; |
| 82561 | 83064 | for(i=0; i<p->nCursor; i++){ |
| 82562 | 83065 | VdbeCursor *pC = p->apCsr[i]; |
| 82563 | 83066 | if( pC ){ |
| 82564 | | - sqlite3VdbeFreeCursor(p, pC); |
| 83067 | + sqlite3VdbeFreeCursorNN(p, pC); |
| 82565 | 83068 | p->apCsr[i] = 0; |
| 82566 | 83069 | } |
| 82567 | 83070 | } |
| 82568 | 83071 | } |
| 82569 | 83072 | |
| | @@ -83089,13 +83592,11 @@ |
| 83089 | 83592 | ** Then the internal cache might have been left in an inconsistent |
| 83090 | 83593 | ** state. We need to rollback the statement transaction, if there is |
| 83091 | 83594 | ** one, or the complete transaction if there is no statement transaction. |
| 83092 | 83595 | */ |
| 83093 | 83596 | |
| 83094 | | - if( p->eVdbeState!=VDBE_RUN_STATE ){ |
| 83095 | | - return SQLITE_OK; |
| 83096 | | - } |
| 83597 | + assert( p->eVdbeState==VDBE_RUN_STATE ); |
| 83097 | 83598 | if( db->mallocFailed ){ |
| 83098 | 83599 | p->rc = SQLITE_NOMEM_BKPT; |
| 83099 | 83600 | } |
| 83100 | 83601 | closeAllCursors(p); |
| 83101 | 83602 | checkActiveVdbeCnt(db); |
| | @@ -83351,11 +83852,11 @@ |
| 83351 | 83852 | |
| 83352 | 83853 | /* If the VM did not run to completion or if it encountered an |
| 83353 | 83854 | ** error, then it might not have been halted properly. So halt |
| 83354 | 83855 | ** it now. |
| 83355 | 83856 | */ |
| 83356 | | - sqlite3VdbeHalt(p); |
| 83857 | + if( p->eVdbeState==VDBE_RUN_STATE ) sqlite3VdbeHalt(p); |
| 83357 | 83858 | |
| 83358 | 83859 | /* If the VDBE has been run even partially, then transfer the error code |
| 83359 | 83860 | ** and error message from the VDBE into the main database structure. But |
| 83360 | 83861 | ** if the VDBE has just been set to run but has not actually executed any |
| 83361 | 83862 | ** instructions yet, leave the main database error information unchanged. |
| | @@ -83365,11 +83866,10 @@ |
| 83365 | 83866 | if( db->pErr || p->zErrMsg ){ |
| 83366 | 83867 | sqlite3VdbeTransferError(p); |
| 83367 | 83868 | }else{ |
| 83368 | 83869 | db->errCode = p->rc; |
| 83369 | 83870 | } |
| 83370 | | - if( p->runOnlyOnce ) p->expired = 1; |
| 83371 | 83871 | } |
| 83372 | 83872 | |
| 83373 | 83873 | /* Reset register contents and reclaim error message memory. |
| 83374 | 83874 | */ |
| 83375 | 83875 | #ifdef SQLITE_DEBUG |
| | @@ -83486,11 +83986,11 @@ |
| 83486 | 83986 | ** |
| 83487 | 83987 | ** The difference between this function and sqlite3VdbeDelete() is that |
| 83488 | 83988 | ** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with |
| 83489 | 83989 | ** the database connection and frees the object itself. |
| 83490 | 83990 | */ |
| 83491 | | -SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){ |
| 83991 | +static void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){ |
| 83492 | 83992 | SubProgram *pSub, *pNext; |
| 83493 | 83993 | assert( p->db==0 || p->db==db ); |
| 83494 | 83994 | if( p->aColName ){ |
| 83495 | 83995 | releaseMemArray(p->aColName, p->nResColumn*COLNAME_N); |
| 83496 | 83996 | sqlite3DbFreeNN(db, p->aColName); |
| | @@ -83536,18 +84036,20 @@ |
| 83536 | 84036 | |
| 83537 | 84037 | assert( p!=0 ); |
| 83538 | 84038 | db = p->db; |
| 83539 | 84039 | assert( sqlite3_mutex_held(db->mutex) ); |
| 83540 | 84040 | sqlite3VdbeClearObject(db, p); |
| 83541 | | - if( p->pPrev ){ |
| 83542 | | - p->pPrev->pNext = p->pNext; |
| 83543 | | - }else{ |
| 83544 | | - assert( db->pVdbe==p ); |
| 83545 | | - db->pVdbe = p->pNext; |
| 83546 | | - } |
| 83547 | | - if( p->pNext ){ |
| 83548 | | - p->pNext->pPrev = p->pPrev; |
| 84041 | + if( db->pnBytesFreed==0 ){ |
| 84042 | + if( p->pPrev ){ |
| 84043 | + p->pPrev->pNext = p->pNext; |
| 84044 | + }else{ |
| 84045 | + assert( db->pVdbe==p ); |
| 84046 | + db->pVdbe = p->pNext; |
| 84047 | + } |
| 84048 | + if( p->pNext ){ |
| 84049 | + p->pNext->pPrev = p->pPrev; |
| 84050 | + } |
| 83549 | 84051 | } |
| 83550 | 84052 | sqlite3DbFreeNN(db, p); |
| 83551 | 84053 | } |
| 83552 | 84054 | |
| 83553 | 84055 | /* |
| | @@ -83595,11 +84097,11 @@ |
| 83595 | 84097 | /* |
| 83596 | 84098 | ** Check to ensure that the cursor is valid. Restore the cursor |
| 83597 | 84099 | ** if need be. Return any I/O error from the restore operation. |
| 83598 | 84100 | */ |
| 83599 | 84101 | SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor *p){ |
| 83600 | | - assert( p->eCurType==CURTYPE_BTREE ); |
| 84102 | + assert( p->eCurType==CURTYPE_BTREE || IsNullCursor(p) ); |
| 83601 | 84103 | if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){ |
| 83602 | 84104 | return sqlite3VdbeHandleMovedCursor(p); |
| 83603 | 84105 | } |
| 83604 | 84106 | return SQLITE_OK; |
| 83605 | 84107 | } |
| | @@ -83608,11 +84110,11 @@ |
| 83608 | 84110 | ** The following functions: |
| 83609 | 84111 | ** |
| 83610 | 84112 | ** sqlite3VdbeSerialType() |
| 83611 | 84113 | ** sqlite3VdbeSerialTypeLen() |
| 83612 | 84114 | ** sqlite3VdbeSerialLen() |
| 83613 | | -** sqlite3VdbeSerialPut() |
| 84115 | +** sqlite3VdbeSerialPut() <--- in-lined into OP_MakeRecord as of 2022-04-02 |
| 83614 | 84116 | ** sqlite3VdbeSerialGet() |
| 83615 | 84117 | ** |
| 83616 | 84118 | ** encapsulate the code that serializes values for storage in SQLite |
| 83617 | 84119 | ** data and index records. Each serialized value consists of a |
| 83618 | 84120 | ** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned |
| | @@ -83720,11 +84222,11 @@ |
| 83720 | 84222 | #endif /* inlined into OP_MakeRecord */ |
| 83721 | 84223 | |
| 83722 | 84224 | /* |
| 83723 | 84225 | ** The sizes for serial types less than 128 |
| 83724 | 84226 | */ |
| 83725 | | -static const u8 sqlite3SmallTypeSizes[] = { |
| 84227 | +SQLITE_PRIVATE const u8 sqlite3SmallTypeSizes[128] = { |
| 83726 | 84228 | /* 0 1 2 3 4 5 6 7 8 9 */ |
| 83727 | 84229 | /* 0 */ 0, 1, 2, 3, 4, 6, 8, 8, 0, 0, |
| 83728 | 84230 | /* 10 */ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, |
| 83729 | 84231 | /* 20 */ 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, |
| 83730 | 84232 | /* 30 */ 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, |
| | @@ -83789,11 +84291,11 @@ |
| 83789 | 84291 | ** works for him. We, the developers, have no way to independently |
| 83790 | 84292 | ** verify this, but Frank seems to know what he is talking about |
| 83791 | 84293 | ** so we trust him. |
| 83792 | 84294 | */ |
| 83793 | 84295 | #ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT |
| 83794 | | -static u64 floatSwap(u64 in){ |
| 84296 | +SQLITE_PRIVATE u64 sqlite3FloatSwap(u64 in){ |
| 83795 | 84297 | union { |
| 83796 | 84298 | u64 r; |
| 83797 | 84299 | u32 i[2]; |
| 83798 | 84300 | } u; |
| 83799 | 84301 | u32 t; |
| | @@ -83802,63 +84304,12 @@ |
| 83802 | 84304 | t = u.i[0]; |
| 83803 | 84305 | u.i[0] = u.i[1]; |
| 83804 | 84306 | u.i[1] = t; |
| 83805 | 84307 | return u.r; |
| 83806 | 84308 | } |
| 83807 | | -# define swapMixedEndianFloat(X) X = floatSwap(X) |
| 83808 | | -#else |
| 83809 | | -# define swapMixedEndianFloat(X) |
| 83810 | | -#endif |
| 83811 | | - |
| 83812 | | -/* |
| 83813 | | -** Write the serialized data blob for the value stored in pMem into |
| 83814 | | -** buf. It is assumed that the caller has allocated sufficient space. |
| 83815 | | -** Return the number of bytes written. |
| 83816 | | -** |
| 83817 | | -** nBuf is the amount of space left in buf[]. The caller is responsible |
| 83818 | | -** for allocating enough space to buf[] to hold the entire field, exclusive |
| 83819 | | -** of the pMem->u.nZero bytes for a MEM_Zero value. |
| 83820 | | -** |
| 83821 | | -** Return the number of bytes actually written into buf[]. The number |
| 83822 | | -** of bytes in the zero-filled tail is included in the return value only |
| 83823 | | -** if those bytes were zeroed in buf[]. |
| 83824 | | -*/ |
| 83825 | | -SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){ |
| 83826 | | - u32 len; |
| 83827 | | - |
| 83828 | | - /* Integer and Real */ |
| 83829 | | - if( serial_type<=7 && serial_type>0 ){ |
| 83830 | | - u64 v; |
| 83831 | | - u32 i; |
| 83832 | | - if( serial_type==7 ){ |
| 83833 | | - assert( sizeof(v)==sizeof(pMem->u.r) ); |
| 83834 | | - memcpy(&v, &pMem->u.r, sizeof(v)); |
| 83835 | | - swapMixedEndianFloat(v); |
| 83836 | | - }else{ |
| 83837 | | - v = pMem->u.i; |
| 83838 | | - } |
| 83839 | | - len = i = sqlite3SmallTypeSizes[serial_type]; |
| 83840 | | - assert( i>0 ); |
| 83841 | | - do{ |
| 83842 | | - buf[--i] = (u8)(v&0xFF); |
| 83843 | | - v >>= 8; |
| 83844 | | - }while( i ); |
| 83845 | | - return len; |
| 83846 | | - } |
| 83847 | | - |
| 83848 | | - /* String or blob */ |
| 83849 | | - if( serial_type>=12 ){ |
| 83850 | | - assert( pMem->n + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0) |
| 83851 | | - == (int)sqlite3VdbeSerialTypeLen(serial_type) ); |
| 83852 | | - len = pMem->n; |
| 83853 | | - if( len>0 ) memcpy(buf, pMem->z, len); |
| 83854 | | - return len; |
| 83855 | | - } |
| 83856 | | - |
| 83857 | | - /* NULL or constants 0 or 1 */ |
| 83858 | | - return 0; |
| 83859 | | -} |
| 84309 | +#endif /* SQLITE_MIXED_ENDIAN_64BIT_FLOAT */ |
| 84310 | + |
| 83860 | 84311 | |
| 83861 | 84312 | /* Input "x" is a sequence of unsigned characters that represent a |
| 83862 | 84313 | ** big-endian integer. Return the equivalent native integer |
| 83863 | 84314 | */ |
| 83864 | 84315 | #define ONE_BYTE_INT(x) ((i8)(x)[0]) |
| | @@ -84020,14 +84471,14 @@ |
| 84020 | 84471 | SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord( |
| 84021 | 84472 | KeyInfo *pKeyInfo /* Description of the record */ |
| 84022 | 84473 | ){ |
| 84023 | 84474 | UnpackedRecord *p; /* Unpacked record to return */ |
| 84024 | 84475 | int nByte; /* Number of bytes required for *p */ |
| 84025 | | - nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1); |
| 84476 | + nByte = ROUND8P(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1); |
| 84026 | 84477 | p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte); |
| 84027 | 84478 | if( !p ) return 0; |
| 84028 | | - p->aMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))]; |
| 84479 | + p->aMem = (Mem*)&((char*)p)[ROUND8P(sizeof(UnpackedRecord))]; |
| 84029 | 84480 | assert( pKeyInfo->aSortFlags!=0 ); |
| 84030 | 84481 | p->pKeyInfo = pKeyInfo; |
| 84031 | 84482 | p->nField = pKeyInfo->nKeyField + 1; |
| 84032 | 84483 | return p; |
| 84033 | 84484 | } |
| | @@ -84521,18 +84972,26 @@ |
| 84521 | 84972 | |
| 84522 | 84973 | /* If bSkip is true, then the caller has already determined that the first |
| 84523 | 84974 | ** two elements in the keys are equal. Fix the various stack variables so |
| 84524 | 84975 | ** that this routine begins comparing at the second field. */ |
| 84525 | 84976 | if( bSkip ){ |
| 84526 | | - u32 s1; |
| 84527 | | - idx1 = 1 + getVarint32(&aKey1[1], s1); |
| 84977 | + u32 s1 = aKey1[1]; |
| 84978 | + if( s1<0x80 ){ |
| 84979 | + idx1 = 2; |
| 84980 | + }else{ |
| 84981 | + idx1 = 1 + sqlite3GetVarint32(&aKey1[1], &s1); |
| 84982 | + } |
| 84528 | 84983 | szHdr1 = aKey1[0]; |
| 84529 | 84984 | d1 = szHdr1 + sqlite3VdbeSerialTypeLen(s1); |
| 84530 | 84985 | i = 1; |
| 84531 | 84986 | pRhs++; |
| 84532 | 84987 | }else{ |
| 84533 | | - idx1 = getVarint32(aKey1, szHdr1); |
| 84988 | + if( (szHdr1 = aKey1[0])<0x80 ){ |
| 84989 | + idx1 = 1; |
| 84990 | + }else{ |
| 84991 | + idx1 = sqlite3GetVarint32(aKey1, &szHdr1); |
| 84992 | + } |
| 84534 | 84993 | d1 = szHdr1; |
| 84535 | 84994 | i = 0; |
| 84536 | 84995 | } |
| 84537 | 84996 | if( d1>(unsigned)nKey1 ){ |
| 84538 | 84997 | pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT; |
| | @@ -85932,18 +86391,12 @@ |
| 85932 | 86391 | */ |
| 85933 | 86392 | static int sqlite3Step(Vdbe *p){ |
| 85934 | 86393 | sqlite3 *db; |
| 85935 | 86394 | int rc; |
| 85936 | 86395 | |
| 85937 | | - /* Check that malloc() has not failed. If it has, return early. */ |
| 85938 | | - db = p->db; |
| 85939 | | - if( db->mallocFailed ){ |
| 85940 | | - p->rc = SQLITE_NOMEM; |
| 85941 | | - return SQLITE_NOMEM_BKPT; |
| 85942 | | - } |
| 85943 | | - |
| 85944 | 86396 | assert(p); |
| 86397 | + db = p->db; |
| 85945 | 86398 | if( p->eVdbeState!=VDBE_RUN_STATE ){ |
| 85946 | 86399 | restart_step: |
| 85947 | 86400 | if( p->eVdbeState==VDBE_READY_STATE ){ |
| 85948 | 86401 | if( p->expired ){ |
| 85949 | 86402 | p->rc = SQLITE_SCHEMA; |
| | @@ -86087,11 +86540,10 @@ |
| 86087 | 86540 | if( vdbeSafetyNotNull(v) ){ |
| 86088 | 86541 | return SQLITE_MISUSE_BKPT; |
| 86089 | 86542 | } |
| 86090 | 86543 | db = v->db; |
| 86091 | 86544 | sqlite3_mutex_enter(db->mutex); |
| 86092 | | - v->doingRerun = 0; |
| 86093 | 86545 | while( (rc = sqlite3Step(v))==SQLITE_SCHEMA |
| 86094 | 86546 | && cnt++ < SQLITE_MAX_SCHEMA_RETRY ){ |
| 86095 | 86547 | int savedPc = v->pc; |
| 86096 | 86548 | rc = sqlite3Reprepare(v); |
| 86097 | 86549 | if( rc!=SQLITE_OK ){ |
| | @@ -86113,11 +86565,17 @@ |
| 86113 | 86565 | v->rc = rc = SQLITE_NOMEM_BKPT; |
| 86114 | 86566 | } |
| 86115 | 86567 | break; |
| 86116 | 86568 | } |
| 86117 | 86569 | sqlite3_reset(pStmt); |
| 86118 | | - if( savedPc>=0 ) v->doingRerun = 1; |
| 86570 | + if( savedPc>=0 ){ |
| 86571 | + /* Setting minWriteFileFormat to 254 is a signal to the OP_Init and |
| 86572 | + ** OP_Trace opcodes to *not* perform SQLITE_TRACE_STMT because one |
| 86573 | + ** should output has already occurred due to SQLITE_SCHEMA. |
| 86574 | + ** tag-20220401a */ |
| 86575 | + v->minWriteFileFormat = 254; |
| 86576 | + } |
| 86119 | 86577 | assert( v->expired==0 ); |
| 86120 | 86578 | } |
| 86121 | 86579 | sqlite3_mutex_leave(db->mutex); |
| 86122 | 86580 | return rc; |
| 86123 | 86581 | } |
| | @@ -87126,12 +87584,11 @@ |
| 87126 | 87584 | if( op==SQLITE_STMTSTATUS_MEMUSED ){ |
| 87127 | 87585 | sqlite3 *db = pVdbe->db; |
| 87128 | 87586 | sqlite3_mutex_enter(db->mutex); |
| 87129 | 87587 | v = 0; |
| 87130 | 87588 | db->pnBytesFreed = (int*)&v; |
| 87131 | | - sqlite3VdbeClearObject(db, pVdbe); |
| 87132 | | - sqlite3DbFree(db, pVdbe); |
| 87589 | + sqlite3VdbeDelete(pVdbe); |
| 87133 | 87590 | db->pnBytesFreed = 0; |
| 87134 | 87591 | sqlite3_mutex_leave(db->mutex); |
| 87135 | 87592 | }else{ |
| 87136 | 87593 | v = pVdbe->aCounter[op]; |
| 87137 | 87594 | if( resetFlag ) pVdbe->aCounter[op] = 0; |
| | @@ -87920,16 +88377,16 @@ |
| 87920 | 88377 | Mem *pMem = iCur>0 ? &p->aMem[p->nMem-iCur] : p->aMem; |
| 87921 | 88378 | |
| 87922 | 88379 | int nByte; |
| 87923 | 88380 | VdbeCursor *pCx = 0; |
| 87924 | 88381 | nByte = |
| 87925 | | - ROUND8(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField + |
| 88382 | + ROUND8P(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField + |
| 87926 | 88383 | (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0); |
| 87927 | 88384 | |
| 87928 | 88385 | assert( iCur>=0 && iCur<p->nCursor ); |
| 87929 | 88386 | if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/ |
| 87930 | | - sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); |
| 88387 | + sqlite3VdbeFreeCursorNN(p, p->apCsr[iCur]); |
| 87931 | 88388 | p->apCsr[iCur] = 0; |
| 87932 | 88389 | } |
| 87933 | 88390 | |
| 87934 | 88391 | /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure |
| 87935 | 88392 | ** the pMem used to hold space for the cursor has enough storage available |
| | @@ -87955,11 +88412,11 @@ |
| 87955 | 88412 | pCx->eCurType = eCurType; |
| 87956 | 88413 | pCx->nField = nField; |
| 87957 | 88414 | pCx->aOffset = &pCx->aType[nField]; |
| 87958 | 88415 | if( eCurType==CURTYPE_BTREE ){ |
| 87959 | 88416 | pCx->uc.pCursor = (BtCursor*) |
| 87960 | | - &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField]; |
| 88417 | + &pMem->z[ROUND8P(sizeof(VdbeCursor))+2*sizeof(u32)*nField]; |
| 87961 | 88418 | sqlite3BtreeCursorZero(pCx->uc.pCursor); |
| 87962 | 88419 | } |
| 87963 | 88420 | return pCx; |
| 87964 | 88421 | } |
| 87965 | 88422 | |
| | @@ -88637,32 +89094,43 @@ |
| 88637 | 89094 | assert( VdbeMemDynamic(pIn1)==0 ); |
| 88638 | 89095 | memAboutToChange(p, pIn1); |
| 88639 | 89096 | pIn1->flags = MEM_Int; |
| 88640 | 89097 | pIn1->u.i = (int)(pOp-aOp); |
| 88641 | 89098 | REGISTER_TRACE(pOp->p1, pIn1); |
| 88642 | | - |
| 88643 | | - /* Most jump operations do a goto to this spot in order to update |
| 88644 | | - ** the pOp pointer. */ |
| 88645 | | -jump_to_p2: |
| 88646 | | - pOp = &aOp[pOp->p2 - 1]; |
| 88647 | | - break; |
| 88648 | | -} |
| 88649 | | - |
| 88650 | | -/* Opcode: Return P1 * P3 * * |
| 88651 | | -** |
| 88652 | | -** Jump to the next instruction after the address in register P1. After |
| 88653 | | -** the jump, register P1 becomes undefined. |
| 88654 | | -** |
| 88655 | | -** P3 is not used by the byte-code engine. However, the code generator |
| 88656 | | -** sets P3 to address of the associated OP_BeginSubrtn opcode, if there is |
| 88657 | | -** one. |
| 89099 | + goto jump_to_p2_and_check_for_interrupt; |
| 89100 | +} |
| 89101 | + |
| 89102 | +/* Opcode: Return P1 P2 P3 * * |
| 89103 | +** |
| 89104 | +** Jump to the address stored in register P1. If P1 is a return address |
| 89105 | +** register, then this accomplishes a return from a subroutine. |
| 89106 | +** |
| 89107 | +** If P3 is 1, then the jump is only taken if register P1 holds an integer |
| 89108 | +** values, otherwise execution falls through to the next opcode, and the |
| 89109 | +** OP_Return becomes a no-op. If P3 is 0, then register P1 must hold an |
| 89110 | +** integer or else an assert() is raised. P3 should be set to 1 when |
| 89111 | +** this opcode is used in combination with OP_BeginSubrtn, and set to 0 |
| 89112 | +** otherwise. |
| 89113 | +** |
| 89114 | +** The value in register P1 is unchanged by this opcode. |
| 89115 | +** |
| 89116 | +** P2 is not used by the byte-code engine. However, if P2 is positive |
| 89117 | +** and also less than the current address, then the "EXPLAIN" output |
| 89118 | +** formatter in the CLI will indent all opcodes from the P2 opcode up |
| 89119 | +** to be not including the current Return. P2 should be the first opcode |
| 89120 | +** in the subroutine from which this opcode is returnning. Thus the P2 |
| 89121 | +** value is a byte-code indentation hint. See tag-20220407a in |
| 89122 | +** wherecode.c and shell.c. |
| 88658 | 89123 | */ |
| 88659 | 89124 | case OP_Return: { /* in1 */ |
| 88660 | 89125 | pIn1 = &aMem[pOp->p1]; |
| 88661 | | - assert( pIn1->flags==MEM_Int ); |
| 88662 | | - pOp = &aOp[pIn1->u.i]; |
| 88663 | | - pIn1->flags = MEM_Undefined; |
| 89126 | + if( pIn1->flags & MEM_Int ){ |
| 89127 | + if( pOp->p3 ){ VdbeBranchTaken(1, 2); } |
| 89128 | + pOp = &aOp[pIn1->u.i]; |
| 89129 | + }else if( ALWAYS(pOp->p3) ){ |
| 89130 | + VdbeBranchTaken(0, 2); |
| 89131 | + } |
| 88664 | 89132 | break; |
| 88665 | 89133 | } |
| 88666 | 89134 | |
| 88667 | 89135 | /* Opcode: InitCoroutine P1 P2 P3 * * |
| 88668 | 89136 | ** |
| | @@ -88681,11 +89149,16 @@ |
| 88681 | 89149 | assert( pOp->p3>=0 && pOp->p3<p->nOp ); |
| 88682 | 89150 | pOut = &aMem[pOp->p1]; |
| 88683 | 89151 | assert( !VdbeMemDynamic(pOut) ); |
| 88684 | 89152 | pOut->u.i = pOp->p3 - 1; |
| 88685 | 89153 | pOut->flags = MEM_Int; |
| 88686 | | - if( pOp->p2 ) goto jump_to_p2; |
| 89154 | + if( pOp->p2==0 ) break; |
| 89155 | + |
| 89156 | + /* Most jump operations do a goto to this spot in order to update |
| 89157 | + ** the pOp pointer. */ |
| 89158 | +jump_to_p2: |
| 89159 | + pOp = &aOp[pOp->p2 - 1]; |
| 88687 | 89160 | break; |
| 88688 | 89161 | } |
| 88689 | 89162 | |
| 88690 | 89163 | /* Opcode: EndCoroutine P1 * * * * |
| 88691 | 89164 | ** |
| | @@ -88783,15 +89256,14 @@ |
| 88783 | 89256 | */ |
| 88784 | 89257 | case OP_Halt: { |
| 88785 | 89258 | VdbeFrame *pFrame; |
| 88786 | 89259 | int pcx; |
| 88787 | 89260 | |
| 88788 | | - pcx = (int)(pOp - aOp); |
| 88789 | 89261 | #ifdef SQLITE_DEBUG |
| 88790 | 89262 | if( pOp->p2==OE_Abort ){ sqlite3VdbeAssertAbortable(p); } |
| 88791 | 89263 | #endif |
| 88792 | | - if( pOp->p1==SQLITE_OK && p->pFrame ){ |
| 89264 | + if( p->pFrame && pOp->p1==SQLITE_OK ){ |
| 88793 | 89265 | /* Halt the sub-program. Return control to the parent frame. */ |
| 88794 | 89266 | pFrame = p->pFrame; |
| 88795 | 89267 | p->pFrame = pFrame->pParent; |
| 88796 | 89268 | p->nFrame--; |
| 88797 | 89269 | sqlite3VdbeSetChanges(db, p->nChange); |
| | @@ -88809,11 +89281,10 @@ |
| 88809 | 89281 | pOp = &aOp[pcx]; |
| 88810 | 89282 | break; |
| 88811 | 89283 | } |
| 88812 | 89284 | p->rc = pOp->p1; |
| 88813 | 89285 | p->errorAction = (u8)pOp->p2; |
| 88814 | | - p->pc = pcx; |
| 88815 | 89286 | assert( pOp->p5<=4 ); |
| 88816 | 89287 | if( p->rc ){ |
| 88817 | 89288 | if( pOp->p5 ){ |
| 88818 | 89289 | static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK", |
| 88819 | 89290 | "FOREIGN KEY" }; |
| | @@ -88826,10 +89297,11 @@ |
| 88826 | 89297 | p->zErrMsg = sqlite3MPrintf(db, "%z: %s", p->zErrMsg, pOp->p4.z); |
| 88827 | 89298 | } |
| 88828 | 89299 | }else{ |
| 88829 | 89300 | sqlite3VdbeError(p, "%s", pOp->p4.z); |
| 88830 | 89301 | } |
| 89302 | + pcx = (int)(pOp - aOp); |
| 88831 | 89303 | sqlite3_log(pOp->p1, "abort at %d in [%s]: %s", pcx, p->zSql, p->zErrMsg); |
| 88832 | 89304 | } |
| 88833 | 89305 | rc = sqlite3VdbeHalt(p); |
| 88834 | 89306 | assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR ); |
| 88835 | 89307 | if( rc==SQLITE_BUSY ){ |
| | @@ -88840,26 +89312,15 @@ |
| 88840 | 89312 | rc = p->rc ? SQLITE_ERROR : SQLITE_DONE; |
| 88841 | 89313 | } |
| 88842 | 89314 | goto vdbe_return; |
| 88843 | 89315 | } |
| 88844 | 89316 | |
| 88845 | | -/* Opcode: BeginSubrtn P1 P2 * * * |
| 88846 | | -** Synopsis: r[P2]=P1 |
| 88847 | | -** |
| 88848 | | -** Mark the beginning of a subroutine by loading the integer value P1 |
| 88849 | | -** into register r[P2]. The P2 register is used to store the return |
| 88850 | | -** address of the subroutine call. |
| 88851 | | -** |
| 88852 | | -** This opcode is identical to OP_Integer. It has a different name |
| 88853 | | -** only to make the byte code easier to read and verify. |
| 88854 | | -*/ |
| 88855 | 89317 | /* Opcode: Integer P1 P2 * * * |
| 88856 | 89318 | ** Synopsis: r[P2]=P1 |
| 88857 | 89319 | ** |
| 88858 | 89320 | ** The 32-bit integer value P1 is written into register P2. |
| 88859 | 89321 | */ |
| 88860 | | -case OP_BeginSubrtn: |
| 88861 | 89322 | case OP_Integer: { /* out2 */ |
| 88862 | 89323 | pOut = out2Prerelease(p, pOp); |
| 88863 | 89324 | pOut->u.i = pOp->p1; |
| 88864 | 89325 | break; |
| 88865 | 89326 | } |
| | @@ -88962,10 +89423,32 @@ |
| 88962 | 89423 | } |
| 88963 | 89424 | #endif |
| 88964 | 89425 | break; |
| 88965 | 89426 | } |
| 88966 | 89427 | |
| 89428 | +/* Opcode: BeginSubrtn * P2 * * * |
| 89429 | +** Synopsis: r[P2]=NULL |
| 89430 | +** |
| 89431 | +** Mark the beginning of a subroutine that can be entered in-line |
| 89432 | +** or that can be called using OP_Gosub. The subroutine should |
| 89433 | +** be terminated by an OP_Return instruction that has a P1 operand that |
| 89434 | +** is the same as the P2 operand to this opcode and that has P3 set to 1. |
| 89435 | +** If the subroutine is entered in-line, then the OP_Return will simply |
| 89436 | +** fall through. But if the subroutine is entered using OP_Gosub, then |
| 89437 | +** the OP_Return will jump back to the first instruction after the OP_Gosub. |
| 89438 | +** |
| 89439 | +** This routine works by loading a NULL into the P2 register. When the |
| 89440 | +** return address register contains a NULL, the OP_Return instruction is |
| 89441 | +** a no-op that simply falls through to the next instruction (assuming that |
| 89442 | +** the OP_Return opcode has a P3 value of 1). Thus if the subroutine is |
| 89443 | +** entered in-line, then the OP_Return will cause in-line execution to |
| 89444 | +** continue. But if the subroutine is entered via OP_Gosub, then the |
| 89445 | +** OP_Return will cause a return to the address following the OP_Gosub. |
| 89446 | +** |
| 89447 | +** This opcode is identical to OP_Null. It has a different name |
| 89448 | +** only to make the byte code easier to read and verify. |
| 89449 | +*/ |
| 88967 | 89450 | /* Opcode: Null P1 P2 P3 * * |
| 88968 | 89451 | ** Synopsis: r[P2..P3]=NULL |
| 88969 | 89452 | ** |
| 88970 | 89453 | ** Write a NULL into registers P2. If P3 greater than P2, then also write |
| 88971 | 89454 | ** NULL into register P3 and every register in between P2 and P3. If P3 |
| | @@ -88974,10 +89457,11 @@ |
| 88974 | 89457 | ** |
| 88975 | 89458 | ** If the P1 value is non-zero, then also set the MEM_Cleared flag so that |
| 88976 | 89459 | ** NULL values will not compare equal even if SQLITE_NULLEQ is set on |
| 88977 | 89460 | ** OP_Ne or OP_Eq. |
| 88978 | 89461 | */ |
| 89462 | +case OP_BeginSubrtn: |
| 88979 | 89463 | case OP_Null: { /* out2 */ |
| 88980 | 89464 | int cnt; |
| 88981 | 89465 | u16 nullFlag; |
| 88982 | 89466 | pOut = out2Prerelease(p, pOp); |
| 88983 | 89467 | cnt = pOp->p3-pOp->p2; |
| | @@ -89203,49 +89687,36 @@ |
| 89203 | 89687 | ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt |
| 89204 | 89688 | ** structure to provide access to the r(P1)..r(P1+P2-1) values as |
| 89205 | 89689 | ** the result row. |
| 89206 | 89690 | */ |
| 89207 | 89691 | case OP_ResultRow: { |
| 89208 | | - Mem *pMem; |
| 89209 | | - int i; |
| 89210 | 89692 | assert( p->nResColumn==pOp->p2 ); |
| 89211 | 89693 | assert( pOp->p1>0 || CORRUPT_DB ); |
| 89212 | 89694 | assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 ); |
| 89213 | 89695 | |
| 89214 | | - /* Invalidate all ephemeral cursor row caches */ |
| 89215 | 89696 | p->cacheCtr = (p->cacheCtr + 2)|1; |
| 89216 | | - |
| 89217 | | - /* Make sure the results of the current row are \000 terminated |
| 89218 | | - ** and have an assigned type. The results are de-ephemeralized as |
| 89219 | | - ** a side effect. |
| 89220 | | - */ |
| 89221 | | - pMem = p->pResultSet = &aMem[pOp->p1]; |
| 89222 | | - for(i=0; i<pOp->p2; i++){ |
| 89223 | | - assert( memIsValid(&pMem[i]) ); |
| 89224 | | - Deephemeralize(&pMem[i]); |
| 89225 | | - assert( (pMem[i].flags & MEM_Ephem)==0 |
| 89226 | | - || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 ); |
| 89227 | | - sqlite3VdbeMemNulTerminate(&pMem[i]); |
| 89228 | | - REGISTER_TRACE(pOp->p1+i, &pMem[i]); |
| 89697 | + p->pResultSet = &aMem[pOp->p1]; |
| 89229 | 89698 | #ifdef SQLITE_DEBUG |
| 89230 | | - /* The registers in the result will not be used again when the |
| 89231 | | - ** prepared statement restarts. This is because sqlite3_column() |
| 89232 | | - ** APIs might have caused type conversions of made other changes to |
| 89233 | | - ** the register values. Therefore, we can go ahead and break any |
| 89234 | | - ** OP_SCopy dependencies. */ |
| 89235 | | - pMem[i].pScopyFrom = 0; |
| 89699 | + { |
| 89700 | + Mem *pMem = p->pResultSet; |
| 89701 | + int i; |
| 89702 | + for(i=0; i<pOp->p2; i++){ |
| 89703 | + assert( memIsValid(&pMem[i]) ); |
| 89704 | + REGISTER_TRACE(pOp->p1+i, &pMem[i]); |
| 89705 | + /* The registers in the result will not be used again when the |
| 89706 | + ** prepared statement restarts. This is because sqlite3_column() |
| 89707 | + ** APIs might have caused type conversions of made other changes to |
| 89708 | + ** the register values. Therefore, we can go ahead and break any |
| 89709 | + ** OP_SCopy dependencies. */ |
| 89710 | + pMem[i].pScopyFrom = 0; |
| 89711 | + } |
| 89712 | + } |
| 89236 | 89713 | #endif |
| 89237 | | - } |
| 89238 | 89714 | if( db->mallocFailed ) goto no_mem; |
| 89239 | | - |
| 89240 | 89715 | if( db->mTrace & SQLITE_TRACE_ROW ){ |
| 89241 | 89716 | db->trace.xV2(SQLITE_TRACE_ROW, db->pTraceArg, p, 0); |
| 89242 | 89717 | } |
| 89243 | | - |
| 89244 | | - |
| 89245 | | - /* Return SQLITE_ROW |
| 89246 | | - */ |
| 89247 | 89718 | p->pc = (int)(pOp - aOp) + 1; |
| 89248 | 89719 | rc = SQLITE_ROW; |
| 89249 | 89720 | goto vdbe_return; |
| 89250 | 89721 | } |
| 89251 | 89722 | |
| | @@ -89755,27 +90226,27 @@ |
| 89755 | 90226 | flags3 = pIn3->flags; |
| 89756 | 90227 | if( (flags1 & flags3 & MEM_Int)!=0 ){ |
| 89757 | 90228 | assert( (pOp->p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_TEXT || CORRUPT_DB ); |
| 89758 | 90229 | /* Common case of comparison of two integers */ |
| 89759 | 90230 | if( pIn3->u.i > pIn1->u.i ){ |
| 89760 | | - iCompare = +1; |
| 89761 | 90231 | if( sqlite3aGTb[pOp->opcode] ){ |
| 89762 | 90232 | VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 89763 | 90233 | goto jump_to_p2; |
| 89764 | 90234 | } |
| 90235 | + iCompare = +1; |
| 89765 | 90236 | }else if( pIn3->u.i < pIn1->u.i ){ |
| 89766 | | - iCompare = -1; |
| 89767 | 90237 | if( sqlite3aLTb[pOp->opcode] ){ |
| 89768 | 90238 | VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 89769 | 90239 | goto jump_to_p2; |
| 89770 | 90240 | } |
| 90241 | + iCompare = -1; |
| 89771 | 90242 | }else{ |
| 89772 | | - iCompare = 0; |
| 89773 | 90243 | if( sqlite3aEQb[pOp->opcode] ){ |
| 89774 | 90244 | VdbeBranchTaken(1, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 89775 | 90245 | goto jump_to_p2; |
| 89776 | 90246 | } |
| 90247 | + iCompare = 0; |
| 89777 | 90248 | } |
| 89778 | 90249 | VdbeBranchTaken(0, (pOp->p5 & SQLITE_NULLEQ)?2:3); |
| 89779 | 90250 | break; |
| 89780 | 90251 | } |
| 89781 | 90252 | if( (flags1 | flags3)&MEM_Null ){ |
| | @@ -89798,15 +90269,15 @@ |
| 89798 | 90269 | }else{ |
| 89799 | 90270 | /* SQLITE_NULLEQ is clear and at least one operand is NULL, |
| 89800 | 90271 | ** then the result is always NULL. |
| 89801 | 90272 | ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. |
| 89802 | 90273 | */ |
| 89803 | | - iCompare = 1; /* Operands are not equal */ |
| 89804 | 90274 | VdbeBranchTaken(2,3); |
| 89805 | 90275 | if( pOp->p5 & SQLITE_JUMPIFNULL ){ |
| 89806 | 90276 | goto jump_to_p2; |
| 89807 | 90277 | } |
| 90278 | + iCompare = 1; /* Operands are not equal */ |
| 89808 | 90279 | break; |
| 89809 | 90280 | } |
| 89810 | 90281 | }else{ |
| 89811 | 90282 | /* Neither operand is NULL and we couldn't do the special high-speed |
| 89812 | 90283 | ** integer comparison case. So do a general-case comparison. */ |
| | @@ -89908,13 +90379,12 @@ |
| 89908 | 90379 | /* Opcode: Permutation * * * P4 * |
| 89909 | 90380 | ** |
| 89910 | 90381 | ** Set the permutation used by the OP_Compare operator in the next |
| 89911 | 90382 | ** instruction. The permutation is stored in the P4 operand. |
| 89912 | 90383 | ** |
| 89913 | | -** The permutation is only valid until the next OP_Compare that has |
| 89914 | | -** the OPFLAG_PERMUTE bit set in P5. Typically the OP_Permutation should |
| 89915 | | -** occur immediately prior to the OP_Compare. |
| 90384 | +** The permutation is only valid for the next opcode which must be |
| 90385 | +** an OP_Compare that has the OPFLAG_PERMUTE bit set in P5. |
| 89916 | 90386 | ** |
| 89917 | 90387 | ** The first integer in the P4 integer array is the length of the array |
| 89918 | 90388 | ** and does not become part of the permutation. |
| 89919 | 90389 | */ |
| 89920 | 90390 | case OP_Permutation: { |
| | @@ -89942,10 +90412,12 @@ |
| 89942 | 90412 | ** only. The KeyInfo elements are used sequentially. |
| 89943 | 90413 | ** |
| 89944 | 90414 | ** The comparison is a sort comparison, so NULLs compare equal, |
| 89945 | 90415 | ** NULLs are less than numbers, numbers are less than strings, |
| 89946 | 90416 | ** and strings are less than blobs. |
| 90417 | +** |
| 90418 | +** This opcode must be immediately followed by an OP_Jump opcode. |
| 89947 | 90419 | */ |
| 89948 | 90420 | case OP_Compare: { |
| 89949 | 90421 | int n; |
| 89950 | 90422 | int i; |
| 89951 | 90423 | int p1; |
| | @@ -90000,20 +90472,24 @@ |
| 90000 | 90472 | } |
| 90001 | 90473 | if( bRev ) iCompare = -iCompare; |
| 90002 | 90474 | break; |
| 90003 | 90475 | } |
| 90004 | 90476 | } |
| 90477 | + assert( pOp[1].opcode==OP_Jump ); |
| 90005 | 90478 | break; |
| 90006 | 90479 | } |
| 90007 | 90480 | |
| 90008 | 90481 | /* Opcode: Jump P1 P2 P3 * * |
| 90009 | 90482 | ** |
| 90010 | 90483 | ** Jump to the instruction at address P1, P2, or P3 depending on whether |
| 90011 | 90484 | ** in the most recent OP_Compare instruction the P1 vector was less than |
| 90012 | 90485 | ** equal to, or greater than the P2 vector, respectively. |
| 90486 | +** |
| 90487 | +** This opcode must immediately follow an OP_Compare opcode. |
| 90013 | 90488 | */ |
| 90014 | 90489 | case OP_Jump: { /* jump */ |
| 90490 | + assert( pOp>aOp && pOp[-1].opcode==OP_Compare ); |
| 90015 | 90491 | if( iCompare<0 ){ |
| 90016 | 90492 | VdbeBranchTaken(0,4); pOp = &aOp[pOp->p1 - 1]; |
| 90017 | 90493 | }else if( iCompare==0 ){ |
| 90018 | 90494 | VdbeBranchTaken(1,4); pOp = &aOp[pOp->p2 - 1]; |
| 90019 | 90495 | }else{ |
| | @@ -90314,11 +90790,11 @@ |
| 90314 | 90790 | break; |
| 90315 | 90791 | } |
| 90316 | 90792 | #endif /* SQLITE_ENABLE_OFFSET_SQL_FUNC */ |
| 90317 | 90793 | |
| 90318 | 90794 | /* Opcode: Column P1 P2 P3 P4 P5 |
| 90319 | | -** Synopsis: r[P3]=PX |
| 90795 | +** Synopsis: r[P3]=PX cursor P1 column P2 |
| 90320 | 90796 | ** |
| 90321 | 90797 | ** Interpret the data that cursor P1 points to as a structure built using |
| 90322 | 90798 | ** the MakeRecord instruction. (See the MakeRecord opcode for additional |
| 90323 | 90799 | ** information about the format of the data.) Extract the P2-th column |
| 90324 | 90800 | ** from this record. If there are less that (P2+1) |
| | @@ -90356,23 +90832,23 @@ |
| 90356 | 90832 | pC = p->apCsr[pOp->p1]; |
| 90357 | 90833 | p2 = (u32)pOp->p2; |
| 90358 | 90834 | |
| 90359 | 90835 | op_column_restart: |
| 90360 | 90836 | assert( pC!=0 ); |
| 90361 | | - assert( p2<(u32)pC->nField ); |
| 90837 | + assert( p2<(u32)pC->nField |
| 90838 | + || (pC->eCurType==CURTYPE_PSEUDO && pC->seekResult==0) ); |
| 90362 | 90839 | aOffset = pC->aOffset; |
| 90363 | 90840 | assert( aOffset==pC->aType+pC->nField ); |
| 90364 | 90841 | assert( pC->eCurType!=CURTYPE_VTAB ); |
| 90365 | 90842 | assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow ); |
| 90366 | 90843 | assert( pC->eCurType!=CURTYPE_SORTER ); |
| 90367 | 90844 | |
| 90368 | 90845 | if( pC->cacheStatus!=p->cacheCtr ){ /*OPTIMIZATION-IF-FALSE*/ |
| 90369 | 90846 | if( pC->nullRow ){ |
| 90370 | | - if( pC->eCurType==CURTYPE_PSEUDO ){ |
| 90847 | + if( pC->eCurType==CURTYPE_PSEUDO && pC->seekResult>0 ){ |
| 90371 | 90848 | /* For the special case of as pseudo-cursor, the seekResult field |
| 90372 | 90849 | ** identifies the register that holds the record */ |
| 90373 | | - assert( pC->seekResult>0 ); |
| 90374 | 90850 | pReg = &aMem[pC->seekResult]; |
| 90375 | 90851 | assert( pReg->flags & MEM_Blob ); |
| 90376 | 90852 | assert( memIsValid(pReg) ); |
| 90377 | 90853 | pC->payloadSize = pC->szRow = pReg->n; |
| 90378 | 90854 | pC->aRow = (u8*)pReg->z; |
| | @@ -90406,11 +90882,15 @@ |
| 90406 | 90882 | pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &pC->szRow); |
| 90407 | 90883 | assert( pC->szRow<=pC->payloadSize ); |
| 90408 | 90884 | assert( pC->szRow<=65536 ); /* Maximum page size is 64KiB */ |
| 90409 | 90885 | } |
| 90410 | 90886 | pC->cacheStatus = p->cacheCtr; |
| 90411 | | - pC->iHdrOffset = getVarint32(pC->aRow, aOffset[0]); |
| 90887 | + if( (aOffset[0] = pC->aRow[0])<0x80 ){ |
| 90888 | + pC->iHdrOffset = 1; |
| 90889 | + }else{ |
| 90890 | + pC->iHdrOffset = sqlite3GetVarint32(pC->aRow, aOffset); |
| 90891 | + } |
| 90412 | 90892 | pC->nHdrParsed = 0; |
| 90413 | 90893 | |
| 90414 | 90894 | if( pC->szRow<aOffset[0] ){ /*OPTIMIZATION-IF-FALSE*/ |
| 90415 | 90895 | /* pC->aRow does not have to hold the entire row, but it does at least |
| 90416 | 90896 | ** need to cover the header of the record. If pC->aRow does not contain |
| | @@ -91041,22 +91521,64 @@ |
| 91041 | 91521 | UPDATE_MAX_BLOBSIZE(pOut); |
| 91042 | 91522 | zHdr = (u8 *)pOut->z; |
| 91043 | 91523 | zPayload = zHdr + nHdr; |
| 91044 | 91524 | |
| 91045 | 91525 | /* Write the record */ |
| 91046 | | - zHdr += putVarint32(zHdr, nHdr); |
| 91526 | + if( nHdr<0x80 ){ |
| 91527 | + *(zHdr++) = nHdr; |
| 91528 | + }else{ |
| 91529 | + zHdr += sqlite3PutVarint(zHdr,nHdr); |
| 91530 | + } |
| 91047 | 91531 | assert( pData0<=pLast ); |
| 91048 | 91532 | pRec = pData0; |
| 91049 | | - do{ |
| 91533 | + while( 1 /*exit-by-break*/ ){ |
| 91050 | 91534 | serial_type = pRec->uTemp; |
| 91051 | 91535 | /* EVIDENCE-OF: R-06529-47362 Following the size varint are one or more |
| 91052 | | - ** additional varints, one per column. */ |
| 91053 | | - zHdr += putVarint32(zHdr, serial_type); /* serial type */ |
| 91054 | | - /* EVIDENCE-OF: R-64536-51728 The values for each column in the record |
| 91536 | + ** additional varints, one per column. |
| 91537 | + ** EVIDENCE-OF: R-64536-51728 The values for each column in the record |
| 91055 | 91538 | ** immediately follow the header. */ |
| 91056 | | - zPayload += sqlite3VdbeSerialPut(zPayload, pRec, serial_type); /* content */ |
| 91057 | | - }while( (++pRec)<=pLast ); |
| 91539 | + if( serial_type<=7 ){ |
| 91540 | + *(zHdr++) = serial_type; |
| 91541 | + if( serial_type==0 ){ |
| 91542 | + /* NULL value. No change in zPayload */ |
| 91543 | + }else{ |
| 91544 | + u64 v; |
| 91545 | + u32 i; |
| 91546 | + if( serial_type==7 ){ |
| 91547 | + assert( sizeof(v)==sizeof(pRec->u.r) ); |
| 91548 | + memcpy(&v, &pRec->u.r, sizeof(v)); |
| 91549 | + swapMixedEndianFloat(v); |
| 91550 | + }else{ |
| 91551 | + v = pRec->u.i; |
| 91552 | + } |
| 91553 | + len = i = sqlite3SmallTypeSizes[serial_type]; |
| 91554 | + assert( i>0 ); |
| 91555 | + while( 1 /*exit-by-break*/ ){ |
| 91556 | + zPayload[--i] = (u8)(v&0xFF); |
| 91557 | + if( i==0 ) break; |
| 91558 | + v >>= 8; |
| 91559 | + } |
| 91560 | + zPayload += len; |
| 91561 | + } |
| 91562 | + }else if( serial_type<0x80 ){ |
| 91563 | + *(zHdr++) = serial_type; |
| 91564 | + if( serial_type>=14 && pRec->n>0 ){ |
| 91565 | + assert( pRec->z!=0 ); |
| 91566 | + memcpy(zPayload, pRec->z, pRec->n); |
| 91567 | + zPayload += pRec->n; |
| 91568 | + } |
| 91569 | + }else{ |
| 91570 | + zHdr += sqlite3PutVarint(zHdr, serial_type); |
| 91571 | + if( pRec->n ){ |
| 91572 | + assert( pRec->z!=0 ); |
| 91573 | + memcpy(zPayload, pRec->z, pRec->n); |
| 91574 | + zPayload += pRec->n; |
| 91575 | + } |
| 91576 | + } |
| 91577 | + if( pRec==pLast ) break; |
| 91578 | + pRec++; |
| 91579 | + } |
| 91058 | 91580 | assert( nHdr==(int)(zHdr - (u8*)pOut->z) ); |
| 91059 | 91581 | assert( nByte==(int)(zPayload - (u8*)pOut->z) ); |
| 91060 | 91582 | |
| 91061 | 91583 | assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); |
| 91062 | 91584 | REGISTER_TRACE(pOp->p3, pOut); |
| | @@ -91271,11 +91793,14 @@ |
| 91271 | 91793 | if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 91272 | 91794 | } |
| 91273 | 91795 | } |
| 91274 | 91796 | } |
| 91275 | 91797 | if( rc ) goto abort_due_to_error; |
| 91276 | | - |
| 91798 | + if( p->eVdbeState==VDBE_HALT_STATE ){ |
| 91799 | + rc = SQLITE_DONE; |
| 91800 | + goto vdbe_return; |
| 91801 | + } |
| 91277 | 91802 | break; |
| 91278 | 91803 | } |
| 91279 | 91804 | |
| 91280 | 91805 | /* Opcode: AutoCommit P1 P2 * * * |
| 91281 | 91806 | ** |
| | @@ -91375,10 +91900,11 @@ |
| 91375 | 91900 | ** halts. The sqlite3_step() wrapper function might then reprepare the |
| 91376 | 91901 | ** statement and rerun it from the beginning. |
| 91377 | 91902 | */ |
| 91378 | 91903 | case OP_Transaction: { |
| 91379 | 91904 | Btree *pBt; |
| 91905 | + Db *pDb; |
| 91380 | 91906 | int iMeta = 0; |
| 91381 | 91907 | |
| 91382 | 91908 | assert( p->bIsReader ); |
| 91383 | 91909 | assert( p->readOnly==0 || pOp->p2==0 ); |
| 91384 | 91910 | assert( pOp->p2>=0 && pOp->p2<=2 ); |
| | @@ -91394,11 +91920,12 @@ |
| 91394 | 91920 | ** transaction */ |
| 91395 | 91921 | rc = SQLITE_CORRUPT; |
| 91396 | 91922 | } |
| 91397 | 91923 | goto abort_due_to_error; |
| 91398 | 91924 | } |
| 91399 | | - pBt = db->aDb[pOp->p1].pBt; |
| 91925 | + pDb = &db->aDb[pOp->p1]; |
| 91926 | + pBt = pDb->pBt; |
| 91400 | 91927 | |
| 91401 | 91928 | if( pBt ){ |
| 91402 | 91929 | rc = sqlite3BtreeBeginTrans(pBt, pOp->p2, &iMeta); |
| 91403 | 91930 | testcase( rc==SQLITE_BUSY_SNAPSHOT ); |
| 91404 | 91931 | testcase( rc==SQLITE_BUSY_RECOVERY ); |
| | @@ -91435,12 +91962,11 @@ |
| 91435 | 91962 | } |
| 91436 | 91963 | } |
| 91437 | 91964 | assert( pOp->p5==0 || pOp->p4type==P4_INT32 ); |
| 91438 | 91965 | if( rc==SQLITE_OK |
| 91439 | 91966 | && pOp->p5 |
| 91440 | | - && (iMeta!=pOp->p3 |
| 91441 | | - || db->aDb[pOp->p1].pSchema->iGeneration!=pOp->p4.i) |
| 91967 | + && (iMeta!=pOp->p3 || pDb->pSchema->iGeneration!=pOp->p4.i) |
| 91442 | 91968 | ){ |
| 91443 | 91969 | /* |
| 91444 | 91970 | ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema |
| 91445 | 91971 | ** version is checked to ensure that the schema has not changed since the |
| 91446 | 91972 | ** SQL statement was prepared. |
| | @@ -92579,15 +93105,12 @@ |
| 92579 | 93105 | } |
| 92580 | 93106 | case OP_NoConflict: /* jump, in3 */ |
| 92581 | 93107 | case OP_NotFound: /* jump, in3 */ |
| 92582 | 93108 | case OP_Found: { /* jump, in3 */ |
| 92583 | 93109 | int alreadyExists; |
| 92584 | | - int takeJump; |
| 92585 | 93110 | int ii; |
| 92586 | 93111 | VdbeCursor *pC; |
| 92587 | | - int res; |
| 92588 | | - UnpackedRecord *pFree; |
| 92589 | 93112 | UnpackedRecord *pIdxKey; |
| 92590 | 93113 | UnpackedRecord r; |
| 92591 | 93114 | |
| 92592 | 93115 | #ifdef SQLITE_TEST |
| 92593 | 93116 | if( pOp->opcode!=OP_NoConflict ) sqlite3_found_count++; |
| | @@ -92598,66 +93121,71 @@ |
| 92598 | 93121 | pC = p->apCsr[pOp->p1]; |
| 92599 | 93122 | assert( pC!=0 ); |
| 92600 | 93123 | #ifdef SQLITE_DEBUG |
| 92601 | 93124 | pC->seekOp = pOp->opcode; |
| 92602 | 93125 | #endif |
| 92603 | | - pIn3 = &aMem[pOp->p3]; |
| 93126 | + r.aMem = &aMem[pOp->p3]; |
| 92604 | 93127 | assert( pC->eCurType==CURTYPE_BTREE ); |
| 92605 | 93128 | assert( pC->uc.pCursor!=0 ); |
| 92606 | 93129 | assert( pC->isTable==0 ); |
| 92607 | | - if( pOp->p4.i>0 ){ |
| 93130 | + r.nField = (u16)pOp->p4.i; |
| 93131 | + if( r.nField>0 ){ |
| 93132 | + /* Key values in an array of registers */ |
| 92608 | 93133 | r.pKeyInfo = pC->pKeyInfo; |
| 92609 | | - r.nField = (u16)pOp->p4.i; |
| 92610 | | - r.aMem = pIn3; |
| 93134 | + r.default_rc = 0; |
| 92611 | 93135 | #ifdef SQLITE_DEBUG |
| 92612 | 93136 | for(ii=0; ii<r.nField; ii++){ |
| 92613 | 93137 | assert( memIsValid(&r.aMem[ii]) ); |
| 92614 | 93138 | assert( (r.aMem[ii].flags & MEM_Zero)==0 || r.aMem[ii].n==0 ); |
| 92615 | 93139 | if( ii ) REGISTER_TRACE(pOp->p3+ii, &r.aMem[ii]); |
| 92616 | 93140 | } |
| 92617 | 93141 | #endif |
| 92618 | | - pIdxKey = &r; |
| 92619 | | - pFree = 0; |
| 93142 | + rc = sqlite3BtreeIndexMoveto(pC->uc.pCursor, &r, &pC->seekResult); |
| 92620 | 93143 | }else{ |
| 92621 | | - assert( pIn3->flags & MEM_Blob ); |
| 92622 | | - rc = ExpandBlob(pIn3); |
| 93144 | + /* Composite key generated by OP_MakeRecord */ |
| 93145 | + assert( r.aMem->flags & MEM_Blob ); |
| 93146 | + assert( pOp->opcode!=OP_NoConflict ); |
| 93147 | + rc = ExpandBlob(r.aMem); |
| 92623 | 93148 | assert( rc==SQLITE_OK || rc==SQLITE_NOMEM ); |
| 92624 | 93149 | if( rc ) goto no_mem; |
| 92625 | | - pFree = pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo); |
| 93150 | + pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo); |
| 92626 | 93151 | if( pIdxKey==0 ) goto no_mem; |
| 92627 | | - sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey); |
| 92628 | | - } |
| 92629 | | - pIdxKey->default_rc = 0; |
| 92630 | | - takeJump = 0; |
| 92631 | | - if( pOp->opcode==OP_NoConflict ){ |
| 92632 | | - /* For the OP_NoConflict opcode, take the jump if any of the |
| 92633 | | - ** input fields are NULL, since any key with a NULL will not |
| 92634 | | - ** conflict */ |
| 92635 | | - for(ii=0; ii<pIdxKey->nField; ii++){ |
| 92636 | | - if( pIdxKey->aMem[ii].flags & MEM_Null ){ |
| 92637 | | - takeJump = 1; |
| 92638 | | - break; |
| 92639 | | - } |
| 92640 | | - } |
| 92641 | | - } |
| 92642 | | - rc = sqlite3BtreeIndexMoveto(pC->uc.pCursor, pIdxKey, &res); |
| 92643 | | - if( pFree ) sqlite3DbFreeNN(db, pFree); |
| 93152 | + sqlite3VdbeRecordUnpack(pC->pKeyInfo, r.aMem->n, r.aMem->z, pIdxKey); |
| 93153 | + pIdxKey->default_rc = 0; |
| 93154 | + rc = sqlite3BtreeIndexMoveto(pC->uc.pCursor, pIdxKey, &pC->seekResult); |
| 93155 | + sqlite3DbFreeNN(db, pIdxKey); |
| 93156 | + } |
| 92644 | 93157 | if( rc!=SQLITE_OK ){ |
| 92645 | 93158 | goto abort_due_to_error; |
| 92646 | 93159 | } |
| 92647 | | - pC->seekResult = res; |
| 92648 | | - alreadyExists = (res==0); |
| 93160 | + alreadyExists = (pC->seekResult==0); |
| 92649 | 93161 | pC->nullRow = 1-alreadyExists; |
| 92650 | 93162 | pC->deferredMoveto = 0; |
| 92651 | 93163 | pC->cacheStatus = CACHE_STALE; |
| 92652 | 93164 | if( pOp->opcode==OP_Found ){ |
| 92653 | 93165 | VdbeBranchTaken(alreadyExists!=0,2); |
| 92654 | 93166 | if( alreadyExists ) goto jump_to_p2; |
| 92655 | 93167 | }else{ |
| 92656 | | - VdbeBranchTaken(takeJump||alreadyExists==0,2); |
| 92657 | | - if( takeJump || !alreadyExists ) goto jump_to_p2; |
| 92658 | | - if( pOp->opcode==OP_IfNoHope ) pC->seekHit = pOp->p4.i; |
| 93168 | + if( !alreadyExists ){ |
| 93169 | + VdbeBranchTaken(1,2); |
| 93170 | + goto jump_to_p2; |
| 93171 | + } |
| 93172 | + if( pOp->opcode==OP_NoConflict ){ |
| 93173 | + /* For the OP_NoConflict opcode, take the jump if any of the |
| 93174 | + ** input fields are NULL, since any key with a NULL will not |
| 93175 | + ** conflict */ |
| 93176 | + for(ii=0; ii<r.nField; ii++){ |
| 93177 | + if( r.aMem[ii].flags & MEM_Null ){ |
| 93178 | + VdbeBranchTaken(1,2); |
| 93179 | + goto jump_to_p2; |
| 93180 | + } |
| 93181 | + } |
| 93182 | + } |
| 93183 | + VdbeBranchTaken(0,2); |
| 93184 | + if( pOp->opcode==OP_IfNoHope ){ |
| 93185 | + pC->seekHit = pOp->p4.i; |
| 93186 | + } |
| 92659 | 93187 | } |
| 92660 | 93188 | break; |
| 92661 | 93189 | } |
| 92662 | 93190 | |
| 92663 | 93191 | /* Opcode: SeekRowid P1 P2 P3 * * |
| | @@ -93344,11 +93872,11 @@ |
| 93344 | 93872 | REGISTER_TRACE(pOp->p2, pOut); |
| 93345 | 93873 | break; |
| 93346 | 93874 | } |
| 93347 | 93875 | |
| 93348 | 93876 | /* Opcode: Rowid P1 P2 * * * |
| 93349 | | -** Synopsis: r[P2]=rowid |
| 93877 | +** Synopsis: r[P2]=PX rowid of P1 |
| 93350 | 93878 | ** |
| 93351 | 93879 | ** Store in register P2 an integer which is the key of the table entry that |
| 93352 | 93880 | ** P1 is currently point to. |
| 93353 | 93881 | ** |
| 93354 | 93882 | ** P1 can be either an ordinary table or a virtual table. There used to |
| | @@ -93400,20 +93928,27 @@ |
| 93400 | 93928 | ** |
| 93401 | 93929 | ** Move the cursor P1 to a null row. Any OP_Column operations |
| 93402 | 93930 | ** that occur while the cursor is on the null row will always |
| 93403 | 93931 | ** write a NULL. |
| 93404 | 93932 | ** |
| 93405 | | -** Or, if P1 is a Pseudo-Cursor (a cursor opened using OP_OpenPseudo) |
| 93406 | | -** just reset the cache for that cursor. This causes the row of |
| 93407 | | -** content held by the pseudo-cursor to be reparsed. |
| 93933 | +** If cursor P1 is not previously opened, open it now to a special |
| 93934 | +** pseudo-cursor that always returns NULL for every column. |
| 93408 | 93935 | */ |
| 93409 | 93936 | case OP_NullRow: { |
| 93410 | 93937 | VdbeCursor *pC; |
| 93411 | 93938 | |
| 93412 | 93939 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 93413 | 93940 | pC = p->apCsr[pOp->p1]; |
| 93414 | | - assert( pC!=0 ); |
| 93941 | + if( pC==0 ){ |
| 93942 | + /* If the cursor is not already open, create a special kind of |
| 93943 | + ** pseudo-cursor that always gives null rows. */ |
| 93944 | + pC = allocateCursor(p, pOp->p1, 1, CURTYPE_PSEUDO); |
| 93945 | + if( pC==0 ) goto no_mem; |
| 93946 | + pC->seekResult = 0; |
| 93947 | + pC->isTable = 1; |
| 93948 | + pC->uc.pCursor = sqlite3BtreeFakeValidCursor(); |
| 93949 | + } |
| 93415 | 93950 | pC->nullRow = 1; |
| 93416 | 93951 | pC->cacheStatus = CACHE_STALE; |
| 93417 | 93952 | if( pC->eCurType==CURTYPE_BTREE ){ |
| 93418 | 93953 | assert( pC->uc.pCursor!=0 ); |
| 93419 | 93954 | sqlite3BtreeClearCursor(pC->uc.pCursor); |
| | @@ -93856,13 +94391,13 @@ |
| 93856 | 94391 | i64 rowid; /* Rowid that P1 current points to */ |
| 93857 | 94392 | |
| 93858 | 94393 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 93859 | 94394 | pC = p->apCsr[pOp->p1]; |
| 93860 | 94395 | assert( pC!=0 ); |
| 93861 | | - assert( pC->eCurType==CURTYPE_BTREE ); |
| 94396 | + assert( pC->eCurType==CURTYPE_BTREE || IsNullCursor(pC) ); |
| 93862 | 94397 | assert( pC->uc.pCursor!=0 ); |
| 93863 | | - assert( pC->isTable==0 ); |
| 94398 | + assert( pC->isTable==0 || IsNullCursor(pC) ); |
| 93864 | 94399 | assert( pC->deferredMoveto==0 ); |
| 93865 | 94400 | assert( !pC->nullRow || pOp->opcode==OP_IdxRowid ); |
| 93866 | 94401 | |
| 93867 | 94402 | /* The IdxRowid and Seek opcodes are combined because of the commonality |
| 93868 | 94403 | ** of sqlite3VdbeCursorRestore() and sqlite3VdbeIdxRowid(). */ |
| | @@ -95994,11 +96529,11 @@ |
| 95994 | 96529 | /* OP_Init is always instruction 0 */ |
| 95995 | 96530 | assert( pOp==p->aOp || pOp->opcode==OP_Trace ); |
| 95996 | 96531 | |
| 95997 | 96532 | #ifndef SQLITE_OMIT_TRACE |
| 95998 | 96533 | if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 |
| 95999 | | - && !p->doingRerun |
| 96534 | + && p->minWriteFileFormat!=254 /* tag-20220401a */ |
| 96000 | 96535 | && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 |
| 96001 | 96536 | ){ |
| 96002 | 96537 | #ifndef SQLITE_OMIT_DEPRECATED |
| 96003 | 96538 | if( db->mTrace & SQLITE_TRACE_LEGACY ){ |
| 96004 | 96539 | char *z = sqlite3VdbeExpandSql(p, zTrace); |
| | @@ -96223,11 +96758,11 @@ |
| 96223 | 96758 | p->rc = rc; |
| 96224 | 96759 | sqlite3SystemError(db, rc); |
| 96225 | 96760 | testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 96226 | 96761 | sqlite3_log(rc, "statement aborts at %d: [%s] %s", |
| 96227 | 96762 | (int)(pOp - aOp), p->zSql, p->zErrMsg); |
| 96228 | | - sqlite3VdbeHalt(p); |
| 96763 | + if( p->eVdbeState==VDBE_RUN_STATE ) sqlite3VdbeHalt(p); |
| 96229 | 96764 | if( rc==SQLITE_IOERR_NOMEM ) sqlite3OomFault(db); |
| 96230 | 96765 | if( rc==SQLITE_CORRUPT && db->autoCommit==0 ){ |
| 96231 | 96766 | db->flags |= SQLITE_CorruptRdOnly; |
| 96232 | 96767 | } |
| 96233 | 96768 | rc = SQLITE_ERROR; |
| | @@ -100815,27 +101350,10 @@ |
| 100815 | 101350 | } |
| 100816 | 101351 | sqlite3DbFree(db, pDup); |
| 100817 | 101352 | } |
| 100818 | 101353 | } |
| 100819 | 101354 | |
| 100820 | | - |
| 100821 | | -/* |
| 100822 | | -** Return TRUE if the name zCol occurs anywhere in the USING clause. |
| 100823 | | -** |
| 100824 | | -** Return FALSE if the USING clause is NULL or if it does not contain |
| 100825 | | -** zCol. |
| 100826 | | -*/ |
| 100827 | | -static int nameInUsingClause(IdList *pUsing, const char *zCol){ |
| 100828 | | - if( pUsing ){ |
| 100829 | | - int k; |
| 100830 | | - for(k=0; k<pUsing->nId; k++){ |
| 100831 | | - if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ) return 1; |
| 100832 | | - } |
| 100833 | | - } |
| 100834 | | - return 0; |
| 100835 | | -} |
| 100836 | | - |
| 100837 | 101355 | /* |
| 100838 | 101356 | ** Subqueries stores the original database, table and column names for their |
| 100839 | 101357 | ** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN". |
| 100840 | 101358 | ** Check to see if the zSpan given to this routine matches the zDb, zTab, |
| 100841 | 101359 | ** and zCol. If any of zDb, zTab, and zCol are NULL then those fields will |
| | @@ -100907,10 +101425,33 @@ |
| 100907 | 101425 | testcase( n==BMS ); |
| 100908 | 101426 | if( n>=BMS ) n = BMS-1; |
| 100909 | 101427 | return ((Bitmask)1)<<n; |
| 100910 | 101428 | } |
| 100911 | 101429 | } |
| 101430 | + |
| 101431 | +/* |
| 101432 | +** Create a new expression term for the column specified by pMatch and |
| 101433 | +** iColumn. Append this new expression term to the FULL JOIN Match set |
| 101434 | +** in *ppList. Create a new *ppList if this is the first term in the |
| 101435 | +** set. |
| 101436 | +*/ |
| 101437 | +static void extendFJMatch( |
| 101438 | + Parse *pParse, /* Parsing context */ |
| 101439 | + ExprList **ppList, /* ExprList to extend */ |
| 101440 | + SrcItem *pMatch, /* Source table containing the column */ |
| 101441 | + i16 iColumn /* The column number */ |
| 101442 | +){ |
| 101443 | + Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLUMN, 0, 0); |
| 101444 | + if( pNew ){ |
| 101445 | + pNew->iTable = pMatch->iCursor; |
| 101446 | + pNew->iColumn = iColumn; |
| 101447 | + pNew->y.pTab = pMatch->pTab; |
| 101448 | + assert( (pMatch->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 ); |
| 101449 | + ExprSetProperty(pNew, EP_CanBeNull); |
| 101450 | + *ppList = sqlite3ExprListAppend(pParse, *ppList, pNew); |
| 101451 | + } |
| 101452 | +} |
| 100912 | 101453 | |
| 100913 | 101454 | /* |
| 100914 | 101455 | ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up |
| 100915 | 101456 | ** that name in the set of source tables in pSrcList and make the pExpr |
| 100916 | 101457 | ** expression node refer back to that source column. The following changes |
| | @@ -100953,15 +101494,17 @@ |
| 100953 | 101494 | SrcItem *pItem; /* Use for looping over pSrcList items */ |
| 100954 | 101495 | SrcItem *pMatch = 0; /* The matching pSrcList item */ |
| 100955 | 101496 | NameContext *pTopNC = pNC; /* First namecontext in the list */ |
| 100956 | 101497 | Schema *pSchema = 0; /* Schema of the expression */ |
| 100957 | 101498 | int eNewExprOp = TK_COLUMN; /* New value for pExpr->op on success */ |
| 100958 | | - Table *pTab = 0; /* Table hold the row */ |
| 101499 | + Table *pTab = 0; /* Table holding the row */ |
| 100959 | 101500 | Column *pCol; /* A column of pTab */ |
| 101501 | + ExprList *pFJMatch = 0; /* Matches for FULL JOIN .. USING */ |
| 100960 | 101502 | |
| 100961 | 101503 | assert( pNC ); /* the name context cannot be NULL. */ |
| 100962 | 101504 | assert( zCol ); /* The Z in X.Y.Z cannot be NULL */ |
| 101505 | + assert( zDb==0 || zTab!=0 ); |
| 100963 | 101506 | assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); |
| 100964 | 101507 | |
| 100965 | 101508 | /* Initialize the node to no-match */ |
| 100966 | 101509 | pExpr->iTable = -1; |
| 100967 | 101510 | ExprSetVVAProperty(pExpr, EP_NoReduce); |
| | @@ -101006,30 +101549,68 @@ |
| 101006 | 101549 | for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){ |
| 101007 | 101550 | u8 hCol; |
| 101008 | 101551 | pTab = pItem->pTab; |
| 101009 | 101552 | assert( pTab!=0 && pTab->zName!=0 ); |
| 101010 | 101553 | assert( pTab->nCol>0 || pParse->nErr ); |
| 101011 | | - if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){ |
| 101554 | + assert( pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) ); |
| 101555 | + if( pItem->fg.isNestedFrom ){ |
| 101556 | + /* In this case, pItem is a subquery that has been formed from a |
| 101557 | + ** parenthesized subset of the FROM clause terms. Example: |
| 101558 | + ** .... FROM t1 LEFT JOIN (t2 RIGHT JOIN t3 USING(x)) USING(y) ... |
| 101559 | + ** \_________________________/ |
| 101560 | + ** This pItem -------------^ |
| 101561 | + */ |
| 101012 | 101562 | int hit = 0; |
| 101563 | + assert( pItem->pSelect!=0 ); |
| 101013 | 101564 | pEList = pItem->pSelect->pEList; |
| 101565 | + assert( pEList!=0 ); |
| 101566 | + assert( pEList->nExpr==pTab->nCol ); |
| 101014 | 101567 | for(j=0; j<pEList->nExpr; j++){ |
| 101015 | | - if( sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){ |
| 101016 | | - cnt++; |
| 101017 | | - cntTab = 2; |
| 101018 | | - pMatch = pItem; |
| 101019 | | - pExpr->iColumn = j; |
| 101020 | | - hit = 1; |
| 101568 | + if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){ |
| 101569 | + continue; |
| 101021 | 101570 | } |
| 101571 | + if( cnt>0 ){ |
| 101572 | + if( pItem->fg.isUsing==0 |
| 101573 | + || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 |
| 101574 | + ){ |
| 101575 | + /* Two or more tables have the same column name which is |
| 101576 | + ** not joined by USING. This is an error. Signal as much |
| 101577 | + ** by clearing pFJMatch and letting cnt go above 1. */ |
| 101578 | + sqlite3ExprListDelete(db, pFJMatch); |
| 101579 | + pFJMatch = 0; |
| 101580 | + }else |
| 101581 | + if( (pItem->fg.jointype & JT_RIGHT)==0 ){ |
| 101582 | + /* An INNER or LEFT JOIN. Use the left-most table */ |
| 101583 | + continue; |
| 101584 | + }else |
| 101585 | + if( (pItem->fg.jointype & JT_LEFT)==0 ){ |
| 101586 | + /* A RIGHT JOIN. Use the right-most table */ |
| 101587 | + cnt = 0; |
| 101588 | + sqlite3ExprListDelete(db, pFJMatch); |
| 101589 | + pFJMatch = 0; |
| 101590 | + }else{ |
| 101591 | + /* For a FULL JOIN, we must construct a coalesce() func */ |
| 101592 | + extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); |
| 101593 | + } |
| 101594 | + } |
| 101595 | + cnt++; |
| 101596 | + cntTab = 2; |
| 101597 | + pMatch = pItem; |
| 101598 | + pExpr->iColumn = j; |
| 101599 | + pEList->a[j].bUsed = 1; |
| 101600 | + hit = 1; |
| 101022 | 101601 | } |
| 101023 | 101602 | if( hit || zTab==0 ) continue; |
| 101024 | 101603 | } |
| 101025 | | - if( zDb ){ |
| 101026 | | - if( pTab->pSchema!=pSchema ) continue; |
| 101027 | | - if( pSchema==0 && strcmp(zDb,"*")!=0 ) continue; |
| 101028 | | - } |
| 101604 | + assert( zDb==0 || zTab!=0 ); |
| 101029 | 101605 | if( zTab ){ |
| 101030 | | - const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName; |
| 101606 | + const char *zTabName; |
| 101607 | + if( zDb ){ |
| 101608 | + if( pTab->pSchema!=pSchema ) continue; |
| 101609 | + if( pSchema==0 && strcmp(zDb,"*")!=0 ) continue; |
| 101610 | + } |
| 101611 | + zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName; |
| 101031 | 101612 | assert( zTabName!=0 ); |
| 101032 | 101613 | if( sqlite3StrICmp(zTabName, zTab)!=0 ){ |
| 101033 | 101614 | continue; |
| 101034 | 101615 | } |
| 101035 | 101616 | assert( ExprUseYTab(pExpr) ); |
| | @@ -101040,22 +101621,41 @@ |
| 101040 | 101621 | hCol = sqlite3StrIHash(zCol); |
| 101041 | 101622 | for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){ |
| 101042 | 101623 | if( pCol->hName==hCol |
| 101043 | 101624 | && sqlite3StrICmp(pCol->zCnName, zCol)==0 |
| 101044 | 101625 | ){ |
| 101045 | | - /* If there has been exactly one prior match and this match |
| 101046 | | - ** is for the right-hand table of a NATURAL JOIN or is in a |
| 101047 | | - ** USING clause, then skip this match. |
| 101048 | | - */ |
| 101049 | | - if( cnt==1 ){ |
| 101050 | | - if( pItem->fg.jointype & JT_NATURAL ) continue; |
| 101051 | | - if( nameInUsingClause(pItem->pUsing, zCol) ) continue; |
| 101626 | + if( cnt>0 ){ |
| 101627 | + if( pItem->fg.isUsing==0 |
| 101628 | + || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 |
| 101629 | + ){ |
| 101630 | + /* Two or more tables have the same column name which is |
| 101631 | + ** not joined by USING. This is an error. Signal as much |
| 101632 | + ** by clearing pFJMatch and letting cnt go above 1. */ |
| 101633 | + sqlite3ExprListDelete(db, pFJMatch); |
| 101634 | + pFJMatch = 0; |
| 101635 | + }else |
| 101636 | + if( (pItem->fg.jointype & JT_RIGHT)==0 ){ |
| 101637 | + /* An INNER or LEFT JOIN. Use the left-most table */ |
| 101638 | + continue; |
| 101639 | + }else |
| 101640 | + if( (pItem->fg.jointype & JT_LEFT)==0 ){ |
| 101641 | + /* A RIGHT JOIN. Use the right-most table */ |
| 101642 | + cnt = 0; |
| 101643 | + sqlite3ExprListDelete(db, pFJMatch); |
| 101644 | + pFJMatch = 0; |
| 101645 | + }else{ |
| 101646 | + /* For a FULL JOIN, we must construct a coalesce() func */ |
| 101647 | + extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); |
| 101648 | + } |
| 101052 | 101649 | } |
| 101053 | 101650 | cnt++; |
| 101054 | 101651 | pMatch = pItem; |
| 101055 | 101652 | /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ |
| 101056 | 101653 | pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j; |
| 101654 | + if( pItem->fg.isNestedFrom ){ |
| 101655 | + sqlite3SrcItemColumnUsed(pItem, j); |
| 101656 | + } |
| 101057 | 101657 | break; |
| 101058 | 101658 | } |
| 101059 | 101659 | } |
| 101060 | 101660 | if( 0==cnt && VisibleRowid(pTab) ){ |
| 101061 | 101661 | cntTab++; |
| | @@ -101064,13 +101664,11 @@ |
| 101064 | 101664 | } |
| 101065 | 101665 | if( pMatch ){ |
| 101066 | 101666 | pExpr->iTable = pMatch->iCursor; |
| 101067 | 101667 | assert( ExprUseYTab(pExpr) ); |
| 101068 | 101668 | pExpr->y.pTab = pMatch->pTab; |
| 101069 | | - /* RIGHT JOIN not (yet) supported */ |
| 101070 | | - assert( (pMatch->fg.jointype & JT_RIGHT)==0 ); |
| 101071 | | - if( (pMatch->fg.jointype & JT_LEFT)!=0 ){ |
| 101669 | + if( (pMatch->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 ){ |
| 101072 | 101670 | ExprSetProperty(pExpr, EP_CanBeNull); |
| 101073 | 101671 | } |
| 101074 | 101672 | pSchema = pExpr->y.pTab->pSchema; |
| 101075 | 101673 | } |
| 101076 | 101674 | } /* if( pSrcList ) */ |
| | @@ -101307,15 +101905,41 @@ |
| 101307 | 101905 | return WRC_Prune; |
| 101308 | 101906 | } |
| 101309 | 101907 | } |
| 101310 | 101908 | |
| 101311 | 101909 | /* |
| 101312 | | - ** cnt==0 means there was not match. cnt>1 means there were two or |
| 101313 | | - ** more matches. Either way, we have an error. |
| 101910 | + ** cnt==0 means there was not match. |
| 101911 | + ** cnt>1 means there were two or more matches. |
| 101912 | + ** |
| 101913 | + ** cnt==0 is always an error. cnt>1 is often an error, but might |
| 101914 | + ** be multiple matches for a NATURAL LEFT JOIN or a LEFT JOIN USING. |
| 101314 | 101915 | */ |
| 101916 | + assert( pFJMatch==0 || cnt>0 ); |
| 101917 | + assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) ); |
| 101315 | 101918 | if( cnt!=1 ){ |
| 101316 | 101919 | const char *zErr; |
| 101920 | + if( pFJMatch ){ |
| 101921 | + if( pFJMatch->nExpr==cnt-1 ){ |
| 101922 | + if( ExprHasProperty(pExpr,EP_Leaf) ){ |
| 101923 | + ExprClearProperty(pExpr,EP_Leaf); |
| 101924 | + }else{ |
| 101925 | + sqlite3ExprDelete(db, pExpr->pLeft); |
| 101926 | + pExpr->pLeft = 0; |
| 101927 | + sqlite3ExprDelete(db, pExpr->pRight); |
| 101928 | + pExpr->pRight = 0; |
| 101929 | + } |
| 101930 | + extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); |
| 101931 | + pExpr->op = TK_FUNCTION; |
| 101932 | + pExpr->u.zToken = "coalesce"; |
| 101933 | + pExpr->x.pList = pFJMatch; |
| 101934 | + cnt = 1; |
| 101935 | + goto lookupname_end; |
| 101936 | + }else{ |
| 101937 | + sqlite3ExprListDelete(db, pFJMatch); |
| 101938 | + pFJMatch = 0; |
| 101939 | + } |
| 101940 | + } |
| 101317 | 101941 | zErr = cnt==0 ? "no such column" : "ambiguous column name"; |
| 101318 | 101942 | if( zDb ){ |
| 101319 | 101943 | sqlite3ErrorMsg(pParse, "%s: %s.%s.%s", zErr, zDb, zTab, zCol); |
| 101320 | 101944 | }else if( zTab ){ |
| 101321 | 101945 | sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol); |
| | @@ -101324,10 +101948,20 @@ |
| 101324 | 101948 | } |
| 101325 | 101949 | sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr); |
| 101326 | 101950 | pParse->checkSchema = 1; |
| 101327 | 101951 | pTopNC->nNcErr++; |
| 101328 | 101952 | } |
| 101953 | + assert( pFJMatch==0 ); |
| 101954 | + |
| 101955 | + /* Remove all substructure from pExpr */ |
| 101956 | + if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){ |
| 101957 | + sqlite3ExprDelete(db, pExpr->pLeft); |
| 101958 | + pExpr->pLeft = 0; |
| 101959 | + sqlite3ExprDelete(db, pExpr->pRight); |
| 101960 | + pExpr->pRight = 0; |
| 101961 | + ExprSetProperty(pExpr, EP_Leaf); |
| 101962 | + } |
| 101329 | 101963 | |
| 101330 | 101964 | /* If a column from a table in pSrcList is referenced, then record |
| 101331 | 101965 | ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes |
| 101332 | 101966 | ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is |
| 101333 | 101967 | ** set if the 63rd or any subsequent column is used. |
| | @@ -101343,20 +101977,11 @@ |
| 101343 | 101977 | */ |
| 101344 | 101978 | if( pExpr->iColumn>=0 && pMatch!=0 ){ |
| 101345 | 101979 | pMatch->colUsed |= sqlite3ExprColUsed(pExpr); |
| 101346 | 101980 | } |
| 101347 | 101981 | |
| 101348 | | - /* Clean up and return |
| 101349 | | - */ |
| 101350 | | - if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){ |
| 101351 | | - sqlite3ExprDelete(db, pExpr->pLeft); |
| 101352 | | - pExpr->pLeft = 0; |
| 101353 | | - sqlite3ExprDelete(db, pExpr->pRight); |
| 101354 | | - pExpr->pRight = 0; |
| 101355 | | - } |
| 101356 | 101982 | pExpr->op = eNewExprOp; |
| 101357 | | - ExprSetProperty(pExpr, EP_Leaf); |
| 101358 | 101983 | lookupname_end: |
| 101359 | 101984 | if( cnt==1 ){ |
| 101360 | 101985 | assert( pNC!=0 ); |
| 101361 | 101986 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 101362 | 101987 | if( pParse->db->xAuth |
| | @@ -104008,10 +104633,22 @@ |
| 104008 | 104633 | } |
| 104009 | 104634 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){ |
| 104010 | 104635 | if( p ) sqlite3ExprDeleteNN(db, p); |
| 104011 | 104636 | } |
| 104012 | 104637 | |
| 104638 | +/* |
| 104639 | +** Clear both elements of an OnOrUsing object |
| 104640 | +*/ |
| 104641 | +SQLITE_PRIVATE void sqlite3ClearOnOrUsing(sqlite3 *db, OnOrUsing *p){ |
| 104642 | + if( p==0 ){ |
| 104643 | + /* Nothing to clear */ |
| 104644 | + }else if( p->pOn ){ |
| 104645 | + sqlite3ExprDeleteNN(db, p->pOn); |
| 104646 | + }else if( p->pUsing ){ |
| 104647 | + sqlite3IdListDelete(db, p->pUsing); |
| 104648 | + } |
| 104649 | +} |
| 104013 | 104650 | |
| 104014 | 104651 | /* |
| 104015 | 104652 | ** Arrange to cause pExpr to be deleted when the pParse is deleted. |
| 104016 | 104653 | ** This is similar to sqlite3ExprDelete() except that the delete is |
| 104017 | 104654 | ** deferred untilthe pParse is deleted. |
| | @@ -104378,10 +105015,11 @@ |
| 104378 | 105015 | pItem->zEName = sqlite3DbStrDup(db, pOldItem->zEName); |
| 104379 | 105016 | pItem->sortFlags = pOldItem->sortFlags; |
| 104380 | 105017 | pItem->eEName = pOldItem->eEName; |
| 104381 | 105018 | pItem->done = 0; |
| 104382 | 105019 | pItem->bNulls = pOldItem->bNulls; |
| 105020 | + pItem->bUsed = pOldItem->bUsed; |
| 104383 | 105021 | pItem->bSorterRef = pOldItem->bSorterRef; |
| 104384 | 105022 | pItem->u = pOldItem->u; |
| 104385 | 105023 | } |
| 104386 | 105024 | return pNew; |
| 104387 | 105025 | } |
| | @@ -104430,37 +105068,35 @@ |
| 104430 | 105068 | pTab = pNewItem->pTab = pOldItem->pTab; |
| 104431 | 105069 | if( pTab ){ |
| 104432 | 105070 | pTab->nTabRef++; |
| 104433 | 105071 | } |
| 104434 | 105072 | pNewItem->pSelect = sqlite3SelectDup(db, pOldItem->pSelect, flags); |
| 104435 | | - pNewItem->pOn = sqlite3ExprDup(db, pOldItem->pOn, flags); |
| 104436 | | - pNewItem->pUsing = sqlite3IdListDup(db, pOldItem->pUsing); |
| 105073 | + if( pOldItem->fg.isUsing ){ |
| 105074 | + assert( pNewItem->fg.isUsing ); |
| 105075 | + pNewItem->u3.pUsing = sqlite3IdListDup(db, pOldItem->u3.pUsing); |
| 105076 | + }else{ |
| 105077 | + pNewItem->u3.pOn = sqlite3ExprDup(db, pOldItem->u3.pOn, flags); |
| 105078 | + } |
| 104437 | 105079 | pNewItem->colUsed = pOldItem->colUsed; |
| 104438 | 105080 | } |
| 104439 | 105081 | return pNew; |
| 104440 | 105082 | } |
| 104441 | 105083 | SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, const IdList *p){ |
| 104442 | 105084 | IdList *pNew; |
| 104443 | 105085 | int i; |
| 104444 | 105086 | assert( db!=0 ); |
| 104445 | 105087 | if( p==0 ) return 0; |
| 104446 | | - pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) ); |
| 105088 | + assert( p->eU4!=EU4_EXPR ); |
| 105089 | + pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew)+(p->nId-1)*sizeof(p->a[0]) ); |
| 104447 | 105090 | if( pNew==0 ) return 0; |
| 104448 | 105091 | pNew->nId = p->nId; |
| 104449 | | - pNew->a = sqlite3DbMallocRawNN(db, p->nId*sizeof(p->a[0]) ); |
| 104450 | | - if( pNew->a==0 ){ |
| 104451 | | - sqlite3DbFreeNN(db, pNew); |
| 104452 | | - return 0; |
| 104453 | | - } |
| 104454 | | - /* Note that because the size of the allocation for p->a[] is not |
| 104455 | | - ** necessarily a power of two, sqlite3IdListAppend() may not be called |
| 104456 | | - ** on the duplicate created by this function. */ |
| 105092 | + pNew->eU4 = p->eU4; |
| 104457 | 105093 | for(i=0; i<p->nId; i++){ |
| 104458 | 105094 | struct IdList_item *pNewItem = &pNew->a[i]; |
| 104459 | | - struct IdList_item *pOldItem = &p->a[i]; |
| 105095 | + const struct IdList_item *pOldItem = &p->a[i]; |
| 104460 | 105096 | pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName); |
| 104461 | | - pNewItem->idx = pOldItem->idx; |
| 105097 | + pNewItem->u4 = pOldItem->u4; |
| 104462 | 105098 | } |
| 104463 | 105099 | return pNew; |
| 104464 | 105100 | } |
| 104465 | 105101 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, const Select *pDup, int flags){ |
| 104466 | 105102 | Select *pRet = 0; |
| | @@ -104922,11 +105558,11 @@ |
| 104922 | 105558 | ** malformed schema error. |
| 104923 | 105559 | */ |
| 104924 | 105560 | static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ |
| 104925 | 105561 | |
| 104926 | 105562 | /* If pWalker->eCode is 2 then any term of the expression that comes from |
| 104927 | | - ** the ON or USING clauses of a left join disqualifies the expression |
| 105563 | + ** the ON or USING clauses of an outer join disqualifies the expression |
| 104928 | 105564 | ** from being considered constant. */ |
| 104929 | 105565 | if( pWalker->eCode==2 && ExprHasProperty(pExpr, EP_FromJoin) ){ |
| 104930 | 105566 | pWalker->eCode = 0; |
| 104931 | 105567 | return WRC_Abort; |
| 104932 | 105568 | } |
| | @@ -105924,13 +106560,13 @@ |
| 105924 | 106560 | sqlite3VdbeJumpHere(v, addrOnce); |
| 105925 | 106561 | /* Subroutine return */ |
| 105926 | 106562 | assert( ExprUseYSub(pExpr) ); |
| 105927 | 106563 | assert( sqlite3VdbeGetOp(v,pExpr->y.sub.iAddr-1)->opcode==OP_BeginSubrtn |
| 105928 | 106564 | || pParse->nErr ); |
| 105929 | | - sqlite3VdbeAddOp3(v, OP_Return, pExpr->y.sub.regReturn, 0, |
| 105930 | | - pExpr->y.sub.iAddr-1); |
| 105931 | | - sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1); |
| 106565 | + sqlite3VdbeAddOp3(v, OP_Return, pExpr->y.sub.regReturn, |
| 106566 | + pExpr->y.sub.iAddr, 1); |
| 106567 | + VdbeCoverage(v); |
| 105932 | 106568 | sqlite3ClearTempRegCache(pParse); |
| 105933 | 106569 | } |
| 105934 | 106570 | } |
| 105935 | 106571 | #endif /* SQLITE_OMIT_SUBQUERY */ |
| 105936 | 106572 | |
| | @@ -106055,13 +106691,13 @@ |
| 106055 | 106691 | |
| 106056 | 106692 | /* Subroutine return */ |
| 106057 | 106693 | assert( ExprUseYSub(pExpr) ); |
| 106058 | 106694 | assert( sqlite3VdbeGetOp(v,pExpr->y.sub.iAddr-1)->opcode==OP_BeginSubrtn |
| 106059 | 106695 | || pParse->nErr ); |
| 106060 | | - sqlite3VdbeAddOp3(v, OP_Return, pExpr->y.sub.regReturn, 0, |
| 106061 | | - pExpr->y.sub.iAddr-1); |
| 106062 | | - sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1); |
| 106696 | + sqlite3VdbeAddOp3(v, OP_Return, pExpr->y.sub.regReturn, |
| 106697 | + pExpr->y.sub.iAddr, 1); |
| 106698 | + VdbeCoverage(v); |
| 106063 | 106699 | sqlite3ClearTempRegCache(pParse); |
| 106064 | 106700 | return rReg; |
| 106065 | 106701 | } |
| 106066 | 106702 | #endif /* SQLITE_OMIT_SUBQUERY */ |
| 106067 | 106703 | |
| | @@ -106491,10 +107127,11 @@ |
| 106491 | 107127 | sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut); |
| 106492 | 107128 | return; |
| 106493 | 107129 | } |
| 106494 | 107130 | if( iCol<0 || iCol==pTab->iPKey ){ |
| 106495 | 107131 | sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut); |
| 107132 | + VdbeComment((v, "%s.rowid", pTab->zName)); |
| 106496 | 107133 | }else{ |
| 106497 | 107134 | int op; |
| 106498 | 107135 | int x; |
| 106499 | 107136 | if( IsVirtual(pTab) ){ |
| 106500 | 107137 | op = OP_VColumn; |
| | @@ -107243,20 +107880,22 @@ |
| 107243 | 107880 | } |
| 107244 | 107881 | break; |
| 107245 | 107882 | } |
| 107246 | 107883 | case TK_SELECT_COLUMN: { |
| 107247 | 107884 | int n; |
| 107248 | | - if( pExpr->pLeft->iTable==0 ){ |
| 107249 | | - pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft); |
| 107885 | + Expr *pLeft = pExpr->pLeft; |
| 107886 | + if( pLeft->iTable==0 || pParse->withinRJSubrtn > pLeft->op2 ){ |
| 107887 | + pLeft->iTable = sqlite3CodeSubselect(pParse, pLeft); |
| 107888 | + pLeft->op2 = pParse->withinRJSubrtn; |
| 107250 | 107889 | } |
| 107251 | | - assert( pExpr->pLeft->op==TK_SELECT || pExpr->pLeft->op==TK_ERROR ); |
| 107252 | | - n = sqlite3ExprVectorSize(pExpr->pLeft); |
| 107890 | + assert( pLeft->op==TK_SELECT || pLeft->op==TK_ERROR ); |
| 107891 | + n = sqlite3ExprVectorSize(pLeft); |
| 107253 | 107892 | if( pExpr->iTable!=n ){ |
| 107254 | 107893 | sqlite3ErrorMsg(pParse, "%d columns assigned %d values", |
| 107255 | 107894 | pExpr->iTable, n); |
| 107256 | 107895 | } |
| 107257 | | - return pExpr->pLeft->iTable + pExpr->iColumn; |
| 107896 | + return pLeft->iTable + pExpr->iColumn; |
| 107258 | 107897 | } |
| 107259 | 107898 | case TK_IN: { |
| 107260 | 107899 | int destIfFalse = sqlite3VdbeMakeLabel(pParse); |
| 107261 | 107900 | int destIfNull = sqlite3VdbeMakeLabel(pParse); |
| 107262 | 107901 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| | @@ -108560,11 +109199,11 @@ |
| 108560 | 109199 | ** |
| 108561 | 109200 | ** False positives are not allowed, however. A false positive may result |
| 108562 | 109201 | ** in an incorrect answer. |
| 108563 | 109202 | ** |
| 108564 | 109203 | ** Terms of p that are marked with EP_FromJoin (and hence that come from |
| 108565 | | -** the ON or USING clauses of LEFT JOINS) are excluded from the analysis. |
| 109204 | +** the ON or USING clauses of OUTER JOINS) are excluded from the analysis. |
| 108566 | 109205 | ** |
| 108567 | 109206 | ** This routine is used to check if a LEFT JOIN can be converted into |
| 108568 | 109207 | ** an ordinary JOIN. The p argument is the WHERE clause. If the WHERE |
| 108569 | 109208 | ** clause requires that some column of the right table of the LEFT JOIN |
| 108570 | 109209 | ** be non-NULL, then the LEFT JOIN can be safely converted into an |
| | @@ -109974,15 +110613,14 @@ |
| 109974 | 110613 | */ |
| 109975 | 110614 | static void unmapColumnIdlistNames( |
| 109976 | 110615 | Parse *pParse, |
| 109977 | 110616 | const IdList *pIdList |
| 109978 | 110617 | ){ |
| 109979 | | - if( pIdList ){ |
| 109980 | | - int ii; |
| 109981 | | - for(ii=0; ii<pIdList->nId; ii++){ |
| 109982 | | - sqlite3RenameTokenRemap(pParse, 0, (const void*)pIdList->a[ii].zName); |
| 109983 | | - } |
| 110618 | + int ii; |
| 110619 | + assert( pIdList!=0 ); |
| 110620 | + for(ii=0; ii<pIdList->nId; ii++){ |
| 110621 | + sqlite3RenameTokenRemap(pParse, 0, (const void*)pIdList->a[ii].zName); |
| 109984 | 110622 | } |
| 109985 | 110623 | } |
| 109986 | 110624 | |
| 109987 | 110625 | /* |
| 109988 | 110626 | ** Walker callback used by sqlite3RenameExprUnmap(). |
| | @@ -110006,12 +110644,15 @@ |
| 110006 | 110644 | } |
| 110007 | 110645 | if( ALWAYS(p->pSrc) ){ /* Every Select as a SrcList, even if it is empty */ |
| 110008 | 110646 | SrcList *pSrc = p->pSrc; |
| 110009 | 110647 | for(i=0; i<pSrc->nSrc; i++){ |
| 110010 | 110648 | sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName); |
| 110011 | | - sqlite3WalkExpr(pWalker, pSrc->a[i].pOn); |
| 110012 | | - unmapColumnIdlistNames(pParse, pSrc->a[i].pUsing); |
| 110649 | + if( pSrc->a[i].fg.isUsing==0 ){ |
| 110650 | + sqlite3WalkExpr(pWalker, pSrc->a[i].u3.pOn); |
| 110651 | + }else{ |
| 110652 | + unmapColumnIdlistNames(pParse, pSrc->a[i].u3.pUsing); |
| 110653 | + } |
| 110013 | 110654 | } |
| 110014 | 110655 | } |
| 110015 | 110656 | |
| 110016 | 110657 | renameWalkWith(pWalker, p); |
| 110017 | 110658 | return WRC_Continue; |
| | @@ -113792,11 +114433,15 @@ |
| 113792 | 114433 | } |
| 113793 | 114434 | pItem->pSchema = pFix->pSchema; |
| 113794 | 114435 | pItem->fg.fromDDL = 1; |
| 113795 | 114436 | } |
| 113796 | 114437 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) |
| 113797 | | - if( sqlite3WalkExpr(&pFix->w, pList->a[i].pOn) ) return WRC_Abort; |
| 114438 | + if( pList->a[i].fg.isUsing==0 |
| 114439 | + && sqlite3WalkExpr(&pFix->w, pList->a[i].u3.pOn) |
| 114440 | + ){ |
| 114441 | + return WRC_Abort; |
| 114442 | + } |
| 113798 | 114443 | #endif |
| 113799 | 114444 | } |
| 113800 | 114445 | if( pSelect->pWith ){ |
| 113801 | 114446 | for(i=0; i<pSelect->pWith->nCte; i++){ |
| 113802 | 114447 | if( sqlite3WalkSelect(p, pSelect->pWith->a[i].pSelect) ){ |
| | @@ -118856,22 +119501,21 @@ |
| 118856 | 119501 | sqlite3 *db = pParse->db; |
| 118857 | 119502 | int i; |
| 118858 | 119503 | if( pList==0 ){ |
| 118859 | 119504 | pList = sqlite3DbMallocZero(db, sizeof(IdList) ); |
| 118860 | 119505 | if( pList==0 ) return 0; |
| 118861 | | - } |
| 118862 | | - pList->a = sqlite3ArrayAllocate( |
| 118863 | | - db, |
| 118864 | | - pList->a, |
| 118865 | | - sizeof(pList->a[0]), |
| 118866 | | - &pList->nId, |
| 118867 | | - &i |
| 118868 | | - ); |
| 118869 | | - if( i<0 ){ |
| 118870 | | - sqlite3IdListDelete(db, pList); |
| 118871 | | - return 0; |
| 118872 | | - } |
| 119506 | + }else{ |
| 119507 | + IdList *pNew; |
| 119508 | + pNew = sqlite3DbRealloc(db, pList, |
| 119509 | + sizeof(IdList) + pList->nId*sizeof(pList->a)); |
| 119510 | + if( pNew==0 ){ |
| 119511 | + sqlite3IdListDelete(db, pList); |
| 119512 | + return 0; |
| 119513 | + } |
| 119514 | + pList = pNew; |
| 119515 | + } |
| 119516 | + i = pList->nId++; |
| 118873 | 119517 | pList->a[i].zName = sqlite3NameFromToken(db, pToken); |
| 118874 | 119518 | if( IN_RENAME_OBJECT && pList->a[i].zName ){ |
| 118875 | 119519 | sqlite3RenameTokenMap(pParse, (void*)pList->a[i].zName, pToken); |
| 118876 | 119520 | } |
| 118877 | 119521 | return pList; |
| | @@ -118881,24 +119525,24 @@ |
| 118881 | 119525 | ** Delete an IdList. |
| 118882 | 119526 | */ |
| 118883 | 119527 | SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3 *db, IdList *pList){ |
| 118884 | 119528 | int i; |
| 118885 | 119529 | if( pList==0 ) return; |
| 119530 | + assert( pList->eU4!=EU4_EXPR ); /* EU4_EXPR mode is not currently used */ |
| 118886 | 119531 | for(i=0; i<pList->nId; i++){ |
| 118887 | 119532 | sqlite3DbFree(db, pList->a[i].zName); |
| 118888 | 119533 | } |
| 118889 | | - sqlite3DbFree(db, pList->a); |
| 118890 | 119534 | sqlite3DbFreeNN(db, pList); |
| 118891 | 119535 | } |
| 118892 | 119536 | |
| 118893 | 119537 | /* |
| 118894 | 119538 | ** Return the index in pList of the identifier named zId. Return -1 |
| 118895 | 119539 | ** if not found. |
| 118896 | 119540 | */ |
| 118897 | 119541 | SQLITE_PRIVATE int sqlite3IdListIndex(IdList *pList, const char *zName){ |
| 118898 | 119542 | int i; |
| 118899 | | - if( pList==0 ) return -1; |
| 119543 | + assert( pList!=0 ); |
| 118900 | 119544 | for(i=0; i<pList->nId; i++){ |
| 118901 | 119545 | if( sqlite3StrICmp(pList->a[i].zName, zName)==0 ) return i; |
| 118902 | 119546 | } |
| 118903 | 119547 | return -1; |
| 118904 | 119548 | } |
| | @@ -119097,12 +119741,15 @@ |
| 119097 | 119741 | if( pItem->zAlias ) sqlite3DbFreeNN(db, pItem->zAlias); |
| 119098 | 119742 | if( pItem->fg.isIndexedBy ) sqlite3DbFree(db, pItem->u1.zIndexedBy); |
| 119099 | 119743 | if( pItem->fg.isTabFunc ) sqlite3ExprListDelete(db, pItem->u1.pFuncArg); |
| 119100 | 119744 | sqlite3DeleteTable(db, pItem->pTab); |
| 119101 | 119745 | if( pItem->pSelect ) sqlite3SelectDelete(db, pItem->pSelect); |
| 119102 | | - if( pItem->pOn ) sqlite3ExprDelete(db, pItem->pOn); |
| 119103 | | - if( pItem->pUsing ) sqlite3IdListDelete(db, pItem->pUsing); |
| 119746 | + if( pItem->fg.isUsing ){ |
| 119747 | + sqlite3IdListDelete(db, pItem->u3.pUsing); |
| 119748 | + }else if( pItem->u3.pOn ){ |
| 119749 | + sqlite3ExprDelete(db, pItem->u3.pOn); |
| 119750 | + } |
| 119104 | 119751 | } |
| 119105 | 119752 | sqlite3DbFreeNN(db, pList); |
| 119106 | 119753 | } |
| 119107 | 119754 | |
| 119108 | 119755 | /* |
| | @@ -119126,18 +119773,17 @@ |
| 119126 | 119773 | SrcList *p, /* The left part of the FROM clause already seen */ |
| 119127 | 119774 | Token *pTable, /* Name of the table to add to the FROM clause */ |
| 119128 | 119775 | Token *pDatabase, /* Name of the database containing pTable */ |
| 119129 | 119776 | Token *pAlias, /* The right-hand side of the AS subexpression */ |
| 119130 | 119777 | Select *pSubquery, /* A subquery used in place of a table name */ |
| 119131 | | - Expr *pOn, /* The ON clause of a join */ |
| 119132 | | - IdList *pUsing /* The USING clause of a join */ |
| 119778 | + OnOrUsing *pOnUsing /* Either the ON clause or the USING clause */ |
| 119133 | 119779 | ){ |
| 119134 | 119780 | SrcItem *pItem; |
| 119135 | 119781 | sqlite3 *db = pParse->db; |
| 119136 | | - if( !p && (pOn || pUsing) ){ |
| 119782 | + if( !p && pOnUsing!=0 && (pOnUsing->pOn || pOnUsing->pUsing) ){ |
| 119137 | 119783 | sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s", |
| 119138 | | - (pOn ? "ON" : "USING") |
| 119784 | + (pOnUsing->pOn ? "ON" : "USING") |
| 119139 | 119785 | ); |
| 119140 | 119786 | goto append_from_error; |
| 119141 | 119787 | } |
| 119142 | 119788 | p = sqlite3SrcListAppend(pParse, p, pTable, pDatabase); |
| 119143 | 119789 | if( p==0 ){ |
| | @@ -119153,19 +119799,31 @@ |
| 119153 | 119799 | } |
| 119154 | 119800 | assert( pAlias!=0 ); |
| 119155 | 119801 | if( pAlias->n ){ |
| 119156 | 119802 | pItem->zAlias = sqlite3NameFromToken(db, pAlias); |
| 119157 | 119803 | } |
| 119158 | | - pItem->pSelect = pSubquery; |
| 119159 | | - pItem->pOn = pOn; |
| 119160 | | - pItem->pUsing = pUsing; |
| 119804 | + if( pSubquery ){ |
| 119805 | + pItem->pSelect = pSubquery; |
| 119806 | + if( pSubquery->selFlags & SF_NestedFrom ){ |
| 119807 | + pItem->fg.isNestedFrom = 1; |
| 119808 | + } |
| 119809 | + } |
| 119810 | + assert( pOnUsing==0 || pOnUsing->pOn==0 || pOnUsing->pUsing==0 ); |
| 119811 | + assert( pItem->fg.isUsing==0 ); |
| 119812 | + if( pOnUsing==0 ){ |
| 119813 | + pItem->u3.pOn = 0; |
| 119814 | + }else if( pOnUsing->pUsing ){ |
| 119815 | + pItem->fg.isUsing = 1; |
| 119816 | + pItem->u3.pUsing = pOnUsing->pUsing; |
| 119817 | + }else{ |
| 119818 | + pItem->u3.pOn = pOnUsing->pOn; |
| 119819 | + } |
| 119161 | 119820 | return p; |
| 119162 | 119821 | |
| 119163 | 119822 | append_from_error: |
| 119164 | 119823 | assert( p==0 ); |
| 119165 | | - sqlite3ExprDelete(db, pOn); |
| 119166 | | - sqlite3IdListDelete(db, pUsing); |
| 119824 | + sqlite3ClearOnOrUsing(db, pOnUsing); |
| 119167 | 119825 | sqlite3SelectDelete(db, pSubquery); |
| 119168 | 119826 | return 0; |
| 119169 | 119827 | } |
| 119170 | 119828 | |
| 119171 | 119829 | /* |
| | @@ -119206,10 +119864,11 @@ |
| 119206 | 119864 | sqlite3SrcListDelete(pParse->db, p2); |
| 119207 | 119865 | }else{ |
| 119208 | 119866 | p1 = pNew; |
| 119209 | 119867 | memcpy(&p1->a[1], p2->a, p2->nSrc*sizeof(SrcItem)); |
| 119210 | 119868 | sqlite3DbFree(pParse->db, p2); |
| 119869 | + p1->a[0].fg.jointype |= (JT_LTORJ & p1->a[1].fg.jointype); |
| 119211 | 119870 | } |
| 119212 | 119871 | } |
| 119213 | 119872 | return p1; |
| 119214 | 119873 | } |
| 119215 | 119874 | |
| | @@ -119242,18 +119901,38 @@ |
| 119242 | 119901 | ** A natural cross join B |
| 119243 | 119902 | ** |
| 119244 | 119903 | ** The operator is "natural cross join". The A and B operands are stored |
| 119245 | 119904 | ** in p->a[0] and p->a[1], respectively. The parser initially stores the |
| 119246 | 119905 | ** operator with A. This routine shifts that operator over to B. |
| 119906 | +** |
| 119907 | +** Additional changes: |
| 119908 | +** |
| 119909 | +** * All tables to the left of the right-most RIGHT JOIN are tagged with |
| 119910 | +** JT_LTORJ (mnemonic: Left Table Of Right Join) so that the |
| 119911 | +** code generator can easily tell that the table is part of |
| 119912 | +** the left operand of at least one RIGHT JOIN. |
| 119247 | 119913 | */ |
| 119248 | | -SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList *p){ |
| 119249 | | - if( p ){ |
| 119250 | | - int i; |
| 119251 | | - for(i=p->nSrc-1; i>0; i--){ |
| 119252 | | - p->a[i].fg.jointype = p->a[i-1].fg.jointype; |
| 119253 | | - } |
| 119914 | +SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(Parse *pParse, SrcList *p){ |
| 119915 | + (void)pParse; |
| 119916 | + if( p && p->nSrc>1 ){ |
| 119917 | + int i = p->nSrc-1; |
| 119918 | + u8 allFlags = 0; |
| 119919 | + do{ |
| 119920 | + allFlags |= p->a[i].fg.jointype = p->a[i-1].fg.jointype; |
| 119921 | + }while( (--i)>0 ); |
| 119254 | 119922 | p->a[0].fg.jointype = 0; |
| 119923 | + |
| 119924 | + /* All terms to the left of a RIGHT JOIN should be tagged with the |
| 119925 | + ** JT_LTORJ flags */ |
| 119926 | + if( allFlags & JT_RIGHT ){ |
| 119927 | + for(i=p->nSrc-1; ALWAYS(i>0) && (p->a[i].fg.jointype&JT_RIGHT)==0; i--){} |
| 119928 | + i--; |
| 119929 | + assert( i>=0 ); |
| 119930 | + do{ |
| 119931 | + p->a[i].fg.jointype |= JT_LTORJ; |
| 119932 | + }while( (--i)>=0 ); |
| 119933 | + } |
| 119255 | 119934 | } |
| 119256 | 119935 | } |
| 119257 | 119936 | |
| 119258 | 119937 | /* |
| 119259 | 119938 | ** Generate VDBE code for a BEGIN statement. |
| | @@ -120498,12 +121177,12 @@ |
| 120498 | 121177 | pFrom = sqlite3SrcListAppend(pParse, 0, 0, 0); |
| 120499 | 121178 | if( pFrom ){ |
| 120500 | 121179 | assert( pFrom->nSrc==1 ); |
| 120501 | 121180 | pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName); |
| 120502 | 121181 | pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName); |
| 120503 | | - assert( pFrom->a[0].pOn==0 ); |
| 120504 | | - assert( pFrom->a[0].pUsing==0 ); |
| 121182 | + assert( pFrom->a[0].fg.isUsing==0 ); |
| 121183 | + assert( pFrom->a[0].u3.pOn==0 ); |
| 120505 | 121184 | } |
| 120506 | 121185 | pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, pOrderBy, |
| 120507 | 121186 | SF_IncludeHidden, pLimit); |
| 120508 | 121187 | sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur); |
| 120509 | 121188 | sqlite3Select(pParse, pSel, &dest); |
| | @@ -120670,11 +121349,10 @@ |
| 120670 | 121349 | goto delete_from_cleanup; |
| 120671 | 121350 | } |
| 120672 | 121351 | assert( db->mallocFailed==0 ); |
| 120673 | 121352 | assert( pTabList->nSrc==1 ); |
| 120674 | 121353 | |
| 120675 | | - |
| 120676 | 121354 | /* Locate the table which we want to delete. This table has to be |
| 120677 | 121355 | ** put in an SrcList structure because some of the subroutines we |
| 120678 | 121356 | ** will be calling are designed to work with multiple tables and expect |
| 120679 | 121357 | ** an SrcList* parameter instead of just a Table* parameter. |
| 120680 | 121358 | */ |
| | @@ -120694,10 +121372,18 @@ |
| 120694 | 121372 | bComplex = pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0); |
| 120695 | 121373 | #ifdef SQLITE_OMIT_VIEW |
| 120696 | 121374 | # undef isView |
| 120697 | 121375 | # define isView 0 |
| 120698 | 121376 | #endif |
| 121377 | + |
| 121378 | +#if TREETRACE_ENABLED |
| 121379 | + if( sqlite3TreeTrace & 0x10000 ){ |
| 121380 | + sqlite3TreeViewLine(0, "In sqlite3Delete() at %s:%d", __FILE__, __LINE__); |
| 121381 | + sqlite3TreeViewDelete(pParse->pWith, pTabList, pWhere, |
| 121382 | + pOrderBy, pLimit, pTrigger); |
| 121383 | + } |
| 121384 | +#endif |
| 120699 | 121385 | |
| 120700 | 121386 | #ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT |
| 120701 | 121387 | if( !isView ){ |
| 120702 | 121388 | pWhere = sqlite3LimitWhere( |
| 120703 | 121389 | pParse, pTabList, pWhere, pOrderBy, pLimit, "DELETE" |
| | @@ -124132,11 +124818,10 @@ |
| 124132 | 124818 | sqlite3VdbeJumpHere(v, iMustBeInt); |
| 124133 | 124819 | sqlite3ReleaseTempReg(pParse, regTemp); |
| 124134 | 124820 | }else{ |
| 124135 | 124821 | int nCol = pFKey->nCol; |
| 124136 | 124822 | int regTemp = sqlite3GetTempRange(pParse, nCol); |
| 124137 | | - int regRec = sqlite3GetTempReg(pParse); |
| 124138 | 124823 | |
| 124139 | 124824 | sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb); |
| 124140 | 124825 | sqlite3VdbeSetP4KeyInfo(pParse, pIdx); |
| 124141 | 124826 | for(i=0; i<nCol; i++){ |
| 124142 | 124827 | sqlite3VdbeAddOp2(v, OP_Copy, |
| | @@ -124172,15 +124857,14 @@ |
| 124172 | 124857 | sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL); |
| 124173 | 124858 | } |
| 124174 | 124859 | sqlite3VdbeGoto(v, iOk); |
| 124175 | 124860 | } |
| 124176 | 124861 | |
| 124177 | | - sqlite3VdbeAddOp4(v, OP_MakeRecord, regTemp, nCol, regRec, |
| 124862 | + sqlite3VdbeAddOp4(v, OP_Affinity, regTemp, nCol, 0, |
| 124178 | 124863 | sqlite3IndexAffinityStr(pParse->db,pIdx), nCol); |
| 124179 | | - sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0); VdbeCoverage(v); |
| 124180 | | - |
| 124181 | | - sqlite3ReleaseTempReg(pParse, regRec); |
| 124864 | + sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regTemp, nCol); |
| 124865 | + VdbeCoverage(v); |
| 124182 | 124866 | sqlite3ReleaseTempRange(pParse, regTemp, nCol); |
| 124183 | 124867 | } |
| 124184 | 124868 | } |
| 124185 | 124869 | |
| 124186 | 124870 | if( !pFKey->isDeferred && !(pParse->db->flags & SQLITE_DeferFKs) |
| | @@ -124278,18 +124962,14 @@ |
| 124278 | 124962 | ** For each child row found, one of the following actions is taken: |
| 124279 | 124963 | ** |
| 124280 | 124964 | ** Operation | FK type | Action taken |
| 124281 | 124965 | ** -------------------------------------------------------------------------- |
| 124282 | 124966 | ** DELETE immediate Increment the "immediate constraint counter". |
| 124283 | | -** Or, if the ON (UPDATE|DELETE) action is RESTRICT, |
| 124284 | | -** throw a "FOREIGN KEY constraint failed" exception. |
| 124285 | 124967 | ** |
| 124286 | 124968 | ** INSERT immediate Decrement the "immediate constraint counter". |
| 124287 | 124969 | ** |
| 124288 | 124970 | ** DELETE deferred Increment the "deferred constraint counter". |
| 124289 | | -** Or, if the ON (UPDATE|DELETE) action is RESTRICT, |
| 124290 | | -** throw a "FOREIGN KEY constraint failed" exception. |
| 124291 | 124971 | ** |
| 124292 | 124972 | ** INSERT deferred Decrement the "deferred constraint counter". |
| 124293 | 124973 | ** |
| 124294 | 124974 | ** These operations are identified in the comment at the top of this file |
| 124295 | 124975 | ** (fkey.c) as "I.2" and "D.2". |
| | @@ -124933,13 +125613,13 @@ |
| 124933 | 125613 | ** passed a pointer to the list of columns being modified. If it is a |
| 124934 | 125614 | ** DELETE, pChanges is passed a NULL pointer. |
| 124935 | 125615 | ** |
| 124936 | 125616 | ** It returns a pointer to a Trigger structure containing a trigger |
| 124937 | 125617 | ** equivalent to the ON UPDATE or ON DELETE action specified by pFKey. |
| 124938 | | -** If the action is "NO ACTION" or "RESTRICT", then a NULL pointer is |
| 124939 | | -** returned (these actions require no special handling by the triggers |
| 124940 | | -** sub-system, code for them is created by fkScanChildren()). |
| 125618 | +** If the action is "NO ACTION" then a NULL pointer is returned (these actions |
| 125619 | +** require no special handling by the triggers sub-system, code for them is |
| 125620 | +** created by fkScanChildren()). |
| 124941 | 125621 | ** |
| 124942 | 125622 | ** For example, if pFKey is the foreign key and pTab is table "p" in |
| 124943 | 125623 | ** the following schema: |
| 124944 | 125624 | ** |
| 124945 | 125625 | ** CREATE TABLE p(pk PRIMARY KEY); |
| | @@ -125064,22 +125744,27 @@ |
| 125064 | 125744 | |
| 125065 | 125745 | zFrom = pFKey->pFrom->zName; |
| 125066 | 125746 | nFrom = sqlite3Strlen30(zFrom); |
| 125067 | 125747 | |
| 125068 | 125748 | if( action==OE_Restrict ){ |
| 125749 | + int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 125069 | 125750 | Token tFrom; |
| 125751 | + Token tDb; |
| 125070 | 125752 | Expr *pRaise; |
| 125071 | 125753 | |
| 125072 | 125754 | tFrom.z = zFrom; |
| 125073 | 125755 | tFrom.n = nFrom; |
| 125756 | + tDb.z = db->aDb[iDb].zDbSName; |
| 125757 | + tDb.n = sqlite3Strlen30(tDb.z); |
| 125758 | + |
| 125074 | 125759 | pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed"); |
| 125075 | 125760 | if( pRaise ){ |
| 125076 | 125761 | pRaise->affExpr = OE_Abort; |
| 125077 | 125762 | } |
| 125078 | 125763 | pSelect = sqlite3SelectNew(pParse, |
| 125079 | 125764 | sqlite3ExprListAppend(pParse, 0, pRaise), |
| 125080 | | - sqlite3SrcListAppend(pParse, 0, &tFrom, 0), |
| 125765 | + sqlite3SrcListAppend(pParse, 0, &tDb, &tFrom), |
| 125081 | 125766 | pWhere, |
| 125082 | 125767 | 0, 0, 0, 0, 0 |
| 125083 | 125768 | ); |
| 125084 | 125769 | pWhere = 0; |
| 125085 | 125770 | } |
| | @@ -125984,10 +126669,18 @@ |
| 125984 | 126669 | #ifdef SQLITE_OMIT_VIEW |
| 125985 | 126670 | # undef isView |
| 125986 | 126671 | # define isView 0 |
| 125987 | 126672 | #endif |
| 125988 | 126673 | assert( (pTrigger && tmask) || (pTrigger==0 && tmask==0) ); |
| 126674 | + |
| 126675 | +#if TREETRACE_ENABLED |
| 126676 | + if( sqlite3TreeTrace & 0x10000 ){ |
| 126677 | + sqlite3TreeViewLine(0, "In sqlite3Insert() at %s:%d", __FILE__, __LINE__); |
| 126678 | + sqlite3TreeViewInsert(pParse->pWith, pTabList, pColumn, pSelect, pList, |
| 126679 | + onError, pUpsert, pTrigger); |
| 126680 | + } |
| 126681 | +#endif |
| 125989 | 126682 | |
| 125990 | 126683 | /* If pTab is really a view, make sure it has been initialized. |
| 125991 | 126684 | ** ViewGetColumnNames() is a no-op if pTab is not a view. |
| 125992 | 126685 | */ |
| 125993 | 126686 | if( sqlite3ViewGetColumnNames(pParse, pTab) ){ |
| | @@ -126063,17 +126756,19 @@ |
| 126063 | 126756 | ** columns into storage order. False negatives are harmless, |
| 126064 | 126757 | ** but false positives will cause database corruption. |
| 126065 | 126758 | */ |
| 126066 | 126759 | bIdListInOrder = (pTab->tabFlags & (TF_OOOHidden|TF_HasStored))==0; |
| 126067 | 126760 | if( pColumn ){ |
| 126761 | + assert( pColumn->eU4!=EU4_EXPR ); |
| 126762 | + pColumn->eU4 = EU4_IDX; |
| 126068 | 126763 | for(i=0; i<pColumn->nId; i++){ |
| 126069 | | - pColumn->a[i].idx = -1; |
| 126764 | + pColumn->a[i].u4.idx = -1; |
| 126070 | 126765 | } |
| 126071 | 126766 | for(i=0; i<pColumn->nId; i++){ |
| 126072 | 126767 | for(j=0; j<pTab->nCol; j++){ |
| 126073 | 126768 | if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zCnName)==0 ){ |
| 126074 | | - pColumn->a[i].idx = j; |
| 126769 | + pColumn->a[i].u4.idx = j; |
| 126075 | 126770 | if( i!=j ) bIdListInOrder = 0; |
| 126076 | 126771 | if( j==pTab->iPKey ){ |
| 126077 | 126772 | ipkColumn = i; assert( !withoutRowid ); |
| 126078 | 126773 | } |
| 126079 | 126774 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| | @@ -126371,11 +127066,12 @@ |
| 126371 | 127066 | iRegStore); |
| 126372 | 127067 | continue; |
| 126373 | 127068 | } |
| 126374 | 127069 | } |
| 126375 | 127070 | if( pColumn ){ |
| 126376 | | - for(j=0; j<pColumn->nId && pColumn->a[j].idx!=i; j++){} |
| 127071 | + assert( pColumn->eU4==EU4_IDX ); |
| 127072 | + for(j=0; j<pColumn->nId && pColumn->a[j].u4.idx!=i; j++){} |
| 126377 | 127073 | if( j>=pColumn->nId ){ |
| 126378 | 127074 | /* A column not named in the insert column list gets its |
| 126379 | 127075 | ** default value */ |
| 126380 | 127076 | sqlite3ExprCodeFactorable(pParse, |
| 126381 | 127077 | sqlite3ColumnExpr(pTab, &pTab->aCol[i]), |
| | @@ -132244,19 +132940,17 @@ |
| 132244 | 132940 | int i; /* Loop counter: Foreign key number for pTab */ |
| 132245 | 132941 | int j; /* Loop counter: Field of the foreign key */ |
| 132246 | 132942 | HashElem *k; /* Loop counter: Next table in schema */ |
| 132247 | 132943 | int x; /* result variable */ |
| 132248 | 132944 | int regResult; /* 3 registers to hold a result row */ |
| 132249 | | - int regKey; /* Register to hold key for checking the FK */ |
| 132250 | 132945 | int regRow; /* Registers to hold a row from pTab */ |
| 132251 | 132946 | int addrTop; /* Top of a loop checking foreign keys */ |
| 132252 | 132947 | int addrOk; /* Jump here if the key is OK */ |
| 132253 | 132948 | int *aiCols; /* child to parent column mapping */ |
| 132254 | 132949 | |
| 132255 | 132950 | regResult = pParse->nMem+1; |
| 132256 | 132951 | pParse->nMem += 4; |
| 132257 | | - regKey = ++pParse->nMem; |
| 132258 | 132952 | regRow = ++pParse->nMem; |
| 132259 | 132953 | k = sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash); |
| 132260 | 132954 | while( k ){ |
| 132261 | 132955 | if( zRight ){ |
| 132262 | 132956 | pTab = sqlite3LocateTable(pParse, 0, zRight, zDb); |
| | @@ -132319,13 +133013,13 @@ |
| 132319 | 133013 | } |
| 132320 | 133014 | |
| 132321 | 133015 | /* Generate code to query the parent index for a matching parent |
| 132322 | 133016 | ** key. If a match is found, jump to addrOk. */ |
| 132323 | 133017 | if( pIdx ){ |
| 132324 | | - sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, pFK->nCol, regKey, |
| 133018 | + sqlite3VdbeAddOp4(v, OP_Affinity, regRow, pFK->nCol, 0, |
| 132325 | 133019 | sqlite3IndexAffinityStr(db,pIdx), pFK->nCol); |
| 132326 | | - sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); |
| 133020 | + sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regRow, pFK->nCol); |
| 132327 | 133021 | VdbeCoverage(v); |
| 132328 | 133022 | }else if( pParent ){ |
| 132329 | 133023 | int jmp = sqlite3VdbeCurrentAddr(v)+2; |
| 132330 | 133024 | sqlite3VdbeAddOp3(v, OP_SeekRowid, i, jmp, regRow); VdbeCoverage(v); |
| 132331 | 133025 | sqlite3VdbeGoto(v, addrOk); |
| | @@ -134732,10 +135426,56 @@ |
| 134732 | 135426 | ** |
| 134733 | 135427 | ** A full outer join is the combination of JT_LEFT and JT_RIGHT. |
| 134734 | 135428 | ** |
| 134735 | 135429 | ** If an illegal or unsupported join type is seen, then still return |
| 134736 | 135430 | ** a join type, but put an error in the pParse structure. |
| 135431 | +** |
| 135432 | +** These are the valid join types: |
| 135433 | +** |
| 135434 | +** |
| 135435 | +** pA pB pC Return Value |
| 135436 | +** ------- ----- ----- ------------ |
| 135437 | +** CROSS - - JT_CROSS |
| 135438 | +** INNER - - JT_INNER |
| 135439 | +** LEFT - - JT_LEFT|JT_OUTER |
| 135440 | +** LEFT OUTER - JT_LEFT|JT_OUTER |
| 135441 | +** RIGHT - - JT_RIGHT|JT_OUTER |
| 135442 | +** RIGHT OUTER - JT_RIGHT|JT_OUTER |
| 135443 | +** FULL - - JT_LEFT|JT_RIGHT|JT_OUTER |
| 135444 | +** FULL OUTER - JT_LEFT|JT_RIGHT|JT_OUTER |
| 135445 | +** NATURAL INNER - JT_NATURAL|JT_INNER |
| 135446 | +** NATURAL LEFT - JT_NATURAL|JT_LEFT|JT_OUTER |
| 135447 | +** NATURAL LEFT OUTER JT_NATURAL|JT_LEFT|JT_OUTER |
| 135448 | +** NATURAL RIGHT - JT_NATURAL|JT_RIGHT|JT_OUTER |
| 135449 | +** NATURAL RIGHT OUTER JT_NATURAL|JT_RIGHT|JT_OUTER |
| 135450 | +** NATURAL FULL - JT_NATURAL|JT_LEFT|JT_RIGHT |
| 135451 | +** NATURAL FULL OUTER JT_NATRUAL|JT_LEFT|JT_RIGHT |
| 135452 | +** |
| 135453 | +** To preserve historical compatibly, SQLite also accepts a variety |
| 135454 | +** of other non-standard and in many cases non-sensical join types. |
| 135455 | +** This routine makes as much sense at it can from the nonsense join |
| 135456 | +** type and returns a result. Examples of accepted nonsense join types |
| 135457 | +** include but are not limited to: |
| 135458 | +** |
| 135459 | +** INNER CROSS JOIN -> same as JOIN |
| 135460 | +** NATURAL CROSS JOIN -> same as NATURAL JOIN |
| 135461 | +** OUTER LEFT JOIN -> same as LEFT JOIN |
| 135462 | +** LEFT NATURAL JOIN -> same as NATURAL LEFT JOIN |
| 135463 | +** LEFT RIGHT JOIN -> same as FULL JOIN |
| 135464 | +** RIGHT OUTER FULL JOIN -> same as FULL JOIN |
| 135465 | +** CROSS CROSS CROSS JOIN -> same as JOIN |
| 135466 | +** |
| 135467 | +** The only restrictions on the join type name are: |
| 135468 | +** |
| 135469 | +** * "INNER" cannot appear together with "OUTER", "LEFT", "RIGHT", |
| 135470 | +** or "FULL". |
| 135471 | +** |
| 135472 | +** * "CROSS" cannot appear together with "OUTER", "LEFT", "RIGHT, |
| 135473 | +** or "FULL". |
| 135474 | +** |
| 135475 | +** * If "OUTER" is present then there must also be one of |
| 135476 | +** "LEFT", "RIGHT", or "FULL" |
| 134737 | 135477 | */ |
| 134738 | 135478 | SQLITE_PRIVATE int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){ |
| 134739 | 135479 | int jointype = 0; |
| 134740 | 135480 | Token *apAll[3]; |
| 134741 | 135481 | Token *p; |
| | @@ -134744,17 +135484,17 @@ |
| 134744 | 135484 | static const struct { |
| 134745 | 135485 | u8 i; /* Beginning of keyword text in zKeyText[] */ |
| 134746 | 135486 | u8 nChar; /* Length of the keyword in characters */ |
| 134747 | 135487 | u8 code; /* Join type mask */ |
| 134748 | 135488 | } aKeyword[] = { |
| 134749 | | - /* natural */ { 0, 7, JT_NATURAL }, |
| 134750 | | - /* left */ { 6, 4, JT_LEFT|JT_OUTER }, |
| 134751 | | - /* outer */ { 10, 5, JT_OUTER }, |
| 134752 | | - /* right */ { 14, 5, JT_RIGHT|JT_OUTER }, |
| 134753 | | - /* full */ { 19, 4, JT_LEFT|JT_RIGHT|JT_OUTER }, |
| 134754 | | - /* inner */ { 23, 5, JT_INNER }, |
| 134755 | | - /* cross */ { 28, 5, JT_INNER|JT_CROSS }, |
| 135489 | + /* (0) natural */ { 0, 7, JT_NATURAL }, |
| 135490 | + /* (1) left */ { 6, 4, JT_LEFT|JT_OUTER }, |
| 135491 | + /* (2) outer */ { 10, 5, JT_OUTER }, |
| 135492 | + /* (3) right */ { 14, 5, JT_RIGHT|JT_OUTER }, |
| 135493 | + /* (4) full */ { 19, 4, JT_LEFT|JT_RIGHT|JT_OUTER }, |
| 135494 | + /* (5) inner */ { 23, 5, JT_INNER }, |
| 135495 | + /* (6) cross */ { 28, 5, JT_INNER|JT_CROSS }, |
| 134756 | 135496 | }; |
| 134757 | 135497 | int i, j; |
| 134758 | 135498 | apAll[0] = pA; |
| 134759 | 135499 | apAll[1] = pB; |
| 134760 | 135500 | apAll[2] = pC; |
| | @@ -134773,22 +135513,19 @@ |
| 134773 | 135513 | break; |
| 134774 | 135514 | } |
| 134775 | 135515 | } |
| 134776 | 135516 | if( |
| 134777 | 135517 | (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) || |
| 134778 | | - (jointype & JT_ERROR)!=0 |
| 135518 | + (jointype & JT_ERROR)!=0 || |
| 135519 | + (jointype & (JT_OUTER|JT_LEFT|JT_RIGHT))==JT_OUTER |
| 134779 | 135520 | ){ |
| 134780 | | - const char *zSp = " "; |
| 134781 | | - assert( pB!=0 ); |
| 134782 | | - if( pC==0 ){ zSp++; } |
| 134783 | | - sqlite3ErrorMsg(pParse, "unknown or unsupported join type: " |
| 134784 | | - "%T %T%s%T", pA, pB, zSp, pC); |
| 134785 | | - jointype = JT_INNER; |
| 134786 | | - }else if( (jointype & JT_OUTER)!=0 |
| 134787 | | - && (jointype & (JT_LEFT|JT_RIGHT))!=JT_LEFT ){ |
| 134788 | | - sqlite3ErrorMsg(pParse, |
| 134789 | | - "RIGHT and FULL OUTER JOINs are not currently supported"); |
| 135521 | + const char *zSp1 = " "; |
| 135522 | + const char *zSp2 = " "; |
| 135523 | + if( pB==0 ){ zSp1++; } |
| 135524 | + if( pC==0 ){ zSp2++; } |
| 135525 | + sqlite3ErrorMsg(pParse, "unknown join type: " |
| 135526 | + "%T%s%T%s%T", pA, zSp1, pB, zSp2, pC); |
| 134790 | 135527 | jointype = JT_INNER; |
| 134791 | 135528 | } |
| 134792 | 135529 | return jointype; |
| 134793 | 135530 | } |
| 134794 | 135531 | |
| | @@ -134805,106 +135542,81 @@ |
| 134805 | 135542 | } |
| 134806 | 135543 | return -1; |
| 134807 | 135544 | } |
| 134808 | 135545 | |
| 134809 | 135546 | /* |
| 134810 | | -** Search the first N tables in pSrc, from left to right, looking for a |
| 134811 | | -** table that has a column named zCol. |
| 135547 | +** Mark a subquery result column as having been used. |
| 135548 | +*/ |
| 135549 | +SQLITE_PRIVATE void sqlite3SrcItemColumnUsed(SrcItem *pItem, int iCol){ |
| 135550 | + assert( pItem!=0 ); |
| 135551 | + assert( pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) ); |
| 135552 | + if( pItem->fg.isNestedFrom ){ |
| 135553 | + ExprList *pResults; |
| 135554 | + assert( pItem->pSelect!=0 ); |
| 135555 | + pResults = pItem->pSelect->pEList; |
| 135556 | + assert( pResults!=0 ); |
| 135557 | + assert( iCol>=0 && iCol<pResults->nExpr ); |
| 135558 | + pResults->a[iCol].bUsed = 1; |
| 135559 | + } |
| 135560 | +} |
| 135561 | + |
| 135562 | +/* |
| 135563 | +** Search the tables iStart..iEnd (inclusive) in pSrc, looking for a |
| 135564 | +** table that has a column named zCol. The search is left-to-right. |
| 135565 | +** The first match found is returned. |
| 134812 | 135566 | ** |
| 134813 | 135567 | ** When found, set *piTab and *piCol to the table index and column index |
| 134814 | 135568 | ** of the matching column and return TRUE. |
| 134815 | 135569 | ** |
| 134816 | 135570 | ** If not found, return FALSE. |
| 134817 | 135571 | */ |
| 134818 | 135572 | static int tableAndColumnIndex( |
| 134819 | 135573 | SrcList *pSrc, /* Array of tables to search */ |
| 134820 | | - int N, /* Number of tables in pSrc->a[] to search */ |
| 135574 | + int iStart, /* First member of pSrc->a[] to check */ |
| 135575 | + int iEnd, /* Last member of pSrc->a[] to check */ |
| 134821 | 135576 | const char *zCol, /* Name of the column we are looking for */ |
| 134822 | 135577 | int *piTab, /* Write index of pSrc->a[] here */ |
| 134823 | 135578 | int *piCol, /* Write index of pSrc->a[*piTab].pTab->aCol[] here */ |
| 134824 | | - int bIgnoreHidden /* True to ignore hidden columns */ |
| 135579 | + int bIgnoreHidden /* Ignore hidden columns */ |
| 134825 | 135580 | ){ |
| 134826 | 135581 | int i; /* For looping over tables in pSrc */ |
| 134827 | 135582 | int iCol; /* Index of column matching zCol */ |
| 134828 | 135583 | |
| 135584 | + assert( iEnd<pSrc->nSrc ); |
| 135585 | + assert( iStart>=0 ); |
| 134829 | 135586 | assert( (piTab==0)==(piCol==0) ); /* Both or neither are NULL */ |
| 134830 | | - for(i=0; i<N; i++){ |
| 135587 | + |
| 135588 | + for(i=iStart; i<=iEnd; i++){ |
| 134831 | 135589 | iCol = sqlite3ColumnIndex(pSrc->a[i].pTab, zCol); |
| 134832 | 135590 | if( iCol>=0 |
| 134833 | 135591 | && (bIgnoreHidden==0 || IsHiddenColumn(&pSrc->a[i].pTab->aCol[iCol])==0) |
| 134834 | 135592 | ){ |
| 134835 | 135593 | if( piTab ){ |
| 135594 | + sqlite3SrcItemColumnUsed(&pSrc->a[i], iCol); |
| 134836 | 135595 | *piTab = i; |
| 134837 | 135596 | *piCol = iCol; |
| 134838 | 135597 | } |
| 134839 | 135598 | return 1; |
| 134840 | 135599 | } |
| 134841 | 135600 | } |
| 134842 | 135601 | return 0; |
| 134843 | 135602 | } |
| 134844 | 135603 | |
| 134845 | | -/* |
| 134846 | | -** This function is used to add terms implied by JOIN syntax to the |
| 134847 | | -** WHERE clause expression of a SELECT statement. The new term, which |
| 134848 | | -** is ANDed with the existing WHERE clause, is of the form: |
| 134849 | | -** |
| 134850 | | -** (tab1.col1 = tab2.col2) |
| 134851 | | -** |
| 134852 | | -** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the |
| 134853 | | -** (iSrc+1)'th. Column col1 is column iColLeft of tab1, and col2 is |
| 134854 | | -** column iColRight of tab2. |
| 134855 | | -*/ |
| 134856 | | -static void addWhereTerm( |
| 134857 | | - Parse *pParse, /* Parsing context */ |
| 134858 | | - SrcList *pSrc, /* List of tables in FROM clause */ |
| 134859 | | - int iLeft, /* Index of first table to join in pSrc */ |
| 134860 | | - int iColLeft, /* Index of column in first table */ |
| 134861 | | - int iRight, /* Index of second table in pSrc */ |
| 134862 | | - int iColRight, /* Index of column in second table */ |
| 134863 | | - int isOuterJoin, /* True if this is an OUTER join */ |
| 134864 | | - Expr **ppWhere /* IN/OUT: The WHERE clause to add to */ |
| 134865 | | -){ |
| 134866 | | - sqlite3 *db = pParse->db; |
| 134867 | | - Expr *pE1; |
| 134868 | | - Expr *pE2; |
| 134869 | | - Expr *pEq; |
| 134870 | | - |
| 134871 | | - assert( iLeft<iRight ); |
| 134872 | | - assert( pSrc->nSrc>iRight ); |
| 134873 | | - assert( pSrc->a[iLeft].pTab ); |
| 134874 | | - assert( pSrc->a[iRight].pTab ); |
| 134875 | | - |
| 134876 | | - pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft); |
| 134877 | | - pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight); |
| 134878 | | - |
| 134879 | | - pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2); |
| 134880 | | - assert( pE2!=0 || pEq==0 ); /* Due to db->mallocFailed test |
| 134881 | | - ** in sqlite3DbMallocRawNN() called from |
| 134882 | | - ** sqlite3PExpr(). */ |
| 134883 | | - if( pEq && isOuterJoin ){ |
| 134884 | | - ExprSetProperty(pEq, EP_FromJoin); |
| 134885 | | - assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) ); |
| 134886 | | - ExprSetVVAProperty(pEq, EP_NoReduce); |
| 134887 | | - pEq->w.iRightJoinTable = pE2->iTable; |
| 134888 | | - } |
| 134889 | | - *ppWhere = sqlite3ExprAnd(pParse, *ppWhere, pEq); |
| 134890 | | -} |
| 134891 | | - |
| 134892 | 135604 | /* |
| 134893 | 135605 | ** Set the EP_FromJoin property on all terms of the given expression. |
| 134894 | | -** And set the Expr.w.iRightJoinTable to iTable for every term in the |
| 135606 | +** And set the Expr.w.iJoin to iTable for every term in the |
| 134895 | 135607 | ** expression. |
| 134896 | 135608 | ** |
| 134897 | 135609 | ** The EP_FromJoin property is used on terms of an expression to tell |
| 134898 | | -** the LEFT OUTER JOIN processing logic that this term is part of the |
| 135610 | +** the OUTER JOIN processing logic that this term is part of the |
| 134899 | 135611 | ** join restriction specified in the ON or USING clause and not a part |
| 134900 | 135612 | ** of the more general WHERE clause. These terms are moved over to the |
| 134901 | 135613 | ** WHERE clause during join processing but we need to remember that they |
| 134902 | 135614 | ** originated in the ON or USING clause. |
| 134903 | 135615 | ** |
| 134904 | | -** The Expr.w.iRightJoinTable tells the WHERE clause processing that the |
| 134905 | | -** expression depends on table w.iRightJoinTable even if that table is not |
| 135616 | +** The Expr.w.iJoin tells the WHERE clause processing that the |
| 135617 | +** expression depends on table w.iJoin even if that table is not |
| 134906 | 135618 | ** explicitly mentioned in the expression. That information is needed |
| 134907 | 135619 | ** for cases like this: |
| 134908 | 135620 | ** |
| 134909 | 135621 | ** SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5 |
| 134910 | 135622 | ** |
| | @@ -134913,41 +135625,43 @@ |
| 134913 | 135625 | ** NULL t2 row will be inserted whenever t1.x!=5. If we do not |
| 134914 | 135626 | ** defer the handling of t1.x=5, it will be processed immediately |
| 134915 | 135627 | ** after the t1 loop and rows with t1.x!=5 will never appear in |
| 134916 | 135628 | ** the output, which is incorrect. |
| 134917 | 135629 | */ |
| 134918 | | -SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){ |
| 135630 | +SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable, u32 joinFlag){ |
| 135631 | + assert( joinFlag==EP_FromJoin || joinFlag==EP_InnerJoin ); |
| 134919 | 135632 | while( p ){ |
| 134920 | | - ExprSetProperty(p, EP_FromJoin); |
| 135633 | + ExprSetProperty(p, joinFlag); |
| 134921 | 135634 | assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); |
| 134922 | 135635 | ExprSetVVAProperty(p, EP_NoReduce); |
| 134923 | | - p->w.iRightJoinTable = iTable; |
| 135636 | + p->w.iJoin = iTable; |
| 134924 | 135637 | if( p->op==TK_FUNCTION ){ |
| 134925 | 135638 | assert( ExprUseXList(p) ); |
| 134926 | 135639 | if( p->x.pList ){ |
| 134927 | 135640 | int i; |
| 134928 | 135641 | for(i=0; i<p->x.pList->nExpr; i++){ |
| 134929 | | - sqlite3SetJoinExpr(p->x.pList->a[i].pExpr, iTable); |
| 135642 | + sqlite3SetJoinExpr(p->x.pList->a[i].pExpr, iTable, joinFlag); |
| 134930 | 135643 | } |
| 134931 | 135644 | } |
| 134932 | 135645 | } |
| 134933 | | - sqlite3SetJoinExpr(p->pLeft, iTable); |
| 135646 | + sqlite3SetJoinExpr(p->pLeft, iTable, joinFlag); |
| 134934 | 135647 | p = p->pRight; |
| 134935 | 135648 | } |
| 134936 | 135649 | } |
| 134937 | 135650 | |
| 134938 | 135651 | /* Undo the work of sqlite3SetJoinExpr(). In the expression p, convert every |
| 134939 | | -** term that is marked with EP_FromJoin and w.iRightJoinTable==iTable into |
| 135652 | +** term that is marked with EP_FromJoin and w.iJoin==iTable into |
| 134940 | 135653 | ** an ordinary term that omits the EP_FromJoin mark. |
| 134941 | 135654 | ** |
| 134942 | 135655 | ** This happens when a LEFT JOIN is simplified into an ordinary JOIN. |
| 134943 | 135656 | */ |
| 134944 | 135657 | static void unsetJoinExpr(Expr *p, int iTable){ |
| 134945 | 135658 | while( p ){ |
| 134946 | 135659 | if( ExprHasProperty(p, EP_FromJoin) |
| 134947 | | - && (iTable<0 || p->w.iRightJoinTable==iTable) ){ |
| 135660 | + && (iTable<0 || p->w.iJoin==iTable) ){ |
| 134948 | 135661 | ExprClearProperty(p, EP_FromJoin); |
| 135662 | + ExprSetProperty(p, EP_InnerJoin); |
| 134949 | 135663 | } |
| 134950 | 135664 | if( p->op==TK_COLUMN && p->iTable==iTable ){ |
| 134951 | 135665 | ExprClearProperty(p, EP_CanBeNull); |
| 134952 | 135666 | } |
| 134953 | 135667 | if( p->op==TK_FUNCTION ){ |
| | @@ -134964,23 +135678,30 @@ |
| 134964 | 135678 | } |
| 134965 | 135679 | } |
| 134966 | 135680 | |
| 134967 | 135681 | /* |
| 134968 | 135682 | ** This routine processes the join information for a SELECT statement. |
| 134969 | | -** ON and USING clauses are converted into extra terms of the WHERE clause. |
| 134970 | | -** NATURAL joins also create extra WHERE clause terms. |
| 135683 | +** |
| 135684 | +** * A NATURAL join is converted into a USING join. After that, we |
| 135685 | +** do not need to be concerned with NATURAL joins and we only have |
| 135686 | +** think about USING joins. |
| 135687 | +** |
| 135688 | +** * ON and USING clauses result in extra terms being added to the |
| 135689 | +** WHERE clause to enforce the specified constraints. The extra |
| 135690 | +** WHERE clause terms will be tagged with EP_FromJoin or |
| 135691 | +** EP_InnerJoin so that we know that they originated in ON/USING. |
| 134971 | 135692 | ** |
| 134972 | 135693 | ** The terms of a FROM clause are contained in the Select.pSrc structure. |
| 134973 | 135694 | ** The left most table is the first entry in Select.pSrc. The right-most |
| 134974 | 135695 | ** table is the last entry. The join operator is held in the entry to |
| 134975 | | -** the left. Thus entry 0 contains the join operator for the join between |
| 135696 | +** the right. Thus entry 1 contains the join operator for the join between |
| 134976 | 135697 | ** entries 0 and 1. Any ON or USING clauses associated with the join are |
| 134977 | | -** also attached to the left entry. |
| 135698 | +** also attached to the right entry. |
| 134978 | 135699 | ** |
| 134979 | 135700 | ** This routine returns the number of errors encountered. |
| 134980 | 135701 | */ |
| 134981 | | -static int sqliteProcessJoin(Parse *pParse, Select *p){ |
| 135702 | +static int sqlite3ProcessJoin(Parse *pParse, Select *p){ |
| 134982 | 135703 | SrcList *pSrc; /* All tables in the FROM clause */ |
| 134983 | 135704 | int i, j; /* Loop counters */ |
| 134984 | 135705 | SrcItem *pLeft; /* Left table being joined */ |
| 134985 | 135706 | SrcItem *pRight; /* Right table being joined */ |
| 134986 | 135707 | |
| | @@ -134987,83 +135708,135 @@ |
| 134987 | 135708 | pSrc = p->pSrc; |
| 134988 | 135709 | pLeft = &pSrc->a[0]; |
| 134989 | 135710 | pRight = &pLeft[1]; |
| 134990 | 135711 | for(i=0; i<pSrc->nSrc-1; i++, pRight++, pLeft++){ |
| 134991 | 135712 | Table *pRightTab = pRight->pTab; |
| 134992 | | - int isOuter; |
| 135713 | + u32 joinType; |
| 134993 | 135714 | |
| 134994 | 135715 | if( NEVER(pLeft->pTab==0 || pRightTab==0) ) continue; |
| 134995 | | - isOuter = (pRight->fg.jointype & JT_OUTER)!=0; |
| 135716 | + joinType = (pRight->fg.jointype & JT_OUTER)!=0 ? EP_FromJoin : EP_InnerJoin; |
| 134996 | 135717 | |
| 134997 | | - /* When the NATURAL keyword is present, add WHERE clause terms for |
| 134998 | | - ** every column that the two tables have in common. |
| 135718 | + /* If this is a NATURAL join, synthesize an approprate USING clause |
| 135719 | + ** to specify which columns should be joined. |
| 134999 | 135720 | */ |
| 135000 | 135721 | if( pRight->fg.jointype & JT_NATURAL ){ |
| 135001 | | - if( pRight->pOn || pRight->pUsing ){ |
| 135722 | + IdList *pUsing = 0; |
| 135723 | + if( pRight->fg.isUsing || pRight->u3.pOn ){ |
| 135002 | 135724 | sqlite3ErrorMsg(pParse, "a NATURAL join may not have " |
| 135003 | 135725 | "an ON or USING clause", 0); |
| 135004 | 135726 | return 1; |
| 135005 | 135727 | } |
| 135006 | 135728 | for(j=0; j<pRightTab->nCol; j++){ |
| 135007 | 135729 | char *zName; /* Name of column in the right table */ |
| 135008 | | - int iLeft; /* Matching left table */ |
| 135009 | | - int iLeftCol; /* Matching column in the left table */ |
| 135010 | 135730 | |
| 135011 | 135731 | if( IsHiddenColumn(&pRightTab->aCol[j]) ) continue; |
| 135012 | 135732 | zName = pRightTab->aCol[j].zCnName; |
| 135013 | | - if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol, 1) ){ |
| 135014 | | - addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j, |
| 135015 | | - isOuter, &p->pWhere); |
| 135016 | | - } |
| 135017 | | - } |
| 135018 | | - } |
| 135019 | | - |
| 135020 | | - /* Disallow both ON and USING clauses in the same join |
| 135021 | | - */ |
| 135022 | | - if( pRight->pOn && pRight->pUsing ){ |
| 135023 | | - sqlite3ErrorMsg(pParse, "cannot have both ON and USING " |
| 135024 | | - "clauses in the same join"); |
| 135025 | | - return 1; |
| 135026 | | - } |
| 135027 | | - |
| 135028 | | - /* Add the ON clause to the end of the WHERE clause, connected by |
| 135029 | | - ** an AND operator. |
| 135030 | | - */ |
| 135031 | | - if( pRight->pOn ){ |
| 135032 | | - if( isOuter ) sqlite3SetJoinExpr(pRight->pOn, pRight->iCursor); |
| 135033 | | - p->pWhere = sqlite3ExprAnd(pParse, p->pWhere, pRight->pOn); |
| 135034 | | - pRight->pOn = 0; |
| 135733 | + if( tableAndColumnIndex(pSrc, 0, i, zName, 0, 0, 1) ){ |
| 135734 | + pUsing = sqlite3IdListAppend(pParse, pUsing, 0); |
| 135735 | + if( pUsing ){ |
| 135736 | + assert( pUsing->nId>0 ); |
| 135737 | + assert( pUsing->a[pUsing->nId-1].zName==0 ); |
| 135738 | + pUsing->a[pUsing->nId-1].zName = sqlite3DbStrDup(pParse->db, zName); |
| 135739 | + } |
| 135740 | + } |
| 135741 | + } |
| 135742 | + if( pUsing ){ |
| 135743 | + pRight->fg.isUsing = 1; |
| 135744 | + pRight->fg.isSynthUsing = 1; |
| 135745 | + pRight->u3.pUsing = pUsing; |
| 135746 | + } |
| 135747 | + if( pParse->nErr ) return 1; |
| 135035 | 135748 | } |
| 135036 | 135749 | |
| 135037 | 135750 | /* Create extra terms on the WHERE clause for each column named |
| 135038 | 135751 | ** in the USING clause. Example: If the two tables to be joined are |
| 135039 | 135752 | ** A and B and the USING clause names X, Y, and Z, then add this |
| 135040 | 135753 | ** to the WHERE clause: A.X=B.X AND A.Y=B.Y AND A.Z=B.Z |
| 135041 | 135754 | ** Report an error if any column mentioned in the USING clause is |
| 135042 | 135755 | ** not contained in both tables to be joined. |
| 135043 | 135756 | */ |
| 135044 | | - if( pRight->pUsing ){ |
| 135045 | | - IdList *pList = pRight->pUsing; |
| 135757 | + if( pRight->fg.isUsing ){ |
| 135758 | + IdList *pList = pRight->u3.pUsing; |
| 135759 | + sqlite3 *db = pParse->db; |
| 135760 | + assert( pList!=0 ); |
| 135046 | 135761 | for(j=0; j<pList->nId; j++){ |
| 135047 | 135762 | char *zName; /* Name of the term in the USING clause */ |
| 135048 | 135763 | int iLeft; /* Table on the left with matching column name */ |
| 135049 | 135764 | int iLeftCol; /* Column number of matching column on the left */ |
| 135050 | 135765 | int iRightCol; /* Column number of matching column on the right */ |
| 135766 | + Expr *pE1; /* Reference to the column on the LEFT of the join */ |
| 135767 | + Expr *pE2; /* Reference to the column on the RIGHT of the join */ |
| 135768 | + Expr *pEq; /* Equality constraint. pE1 == pE2 */ |
| 135051 | 135769 | |
| 135052 | 135770 | zName = pList->a[j].zName; |
| 135053 | 135771 | iRightCol = sqlite3ColumnIndex(pRightTab, zName); |
| 135054 | 135772 | if( iRightCol<0 |
| 135055 | | - || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol, 0) |
| 135773 | + || tableAndColumnIndex(pSrc, 0, i, zName, &iLeft, &iLeftCol, |
| 135774 | + pRight->fg.isSynthUsing)==0 |
| 135056 | 135775 | ){ |
| 135057 | 135776 | sqlite3ErrorMsg(pParse, "cannot join using column %s - column " |
| 135058 | 135777 | "not present in both tables", zName); |
| 135059 | 135778 | return 1; |
| 135060 | 135779 | } |
| 135061 | | - addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, iRightCol, |
| 135062 | | - isOuter, &p->pWhere); |
| 135780 | + pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iLeftCol); |
| 135781 | + sqlite3SrcItemColumnUsed(&pSrc->a[iLeft], iLeftCol); |
| 135782 | + if( (pSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ |
| 135783 | + /* This branch runs if the query contains one or more RIGHT or FULL |
| 135784 | + ** JOINs. If only a single table on the left side of this join |
| 135785 | + ** contains the zName column, then this branch is a no-op. |
| 135786 | + ** But if there are two or more tables on the left side |
| 135787 | + ** of the join, construct a coalesce() function that gathers all |
| 135788 | + ** such tables. Raise an error if more than one of those references |
| 135789 | + ** to zName is not also within a prior USING clause. |
| 135790 | + ** |
| 135791 | + ** We really ought to raise an error if there are two or more |
| 135792 | + ** non-USING references to zName on the left of an INNER or LEFT |
| 135793 | + ** JOIN. But older versions of SQLite do not do that, so we avoid |
| 135794 | + ** adding a new error so as to not break legacy applications. |
| 135795 | + */ |
| 135796 | + ExprList *pFuncArgs = 0; /* Arguments to the coalesce() */ |
| 135797 | + static const Token tkCoalesce = { "coalesce", 8 }; |
| 135798 | + while( tableAndColumnIndex(pSrc, iLeft+1, i, zName, &iLeft, &iLeftCol, |
| 135799 | + pRight->fg.isSynthUsing)!=0 ){ |
| 135800 | + if( pSrc->a[iLeft].fg.isUsing==0 |
| 135801 | + || sqlite3IdListIndex(pSrc->a[iLeft].u3.pUsing, zName)<0 |
| 135802 | + ){ |
| 135803 | + sqlite3ErrorMsg(pParse, "ambiguous reference to %s in USING()", |
| 135804 | + zName); |
| 135805 | + break; |
| 135806 | + } |
| 135807 | + pFuncArgs = sqlite3ExprListAppend(pParse, pFuncArgs, pE1); |
| 135808 | + pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iLeftCol); |
| 135809 | + sqlite3SrcItemColumnUsed(&pSrc->a[iLeft], iLeftCol); |
| 135810 | + } |
| 135811 | + if( pFuncArgs ){ |
| 135812 | + pFuncArgs = sqlite3ExprListAppend(pParse, pFuncArgs, pE1); |
| 135813 | + pE1 = sqlite3ExprFunction(pParse, pFuncArgs, &tkCoalesce, 0); |
| 135814 | + } |
| 135815 | + } |
| 135816 | + pE2 = sqlite3CreateColumnExpr(db, pSrc, i+1, iRightCol); |
| 135817 | + sqlite3SrcItemColumnUsed(pRight, iRightCol); |
| 135818 | + pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2); |
| 135819 | + assert( pE2!=0 || pEq==0 ); |
| 135820 | + if( pEq ){ |
| 135821 | + ExprSetProperty(pEq, joinType); |
| 135822 | + assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) ); |
| 135823 | + ExprSetVVAProperty(pEq, EP_NoReduce); |
| 135824 | + pEq->w.iJoin = pE2->iTable; |
| 135825 | + } |
| 135826 | + p->pWhere = sqlite3ExprAnd(pParse, p->pWhere, pEq); |
| 135063 | 135827 | } |
| 135064 | 135828 | } |
| 135829 | + |
| 135830 | + /* Add the ON clause to the end of the WHERE clause, connected by |
| 135831 | + ** an AND operator. |
| 135832 | + */ |
| 135833 | + else if( pRight->u3.pOn ){ |
| 135834 | + sqlite3SetJoinExpr(pRight->u3.pOn, pRight->iCursor, joinType); |
| 135835 | + p->pWhere = sqlite3ExprAnd(pParse, p->pWhere, pRight->u3.pOn); |
| 135836 | + pRight->u3.pOn = 0; |
| 135837 | + } |
| 135065 | 135838 | } |
| 135066 | 135839 | return 0; |
| 135067 | 135840 | } |
| 135068 | 135841 | |
| 135069 | 135842 | /* |
| | @@ -136628,16 +137401,17 @@ |
| 136628 | 137401 | assert( nCol==(i16)nCol ); |
| 136629 | 137402 | *pnCol = nCol; |
| 136630 | 137403 | *paCol = aCol; |
| 136631 | 137404 | |
| 136632 | 137405 | for(i=0, pCol=aCol; i<nCol && !db->mallocFailed; i++, pCol++){ |
| 137406 | + struct ExprList_item *pX = &pEList->a[i]; |
| 136633 | 137407 | /* Get an appropriate name for the column |
| 136634 | 137408 | */ |
| 136635 | | - if( (zName = pEList->a[i].zEName)!=0 && pEList->a[i].eEName==ENAME_NAME ){ |
| 137409 | + if( (zName = pX->zEName)!=0 && pX->eEName==ENAME_NAME ){ |
| 136636 | 137410 | /* If the column contains an "AS <name>" phrase, use <name> as the name */ |
| 136637 | 137411 | }else{ |
| 136638 | | - Expr *pColExpr = sqlite3ExprSkipCollateAndLikely(pEList->a[i].pExpr); |
| 137412 | + Expr *pColExpr = sqlite3ExprSkipCollateAndLikely(pX->pExpr); |
| 136639 | 137413 | while( ALWAYS(pColExpr!=0) && pColExpr->op==TK_DOT ){ |
| 136640 | 137414 | pColExpr = pColExpr->pRight; |
| 136641 | 137415 | assert( pColExpr!=0 ); |
| 136642 | 137416 | } |
| 136643 | 137417 | if( pColExpr->op==TK_COLUMN |
| | @@ -136651,11 +137425,11 @@ |
| 136651 | 137425 | }else if( pColExpr->op==TK_ID ){ |
| 136652 | 137426 | assert( !ExprHasProperty(pColExpr, EP_IntValue) ); |
| 136653 | 137427 | zName = pColExpr->u.zToken; |
| 136654 | 137428 | }else{ |
| 136655 | 137429 | /* Use the original text of the column expression as its name */ |
| 136656 | | - zName = pEList->a[i].zEName; |
| 137430 | + assert( zName==pX->zEName ); /* pointer comparison intended */ |
| 136657 | 137431 | } |
| 136658 | 137432 | } |
| 136659 | 137433 | if( zName && !sqlite3IsTrueOrFalse(zName) ){ |
| 136660 | 137434 | zName = sqlite3DbStrDup(db, zName); |
| 136661 | 137435 | }else{ |
| | @@ -138144,16 +138918,44 @@ |
| 138144 | 138918 | /* An instance of the SubstContext object describes an substitution edit |
| 138145 | 138919 | ** to be performed on a parse tree. |
| 138146 | 138920 | ** |
| 138147 | 138921 | ** All references to columns in table iTable are to be replaced by corresponding |
| 138148 | 138922 | ** expressions in pEList. |
| 138923 | +** |
| 138924 | +** ## About "isOuterJoin": |
| 138925 | +** |
| 138926 | +** The isOuterJoin column indicates that the replacement will occur into a |
| 138927 | +** position in the parent that NULL-able due to an OUTER JOIN. Either the |
| 138928 | +** target slot in the parent is the right operand of a LEFT JOIN, or one of |
| 138929 | +** the left operands of a RIGHT JOIN. In either case, we need to potentially |
| 138930 | +** bypass the substituted expression with OP_IfNullRow. |
| 138931 | +** |
| 138932 | +** Suppose the original expression integer constant. Even though the table |
| 138933 | +** has the nullRow flag set, because the expression is an integer constant, |
| 138934 | +** it will not be NULLed out. So instead, we insert an OP_IfNullRow opcode |
| 138935 | +** that checks to see if the nullRow flag is set on the table. If the nullRow |
| 138936 | +** flag is set, then the value in the register is set to NULL and the original |
| 138937 | +** expression is bypassed. If the nullRow flag is not set, then the original |
| 138938 | +** expression runs to populate the register. |
| 138939 | +** |
| 138940 | +** Example where this is needed: |
| 138941 | +** |
| 138942 | +** CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT); |
| 138943 | +** CREATE TABLE t2(x INT UNIQUE); |
| 138944 | +** |
| 138945 | +** SELECT a,b,m,x FROM t1 LEFT JOIN (SELECT 59 AS m,x FROM t2) ON b=x; |
| 138946 | +** |
| 138947 | +** When the subquery on the right side of the LEFT JOIN is flattened, we |
| 138948 | +** have to add OP_IfNullRow in front of the OP_Integer that implements the |
| 138949 | +** "m" value of the subquery so that a NULL will be loaded instead of 59 |
| 138950 | +** when processing a non-matched row of the left. |
| 138149 | 138951 | */ |
| 138150 | 138952 | typedef struct SubstContext { |
| 138151 | 138953 | Parse *pParse; /* The parsing context */ |
| 138152 | 138954 | int iTable; /* Replace references to this table */ |
| 138153 | 138955 | int iNewTable; /* New table number */ |
| 138154 | | - int isLeftJoin; /* Add TK_IF_NULL_ROW opcodes on each replacement */ |
| 138956 | + int isOuterJoin; /* Add TK_IF_NULL_ROW opcodes on each replacement */ |
| 138155 | 138957 | ExprList *pEList; /* Replacement expressions */ |
| 138156 | 138958 | } SubstContext; |
| 138157 | 138959 | |
| 138158 | 138960 | /* Forward Declarations */ |
| 138159 | 138961 | static void substExprList(SubstContext*, ExprList*); |
| | @@ -138176,13 +138978,13 @@ |
| 138176 | 138978 | SubstContext *pSubst, /* Description of the substitution */ |
| 138177 | 138979 | Expr *pExpr /* Expr in which substitution occurs */ |
| 138178 | 138980 | ){ |
| 138179 | 138981 | if( pExpr==0 ) return 0; |
| 138180 | 138982 | if( ExprHasProperty(pExpr, EP_FromJoin) |
| 138181 | | - && pExpr->w.iRightJoinTable==pSubst->iTable |
| 138983 | + && pExpr->w.iJoin==pSubst->iTable |
| 138182 | 138984 | ){ |
| 138183 | | - pExpr->w.iRightJoinTable = pSubst->iNewTable; |
| 138985 | + pExpr->w.iJoin = pSubst->iNewTable; |
| 138184 | 138986 | } |
| 138185 | 138987 | if( pExpr->op==TK_COLUMN |
| 138186 | 138988 | && pExpr->iTable==pSubst->iTable |
| 138187 | 138989 | && !ExprHasProperty(pExpr, EP_FixedCol) |
| 138188 | 138990 | ){ |
| | @@ -138199,11 +139001,11 @@ |
| 138199 | 139001 | assert( pExpr->pRight==0 ); |
| 138200 | 139002 | if( sqlite3ExprIsVector(pCopy) ){ |
| 138201 | 139003 | sqlite3VectorErrorMsg(pSubst->pParse, pCopy); |
| 138202 | 139004 | }else{ |
| 138203 | 139005 | sqlite3 *db = pSubst->pParse->db; |
| 138204 | | - if( pSubst->isLeftJoin && pCopy->op!=TK_COLUMN ){ |
| 139006 | + if( pSubst->isOuterJoin && pCopy->op!=TK_COLUMN ){ |
| 138205 | 139007 | memset(&ifNullRow, 0, sizeof(ifNullRow)); |
| 138206 | 139008 | ifNullRow.op = TK_IF_NULL_ROW; |
| 138207 | 139009 | ifNullRow.pLeft = pCopy; |
| 138208 | 139010 | ifNullRow.iTable = pSubst->iNewTable; |
| 138209 | 139011 | ifNullRow.flags = EP_IfNullRow; |
| | @@ -138213,15 +139015,16 @@ |
| 138213 | 139015 | pNew = sqlite3ExprDup(db, pCopy, 0); |
| 138214 | 139016 | if( db->mallocFailed ){ |
| 138215 | 139017 | sqlite3ExprDelete(db, pNew); |
| 138216 | 139018 | return pExpr; |
| 138217 | 139019 | } |
| 138218 | | - if( pSubst->isLeftJoin ){ |
| 139020 | + if( pSubst->isOuterJoin ){ |
| 138219 | 139021 | ExprSetProperty(pNew, EP_CanBeNull); |
| 138220 | 139022 | } |
| 138221 | | - if( ExprHasProperty(pExpr,EP_FromJoin) ){ |
| 138222 | | - sqlite3SetJoinExpr(pNew, pExpr->w.iRightJoinTable); |
| 139023 | + if( ExprHasProperty(pExpr,EP_FromJoin|EP_InnerJoin) ){ |
| 139024 | + sqlite3SetJoinExpr(pNew, pExpr->w.iJoin, |
| 139025 | + pExpr->flags & (EP_FromJoin|EP_InnerJoin)); |
| 138223 | 139026 | } |
| 138224 | 139027 | sqlite3ExprDelete(db, pExpr); |
| 138225 | 139028 | pExpr = pNew; |
| 138226 | 139029 | |
| 138227 | 139030 | /* Ensure that the expression now has an implicit collation sequence, |
| | @@ -138382,11 +139185,11 @@ |
| 138382 | 139185 | int op = pExpr->op; |
| 138383 | 139186 | if( op==TK_COLUMN || op==TK_IF_NULL_ROW ){ |
| 138384 | 139187 | renumberCursorDoMapping(pWalker, &pExpr->iTable); |
| 138385 | 139188 | } |
| 138386 | 139189 | if( ExprHasProperty(pExpr, EP_FromJoin) ){ |
| 138387 | | - renumberCursorDoMapping(pWalker, &pExpr->w.iRightJoinTable); |
| 139190 | + renumberCursorDoMapping(pWalker, &pExpr->w.iJoin); |
| 138388 | 139191 | } |
| 138389 | 139192 | return WRC_Continue; |
| 138390 | 139193 | } |
| 138391 | 139194 | |
| 138392 | 139195 | /* |
| | @@ -138467,10 +139270,11 @@ |
| 138467 | 139270 | ** (3a) the subquery may not be a join and |
| 138468 | 139271 | ** (3b) the FROM clause of the subquery may not contain a virtual |
| 138469 | 139272 | ** table and |
| 138470 | 139273 | ** (3c) the outer query may not be an aggregate. |
| 138471 | 139274 | ** (3d) the outer query may not be DISTINCT. |
| 139275 | +** See also (26) for restrictions on RIGHT JOIN. |
| 138472 | 139276 | ** |
| 138473 | 139277 | ** (4) The subquery can not be DISTINCT. |
| 138474 | 139278 | ** |
| 138475 | 139279 | ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT |
| 138476 | 139280 | ** sub-queries that were excluded from this optimization. Restriction |
| | @@ -138565,10 +139369,16 @@ |
| 138565 | 139369 | ** |
| 138566 | 139370 | ** (25) If either the subquery or the parent query contains a window |
| 138567 | 139371 | ** function in the select list or ORDER BY clause, flattening |
| 138568 | 139372 | ** is not attempted. |
| 138569 | 139373 | ** |
| 139374 | +** (26) The subquery may not be the right operand of a RIGHT JOIN. |
| 139375 | +** See also (3) for restrictions on LEFT JOIN. |
| 139376 | +** |
| 139377 | +** (27) The subquery may not contain a FULL or RIGHT JOIN unless it |
| 139378 | +** is the first element of the parent query. |
| 139379 | +** |
| 138570 | 139380 | ** |
| 138571 | 139381 | ** In this routine, the "p" parameter is a pointer to the outer query. |
| 138572 | 139382 | ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query |
| 138573 | 139383 | ** uses aggregates. |
| 138574 | 139384 | ** |
| | @@ -138590,11 +139400,11 @@ |
| 138590 | 139400 | Select *pSub1; /* Pointer to the rightmost select in sub-query */ |
| 138591 | 139401 | SrcList *pSrc; /* The FROM clause of the outer query */ |
| 138592 | 139402 | SrcList *pSubSrc; /* The FROM clause of the subquery */ |
| 138593 | 139403 | int iParent; /* VDBE cursor number of the pSub result set temp table */ |
| 138594 | 139404 | int iNewParent = -1;/* Replacement table for iParent */ |
| 138595 | | - int isLeftJoin = 0; /* True if pSub is the right side of a LEFT JOIN */ |
| 139405 | + int isOuterJoin = 0; /* True if pSub is the right side of a LEFT JOIN */ |
| 138596 | 139406 | int i; /* Loop counter */ |
| 138597 | 139407 | Expr *pWhere; /* The WHERE clause */ |
| 138598 | 139408 | SrcItem *pSubitem; /* The subquery */ |
| 138599 | 139409 | sqlite3 *db = pParse->db; |
| 138600 | 139410 | Walker w; /* Walker to persist agginfo data */ |
| | @@ -138663,29 +139473,35 @@ |
| 138663 | 139473 | ** aggregates are processed - there is no mechanism to determine if |
| 138664 | 139474 | ** the LEFT JOIN table should be all-NULL. |
| 138665 | 139475 | ** |
| 138666 | 139476 | ** See also tickets #306, #350, and #3300. |
| 138667 | 139477 | */ |
| 138668 | | - if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){ |
| 138669 | | - isLeftJoin = 1; |
| 138670 | | - if( pSubSrc->nSrc>1 /* (3a) */ |
| 138671 | | - || isAgg /* (3b) */ |
| 138672 | | - || IsVirtual(pSubSrc->a[0].pTab) /* (3c) */ |
| 138673 | | - || (p->selFlags & SF_Distinct)!=0 /* (3d) */ |
| 139478 | + if( (pSubitem->fg.jointype & (JT_OUTER|JT_LTORJ))!=0 ){ |
| 139479 | + if( pSubSrc->nSrc>1 /* (3a) */ |
| 139480 | + || isAgg /* (3b) */ |
| 139481 | + || IsVirtual(pSubSrc->a[0].pTab) /* (3c) */ |
| 139482 | + || (p->selFlags & SF_Distinct)!=0 /* (3d) */ |
| 139483 | + || (pSubitem->fg.jointype & JT_RIGHT)!=0 /* (26) */ |
| 138674 | 139484 | ){ |
| 138675 | 139485 | return 0; |
| 138676 | 139486 | } |
| 139487 | + isOuterJoin = 1; |
| 138677 | 139488 | } |
| 138678 | 139489 | #ifdef SQLITE_EXTRA_IFNULLROW |
| 138679 | 139490 | else if( iFrom>0 && !isAgg ){ |
| 138680 | | - /* Setting isLeftJoin to -1 causes OP_IfNullRow opcodes to be generated for |
| 139491 | + /* Setting isOuterJoin to -1 causes OP_IfNullRow opcodes to be generated for |
| 138681 | 139492 | ** every reference to any result column from subquery in a join, even |
| 138682 | 139493 | ** though they are not necessary. This will stress-test the OP_IfNullRow |
| 138683 | 139494 | ** opcode. */ |
| 138684 | | - isLeftJoin = -1; |
| 139495 | + isOuterJoin = -1; |
| 138685 | 139496 | } |
| 138686 | 139497 | #endif |
| 139498 | + |
| 139499 | + assert( pSubSrc->nSrc>0 ); /* True by restriction (7) */ |
| 139500 | + if( iFrom>0 && (pSubSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ |
| 139501 | + return 0; /* Restriction (27) */ |
| 139502 | + } |
| 138687 | 139503 | |
| 138688 | 139504 | /* Restriction (17): If the sub-query is a compound SELECT, then it must |
| 138689 | 139505 | ** use only the UNION ALL operator. And none of the simple select queries |
| 138690 | 139506 | ** that make up the compound SELECT are allowed to be aggregate or distinct |
| 138691 | 139507 | ** queries. |
| | @@ -138692,11 +139508,11 @@ |
| 138692 | 139508 | */ |
| 138693 | 139509 | if( pSub->pPrior ){ |
| 138694 | 139510 | if( pSub->pOrderBy ){ |
| 138695 | 139511 | return 0; /* Restriction (20) */ |
| 138696 | 139512 | } |
| 138697 | | - if( isAgg || (p->selFlags & SF_Distinct)!=0 || isLeftJoin>0 ){ |
| 139513 | + if( isAgg || (p->selFlags & SF_Distinct)!=0 || isOuterJoin>0 ){ |
| 138698 | 139514 | return 0; /* (17d1), (17d2), or (17f) */ |
| 138699 | 139515 | } |
| 138700 | 139516 | for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){ |
| 138701 | 139517 | testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct ); |
| 138702 | 139518 | testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate ); |
| | @@ -138750,11 +139566,11 @@ |
| 138750 | 139566 | sqlite3DbFree(db, pSubitem->zAlias); |
| 138751 | 139567 | pSubitem->zDatabase = 0; |
| 138752 | 139568 | pSubitem->zName = 0; |
| 138753 | 139569 | pSubitem->zAlias = 0; |
| 138754 | 139570 | pSubitem->pSelect = 0; |
| 138755 | | - assert( pSubitem->pOn==0 ); |
| 139571 | + assert( pSubitem->fg.isUsing!=0 || pSubitem->u3.pOn==0 ); |
| 138756 | 139572 | |
| 138757 | 139573 | /* If the sub-query is a compound SELECT statement, then (by restrictions |
| 138758 | 139574 | ** 17 and 18 above) it must be a UNION ALL and the parent query must |
| 138759 | 139575 | ** be of the form: |
| 138760 | 139576 | ** |
| | @@ -138860,10 +139676,11 @@ |
| 138860 | 139676 | */ |
| 138861 | 139677 | pSub = pSub1; |
| 138862 | 139678 | for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){ |
| 138863 | 139679 | int nSubSrc; |
| 138864 | 139680 | u8 jointype = 0; |
| 139681 | + u8 ltorj = pSrc->a[iFrom].fg.jointype & JT_LTORJ; |
| 138865 | 139682 | assert( pSub!=0 ); |
| 138866 | 139683 | pSubSrc = pSub->pSrc; /* FROM clause of subquery */ |
| 138867 | 139684 | nSubSrc = pSubSrc->nSrc; /* Number of terms in subquery FROM clause */ |
| 138868 | 139685 | pSrc = pParent->pSrc; /* FROM clause of the outer query */ |
| 138869 | 139686 | |
| | @@ -138894,17 +139711,20 @@ |
| 138894 | 139711 | |
| 138895 | 139712 | /* Transfer the FROM clause terms from the subquery into the |
| 138896 | 139713 | ** outer query. |
| 138897 | 139714 | */ |
| 138898 | 139715 | for(i=0; i<nSubSrc; i++){ |
| 138899 | | - sqlite3IdListDelete(db, pSrc->a[i+iFrom].pUsing); |
| 138900 | | - assert( pSrc->a[i+iFrom].fg.isTabFunc==0 ); |
| 138901 | | - pSrc->a[i+iFrom] = pSubSrc->a[i]; |
| 139716 | + SrcItem *pItem = &pSrc->a[i+iFrom]; |
| 139717 | + if( pItem->fg.isUsing ) sqlite3IdListDelete(db, pItem->u3.pUsing); |
| 139718 | + assert( pItem->fg.isTabFunc==0 ); |
| 139719 | + *pItem = pSubSrc->a[i]; |
| 139720 | + pItem->fg.jointype |= ltorj; |
| 138902 | 139721 | iNewParent = pSubSrc->a[i].iCursor; |
| 138903 | 139722 | memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i])); |
| 138904 | 139723 | } |
| 138905 | | - pSrc->a[iFrom].fg.jointype = jointype; |
| 139724 | + pSrc->a[iFrom].fg.jointype &= JT_LTORJ; |
| 139725 | + pSrc->a[iFrom].fg.jointype |= jointype | ltorj; |
| 138906 | 139726 | |
| 138907 | 139727 | /* Now begin substituting subquery result set expressions for |
| 138908 | 139728 | ** references to the iParent in the outer query. |
| 138909 | 139729 | ** |
| 138910 | 139730 | ** Example: |
| | @@ -138935,12 +139755,12 @@ |
| 138935 | 139755 | pParent->pOrderBy = pOrderBy; |
| 138936 | 139756 | pSub->pOrderBy = 0; |
| 138937 | 139757 | } |
| 138938 | 139758 | pWhere = pSub->pWhere; |
| 138939 | 139759 | pSub->pWhere = 0; |
| 138940 | | - if( isLeftJoin>0 ){ |
| 138941 | | - sqlite3SetJoinExpr(pWhere, iNewParent); |
| 139760 | + if( isOuterJoin>0 ){ |
| 139761 | + sqlite3SetJoinExpr(pWhere, iNewParent, EP_FromJoin); |
| 138942 | 139762 | } |
| 138943 | 139763 | if( pWhere ){ |
| 138944 | 139764 | if( pParent->pWhere ){ |
| 138945 | 139765 | pParent->pWhere = sqlite3PExpr(pParse, TK_AND, pWhere, pParent->pWhere); |
| 138946 | 139766 | }else{ |
| | @@ -138950,11 +139770,11 @@ |
| 138950 | 139770 | if( db->mallocFailed==0 ){ |
| 138951 | 139771 | SubstContext x; |
| 138952 | 139772 | x.pParse = pParse; |
| 138953 | 139773 | x.iTable = iParent; |
| 138954 | 139774 | x.iNewTable = iNewParent; |
| 138955 | | - x.isLeftJoin = isLeftJoin; |
| 139775 | + x.isOuterJoin = isOuterJoin; |
| 138956 | 139776 | x.pEList = pSub->pEList; |
| 138957 | 139777 | substSelect(&x, pParent, 0); |
| 138958 | 139778 | } |
| 138959 | 139779 | |
| 138960 | 139780 | /* The flattened query is a compound if either the inner or the |
| | @@ -138985,12 +139805,12 @@ |
| 138985 | 139805 | */ |
| 138986 | 139806 | sqlite3AggInfoPersistWalkerInit(&w, pParse); |
| 138987 | 139807 | sqlite3WalkSelect(&w,pSub1); |
| 138988 | 139808 | sqlite3SelectDelete(db, pSub1); |
| 138989 | 139809 | |
| 138990 | | -#if SELECTTRACE_ENABLED |
| 138991 | | - if( sqlite3SelectTrace & 0x100 ){ |
| 139810 | +#if TREETRACE_ENABLED |
| 139811 | + if( sqlite3TreeTrace & 0x100 ){ |
| 138992 | 139812 | SELECTTRACE(0x100,pParse,p,("After flattening:\n")); |
| 138993 | 139813 | sqlite3TreeViewSelect(0, p, 0); |
| 138994 | 139814 | } |
| 138995 | 139815 | #endif |
| 138996 | 139816 | |
| | @@ -139392,16 +140212,16 @@ |
| 139392 | 140212 | iCursor, isLeftJoin); |
| 139393 | 140213 | pWhere = pWhere->pLeft; |
| 139394 | 140214 | } |
| 139395 | 140215 | if( isLeftJoin |
| 139396 | 140216 | && (ExprHasProperty(pWhere,EP_FromJoin)==0 |
| 139397 | | - || pWhere->w.iRightJoinTable!=iCursor) |
| 140217 | + || pWhere->w.iJoin!=iCursor) |
| 139398 | 140218 | ){ |
| 139399 | 140219 | return 0; /* restriction (4) */ |
| 139400 | 140220 | } |
| 139401 | 140221 | if( ExprHasProperty(pWhere,EP_FromJoin) |
| 139402 | | - && pWhere->w.iRightJoinTable!=iCursor |
| 140222 | + && pWhere->w.iJoin!=iCursor |
| 139403 | 140223 | ){ |
| 139404 | 140224 | return 0; /* restriction (5) */ |
| 139405 | 140225 | } |
| 139406 | 140226 | if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){ |
| 139407 | 140227 | nChng++; |
| | @@ -139411,11 +140231,11 @@ |
| 139411 | 140231 | pNew = sqlite3ExprDup(pParse->db, pWhere, 0); |
| 139412 | 140232 | unsetJoinExpr(pNew, -1); |
| 139413 | 140233 | x.pParse = pParse; |
| 139414 | 140234 | x.iTable = iCursor; |
| 139415 | 140235 | x.iNewTable = iCursor; |
| 139416 | | - x.isLeftJoin = 0; |
| 140236 | + x.isOuterJoin = 0; |
| 139417 | 140237 | x.pEList = pSubq->pEList; |
| 139418 | 140238 | pNew = substExpr(&x, pNew); |
| 139419 | 140239 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 139420 | 140240 | if( pSubq->pWin && 0==pushDownWindowCheck(pParse, pSubq, pNew) ){ |
| 139421 | 140241 | /* Restriction 6c has prevented push-down in this case */ |
| | @@ -139620,11 +140440,11 @@ |
| 139620 | 140440 | pParse = pWalker->pParse; |
| 139621 | 140441 | db = pParse->db; |
| 139622 | 140442 | pNew = sqlite3DbMallocZero(db, sizeof(*pNew) ); |
| 139623 | 140443 | if( pNew==0 ) return WRC_Abort; |
| 139624 | 140444 | memset(&dummy, 0, sizeof(dummy)); |
| 139625 | | - pNewSrc = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&dummy,pNew,0,0); |
| 140445 | + pNewSrc = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&dummy,pNew,0); |
| 139626 | 140446 | if( pNewSrc==0 ) return WRC_Abort; |
| 139627 | 140447 | *pNew = *p; |
| 139628 | 140448 | p->pSrc = pNewSrc; |
| 139629 | 140449 | p->pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ASTERISK, 0)); |
| 139630 | 140450 | p->op = TK_SELECT; |
| | @@ -139965,14 +140785,38 @@ |
| 139965 | 140785 | /* The usual case - do not allow ROWID on a subquery */ |
| 139966 | 140786 | pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid; |
| 139967 | 140787 | #else |
| 139968 | 140788 | pTab->tabFlags |= TF_Ephemeral; /* Legacy compatibility mode */ |
| 139969 | 140789 | #endif |
| 139970 | | - |
| 139971 | | - |
| 139972 | 140790 | return pParse->nErr ? SQLITE_ERROR : SQLITE_OK; |
| 139973 | 140791 | } |
| 140792 | + |
| 140793 | + |
| 140794 | +/* |
| 140795 | +** Check the N SrcItem objects to the right of pBase. (N might be zero!) |
| 140796 | +** If any of those SrcItem objects have a USING clause containing zName |
| 140797 | +** then return true. |
| 140798 | +** |
| 140799 | +** If N is zero, or none of the N SrcItem objects to the right of pBase |
| 140800 | +** contains a USING clause, or if none of the USING clauses contain zName, |
| 140801 | +** then return false. |
| 140802 | +*/ |
| 140803 | +static int inAnyUsingClause( |
| 140804 | + const char *zName, /* Name we are looking for */ |
| 140805 | + SrcItem *pBase, /* The base SrcItem. Looking at pBase[1] and following */ |
| 140806 | + int N /* How many SrcItems to check */ |
| 140807 | +){ |
| 140808 | + while( N>0 ){ |
| 140809 | + N--; |
| 140810 | + pBase++; |
| 140811 | + if( pBase->fg.isUsing==0 ) continue; |
| 140812 | + if( NEVER(pBase->u3.pUsing==0) ) continue; |
| 140813 | + if( sqlite3IdListIndex(pBase->u3.pUsing, zName)>=0 ) return 1; |
| 140814 | + } |
| 140815 | + return 0; |
| 140816 | +} |
| 140817 | + |
| 139974 | 140818 | |
| 139975 | 140819 | /* |
| 139976 | 140820 | ** This routine is a Walker callback for "expanding" a SELECT statement. |
| 139977 | 140821 | ** "Expanding" means to do the following: |
| 139978 | 140822 | ** |
| | @@ -140119,11 +140963,11 @@ |
| 140119 | 140963 | } |
| 140120 | 140964 | |
| 140121 | 140965 | /* Process NATURAL keywords, and ON and USING clauses of joins. |
| 140122 | 140966 | */ |
| 140123 | 140967 | assert( db->mallocFailed==0 || pParse->nErr!=0 ); |
| 140124 | | - if( pParse->nErr || sqliteProcessJoin(pParse, p) ){ |
| 140968 | + if( pParse->nErr || sqlite3ProcessJoin(pParse, p) ){ |
| 140125 | 140969 | return WRC_Abort; |
| 140126 | 140970 | } |
| 140127 | 140971 | |
| 140128 | 140972 | /* For every "*" that occurs in the column list, insert the names of |
| 140129 | 140973 | ** all columns in all tables. And for every TABLE.* insert the names |
| | @@ -140183,31 +141027,34 @@ |
| 140183 | 141027 | assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); |
| 140184 | 141028 | zTName = pE->pLeft->u.zToken; |
| 140185 | 141029 | } |
| 140186 | 141030 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 140187 | 141031 | Table *pTab = pFrom->pTab; |
| 140188 | | - Select *pSub = pFrom->pSelect; |
| 141032 | + Select *pSub; |
| 140189 | 141033 | char *zTabName = pFrom->zAlias; |
| 140190 | 141034 | const char *zSchemaName = 0; |
| 140191 | 141035 | int iDb; |
| 140192 | 141036 | if( zTabName==0 ){ |
| 140193 | 141037 | zTabName = pTab->zName; |
| 140194 | 141038 | } |
| 140195 | 141039 | if( db->mallocFailed ) break; |
| 140196 | | - if( pSub==0 || (pSub->selFlags & SF_NestedFrom)==0 ){ |
| 141040 | + assert( pFrom->fg.isNestedFrom == IsNestedFrom(pFrom->pSelect) ); |
| 141041 | + if( pFrom->fg.isNestedFrom ){ |
| 141042 | + pSub = pFrom->pSelect; |
| 141043 | + assert( pSub->pEList!=0 ); |
| 141044 | + assert( pSub->pEList->nExpr==pTab->nCol ); |
| 141045 | + }else{ |
| 140197 | 141046 | pSub = 0; |
| 140198 | 141047 | if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ |
| 140199 | 141048 | continue; |
| 140200 | 141049 | } |
| 140201 | 141050 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 140202 | 141051 | zSchemaName = iDb>=0 ? db->aDb[iDb].zDbSName : "*"; |
| 140203 | 141052 | } |
| 140204 | 141053 | for(j=0; j<pTab->nCol; j++){ |
| 140205 | 141054 | char *zName = pTab->aCol[j].zCnName; |
| 140206 | | - char *zColname; /* The computed column name */ |
| 140207 | | - char *zToFree; /* Malloced string that needs to be freed */ |
| 140208 | | - Token sColname; /* Computed column name as a token */ |
| 141055 | + struct ExprList_item *pX; /* Newly added ExprList term */ |
| 140209 | 141056 | |
| 140210 | 141057 | assert( zName ); |
| 140211 | 141058 | if( zTName && pSub |
| 140212 | 141059 | && sqlite3MatchEName(&pSub->pEList->a[j], 0, zTName, 0)==0 |
| 140213 | 141060 | ){ |
| | @@ -140224,58 +141071,62 @@ |
| 140224 | 141071 | continue; |
| 140225 | 141072 | } |
| 140226 | 141073 | tableSeen = 1; |
| 140227 | 141074 | |
| 140228 | 141075 | if( i>0 && zTName==0 ){ |
| 140229 | | - if( (pFrom->fg.jointype & JT_NATURAL)!=0 |
| 140230 | | - && tableAndColumnIndex(pTabList, i, zName, 0, 0, 1) |
| 141076 | + if( pFrom->fg.isUsing |
| 141077 | + && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0 |
| 140231 | 141078 | ){ |
| 140232 | | - /* In a NATURAL join, omit the join columns from the |
| 140233 | | - ** table to the right of the join */ |
| 140234 | | - continue; |
| 140235 | | - } |
| 140236 | | - if( sqlite3IdListIndex(pFrom->pUsing, zName)>=0 ){ |
| 140237 | 141079 | /* In a join with a USING clause, omit columns in the |
| 140238 | 141080 | ** using clause from the table on the right. */ |
| 140239 | 141081 | continue; |
| 140240 | 141082 | } |
| 140241 | 141083 | } |
| 140242 | 141084 | pRight = sqlite3Expr(db, TK_ID, zName); |
| 140243 | | - zColname = zName; |
| 140244 | | - zToFree = 0; |
| 140245 | | - if( longNames || pTabList->nSrc>1 ){ |
| 141085 | + if( (pTabList->nSrc>1 |
| 141086 | + && ( (pFrom->fg.jointype & JT_LTORJ)==0 |
| 141087 | + || !inAnyUsingClause(zName,pFrom,pTabList->nSrc-i-1) |
| 141088 | + ) |
| 141089 | + ) |
| 141090 | + || IN_RENAME_OBJECT |
| 141091 | + ){ |
| 140246 | 141092 | Expr *pLeft; |
| 140247 | 141093 | pLeft = sqlite3Expr(db, TK_ID, zTabName); |
| 140248 | 141094 | pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); |
| 141095 | + if( IN_RENAME_OBJECT && pE->pLeft ){ |
| 141096 | + sqlite3RenameTokenRemap(pParse, pLeft, pE->pLeft); |
| 141097 | + } |
| 140249 | 141098 | if( zSchemaName ){ |
| 140250 | 141099 | pLeft = sqlite3Expr(db, TK_ID, zSchemaName); |
| 140251 | 141100 | pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pExpr); |
| 140252 | 141101 | } |
| 140253 | | - if( longNames ){ |
| 140254 | | - zColname = sqlite3MPrintf(db, "%s.%s", zTabName, zName); |
| 140255 | | - zToFree = zColname; |
| 140256 | | - } |
| 140257 | 141102 | }else{ |
| 140258 | 141103 | pExpr = pRight; |
| 140259 | 141104 | } |
| 140260 | 141105 | pNew = sqlite3ExprListAppend(pParse, pNew, pExpr); |
| 140261 | | - sqlite3TokenInit(&sColname, zColname); |
| 140262 | | - sqlite3ExprListSetName(pParse, pNew, &sColname, 0); |
| 140263 | | - if( pNew && (p->selFlags & SF_NestedFrom)!=0 && !IN_RENAME_OBJECT ){ |
| 140264 | | - struct ExprList_item *pX = &pNew->a[pNew->nExpr-1]; |
| 140265 | | - sqlite3DbFree(db, pX->zEName); |
| 141106 | + if( pNew==0 ){ |
| 141107 | + break; /* OOM */ |
| 141108 | + } |
| 141109 | + pX = &pNew->a[pNew->nExpr-1]; |
| 141110 | + assert( pX->zEName==0 ); |
| 141111 | + if( (selFlags & SF_NestedFrom)!=0 && !IN_RENAME_OBJECT ){ |
| 140266 | 141112 | if( pSub ){ |
| 140267 | 141113 | pX->zEName = sqlite3DbStrDup(db, pSub->pEList->a[j].zEName); |
| 140268 | 141114 | testcase( pX->zEName==0 ); |
| 140269 | 141115 | }else{ |
| 140270 | 141116 | pX->zEName = sqlite3MPrintf(db, "%s.%s.%s", |
| 140271 | | - zSchemaName, zTabName, zColname); |
| 141117 | + zSchemaName, zTabName, zName); |
| 140272 | 141118 | testcase( pX->zEName==0 ); |
| 140273 | 141119 | } |
| 140274 | 141120 | pX->eEName = ENAME_TAB; |
| 141121 | + }else if( longNames ){ |
| 141122 | + pX->zEName = sqlite3MPrintf(db, "%s.%s", zTabName, zName); |
| 141123 | + pX->eEName = ENAME_NAME; |
| 141124 | + }else{ |
| 141125 | + pX->zEName = sqlite3DbStrDup(db, zName); |
| 141126 | + pX->eEName = ENAME_NAME; |
| 140275 | 141127 | } |
| 140276 | | - sqlite3DbFree(db, zToFree); |
| 140277 | 141128 | } |
| 140278 | 141129 | } |
| 140279 | 141130 | if( !tableSeen ){ |
| 140280 | 141131 | if( zTName ){ |
| 140281 | 141132 | sqlite3ErrorMsg(pParse, "no such table: %s", zTName); |
| | @@ -140295,10 +141146,16 @@ |
| 140295 | 141146 | } |
| 140296 | 141147 | if( (elistFlags & (EP_HasFunc|EP_Subquery))!=0 ){ |
| 140297 | 141148 | p->selFlags |= SF_ComplexResult; |
| 140298 | 141149 | } |
| 140299 | 141150 | } |
| 141151 | +#if TREETRACE_ENABLED |
| 141152 | + if( sqlite3TreeTrace & 0x100 ){ |
| 141153 | + SELECTTRACE(0x100,pParse,p,("After result-set wildcard expansion:\n")); |
| 141154 | + sqlite3TreeViewSelect(0, p, 0); |
| 141155 | + } |
| 141156 | +#endif |
| 140300 | 141157 | return WRC_Continue; |
| 140301 | 141158 | } |
| 140302 | 141159 | |
| 140303 | 141160 | #if SQLITE_DEBUG |
| 140304 | 141161 | /* |
| | @@ -140685,12 +141542,12 @@ |
| 140685 | 141542 | memset(&sWalker, 0, sizeof(sWalker)); |
| 140686 | 141543 | sWalker.pParse = pParse; |
| 140687 | 141544 | sWalker.xExprCallback = havingToWhereExprCb; |
| 140688 | 141545 | sWalker.u.pSelect = p; |
| 140689 | 141546 | sqlite3WalkExpr(&sWalker, p->pHaving); |
| 140690 | | -#if SELECTTRACE_ENABLED |
| 140691 | | - if( sWalker.eCode && (sqlite3SelectTrace & 0x100)!=0 ){ |
| 141547 | +#if TREETRACE_ENABLED |
| 141548 | + if( sWalker.eCode && (sqlite3TreeTrace & 0x100)!=0 ){ |
| 140692 | 141549 | SELECTTRACE(0x100,pParse,p,("Move HAVING terms into WHERE:\n")); |
| 140693 | 141550 | sqlite3TreeViewSelect(0, p, 0); |
| 140694 | 141551 | } |
| 140695 | 141552 | #endif |
| 140696 | 141553 | } |
| | @@ -140818,12 +141675,12 @@ |
| 140818 | 141675 | pSub = pPrior; |
| 140819 | 141676 | } |
| 140820 | 141677 | p->pEList->a[0].pExpr = pExpr; |
| 140821 | 141678 | p->selFlags &= ~SF_Aggregate; |
| 140822 | 141679 | |
| 140823 | | -#if SELECTTRACE_ENABLED |
| 140824 | | - if( sqlite3SelectTrace & 0x400 ){ |
| 141680 | +#if TREETRACE_ENABLED |
| 141681 | + if( sqlite3TreeTrace & 0x400 ){ |
| 140825 | 141682 | SELECTTRACE(0x400,pParse,p,("After count-of-view optimization:\n")); |
| 140826 | 141683 | sqlite3TreeViewSelect(0, p, 0); |
| 140827 | 141684 | } |
| 140828 | 141685 | #endif |
| 140829 | 141686 | return 1; |
| | @@ -140872,14 +141729,18 @@ |
| 140872 | 141729 | if( p==0 || pParse->nErr ){ |
| 140873 | 141730 | return 1; |
| 140874 | 141731 | } |
| 140875 | 141732 | assert( db->mallocFailed==0 ); |
| 140876 | 141733 | if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1; |
| 140877 | | -#if SELECTTRACE_ENABLED |
| 141734 | +#if TREETRACE_ENABLED |
| 140878 | 141735 | SELECTTRACE(1,pParse,p, ("begin processing:\n", pParse->addrExplain)); |
| 140879 | | - if( sqlite3SelectTrace & 0x100 ){ |
| 140880 | | - sqlite3TreeViewSelect(0, p, 0); |
| 141736 | + if( sqlite3TreeTrace & 0x10100 ){ |
| 141737 | + if( (sqlite3TreeTrace & 0x10001)==0x10000 ){ |
| 141738 | + sqlite3TreeViewLine(0, "In sqlite3Select() at %s:%d", |
| 141739 | + __FILE__, __LINE__); |
| 141740 | + } |
| 141741 | + sqlite3ShowSelect(p); |
| 140881 | 141742 | } |
| 140882 | 141743 | #endif |
| 140883 | 141744 | |
| 140884 | 141745 | assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistFifo ); |
| 140885 | 141746 | assert( p->pOrderBy==0 || pDest->eDest!=SRT_Fifo ); |
| | @@ -140889,13 +141750,13 @@ |
| 140889 | 141750 | assert(pDest->eDest==SRT_Exists || pDest->eDest==SRT_Union || |
| 140890 | 141751 | pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard || |
| 140891 | 141752 | pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_DistFifo ); |
| 140892 | 141753 | /* All of these destinations are also able to ignore the ORDER BY clause */ |
| 140893 | 141754 | if( p->pOrderBy ){ |
| 140894 | | -#if SELECTTRACE_ENABLED |
| 141755 | +#if TREETRACE_ENABLED |
| 140895 | 141756 | SELECTTRACE(1,pParse,p, ("dropping superfluous ORDER BY:\n")); |
| 140896 | | - if( sqlite3SelectTrace & 0x100 ){ |
| 141757 | + if( sqlite3TreeTrace & 0x100 ){ |
| 140897 | 141758 | sqlite3TreeViewExprList(0, p->pOrderBy, 0, "ORDERBY"); |
| 140898 | 141759 | } |
| 140899 | 141760 | #endif |
| 140900 | 141761 | sqlite3ParserAddCleanup(pParse, |
| 140901 | 141762 | (void(*)(sqlite3*,void*))sqlite3ExprListDelete, |
| | @@ -140910,12 +141771,12 @@ |
| 140910 | 141771 | if( pParse->nErr ){ |
| 140911 | 141772 | goto select_end; |
| 140912 | 141773 | } |
| 140913 | 141774 | assert( db->mallocFailed==0 ); |
| 140914 | 141775 | assert( p->pEList!=0 ); |
| 140915 | | -#if SELECTTRACE_ENABLED |
| 140916 | | - if( sqlite3SelectTrace & 0x104 ){ |
| 141776 | +#if TREETRACE_ENABLED |
| 141777 | + if( sqlite3TreeTrace & 0x104 ){ |
| 140917 | 141778 | SELECTTRACE(0x104,pParse,p, ("after name resolution:\n")); |
| 140918 | 141779 | sqlite3TreeViewSelect(0, p, 0); |
| 140919 | 141780 | } |
| 140920 | 141781 | #endif |
| 140921 | 141782 | |
| | @@ -140955,12 +141816,12 @@ |
| 140955 | 141816 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 140956 | 141817 | if( sqlite3WindowRewrite(pParse, p) ){ |
| 140957 | 141818 | assert( pParse->nErr ); |
| 140958 | 141819 | goto select_end; |
| 140959 | 141820 | } |
| 140960 | | -#if SELECTTRACE_ENABLED |
| 140961 | | - if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){ |
| 141821 | +#if TREETRACE_ENABLED |
| 141822 | + if( p->pWin && (sqlite3TreeTrace & 0x108)!=0 ){ |
| 140962 | 141823 | SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n")); |
| 140963 | 141824 | sqlite3TreeViewSelect(0, p, 0); |
| 140964 | 141825 | } |
| 140965 | 141826 | #endif |
| 140966 | 141827 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| | @@ -140984,11 +141845,11 @@ |
| 140984 | 141845 | assert( pTab!=0 ); |
| 140985 | 141846 | |
| 140986 | 141847 | /* Convert LEFT JOIN into JOIN if there are terms of the right table |
| 140987 | 141848 | ** of the LEFT JOIN used in the WHERE clause. |
| 140988 | 141849 | */ |
| 140989 | | - if( (pItem->fg.jointype & JT_LEFT)!=0 |
| 141850 | + if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))==JT_LEFT |
| 140990 | 141851 | && sqlite3ExprImpliesNonNullRow(p->pWhere, pItem->iCursor) |
| 140991 | 141852 | && OptimizationEnabled(db, SQLITE_SimplifyJoin) |
| 140992 | 141853 | ){ |
| 140993 | 141854 | SELECTTRACE(0x100,pParse,p, |
| 140994 | 141855 | ("LEFT-JOIN simplifies to JOIN on term %d\n",i)); |
| | @@ -141070,11 +141931,11 @@ |
| 141070 | 141931 | */ |
| 141071 | 141932 | if( pSub->pOrderBy!=0 |
| 141072 | 141933 | && i==0 |
| 141073 | 141934 | && (p->selFlags & SF_ComplexResult)!=0 |
| 141074 | 141935 | && (pTabList->nSrc==1 |
| 141075 | | - || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0) |
| 141936 | + || (pTabList->a[1].fg.jointype&(JT_OUTER|JT_CROSS))!=0) |
| 141076 | 141937 | ){ |
| 141077 | 141938 | continue; |
| 141078 | 141939 | } |
| 141079 | 141940 | |
| 141080 | 141941 | if( flattenSubquery(pParse, p, i, isAgg) ){ |
| | @@ -141094,13 +141955,13 @@ |
| 141094 | 141955 | /* Handle compound SELECT statements using the separate multiSelect() |
| 141095 | 141956 | ** procedure. |
| 141096 | 141957 | */ |
| 141097 | 141958 | if( p->pPrior ){ |
| 141098 | 141959 | rc = multiSelect(pParse, p, pDest); |
| 141099 | | -#if SELECTTRACE_ENABLED |
| 141960 | +#if TREETRACE_ENABLED |
| 141100 | 141961 | SELECTTRACE(0x1,pParse,p,("end compound-select processing\n")); |
| 141101 | | - if( (sqlite3SelectTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){ |
| 141962 | + if( (sqlite3TreeTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){ |
| 141102 | 141963 | sqlite3TreeViewSelect(0, p, 0); |
| 141103 | 141964 | } |
| 141104 | 141965 | #endif |
| 141105 | 141966 | if( p->pNext==0 ) ExplainQueryPlanPop(pParse); |
| 141106 | 141967 | return rc; |
| | @@ -141115,12 +141976,12 @@ |
| 141115 | 141976 | if( p->pWhere!=0 |
| 141116 | 141977 | && p->pWhere->op==TK_AND |
| 141117 | 141978 | && OptimizationEnabled(db, SQLITE_PropagateConst) |
| 141118 | 141979 | && propagateConstants(pParse, p) |
| 141119 | 141980 | ){ |
| 141120 | | -#if SELECTTRACE_ENABLED |
| 141121 | | - if( sqlite3SelectTrace & 0x100 ){ |
| 141981 | +#if TREETRACE_ENABLED |
| 141982 | + if( sqlite3TreeTrace & 0x100 ){ |
| 141122 | 141983 | SELECTTRACE(0x100,pParse,p,("After constant propagation:\n")); |
| 141123 | 141984 | sqlite3TreeViewSelect(0, p, 0); |
| 141124 | 141985 | } |
| 141125 | 141986 | #endif |
| 141126 | 141987 | }else{ |
| | @@ -141192,15 +142053,16 @@ |
| 141192 | 142053 | ** inside the subquery. This can help the subquery to run more efficiently. |
| 141193 | 142054 | */ |
| 141194 | 142055 | if( OptimizationEnabled(db, SQLITE_PushDown) |
| 141195 | 142056 | && (pItem->fg.isCte==0 |
| 141196 | 142057 | || (pItem->u2.pCteUse->eM10d!=M10d_Yes && pItem->u2.pCteUse->nUse<2)) |
| 142058 | + && (pItem->fg.jointype & JT_RIGHT)==0 |
| 141197 | 142059 | && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor, |
| 141198 | 142060 | (pItem->fg.jointype & JT_OUTER)!=0) |
| 141199 | 142061 | ){ |
| 141200 | | -#if SELECTTRACE_ENABLED |
| 141201 | | - if( sqlite3SelectTrace & 0x100 ){ |
| 142062 | +#if TREETRACE_ENABLED |
| 142063 | + if( sqlite3TreeTrace & 0x100 ){ |
| 141202 | 142064 | SELECTTRACE(0x100,pParse,p, |
| 141203 | 142065 | ("After WHERE-clause push-down into subquery %d:\n", pSub->selId)); |
| 141204 | 142066 | sqlite3TreeViewSelect(0, p, 0); |
| 141205 | 142067 | } |
| 141206 | 142068 | #endif |
| | @@ -141212,22 +142074,23 @@ |
| 141212 | 142074 | zSavedAuthContext = pParse->zAuthContext; |
| 141213 | 142075 | pParse->zAuthContext = pItem->zName; |
| 141214 | 142076 | |
| 141215 | 142077 | /* Generate code to implement the subquery |
| 141216 | 142078 | ** |
| 141217 | | - ** The subquery is implemented as a co-routine if: |
| 142079 | + ** The subquery is implemented as a co-routine all of the following are |
| 142080 | + ** true: |
| 142081 | + ** |
| 141218 | 142082 | ** (1) the subquery is guaranteed to be the outer loop (so that |
| 141219 | 142083 | ** it does not need to be computed more than once), and |
| 141220 | 142084 | ** (2) the subquery is not a CTE that should be materialized |
| 141221 | | - ** |
| 141222 | | - ** TODO: Are there other reasons beside (1) and (2) to use a co-routine |
| 141223 | | - ** implementation? |
| 142085 | + ** (3) the subquery is not part of a left operand for a RIGHT JOIN |
| 141224 | 142086 | */ |
| 141225 | 142087 | if( i==0 |
| 141226 | 142088 | && (pTabList->nSrc==1 |
| 141227 | | - || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0) /* (1) */ |
| 141228 | | - && (pItem->fg.isCte==0 || pItem->u2.pCteUse->eM10d!=M10d_Yes) /* (2) */ |
| 142089 | + || (pTabList->a[1].fg.jointype&(JT_OUTER|JT_CROSS))!=0) /* (1) */ |
| 142090 | + && (pItem->fg.isCte==0 || pItem->u2.pCteUse->eM10d!=M10d_Yes) /* (2) */ |
| 142091 | + && (pTabList->a[0].fg.jointype & JT_LTORJ)==0 /* (3) */ |
| 141229 | 142092 | ){ |
| 141230 | 142093 | /* Implement a co-routine that will return a single row of the result |
| 141231 | 142094 | ** set on each invocation. |
| 141232 | 142095 | */ |
| 141233 | 142096 | int addrTop = sqlite3VdbeCurrentAddr(v)+1; |
| | @@ -141314,12 +142177,12 @@ |
| 141314 | 142177 | pWhere = p->pWhere; |
| 141315 | 142178 | pGroupBy = p->pGroupBy; |
| 141316 | 142179 | pHaving = p->pHaving; |
| 141317 | 142180 | sDistinct.isTnct = (p->selFlags & SF_Distinct)!=0; |
| 141318 | 142181 | |
| 141319 | | -#if SELECTTRACE_ENABLED |
| 141320 | | - if( sqlite3SelectTrace & 0x400 ){ |
| 142182 | +#if TREETRACE_ENABLED |
| 142183 | + if( sqlite3TreeTrace & 0x400 ){ |
| 141321 | 142184 | SELECTTRACE(0x400,pParse,p,("After all FROM-clause analysis:\n")); |
| 141322 | 142185 | sqlite3TreeViewSelect(0, p, 0); |
| 141323 | 142186 | } |
| 141324 | 142187 | #endif |
| 141325 | 142188 | |
| | @@ -141351,12 +142214,12 @@ |
| 141351 | 142214 | ** the sDistinct.isTnct is still set. Hence, isTnct represents the |
| 141352 | 142215 | ** original setting of the SF_Distinct flag, not the current setting */ |
| 141353 | 142216 | assert( sDistinct.isTnct ); |
| 141354 | 142217 | sDistinct.isTnct = 2; |
| 141355 | 142218 | |
| 141356 | | -#if SELECTTRACE_ENABLED |
| 141357 | | - if( sqlite3SelectTrace & 0x400 ){ |
| 142219 | +#if TREETRACE_ENABLED |
| 142220 | + if( sqlite3TreeTrace & 0x400 ){ |
| 141358 | 142221 | SELECTTRACE(0x400,pParse,p,("Transform DISTINCT into GROUP BY:\n")); |
| 141359 | 142222 | sqlite3TreeViewSelect(0, p, 0); |
| 141360 | 142223 | } |
| 141361 | 142224 | #endif |
| 141362 | 142225 | } |
| | @@ -141385,10 +142248,22 @@ |
| 141385 | 142248 | |
| 141386 | 142249 | /* If the output is destined for a temporary table, open that table. |
| 141387 | 142250 | */ |
| 141388 | 142251 | if( pDest->eDest==SRT_EphemTab ){ |
| 141389 | 142252 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iSDParm, pEList->nExpr); |
| 142253 | + if( p->selFlags & SF_NestedFrom ){ |
| 142254 | + /* Delete or NULL-out result columns that will never be used */ |
| 142255 | + int ii; |
| 142256 | + for(ii=pEList->nExpr-1; ii>0 && pEList->a[ii].bUsed==0; ii--){ |
| 142257 | + sqlite3ExprDelete(db, pEList->a[ii].pExpr); |
| 142258 | + sqlite3DbFree(db, pEList->a[ii].zEName); |
| 142259 | + pEList->nExpr--; |
| 142260 | + } |
| 142261 | + for(ii=0; ii<pEList->nExpr; ii++){ |
| 142262 | + if( pEList->a[ii].bUsed==0 ) pEList->a[ii].pExpr->op = TK_NULL; |
| 142263 | + } |
| 142264 | + } |
| 141390 | 142265 | } |
| 141391 | 142266 | |
| 141392 | 142267 | /* Set the limiter. |
| 141393 | 142268 | */ |
| 141394 | 142269 | iEnd = sqlite3VdbeMakeLabel(pParse); |
| | @@ -141604,12 +142479,12 @@ |
| 141604 | 142479 | #endif |
| 141605 | 142480 | sNC.ncFlags &= ~NC_InAggFunc; |
| 141606 | 142481 | } |
| 141607 | 142482 | pAggInfo->mxReg = pParse->nMem; |
| 141608 | 142483 | if( db->mallocFailed ) goto select_end; |
| 141609 | | -#if SELECTTRACE_ENABLED |
| 141610 | | - if( sqlite3SelectTrace & 0x400 ){ |
| 142484 | +#if TREETRACE_ENABLED |
| 142485 | + if( sqlite3TreeTrace & 0x400 ){ |
| 141611 | 142486 | int ii; |
| 141612 | 142487 | SELECTTRACE(0x400,pParse,p,("After aggregate analysis %p:\n", pAggInfo)); |
| 141613 | 142488 | sqlite3TreeViewSelect(0, p, 0); |
| 141614 | 142489 | if( minMaxFlag ){ |
| 141615 | 142490 | sqlite3DebugPrintf("MIN/MAX Optimization (0x%02x) adds:\n", minMaxFlag); |
| | @@ -142001,11 +142876,13 @@ |
| 142001 | 142876 | SELECTTRACE(1,pParse,p,("WhereBegin returns\n")); |
| 142002 | 142877 | eDist = sqlite3WhereIsDistinct(pWInfo); |
| 142003 | 142878 | updateAccumulator(pParse, regAcc, pAggInfo, eDist); |
| 142004 | 142879 | if( eDist!=WHERE_DISTINCT_NOOP ){ |
| 142005 | 142880 | struct AggInfo_func *pF = &pAggInfo->aFunc[0]; |
| 142006 | | - fixDistinctOpenEph(pParse, eDist, pF->iDistinct, pF->iDistAddr); |
| 142881 | + if( pF ){ |
| 142882 | + fixDistinctOpenEph(pParse, eDist, pF->iDistinct, pF->iDistAddr); |
| 142883 | + } |
| 142007 | 142884 | } |
| 142008 | 142885 | |
| 142009 | 142886 | if( regAcc ) sqlite3VdbeAddOp2(v, OP_Integer, 1, regAcc); |
| 142010 | 142887 | if( minMaxFlag ){ |
| 142011 | 142888 | sqlite3WhereMinMaxOptEarlyOut(v, pWInfo); |
| | @@ -142068,13 +142945,13 @@ |
| 142068 | 142945 | assert( pExpr->iAgg==i ); |
| 142069 | 142946 | } |
| 142070 | 142947 | } |
| 142071 | 142948 | #endif |
| 142072 | 142949 | |
| 142073 | | -#if SELECTTRACE_ENABLED |
| 142950 | +#if TREETRACE_ENABLED |
| 142074 | 142951 | SELECTTRACE(0x1,pParse,p,("end processing\n")); |
| 142075 | | - if( (sqlite3SelectTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){ |
| 142952 | + if( (sqlite3TreeTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){ |
| 142076 | 142953 | sqlite3TreeViewSelect(0, p, 0); |
| 142077 | 142954 | } |
| 142078 | 142955 | #endif |
| 142079 | 142956 | ExplainQueryPlanPop(pParse); |
| 142080 | 142957 | return rc; |
| | @@ -142335,13 +143212,11 @@ |
| 142335 | 143212 | SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){ |
| 142336 | 143213 | Schema *pTmpSchema; /* Schema of the pTab table */ |
| 142337 | 143214 | Trigger *pList; /* List of triggers to return */ |
| 142338 | 143215 | HashElem *p; /* Loop variable for TEMP triggers */ |
| 142339 | 143216 | |
| 142340 | | - if( pParse->disableTriggers ){ |
| 142341 | | - return 0; |
| 142342 | | - } |
| 143217 | + assert( pParse->disableTriggers==0 ); |
| 142343 | 143218 | pTmpSchema = pParse->db->aDb[1].pSchema; |
| 142344 | 143219 | p = sqliteHashFirst(&pTmpSchema->trigHash); |
| 142345 | 143220 | pList = pTab->pTrigger; |
| 142346 | 143221 | while( p ){ |
| 142347 | 143222 | Trigger *pTrig = (Trigger *)sqliteHashData(p); |
| | @@ -143011,18 +143886,27 @@ |
| 143011 | 143886 | for(e=0; e<pEList->nExpr; e++){ |
| 143012 | 143887 | if( sqlite3IdListIndex(pIdList, pEList->a[e].zEName)>=0 ) return 1; |
| 143013 | 143888 | } |
| 143014 | 143889 | return 0; |
| 143015 | 143890 | } |
| 143891 | + |
| 143892 | +/* |
| 143893 | +** Return true if any TEMP triggers exist |
| 143894 | +*/ |
| 143895 | +static int tempTriggersExist(sqlite3 *db){ |
| 143896 | + if( NEVER(db->aDb[1].pSchema==0) ) return 0; |
| 143897 | + if( sqliteHashFirst(&db->aDb[1].pSchema->trigHash)==0 ) return 0; |
| 143898 | + return 1; |
| 143899 | +} |
| 143016 | 143900 | |
| 143017 | 143901 | /* |
| 143018 | 143902 | ** Return a list of all triggers on table pTab if there exists at least |
| 143019 | 143903 | ** one trigger that must be fired when an operation of type 'op' is |
| 143020 | 143904 | ** performed on the table, and, if that operation is an UPDATE, if at |
| 143021 | 143905 | ** least one of the columns in pChanges is being modified. |
| 143022 | 143906 | */ |
| 143023 | | -SQLITE_PRIVATE Trigger *sqlite3TriggersExist( |
| 143907 | +static SQLITE_NOINLINE Trigger *triggersReallyExist( |
| 143024 | 143908 | Parse *pParse, /* Parse context */ |
| 143025 | 143909 | Table *pTab, /* The table the contains the triggers */ |
| 143026 | 143910 | int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */ |
| 143027 | 143911 | ExprList *pChanges, /* Columns that change in an UPDATE statement */ |
| 143028 | 143912 | int *pMask /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ |
| | @@ -143081,10 +143965,26 @@ |
| 143081 | 143965 | if( pMask ){ |
| 143082 | 143966 | *pMask = mask; |
| 143083 | 143967 | } |
| 143084 | 143968 | return (mask ? pList : 0); |
| 143085 | 143969 | } |
| 143970 | +SQLITE_PRIVATE Trigger *sqlite3TriggersExist( |
| 143971 | + Parse *pParse, /* Parse context */ |
| 143972 | + Table *pTab, /* The table the contains the triggers */ |
| 143973 | + int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */ |
| 143974 | + ExprList *pChanges, /* Columns that change in an UPDATE statement */ |
| 143975 | + int *pMask /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ |
| 143976 | +){ |
| 143977 | + assert( pTab!=0 ); |
| 143978 | + if( (pTab->pTrigger==0 && !tempTriggersExist(pParse->db)) |
| 143979 | + || pParse->disableTriggers |
| 143980 | + ){ |
| 143981 | + if( pMask ) *pMask = 0; |
| 143982 | + return 0; |
| 143983 | + } |
| 143984 | + return triggersReallyExist(pParse,pTab,op,pChanges,pMask); |
| 143985 | +} |
| 143086 | 143986 | |
| 143087 | 143987 | /* |
| 143088 | 143988 | ** Convert the pStep->zTarget string into a SrcList and return a pointer |
| 143089 | 143989 | ** to that SrcList. |
| 143090 | 143990 | ** |
| | @@ -144088,10 +144988,18 @@ |
| 144088 | 144988 | #endif |
| 144089 | 144989 | #ifdef SQLITE_OMIT_VIEW |
| 144090 | 144990 | # undef isView |
| 144091 | 144991 | # define isView 0 |
| 144092 | 144992 | #endif |
| 144993 | + |
| 144994 | +#if TREETRACE_ENABLED |
| 144995 | + if( sqlite3TreeTrace & 0x10000 ){ |
| 144996 | + sqlite3TreeViewLine(0, "In sqlite3Update() at %s:%d", __FILE__, __LINE__); |
| 144997 | + sqlite3TreeViewUpdate(pParse->pWith, pTabList, pChanges, pWhere, |
| 144998 | + onError, pOrderBy, pLimit, pUpsert, pTrigger); |
| 144999 | + } |
| 145000 | +#endif |
| 144093 | 145001 | |
| 144094 | 145002 | /* If there was a FROM clause, set nChangeFrom to the number of expressions |
| 144095 | 145003 | ** in the change-list. Otherwise, set it to 0. There cannot be a FROM |
| 144096 | 145004 | ** clause if this function is being called to generate code for part of |
| 144097 | 145005 | ** an UPSERT statement. */ |
| | @@ -147181,10 +148089,31 @@ |
| 147181 | 148089 | typedef struct WhereTerm WhereTerm; |
| 147182 | 148090 | typedef struct WhereLoopBuilder WhereLoopBuilder; |
| 147183 | 148091 | typedef struct WhereScan WhereScan; |
| 147184 | 148092 | typedef struct WhereOrCost WhereOrCost; |
| 147185 | 148093 | typedef struct WhereOrSet WhereOrSet; |
| 148094 | +typedef struct WhereMemBlock WhereMemBlock; |
| 148095 | +typedef struct WhereRightJoin WhereRightJoin; |
| 148096 | + |
| 148097 | +/* |
| 148098 | +** This object is a header on a block of allocated memory that will be |
| 148099 | +** automatically freed when its WInfo oject is destructed. |
| 148100 | +*/ |
| 148101 | +struct WhereMemBlock { |
| 148102 | + WhereMemBlock *pNext; /* Next block in the chain */ |
| 148103 | + u8 sz; /* Bytes of space */ |
| 148104 | +}; |
| 148105 | + |
| 148106 | +/* |
| 148107 | +** Extra information attached to a WhereLevel that is a RIGHT JOIN. |
| 148108 | +*/ |
| 148109 | +struct WhereRightJoin { |
| 148110 | + int iMatch; /* Cursor used to determine prior matched rows */ |
| 148111 | + int regBloom; /* Bloom filter for iRJMatch */ |
| 148112 | + int regReturn; /* Return register for the interior subroutine */ |
| 148113 | + int addrSubrtn; /* Starting address for the interior subroutine */ |
| 148114 | +}; |
| 147186 | 148115 | |
| 147187 | 148116 | /* |
| 147188 | 148117 | ** This object contains information needed to implement a single nested |
| 147189 | 148118 | ** loop in WHERE clause. |
| 147190 | 148119 | ** |
| | @@ -147214,10 +148143,11 @@ |
| 147214 | 148143 | #ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS |
| 147215 | 148144 | u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */ |
| 147216 | 148145 | int addrLikeRep; /* LIKE range processing address */ |
| 147217 | 148146 | #endif |
| 147218 | 148147 | int regFilter; /* Bloom filter */ |
| 148148 | + WhereRightJoin *pRJ; /* Extra information for RIGHT JOIN */ |
| 147219 | 148149 | u8 iFrom; /* Which entry in the FROM clause */ |
| 147220 | 148150 | u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */ |
| 147221 | 148151 | int p1, p2; /* Operands of the opcode used to end the loop */ |
| 147222 | 148152 | union { /* Information that depends on pWLoop->wsFlags */ |
| 147223 | 148153 | struct { |
| | @@ -147627,10 +148557,11 @@ |
| 147627 | 148557 | LogEst nRowOut; /* Estimated number of output rows */ |
| 147628 | 148558 | int iTop; /* The very beginning of the WHERE loop */ |
| 147629 | 148559 | int iEndWhere; /* End of the WHERE clause itself */ |
| 147630 | 148560 | WhereLoop *pLoops; /* List of all WhereLoop objects */ |
| 147631 | 148561 | WhereExprMod *pExprMods; /* Expression modifications */ |
| 148562 | + WhereMemBlock *pMemToFree;/* Memory to free when this object destroyed */ |
| 147632 | 148563 | Bitmask revMask; /* Mask of ORDER BY terms that need reversing */ |
| 147633 | 148564 | WhereClause sWC; /* Decomposition of the WHERE clause */ |
| 147634 | 148565 | WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */ |
| 147635 | 148566 | WhereLevel a[1]; /* Information about each nest loop in WHERE */ |
| 147636 | 148567 | }; |
| | @@ -147652,10 +148583,12 @@ |
| 147652 | 148583 | int iColumn, /* Column number of LHS */ |
| 147653 | 148584 | Bitmask notReady, /* RHS must not overlap with this mask */ |
| 147654 | 148585 | u32 op, /* Mask of WO_xx values describing operator */ |
| 147655 | 148586 | Index *pIdx /* Must be compatible with this index, if not NULL */ |
| 147656 | 148587 | ); |
| 148588 | +SQLITE_PRIVATE void *sqlite3WhereMalloc(WhereInfo *pWInfo, u64 nByte); |
| 148589 | +SQLITE_PRIVATE void *sqlite3WhereRealloc(WhereInfo *pWInfo, void *pOld, u64 nByte); |
| 147657 | 148590 | |
| 147658 | 148591 | /* wherecode.c: */ |
| 147659 | 148592 | #ifndef SQLITE_OMIT_EXPLAIN |
| 147660 | 148593 | SQLITE_PRIVATE int sqlite3WhereExplainOneScan( |
| 147661 | 148594 | Parse *pParse, /* Parse context */ |
| | @@ -147687,10 +148620,15 @@ |
| 147687 | 148620 | Vdbe *v, /* Prepared statement under construction */ |
| 147688 | 148621 | WhereInfo *pWInfo, /* Complete information about the WHERE clause */ |
| 147689 | 148622 | int iLevel, /* Which level of pWInfo->a[] should be coded */ |
| 147690 | 148623 | WhereLevel *pLevel, /* The current level pointer */ |
| 147691 | 148624 | Bitmask notReady /* Which tables are currently available */ |
| 148625 | +); |
| 148626 | +SQLITE_PRIVATE SQLITE_NOINLINE void sqlite3WhereRightJoinLoop( |
| 148627 | + WhereInfo *pWInfo, |
| 148628 | + int iLevel, |
| 148629 | + WhereLevel *pLevel |
| 147692 | 148630 | ); |
| 147693 | 148631 | |
| 147694 | 148632 | /* whereexpr.c: */ |
| 147695 | 148633 | SQLITE_PRIVATE void sqlite3WhereClauseInit(WhereClause*,WhereInfo*); |
| 147696 | 148634 | SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause*); |
| | @@ -147955,10 +148893,13 @@ |
| 147955 | 148893 | else if( (flags & WHERE_VIRTUALTABLE)!=0 ){ |
| 147956 | 148894 | sqlite3_str_appendf(&str, " VIRTUAL TABLE INDEX %d:%s", |
| 147957 | 148895 | pLoop->u.vtab.idxNum, pLoop->u.vtab.idxStr); |
| 147958 | 148896 | } |
| 147959 | 148897 | #endif |
| 148898 | + if( pItem->fg.jointype & JT_LEFT ){ |
| 148899 | + sqlite3_str_appendf(&str, " LEFT-JOIN"); |
| 148900 | + } |
| 147960 | 148901 | #ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS |
| 147961 | 148902 | if( pLoop->nOut>=10 ){ |
| 147962 | 148903 | sqlite3_str_appendf(&str, " (~%llu rows)", |
| 147963 | 148904 | sqlite3LogEstToInt(pLoop->nOut)); |
| 147964 | 148905 | }else{ |
| | @@ -148391,12 +149332,13 @@ |
| 148391 | 149332 | } |
| 148392 | 149333 | |
| 148393 | 149334 | i = pLevel->u.in.nIn; |
| 148394 | 149335 | pLevel->u.in.nIn += nEq; |
| 148395 | 149336 | pLevel->u.in.aInLoop = |
| 148396 | | - sqlite3DbReallocOrFree(pParse->db, pLevel->u.in.aInLoop, |
| 148397 | | - sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn); |
| 149337 | + sqlite3WhereRealloc(pTerm->pWC->pWInfo, |
| 149338 | + pLevel->u.in.aInLoop, |
| 149339 | + sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn); |
| 148398 | 149340 | pIn = pLevel->u.in.aInLoop; |
| 148399 | 149341 | if( pIn ){ |
| 148400 | 149342 | int iMap = 0; /* Index in aiMap[] */ |
| 148401 | 149343 | pIn += i; |
| 148402 | 149344 | for(i=iEq;i<pLoop->nLTerm; i++){ |
| | @@ -148814,11 +149756,11 @@ |
| 148814 | 149756 | ** are also excluded. See codeCursorHintIsOrFunction() for details. |
| 148815 | 149757 | */ |
| 148816 | 149758 | if( pTabItem->fg.jointype & JT_LEFT ){ |
| 148817 | 149759 | Expr *pExpr = pTerm->pExpr; |
| 148818 | 149760 | if( !ExprHasProperty(pExpr, EP_FromJoin) |
| 148819 | | - || pExpr->w.iRightJoinTable!=pTabItem->iCursor |
| 149761 | + || pExpr->w.iJoin!=pTabItem->iCursor |
| 148820 | 149762 | ){ |
| 148821 | 149763 | sWalker.eCode = 0; |
| 148822 | 149764 | sWalker.xExprCallback = codeCursorHintIsOrFunction; |
| 148823 | 149765 | sqlite3WalkExpr(&sWalker, pTerm->pExpr); |
| 148824 | 149766 | if( sWalker.eCode ) continue; |
| | @@ -148900,11 +149842,11 @@ |
| 148900 | 149842 | assert( iIdxCur>0 ); |
| 148901 | 149843 | assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 ); |
| 148902 | 149844 | |
| 148903 | 149845 | pWInfo->bDeferredSeek = 1; |
| 148904 | 149846 | sqlite3VdbeAddOp3(v, OP_DeferredSeek, iIdxCur, 0, iCur); |
| 148905 | | - if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE) |
| 149847 | + if( (pWInfo->wctrlFlags & (WHERE_OR_SUBCLAUSE|WHERE_RIGHT_JOIN)) |
| 148906 | 149848 | && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask) |
| 148907 | 149849 | ){ |
| 148908 | 149850 | int i; |
| 148909 | 149851 | Table *pTab = pIdx->pTable; |
| 148910 | 149852 | u32 *ai = (u32*)sqlite3DbMallocZero(pParse->db, sizeof(u32)*(pTab->nCol+1)); |
| | @@ -149252,11 +150194,11 @@ |
| 149252 | 150194 | |
| 149253 | 150195 | /* If this is the right table of a LEFT OUTER JOIN, allocate and |
| 149254 | 150196 | ** initialize a memory cell that records if this table matches any |
| 149255 | 150197 | ** row of the left table of the join. |
| 149256 | 150198 | */ |
| 149257 | | - assert( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE) |
| 150199 | + assert( (pWInfo->wctrlFlags & (WHERE_OR_SUBCLAUSE|WHERE_RIGHT_JOIN)) |
| 149258 | 150200 | || pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0 |
| 149259 | 150201 | ); |
| 149260 | 150202 | if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){ |
| 149261 | 150203 | pLevel->iLeftJoin = ++pParse->nMem; |
| 149262 | 150204 | sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin); |
| | @@ -149263,11 +150205,14 @@ |
| 149263 | 150205 | VdbeComment((v, "init LEFT JOIN no-match flag")); |
| 149264 | 150206 | } |
| 149265 | 150207 | |
| 149266 | 150208 | /* Compute a safe address to jump to if we discover that the table for |
| 149267 | 150209 | ** this loop is empty and can never contribute content. */ |
| 149268 | | - for(j=iLevel; j>0 && pWInfo->a[j].iLeftJoin==0; j--){} |
| 150210 | + for(j=iLevel; j>0; j--){ |
| 150211 | + if( pWInfo->a[j].iLeftJoin ) break; |
| 150212 | + if( pWInfo->a[j].pRJ ) break; |
| 150213 | + } |
| 149269 | 150214 | addrHalt = pWInfo->a[j].addrBrk; |
| 149270 | 150215 | |
| 149271 | 150216 | /* Special case of a FROM clause subquery implemented as a co-routine */ |
| 149272 | 150217 | if( pTabItem->fg.viaCoroutine ){ |
| 149273 | 150218 | int regYield = pTabItem->regReturn; |
| | @@ -149890,11 +150835,11 @@ |
| 149890 | 150835 | sqlite3VdbeAddOp3(v, OP_SeekHit, iIdxCur, nEq, nEq); |
| 149891 | 150836 | } |
| 149892 | 150837 | |
| 149893 | 150838 | /* Seek the table cursor, if required */ |
| 149894 | 150839 | omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0 |
| 149895 | | - && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0; |
| 150840 | + && (pWInfo->wctrlFlags & (WHERE_OR_SUBCLAUSE|WHERE_RIGHT_JOIN))==0; |
| 149896 | 150841 | if( omitTable ){ |
| 149897 | 150842 | /* pIdx is a covering index. No need to access the main table. */ |
| 149898 | 150843 | }else if( HasRowid(pIdx->pTable) ){ |
| 149899 | 150844 | codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur); |
| 149900 | 150845 | }else if( iCur!=iIdxCur ){ |
| | @@ -149924,11 +150869,11 @@ |
| 149924 | 150869 | ** Also, do not do this when processing one index an a multi-index |
| 149925 | 150870 | ** OR clause, since the transformation will become invalid once we |
| 149926 | 150871 | ** move forward to the next index. |
| 149927 | 150872 | ** https://sqlite.org/src/info/4e8e4857d32d401f |
| 149928 | 150873 | */ |
| 149929 | | - if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){ |
| 150874 | + if( (pWInfo->wctrlFlags & (WHERE_OR_SUBCLAUSE|WHERE_RIGHT_JOIN))==0 ){ |
| 149930 | 150875 | whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo); |
| 149931 | 150876 | } |
| 149932 | 150877 | |
| 149933 | 150878 | /* If a partial index is driving the loop, try to eliminate WHERE clause |
| 149934 | 150879 | ** terms from the query that must be true due to the WHERE clause of |
| | @@ -149943,11 +150888,11 @@ |
| 149943 | 150888 | }else{ |
| 149944 | 150889 | testcase( pIdx->pPartIdxWhere ); |
| 149945 | 150890 | /* The following assert() is not a requirement, merely an observation: |
| 149946 | 150891 | ** The OR-optimization doesn't work for the right hand table of |
| 149947 | 150892 | ** a LEFT JOIN: */ |
| 149948 | | - assert( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ); |
| 150893 | + assert( (pWInfo->wctrlFlags & (WHERE_OR_SUBCLAUSE|WHERE_RIGHT_JOIN))==0 ); |
| 149949 | 150894 | } |
| 149950 | 150895 | |
| 149951 | 150896 | /* Record the instruction used to terminate the loop. */ |
| 149952 | 150897 | if( pLoop->wsFlags & WHERE_ONEROW ){ |
| 149953 | 150898 | pLevel->op = OP_Noop; |
| | @@ -150284,10 +151229,18 @@ |
| 150284 | 151229 | sqlite3ExprDelete(db, pAndExpr); |
| 150285 | 151230 | } |
| 150286 | 151231 | sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); |
| 150287 | 151232 | sqlite3VdbeGoto(v, pLevel->addrBrk); |
| 150288 | 151233 | sqlite3VdbeResolveLabel(v, iLoopBody); |
| 151234 | + |
| 151235 | + /* Set the P2 operand of the OP_Return opcode that will end the current |
| 151236 | + ** loop to point to this spot, which is the top of the next containing |
| 151237 | + ** loop. The byte-code formatter will use that P2 value as a hint to |
| 151238 | + ** indent everything in between the this point and the final OP_Return. |
| 151239 | + ** See tag-20220407a in vdbe.c and shell.c */ |
| 151240 | + assert( pLevel->op==OP_Return ); |
| 151241 | + pLevel->p2 = sqlite3VdbeCurrentAddr(v); |
| 150289 | 151242 | |
| 150290 | 151243 | if( pWInfo->nLevel>1 ){ sqlite3StackFree(db, pOrTab); } |
| 150291 | 151244 | if( !untestedTerms ) disableTerm(pLevel, pTerm); |
| 150292 | 151245 | }else |
| 150293 | 151246 | #endif /* SQLITE_OMIT_OR_OPTIMIZATION */ |
| | @@ -150347,11 +151300,13 @@ |
| 150347 | 151300 | pWInfo->untestedTerms = 1; |
| 150348 | 151301 | continue; |
| 150349 | 151302 | } |
| 150350 | 151303 | pE = pTerm->pExpr; |
| 150351 | 151304 | assert( pE!=0 ); |
| 150352 | | - if( (pTabItem->fg.jointype&JT_LEFT) && !ExprHasProperty(pE,EP_FromJoin) ){ |
| 151305 | + if( (pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ)) |
| 151306 | + && !ExprHasProperty(pE,EP_FromJoin) |
| 151307 | + ){ |
| 150353 | 151308 | continue; |
| 150354 | 151309 | } |
| 150355 | 151310 | |
| 150356 | 151311 | if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){ |
| 150357 | 151312 | iNext = 2; |
| | @@ -150409,11 +151364,11 @@ |
| 150409 | 151364 | WhereTerm *pAlt; |
| 150410 | 151365 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 150411 | 151366 | if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue; |
| 150412 | 151367 | if( (pTerm->eOperator & WO_EQUIV)==0 ) continue; |
| 150413 | 151368 | if( pTerm->leftCursor!=iCur ) continue; |
| 150414 | | - if( pTabItem->fg.jointype & JT_LEFT ) continue; |
| 151369 | + if( pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ) ) continue; |
| 150415 | 151370 | pE = pTerm->pExpr; |
| 150416 | 151371 | #ifdef WHERETRACE_ENABLED /* 0x800 */ |
| 150417 | 151372 | if( sqlite3WhereTrace & 0x800 ){ |
| 150418 | 151373 | sqlite3DebugPrintf("Coding transitive constraint:\n"); |
| 150419 | 151374 | sqlite3WhereTermPrint(pTerm, pWC->nTerm-j); |
| | @@ -150439,10 +151394,51 @@ |
| 150439 | 151394 | sEAlt = *pAlt->pExpr; |
| 150440 | 151395 | sEAlt.pLeft = pE->pLeft; |
| 150441 | 151396 | sqlite3ExprIfFalse(pParse, &sEAlt, addrCont, SQLITE_JUMPIFNULL); |
| 150442 | 151397 | pAlt->wtFlags |= TERM_CODED; |
| 150443 | 151398 | } |
| 151399 | + |
| 151400 | + /* For a RIGHT OUTER JOIN, record the fact that the current row has |
| 151401 | + ** been matched at least once. |
| 151402 | + */ |
| 151403 | + if( pLevel->pRJ ){ |
| 151404 | + Table *pTab; |
| 151405 | + int nPk; |
| 151406 | + int r; |
| 151407 | + int jmp1 = 0; |
| 151408 | + WhereRightJoin *pRJ = pLevel->pRJ; |
| 151409 | + |
| 151410 | + /* pTab is the right-hand table of the RIGHT JOIN. Generate code that |
| 151411 | + ** will record that the current row of that table has been matched at |
| 151412 | + ** least once. This is accomplished by storing the PK for the row in |
| 151413 | + ** both the iMatch index and the regBloom Bloom filter. |
| 151414 | + */ |
| 151415 | + pTab = pWInfo->pTabList->a[pLevel->iFrom].pTab; |
| 151416 | + if( HasRowid(pTab) ){ |
| 151417 | + r = sqlite3GetTempRange(pParse, 2); |
| 151418 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, pLevel->iTabCur, -1, r+1); |
| 151419 | + nPk = 1; |
| 151420 | + }else{ |
| 151421 | + int iPk; |
| 151422 | + Index *pPk = sqlite3PrimaryKeyIndex(pTab); |
| 151423 | + nPk = pPk->nKeyCol; |
| 151424 | + r = sqlite3GetTempRange(pParse, nPk+1); |
| 151425 | + for(iPk=0; iPk<nPk; iPk++){ |
| 151426 | + int iCol = pPk->aiColumn[iPk]; |
| 151427 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol,r+1+iPk); |
| 151428 | + } |
| 151429 | + } |
| 151430 | + jmp1 = sqlite3VdbeAddOp4Int(v, OP_Found, pRJ->iMatch, 0, r+1, nPk); |
| 151431 | + VdbeCoverage(v); |
| 151432 | + VdbeComment((v, "match against %s", pTab->zName)); |
| 151433 | + sqlite3VdbeAddOp3(v, OP_MakeRecord, r+1, nPk, r); |
| 151434 | + sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pRJ->iMatch, r, r+1, nPk); |
| 151435 | + sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pRJ->regBloom, 0, r+1, nPk); |
| 151436 | + sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 151437 | + sqlite3VdbeJumpHere(v, jmp1); |
| 151438 | + sqlite3ReleaseTempRange(pParse, r, nPk+1); |
| 151439 | + } |
| 150444 | 151440 | |
| 150445 | 151441 | /* For a LEFT OUTER JOIN, generate code that will record the fact that |
| 150446 | 151442 | ** at least one row of the right table has matched the left table. |
| 150447 | 151443 | */ |
| 150448 | 151444 | if( pLevel->iLeftJoin ){ |
| | @@ -150455,15 +151451,30 @@ |
| 150455 | 151451 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 150456 | 151452 | if( (pTerm->prereqAll & pLevel->notReady)!=0 ){ |
| 150457 | 151453 | assert( pWInfo->untestedTerms ); |
| 150458 | 151454 | continue; |
| 150459 | 151455 | } |
| 151456 | + if( pTabItem->fg.jointype & JT_LTORJ ) continue; |
| 150460 | 151457 | assert( pTerm->pExpr ); |
| 150461 | 151458 | sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL); |
| 150462 | 151459 | pTerm->wtFlags |= TERM_CODED; |
| 150463 | 151460 | } |
| 150464 | 151461 | } |
| 151462 | + |
| 151463 | + if( pLevel->pRJ ){ |
| 151464 | + /* Create a subroutine used to process all interior loops and code |
| 151465 | + ** of the RIGHT JOIN. During normal operation, the subroutine will |
| 151466 | + ** be in-line with the rest of the code. But at the end, a separate |
| 151467 | + ** loop will run that invokes this subroutine for unmatched rows |
| 151468 | + ** of pTab, with all tables to left begin set to NULL. |
| 151469 | + */ |
| 151470 | + WhereRightJoin *pRJ = pLevel->pRJ; |
| 151471 | + sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pRJ->regReturn); |
| 151472 | + pRJ->addrSubrtn = sqlite3VdbeCurrentAddr(v); |
| 151473 | + assert( pParse->withinRJSubrtn < 255 ); |
| 151474 | + pParse->withinRJSubrtn++; |
| 151475 | + } |
| 150465 | 151476 | |
| 150466 | 151477 | #if WHERETRACE_ENABLED /* 0x20800 */ |
| 150467 | 151478 | if( sqlite3WhereTrace & 0x20000 ){ |
| 150468 | 151479 | sqlite3DebugPrintf("All WHERE-clause terms after coding level %d:\n", |
| 150469 | 151480 | iLevel); |
| | @@ -150474,10 +151485,94 @@ |
| 150474 | 151485 | iLevel, (u64)pLevel->notReady); |
| 150475 | 151486 | } |
| 150476 | 151487 | #endif |
| 150477 | 151488 | return pLevel->notReady; |
| 150478 | 151489 | } |
| 151490 | + |
| 151491 | +/* |
| 151492 | +** Generate the code for the loop that finds all non-matched terms |
| 151493 | +** for a RIGHT JOIN. |
| 151494 | +*/ |
| 151495 | +SQLITE_PRIVATE SQLITE_NOINLINE void sqlite3WhereRightJoinLoop( |
| 151496 | + WhereInfo *pWInfo, |
| 151497 | + int iLevel, |
| 151498 | + WhereLevel *pLevel |
| 151499 | +){ |
| 151500 | + Parse *pParse = pWInfo->pParse; |
| 151501 | + Vdbe *v = pParse->pVdbe; |
| 151502 | + WhereRightJoin *pRJ = pLevel->pRJ; |
| 151503 | + Expr *pSubWhere = 0; |
| 151504 | + WhereClause *pWC = &pWInfo->sWC; |
| 151505 | + WhereInfo *pSubWInfo; |
| 151506 | + WhereLoop *pLoop = pLevel->pWLoop; |
| 151507 | + SrcItem *pTabItem = &pWInfo->pTabList->a[pLevel->iFrom]; |
| 151508 | + SrcList sFrom; |
| 151509 | + Bitmask mAll = 0; |
| 151510 | + int k; |
| 151511 | + |
| 151512 | + ExplainQueryPlan((pParse, 1, "RIGHT-JOIN %s", pTabItem->pTab->zName)); |
| 151513 | + for(k=0; k<iLevel; k++){ |
| 151514 | + int iIdxCur; |
| 151515 | + mAll |= pWInfo->a[k].pWLoop->maskSelf; |
| 151516 | + sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur); |
| 151517 | + iIdxCur = pWInfo->a[k].iIdxCur; |
| 151518 | + if( iIdxCur ){ |
| 151519 | + sqlite3VdbeAddOp1(v, OP_NullRow, iIdxCur); |
| 151520 | + } |
| 151521 | + } |
| 151522 | + if( (pTabItem->fg.jointype & JT_LTORJ)==0 ){ |
| 151523 | + mAll |= pLoop->maskSelf; |
| 151524 | + for(k=0; k<pWC->nTerm; k++){ |
| 151525 | + WhereTerm *pTerm = &pWC->a[k]; |
| 151526 | + if( pTerm->wtFlags & TERM_VIRTUAL ) break; |
| 151527 | + if( pTerm->prereqAll & ~mAll ) continue; |
| 151528 | + if( ExprHasProperty(pTerm->pExpr, EP_FromJoin|EP_InnerJoin) ) continue; |
| 151529 | + pSubWhere = sqlite3ExprAnd(pParse, pSubWhere, |
| 151530 | + sqlite3ExprDup(pParse->db, pTerm->pExpr, 0)); |
| 151531 | + } |
| 151532 | + } |
| 151533 | + sFrom.nSrc = 1; |
| 151534 | + sFrom.nAlloc = 1; |
| 151535 | + memcpy(&sFrom.a[0], pTabItem, sizeof(SrcItem)); |
| 151536 | + sFrom.a[0].fg.jointype = 0; |
| 151537 | + assert( pParse->withinRJSubrtn < 100 ); |
| 151538 | + pParse->withinRJSubrtn++; |
| 151539 | + pSubWInfo = sqlite3WhereBegin(pParse, &sFrom, pSubWhere, 0, 0, 0, |
| 151540 | + WHERE_RIGHT_JOIN, 0); |
| 151541 | + if( pSubWInfo ){ |
| 151542 | + int iCur = pLevel->iTabCur; |
| 151543 | + int r = ++pParse->nMem; |
| 151544 | + int nPk; |
| 151545 | + int jmp; |
| 151546 | + int addrCont = sqlite3WhereContinueLabel(pSubWInfo); |
| 151547 | + Table *pTab = pTabItem->pTab; |
| 151548 | + if( HasRowid(pTab) ){ |
| 151549 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, -1, r); |
| 151550 | + nPk = 1; |
| 151551 | + }else{ |
| 151552 | + int iPk; |
| 151553 | + Index *pPk = sqlite3PrimaryKeyIndex(pTab); |
| 151554 | + nPk = pPk->nKeyCol; |
| 151555 | + pParse->nMem += nPk - 1; |
| 151556 | + for(iPk=0; iPk<nPk; iPk++){ |
| 151557 | + int iCol = pPk->aiColumn[iPk]; |
| 151558 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol,r+iPk); |
| 151559 | + } |
| 151560 | + } |
| 151561 | + jmp = sqlite3VdbeAddOp4Int(v, OP_Filter, pRJ->regBloom, 0, r, nPk); |
| 151562 | + VdbeCoverage(v); |
| 151563 | + sqlite3VdbeAddOp4Int(v, OP_Found, pRJ->iMatch, addrCont, r, nPk); |
| 151564 | + VdbeCoverage(v); |
| 151565 | + sqlite3VdbeJumpHere(v, jmp); |
| 151566 | + sqlite3VdbeAddOp2(v, OP_Gosub, pRJ->regReturn, pRJ->addrSubrtn); |
| 151567 | + sqlite3WhereEnd(pSubWInfo); |
| 151568 | + } |
| 151569 | + sqlite3ExprDelete(pParse->db, pSubWhere); |
| 151570 | + ExplainQueryPlanPop(pParse); |
| 151571 | + assert( pParse->withinRJSubrtn>0 ); |
| 151572 | + pParse->withinRJSubrtn--; |
| 151573 | +} |
| 150479 | 151574 | |
| 150480 | 151575 | /************** End of wherecode.c *******************************************/ |
| 150481 | 151576 | /************** Begin file whereexpr.c ***************************************/ |
| 150482 | 151577 | /* |
| 150483 | 151578 | ** 2015-06-08 |
| | @@ -150543,23 +151638,20 @@ |
| 150543 | 151638 | int idx; |
| 150544 | 151639 | testcase( wtFlags & TERM_VIRTUAL ); |
| 150545 | 151640 | if( pWC->nTerm>=pWC->nSlot ){ |
| 150546 | 151641 | WhereTerm *pOld = pWC->a; |
| 150547 | 151642 | sqlite3 *db = pWC->pWInfo->pParse->db; |
| 150548 | | - pWC->a = sqlite3DbMallocRawNN(db, sizeof(pWC->a[0])*pWC->nSlot*2 ); |
| 151643 | + pWC->a = sqlite3WhereMalloc(pWC->pWInfo, sizeof(pWC->a[0])*pWC->nSlot*2 ); |
| 150549 | 151644 | if( pWC->a==0 ){ |
| 150550 | 151645 | if( wtFlags & TERM_DYNAMIC ){ |
| 150551 | 151646 | sqlite3ExprDelete(db, p); |
| 150552 | 151647 | } |
| 150553 | 151648 | pWC->a = pOld; |
| 150554 | 151649 | return 0; |
| 150555 | 151650 | } |
| 150556 | 151651 | memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm); |
| 150557 | | - if( pOld!=pWC->aStatic ){ |
| 150558 | | - sqlite3DbFree(db, pOld); |
| 150559 | | - } |
| 150560 | | - pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]); |
| 151652 | + pWC->nSlot = pWC->nSlot*2; |
| 150561 | 151653 | } |
| 150562 | 151654 | pTerm = &pWC->a[idx = pWC->nTerm++]; |
| 150563 | 151655 | if( (wtFlags & TERM_VIRTUAL)==0 ) pWC->nBase = pWC->nTerm; |
| 150564 | 151656 | if( p && ExprHasProperty(p, EP_Unlikely) ){ |
| 150565 | 151657 | pTerm->truthProb = sqlite3LogEst(p->iTable) - 270; |
| | @@ -150945,11 +152037,11 @@ |
| 150945 | 152037 | ** a join, then transfer the appropriate markings over to derived. |
| 150946 | 152038 | */ |
| 150947 | 152039 | static void transferJoinMarkings(Expr *pDerived, Expr *pBase){ |
| 150948 | 152040 | if( pDerived ){ |
| 150949 | 152041 | pDerived->flags |= pBase->flags & EP_FromJoin; |
| 150950 | | - pDerived->w.iRightJoinTable = pBase->w.iRightJoinTable; |
| 152042 | + pDerived->w.iJoin = pBase->w.iJoin; |
| 150951 | 152043 | } |
| 150952 | 152044 | } |
| 150953 | 152045 | |
| 150954 | 152046 | /* |
| 150955 | 152047 | ** Mark term iChild as being a child of term iParent |
| | @@ -151430,11 +152522,13 @@ |
| 151430 | 152522 | mask |= sqlite3WhereExprUsage(pMaskSet, pS->pHaving); |
| 151431 | 152523 | if( ALWAYS(pSrc!=0) ){ |
| 151432 | 152524 | int i; |
| 151433 | 152525 | for(i=0; i<pSrc->nSrc; i++){ |
| 151434 | 152526 | mask |= exprSelectUsage(pMaskSet, pSrc->a[i].pSelect); |
| 151435 | | - mask |= sqlite3WhereExprUsage(pMaskSet, pSrc->a[i].pOn); |
| 152527 | + if( pSrc->a[i].fg.isUsing==0 ){ |
| 152528 | + mask |= sqlite3WhereExprUsage(pMaskSet, pSrc->a[i].u3.pOn); |
| 152529 | + } |
| 151436 | 152530 | if( pSrc->a[i].fg.isTabFunc ){ |
| 151437 | 152531 | mask |= sqlite3WhereExprListUsage(pMaskSet, pSrc->a[i].u1.pFuncArg); |
| 151438 | 152532 | } |
| 151439 | 152533 | } |
| 151440 | 152534 | } |
| | @@ -151590,11 +152684,11 @@ |
| 151590 | 152684 | abort(); |
| 151591 | 152685 | } |
| 151592 | 152686 | #endif |
| 151593 | 152687 | |
| 151594 | 152688 | if( ExprHasProperty(pExpr, EP_FromJoin) ){ |
| 151595 | | - Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->w.iRightJoinTable); |
| 152689 | + Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->w.iJoin); |
| 151596 | 152690 | prereqAll |= x; |
| 151597 | 152691 | extraRight = x-1; /* ON clause terms may not be used with an index |
| 151598 | 152692 | ** on left table of a LEFT JOIN. Ticket #3015 */ |
| 151599 | 152693 | if( (prereqAll>>1)>=x ){ |
| 151600 | 152694 | sqlite3ErrorMsg(pParse, "ON clause references tables to its right"); |
| | @@ -151941,11 +153035,11 @@ |
| 151941 | 153035 | Expr *pNewExpr; |
| 151942 | 153036 | pNewExpr = sqlite3PExpr(pParse, TK_MATCH, |
| 151943 | 153037 | 0, sqlite3ExprDup(db, pRight, 0)); |
| 151944 | 153038 | if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){ |
| 151945 | 153039 | ExprSetProperty(pNewExpr, EP_FromJoin); |
| 151946 | | - pNewExpr->w.iRightJoinTable = pExpr->w.iRightJoinTable; |
| 153040 | + pNewExpr->w.iJoin = pExpr->w.iJoin; |
| 151947 | 153041 | } |
| 151948 | 153042 | idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC); |
| 151949 | 153043 | testcase( idxNew==0 ); |
| 151950 | 153044 | pNewTerm = &pWC->a[idxNew]; |
| 151951 | 153045 | pNewTerm->prereqRight = prereqExpr; |
| | @@ -152163,13 +153257,10 @@ |
| 152163 | 153257 | } |
| 152164 | 153258 | if( a==aLast ) break; |
| 152165 | 153259 | a++; |
| 152166 | 153260 | } |
| 152167 | 153261 | } |
| 152168 | | - if( pWC->a!=pWC->aStatic ){ |
| 152169 | | - sqlite3DbFree(db, pWC->a); |
| 152170 | | - } |
| 152171 | 153262 | } |
| 152172 | 153263 | |
| 152173 | 153264 | |
| 152174 | 153265 | /* |
| 152175 | 153266 | ** These routines walk (recursively) an expression tree and generate |
| | @@ -152292,10 +153383,11 @@ |
| 152292 | 153383 | assert( pTab!=0 ); |
| 152293 | 153384 | pArgs = pItem->u1.pFuncArg; |
| 152294 | 153385 | if( pArgs==0 ) return; |
| 152295 | 153386 | for(j=k=0; j<pArgs->nExpr; j++){ |
| 152296 | 153387 | Expr *pRhs; |
| 153388 | + u32 joinType; |
| 152297 | 153389 | while( k<pTab->nCol && (pTab->aCol[k].colFlags & COLFLAG_HIDDEN)==0 ){k++;} |
| 152298 | 153390 | if( k>=pTab->nCol ){ |
| 152299 | 153391 | sqlite3ErrorMsg(pParse, "too many arguments on %s() - max %d", |
| 152300 | 153392 | pTab->zName, j); |
| 152301 | 153393 | return; |
| | @@ -152308,13 +153400,16 @@ |
| 152308 | 153400 | pColRef->y.pTab = pTab; |
| 152309 | 153401 | pItem->colUsed |= sqlite3ExprColUsed(pColRef); |
| 152310 | 153402 | pRhs = sqlite3PExpr(pParse, TK_UPLUS, |
| 152311 | 153403 | sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0); |
| 152312 | 153404 | pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs); |
| 152313 | | - if( pItem->fg.jointype & JT_LEFT ){ |
| 152314 | | - sqlite3SetJoinExpr(pTerm, pItem->iCursor); |
| 153405 | + if( pItem->fg.jointype & (JT_LEFT|JT_LTORJ) ){ |
| 153406 | + joinType = EP_FromJoin; |
| 153407 | + }else{ |
| 153408 | + joinType = EP_InnerJoin; |
| 152315 | 153409 | } |
| 153410 | + sqlite3SetJoinExpr(pTerm, pItem->iCursor, joinType); |
| 152316 | 153411 | whereClauseInsert(pWC, pTerm, TERM_DYNAMIC); |
| 152317 | 153412 | } |
| 152318 | 153413 | } |
| 152319 | 153414 | |
| 152320 | 153415 | /************** End of whereexpr.c *******************************************/ |
| | @@ -152571,10 +153666,34 @@ |
| 152571 | 153666 | return MASKBIT(i); |
| 152572 | 153667 | } |
| 152573 | 153668 | } |
| 152574 | 153669 | return 0; |
| 152575 | 153670 | } |
| 153671 | + |
| 153672 | +/* Allocate memory that is automatically freed when pWInfo is freed. |
| 153673 | +*/ |
| 153674 | +SQLITE_PRIVATE void *sqlite3WhereMalloc(WhereInfo *pWInfo, u64 nByte){ |
| 153675 | + WhereMemBlock *pBlock; |
| 153676 | + pBlock = sqlite3DbMallocRawNN(pWInfo->pParse->db, nByte+sizeof(*pBlock)); |
| 153677 | + if( pBlock ){ |
| 153678 | + pBlock->pNext = pWInfo->pMemToFree; |
| 153679 | + pBlock->sz = nByte; |
| 153680 | + pWInfo->pMemToFree = pBlock; |
| 153681 | + pBlock++; |
| 153682 | + } |
| 153683 | + return (void*)pBlock; |
| 153684 | +} |
| 153685 | +SQLITE_PRIVATE void *sqlite3WhereRealloc(WhereInfo *pWInfo, void *pOld, u64 nByte){ |
| 153686 | + void *pNew = sqlite3WhereMalloc(pWInfo, nByte); |
| 153687 | + if( pNew && pOld ){ |
| 153688 | + WhereMemBlock *pOldBlk = (WhereMemBlock*)pOld; |
| 153689 | + pOldBlk--; |
| 153690 | + assert( pOldBlk->sz<nByte ); |
| 153691 | + memcpy(pNew, pOld, pOldBlk->sz); |
| 153692 | + } |
| 153693 | + return pNew; |
| 153694 | +} |
| 152576 | 153695 | |
| 152577 | 153696 | /* |
| 152578 | 153697 | ** Create a new mask for cursor iCursor. |
| 152579 | 153698 | ** |
| 152580 | 153699 | ** There is one cursor per table in the FROM clause. The number of |
| | @@ -153051,17 +154170,17 @@ |
| 153051 | 154170 | const Bitmask notReady /* Tables in outer loops of the join */ |
| 153052 | 154171 | ){ |
| 153053 | 154172 | char aff; |
| 153054 | 154173 | if( pTerm->leftCursor!=pSrc->iCursor ) return 0; |
| 153055 | 154174 | if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0; |
| 153056 | | - if( (pSrc->fg.jointype & JT_LEFT) |
| 154175 | + if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 |
| 153057 | 154176 | && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) |
| 153058 | 154177 | && (pTerm->eOperator & WO_IS) |
| 153059 | 154178 | ){ |
| 153060 | 154179 | /* Cannot use an IS term from the WHERE clause as an index driver for |
| 153061 | | - ** the RHS of a LEFT JOIN. Such a term can only be used if it is from |
| 153062 | | - ** the ON clause. */ |
| 154180 | + ** the RHS of a LEFT JOIN or for the LHS of a RIGHT JOIN. Such a term |
| 154181 | + ** can only be used if it is from the ON clause. */ |
| 153063 | 154182 | return 0; |
| 153064 | 154183 | } |
| 153065 | 154184 | if( (pTerm->prereqRight & notReady)!=0 ) return 0; |
| 153066 | 154185 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 153067 | 154186 | if( pTerm->u.x.leftColumn<0 ) return 0; |
| | @@ -153127,11 +154246,12 @@ |
| 153127 | 154246 | Expr *pExpr = pTerm->pExpr; |
| 153128 | 154247 | /* Make the automatic index a partial index if there are terms in the |
| 153129 | 154248 | ** WHERE clause (or the ON clause of a LEFT join) that constrain which |
| 153130 | 154249 | ** rows of the target table (pSrc) that can be used. */ |
| 153131 | 154250 | if( (pTerm->wtFlags & TERM_VIRTUAL)==0 |
| 153132 | | - && ((pSrc->fg.jointype&JT_LEFT)==0 || ExprHasProperty(pExpr,EP_FromJoin)) |
| 154251 | + && ((pSrc->fg.jointype&(JT_LEFT|JT_LTORJ))==0 |
| 154252 | + || ExprHasProperty(pExpr,EP_FromJoin)) |
| 153133 | 154253 | && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) |
| 153134 | 154254 | ){ |
| 153135 | 154255 | pPartial = sqlite3ExprAnd(pParse, pPartial, |
| 153136 | 154256 | sqlite3ExprDup(pParse->db, pExpr, 0)); |
| 153137 | 154257 | } |
| | @@ -153400,11 +154520,11 @@ |
| 153400 | 154520 | if( OptimizationDisabled(pParse->db, SQLITE_BloomPulldown) ) break; |
| 153401 | 154521 | while( ++iLevel < pWInfo->nLevel ){ |
| 153402 | 154522 | const SrcItem *pTabItem; |
| 153403 | 154523 | pLevel = &pWInfo->a[iLevel]; |
| 153404 | 154524 | pTabItem = &pWInfo->pTabList->a[pLevel->iFrom]; |
| 153405 | | - if( pTabItem->fg.jointype & JT_LEFT ) continue; |
| 154525 | + if( pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ) ) continue; |
| 153406 | 154526 | pLoop = pLevel->pWLoop; |
| 153407 | 154527 | if( NEVER(pLoop==0) ) continue; |
| 153408 | 154528 | if( pLoop->prereq & notReady ) continue; |
| 153409 | 154529 | if( (pLoop->wsFlags & (WHERE_BLOOMFILTER|WHERE_COLUMN_IN)) |
| 153410 | 154530 | ==WHERE_BLOOMFILTER |
| | @@ -153473,13 +154593,14 @@ |
| 153473 | 154593 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); |
| 153474 | 154594 | assert( pTerm->u.x.leftColumn>=XN_ROWID ); |
| 153475 | 154595 | assert( pTerm->u.x.leftColumn<pTab->nCol ); |
| 153476 | 154596 | |
| 153477 | 154597 | /* tag-20191211-002: WHERE-clause constraints are not useful to the |
| 153478 | | - ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the |
| 154598 | + ** right-hand table of a LEFT JOIN nor to the left-hand table of a |
| 154599 | + ** RIGHT JOIN. See tag-20191211-001 for the |
| 153479 | 154600 | ** equivalent restriction for ordinary tables. */ |
| 153480 | | - if( (pSrc->fg.jointype & JT_LEFT)!=0 |
| 154601 | + if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 |
| 153481 | 154602 | && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) |
| 153482 | 154603 | ){ |
| 153483 | 154604 | continue; |
| 153484 | 154605 | } |
| 153485 | 154606 | nTerm++; |
| | @@ -154535,26 +155656,23 @@ |
| 154535 | 155656 | |
| 154536 | 155657 | /* |
| 154537 | 155658 | ** Free a WhereInfo structure |
| 154538 | 155659 | */ |
| 154539 | 155660 | static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){ |
| 154540 | | - int i; |
| 154541 | 155661 | assert( pWInfo!=0 ); |
| 154542 | | - for(i=0; i<pWInfo->nLevel; i++){ |
| 154543 | | - WhereLevel *pLevel = &pWInfo->a[i]; |
| 154544 | | - if( pLevel->pWLoop && (pLevel->pWLoop->wsFlags & WHERE_IN_ABLE)!=0 ){ |
| 154545 | | - assert( (pLevel->pWLoop->wsFlags & WHERE_MULTI_OR)==0 ); |
| 154546 | | - sqlite3DbFree(db, pLevel->u.in.aInLoop); |
| 154547 | | - } |
| 154548 | | - } |
| 154549 | 155662 | sqlite3WhereClauseClear(&pWInfo->sWC); |
| 154550 | 155663 | while( pWInfo->pLoops ){ |
| 154551 | 155664 | WhereLoop *p = pWInfo->pLoops; |
| 154552 | 155665 | pWInfo->pLoops = p->pNextLoop; |
| 154553 | 155666 | whereLoopDelete(db, p); |
| 154554 | 155667 | } |
| 154555 | 155668 | assert( pWInfo->pExprMods==0 ); |
| 155669 | + while( pWInfo->pMemToFree ){ |
| 155670 | + WhereMemBlock *pNext = pWInfo->pMemToFree->pNext; |
| 155671 | + sqlite3DbFreeNN(db, pWInfo->pMemToFree); |
| 155672 | + pWInfo->pMemToFree = pNext; |
| 155673 | + } |
| 154556 | 155674 | sqlite3DbFreeNN(db, pWInfo); |
| 154557 | 155675 | } |
| 154558 | 155676 | |
| 154559 | 155677 | /* Undo all Expr node modifications |
| 154560 | 155678 | */ |
| | @@ -154919,14 +156037,15 @@ |
| 154919 | 156037 | ** cause many rows to be omitted, then mark that table as |
| 154920 | 156038 | ** "self-culling". |
| 154921 | 156039 | ** |
| 154922 | 156040 | ** 2022-03-24: Self-culling only applies if either the extra terms |
| 154923 | 156041 | ** are straight comparison operators that are non-true with NULL |
| 154924 | | - ** operand, or if the loop is not a LEFT JOIN. |
| 156042 | + ** operand, or if the loop is not an OUTER JOIN. |
| 154925 | 156043 | */ |
| 154926 | 156044 | if( (pTerm->eOperator & 0x3f)!=0 |
| 154927 | | - || (pWC->pWInfo->pTabList->a[pLoop->iTab].fg.jointype & JT_LEFT)==0 |
| 156045 | + || (pWC->pWInfo->pTabList->a[pLoop->iTab].fg.jointype |
| 156046 | + & (JT_LEFT|JT_LTORJ))==0 |
| 154928 | 156047 | ){ |
| 154929 | 156048 | pLoop->wsFlags |= WHERE_SELFCULL; |
| 154930 | 156049 | } |
| 154931 | 156050 | } |
| 154932 | 156051 | if( pTerm->truthProb<=0 ){ |
| | @@ -155129,13 +156248,14 @@ |
| 155129 | 156248 | /* Do not allow the upper bound of a LIKE optimization range constraint |
| 155130 | 156249 | ** to mix with a lower range bound from some other source */ |
| 155131 | 156250 | if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue; |
| 155132 | 156251 | |
| 155133 | 156252 | /* tag-20191211-001: Do not allow constraints from the WHERE clause to |
| 155134 | | - ** be used by the right table of a LEFT JOIN. Only constraints in the |
| 156253 | + ** be used by the right table of a LEFT JOIN nor by the left table of a |
| 156254 | + ** RIGHT JOIN. Only constraints in the |
| 155135 | 156255 | ** ON clause are allowed. See tag-20191211-002 for the vtab equivalent. */ |
| 155136 | | - if( (pSrc->fg.jointype & JT_LEFT)!=0 |
| 156256 | + if( (pSrc->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 |
| 155137 | 156257 | && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) |
| 155138 | 156258 | ){ |
| 155139 | 156259 | continue; |
| 155140 | 156260 | } |
| 155141 | 156261 | |
| | @@ -155501,11 +156621,11 @@ |
| 155501 | 156621 | } |
| 155502 | 156622 | if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0; |
| 155503 | 156623 | for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){ |
| 155504 | 156624 | Expr *pExpr; |
| 155505 | 156625 | pExpr = pTerm->pExpr; |
| 155506 | | - if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->w.iRightJoinTable==iTab) |
| 156626 | + if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->w.iJoin==iTab) |
| 155507 | 156627 | && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin)) |
| 155508 | 156628 | && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) |
| 155509 | 156629 | && (pTerm->wtFlags & TERM_VNULL)==0 |
| 155510 | 156630 | ){ |
| 155511 | 156631 | return 1; |
| | @@ -155611,17 +156731,18 @@ |
| 155611 | 156731 | rSize = pTab->nRowLogEst; |
| 155612 | 156732 | |
| 155613 | 156733 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 155614 | 156734 | /* Automatic indexes */ |
| 155615 | 156735 | if( !pBuilder->pOrSet /* Not part of an OR optimization */ |
| 155616 | | - && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 |
| 156736 | + && (pWInfo->wctrlFlags & (WHERE_RIGHT_JOIN|WHERE_OR_SUBCLAUSE))==0 |
| 155617 | 156737 | && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 |
| 155618 | 156738 | && !pSrc->fg.isIndexedBy /* Has no INDEXED BY clause */ |
| 155619 | 156739 | && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */ |
| 155620 | 156740 | && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */ |
| 155621 | 156741 | && !pSrc->fg.isCorrelated /* Not a correlated subquery */ |
| 155622 | 156742 | && !pSrc->fg.isRecursive /* Not a recursive common table expression. */ |
| 156743 | + && (pSrc->fg.jointype & JT_RIGHT)==0 /* Not the right tab of a RIGHT JOIN */ |
| 155623 | 156744 | ){ |
| 155624 | 156745 | /* Generate auto-index WhereLoops */ |
| 155625 | 156746 | LogEst rLogSize; /* Logarithm of the number of rows in the table */ |
| 155626 | 156747 | WhereTerm *pTerm; |
| 155627 | 156748 | WhereTerm *pWCEnd = pWC->a + pWC->nTerm; |
| | @@ -156107,19 +157228,30 @@ |
| 156107 | 157228 | |
| 156108 | 157229 | #if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \ |
| 156109 | 157230 | && !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 156110 | 157231 | /* |
| 156111 | 157232 | ** Cause the prepared statement that is associated with a call to |
| 156112 | | -** xBestIndex to open write transactions on all attached schemas. |
| 157233 | +** xBestIndex to potentiall use all schemas. If the statement being |
| 157234 | +** prepared is read-only, then just start read transactions on all |
| 157235 | +** schemas. But if this is a write operation, start writes on all |
| 157236 | +** schemas. |
| 157237 | +** |
| 156113 | 157238 | ** This is used by the (built-in) sqlite_dbpage virtual table. |
| 156114 | 157239 | */ |
| 156115 | | -SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info *pIdxInfo){ |
| 157240 | +SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info *pIdxInfo){ |
| 156116 | 157241 | HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1]; |
| 156117 | 157242 | Parse *pParse = pHidden->pParse; |
| 156118 | 157243 | int nDb = pParse->db->nDb; |
| 156119 | 157244 | int i; |
| 156120 | | - for(i=0; i<nDb; i++) sqlite3BeginWriteOperation(pParse, 0, i); |
| 157245 | + for(i=0; i<nDb; i++){ |
| 157246 | + sqlite3CodeVerifySchema(pParse, i); |
| 157247 | + } |
| 157248 | + if( pParse->writeMask ){ |
| 157249 | + for(i=0; i<nDb; i++){ |
| 157250 | + sqlite3BeginWriteOperation(pParse, 0, i); |
| 157251 | + } |
| 157252 | + } |
| 156121 | 157253 | } |
| 156122 | 157254 | #endif |
| 156123 | 157255 | |
| 156124 | 157256 | /* |
| 156125 | 157257 | ** Add all WhereLoop objects for a table of the join identified by |
| | @@ -156297,10 +157429,13 @@ |
| 156297 | 157429 | pWCEnd = pWC->a + pWC->nTerm; |
| 156298 | 157430 | pNew = pBuilder->pNew; |
| 156299 | 157431 | memset(&sSum, 0, sizeof(sSum)); |
| 156300 | 157432 | pItem = pWInfo->pTabList->a + pNew->iTab; |
| 156301 | 157433 | iCur = pItem->iCursor; |
| 157434 | + |
| 157435 | + /* The multi-index OR optimization does not work for RIGHT and FULL JOIN */ |
| 157436 | + if( pItem->fg.jointype & JT_RIGHT ) return SQLITE_OK; |
| 156302 | 157437 | |
| 156303 | 157438 | for(pTerm=pWC->a; pTerm<pWCEnd && rc==SQLITE_OK; pTerm++){ |
| 156304 | 157439 | if( (pTerm->eOperator & WO_OR)!=0 |
| 156305 | 157440 | && (pTerm->u.pOrInfo->indexable & pNew->maskSelf)!=0 |
| 156306 | 157441 | ){ |
| | @@ -156422,22 +157557,22 @@ |
| 156422 | 157557 | for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){ |
| 156423 | 157558 | Bitmask mUnusable = 0; |
| 156424 | 157559 | pNew->iTab = iTab; |
| 156425 | 157560 | pBuilder->iPlanLimit += SQLITE_QUERY_PLANNER_LIMIT_INCR; |
| 156426 | 157561 | pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor); |
| 156427 | | - if( (pItem->fg.jointype & (JT_LEFT|JT_CROSS))!=0 ){ |
| 157562 | + if( (pItem->fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){ |
| 156428 | 157563 | /* This condition is true when pItem is the FROM clause term on the |
| 156429 | | - ** right-hand-side of a LEFT or CROSS JOIN. */ |
| 157564 | + ** right-hand-side of a OUTER or CROSS JOIN. */ |
| 156430 | 157565 | mPrereq = mPrior; |
| 156431 | 157566 | }else{ |
| 156432 | 157567 | mPrereq = 0; |
| 156433 | 157568 | } |
| 156434 | 157569 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 156435 | 157570 | if( IsVirtual(pItem->pTab) ){ |
| 156436 | 157571 | SrcItem *p; |
| 156437 | 157572 | for(p=&pItem[1]; p<pEnd; p++){ |
| 156438 | | - if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){ |
| 157573 | + if( mUnusable || (p->fg.jointype & (JT_OUTER|JT_CROSS)) ){ |
| 156439 | 157574 | mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor); |
| 156440 | 157575 | } |
| 156441 | 157576 | } |
| 156442 | 157577 | rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable); |
| 156443 | 157578 | }else |
| | @@ -157496,11 +158631,11 @@ |
| 157496 | 158631 | if( (tabUsed & pLoop->maskSelf)!=0 ) continue; |
| 157497 | 158632 | pEnd = pWInfo->sWC.a + pWInfo->sWC.nTerm; |
| 157498 | 158633 | for(pTerm=pWInfo->sWC.a; pTerm<pEnd; pTerm++){ |
| 157499 | 158634 | if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){ |
| 157500 | 158635 | if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin) |
| 157501 | | - || pTerm->pExpr->w.iRightJoinTable!=pItem->iCursor |
| 158636 | + || pTerm->pExpr->w.iJoin!=pItem->iCursor |
| 157502 | 158637 | ){ |
| 157503 | 158638 | break; |
| 157504 | 158639 | } |
| 157505 | 158640 | } |
| 157506 | 158641 | } |
| | @@ -157727,11 +158862,11 @@ |
| 157727 | 158862 | ** struct, the contents of WhereInfo.a[], the WhereClause structure |
| 157728 | 158863 | ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte |
| 157729 | 158864 | ** field (type Bitmask) it must be aligned on an 8-byte boundary on |
| 157730 | 158865 | ** some architectures. Hence the ROUND8() below. |
| 157731 | 158866 | */ |
| 157732 | | - nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); |
| 158867 | + nByteWInfo = ROUND8P(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); |
| 157733 | 158868 | pWInfo = sqlite3DbMallocRawNN(db, nByteWInfo + sizeof(WhereLoop)); |
| 157734 | 158869 | if( db->mallocFailed ){ |
| 157735 | 158870 | sqlite3DbFree(db, pWInfo); |
| 157736 | 158871 | pWInfo = 0; |
| 157737 | 158872 | goto whereBeginError; |
| | @@ -158049,12 +159184,14 @@ |
| 158049 | 159184 | sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB); |
| 158050 | 159185 | }else if( IsVirtual(pTab) ){ |
| 158051 | 159186 | /* noop */ |
| 158052 | 159187 | }else |
| 158053 | 159188 | #endif |
| 158054 | | - if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 |
| 158055 | | - && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){ |
| 159189 | + if( ((pLoop->wsFlags & WHERE_IDX_ONLY)==0 |
| 159190 | + && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0) |
| 159191 | + || (pTabItem->fg.jointype & (JT_LTORJ|JT_RIGHT))!=0 |
| 159192 | + ){ |
| 158056 | 159193 | int op = OP_OpenRead; |
| 158057 | 159194 | if( pWInfo->eOnePass!=ONEPASS_OFF ){ |
| 158058 | 159195 | op = OP_OpenWrite; |
| 158059 | 159196 | pWInfo->aiCurOnePass[0] = pTabItem->iCursor; |
| 158060 | 159197 | }; |
| | @@ -158152,10 +159289,41 @@ |
| 158152 | 159289 | } |
| 158153 | 159290 | #endif /* SQLITE_ENABLE_COLUMN_USED_MASK */ |
| 158154 | 159291 | } |
| 158155 | 159292 | } |
| 158156 | 159293 | if( iDb>=0 ) sqlite3CodeVerifySchema(pParse, iDb); |
| 159294 | + if( (pTabItem->fg.jointype & JT_RIGHT)!=0 |
| 159295 | + && (pLevel->pRJ = sqlite3WhereMalloc(pWInfo, sizeof(WhereRightJoin)))!=0 |
| 159296 | + ){ |
| 159297 | + WhereRightJoin *pRJ = pLevel->pRJ; |
| 159298 | + pRJ->iMatch = pParse->nTab++; |
| 159299 | + pRJ->regBloom = ++pParse->nMem; |
| 159300 | + sqlite3VdbeAddOp2(v, OP_Blob, 65536, pRJ->regBloom); |
| 159301 | + pRJ->regReturn = ++pParse->nMem; |
| 159302 | + sqlite3VdbeAddOp2(v, OP_Null, 0, pRJ->regReturn); |
| 159303 | + assert( pTab==pTabItem->pTab ); |
| 159304 | + if( HasRowid(pTab) ){ |
| 159305 | + KeyInfo *pInfo; |
| 159306 | + sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRJ->iMatch, 1); |
| 159307 | + pInfo = sqlite3KeyInfoAlloc(pParse->db, 1, 0); |
| 159308 | + if( pInfo ){ |
| 159309 | + pInfo->aColl[0] = 0; |
| 159310 | + pInfo->aSortFlags[0] = 0; |
| 159311 | + sqlite3VdbeAppendP4(v, pInfo, P4_KEYINFO); |
| 159312 | + } |
| 159313 | + }else{ |
| 159314 | + Index *pPk = sqlite3PrimaryKeyIndex(pTab); |
| 159315 | + sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRJ->iMatch, pPk->nKeyCol); |
| 159316 | + sqlite3VdbeSetP4KeyInfo(pParse, pPk); |
| 159317 | + } |
| 159318 | + pLoop->wsFlags &= ~WHERE_IDX_ONLY; |
| 159319 | + /* The nature of RIGHT JOIN processing is such that it messes up |
| 159320 | + ** the output order. So omit any ORDER BY/GROUP BY elimination |
| 159321 | + ** optimizations. We need to do an actual sort for RIGHT JOIN. */ |
| 159322 | + pWInfo->nOBSat = 0; |
| 159323 | + pWInfo->eDistinct = WHERE_DISTINCT_UNORDERED; |
| 159324 | + } |
| 158157 | 159325 | } |
| 158158 | 159326 | pWInfo->iTop = sqlite3VdbeCurrentAddr(v); |
| 158159 | 159327 | if( db->mallocFailed ) goto whereBeginError; |
| 158160 | 159328 | |
| 158161 | 159329 | /* Generate the code to do the search. Each iteration of the for |
| | @@ -158264,10 +159432,21 @@ |
| 158264 | 159432 | */ |
| 158265 | 159433 | VdbeModuleComment((v, "End WHERE-core")); |
| 158266 | 159434 | for(i=pWInfo->nLevel-1; i>=0; i--){ |
| 158267 | 159435 | int addr; |
| 158268 | 159436 | pLevel = &pWInfo->a[i]; |
| 159437 | + if( pLevel->pRJ ){ |
| 159438 | + /* Terminate the subroutine that forms the interior of the loop of |
| 159439 | + ** the RIGHT JOIN table */ |
| 159440 | + WhereRightJoin *pRJ = pLevel->pRJ; |
| 159441 | + sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 159442 | + pLevel->addrCont = 0; |
| 159443 | + sqlite3VdbeAddOp3(v, OP_Return, pRJ->regReturn, pRJ->addrSubrtn, 1); |
| 159444 | + VdbeCoverage(v); |
| 159445 | + assert( pParse->withinRJSubrtn>0 ); |
| 159446 | + pParse->withinRJSubrtn--; |
| 159447 | + } |
| 158269 | 159448 | pLoop = pLevel->pWLoop; |
| 158270 | 159449 | if( pLevel->op!=OP_Noop ){ |
| 158271 | 159450 | #ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT |
| 158272 | 159451 | int addrSeek = 0; |
| 158273 | 159452 | Index *pIdx; |
| | @@ -158291,11 +159470,11 @@ |
| 158291 | 159470 | VdbeCoverageIf(v, op==OP_SeekGT); |
| 158292 | 159471 | sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2); |
| 158293 | 159472 | } |
| 158294 | 159473 | #endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */ |
| 158295 | 159474 | /* The common case: Advance to the next row */ |
| 158296 | | - sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 159475 | + if( pLevel->addrCont ) sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 158297 | 159476 | sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3); |
| 158298 | 159477 | sqlite3VdbeChangeP5(v, pLevel->p5); |
| 158299 | 159478 | VdbeCoverage(v); |
| 158300 | 159479 | VdbeCoverageIf(v, pLevel->op==OP_Next); |
| 158301 | 159480 | VdbeCoverageIf(v, pLevel->op==OP_Prev); |
| | @@ -158306,11 +159485,11 @@ |
| 158306 | 159485 | VdbeCoverage(v); |
| 158307 | 159486 | } |
| 158308 | 159487 | #ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT |
| 158309 | 159488 | if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek); |
| 158310 | 159489 | #endif |
| 158311 | | - }else{ |
| 159490 | + }else if( pLevel->addrCont ){ |
| 158312 | 159491 | sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 158313 | 159492 | } |
| 158314 | 159493 | if( (pLoop->wsFlags & WHERE_IN_ABLE)!=0 && pLevel->u.in.nIn>0 ){ |
| 158315 | 159494 | struct InLoop *pIn; |
| 158316 | 159495 | int j; |
| | @@ -158356,10 +159535,14 @@ |
| 158356 | 159535 | } |
| 158357 | 159536 | sqlite3VdbeJumpHere(v, pIn->addrInTop-1); |
| 158358 | 159537 | } |
| 158359 | 159538 | } |
| 158360 | 159539 | sqlite3VdbeResolveLabel(v, pLevel->addrBrk); |
| 159540 | + if( pLevel->pRJ ){ |
| 159541 | + sqlite3VdbeAddOp3(v, OP_Return, pLevel->pRJ->regReturn, 0, 1); |
| 159542 | + VdbeCoverage(v); |
| 159543 | + } |
| 158361 | 159544 | if( pLevel->addrSkip ){ |
| 158362 | 159545 | sqlite3VdbeGoto(v, pLevel->addrSkip); |
| 158363 | 159546 | VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName)); |
| 158364 | 159547 | sqlite3VdbeJumpHere(v, pLevel->addrSkip); |
| 158365 | 159548 | sqlite3VdbeJumpHere(v, pLevel->addrSkip-2); |
| | @@ -158399,24 +159582,28 @@ |
| 158399 | 159582 | } |
| 158400 | 159583 | VdbeModuleComment((v, "End WHERE-loop%d: %s", i, |
| 158401 | 159584 | pWInfo->pTabList->a[pLevel->iFrom].pTab->zName)); |
| 158402 | 159585 | } |
| 158403 | 159586 | |
| 158404 | | - /* The "break" point is here, just past the end of the outer loop. |
| 158405 | | - ** Set it. |
| 158406 | | - */ |
| 158407 | | - sqlite3VdbeResolveLabel(v, pWInfo->iBreak); |
| 158408 | | - |
| 158409 | 159587 | assert( pWInfo->nLevel<=pTabList->nSrc ); |
| 158410 | 159588 | for(i=0, pLevel=pWInfo->a; i<pWInfo->nLevel; i++, pLevel++){ |
| 158411 | 159589 | int k, last; |
| 158412 | 159590 | VdbeOp *pOp, *pLastOp; |
| 158413 | 159591 | Index *pIdx = 0; |
| 158414 | 159592 | SrcItem *pTabItem = &pTabList->a[pLevel->iFrom]; |
| 158415 | 159593 | Table *pTab = pTabItem->pTab; |
| 158416 | 159594 | assert( pTab!=0 ); |
| 158417 | 159595 | pLoop = pLevel->pWLoop; |
| 159596 | + |
| 159597 | + /* Do RIGHT JOIN processing. Generate code that will output the |
| 159598 | + ** unmatched rows of the right operand of the RIGHT JOIN with |
| 159599 | + ** all of the columns of the left operand set to NULL. |
| 159600 | + */ |
| 159601 | + if( pLevel->pRJ ){ |
| 159602 | + sqlite3WhereRightJoinLoop(pWInfo, i, pLevel); |
| 159603 | + continue; |
| 159604 | + } |
| 158418 | 159605 | |
| 158419 | 159606 | /* For a co-routine, change all OP_Column references to the table of |
| 158420 | 159607 | ** the co-routine into OP_Copy of result contained in a register. |
| 158421 | 159608 | ** OP_Rowid becomes OP_Null. |
| 158422 | 159609 | */ |
| | @@ -158425,33 +159612,10 @@ |
| 158425 | 159612 | translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur, |
| 158426 | 159613 | pTabItem->regResult, 0); |
| 158427 | 159614 | continue; |
| 158428 | 159615 | } |
| 158429 | 159616 | |
| 158430 | | -#ifdef SQLITE_ENABLE_EARLY_CURSOR_CLOSE |
| 158431 | | - /* Close all of the cursors that were opened by sqlite3WhereBegin. |
| 158432 | | - ** Except, do not close cursors that will be reused by the OR optimization |
| 158433 | | - ** (WHERE_OR_SUBCLAUSE). And do not close the OP_OpenWrite cursors |
| 158434 | | - ** created for the ONEPASS optimization. |
| 158435 | | - */ |
| 158436 | | - if( (pTab->tabFlags & TF_Ephemeral)==0 |
| 158437 | | - && !IsView(pTab) |
| 158438 | | - && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 |
| 158439 | | - ){ |
| 158440 | | - int ws = pLoop->wsFlags; |
| 158441 | | - if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){ |
| 158442 | | - sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor); |
| 158443 | | - } |
| 158444 | | - if( (ws & WHERE_INDEXED)!=0 |
| 158445 | | - && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0 |
| 158446 | | - && pLevel->iIdxCur!=pWInfo->aiCurOnePass[1] |
| 158447 | | - ){ |
| 158448 | | - sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur); |
| 158449 | | - } |
| 158450 | | - } |
| 158451 | | -#endif |
| 158452 | | - |
| 158453 | 159617 | /* If this scan uses an index, make VDBE code substitutions to read data |
| 158454 | 159618 | ** from the index instead of from the table where possible. In some cases |
| 158455 | 159619 | ** this optimization prevents the table from ever being read, which can |
| 158456 | 159620 | ** yield a significant performance boost. |
| 158457 | 159621 | ** |
| | @@ -158547,10 +159711,15 @@ |
| 158547 | 159711 | #ifdef SQLITE_DEBUG |
| 158548 | 159712 | if( db->flags & SQLITE_VdbeAddopTrace ) printf("TRANSLATE complete\n"); |
| 158549 | 159713 | #endif |
| 158550 | 159714 | } |
| 158551 | 159715 | } |
| 159716 | + |
| 159717 | + /* The "break" point is here, just past the end of the outer loop. |
| 159718 | + ** Set it. |
| 159719 | + */ |
| 159720 | + sqlite3VdbeResolveLabel(v, pWInfo->iBreak); |
| 158552 | 159721 | |
| 158553 | 159722 | /* Final cleanup |
| 158554 | 159723 | */ |
| 158555 | 159724 | if( pWInfo->pExprMods ) whereUndoExprMods(pWInfo); |
| 158556 | 159725 | pParse->nQueryLoop = pWInfo->savedNQueryLoop; |
| | @@ -160289,11 +161458,11 @@ |
| 160289 | 161458 | regArg = sqlite3GetTempRange(pParse, nArg); |
| 160290 | 161459 | sqlite3ExprCodeExprList(pParse, pWin->pOwner->x.pList, regArg, 0, 0); |
| 160291 | 161460 | |
| 160292 | 161461 | for(iEnd=sqlite3VdbeCurrentAddr(v); iOp<iEnd; iOp++){ |
| 160293 | 161462 | VdbeOp *pOp = sqlite3VdbeGetOp(v, iOp); |
| 160294 | | - if( pOp->opcode==OP_Column && pOp->p1==pWin->iEphCsr ){ |
| 161463 | + if( pOp->opcode==OP_Column && pOp->p1==pMWin->iEphCsr ){ |
| 160295 | 161464 | pOp->p1 = csr; |
| 160296 | 161465 | } |
| 160297 | 161466 | } |
| 160298 | 161467 | } |
| 160299 | 161468 | if( pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ |
| | @@ -161828,11 +162997,11 @@ |
| 161828 | 162997 | /* memset(p, 0, sizeof(Expr)); */ |
| 161829 | 162998 | p->op = (u8)op; |
| 161830 | 162999 | p->affExpr = 0; |
| 161831 | 163000 | p->flags = EP_Leaf; |
| 161832 | 163001 | ExprClearVVAProperties(p); |
| 161833 | | - p->iAgg = -1; |
| 163002 | + /* p->iAgg = -1; // Not required */ |
| 161834 | 163003 | p->pLeft = p->pRight = 0; |
| 161835 | 163004 | p->pAggInfo = 0; |
| 161836 | 163005 | memset(&p->x, 0, sizeof(p->x)); |
| 161837 | 163006 | memset(&p->y, 0, sizeof(p->y)); |
| 161838 | 163007 | p->op2 = 0; |
| | @@ -162161,10 +163330,11 @@ |
| 162161 | 163330 | Upsert* yy444; |
| 162162 | 163331 | u8 yy516; |
| 162163 | 163332 | With* yy521; |
| 162164 | 163333 | const char* yy522; |
| 162165 | 163334 | Expr* yy528; |
| 163335 | + OnOrUsing yy561; |
| 162166 | 163336 | struct FrameBound yy595; |
| 162167 | 163337 | } YYMINORTYPE; |
| 162168 | 163338 | #ifndef YYSTACKDEPTH |
| 162169 | 163339 | #define YYSTACKDEPTH 100 |
| 162170 | 163340 | #endif |
| | @@ -162177,21 +163347,21 @@ |
| 162177 | 163347 | #define sqlite3ParserCTX_PDECL ,Parse *pParse |
| 162178 | 163348 | #define sqlite3ParserCTX_PARAM ,pParse |
| 162179 | 163349 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; |
| 162180 | 163350 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 162181 | 163351 | #define YYFALLBACK 1 |
| 162182 | | -#define YYNSTATE 574 |
| 162183 | | -#define YYNRULE 402 |
| 163352 | +#define YYNSTATE 570 |
| 163353 | +#define YYNRULE 403 |
| 162184 | 163354 | #define YYNRULE_WITH_ACTION 340 |
| 162185 | 163355 | #define YYNTOKEN 185 |
| 162186 | | -#define YY_MAX_SHIFT 573 |
| 162187 | | -#define YY_MIN_SHIFTREDUCE 831 |
| 162188 | | -#define YY_MAX_SHIFTREDUCE 1232 |
| 162189 | | -#define YY_ERROR_ACTION 1233 |
| 162190 | | -#define YY_ACCEPT_ACTION 1234 |
| 162191 | | -#define YY_NO_ACTION 1235 |
| 162192 | | -#define YY_MIN_REDUCE 1236 |
| 163356 | +#define YY_MAX_SHIFT 569 |
| 163357 | +#define YY_MIN_SHIFTREDUCE 829 |
| 163358 | +#define YY_MAX_SHIFTREDUCE 1231 |
| 163359 | +#define YY_ERROR_ACTION 1232 |
| 163360 | +#define YY_ACCEPT_ACTION 1233 |
| 163361 | +#define YY_NO_ACTION 1234 |
| 163362 | +#define YY_MIN_REDUCE 1235 |
| 162193 | 163363 | #define YY_MAX_REDUCE 1637 |
| 162194 | 163364 | /************* End control #defines *******************************************/ |
| 162195 | 163365 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
| 162196 | 163366 | |
| 162197 | 163367 | /* Define the yytestcase() macro to be a no-op if is not already defined |
| | @@ -162255,428 +163425,428 @@ |
| 162255 | 163425 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 162256 | 163426 | ** shifting non-terminals after a reduce. |
| 162257 | 163427 | ** yy_default[] Default action for each state. |
| 162258 | 163428 | ** |
| 162259 | 163429 | *********** Begin parsing tables **********************************************/ |
| 162260 | | -#define YY_ACTTAB_COUNT (2070) |
| 163430 | +#define YY_ACTTAB_COUNT (2064) |
| 162261 | 163431 | static const YYACTIONTYPE yy_action[] = { |
| 162262 | | - /* 0 */ 566, 1307, 566, 1286, 201, 201, 566, 116, 112, 222, |
| 162263 | | - /* 10 */ 566, 1307, 377, 566, 116, 112, 222, 397, 408, 409, |
| 162264 | | - /* 20 */ 1260, 378, 1269, 41, 41, 41, 41, 1412, 1517, 71, |
| 162265 | | - /* 30 */ 71, 967, 1258, 41, 41, 491, 71, 71, 272, 968, |
| 162266 | | - /* 40 */ 298, 476, 298, 123, 124, 114, 1210, 1210, 1044, 1047, |
| 162267 | | - /* 50 */ 1036, 1036, 121, 121, 122, 122, 122, 122, 543, 409, |
| 162268 | | - /* 60 */ 1234, 1, 1, 573, 2, 1238, 548, 116, 112, 222, |
| 162269 | | - /* 70 */ 309, 480, 142, 548, 1272, 524, 116, 112, 222, 1320, |
| 162270 | | - /* 80 */ 417, 523, 547, 123, 124, 114, 1210, 1210, 1044, 1047, |
| 162271 | | - /* 90 */ 1036, 1036, 121, 121, 122, 122, 122, 122, 424, 116, |
| 162272 | | - /* 100 */ 112, 222, 120, 120, 120, 120, 119, 119, 118, 118, |
| 162273 | | - /* 110 */ 118, 117, 113, 444, 277, 277, 277, 277, 560, 560, |
| 162274 | | - /* 120 */ 560, 1558, 376, 1560, 1186, 375, 1157, 563, 1157, 563, |
| 162275 | | - /* 130 */ 409, 1558, 537, 252, 219, 1553, 99, 141, 449, 6, |
| 162276 | | - /* 140 */ 365, 233, 120, 120, 120, 120, 119, 119, 118, 118, |
| 162277 | | - /* 150 */ 118, 117, 113, 444, 123, 124, 114, 1210, 1210, 1044, |
| 162278 | | - /* 160 */ 1047, 1036, 1036, 121, 121, 122, 122, 122, 122, 138, |
| 162279 | | - /* 170 */ 289, 1186, 1546, 448, 118, 118, 118, 117, 113, 444, |
| 162280 | | - /* 180 */ 125, 1186, 1187, 1188, 144, 465, 334, 566, 150, 127, |
| 162281 | | - /* 190 */ 444, 122, 122, 122, 122, 115, 120, 120, 120, 120, |
| 162282 | | - /* 200 */ 119, 119, 118, 118, 118, 117, 113, 444, 454, 419, |
| 162283 | | - /* 210 */ 13, 13, 215, 120, 120, 120, 120, 119, 119, 118, |
| 162284 | | - /* 220 */ 118, 118, 117, 113, 444, 422, 308, 557, 1186, 1187, |
| 162285 | | - /* 230 */ 1188, 441, 440, 409, 1271, 122, 122, 122, 122, 120, |
| 163432 | + /* 0 */ 562, 204, 562, 116, 112, 225, 562, 116, 112, 225, |
| 163433 | + /* 10 */ 562, 1306, 373, 1285, 404, 556, 556, 556, 562, 405, |
| 163434 | + /* 20 */ 374, 1306, 1268, 41, 41, 41, 41, 204, 1516, 71, |
| 163435 | + /* 30 */ 71, 965, 415, 41, 41, 487, 299, 275, 299, 966, |
| 163436 | + /* 40 */ 393, 71, 71, 123, 124, 114, 1209, 1209, 1042, 1045, |
| 163437 | + /* 50 */ 1034, 1034, 121, 121, 122, 122, 122, 122, 472, 405, |
| 163438 | + /* 60 */ 1233, 1, 1, 569, 2, 1237, 544, 116, 112, 225, |
| 163439 | + /* 70 */ 313, 476, 142, 476, 520, 116, 112, 225, 525, 1319, |
| 163440 | + /* 80 */ 413, 519, 138, 123, 124, 114, 1209, 1209, 1042, 1045, |
| 163441 | + /* 90 */ 1034, 1034, 121, 121, 122, 122, 122, 122, 116, 112, |
| 163442 | + /* 100 */ 225, 323, 120, 120, 120, 120, 119, 119, 118, 118, |
| 163443 | + /* 110 */ 118, 117, 113, 440, 280, 280, 280, 280, 438, 438, |
| 163444 | + /* 120 */ 438, 1557, 372, 1559, 1184, 371, 1155, 559, 1155, 559, |
| 163445 | + /* 130 */ 405, 1557, 533, 255, 222, 440, 99, 141, 445, 312, |
| 163446 | + /* 140 */ 553, 236, 120, 120, 120, 120, 119, 119, 118, 118, |
| 163447 | + /* 150 */ 118, 117, 113, 440, 123, 124, 114, 1209, 1209, 1042, |
| 163448 | + /* 160 */ 1045, 1034, 1034, 121, 121, 122, 122, 122, 122, 138, |
| 163449 | + /* 170 */ 290, 1184, 335, 444, 118, 118, 118, 117, 113, 440, |
| 163450 | + /* 180 */ 125, 1184, 1185, 1186, 144, 437, 436, 562, 117, 113, |
| 163451 | + /* 190 */ 440, 122, 122, 122, 122, 115, 120, 120, 120, 120, |
| 163452 | + /* 200 */ 119, 119, 118, 118, 118, 117, 113, 440, 450, 110, |
| 163453 | + /* 210 */ 13, 13, 542, 120, 120, 120, 120, 119, 119, 118, |
| 163454 | + /* 220 */ 118, 118, 117, 113, 440, 418, 312, 553, 1184, 1185, |
| 163455 | + /* 230 */ 1186, 145, 1216, 405, 1216, 122, 122, 122, 122, 120, |
| 162286 | 163456 | /* 240 */ 120, 120, 120, 119, 119, 118, 118, 118, 117, 113, |
| 162287 | | - /* 250 */ 444, 1543, 98, 1033, 1033, 1045, 1048, 123, 124, 114, |
| 162288 | | - /* 260 */ 1210, 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, |
| 162289 | | - /* 270 */ 122, 122, 566, 406, 405, 1186, 566, 409, 1217, 319, |
| 162290 | | - /* 280 */ 1217, 80, 81, 120, 120, 120, 120, 119, 119, 118, |
| 162291 | | - /* 290 */ 118, 118, 117, 113, 444, 70, 70, 1186, 1604, 71, |
| 162292 | | - /* 300 */ 71, 123, 124, 114, 1210, 1210, 1044, 1047, 1036, 1036, |
| 163457 | + /* 250 */ 440, 461, 338, 1031, 1031, 1043, 1046, 123, 124, 114, |
| 163458 | + /* 260 */ 1209, 1209, 1042, 1045, 1034, 1034, 121, 121, 122, 122, |
| 163459 | + /* 270 */ 122, 122, 1271, 518, 218, 1184, 562, 405, 220, 510, |
| 163460 | + /* 280 */ 171, 80, 81, 120, 120, 120, 120, 119, 119, 118, |
| 163461 | + /* 290 */ 118, 118, 117, 113, 440, 1001, 16, 16, 1184, 55, |
| 163462 | + /* 300 */ 55, 123, 124, 114, 1209, 1209, 1042, 1045, 1034, 1034, |
| 162293 | 163463 | /* 310 */ 121, 121, 122, 122, 122, 122, 120, 120, 120, 120, |
| 162294 | | - /* 320 */ 119, 119, 118, 118, 118, 117, 113, 444, 1037, 210, |
| 162295 | | - /* 330 */ 1186, 365, 1186, 1187, 1188, 245, 548, 399, 504, 501, |
| 162296 | | - /* 340 */ 500, 108, 558, 138, 4, 516, 933, 433, 499, 217, |
| 162297 | | - /* 350 */ 514, 522, 352, 879, 1186, 1187, 1188, 383, 561, 566, |
| 163464 | + /* 320 */ 119, 119, 118, 118, 118, 117, 113, 440, 1035, 542, |
| 163465 | + /* 330 */ 1184, 369, 1184, 1185, 1186, 248, 1426, 395, 500, 497, |
| 163466 | + /* 340 */ 496, 108, 554, 560, 4, 920, 920, 429, 495, 336, |
| 163467 | + /* 350 */ 456, 324, 356, 390, 1229, 1184, 1185, 1186, 557, 562, |
| 162298 | 163468 | /* 360 */ 120, 120, 120, 120, 119, 119, 118, 118, 118, 117, |
| 162299 | | - /* 370 */ 113, 444, 277, 277, 16, 16, 1598, 441, 440, 153, |
| 162300 | | - /* 380 */ 409, 445, 13, 13, 1279, 563, 1214, 1186, 1187, 1188, |
| 162301 | | - /* 390 */ 1003, 1216, 264, 555, 1574, 186, 566, 427, 138, 1215, |
| 162302 | | - /* 400 */ 308, 557, 472, 138, 123, 124, 114, 1210, 1210, 1044, |
| 162303 | | - /* 410 */ 1047, 1036, 1036, 121, 121, 122, 122, 122, 122, 55, |
| 162304 | | - /* 420 */ 55, 413, 1023, 507, 1217, 1186, 1217, 474, 106, 106, |
| 162305 | | - /* 430 */ 1312, 1312, 1186, 171, 566, 384, 107, 380, 445, 568, |
| 162306 | | - /* 440 */ 567, 430, 1543, 1013, 332, 549, 565, 263, 280, 360, |
| 162307 | | - /* 450 */ 510, 355, 509, 250, 491, 308, 557, 71, 71, 351, |
| 162308 | | - /* 460 */ 308, 557, 374, 120, 120, 120, 120, 119, 119, 118, |
| 162309 | | - /* 470 */ 118, 118, 117, 113, 444, 1013, 1013, 1015, 1016, 27, |
| 162310 | | - /* 480 */ 277, 277, 1186, 1187, 1188, 1152, 566, 528, 409, 1186, |
| 162311 | | - /* 490 */ 1187, 1188, 348, 563, 548, 1260, 533, 517, 1152, 1516, |
| 162312 | | - /* 500 */ 317, 1152, 285, 550, 485, 569, 566, 569, 482, 51, |
| 162313 | | - /* 510 */ 51, 207, 123, 124, 114, 1210, 1210, 1044, 1047, 1036, |
| 162314 | | - /* 520 */ 1036, 121, 121, 122, 122, 122, 122, 171, 1412, 13, |
| 162315 | | - /* 530 */ 13, 409, 277, 277, 1186, 505, 119, 119, 118, 118, |
| 162316 | | - /* 540 */ 118, 117, 113, 444, 429, 563, 518, 220, 515, 1552, |
| 162317 | | - /* 550 */ 365, 546, 1186, 6, 532, 123, 124, 114, 1210, 1210, |
| 162318 | | - /* 560 */ 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, 122, |
| 162319 | | - /* 570 */ 145, 120, 120, 120, 120, 119, 119, 118, 118, 118, |
| 162320 | | - /* 580 */ 117, 113, 444, 245, 566, 474, 504, 501, 500, 566, |
| 162321 | | - /* 590 */ 1481, 1186, 1187, 1188, 1310, 1310, 499, 1186, 149, 425, |
| 162322 | | - /* 600 */ 1186, 480, 409, 274, 365, 952, 872, 56, 56, 1186, |
| 162323 | | - /* 610 */ 1187, 1188, 71, 71, 120, 120, 120, 120, 119, 119, |
| 162324 | | - /* 620 */ 118, 118, 118, 117, 113, 444, 123, 124, 114, 1210, |
| 162325 | | - /* 630 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, |
| 162326 | | - /* 640 */ 122, 409, 541, 1552, 83, 865, 98, 6, 928, 529, |
| 162327 | | - /* 650 */ 848, 543, 151, 927, 1186, 1187, 1188, 1186, 1187, 1188, |
| 162328 | | - /* 660 */ 290, 1543, 187, 1633, 395, 123, 124, 114, 1210, 1210, |
| 162329 | | - /* 670 */ 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, 122, |
| 162330 | | - /* 680 */ 566, 954, 566, 453, 953, 120, 120, 120, 120, 119, |
| 162331 | | - /* 690 */ 119, 118, 118, 118, 117, 113, 444, 1152, 221, 1186, |
| 162332 | | - /* 700 */ 331, 453, 452, 13, 13, 13, 13, 1003, 365, 463, |
| 162333 | | - /* 710 */ 1152, 193, 409, 1152, 382, 1543, 1170, 32, 297, 474, |
| 162334 | | - /* 720 */ 195, 1527, 5, 952, 120, 120, 120, 120, 119, 119, |
| 162335 | | - /* 730 */ 118, 118, 118, 117, 113, 444, 123, 124, 114, 1210, |
| 162336 | | - /* 740 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, |
| 162337 | | - /* 750 */ 122, 409, 1067, 419, 1186, 1024, 1186, 1187, 1188, 1186, |
| 162338 | | - /* 760 */ 419, 332, 460, 320, 544, 1545, 442, 442, 442, 566, |
| 162339 | | - /* 770 */ 3, 117, 113, 444, 453, 123, 124, 114, 1210, 1210, |
| 162340 | | - /* 780 */ 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, 122, |
| 162341 | | - /* 790 */ 1473, 566, 15, 15, 293, 120, 120, 120, 120, 119, |
| 162342 | | - /* 800 */ 119, 118, 118, 118, 117, 113, 444, 1186, 566, 1486, |
| 162343 | | - /* 810 */ 1412, 1186, 1187, 1188, 13, 13, 1186, 1187, 1188, 1544, |
| 162344 | | - /* 820 */ 271, 271, 409, 286, 308, 557, 1008, 1486, 1488, 196, |
| 162345 | | - /* 830 */ 288, 71, 71, 563, 120, 120, 120, 120, 119, 119, |
| 162346 | | - /* 840 */ 118, 118, 118, 117, 113, 444, 123, 124, 114, 1210, |
| 162347 | | - /* 850 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, |
| 162348 | | - /* 860 */ 122, 409, 201, 1087, 1186, 1187, 1188, 1324, 304, 1529, |
| 162349 | | - /* 870 */ 388, 278, 278, 450, 564, 402, 922, 922, 566, 563, |
| 162350 | | - /* 880 */ 566, 426, 491, 480, 563, 123, 124, 114, 1210, 1210, |
| 162351 | | - /* 890 */ 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, 122, |
| 162352 | | - /* 900 */ 1486, 71, 71, 13, 13, 120, 120, 120, 120, 119, |
| 162353 | | - /* 910 */ 119, 118, 118, 118, 117, 113, 444, 566, 545, 566, |
| 162354 | | - /* 920 */ 1577, 573, 2, 1238, 1092, 1092, 488, 1480, 309, 1525, |
| 162355 | | - /* 930 */ 142, 324, 409, 836, 837, 838, 312, 1320, 305, 363, |
| 162356 | | - /* 940 */ 43, 43, 57, 57, 120, 120, 120, 120, 119, 119, |
| 162357 | | - /* 950 */ 118, 118, 118, 117, 113, 444, 123, 124, 114, 1210, |
| 162358 | | - /* 960 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, |
| 162359 | | - /* 970 */ 122, 12, 277, 277, 566, 1152, 409, 572, 428, 1238, |
| 162360 | | - /* 980 */ 465, 334, 296, 474, 309, 563, 142, 249, 1152, 308, |
| 162361 | | - /* 990 */ 557, 1152, 321, 1320, 323, 491, 455, 71, 71, 233, |
| 162362 | | - /* 1000 */ 283, 101, 114, 1210, 1210, 1044, 1047, 1036, 1036, 121, |
| 163469 | + /* 370 */ 113, 440, 280, 280, 365, 1570, 1597, 437, 436, 150, |
| 163470 | + /* 380 */ 405, 441, 71, 71, 1278, 559, 1213, 1184, 1185, 1186, |
| 163471 | + /* 390 */ 83, 1215, 267, 551, 539, 511, 1551, 562, 96, 1214, |
| 163472 | + /* 400 */ 6, 1270, 468, 138, 123, 124, 114, 1209, 1209, 1042, |
| 163473 | + /* 410 */ 1045, 1034, 1034, 121, 121, 122, 122, 122, 122, 544, |
| 163474 | + /* 420 */ 13, 13, 1021, 503, 1216, 1184, 1216, 543, 106, 106, |
| 163475 | + /* 430 */ 218, 562, 1230, 171, 562, 423, 107, 193, 441, 564, |
| 163476 | + /* 440 */ 563, 426, 1542, 1011, 321, 545, 1184, 266, 283, 364, |
| 163477 | + /* 450 */ 506, 359, 505, 253, 71, 71, 539, 71, 71, 355, |
| 163478 | + /* 460 */ 312, 553, 1603, 120, 120, 120, 120, 119, 119, 118, |
| 163479 | + /* 470 */ 118, 118, 117, 113, 440, 1011, 1011, 1013, 1014, 27, |
| 163480 | + /* 480 */ 280, 280, 1184, 1185, 1186, 1150, 562, 1602, 405, 895, |
| 163481 | + /* 490 */ 186, 544, 352, 559, 544, 931, 529, 513, 1150, 512, |
| 163482 | + /* 500 */ 409, 1150, 546, 1184, 1185, 1186, 562, 540, 1544, 51, |
| 163483 | + /* 510 */ 51, 210, 123, 124, 114, 1209, 1209, 1042, 1045, 1034, |
| 163484 | + /* 520 */ 1034, 121, 121, 122, 122, 122, 122, 1184, 470, 56, |
| 163485 | + /* 530 */ 56, 405, 280, 280, 1480, 501, 119, 119, 118, 118, |
| 163486 | + /* 540 */ 118, 117, 113, 440, 1001, 559, 514, 213, 537, 1551, |
| 163487 | + /* 550 */ 312, 553, 138, 6, 528, 123, 124, 114, 1209, 1209, |
| 163488 | + /* 560 */ 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, 122, |
| 163489 | + /* 570 */ 1545, 120, 120, 120, 120, 119, 119, 118, 118, 118, |
| 163490 | + /* 580 */ 117, 113, 440, 481, 1184, 1185, 1186, 478, 277, 1259, |
| 163491 | + /* 590 */ 951, 248, 1184, 369, 500, 497, 496, 1184, 336, 565, |
| 163492 | + /* 600 */ 1184, 565, 405, 288, 495, 951, 870, 187, 476, 312, |
| 163493 | + /* 610 */ 553, 380, 286, 376, 120, 120, 120, 120, 119, 119, |
| 163494 | + /* 620 */ 118, 118, 118, 117, 113, 440, 123, 124, 114, 1209, |
| 163495 | + /* 630 */ 1209, 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, |
| 163496 | + /* 640 */ 122, 405, 390, 1128, 1184, 863, 98, 280, 280, 1184, |
| 163497 | + /* 650 */ 1185, 1186, 369, 1085, 1184, 1185, 1186, 1184, 1185, 1186, |
| 163498 | + /* 660 */ 559, 451, 32, 369, 229, 123, 124, 114, 1209, 1209, |
| 163499 | + /* 670 */ 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, 122, |
| 163500 | + /* 680 */ 1425, 953, 562, 224, 952, 120, 120, 120, 120, 119, |
| 163501 | + /* 690 */ 119, 118, 118, 118, 117, 113, 440, 1150, 224, 1184, |
| 163502 | + /* 700 */ 153, 1184, 1185, 1186, 1543, 13, 13, 297, 951, 1224, |
| 163503 | + /* 710 */ 1150, 149, 405, 1150, 369, 1573, 1168, 5, 365, 1570, |
| 163504 | + /* 720 */ 425, 1230, 3, 951, 120, 120, 120, 120, 119, 119, |
| 163505 | + /* 730 */ 118, 118, 118, 117, 113, 440, 123, 124, 114, 1209, |
| 163506 | + /* 740 */ 1209, 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, |
| 163507 | + /* 750 */ 122, 405, 204, 561, 1184, 1022, 1184, 1185, 1186, 1184, |
| 163508 | + /* 760 */ 384, 846, 151, 1542, 282, 398, 1090, 1090, 484, 562, |
| 163509 | + /* 770 */ 461, 338, 1311, 1311, 1542, 123, 124, 114, 1209, 1209, |
| 163510 | + /* 780 */ 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, 122, |
| 163511 | + /* 790 */ 127, 562, 13, 13, 370, 120, 120, 120, 120, 119, |
| 163512 | + /* 800 */ 119, 118, 118, 118, 117, 113, 440, 298, 562, 449, |
| 163513 | + /* 810 */ 524, 1184, 1185, 1186, 13, 13, 1184, 1185, 1186, 1289, |
| 163514 | + /* 820 */ 459, 1259, 405, 1309, 1309, 1542, 1006, 449, 448, 196, |
| 163515 | + /* 830 */ 295, 71, 71, 1257, 120, 120, 120, 120, 119, 119, |
| 163516 | + /* 840 */ 118, 118, 118, 117, 113, 440, 123, 124, 114, 1209, |
| 163517 | + /* 850 */ 1209, 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, |
| 163518 | + /* 860 */ 122, 405, 223, 1065, 1150, 280, 280, 415, 308, 274, |
| 163519 | + /* 870 */ 274, 281, 281, 1411, 402, 401, 378, 1150, 559, 562, |
| 163520 | + /* 880 */ 1150, 1188, 559, 1590, 559, 123, 124, 114, 1209, 1209, |
| 163521 | + /* 890 */ 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, 122, |
| 163522 | + /* 900 */ 449, 1472, 13, 13, 1526, 120, 120, 120, 120, 119, |
| 163523 | + /* 910 */ 119, 118, 118, 118, 117, 113, 440, 197, 562, 350, |
| 163524 | + /* 920 */ 1576, 569, 2, 1237, 834, 835, 836, 1552, 313, 1204, |
| 163525 | + /* 930 */ 142, 6, 405, 251, 250, 249, 202, 1319, 9, 1188, |
| 163526 | + /* 940 */ 258, 71, 71, 420, 120, 120, 120, 120, 119, 119, |
| 163527 | + /* 950 */ 118, 118, 118, 117, 113, 440, 123, 124, 114, 1209, |
| 163528 | + /* 960 */ 1209, 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, |
| 163529 | + /* 970 */ 122, 562, 280, 280, 562, 1205, 405, 568, 309, 1237, |
| 163530 | + /* 980 */ 345, 1288, 348, 415, 313, 559, 142, 487, 521, 1633, |
| 163531 | + /* 990 */ 391, 367, 487, 1319, 70, 70, 1287, 71, 71, 236, |
| 163532 | + /* 1000 */ 1317, 101, 114, 1209, 1209, 1042, 1045, 1034, 1034, 121, |
| 162363 | 163533 | /* 1010 */ 121, 122, 122, 122, 122, 120, 120, 120, 120, 119, |
| 162364 | | - /* 1020 */ 119, 118, 118, 118, 117, 113, 444, 1108, 277, 277, |
| 162365 | | - /* 1030 */ 1412, 448, 394, 1230, 439, 277, 277, 248, 247, 246, |
| 162366 | | - /* 1040 */ 1319, 563, 1109, 313, 198, 294, 491, 1318, 563, 464, |
| 162367 | | - /* 1050 */ 566, 1427, 394, 1130, 1023, 233, 414, 1110, 295, 120, |
| 163534 | + /* 1020 */ 119, 118, 118, 118, 117, 113, 440, 1106, 280, 280, |
| 163535 | + /* 1030 */ 424, 444, 1515, 1205, 435, 280, 280, 1479, 1344, 307, |
| 163536 | + /* 1040 */ 470, 559, 1107, 965, 487, 487, 213, 1255, 559, 1528, |
| 163537 | + /* 1050 */ 562, 966, 203, 562, 1021, 236, 379, 1108, 515, 120, |
| 162368 | 163538 | /* 1060 */ 120, 120, 120, 119, 119, 118, 118, 118, 117, 113, |
| 162369 | | - /* 1070 */ 444, 1014, 104, 71, 71, 1013, 322, 496, 908, 566, |
| 162370 | | - /* 1080 */ 277, 277, 277, 277, 1108, 1261, 415, 448, 909, 361, |
| 162371 | | - /* 1090 */ 1571, 1315, 409, 563, 952, 563, 9, 202, 255, 1109, |
| 162372 | | - /* 1100 */ 316, 487, 44, 44, 249, 559, 415, 1013, 1013, 1015, |
| 162373 | | - /* 1110 */ 443, 1231, 409, 1603, 1110, 897, 123, 124, 114, 1210, |
| 162374 | | - /* 1120 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, |
| 162375 | | - /* 1130 */ 122, 1231, 409, 1207, 215, 554, 123, 124, 114, 1210, |
| 162376 | | - /* 1140 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, |
| 162377 | | - /* 1150 */ 122, 1131, 1631, 470, 1631, 255, 123, 111, 114, 1210, |
| 162378 | | - /* 1160 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, |
| 162379 | | - /* 1170 */ 122, 1131, 1632, 414, 1632, 120, 120, 120, 120, 119, |
| 162380 | | - /* 1180 */ 119, 118, 118, 118, 117, 113, 444, 221, 209, 351, |
| 162381 | | - /* 1190 */ 1207, 1207, 147, 1426, 491, 120, 120, 120, 120, 119, |
| 162382 | | - /* 1200 */ 119, 118, 118, 118, 117, 113, 444, 1256, 539, 519, |
| 162383 | | - /* 1210 */ 888, 551, 952, 12, 566, 120, 120, 120, 120, 119, |
| 162384 | | - /* 1220 */ 119, 118, 118, 118, 117, 113, 444, 538, 566, 860, |
| 162385 | | - /* 1230 */ 1129, 361, 1571, 346, 1356, 409, 1163, 58, 58, 339, |
| 162386 | | - /* 1240 */ 1355, 508, 277, 277, 277, 277, 277, 277, 1207, 889, |
| 162387 | | - /* 1250 */ 1129, 59, 59, 459, 363, 563, 566, 563, 96, 563, |
| 162388 | | - /* 1260 */ 124, 114, 1210, 1210, 1044, 1047, 1036, 1036, 121, 121, |
| 162389 | | - /* 1270 */ 122, 122, 122, 122, 566, 1412, 566, 281, 1186, 60, |
| 162390 | | - /* 1280 */ 60, 110, 392, 392, 391, 266, 389, 860, 1163, 845, |
| 162391 | | - /* 1290 */ 566, 481, 566, 436, 341, 1152, 344, 61, 61, 62, |
| 162392 | | - /* 1300 */ 62, 967, 227, 1550, 315, 431, 540, 6, 1152, 968, |
| 162393 | | - /* 1310 */ 566, 1152, 314, 45, 45, 46, 46, 512, 120, 120, |
| 162394 | | - /* 1320 */ 120, 120, 119, 119, 118, 118, 118, 117, 113, 444, |
| 162395 | | - /* 1330 */ 416, 173, 1532, 47, 47, 1186, 1187, 1188, 108, 558, |
| 162396 | | - /* 1340 */ 325, 4, 229, 1551, 928, 566, 437, 6, 566, 927, |
| 162397 | | - /* 1350 */ 164, 566, 1290, 137, 1190, 561, 566, 1549, 566, 1089, |
| 162398 | | - /* 1360 */ 566, 6, 566, 1089, 531, 566, 868, 8, 49, 49, |
| 162399 | | - /* 1370 */ 228, 50, 50, 566, 63, 63, 566, 457, 445, 64, |
| 162400 | | - /* 1380 */ 64, 65, 65, 14, 14, 66, 66, 407, 129, 129, |
| 162401 | | - /* 1390 */ 555, 566, 458, 566, 1505, 486, 67, 67, 566, 52, |
| 162402 | | - /* 1400 */ 52, 546, 407, 467, 535, 410, 226, 1023, 566, 534, |
| 162403 | | - /* 1410 */ 308, 557, 1190, 407, 68, 68, 69, 69, 566, 1023, |
| 162404 | | - /* 1420 */ 566, 53, 53, 868, 1014, 106, 106, 525, 1013, 566, |
| 162405 | | - /* 1430 */ 1504, 159, 159, 107, 451, 445, 568, 567, 471, 307, |
| 162406 | | - /* 1440 */ 1013, 160, 160, 76, 76, 566, 1548, 466, 407, 407, |
| 162407 | | - /* 1450 */ 6, 1225, 54, 54, 478, 276, 219, 566, 887, 886, |
| 162408 | | - /* 1460 */ 1013, 1013, 1015, 84, 206, 1206, 230, 282, 72, 72, |
| 162409 | | - /* 1470 */ 329, 483, 1013, 1013, 1015, 1016, 27, 1576, 1174, 447, |
| 162410 | | - /* 1480 */ 130, 130, 281, 148, 105, 38, 103, 392, 392, 391, |
| 162411 | | - /* 1490 */ 266, 389, 566, 1126, 845, 396, 566, 108, 558, 566, |
| 162412 | | - /* 1500 */ 4, 311, 566, 30, 17, 566, 279, 227, 566, 315, |
| 162413 | | - /* 1510 */ 108, 558, 468, 4, 561, 73, 73, 314, 566, 157, |
| 162414 | | - /* 1520 */ 157, 566, 131, 131, 526, 132, 132, 561, 128, 128, |
| 162415 | | - /* 1530 */ 566, 158, 158, 566, 31, 291, 566, 445, 330, 521, |
| 162416 | | - /* 1540 */ 98, 152, 152, 420, 136, 136, 1005, 229, 254, 555, |
| 162417 | | - /* 1550 */ 445, 479, 336, 135, 135, 164, 133, 133, 137, 134, |
| 162418 | | - /* 1560 */ 134, 875, 555, 535, 566, 473, 566, 254, 536, 475, |
| 162419 | | - /* 1570 */ 335, 254, 98, 894, 895, 228, 535, 566, 1023, 566, |
| 162420 | | - /* 1580 */ 1074, 534, 210, 232, 106, 106, 1352, 75, 75, 77, |
| 162421 | | - /* 1590 */ 77, 1023, 107, 340, 445, 568, 567, 106, 106, 1013, |
| 162422 | | - /* 1600 */ 74, 74, 42, 42, 566, 107, 343, 445, 568, 567, |
| 162423 | | - /* 1610 */ 410, 497, 1013, 251, 359, 308, 557, 1135, 349, 875, |
| 162424 | | - /* 1620 */ 98, 1070, 345, 251, 358, 1591, 347, 48, 48, 1017, |
| 162425 | | - /* 1630 */ 1303, 1013, 1013, 1015, 1016, 27, 1289, 1287, 1074, 451, |
| 162426 | | - /* 1640 */ 961, 925, 254, 110, 1013, 1013, 1015, 1016, 27, 1174, |
| 162427 | | - /* 1650 */ 447, 970, 971, 281, 108, 558, 1288, 4, 392, 392, |
| 162428 | | - /* 1660 */ 391, 266, 389, 1343, 1086, 845, 1086, 1085, 858, 1085, |
| 162429 | | - /* 1670 */ 146, 561, 926, 354, 110, 303, 364, 553, 227, 1364, |
| 162430 | | - /* 1680 */ 315, 108, 558, 1411, 4, 1339, 492, 1017, 314, 1350, |
| 162431 | | - /* 1690 */ 1565, 552, 1417, 1268, 445, 204, 1259, 1247, 561, 1246, |
| 162432 | | - /* 1700 */ 1248, 1584, 269, 1336, 367, 369, 555, 371, 11, 212, |
| 162433 | | - /* 1710 */ 393, 225, 1393, 284, 1398, 456, 287, 327, 229, 328, |
| 162434 | | - /* 1720 */ 292, 445, 1386, 216, 333, 1403, 164, 477, 373, 137, |
| 162435 | | - /* 1730 */ 1402, 400, 502, 555, 1286, 1023, 357, 1477, 199, 1587, |
| 162436 | | - /* 1740 */ 211, 106, 106, 932, 1476, 1225, 228, 556, 175, 107, |
| 162437 | | - /* 1750 */ 200, 445, 568, 567, 258, 387, 1013, 1524, 1522, 223, |
| 162438 | | - /* 1760 */ 1222, 418, 1023, 83, 208, 79, 82, 184, 106, 106, |
| 162439 | | - /* 1770 */ 1482, 169, 177, 461, 179, 462, 107, 1399, 445, 568, |
| 162440 | | - /* 1780 */ 567, 410, 180, 1013, 495, 181, 308, 557, 1013, 1013, |
| 162441 | | - /* 1790 */ 1015, 1016, 27, 182, 35, 235, 100, 558, 398, 4, |
| 162442 | | - /* 1800 */ 96, 1405, 1404, 36, 484, 469, 1407, 188, 401, 1471, |
| 162443 | | - /* 1810 */ 451, 89, 1493, 561, 239, 1013, 1013, 1015, 1016, 27, |
| 162444 | | - /* 1820 */ 490, 338, 270, 241, 192, 342, 493, 242, 403, 1249, |
| 162445 | | - /* 1830 */ 243, 511, 432, 1297, 1306, 91, 445, 1305, 1304, 879, |
| 162446 | | - /* 1840 */ 217, 434, 435, 1570, 1276, 1602, 520, 1601, 555, 301, |
| 162447 | | - /* 1850 */ 527, 404, 1275, 302, 356, 1274, 1600, 95, 1347, 366, |
| 162448 | | - /* 1860 */ 1296, 362, 1348, 368, 256, 257, 1556, 1555, 438, 1346, |
| 162449 | | - /* 1870 */ 370, 126, 1345, 10, 1371, 546, 381, 1023, 102, 1457, |
| 162450 | | - /* 1880 */ 97, 530, 34, 106, 106, 570, 1180, 372, 265, 1329, |
| 162451 | | - /* 1890 */ 379, 107, 203, 445, 568, 567, 1328, 385, 1013, 1370, |
| 162452 | | - /* 1900 */ 386, 267, 268, 571, 1244, 161, 1239, 162, 1509, 1510, |
| 162453 | | - /* 1910 */ 1508, 143, 1507, 299, 832, 213, 214, 78, 446, 205, |
| 162454 | | - /* 1920 */ 310, 306, 163, 224, 1084, 140, 1082, 318, 165, 176, |
| 162455 | | - /* 1930 */ 1013, 1013, 1015, 1016, 27, 178, 1206, 231, 911, 234, |
| 162456 | | - /* 1940 */ 326, 1098, 183, 421, 166, 167, 411, 185, 85, 423, |
| 162457 | | - /* 1950 */ 412, 86, 174, 87, 168, 88, 1101, 236, 1097, 237, |
| 162458 | | - /* 1960 */ 154, 18, 238, 254, 337, 1219, 489, 1090, 240, 190, |
| 162459 | | - /* 1970 */ 37, 847, 189, 494, 358, 244, 350, 506, 191, 877, |
| 162460 | | - /* 1980 */ 90, 498, 19, 20, 503, 92, 353, 890, 300, 170, |
| 162461 | | - /* 1990 */ 155, 93, 513, 94, 1168, 156, 1050, 1137, 39, 218, |
| 162462 | | - /* 2000 */ 273, 275, 1136, 960, 194, 955, 110, 1154, 1158, 253, |
| 162463 | | - /* 2010 */ 7, 1162, 1156, 21, 22, 1161, 1142, 23, 24, 25, |
| 162464 | | - /* 2020 */ 33, 542, 26, 260, 197, 98, 1065, 1051, 1049, 1053, |
| 162465 | | - /* 2030 */ 1107, 1054, 1106, 259, 28, 40, 562, 1018, 859, 109, |
| 162466 | | - /* 2040 */ 29, 921, 390, 1176, 172, 139, 1175, 1235, 261, 1235, |
| 162467 | | - /* 2050 */ 1235, 1235, 1235, 1235, 1235, 1235, 1235, 262, 1235, 1235, |
| 162468 | | - /* 2060 */ 1235, 1235, 1235, 1235, 1235, 1235, 1235, 1235, 1593, 1592, |
| 163539 | + /* 1070 */ 440, 1012, 104, 71, 71, 1011, 13, 13, 906, 562, |
| 163540 | + /* 1080 */ 1485, 562, 280, 280, 95, 522, 487, 444, 907, 1318, |
| 163541 | + /* 1090 */ 1314, 541, 405, 280, 280, 559, 147, 205, 1485, 1487, |
| 163542 | + /* 1100 */ 258, 446, 15, 15, 43, 43, 559, 1011, 1011, 1013, |
| 163543 | + /* 1110 */ 439, 328, 405, 523, 12, 291, 123, 124, 114, 1209, |
| 163544 | + /* 1120 */ 1209, 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, |
| 163545 | + /* 1130 */ 122, 343, 405, 858, 1524, 1205, 123, 124, 114, 1209, |
| 163546 | + /* 1140 */ 1209, 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, |
| 163547 | + /* 1150 */ 122, 1129, 1631, 470, 1631, 367, 123, 111, 114, 1209, |
| 163548 | + /* 1160 */ 1209, 1042, 1045, 1034, 1034, 121, 121, 122, 122, 122, |
| 163549 | + /* 1170 */ 122, 1485, 325, 470, 327, 120, 120, 120, 120, 119, |
| 163550 | + /* 1180 */ 119, 118, 118, 118, 117, 113, 440, 199, 1411, 562, |
| 163551 | + /* 1190 */ 1286, 858, 460, 1205, 432, 120, 120, 120, 120, 119, |
| 163552 | + /* 1200 */ 119, 118, 118, 118, 117, 113, 440, 547, 1129, 1632, |
| 163553 | + /* 1210 */ 535, 1632, 57, 57, 886, 120, 120, 120, 120, 119, |
| 163554 | + /* 1220 */ 119, 118, 118, 118, 117, 113, 440, 562, 294, 534, |
| 163555 | + /* 1230 */ 1127, 1411, 1549, 1550, 1323, 405, 6, 6, 1161, 1260, |
| 163556 | + /* 1240 */ 411, 316, 280, 280, 1411, 504, 559, 521, 296, 453, |
| 163557 | + /* 1250 */ 44, 44, 562, 887, 12, 559, 326, 474, 421, 403, |
| 163558 | + /* 1260 */ 124, 114, 1209, 1209, 1042, 1045, 1034, 1034, 121, 121, |
| 163559 | + /* 1270 */ 122, 122, 122, 122, 562, 58, 58, 284, 1184, 1411, |
| 163560 | + /* 1280 */ 492, 454, 388, 388, 387, 269, 385, 1127, 1548, 843, |
| 163561 | + /* 1290 */ 1161, 403, 6, 562, 317, 1150, 466, 59, 59, 1547, |
| 163562 | + /* 1300 */ 1106, 422, 230, 6, 319, 252, 536, 252, 1150, 427, |
| 163563 | + /* 1310 */ 562, 1150, 318, 17, 483, 1107, 60, 60, 120, 120, |
| 163564 | + /* 1320 */ 120, 120, 119, 119, 118, 118, 118, 117, 113, 440, |
| 163565 | + /* 1330 */ 1108, 212, 477, 61, 61, 1184, 1185, 1186, 108, 554, |
| 163566 | + /* 1340 */ 320, 4, 232, 452, 522, 562, 233, 452, 562, 433, |
| 163567 | + /* 1350 */ 164, 550, 416, 137, 475, 557, 562, 289, 562, 1087, |
| 163568 | + /* 1360 */ 562, 289, 562, 1087, 527, 562, 866, 8, 62, 62, |
| 163569 | + /* 1370 */ 231, 45, 45, 562, 410, 562, 410, 562, 441, 46, |
| 163570 | + /* 1380 */ 46, 47, 47, 49, 49, 50, 50, 195, 63, 63, |
| 163571 | + /* 1390 */ 551, 562, 355, 562, 98, 482, 64, 64, 65, 65, |
| 163572 | + /* 1400 */ 14, 14, 555, 411, 531, 406, 562, 1021, 562, 530, |
| 163573 | + /* 1410 */ 312, 553, 312, 553, 66, 66, 129, 129, 562, 1021, |
| 163574 | + /* 1420 */ 562, 508, 926, 866, 1012, 106, 106, 925, 1011, 67, |
| 163575 | + /* 1430 */ 67, 52, 52, 107, 447, 441, 564, 563, 412, 173, |
| 163576 | + /* 1440 */ 1011, 68, 68, 69, 69, 562, 463, 562, 926, 467, |
| 163577 | + /* 1450 */ 1356, 279, 222, 925, 311, 1355, 403, 562, 455, 403, |
| 163578 | + /* 1460 */ 1011, 1011, 1013, 235, 403, 84, 209, 1342, 53, 53, |
| 163579 | + /* 1470 */ 159, 159, 1011, 1011, 1013, 1014, 27, 1575, 1172, 443, |
| 163580 | + /* 1480 */ 160, 160, 284, 95, 105, 1531, 103, 388, 388, 387, |
| 163581 | + /* 1490 */ 269, 385, 562, 873, 843, 877, 562, 108, 554, 462, |
| 163582 | + /* 1500 */ 4, 562, 148, 30, 38, 562, 1124, 230, 392, 319, |
| 163583 | + /* 1510 */ 108, 554, 523, 4, 557, 76, 76, 318, 562, 54, |
| 163584 | + /* 1520 */ 54, 562, 333, 464, 72, 72, 329, 557, 130, 130, |
| 163585 | + /* 1530 */ 562, 285, 1504, 562, 31, 1503, 562, 441, 334, 479, |
| 163586 | + /* 1540 */ 98, 73, 73, 340, 157, 157, 292, 232, 1072, 551, |
| 163587 | + /* 1550 */ 441, 873, 1352, 131, 131, 164, 132, 132, 137, 128, |
| 163588 | + /* 1560 */ 128, 1564, 551, 531, 562, 315, 562, 344, 532, 1003, |
| 163589 | + /* 1570 */ 469, 257, 257, 885, 884, 231, 531, 562, 1021, 562, |
| 163590 | + /* 1580 */ 471, 530, 257, 363, 106, 106, 517, 158, 158, 152, |
| 163591 | + /* 1590 */ 152, 1021, 107, 362, 441, 564, 563, 106, 106, 1011, |
| 163592 | + /* 1600 */ 136, 136, 135, 135, 562, 107, 1072, 441, 564, 563, |
| 163593 | + /* 1610 */ 406, 347, 1011, 562, 349, 312, 553, 562, 339, 562, |
| 163594 | + /* 1620 */ 98, 493, 353, 254, 98, 892, 893, 133, 133, 351, |
| 163595 | + /* 1630 */ 1302, 1011, 1011, 1013, 1014, 27, 134, 134, 1015, 447, |
| 163596 | + /* 1640 */ 75, 75, 77, 77, 1011, 1011, 1013, 1014, 27, 1172, |
| 163597 | + /* 1650 */ 443, 562, 358, 284, 108, 554, 368, 4, 388, 388, |
| 163598 | + /* 1660 */ 387, 269, 385, 562, 1133, 843, 562, 1068, 956, 254, |
| 163599 | + /* 1670 */ 257, 557, 968, 969, 74, 74, 549, 923, 230, 110, |
| 163600 | + /* 1680 */ 319, 108, 554, 1084, 4, 1084, 42, 42, 318, 48, |
| 163601 | + /* 1690 */ 48, 1083, 1365, 1083, 441, 856, 1015, 146, 557, 924, |
| 163602 | + /* 1700 */ 1410, 110, 1338, 1350, 548, 1416, 551, 1267, 207, 1258, |
| 163603 | + /* 1710 */ 1246, 1245, 1247, 1583, 11, 488, 272, 215, 232, 1335, |
| 163604 | + /* 1720 */ 304, 441, 305, 306, 389, 228, 164, 1397, 1392, 137, |
| 163605 | + /* 1730 */ 287, 331, 332, 551, 293, 1021, 1385, 337, 473, 200, |
| 163606 | + /* 1740 */ 361, 106, 106, 930, 498, 1402, 231, 1401, 1285, 107, |
| 163607 | + /* 1750 */ 396, 441, 564, 563, 219, 1476, 1011, 1347, 1475, 1348, |
| 163608 | + /* 1760 */ 1346, 1345, 1021, 1224, 552, 1586, 261, 1221, 106, 106, |
| 163609 | + /* 1770 */ 1523, 201, 383, 1521, 214, 414, 107, 83, 441, 564, |
| 163610 | + /* 1780 */ 563, 406, 211, 1011, 175, 1398, 312, 553, 1011, 1011, |
| 163611 | + /* 1790 */ 1013, 1014, 27, 226, 184, 169, 100, 554, 79, 4, |
| 163612 | + /* 1800 */ 82, 457, 35, 179, 458, 177, 491, 238, 96, 1481, |
| 163613 | + /* 1810 */ 447, 180, 1404, 557, 181, 1011, 1011, 1013, 1014, 27, |
| 163614 | + /* 1820 */ 182, 1403, 394, 36, 465, 1406, 397, 188, 1470, 480, |
| 163615 | + /* 1830 */ 242, 89, 1492, 486, 342, 244, 441, 273, 192, 346, |
| 163616 | + /* 1840 */ 489, 245, 399, 1248, 428, 246, 507, 1296, 551, 91, |
| 163617 | + /* 1850 */ 877, 1305, 1304, 220, 1601, 1295, 1303, 430, 431, 516, |
| 163618 | + /* 1860 */ 1569, 259, 400, 302, 1600, 1275, 303, 260, 360, 1274, |
| 163619 | + /* 1870 */ 1273, 1599, 366, 1555, 434, 1554, 1370, 1021, 1369, 542, |
| 163620 | + /* 1880 */ 126, 10, 1456, 106, 106, 377, 102, 97, 310, 526, |
| 163621 | + /* 1890 */ 34, 107, 566, 441, 564, 563, 1178, 271, 1011, 268, |
| 163622 | + /* 1900 */ 270, 567, 1243, 1238, 206, 1328, 375, 381, 1327, 382, |
| 163623 | + /* 1910 */ 407, 161, 174, 408, 1508, 1509, 143, 300, 830, 162, |
| 163624 | + /* 1920 */ 1507, 1506, 163, 442, 208, 314, 227, 216, 217, 78, |
| 163625 | + /* 1930 */ 1011, 1011, 1013, 1014, 27, 140, 1082, 322, 1080, 165, |
| 163626 | + /* 1940 */ 176, 1204, 234, 178, 909, 330, 237, 1096, 183, 166, |
| 163627 | + /* 1950 */ 167, 417, 85, 86, 419, 185, 87, 88, 168, 1099, |
| 163628 | + /* 1960 */ 239, 1095, 240, 154, 18, 241, 341, 1218, 257, 1088, |
| 163629 | + /* 1970 */ 243, 485, 190, 189, 37, 845, 490, 362, 247, 494, |
| 163630 | + /* 1980 */ 357, 191, 875, 90, 19, 502, 354, 20, 499, 92, |
| 163631 | + /* 1990 */ 170, 155, 888, 93, 301, 509, 94, 1166, 156, 1048, |
| 163632 | + /* 2000 */ 1135, 39, 221, 1134, 276, 278, 256, 194, 110, 960, |
| 163633 | + /* 2010 */ 954, 1156, 21, 1152, 22, 1160, 1140, 1154, 23, 33, |
| 163634 | + /* 2020 */ 24, 1159, 25, 538, 26, 198, 98, 1063, 1049, 1047, |
| 163635 | + /* 2030 */ 1051, 7, 1105, 262, 1104, 263, 1052, 28, 40, 558, |
| 163636 | + /* 2040 */ 1016, 857, 109, 29, 919, 386, 139, 172, 264, 265, |
| 163637 | + /* 2050 */ 1174, 1592, 1173, 1234, 1234, 1234, 1234, 1234, 1234, 1234, |
| 163638 | + /* 2060 */ 1234, 1234, 1234, 1591, |
| 162469 | 163639 | }; |
| 162470 | 163640 | static const YYCODETYPE yy_lookahead[] = { |
| 162471 | | - /* 0 */ 193, 223, 193, 225, 193, 193, 193, 274, 275, 276, |
| 162472 | | - /* 10 */ 193, 233, 219, 193, 274, 275, 276, 206, 206, 19, |
| 162473 | | - /* 20 */ 193, 219, 216, 216, 217, 216, 217, 193, 295, 216, |
| 162474 | | - /* 30 */ 217, 31, 205, 216, 217, 193, 216, 217, 213, 39, |
| 162475 | | - /* 40 */ 228, 193, 230, 43, 44, 45, 46, 47, 48, 49, |
| 163641 | + /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276, |
| 163642 | + /* 10 */ 193, 223, 219, 225, 206, 210, 211, 212, 193, 19, |
| 163643 | + /* 20 */ 219, 233, 216, 216, 217, 216, 217, 193, 295, 216, |
| 163644 | + /* 30 */ 217, 31, 193, 216, 217, 193, 228, 213, 230, 39, |
| 163645 | + /* 40 */ 206, 216, 217, 43, 44, 45, 46, 47, 48, 49, |
| 162476 | 163646 | /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 193, 19, |
| 162477 | 163647 | /* 60 */ 185, 186, 187, 188, 189, 190, 253, 274, 275, 276, |
| 162478 | | - /* 70 */ 195, 193, 197, 253, 216, 262, 274, 275, 276, 204, |
| 162479 | | - /* 80 */ 238, 204, 262, 43, 44, 45, 46, 47, 48, 49, |
| 162480 | | - /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 264, 274, |
| 162481 | | - /* 100 */ 275, 276, 102, 103, 104, 105, 106, 107, 108, 109, |
| 163648 | + /* 70 */ 195, 193, 197, 193, 261, 274, 275, 276, 253, 204, |
| 163649 | + /* 80 */ 238, 204, 81, 43, 44, 45, 46, 47, 48, 49, |
| 163650 | + /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 274, 275, |
| 163651 | + /* 100 */ 276, 262, 102, 103, 104, 105, 106, 107, 108, 109, |
| 162482 | 163652 | /* 110 */ 110, 111, 112, 113, 239, 240, 239, 240, 210, 211, |
| 162483 | 163653 | /* 120 */ 212, 314, 315, 314, 59, 316, 86, 252, 88, 252, |
| 162484 | | - /* 130 */ 19, 314, 315, 256, 257, 309, 25, 72, 296, 313, |
| 162485 | | - /* 140 */ 193, 266, 102, 103, 104, 105, 106, 107, 108, 109, |
| 163654 | + /* 130 */ 19, 314, 315, 256, 257, 113, 25, 72, 296, 138, |
| 163655 | + /* 140 */ 139, 266, 102, 103, 104, 105, 106, 107, 108, 109, |
| 162486 | 163656 | /* 150 */ 110, 111, 112, 113, 43, 44, 45, 46, 47, 48, |
| 162487 | 163657 | /* 160 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 81, |
| 162488 | | - /* 170 */ 292, 59, 307, 298, 108, 109, 110, 111, 112, 113, |
| 162489 | | - /* 180 */ 69, 116, 117, 118, 72, 128, 129, 193, 241, 22, |
| 163658 | + /* 170 */ 292, 59, 292, 298, 108, 109, 110, 111, 112, 113, |
| 163659 | + /* 180 */ 69, 116, 117, 118, 72, 106, 107, 193, 111, 112, |
| 162490 | 163660 | /* 190 */ 113, 54, 55, 56, 57, 58, 102, 103, 104, 105, |
| 162491 | | - /* 200 */ 106, 107, 108, 109, 110, 111, 112, 113, 120, 193, |
| 162492 | | - /* 210 */ 216, 217, 25, 102, 103, 104, 105, 106, 107, 108, |
| 163661 | + /* 200 */ 106, 107, 108, 109, 110, 111, 112, 113, 120, 25, |
| 163662 | + /* 210 */ 216, 217, 145, 102, 103, 104, 105, 106, 107, 108, |
| 162493 | 163663 | /* 220 */ 109, 110, 111, 112, 113, 231, 138, 139, 116, 117, |
| 162494 | | - /* 230 */ 118, 106, 107, 19, 216, 54, 55, 56, 57, 102, |
| 163664 | + /* 230 */ 118, 164, 153, 19, 155, 54, 55, 56, 57, 102, |
| 162495 | 163665 | /* 240 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 162496 | | - /* 250 */ 113, 304, 25, 46, 47, 48, 49, 43, 44, 45, |
| 163666 | + /* 250 */ 113, 128, 129, 46, 47, 48, 49, 43, 44, 45, |
| 162497 | 163667 | /* 260 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, |
| 162498 | | - /* 270 */ 56, 57, 193, 106, 107, 59, 193, 19, 153, 263, |
| 162499 | | - /* 280 */ 155, 67, 24, 102, 103, 104, 105, 106, 107, 108, |
| 162500 | | - /* 290 */ 109, 110, 111, 112, 113, 216, 217, 59, 230, 216, |
| 163668 | + /* 270 */ 56, 57, 216, 193, 25, 59, 193, 19, 165, 166, |
| 163669 | + /* 280 */ 193, 67, 24, 102, 103, 104, 105, 106, 107, 108, |
| 163670 | + /* 290 */ 109, 110, 111, 112, 113, 73, 216, 217, 59, 216, |
| 162501 | 163671 | /* 300 */ 217, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 162502 | 163672 | /* 310 */ 52, 53, 54, 55, 56, 57, 102, 103, 104, 105, |
| 162503 | | - /* 320 */ 106, 107, 108, 109, 110, 111, 112, 113, 121, 142, |
| 162504 | | - /* 330 */ 59, 193, 116, 117, 118, 119, 253, 204, 122, 123, |
| 162505 | | - /* 340 */ 124, 19, 20, 81, 22, 262, 108, 19, 132, 165, |
| 162506 | | - /* 350 */ 166, 193, 24, 126, 116, 117, 118, 278, 36, 193, |
| 163673 | + /* 320 */ 106, 107, 108, 109, 110, 111, 112, 113, 121, 145, |
| 163674 | + /* 330 */ 59, 193, 116, 117, 118, 119, 273, 204, 122, 123, |
| 163675 | + /* 340 */ 124, 19, 20, 134, 22, 136, 137, 19, 132, 127, |
| 163676 | + /* 350 */ 128, 129, 24, 22, 23, 116, 117, 118, 36, 193, |
| 162507 | 163677 | /* 360 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 162508 | | - /* 370 */ 112, 113, 239, 240, 216, 217, 215, 106, 107, 241, |
| 163678 | + /* 370 */ 112, 113, 239, 240, 311, 312, 215, 106, 107, 241, |
| 162509 | 163679 | /* 380 */ 19, 59, 216, 217, 223, 252, 115, 116, 117, 118, |
| 162510 | | - /* 390 */ 73, 120, 26, 71, 193, 22, 193, 231, 81, 128, |
| 162511 | | - /* 400 */ 138, 139, 269, 81, 43, 44, 45, 46, 47, 48, |
| 162512 | | - /* 410 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 216, |
| 162513 | | - /* 420 */ 217, 198, 100, 95, 153, 59, 155, 193, 106, 107, |
| 162514 | | - /* 430 */ 235, 236, 59, 193, 193, 249, 114, 251, 116, 117, |
| 162515 | | - /* 440 */ 118, 113, 304, 121, 127, 204, 193, 119, 120, 121, |
| 162516 | | - /* 450 */ 122, 123, 124, 125, 193, 138, 139, 216, 217, 131, |
| 162517 | | - /* 460 */ 138, 139, 193, 102, 103, 104, 105, 106, 107, 108, |
| 163680 | + /* 390 */ 151, 120, 26, 71, 193, 308, 309, 193, 149, 128, |
| 163681 | + /* 400 */ 313, 216, 269, 81, 43, 44, 45, 46, 47, 48, |
| 163682 | + /* 410 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 253, |
| 163683 | + /* 420 */ 216, 217, 100, 95, 153, 59, 155, 261, 106, 107, |
| 163684 | + /* 430 */ 25, 193, 101, 193, 193, 231, 114, 25, 116, 117, |
| 163685 | + /* 440 */ 118, 113, 304, 121, 193, 204, 59, 119, 120, 121, |
| 163686 | + /* 450 */ 122, 123, 124, 125, 216, 217, 193, 216, 217, 131, |
| 163687 | + /* 460 */ 138, 139, 230, 102, 103, 104, 105, 106, 107, 108, |
| 162518 | 163688 | /* 470 */ 109, 110, 111, 112, 113, 153, 154, 155, 156, 157, |
| 162519 | | - /* 480 */ 239, 240, 116, 117, 118, 76, 193, 193, 19, 116, |
| 162520 | | - /* 490 */ 117, 118, 23, 252, 253, 193, 87, 204, 89, 238, |
| 162521 | | - /* 500 */ 193, 92, 268, 262, 281, 203, 193, 205, 285, 216, |
| 163689 | + /* 480 */ 239, 240, 116, 117, 118, 76, 193, 23, 19, 25, |
| 163690 | + /* 490 */ 22, 253, 23, 252, 253, 108, 87, 204, 89, 261, |
| 163691 | + /* 500 */ 198, 92, 261, 116, 117, 118, 193, 306, 307, 216, |
| 162522 | 163692 | /* 510 */ 217, 150, 43, 44, 45, 46, 47, 48, 49, 50, |
| 162523 | | - /* 520 */ 51, 52, 53, 54, 55, 56, 57, 193, 193, 216, |
| 162524 | | - /* 530 */ 217, 19, 239, 240, 59, 23, 106, 107, 108, 109, |
| 162525 | | - /* 540 */ 110, 111, 112, 113, 231, 252, 253, 193, 308, 309, |
| 162526 | | - /* 550 */ 193, 145, 59, 313, 145, 43, 44, 45, 46, 47, |
| 163693 | + /* 520 */ 51, 52, 53, 54, 55, 56, 57, 59, 193, 216, |
| 163694 | + /* 530 */ 217, 19, 239, 240, 283, 23, 106, 107, 108, 109, |
| 163695 | + /* 540 */ 110, 111, 112, 113, 73, 252, 253, 142, 308, 309, |
| 163696 | + /* 550 */ 138, 139, 81, 313, 145, 43, 44, 45, 46, 47, |
| 162527 | 163697 | /* 560 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 162528 | | - /* 570 */ 164, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 162529 | | - /* 580 */ 111, 112, 113, 119, 193, 193, 122, 123, 124, 193, |
| 162530 | | - /* 590 */ 283, 116, 117, 118, 235, 236, 132, 59, 241, 264, |
| 162531 | | - /* 600 */ 59, 193, 19, 23, 193, 25, 23, 216, 217, 116, |
| 162532 | | - /* 610 */ 117, 118, 216, 217, 102, 103, 104, 105, 106, 107, |
| 163698 | + /* 570 */ 307, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 163699 | + /* 580 */ 111, 112, 113, 281, 116, 117, 118, 285, 23, 193, |
| 163700 | + /* 590 */ 25, 119, 59, 193, 122, 123, 124, 59, 127, 203, |
| 163701 | + /* 600 */ 59, 205, 19, 268, 132, 25, 23, 22, 193, 138, |
| 163702 | + /* 610 */ 139, 249, 204, 251, 102, 103, 104, 105, 106, 107, |
| 162533 | 163703 | /* 620 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 162534 | 163704 | /* 630 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 162535 | | - /* 640 */ 57, 19, 308, 309, 151, 23, 25, 313, 135, 253, |
| 162536 | | - /* 650 */ 21, 193, 241, 140, 116, 117, 118, 116, 117, 118, |
| 162537 | | - /* 660 */ 268, 304, 22, 301, 302, 43, 44, 45, 46, 47, |
| 163705 | + /* 640 */ 57, 19, 22, 23, 59, 23, 25, 239, 240, 116, |
| 163706 | + /* 650 */ 117, 118, 193, 11, 116, 117, 118, 116, 117, 118, |
| 163707 | + /* 660 */ 252, 269, 22, 193, 15, 43, 44, 45, 46, 47, |
| 162538 | 163708 | /* 670 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 162539 | | - /* 680 */ 193, 143, 193, 193, 143, 102, 103, 104, 105, 106, |
| 163709 | + /* 680 */ 273, 143, 193, 118, 143, 102, 103, 104, 105, 106, |
| 162540 | 163710 | /* 690 */ 107, 108, 109, 110, 111, 112, 113, 76, 118, 59, |
| 162541 | | - /* 700 */ 292, 211, 212, 216, 217, 216, 217, 73, 193, 80, |
| 162542 | | - /* 710 */ 89, 25, 19, 92, 193, 304, 23, 22, 231, 193, |
| 162543 | | - /* 720 */ 231, 193, 22, 143, 102, 103, 104, 105, 106, 107, |
| 163711 | + /* 700 */ 241, 116, 117, 118, 304, 216, 217, 292, 143, 60, |
| 163712 | + /* 710 */ 89, 241, 19, 92, 193, 193, 23, 22, 311, 312, |
| 163713 | + /* 720 */ 231, 101, 22, 143, 102, 103, 104, 105, 106, 107, |
| 162544 | 163714 | /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 162545 | 163715 | /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 162546 | | - /* 750 */ 57, 19, 123, 193, 59, 23, 116, 117, 118, 59, |
| 162547 | | - /* 760 */ 193, 127, 128, 129, 306, 307, 210, 211, 212, 193, |
| 162548 | | - /* 770 */ 22, 111, 112, 113, 284, 43, 44, 45, 46, 47, |
| 163716 | + /* 750 */ 57, 19, 193, 193, 59, 23, 116, 117, 118, 59, |
| 163717 | + /* 760 */ 201, 21, 241, 304, 22, 206, 127, 128, 129, 193, |
| 163718 | + /* 770 */ 128, 129, 235, 236, 304, 43, 44, 45, 46, 47, |
| 162549 | 163719 | /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 162550 | | - /* 790 */ 161, 193, 216, 217, 268, 102, 103, 104, 105, 106, |
| 162551 | | - /* 800 */ 107, 108, 109, 110, 111, 112, 113, 59, 193, 193, |
| 162552 | | - /* 810 */ 193, 116, 117, 118, 216, 217, 116, 117, 118, 304, |
| 162553 | | - /* 820 */ 239, 240, 19, 263, 138, 139, 23, 211, 212, 231, |
| 162554 | | - /* 830 */ 263, 216, 217, 252, 102, 103, 104, 105, 106, 107, |
| 163720 | + /* 790 */ 22, 193, 216, 217, 193, 102, 103, 104, 105, 106, |
| 163721 | + /* 800 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 193, |
| 163722 | + /* 810 */ 193, 116, 117, 118, 216, 217, 116, 117, 118, 226, |
| 163723 | + /* 820 */ 80, 193, 19, 235, 236, 304, 23, 211, 212, 231, |
| 163724 | + /* 830 */ 204, 216, 217, 205, 102, 103, 104, 105, 106, 107, |
| 162555 | 163725 | /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 162556 | 163726 | /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 162557 | | - /* 860 */ 57, 19, 193, 11, 116, 117, 118, 240, 253, 193, |
| 162558 | | - /* 870 */ 201, 239, 240, 193, 134, 206, 136, 137, 193, 252, |
| 162559 | | - /* 880 */ 193, 264, 193, 193, 252, 43, 44, 45, 46, 47, |
| 163727 | + /* 860 */ 57, 19, 193, 123, 76, 239, 240, 193, 253, 239, |
| 163728 | + /* 870 */ 240, 239, 240, 193, 106, 107, 193, 89, 252, 193, |
| 163729 | + /* 880 */ 92, 59, 252, 141, 252, 43, 44, 45, 46, 47, |
| 162560 | 163730 | /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 162561 | | - /* 900 */ 284, 216, 217, 216, 217, 102, 103, 104, 105, 106, |
| 162562 | | - /* 910 */ 107, 108, 109, 110, 111, 112, 113, 193, 231, 193, |
| 162563 | | - /* 920 */ 187, 188, 189, 190, 127, 128, 129, 238, 195, 193, |
| 162564 | | - /* 930 */ 197, 16, 19, 7, 8, 9, 193, 204, 253, 193, |
| 162565 | | - /* 940 */ 216, 217, 216, 217, 102, 103, 104, 105, 106, 107, |
| 163731 | + /* 900 */ 284, 161, 216, 217, 193, 102, 103, 104, 105, 106, |
| 163732 | + /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 16, |
| 163733 | + /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 25, |
| 163734 | + /* 930 */ 197, 313, 19, 127, 128, 129, 262, 204, 22, 117, |
| 163735 | + /* 940 */ 24, 216, 217, 263, 102, 103, 104, 105, 106, 107, |
| 162566 | 163736 | /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, |
| 162567 | 163737 | /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 162568 | | - /* 970 */ 57, 213, 239, 240, 193, 76, 19, 188, 232, 190, |
| 162569 | | - /* 980 */ 128, 129, 292, 193, 195, 252, 197, 46, 89, 138, |
| 162570 | | - /* 990 */ 139, 92, 77, 204, 79, 193, 269, 216, 217, 266, |
| 163738 | + /* 970 */ 57, 193, 239, 240, 193, 59, 19, 188, 253, 190, |
| 163739 | + /* 980 */ 77, 226, 79, 193, 195, 252, 197, 193, 19, 301, |
| 163740 | + /* 990 */ 302, 193, 193, 204, 216, 217, 226, 216, 217, 266, |
| 162571 | 163741 | /* 1000 */ 204, 159, 45, 46, 47, 48, 49, 50, 51, 52, |
| 162572 | 163742 | /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106, |
| 162573 | 163743 | /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 12, 239, 240, |
| 162574 | | - /* 1030 */ 193, 298, 22, 23, 253, 239, 240, 127, 128, 129, |
| 162575 | | - /* 1040 */ 238, 252, 27, 193, 286, 204, 193, 204, 252, 291, |
| 162576 | | - /* 1050 */ 193, 273, 22, 23, 100, 266, 115, 42, 268, 102, |
| 163744 | + /* 1030 */ 232, 298, 238, 117, 253, 239, 240, 238, 259, 260, |
| 163745 | + /* 1040 */ 193, 252, 27, 31, 193, 193, 142, 204, 252, 193, |
| 163746 | + /* 1050 */ 193, 39, 262, 193, 100, 266, 278, 42, 204, 102, |
| 162577 | 163747 | /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 162578 | | - /* 1070 */ 113, 117, 159, 216, 217, 121, 161, 19, 63, 193, |
| 162579 | | - /* 1080 */ 239, 240, 239, 240, 12, 208, 209, 298, 73, 311, |
| 162580 | | - /* 1090 */ 312, 238, 19, 252, 25, 252, 22, 24, 24, 27, |
| 162581 | | - /* 1100 */ 193, 264, 216, 217, 46, 208, 209, 153, 154, 155, |
| 162582 | | - /* 1110 */ 253, 101, 19, 23, 42, 25, 43, 44, 45, 46, |
| 163748 | + /* 1070 */ 113, 117, 159, 216, 217, 121, 216, 217, 63, 193, |
| 163749 | + /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 238, |
| 163750 | + /* 1090 */ 238, 231, 19, 239, 240, 252, 22, 24, 211, 212, |
| 163751 | + /* 1100 */ 24, 193, 216, 217, 216, 217, 252, 153, 154, 155, |
| 163752 | + /* 1110 */ 253, 16, 19, 144, 213, 268, 43, 44, 45, 46, |
| 162583 | 163753 | /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 162584 | | - /* 1130 */ 57, 101, 19, 59, 25, 63, 43, 44, 45, 46, |
| 163754 | + /* 1130 */ 57, 238, 19, 59, 193, 59, 43, 44, 45, 46, |
| 162585 | 163755 | /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 162586 | | - /* 1150 */ 57, 22, 23, 115, 25, 24, 43, 44, 45, 46, |
| 163756 | + /* 1150 */ 57, 22, 23, 193, 25, 193, 43, 44, 45, 46, |
| 162587 | 163757 | /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 162588 | | - /* 1170 */ 57, 22, 23, 115, 25, 102, 103, 104, 105, 106, |
| 162589 | | - /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 118, 150, 131, |
| 162590 | | - /* 1190 */ 59, 117, 22, 273, 193, 102, 103, 104, 105, 106, |
| 162591 | | - /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 204, 66, 204, |
| 162592 | | - /* 1210 */ 35, 204, 143, 213, 193, 102, 103, 104, 105, 106, |
| 162593 | | - /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 85, 193, 59, |
| 162594 | | - /* 1230 */ 101, 311, 312, 16, 193, 19, 94, 216, 217, 238, |
| 162595 | | - /* 1240 */ 193, 66, 239, 240, 239, 240, 239, 240, 117, 74, |
| 162596 | | - /* 1250 */ 101, 216, 217, 193, 193, 252, 193, 252, 149, 252, |
| 163758 | + /* 1170 */ 57, 284, 77, 193, 79, 102, 103, 104, 105, 106, |
| 163759 | + /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 193, 193, |
| 163760 | + /* 1190 */ 193, 117, 291, 117, 232, 102, 103, 104, 105, 106, |
| 163761 | + /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 204, 22, 23, |
| 163762 | + /* 1210 */ 66, 25, 216, 217, 35, 102, 103, 104, 105, 106, |
| 163763 | + /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 268, 85, |
| 163764 | + /* 1230 */ 101, 193, 309, 309, 240, 19, 313, 313, 94, 208, |
| 163765 | + /* 1240 */ 209, 193, 239, 240, 193, 66, 252, 19, 268, 244, |
| 163766 | + /* 1250 */ 216, 217, 193, 74, 213, 252, 161, 19, 263, 254, |
| 162597 | 163767 | /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 162598 | | - /* 1270 */ 54, 55, 56, 57, 193, 193, 193, 5, 59, 216, |
| 162599 | | - /* 1280 */ 217, 25, 10, 11, 12, 13, 14, 117, 146, 17, |
| 162600 | | - /* 1290 */ 193, 291, 193, 232, 77, 76, 79, 216, 217, 216, |
| 162601 | | - /* 1300 */ 217, 31, 30, 309, 32, 130, 87, 313, 89, 39, |
| 162602 | | - /* 1310 */ 193, 92, 40, 216, 217, 216, 217, 108, 102, 103, |
| 163768 | + /* 1270 */ 54, 55, 56, 57, 193, 216, 217, 5, 59, 193, |
| 163769 | + /* 1280 */ 19, 244, 10, 11, 12, 13, 14, 101, 309, 17, |
| 163770 | + /* 1290 */ 146, 254, 313, 193, 193, 76, 115, 216, 217, 309, |
| 163771 | + /* 1300 */ 12, 263, 30, 313, 32, 46, 87, 46, 89, 130, |
| 163772 | + /* 1310 */ 193, 92, 40, 22, 263, 27, 216, 217, 102, 103, |
| 162603 | 163773 | /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, |
| 162604 | | - /* 1330 */ 299, 300, 193, 216, 217, 116, 117, 118, 19, 20, |
| 162605 | | - /* 1340 */ 193, 22, 70, 309, 135, 193, 264, 313, 193, 140, |
| 162606 | | - /* 1350 */ 78, 193, 226, 81, 59, 36, 193, 309, 193, 29, |
| 162607 | | - /* 1360 */ 193, 313, 193, 33, 145, 193, 59, 48, 216, 217, |
| 162608 | | - /* 1370 */ 98, 216, 217, 193, 216, 217, 193, 244, 59, 216, |
| 162609 | | - /* 1380 */ 217, 216, 217, 216, 217, 216, 217, 254, 216, 217, |
| 162610 | | - /* 1390 */ 71, 193, 244, 193, 193, 65, 216, 217, 193, 216, |
| 162611 | | - /* 1400 */ 217, 145, 254, 244, 85, 133, 15, 100, 193, 90, |
| 162612 | | - /* 1410 */ 138, 139, 117, 254, 216, 217, 216, 217, 193, 100, |
| 162613 | | - /* 1420 */ 193, 216, 217, 116, 117, 106, 107, 19, 121, 193, |
| 162614 | | - /* 1430 */ 193, 216, 217, 114, 162, 116, 117, 118, 244, 244, |
| 162615 | | - /* 1440 */ 121, 216, 217, 216, 217, 193, 309, 129, 254, 254, |
| 162616 | | - /* 1450 */ 313, 60, 216, 217, 19, 256, 257, 193, 120, 121, |
| 162617 | | - /* 1460 */ 153, 154, 155, 149, 150, 25, 24, 99, 216, 217, |
| 162618 | | - /* 1470 */ 152, 193, 153, 154, 155, 156, 157, 0, 1, 2, |
| 162619 | | - /* 1480 */ 216, 217, 5, 22, 158, 24, 160, 10, 11, 12, |
| 162620 | | - /* 1490 */ 13, 14, 193, 23, 17, 25, 193, 19, 20, 193, |
| 162621 | | - /* 1500 */ 22, 133, 193, 22, 22, 193, 22, 30, 193, 32, |
| 162622 | | - /* 1510 */ 19, 20, 129, 22, 36, 216, 217, 40, 193, 216, |
| 162623 | | - /* 1520 */ 217, 193, 216, 217, 116, 216, 217, 36, 216, 217, |
| 162624 | | - /* 1530 */ 193, 216, 217, 193, 53, 152, 193, 59, 23, 19, |
| 162625 | | - /* 1540 */ 25, 216, 217, 61, 216, 217, 23, 70, 25, 71, |
| 162626 | | - /* 1550 */ 59, 116, 193, 216, 217, 78, 216, 217, 81, 216, |
| 162627 | | - /* 1560 */ 217, 59, 71, 85, 193, 23, 193, 25, 90, 23, |
| 162628 | | - /* 1570 */ 23, 25, 25, 7, 8, 98, 85, 193, 100, 193, |
| 162629 | | - /* 1580 */ 59, 90, 142, 141, 106, 107, 193, 216, 217, 216, |
| 162630 | | - /* 1590 */ 217, 100, 114, 193, 116, 117, 118, 106, 107, 121, |
| 162631 | | - /* 1600 */ 216, 217, 216, 217, 193, 114, 193, 116, 117, 118, |
| 162632 | | - /* 1610 */ 133, 23, 121, 25, 121, 138, 139, 97, 23, 117, |
| 162633 | | - /* 1620 */ 25, 23, 193, 25, 131, 141, 193, 216, 217, 59, |
| 162634 | | - /* 1630 */ 193, 153, 154, 155, 156, 157, 226, 193, 117, 162, |
| 162635 | | - /* 1640 */ 23, 23, 25, 25, 153, 154, 155, 156, 157, 1, |
| 162636 | | - /* 1650 */ 2, 83, 84, 5, 19, 20, 226, 22, 10, 11, |
| 162637 | | - /* 1660 */ 12, 13, 14, 258, 153, 17, 155, 153, 23, 155, |
| 162638 | | - /* 1670 */ 25, 36, 23, 193, 25, 255, 193, 236, 30, 193, |
| 162639 | | - /* 1680 */ 32, 19, 20, 193, 22, 193, 288, 117, 40, 193, |
| 162640 | | - /* 1690 */ 318, 193, 193, 193, 59, 242, 193, 193, 36, 193, |
| 162641 | | - /* 1700 */ 193, 193, 287, 255, 255, 255, 71, 255, 243, 214, |
| 162642 | | - /* 1710 */ 191, 297, 267, 245, 271, 259, 259, 293, 70, 246, |
| 162643 | | - /* 1720 */ 246, 59, 267, 229, 245, 271, 78, 293, 259, 81, |
| 162644 | | - /* 1730 */ 271, 271, 220, 71, 225, 100, 219, 219, 249, 196, |
| 162645 | | - /* 1740 */ 243, 106, 107, 108, 219, 60, 98, 280, 297, 114, |
| 162646 | | - /* 1750 */ 249, 116, 117, 118, 141, 245, 121, 200, 200, 297, |
| 162647 | | - /* 1760 */ 38, 200, 100, 151, 150, 294, 294, 22, 106, 107, |
| 162648 | | - /* 1770 */ 283, 43, 234, 18, 237, 200, 114, 272, 116, 117, |
| 162649 | | - /* 1780 */ 118, 133, 237, 121, 18, 237, 138, 139, 153, 154, |
| 162650 | | - /* 1790 */ 155, 156, 157, 237, 270, 199, 19, 20, 246, 22, |
| 162651 | | - /* 1800 */ 149, 272, 272, 270, 200, 246, 234, 234, 246, 246, |
| 162652 | | - /* 1810 */ 162, 158, 290, 36, 199, 153, 154, 155, 156, 157, |
| 162653 | | - /* 1820 */ 62, 289, 200, 199, 22, 200, 221, 199, 221, 200, |
| 162654 | | - /* 1830 */ 199, 115, 64, 227, 218, 22, 59, 218, 218, 126, |
| 162655 | | - /* 1840 */ 165, 24, 113, 312, 218, 224, 305, 224, 71, 282, |
| 162656 | | - /* 1850 */ 144, 221, 220, 282, 218, 218, 218, 115, 261, 260, |
| 162657 | | - /* 1860 */ 227, 221, 261, 260, 200, 91, 317, 317, 82, 261, |
| 162658 | | - /* 1870 */ 260, 148, 261, 22, 265, 145, 200, 100, 158, 277, |
| 162659 | | - /* 1880 */ 147, 146, 25, 106, 107, 202, 13, 260, 194, 250, |
| 162660 | | - /* 1890 */ 249, 114, 248, 116, 117, 118, 250, 247, 121, 265, |
| 162661 | | - /* 1900 */ 246, 194, 6, 192, 192, 207, 192, 207, 213, 213, |
| 162662 | | - /* 1910 */ 213, 222, 213, 222, 4, 214, 214, 213, 3, 22, |
| 162663 | | - /* 1920 */ 163, 279, 207, 15, 23, 16, 23, 139, 130, 151, |
| 162664 | | - /* 1930 */ 153, 154, 155, 156, 157, 142, 25, 24, 20, 144, |
| 162665 | | - /* 1940 */ 16, 1, 142, 61, 130, 130, 303, 151, 53, 37, |
| 162666 | | - /* 1950 */ 303, 53, 300, 53, 130, 53, 116, 34, 1, 141, |
| 162667 | | - /* 1960 */ 5, 22, 115, 25, 161, 75, 41, 68, 141, 115, |
| 162668 | | - /* 1970 */ 24, 20, 68, 19, 131, 125, 23, 96, 22, 59, |
| 162669 | | - /* 1980 */ 22, 67, 22, 22, 67, 22, 24, 28, 67, 37, |
| 162670 | | - /* 1990 */ 23, 149, 22, 25, 23, 23, 23, 23, 22, 141, |
| 162671 | | - /* 2000 */ 23, 23, 97, 116, 22, 143, 25, 88, 75, 34, |
| 162672 | | - /* 2010 */ 44, 75, 86, 34, 34, 93, 23, 34, 34, 34, |
| 162673 | | - /* 2020 */ 22, 24, 34, 22, 25, 25, 23, 23, 23, 23, |
| 162674 | | - /* 2030 */ 23, 11, 23, 25, 22, 22, 25, 23, 23, 22, |
| 162675 | | - /* 2040 */ 22, 135, 15, 1, 25, 23, 1, 319, 141, 319, |
| 162676 | | - /* 2050 */ 319, 319, 319, 319, 319, 319, 319, 141, 319, 319, |
| 162677 | | - /* 2060 */ 319, 319, 319, 319, 319, 319, 319, 319, 141, 141, |
| 163774 | + /* 1330 */ 42, 150, 291, 216, 217, 116, 117, 118, 19, 20, |
| 163775 | + /* 1340 */ 193, 22, 70, 260, 116, 193, 24, 264, 193, 263, |
| 163776 | + /* 1350 */ 78, 63, 61, 81, 116, 36, 193, 260, 193, 29, |
| 163777 | + /* 1360 */ 193, 264, 193, 33, 145, 193, 59, 48, 216, 217, |
| 163778 | + /* 1370 */ 98, 216, 217, 193, 115, 193, 115, 193, 59, 216, |
| 163779 | + /* 1380 */ 217, 216, 217, 216, 217, 216, 217, 255, 216, 217, |
| 163780 | + /* 1390 */ 71, 193, 131, 193, 25, 65, 216, 217, 216, 217, |
| 163781 | + /* 1400 */ 216, 217, 208, 209, 85, 133, 193, 100, 193, 90, |
| 163782 | + /* 1410 */ 138, 139, 138, 139, 216, 217, 216, 217, 193, 100, |
| 163783 | + /* 1420 */ 193, 108, 135, 116, 117, 106, 107, 140, 121, 216, |
| 163784 | + /* 1430 */ 217, 216, 217, 114, 162, 116, 117, 118, 299, 300, |
| 163785 | + /* 1440 */ 121, 216, 217, 216, 217, 193, 244, 193, 135, 244, |
| 163786 | + /* 1450 */ 193, 256, 257, 140, 244, 193, 254, 193, 193, 254, |
| 163787 | + /* 1460 */ 153, 154, 155, 141, 254, 149, 150, 258, 216, 217, |
| 163788 | + /* 1470 */ 216, 217, 153, 154, 155, 156, 157, 0, 1, 2, |
| 163789 | + /* 1480 */ 216, 217, 5, 115, 158, 193, 160, 10, 11, 12, |
| 163790 | + /* 1490 */ 13, 14, 193, 59, 17, 126, 193, 19, 20, 129, |
| 163791 | + /* 1500 */ 22, 193, 22, 22, 24, 193, 23, 30, 25, 32, |
| 163792 | + /* 1510 */ 19, 20, 144, 22, 36, 216, 217, 40, 193, 216, |
| 163793 | + /* 1520 */ 217, 193, 152, 129, 216, 217, 193, 36, 216, 217, |
| 163794 | + /* 1530 */ 193, 99, 193, 193, 53, 193, 193, 59, 23, 193, |
| 163795 | + /* 1540 */ 25, 216, 217, 193, 216, 217, 152, 70, 59, 71, |
| 163796 | + /* 1550 */ 59, 117, 193, 216, 217, 78, 216, 217, 81, 216, |
| 163797 | + /* 1560 */ 217, 318, 71, 85, 193, 133, 193, 193, 90, 23, |
| 163798 | + /* 1570 */ 23, 25, 25, 120, 121, 98, 85, 193, 100, 193, |
| 163799 | + /* 1580 */ 23, 90, 25, 121, 106, 107, 19, 216, 217, 216, |
| 163800 | + /* 1590 */ 217, 100, 114, 131, 116, 117, 118, 106, 107, 121, |
| 163801 | + /* 1600 */ 216, 217, 216, 217, 193, 114, 117, 116, 117, 118, |
| 163802 | + /* 1610 */ 133, 193, 121, 193, 193, 138, 139, 193, 23, 193, |
| 163803 | + /* 1620 */ 25, 23, 23, 25, 25, 7, 8, 216, 217, 193, |
| 163804 | + /* 1630 */ 193, 153, 154, 155, 156, 157, 216, 217, 59, 162, |
| 163805 | + /* 1640 */ 216, 217, 216, 217, 153, 154, 155, 156, 157, 1, |
| 163806 | + /* 1650 */ 2, 193, 193, 5, 19, 20, 193, 22, 10, 11, |
| 163807 | + /* 1660 */ 12, 13, 14, 193, 97, 17, 193, 23, 23, 25, |
| 163808 | + /* 1670 */ 25, 36, 83, 84, 216, 217, 236, 23, 30, 25, |
| 163809 | + /* 1680 */ 32, 19, 20, 153, 22, 155, 216, 217, 40, 216, |
| 163810 | + /* 1690 */ 217, 153, 193, 155, 59, 23, 117, 25, 36, 23, |
| 163811 | + /* 1700 */ 193, 25, 193, 193, 193, 193, 71, 193, 242, 193, |
| 163812 | + /* 1710 */ 193, 193, 193, 193, 243, 288, 287, 214, 70, 255, |
| 163813 | + /* 1720 */ 255, 59, 255, 255, 191, 297, 78, 271, 267, 81, |
| 163814 | + /* 1730 */ 245, 293, 246, 71, 246, 100, 267, 245, 293, 249, |
| 163815 | + /* 1740 */ 219, 106, 107, 108, 220, 271, 98, 271, 225, 114, |
| 163816 | + /* 1750 */ 271, 116, 117, 118, 229, 219, 121, 259, 219, 259, |
| 163817 | + /* 1760 */ 259, 259, 100, 60, 280, 196, 141, 38, 106, 107, |
| 163818 | + /* 1770 */ 200, 249, 245, 200, 243, 200, 114, 151, 116, 117, |
| 163819 | + /* 1780 */ 118, 133, 150, 121, 297, 272, 138, 139, 153, 154, |
| 163820 | + /* 1790 */ 155, 156, 157, 297, 22, 43, 19, 20, 294, 22, |
| 163821 | + /* 1800 */ 294, 18, 270, 237, 200, 234, 18, 199, 149, 283, |
| 163822 | + /* 1810 */ 162, 237, 272, 36, 237, 153, 154, 155, 156, 157, |
| 163823 | + /* 1820 */ 237, 272, 246, 270, 246, 234, 246, 234, 246, 200, |
| 163824 | + /* 1830 */ 199, 158, 290, 62, 289, 199, 59, 200, 22, 200, |
| 163825 | + /* 1840 */ 221, 199, 221, 200, 64, 199, 115, 227, 71, 22, |
| 163826 | + /* 1850 */ 126, 218, 218, 165, 224, 227, 218, 24, 113, 305, |
| 163827 | + /* 1860 */ 312, 200, 221, 282, 224, 218, 282, 91, 218, 220, |
| 163828 | + /* 1870 */ 218, 218, 221, 317, 82, 317, 265, 100, 265, 145, |
| 163829 | + /* 1880 */ 148, 22, 277, 106, 107, 200, 158, 147, 279, 146, |
| 163830 | + /* 1890 */ 25, 114, 202, 116, 117, 118, 13, 6, 121, 194, |
| 163831 | + /* 1900 */ 194, 192, 192, 192, 248, 250, 249, 247, 250, 246, |
| 163832 | + /* 1910 */ 303, 207, 300, 303, 213, 213, 222, 222, 4, 207, |
| 163833 | + /* 1920 */ 213, 213, 207, 3, 22, 163, 15, 214, 214, 213, |
| 163834 | + /* 1930 */ 153, 154, 155, 156, 157, 16, 23, 139, 23, 130, |
| 163835 | + /* 1940 */ 151, 25, 24, 142, 20, 16, 144, 1, 142, 130, |
| 163836 | + /* 1950 */ 130, 61, 53, 53, 37, 151, 53, 53, 130, 116, |
| 163837 | + /* 1960 */ 34, 1, 141, 5, 22, 115, 161, 75, 25, 68, |
| 163838 | + /* 1970 */ 141, 41, 115, 68, 24, 20, 19, 131, 125, 67, |
| 163839 | + /* 1980 */ 24, 22, 59, 22, 22, 96, 23, 22, 67, 22, |
| 163840 | + /* 1990 */ 37, 23, 28, 149, 67, 22, 25, 23, 23, 23, |
| 163841 | + /* 2000 */ 23, 22, 141, 97, 23, 23, 34, 22, 25, 116, |
| 163842 | + /* 2010 */ 143, 75, 34, 88, 34, 75, 23, 86, 34, 22, |
| 163843 | + /* 2020 */ 34, 93, 34, 24, 34, 25, 25, 23, 23, 23, |
| 163844 | + /* 2030 */ 23, 44, 23, 25, 23, 22, 11, 22, 22, 25, |
| 163845 | + /* 2040 */ 23, 23, 22, 22, 135, 15, 23, 25, 141, 141, |
| 163846 | + /* 2050 */ 1, 141, 1, 319, 319, 319, 319, 319, 319, 319, |
| 163847 | + /* 2060 */ 319, 319, 319, 141, 319, 319, 319, 319, 319, 319, |
| 162678 | 163848 | /* 2070 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162679 | 163849 | /* 2080 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162680 | 163850 | /* 2090 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162681 | 163851 | /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162682 | 163852 | /* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| | @@ -162690,181 +163860,178 @@ |
| 162690 | 163860 | /* 2190 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162691 | 163861 | /* 2200 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162692 | 163862 | /* 2210 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162693 | 163863 | /* 2220 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162694 | 163864 | /* 2230 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162695 | | - /* 2240 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162696 | | - /* 2250 */ 319, 319, 319, 319, 319, |
| 163865 | + /* 2240 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, |
| 162697 | 163866 | }; |
| 162698 | | -#define YY_SHIFT_COUNT (573) |
| 163867 | +#define YY_SHIFT_COUNT (569) |
| 162699 | 163868 | #define YY_SHIFT_MIN (0) |
| 162700 | | -#define YY_SHIFT_MAX (2045) |
| 163869 | +#define YY_SHIFT_MAX (2051) |
| 162701 | 163870 | static const unsigned short int yy_shift_ofst[] = { |
| 162702 | | - /* 0 */ 1648, 1477, 1272, 322, 322, 262, 1319, 1478, 1491, 1662, |
| 162703 | | - /* 10 */ 1662, 1662, 317, 0, 0, 214, 1093, 1662, 1662, 1662, |
| 163871 | + /* 0 */ 1648, 1477, 1272, 322, 322, 1, 1319, 1478, 1491, 1662, |
| 163872 | + /* 10 */ 1662, 1662, 471, 0, 0, 214, 1093, 1662, 1662, 1662, |
| 162704 | 163873 | /* 20 */ 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, |
| 162705 | | - /* 30 */ 271, 271, 1219, 1219, 216, 88, 262, 262, 262, 262, |
| 162706 | | - /* 40 */ 262, 40, 111, 258, 361, 469, 512, 583, 622, 693, |
| 163874 | + /* 30 */ 271, 271, 1219, 1219, 216, 88, 1, 1, 1, 1, |
| 163875 | + /* 40 */ 1, 40, 111, 258, 361, 469, 512, 583, 622, 693, |
| 162707 | 163876 | /* 50 */ 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, 1093, |
| 162708 | 163877 | /* 60 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, |
| 162709 | 163878 | /* 70 */ 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, 1662, |
| 162710 | 163879 | /* 80 */ 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, |
| 162711 | 163880 | /* 90 */ 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, |
| 162712 | 163881 | /* 100 */ 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, |
| 162713 | 163882 | /* 110 */ 1662, 1662, 1662, 1662, 1777, 1662, 1662, 1662, 1662, 1662, |
| 162714 | 163883 | /* 120 */ 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 137, 181, |
| 162715 | 163884 | /* 130 */ 181, 181, 181, 181, 94, 430, 66, 65, 112, 366, |
| 162716 | | - /* 140 */ 475, 475, 629, 1058, 475, 475, 125, 125, 475, 686, |
| 162717 | | - /* 150 */ 686, 686, 660, 686, 57, 184, 184, 77, 77, 2070, |
| 162718 | | - /* 160 */ 2070, 328, 328, 328, 493, 373, 373, 373, 373, 1015, |
| 162719 | | - /* 170 */ 1015, 409, 366, 1129, 1149, 475, 475, 475, 475, 475, |
| 162720 | | - /* 180 */ 475, 475, 475, 475, 475, 475, 475, 475, 475, 475, |
| 162721 | | - /* 190 */ 475, 475, 475, 475, 475, 621, 621, 475, 852, 899, |
| 162722 | | - /* 200 */ 899, 1295, 1295, 406, 851, 2070, 2070, 2070, 2070, 2070, |
| 162723 | | - /* 210 */ 2070, 2070, 1307, 954, 954, 640, 464, 695, 238, 700, |
| 162724 | | - /* 220 */ 538, 541, 748, 475, 475, 475, 475, 475, 475, 475, |
| 162725 | | - /* 230 */ 475, 475, 475, 634, 475, 475, 475, 475, 475, 475, |
| 162726 | | - /* 240 */ 475, 475, 475, 475, 475, 475, 1175, 1175, 1175, 475, |
| 162727 | | - /* 250 */ 475, 475, 580, 475, 475, 475, 1074, 1142, 475, 475, |
| 162728 | | - /* 260 */ 1072, 475, 475, 475, 475, 475, 475, 475, 475, 797, |
| 162729 | | - /* 270 */ 1330, 740, 1131, 1131, 1131, 1131, 1069, 740, 740, 1209, |
| 162730 | | - /* 280 */ 167, 926, 1391, 1038, 1314, 187, 1408, 1314, 1408, 1435, |
| 162731 | | - /* 290 */ 1109, 1038, 1038, 1109, 1038, 187, 1435, 227, 1090, 941, |
| 162732 | | - /* 300 */ 1270, 1270, 1270, 1408, 1256, 1256, 1326, 1440, 513, 1461, |
| 162733 | | - /* 310 */ 1685, 1685, 1613, 1613, 1722, 1722, 1613, 1612, 1614, 1745, |
| 162734 | | - /* 320 */ 1728, 1755, 1755, 1755, 1755, 1613, 1766, 1651, 1614, 1614, |
| 162735 | | - /* 330 */ 1651, 1745, 1728, 1651, 1728, 1651, 1613, 1766, 1653, 1758, |
| 162736 | | - /* 340 */ 1613, 1766, 1802, 1613, 1766, 1613, 1766, 1802, 1716, 1716, |
| 162737 | | - /* 350 */ 1716, 1768, 1813, 1813, 1802, 1716, 1713, 1716, 1768, 1716, |
| 162738 | | - /* 360 */ 1716, 1675, 1817, 1729, 1729, 1802, 1706, 1742, 1706, 1742, |
| 162739 | | - /* 370 */ 1706, 1742, 1706, 1742, 1613, 1774, 1774, 1786, 1786, 1723, |
| 162740 | | - /* 380 */ 1730, 1851, 1613, 1720, 1723, 1733, 1735, 1651, 1857, 1873, |
| 162741 | | - /* 390 */ 1873, 1896, 1896, 1896, 2070, 2070, 2070, 2070, 2070, 2070, |
| 162742 | | - /* 400 */ 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, 207, |
| 162743 | | - /* 410 */ 915, 1010, 1030, 1217, 910, 1170, 1470, 1368, 1481, 1442, |
| 162744 | | - /* 420 */ 1318, 1383, 1515, 1482, 1523, 1542, 1546, 1547, 1588, 1595, |
| 162745 | | - /* 430 */ 1502, 1338, 1566, 1493, 1520, 1521, 1598, 1617, 1568, 1618, |
| 162746 | | - /* 440 */ 1511, 1514, 1645, 1649, 1570, 1484, 1910, 1915, 1897, 1757, |
| 162747 | | - /* 450 */ 1908, 1909, 1901, 1903, 1788, 1778, 1798, 1911, 1911, 1913, |
| 162748 | | - /* 460 */ 1793, 1918, 1795, 1924, 1940, 1800, 1814, 1911, 1815, 1882, |
| 162749 | | - /* 470 */ 1912, 1911, 1796, 1895, 1898, 1900, 1902, 1824, 1840, 1923, |
| 162750 | | - /* 480 */ 1818, 1957, 1955, 1939, 1847, 1803, 1899, 1938, 1904, 1890, |
| 162751 | | - /* 490 */ 1925, 1827, 1854, 1946, 1951, 1954, 1843, 1850, 1956, 1914, |
| 162752 | | - /* 500 */ 1958, 1960, 1953, 1961, 1917, 1920, 1962, 1881, 1959, 1963, |
| 162753 | | - /* 510 */ 1921, 1952, 1967, 1842, 1970, 1971, 1972, 1973, 1968, 1974, |
| 162754 | | - /* 520 */ 1976, 1905, 1858, 1977, 1978, 1887, 1975, 1982, 1862, 1981, |
| 162755 | | - /* 530 */ 1979, 1980, 1983, 1984, 1919, 1933, 1926, 1966, 1936, 1922, |
| 162756 | | - /* 540 */ 1985, 1993, 1998, 1997, 1999, 2000, 1988, 2003, 1981, 2004, |
| 162757 | | - /* 550 */ 2005, 2006, 2007, 2008, 2009, 2001, 2020, 2012, 2013, 2014, |
| 162758 | | - /* 560 */ 2015, 2017, 2018, 2011, 1906, 1907, 1916, 1927, 1928, 2019, |
| 162759 | | - /* 570 */ 2022, 2027, 2042, 2045, |
| 163885 | + /* 140 */ 533, 533, 740, 1261, 533, 533, 79, 79, 533, 412, |
| 163886 | + /* 150 */ 412, 412, 77, 412, 123, 113, 113, 22, 22, 2064, |
| 163887 | + /* 160 */ 2064, 328, 328, 328, 239, 468, 468, 468, 468, 1015, |
| 163888 | + /* 170 */ 1015, 409, 366, 1129, 1186, 533, 533, 533, 533, 533, |
| 163889 | + /* 180 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, |
| 163890 | + /* 190 */ 533, 533, 533, 533, 533, 969, 621, 621, 533, 642, |
| 163891 | + /* 200 */ 788, 788, 1228, 1228, 822, 822, 67, 1274, 2064, 2064, |
| 163892 | + /* 210 */ 2064, 2064, 2064, 2064, 2064, 1307, 954, 954, 585, 472, |
| 163893 | + /* 220 */ 640, 387, 695, 538, 541, 700, 533, 533, 533, 533, |
| 163894 | + /* 230 */ 533, 533, 533, 533, 533, 533, 222, 533, 533, 533, |
| 163895 | + /* 240 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 1179, |
| 163896 | + /* 250 */ 1179, 1179, 533, 533, 533, 565, 533, 533, 533, 916, |
| 163897 | + /* 260 */ 1144, 533, 533, 1288, 533, 533, 533, 533, 533, 533, |
| 163898 | + /* 270 */ 533, 533, 639, 1330, 209, 1076, 1076, 1076, 1076, 580, |
| 163899 | + /* 280 */ 209, 209, 1313, 768, 917, 649, 1181, 1316, 405, 1316, |
| 163900 | + /* 290 */ 1238, 249, 1181, 1181, 249, 1181, 405, 1238, 1369, 464, |
| 163901 | + /* 300 */ 1259, 1012, 1012, 1012, 1368, 1368, 1368, 1368, 184, 184, |
| 163902 | + /* 310 */ 1326, 904, 1287, 1480, 1703, 1703, 1625, 1625, 1729, 1729, |
| 163903 | + /* 320 */ 1625, 1626, 1632, 1772, 1752, 1783, 1783, 1783, 1783, 1625, |
| 163904 | + /* 330 */ 1788, 1659, 1632, 1632, 1659, 1772, 1752, 1659, 1752, 1659, |
| 163905 | + /* 340 */ 1625, 1788, 1673, 1771, 1625, 1788, 1816, 1625, 1788, 1625, |
| 163906 | + /* 350 */ 1788, 1816, 1731, 1731, 1731, 1780, 1827, 1827, 1816, 1731, |
| 163907 | + /* 360 */ 1724, 1731, 1780, 1731, 1731, 1688, 1833, 1745, 1745, 1816, |
| 163908 | + /* 370 */ 1625, 1776, 1776, 1792, 1792, 1732, 1734, 1859, 1625, 1728, |
| 163909 | + /* 380 */ 1732, 1740, 1743, 1659, 1865, 1883, 1883, 1891, 1891, 1891, |
| 163910 | + /* 390 */ 2064, 2064, 2064, 2064, 2064, 2064, 2064, 2064, 2064, 2064, |
| 163911 | + /* 400 */ 2064, 2064, 2064, 2064, 2064, 207, 1095, 331, 620, 903, |
| 163912 | + /* 410 */ 806, 1074, 1483, 1432, 1481, 1322, 1370, 1394, 1515, 1291, |
| 163913 | + /* 420 */ 1546, 1547, 1557, 1595, 1598, 1599, 1434, 1453, 1618, 1462, |
| 163914 | + /* 430 */ 1567, 1489, 1644, 1645, 1589, 1654, 1530, 1538, 1672, 1676, |
| 163915 | + /* 440 */ 1579, 742, 1914, 1920, 1902, 1762, 1911, 1919, 1913, 1915, |
| 163916 | + /* 450 */ 1798, 1789, 1809, 1916, 1916, 1918, 1801, 1924, 1802, 1929, |
| 163917 | + /* 460 */ 1946, 1806, 1819, 1916, 1820, 1890, 1917, 1916, 1804, 1899, |
| 163918 | + /* 470 */ 1900, 1903, 1904, 1828, 1843, 1926, 1821, 1960, 1958, 1942, |
| 163919 | + /* 480 */ 1850, 1805, 1901, 1943, 1905, 1892, 1930, 1829, 1857, 1950, |
| 163920 | + /* 490 */ 1955, 1957, 1846, 1853, 1959, 1912, 1961, 1962, 1963, 1965, |
| 163921 | + /* 500 */ 1921, 1923, 1956, 1889, 1964, 1967, 1927, 1953, 1968, 1844, |
| 163922 | + /* 510 */ 1973, 1974, 1975, 1976, 1971, 1977, 1979, 1906, 1861, 1981, |
| 163923 | + /* 520 */ 1982, 1893, 1972, 1985, 1867, 1983, 1978, 1980, 1984, 1986, |
| 163924 | + /* 530 */ 1925, 1936, 1931, 1987, 1940, 1928, 1988, 1993, 1997, 1999, |
| 163925 | + /* 540 */ 2000, 2001, 1990, 2004, 1983, 2005, 2006, 2007, 2009, 2008, |
| 163926 | + /* 550 */ 2011, 2013, 2025, 2015, 2016, 2017, 2018, 2020, 2021, 2014, |
| 163927 | + /* 560 */ 1909, 1907, 1908, 1910, 1922, 2022, 2023, 2030, 2049, 2051, |
| 162760 | 163928 | }; |
| 162761 | | -#define YY_REDUCE_COUNT (408) |
| 162762 | | -#define YY_REDUCE_MIN (-267) |
| 162763 | | -#define YY_REDUCE_MAX (1715) |
| 163929 | +#define YY_REDUCE_COUNT (404) |
| 163930 | +#define YY_REDUCE_MIN (-271) |
| 163931 | +#define YY_REDUCE_MAX (1716) |
| 162764 | 163932 | static const short yy_reduce_ofst[] = { |
| 162765 | 163933 | /* 0 */ -125, 733, 789, 241, 293, -123, -193, -191, -183, -187, |
| 162766 | | - /* 10 */ -180, 83, 133, -207, -198, -267, -175, -6, 166, 313, |
| 162767 | | - /* 20 */ 487, 396, 489, 598, 615, 685, 687, 79, 781, 857, |
| 162768 | | - /* 30 */ 490, 616, 240, 334, -188, 796, 841, 843, 1003, 1005, |
| 162769 | | - /* 40 */ 1007, -260, -260, -260, -260, -260, -260, -260, -260, -260, |
| 162770 | | - /* 50 */ -260, -260, -260, -260, -260, -260, -260, -260, -260, -260, |
| 162771 | | - /* 60 */ -260, -260, -260, -260, -260, -260, -260, -260, -260, -260, |
| 162772 | | - /* 70 */ -260, -260, -260, -260, -260, -260, -260, -260, 158, 203, |
| 162773 | | - /* 80 */ 391, 576, 724, 726, 886, 1021, 1035, 1063, 1081, 1083, |
| 162774 | | - /* 90 */ 1097, 1099, 1117, 1152, 1155, 1158, 1163, 1165, 1167, 1169, |
| 162775 | | - /* 100 */ 1172, 1180, 1183, 1198, 1200, 1205, 1215, 1225, 1227, 1236, |
| 162776 | | - /* 110 */ 1252, 1264, 1299, 1303, 1306, 1309, 1312, 1315, 1325, 1328, |
| 162777 | | - /* 120 */ 1337, 1340, 1343, 1371, 1373, 1384, 1386, 1411, -260, -260, |
| 162778 | | - /* 130 */ -260, -260, -260, -260, -260, -260, -260, -53, 138, 302, |
| 162779 | | - /* 140 */ -158, 357, 223, -222, 411, 458, -92, 556, 669, 581, |
| 162780 | | - /* 150 */ 632, 581, -260, 632, 758, 778, 920, -260, -260, -260, |
| 162781 | | - /* 160 */ -260, 161, 161, 161, 307, 234, 392, 526, 790, 195, |
| 162782 | | - /* 170 */ 359, -174, -173, 362, 362, -189, 16, 560, 567, 261, |
| 162783 | | - /* 180 */ 689, 802, 853, -122, -166, 408, 335, 617, 690, 837, |
| 162784 | | - /* 190 */ 1001, 746, 1061, 515, 1082, 994, 1034, -135, 1000, 1048, |
| 162785 | | - /* 200 */ 1137, 877, 897, 186, 627, 1031, 1133, 1148, 1159, 1194, |
| 162786 | | - /* 210 */ 1199, 1195, -194, -142, 18, -152, 68, 201, 253, 269, |
| 162787 | | - /* 220 */ 294, 354, 521, 528, 676, 680, 736, 743, 850, 907, |
| 162788 | | - /* 230 */ 1041, 1047, 1060, 727, 1139, 1147, 1201, 1237, 1278, 1359, |
| 162789 | | - /* 240 */ 1393, 1400, 1413, 1429, 1433, 1437, 1126, 1410, 1430, 1444, |
| 162790 | | - /* 250 */ 1480, 1483, 1405, 1486, 1490, 1492, 1420, 1372, 1496, 1498, |
| 162791 | | - /* 260 */ 1441, 1499, 253, 1500, 1503, 1504, 1506, 1507, 1508, 1398, |
| 162792 | | - /* 270 */ 1415, 1453, 1448, 1449, 1450, 1452, 1405, 1453, 1453, 1465, |
| 162793 | | - /* 280 */ 1495, 1519, 1414, 1443, 1445, 1468, 1456, 1455, 1457, 1424, |
| 162794 | | - /* 290 */ 1473, 1454, 1459, 1474, 1460, 1479, 1434, 1512, 1494, 1509, |
| 162795 | | - /* 300 */ 1517, 1518, 1525, 1469, 1489, 1501, 1467, 1510, 1497, 1543, |
| 162796 | | - /* 310 */ 1451, 1462, 1557, 1558, 1471, 1472, 1561, 1487, 1505, 1524, |
| 162797 | | - /* 320 */ 1538, 1537, 1545, 1548, 1556, 1575, 1596, 1552, 1529, 1530, |
| 162798 | | - /* 330 */ 1559, 1533, 1572, 1562, 1573, 1563, 1604, 1615, 1522, 1532, |
| 162799 | | - /* 340 */ 1622, 1624, 1605, 1625, 1628, 1629, 1631, 1607, 1616, 1619, |
| 162800 | | - /* 350 */ 1620, 1606, 1621, 1623, 1630, 1626, 1632, 1636, 1633, 1637, |
| 162801 | | - /* 360 */ 1638, 1531, 1541, 1567, 1571, 1640, 1597, 1599, 1601, 1603, |
| 162802 | | - /* 370 */ 1608, 1610, 1611, 1627, 1664, 1549, 1550, 1609, 1634, 1639, |
| 162803 | | - /* 380 */ 1641, 1602, 1676, 1642, 1646, 1644, 1650, 1654, 1683, 1694, |
| 162804 | | - /* 390 */ 1707, 1711, 1712, 1714, 1643, 1647, 1652, 1698, 1695, 1696, |
| 162805 | | - /* 400 */ 1697, 1699, 1700, 1689, 1691, 1701, 1702, 1704, 1715, |
| 163934 | + /* 10 */ 166, 238, 133, -207, -199, -267, -176, -6, 204, 489, |
| 163935 | + /* 20 */ 576, -175, 598, 686, 615, 725, 860, 778, 781, 857, |
| 163936 | + /* 30 */ 616, 887, 87, 240, -192, 408, 626, 796, 843, 854, |
| 163937 | + /* 40 */ 1003, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 163938 | + /* 50 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 163939 | + /* 60 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, |
| 163940 | + /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, 80, 83, |
| 163941 | + /* 80 */ 313, 886, 888, 996, 1034, 1059, 1081, 1100, 1117, 1152, |
| 163942 | + /* 90 */ 1155, 1163, 1165, 1167, 1169, 1172, 1180, 1182, 1184, 1198, |
| 163943 | + /* 100 */ 1200, 1213, 1215, 1225, 1227, 1252, 1254, 1264, 1299, 1303, |
| 163944 | + /* 110 */ 1308, 1312, 1325, 1328, 1337, 1340, 1343, 1371, 1373, 1384, |
| 163945 | + /* 120 */ 1386, 1411, 1420, 1424, 1426, 1458, 1470, 1473, -271, -271, |
| 163946 | + /* 130 */ -271, -271, -271, -271, -271, -271, -271, 138, 459, 396, |
| 163947 | + /* 140 */ -158, 470, 302, -212, 521, 201, -195, -92, 559, 630, |
| 163948 | + /* 150 */ 632, 630, -271, 632, 901, 63, 407, -271, -271, -271, |
| 163949 | + /* 160 */ -271, 161, 161, 161, 251, 335, 847, 960, 980, 537, |
| 163950 | + /* 170 */ 588, 618, 628, 688, 688, -166, -161, 674, 790, 794, |
| 163951 | + /* 180 */ 799, 851, 852, -122, 680, -120, 995, 1038, 415, 1051, |
| 163952 | + /* 190 */ 893, 798, 962, 400, 1086, 779, 923, 924, 263, 1041, |
| 163953 | + /* 200 */ 979, 990, 1083, 1097, 1031, 1194, 362, 994, 1139, 1005, |
| 163954 | + /* 210 */ 1037, 1202, 1205, 1195, 1210, -194, 56, 185, -135, 232, |
| 163955 | + /* 220 */ 522, 560, 601, 617, 669, 683, 711, 856, 908, 941, |
| 163956 | + /* 230 */ 1048, 1101, 1147, 1257, 1262, 1265, 392, 1292, 1333, 1339, |
| 163957 | + /* 240 */ 1342, 1346, 1350, 1359, 1374, 1418, 1421, 1436, 1437, 593, |
| 163958 | + /* 250 */ 755, 770, 997, 1459, 1463, 1209, 1499, 1507, 1509, 1132, |
| 163959 | + /* 260 */ 1243, 1510, 1511, 1440, 1512, 560, 1514, 1516, 1517, 1518, |
| 163960 | + /* 270 */ 1519, 1520, 1427, 1429, 1466, 1464, 1465, 1467, 1468, 1209, |
| 163961 | + /* 280 */ 1466, 1466, 1471, 1503, 1533, 1428, 1456, 1461, 1485, 1469, |
| 163962 | + /* 290 */ 1438, 1486, 1474, 1476, 1488, 1479, 1492, 1445, 1524, 1525, |
| 163963 | + /* 300 */ 1523, 1521, 1536, 1539, 1498, 1500, 1501, 1502, 1490, 1522, |
| 163964 | + /* 310 */ 1484, 1527, 1531, 1569, 1487, 1496, 1570, 1573, 1504, 1506, |
| 163965 | + /* 320 */ 1575, 1526, 1513, 1532, 1571, 1566, 1574, 1577, 1583, 1604, |
| 163966 | + /* 330 */ 1608, 1576, 1540, 1549, 1578, 1553, 1591, 1580, 1593, 1582, |
| 163967 | + /* 340 */ 1629, 1631, 1542, 1545, 1637, 1636, 1619, 1639, 1642, 1643, |
| 163968 | + /* 350 */ 1646, 1621, 1633, 1634, 1638, 1620, 1630, 1640, 1641, 1647, |
| 163969 | + /* 360 */ 1649, 1650, 1628, 1652, 1653, 1548, 1554, 1581, 1584, 1651, |
| 163970 | + /* 370 */ 1661, 1556, 1558, 1611, 1613, 1655, 1657, 1605, 1685, 1609, |
| 163971 | + /* 380 */ 1658, 1656, 1660, 1663, 1690, 1705, 1706, 1709, 1710, 1711, |
| 163972 | + /* 390 */ 1607, 1610, 1612, 1704, 1701, 1702, 1707, 1708, 1712, 1694, |
| 163973 | + /* 400 */ 1695, 1713, 1714, 1716, 1715, |
| 162806 | 163974 | }; |
| 162807 | 163975 | static const YYACTIONTYPE yy_default[] = { |
| 162808 | | - /* 0 */ 1637, 1637, 1637, 1466, 1233, 1344, 1233, 1233, 1233, 1466, |
| 162809 | | - /* 10 */ 1466, 1466, 1233, 1374, 1374, 1519, 1266, 1233, 1233, 1233, |
| 162810 | | - /* 20 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1465, 1233, 1233, |
| 162811 | | - /* 30 */ 1233, 1233, 1554, 1554, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162812 | | - /* 40 */ 1233, 1233, 1383, 1233, 1390, 1233, 1233, 1233, 1233, 1233, |
| 162813 | | - /* 50 */ 1467, 1468, 1233, 1233, 1233, 1518, 1520, 1483, 1397, 1396, |
| 162814 | | - /* 60 */ 1395, 1394, 1501, 1361, 1388, 1381, 1385, 1461, 1462, 1460, |
| 162815 | | - /* 70 */ 1464, 1468, 1467, 1233, 1384, 1431, 1445, 1430, 1233, 1233, |
| 162816 | | - /* 80 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162817 | | - /* 90 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162818 | | - /* 100 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162819 | | - /* 110 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162820 | | - /* 120 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1439, 1444, |
| 162821 | | - /* 130 */ 1451, 1443, 1440, 1433, 1432, 1434, 1435, 1233, 1233, 1257, |
| 162822 | | - /* 140 */ 1233, 1233, 1254, 1308, 1233, 1233, 1233, 1233, 1233, 1538, |
| 162823 | | - /* 150 */ 1537, 1233, 1436, 1233, 1266, 1425, 1424, 1448, 1437, 1447, |
| 162824 | | - /* 160 */ 1446, 1526, 1590, 1589, 1484, 1233, 1233, 1233, 1233, 1233, |
| 162825 | | - /* 170 */ 1233, 1554, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162826 | | - /* 180 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162827 | | - /* 190 */ 1233, 1233, 1233, 1233, 1233, 1554, 1554, 1233, 1266, 1554, |
| 162828 | | - /* 200 */ 1554, 1262, 1262, 1368, 1233, 1533, 1335, 1335, 1335, 1335, |
| 162829 | | - /* 210 */ 1344, 1335, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162830 | | - /* 220 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1523, 1521, 1233, |
| 162831 | | - /* 230 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162832 | | - /* 240 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162833 | | - /* 250 */ 1233, 1233, 1233, 1233, 1233, 1233, 1340, 1233, 1233, 1233, |
| 162834 | | - /* 260 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1583, 1233, |
| 162835 | | - /* 270 */ 1496, 1322, 1340, 1340, 1340, 1340, 1342, 1323, 1321, 1334, |
| 162836 | | - /* 280 */ 1267, 1240, 1629, 1400, 1389, 1341, 1363, 1389, 1363, 1626, |
| 162837 | | - /* 290 */ 1387, 1400, 1400, 1387, 1400, 1341, 1626, 1283, 1606, 1278, |
| 162838 | | - /* 300 */ 1374, 1374, 1374, 1363, 1368, 1368, 1463, 1341, 1334, 1233, |
| 162839 | | - /* 310 */ 1629, 1629, 1349, 1349, 1628, 1628, 1349, 1484, 1613, 1409, |
| 162840 | | - /* 320 */ 1311, 1317, 1317, 1317, 1317, 1349, 1251, 1387, 1613, 1613, |
| 162841 | | - /* 330 */ 1387, 1409, 1311, 1387, 1311, 1387, 1349, 1251, 1500, 1623, |
| 162842 | | - /* 340 */ 1349, 1251, 1474, 1349, 1251, 1349, 1251, 1474, 1309, 1309, |
| 162843 | | - /* 350 */ 1309, 1298, 1233, 1233, 1474, 1309, 1283, 1309, 1298, 1309, |
| 162844 | | - /* 360 */ 1309, 1572, 1233, 1478, 1478, 1474, 1367, 1362, 1367, 1362, |
| 162845 | | - /* 370 */ 1367, 1362, 1367, 1362, 1349, 1564, 1564, 1377, 1377, 1382, |
| 162846 | | - /* 380 */ 1368, 1469, 1349, 1233, 1382, 1380, 1378, 1387, 1301, 1586, |
| 162847 | | - /* 390 */ 1586, 1582, 1582, 1582, 1634, 1634, 1533, 1599, 1266, 1266, |
| 162848 | | - /* 400 */ 1266, 1266, 1599, 1285, 1285, 1267, 1267, 1266, 1599, 1233, |
| 162849 | | - /* 410 */ 1233, 1233, 1233, 1233, 1233, 1594, 1233, 1528, 1485, 1353, |
| 162850 | | - /* 420 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162851 | | - /* 430 */ 1233, 1233, 1233, 1233, 1539, 1233, 1233, 1233, 1233, 1233, |
| 162852 | | - /* 440 */ 1233, 1233, 1233, 1233, 1233, 1414, 1233, 1236, 1530, 1233, |
| 162853 | | - /* 450 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1391, 1392, 1354, |
| 162854 | | - /* 460 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1406, 1233, 1233, |
| 162855 | | - /* 470 */ 1233, 1401, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162856 | | - /* 480 */ 1625, 1233, 1233, 1233, 1233, 1233, 1233, 1499, 1498, 1233, |
| 162857 | | - /* 490 */ 1233, 1351, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162858 | | - /* 500 */ 1233, 1233, 1233, 1233, 1233, 1281, 1233, 1233, 1233, 1233, |
| 162859 | | - /* 510 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162860 | | - /* 520 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1379, |
| 162861 | | - /* 530 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162862 | | - /* 540 */ 1233, 1233, 1233, 1233, 1569, 1369, 1233, 1233, 1616, 1233, |
| 162863 | | - /* 550 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, |
| 162864 | | - /* 560 */ 1233, 1233, 1233, 1610, 1325, 1416, 1233, 1415, 1419, 1255, |
| 162865 | | - /* 570 */ 1233, 1245, 1233, 1233, |
| 163976 | + /* 0 */ 1637, 1637, 1637, 1465, 1232, 1343, 1232, 1232, 1232, 1465, |
| 163977 | + /* 10 */ 1465, 1465, 1232, 1373, 1373, 1518, 1265, 1232, 1232, 1232, |
| 163978 | + /* 20 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1464, 1232, 1232, |
| 163979 | + /* 30 */ 1232, 1232, 1553, 1553, 1232, 1232, 1232, 1232, 1232, 1232, |
| 163980 | + /* 40 */ 1232, 1232, 1382, 1232, 1389, 1232, 1232, 1232, 1232, 1232, |
| 163981 | + /* 50 */ 1466, 1467, 1232, 1232, 1232, 1517, 1519, 1482, 1396, 1395, |
| 163982 | + /* 60 */ 1394, 1393, 1500, 1361, 1387, 1380, 1384, 1460, 1461, 1459, |
| 163983 | + /* 70 */ 1463, 1467, 1466, 1232, 1383, 1430, 1444, 1429, 1232, 1232, |
| 163984 | + /* 80 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 163985 | + /* 90 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 163986 | + /* 100 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 163987 | + /* 110 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 163988 | + /* 120 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1438, 1443, |
| 163989 | + /* 130 */ 1450, 1442, 1439, 1432, 1431, 1433, 1434, 1232, 1232, 1256, |
| 163990 | + /* 140 */ 1232, 1232, 1253, 1307, 1232, 1232, 1232, 1232, 1232, 1537, |
| 163991 | + /* 150 */ 1536, 1232, 1435, 1232, 1265, 1424, 1423, 1447, 1436, 1446, |
| 163992 | + /* 160 */ 1445, 1525, 1589, 1588, 1483, 1232, 1232, 1232, 1232, 1232, |
| 163993 | + /* 170 */ 1232, 1553, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 163994 | + /* 180 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 163995 | + /* 190 */ 1232, 1232, 1232, 1232, 1232, 1363, 1553, 1553, 1232, 1265, |
| 163996 | + /* 200 */ 1553, 1553, 1364, 1364, 1261, 1261, 1367, 1232, 1532, 1334, |
| 163997 | + /* 210 */ 1334, 1334, 1334, 1343, 1334, 1232, 1232, 1232, 1232, 1232, |
| 163998 | + /* 220 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 163999 | + /* 230 */ 1522, 1520, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 164000 | + /* 240 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 164001 | + /* 250 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1339, |
| 164002 | + /* 260 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 164003 | + /* 270 */ 1232, 1582, 1232, 1495, 1321, 1339, 1339, 1339, 1339, 1341, |
| 164004 | + /* 280 */ 1322, 1320, 1333, 1266, 1239, 1629, 1399, 1388, 1340, 1388, |
| 164005 | + /* 290 */ 1626, 1386, 1399, 1399, 1386, 1399, 1340, 1626, 1282, 1605, |
| 164006 | + /* 300 */ 1277, 1373, 1373, 1373, 1363, 1363, 1363, 1363, 1367, 1367, |
| 164007 | + /* 310 */ 1462, 1340, 1333, 1232, 1629, 1629, 1349, 1349, 1628, 1628, |
| 164008 | + /* 320 */ 1349, 1483, 1613, 1408, 1310, 1316, 1316, 1316, 1316, 1349, |
| 164009 | + /* 330 */ 1250, 1386, 1613, 1613, 1386, 1408, 1310, 1386, 1310, 1386, |
| 164010 | + /* 340 */ 1349, 1250, 1499, 1623, 1349, 1250, 1473, 1349, 1250, 1349, |
| 164011 | + /* 350 */ 1250, 1473, 1308, 1308, 1308, 1297, 1232, 1232, 1473, 1308, |
| 164012 | + /* 360 */ 1282, 1308, 1297, 1308, 1308, 1571, 1232, 1477, 1477, 1473, |
| 164013 | + /* 370 */ 1349, 1563, 1563, 1376, 1376, 1381, 1367, 1468, 1349, 1232, |
| 164014 | + /* 380 */ 1381, 1379, 1377, 1386, 1300, 1585, 1585, 1581, 1581, 1581, |
| 164015 | + /* 390 */ 1634, 1634, 1532, 1598, 1265, 1265, 1265, 1265, 1598, 1284, |
| 164016 | + /* 400 */ 1284, 1266, 1266, 1265, 1598, 1232, 1232, 1232, 1232, 1232, |
| 164017 | + /* 410 */ 1232, 1593, 1232, 1527, 1484, 1353, 1232, 1232, 1232, 1232, |
| 164018 | + /* 420 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 164019 | + /* 430 */ 1538, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 164020 | + /* 440 */ 1232, 1413, 1232, 1235, 1529, 1232, 1232, 1232, 1232, 1232, |
| 164021 | + /* 450 */ 1232, 1232, 1232, 1390, 1391, 1354, 1232, 1232, 1232, 1232, |
| 164022 | + /* 460 */ 1232, 1232, 1232, 1405, 1232, 1232, 1232, 1400, 1232, 1232, |
| 164023 | + /* 470 */ 1232, 1232, 1232, 1232, 1232, 1232, 1625, 1232, 1232, 1232, |
| 164024 | + /* 480 */ 1232, 1232, 1232, 1498, 1497, 1232, 1232, 1351, 1232, 1232, |
| 164025 | + /* 490 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 164026 | + /* 500 */ 1232, 1280, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 164027 | + /* 510 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 164028 | + /* 520 */ 1232, 1232, 1232, 1232, 1232, 1378, 1232, 1232, 1232, 1232, |
| 164029 | + /* 530 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 164030 | + /* 540 */ 1568, 1368, 1232, 1232, 1616, 1232, 1232, 1232, 1232, 1232, |
| 164031 | + /* 550 */ 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1609, |
| 164032 | + /* 560 */ 1324, 1415, 1232, 1414, 1418, 1254, 1232, 1244, 1232, 1232, |
| 162866 | 164033 | }; |
| 162867 | 164034 | /********** End of lemon-generated parsing tables *****************************/ |
| 162868 | 164035 | |
| 162869 | 164036 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| 162870 | 164037 | ** If a construct like the following: |
| | @@ -163412,16 +164579,16 @@ |
| 163412 | 164579 | /* 254 */ "sclp", |
| 163413 | 164580 | /* 255 */ "as", |
| 163414 | 164581 | /* 256 */ "seltablist", |
| 163415 | 164582 | /* 257 */ "stl_prefix", |
| 163416 | 164583 | /* 258 */ "joinop", |
| 163417 | | - /* 259 */ "indexed_opt", |
| 163418 | | - /* 260 */ "on_opt", |
| 163419 | | - /* 261 */ "using_opt", |
| 163420 | | - /* 262 */ "exprlist", |
| 163421 | | - /* 263 */ "xfullname", |
| 163422 | | - /* 264 */ "idlist", |
| 164584 | + /* 259 */ "on_using", |
| 164585 | + /* 260 */ "indexed_by", |
| 164586 | + /* 261 */ "exprlist", |
| 164587 | + /* 262 */ "xfullname", |
| 164588 | + /* 263 */ "idlist", |
| 164589 | + /* 264 */ "indexed_opt", |
| 163423 | 164590 | /* 265 */ "nulls", |
| 163424 | 164591 | /* 266 */ "with", |
| 163425 | 164592 | /* 267 */ "where_opt_ret", |
| 163426 | 164593 | /* 268 */ "setlist", |
| 163427 | 164594 | /* 269 */ "insert_cmd", |
| | @@ -163588,33 +164755,33 @@ |
| 163588 | 164755 | /* 104 */ "as ::=", |
| 163589 | 164756 | /* 105 */ "from ::=", |
| 163590 | 164757 | /* 106 */ "from ::= FROM seltablist", |
| 163591 | 164758 | /* 107 */ "stl_prefix ::= seltablist joinop", |
| 163592 | 164759 | /* 108 */ "stl_prefix ::=", |
| 163593 | | - /* 109 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", |
| 163594 | | - /* 110 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt", |
| 163595 | | - /* 111 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", |
| 163596 | | - /* 112 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", |
| 163597 | | - /* 113 */ "dbnm ::=", |
| 163598 | | - /* 114 */ "dbnm ::= DOT nm", |
| 163599 | | - /* 115 */ "fullname ::= nm", |
| 163600 | | - /* 116 */ "fullname ::= nm DOT nm", |
| 163601 | | - /* 117 */ "xfullname ::= nm", |
| 163602 | | - /* 118 */ "xfullname ::= nm DOT nm", |
| 163603 | | - /* 119 */ "xfullname ::= nm DOT nm AS nm", |
| 163604 | | - /* 120 */ "xfullname ::= nm AS nm", |
| 163605 | | - /* 121 */ "joinop ::= COMMA|JOIN", |
| 163606 | | - /* 122 */ "joinop ::= JOIN_KW JOIN", |
| 163607 | | - /* 123 */ "joinop ::= JOIN_KW nm JOIN", |
| 163608 | | - /* 124 */ "joinop ::= JOIN_KW nm nm JOIN", |
| 163609 | | - /* 125 */ "on_opt ::= ON expr", |
| 163610 | | - /* 126 */ "on_opt ::=", |
| 163611 | | - /* 127 */ "indexed_opt ::=", |
| 163612 | | - /* 128 */ "indexed_opt ::= INDEXED BY nm", |
| 163613 | | - /* 129 */ "indexed_opt ::= NOT INDEXED", |
| 163614 | | - /* 130 */ "using_opt ::= USING LP idlist RP", |
| 163615 | | - /* 131 */ "using_opt ::=", |
| 164760 | + /* 109 */ "seltablist ::= stl_prefix nm dbnm as on_using", |
| 164761 | + /* 110 */ "seltablist ::= stl_prefix nm dbnm as indexed_by on_using", |
| 164762 | + /* 111 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using", |
| 164763 | + /* 112 */ "seltablist ::= stl_prefix LP select RP as on_using", |
| 164764 | + /* 113 */ "seltablist ::= stl_prefix LP seltablist RP as on_using", |
| 164765 | + /* 114 */ "dbnm ::=", |
| 164766 | + /* 115 */ "dbnm ::= DOT nm", |
| 164767 | + /* 116 */ "fullname ::= nm", |
| 164768 | + /* 117 */ "fullname ::= nm DOT nm", |
| 164769 | + /* 118 */ "xfullname ::= nm", |
| 164770 | + /* 119 */ "xfullname ::= nm DOT nm", |
| 164771 | + /* 120 */ "xfullname ::= nm DOT nm AS nm", |
| 164772 | + /* 121 */ "xfullname ::= nm AS nm", |
| 164773 | + /* 122 */ "joinop ::= COMMA|JOIN", |
| 164774 | + /* 123 */ "joinop ::= JOIN_KW JOIN", |
| 164775 | + /* 124 */ "joinop ::= JOIN_KW nm JOIN", |
| 164776 | + /* 125 */ "joinop ::= JOIN_KW nm nm JOIN", |
| 164777 | + /* 126 */ "on_using ::= ON expr", |
| 164778 | + /* 127 */ "on_using ::= USING LP idlist RP", |
| 164779 | + /* 128 */ "on_using ::=", |
| 164780 | + /* 129 */ "indexed_opt ::=", |
| 164781 | + /* 130 */ "indexed_by ::= INDEXED BY nm", |
| 164782 | + /* 131 */ "indexed_by ::= NOT INDEXED", |
| 163616 | 164783 | /* 132 */ "orderby_opt ::=", |
| 163617 | 164784 | /* 133 */ "orderby_opt ::= ORDER BY sortlist", |
| 163618 | 164785 | /* 134 */ "sortlist ::= sortlist COMMA expr sortorder nulls", |
| 163619 | 164786 | /* 135 */ "sortlist ::= expr sortorder nulls", |
| 163620 | 164787 | /* 136 */ "sortorder ::= ASC", |
| | @@ -163856,35 +165023,36 @@ |
| 163856 | 165023 | /* 372 */ "resolvetype ::= raisetype", |
| 163857 | 165024 | /* 373 */ "selectnowith ::= oneselect", |
| 163858 | 165025 | /* 374 */ "oneselect ::= values", |
| 163859 | 165026 | /* 375 */ "sclp ::= selcollist COMMA", |
| 163860 | 165027 | /* 376 */ "as ::= ID|STRING", |
| 163861 | | - /* 377 */ "returning ::=", |
| 163862 | | - /* 378 */ "expr ::= term", |
| 163863 | | - /* 379 */ "likeop ::= LIKE_KW|MATCH", |
| 163864 | | - /* 380 */ "exprlist ::= nexprlist", |
| 163865 | | - /* 381 */ "nmnum ::= plus_num", |
| 163866 | | - /* 382 */ "nmnum ::= nm", |
| 163867 | | - /* 383 */ "nmnum ::= ON", |
| 163868 | | - /* 384 */ "nmnum ::= DELETE", |
| 163869 | | - /* 385 */ "nmnum ::= DEFAULT", |
| 163870 | | - /* 386 */ "plus_num ::= INTEGER|FLOAT", |
| 163871 | | - /* 387 */ "foreach_clause ::=", |
| 163872 | | - /* 388 */ "foreach_clause ::= FOR EACH ROW", |
| 163873 | | - /* 389 */ "trnm ::= nm", |
| 163874 | | - /* 390 */ "tridxby ::=", |
| 163875 | | - /* 391 */ "database_kw_opt ::= DATABASE", |
| 163876 | | - /* 392 */ "database_kw_opt ::=", |
| 163877 | | - /* 393 */ "kwcolumn_opt ::=", |
| 163878 | | - /* 394 */ "kwcolumn_opt ::= COLUMNKW", |
| 163879 | | - /* 395 */ "vtabarglist ::= vtabarg", |
| 163880 | | - /* 396 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 163881 | | - /* 397 */ "vtabarg ::= vtabarg vtabargtoken", |
| 163882 | | - /* 398 */ "anylist ::=", |
| 163883 | | - /* 399 */ "anylist ::= anylist LP anylist RP", |
| 163884 | | - /* 400 */ "anylist ::= anylist ANY", |
| 163885 | | - /* 401 */ "with ::=", |
| 165028 | + /* 377 */ "indexed_opt ::= indexed_by", |
| 165029 | + /* 378 */ "returning ::=", |
| 165030 | + /* 379 */ "expr ::= term", |
| 165031 | + /* 380 */ "likeop ::= LIKE_KW|MATCH", |
| 165032 | + /* 381 */ "exprlist ::= nexprlist", |
| 165033 | + /* 382 */ "nmnum ::= plus_num", |
| 165034 | + /* 383 */ "nmnum ::= nm", |
| 165035 | + /* 384 */ "nmnum ::= ON", |
| 165036 | + /* 385 */ "nmnum ::= DELETE", |
| 165037 | + /* 386 */ "nmnum ::= DEFAULT", |
| 165038 | + /* 387 */ "plus_num ::= INTEGER|FLOAT", |
| 165039 | + /* 388 */ "foreach_clause ::=", |
| 165040 | + /* 389 */ "foreach_clause ::= FOR EACH ROW", |
| 165041 | + /* 390 */ "trnm ::= nm", |
| 165042 | + /* 391 */ "tridxby ::=", |
| 165043 | + /* 392 */ "database_kw_opt ::= DATABASE", |
| 165044 | + /* 393 */ "database_kw_opt ::=", |
| 165045 | + /* 394 */ "kwcolumn_opt ::=", |
| 165046 | + /* 395 */ "kwcolumn_opt ::= COLUMNKW", |
| 165047 | + /* 396 */ "vtabarglist ::= vtabarg", |
| 165048 | + /* 397 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 165049 | + /* 398 */ "vtabarg ::= vtabarg vtabargtoken", |
| 165050 | + /* 399 */ "anylist ::=", |
| 165051 | + /* 400 */ "anylist ::= anylist LP anylist RP", |
| 165052 | + /* 401 */ "anylist ::= anylist ANY", |
| 165053 | + /* 402 */ "with ::=", |
| 163886 | 165054 | }; |
| 163887 | 165055 | #endif /* NDEBUG */ |
| 163888 | 165056 | |
| 163889 | 165057 | |
| 163890 | 165058 | #if YYSTACKDEPTH<=0 |
| | @@ -164018,11 +165186,10 @@ |
| 164018 | 165186 | break; |
| 164019 | 165187 | case 216: /* term */ |
| 164020 | 165188 | case 217: /* expr */ |
| 164021 | 165189 | case 246: /* where_opt */ |
| 164022 | 165190 | case 248: /* having_opt */ |
| 164023 | | - case 260: /* on_opt */ |
| 164024 | 165191 | case 267: /* where_opt_ret */ |
| 164025 | 165192 | case 278: /* case_operand */ |
| 164026 | 165193 | case 280: /* case_else */ |
| 164027 | 165194 | case 283: /* vinto */ |
| 164028 | 165195 | case 290: /* when_clause */ |
| | @@ -164038,11 +165205,11 @@ |
| 164038 | 165205 | case 244: /* selcollist */ |
| 164039 | 165206 | case 247: /* groupby_opt */ |
| 164040 | 165207 | case 249: /* orderby_opt */ |
| 164041 | 165208 | case 253: /* nexprlist */ |
| 164042 | 165209 | case 254: /* sclp */ |
| 164043 | | - case 262: /* exprlist */ |
| 165210 | + case 261: /* exprlist */ |
| 164044 | 165211 | case 268: /* setlist */ |
| 164045 | 165212 | case 277: /* paren_exprlist */ |
| 164046 | 165213 | case 279: /* case_exprlist */ |
| 164047 | 165214 | case 310: /* part_opt */ |
| 164048 | 165215 | { |
| | @@ -164051,11 +165218,11 @@ |
| 164051 | 165218 | break; |
| 164052 | 165219 | case 238: /* fullname */ |
| 164053 | 165220 | case 245: /* from */ |
| 164054 | 165221 | case 256: /* seltablist */ |
| 164055 | 165222 | case 257: /* stl_prefix */ |
| 164056 | | - case 263: /* xfullname */ |
| 165223 | + case 262: /* xfullname */ |
| 164057 | 165224 | { |
| 164058 | 165225 | sqlite3SrcListDelete(pParse->db, (yypminor->yy131)); |
| 164059 | 165226 | } |
| 164060 | 165227 | break; |
| 164061 | 165228 | case 241: /* wqlist */ |
| | @@ -164067,12 +165234,11 @@ |
| 164067 | 165234 | case 306: /* windowdefn_list */ |
| 164068 | 165235 | { |
| 164069 | 165236 | sqlite3WindowListDelete(pParse->db, (yypminor->yy41)); |
| 164070 | 165237 | } |
| 164071 | 165238 | break; |
| 164072 | | - case 261: /* using_opt */ |
| 164073 | | - case 264: /* idlist */ |
| 165239 | + case 263: /* idlist */ |
| 164074 | 165240 | case 270: /* idlist_opt */ |
| 164075 | 165241 | { |
| 164076 | 165242 | sqlite3IdListDelete(pParse->db, (yypminor->yy254)); |
| 164077 | 165243 | } |
| 164078 | 165244 | break; |
| | @@ -164498,33 +165664,33 @@ |
| 164498 | 165664 | 255, /* (104) as ::= */ |
| 164499 | 165665 | 245, /* (105) from ::= */ |
| 164500 | 165666 | 245, /* (106) from ::= FROM seltablist */ |
| 164501 | 165667 | 257, /* (107) stl_prefix ::= seltablist joinop */ |
| 164502 | 165668 | 257, /* (108) stl_prefix ::= */ |
| 164503 | | - 256, /* (109) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 164504 | | - 256, /* (110) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 164505 | | - 256, /* (111) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 164506 | | - 256, /* (112) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 164507 | | - 200, /* (113) dbnm ::= */ |
| 164508 | | - 200, /* (114) dbnm ::= DOT nm */ |
| 164509 | | - 238, /* (115) fullname ::= nm */ |
| 164510 | | - 238, /* (116) fullname ::= nm DOT nm */ |
| 164511 | | - 263, /* (117) xfullname ::= nm */ |
| 164512 | | - 263, /* (118) xfullname ::= nm DOT nm */ |
| 164513 | | - 263, /* (119) xfullname ::= nm DOT nm AS nm */ |
| 164514 | | - 263, /* (120) xfullname ::= nm AS nm */ |
| 164515 | | - 258, /* (121) joinop ::= COMMA|JOIN */ |
| 164516 | | - 258, /* (122) joinop ::= JOIN_KW JOIN */ |
| 164517 | | - 258, /* (123) joinop ::= JOIN_KW nm JOIN */ |
| 164518 | | - 258, /* (124) joinop ::= JOIN_KW nm nm JOIN */ |
| 164519 | | - 260, /* (125) on_opt ::= ON expr */ |
| 164520 | | - 260, /* (126) on_opt ::= */ |
| 164521 | | - 259, /* (127) indexed_opt ::= */ |
| 164522 | | - 259, /* (128) indexed_opt ::= INDEXED BY nm */ |
| 164523 | | - 259, /* (129) indexed_opt ::= NOT INDEXED */ |
| 164524 | | - 261, /* (130) using_opt ::= USING LP idlist RP */ |
| 164525 | | - 261, /* (131) using_opt ::= */ |
| 165669 | + 256, /* (109) seltablist ::= stl_prefix nm dbnm as on_using */ |
| 165670 | + 256, /* (110) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */ |
| 165671 | + 256, /* (111) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */ |
| 165672 | + 256, /* (112) seltablist ::= stl_prefix LP select RP as on_using */ |
| 165673 | + 256, /* (113) seltablist ::= stl_prefix LP seltablist RP as on_using */ |
| 165674 | + 200, /* (114) dbnm ::= */ |
| 165675 | + 200, /* (115) dbnm ::= DOT nm */ |
| 165676 | + 238, /* (116) fullname ::= nm */ |
| 165677 | + 238, /* (117) fullname ::= nm DOT nm */ |
| 165678 | + 262, /* (118) xfullname ::= nm */ |
| 165679 | + 262, /* (119) xfullname ::= nm DOT nm */ |
| 165680 | + 262, /* (120) xfullname ::= nm DOT nm AS nm */ |
| 165681 | + 262, /* (121) xfullname ::= nm AS nm */ |
| 165682 | + 258, /* (122) joinop ::= COMMA|JOIN */ |
| 165683 | + 258, /* (123) joinop ::= JOIN_KW JOIN */ |
| 165684 | + 258, /* (124) joinop ::= JOIN_KW nm JOIN */ |
| 165685 | + 258, /* (125) joinop ::= JOIN_KW nm nm JOIN */ |
| 165686 | + 259, /* (126) on_using ::= ON expr */ |
| 165687 | + 259, /* (127) on_using ::= USING LP idlist RP */ |
| 165688 | + 259, /* (128) on_using ::= */ |
| 165689 | + 264, /* (129) indexed_opt ::= */ |
| 165690 | + 260, /* (130) indexed_by ::= INDEXED BY nm */ |
| 165691 | + 260, /* (131) indexed_by ::= NOT INDEXED */ |
| 164526 | 165692 | 249, /* (132) orderby_opt ::= */ |
| 164527 | 165693 | 249, /* (133) orderby_opt ::= ORDER BY sortlist */ |
| 164528 | 165694 | 231, /* (134) sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 164529 | 165695 | 231, /* (135) sortlist ::= expr sortorder nulls */ |
| 164530 | 165696 | 219, /* (136) sortorder ::= ASC */ |
| | @@ -164564,12 +165730,12 @@ |
| 164564 | 165730 | 272, /* (170) returning ::= RETURNING selcollist */ |
| 164565 | 165731 | 269, /* (171) insert_cmd ::= INSERT orconf */ |
| 164566 | 165732 | 269, /* (172) insert_cmd ::= REPLACE */ |
| 164567 | 165733 | 270, /* (173) idlist_opt ::= */ |
| 164568 | 165734 | 270, /* (174) idlist_opt ::= LP idlist RP */ |
| 164569 | | - 264, /* (175) idlist ::= idlist COMMA nm */ |
| 164570 | | - 264, /* (176) idlist ::= nm */ |
| 165735 | + 263, /* (175) idlist ::= idlist COMMA nm */ |
| 165736 | + 263, /* (176) idlist ::= nm */ |
| 164571 | 165737 | 217, /* (177) expr ::= LP expr RP */ |
| 164572 | 165738 | 217, /* (178) expr ::= ID|INDEXED */ |
| 164573 | 165739 | 217, /* (179) expr ::= JOIN_KW */ |
| 164574 | 165740 | 217, /* (180) expr ::= nm DOT nm */ |
| 164575 | 165741 | 217, /* (181) expr ::= nm DOT nm DOT nm */ |
| | @@ -164619,11 +165785,11 @@ |
| 164619 | 165785 | 279, /* (225) case_exprlist ::= WHEN expr THEN expr */ |
| 164620 | 165786 | 280, /* (226) case_else ::= ELSE expr */ |
| 164621 | 165787 | 280, /* (227) case_else ::= */ |
| 164622 | 165788 | 278, /* (228) case_operand ::= expr */ |
| 164623 | 165789 | 278, /* (229) case_operand ::= */ |
| 164624 | | - 262, /* (230) exprlist ::= */ |
| 165790 | + 261, /* (230) exprlist ::= */ |
| 164625 | 165791 | 253, /* (231) nexprlist ::= nexprlist COMMA expr */ |
| 164626 | 165792 | 253, /* (232) nexprlist ::= expr */ |
| 164627 | 165793 | 277, /* (233) paren_exprlist ::= */ |
| 164628 | 165794 | 277, /* (234) paren_exprlist ::= LP exprlist RP */ |
| 164629 | 165795 | 190, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| | @@ -164766,35 +165932,36 @@ |
| 164766 | 165932 | 235, /* (372) resolvetype ::= raisetype */ |
| 164767 | 165933 | 239, /* (373) selectnowith ::= oneselect */ |
| 164768 | 165934 | 240, /* (374) oneselect ::= values */ |
| 164769 | 165935 | 254, /* (375) sclp ::= selcollist COMMA */ |
| 164770 | 165936 | 255, /* (376) as ::= ID|STRING */ |
| 164771 | | - 272, /* (377) returning ::= */ |
| 164772 | | - 217, /* (378) expr ::= term */ |
| 164773 | | - 274, /* (379) likeop ::= LIKE_KW|MATCH */ |
| 164774 | | - 262, /* (380) exprlist ::= nexprlist */ |
| 164775 | | - 284, /* (381) nmnum ::= plus_num */ |
| 164776 | | - 284, /* (382) nmnum ::= nm */ |
| 164777 | | - 284, /* (383) nmnum ::= ON */ |
| 164778 | | - 284, /* (384) nmnum ::= DELETE */ |
| 164779 | | - 284, /* (385) nmnum ::= DEFAULT */ |
| 164780 | | - 211, /* (386) plus_num ::= INTEGER|FLOAT */ |
| 164781 | | - 289, /* (387) foreach_clause ::= */ |
| 164782 | | - 289, /* (388) foreach_clause ::= FOR EACH ROW */ |
| 164783 | | - 292, /* (389) trnm ::= nm */ |
| 164784 | | - 293, /* (390) tridxby ::= */ |
| 164785 | | - 294, /* (391) database_kw_opt ::= DATABASE */ |
| 164786 | | - 294, /* (392) database_kw_opt ::= */ |
| 164787 | | - 297, /* (393) kwcolumn_opt ::= */ |
| 164788 | | - 297, /* (394) kwcolumn_opt ::= COLUMNKW */ |
| 164789 | | - 299, /* (395) vtabarglist ::= vtabarg */ |
| 164790 | | - 299, /* (396) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 164791 | | - 300, /* (397) vtabarg ::= vtabarg vtabargtoken */ |
| 164792 | | - 303, /* (398) anylist ::= */ |
| 164793 | | - 303, /* (399) anylist ::= anylist LP anylist RP */ |
| 164794 | | - 303, /* (400) anylist ::= anylist ANY */ |
| 164795 | | - 266, /* (401) with ::= */ |
| 165937 | + 264, /* (377) indexed_opt ::= indexed_by */ |
| 165938 | + 272, /* (378) returning ::= */ |
| 165939 | + 217, /* (379) expr ::= term */ |
| 165940 | + 274, /* (380) likeop ::= LIKE_KW|MATCH */ |
| 165941 | + 261, /* (381) exprlist ::= nexprlist */ |
| 165942 | + 284, /* (382) nmnum ::= plus_num */ |
| 165943 | + 284, /* (383) nmnum ::= nm */ |
| 165944 | + 284, /* (384) nmnum ::= ON */ |
| 165945 | + 284, /* (385) nmnum ::= DELETE */ |
| 165946 | + 284, /* (386) nmnum ::= DEFAULT */ |
| 165947 | + 211, /* (387) plus_num ::= INTEGER|FLOAT */ |
| 165948 | + 289, /* (388) foreach_clause ::= */ |
| 165949 | + 289, /* (389) foreach_clause ::= FOR EACH ROW */ |
| 165950 | + 292, /* (390) trnm ::= nm */ |
| 165951 | + 293, /* (391) tridxby ::= */ |
| 165952 | + 294, /* (392) database_kw_opt ::= DATABASE */ |
| 165953 | + 294, /* (393) database_kw_opt ::= */ |
| 165954 | + 297, /* (394) kwcolumn_opt ::= */ |
| 165955 | + 297, /* (395) kwcolumn_opt ::= COLUMNKW */ |
| 165956 | + 299, /* (396) vtabarglist ::= vtabarg */ |
| 165957 | + 299, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 165958 | + 300, /* (398) vtabarg ::= vtabarg vtabargtoken */ |
| 165959 | + 303, /* (399) anylist ::= */ |
| 165960 | + 303, /* (400) anylist ::= anylist LP anylist RP */ |
| 165961 | + 303, /* (401) anylist ::= anylist ANY */ |
| 165962 | + 266, /* (402) with ::= */ |
| 164796 | 165963 | }; |
| 164797 | 165964 | |
| 164798 | 165965 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
| 164799 | 165966 | ** of symbols on the right-hand side of that rule. */ |
| 164800 | 165967 | static const signed char yyRuleInfoNRhs[] = { |
| | @@ -164905,33 +166072,33 @@ |
| 164905 | 166072 | 0, /* (104) as ::= */ |
| 164906 | 166073 | 0, /* (105) from ::= */ |
| 164907 | 166074 | -2, /* (106) from ::= FROM seltablist */ |
| 164908 | 166075 | -2, /* (107) stl_prefix ::= seltablist joinop */ |
| 164909 | 166076 | 0, /* (108) stl_prefix ::= */ |
| 164910 | | - -7, /* (109) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 164911 | | - -9, /* (110) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 164912 | | - -7, /* (111) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 164913 | | - -7, /* (112) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 164914 | | - 0, /* (113) dbnm ::= */ |
| 164915 | | - -2, /* (114) dbnm ::= DOT nm */ |
| 164916 | | - -1, /* (115) fullname ::= nm */ |
| 164917 | | - -3, /* (116) fullname ::= nm DOT nm */ |
| 164918 | | - -1, /* (117) xfullname ::= nm */ |
| 164919 | | - -3, /* (118) xfullname ::= nm DOT nm */ |
| 164920 | | - -5, /* (119) xfullname ::= nm DOT nm AS nm */ |
| 164921 | | - -3, /* (120) xfullname ::= nm AS nm */ |
| 164922 | | - -1, /* (121) joinop ::= COMMA|JOIN */ |
| 164923 | | - -2, /* (122) joinop ::= JOIN_KW JOIN */ |
| 164924 | | - -3, /* (123) joinop ::= JOIN_KW nm JOIN */ |
| 164925 | | - -4, /* (124) joinop ::= JOIN_KW nm nm JOIN */ |
| 164926 | | - -2, /* (125) on_opt ::= ON expr */ |
| 164927 | | - 0, /* (126) on_opt ::= */ |
| 164928 | | - 0, /* (127) indexed_opt ::= */ |
| 164929 | | - -3, /* (128) indexed_opt ::= INDEXED BY nm */ |
| 164930 | | - -2, /* (129) indexed_opt ::= NOT INDEXED */ |
| 164931 | | - -4, /* (130) using_opt ::= USING LP idlist RP */ |
| 164932 | | - 0, /* (131) using_opt ::= */ |
| 166077 | + -5, /* (109) seltablist ::= stl_prefix nm dbnm as on_using */ |
| 166078 | + -6, /* (110) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */ |
| 166079 | + -8, /* (111) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */ |
| 166080 | + -6, /* (112) seltablist ::= stl_prefix LP select RP as on_using */ |
| 166081 | + -6, /* (113) seltablist ::= stl_prefix LP seltablist RP as on_using */ |
| 166082 | + 0, /* (114) dbnm ::= */ |
| 166083 | + -2, /* (115) dbnm ::= DOT nm */ |
| 166084 | + -1, /* (116) fullname ::= nm */ |
| 166085 | + -3, /* (117) fullname ::= nm DOT nm */ |
| 166086 | + -1, /* (118) xfullname ::= nm */ |
| 166087 | + -3, /* (119) xfullname ::= nm DOT nm */ |
| 166088 | + -5, /* (120) xfullname ::= nm DOT nm AS nm */ |
| 166089 | + -3, /* (121) xfullname ::= nm AS nm */ |
| 166090 | + -1, /* (122) joinop ::= COMMA|JOIN */ |
| 166091 | + -2, /* (123) joinop ::= JOIN_KW JOIN */ |
| 166092 | + -3, /* (124) joinop ::= JOIN_KW nm JOIN */ |
| 166093 | + -4, /* (125) joinop ::= JOIN_KW nm nm JOIN */ |
| 166094 | + -2, /* (126) on_using ::= ON expr */ |
| 166095 | + -4, /* (127) on_using ::= USING LP idlist RP */ |
| 166096 | + 0, /* (128) on_using ::= */ |
| 166097 | + 0, /* (129) indexed_opt ::= */ |
| 166098 | + -3, /* (130) indexed_by ::= INDEXED BY nm */ |
| 166099 | + -2, /* (131) indexed_by ::= NOT INDEXED */ |
| 164933 | 166100 | 0, /* (132) orderby_opt ::= */ |
| 164934 | 166101 | -3, /* (133) orderby_opt ::= ORDER BY sortlist */ |
| 164935 | 166102 | -5, /* (134) sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 164936 | 166103 | -3, /* (135) sortlist ::= expr sortorder nulls */ |
| 164937 | 166104 | -1, /* (136) sortorder ::= ASC */ |
| | @@ -165173,35 +166340,36 @@ |
| 165173 | 166340 | -1, /* (372) resolvetype ::= raisetype */ |
| 165174 | 166341 | -1, /* (373) selectnowith ::= oneselect */ |
| 165175 | 166342 | -1, /* (374) oneselect ::= values */ |
| 165176 | 166343 | -2, /* (375) sclp ::= selcollist COMMA */ |
| 165177 | 166344 | -1, /* (376) as ::= ID|STRING */ |
| 165178 | | - 0, /* (377) returning ::= */ |
| 165179 | | - -1, /* (378) expr ::= term */ |
| 165180 | | - -1, /* (379) likeop ::= LIKE_KW|MATCH */ |
| 165181 | | - -1, /* (380) exprlist ::= nexprlist */ |
| 165182 | | - -1, /* (381) nmnum ::= plus_num */ |
| 165183 | | - -1, /* (382) nmnum ::= nm */ |
| 165184 | | - -1, /* (383) nmnum ::= ON */ |
| 165185 | | - -1, /* (384) nmnum ::= DELETE */ |
| 165186 | | - -1, /* (385) nmnum ::= DEFAULT */ |
| 165187 | | - -1, /* (386) plus_num ::= INTEGER|FLOAT */ |
| 165188 | | - 0, /* (387) foreach_clause ::= */ |
| 165189 | | - -3, /* (388) foreach_clause ::= FOR EACH ROW */ |
| 165190 | | - -1, /* (389) trnm ::= nm */ |
| 165191 | | - 0, /* (390) tridxby ::= */ |
| 165192 | | - -1, /* (391) database_kw_opt ::= DATABASE */ |
| 165193 | | - 0, /* (392) database_kw_opt ::= */ |
| 165194 | | - 0, /* (393) kwcolumn_opt ::= */ |
| 165195 | | - -1, /* (394) kwcolumn_opt ::= COLUMNKW */ |
| 165196 | | - -1, /* (395) vtabarglist ::= vtabarg */ |
| 165197 | | - -3, /* (396) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 165198 | | - -2, /* (397) vtabarg ::= vtabarg vtabargtoken */ |
| 165199 | | - 0, /* (398) anylist ::= */ |
| 165200 | | - -4, /* (399) anylist ::= anylist LP anylist RP */ |
| 165201 | | - -2, /* (400) anylist ::= anylist ANY */ |
| 165202 | | - 0, /* (401) with ::= */ |
| 166345 | + -1, /* (377) indexed_opt ::= indexed_by */ |
| 166346 | + 0, /* (378) returning ::= */ |
| 166347 | + -1, /* (379) expr ::= term */ |
| 166348 | + -1, /* (380) likeop ::= LIKE_KW|MATCH */ |
| 166349 | + -1, /* (381) exprlist ::= nexprlist */ |
| 166350 | + -1, /* (382) nmnum ::= plus_num */ |
| 166351 | + -1, /* (383) nmnum ::= nm */ |
| 166352 | + -1, /* (384) nmnum ::= ON */ |
| 166353 | + -1, /* (385) nmnum ::= DELETE */ |
| 166354 | + -1, /* (386) nmnum ::= DEFAULT */ |
| 166355 | + -1, /* (387) plus_num ::= INTEGER|FLOAT */ |
| 166356 | + 0, /* (388) foreach_clause ::= */ |
| 166357 | + -3, /* (389) foreach_clause ::= FOR EACH ROW */ |
| 166358 | + -1, /* (390) trnm ::= nm */ |
| 166359 | + 0, /* (391) tridxby ::= */ |
| 166360 | + -1, /* (392) database_kw_opt ::= DATABASE */ |
| 166361 | + 0, /* (393) database_kw_opt ::= */ |
| 166362 | + 0, /* (394) kwcolumn_opt ::= */ |
| 166363 | + -1, /* (395) kwcolumn_opt ::= COLUMNKW */ |
| 166364 | + -1, /* (396) vtabarglist ::= vtabarg */ |
| 166365 | + -3, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 166366 | + -2, /* (398) vtabarg ::= vtabarg vtabargtoken */ |
| 166367 | + 0, /* (399) anylist ::= */ |
| 166368 | + -4, /* (400) anylist ::= anylist LP anylist RP */ |
| 166369 | + -2, /* (401) anylist ::= anylist ANY */ |
| 166370 | + 0, /* (402) with ::= */ |
| 165203 | 166371 | }; |
| 165204 | 166372 | |
| 165205 | 166373 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| 165206 | 166374 | |
| 165207 | 166375 | /* |
| | @@ -165565,11 +166733,11 @@ |
| 165565 | 166733 | if( pRhs && pRhs->pPrior ){ |
| 165566 | 166734 | SrcList *pFrom; |
| 165567 | 166735 | Token x; |
| 165568 | 166736 | x.n = 0; |
| 165569 | 166737 | parserDoubleLinkSelect(pParse, pRhs); |
| 165570 | | - pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0); |
| 166738 | + pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0); |
| 165571 | 166739 | pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); |
| 165572 | 166740 | } |
| 165573 | 166741 | if( pRhs ){ |
| 165574 | 166742 | pRhs->op = (u8)yymsp[-1].minor.yy394; |
| 165575 | 166743 | pRhs->pPrior = pLhs; |
| | @@ -165657,11 +166825,11 @@ |
| 165657 | 166825 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); |
| 165658 | 166826 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot); |
| 165659 | 166827 | } |
| 165660 | 166828 | break; |
| 165661 | 166829 | case 103: /* as ::= AS nm */ |
| 165662 | | - case 114: /* dbnm ::= DOT nm */ yytestcase(yyruleno==114); |
| 166830 | + case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115); |
| 165663 | 166831 | case 254: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==254); |
| 165664 | 166832 | case 255: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==255); |
| 165665 | 166833 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 165666 | 166834 | break; |
| 165667 | 166835 | case 105: /* from ::= */ |
| | @@ -165669,144 +166837,136 @@ |
| 165669 | 166837 | {yymsp[1].minor.yy131 = 0;} |
| 165670 | 166838 | break; |
| 165671 | 166839 | case 106: /* from ::= FROM seltablist */ |
| 165672 | 166840 | { |
| 165673 | 166841 | yymsp[-1].minor.yy131 = yymsp[0].minor.yy131; |
| 165674 | | - sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy131); |
| 166842 | + sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy131); |
| 165675 | 166843 | } |
| 165676 | 166844 | break; |
| 165677 | 166845 | case 107: /* stl_prefix ::= seltablist joinop */ |
| 165678 | 166846 | { |
| 165679 | 166847 | if( ALWAYS(yymsp[-1].minor.yy131 && yymsp[-1].minor.yy131->nSrc>0) ) yymsp[-1].minor.yy131->a[yymsp[-1].minor.yy131->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy394; |
| 165680 | 166848 | } |
| 165681 | 166849 | break; |
| 165682 | | - case 109: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 165683 | | -{ |
| 165684 | | - yymsp[-6].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy131,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy528,yymsp[0].minor.yy254); |
| 165685 | | - sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy131, &yymsp[-2].minor.yy0); |
| 165686 | | -} |
| 165687 | | - break; |
| 165688 | | - case 110: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 165689 | | -{ |
| 165690 | | - yymsp[-8].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy131,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy528,yymsp[0].minor.yy254); |
| 165691 | | - sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy131, yymsp[-4].minor.yy322); |
| 165692 | | -} |
| 165693 | | - break; |
| 165694 | | - case 111: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 165695 | | -{ |
| 165696 | | - yymsp[-6].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy131,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy47,yymsp[-1].minor.yy528,yymsp[0].minor.yy254); |
| 165697 | | - } |
| 165698 | | - break; |
| 165699 | | - case 112: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 165700 | | -{ |
| 165701 | | - if( yymsp[-6].minor.yy131==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy528==0 && yymsp[0].minor.yy254==0 ){ |
| 165702 | | - yymsp[-6].minor.yy131 = yymsp[-4].minor.yy131; |
| 165703 | | - }else if( yymsp[-4].minor.yy131->nSrc==1 ){ |
| 165704 | | - yymsp[-6].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy131,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy528,yymsp[0].minor.yy254); |
| 165705 | | - if( yymsp[-6].minor.yy131 ){ |
| 165706 | | - SrcItem *pNew = &yymsp[-6].minor.yy131->a[yymsp[-6].minor.yy131->nSrc-1]; |
| 165707 | | - SrcItem *pOld = yymsp[-4].minor.yy131->a; |
| 166850 | + case 109: /* seltablist ::= stl_prefix nm dbnm as on_using */ |
| 166851 | +{ |
| 166852 | + yymsp[-4].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy131,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy561); |
| 166853 | +} |
| 166854 | + break; |
| 166855 | + case 110: /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */ |
| 166856 | +{ |
| 166857 | + yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy561); |
| 166858 | + sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy131, &yymsp[-1].minor.yy0); |
| 166859 | +} |
| 166860 | + break; |
| 166861 | + case 111: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */ |
| 166862 | +{ |
| 166863 | + yymsp[-7].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy131,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy561); |
| 166864 | + sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy131, yymsp[-3].minor.yy322); |
| 166865 | +} |
| 166866 | + break; |
| 166867 | + case 112: /* seltablist ::= stl_prefix LP select RP as on_using */ |
| 166868 | +{ |
| 166869 | + yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy47,&yymsp[0].minor.yy561); |
| 166870 | + } |
| 166871 | + break; |
| 166872 | + case 113: /* seltablist ::= stl_prefix LP seltablist RP as on_using */ |
| 166873 | +{ |
| 166874 | + if( yymsp[-5].minor.yy131==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy561.pOn==0 && yymsp[0].minor.yy561.pUsing==0 ){ |
| 166875 | + yymsp[-5].minor.yy131 = yymsp[-3].minor.yy131; |
| 166876 | + }else if( yymsp[-3].minor.yy131->nSrc==1 ){ |
| 166877 | + yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy561); |
| 166878 | + if( yymsp[-5].minor.yy131 ){ |
| 166879 | + SrcItem *pNew = &yymsp[-5].minor.yy131->a[yymsp[-5].minor.yy131->nSrc-1]; |
| 166880 | + SrcItem *pOld = yymsp[-3].minor.yy131->a; |
| 165708 | 166881 | pNew->zName = pOld->zName; |
| 165709 | 166882 | pNew->zDatabase = pOld->zDatabase; |
| 165710 | 166883 | pNew->pSelect = pOld->pSelect; |
| 166884 | + if( pNew->pSelect && (pNew->pSelect->selFlags & SF_NestedFrom)!=0 ){ |
| 166885 | + pNew->fg.isNestedFrom = 1; |
| 166886 | + } |
| 165711 | 166887 | if( pOld->fg.isTabFunc ){ |
| 165712 | 166888 | pNew->u1.pFuncArg = pOld->u1.pFuncArg; |
| 165713 | 166889 | pOld->u1.pFuncArg = 0; |
| 165714 | 166890 | pOld->fg.isTabFunc = 0; |
| 165715 | 166891 | pNew->fg.isTabFunc = 1; |
| 165716 | 166892 | } |
| 165717 | 166893 | pOld->zName = pOld->zDatabase = 0; |
| 165718 | 166894 | pOld->pSelect = 0; |
| 165719 | 166895 | } |
| 165720 | | - sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy131); |
| 166896 | + sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy131); |
| 165721 | 166897 | }else{ |
| 165722 | 166898 | Select *pSubquery; |
| 165723 | | - sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy131); |
| 165724 | | - pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy131,0,0,0,0,SF_NestedFrom,0); |
| 165725 | | - yymsp[-6].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy131,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy528,yymsp[0].minor.yy254); |
| 166899 | + sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy131); |
| 166900 | + pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy131,0,0,0,0,SF_NestedFrom,0); |
| 166901 | + yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy561); |
| 165726 | 166902 | } |
| 165727 | 166903 | } |
| 165728 | 166904 | break; |
| 165729 | | - case 113: /* dbnm ::= */ |
| 165730 | | - case 127: /* indexed_opt ::= */ yytestcase(yyruleno==127); |
| 166905 | + case 114: /* dbnm ::= */ |
| 166906 | + case 129: /* indexed_opt ::= */ yytestcase(yyruleno==129); |
| 165731 | 166907 | {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;} |
| 165732 | 166908 | break; |
| 165733 | | - case 115: /* fullname ::= nm */ |
| 166909 | + case 116: /* fullname ::= nm */ |
| 165734 | 166910 | { |
| 165735 | 166911 | yylhsminor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); |
| 165736 | 166912 | if( IN_RENAME_OBJECT && yylhsminor.yy131 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy131->a[0].zName, &yymsp[0].minor.yy0); |
| 165737 | 166913 | } |
| 165738 | 166914 | yymsp[0].minor.yy131 = yylhsminor.yy131; |
| 165739 | 166915 | break; |
| 165740 | | - case 116: /* fullname ::= nm DOT nm */ |
| 166916 | + case 117: /* fullname ::= nm DOT nm */ |
| 165741 | 166917 | { |
| 165742 | 166918 | yylhsminor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 165743 | 166919 | if( IN_RENAME_OBJECT && yylhsminor.yy131 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy131->a[0].zName, &yymsp[0].minor.yy0); |
| 165744 | 166920 | } |
| 165745 | 166921 | yymsp[-2].minor.yy131 = yylhsminor.yy131; |
| 165746 | 166922 | break; |
| 165747 | | - case 117: /* xfullname ::= nm */ |
| 166923 | + case 118: /* xfullname ::= nm */ |
| 165748 | 166924 | {yymsp[0].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} |
| 165749 | 166925 | break; |
| 165750 | | - case 118: /* xfullname ::= nm DOT nm */ |
| 166926 | + case 119: /* xfullname ::= nm DOT nm */ |
| 165751 | 166927 | {yymsp[-2].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 165752 | 166928 | break; |
| 165753 | | - case 119: /* xfullname ::= nm DOT nm AS nm */ |
| 166929 | + case 120: /* xfullname ::= nm DOT nm AS nm */ |
| 165754 | 166930 | { |
| 165755 | 166931 | yymsp[-4].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ |
| 165756 | 166932 | if( yymsp[-4].minor.yy131 ) yymsp[-4].minor.yy131->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 165757 | 166933 | } |
| 165758 | 166934 | break; |
| 165759 | | - case 120: /* xfullname ::= nm AS nm */ |
| 166935 | + case 121: /* xfullname ::= nm AS nm */ |
| 165760 | 166936 | { |
| 165761 | 166937 | yymsp[-2].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ |
| 165762 | 166938 | if( yymsp[-2].minor.yy131 ) yymsp[-2].minor.yy131->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 165763 | 166939 | } |
| 165764 | 166940 | break; |
| 165765 | | - case 121: /* joinop ::= COMMA|JOIN */ |
| 166941 | + case 122: /* joinop ::= COMMA|JOIN */ |
| 165766 | 166942 | { yymsp[0].minor.yy394 = JT_INNER; } |
| 165767 | 166943 | break; |
| 165768 | | - case 122: /* joinop ::= JOIN_KW JOIN */ |
| 166944 | + case 123: /* joinop ::= JOIN_KW JOIN */ |
| 165769 | 166945 | {yymsp[-1].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} |
| 165770 | 166946 | break; |
| 165771 | | - case 123: /* joinop ::= JOIN_KW nm JOIN */ |
| 166947 | + case 124: /* joinop ::= JOIN_KW nm JOIN */ |
| 165772 | 166948 | {yymsp[-2].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} |
| 165773 | 166949 | break; |
| 165774 | | - case 124: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 166950 | + case 125: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 165775 | 166951 | {yymsp[-3].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} |
| 165776 | 166952 | break; |
| 165777 | | - case 125: /* on_opt ::= ON expr */ |
| 165778 | | - case 145: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==145); |
| 165779 | | - case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); |
| 165780 | | - case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); |
| 165781 | | - case 226: /* case_else ::= ELSE expr */ yytestcase(yyruleno==226); |
| 165782 | | - case 247: /* vinto ::= INTO expr */ yytestcase(yyruleno==247); |
| 165783 | | -{yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;} |
| 165784 | | - break; |
| 165785 | | - case 126: /* on_opt ::= */ |
| 165786 | | - case 144: /* having_opt ::= */ yytestcase(yyruleno==144); |
| 165787 | | - case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); |
| 165788 | | - case 151: /* where_opt ::= */ yytestcase(yyruleno==151); |
| 165789 | | - case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); |
| 165790 | | - case 227: /* case_else ::= */ yytestcase(yyruleno==227); |
| 165791 | | - case 229: /* case_operand ::= */ yytestcase(yyruleno==229); |
| 165792 | | - case 248: /* vinto ::= */ yytestcase(yyruleno==248); |
| 165793 | | -{yymsp[1].minor.yy528 = 0;} |
| 165794 | | - break; |
| 165795 | | - case 128: /* indexed_opt ::= INDEXED BY nm */ |
| 166953 | + case 126: /* on_using ::= ON expr */ |
| 166954 | +{yymsp[-1].minor.yy561.pOn = yymsp[0].minor.yy528; yymsp[-1].minor.yy561.pUsing = 0;} |
| 166955 | + break; |
| 166956 | + case 127: /* on_using ::= USING LP idlist RP */ |
| 166957 | +{yymsp[-3].minor.yy561.pOn = 0; yymsp[-3].minor.yy561.pUsing = yymsp[-1].minor.yy254;} |
| 166958 | + break; |
| 166959 | + case 128: /* on_using ::= */ |
| 166960 | +{yymsp[1].minor.yy561.pOn = 0; yymsp[1].minor.yy561.pUsing = 0;} |
| 166961 | + break; |
| 166962 | + case 130: /* indexed_by ::= INDEXED BY nm */ |
| 165796 | 166963 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} |
| 165797 | 166964 | break; |
| 165798 | | - case 129: /* indexed_opt ::= NOT INDEXED */ |
| 166965 | + case 131: /* indexed_by ::= NOT INDEXED */ |
| 165799 | 166966 | {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} |
| 165800 | 166967 | break; |
| 165801 | | - case 130: /* using_opt ::= USING LP idlist RP */ |
| 165802 | | -{yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;} |
| 165803 | | - break; |
| 165804 | | - case 131: /* using_opt ::= */ |
| 165805 | | - case 173: /* idlist_opt ::= */ yytestcase(yyruleno==173); |
| 165806 | | -{yymsp[1].minor.yy254 = 0;} |
| 165807 | | - break; |
| 165808 | 166968 | case 133: /* orderby_opt ::= ORDER BY sortlist */ |
| 165809 | 166969 | case 143: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==143); |
| 165810 | 166970 | {yymsp[-2].minor.yy322 = yymsp[0].minor.yy322;} |
| 165811 | 166971 | break; |
| 165812 | 166972 | case 134: /* sortlist ::= sortlist COMMA expr sortorder nulls */ |
| | @@ -165835,10 +166995,26 @@ |
| 165835 | 166995 | {yymsp[-1].minor.yy394 = SQLITE_SO_ASC;} |
| 165836 | 166996 | break; |
| 165837 | 166997 | case 140: /* nulls ::= NULLS LAST */ |
| 165838 | 166998 | {yymsp[-1].minor.yy394 = SQLITE_SO_DESC;} |
| 165839 | 166999 | break; |
| 167000 | + case 144: /* having_opt ::= */ |
| 167001 | + case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); |
| 167002 | + case 151: /* where_opt ::= */ yytestcase(yyruleno==151); |
| 167003 | + case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); |
| 167004 | + case 227: /* case_else ::= */ yytestcase(yyruleno==227); |
| 167005 | + case 229: /* case_operand ::= */ yytestcase(yyruleno==229); |
| 167006 | + case 248: /* vinto ::= */ yytestcase(yyruleno==248); |
| 167007 | +{yymsp[1].minor.yy528 = 0;} |
| 167008 | + break; |
| 167009 | + case 145: /* having_opt ::= HAVING expr */ |
| 167010 | + case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); |
| 167011 | + case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); |
| 167012 | + case 226: /* case_else ::= ELSE expr */ yytestcase(yyruleno==226); |
| 167013 | + case 247: /* vinto ::= INTO expr */ yytestcase(yyruleno==247); |
| 167014 | +{yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;} |
| 167015 | + break; |
| 165840 | 167016 | case 147: /* limit_opt ::= LIMIT expr */ |
| 165841 | 167017 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,0);} |
| 165842 | 167018 | break; |
| 165843 | 167019 | case 148: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 165844 | 167020 | {yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} |
| | @@ -165917,10 +167093,13 @@ |
| 165917 | 167093 | case 169: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 165918 | 167094 | { yymsp[-7].minor.yy444 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528,0);} |
| 165919 | 167095 | break; |
| 165920 | 167096 | case 170: /* returning ::= RETURNING selcollist */ |
| 165921 | 167097 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy322);} |
| 167098 | + break; |
| 167099 | + case 173: /* idlist_opt ::= */ |
| 167100 | +{yymsp[1].minor.yy254 = 0;} |
| 165922 | 167101 | break; |
| 165923 | 167102 | case 174: /* idlist_opt ::= LP idlist RP */ |
| 165924 | 167103 | {yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;} |
| 165925 | 167104 | break; |
| 165926 | 167105 | case 175: /* idlist ::= idlist COMMA nm */ |
| | @@ -166693,35 +167872,36 @@ |
| 166693 | 167872 | /* (372) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=372); |
| 166694 | 167873 | /* (373) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=373); |
| 166695 | 167874 | /* (374) oneselect ::= values */ yytestcase(yyruleno==374); |
| 166696 | 167875 | /* (375) sclp ::= selcollist COMMA */ yytestcase(yyruleno==375); |
| 166697 | 167876 | /* (376) as ::= ID|STRING */ yytestcase(yyruleno==376); |
| 166698 | | - /* (377) returning ::= */ yytestcase(yyruleno==377); |
| 166699 | | - /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378); |
| 166700 | | - /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379); |
| 166701 | | - /* (380) exprlist ::= nexprlist */ yytestcase(yyruleno==380); |
| 166702 | | - /* (381) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=381); |
| 166703 | | - /* (382) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=382); |
| 166704 | | - /* (383) nmnum ::= ON */ yytestcase(yyruleno==383); |
| 166705 | | - /* (384) nmnum ::= DELETE */ yytestcase(yyruleno==384); |
| 166706 | | - /* (385) nmnum ::= DEFAULT */ yytestcase(yyruleno==385); |
| 166707 | | - /* (386) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==386); |
| 166708 | | - /* (387) foreach_clause ::= */ yytestcase(yyruleno==387); |
| 166709 | | - /* (388) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==388); |
| 166710 | | - /* (389) trnm ::= nm */ yytestcase(yyruleno==389); |
| 166711 | | - /* (390) tridxby ::= */ yytestcase(yyruleno==390); |
| 166712 | | - /* (391) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==391); |
| 166713 | | - /* (392) database_kw_opt ::= */ yytestcase(yyruleno==392); |
| 166714 | | - /* (393) kwcolumn_opt ::= */ yytestcase(yyruleno==393); |
| 166715 | | - /* (394) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==394); |
| 166716 | | - /* (395) vtabarglist ::= vtabarg */ yytestcase(yyruleno==395); |
| 166717 | | - /* (396) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==396); |
| 166718 | | - /* (397) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==397); |
| 166719 | | - /* (398) anylist ::= */ yytestcase(yyruleno==398); |
| 166720 | | - /* (399) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==399); |
| 166721 | | - /* (400) anylist ::= anylist ANY */ yytestcase(yyruleno==400); |
| 166722 | | - /* (401) with ::= */ yytestcase(yyruleno==401); |
| 167877 | + /* (377) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=377); |
| 167878 | + /* (378) returning ::= */ yytestcase(yyruleno==378); |
| 167879 | + /* (379) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=379); |
| 167880 | + /* (380) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==380); |
| 167881 | + /* (381) exprlist ::= nexprlist */ yytestcase(yyruleno==381); |
| 167882 | + /* (382) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=382); |
| 167883 | + /* (383) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=383); |
| 167884 | + /* (384) nmnum ::= ON */ yytestcase(yyruleno==384); |
| 167885 | + /* (385) nmnum ::= DELETE */ yytestcase(yyruleno==385); |
| 167886 | + /* (386) nmnum ::= DEFAULT */ yytestcase(yyruleno==386); |
| 167887 | + /* (387) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==387); |
| 167888 | + /* (388) foreach_clause ::= */ yytestcase(yyruleno==388); |
| 167889 | + /* (389) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==389); |
| 167890 | + /* (390) trnm ::= nm */ yytestcase(yyruleno==390); |
| 167891 | + /* (391) tridxby ::= */ yytestcase(yyruleno==391); |
| 167892 | + /* (392) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==392); |
| 167893 | + /* (393) database_kw_opt ::= */ yytestcase(yyruleno==393); |
| 167894 | + /* (394) kwcolumn_opt ::= */ yytestcase(yyruleno==394); |
| 167895 | + /* (395) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==395); |
| 167896 | + /* (396) vtabarglist ::= vtabarg */ yytestcase(yyruleno==396); |
| 167897 | + /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==397); |
| 167898 | + /* (398) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==398); |
| 167899 | + /* (399) anylist ::= */ yytestcase(yyruleno==399); |
| 167900 | + /* (400) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==400); |
| 167901 | + /* (401) anylist ::= anylist ANY */ yytestcase(yyruleno==401); |
| 167902 | + /* (402) with ::= */ yytestcase(yyruleno==402); |
| 166723 | 167903 | break; |
| 166724 | 167904 | /********** End reduce actions ************************************************/ |
| 166725 | 167905 | }; |
| 166726 | 167906 | assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) ); |
| 166727 | 167907 | yygoto = yyRuleInfoLhs[yyruleno]; |
| | @@ -172889,10 +174069,29 @@ |
| 172889 | 174069 | */ |
| 172890 | 174070 | case SQLITE_TESTCTRL_ASSERT: { |
| 172891 | 174071 | volatile int x = 0; |
| 172892 | 174072 | assert( /*side-effects-ok*/ (x = va_arg(ap,int))!=0 ); |
| 172893 | 174073 | rc = x; |
| 174074 | +#if defined(SQLITE_DEBUG) |
| 174075 | + /* Invoke these debugging routines so that the compiler does not |
| 174076 | + ** issue "defined but not used" warnings. */ |
| 174077 | + if( x==9999 ){ |
| 174078 | + sqlite3ShowExpr(0); |
| 174079 | + sqlite3ShowExpr(0); |
| 174080 | + sqlite3ShowExprList(0); |
| 174081 | + sqlite3ShowIdList(0); |
| 174082 | + sqlite3ShowSrcList(0); |
| 174083 | + sqlite3ShowWith(0); |
| 174084 | + sqlite3ShowUpsert(0); |
| 174085 | + sqlite3ShowTriggerStep(0); |
| 174086 | + sqlite3ShowTriggerStepList(0); |
| 174087 | + sqlite3ShowTrigger(0); |
| 174088 | + sqlite3ShowTriggerList(0); |
| 174089 | + sqlite3ShowWindow(0); |
| 174090 | + sqlite3ShowWinFunc(0); |
| 174091 | + } |
| 174092 | +#endif |
| 172894 | 174093 | break; |
| 172895 | 174094 | } |
| 172896 | 174095 | |
| 172897 | 174096 | |
| 172898 | 174097 | /* |
| | @@ -173150,23 +174349,23 @@ |
| 173150 | 174349 | |
| 173151 | 174350 | /* sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, op, ptr) |
| 173152 | 174351 | ** |
| 173153 | 174352 | ** "ptr" is a pointer to a u32. |
| 173154 | 174353 | ** |
| 173155 | | - ** op==0 Store the current sqlite3SelectTrace in *ptr |
| 173156 | | - ** op==1 Set sqlite3SelectTrace to the value *ptr |
| 174354 | + ** op==0 Store the current sqlite3TreeTrace in *ptr |
| 174355 | + ** op==1 Set sqlite3TreeTrace to the value *ptr |
| 173157 | 174356 | ** op==3 Store the current sqlite3WhereTrace in *ptr |
| 173158 | 174357 | ** op==3 Set sqlite3WhereTrace to the value *ptr |
| 173159 | 174358 | */ |
| 173160 | 174359 | case SQLITE_TESTCTRL_TRACEFLAGS: { |
| 173161 | 174360 | int opTrace = va_arg(ap, int); |
| 173162 | 174361 | u32 *ptr = va_arg(ap, u32*); |
| 173163 | 174362 | switch( opTrace ){ |
| 173164 | | - case 0: *ptr = sqlite3SelectTrace; break; |
| 173165 | | - case 1: sqlite3SelectTrace = *ptr; break; |
| 173166 | | - case 2: *ptr = sqlite3WhereTrace; break; |
| 173167 | | - case 3: sqlite3WhereTrace = *ptr; break; |
| 174363 | + case 0: *ptr = sqlite3TreeTrace; break; |
| 174364 | + case 1: sqlite3TreeTrace = *ptr; break; |
| 174365 | + case 2: *ptr = sqlite3WhereTrace; break; |
| 174366 | + case 3: sqlite3WhereTrace = *ptr; break; |
| 173168 | 174367 | } |
| 173169 | 174368 | break; |
| 173170 | 174369 | } |
| 173171 | 174370 | |
| 173172 | 174371 | /* sqlite3_test_control(SQLITE_TESTCTRL_LOGEST, |
| | @@ -194609,18 +195808,19 @@ |
| 194609 | 195808 | i++; |
| 194610 | 195809 | }else{ |
| 194611 | 195810 | *pzErr = zPath; |
| 194612 | 195811 | return 0; |
| 194613 | 195812 | } |
| 195813 | + testcase( nKey==0 ); |
| 194614 | 195814 | }else{ |
| 194615 | 195815 | zKey = zPath; |
| 194616 | 195816 | for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){} |
| 194617 | 195817 | nKey = i; |
| 194618 | | - } |
| 194619 | | - if( nKey==0 ){ |
| 194620 | | - *pzErr = zPath; |
| 194621 | | - return 0; |
| 195818 | + if( nKey==0 ){ |
| 195819 | + *pzErr = zPath; |
| 195820 | + return 0; |
| 195821 | + } |
| 194622 | 195822 | } |
| 194623 | 195823 | j = 1; |
| 194624 | 195824 | for(;;){ |
| 194625 | 195825 | while( j<=pRoot->n ){ |
| 194626 | 195826 | if( jsonLabelCompare(pRoot+j, zKey, nKey) ){ |
| | @@ -195763,10 +196963,37 @@ |
| 195763 | 196963 | } |
| 195764 | 196964 | } |
| 195765 | 196965 | } |
| 195766 | 196966 | return SQLITE_OK; |
| 195767 | 196967 | } |
| 196968 | + |
| 196969 | +/* Append an object label to the JSON Path being constructed |
| 196970 | +** in pStr. |
| 196971 | +*/ |
| 196972 | +static void jsonAppendObjectPathElement( |
| 196973 | + JsonString *pStr, |
| 196974 | + JsonNode *pNode |
| 196975 | +){ |
| 196976 | + int jj, nn; |
| 196977 | + const char *z; |
| 196978 | + assert( pNode->eType==JSON_STRING ); |
| 196979 | + assert( pNode->jnFlags & JNODE_LABEL ); |
| 196980 | + assert( pNode->eU==1 ); |
| 196981 | + z = pNode->u.zJContent; |
| 196982 | + nn = pNode->n; |
| 196983 | + assert( nn>=2 ); |
| 196984 | + assert( z[0]=='"' ); |
| 196985 | + assert( z[nn-1]=='"' ); |
| 196986 | + if( nn>2 && sqlite3Isalpha(z[1]) ){ |
| 196987 | + for(jj=2; jj<nn-1 && sqlite3Isalnum(z[jj]); jj++){} |
| 196988 | + if( jj==nn-1 ){ |
| 196989 | + z++; |
| 196990 | + nn -= 2; |
| 196991 | + } |
| 196992 | + } |
| 196993 | + jsonPrintf(nn+2, pStr, ".%.*s", nn, z); |
| 196994 | +} |
| 195768 | 196995 | |
| 195769 | 196996 | /* Append the name of the path for element i to pStr |
| 195770 | 196997 | */ |
| 195771 | 196998 | static void jsonEachComputePath( |
| 195772 | 196999 | JsonEachCursor *p, /* The cursor */ |
| | @@ -195788,14 +197015,11 @@ |
| 195788 | 197015 | testcase( pUp->eU==0 ); |
| 195789 | 197016 | jsonPrintf(30, pStr, "[%d]", pUp->u.iKey); |
| 195790 | 197017 | }else{ |
| 195791 | 197018 | assert( pUp->eType==JSON_OBJECT ); |
| 195792 | 197019 | if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--; |
| 195793 | | - assert( pNode->eType==JSON_STRING ); |
| 195794 | | - assert( pNode->jnFlags & JNODE_LABEL ); |
| 195795 | | - assert( pNode->eU==1 ); |
| 195796 | | - jsonPrintf(pNode->n+1, pStr, ".%.*s", pNode->n-2, pNode->u.zJContent+1); |
| 197020 | + jsonAppendObjectPathElement(pStr, pNode); |
| 195797 | 197021 | } |
| 195798 | 197022 | } |
| 195799 | 197023 | |
| 195800 | 197024 | /* Return the value of a column */ |
| 195801 | 197025 | static int jsonEachColumn( |
| | @@ -195862,12 +197086,11 @@ |
| 195862 | 197086 | jsonAppendChar(&x, '$'); |
| 195863 | 197087 | } |
| 195864 | 197088 | if( p->eType==JSON_ARRAY ){ |
| 195865 | 197089 | jsonPrintf(30, &x, "[%d]", p->iRowid); |
| 195866 | 197090 | }else if( p->eType==JSON_OBJECT ){ |
| 195867 | | - assert( pThis->eU==1 ); |
| 195868 | | - jsonPrintf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1); |
| 197091 | + jsonAppendObjectPathElement(&x, pThis); |
| 195869 | 197092 | } |
| 195870 | 197093 | } |
| 195871 | 197094 | jsonResult(&x); |
| 195872 | 197095 | break; |
| 195873 | 197096 | } |
| | @@ -210410,11 +211633,11 @@ |
| 210410 | 211633 | && pIdxInfo->aOrderBy[0].iColumn<=0 |
| 210411 | 211634 | && pIdxInfo->aOrderBy[0].desc==0 |
| 210412 | 211635 | ){ |
| 210413 | 211636 | pIdxInfo->orderByConsumed = 1; |
| 210414 | 211637 | } |
| 210415 | | - sqlite3VtabWriteAll(pIdxInfo); |
| 211638 | + sqlite3VtabUsesAllSchemas(pIdxInfo); |
| 210416 | 211639 | return SQLITE_OK; |
| 210417 | 211640 | } |
| 210418 | 211641 | |
| 210419 | 211642 | /* |
| 210420 | 211643 | ** Open a new dbpagevfs cursor. |
| | @@ -223138,10 +224361,13 @@ |
| 223138 | 224361 | sqlite3Fts5ParseNearsetFree(pNear); |
| 223139 | 224362 | sqlite3Fts5ParsePhraseFree(pPhrase); |
| 223140 | 224363 | }else{ |
| 223141 | 224364 | if( pRet->nPhrase>0 ){ |
| 223142 | 224365 | Fts5ExprPhrase *pLast = pRet->apPhrase[pRet->nPhrase-1]; |
| 224366 | + assert( pParse!=0 ); |
| 224367 | + assert( pParse->apPhrase!=0 ); |
| 224368 | + assert( pParse->nPhrase>=2 ); |
| 223143 | 224369 | assert( pLast==pParse->apPhrase[pParse->nPhrase-2] ); |
| 223144 | 224370 | if( pPhrase->nTerm==0 ){ |
| 223145 | 224371 | fts5ExprPhraseFree(pPhrase); |
| 223146 | 224372 | pRet->nPhrase--; |
| 223147 | 224373 | pParse->nPhrase--; |
| | @@ -234754,11 +235980,11 @@ |
| 234754 | 235980 | int nArg, /* Number of args */ |
| 234755 | 235981 | sqlite3_value **apUnused /* Function arguments */ |
| 234756 | 235982 | ){ |
| 234757 | 235983 | assert( nArg==0 ); |
| 234758 | 235984 | UNUSED_PARAM2(nArg, apUnused); |
| 234759 | | - sqlite3_result_text(pCtx, "fts5: 2022-03-31 11:12:56 f2d9262e4427ab37ba26c004fc7a4790c86c1856d695a6b4ec3e72732ea54c09", -1, SQLITE_TRANSIENT); |
| 235985 | + sqlite3_result_text(pCtx, "fts5: 2022-04-19 15:56:03 b966d52437f08a6759a83a45cafb0d706a8933a8e55dee38ae78166d1a5b3ba4", -1, SQLITE_TRANSIENT); |
| 234760 | 235986 | } |
| 234761 | 235987 | |
| 234762 | 235988 | /* |
| 234763 | 235989 | ** Return true if zName is the extension on one of the shadow tables used |
| 234764 | 235990 | ** by this module. |
| 234765 | 235991 | |