Fossil SCM

Merge updates from trunk.

mistachkin 2016-09-08 20:17 openssl-1.1 merge
Commit fc995eb9d0bc8fd6dc1ddc06205c1215dc296471
+1 -1
--- src/bundle.c
+++ src/bundle.c
@@ -761,11 +761,11 @@
761761
**
762762
** fossil bundle import BUNDLE ?--publish?
763763
**
764764
** Import all content from BUNDLE into the repository. By default, the
765765
** imported files are private and will not sync. Use the --publish
766
-** option makes the import public.
766
+** option to make the import public.
767767
**
768768
** fossil bundle ls BUNDLE
769769
**
770770
** List the contents of BUNDLE on standard output
771771
**
772772
--- src/bundle.c
+++ src/bundle.c
@@ -761,11 +761,11 @@
761 **
762 ** fossil bundle import BUNDLE ?--publish?
763 **
764 ** Import all content from BUNDLE into the repository. By default, the
765 ** imported files are private and will not sync. Use the --publish
766 ** option makes the import public.
767 **
768 ** fossil bundle ls BUNDLE
769 **
770 ** List the contents of BUNDLE on standard output
771 **
772
--- src/bundle.c
+++ src/bundle.c
@@ -761,11 +761,11 @@
761 **
762 ** fossil bundle import BUNDLE ?--publish?
763 **
764 ** Import all content from BUNDLE into the repository. By default, the
765 ** imported files are private and will not sync. Use the --publish
766 ** option to make the import public.
767 **
768 ** fossil bundle ls BUNDLE
769 **
770 ** List the contents of BUNDLE on standard output
771 **
772
+2 -2
--- src/shell.c
+++ src/shell.c
@@ -522,11 +522,11 @@
522522
}
523523
}
524524
#if defined(_WIN32) || defined(WIN32)
525525
/* For interactive input on Windows systems, translate the
526526
** multi-byte characterset characters into UTF-8. */
527
- if( stdin_is_interactive ){
527
+ if( stdin_is_interactive && in==stdin ){
528528
char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);
529529
if( zTrans ){
530530
int nTrans = strlen30(zTrans)+1;
531531
if( nTrans>nLine ){
532532
zLine = realloc(zLine, nTrans);
@@ -4903,11 +4903,11 @@
49034903
while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
49044904
fflush(p->out);
49054905
zLine = one_input_line(in, zLine, nSql>0);
49064906
if( zLine==0 ){
49074907
/* End of input */
4908
- if( stdin_is_interactive ) printf("\n");
4908
+ if( in==0 && stdin_is_interactive ) printf("\n");
49094909
break;
49104910
}
49114911
if( seenInterrupt ){
49124912
if( in!=0 ) break;
49134913
seenInterrupt = 0;
49144914
--- src/shell.c
+++ src/shell.c
@@ -522,11 +522,11 @@
522 }
523 }
524 #if defined(_WIN32) || defined(WIN32)
525 /* For interactive input on Windows systems, translate the
526 ** multi-byte characterset characters into UTF-8. */
527 if( stdin_is_interactive ){
528 char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);
529 if( zTrans ){
530 int nTrans = strlen30(zTrans)+1;
531 if( nTrans>nLine ){
532 zLine = realloc(zLine, nTrans);
@@ -4903,11 +4903,11 @@
4903 while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
4904 fflush(p->out);
4905 zLine = one_input_line(in, zLine, nSql>0);
4906 if( zLine==0 ){
4907 /* End of input */
4908 if( stdin_is_interactive ) printf("\n");
4909 break;
4910 }
4911 if( seenInterrupt ){
4912 if( in!=0 ) break;
4913 seenInterrupt = 0;
4914
--- src/shell.c
+++ src/shell.c
@@ -522,11 +522,11 @@
522 }
523 }
524 #if defined(_WIN32) || defined(WIN32)
525 /* For interactive input on Windows systems, translate the
526 ** multi-byte characterset characters into UTF-8. */
527 if( stdin_is_interactive && in==stdin ){
528 char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);
529 if( zTrans ){
530 int nTrans = strlen30(zTrans)+1;
531 if( nTrans>nLine ){
532 zLine = realloc(zLine, nTrans);
@@ -4903,11 +4903,11 @@
4903 while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
4904 fflush(p->out);
4905 zLine = one_input_line(in, zLine, nSql>0);
4906 if( zLine==0 ){
4907 /* End of input */
4908 if( in==0 && stdin_is_interactive ) printf("\n");
4909 break;
4910 }
4911 if( seenInterrupt ){
4912 if( in!=0 ) break;
4913 seenInterrupt = 0;
4914
+3114 -1690
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -380,11 +380,11 @@
380380
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
381381
** [sqlite_version()] and [sqlite_source_id()].
382382
*/
383383
#define SQLITE_VERSION "3.15.0"
384384
#define SQLITE_VERSION_NUMBER 3015000
385
-#define SQLITE_SOURCE_ID "2016-08-22 20:10:01 7839519349c7371cdb4e16a215eacd27004cbc62"
385
+#define SQLITE_SOURCE_ID "2016-09-07 19:54:24 ddb5f0558c44569913d22781ab78f3e9b58d7aea"
386386
387387
/*
388388
** CAPI3REF: Run-Time Library Version Numbers
389389
** KEYWORDS: sqlite3_version, sqlite3_sourceid
390390
**
@@ -9477,16 +9477,16 @@
94779477
void **ppOut /* OUT: Buffer containing output changeset */
94789478
);
94799479
94809480
94819481
/*
9482
-** Changegroup handle.
9482
+** CAPI3REF: Changegroup Handle
94839483
*/
94849484
typedef struct sqlite3_changegroup sqlite3_changegroup;
94859485
94869486
/*
9487
-** CAPI3REF: Combine two or more changesets into a single changeset.
9487
+** CAPI3REF: Create A New Changegroup Object
94889488
**
94899489
** An sqlite3_changegroup object is used to combine two or more changesets
94909490
** (or patchsets) into a single changeset (or patchset). A single changegroup
94919491
** object may combine changesets or patchsets, but not both. The output is
94929492
** always in the same format as the input.
@@ -9519,10 +9519,12 @@
95199519
** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
95209520
*/
95219521
int sqlite3changegroup_new(sqlite3_changegroup **pp);
95229522
95239523
/*
9524
+** CAPI3REF: Add A Changeset To A Changegroup
9525
+**
95249526
** Add all changes within the changeset (or patchset) in buffer pData (size
95259527
** nData bytes) to the changegroup.
95269528
**
95279529
** If the buffer contains a patchset, then all prior calls to this function
95289530
** on the same changegroup object must also have specified patchsets. Or, if
@@ -9594,10 +9596,12 @@
95949596
** If no error occurs, SQLITE_OK is returned.
95959597
*/
95969598
int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
95979599
95989600
/*
9601
+** CAPI3REF: Obtain A Composite Changeset From A Changegroup
9602
+**
95999603
** Obtain a buffer containing a changeset (or patchset) representing the
96009604
** current contents of the changegroup. If the inputs to the changegroup
96019605
** were themselves changesets, the output is a changeset. Or, if the
96029606
** inputs were patchsets, the output is also a patchset.
96039607
**
@@ -9622,11 +9626,11 @@
96229626
int *pnData, /* OUT: Size of output buffer in bytes */
96239627
void **ppData /* OUT: Pointer to output buffer */
96249628
);
96259629
96269630
/*
9627
-** Delete a changegroup object.
9631
+** CAPI3REF: Delete A Changegroup Object
96289632
*/
96299633
void sqlite3changegroup_delete(sqlite3_changegroup*);
96309634
96319635
/*
96329636
** CAPI3REF: Apply A Changeset To A Database
@@ -11425,14 +11429,16 @@
1142511429
#define TK_AGG_FUNCTION 153
1142611430
#define TK_AGG_COLUMN 154
1142711431
#define TK_UMINUS 155
1142811432
#define TK_UPLUS 156
1142911433
#define TK_REGISTER 157
11430
-#define TK_ASTERISK 158
11431
-#define TK_SPAN 159
11432
-#define TK_SPACE 160
11433
-#define TK_ILLEGAL 161
11434
+#define TK_VECTOR 158
11435
+#define TK_SELECT_COLUMN 159
11436
+#define TK_ASTERISK 160
11437
+#define TK_SPAN 161
11438
+#define TK_SPACE 162
11439
+#define TK_ILLEGAL 163
1143411440
1143511441
/* The token codes above must all fit in 8 bits */
1143611442
#define TKFLG_MASK 0xff
1143711443
1143811444
/* Flags that can be added to a token code when it is not
@@ -12569,17 +12575,17 @@
1256912575
#define OP_Found 31 /* synopsis: key=r[P3@P4] */
1257012576
#define OP_SeekRowid 32 /* synopsis: intkey=r[P3] */
1257112577
#define OP_NotExists 33 /* synopsis: intkey=r[P3] */
1257212578
#define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
1257312579
#define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
12574
-#define OP_Ne 36 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */
12575
-#define OP_Eq 37 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */
12576
-#define OP_Gt 38 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */
12577
-#define OP_Le 39 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */
12578
-#define OP_Lt 40 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */
12579
-#define OP_Ge 41 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */
12580
-#define OP_Last 42
12580
+#define OP_Ne 36 /* same as TK_NE, synopsis: IF r[P3]!=r[P1] */
12581
+#define OP_Eq 37 /* same as TK_EQ, synopsis: IF r[P3]==r[P1] */
12582
+#define OP_Gt 38 /* same as TK_GT, synopsis: IF r[P3]>r[P1] */
12583
+#define OP_Le 39 /* same as TK_LE, synopsis: IF r[P3]<=r[P1] */
12584
+#define OP_Lt 40 /* same as TK_LT, synopsis: IF r[P3]<r[P1] */
12585
+#define OP_Ge 41 /* same as TK_GE, synopsis: IF r[P3]>=r[P1] */
12586
+#define OP_ElseNotEq 42 /* same as TK_ESCAPE */
1258112587
#define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
1258212588
#define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
1258312589
#define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
1258412590
#define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
1258512591
#define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -12586,119 +12592,120 @@
1258612592
#define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
1258712593
#define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
1258812594
#define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
1258912595
#define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
1259012596
#define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
12591
-#define OP_SorterSort 53
12597
+#define OP_Last 53
1259212598
#define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12593
-#define OP_Sort 55
12594
-#define OP_Rewind 56
12595
-#define OP_IdxLE 57 /* synopsis: key=r[P3@P4] */
12596
-#define OP_IdxGT 58 /* synopsis: key=r[P3@P4] */
12597
-#define OP_IdxLT 59 /* synopsis: key=r[P3@P4] */
12598
-#define OP_IdxGE 60 /* synopsis: key=r[P3@P4] */
12599
-#define OP_RowSetRead 61 /* synopsis: r[P3]=rowset(P1) */
12600
-#define OP_RowSetTest 62 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12601
-#define OP_Program 63
12602
-#define OP_FkIfZero 64 /* synopsis: if fkctr[P1]==0 goto P2 */
12603
-#define OP_IfPos 65 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12604
-#define OP_IfNotZero 66 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12605
-#define OP_DecrJumpZero 67 /* synopsis: if (--r[P1])==0 goto P2 */
12606
-#define OP_IncrVacuum 68
12607
-#define OP_VNext 69
12608
-#define OP_Init 70 /* synopsis: Start at P2 */
12609
-#define OP_Return 71
12610
-#define OP_EndCoroutine 72
12611
-#define OP_HaltIfNull 73 /* synopsis: if r[P3]=null halt */
12612
-#define OP_Halt 74
12613
-#define OP_Integer 75 /* synopsis: r[P2]=P1 */
12614
-#define OP_Int64 76 /* synopsis: r[P2]=P4 */
12615
-#define OP_String 77 /* synopsis: r[P2]='P4' (len=P1) */
12616
-#define OP_Null 78 /* synopsis: r[P2..P3]=NULL */
12617
-#define OP_SoftNull 79 /* synopsis: r[P1]=NULL */
12618
-#define OP_Blob 80 /* synopsis: r[P2]=P4 (len=P1) */
12619
-#define OP_Variable 81 /* synopsis: r[P2]=parameter(P1,P4) */
12620
-#define OP_Move 82 /* synopsis: r[P2@P3]=r[P1@P3] */
12621
-#define OP_Copy 83 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12622
-#define OP_SCopy 84 /* synopsis: r[P2]=r[P1] */
12623
-#define OP_IntCopy 85 /* synopsis: r[P2]=r[P1] */
12624
-#define OP_ResultRow 86 /* synopsis: output=r[P1@P2] */
12625
-#define OP_CollSeq 87
12626
-#define OP_Function0 88 /* synopsis: r[P3]=func(r[P2@P5]) */
12627
-#define OP_Function 89 /* synopsis: r[P3]=func(r[P2@P5]) */
12628
-#define OP_AddImm 90 /* synopsis: r[P1]=r[P1]+P2 */
12629
-#define OP_RealAffinity 91
12630
-#define OP_Cast 92 /* synopsis: affinity(r[P1]) */
12631
-#define OP_Permutation 93
12632
-#define OP_Compare 94 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12633
-#define OP_Column 95 /* synopsis: r[P3]=PX */
12634
-#define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */
12599
+#define OP_SorterSort 55
12600
+#define OP_Sort 56
12601
+#define OP_Rewind 57
12602
+#define OP_IdxLE 58 /* synopsis: key=r[P3@P4] */
12603
+#define OP_IdxGT 59 /* synopsis: key=r[P3@P4] */
12604
+#define OP_IdxLT 60 /* synopsis: key=r[P3@P4] */
12605
+#define OP_IdxGE 61 /* synopsis: key=r[P3@P4] */
12606
+#define OP_RowSetRead 62 /* synopsis: r[P3]=rowset(P1) */
12607
+#define OP_RowSetTest 63 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12608
+#define OP_Program 64
12609
+#define OP_FkIfZero 65 /* synopsis: if fkctr[P1]==0 goto P2 */
12610
+#define OP_IfPos 66 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12611
+#define OP_IfNotZero 67 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12612
+#define OP_DecrJumpZero 68 /* synopsis: if (--r[P1])==0 goto P2 */
12613
+#define OP_IncrVacuum 69
12614
+#define OP_VNext 70
12615
+#define OP_Init 71 /* synopsis: Start at P2 */
12616
+#define OP_Return 72
12617
+#define OP_EndCoroutine 73
12618
+#define OP_HaltIfNull 74 /* synopsis: if r[P3]=null halt */
12619
+#define OP_Halt 75
12620
+#define OP_Integer 76 /* synopsis: r[P2]=P1 */
12621
+#define OP_Int64 77 /* synopsis: r[P2]=P4 */
12622
+#define OP_String 78 /* synopsis: r[P2]='P4' (len=P1) */
12623
+#define OP_Null 79 /* synopsis: r[P2..P3]=NULL */
12624
+#define OP_SoftNull 80 /* synopsis: r[P1]=NULL */
12625
+#define OP_Blob 81 /* synopsis: r[P2]=P4 (len=P1) */
12626
+#define OP_Variable 82 /* synopsis: r[P2]=parameter(P1,P4) */
12627
+#define OP_Move 83 /* synopsis: r[P2@P3]=r[P1@P3] */
12628
+#define OP_Copy 84 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12629
+#define OP_SCopy 85 /* synopsis: r[P2]=r[P1] */
12630
+#define OP_IntCopy 86 /* synopsis: r[P2]=r[P1] */
12631
+#define OP_ResultRow 87 /* synopsis: output=r[P1@P2] */
12632
+#define OP_CollSeq 88
12633
+#define OP_Function0 89 /* synopsis: r[P3]=func(r[P2@P5]) */
12634
+#define OP_Function 90 /* synopsis: r[P3]=func(r[P2@P5]) */
12635
+#define OP_AddImm 91 /* synopsis: r[P1]=r[P1]+P2 */
12636
+#define OP_RealAffinity 92
12637
+#define OP_Cast 93 /* synopsis: affinity(r[P1]) */
12638
+#define OP_Permutation 94
12639
+#define OP_Compare 95 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12640
+#define OP_Column 96 /* synopsis: r[P3]=PX */
1263512641
#define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12636
-#define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12637
-#define OP_Count 99 /* synopsis: r[P2]=count() */
12638
-#define OP_ReadCookie 100
12639
-#define OP_SetCookie 101
12640
-#define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
12641
-#define OP_OpenRead 103 /* synopsis: root=P2 iDb=P3 */
12642
-#define OP_OpenWrite 104 /* synopsis: root=P2 iDb=P3 */
12643
-#define OP_OpenAutoindex 105 /* synopsis: nColumn=P2 */
12644
-#define OP_OpenEphemeral 106 /* synopsis: nColumn=P2 */
12645
-#define OP_SorterOpen 107
12646
-#define OP_SequenceTest 108 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12647
-#define OP_OpenPseudo 109 /* synopsis: P3 columns in r[P2] */
12648
-#define OP_Close 110
12649
-#define OP_ColumnsUsed 111
12650
-#define OP_Sequence 112 /* synopsis: r[P2]=cursor[P1].ctr++ */
12651
-#define OP_NewRowid 113 /* synopsis: r[P2]=rowid */
12652
-#define OP_Insert 114 /* synopsis: intkey=r[P3] data=r[P2] */
12653
-#define OP_InsertInt 115 /* synopsis: intkey=P3 data=r[P2] */
12654
-#define OP_Delete 116
12655
-#define OP_ResetCount 117
12656
-#define OP_SorterCompare 118 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12657
-#define OP_SorterData 119 /* synopsis: r[P2]=data */
12658
-#define OP_RowKey 120 /* synopsis: r[P2]=key */
12659
-#define OP_RowData 121 /* synopsis: r[P2]=data */
12660
-#define OP_Rowid 122 /* synopsis: r[P2]=rowid */
12661
-#define OP_NullRow 123
12662
-#define OP_SorterInsert 124
12663
-#define OP_IdxInsert 125 /* synopsis: key=r[P2] */
12664
-#define OP_IdxDelete 126 /* synopsis: key=r[P2@P3] */
12665
-#define OP_Seek 127 /* synopsis: Move P3 to P1.rowid */
12666
-#define OP_IdxRowid 128 /* synopsis: r[P2]=rowid */
12667
-#define OP_Destroy 129
12668
-#define OP_Clear 130
12669
-#define OP_ResetSorter 131
12670
-#define OP_CreateIndex 132 /* synopsis: r[P2]=root iDb=P1 */
12642
+#define OP_Affinity 98 /* synopsis: affinity(r[P1@P2]) */
12643
+#define OP_MakeRecord 99 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12644
+#define OP_Count 100 /* synopsis: r[P2]=count() */
12645
+#define OP_ReadCookie 101
12646
+#define OP_SetCookie 102
12647
+#define OP_ReopenIdx 103 /* synopsis: root=P2 iDb=P3 */
12648
+#define OP_OpenRead 104 /* synopsis: root=P2 iDb=P3 */
12649
+#define OP_OpenWrite 105 /* synopsis: root=P2 iDb=P3 */
12650
+#define OP_OpenAutoindex 106 /* synopsis: nColumn=P2 */
12651
+#define OP_OpenEphemeral 107 /* synopsis: nColumn=P2 */
12652
+#define OP_SorterOpen 108
12653
+#define OP_SequenceTest 109 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12654
+#define OP_OpenPseudo 110 /* synopsis: P3 columns in r[P2] */
12655
+#define OP_Close 111
12656
+#define OP_ColumnsUsed 112
12657
+#define OP_Sequence 113 /* synopsis: r[P2]=cursor[P1].ctr++ */
12658
+#define OP_NewRowid 114 /* synopsis: r[P2]=rowid */
12659
+#define OP_Insert 115 /* synopsis: intkey=r[P3] data=r[P2] */
12660
+#define OP_InsertInt 116 /* synopsis: intkey=P3 data=r[P2] */
12661
+#define OP_Delete 117
12662
+#define OP_ResetCount 118
12663
+#define OP_SorterCompare 119 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12664
+#define OP_SorterData 120 /* synopsis: r[P2]=data */
12665
+#define OP_RowKey 121 /* synopsis: r[P2]=key */
12666
+#define OP_RowData 122 /* synopsis: r[P2]=data */
12667
+#define OP_Rowid 123 /* synopsis: r[P2]=rowid */
12668
+#define OP_NullRow 124
12669
+#define OP_SorterInsert 125
12670
+#define OP_IdxInsert 126 /* synopsis: key=r[P2] */
12671
+#define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */
12672
+#define OP_Seek 128 /* synopsis: Move P3 to P1.rowid */
12673
+#define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */
12674
+#define OP_Destroy 130
12675
+#define OP_Clear 131
12676
+#define OP_ResetSorter 132
1267112677
#define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12672
-#define OP_CreateTable 134 /* synopsis: r[P2]=root iDb=P1 */
12673
-#define OP_ParseSchema 135
12674
-#define OP_LoadAnalysis 136
12675
-#define OP_DropTable 137
12676
-#define OP_DropIndex 138
12677
-#define OP_DropTrigger 139
12678
-#define OP_IntegrityCk 140
12679
-#define OP_RowSetAdd 141 /* synopsis: rowset(P1)=r[P2] */
12680
-#define OP_Param 142
12681
-#define OP_FkCounter 143 /* synopsis: fkctr[P1]+=P2 */
12682
-#define OP_MemMax 144 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12683
-#define OP_OffsetLimit 145 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12684
-#define OP_AggStep0 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12685
-#define OP_AggStep 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12686
-#define OP_AggFinal 148 /* synopsis: accum=r[P1] N=P2 */
12687
-#define OP_Expire 149
12688
-#define OP_TableLock 150 /* synopsis: iDb=P1 root=P2 write=P3 */
12689
-#define OP_VBegin 151
12690
-#define OP_VCreate 152
12691
-#define OP_VDestroy 153
12692
-#define OP_VOpen 154
12693
-#define OP_VColumn 155 /* synopsis: r[P3]=vcolumn(P2) */
12694
-#define OP_VRename 156
12695
-#define OP_Pagecount 157
12696
-#define OP_MaxPgcnt 158
12697
-#define OP_CursorHint 159
12698
-#define OP_Noop 160
12699
-#define OP_Explain 161
12678
+#define OP_CreateIndex 134 /* synopsis: r[P2]=root iDb=P1 */
12679
+#define OP_CreateTable 135 /* synopsis: r[P2]=root iDb=P1 */
12680
+#define OP_ParseSchema 136
12681
+#define OP_LoadAnalysis 137
12682
+#define OP_DropTable 138
12683
+#define OP_DropIndex 139
12684
+#define OP_DropTrigger 140
12685
+#define OP_IntegrityCk 141
12686
+#define OP_RowSetAdd 142 /* synopsis: rowset(P1)=r[P2] */
12687
+#define OP_Param 143
12688
+#define OP_FkCounter 144 /* synopsis: fkctr[P1]+=P2 */
12689
+#define OP_MemMax 145 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12690
+#define OP_OffsetLimit 146 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12691
+#define OP_AggStep0 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12692
+#define OP_AggStep 148 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12693
+#define OP_AggFinal 149 /* synopsis: accum=r[P1] N=P2 */
12694
+#define OP_Expire 150
12695
+#define OP_TableLock 151 /* synopsis: iDb=P1 root=P2 write=P3 */
12696
+#define OP_VBegin 152
12697
+#define OP_VCreate 153
12698
+#define OP_VDestroy 154
12699
+#define OP_VOpen 155
12700
+#define OP_VColumn 156 /* synopsis: r[P3]=vcolumn(P2) */
12701
+#define OP_VRename 157
12702
+#define OP_Pagecount 158
12703
+#define OP_MaxPgcnt 159
12704
+#define OP_CursorHint 160
12705
+#define OP_Noop 161
12706
+#define OP_Explain 162
1270012707
1270112708
/* Properties such as "out2" or "jump" that are specified in
1270212709
** comments following the "case" for each opcode in the vdbe.c
1270312710
** are encoded into bitvectors as follows:
1270412711
*/
@@ -12714,32 +12721,32 @@
1271412721
/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
1271512722
/* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
1271612723
/* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
1271712724
/* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
1271812725
/* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12719
-/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01,\
12720
-/* 64 */ 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02,\
12721
-/* 72 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
12722
-/* 80 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12723
-/* 88 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00,\
12724
-/* 96 */ 0x00, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
12726
+/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b,\
12727
+/* 64 */ 0x01, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01,\
12728
+/* 72 */ 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10,\
12729
+/* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00,\
12730
+/* 88 */ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
12731
+/* 96 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
1272512732
/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12726
-/* 112 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12727
-/* 120 */ 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00,\
12728
-/* 128 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
12729
-/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00,\
12730
-/* 144 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12731
-/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
12732
-/* 160 */ 0x00, 0x00,}
12733
+/* 112 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
12734
+/* 120 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00,\
12735
+/* 128 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10,\
12736
+/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10,\
12737
+/* 144 */ 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,\
12738
+/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
12739
+/* 160 */ 0x00, 0x00, 0x00,}
1273312740
1273412741
/* The sqlite3P2Values() routine is able to run faster if it knows
1273512742
** the value of the largest JUMP opcode. The smaller the maximum
1273612743
** JUMP opcode the better, so the mkopcodeh.tcl script that
1273712744
** generated this include file strives to group all JUMP opcodes
1273812745
** together near the beginning of the list.
1273912746
*/
12740
-#define SQLITE_MX_JUMP_OPCODE 70 /* Maximum JUMP opcode */
12747
+#define SQLITE_MX_JUMP_OPCODE 71 /* Maximum JUMP opcode */
1274112748
1274212749
/************** End of opcodes.h *********************************************/
1274312750
/************** Continuing where we left off in vdbe.h ***********************/
1274412751
1274512752
/*
@@ -14340,10 +14347,11 @@
1434014347
** The SQLITE_NOTNULL flag is a combination of NULLEQ and JUMPIFNULL.
1434114348
** It causes an assert() to fire if either operand to a comparison
1434214349
** operator is NULL. It is added to certain comparison operators to
1434314350
** prove that the operands are always NOT NULL.
1434414351
*/
14352
+#define SQLITE_KEEPNULL 0x08 /* Used by vector == or <> */
1434514353
#define SQLITE_JUMPIFNULL 0x10 /* jumps if either operand is NULL */
1434614354
#define SQLITE_STOREP2 0x20 /* Store result in reg[P2] rather than jump */
1434714355
#define SQLITE_NULLEQ 0x80 /* NULL=NULL */
1434814356
#define SQLITE_NOTNULL 0x90 /* Assert that operands are never NULL */
1434914357
@@ -14904,13 +14912,15 @@
1490414912
int nHeight; /* Height of the tree headed by this node */
1490514913
#endif
1490614914
int iTable; /* TK_COLUMN: cursor number of table holding column
1490714915
** TK_REGISTER: register number
1490814916
** TK_TRIGGER: 1 -> new, 0 -> old
14909
- ** EP_Unlikely: 134217728 times likelihood */
14917
+ ** EP_Unlikely: 134217728 times likelihood
14918
+ ** TK_SELECT: 1st register of result vector */
1491014919
ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
14911
- ** TK_VARIABLE: variable number (always >= 1). */
14920
+ ** TK_VARIABLE: variable number (always >= 1).
14921
+ ** TK_SELECT_COLUMN: column of the result vector */
1491214922
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
1491314923
i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
1491414924
u8 op2; /* TK_REGISTER: original value of Expr.op
1491514925
** TK_COLUMN: the value of p5 for OP_Column
1491614926
** TK_AGG_FUNCTION: nesting depth */
@@ -15387,11 +15397,11 @@
1538715397
** An instance of this object describes where to put of the results of
1538815398
** a SELECT statement.
1538915399
*/
1539015400
struct SelectDest {
1539115401
u8 eDest; /* How to dispose of the results. On of SRT_* above. */
15392
- char affSdst; /* Affinity used when eDest==SRT_Set */
15402
+ char *zAffSdst; /* Affinity used when eDest==SRT_Set */
1539315403
int iSDParm; /* A parameter used by the eDest disposal method */
1539415404
int iSdst; /* Base register where results are written */
1539515405
int nSdst; /* Number of registers allocated */
1539615406
ExprList *pOrderBy; /* Key columns for SRT_Queue and SRT_DistQueue */
1539715407
};
@@ -16119,10 +16129,11 @@
1611916129
SQLITE_PRIVATE void *sqlite3TestTextToPtr(const char*);
1612016130
#endif
1612116131
1612216132
#if defined(SQLITE_DEBUG)
1612316133
SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
16134
+SQLITE_PRIVATE void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);
1612416135
SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
1612516136
SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
1612616137
SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8);
1612716138
#endif
1612816139
@@ -16150,10 +16161,11 @@
1615016161
SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);
1615116162
SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*);
1615216163
SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*);
1615316164
SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
1615416165
SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
16166
+SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
1615516167
SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);
1615616168
SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
1615716169
SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
1615816170
SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
1615916171
SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
@@ -16485,10 +16497,11 @@
1648516497
1648616498
SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3*, Index*);
1648716499
SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int);
1648816500
SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);
1648916501
SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
16502
+SQLITE_PRIVATE char sqlite3TableColumnAffinity(Table*,int);
1649016503
SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);
1649116504
SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8);
1649216505
SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);
1649316506
SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
1649416507
SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
@@ -16550,11 +16563,11 @@
1655016563
SQLITE_PRIVATE void sqlite3AlterFunctions(void);
1655116564
SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
1655216565
SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
1655316566
SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
1655416567
SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);
16555
-SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
16568
+SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
1655616569
SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
1655716570
SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
1655816571
SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
1655916572
SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
1656016573
SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*);
@@ -16604,17 +16617,25 @@
1660416617
SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
1660516618
SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
1660616619
1660716620
SQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);
1660816621
SQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
16622
+
16623
+#ifndef SQLITE_OMIT_SUBQUERY
16624
+SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse*, Expr*);
16625
+#else
16626
+# define sqlite3ExprCheckIN(x,y) SQLITE_OK
16627
+#endif
1660916628
1661016629
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
1661116630
SQLITE_PRIVATE void sqlite3AnalyzeFunctions(void);
16612
-SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(Parse*,Index*,UnpackedRecord**,Expr*,u8,int,int*);
16631
+SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(
16632
+ Parse*,Index*,UnpackedRecord**,Expr*,int,int,int*);
1661316633
SQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);
1661416634
SQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord*);
1661516635
SQLITE_PRIVATE int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);
16636
+SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3*, Index*, int);
1661616637
#endif
1661716638
1661816639
/*
1661916640
** The interface to the LEMON-generated parser
1662016641
*/
@@ -16763,11 +16784,11 @@
1676316784
** Allowed flags for the 3rd parameter to sqlite3FindInIndex().
1676416785
*/
1676516786
#define IN_INDEX_NOOP_OK 0x0001 /* OK to return IN_INDEX_NOOP */
1676616787
#define IN_INDEX_MEMBERSHIP 0x0002 /* IN operator used for membership test */
1676716788
#define IN_INDEX_LOOP 0x0004 /* IN operator used as a loop */
16768
-SQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, u32, int*);
16789
+SQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*);
1676916790
1677016791
SQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
1677116792
SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *);
1677216793
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
1677316794
SQLITE_PRIVATE int sqlite3JournalCreate(sqlite3_file *);
@@ -16868,10 +16889,15 @@
1686816889
1686916890
#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
1687016891
SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
1687116892
#endif
1687216893
16894
+SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr);
16895
+SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);
16896
+SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);
16897
+SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);
16898
+
1687316899
#endif /* SQLITEINT_H */
1687416900
1687516901
/************** End of sqliteInt.h *******************************************/
1687616902
/************** Begin file global.c ******************************************/
1687716903
/*
@@ -25882,11 +25908,11 @@
2588225908
}
2588325909
}
2588425910
2588525911
2588625912
/*
25887
-** Generate a human-readable description of a the Select object.
25913
+** Generate a human-readable description of a Select object.
2588825914
*/
2588925915
SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
2589025916
int n = 0;
2589125917
int cnt = 0;
2589225918
pView = sqlite3TreeViewPush(pView, moreToFollow);
@@ -26212,10 +26238,19 @@
2621226238
case TK_MATCH: {
2621326239
sqlite3TreeViewLine(pView, "MATCH {%d:%d}%s",
2621426240
pExpr->iTable, pExpr->iColumn, zFlgs);
2621526241
sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
2621626242
break;
26243
+ }
26244
+ case TK_VECTOR: {
26245
+ sqlite3TreeViewBareExprList(pView, pExpr->x.pList, "VECTOR");
26246
+ break;
26247
+ }
26248
+ case TK_SELECT_COLUMN: {
26249
+ sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn);
26250
+ sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);
26251
+ break;
2621726252
}
2621826253
default: {
2621926254
sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
2622026255
break;
2622126256
}
@@ -26228,26 +26263,25 @@
2622826263
sqlite3TreeViewLine(pView, "%s%s", zUniOp, zFlgs);
2622926264
sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
2623026265
}
2623126266
sqlite3TreeViewPop(pView);
2623226267
}
26268
+
2623326269
2623426270
/*
2623526271
** Generate a human-readable explanation of an expression list.
2623626272
*/
26237
-SQLITE_PRIVATE void sqlite3TreeViewExprList(
26273
+SQLITE_PRIVATE void sqlite3TreeViewBareExprList(
2623826274
TreeView *pView,
2623926275
const ExprList *pList,
26240
- u8 moreToFollow,
2624126276
const char *zLabel
2624226277
){
26243
- int i;
26244
- pView = sqlite3TreeViewPush(pView, moreToFollow);
2624526278
if( zLabel==0 || zLabel[0]==0 ) zLabel = "LIST";
2624626279
if( pList==0 ){
2624726280
sqlite3TreeViewLine(pView, "%s (empty)", zLabel);
2624826281
}else{
26282
+ int i;
2624926283
sqlite3TreeViewLine(pView, "%s", zLabel);
2625026284
for(i=0; i<pList->nExpr; i++){
2625126285
int j = pList->a[i].u.x.iOrderByCol;
2625226286
if( j ){
2625326287
sqlite3TreeViewPush(pView, 0);
@@ -26255,10 +26289,19 @@
2625526289
}
2625626290
sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);
2625726291
if( j ) sqlite3TreeViewPop(pView);
2625826292
}
2625926293
}
26294
+}
26295
+SQLITE_PRIVATE void sqlite3TreeViewExprList(
26296
+ TreeView *pView,
26297
+ const ExprList *pList,
26298
+ u8 moreToFollow,
26299
+ const char *zLabel
26300
+){
26301
+ pView = sqlite3TreeViewPush(pView, moreToFollow);
26302
+ sqlite3TreeViewBareExprList(pView, pList, zLabel);
2626026303
sqlite3TreeViewPop(pView);
2626126304
}
2626226305
2626326306
#endif /* SQLITE_DEBUG */
2626426307
@@ -29000,17 +29043,17 @@
2900029043
/* 31 */ "Found" OpHelp("key=r[P3@P4]"),
2900129044
/* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"),
2900229045
/* 33 */ "NotExists" OpHelp("intkey=r[P3]"),
2900329046
/* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
2900429047
/* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
29005
- /* 36 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"),
29006
- /* 37 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"),
29007
- /* 38 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"),
29008
- /* 39 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"),
29009
- /* 40 */ "Lt" OpHelp("if r[P1]<r[P3] goto P2"),
29010
- /* 41 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"),
29011
- /* 42 */ "Last" OpHelp(""),
29048
+ /* 36 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
29049
+ /* 37 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
29050
+ /* 38 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
29051
+ /* 39 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
29052
+ /* 40 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
29053
+ /* 41 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
29054
+ /* 42 */ "ElseNotEq" OpHelp(""),
2901229055
/* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
2901329056
/* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
2901429057
/* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
2901529058
/* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
2901629059
/* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -29017,119 +29060,120 @@
2901729060
/* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
2901829061
/* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
2901929062
/* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
2902029063
/* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
2902129064
/* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
29022
- /* 53 */ "SorterSort" OpHelp(""),
29065
+ /* 53 */ "Last" OpHelp(""),
2902329066
/* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
29024
- /* 55 */ "Sort" OpHelp(""),
29025
- /* 56 */ "Rewind" OpHelp(""),
29026
- /* 57 */ "IdxLE" OpHelp("key=r[P3@P4]"),
29027
- /* 58 */ "IdxGT" OpHelp("key=r[P3@P4]"),
29028
- /* 59 */ "IdxLT" OpHelp("key=r[P3@P4]"),
29029
- /* 60 */ "IdxGE" OpHelp("key=r[P3@P4]"),
29030
- /* 61 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
29031
- /* 62 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
29032
- /* 63 */ "Program" OpHelp(""),
29033
- /* 64 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
29034
- /* 65 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
29035
- /* 66 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
29036
- /* 67 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
29037
- /* 68 */ "IncrVacuum" OpHelp(""),
29038
- /* 69 */ "VNext" OpHelp(""),
29039
- /* 70 */ "Init" OpHelp("Start at P2"),
29040
- /* 71 */ "Return" OpHelp(""),
29041
- /* 72 */ "EndCoroutine" OpHelp(""),
29042
- /* 73 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
29043
- /* 74 */ "Halt" OpHelp(""),
29044
- /* 75 */ "Integer" OpHelp("r[P2]=P1"),
29045
- /* 76 */ "Int64" OpHelp("r[P2]=P4"),
29046
- /* 77 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
29047
- /* 78 */ "Null" OpHelp("r[P2..P3]=NULL"),
29048
- /* 79 */ "SoftNull" OpHelp("r[P1]=NULL"),
29049
- /* 80 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29050
- /* 81 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29051
- /* 82 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29052
- /* 83 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29053
- /* 84 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29054
- /* 85 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29055
- /* 86 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29056
- /* 87 */ "CollSeq" OpHelp(""),
29057
- /* 88 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29058
- /* 89 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29059
- /* 90 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29060
- /* 91 */ "RealAffinity" OpHelp(""),
29061
- /* 92 */ "Cast" OpHelp("affinity(r[P1])"),
29062
- /* 93 */ "Permutation" OpHelp(""),
29063
- /* 94 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29064
- /* 95 */ "Column" OpHelp("r[P3]=PX"),
29065
- /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
29067
+ /* 55 */ "SorterSort" OpHelp(""),
29068
+ /* 56 */ "Sort" OpHelp(""),
29069
+ /* 57 */ "Rewind" OpHelp(""),
29070
+ /* 58 */ "IdxLE" OpHelp("key=r[P3@P4]"),
29071
+ /* 59 */ "IdxGT" OpHelp("key=r[P3@P4]"),
29072
+ /* 60 */ "IdxLT" OpHelp("key=r[P3@P4]"),
29073
+ /* 61 */ "IdxGE" OpHelp("key=r[P3@P4]"),
29074
+ /* 62 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
29075
+ /* 63 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
29076
+ /* 64 */ "Program" OpHelp(""),
29077
+ /* 65 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
29078
+ /* 66 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
29079
+ /* 67 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
29080
+ /* 68 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
29081
+ /* 69 */ "IncrVacuum" OpHelp(""),
29082
+ /* 70 */ "VNext" OpHelp(""),
29083
+ /* 71 */ "Init" OpHelp("Start at P2"),
29084
+ /* 72 */ "Return" OpHelp(""),
29085
+ /* 73 */ "EndCoroutine" OpHelp(""),
29086
+ /* 74 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
29087
+ /* 75 */ "Halt" OpHelp(""),
29088
+ /* 76 */ "Integer" OpHelp("r[P2]=P1"),
29089
+ /* 77 */ "Int64" OpHelp("r[P2]=P4"),
29090
+ /* 78 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
29091
+ /* 79 */ "Null" OpHelp("r[P2..P3]=NULL"),
29092
+ /* 80 */ "SoftNull" OpHelp("r[P1]=NULL"),
29093
+ /* 81 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29094
+ /* 82 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29095
+ /* 83 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29096
+ /* 84 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29097
+ /* 85 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29098
+ /* 86 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29099
+ /* 87 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29100
+ /* 88 */ "CollSeq" OpHelp(""),
29101
+ /* 89 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29102
+ /* 90 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29103
+ /* 91 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29104
+ /* 92 */ "RealAffinity" OpHelp(""),
29105
+ /* 93 */ "Cast" OpHelp("affinity(r[P1])"),
29106
+ /* 94 */ "Permutation" OpHelp(""),
29107
+ /* 95 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29108
+ /* 96 */ "Column" OpHelp("r[P3]=PX"),
2906629109
/* 97 */ "String8" OpHelp("r[P2]='P4'"),
29067
- /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29068
- /* 99 */ "Count" OpHelp("r[P2]=count()"),
29069
- /* 100 */ "ReadCookie" OpHelp(""),
29070
- /* 101 */ "SetCookie" OpHelp(""),
29071
- /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29072
- /* 103 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29073
- /* 104 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29074
- /* 105 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29075
- /* 106 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29076
- /* 107 */ "SorterOpen" OpHelp(""),
29077
- /* 108 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29078
- /* 109 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29079
- /* 110 */ "Close" OpHelp(""),
29080
- /* 111 */ "ColumnsUsed" OpHelp(""),
29081
- /* 112 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29082
- /* 113 */ "NewRowid" OpHelp("r[P2]=rowid"),
29083
- /* 114 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29084
- /* 115 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29085
- /* 116 */ "Delete" OpHelp(""),
29086
- /* 117 */ "ResetCount" OpHelp(""),
29087
- /* 118 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29088
- /* 119 */ "SorterData" OpHelp("r[P2]=data"),
29089
- /* 120 */ "RowKey" OpHelp("r[P2]=key"),
29090
- /* 121 */ "RowData" OpHelp("r[P2]=data"),
29091
- /* 122 */ "Rowid" OpHelp("r[P2]=rowid"),
29092
- /* 123 */ "NullRow" OpHelp(""),
29093
- /* 124 */ "SorterInsert" OpHelp(""),
29094
- /* 125 */ "IdxInsert" OpHelp("key=r[P2]"),
29095
- /* 126 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29096
- /* 127 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29097
- /* 128 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29098
- /* 129 */ "Destroy" OpHelp(""),
29099
- /* 130 */ "Clear" OpHelp(""),
29100
- /* 131 */ "ResetSorter" OpHelp(""),
29101
- /* 132 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
29110
+ /* 98 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
29111
+ /* 99 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29112
+ /* 100 */ "Count" OpHelp("r[P2]=count()"),
29113
+ /* 101 */ "ReadCookie" OpHelp(""),
29114
+ /* 102 */ "SetCookie" OpHelp(""),
29115
+ /* 103 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29116
+ /* 104 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29117
+ /* 105 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29118
+ /* 106 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29119
+ /* 107 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29120
+ /* 108 */ "SorterOpen" OpHelp(""),
29121
+ /* 109 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29122
+ /* 110 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29123
+ /* 111 */ "Close" OpHelp(""),
29124
+ /* 112 */ "ColumnsUsed" OpHelp(""),
29125
+ /* 113 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29126
+ /* 114 */ "NewRowid" OpHelp("r[P2]=rowid"),
29127
+ /* 115 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29128
+ /* 116 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29129
+ /* 117 */ "Delete" OpHelp(""),
29130
+ /* 118 */ "ResetCount" OpHelp(""),
29131
+ /* 119 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29132
+ /* 120 */ "SorterData" OpHelp("r[P2]=data"),
29133
+ /* 121 */ "RowKey" OpHelp("r[P2]=key"),
29134
+ /* 122 */ "RowData" OpHelp("r[P2]=data"),
29135
+ /* 123 */ "Rowid" OpHelp("r[P2]=rowid"),
29136
+ /* 124 */ "NullRow" OpHelp(""),
29137
+ /* 125 */ "SorterInsert" OpHelp(""),
29138
+ /* 126 */ "IdxInsert" OpHelp("key=r[P2]"),
29139
+ /* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29140
+ /* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29141
+ /* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29142
+ /* 130 */ "Destroy" OpHelp(""),
29143
+ /* 131 */ "Clear" OpHelp(""),
29144
+ /* 132 */ "ResetSorter" OpHelp(""),
2910229145
/* 133 */ "Real" OpHelp("r[P2]=P4"),
29103
- /* 134 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29104
- /* 135 */ "ParseSchema" OpHelp(""),
29105
- /* 136 */ "LoadAnalysis" OpHelp(""),
29106
- /* 137 */ "DropTable" OpHelp(""),
29107
- /* 138 */ "DropIndex" OpHelp(""),
29108
- /* 139 */ "DropTrigger" OpHelp(""),
29109
- /* 140 */ "IntegrityCk" OpHelp(""),
29110
- /* 141 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29111
- /* 142 */ "Param" OpHelp(""),
29112
- /* 143 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29113
- /* 144 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29114
- /* 145 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29115
- /* 146 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29116
- /* 147 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29117
- /* 148 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29118
- /* 149 */ "Expire" OpHelp(""),
29119
- /* 150 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29120
- /* 151 */ "VBegin" OpHelp(""),
29121
- /* 152 */ "VCreate" OpHelp(""),
29122
- /* 153 */ "VDestroy" OpHelp(""),
29123
- /* 154 */ "VOpen" OpHelp(""),
29124
- /* 155 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29125
- /* 156 */ "VRename" OpHelp(""),
29126
- /* 157 */ "Pagecount" OpHelp(""),
29127
- /* 158 */ "MaxPgcnt" OpHelp(""),
29128
- /* 159 */ "CursorHint" OpHelp(""),
29129
- /* 160 */ "Noop" OpHelp(""),
29130
- /* 161 */ "Explain" OpHelp(""),
29146
+ /* 134 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
29147
+ /* 135 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29148
+ /* 136 */ "ParseSchema" OpHelp(""),
29149
+ /* 137 */ "LoadAnalysis" OpHelp(""),
29150
+ /* 138 */ "DropTable" OpHelp(""),
29151
+ /* 139 */ "DropIndex" OpHelp(""),
29152
+ /* 140 */ "DropTrigger" OpHelp(""),
29153
+ /* 141 */ "IntegrityCk" OpHelp(""),
29154
+ /* 142 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29155
+ /* 143 */ "Param" OpHelp(""),
29156
+ /* 144 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29157
+ /* 145 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29158
+ /* 146 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29159
+ /* 147 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29160
+ /* 148 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29161
+ /* 149 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29162
+ /* 150 */ "Expire" OpHelp(""),
29163
+ /* 151 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29164
+ /* 152 */ "VBegin" OpHelp(""),
29165
+ /* 153 */ "VCreate" OpHelp(""),
29166
+ /* 154 */ "VDestroy" OpHelp(""),
29167
+ /* 155 */ "VOpen" OpHelp(""),
29168
+ /* 156 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29169
+ /* 157 */ "VRename" OpHelp(""),
29170
+ /* 158 */ "Pagecount" OpHelp(""),
29171
+ /* 159 */ "MaxPgcnt" OpHelp(""),
29172
+ /* 160 */ "CursorHint" OpHelp(""),
29173
+ /* 161 */ "Noop" OpHelp(""),
29174
+ /* 162 */ "Explain" OpHelp(""),
2913129175
};
2913229176
return azName[i];
2913329177
}
2913429178
#endif
2913529179
@@ -52964,11 +53008,15 @@
5296453008
** This function may return SQLITE_NOMEM if a memory allocation fails,
5296553009
** or an IO error code if an IO error occurs while rolling back a
5296653010
** savepoint. If no errors occur, SQLITE_OK is returned.
5296753011
*/
5296853012
SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
52969
- int rc = pPager->errCode; /* Return code */
53013
+ int rc = pPager->errCode;
53014
+
53015
+#ifdef SQLITE_ENABLE_ZIPVFS
53016
+ if( op==SAVEPOINT_RELEASE ) rc = SQLITE_OK;
53017
+#endif
5297053018
5297153019
assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
5297253020
assert( iSavepoint>=0 || op==SAVEPOINT_ROLLBACK );
5297353021
5297453022
if( rc==SQLITE_OK && iSavepoint<pPager->nSavepoint ){
@@ -53005,10 +53053,24 @@
5300553053
else if( pagerUseWal(pPager) || isOpen(pPager->jfd) ){
5300653054
PagerSavepoint *pSavepoint = (nNew==0)?0:&pPager->aSavepoint[nNew-1];
5300753055
rc = pagerPlaybackSavepoint(pPager, pSavepoint);
5300853056
assert(rc!=SQLITE_DONE);
5300953057
}
53058
+
53059
+#ifdef SQLITE_ENABLE_ZIPVFS
53060
+ /* If the cache has been modified but the savepoint cannot be rolled
53061
+ ** back journal_mode=off, put the pager in the error state. This way,
53062
+ ** if the VFS used by this pager includes ZipVFS, the entire transaction
53063
+ ** can be rolled back at the ZipVFS level. */
53064
+ else if(
53065
+ pPager->journalMode==PAGER_JOURNALMODE_OFF
53066
+ && pPager->eState>=PAGER_WRITER_CACHEMOD
53067
+ ){
53068
+ pPager->errCode = SQLITE_ABORT;
53069
+ pPager->eState = PAGER_ERROR;
53070
+ }
53071
+#endif
5301053072
}
5301153073
5301253074
return rc;
5301353075
}
5301453076
@@ -68078,11 +68140,10 @@
6807868140
p->pSrcDb = pSrcDb;
6807968141
p->iNext = 1;
6808068142
p->isAttached = 0;
6808168143
6808268144
if( 0==p->pSrc || 0==p->pDest
68083
- || setDestPgsz(p)==SQLITE_NOMEM
6808468145
|| checkReadTransaction(pDestDb, p->pDest)!=SQLITE_OK
6808568146
){
6808668147
/* One (or both) of the named databases did not exist or an OOM
6808768148
** error was hit. Or there is a transaction open on the destination
6808868149
** database. The error has already been written into the pDestDb
@@ -68266,26 +68327,36 @@
6826668327
rc = SQLITE_BUSY;
6826768328
}else{
6826868329
rc = SQLITE_OK;
6826968330
}
6827068331
68271
- /* Lock the destination database, if it is not locked already. */
68272
- if( SQLITE_OK==rc && p->bDestLocked==0
68273
- && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2))
68274
- ){
68275
- p->bDestLocked = 1;
68276
- sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);
68277
- }
68278
-
6827968332
/* If there is no open read-transaction on the source database, open
6828068333
** one now. If a transaction is opened here, then it will be closed
6828168334
** before this function exits.
6828268335
*/
6828368336
if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){
6828468337
rc = sqlite3BtreeBeginTrans(p->pSrc, 0);
6828568338
bCloseTrans = 1;
6828668339
}
68340
+
68341
+ /* If the destination database has not yet been locked (i.e. if this
68342
+ ** is the first call to backup_step() for the current backup operation),
68343
+ ** try to set its page size to the same as the source database. This
68344
+ ** is especially important on ZipVFS systems, as in that case it is
68345
+ ** not possible to create a database file that uses one page size by
68346
+ ** writing to it with another. */
68347
+ if( p->bDestLocked==0 && rc==SQLITE_OK && setDestPgsz(p)==SQLITE_NOMEM ){
68348
+ rc = SQLITE_NOMEM;
68349
+ }
68350
+
68351
+ /* Lock the destination database, if it is not locked already. */
68352
+ if( SQLITE_OK==rc && p->bDestLocked==0
68353
+ && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2))
68354
+ ){
68355
+ p->bDestLocked = 1;
68356
+ sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);
68357
+ }
6828768358
6828868359
/* Do not allow backup if the destination database is in WAL mode
6828968360
** and the page sizes are different between source and destination */
6829068361
pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);
6829168362
pgszDest = sqlite3BtreeGetPageSize(p->pDest);
@@ -70202,25 +70273,29 @@
7020270273
/*
7020370274
** This function is used to allocate and populate UnpackedRecord
7020470275
** structures intended to be compared against sample index keys stored
7020570276
** in the sqlite_stat4 table.
7020670277
**
70207
-** A single call to this function attempts to populates field iVal (leftmost
70208
-** is 0 etc.) of the unpacked record with a value extracted from expression
70209
-** pExpr. Extraction of values is possible if:
70278
+** A single call to this function populates zero or more fields of the
70279
+** record starting with field iVal (fields are numbered from left to
70280
+** right starting with 0). A single field is populated if:
7021070281
**
7021170282
** * (pExpr==0). In this case the value is assumed to be an SQL NULL,
7021270283
**
7021370284
** * The expression is a bound variable, and this is a reprepare, or
7021470285
**
7021570286
** * The sqlite3ValueFromExpr() function is able to extract a value
7021670287
** from the expression (i.e. the expression is a literal value).
7021770288
**
70218
-** If a value can be extracted, the affinity passed as the 5th argument
70219
-** is applied to it before it is copied into the UnpackedRecord. Output
70220
-** parameter *pbOk is set to true if a value is extracted, or false
70221
-** otherwise.
70289
+** Or, if pExpr is a TK_VECTOR, one field is populated for each of the
70290
+** vector components that match either of the two latter criteria listed
70291
+** above.
70292
+**
70293
+** Before any value is appended to the record, the affinity of the
70294
+** corresponding column within index pIdx is applied to it. Before
70295
+** this function returns, output parameter *pnExtract is set to the
70296
+** number of values appended to the record.
7022270297
**
7022370298
** When this function is called, *ppRec must either point to an object
7022470299
** allocated by an earlier call to this function, or must be NULL. If it
7022570300
** is NULL and a value can be successfully extracted, a new UnpackedRecord
7022670301
** is allocated (and *ppRec set to point to it) before returning.
@@ -70232,26 +70307,37 @@
7023270307
SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(
7023370308
Parse *pParse, /* Parse context */
7023470309
Index *pIdx, /* Index being probed */
7023570310
UnpackedRecord **ppRec, /* IN/OUT: Probe record */
7023670311
Expr *pExpr, /* The expression to extract a value from */
70237
- u8 affinity, /* Affinity to use */
70312
+ int nElem, /* Maximum number of values to append */
7023870313
int iVal, /* Array element to populate */
70239
- int *pbOk /* OUT: True if value was extracted */
70314
+ int *pnExtract /* OUT: Values appended to the record */
7024070315
){
70241
- int rc;
70242
- sqlite3_value *pVal = 0;
70243
- struct ValueNewStat4Ctx alloc;
70244
-
70245
- alloc.pParse = pParse;
70246
- alloc.pIdx = pIdx;
70247
- alloc.ppRec = ppRec;
70248
- alloc.iVal = iVal;
70249
-
70250
- rc = stat4ValueFromExpr(pParse, pExpr, affinity, &alloc, &pVal);
70251
- assert( pVal==0 || pVal->db==pParse->db );
70252
- *pbOk = (pVal!=0);
70316
+ int rc = SQLITE_OK;
70317
+ int nExtract = 0;
70318
+
70319
+ if( pExpr==0 || pExpr->op!=TK_SELECT ){
70320
+ int i;
70321
+ struct ValueNewStat4Ctx alloc;
70322
+
70323
+ alloc.pParse = pParse;
70324
+ alloc.pIdx = pIdx;
70325
+ alloc.ppRec = ppRec;
70326
+
70327
+ for(i=0; i<nElem; i++){
70328
+ sqlite3_value *pVal = 0;
70329
+ Expr *pElem = (pExpr ? sqlite3VectorFieldSubexpr(pExpr, i) : 0);
70330
+ u8 aff = sqlite3IndexColumnAffinity(pParse->db, pIdx, iVal+i);
70331
+ alloc.iVal = iVal+i;
70332
+ rc = stat4ValueFromExpr(pParse, pElem, aff, &alloc, &pVal);
70333
+ if( !pVal ) break;
70334
+ nExtract++;
70335
+ }
70336
+ }
70337
+
70338
+ *pnExtract = nExtract;
7025370339
return rc;
7025470340
}
7025570341
7025670342
/*
7025770343
** Attempt to extract a value from expression pExpr using the methods
@@ -71483,16 +71569,25 @@
7148371569
){
7148471570
const char *zOpName;
7148571571
const char *zSynopsis;
7148671572
int nOpName;
7148771573
int ii, jj;
71574
+ char zAlt[50];
7148871575
zOpName = sqlite3OpcodeName(pOp->opcode);
7148971576
nOpName = sqlite3Strlen30(zOpName);
7149071577
if( zOpName[nOpName+1] ){
7149171578
int seenCom = 0;
7149271579
char c;
7149371580
zSynopsis = zOpName += nOpName + 1;
71581
+ if( strncmp(zSynopsis,"IF ",3)==0 ){
71582
+ if( pOp->p5 & SQLITE_STOREP2 ){
71583
+ sqlite3_snprintf(sizeof(zAlt), zAlt, "r[P2] = (%s)", zSynopsis+3);
71584
+ }else{
71585
+ sqlite3_snprintf(sizeof(zAlt), zAlt, "if %s goto P2", zSynopsis+3);
71586
+ }
71587
+ zSynopsis = zAlt;
71588
+ }
7149471589
for(ii=jj=0; jj<nTemp-1 && (c = zSynopsis[ii])!=0; ii++){
7149571590
if( c=='P' ){
7149671591
c = zSynopsis[++ii];
7149771592
if( c=='4' ){
7149871593
sqlite3_snprintf(nTemp-jj, zTemp+jj, "%s", zP4);
@@ -77732,11 +77827,11 @@
7773277827
#endif
7773377828
int rc = SQLITE_OK; /* Value to return */
7773477829
sqlite3 *db = p->db; /* The database */
7773577830
u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
7773677831
u8 encoding = ENC(db); /* The database encoding */
77737
- int iCompare = 0; /* Result of last OP_Compare operation */
77832
+ int iCompare = 0; /* Result of last comparison */
7773877833
unsigned nVmStep = 0; /* Number of virtual machine steps */
7773977834
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
7774077835
unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
7774177836
#endif
7774277837
Mem *aMem = p->aMem; /* Copy of p->aMem */
@@ -78064,11 +78159,11 @@
7806478159
pOp = &aOp[pcDest];
7806578160
break;
7806678161
}
7806778162
7806878163
/* Opcode: HaltIfNull P1 P2 P3 P4 P5
78069
-** Synopsis: if r[P3]=null halt
78164
+** Synopsis: if r[P3]=null halt
7807078165
**
7807178166
** Check the value in register P3. If it is NULL then Halt using
7807278167
** parameter P1, P2, and P4 as if this were a Halt instruction. If the
7807378168
** value in register P3 is not NULL, then this routine is a no-op.
7807478169
** The P5 parameter should be 1.
@@ -78277,11 +78372,11 @@
7827778372
#endif
7827878373
break;
7827978374
}
7828078375
7828178376
/* Opcode: Null P1 P2 P3 * *
78282
-** Synopsis: r[P2..P3]=NULL
78377
+** Synopsis: r[P2..P3]=NULL
7828378378
**
7828478379
** Write a NULL into registers P2. If P3 greater than P2, then also write
7828578380
** NULL into register P3 and every register in between P2 and P3. If P3
7828678381
** is less than P2 (typically P3 is zero) then only register P2 is
7828778382
** set to NULL.
@@ -78306,11 +78401,11 @@
7830678401
}
7830778402
break;
7830878403
}
7830978404
7831078405
/* Opcode: SoftNull P1 * * * *
78311
-** Synopsis: r[P1]=NULL
78406
+** Synopsis: r[P1]=NULL
7831278407
**
7831378408
** Set register P1 to have the value NULL as seen by the OP_MakeRecord
7831478409
** instruction, but do not free any string or blob memory associated with
7831578410
** the register, so that if the value was a string or blob that was
7831678411
** previously copied using OP_SCopy, the copies will continue to be valid.
@@ -78359,11 +78454,11 @@
7835978454
UPDATE_MAX_BLOBSIZE(pOut);
7836078455
break;
7836178456
}
7836278457
7836378458
/* Opcode: Move P1 P2 P3 * *
78364
-** Synopsis: r[P2@P3]=r[P1@P3]
78459
+** Synopsis: r[P2@P3]=r[P1@P3]
7836578460
**
7836678461
** Move the P3 values in register P1..P1+P3-1 over into
7836778462
** registers P2..P2+P3-1. Registers P1..P1+P3-1 are
7836878463
** left holding a NULL. It is an error for register ranges
7836978464
** P1..P1+P3-1 and P2..P2+P3-1 to overlap. It is an error
@@ -78469,11 +78564,11 @@
7846978564
sqlite3VdbeMemSetInt64(pOut, pIn1->u.i);
7847078565
break;
7847178566
}
7847278567
7847378568
/* Opcode: ResultRow P1 P2 * * *
78474
-** Synopsis: output=r[P1@P2]
78569
+** Synopsis: output=r[P1@P2]
7847578570
**
7847678571
** The registers P1 through P1+P2-1 contain a single row of
7847778572
** results. This opcode causes the sqlite3_step() call to terminate
7847878573
** with an SQLITE_ROW return code and it sets up the sqlite3_stmt
7847978574
** structure to provide access to the r(P1)..r(P1+P2-1) values as
@@ -78602,41 +78697,41 @@
7860278697
UPDATE_MAX_BLOBSIZE(pOut);
7860378698
break;
7860478699
}
7860578700
7860678701
/* Opcode: Add P1 P2 P3 * *
78607
-** Synopsis: r[P3]=r[P1]+r[P2]
78702
+** Synopsis: r[P3]=r[P1]+r[P2]
7860878703
**
7860978704
** Add the value in register P1 to the value in register P2
7861078705
** and store the result in register P3.
7861178706
** If either input is NULL, the result is NULL.
7861278707
*/
7861378708
/* Opcode: Multiply P1 P2 P3 * *
78614
-** Synopsis: r[P3]=r[P1]*r[P2]
78709
+** Synopsis: r[P3]=r[P1]*r[P2]
7861578710
**
7861678711
**
7861778712
** Multiply the value in register P1 by the value in register P2
7861878713
** and store the result in register P3.
7861978714
** If either input is NULL, the result is NULL.
7862078715
*/
7862178716
/* Opcode: Subtract P1 P2 P3 * *
78622
-** Synopsis: r[P3]=r[P2]-r[P1]
78717
+** Synopsis: r[P3]=r[P2]-r[P1]
7862378718
**
7862478719
** Subtract the value in register P1 from the value in register P2
7862578720
** and store the result in register P3.
7862678721
** If either input is NULL, the result is NULL.
7862778722
*/
7862878723
/* Opcode: Divide P1 P2 P3 * *
78629
-** Synopsis: r[P3]=r[P2]/r[P1]
78724
+** Synopsis: r[P3]=r[P2]/r[P1]
7863078725
**
7863178726
** Divide the value in register P1 by the value in register P2
7863278727
** and store the result in register P3 (P3=P2/P1). If the value in
7863378728
** register P1 is zero, then the result is NULL. If either input is
7863478729
** NULL, the result is NULL.
7863578730
*/
7863678731
/* Opcode: Remainder P1 P2 P3 * *
78637
-** Synopsis: r[P3]=r[P2]%r[P1]
78732
+** Synopsis: r[P3]=r[P2]%r[P1]
7863878733
**
7863978734
** Compute the remainder after integer register P2 is divided by
7864078735
** register P1 and store the result in register P3.
7864178736
** If the value in register P1 is zero the result is NULL.
7864278737
** If either operand is NULL, the result is NULL.
@@ -78865,33 +78960,33 @@
7886578960
UPDATE_MAX_BLOBSIZE(pCtx->pOut);
7886678961
break;
7886778962
}
7886878963
7886978964
/* Opcode: BitAnd P1 P2 P3 * *
78870
-** Synopsis: r[P3]=r[P1]&r[P2]
78965
+** Synopsis: r[P3]=r[P1]&r[P2]
7887178966
**
7887278967
** Take the bit-wise AND of the values in register P1 and P2 and
7887378968
** store the result in register P3.
7887478969
** If either input is NULL, the result is NULL.
7887578970
*/
7887678971
/* Opcode: BitOr P1 P2 P3 * *
78877
-** Synopsis: r[P3]=r[P1]|r[P2]
78972
+** Synopsis: r[P3]=r[P1]|r[P2]
7887878973
**
7887978974
** Take the bit-wise OR of the values in register P1 and P2 and
7888078975
** store the result in register P3.
7888178976
** If either input is NULL, the result is NULL.
7888278977
*/
7888378978
/* Opcode: ShiftLeft P1 P2 P3 * *
78884
-** Synopsis: r[P3]=r[P2]<<r[P1]
78979
+** Synopsis: r[P3]=r[P2]<<r[P1]
7888578980
**
7888678981
** Shift the integer value in register P2 to the left by the
7888778982
** number of bits specified by the integer in register P1.
7888878983
** Store the result in register P3.
7888978984
** If either input is NULL, the result is NULL.
7889078985
*/
7889178986
/* Opcode: ShiftRight P1 P2 P3 * *
78892
-** Synopsis: r[P3]=r[P2]>>r[P1]
78987
+** Synopsis: r[P3]=r[P2]>>r[P1]
7889378988
**
7889478989
** Shift the integer value in register P2 to the right by the
7889578990
** number of bits specified by the integer in register P1.
7889678991
** Store the result in register P3.
7889778992
** If either input is NULL, the result is NULL.
@@ -78947,11 +79042,11 @@
7894779042
MemSetTypeFlag(pOut, MEM_Int);
7894879043
break;
7894979044
}
7895079045
7895179046
/* Opcode: AddImm P1 P2 * * *
78952
-** Synopsis: r[P1]=r[P1]+P2
79047
+** Synopsis: r[P1]=r[P1]+P2
7895379048
**
7895479049
** Add the constant P2 to the value in register P1.
7895579050
** The result is always an integer.
7895679051
**
7895779052
** To force any register to be an integer, just add 0.
@@ -79039,18 +79134,65 @@
7903979134
if( rc ) goto abort_due_to_error;
7904079135
break;
7904179136
}
7904279137
#endif /* SQLITE_OMIT_CAST */
7904379138
79139
+/* Opcode: Eq P1 P2 P3 P4 P5
79140
+** Synopsis: IF r[P3]==r[P1]
79141
+**
79142
+** Compare the values in register P1 and P3. If reg(P3)==reg(P1) then
79143
+** jump to address P2. Or if the SQLITE_STOREP2 flag is set in P5, then
79144
+** store the result of comparison in register P2.
79145
+**
79146
+** The SQLITE_AFF_MASK portion of P5 must be an affinity character -
79147
+** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made
79148
+** to coerce both inputs according to this affinity before the
79149
+** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric
79150
+** affinity is used. Note that the affinity conversions are stored
79151
+** back into the input registers P1 and P3. So this opcode can cause
79152
+** persistent changes to registers P1 and P3.
79153
+**
79154
+** Once any conversions have taken place, and neither value is NULL,
79155
+** the values are compared. If both values are blobs then memcmp() is
79156
+** used to determine the results of the comparison. If both values
79157
+** are text, then the appropriate collating function specified in
79158
+** P4 is used to do the comparison. If P4 is not specified then
79159
+** memcmp() is used to compare text string. If both values are
79160
+** numeric, then a numeric comparison is used. If the two values
79161
+** are of different types, then numbers are considered less than
79162
+** strings and strings are considered less than blobs.
79163
+**
79164
+** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
79165
+** true or false and is never NULL. If both operands are NULL then the result
79166
+** of comparison is true. If either operand is NULL then the result is false.
79167
+** If neither operand is NULL the result is the same as it would be if
79168
+** the SQLITE_NULLEQ flag were omitted from P5.
79169
+**
79170
+** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the
79171
+** content of r[P2] is only changed if the new value is NULL or 0 (false).
79172
+** In other words, a prior r[P2] value will not be overwritten by 1 (true).
79173
+*/
79174
+/* Opcode: Ne P1 P2 P3 P4 P5
79175
+** Synopsis: IF r[P3]!=r[P1]
79176
+**
79177
+** This works just like the Eq opcode except that the jump is taken if
79178
+** the operands in registers P1 and P3 are not equal. See the Eq opcode for
79179
+** additional information.
79180
+**
79181
+** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the
79182
+** content of r[P2] is only changed if the new value is NULL or 1 (true).
79183
+** In other words, a prior r[P2] value will not be overwritten by 0 (false).
79184
+*/
7904479185
/* Opcode: Lt P1 P2 P3 P4 P5
79045
-** Synopsis: if r[P1]<r[P3] goto P2
79186
+** Synopsis: IF r[P3]<r[P1]
7904679187
**
7904779188
** Compare the values in register P1 and P3. If reg(P3)<reg(P1) then
79048
-** jump to address P2.
79189
+** jump to address P2. Or if the SQLITE_STOREP2 flag is set in P5 store
79190
+** the result of comparison (0 or 1 or NULL) into register P2.
7904979191
**
7905079192
** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or
79051
-** reg(P3) is NULL then take the jump. If the SQLITE_JUMPIFNULL
79193
+** reg(P3) is NULL then the take the jump. If the SQLITE_JUMPIFNULL
7905279194
** bit is clear then fall through if either operand is NULL.
7905379195
**
7905479196
** The SQLITE_AFF_MASK portion of P5 must be an affinity character -
7905579197
** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made
7905679198
** to coerce both inputs according to this affinity before the
@@ -79066,60 +79208,27 @@
7906679208
** P4 is used to do the comparison. If P4 is not specified then
7906779209
** memcmp() is used to compare text string. If both values are
7906879210
** numeric, then a numeric comparison is used. If the two values
7906979211
** are of different types, then numbers are considered less than
7907079212
** strings and strings are considered less than blobs.
79071
-**
79072
-** If the SQLITE_STOREP2 bit of P5 is set, then do not jump. Instead,
79073
-** store a boolean result (either 0, or 1, or NULL) in register P2.
79074
-**
79075
-** If the SQLITE_NULLEQ bit is set in P5, then NULL values are considered
79076
-** equal to one another, provided that they do not have their MEM_Cleared
79077
-** bit set.
79078
-*/
79079
-/* Opcode: Ne P1 P2 P3 P4 P5
79080
-** Synopsis: if r[P1]!=r[P3] goto P2
79081
-**
79082
-** This works just like the Lt opcode except that the jump is taken if
79083
-** the operands in registers P1 and P3 are not equal. See the Lt opcode for
79084
-** additional information.
79085
-**
79086
-** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
79087
-** true or false and is never NULL. If both operands are NULL then the result
79088
-** of comparison is false. If either operand is NULL then the result is true.
79089
-** If neither operand is NULL the result is the same as it would be if
79090
-** the SQLITE_NULLEQ flag were omitted from P5.
79091
-*/
79092
-/* Opcode: Eq P1 P2 P3 P4 P5
79093
-** Synopsis: if r[P1]==r[P3] goto P2
79094
-**
79095
-** This works just like the Lt opcode except that the jump is taken if
79096
-** the operands in registers P1 and P3 are equal.
79097
-** See the Lt opcode for additional information.
79098
-**
79099
-** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
79100
-** true or false and is never NULL. If both operands are NULL then the result
79101
-** of comparison is true. If either operand is NULL then the result is false.
79102
-** If neither operand is NULL the result is the same as it would be if
79103
-** the SQLITE_NULLEQ flag were omitted from P5.
7910479213
*/
7910579214
/* Opcode: Le P1 P2 P3 P4 P5
79106
-** Synopsis: if r[P1]<=r[P3] goto P2
79215
+** Synopsis: IF r[P3]<=r[P1]
7910779216
**
7910879217
** This works just like the Lt opcode except that the jump is taken if
7910979218
** the content of register P3 is less than or equal to the content of
7911079219
** register P1. See the Lt opcode for additional information.
7911179220
*/
7911279221
/* Opcode: Gt P1 P2 P3 P4 P5
79113
-** Synopsis: if r[P1]>r[P3] goto P2
79222
+** Synopsis: IF r[P3]>r[P1]
7911479223
**
7911579224
** This works just like the Lt opcode except that the jump is taken if
7911679225
** the content of register P3 is greater than the content of
7911779226
** register P1. See the Lt opcode for additional information.
7911879227
*/
7911979228
/* Opcode: Ge P1 P2 P3 P4 P5
79120
-** Synopsis: if r[P1]>=r[P3] goto P2
79229
+** Synopsis: IF r[P3]>=r[P1]
7912179230
**
7912279231
** This works just like the Lt opcode except that the jump is taken if
7912379232
** the content of register P3 is greater than or equal to the content of
7912479233
** register P1. See the Lt opcode for additional information.
7912579234
*/
@@ -79127,11 +79236,11 @@
7912779236
case OP_Ne: /* same as TK_NE, jump, in1, in3 */
7912879237
case OP_Lt: /* same as TK_LT, jump, in1, in3 */
7912979238
case OP_Le: /* same as TK_LE, jump, in1, in3 */
7913079239
case OP_Gt: /* same as TK_GT, jump, in1, in3 */
7913179240
case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
79132
- int res; /* Result of the comparison of pIn1 against pIn3 */
79241
+ int res, res2; /* Result of the comparison of pIn1 against pIn3 */
7913379242
char affinity; /* Affinity to use for comparison */
7913479243
u16 flags1; /* Copy of initial value of pIn1->flags */
7913579244
u16 flags3; /* Copy of initial value of pIn3->flags */
7913679245
7913779246
pIn1 = &aMem[pOp->p1];
@@ -79150,21 +79259,22 @@
7915079259
assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 );
7915179260
if( (flags1&MEM_Null)!=0
7915279261
&& (flags3&MEM_Null)!=0
7915379262
&& (flags3&MEM_Cleared)==0
7915479263
){
79155
- res = 0; /* Results are equal */
79264
+ res = 0; /* Operands are equal */
7915679265
}else{
79157
- res = 1; /* Results are not equal */
79266
+ res = 1; /* Operands are not equal */
7915879267
}
7915979268
}else{
7916079269
/* SQLITE_NULLEQ is clear and at least one operand is NULL,
7916179270
** then the result is always NULL.
7916279271
** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
7916379272
*/
7916479273
if( pOp->p5 & SQLITE_STOREP2 ){
7916579274
pOut = &aMem[pOp->p2];
79275
+ iCompare = 1; /* Operands are not equal */
7916679276
memAboutToChange(p, pOut);
7916779277
MemSetTypeFlag(pOut, MEM_Null);
7916879278
REGISTER_TRACE(pOp->p2, pOut);
7916979279
}else{
7917079280
VdbeBranchTaken(2,3);
@@ -79214,16 +79324,16 @@
7921479324
flags3 &= ~MEM_Zero;
7921579325
}
7921679326
res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
7921779327
}
7921879328
switch( pOp->opcode ){
79219
- case OP_Eq: res = res==0; break;
79220
- case OP_Ne: res = res!=0; break;
79221
- case OP_Lt: res = res<0; break;
79222
- case OP_Le: res = res<=0; break;
79223
- case OP_Gt: res = res>0; break;
79224
- default: res = res>=0; break;
79329
+ case OP_Eq: res2 = res==0; break;
79330
+ case OP_Ne: res2 = res; break;
79331
+ case OP_Lt: res2 = res<0; break;
79332
+ case OP_Le: res2 = res<=0; break;
79333
+ case OP_Gt: res2 = res>0; break;
79334
+ default: res2 = res>=0; break;
7922579335
}
7922679336
7922779337
/* Undo any changes made by applyAffinity() to the input registers. */
7922879338
assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
7922979339
pIn1->flags = flags1;
@@ -79230,22 +79340,58 @@
7923079340
assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );
7923179341
pIn3->flags = flags3;
7923279342
7923379343
if( pOp->p5 & SQLITE_STOREP2 ){
7923479344
pOut = &aMem[pOp->p2];
79345
+ iCompare = res;
79346
+ res2 = res2!=0; /* For this path res2 must be exactly 0 or 1 */
79347
+ if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){
79348
+ /* The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1
79349
+ ** and prevents OP_Ne from overwriting NULL with 0. This flag
79350
+ ** is only used in contexts where either:
79351
+ ** (1) op==OP_Eq && (r[P2]==NULL || r[P2]==0)
79352
+ ** (2) op==OP_Ne && (r[P2]==NULL || r[P2]==1)
79353
+ ** Therefore it is not necessary to check the content of r[P2] for
79354
+ ** NULL. */
79355
+ assert( pOp->opcode==OP_Ne || pOp->opcode==OP_Eq );
79356
+ assert( res2==0 || res2==1 );
79357
+ testcase( res2==0 && pOp->opcode==OP_Eq );
79358
+ testcase( res2==1 && pOp->opcode==OP_Eq );
79359
+ testcase( res2==0 && pOp->opcode==OP_Ne );
79360
+ testcase( res2==1 && pOp->opcode==OP_Ne );
79361
+ if( (pOp->opcode==OP_Eq)==res2 ) break;
79362
+ }
7923579363
memAboutToChange(p, pOut);
7923679364
MemSetTypeFlag(pOut, MEM_Int);
79237
- pOut->u.i = res;
79365
+ pOut->u.i = res2;
7923879366
REGISTER_TRACE(pOp->p2, pOut);
7923979367
}else{
7924079368
VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
79241
- if( res ){
79369
+ if( res2 ){
7924279370
goto jump_to_p2;
7924379371
}
7924479372
}
7924579373
break;
7924679374
}
79375
+
79376
+/* Opcode: ElseNotEq * P2 * * *
79377
+**
79378
+** This opcode must immediately follow an Lt or Gt comparison operator.
79379
+** If the operands in that previous comparison had been used with an Eq
79380
+** operator and if the result of that Eq would be NULL or false (0), then
79381
+** then jump to P2. If the result of comparing the two previous operands
79382
+** using Eq would have been true (1), then fall through.
79383
+*/
79384
+case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */
79385
+ assert( pOp>aOp );
79386
+ assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt );
79387
+ assert( pOp[-1].p5 & SQLITE_STOREP2 );
79388
+ VdbeBranchTaken(iCompare!=0, 2);
79389
+ if( iCompare!=0 ) goto jump_to_p2;
79390
+ break;
79391
+}
79392
+
7924779393
7924879394
/* Opcode: Permutation * * * P4 *
7924979395
**
7925079396
** Set the permutation used by the OP_Compare operator to be the array
7925179397
** of integers in P4.
@@ -79492,11 +79638,11 @@
7949279638
}
7949379639
break;
7949479640
}
7949579641
7949679642
/* Opcode: IsNull P1 P2 * * *
79497
-** Synopsis: if r[P1]==NULL goto P2
79643
+** Synopsis: if r[P1]==NULL goto P2
7949879644
**
7949979645
** Jump to P2 if the value in register P1 is NULL.
7950079646
*/
7950179647
case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */
7950279648
pIn1 = &aMem[pOp->p1];
@@ -79520,11 +79666,11 @@
7952079666
}
7952179667
break;
7952279668
}
7952379669
7952479670
/* Opcode: Column P1 P2 P3 P4 P5
79525
-** Synopsis: r[P3]=PX
79671
+** Synopsis: r[P3]=PX
7952679672
**
7952779673
** Interpret the data that cursor P1 points to as a structure built using
7952879674
** the MakeRecord instruction. (See the MakeRecord opcode for additional
7952979675
** information about the format of the data.) Extract the P2-th column
7953079676
** from this record. If there are less that (P2+1)
@@ -81030,11 +81176,10 @@
8103081176
assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
8103181177
pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */
8103281178
}
8103381179
break;
8103481180
}
81035
-
8103681181
8103781182
/* Opcode: Found P1 P2 P3 P4 *
8103881183
** Synopsis: key=r[P3@P4]
8103981184
**
8104081185
** If P4==0 then register P3 holds a blob constructed by MakeRecord. If
@@ -81463,11 +81608,11 @@
8146381608
**
8146481609
** This instruction only works on tables. The equivalent instruction
8146581610
** for indices is OP_IdxInsert.
8146681611
*/
8146781612
/* Opcode: InsertInt P1 P2 P3 P4 P5
81468
-** Synopsis: intkey=P3 data=r[P2]
81613
+** Synopsis: intkey=P3 data=r[P2]
8146981614
**
8147081615
** This works exactly like OP_Insert except that the key is the
8147181616
** integer value P3, not the value of the integer stored in register P3.
8147281617
*/
8147381618
case OP_Insert:
@@ -81694,11 +81839,11 @@
8169481839
p->nChange = 0;
8169581840
break;
8169681841
}
8169781842
8169881843
/* Opcode: SorterCompare P1 P2 P3 P4
81699
-** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2
81844
+** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2
8170081845
**
8170181846
** P1 is a sorter cursor. This instruction compares a prefix of the
8170281847
** record blob in register P3 against a prefix of the entry that
8170381848
** the sorter cursor currently points to. Only the first P4 fields
8170481849
** of r[P3] and the sorter record are compared.
@@ -82221,11 +82366,11 @@
8222182366
pC->cacheStatus = CACHE_STALE;
8222282367
break;
8222382368
}
8222482369
8222582370
/* Opcode: Seek P1 * P3 P4 *
82226
-** Synopsis: Move P3 to P1.rowid
82371
+** Synopsis: Move P3 to P1.rowid
8222782372
**
8222882373
** P1 is an open index cursor and P3 is a cursor on the corresponding
8222982374
** table. This opcode does a deferred seek of the P3 table cursor
8223082375
** to the row that corresponds to the current row of P1.
8223182376
**
@@ -82728,11 +82873,11 @@
8272882873
break;
8272982874
}
8273082875
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */
8273182876
8273282877
/* Opcode: RowSetAdd P1 P2 * * *
82733
-** Synopsis: rowset(P1)=r[P2]
82878
+** Synopsis: rowset(P1)=r[P2]
8273482879
**
8273582880
** Insert the integer value held by register P2 into a boolean index
8273682881
** held in register P1.
8273782882
**
8273882883
** An assertion fails if P2 is not an integer.
@@ -82748,11 +82893,11 @@
8274882893
sqlite3RowSetInsert(pIn1->u.pRowSet, pIn2->u.i);
8274982894
break;
8275082895
}
8275182896
8275282897
/* Opcode: RowSetRead P1 P2 P3 * *
82753
-** Synopsis: r[P3]=rowset(P1)
82898
+** Synopsis: r[P3]=rowset(P1)
8275482899
**
8275582900
** Extract the smallest value from boolean index P1 and put that value into
8275682901
** register P3. Or, if boolean index P1 is initially empty, leave P3
8275782902
** unchanged and jump to instruction P2.
8275882903
*/
@@ -83927,11 +84072,11 @@
8392784072
}
8392884073
#endif
8392984074
8393084075
8393184076
/* Opcode: Init * P2 * P4 *
83932
-** Synopsis: Start at P2
84077
+** Synopsis: Start at P2
8393384078
**
8393484079
** Programs contain a single instance of this opcode as the very first
8393584080
** opcode.
8393684081
**
8393784082
** If tracing is enabled (by the sqlite3_trace()) interface, then
@@ -83987,12 +84132,12 @@
8398784132
){
8398884133
sqlite3DebugPrintf("SQL-trace: %s\n", zTrace);
8398984134
}
8399084135
#endif /* SQLITE_DEBUG */
8399184136
#endif /* SQLITE_OMIT_TRACE */
83992
- if( pOp->p2 ) goto jump_to_p2;
83993
- break;
84137
+ assert( pOp->p2>0 );
84138
+ goto jump_to_p2;
8399484139
}
8399584140
8399684141
#ifdef SQLITE_ENABLE_CURSOR_HINTS
8399784142
/* Opcode: CursorHint P1 * * P4 *
8399884143
**
@@ -88760,10 +88905,37 @@
8876088905
}
8876188906
case TK_VARIABLE: {
8876288907
notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
8876388908
break;
8876488909
}
88910
+ case TK_EQ:
88911
+ case TK_NE:
88912
+ case TK_LT:
88913
+ case TK_LE:
88914
+ case TK_GT:
88915
+ case TK_GE:
88916
+ case TK_IS:
88917
+ case TK_ISNOT: {
88918
+ int nLeft, nRight;
88919
+ if( pParse->db->mallocFailed ) break;
88920
+ assert( pExpr->pRight!=0 );
88921
+ assert( pExpr->pLeft!=0 );
88922
+ nLeft = sqlite3ExprVectorSize(pExpr->pLeft);
88923
+ nRight = sqlite3ExprVectorSize(pExpr->pRight);
88924
+ if( nLeft!=nRight ){
88925
+ testcase( pExpr->op==TK_EQ );
88926
+ testcase( pExpr->op==TK_NE );
88927
+ testcase( pExpr->op==TK_LT );
88928
+ testcase( pExpr->op==TK_LE );
88929
+ testcase( pExpr->op==TK_GT );
88930
+ testcase( pExpr->op==TK_GE );
88931
+ testcase( pExpr->op==TK_IS );
88932
+ testcase( pExpr->op==TK_ISNOT );
88933
+ sqlite3ErrorMsg(pParse, "row value misused");
88934
+ }
88935
+ break;
88936
+ }
8876588937
}
8876688938
return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
8876788939
}
8876888940
8876988941
/*
@@ -89501,10 +89673,22 @@
8950189673
*************************************************************************
8950289674
** This file contains routines used for analyzing expressions and
8950389675
** for generating VDBE code that evaluates expressions in SQLite.
8950489676
*/
8950589677
/* #include "sqliteInt.h" */
89678
+
89679
+/* Forward declarations */
89680
+static void exprCodeBetween(Parse*,Expr*,int,void(*)(Parse*,Expr*,int,int),int);
89681
+static int exprCodeVector(Parse *pParse, Expr *p, int *piToFree);
89682
+
89683
+/*
89684
+** Return the affinity character for a single column of a table.
89685
+*/
89686
+SQLITE_PRIVATE char sqlite3TableColumnAffinity(Table *pTab, int iCol){
89687
+ assert( iCol<pTab->nCol );
89688
+ return iCol>=0 ? pTab->aCol[iCol].affinity : SQLITE_AFF_INTEGER;
89689
+}
8950689690
8950789691
/*
8950889692
** Return the 'affinity' of the expression pExpr if any.
8950989693
**
8951089694
** If pExpr is a column, a reference to a column via an 'AS' alias,
@@ -89527,25 +89711,25 @@
8952789711
op = pExpr->op;
8952889712
if( op==TK_SELECT ){
8952989713
assert( pExpr->flags&EP_xIsSelect );
8953089714
return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
8953189715
}
89716
+ if( op==TK_REGISTER ) op = pExpr->op2;
8953289717
#ifndef SQLITE_OMIT_CAST
8953389718
if( op==TK_CAST ){
8953489719
assert( !ExprHasProperty(pExpr, EP_IntValue) );
8953589720
return sqlite3AffinityType(pExpr->u.zToken, 0);
8953689721
}
8953789722
#endif
89538
- if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_REGISTER)
89539
- && pExpr->pTab!=0
89540
- ){
89541
- /* op==TK_REGISTER && pExpr->pTab!=0 happens when pExpr was originally
89542
- ** a TK_COLUMN but was previously evaluated and cached in a register */
89543
- int j = pExpr->iColumn;
89544
- if( j<0 ) return SQLITE_AFF_INTEGER;
89545
- assert( pExpr->pTab && j<pExpr->pTab->nCol );
89546
- return pExpr->pTab->aCol[j].affinity;
89723
+ if( op==TK_AGG_COLUMN || op==TK_COLUMN ){
89724
+ return sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn);
89725
+ }
89726
+ if( op==TK_SELECT_COLUMN ){
89727
+ assert( pExpr->pLeft->flags&EP_xIsSelect );
89728
+ return sqlite3ExprAffinity(
89729
+ pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
89730
+ );
8954789731
}
8954889732
return pExpr->affinity;
8954989733
}
8955089734
8955189735
/*
@@ -89707,11 +89891,11 @@
8970789891
aff = sqlite3ExprAffinity(pExpr->pLeft);
8970889892
if( pExpr->pRight ){
8970989893
aff = sqlite3CompareAffinity(pExpr->pRight, aff);
8971089894
}else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
8971189895
aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);
89712
- }else if( !aff ){
89896
+ }else if( NEVER(aff==0) ){
8971389897
aff = SQLITE_AFF_BLOB;
8971489898
}
8971589899
return aff;
8971689900
}
8971789901
@@ -89796,10 +89980,274 @@
8979689980
addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
8979789981
(void*)p4, P4_COLLSEQ);
8979889982
sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
8979989983
return addr;
8980089984
}
89985
+
89986
+/*
89987
+** Return true if expression pExpr is a vector, or false otherwise.
89988
+**
89989
+** A vector is defined as any expression that results in two or more
89990
+** columns of result. Every TK_VECTOR node is an vector because the
89991
+** parser will not generate a TK_VECTOR with fewer than two entries.
89992
+** But a TK_SELECT might be either a vector or a scalar. It is only
89993
+** considered a vector if it has two or more result columns.
89994
+*/
89995
+SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr){
89996
+ return sqlite3ExprVectorSize(pExpr)>1;
89997
+}
89998
+
89999
+/*
90000
+** If the expression passed as the only argument is of type TK_VECTOR
90001
+** return the number of expressions in the vector. Or, if the expression
90002
+** is a sub-select, return the number of columns in the sub-select. For
90003
+** any other type of expression, return 1.
90004
+*/
90005
+SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr){
90006
+ u8 op = pExpr->op;
90007
+ if( op==TK_REGISTER ) op = pExpr->op2;
90008
+ if( op==TK_VECTOR ){
90009
+ return pExpr->x.pList->nExpr;
90010
+ }else if( op==TK_SELECT ){
90011
+ return pExpr->x.pSelect->pEList->nExpr;
90012
+ }else{
90013
+ return 1;
90014
+ }
90015
+}
90016
+
90017
+#ifndef SQLITE_OMIT_SUBQUERY
90018
+/*
90019
+** Return a pointer to a subexpression of pVector that is the i-th
90020
+** column of the vector (numbered starting with 0). The caller must
90021
+** ensure that i is within range.
90022
+**
90023
+** If pVector is really a scalar (and "scalar" here includes subqueries
90024
+** that return a single column!) then return pVector unmodified.
90025
+**
90026
+** pVector retains ownership of the returned subexpression.
90027
+**
90028
+** If the vector is a (SELECT ...) then the expression returned is
90029
+** just the expression for the i-th term of the result set, and may
90030
+** not be ready for evaluation because the table cursor has not yet
90031
+** been positioned.
90032
+*/
90033
+SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){
90034
+ assert( i<sqlite3ExprVectorSize(pVector) );
90035
+ if( sqlite3ExprIsVector(pVector) ){
90036
+ assert( pVector->op2==0 || pVector->op==TK_REGISTER );
90037
+ if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){
90038
+ return pVector->x.pSelect->pEList->a[i].pExpr;
90039
+ }else{
90040
+ return pVector->x.pList->a[i].pExpr;
90041
+ }
90042
+ }
90043
+ return pVector;
90044
+}
90045
+#endif /* !defined(SQLITE_OMIT_SUBQUERY) */
90046
+
90047
+#ifndef SQLITE_OMIT_SUBQUERY
90048
+/*
90049
+** Compute and return a new Expr object which when passed to
90050
+** sqlite3ExprCode() will generate all necessary code to compute
90051
+** the iField-th column of the vector expression pVector.
90052
+**
90053
+** It is ok for pVector to be a scalar (as long as iField==0).
90054
+** In that case, this routine works like sqlite3ExprDup().
90055
+**
90056
+** The caller owns the returned Expr object and is responsible for
90057
+** ensuring that the returned value eventually gets freed.
90058
+**
90059
+** The caller retains ownership of pVector. If pVector is a TK_SELECT,
90060
+** then the returned object will reference pVector and so pVector must remain
90061
+** valid for the life of the returned object. If pVector is a TK_VECTOR
90062
+** or a scalar expression, then it can be deleted as soon as this routine
90063
+** returns.
90064
+**
90065
+** A trick to cause a TK_SELECT pVector to be deleted together with
90066
+** the returned Expr object is to attach the pVector to the pRight field
90067
+** of the returned TK_SELECT_COLUMN Expr object.
90068
+*/
90069
+SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(
90070
+ Parse *pParse, /* Parsing context */
90071
+ Expr *pVector, /* The vector. List of expressions or a sub-SELECT */
90072
+ int iField /* Which column of the vector to return */
90073
+){
90074
+ Expr *pRet;
90075
+ if( pVector->op==TK_SELECT ){
90076
+ assert( pVector->flags & EP_xIsSelect );
90077
+ /* The TK_SELECT_COLUMN Expr node:
90078
+ **
90079
+ ** pLeft: pVector containing TK_SELECT
90080
+ ** pRight: not used. But recursively deleted.
90081
+ ** iColumn: Index of a column in pVector
90082
+ ** pLeft->iTable: First in an array of register holding result, or 0
90083
+ ** if the result is not yet computed.
90084
+ **
90085
+ ** sqlite3ExprDelete() specifically skips the recursive delete of
90086
+ ** pLeft on TK_SELECT_COLUMN nodes. But pRight is followed, so pVector
90087
+ ** can be attached to pRight to cause this node to take ownership of
90088
+ ** pVector. Typically there will be multiple TK_SELECT_COLUMN nodes
90089
+ ** with the same pLeft pointer to the pVector, but only one of them
90090
+ ** will own the pVector.
90091
+ */
90092
+ pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0, 0);
90093
+ if( pRet ){
90094
+ pRet->iColumn = iField;
90095
+ pRet->pLeft = pVector;
90096
+ }
90097
+ assert( pRet==0 || pRet->iTable==0 );
90098
+ }else{
90099
+ if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
90100
+ pRet = sqlite3ExprDup(pParse->db, pVector, 0);
90101
+ }
90102
+ return pRet;
90103
+}
90104
+#endif /* !define(SQLITE_OMIT_SUBQUERY) */
90105
+
90106
+/*
90107
+** If expression pExpr is of type TK_SELECT, generate code to evaluate
90108
+** it. Return the register in which the result is stored (or, if the
90109
+** sub-select returns more than one column, the first in an array
90110
+** of registers in which the result is stored).
90111
+**
90112
+** If pExpr is not a TK_SELECT expression, return 0.
90113
+*/
90114
+static int exprCodeSubselect(Parse *pParse, Expr *pExpr){
90115
+ int reg = 0;
90116
+#ifndef SQLITE_OMIT_SUBQUERY
90117
+ if( pExpr->op==TK_SELECT ){
90118
+ reg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
90119
+ }
90120
+#endif
90121
+ return reg;
90122
+}
90123
+
90124
+/*
90125
+** Argument pVector points to a vector expression - either a TK_VECTOR
90126
+** or TK_SELECT that returns more than one column. This function returns
90127
+** the register number of a register that contains the value of
90128
+** element iField of the vector.
90129
+**
90130
+** If pVector is a TK_SELECT expression, then code for it must have
90131
+** already been generated using the exprCodeSubselect() routine. In this
90132
+** case parameter regSelect should be the first in an array of registers
90133
+** containing the results of the sub-select.
90134
+**
90135
+** If pVector is of type TK_VECTOR, then code for the requested field
90136
+** is generated. In this case (*pRegFree) may be set to the number of
90137
+** a temporary register to be freed by the caller before returning.
90138
+**
90139
+** Before returning, output parameter (*ppExpr) is set to point to the
90140
+** Expr object corresponding to element iElem of the vector.
90141
+*/
90142
+static int exprVectorRegister(
90143
+ Parse *pParse, /* Parse context */
90144
+ Expr *pVector, /* Vector to extract element from */
90145
+ int iField, /* Field to extract from pVector */
90146
+ int regSelect, /* First in array of registers */
90147
+ Expr **ppExpr, /* OUT: Expression element */
90148
+ int *pRegFree /* OUT: Temp register to free */
90149
+){
90150
+ u8 op = pVector->op;
90151
+ assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT );
90152
+ if( op==TK_REGISTER ){
90153
+ *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField);
90154
+ return pVector->iTable+iField;
90155
+ }
90156
+ if( op==TK_SELECT ){
90157
+ *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;
90158
+ return regSelect+iField;
90159
+ }
90160
+ *ppExpr = pVector->x.pList->a[iField].pExpr;
90161
+ return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);
90162
+}
90163
+
90164
+/*
90165
+** Expression pExpr is a comparison between two vector values. Compute
90166
+** the result of the comparison (1, 0, or NULL) and write that
90167
+** result into register dest.
90168
+**
90169
+** The caller must satisfy the following preconditions:
90170
+**
90171
+** if pExpr->op==TK_IS: op==TK_EQ and p5==SQLITE_NULLEQ
90172
+** if pExpr->op==TK_ISNOT: op==TK_NE and p5==SQLITE_NULLEQ
90173
+** otherwise: op==pExpr->op and p5==0
90174
+*/
90175
+static void codeVectorCompare(
90176
+ Parse *pParse, /* Code generator context */
90177
+ Expr *pExpr, /* The comparison operation */
90178
+ int dest, /* Write results into this register */
90179
+ u8 op, /* Comparison operator */
90180
+ u8 p5 /* SQLITE_NULLEQ or zero */
90181
+){
90182
+ Vdbe *v = pParse->pVdbe;
90183
+ Expr *pLeft = pExpr->pLeft;
90184
+ Expr *pRight = pExpr->pRight;
90185
+ int nLeft = sqlite3ExprVectorSize(pLeft);
90186
+ int i;
90187
+ int regLeft = 0;
90188
+ int regRight = 0;
90189
+ u8 opx = op;
90190
+ int addrDone = sqlite3VdbeMakeLabel(v);
90191
+
90192
+ assert( nLeft==sqlite3ExprVectorSize(pRight) );
90193
+ assert( pExpr->op==TK_EQ || pExpr->op==TK_NE
90194
+ || pExpr->op==TK_IS || pExpr->op==TK_ISNOT
90195
+ || pExpr->op==TK_LT || pExpr->op==TK_GT
90196
+ || pExpr->op==TK_LE || pExpr->op==TK_GE
90197
+ );
90198
+ assert( pExpr->op==op || (pExpr->op==TK_IS && op==TK_EQ)
90199
+ || (pExpr->op==TK_ISNOT && op==TK_NE) );
90200
+ assert( p5==0 || pExpr->op!=op );
90201
+ assert( p5==SQLITE_NULLEQ || pExpr->op==op );
90202
+
90203
+ p5 |= SQLITE_STOREP2;
90204
+ if( opx==TK_LE ) opx = TK_LT;
90205
+ if( opx==TK_GE ) opx = TK_GT;
90206
+
90207
+ regLeft = exprCodeSubselect(pParse, pLeft);
90208
+ regRight = exprCodeSubselect(pParse, pRight);
90209
+
90210
+ for(i=0; 1 /*Loop exits by "break"*/; i++){
90211
+ int regFree1 = 0, regFree2 = 0;
90212
+ Expr *pL, *pR;
90213
+ int r1, r2;
90214
+ assert( i>=0 && i<nLeft );
90215
+ if( i>0 ) sqlite3ExprCachePush(pParse);
90216
+ r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);
90217
+ r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);
90218
+ codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5);
90219
+ testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
90220
+ testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
90221
+ testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
90222
+ testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
90223
+ testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
90224
+ testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
90225
+ sqlite3ReleaseTempReg(pParse, regFree1);
90226
+ sqlite3ReleaseTempReg(pParse, regFree2);
90227
+ if( i>0 ) sqlite3ExprCachePop(pParse);
90228
+ if( i==nLeft-1 ){
90229
+ break;
90230
+ }
90231
+ if( opx==TK_EQ ){
90232
+ sqlite3VdbeAddOp2(v, OP_IfNot, dest, addrDone); VdbeCoverage(v);
90233
+ p5 |= SQLITE_KEEPNULL;
90234
+ }else if( opx==TK_NE ){
90235
+ sqlite3VdbeAddOp2(v, OP_If, dest, addrDone); VdbeCoverage(v);
90236
+ p5 |= SQLITE_KEEPNULL;
90237
+ }else{
90238
+ assert( op==TK_LT || op==TK_GT || op==TK_LE || op==TK_GE );
90239
+ sqlite3VdbeAddOp2(v, OP_ElseNotEq, 0, addrDone);
90240
+ VdbeCoverageIf(v, op==TK_LT);
90241
+ VdbeCoverageIf(v, op==TK_GT);
90242
+ VdbeCoverageIf(v, op==TK_LE);
90243
+ VdbeCoverageIf(v, op==TK_GE);
90244
+ if( i==nLeft-2 ) opx = op;
90245
+ }
90246
+ }
90247
+ sqlite3VdbeResolveLabel(v, addrDone);
90248
+}
8980190249
8980290250
#if SQLITE_MAX_EXPR_DEPTH>0
8980390251
/*
8980490252
** Check that argument nHeight is less than or equal to the maximum
8980590253
** expression depth allowed. If it is not, leave an error message in
@@ -90231,11 +90679,11 @@
9023190679
/* Sanity check: Assert that the IntValue is non-negative if it exists */
9023290680
assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );
9023390681
if( !ExprHasProperty(p, EP_TokenOnly) ){
9023490682
/* The Expr.x union is never used at the same time as Expr.pRight */
9023590683
assert( p->x.pList==0 || p->pRight==0 );
90236
- sqlite3ExprDelete(db, p->pLeft);
90684
+ if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);
9023790685
sqlite3ExprDelete(db, p->pRight);
9023890686
if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
9023990687
if( ExprHasProperty(p, EP_xIsSelect) ){
9024090688
sqlite3SelectDelete(db, p->x.pSelect);
9024190689
}else{
@@ -90439,11 +90887,15 @@
9043990887
if( pzBuffer ){
9044090888
*pzBuffer = zAlloc;
9044190889
}
9044290890
}else{
9044390891
if( !ExprHasProperty(p, EP_TokenOnly) ){
90444
- pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
90892
+ if( pNew->op==TK_SELECT_COLUMN ){
90893
+ pNew->pLeft = p->pLeft;
90894
+ }else{
90895
+ pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
90896
+ }
9044590897
pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
9044690898
}
9044790899
}
9044890900
}
9044990901
return pNew;
@@ -90679,10 +91131,64 @@
9067991131
/* Avoid leaking memory if malloc has failed. */
9068091132
sqlite3ExprDelete(db, pExpr);
9068191133
sqlite3ExprListDelete(db, pList);
9068291134
return 0;
9068391135
}
91136
+
91137
+/*
91138
+** pColumns and pExpr form a vector assignment which is part of the SET
91139
+** clause of an UPDATE statement. Like this:
91140
+**
91141
+** (a,b,c) = (expr1,expr2,expr3)
91142
+** Or: (a,b,c) = (SELECT x,y,z FROM ....)
91143
+**
91144
+** For each term of the vector assignment, append new entries to the
91145
+** expression list pList. In the case of a subquery on the LHS, append
91146
+** TK_SELECT_COLUMN expressions.
91147
+*/
91148
+SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(
91149
+ Parse *pParse, /* Parsing context */
91150
+ ExprList *pList, /* List to which to append. Might be NULL */
91151
+ IdList *pColumns, /* List of names of LHS of the assignment */
91152
+ Expr *pExpr /* Vector expression to be appended. Might be NULL */
91153
+){
91154
+ sqlite3 *db = pParse->db;
91155
+ int n;
91156
+ int i;
91157
+ int iFirst = pList ? pList->nExpr : 0;
91158
+ /* pColumns can only be NULL due to an OOM but an OOM will cause an
91159
+ ** exit prior to this routine being invoked */
91160
+ if( NEVER(pColumns==0) ) goto vector_append_error;
91161
+ if( pExpr==0 ) goto vector_append_error;
91162
+ n = sqlite3ExprVectorSize(pExpr);
91163
+ if( pColumns->nId!=n ){
91164
+ sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
91165
+ pColumns->nId, n);
91166
+ goto vector_append_error;
91167
+ }
91168
+ for(i=0; i<n; i++){
91169
+ Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);
91170
+ pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);
91171
+ if( pList ){
91172
+ assert( pList->nExpr==iFirst+i+1 );
91173
+ pList->a[pList->nExpr-1].zName = pColumns->a[i].zName;
91174
+ pColumns->a[i].zName = 0;
91175
+ }
91176
+ }
91177
+ if( pExpr->op==TK_SELECT ){
91178
+ if( pList && pList->a[iFirst].pExpr ){
91179
+ assert( pList->a[iFirst].pExpr->op==TK_SELECT_COLUMN );
91180
+ pList->a[iFirst].pExpr->pRight = pExpr;
91181
+ pExpr = 0;
91182
+ }
91183
+ }
91184
+
91185
+vector_append_error:
91186
+ sqlite3ExprDelete(db, pExpr);
91187
+ sqlite3IdListDelete(db, pColumns);
91188
+ return pList;
91189
+}
9068491190
9068591191
/*
9068691192
** Set the sort order for the last element on the given ExprList.
9068791193
*/
9068891194
SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder){
@@ -91087,12 +91593,12 @@
9108791593
#ifndef SQLITE_OMIT_SUBQUERY
9108891594
static Select *isCandidateForInOpt(Expr *pX){
9108991595
Select *p;
9109091596
SrcList *pSrc;
9109191597
ExprList *pEList;
91092
- Expr *pRes;
9109391598
Table *pTab;
91599
+ int i;
9109491600
if( !ExprHasProperty(pX, EP_xIsSelect) ) return 0; /* Not a subquery */
9109591601
if( ExprHasProperty(pX, EP_VarSelect) ) return 0; /* Correlated subq */
9109691602
p = pX->x.pSelect;
9109791603
if( p->pPrior ) return 0; /* Not a compound SELECT */
9109891604
if( p->selFlags & (SF_Distinct|SF_Aggregate) ){
@@ -91111,14 +91617,17 @@
9111191617
pTab = pSrc->a[0].pTab;
9111291618
assert( pTab!=0 );
9111391619
assert( pTab->pSelect==0 ); /* FROM clause is not a view */
9111491620
if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */
9111591621
pEList = p->pEList;
91116
- if( pEList->nExpr!=1 ) return 0; /* One column in the result set */
91117
- pRes = pEList->a[0].pExpr;
91118
- if( pRes->op!=TK_COLUMN ) return 0; /* Result is a column */
91119
- assert( pRes->iTable==pSrc->a[0].iCursor ); /* Not a correlated subquery */
91622
+ assert( pEList!=0 );
91623
+ /* All SELECT results must be columns. */
91624
+ for(i=0; i<pEList->nExpr; i++){
91625
+ Expr *pRes = pEList->a[i].pExpr;
91626
+ if( pRes->op!=TK_COLUMN ) return 0;
91627
+ assert( pRes->iTable==pSrc->a[0].iCursor ); /* Not a correlated subquery */
91628
+ }
9112091629
return p;
9112191630
}
9112291631
#endif /* SQLITE_OMIT_SUBQUERY */
9112391632
9112491633
/*
@@ -91128,10 +91637,11 @@
9112891637
SQLITE_PRIVATE int sqlite3CodeOnce(Parse *pParse){
9112991638
Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */
9113091639
return sqlite3VdbeAddOp1(v, OP_Once, pParse->nOnce++);
9113191640
}
9113291641
91642
+#ifndef SQLITE_OMIT_SUBQUERY
9113391643
/*
9113491644
** Generate code that checks the left-most column of index table iCur to see if
9113591645
** it contains any NULL entries. Cause the register at regHasNull to be set
9113691646
** to a non-NULL value if iCur contains no NULLs. Cause register regHasNull
9113791647
** to be set to NULL if iCur contains one or more NULL values.
@@ -91143,10 +91653,11 @@
9114391653
sqlite3VdbeAddOp3(v, OP_Column, iCur, 0, regHasNull);
9114491654
sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
9114591655
VdbeComment((v, "first_entry_in(%d)", iCur));
9114691656
sqlite3VdbeJumpHere(v, addr1);
9114791657
}
91658
+#endif
9114891659
9114991660
9115091661
#ifndef SQLITE_OMIT_SUBQUERY
9115191662
/*
9115291663
** The argument is an IN operator with a list (not a subquery) on the
@@ -91187,11 +91698,11 @@
9118791698
** implemented as a sequence of comparisons.
9118891699
**
9118991700
** An existing b-tree might be used if the RHS expression pX is a simple
9119091701
** subquery such as:
9119191702
**
91192
-** SELECT <column> FROM <table>
91703
+** SELECT <column1>, <column2>... FROM <table>
9119391704
**
9119491705
** If the RHS of the IN operator is a list or a more complex subquery, then
9119591706
** an ephemeral table might need to be generated from the RHS and then
9119691707
** pX->iTable made to point to the ephemeral table instead of an
9119791708
** existing table.
@@ -91203,18 +91714,18 @@
9120391714
** IN index will be used to loop over all values of the RHS of the
9120491715
** IN operator.
9120591716
**
9120691717
** When IN_INDEX_LOOP is used (and the b-tree will be used to iterate
9120791718
** through the set members) then the b-tree must not contain duplicates.
91208
-** An epheremal table must be used unless the selected <column> is guaranteed
91209
-** to be unique - either because it is an INTEGER PRIMARY KEY or it
91210
-** has a UNIQUE constraint or UNIQUE index.
91719
+** An epheremal table must be used unless the selected columns are guaranteed
91720
+** to be unique - either because it is an INTEGER PRIMARY KEY or due to
91721
+** a UNIQUE constraint or index.
9121191722
**
9121291723
** When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used
9121391724
** for fast set membership tests) then an epheremal table must
91214
-** be used unless <column> is an INTEGER PRIMARY KEY or an index can
91215
-** be found with <column> as its left-most column.
91725
+** be used unless <columns> is a single INTEGER PRIMARY KEY column or an
91726
+** index can be found with the specified <columns> as its left-most.
9121691727
**
9121791728
** If the IN_INDEX_NOOP_OK and IN_INDEX_MEMBERSHIP are both set and
9121891729
** if the RHS of the IN operator is a list (not a subquery) then this
9121991730
** routine might decide that creating an ephemeral b-tree for membership
9122091731
** testing is too expensive and return IN_INDEX_NOOP. In that case, the
@@ -91231,98 +91742,190 @@
9123191742
**
9123291743
** If a register is allocated and its location stored in *prRhsHasNull, then
9123391744
** the value in that register will be NULL if the b-tree contains one or more
9123491745
** NULL values, and it will be some non-NULL value if the b-tree contains no
9123591746
** NULL values.
91747
+**
91748
+** If the aiMap parameter is not NULL, it must point to an array containing
91749
+** one element for each column returned by the SELECT statement on the RHS
91750
+** of the IN(...) operator. The i'th entry of the array is populated with the
91751
+** offset of the index column that matches the i'th column returned by the
91752
+** SELECT. For example, if the expression and selected index are:
91753
+**
91754
+** (?,?,?) IN (SELECT a, b, c FROM t1)
91755
+** CREATE INDEX i1 ON t1(b, c, a);
91756
+**
91757
+** then aiMap[] is populated with {2, 0, 1}.
9123691758
*/
9123791759
#ifndef SQLITE_OMIT_SUBQUERY
91238
-SQLITE_PRIVATE int sqlite3FindInIndex(Parse *pParse, Expr *pX, u32 inFlags, int *prRhsHasNull){
91760
+SQLITE_PRIVATE int sqlite3FindInIndex(
91761
+ Parse *pParse, /* Parsing context */
91762
+ Expr *pX, /* The right-hand side (RHS) of the IN operator */
91763
+ u32 inFlags, /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */
91764
+ int *prRhsHasNull, /* Register holding NULL status. See notes */
91765
+ int *aiMap /* Mapping from Index fields to RHS fields */
91766
+){
9123991767
Select *p; /* SELECT to the right of IN operator */
9124091768
int eType = 0; /* Type of RHS table. IN_INDEX_* */
9124191769
int iTab = pParse->nTab++; /* Cursor of the RHS table */
9124291770
int mustBeUnique; /* True if RHS must be unique */
9124391771
Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */
9124491772
9124591773
assert( pX->op==TK_IN );
9124691774
mustBeUnique = (inFlags & IN_INDEX_LOOP)!=0;
91775
+
91776
+ /* If the RHS of this IN(...) operator is a SELECT, and if it matters
91777
+ ** whether or not the SELECT result contains NULL values, check whether
91778
+ ** or not NULL is actually possible (it may not be, for example, due
91779
+ ** to NOT NULL constraints in the schema). If no NULL values are possible,
91780
+ ** set prRhsHasNull to 0 before continuing. */
91781
+ if( prRhsHasNull && (pX->flags & EP_xIsSelect) ){
91782
+ int i;
91783
+ ExprList *pEList = pX->x.pSelect->pEList;
91784
+ for(i=0; i<pEList->nExpr; i++){
91785
+ if( sqlite3ExprCanBeNull(pEList->a[i].pExpr) ) break;
91786
+ }
91787
+ if( i==pEList->nExpr ){
91788
+ prRhsHasNull = 0;
91789
+ }
91790
+ }
9124791791
9124891792
/* Check to see if an existing table or index can be used to
9124991793
** satisfy the query. This is preferable to generating a new
91250
- ** ephemeral table.
91251
- */
91794
+ ** ephemeral table. */
9125291795
if( pParse->nErr==0 && (p = isCandidateForInOpt(pX))!=0 ){
9125391796
sqlite3 *db = pParse->db; /* Database connection */
9125491797
Table *pTab; /* Table <table>. */
91255
- Expr *pExpr; /* Expression <column> */
91256
- i16 iCol; /* Index of column <column> */
9125791798
i16 iDb; /* Database idx for pTab */
91799
+ ExprList *pEList = p->pEList;
91800
+ int nExpr = pEList->nExpr;
9125891801
9125991802
assert( p->pEList!=0 ); /* Because of isCandidateForInOpt(p) */
9126091803
assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */
9126191804
assert( p->pSrc!=0 ); /* Because of isCandidateForInOpt(p) */
9126291805
pTab = p->pSrc->a[0].pTab;
91263
- pExpr = p->pEList->a[0].pExpr;
91264
- iCol = (i16)pExpr->iColumn;
91265
-
91806
+
9126691807
/* Code an OP_Transaction and OP_TableLock for <table>. */
9126791808
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
9126891809
sqlite3CodeVerifySchema(pParse, iDb);
9126991810
sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
9127091811
91271
- /* This function is only called from two places. In both cases the vdbe
91272
- ** has already been allocated. So assume sqlite3GetVdbe() is always
91273
- ** successful here.
91274
- */
91275
- assert(v);
91276
- if( iCol<0 ){
91812
+ assert(v); /* sqlite3GetVdbe() has always been previously called */
91813
+ if( nExpr==1 && pEList->a[0].pExpr->iColumn<0 ){
91814
+ /* The "x IN (SELECT rowid FROM table)" case */
9127791815
int iAddr = sqlite3CodeOnce(pParse);
9127891816
VdbeCoverage(v);
9127991817
9128091818
sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
9128191819
eType = IN_INDEX_ROWID;
9128291820
9128391821
sqlite3VdbeJumpHere(v, iAddr);
9128491822
}else{
9128591823
Index *pIdx; /* Iterator variable */
91286
-
91287
- /* The collation sequence used by the comparison. If an index is to
91288
- ** be used in place of a temp-table, it must be ordered according
91289
- ** to this collation sequence. */
91290
- CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pExpr);
91291
-
91292
- /* Check that the affinity that will be used to perform the
91293
- ** comparison is the same as the affinity of the column. If
91294
- ** it is not, it is not possible to use any index.
91295
- */
91296
- int affinity_ok = sqlite3IndexAffinityOk(pX, pTab->aCol[iCol].affinity);
91297
-
91298
- for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){
91299
- if( (pIdx->aiColumn[0]==iCol)
91300
- && sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], 0)==pReq
91301
- && (!mustBeUnique || (pIdx->nKeyCol==1 && IsUniqueIndex(pIdx)))
91302
- ){
91303
- int iAddr = sqlite3CodeOnce(pParse); VdbeCoverage(v);
91304
- sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);
91305
- sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
91306
- VdbeComment((v, "%s", pIdx->zName));
91307
- assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
91308
- eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
91309
-
91310
- if( prRhsHasNull && !pTab->aCol[iCol].notNull ){
91311
-#ifdef SQLITE_ENABLE_COLUMN_USED_MASK
91312
- const i64 sOne = 1;
91313
- sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed,
91314
- iTab, 0, 0, (u8*)&sOne, P4_INT64);
91315
-#endif
91316
- *prRhsHasNull = ++pParse->nMem;
91317
- sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);
91318
- }
91319
- sqlite3VdbeJumpHere(v, iAddr);
91320
- }
91321
- }
91322
- }
91323
- }
91824
+ int affinity_ok = 1;
91825
+ int i;
91826
+
91827
+ /* Check that the affinity that will be used to perform each
91828
+ ** comparison is the same as the affinity of each column in table
91829
+ ** on the RHS of the IN operator. If it not, it is not possible to
91830
+ ** use any index of the RHS table. */
91831
+ for(i=0; i<nExpr && affinity_ok; i++){
91832
+ Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);
91833
+ int iCol = pEList->a[i].pExpr->iColumn;
91834
+ char idxaff = sqlite3TableColumnAffinity(pTab,iCol); /* RHS table */
91835
+ char cmpaff = sqlite3CompareAffinity(pLhs, idxaff);
91836
+ testcase( cmpaff==SQLITE_AFF_BLOB );
91837
+ testcase( cmpaff==SQLITE_AFF_TEXT );
91838
+ switch( cmpaff ){
91839
+ case SQLITE_AFF_BLOB:
91840
+ break;
91841
+ case SQLITE_AFF_TEXT:
91842
+ /* sqlite3CompareAffinity() only returns TEXT if one side or the
91843
+ ** other has no affinity and the other side is TEXT. Hence,
91844
+ ** the only way for cmpaff to be TEXT is for idxaff to be TEXT
91845
+ ** and for the term on the LHS of the IN to have no affinity. */
91846
+ assert( idxaff==SQLITE_AFF_TEXT );
91847
+ break;
91848
+ default:
91849
+ affinity_ok = sqlite3IsNumericAffinity(idxaff);
91850
+ }
91851
+ }
91852
+
91853
+ if( affinity_ok ){
91854
+ /* Search for an existing index that will work for this IN operator */
91855
+ for(pIdx=pTab->pIndex; pIdx && eType==0; pIdx=pIdx->pNext){
91856
+ Bitmask colUsed; /* Columns of the index used */
91857
+ Bitmask mCol; /* Mask for the current column */
91858
+ if( pIdx->nColumn<nExpr ) continue;
91859
+ /* Maximum nColumn is BMS-2, not BMS-1, so that we can compute
91860
+ ** BITMASK(nExpr) without overflowing */
91861
+ testcase( pIdx->nColumn==BMS-2 );
91862
+ testcase( pIdx->nColumn==BMS-1 );
91863
+ if( pIdx->nColumn>=BMS-1 ) continue;
91864
+ if( mustBeUnique ){
91865
+ if( pIdx->nKeyCol>nExpr
91866
+ ||(pIdx->nColumn>nExpr && !IsUniqueIndex(pIdx))
91867
+ ){
91868
+ continue; /* This index is not unique over the IN RHS columns */
91869
+ }
91870
+ }
91871
+
91872
+ colUsed = 0; /* Columns of index used so far */
91873
+ for(i=0; i<nExpr; i++){
91874
+ Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);
91875
+ Expr *pRhs = pEList->a[i].pExpr;
91876
+ CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
91877
+ int j;
91878
+
91879
+ assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );
91880
+ for(j=0; j<nExpr; j++){
91881
+ if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
91882
+ assert( pIdx->azColl[j] );
91883
+ if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){
91884
+ continue;
91885
+ }
91886
+ break;
91887
+ }
91888
+ if( j==nExpr ) break;
91889
+ mCol = MASKBIT(j);
91890
+ if( mCol & colUsed ) break; /* Each column used only once */
91891
+ colUsed |= mCol;
91892
+ if( aiMap ) aiMap[i] = j;
91893
+ }
91894
+
91895
+ assert( i==nExpr || colUsed!=(MASKBIT(nExpr)-1) );
91896
+ if( colUsed==(MASKBIT(nExpr)-1) ){
91897
+ /* If we reach this point, that means the index pIdx is usable */
91898
+ int iAddr = sqlite3CodeOnce(pParse); VdbeCoverage(v);
91899
+ #ifndef SQLITE_OMIT_EXPLAIN
91900
+ sqlite3VdbeAddOp4(v, OP_Explain, 0, 0, 0,
91901
+ sqlite3MPrintf(db, "USING INDEX %s FOR IN-OPERATOR",pIdx->zName),
91902
+ P4_DYNAMIC);
91903
+ #endif
91904
+ sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);
91905
+ sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
91906
+ VdbeComment((v, "%s", pIdx->zName));
91907
+ assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
91908
+ eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
91909
+
91910
+ if( prRhsHasNull ){
91911
+ *prRhsHasNull = ++pParse->nMem;
91912
+ #ifdef SQLITE_ENABLE_COLUMN_USED_MASK
91913
+ i64 mask = (1<<nExpr)-1;
91914
+ sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed,
91915
+ iTab, 0, 0, (u8*)&mask, P4_INT64);
91916
+ #endif
91917
+ if( nExpr==1 ){
91918
+ sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);
91919
+ }
91920
+ }
91921
+ sqlite3VdbeJumpHere(v, iAddr);
91922
+ }
91923
+ } /* End loop over indexes */
91924
+ } /* End if( affinity_ok ) */
91925
+ } /* End if not an rowid index */
91926
+ } /* End attempt to optimize using an index */
9132491927
9132591928
/* If no preexisting index is available for the IN clause
9132691929
** and IN_INDEX_NOOP is an allowed reply
9132791930
** and the RHS of the IN operator is a list, not a subquery
9132891931
** and the RHS is not constant or has two or fewer terms,
@@ -91334,11 +91937,10 @@
9133491937
&& !ExprHasProperty(pX, EP_xIsSelect)
9133591938
&& (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2)
9133691939
){
9133791940
eType = IN_INDEX_NOOP;
9133891941
}
91339
-
9134091942
9134191943
if( eType==0 ){
9134291944
/* Could not find an existing table or index to use as the RHS b-tree.
9134391945
** We will have to generate an ephemeral table to do the job.
9134491946
*/
@@ -91356,13 +91958,66 @@
9135691958
sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);
9135791959
pParse->nQueryLoop = savedNQueryLoop;
9135891960
}else{
9135991961
pX->iTable = iTab;
9136091962
}
91963
+
91964
+ if( aiMap && eType!=IN_INDEX_INDEX_ASC && eType!=IN_INDEX_INDEX_DESC ){
91965
+ int i, n;
91966
+ n = sqlite3ExprVectorSize(pX->pLeft);
91967
+ for(i=0; i<n; i++) aiMap[i] = i;
91968
+ }
9136191969
return eType;
9136291970
}
9136391971
#endif
91972
+
91973
+#ifndef SQLITE_OMIT_SUBQUERY
91974
+/*
91975
+** Argument pExpr is an (?, ?...) IN(...) expression. This
91976
+** function allocates and returns a nul-terminated string containing
91977
+** the affinities to be used for each column of the comparison.
91978
+**
91979
+** It is the responsibility of the caller to ensure that the returned
91980
+** string is eventually freed using sqlite3DbFree().
91981
+*/
91982
+static char *exprINAffinity(Parse *pParse, Expr *pExpr){
91983
+ Expr *pLeft = pExpr->pLeft;
91984
+ int nVal = sqlite3ExprVectorSize(pLeft);
91985
+ Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;
91986
+ char *zRet;
91987
+
91988
+ assert( pExpr->op==TK_IN );
91989
+ zRet = sqlite3DbMallocZero(pParse->db, nVal+1);
91990
+ if( zRet ){
91991
+ int i;
91992
+ for(i=0; i<nVal; i++){
91993
+ Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);
91994
+ char a = sqlite3ExprAffinity(pA);
91995
+ if( pSelect ){
91996
+ zRet[i] = sqlite3CompareAffinity(pSelect->pEList->a[i].pExpr, a);
91997
+ }else{
91998
+ zRet[i] = a;
91999
+ }
92000
+ }
92001
+ zRet[nVal] = '\0';
92002
+ }
92003
+ return zRet;
92004
+}
92005
+#endif
92006
+
92007
+#ifndef SQLITE_OMIT_SUBQUERY
92008
+/*
92009
+** Load the Parse object passed as the first argument with an error
92010
+** message of the form:
92011
+**
92012
+** "sub-select returns N columns - expected M"
92013
+*/
92014
+SQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){
92015
+ const char *zFmt = "sub-select returns %d columns - expected %d";
92016
+ sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect);
92017
+}
92018
+#endif
9136492019
9136592020
/*
9136692021
** Generate code for scalar subqueries used as a subquery expression, EXISTS,
9136792022
** or IN operators. Examples:
9136892023
**
@@ -91385,11 +92040,13 @@
9138592040
** All this routine does is initialize the register given by rMayHaveNull
9138692041
** to NULL. Calling routines will take care of changing this register
9138792042
** value to non-NULL if the RHS is NULL-free.
9138892043
**
9138992044
** For a SELECT or EXISTS operator, return the register that holds the
91390
-** result. For IN operators or if an error occurs, the return value is 0.
92045
+** result. For a multi-column SELECT, the result is stored in a contiguous
92046
+** array of registers and the return value is the register of the left-most
92047
+** result column. Return 0 for IN operators or if an error occurs.
9139192048
*/
9139292049
#ifndef SQLITE_OMIT_SUBQUERY
9139392050
SQLITE_PRIVATE int sqlite3CodeSubselect(
9139492051
Parse *pParse, /* Parsing context */
9139592052
Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
@@ -91400,12 +92057,12 @@
9140092057
int rReg = 0; /* Register storing resulting */
9140192058
Vdbe *v = sqlite3GetVdbe(pParse);
9140292059
if( NEVER(v==0) ) return 0;
9140392060
sqlite3ExprCachePush(pParse);
9140492061
91405
- /* This code must be run in its entirety every time it is encountered
91406
- ** if any of the following is true:
92062
+ /* The evaluation of the IN/EXISTS/SELECT must be repeated every time it
92063
+ ** is encountered if any of the following is true:
9140792064
**
9140892065
** * The right-hand side is a correlated subquery
9140992066
** * The right-hand side is an expression list containing variables
9141092067
** * We are inside a trigger
9141192068
**
@@ -91427,21 +92084,22 @@
9142792084
}
9142892085
#endif
9142992086
9143092087
switch( pExpr->op ){
9143192088
case TK_IN: {
91432
- char affinity; /* Affinity of the LHS of the IN */
9143392089
int addr; /* Address of OP_OpenEphemeral instruction */
9143492090
Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
9143592091
KeyInfo *pKeyInfo = 0; /* Key information */
91436
-
91437
- affinity = sqlite3ExprAffinity(pLeft);
92092
+ int nVal; /* Size of vector pLeft */
92093
+
92094
+ nVal = sqlite3ExprVectorSize(pLeft);
92095
+ assert( !isRowid || nVal==1 );
9143892096
9143992097
/* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
9144092098
** expression it is handled the same way. An ephemeral table is
91441
- ** filled with single-field index keys representing the results
91442
- ** from the SELECT or the <exprlist>.
92099
+ ** filled with index keys representing the results from the
92100
+ ** SELECT or the <exprlist>.
9144392101
**
9144492102
** If the 'x' expression is a column value, or the SELECT...
9144592103
** statement returns a column value, then the affinity of that
9144692104
** column is used to build the index keys. If both 'x' and the
9144792105
** SELECT... statement are columns, then numeric affinity is used
@@ -91448,54 +92106,67 @@
9144892106
** if either column has NUMERIC or INTEGER affinity. If neither
9144992107
** 'x' nor the SELECT... statement are columns, then numeric affinity
9145092108
** is used.
9145192109
*/
9145292110
pExpr->iTable = pParse->nTab++;
91453
- addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
91454
- pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1, 1);
92111
+ addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral,
92112
+ pExpr->iTable, (isRowid?0:nVal));
92113
+ pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, nVal, 1);
9145592114
9145692115
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
9145792116
/* Case 1: expr IN (SELECT ...)
9145892117
**
9145992118
** Generate code to write the results of the select into the temporary
9146092119
** table allocated and opened above.
9146192120
*/
9146292121
Select *pSelect = pExpr->x.pSelect;
91463
- SelectDest dest;
91464
- ExprList *pEList;
92122
+ ExprList *pEList = pSelect->pEList;
9146592123
9146692124
assert( !isRowid );
91467
- sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
91468
- dest.affSdst = (u8)affinity;
91469
- assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
91470
- pSelect->iLimit = 0;
91471
- testcase( pSelect->selFlags & SF_Distinct );
91472
- testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
91473
- if( sqlite3Select(pParse, pSelect, &dest) ){
91474
- sqlite3KeyInfoUnref(pKeyInfo);
91475
- return 0;
91476
- }
91477
- pEList = pSelect->pEList;
91478
- assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
91479
- assert( pEList!=0 );
91480
- assert( pEList->nExpr>0 );
91481
- assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
91482
- pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
91483
- pEList->a[0].pExpr);
92125
+ /* If the LHS and RHS of the IN operator do not match, that
92126
+ ** error will have been caught long before we reach this point. */
92127
+ if( ALWAYS(pEList->nExpr==nVal) ){
92128
+ SelectDest dest;
92129
+ int i;
92130
+ sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
92131
+ dest.zAffSdst = exprINAffinity(pParse, pExpr);
92132
+ assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
92133
+ pSelect->iLimit = 0;
92134
+ testcase( pSelect->selFlags & SF_Distinct );
92135
+ testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
92136
+ if( sqlite3Select(pParse, pSelect, &dest) ){
92137
+ sqlite3DbFree(pParse->db, dest.zAffSdst);
92138
+ sqlite3KeyInfoUnref(pKeyInfo);
92139
+ return 0;
92140
+ }
92141
+ sqlite3DbFree(pParse->db, dest.zAffSdst);
92142
+ assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
92143
+ assert( pEList!=0 );
92144
+ assert( pEList->nExpr>0 );
92145
+ assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
92146
+ for(i=0; i<nVal; i++){
92147
+ Expr *p = sqlite3VectorFieldSubexpr(pLeft, i);
92148
+ pKeyInfo->aColl[i] = sqlite3BinaryCompareCollSeq(
92149
+ pParse, p, pEList->a[i].pExpr
92150
+ );
92151
+ }
92152
+ }
9148492153
}else if( ALWAYS(pExpr->x.pList!=0) ){
9148592154
/* Case 2: expr IN (exprlist)
9148692155
**
9148792156
** For each expression, build an index key from the evaluation and
9148892157
** store it in the temporary table. If <expr> is a column, then use
9148992158
** that columns affinity when building index keys. If <expr> is not
9149092159
** a column, use numeric affinity.
9149192160
*/
92161
+ char affinity; /* Affinity of the LHS of the IN */
9149292162
int i;
9149392163
ExprList *pList = pExpr->x.pList;
9149492164
struct ExprList_item *pItem;
9149592165
int r1, r2, r3;
9149692166
92167
+ affinity = sqlite3ExprAffinity(pLeft);
9149792168
if( !affinity ){
9149892169
affinity = SQLITE_AFF_BLOB;
9149992170
}
9150092171
if( pKeyInfo ){
9150192172
assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
@@ -91547,30 +92218,41 @@
9154792218
}
9154892219
9154992220
case TK_EXISTS:
9155092221
case TK_SELECT:
9155192222
default: {
91552
- /* If this has to be a scalar SELECT. Generate code to put the
91553
- ** value of this select in a memory cell and record the number
91554
- ** of the memory cell in iColumn. If this is an EXISTS, write
91555
- ** an integer 0 (not exists) or 1 (exists) into a memory cell
91556
- ** and record that memory cell in iColumn.
92223
+ /* Case 3: (SELECT ... FROM ...)
92224
+ ** or: EXISTS(SELECT ... FROM ...)
92225
+ **
92226
+ ** For a SELECT, generate code to put the values for all columns of
92227
+ ** the first row into an array of registers and return the index of
92228
+ ** the first register.
92229
+ **
92230
+ ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)
92231
+ ** into a register and return that register number.
92232
+ **
92233
+ ** In both cases, the query is augmented with "LIMIT 1". Any
92234
+ ** preexisting limit is discarded in place of the new LIMIT 1.
9155792235
*/
9155892236
Select *pSel; /* SELECT statement to encode */
91559
- SelectDest dest; /* How to deal with SELECt result */
92237
+ SelectDest dest; /* How to deal with SELECT result */
92238
+ int nReg; /* Registers to allocate */
9156092239
9156192240
testcase( pExpr->op==TK_EXISTS );
9156292241
testcase( pExpr->op==TK_SELECT );
9156392242
assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
91564
-
9156592243
assert( ExprHasProperty(pExpr, EP_xIsSelect) );
92244
+
9156692245
pSel = pExpr->x.pSelect;
91567
- sqlite3SelectDestInit(&dest, 0, ++pParse->nMem);
92246
+ nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;
92247
+ sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);
92248
+ pParse->nMem += nReg;
9156892249
if( pExpr->op==TK_SELECT ){
9156992250
dest.eDest = SRT_Mem;
9157092251
dest.iSdst = dest.iSDParm;
91571
- sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iSDParm);
92252
+ dest.nSdst = nReg;
92253
+ sqlite3VdbeAddOp3(v, OP_Null, 0, dest.iSDParm, dest.iSDParm+nReg-1);
9157292254
VdbeComment((v, "Init subquery result"));
9157392255
}else{
9157492256
dest.eDest = SRT_Exists;
9157592257
sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
9157692258
VdbeComment((v, "Init EXISTS result"));
@@ -91599,66 +92281,147 @@
9159992281
sqlite3ExprCachePop(pParse);
9160092282
9160192283
return rReg;
9160292284
}
9160392285
#endif /* SQLITE_OMIT_SUBQUERY */
92286
+
92287
+#ifndef SQLITE_OMIT_SUBQUERY
92288
+/*
92289
+** Expr pIn is an IN(...) expression. This function checks that the
92290
+** sub-select on the RHS of the IN() operator has the same number of
92291
+** columns as the vector on the LHS. Or, if the RHS of the IN() is not
92292
+** a sub-query, that the LHS is a vector of size 1.
92293
+*/
92294
+SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){
92295
+ int nVector = sqlite3ExprVectorSize(pIn->pLeft);
92296
+ if( (pIn->flags & EP_xIsSelect) ){
92297
+ if( nVector!=pIn->x.pSelect->pEList->nExpr ){
92298
+ sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector);
92299
+ return 1;
92300
+ }
92301
+ }else if( nVector!=1 ){
92302
+ if( (pIn->pLeft->flags & EP_xIsSelect) ){
92303
+ sqlite3SubselectError(pParse, nVector, 1);
92304
+ }else{
92305
+ sqlite3ErrorMsg(pParse, "row value misused");
92306
+ }
92307
+ return 1;
92308
+ }
92309
+ return 0;
92310
+}
92311
+#endif
9160492312
9160592313
#ifndef SQLITE_OMIT_SUBQUERY
9160692314
/*
9160792315
** Generate code for an IN expression.
9160892316
**
9160992317
** x IN (SELECT ...)
9161092318
** x IN (value, value, ...)
9161192319
**
91612
-** The left-hand side (LHS) is a scalar expression. The right-hand side (RHS)
91613
-** is an array of zero or more values. The expression is true if the LHS is
91614
-** contained within the RHS. The value of the expression is unknown (NULL)
91615
-** if the LHS is NULL or if the LHS is not contained within the RHS and the
91616
-** RHS contains one or more NULL values.
92320
+** The left-hand side (LHS) is a scalar or vector expression. The
92321
+** right-hand side (RHS) is an array of zero or more scalar values, or a
92322
+** subquery. If the RHS is a subquery, the number of result columns must
92323
+** match the number of columns in the vector on the LHS. If the RHS is
92324
+** a list of values, the LHS must be a scalar.
92325
+**
92326
+** The IN operator is true if the LHS value is contained within the RHS.
92327
+** The result is false if the LHS is definitely not in the RHS. The
92328
+** result is NULL if the presence of the LHS in the RHS cannot be
92329
+** determined due to NULLs.
9161792330
**
9161892331
** This routine generates code that jumps to destIfFalse if the LHS is not
9161992332
** contained within the RHS. If due to NULLs we cannot determine if the LHS
9162092333
** is contained in the RHS then jump to destIfNull. If the LHS is contained
9162192334
** within the RHS then fall through.
92335
+**
92336
+** See the separate in-operator.md documentation file in the canonical
92337
+** SQLite source tree for additional information.
9162292338
*/
9162392339
static void sqlite3ExprCodeIN(
9162492340
Parse *pParse, /* Parsing and code generating context */
9162592341
Expr *pExpr, /* The IN expression */
9162692342
int destIfFalse, /* Jump here if LHS is not contained in the RHS */
9162792343
int destIfNull /* Jump here if the results are unknown due to NULLs */
9162892344
){
9162992345
int rRhsHasNull = 0; /* Register that is true if RHS contains NULL values */
91630
- char affinity; /* Comparison affinity to use */
9163192346
int eType; /* Type of the RHS */
91632
- int r1; /* Temporary use register */
92347
+ int rLhs; /* Register(s) holding the LHS values */
92348
+ int rLhsOrig; /* LHS values prior to reordering by aiMap[] */
9163392349
Vdbe *v; /* Statement under construction */
92350
+ int *aiMap = 0; /* Map from vector field to index column */
92351
+ char *zAff = 0; /* Affinity string for comparisons */
92352
+ int nVector; /* Size of vectors for this IN operator */
92353
+ int iDummy; /* Dummy parameter to exprCodeVector() */
92354
+ Expr *pLeft; /* The LHS of the IN operator */
92355
+ int i; /* loop counter */
92356
+ int destStep2; /* Where to jump when NULLs seen in step 2 */
92357
+ int destStep6 = 0; /* Start of code for Step 6 */
92358
+ int addrTruthOp; /* Address of opcode that determines the IN is true */
92359
+ int destNotNull; /* Jump here if a comparison is not true in step 6 */
92360
+ int addrTop; /* Top of the step-6 loop */
9163492361
91635
- /* Compute the RHS. After this step, the table with cursor
91636
- ** pExpr->iTable will contains the values that make up the RHS.
91637
- */
92362
+ pLeft = pExpr->pLeft;
92363
+ if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
92364
+ zAff = exprINAffinity(pParse, pExpr);
92365
+ nVector = sqlite3ExprVectorSize(pExpr->pLeft);
92366
+ aiMap = (int*)sqlite3DbMallocZero(
92367
+ pParse->db, nVector*(sizeof(int) + sizeof(char)) + 1
92368
+ );
92369
+ if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error;
92370
+
92371
+ /* Attempt to compute the RHS. After this step, if anything other than
92372
+ ** IN_INDEX_NOOP is returned, the table opened ith cursor pExpr->iTable
92373
+ ** contains the values that make up the RHS. If IN_INDEX_NOOP is returned,
92374
+ ** the RHS has not yet been coded. */
9163892375
v = pParse->pVdbe;
9163992376
assert( v!=0 ); /* OOM detected prior to this routine */
9164092377
VdbeNoopComment((v, "begin IN expr"));
9164192378
eType = sqlite3FindInIndex(pParse, pExpr,
9164292379
IN_INDEX_MEMBERSHIP | IN_INDEX_NOOP_OK,
91643
- destIfFalse==destIfNull ? 0 : &rRhsHasNull);
91644
-
91645
- /* Figure out the affinity to use to create a key from the results
91646
- ** of the expression. affinityStr stores a static string suitable for
91647
- ** P4 of OP_MakeRecord.
91648
- */
91649
- affinity = comparisonAffinity(pExpr);
91650
-
91651
- /* Code the LHS, the <expr> from "<expr> IN (...)".
92380
+ destIfFalse==destIfNull ? 0 : &rRhsHasNull, aiMap);
92381
+
92382
+ assert( pParse->nErr || nVector==1 || eType==IN_INDEX_EPH
92383
+ || eType==IN_INDEX_INDEX_ASC || eType==IN_INDEX_INDEX_DESC
92384
+ );
92385
+#ifdef SQLITE_DEBUG
92386
+ /* Confirm that aiMap[] contains nVector integer values between 0 and
92387
+ ** nVector-1. */
92388
+ for(i=0; i<nVector; i++){
92389
+ int j, cnt;
92390
+ for(cnt=j=0; j<nVector; j++) if( aiMap[j]==i ) cnt++;
92391
+ assert( cnt==1 );
92392
+ }
92393
+#endif
92394
+
92395
+ /* Code the LHS, the <expr> from "<expr> IN (...)". If the LHS is a
92396
+ ** vector, then it is stored in an array of nVector registers starting
92397
+ ** at r1.
92398
+ **
92399
+ ** sqlite3FindInIndex() might have reordered the fields of the LHS vector
92400
+ ** so that the fields are in the same order as an existing index. The
92401
+ ** aiMap[] array contains a mapping from the original LHS field order to
92402
+ ** the field order that matches the RHS index.
9165292403
*/
9165392404
sqlite3ExprCachePush(pParse);
91654
- r1 = sqlite3GetTempReg(pParse);
91655
- sqlite3ExprCode(pParse, pExpr->pLeft, r1);
92405
+ rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy);
92406
+ for(i=0; i<nVector && aiMap[i]==i; i++){} /* Are LHS fields reordered? */
92407
+ if( i==nVector ){
92408
+ /* LHS fields are not reordered */
92409
+ rLhs = rLhsOrig;
92410
+ }else{
92411
+ /* Need to reorder the LHS fields according to aiMap */
92412
+ rLhs = sqlite3GetTempRange(pParse, nVector);
92413
+ for(i=0; i<nVector; i++){
92414
+ sqlite3VdbeAddOp3(v, OP_Copy, rLhsOrig+i, rLhs+aiMap[i], 0);
92415
+ }
92416
+ }
9165692417
9165792418
/* If sqlite3FindInIndex() did not find or create an index that is
9165892419
** suitable for evaluating the IN operator, then evaluate using a
9165992420
** sequence of comparisons.
92421
+ **
92422
+ ** This is step (1) in the in-operator.md optimized algorithm.
9166092423
*/
9166192424
if( eType==IN_INDEX_NOOP ){
9166292425
ExprList *pList = pExpr->x.pList;
9166392426
CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
9166492427
int labelOk = sqlite3VdbeMakeLabel(v);
@@ -91666,108 +92429,144 @@
9166692429
int regCkNull = 0;
9166792430
int ii;
9166892431
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
9166992432
if( destIfNull!=destIfFalse ){
9167092433
regCkNull = sqlite3GetTempReg(pParse);
91671
- sqlite3VdbeAddOp3(v, OP_BitAnd, r1, r1, regCkNull);
92434
+ sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull);
9167292435
}
9167392436
for(ii=0; ii<pList->nExpr; ii++){
9167492437
r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);
9167592438
if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
9167692439
sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
9167792440
}
9167892441
if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
91679
- sqlite3VdbeAddOp4(v, OP_Eq, r1, labelOk, r2,
92442
+ sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,
9168092443
(void*)pColl, P4_COLLSEQ);
9168192444
VdbeCoverageIf(v, ii<pList->nExpr-1);
9168292445
VdbeCoverageIf(v, ii==pList->nExpr-1);
91683
- sqlite3VdbeChangeP5(v, affinity);
92446
+ sqlite3VdbeChangeP5(v, zAff[0]);
9168492447
}else{
9168592448
assert( destIfNull==destIfFalse );
91686
- sqlite3VdbeAddOp4(v, OP_Ne, r1, destIfFalse, r2,
92449
+ sqlite3VdbeAddOp4(v, OP_Ne, rLhs, destIfFalse, r2,
9168792450
(void*)pColl, P4_COLLSEQ); VdbeCoverage(v);
91688
- sqlite3VdbeChangeP5(v, affinity | SQLITE_JUMPIFNULL);
92451
+ sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL);
9168992452
}
9169092453
sqlite3ReleaseTempReg(pParse, regToFree);
9169192454
}
9169292455
if( regCkNull ){
9169392456
sqlite3VdbeAddOp2(v, OP_IsNull, regCkNull, destIfNull); VdbeCoverage(v);
9169492457
sqlite3VdbeGoto(v, destIfFalse);
9169592458
}
9169692459
sqlite3VdbeResolveLabel(v, labelOk);
9169792460
sqlite3ReleaseTempReg(pParse, regCkNull);
91698
- }else{
91699
-
91700
- /* If the LHS is NULL, then the result is either false or NULL depending
91701
- ** on whether the RHS is empty or not, respectively.
91702
- */
91703
- if( sqlite3ExprCanBeNull(pExpr->pLeft) ){
91704
- if( destIfNull==destIfFalse ){
91705
- /* Shortcut for the common case where the false and NULL outcomes are
91706
- ** the same. */
91707
- sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull); VdbeCoverage(v);
91708
- }else{
91709
- int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, r1); VdbeCoverage(v);
91710
- sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
91711
- VdbeCoverage(v);
91712
- sqlite3VdbeGoto(v, destIfNull);
91713
- sqlite3VdbeJumpHere(v, addr1);
91714
- }
91715
- }
91716
-
91717
- if( eType==IN_INDEX_ROWID ){
91718
- /* In this case, the RHS is the ROWID of table b-tree
91719
- */
91720
- sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, r1);
91721
- VdbeCoverage(v);
91722
- }else{
91723
- /* In this case, the RHS is an index b-tree.
91724
- */
91725
- sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, &affinity, 1);
91726
-
91727
- /* If the set membership test fails, then the result of the
91728
- ** "x IN (...)" expression must be either 0 or NULL. If the set
91729
- ** contains no NULL values, then the result is 0. If the set
91730
- ** contains one or more NULL values, then the result of the
91731
- ** expression is also NULL.
91732
- */
91733
- assert( destIfFalse!=destIfNull || rRhsHasNull==0 );
91734
- if( rRhsHasNull==0 ){
91735
- /* This branch runs if it is known at compile time that the RHS
91736
- ** cannot contain NULL values. This happens as the result
91737
- ** of a "NOT NULL" constraint in the database schema.
91738
- **
91739
- ** Also run this branch if NULL is equivalent to FALSE
91740
- ** for this particular IN operator.
91741
- */
91742
- sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse, r1, 1);
91743
- VdbeCoverage(v);
91744
- }else{
91745
- /* In this branch, the RHS of the IN might contain a NULL and
91746
- ** the presence of a NULL on the RHS makes a difference in the
91747
- ** outcome.
91748
- */
91749
- int addr1;
91750
-
91751
- /* First check to see if the LHS is contained in the RHS. If so,
91752
- ** then the answer is TRUE the presence of NULLs in the RHS does
91753
- ** not matter. If the LHS is not contained in the RHS, then the
91754
- ** answer is NULL if the RHS contains NULLs and the answer is
91755
- ** FALSE if the RHS is NULL-free.
91756
- */
91757
- addr1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, r1, 1);
91758
- VdbeCoverage(v);
91759
- sqlite3VdbeAddOp2(v, OP_IsNull, rRhsHasNull, destIfNull);
91760
- VdbeCoverage(v);
91761
- sqlite3VdbeGoto(v, destIfFalse);
91762
- sqlite3VdbeJumpHere(v, addr1);
91763
- }
91764
- }
91765
- }
91766
- sqlite3ReleaseTempReg(pParse, r1);
92461
+ goto sqlite3ExprCodeIN_finished;
92462
+ }
92463
+
92464
+ /* Step 2: Check to see if the LHS contains any NULL columns. If the
92465
+ ** LHS does contain NULLs then the result must be either FALSE or NULL.
92466
+ ** We will then skip the binary search of the RHS.
92467
+ */
92468
+ if( destIfNull==destIfFalse ){
92469
+ destStep2 = destIfFalse;
92470
+ }else{
92471
+ destStep2 = destStep6 = sqlite3VdbeMakeLabel(v);
92472
+ }
92473
+ for(i=0; i<nVector; i++){
92474
+ Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
92475
+ if( sqlite3ExprCanBeNull(p) ){
92476
+ sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);
92477
+ VdbeCoverage(v);
92478
+ }
92479
+ }
92480
+
92481
+ /* Step 3. The LHS is now known to be non-NULL. Do the binary search
92482
+ ** of the RHS using the LHS as a probe. If found, the result is
92483
+ ** true.
92484
+ */
92485
+ if( eType==IN_INDEX_ROWID ){
92486
+ /* In this case, the RHS is the ROWID of table b-tree and so we also
92487
+ ** know that the RHS is non-NULL. Hence, we combine steps 3 and 4
92488
+ ** into a single opcode. */
92489
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, rLhs);
92490
+ VdbeCoverage(v);
92491
+ addrTruthOp = sqlite3VdbeAddOp0(v, OP_Goto); /* Return True */
92492
+ }else{
92493
+ sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector);
92494
+ if( destIfFalse==destIfNull ){
92495
+ /* Combine Step 3 and Step 5 into a single opcode */
92496
+ sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse,
92497
+ rLhs, nVector); VdbeCoverage(v);
92498
+ goto sqlite3ExprCodeIN_finished;
92499
+ }
92500
+ /* Ordinary Step 3, for the case where FALSE and NULL are distinct */
92501
+ addrTruthOp = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0,
92502
+ rLhs, nVector); VdbeCoverage(v);
92503
+ }
92504
+
92505
+ /* Step 4. If the RHS is known to be non-NULL and we did not find
92506
+ ** an match on the search above, then the result must be FALSE.
92507
+ */
92508
+ if( rRhsHasNull && nVector==1 ){
92509
+ sqlite3VdbeAddOp2(v, OP_NotNull, rRhsHasNull, destIfFalse);
92510
+ VdbeCoverage(v);
92511
+ }
92512
+
92513
+ /* Step 5. If we do not care about the difference between NULL and
92514
+ ** FALSE, then just return false.
92515
+ */
92516
+ if( destIfFalse==destIfNull ) sqlite3VdbeGoto(v, destIfFalse);
92517
+
92518
+ /* Step 6: Loop through rows of the RHS. Compare each row to the LHS.
92519
+ ** If any comparison is NULL, then the result is NULL. If all
92520
+ ** comparisons are FALSE then the final result is FALSE.
92521
+ **
92522
+ ** For a scalar LHS, it is sufficient to check just the first row
92523
+ ** of the RHS.
92524
+ */
92525
+ if( destStep6 ) sqlite3VdbeResolveLabel(v, destStep6);
92526
+ addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
92527
+ VdbeCoverage(v);
92528
+ if( nVector>1 ){
92529
+ destNotNull = sqlite3VdbeMakeLabel(v);
92530
+ }else{
92531
+ /* For nVector==1, combine steps 6 and 7 by immediately returning
92532
+ ** FALSE if the first comparison is not NULL */
92533
+ destNotNull = destIfFalse;
92534
+ }
92535
+ for(i=0; i<nVector; i++){
92536
+ Expr *p;
92537
+ CollSeq *pColl;
92538
+ int r3 = sqlite3GetTempReg(pParse);
92539
+ p = sqlite3VectorFieldSubexpr(pLeft, i);
92540
+ pColl = sqlite3ExprCollSeq(pParse, p);
92541
+ sqlite3VdbeAddOp3(v, OP_Column, pExpr->iTable, i, r3);
92542
+ sqlite3VdbeAddOp4(v, OP_Ne, rLhs+i, destNotNull, r3,
92543
+ (void*)pColl, P4_COLLSEQ);
92544
+ VdbeCoverage(v);
92545
+ sqlite3ReleaseTempReg(pParse, r3);
92546
+ }
92547
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);
92548
+ if( nVector>1 ){
92549
+ sqlite3VdbeResolveLabel(v, destNotNull);
92550
+ sqlite3VdbeAddOp2(v, OP_Next, pExpr->iTable, addrTop+1);
92551
+ VdbeCoverage(v);
92552
+
92553
+ /* Step 7: If we reach this point, we know that the result must
92554
+ ** be false. */
92555
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse);
92556
+ }
92557
+
92558
+ /* Jumps here in order to return true. */
92559
+ sqlite3VdbeJumpHere(v, addrTruthOp);
92560
+
92561
+sqlite3ExprCodeIN_finished:
92562
+ if( rLhs!=rLhsOrig ) sqlite3ReleaseTempReg(pParse, rLhs);
9176792563
sqlite3ExprCachePop(pParse);
9176892564
VdbeComment((v, "end IN expr"));
92565
+sqlite3ExprCodeIN_oom_error:
92566
+ sqlite3DbFree(pParse->db, aiMap);
92567
+ sqlite3DbFree(pParse->db, zAff);
9176992568
}
9177092569
#endif /* SQLITE_OMIT_SUBQUERY */
9177192570
9177292571
#ifndef SQLITE_OMIT_FLOATING_POINT
9177392572
/*
@@ -92148,18 +92947,52 @@
9214892947
}
9214992948
#endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */
9215092949
9215192950
9215292951
/*
92153
-** Convert an expression node to a TK_REGISTER
92952
+** Convert a scalar expression node to a TK_REGISTER referencing
92953
+** register iReg. The caller must ensure that iReg already contains
92954
+** the correct value for the expression.
9215492955
*/
9215592956
static void exprToRegister(Expr *p, int iReg){
9215692957
p->op2 = p->op;
9215792958
p->op = TK_REGISTER;
9215892959
p->iTable = iReg;
9215992960
ExprClearProperty(p, EP_Skip);
9216092961
}
92962
+
92963
+/*
92964
+** Evaluate an expression (either a vector or a scalar expression) and store
92965
+** the result in continguous temporary registers. Return the index of
92966
+** the first register used to store the result.
92967
+**
92968
+** If the returned result register is a temporary scalar, then also write
92969
+** that register number into *piFreeable. If the returned result register
92970
+** is not a temporary or if the expression is a vector set *piFreeable
92971
+** to 0.
92972
+*/
92973
+static int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){
92974
+ int iResult;
92975
+ int nResult = sqlite3ExprVectorSize(p);
92976
+ if( nResult==1 ){
92977
+ iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable);
92978
+ }else{
92979
+ *piFreeable = 0;
92980
+ if( p->op==TK_SELECT ){
92981
+ iResult = sqlite3CodeSubselect(pParse, p, 0, 0);
92982
+ }else{
92983
+ int i;
92984
+ iResult = pParse->nMem+1;
92985
+ pParse->nMem += nResult;
92986
+ for(i=0; i<nResult; i++){
92987
+ sqlite3ExprCode(pParse, p->x.pList->a[i].pExpr, i+iResult);
92988
+ }
92989
+ }
92990
+ }
92991
+ return iResult;
92992
+}
92993
+
9216192994
9216292995
/*
9216392996
** Generate code into the current Vdbe to evaluate the given
9216492997
** expression. Attempt to store the results in register "target".
9216592998
** Return the register where results are stored.
@@ -92174,13 +93007,14 @@
9217493007
Vdbe *v = pParse->pVdbe; /* The VM under construction */
9217593008
int op; /* The opcode being coded */
9217693009
int inReg = target; /* Results stored in register inReg */
9217793010
int regFree1 = 0; /* If non-zero free this temporary register */
9217893011
int regFree2 = 0; /* If non-zero free this temporary register */
92179
- int r1, r2, r3, r4; /* Various register numbers */
93012
+ int r1, r2; /* Various register numbers */
9218093013
sqlite3 *db = pParse->db; /* The database connection */
9218193014
Expr tempX; /* Temporary expression node */
93015
+ int p5 = 0;
9218293016
9218393017
assert( target>0 && target<=pParse->nMem );
9218493018
if( v==0 ){
9218593019
assert( pParse->db->mallocFailed );
9218693020
return 0;
@@ -92289,43 +93123,38 @@
9228993123
testcase( usedAsColumnCache(pParse, inReg, inReg) );
9229093124
sqlite3ExprCacheAffinityChange(pParse, inReg, 1);
9229193125
break;
9229293126
}
9229393127
#endif /* SQLITE_OMIT_CAST */
93128
+ case TK_IS:
93129
+ case TK_ISNOT:
93130
+ op = (op==TK_IS) ? TK_EQ : TK_NE;
93131
+ p5 = SQLITE_NULLEQ;
93132
+ /* fall-through */
9229493133
case TK_LT:
9229593134
case TK_LE:
9229693135
case TK_GT:
9229793136
case TK_GE:
9229893137
case TK_NE:
9229993138
case TK_EQ: {
92300
- r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
92301
- r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
92302
- codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
92303
- r1, r2, inReg, SQLITE_STOREP2);
92304
- assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
92305
- assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
92306
- assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
92307
- assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
92308
- assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
92309
- assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
92310
- testcase( regFree1==0 );
92311
- testcase( regFree2==0 );
92312
- break;
92313
- }
92314
- case TK_IS:
92315
- case TK_ISNOT: {
92316
- testcase( op==TK_IS );
92317
- testcase( op==TK_ISNOT );
92318
- r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
92319
- r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
92320
- op = (op==TK_IS) ? TK_EQ : TK_NE;
92321
- codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
92322
- r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ);
92323
- VdbeCoverageIf(v, op==TK_EQ);
92324
- VdbeCoverageIf(v, op==TK_NE);
92325
- testcase( regFree1==0 );
92326
- testcase( regFree2==0 );
93139
+ Expr *pLeft = pExpr->pLeft;
93140
+ if( sqlite3ExprIsVector(pLeft) ){
93141
+ codeVectorCompare(pParse, pExpr, target, op, p5);
93142
+ }else{
93143
+ r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);
93144
+ r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
93145
+ codeCompare(pParse, pLeft, pExpr->pRight, op,
93146
+ r1, r2, inReg, SQLITE_STOREP2 | p5);
93147
+ assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
93148
+ assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
93149
+ assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
93150
+ assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
93151
+ assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
93152
+ assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
93153
+ testcase( regFree1==0 );
93154
+ testcase( regFree2==0 );
93155
+ }
9232793156
break;
9232893157
}
9232993158
case TK_AND:
9233093159
case TK_OR:
9233193160
case TK_PLUS:
@@ -92547,13 +93376,25 @@
9254793376
break;
9254893377
}
9254993378
#ifndef SQLITE_OMIT_SUBQUERY
9255093379
case TK_EXISTS:
9255193380
case TK_SELECT: {
93381
+ int nCol;
9255293382
testcase( op==TK_EXISTS );
9255393383
testcase( op==TK_SELECT );
92554
- inReg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
93384
+ if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){
93385
+ sqlite3SubselectError(pParse, nCol, 1);
93386
+ }else{
93387
+ inReg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
93388
+ }
93389
+ break;
93390
+ }
93391
+ case TK_SELECT_COLUMN: {
93392
+ if( pExpr->pLeft->iTable==0 ){
93393
+ pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft, 0, 0);
93394
+ }
93395
+ inReg = pExpr->pLeft->iTable + pExpr->iColumn;
9255593396
break;
9255693397
}
9255793398
case TK_IN: {
9255893399
int destIfFalse = sqlite3VdbeMakeLabel(v);
9255993400
int destIfNull = sqlite3VdbeMakeLabel(v);
@@ -92578,32 +93419,11 @@
9257893419
** X is stored in pExpr->pLeft.
9257993420
** Y is stored in pExpr->pList->a[0].pExpr.
9258093421
** Z is stored in pExpr->pList->a[1].pExpr.
9258193422
*/
9258293423
case TK_BETWEEN: {
92583
- Expr *pLeft = pExpr->pLeft;
92584
- struct ExprList_item *pLItem = pExpr->x.pList->a;
92585
- Expr *pRight = pLItem->pExpr;
92586
-
92587
- r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);
92588
- r2 = sqlite3ExprCodeTemp(pParse, pRight, &regFree2);
92589
- testcase( regFree1==0 );
92590
- testcase( regFree2==0 );
92591
- r3 = sqlite3GetTempReg(pParse);
92592
- r4 = sqlite3GetTempReg(pParse);
92593
- codeCompare(pParse, pLeft, pRight, OP_Ge,
92594
- r1, r2, r3, SQLITE_STOREP2); VdbeCoverage(v);
92595
- pLItem++;
92596
- pRight = pLItem->pExpr;
92597
- sqlite3ReleaseTempReg(pParse, regFree2);
92598
- r2 = sqlite3ExprCodeTemp(pParse, pRight, &regFree2);
92599
- testcase( regFree2==0 );
92600
- codeCompare(pParse, pLeft, pRight, OP_Le, r1, r2, r4, SQLITE_STOREP2);
92601
- VdbeCoverage(v);
92602
- sqlite3VdbeAddOp3(v, OP_And, r3, r4, target);
92603
- sqlite3ReleaseTempReg(pParse, r3);
92604
- sqlite3ReleaseTempReg(pParse, r4);
93424
+ exprCodeBetween(pParse, pExpr, target, 0, 0);
9260593425
break;
9260693426
}
9260793427
case TK_SPAN:
9260893428
case TK_COLLATE:
9260993429
case TK_UPLUS: {
@@ -92665,10 +93485,14 @@
9266593485
}
9266693486
#endif
9266793487
break;
9266893488
}
9266993489
93490
+ case TK_VECTOR: {
93491
+ sqlite3ErrorMsg(pParse, "row value misused");
93492
+ break;
93493
+ }
9267093494
9267193495
/*
9267293496
** Form A:
9267393497
** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END
9267493498
**
@@ -92708,12 +93532,13 @@
9270893532
nExpr = pEList->nExpr;
9270993533
endLabel = sqlite3VdbeMakeLabel(v);
9271093534
if( (pX = pExpr->pLeft)!=0 ){
9271193535
tempX = *pX;
9271293536
testcase( pX->op==TK_COLUMN );
92713
- exprToRegister(&tempX, sqlite3ExprCodeTemp(pParse, pX, &regFree1));
93537
+ exprToRegister(&tempX, exprCodeVector(pParse, &tempX, &regFree1));
9271493538
testcase( regFree1==0 );
93539
+ memset(&opCompare, 0, sizeof(opCompare));
9271593540
opCompare.op = TK_EQ;
9271693541
opCompare.pLeft = &tempX;
9271793542
pTest = &opCompare;
9271893543
/* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
9271993544
** The value in regFree1 might get SCopy-ed into the file result.
@@ -92988,24 +93813,37 @@
9298893813
**
9298993814
** x>=y AND x<=z
9299093815
**
9299193816
** Code it as such, taking care to do the common subexpression
9299293817
** elimination of x.
93818
+**
93819
+** The xJumpIf parameter determines details:
93820
+**
93821
+** NULL: Store the boolean result in reg[dest]
93822
+** sqlite3ExprIfTrue: Jump to dest if true
93823
+** sqlite3ExprIfFalse: Jump to dest if false
93824
+**
93825
+** The jumpIfNull parameter is ignored if xJumpIf is NULL.
9299393826
*/
9299493827
static void exprCodeBetween(
9299593828
Parse *pParse, /* Parsing and code generating context */
9299693829
Expr *pExpr, /* The BETWEEN expression */
92997
- int dest, /* Jump here if the jump is taken */
92998
- int jumpIfTrue, /* Take the jump if the BETWEEN is true */
93830
+ int dest, /* Jump destination or storage location */
93831
+ void (*xJump)(Parse*,Expr*,int,int), /* Action to take */
9299993832
int jumpIfNull /* Take the jump if the BETWEEN is NULL */
9300093833
){
93001
- Expr exprAnd; /* The AND operator in x>=y AND x<=z */
93834
+ Expr exprAnd; /* The AND operator in x>=y AND x<=z */
9300293835
Expr compLeft; /* The x>=y term */
9300393836
Expr compRight; /* The x<=z term */
9300493837
Expr exprX; /* The x subexpression */
9300593838
int regFree1 = 0; /* Temporary use register */
9300693839
93840
+
93841
+ memset(&compLeft, 0, sizeof(Expr));
93842
+ memset(&compRight, 0, sizeof(Expr));
93843
+ memset(&exprAnd, 0, sizeof(Expr));
93844
+
9300793845
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
9300893846
exprX = *pExpr->pLeft;
9300993847
exprAnd.op = TK_AND;
9301093848
exprAnd.pLeft = &compLeft;
9301193849
exprAnd.pRight = &compRight;
@@ -93013,27 +93851,29 @@
9301393851
compLeft.pLeft = &exprX;
9301493852
compLeft.pRight = pExpr->x.pList->a[0].pExpr;
9301593853
compRight.op = TK_LE;
9301693854
compRight.pLeft = &exprX;
9301793855
compRight.pRight = pExpr->x.pList->a[1].pExpr;
93018
- exprToRegister(&exprX, sqlite3ExprCodeTemp(pParse, &exprX, &regFree1));
93019
- if( jumpIfTrue ){
93020
- sqlite3ExprIfTrue(pParse, &exprAnd, dest, jumpIfNull);
93856
+ exprToRegister(&exprX, exprCodeVector(pParse, &exprX, &regFree1));
93857
+ if( xJump ){
93858
+ xJump(pParse, &exprAnd, dest, jumpIfNull);
9302193859
}else{
93022
- sqlite3ExprIfFalse(pParse, &exprAnd, dest, jumpIfNull);
93860
+ exprX.flags |= EP_FromJoin;
93861
+ sqlite3ExprCodeTarget(pParse, &exprAnd, dest);
9302393862
}
9302493863
sqlite3ReleaseTempReg(pParse, regFree1);
9302593864
9302693865
/* Ensure adequate test coverage */
93027
- testcase( jumpIfTrue==0 && jumpIfNull==0 && regFree1==0 );
93028
- testcase( jumpIfTrue==0 && jumpIfNull==0 && regFree1!=0 );
93029
- testcase( jumpIfTrue==0 && jumpIfNull!=0 && regFree1==0 );
93030
- testcase( jumpIfTrue==0 && jumpIfNull!=0 && regFree1!=0 );
93031
- testcase( jumpIfTrue!=0 && jumpIfNull==0 && regFree1==0 );
93032
- testcase( jumpIfTrue!=0 && jumpIfNull==0 && regFree1!=0 );
93033
- testcase( jumpIfTrue!=0 && jumpIfNull!=0 && regFree1==0 );
93034
- testcase( jumpIfTrue!=0 && jumpIfNull!=0 && regFree1!=0 );
93866
+ testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1==0 );
93867
+ testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1!=0 );
93868
+ testcase( xJump==sqlite3ExprIfTrue && jumpIfNull!=0 && regFree1==0 );
93869
+ testcase( xJump==sqlite3ExprIfTrue && jumpIfNull!=0 && regFree1!=0 );
93870
+ testcase( xJump==sqlite3ExprIfFalse && jumpIfNull==0 && regFree1==0 );
93871
+ testcase( xJump==sqlite3ExprIfFalse && jumpIfNull==0 && regFree1!=0 );
93872
+ testcase( xJump==sqlite3ExprIfFalse && jumpIfNull!=0 && regFree1==0 );
93873
+ testcase( xJump==sqlite3ExprIfFalse && jumpIfNull!=0 && regFree1!=0 );
93874
+ testcase( xJump==0 );
9303593875
}
9303693876
9303793877
/*
9303893878
** Generate code for a boolean expression such that a jump is made
9303993879
** to the label "dest" if the expression is true but execution
@@ -93094,10 +93934,11 @@
9309493934
case TK_LE:
9309593935
case TK_GT:
9309693936
case TK_GE:
9309793937
case TK_NE:
9309893938
case TK_EQ: {
93939
+ if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
9309993940
testcase( jumpIfNull==0 );
9310093941
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
9310193942
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
9310293943
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
9310393944
r1, r2, dest, jumpIfNull);
@@ -93126,11 +93967,11 @@
9312693967
testcase( regFree1==0 );
9312793968
break;
9312893969
}
9312993970
case TK_BETWEEN: {
9313093971
testcase( jumpIfNull==0 );
93131
- exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull);
93972
+ exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfTrue, jumpIfNull);
9313293973
break;
9313393974
}
9313493975
#ifndef SQLITE_OMIT_SUBQUERY
9313593976
case TK_IN: {
9313693977
int destIfFalse = sqlite3VdbeMakeLabel(v);
@@ -93140,10 +93981,11 @@
9314093981
sqlite3VdbeResolveLabel(v, destIfFalse);
9314193982
break;
9314293983
}
9314393984
#endif
9314493985
default: {
93986
+ default_expr:
9314593987
if( exprAlwaysTrue(pExpr) ){
9314693988
sqlite3VdbeGoto(v, dest);
9314793989
}else if( exprAlwaysFalse(pExpr) ){
9314893990
/* No-op */
9314993991
}else{
@@ -93246,10 +94088,11 @@
9324694088
case TK_LE:
9324794089
case TK_GT:
9324894090
case TK_GE:
9324994091
case TK_NE:
9325094092
case TK_EQ: {
94093
+ if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
9325194094
testcase( jumpIfNull==0 );
9325294095
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
9325394096
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
9325494097
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
9325594098
r1, r2, dest, jumpIfNull);
@@ -93276,11 +94119,11 @@
9327694119
testcase( regFree1==0 );
9327794120
break;
9327894121
}
9327994122
case TK_BETWEEN: {
9328094123
testcase( jumpIfNull==0 );
93281
- exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull);
94124
+ exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfFalse, jumpIfNull);
9328294125
break;
9328394126
}
9328494127
#ifndef SQLITE_OMIT_SUBQUERY
9328594128
case TK_IN: {
9328694129
if( jumpIfNull ){
@@ -93292,10 +94135,11 @@
9329294135
}
9329394136
break;
9329494137
}
9329594138
#endif
9329694139
default: {
94140
+ default_expr:
9329794141
if( exprAlwaysFalse(pExpr) ){
9329894142
sqlite3VdbeGoto(v, dest);
9329994143
}else if( exprAlwaysTrue(pExpr) ){
9330094144
/* no-op */
9330194145
}else{
@@ -93807,14 +94651,15 @@
9380794651
pParse->aTempReg[pParse->nTempReg++] = iReg;
9380894652
}
9380994653
}
9381094654
9381194655
/*
93812
-** Allocate or deallocate a block of nReg consecutive registers
94656
+** Allocate or deallocate a block of nReg consecutive registers.
9381394657
*/
9381494658
SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
9381594659
int i, n;
94660
+ if( nReg==1 ) return sqlite3GetTempReg(pParse);
9381694661
i = pParse->iRangeReg;
9381794662
n = pParse->nRangeReg;
9381894663
if( nReg<=n ){
9381994664
assert( !usedAsColumnCache(pParse, i, i+n-1) );
9382094665
pParse->iRangeReg += nReg;
@@ -93824,10 +94669,14 @@
9382494669
pParse->nMem += nReg;
9382594670
}
9382694671
return i;
9382794672
}
9382894673
SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
94674
+ if( nReg==1 ){
94675
+ sqlite3ReleaseTempReg(pParse, iReg);
94676
+ return;
94677
+ }
9382994678
sqlite3ExprCacheRemove(pParse, iReg, nReg);
9383094679
if( nReg>pParse->nRangeReg ){
9383194680
pParse->nRangeReg = nReg;
9383294681
pParse->iRangeReg = iReg;
9383394682
}
@@ -97568,12 +98417,12 @@
9756898417
9756998418
#if SQLITE_USER_AUTHENTICATION
9757098419
if( pParse->nTableLock>0 && db->init.busy==0 ){
9757198420
sqlite3UserAuthInit(db);
9757298421
if( db->auth.authLevel<UAUTH_User ){
97573
- pParse->rc = SQLITE_AUTH_USER;
9757498422
sqlite3ErrorMsg(pParse, "user not authenticated");
98423
+ pParse->rc = SQLITE_AUTH_USER;
9757598424
return;
9757698425
}
9757798426
}
9757898427
#endif
9757998428
@@ -108279,19 +109128,19 @@
108279109128
}
108280109129
if( piIdxCur ) *piIdxCur = iBase;
108281109130
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
108282109131
int iIdxCur = iBase++;
108283109132
assert( pIdx->pSchema==pTab->pSchema );
109133
+ if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
109134
+ if( piDataCur ) *piDataCur = iIdxCur;
109135
+ p5 = 0;
109136
+ }
108284109137
if( aToOpen==0 || aToOpen[i+1] ){
108285109138
sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);
108286109139
sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
108287
- VdbeComment((v, "%s", pIdx->zName));
108288
- }
108289
- if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
108290
- if( piDataCur ) *piDataCur = iIdxCur;
108291
- }else{
108292109140
sqlite3VdbeChangeP5(v, p5);
109141
+ VdbeComment((v, "%s", pIdx->zName));
108293109142
}
108294109143
}
108295109144
if( iBase>pParse->nTab ) pParse->nTab = iBase;
108296109145
return i;
108297109146
}
@@ -113611,11 +114460,11 @@
113611114460
** Initialize a SelectDest structure.
113612114461
*/
113613114462
SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){
113614114463
pDest->eDest = (u8)eDest;
113615114464
pDest->iSDParm = iParm;
113616
- pDest->affSdst = 0;
114465
+ pDest->zAffSdst = 0;
113617114466
pDest->iSdst = 0;
113618114467
pDest->nSdst = 0;
113619114468
}
113620114469
113621114470
@@ -114182,34 +115031,10 @@
114182115031
sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);
114183115032
sqlite3VdbeAddOp2(v, OP_IdxInsert, iTab, r1);
114184115033
sqlite3ReleaseTempReg(pParse, r1);
114185115034
}
114186115035
114187
-#ifndef SQLITE_OMIT_SUBQUERY
114188
-/*
114189
-** Generate an error message when a SELECT is used within a subexpression
114190
-** (example: "a IN (SELECT * FROM table)") but it has more than 1 result
114191
-** column. We do this in a subroutine because the error used to occur
114192
-** in multiple places. (The error only occurs in one place now, but we
114193
-** retain the subroutine to minimize code disruption.)
114194
-*/
114195
-static int checkForMultiColumnSelectError(
114196
- Parse *pParse, /* Parse context. */
114197
- SelectDest *pDest, /* Destination of SELECT results */
114198
- int nExpr /* Number of result columns returned by SELECT */
114199
-){
114200
- int eDest = pDest->eDest;
114201
- if( nExpr>1 && (eDest==SRT_Mem || eDest==SRT_Set) ){
114202
- sqlite3ErrorMsg(pParse, "only a single result allowed for "
114203
- "a SELECT that is part of an expression");
114204
- return 1;
114205
- }else{
114206
- return 0;
114207
- }
114208
-}
114209
-#endif
114210
-
114211115036
/*
114212115037
** This routine generates the code for the inside of the inner loop
114213115038
** of a SELECT.
114214115039
**
114215115040
** If srcTab is negative, then the pEList expressions
@@ -114415,23 +115240,23 @@
114415115240
/* If we are creating a set for an "expr IN (SELECT ...)" construct,
114416115241
** then there should be a single item on the stack. Write this
114417115242
** item into the set table with bogus data.
114418115243
*/
114419115244
case SRT_Set: {
114420
- assert( nResultCol==1 );
114421
- pDest->affSdst =
114422
- sqlite3CompareAffinity(pEList->a[0].pExpr, pDest->affSdst);
114423115245
if( pSort ){
114424115246
/* At first glance you would think we could optimize out the
114425115247
** ORDER BY in this case since the order of entries in the set
114426115248
** does not matter. But there might be a LIMIT clause, in which
114427115249
** case the order does matter */
114428
- pushOntoSorter(pParse, pSort, p, regResult, regResult, 1, nPrefixReg);
115250
+ pushOntoSorter(
115251
+ pParse, pSort, p, regResult, regResult, nResultCol, nPrefixReg);
114429115252
}else{
114430115253
int r1 = sqlite3GetTempReg(pParse);
114431
- sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult,1,r1, &pDest->affSdst, 1);
114432
- sqlite3ExprCacheAffinityChange(pParse, regResult, 1);
115254
+ assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol );
115255
+ sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, nResultCol,
115256
+ r1, pDest->zAffSdst, nResultCol);
115257
+ sqlite3ExprCacheAffinityChange(pParse, regResult, nResultCol);
114433115258
sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1);
114434115259
sqlite3ReleaseTempReg(pParse, r1);
114435115260
}
114436115261
break;
114437115262
}
@@ -114443,17 +115268,18 @@
114443115268
/* The LIMIT clause will terminate the loop for us */
114444115269
break;
114445115270
}
114446115271
114447115272
/* If this is a scalar select that is part of an expression, then
114448
- ** store the results in the appropriate memory cell and break out
114449
- ** of the scan loop.
115273
+ ** store the results in the appropriate memory cell or array of
115274
+ ** memory cells and break out of the scan loop.
114450115275
*/
114451115276
case SRT_Mem: {
114452
- assert( nResultCol==1 );
115277
+ assert( nResultCol==pDest->nSdst );
114453115278
if( pSort ){
114454
- pushOntoSorter(pParse, pSort, p, regResult, regResult, 1, nPrefixReg);
115279
+ pushOntoSorter(
115280
+ pParse, pSort, p, regResult, regResult, nResultCol, nPrefixReg);
114455115281
}else{
114456115282
assert( regResult==iParm );
114457115283
/* The LIMIT clause will jump out of the loop for us */
114458115284
}
114459115285
break;
@@ -114764,18 +115590,18 @@
114764115590
sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
114765115591
sqlite3VdbeGoto(v, addrBreak);
114766115592
sqlite3VdbeResolveLabel(v, pSort->labelBkOut);
114767115593
}
114768115594
iTab = pSort->iECursor;
114769
- if( eDest==SRT_Output || eDest==SRT_Coroutine ){
115595
+ if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){
114770115596
regRowid = 0;
114771115597
regRow = pDest->iSdst;
114772115598
nSortData = nColumn;
114773115599
}else{
114774115600
regRowid = sqlite3GetTempReg(pParse);
114775
- regRow = sqlite3GetTempReg(pParse);
114776
- nSortData = 1;
115601
+ regRow = sqlite3GetTempRange(pParse, nColumn);
115602
+ nSortData = nColumn;
114777115603
}
114778115604
nKey = pOrderBy->nExpr - pSort->nOBSat;
114779115605
if( pSort->sortFlags & SORTFLAG_UseSorter ){
114780115606
int regSortOut = ++pParse->nMem;
114781115607
iSortTab = pParse->nTab++;
@@ -114806,20 +115632,18 @@
114806115632
sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
114807115633
break;
114808115634
}
114809115635
#ifndef SQLITE_OMIT_SUBQUERY
114810115636
case SRT_Set: {
114811
- assert( nColumn==1 );
114812
- sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, 1, regRowid,
114813
- &pDest->affSdst, 1);
114814
- sqlite3ExprCacheAffinityChange(pParse, regRow, 1);
115637
+ assert( nColumn==sqlite3Strlen30(pDest->zAffSdst) );
115638
+ sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, nColumn, regRowid,
115639
+ pDest->zAffSdst, nColumn);
115640
+ sqlite3ExprCacheAffinityChange(pParse, regRow, nColumn);
114815115641
sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, regRowid);
114816115642
break;
114817115643
}
114818115644
case SRT_Mem: {
114819
- assert( nColumn==1 );
114820
- sqlite3ExprCodeMove(pParse, regRow, iParm, 1);
114821115645
/* The LIMIT clause will terminate the loop for us */
114822115646
break;
114823115647
}
114824115648
#endif
114825115649
default: {
@@ -114834,11 +115658,15 @@
114834115658
}
114835115659
break;
114836115660
}
114837115661
}
114838115662
if( regRowid ){
114839
- sqlite3ReleaseTempReg(pParse, regRow);
115663
+ if( eDest==SRT_Set ){
115664
+ sqlite3ReleaseTempRange(pParse, regRow, nColumn);
115665
+ }else{
115666
+ sqlite3ReleaseTempReg(pParse, regRow);
115667
+ }
114840115668
sqlite3ReleaseTempReg(pParse, regRowid);
114841115669
}
114842115670
/* The bottom of the loop
114843115671
*/
114844115672
sqlite3VdbeResolveLabel(v, addrContinue);
@@ -115336,11 +116164,11 @@
115336116164
** Get a VDBE for the given parser context. Create a new one if necessary.
115337116165
** If an error occurs, return NULL and leave a message in pParse.
115338116166
*/
115339116167
static SQLITE_NOINLINE Vdbe *allocVdbe(Parse *pParse){
115340116168
Vdbe *v = pParse->pVdbe = sqlite3VdbeCreate(pParse);
115341
- if( v ) sqlite3VdbeAddOp0(v, OP_Init);
116169
+ if( v ) sqlite3VdbeAddOp2(v, OP_Init, 0, 1);
115342116170
if( pParse->pToplevel==0
115343116171
&& OptimizationEnabled(pParse->db,SQLITE_FactorOutConst)
115344116172
){
115345116173
pParse->okConstFactor = 1;
115346116174
}
@@ -116175,22 +117003,19 @@
116175117003
sqlite3ReleaseTempReg(pParse, r1);
116176117004
break;
116177117005
}
116178117006
116179117007
#ifndef SQLITE_OMIT_SUBQUERY
116180
- /* If we are creating a set for an "expr IN (SELECT ...)" construct,
116181
- ** then there should be a single item on the stack. Write this
116182
- ** item into the set table with bogus data.
117008
+ /* If we are creating a set for an "expr IN (SELECT ...)".
116183117009
*/
116184117010
case SRT_Set: {
116185117011
int r1;
116186
- assert( pIn->nSdst==1 || pParse->nErr>0 );
116187
- pDest->affSdst =
116188
- sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affSdst);
117012
+ testcase( pIn->nSdst>1 );
116189117013
r1 = sqlite3GetTempReg(pParse);
116190
- sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, 1, r1, &pDest->affSdst,1);
116191
- sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1);
117014
+ sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst,
117015
+ r1, pDest->zAffSdst, pIn->nSdst);
117016
+ sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);
116192117017
sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iSDParm, r1);
116193117018
sqlite3ReleaseTempReg(pParse, r1);
116194117019
break;
116195117020
}
116196117021
@@ -118418,20 +119243,10 @@
118418119243
#if SELECTTRACE_ENABLED
118419119244
if( sqlite3SelectTrace & 0x100 ){
118420119245
SELECTTRACE(0x100,pParse,p, ("after name resolution:\n"));
118421119246
sqlite3TreeViewSelect(0, p, 0);
118422119247
}
118423
-#endif
118424
-
118425
-
118426
- /* If writing to memory or generating a set
118427
- ** only a single column may be output.
118428
- */
118429
-#ifndef SQLITE_OMIT_SUBQUERY
118430
- if( checkForMultiColumnSelectError(pParse, pDest, p->pEList->nExpr) ){
118431
- goto select_end;
118432
- }
118433119248
#endif
118434119249
118435119250
/* Try to flatten subqueries in the FROM clause up into the main query
118436119251
*/
118437119252
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
@@ -122398,11 +123213,11 @@
122398123213
122399123214
/*
122400123215
** This function is invoked by the vdbe to call the xCreate method
122401123216
** of the virtual table named zTab in database iDb.
122402123217
**
122403
-** If an error occurs, *pzErr is set to point an an English language
123218
+** If an error occurs, *pzErr is set to point to an English language
122404123219
** description of the error and an SQLITE_XXX error code is returned.
122405123220
** In this case the caller must call sqlite3DbFree(db, ) on *pzErr.
122406123221
*/
122407123222
SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
122408123223
int rc = SQLITE_OK;
@@ -123099,10 +123914,12 @@
123099123914
LogEst rRun; /* Cost of running each loop */
123100123915
LogEst nOut; /* Estimated number of output rows */
123101123916
union {
123102123917
struct { /* Information for internal btree tables */
123103123918
u16 nEq; /* Number of equality constraints */
123919
+ u16 nBtm; /* Size of BTM vector */
123920
+ u16 nTop; /* Size of TOP vector */
123104123921
Index *pIndex; /* Index used, or NULL */
123105123922
} btree;
123106123923
struct { /* Information for virtual tables */
123107123924
int idxNum; /* Index number */
123108123925
u8 needFree; /* True if sqlite3_free(idxStr) is needed */
@@ -123223,10 +124040,11 @@
123223124040
*/
123224124041
struct WhereTerm {
123225124042
Expr *pExpr; /* Pointer to the subexpression that is this term */
123226124043
int iParent; /* Disable pWC->a[iParent] when this term disabled */
123227124044
int leftCursor; /* Cursor number of X in "X <op> <expr>" */
124045
+ int iField; /* Field in (?,?,?) IN (SELECT...) vector */
123228124046
union {
123229124047
int leftColumn; /* Column number of X in "X <op> <expr>" */
123230124048
WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
123231124049
WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
123232124050
} u;
@@ -123528,10 +124346,21 @@
123528124346
123529124347
/************** End of whereInt.h ********************************************/
123530124348
/************** Continuing where we left off in wherecode.c ******************/
123531124349
123532124350
#ifndef SQLITE_OMIT_EXPLAIN
124351
+
124352
+/*
124353
+** Return the name of the i-th column of the pIdx index.
124354
+*/
124355
+static const char *explainIndexColumnName(Index *pIdx, int i){
124356
+ i = pIdx->aiColumn[i];
124357
+ if( i==XN_EXPR ) return "<expr>";
124358
+ if( i==XN_ROWID ) return "rowid";
124359
+ return pIdx->pTable->aCol[i].zName;
124360
+}
124361
+
123533124362
/*
123534124363
** This routine is a helper for explainIndexRange() below
123535124364
**
123536124365
** pStr holds the text of an expression that we are building up one term
123537124366
** at a time. This routine adds a new term to the end of the expression.
@@ -123538,28 +124367,36 @@
123538124367
** Terms are separated by AND so add the "AND" text for second and subsequent
123539124368
** terms only.
123540124369
*/
123541124370
static void explainAppendTerm(
123542124371
StrAccum *pStr, /* The text expression being built */
123543
- int iTerm, /* Index of this term. First is zero */
123544
- const char *zColumn, /* Name of the column */
124372
+ Index *pIdx, /* Index to read column names from */
124373
+ int nTerm, /* Number of terms */
124374
+ int iTerm, /* Zero-based index of first term. */
124375
+ int bAnd, /* Non-zero to append " AND " */
123545124376
const char *zOp /* Name of the operator */
123546124377
){
123547
- if( iTerm ) sqlite3StrAccumAppend(pStr, " AND ", 5);
123548
- sqlite3StrAccumAppendAll(pStr, zColumn);
124378
+ int i;
124379
+
124380
+ assert( nTerm>=1 );
124381
+ if( bAnd ) sqlite3StrAccumAppend(pStr, " AND ", 5);
124382
+
124383
+ if( nTerm>1 ) sqlite3StrAccumAppend(pStr, "(", 1);
124384
+ for(i=0; i<nTerm; i++){
124385
+ if( i ) sqlite3StrAccumAppend(pStr, ",", 1);
124386
+ sqlite3StrAccumAppendAll(pStr, explainIndexColumnName(pIdx, iTerm+i));
124387
+ }
124388
+ if( nTerm>1 ) sqlite3StrAccumAppend(pStr, ")", 1);
124389
+
123549124390
sqlite3StrAccumAppend(pStr, zOp, 1);
123550
- sqlite3StrAccumAppend(pStr, "?", 1);
123551
-}
123552
-
123553
-/*
123554
-** Return the name of the i-th column of the pIdx index.
123555
-*/
123556
-static const char *explainIndexColumnName(Index *pIdx, int i){
123557
- i = pIdx->aiColumn[i];
123558
- if( i==XN_EXPR ) return "<expr>";
123559
- if( i==XN_ROWID ) return "rowid";
123560
- return pIdx->pTable->aCol[i].zName;
124391
+
124392
+ if( nTerm>1 ) sqlite3StrAccumAppend(pStr, "(", 1);
124393
+ for(i=0; i<nTerm; i++){
124394
+ if( i ) sqlite3StrAccumAppend(pStr, ",", 1);
124395
+ sqlite3StrAccumAppend(pStr, "?", 1);
124396
+ }
124397
+ if( nTerm>1 ) sqlite3StrAccumAppend(pStr, ")", 1);
123561124398
}
123562124399
123563124400
/*
123564124401
** Argument pLevel describes a strategy for scanning table pTab. This
123565124402
** function appends text to pStr that describes the subset of table
@@ -123588,16 +124425,15 @@
123588124425
sqlite3XPrintf(pStr, i>=nSkip ? "%s=?" : "ANY(%s)", z);
123589124426
}
123590124427
123591124428
j = i;
123592124429
if( pLoop->wsFlags&WHERE_BTM_LIMIT ){
123593
- const char *z = explainIndexColumnName(pIndex, i);
123594
- explainAppendTerm(pStr, i++, z, ">");
124430
+ explainAppendTerm(pStr, pIndex, pLoop->u.btree.nBtm, j, i, ">");
124431
+ i = 1;
123595124432
}
123596124433
if( pLoop->wsFlags&WHERE_TOP_LIMIT ){
123597
- const char *z = explainIndexColumnName(pIndex, j);
123598
- explainAppendTerm(pStr, i, z, "<");
124434
+ explainAppendTerm(pStr, pIndex, pLoop->u.btree.nTop, j, i, "<");
123599124435
}
123600124436
sqlite3StrAccumAppend(pStr, ")", 1);
123601124437
}
123602124438
123603124439
/*
@@ -123783,11 +124619,11 @@
123783124619
** a conditional such that is only evaluated on the second pass of a
123784124620
** LIKE-optimization loop, when scanning BLOBs instead of strings.
123785124621
*/
123786124622
static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){
123787124623
int nLoop = 0;
123788
- while( pTerm
124624
+ while( ALWAYS(pTerm!=0)
123789124625
&& (pTerm->wtFlags & TERM_CODED)==0
123790124626
&& (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
123791124627
&& (pLevel->notReady & pTerm->prereqAll)==0
123792124628
){
123793124629
if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){
@@ -123839,20 +124675,50 @@
123839124675
sqlite3VdbeAddOp4(v, OP_Affinity, base, n, 0, zAff, n);
123840124676
sqlite3ExprCacheAffinityChange(pParse, base, n);
123841124677
}
123842124678
}
123843124679
124680
+/*
124681
+** Expression pRight, which is the RHS of a comparison operation, is
124682
+** either a vector of n elements or, if n==1, a scalar expression.
124683
+** Before the comparison operation, affinity zAff is to be applied
124684
+** to the pRight values. This function modifies characters within the
124685
+** affinity string to SQLITE_AFF_BLOB if either:
124686
+**
124687
+** * the comparison will be performed with no affinity, or
124688
+** * the affinity change in zAff is guaranteed not to change the value.
124689
+*/
124690
+static void updateRangeAffinityStr(
124691
+ Parse *pParse, /* Parse context */
124692
+ Expr *pRight, /* RHS of comparison */
124693
+ int n, /* Number of vector elements in comparison */
124694
+ char *zAff /* Affinity string to modify */
124695
+){
124696
+ int i;
124697
+ for(i=0; i<n; i++){
124698
+ Expr *p = sqlite3VectorFieldSubexpr(pRight, i);
124699
+ if( sqlite3CompareAffinity(p, zAff[i])==SQLITE_AFF_BLOB
124700
+ || sqlite3ExprNeedsNoAffinityChange(p, zAff[i])
124701
+ ){
124702
+ zAff[i] = SQLITE_AFF_BLOB;
124703
+ }
124704
+ }
124705
+}
123844124706
123845124707
/*
123846124708
** Generate code for a single equality term of the WHERE clause. An equality
123847124709
** term can be either X=expr or X IN (...). pTerm is the term to be
123848124710
** coded.
123849124711
**
123850
-** The current value for the constraint is left in register iReg.
124712
+** The current value for the constraint is left in a register, the index
124713
+** of which is returned. An attempt is made store the result in iTarget but
124714
+** this is only guaranteed for TK_ISNULL and TK_IN constraints. If the
124715
+** constraint is a TK_EQ or TK_IS, then the current value might be left in
124716
+** some other register and it is the caller's responsibility to compensate.
123851124717
**
123852
-** For a constraint of the form X=expr, the expression is evaluated and its
123853
-** result is left on the stack. For constraints of the form X IN (...)
124718
+** For a constraint of the form X=expr, the expression is evaluated in
124719
+** straight-line code. For constraints of the form X IN (...)
123854124720
** this routine sets up a loop that will iterate over all values of X.
123855124721
*/
123856124722
static int codeEqualityTerm(
123857124723
Parse *pParse, /* The parsing context */
123858124724
WhereTerm *pTerm, /* The term of the WHERE clause to be coded */
@@ -123863,22 +124729,26 @@
123863124729
){
123864124730
Expr *pX = pTerm->pExpr;
123865124731
Vdbe *v = pParse->pVdbe;
123866124732
int iReg; /* Register holding results */
123867124733
124734
+ assert( pLevel->pWLoop->aLTerm[iEq]==pTerm );
123868124735
assert( iTarget>0 );
123869124736
if( pX->op==TK_EQ || pX->op==TK_IS ){
123870124737
iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget);
123871124738
}else if( pX->op==TK_ISNULL ){
123872124739
iReg = iTarget;
123873124740
sqlite3VdbeAddOp2(v, OP_Null, 0, iReg);
123874124741
#ifndef SQLITE_OMIT_SUBQUERY
123875124742
}else{
123876
- int eType;
124743
+ int eType = IN_INDEX_NOOP;
123877124744
int iTab;
123878124745
struct InLoop *pIn;
123879124746
WhereLoop *pLoop = pLevel->pWLoop;
124747
+ int i;
124748
+ int nEq = 0;
124749
+ int *aiMap = 0;
123880124750
123881124751
if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0
123882124752
&& pLoop->u.btree.pIndex!=0
123883124753
&& pLoop->u.btree.pIndex->aSortOrder[iEq]
123884124754
){
@@ -123886,42 +124756,128 @@
123886124756
testcase( bRev );
123887124757
bRev = !bRev;
123888124758
}
123889124759
assert( pX->op==TK_IN );
123890124760
iReg = iTarget;
123891
- eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0);
124761
+
124762
+ for(i=0; i<iEq; i++){
124763
+ if( pLoop->aLTerm[i] && pLoop->aLTerm[i]->pExpr==pX ){
124764
+ disableTerm(pLevel, pTerm);
124765
+ return iTarget;
124766
+ }
124767
+ }
124768
+ for(i=iEq;i<pLoop->nLTerm; i++){
124769
+ if( ALWAYS(pLoop->aLTerm[i]) && pLoop->aLTerm[i]->pExpr==pX ) nEq++;
124770
+ }
124771
+
124772
+ if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){
124773
+ eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0);
124774
+ }else{
124775
+ Select *pSelect = pX->x.pSelect;
124776
+ sqlite3 *db = pParse->db;
124777
+ ExprList *pOrigRhs = pSelect->pEList;
124778
+ ExprList *pOrigLhs = pX->pLeft->x.pList;
124779
+ ExprList *pRhs = 0; /* New Select.pEList for RHS */
124780
+ ExprList *pLhs = 0; /* New pX->pLeft vector */
124781
+
124782
+ for(i=iEq;i<pLoop->nLTerm; i++){
124783
+ if( pLoop->aLTerm[i]->pExpr==pX ){
124784
+ int iField = pLoop->aLTerm[i]->iField - 1;
124785
+ Expr *pNewRhs = sqlite3ExprDup(db, pOrigRhs->a[iField].pExpr, 0);
124786
+ Expr *pNewLhs = sqlite3ExprDup(db, pOrigLhs->a[iField].pExpr, 0);
124787
+
124788
+ pRhs = sqlite3ExprListAppend(pParse, pRhs, pNewRhs);
124789
+ pLhs = sqlite3ExprListAppend(pParse, pLhs, pNewLhs);
124790
+ }
124791
+ }
124792
+ if( !db->mallocFailed ){
124793
+ Expr *pLeft = pX->pLeft;
124794
+
124795
+ if( pSelect->pOrderBy ){
124796
+ /* If the SELECT statement has an ORDER BY clause, zero the
124797
+ ** iOrderByCol variables. These are set to non-zero when an
124798
+ ** ORDER BY term exactly matches one of the terms of the
124799
+ ** result-set. Since the result-set of the SELECT statement may
124800
+ ** have been modified or reordered, these variables are no longer
124801
+ ** set correctly. Since setting them is just an optimization,
124802
+ ** it's easiest just to zero them here. */
124803
+ ExprList *pOrderBy = pSelect->pOrderBy;
124804
+ for(i=0; i<pOrderBy->nExpr; i++){
124805
+ pOrderBy->a[i].u.x.iOrderByCol = 0;
124806
+ }
124807
+ }
124808
+
124809
+ /* Take care here not to generate a TK_VECTOR containing only a
124810
+ ** single value. Since the parser never creates such a vector, some
124811
+ ** of the subroutines do not handle this case. */
124812
+ if( pLhs->nExpr==1 ){
124813
+ pX->pLeft = pLhs->a[0].pExpr;
124814
+ }else{
124815
+ pLeft->x.pList = pLhs;
124816
+ aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int) * nEq);
124817
+ testcase( aiMap==0 );
124818
+ }
124819
+ pSelect->pEList = pRhs;
124820
+ eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap);
124821
+ testcase( aiMap!=0 && aiMap[0]!=0 );
124822
+ pSelect->pEList = pOrigRhs;
124823
+ pLeft->x.pList = pOrigLhs;
124824
+ pX->pLeft = pLeft;
124825
+ }
124826
+ sqlite3ExprListDelete(pParse->db, pLhs);
124827
+ sqlite3ExprListDelete(pParse->db, pRhs);
124828
+ }
124829
+
123892124830
if( eType==IN_INDEX_INDEX_DESC ){
123893124831
testcase( bRev );
123894124832
bRev = !bRev;
123895124833
}
123896124834
iTab = pX->iTable;
123897124835
sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);
123898124836
VdbeCoverageIf(v, bRev);
123899124837
VdbeCoverageIf(v, !bRev);
123900124838
assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );
124839
+
123901124840
pLoop->wsFlags |= WHERE_IN_ABLE;
123902124841
if( pLevel->u.in.nIn==0 ){
123903124842
pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
123904124843
}
123905
- pLevel->u.in.nIn++;
124844
+
124845
+ i = pLevel->u.in.nIn;
124846
+ pLevel->u.in.nIn += nEq;
123906124847
pLevel->u.in.aInLoop =
123907124848
sqlite3DbReallocOrFree(pParse->db, pLevel->u.in.aInLoop,
123908124849
sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn);
123909124850
pIn = pLevel->u.in.aInLoop;
123910124851
if( pIn ){
123911
- pIn += pLevel->u.in.nIn - 1;
123912
- pIn->iCur = iTab;
123913
- if( eType==IN_INDEX_ROWID ){
123914
- pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iReg);
123915
- }else{
123916
- pIn->addrInTop = sqlite3VdbeAddOp3(v, OP_Column, iTab, 0, iReg);
123917
- }
123918
- pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;
123919
- sqlite3VdbeAddOp1(v, OP_IsNull, iReg); VdbeCoverage(v);
124852
+ int iMap = 0; /* Index in aiMap[] */
124853
+ pIn += i;
124854
+ for(i=iEq;i<pLoop->nLTerm; i++){
124855
+ int iOut = iReg;
124856
+ if( pLoop->aLTerm[i]->pExpr==pX ){
124857
+ if( eType==IN_INDEX_ROWID ){
124858
+ assert( nEq==1 && i==iEq );
124859
+ pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iReg);
124860
+ }else{
124861
+ int iCol = aiMap ? aiMap[iMap++] : 0;
124862
+ iOut = iReg + i - iEq;
124863
+ pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut);
124864
+ }
124865
+ sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);
124866
+ if( i==iEq ){
124867
+ pIn->iCur = iTab;
124868
+ pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;
124869
+ }else{
124870
+ pIn->eEndLoopOp = OP_Noop;
124871
+ }
124872
+ pIn++;
124873
+ }
124874
+ }
123920124875
}else{
123921124876
pLevel->u.in.nIn = 0;
123922124877
}
124878
+ sqlite3DbFree(pParse->db, aiMap);
123923124879
#endif
123924124880
}
123925124881
disableTerm(pLevel, pTerm);
123926124882
return iReg;
123927124883
}
@@ -124043,13 +124999,19 @@
124043124999
regBase = r1;
124044125000
}else{
124045125001
sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);
124046125002
}
124047125003
}
124048
- testcase( pTerm->eOperator & WO_ISNULL );
124049
- testcase( pTerm->eOperator & WO_IN );
124050
- if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){
125004
+ if( pTerm->eOperator & WO_IN ){
125005
+ if( pTerm->pExpr->flags & EP_xIsSelect ){
125006
+ /* No affinity ever needs to be (or should be) applied to a value
125007
+ ** from the RHS of an "? IN (SELECT ...)" expression. The
125008
+ ** sqlite3FindInIndex() routine has already ensured that the
125009
+ ** affinity of the comparison has been applied to the value. */
125010
+ if( zAff ) zAff[j] = SQLITE_AFF_BLOB;
125011
+ }
125012
+ }else if( (pTerm->eOperator & WO_ISNULL)==0 ){
124051125013
Expr *pRight = pTerm->pExpr->pRight;
124052125014
if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
124053125015
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
124054125016
VdbeCoverage(v);
124055125017
}
@@ -124367,10 +125329,43 @@
124367125329
}
124368125330
sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);
124369125331
}
124370125332
}
124371125333
}
125334
+
125335
+/*
125336
+** If the expression passed as the second argument is a vector, generate
125337
+** code to write the first nReg elements of the vector into an array
125338
+** of registers starting with iReg.
125339
+**
125340
+** If the expression is not a vector, then nReg must be passed 1. In
125341
+** this case, generate code to evaluate the expression and leave the
125342
+** result in register iReg.
125343
+*/
125344
+static void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){
125345
+ assert( nReg>0 );
125346
+ if( sqlite3ExprIsVector(p) ){
125347
+#ifndef SQLITE_OMIT_SUBQUERY
125348
+ if( (p->flags & EP_xIsSelect) ){
125349
+ Vdbe *v = pParse->pVdbe;
125350
+ int iSelect = sqlite3CodeSubselect(pParse, p, 0, 0);
125351
+ sqlite3VdbeAddOp3(v, OP_Copy, iSelect, iReg, nReg-1);
125352
+ }else
125353
+#endif
125354
+ {
125355
+ int i;
125356
+ ExprList *pList = p->x.pList;
125357
+ assert( nReg<=pList->nExpr );
125358
+ for(i=0; i<nReg; i++){
125359
+ sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i);
125360
+ }
125361
+ }
125362
+ }else{
125363
+ assert( nReg==1 );
125364
+ sqlite3ExprCode(pParse, p, iReg);
125365
+ }
125366
+}
124372125367
124373125368
/*
124374125369
** Generate code for the start of the iLevel-th loop in the WHERE clause
124375125370
** implementation described by pWInfo.
124376125371
*/
@@ -124463,11 +125458,12 @@
124463125458
if( NEVER(pTerm==0) ) continue;
124464125459
if( pTerm->eOperator & WO_IN ){
124465125460
codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
124466125461
addrNotFound = pLevel->addrNxt;
124467125462
}else{
124468
- sqlite3ExprCode(pParse, pTerm->pExpr->pRight, iTarget);
125463
+ Expr *pRight = pTerm->pExpr->pRight;
125464
+ codeExprOrVector(pParse, pRight, iTarget, 1);
124469125465
}
124470125466
}
124471125467
sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);
124472125468
sqlite3VdbeAddOp2(v, OP_Integer, nConstraint, iReg+1);
124473125469
sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrNotFound, iReg,
@@ -124577,10 +125573,11 @@
124577125573
}
124578125574
codeCursorHint(pTabItem, pWInfo, pLevel, pEnd);
124579125575
if( pStart ){
124580125576
Expr *pX; /* The expression that defines the start bound */
124581125577
int r1, rTemp; /* Registers for holding the start boundary */
125578
+ int op; /* Cursor seek operation */
124582125579
124583125580
/* The following constant maps TK_xx codes into corresponding
124584125581
** seek opcodes. It depends on a particular ordering of TK_xx
124585125582
*/
124586125583
const u8 aMoveOp[] = {
@@ -124596,20 +125593,27 @@
124596125593
assert( (pStart->wtFlags & TERM_VNULL)==0 );
124597125594
testcase( pStart->wtFlags & TERM_VIRTUAL );
124598125595
pX = pStart->pExpr;
124599125596
assert( pX!=0 );
124600125597
testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
124601
- r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
124602
- sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
125598
+ if( sqlite3ExprIsVector(pX->pRight) ){
125599
+ r1 = rTemp = sqlite3GetTempReg(pParse);
125600
+ codeExprOrVector(pParse, pX->pRight, r1, 1);
125601
+ op = aMoveOp[(pX->op - TK_GT) | 0x0001];
125602
+ }else{
125603
+ r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
125604
+ disableTerm(pLevel, pStart);
125605
+ op = aMoveOp[(pX->op - TK_GT)];
125606
+ }
125607
+ sqlite3VdbeAddOp3(v, op, iCur, addrBrk, r1);
124603125608
VdbeComment((v, "pk"));
124604125609
VdbeCoverageIf(v, pX->op==TK_GT);
124605125610
VdbeCoverageIf(v, pX->op==TK_LE);
124606125611
VdbeCoverageIf(v, pX->op==TK_LT);
124607125612
VdbeCoverageIf(v, pX->op==TK_GE);
124608125613
sqlite3ExprCacheAffinityChange(pParse, r1, 1);
124609125614
sqlite3ReleaseTempReg(pParse, rTemp);
124610
- disableTerm(pLevel, pStart);
124611125615
}else{
124612125616
sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrBrk);
124613125617
VdbeCoverageIf(v, bRev==0);
124614125618
VdbeCoverageIf(v, bRev!=0);
124615125619
}
@@ -124619,17 +125623,21 @@
124619125623
assert( pX!=0 );
124620125624
assert( (pEnd->wtFlags & TERM_VNULL)==0 );
124621125625
testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
124622125626
testcase( pEnd->wtFlags & TERM_VIRTUAL );
124623125627
memEndValue = ++pParse->nMem;
124624
- sqlite3ExprCode(pParse, pX->pRight, memEndValue);
124625
- if( pX->op==TK_LT || pX->op==TK_GT ){
125628
+ codeExprOrVector(pParse, pX->pRight, memEndValue, 1);
125629
+ if( 0==sqlite3ExprIsVector(pX->pRight)
125630
+ && (pX->op==TK_LT || pX->op==TK_GT)
125631
+ ){
124626125632
testOp = bRev ? OP_Le : OP_Ge;
124627125633
}else{
124628125634
testOp = bRev ? OP_Lt : OP_Gt;
124629125635
}
124630
- disableTerm(pLevel, pEnd);
125636
+ if( 0==sqlite3ExprIsVector(pX->pRight) ){
125637
+ disableTerm(pLevel, pEnd);
125638
+ }
124631125639
}
124632125640
start = sqlite3VdbeCurrentAddr(v);
124633125641
pLevel->op = bRev ? OP_Prev : OP_Next;
124634125642
pLevel->p1 = iCur;
124635125643
pLevel->p2 = start;
@@ -124692,10 +125700,12 @@
124692125700
OP_IdxGT, /* 1: (end_constraints && !bRev && endEq) */
124693125701
OP_IdxLE, /* 2: (end_constraints && bRev && !endEq) */
124694125702
OP_IdxLT, /* 3: (end_constraints && bRev && endEq) */
124695125703
};
124696125704
u16 nEq = pLoop->u.btree.nEq; /* Number of == or IN terms */
125705
+ u16 nBtm = pLoop->u.btree.nBtm; /* Length of BTM vector */
125706
+ u16 nTop = pLoop->u.btree.nTop; /* Length of TOP vector */
124697125707
int regBase; /* Base register holding constraint values */
124698125708
WhereTerm *pRangeStart = 0; /* Inequality constraint at range start */
124699125709
WhereTerm *pRangeEnd = 0; /* Inequality constraint at range end */
124700125710
int startEq; /* True if range start uses ==, >= or <= */
124701125711
int endEq; /* True if range end uses ==, >= or <= */
@@ -124704,11 +125714,11 @@
124704125714
Index *pIdx; /* The index we will be using */
124705125715
int iIdxCur; /* The VDBE cursor for the index */
124706125716
int nExtraReg = 0; /* Number of extra registers needed */
124707125717
int op; /* Instruction opcode */
124708125718
char *zStartAff; /* Affinity for start of range constraint */
124709
- char cEndAff = 0; /* Affinity for end of range constraint */
125719
+ char *zEndAff = 0; /* Affinity for end of range constraint */
124710125720
u8 bSeekPastNull = 0; /* True to seek past initial nulls */
124711125721
u8 bStopAtNull = 0; /* Add condition to terminate at NULLs */
124712125722
124713125723
pIdx = pLoop->u.btree.pIndex;
124714125724
iIdxCur = pLevel->iIdxCur;
@@ -124738,18 +125748,18 @@
124738125748
** of the range.
124739125749
*/
124740125750
j = nEq;
124741125751
if( pLoop->wsFlags & WHERE_BTM_LIMIT ){
124742125752
pRangeStart = pLoop->aLTerm[j++];
124743
- nExtraReg = 1;
125753
+ nExtraReg = MAX(nExtraReg, pLoop->u.btree.nBtm);
124744125754
/* Like optimization range constraints always occur in pairs */
124745125755
assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 ||
124746125756
(pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 );
124747125757
}
124748125758
if( pLoop->wsFlags & WHERE_TOP_LIMIT ){
124749125759
pRangeEnd = pLoop->aLTerm[j++];
124750
- nExtraReg = 1;
125760
+ nExtraReg = MAX(nExtraReg, pLoop->u.btree.nTop);
124751125761
#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
124752125762
if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){
124753125763
assert( pRangeStart!=0 ); /* LIKE opt constraints */
124754125764
assert( pRangeStart->wtFlags & TERM_LIKEOPT ); /* occur in pairs */
124755125765
pLevel->iLikeRepCntr = (u32)++pParse->nMem;
@@ -124781,20 +125791,23 @@
124781125791
if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))
124782125792
|| (bRev && pIdx->nKeyCol==nEq)
124783125793
){
124784125794
SWAP(WhereTerm *, pRangeEnd, pRangeStart);
124785125795
SWAP(u8, bSeekPastNull, bStopAtNull);
125796
+ SWAP(u8, nBtm, nTop);
124786125797
}
124787125798
124788125799
/* Generate code to evaluate all constraint terms using == or IN
124789125800
** and store the values of those terms in an array of registers
124790125801
** starting at regBase.
124791125802
*/
124792125803
codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd);
124793125804
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
124794125805
assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
124795
- if( zStartAff ) cEndAff = zStartAff[nEq];
125806
+ if( zStartAff && nTop ){
125807
+ zEndAff = sqlite3DbStrDup(db, &zStartAff[nEq]);
125808
+ }
124796125809
addrNxt = pLevel->addrNxt;
124797125810
124798125811
testcase( pRangeStart && (pRangeStart->eOperator & WO_LE)!=0 );
124799125812
testcase( pRangeStart && (pRangeStart->eOperator & WO_GE)!=0 );
124800125813
testcase( pRangeEnd && (pRangeEnd->eOperator & WO_LE)!=0 );
@@ -124805,31 +125818,28 @@
124805125818
124806125819
/* Seek the index cursor to the start of the range. */
124807125820
nConstraint = nEq;
124808125821
if( pRangeStart ){
124809125822
Expr *pRight = pRangeStart->pExpr->pRight;
124810
- sqlite3ExprCode(pParse, pRight, regBase+nEq);
125823
+ codeExprOrVector(pParse, pRight, regBase+nEq, nBtm);
124811125824
whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);
124812125825
if( (pRangeStart->wtFlags & TERM_VNULL)==0
124813125826
&& sqlite3ExprCanBeNull(pRight)
124814125827
){
124815125828
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
124816125829
VdbeCoverage(v);
124817125830
}
124818125831
if( zStartAff ){
124819
- if( sqlite3CompareAffinity(pRight, zStartAff[nEq])==SQLITE_AFF_BLOB){
124820
- /* Since the comparison is to be performed with no conversions
124821
- ** applied to the operands, set the affinity to apply to pRight to
124822
- ** SQLITE_AFF_BLOB. */
124823
- zStartAff[nEq] = SQLITE_AFF_BLOB;
124824
- }
124825
- if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
124826
- zStartAff[nEq] = SQLITE_AFF_BLOB;
124827
- }
124828
- }
124829
- nConstraint++;
124830
- testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
125832
+ updateRangeAffinityStr(pParse, pRight, nBtm, &zStartAff[nEq]);
125833
+ }
125834
+ nConstraint += nBtm;
125835
+ testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
125836
+ if( sqlite3ExprIsVector(pRight)==0 ){
125837
+ disableTerm(pLevel, pRangeStart);
125838
+ }else{
125839
+ startEq = 1;
125840
+ }
124831125841
bSeekPastNull = 0;
124832125842
}else if( bSeekPastNull ){
124833125843
sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
124834125844
nConstraint++;
124835125845
startEq = 0;
@@ -124858,31 +125868,39 @@
124858125868
*/
124859125869
nConstraint = nEq;
124860125870
if( pRangeEnd ){
124861125871
Expr *pRight = pRangeEnd->pExpr->pRight;
124862125872
sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
124863
- sqlite3ExprCode(pParse, pRight, regBase+nEq);
125873
+ codeExprOrVector(pParse, pRight, regBase+nEq, nTop);
124864125874
whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
124865125875
if( (pRangeEnd->wtFlags & TERM_VNULL)==0
124866125876
&& sqlite3ExprCanBeNull(pRight)
124867125877
){
124868125878
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
124869125879
VdbeCoverage(v);
124870125880
}
124871
- if( sqlite3CompareAffinity(pRight, cEndAff)!=SQLITE_AFF_BLOB
124872
- && !sqlite3ExprNeedsNoAffinityChange(pRight, cEndAff)
124873
- ){
124874
- codeApplyAffinity(pParse, regBase+nEq, 1, &cEndAff);
125881
+ if( zEndAff ){
125882
+ updateRangeAffinityStr(pParse, pRight, nTop, zEndAff);
125883
+ codeApplyAffinity(pParse, regBase+nEq, nTop, zEndAff);
125884
+ }else{
125885
+ assert( pParse->db->mallocFailed );
124875125886
}
124876
- nConstraint++;
125887
+ nConstraint += nTop;
124877125888
testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );
125889
+
125890
+ if( sqlite3ExprIsVector(pRight)==0 ){
125891
+ disableTerm(pLevel, pRangeEnd);
125892
+ }else{
125893
+ endEq = 1;
125894
+ }
124878125895
}else if( bStopAtNull ){
124879125896
sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
124880125897
endEq = 0;
124881125898
nConstraint++;
124882125899
}
124883125900
sqlite3DbFree(db, zStartAff);
125901
+ sqlite3DbFree(db, zEndAff);
124884125902
124885125903
/* Top of the loop body */
124886125904
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
124887125905
124888125906
/* Check if the index cursor is past the end of the range. */
@@ -124894,12 +125912,10 @@
124894125912
testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
124895125913
testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
124896125914
}
124897125915
124898125916
/* Seek the table cursor, if required */
124899
- disableTerm(pLevel, pRangeStart);
124900
- disableTerm(pLevel, pRangeEnd);
124901125917
if( omitTable ){
124902125918
/* pIdx is a covering index. No need to access the main table. */
124903125919
}else if( HasRowid(pIdx->pTable) ){
124904125920
if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE)!=0 ){
124905125921
iRowidReg = ++pParse->nMem;
@@ -124919,13 +125935,11 @@
124919125935
}
124920125936
sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,
124921125937
iRowidReg, pPk->nKeyCol); VdbeCoverage(v);
124922125938
}
124923125939
124924
- /* Record the instruction used to terminate the loop. Disable
124925
- ** WHERE clause terms made redundant by the index range scan.
124926
- */
125940
+ /* Record the instruction used to terminate the loop. */
124927125941
if( pLoop->wsFlags & WHERE_ONEROW ){
124928125942
pLevel->op = OP_Noop;
124929125943
}else if( bRev ){
124930125944
pLevel->op = OP_Prev;
124931125945
}else{
@@ -124998,11 +126012,11 @@
124998126012
int untestedTerms = 0; /* Some terms not completely tested */
124999126013
int ii; /* Loop counter */
125000126014
u16 wctrlFlags; /* Flags for sub-WHERE clause */
125001126015
Expr *pAndExpr = 0; /* An ".. AND (...)" expression */
125002126016
Table *pTab = pTabItem->pTab;
125003
-
126017
+
125004126018
pTerm = pLoop->aLTerm[0];
125005126019
assert( pTerm!=0 );
125006126020
assert( pTerm->eOperator & WO_OR );
125007126021
assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );
125008126022
pOrWc = &pTerm->u.pOrInfo->wc;
@@ -125450,11 +126464,11 @@
125450126464
}
125451126465
125452126466
/*
125453126467
** Return TRUE if the given operator is one of the operators that is
125454126468
** allowed for an indexable WHERE clause term. The allowed operators are
125455
-** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
126469
+** "=", "<", ">", "<=", ">=", "IN", "IS", and "IS NULL"
125456126470
*/
125457126471
static int allowedOp(int op){
125458126472
assert( TK_GT>TK_EQ && TK_GT<TK_GE );
125459126473
assert( TK_LT>TK_EQ && TK_LT<TK_GE );
125460126474
assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -126178,26 +127192,39 @@
126178127192
** Expression pExpr is one operand of a comparison operator that might
126179127193
** be useful for indexing. This routine checks to see if pExpr appears
126180127194
** in any index. Return TRUE (1) if pExpr is an indexed term and return
126181127195
** FALSE (0) if not. If TRUE is returned, also set *piCur to the cursor
126182127196
** number of the table that is indexed and *piColumn to the column number
126183
-** of the column that is indexed, or -2 if an expression is being indexed.
127197
+** of the column that is indexed, or XN_EXPR (-2) if an expression is being
127198
+** indexed.
126184127199
**
126185127200
** If pExpr is a TK_COLUMN column reference, then this routine always returns
126186127201
** true even if that particular column is not indexed, because the column
126187127202
** might be added to an automatic index later.
126188127203
*/
126189127204
static int exprMightBeIndexed(
126190127205
SrcList *pFrom, /* The FROM clause */
127206
+ int op, /* The specific comparison operator */
126191127207
Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */
126192127208
Expr *pExpr, /* An operand of a comparison operator */
126193127209
int *piCur, /* Write the referenced table cursor number here */
126194127210
int *piColumn /* Write the referenced table column number here */
126195127211
){
126196127212
Index *pIdx;
126197127213
int i;
126198127214
int iCur;
127215
+
127216
+ /* If this expression is a vector to the left or right of a
127217
+ ** inequality constraint (>, <, >= or <=), perform the processing
127218
+ ** on the first element of the vector. */
127219
+ assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE );
127220
+ assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE );
127221
+ assert( op<=TK_GE );
127222
+ if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){
127223
+ pExpr = pExpr->x.pList->a[0].pExpr;
127224
+ }
127225
+
126199127226
if( pExpr->op==TK_COLUMN ){
126200127227
*piCur = pExpr->iTable;
126201127228
*piColumn = pExpr->iColumn;
126202127229
return 1;
126203127230
}
@@ -126206,14 +127233,14 @@
126206127233
for(i=0; mPrereq>1; i++, mPrereq>>=1){}
126207127234
iCur = pFrom->a[i].iCursor;
126208127235
for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
126209127236
if( pIdx->aColExpr==0 ) continue;
126210127237
for(i=0; i<pIdx->nKeyCol; i++){
126211
- if( pIdx->aiColumn[i]!=(-2) ) continue;
127238
+ if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
126212127239
if( sqlite3ExprCompare(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
126213127240
*piCur = iCur;
126214
- *piColumn = -2;
127241
+ *piColumn = XN_EXPR;
126215127242
return 1;
126216127243
}
126217127244
}
126218127245
}
126219127246
return 0;
@@ -126266,10 +127293,11 @@
126266127293
assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );
126267127294
prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);
126268127295
op = pExpr->op;
126269127296
if( op==TK_IN ){
126270127297
assert( pExpr->pRight==0 );
127298
+ if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
126271127299
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
126272127300
pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect);
126273127301
}else{
126274127302
pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);
126275127303
}
@@ -126292,22 +127320,30 @@
126292127320
if( allowedOp(op) ){
126293127321
int iCur, iColumn;
126294127322
Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);
126295127323
Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);
126296127324
u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;
126297
- if( exprMightBeIndexed(pSrc, prereqLeft, pLeft, &iCur, &iColumn) ){
127325
+
127326
+ if( pTerm->iField>0 ){
127327
+ assert( op==TK_IN );
127328
+ assert( pLeft->op==TK_VECTOR );
127329
+ pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr;
127330
+ }
127331
+
127332
+ if( exprMightBeIndexed(pSrc, op, prereqLeft, pLeft, &iCur, &iColumn) ){
126298127333
pTerm->leftCursor = iCur;
126299127334
pTerm->u.leftColumn = iColumn;
126300127335
pTerm->eOperator = operatorMask(op) & opMask;
126301127336
}
126302127337
if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;
126303127338
if( pRight
126304
- && exprMightBeIndexed(pSrc, pTerm->prereqRight, pRight, &iCur, &iColumn)
127339
+ && exprMightBeIndexed(pSrc, op, pTerm->prereqRight, pRight, &iCur,&iColumn)
126305127340
){
126306127341
WhereTerm *pNew;
126307127342
Expr *pDup;
126308127343
u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */
127344
+ assert( pTerm->iField==0 );
126309127345
if( pTerm->leftCursor>=0 ){
126310127346
int idxNew;
126311127347
pDup = sqlite3ExprDup(db, pExpr, 0);
126312127348
if( db->mallocFailed ){
126313127349
sqlite3ExprDelete(db, pDup);
@@ -126506,10 +127542,63 @@
126506127542
pTerm->wtFlags |= TERM_COPIED;
126507127543
pNewTerm->prereqAll = pTerm->prereqAll;
126508127544
}
126509127545
}
126510127546
#endif /* SQLITE_OMIT_VIRTUALTABLE */
127547
+
127548
+ /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create
127549
+ ** new terms for each component comparison - "a = ?" and "b = ?". The
127550
+ ** new terms completely replace the original vector comparison, which is
127551
+ ** no longer used.
127552
+ **
127553
+ ** This is only required if at least one side of the comparison operation
127554
+ ** is not a sub-select. */
127555
+ if( pWC->op==TK_AND
127556
+ && (pExpr->op==TK_EQ || pExpr->op==TK_IS)
127557
+ && sqlite3ExprIsVector(pExpr->pLeft)
127558
+ && ( (pExpr->pLeft->flags & EP_xIsSelect)==0
127559
+ || (pExpr->pRight->flags & EP_xIsSelect)==0
127560
+ )){
127561
+ int nLeft = sqlite3ExprVectorSize(pExpr->pLeft);
127562
+ int i;
127563
+ assert( nLeft==sqlite3ExprVectorSize(pExpr->pRight) );
127564
+ for(i=0; i<nLeft; i++){
127565
+ int idxNew;
127566
+ Expr *pNew;
127567
+ Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
127568
+ Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
127569
+
127570
+ pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight, 0);
127571
+ idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
127572
+ exprAnalyze(pSrc, pWC, idxNew);
127573
+ }
127574
+ pTerm = &pWC->a[idxTerm];
127575
+ pTerm->wtFlags = TERM_CODED|TERM_VIRTUAL; /* Disable the original */
127576
+ pTerm->eOperator = 0;
127577
+ }
127578
+
127579
+ /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
127580
+ ** a virtual term for each vector component. The expression object
127581
+ ** used by each such virtual term is pExpr (the full vector IN(...)
127582
+ ** expression). The WhereTerm.iField variable identifies the index within
127583
+ ** the vector on the LHS that the virtual term represents.
127584
+ **
127585
+ ** This only works if the RHS is a simple SELECT, not a compound
127586
+ */
127587
+ if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
127588
+ && pExpr->pLeft->op==TK_VECTOR
127589
+ && pExpr->x.pSelect->pPrior==0
127590
+ ){
127591
+ int i;
127592
+ for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
127593
+ int idxNew;
127594
+ idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
127595
+ pWC->a[idxNew].iField = i+1;
127596
+ exprAnalyze(pSrc, pWC, idxNew);
127597
+ markTermAsChild(pWC, idxNew, idxTerm);
127598
+ }
127599
+ }
126511127600
126512127601
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
126513127602
/* When sqlite_stat3 histogram data is available an operator of the
126514127603
** form "x IS NOT NULL" can sometimes be evaluated more efficiently
126515127604
** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
@@ -127546,20 +128635,22 @@
127546128635
static sqlite3_index_info *allocateIndexInfo(
127547128636
Parse *pParse,
127548128637
WhereClause *pWC,
127549128638
Bitmask mUnusable, /* Ignore terms with these prereqs */
127550128639
struct SrcList_item *pSrc,
127551
- ExprList *pOrderBy
128640
+ ExprList *pOrderBy,
128641
+ u16 *pmNoOmit /* Mask of terms not to omit */
127552128642
){
127553128643
int i, j;
127554128644
int nTerm;
127555128645
struct sqlite3_index_constraint *pIdxCons;
127556128646
struct sqlite3_index_orderby *pIdxOrderBy;
127557128647
struct sqlite3_index_constraint_usage *pUsage;
127558128648
WhereTerm *pTerm;
127559128649
int nOrderBy;
127560128650
sqlite3_index_info *pIdxInfo;
128651
+ u16 mNoOmit = 0;
127561128652
127562128653
/* Count the number of possible WHERE clause constraints referring
127563128654
** to this virtual table */
127564128655
for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
127565128656
if( pTerm->leftCursor != pSrc->iCursor ) continue;
@@ -127644,18 +128735,28 @@
127644128735
assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE );
127645128736
assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT );
127646128737
assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE );
127647128738
assert( WO_MATCH==SQLITE_INDEX_CONSTRAINT_MATCH );
127648128739
assert( pTerm->eOperator & (WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_MATCH) );
128740
+
128741
+ if( op & (WO_LT|WO_LE|WO_GT|WO_GE)
128742
+ && sqlite3ExprIsVector(pTerm->pExpr->pRight)
128743
+ ){
128744
+ if( i<16 ) mNoOmit |= (1 << i);
128745
+ if( op==WO_LT ) pIdxCons[j].op = WO_LE;
128746
+ if( op==WO_GT ) pIdxCons[j].op = WO_GE;
128747
+ }
128748
+
127649128749
j++;
127650128750
}
127651128751
for(i=0; i<nOrderBy; i++){
127652128752
Expr *pExpr = pOrderBy->a[i].pExpr;
127653128753
pIdxOrderBy[i].iColumn = pExpr->iColumn;
127654128754
pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;
127655128755
}
127656128756
128757
+ *pmNoOmit = mNoOmit;
127657128758
return pIdxInfo;
127658128759
}
127659128760
127660128761
/*
127661128762
** The table object reference passed as the second argument to this function
@@ -127927,11 +129028,11 @@
127927129028
127928129029
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
127929129030
/*
127930129031
** Return the affinity for a single column of an index.
127931129032
*/
127932
-static char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){
129033
+SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){
127933129034
assert( iCol>=0 && iCol<pIdx->nColumn );
127934129035
if( !pIdx->zColAff ){
127935129036
if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;
127936129037
}
127937129038
return pIdx->zColAff[iCol];
@@ -128104,11 +129205,12 @@
128104129205
128105129206
if( p->nSample>0 && nEq<p->nSampleCol ){
128106129207
if( nEq==pBuilder->nRecValid ){
128107129208
UnpackedRecord *pRec = pBuilder->pRec;
128108129209
tRowcnt a[2];
128109
- u8 aff;
129210
+ int nBtm = pLoop->u.btree.nBtm;
129211
+ int nTop = pLoop->u.btree.nTop;
128110129212
128111129213
/* Variable iLower will be set to the estimate of the number of rows in
128112129214
** the index that are less than the lower bound of the range query. The
128113129215
** lower bound being the concatenation of $P and $L, where $P is the
128114129216
** key-prefix formed by the nEq values matched against the nEq left-most
@@ -128134,12 +129236,10 @@
128134129236
128135129237
if( pRec ){
128136129238
testcase( pRec->nField!=pBuilder->nRecValid );
128137129239
pRec->nField = pBuilder->nRecValid;
128138129240
}
128139
- aff = sqlite3IndexColumnAffinity(pParse->db, p, nEq);
128140
- assert( nEq!=p->nKeyCol || aff==SQLITE_AFF_INTEGER );
128141129241
/* Determine iLower and iUpper using ($P) only. */
128142129242
if( nEq==0 ){
128143129243
iLower = 0;
128144129244
iUpper = p->nRowEst0;
128145129245
}else{
@@ -128154,36 +129254,41 @@
128154129254
assert( pUpper==0 || (pUpper->eOperator & (WO_LT|WO_LE))!=0 );
128155129255
assert( p->aSortOrder!=0 );
128156129256
if( p->aSortOrder[nEq] ){
128157129257
/* The roles of pLower and pUpper are swapped for a DESC index */
128158129258
SWAP(WhereTerm*, pLower, pUpper);
129259
+ SWAP(int, nBtm, nTop);
128159129260
}
128160129261
128161129262
/* If possible, improve on the iLower estimate using ($P:$L). */
128162129263
if( pLower ){
128163
- int bOk; /* True if value is extracted from pExpr */
129264
+ int n; /* Values extracted from pExpr */
128164129265
Expr *pExpr = pLower->pExpr->pRight;
128165
- rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk);
128166
- if( rc==SQLITE_OK && bOk ){
129266
+ rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nBtm, nEq, &n);
129267
+ if( rc==SQLITE_OK && n ){
128167129268
tRowcnt iNew;
129269
+ u16 mask = WO_GT|WO_LE;
129270
+ if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);
128168129271
iLwrIdx = whereKeyStats(pParse, p, pRec, 0, a);
128169
- iNew = a[0] + ((pLower->eOperator & (WO_GT|WO_LE)) ? a[1] : 0);
129272
+ iNew = a[0] + ((pLower->eOperator & mask) ? a[1] : 0);
128170129273
if( iNew>iLower ) iLower = iNew;
128171129274
nOut--;
128172129275
pLower = 0;
128173129276
}
128174129277
}
128175129278
128176129279
/* If possible, improve on the iUpper estimate using ($P:$U). */
128177129280
if( pUpper ){
128178
- int bOk; /* True if value is extracted from pExpr */
129281
+ int n; /* Values extracted from pExpr */
128179129282
Expr *pExpr = pUpper->pExpr->pRight;
128180
- rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk);
128181
- if( rc==SQLITE_OK && bOk ){
129283
+ rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nTop, nEq, &n);
129284
+ if( rc==SQLITE_OK && n ){
128182129285
tRowcnt iNew;
129286
+ u16 mask = WO_GT|WO_LE;
129287
+ if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);
128183129288
iUprIdx = whereKeyStats(pParse, p, pRec, 1, a);
128184
- iNew = a[0] + ((pUpper->eOperator & (WO_GT|WO_LE)) ? a[1] : 0);
129289
+ iNew = a[0] + ((pUpper->eOperator & mask) ? a[1] : 0);
128185129290
if( iNew<iUpper ) iUpper = iNew;
128186129291
nOut--;
128187129292
pUpper = 0;
128188129293
}
128189129294
}
@@ -128269,11 +129374,10 @@
128269129374
tRowcnt *pnRow /* Write the revised row estimate here */
128270129375
){
128271129376
Index *p = pBuilder->pNew->u.btree.pIndex;
128272129377
int nEq = pBuilder->pNew->u.btree.nEq;
128273129378
UnpackedRecord *pRec = pBuilder->pRec;
128274
- u8 aff; /* Column affinity */
128275129379
int rc; /* Subfunction return code */
128276129380
tRowcnt a[2]; /* Statistics */
128277129381
int bOk;
128278129382
128279129383
assert( nEq>=1 );
@@ -128293,12 +129397,11 @@
128293129397
if( nEq>=p->nColumn ){
128294129398
*pnRow = 1;
128295129399
return SQLITE_OK;
128296129400
}
128297129401
128298
- aff = sqlite3IndexColumnAffinity(pParse->db, p, nEq-1);
128299
- rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq-1, &bOk);
129402
+ rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, 1, nEq-1, &bOk);
128300129403
pBuilder->pRec = pRec;
128301129404
if( rc!=SQLITE_OK ) return rc;
128302129405
if( bOk==0 ) return SQLITE_NOTFOUND;
128303129406
pBuilder->nRecValid = nEq;
128304129407
@@ -128383,13 +129486,18 @@
128383129486
pTerm->u.pOrInfo->indexable);
128384129487
}else{
128385129488
sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
128386129489
}
128387129490
sqlite3DebugPrintf(
128388
- "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\n",
129491
+ "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x",
128389129492
iTerm, pTerm, zType, zLeft, pTerm->truthProb,
128390129493
pTerm->eOperator, pTerm->wtFlags);
129494
+ if( pTerm->iField ){
129495
+ sqlite3DebugPrintf(" iField=%d\n", pTerm->iField);
129496
+ }else{
129497
+ sqlite3DebugPrintf("\n");
129498
+ }
128391129499
sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
128392129500
}
128393129501
}
128394129502
#endif
128395129503
@@ -128906,10 +130014,76 @@
128906130014
}
128907130015
}
128908130016
}
128909130017
if( pLoop->nOut > nRow-iReduce ) pLoop->nOut = nRow - iReduce;
128910130018
}
130019
+
130020
+/*
130021
+** Term pTerm is a vector range comparison operation. The first comparison
130022
+** in the vector can be optimized using column nEq of the index. This
130023
+** function returns the total number of vector elements that can be used
130024
+** as part of the range comparison.
130025
+**
130026
+** For example, if the query is:
130027
+**
130028
+** WHERE a = ? AND (b, c, d) > (?, ?, ?)
130029
+**
130030
+** and the index:
130031
+**
130032
+** CREATE INDEX ... ON (a, b, c, d, e)
130033
+**
130034
+** then this function would be invoked with nEq=1. The value returned in
130035
+** this case is 3.
130036
+*/
130037
+int whereRangeVectorLen(
130038
+ Parse *pParse, /* Parsing context */
130039
+ int iCur, /* Cursor open on pIdx */
130040
+ Index *pIdx, /* The index to be used for a inequality constraint */
130041
+ int nEq, /* Number of prior equality constraints on same index */
130042
+ WhereTerm *pTerm /* The vector inequality constraint */
130043
+){
130044
+ int nCmp = sqlite3ExprVectorSize(pTerm->pExpr->pLeft);
130045
+ int i;
130046
+
130047
+ nCmp = MIN(nCmp, (pIdx->nColumn - nEq));
130048
+ for(i=1; i<nCmp; i++){
130049
+ /* Test if comparison i of pTerm is compatible with column (i+nEq)
130050
+ ** of the index. If not, exit the loop. */
130051
+ char aff; /* Comparison affinity */
130052
+ char idxaff = 0; /* Indexed columns affinity */
130053
+ CollSeq *pColl; /* Comparison collation sequence */
130054
+ Expr *pLhs = pTerm->pExpr->pLeft->x.pList->a[i].pExpr;
130055
+ Expr *pRhs = pTerm->pExpr->pRight;
130056
+ if( pRhs->flags & EP_xIsSelect ){
130057
+ pRhs = pRhs->x.pSelect->pEList->a[i].pExpr;
130058
+ }else{
130059
+ pRhs = pRhs->x.pList->a[i].pExpr;
130060
+ }
130061
+
130062
+ /* Check that the LHS of the comparison is a column reference to
130063
+ ** the right column of the right source table. And that the sort
130064
+ ** order of the index column is the same as the sort order of the
130065
+ ** leftmost index column. */
130066
+ if( pLhs->op!=TK_COLUMN
130067
+ || pLhs->iTable!=iCur
130068
+ || pLhs->iColumn!=pIdx->aiColumn[i+nEq]
130069
+ || pIdx->aSortOrder[i+nEq]!=pIdx->aSortOrder[nEq]
130070
+ ){
130071
+ break;
130072
+ }
130073
+
130074
+ testcase( pLhs->iColumn==XN_ROWID );
130075
+ aff = sqlite3CompareAffinity(pRhs, sqlite3ExprAffinity(pLhs));
130076
+ idxaff = sqlite3TableColumnAffinity(pIdx->pTable, pLhs->iColumn);
130077
+ if( aff!=idxaff ) break;
130078
+
130079
+ pColl = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
130080
+ if( pColl==0 ) break;
130081
+ if( sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;
130082
+ }
130083
+ return i;
130084
+}
128911130085
128912130086
/*
128913130087
** Adjust the cost C by the costMult facter T. This only occurs if
128914130088
** compiled with -DSQLITE_ENABLE_COSTMULT
128915130089
*/
@@ -128945,10 +130119,12 @@
128945130119
int opMask; /* Valid operators for constraints */
128946130120
WhereScan scan; /* Iterator for WHERE terms */
128947130121
Bitmask saved_prereq; /* Original value of pNew->prereq */
128948130122
u16 saved_nLTerm; /* Original value of pNew->nLTerm */
128949130123
u16 saved_nEq; /* Original value of pNew->u.btree.nEq */
130124
+ u16 saved_nBtm; /* Original value of pNew->u.btree.nBtm */
130125
+ u16 saved_nTop; /* Original value of pNew->u.btree.nTop */
128950130126
u16 saved_nSkip; /* Original value of pNew->nSkip */
128951130127
u32 saved_wsFlags; /* Original value of pNew->wsFlags */
128952130128
LogEst saved_nOut; /* Original value of pNew->nOut */
128953130129
int rc = SQLITE_OK; /* Return code */
128954130130
LogEst rSize; /* Number of rows in the table */
@@ -128961,17 +130137,20 @@
128961130137
assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );
128962130138
assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
128963130139
if( pNew->wsFlags & WHERE_BTM_LIMIT ){
128964130140
opMask = WO_LT|WO_LE;
128965130141
}else{
130142
+ assert( pNew->u.btree.nBtm==0 );
128966130143
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
128967130144
}
128968130145
if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
128969130146
128970130147
assert( pNew->u.btree.nEq<pProbe->nColumn );
128971130148
128972130149
saved_nEq = pNew->u.btree.nEq;
130150
+ saved_nBtm = pNew->u.btree.nBtm;
130151
+ saved_nTop = pNew->u.btree.nTop;
128973130152
saved_nSkip = pNew->nSkip;
128974130153
saved_nLTerm = pNew->nLTerm;
128975130154
saved_wsFlags = pNew->wsFlags;
128976130155
saved_prereq = pNew->prereq;
128977130156
saved_nOut = pNew->nOut;
@@ -129011,10 +130190,12 @@
129011130190
continue;
129012130191
}
129013130192
129014130193
pNew->wsFlags = saved_wsFlags;
129015130194
pNew->u.btree.nEq = saved_nEq;
130195
+ pNew->u.btree.nBtm = saved_nBtm;
130196
+ pNew->u.btree.nTop = saved_nTop;
129016130197
pNew->nLTerm = saved_nLTerm;
129017130198
if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
129018130199
pNew->aLTerm[pNew->nLTerm++] = pTerm;
129019130200
pNew->prereq = (saved_prereq | pTerm->prereqRight) & ~pNew->maskSelf;
129020130201
@@ -129027,18 +130208,27 @@
129027130208
if( eOp & WO_IN ){
129028130209
Expr *pExpr = pTerm->pExpr;
129029130210
pNew->wsFlags |= WHERE_COLUMN_IN;
129030130211
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
129031130212
/* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */
130213
+ int i;
129032130214
nIn = 46; assert( 46==sqlite3LogEst(25) );
130215
+
130216
+ /* The expression may actually be of the form (x, y) IN (SELECT...).
130217
+ ** In this case there is a separate term for each of (x) and (y).
130218
+ ** However, the nIn multiplier should only be applied once, not once
130219
+ ** for each such term. The following loop checks that pTerm is the
130220
+ ** first such term in use, and sets nIn back to 0 if it is not. */
130221
+ for(i=0; i<pNew->nLTerm-1; i++){
130222
+ if( pNew->aLTerm[i]->pExpr==pExpr ) nIn = 0;
130223
+ }
129033130224
}else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
129034130225
/* "x IN (value, value, ...)" */
129035130226
nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
130227
+ assert( nIn>0 ); /* RHS always has 2 or more terms... The parser
130228
+ ** changes "x IN (?)" into "x=?". */
129036130229
}
129037
- assert( nIn>0 ); /* RHS always has 2 or more terms... The parser
129038
- ** changes "x IN (?)" into "x=?". */
129039
-
129040130230
}else if( eOp & (WO_EQ|WO_IS) ){
129041130231
int iCol = pProbe->aiColumn[saved_nEq];
129042130232
pNew->wsFlags |= WHERE_COLUMN_EQ;
129043130233
assert( saved_nEq==pNew->u.btree.nEq );
129044130234
if( iCol==XN_ROWID
@@ -129054,10 +130244,13 @@
129054130244
pNew->wsFlags |= WHERE_COLUMN_NULL;
129055130245
}else if( eOp & (WO_GT|WO_GE) ){
129056130246
testcase( eOp & WO_GT );
129057130247
testcase( eOp & WO_GE );
129058130248
pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
130249
+ pNew->u.btree.nBtm = whereRangeVectorLen(
130250
+ pParse, pSrc->iCursor, pProbe, saved_nEq, pTerm
130251
+ );
129059130252
pBtm = pTerm;
129060130253
pTop = 0;
129061130254
if( pTerm->wtFlags & TERM_LIKEOPT ){
129062130255
/* Range contraints that come from the LIKE optimization are
129063130256
** always used in pairs. */
@@ -129066,16 +130259,20 @@
129066130259
assert( pTop->wtFlags & TERM_LIKEOPT );
129067130260
assert( pTop->eOperator==WO_LT );
129068130261
if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
129069130262
pNew->aLTerm[pNew->nLTerm++] = pTop;
129070130263
pNew->wsFlags |= WHERE_TOP_LIMIT;
130264
+ pNew->u.btree.nTop = 1;
129071130265
}
129072130266
}else{
129073130267
assert( eOp & (WO_LT|WO_LE) );
129074130268
testcase( eOp & WO_LT );
129075130269
testcase( eOp & WO_LE );
129076130270
pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_TOP_LIMIT;
130271
+ pNew->u.btree.nTop = whereRangeVectorLen(
130272
+ pParse, pSrc->iCursor, pProbe, saved_nEq, pTerm
130273
+ );
129077130274
pTop = pTerm;
129078130275
pBtm = (pNew->wsFlags & WHERE_BTM_LIMIT)!=0 ?
129079130276
pNew->aLTerm[pNew->nLTerm-2] : 0;
129080130277
}
129081130278
@@ -129171,10 +130368,12 @@
129171130368
pBuilder->nRecValid = nRecValid;
129172130369
#endif
129173130370
}
129174130371
pNew->prereq = saved_prereq;
129175130372
pNew->u.btree.nEq = saved_nEq;
130373
+ pNew->u.btree.nBtm = saved_nBtm;
130374
+ pNew->u.btree.nTop = saved_nTop;
129176130375
pNew->nSkip = saved_nSkip;
129177130376
pNew->wsFlags = saved_wsFlags;
129178130377
pNew->nOut = saved_nOut;
129179130378
pNew->nLTerm = saved_nLTerm;
129180130379
@@ -129292,11 +130491,11 @@
129292130491
return 0;
129293130492
}
129294130493
129295130494
/*
129296130495
** Add all WhereLoop objects for a single table of the join where the table
129297
-** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
130496
+** is identified by pBuilder->pNew->iTab. That table is guaranteed to be
129298130497
** a b-tree table, not a virtual table.
129299130498
**
129300130499
** The costs (WhereLoop.rRun) of the b-tree loops added by this function
129301130500
** are calculated as follows:
129302130501
**
@@ -129446,10 +130645,12 @@
129446130645
testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
129447130646
continue; /* Partial index inappropriate for this query */
129448130647
}
129449130648
rSize = pProbe->aiRowLogEst[0];
129450130649
pNew->u.btree.nEq = 0;
130650
+ pNew->u.btree.nBtm = 0;
130651
+ pNew->u.btree.nTop = 0;
129451130652
pNew->nSkip = 0;
129452130653
pNew->nLTerm = 0;
129453130654
pNew->iSortIdx = 0;
129454130655
pNew->rSetup = 0;
129455130656
pNew->prereq = mPrereq;
@@ -129574,10 +130775,11 @@
129574130775
WhereLoopBuilder *pBuilder,
129575130776
Bitmask mPrereq, /* Mask of tables that must be used. */
129576130777
Bitmask mUsable, /* Mask of usable tables */
129577130778
u16 mExclude, /* Exclude terms using these operators */
129578130779
sqlite3_index_info *pIdxInfo, /* Populated object for xBestIndex */
130780
+ u16 mNoOmit, /* Do not omit these constraints */
129579130781
int *pbIn /* OUT: True if plan uses an IN(...) op */
129580130782
){
129581130783
WhereClause *pWC = pBuilder->pWC;
129582130784
struct sqlite3_index_constraint *pIdxCons;
129583130785
struct sqlite3_index_constraint_usage *pUsage = pIdxInfo->aConstraintUsage;
@@ -129662,10 +130864,11 @@
129662130864
pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;
129663130865
*pbIn = 1; assert( (mExclude & WO_IN)==0 );
129664130866
}
129665130867
}
129666130868
}
130869
+ pNew->u.vtab.omitMask &= ~mNoOmit;
129667130870
129668130871
pNew->nLTerm = mxTerm+1;
129669130872
assert( pNew->nLTerm<=pNew->nLSlot );
129670130873
pNew->u.vtab.idxNum = pIdxInfo->idxNum;
129671130874
pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr;
@@ -129735,19 +130938,21 @@
129735130938
sqlite3_index_info *p; /* Object to pass to xBestIndex() */
129736130939
int nConstraint; /* Number of constraints in p */
129737130940
int bIn; /* True if plan uses IN(...) operator */
129738130941
WhereLoop *pNew;
129739130942
Bitmask mBest; /* Tables used by best possible plan */
130943
+ u16 mNoOmit;
129740130944
129741130945
assert( (mPrereq & mUnusable)==0 );
129742130946
pWInfo = pBuilder->pWInfo;
129743130947
pParse = pWInfo->pParse;
129744130948
pWC = pBuilder->pWC;
129745130949
pNew = pBuilder->pNew;
129746130950
pSrc = &pWInfo->pTabList->a[pNew->iTab];
129747130951
assert( IsVirtual(pSrc->pTab) );
129748
- p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy);
130952
+ p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy,
130953
+ &mNoOmit);
129749130954
if( p==0 ) return SQLITE_NOMEM_BKPT;
129750130955
pNew->rSetup = 0;
129751130956
pNew->wsFlags = WHERE_VIRTUALTABLE;
129752130957
pNew->nLTerm = 0;
129753130958
pNew->u.vtab.needFree = 0;
@@ -129757,11 +130962,11 @@
129757130962
return SQLITE_NOMEM_BKPT;
129758130963
}
129759130964
129760130965
/* First call xBestIndex() with all constraints usable. */
129761130966
WHERETRACE(0x40, (" VirtualOne: all usable\n"));
129762
- rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, &bIn);
130967
+ rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);
129763130968
129764130969
/* If the call to xBestIndex() with all terms enabled produced a plan
129765130970
** that does not require any source tables (IOW: a plan with mBest==0),
129766130971
** then there is no point in making any further calls to xBestIndex()
129767130972
** since they will all return the same result (if the xBestIndex()
@@ -129774,11 +130979,12 @@
129774130979
129775130980
/* If the plan produced by the earlier call uses an IN(...) term, call
129776130981
** xBestIndex again, this time with IN(...) terms disabled. */
129777130982
if( bIn ){
129778130983
WHERETRACE(0x40, (" VirtualOne: all usable w/o IN\n"));
129779
- rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, WO_IN, p, &bIn);
130984
+ rc = whereLoopAddVirtualOne(
130985
+ pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn);
129780130986
assert( bIn==0 );
129781130987
mBestNoIn = pNew->prereq & ~mPrereq;
129782130988
if( mBestNoIn==0 ){
129783130989
seenZero = 1;
129784130990
seenZeroNoIN = 1;
@@ -129800,11 +131006,12 @@
129800131006
mPrev = mNext;
129801131007
if( mNext==ALLBITS ) break;
129802131008
if( mNext==mBest || mNext==mBestNoIn ) continue;
129803131009
WHERETRACE(0x40, (" VirtualOne: mPrev=%04llx mNext=%04llx\n",
129804131010
(sqlite3_uint64)mPrev, (sqlite3_uint64)mNext));
129805
- rc = whereLoopAddVirtualOne(pBuilder, mPrereq, mNext|mPrereq, 0, p, &bIn);
131011
+ rc = whereLoopAddVirtualOne(
131012
+ pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn);
129806131013
if( pNew->prereq==mPrereq ){
129807131014
seenZero = 1;
129808131015
if( bIn==0 ) seenZeroNoIN = 1;
129809131016
}
129810131017
}
@@ -129812,20 +131019,22 @@
129812131019
/* If the calls to xBestIndex() in the above loop did not find a plan
129813131020
** that requires no source tables at all (i.e. one guaranteed to be
129814131021
** usable), make a call here with all source tables disabled */
129815131022
if( rc==SQLITE_OK && seenZero==0 ){
129816131023
WHERETRACE(0x40, (" VirtualOne: all disabled\n"));
129817
- rc = whereLoopAddVirtualOne(pBuilder, mPrereq, mPrereq, 0, p, &bIn);
131024
+ rc = whereLoopAddVirtualOne(
131025
+ pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn);
129818131026
if( bIn==0 ) seenZeroNoIN = 1;
129819131027
}
129820131028
129821131029
/* If the calls to xBestIndex() have so far failed to find a plan
129822131030
** that requires no source tables at all and does not use an IN(...)
129823131031
** operator, make a final call to obtain one here. */
129824131032
if( rc==SQLITE_OK && seenZeroNoIN==0 ){
129825131033
WHERETRACE(0x40, (" VirtualOne: all disabled and w/o IN\n"));
129826
- rc = whereLoopAddVirtualOne(pBuilder, mPrereq, mPrereq, WO_IN, p, &bIn);
131034
+ rc = whereLoopAddVirtualOne(
131035
+ pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn);
129827131036
}
129828131037
}
129829131038
129830131039
if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);
129831131040
sqlite3DbFree(pParse->db, p);
@@ -130121,10 +131330,18 @@
130121131330
if( pOBExpr->op!=TK_COLUMN ) continue;
130122131331
if( pOBExpr->iTable!=iCur ) continue;
130123131332
pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
130124131333
~ready, eqOpMask, 0);
130125131334
if( pTerm==0 ) continue;
131335
+ if( pTerm->eOperator==WO_IN ){
131336
+ /* IN terms are only valid for sorting in the ORDER BY LIMIT
131337
+ ** optimization, and then only if they are actually used
131338
+ ** by the query plan */
131339
+ assert( wctrlFlags & WHERE_ORDERBY_LIMIT );
131340
+ for(j=0; j<pLoop->nLTerm && pTerm!=pLoop->aLTerm[j]; j++){}
131341
+ if( j>=pLoop->nLTerm ) continue;
131342
+ }
130126131343
if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){
130127131344
const char *z1, *z2;
130128131345
pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
130129131346
if( !pColl ) pColl = db->pDfltColl;
130130131347
z1 = pColl->zName;
@@ -130157,24 +131374,46 @@
130157131374
** that are not constrained by == or IN.
130158131375
*/
130159131376
rev = revSet = 0;
130160131377
distinctColumns = 0;
130161131378
for(j=0; j<nColumn; j++){
130162
- u8 bOnce; /* True to run the ORDER BY search loop */
130163
-
130164
- /* Skip over == and IS and ISNULL terms.
130165
- ** (Also skip IN terms when doing WHERE_ORDERBY_LIMIT processing)
130166
- */
130167
- if( j<pLoop->u.btree.nEq
130168
- && pLoop->nSkip==0
130169
- && ((i = pLoop->aLTerm[j]->eOperator) & eqOpMask)!=0
130170
- ){
130171
- if( i & WO_ISNULL ){
130172
- testcase( isOrderDistinct );
130173
- isOrderDistinct = 0;
130174
- }
130175
- continue;
131379
+ u8 bOnce = 1; /* True to run the ORDER BY search loop */
131380
+
131381
+ assert( j>=pLoop->u.btree.nEq
131382
+ || (pLoop->aLTerm[j]==0)==(j<pLoop->nSkip)
131383
+ );
131384
+ if( j<pLoop->u.btree.nEq && j>=pLoop->nSkip ){
131385
+ u16 eOp = pLoop->aLTerm[j]->eOperator;
131386
+
131387
+ /* Skip over == and IS and ISNULL terms. (Also skip IN terms when
131388
+ ** doing WHERE_ORDERBY_LIMIT processing).
131389
+ **
131390
+ ** If the current term is a column of an ((?,?) IN (SELECT...))
131391
+ ** expression for which the SELECT returns more than one column,
131392
+ ** check that it is the only column used by this loop. Otherwise,
131393
+ ** if it is one of two or more, none of the columns can be
131394
+ ** considered to match an ORDER BY term. */
131395
+ if( (eOp & eqOpMask)!=0 ){
131396
+ if( eOp & WO_ISNULL ){
131397
+ testcase( isOrderDistinct );
131398
+ isOrderDistinct = 0;
131399
+ }
131400
+ continue;
131401
+ }else if( ALWAYS(eOp & WO_IN) ){
131402
+ /* ALWAYS() justification: eOp is an equality operator due to the
131403
+ ** j<pLoop->u.btree.nEq constraint above. Any equality other
131404
+ ** than WO_IN is captured by the previous "if". So this one
131405
+ ** always has to be WO_IN. */
131406
+ Expr *pX = pLoop->aLTerm[j]->pExpr;
131407
+ for(i=j+1; i<pLoop->u.btree.nEq; i++){
131408
+ if( pLoop->aLTerm[i]->pExpr==pX ){
131409
+ assert( (pLoop->aLTerm[i]->eOperator & WO_IN) );
131410
+ bOnce = 0;
131411
+ break;
131412
+ }
131413
+ }
131414
+ }
130176131415
}
130177131416
130178131417
/* Get the column number in the table (iColumn) and sort order
130179131418
** (revIdx) for the j-th column of the index.
130180131419
*/
@@ -130199,11 +131438,10 @@
130199131438
}
130200131439
130201131440
/* Find the ORDER BY term that corresponds to the j-th column
130202131441
** of the index and mark that ORDER BY term off
130203131442
*/
130204
- bOnce = 1;
130205131443
isMatch = 0;
130206131444
for(i=0; bOnce && i<nOrderBy; i++){
130207131445
if( MASKBIT(i) & obSat ) continue;
130208131446
pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
130209131447
testcase( wctrlFlags & WHERE_GROUPBY );
@@ -131393,14 +132631,16 @@
131393132631
struct InLoop *pIn;
131394132632
int j;
131395132633
sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
131396132634
for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
131397132635
sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
131398
- sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
131399
- VdbeCoverage(v);
131400
- VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
131401
- VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
132636
+ if( pIn->eEndLoopOp!=OP_Noop ){
132637
+ sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
132638
+ VdbeCoverage(v);
132639
+ VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
132640
+ VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
132641
+ }
131402132642
sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
131403132643
}
131404132644
}
131405132645
sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
131406132646
if( pLevel->addrSkip ){
@@ -131843,20 +133083,20 @@
131843133083
#define sqlite3ParserARG_SDECL Parse *pParse;
131844133084
#define sqlite3ParserARG_PDECL ,Parse *pParse
131845133085
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
131846133086
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
131847133087
#define YYFALLBACK 1
131848
-#define YYNSTATE 443
131849
-#define YYNRULE 328
131850
-#define YY_MAX_SHIFT 442
131851
-#define YY_MIN_SHIFTREDUCE 653
131852
-#define YY_MAX_SHIFTREDUCE 980
131853
-#define YY_MIN_REDUCE 981
131854
-#define YY_MAX_REDUCE 1308
131855
-#define YY_ERROR_ACTION 1309
131856
-#define YY_ACCEPT_ACTION 1310
131857
-#define YY_NO_ACTION 1311
133088
+#define YYNSTATE 456
133089
+#define YYNRULE 331
133090
+#define YY_MAX_SHIFT 455
133091
+#define YY_MIN_SHIFTREDUCE 667
133092
+#define YY_MAX_SHIFTREDUCE 997
133093
+#define YY_MIN_REDUCE 998
133094
+#define YY_MAX_REDUCE 1328
133095
+#define YY_ERROR_ACTION 1329
133096
+#define YY_ACCEPT_ACTION 1330
133097
+#define YY_NO_ACTION 1331
131858133098
/************* End control #defines *******************************************/
131859133099
131860133100
/* Define the yytestcase() macro to be a no-op if is not already defined
131861133101
** otherwise.
131862133102
**
@@ -131924,163 +133164,170 @@
131924133164
** yy_reduce_ofst[] For each state, the offset into yy_action for
131925133165
** shifting non-terminals after a reduce.
131926133166
** yy_default[] Default action for each state.
131927133167
**
131928133168
*********** Begin parsing tables **********************************************/
131929
-#define YY_ACTTAB_COUNT (1507)
133169
+#define YY_ACTTAB_COUNT (1571)
131930133170
static const YYACTIONTYPE yy_action[] = {
131931
- /* 0 */ 317, 814, 341, 808, 5, 195, 195, 802, 93, 94,
131932
- /* 10 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131933
- /* 20 */ 92, 92, 92, 293, 90, 90, 90, 90, 89, 89,
131934
- /* 30 */ 88, 88, 88, 87, 341, 317, 958, 958, 807, 807,
131935
- /* 40 */ 807, 928, 344, 93, 94, 84, 823, 823, 835, 838,
131936
- /* 50 */ 827, 827, 91, 91, 92, 92, 92, 92, 328, 90,
131937
- /* 60 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
131938
- /* 70 */ 89, 89, 88, 88, 88, 87, 341, 776, 958, 958,
131939
- /* 80 */ 317, 88, 88, 88, 87, 341, 777, 69, 93, 94,
131940
- /* 90 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131941
- /* 100 */ 92, 92, 92, 437, 90, 90, 90, 90, 89, 89,
131942
- /* 110 */ 88, 88, 88, 87, 341, 1310, 147, 147, 2, 317,
131943
- /* 120 */ 76, 25, 74, 49, 49, 87, 341, 93, 94, 84,
131944
- /* 130 */ 823, 823, 835, 838, 827, 827, 91, 91, 92, 92,
131945
- /* 140 */ 92, 92, 95, 90, 90, 90, 90, 89, 89, 88,
131946
- /* 150 */ 88, 88, 87, 341, 939, 939, 317, 260, 415, 400,
131947
- /* 160 */ 398, 58, 737, 737, 93, 94, 84, 823, 823, 835,
131948
- /* 170 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 57,
131949
- /* 180 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131950
- /* 190 */ 341, 317, 1253, 928, 344, 269, 940, 941, 242, 93,
131951
- /* 200 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131952
- /* 210 */ 92, 92, 92, 92, 293, 90, 90, 90, 90, 89,
131953
- /* 220 */ 89, 88, 88, 88, 87, 341, 317, 919, 1303, 793,
131954
- /* 230 */ 691, 1303, 724, 724, 93, 94, 84, 823, 823, 835,
131955
- /* 240 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 337,
131956
- /* 250 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131957
- /* 260 */ 341, 317, 114, 919, 1304, 684, 395, 1304, 124, 93,
131958
- /* 270 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131959
- /* 280 */ 92, 92, 92, 92, 683, 90, 90, 90, 90, 89,
131960
- /* 290 */ 89, 88, 88, 88, 87, 341, 317, 86, 83, 169,
131961
- /* 300 */ 801, 917, 234, 399, 93, 94, 84, 823, 823, 835,
131962
- /* 310 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 686,
131963
- /* 320 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131964
- /* 330 */ 341, 317, 436, 742, 86, 83, 169, 917, 741, 93,
131965
- /* 340 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131966
- /* 350 */ 92, 92, 92, 92, 902, 90, 90, 90, 90, 89,
131967
- /* 360 */ 89, 88, 88, 88, 87, 341, 317, 321, 434, 434,
131968
- /* 370 */ 434, 1, 722, 722, 93, 94, 84, 823, 823, 835,
131969
- /* 380 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 190,
131970
- /* 390 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131971
- /* 400 */ 341, 317, 685, 292, 939, 939, 150, 977, 310, 93,
131972
- /* 410 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131973
- /* 420 */ 92, 92, 92, 92, 437, 90, 90, 90, 90, 89,
131974
- /* 430 */ 89, 88, 88, 88, 87, 341, 926, 2, 372, 719,
131975
- /* 440 */ 698, 369, 950, 317, 49, 49, 940, 941, 719, 177,
131976
- /* 450 */ 72, 93, 94, 84, 823, 823, 835, 838, 827, 827,
131977
- /* 460 */ 91, 91, 92, 92, 92, 92, 322, 90, 90, 90,
131978
- /* 470 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 415,
131979
- /* 480 */ 405, 824, 824, 836, 839, 75, 93, 82, 84, 823,
131980
- /* 490 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131981
- /* 500 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88,
131982
- /* 510 */ 88, 87, 341, 317, 340, 340, 340, 658, 659, 660,
131983
- /* 520 */ 333, 288, 94, 84, 823, 823, 835, 838, 827, 827,
131984
- /* 530 */ 91, 91, 92, 92, 92, 92, 437, 90, 90, 90,
131985
- /* 540 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 882,
131986
- /* 550 */ 882, 375, 828, 66, 330, 409, 49, 49, 84, 823,
131987
- /* 560 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131988
- /* 570 */ 92, 351, 90, 90, 90, 90, 89, 89, 88, 88,
131989
- /* 580 */ 88, 87, 341, 80, 432, 742, 3, 1180, 351, 350,
131990
- /* 590 */ 741, 334, 796, 939, 939, 761, 80, 432, 278, 3,
131991
- /* 600 */ 204, 161, 279, 393, 274, 392, 191, 362, 437, 277,
131992
- /* 610 */ 745, 77, 78, 272, 800, 254, 355, 243, 79, 342,
131993
- /* 620 */ 342, 86, 83, 169, 77, 78, 234, 399, 49, 49,
131994
- /* 630 */ 435, 79, 342, 342, 437, 940, 941, 186, 442, 655,
131995
- /* 640 */ 390, 387, 386, 435, 235, 213, 108, 421, 761, 351,
131996
- /* 650 */ 437, 385, 167, 732, 10, 10, 124, 124, 671, 814,
131997
- /* 660 */ 421, 439, 438, 415, 414, 802, 362, 168, 327, 124,
131998
- /* 670 */ 49, 49, 814, 219, 439, 438, 800, 186, 802, 326,
131999
- /* 680 */ 390, 387, 386, 437, 1248, 1248, 23, 939, 939, 80,
132000
- /* 690 */ 432, 385, 3, 761, 416, 876, 807, 807, 807, 809,
132001
- /* 700 */ 19, 290, 149, 49, 49, 415, 396, 260, 910, 807,
132002
- /* 710 */ 807, 807, 809, 19, 312, 237, 145, 77, 78, 746,
132003
- /* 720 */ 168, 702, 437, 149, 79, 342, 342, 114, 358, 940,
132004
- /* 730 */ 941, 302, 223, 397, 345, 313, 435, 260, 415, 417,
132005
- /* 740 */ 858, 374, 31, 31, 80, 432, 761, 3, 348, 92,
132006
- /* 750 */ 92, 92, 92, 421, 90, 90, 90, 90, 89, 89,
132007
- /* 760 */ 88, 88, 88, 87, 341, 814, 114, 439, 438, 796,
132008
- /* 770 */ 367, 802, 77, 78, 701, 796, 124, 1187, 220, 79,
132009
- /* 780 */ 342, 342, 124, 747, 734, 939, 939, 775, 404, 939,
132010
- /* 790 */ 939, 435, 254, 360, 253, 402, 895, 346, 254, 360,
132011
- /* 800 */ 253, 774, 807, 807, 807, 809, 19, 800, 421, 90,
132012
- /* 810 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
132013
- /* 820 */ 814, 114, 439, 438, 939, 939, 802, 940, 941, 114,
132014
- /* 830 */ 437, 940, 941, 86, 83, 169, 192, 166, 309, 979,
132015
- /* 840 */ 70, 432, 700, 3, 382, 870, 238, 86, 83, 169,
132016
- /* 850 */ 10, 10, 361, 406, 763, 190, 222, 807, 807, 807,
132017
- /* 860 */ 809, 19, 870, 872, 329, 24, 940, 941, 77, 78,
132018
- /* 870 */ 359, 437, 335, 260, 218, 79, 342, 342, 437, 307,
132019
- /* 880 */ 306, 305, 207, 303, 339, 338, 668, 435, 339, 338,
132020
- /* 890 */ 407, 10, 10, 762, 216, 216, 939, 939, 49, 49,
132021
- /* 900 */ 437, 260, 97, 241, 421, 225, 402, 189, 188, 187,
132022
- /* 910 */ 309, 918, 980, 149, 221, 898, 814, 868, 439, 438,
132023
- /* 920 */ 10, 10, 802, 870, 915, 316, 898, 163, 162, 171,
132024
- /* 930 */ 249, 240, 322, 410, 412, 687, 687, 272, 940, 941,
132025
- /* 940 */ 239, 965, 901, 437, 226, 403, 226, 437, 963, 367,
132026
- /* 950 */ 964, 173, 248, 807, 807, 807, 809, 19, 174, 367,
132027
- /* 960 */ 899, 124, 172, 48, 48, 9, 9, 35, 35, 966,
132028
- /* 970 */ 966, 899, 363, 966, 966, 814, 900, 808, 725, 939,
132029
- /* 980 */ 939, 802, 895, 318, 980, 324, 125, 900, 726, 420,
132030
- /* 990 */ 92, 92, 92, 92, 85, 90, 90, 90, 90, 89,
132031
- /* 1000 */ 89, 88, 88, 88, 87, 341, 216, 216, 437, 946,
132032
- /* 1010 */ 349, 292, 807, 807, 807, 114, 291, 693, 402, 705,
132033
- /* 1020 */ 890, 940, 941, 437, 245, 889, 247, 437, 36, 36,
132034
- /* 1030 */ 437, 353, 391, 437, 260, 252, 260, 437, 361, 437,
132035
- /* 1040 */ 706, 437, 370, 12, 12, 224, 437, 27, 27, 437,
132036
- /* 1050 */ 37, 37, 437, 38, 38, 752, 368, 39, 39, 28,
132037
- /* 1060 */ 28, 29, 29, 215, 166, 331, 40, 40, 437, 41,
132038
- /* 1070 */ 41, 437, 42, 42, 437, 866, 246, 731, 437, 879,
132039
- /* 1080 */ 437, 256, 437, 878, 437, 267, 437, 261, 11, 11,
132040
- /* 1090 */ 437, 43, 43, 437, 99, 99, 437, 373, 44, 44,
132041
- /* 1100 */ 45, 45, 32, 32, 46, 46, 47, 47, 437, 426,
132042
- /* 1110 */ 33, 33, 776, 116, 116, 437, 117, 117, 437, 124,
132043
- /* 1120 */ 437, 777, 437, 260, 437, 957, 437, 352, 118, 118,
132044
- /* 1130 */ 437, 195, 437, 111, 437, 53, 53, 264, 34, 34,
132045
- /* 1140 */ 100, 100, 50, 50, 101, 101, 102, 102, 437, 260,
132046
- /* 1150 */ 98, 98, 115, 115, 113, 113, 437, 262, 437, 265,
132047
- /* 1160 */ 437, 943, 958, 437, 727, 437, 681, 437, 106, 106,
132048
- /* 1170 */ 68, 437, 893, 730, 437, 365, 105, 105, 103, 103,
132049
- /* 1180 */ 104, 104, 217, 52, 52, 54, 54, 51, 51, 694,
132050
- /* 1190 */ 259, 26, 26, 266, 30, 30, 677, 323, 433, 323,
132051
- /* 1200 */ 674, 423, 427, 943, 958, 114, 114, 431, 681, 865,
132052
- /* 1210 */ 1277, 233, 366, 714, 112, 20, 154, 704, 703, 810,
132053
- /* 1220 */ 914, 55, 159, 311, 798, 255, 383, 194, 68, 200,
132054
- /* 1230 */ 21, 694, 268, 114, 114, 114, 270, 711, 712, 68,
132055
- /* 1240 */ 114, 739, 770, 715, 71, 194, 861, 875, 875, 200,
132056
- /* 1250 */ 696, 865, 874, 874, 679, 699, 273, 110, 229, 419,
132057
- /* 1260 */ 768, 810, 799, 378, 748, 759, 418, 210, 294, 281,
132058
- /* 1270 */ 295, 806, 283, 682, 676, 665, 664, 666, 933, 151,
132059
- /* 1280 */ 285, 7, 1267, 308, 251, 790, 354, 244, 892, 364,
132060
- /* 1290 */ 287, 422, 300, 164, 160, 936, 974, 127, 197, 137,
132061
- /* 1300 */ 909, 907, 971, 388, 276, 863, 862, 56, 698, 325,
132062
- /* 1310 */ 148, 59, 122, 66, 356, 381, 357, 176, 152, 62,
132063
- /* 1320 */ 371, 130, 877, 181, 377, 760, 211, 182, 132, 133,
132064
- /* 1330 */ 134, 135, 258, 146, 140, 795, 787, 263, 183, 379,
132065
- /* 1340 */ 667, 394, 184, 332, 894, 314, 718, 717, 857, 716,
132066
- /* 1350 */ 696, 315, 709, 690, 65, 196, 6, 408, 289, 708,
132067
- /* 1360 */ 275, 689, 688, 948, 756, 757, 280, 282, 425, 755,
132068
- /* 1370 */ 284, 336, 73, 67, 754, 429, 411, 96, 286, 413,
132069
- /* 1380 */ 205, 934, 673, 22, 209, 440, 119, 120, 109, 206,
132070
- /* 1390 */ 208, 441, 662, 661, 656, 843, 654, 343, 158, 236,
132071
- /* 1400 */ 170, 347, 107, 227, 121, 738, 873, 298, 296, 297,
132072
- /* 1410 */ 299, 871, 794, 128, 129, 728, 230, 131, 175, 250,
132073
- /* 1420 */ 888, 136, 138, 231, 232, 139, 60, 61, 891, 178,
132074
- /* 1430 */ 179, 887, 8, 13, 180, 257, 880, 968, 194, 141,
132075
- /* 1440 */ 142, 376, 153, 670, 380, 185, 143, 277, 63, 384,
132076
- /* 1450 */ 14, 707, 271, 15, 389, 64, 319, 320, 126, 228,
132077
- /* 1460 */ 813, 812, 841, 736, 123, 16, 401, 740, 4, 769,
132078
- /* 1470 */ 165, 212, 214, 193, 144, 764, 71, 68, 17, 18,
132079
- /* 1480 */ 856, 842, 840, 897, 845, 896, 199, 198, 923, 155,
132080
- /* 1490 */ 424, 929, 924, 156, 201, 202, 428, 844, 157, 203,
132081
- /* 1500 */ 811, 680, 81, 1269, 1268, 301, 304,
133171
+ /* 0 */ 325, 830, 351, 824, 5, 203, 203, 818, 99, 100,
133172
+ /* 10 */ 90, 840, 840, 852, 855, 844, 844, 97, 97, 98,
133173
+ /* 20 */ 98, 98, 98, 301, 96, 96, 96, 96, 95, 95,
133174
+ /* 30 */ 94, 94, 94, 93, 351, 325, 975, 975, 823, 823,
133175
+ /* 40 */ 823, 945, 354, 99, 100, 90, 840, 840, 852, 855,
133176
+ /* 50 */ 844, 844, 97, 97, 98, 98, 98, 98, 338, 96,
133177
+ /* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
133178
+ /* 70 */ 95, 95, 94, 94, 94, 93, 351, 790, 975, 975,
133179
+ /* 80 */ 325, 94, 94, 94, 93, 351, 791, 75, 99, 100,
133180
+ /* 90 */ 90, 840, 840, 852, 855, 844, 844, 97, 97, 98,
133181
+ /* 100 */ 98, 98, 98, 450, 96, 96, 96, 96, 95, 95,
133182
+ /* 110 */ 94, 94, 94, 93, 351, 1330, 155, 155, 2, 325,
133183
+ /* 120 */ 275, 146, 132, 52, 52, 93, 351, 99, 100, 90,
133184
+ /* 130 */ 840, 840, 852, 855, 844, 844, 97, 97, 98, 98,
133185
+ /* 140 */ 98, 98, 101, 96, 96, 96, 96, 95, 95, 94,
133186
+ /* 150 */ 94, 94, 93, 351, 956, 956, 325, 268, 428, 413,
133187
+ /* 160 */ 411, 61, 751, 751, 99, 100, 90, 840, 840, 852,
133188
+ /* 170 */ 855, 844, 844, 97, 97, 98, 98, 98, 98, 60,
133189
+ /* 180 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133190
+ /* 190 */ 351, 325, 270, 329, 273, 277, 957, 958, 250, 99,
133191
+ /* 200 */ 100, 90, 840, 840, 852, 855, 844, 844, 97, 97,
133192
+ /* 210 */ 98, 98, 98, 98, 301, 96, 96, 96, 96, 95,
133193
+ /* 220 */ 95, 94, 94, 94, 93, 351, 325, 936, 1323, 697,
133194
+ /* 230 */ 705, 1323, 242, 412, 99, 100, 90, 840, 840, 852,
133195
+ /* 240 */ 855, 844, 844, 97, 97, 98, 98, 98, 98, 347,
133196
+ /* 250 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133197
+ /* 260 */ 351, 325, 936, 1324, 384, 698, 1324, 381, 379, 99,
133198
+ /* 270 */ 100, 90, 840, 840, 852, 855, 844, 844, 97, 97,
133199
+ /* 280 */ 98, 98, 98, 98, 700, 96, 96, 96, 96, 95,
133200
+ /* 290 */ 95, 94, 94, 94, 93, 351, 325, 92, 89, 178,
133201
+ /* 300 */ 831, 934, 373, 699, 99, 100, 90, 840, 840, 852,
133202
+ /* 310 */ 855, 844, 844, 97, 97, 98, 98, 98, 98, 375,
133203
+ /* 320 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133204
+ /* 330 */ 351, 325, 1273, 945, 354, 817, 934, 738, 738, 99,
133205
+ /* 340 */ 100, 90, 840, 840, 852, 855, 844, 844, 97, 97,
133206
+ /* 350 */ 98, 98, 98, 98, 230, 96, 96, 96, 96, 95,
133207
+ /* 360 */ 95, 94, 94, 94, 93, 351, 325, 967, 227, 92,
133208
+ /* 370 */ 89, 178, 373, 300, 99, 100, 90, 840, 840, 852,
133209
+ /* 380 */ 855, 844, 844, 97, 97, 98, 98, 98, 98, 919,
133210
+ /* 390 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133211
+ /* 400 */ 351, 325, 449, 447, 447, 447, 147, 736, 736, 99,
133212
+ /* 410 */ 100, 90, 840, 840, 852, 855, 844, 844, 97, 97,
133213
+ /* 420 */ 98, 98, 98, 98, 296, 96, 96, 96, 96, 95,
133214
+ /* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 956,
133215
+ /* 440 */ 956, 158, 25, 422, 99, 100, 90, 840, 840, 852,
133216
+ /* 450 */ 855, 844, 844, 97, 97, 98, 98, 98, 98, 450,
133217
+ /* 460 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133218
+ /* 470 */ 351, 443, 224, 224, 420, 956, 956, 960, 325, 52,
133219
+ /* 480 */ 52, 957, 958, 176, 415, 78, 99, 100, 90, 840,
133220
+ /* 490 */ 840, 852, 855, 844, 844, 97, 97, 98, 98, 98,
133221
+ /* 500 */ 98, 379, 96, 96, 96, 96, 95, 95, 94, 94,
133222
+ /* 510 */ 94, 93, 351, 325, 428, 418, 298, 957, 958, 960,
133223
+ /* 520 */ 81, 99, 88, 90, 840, 840, 852, 855, 844, 844,
133224
+ /* 530 */ 97, 97, 98, 98, 98, 98, 716, 96, 96, 96,
133225
+ /* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 841,
133226
+ /* 550 */ 841, 853, 856, 994, 318, 343, 379, 100, 90, 840,
133227
+ /* 560 */ 840, 852, 855, 844, 844, 97, 97, 98, 98, 98,
133228
+ /* 570 */ 98, 450, 96, 96, 96, 96, 95, 95, 94, 94,
133229
+ /* 580 */ 94, 93, 351, 325, 350, 350, 350, 260, 377, 340,
133230
+ /* 590 */ 927, 52, 52, 90, 840, 840, 852, 855, 844, 844,
133231
+ /* 600 */ 97, 97, 98, 98, 98, 98, 361, 96, 96, 96,
133232
+ /* 610 */ 96, 95, 95, 94, 94, 94, 93, 351, 86, 445,
133233
+ /* 620 */ 845, 3, 1200, 361, 360, 378, 344, 812, 956, 956,
133234
+ /* 630 */ 1297, 86, 445, 728, 3, 212, 169, 287, 405, 282,
133235
+ /* 640 */ 404, 199, 232, 450, 300, 759, 83, 84, 280, 245,
133236
+ /* 650 */ 262, 365, 251, 85, 352, 352, 92, 89, 178, 83,
133237
+ /* 660 */ 84, 242, 412, 52, 52, 448, 85, 352, 352, 246,
133238
+ /* 670 */ 957, 958, 194, 455, 669, 402, 399, 398, 448, 243,
133239
+ /* 680 */ 221, 114, 434, 775, 361, 450, 397, 268, 746, 224,
133240
+ /* 690 */ 224, 132, 132, 198, 830, 434, 452, 451, 428, 427,
133241
+ /* 700 */ 818, 415, 733, 712, 132, 52, 52, 830, 268, 452,
133242
+ /* 710 */ 451, 733, 194, 818, 363, 402, 399, 398, 450, 1268,
133243
+ /* 720 */ 1268, 23, 956, 956, 86, 445, 397, 3, 228, 429,
133244
+ /* 730 */ 893, 823, 823, 823, 825, 19, 203, 719, 52, 52,
133245
+ /* 740 */ 428, 408, 439, 249, 823, 823, 823, 825, 19, 229,
133246
+ /* 750 */ 403, 153, 83, 84, 760, 177, 241, 450, 720, 85,
133247
+ /* 760 */ 352, 352, 120, 157, 957, 958, 58, 975, 409, 355,
133248
+ /* 770 */ 330, 448, 268, 428, 430, 320, 789, 32, 32, 86,
133249
+ /* 780 */ 445, 775, 3, 341, 98, 98, 98, 98, 434, 96,
133250
+ /* 790 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
133251
+ /* 800 */ 830, 120, 452, 451, 812, 885, 818, 83, 84, 975,
133252
+ /* 810 */ 812, 132, 410, 918, 85, 352, 352, 132, 407, 788,
133253
+ /* 820 */ 956, 956, 92, 89, 178, 915, 448, 262, 370, 261,
133254
+ /* 830 */ 82, 912, 80, 262, 370, 261, 932, 823, 823, 823,
133255
+ /* 840 */ 825, 19, 257, 434, 96, 96, 96, 96, 95, 95,
133256
+ /* 850 */ 94, 94, 94, 93, 351, 830, 268, 452, 451, 956,
133257
+ /* 860 */ 956, 818, 957, 958, 120, 92, 89, 178, 943, 2,
133258
+ /* 870 */ 916, 963, 268, 1, 766, 76, 445, 761, 3, 707,
133259
+ /* 880 */ 899, 899, 387, 956, 956, 756, 917, 371, 739, 777,
133260
+ /* 890 */ 755, 907, 823, 823, 823, 825, 19, 883, 740, 450,
133261
+ /* 900 */ 24, 957, 958, 83, 84, 369, 956, 956, 708, 226,
133262
+ /* 910 */ 85, 352, 352, 745, 315, 314, 313, 215, 311, 10,
133263
+ /* 920 */ 10, 682, 448, 349, 348, 957, 958, 887, 776, 691,
133264
+ /* 930 */ 331, 956, 956, 337, 157, 450, 268, 103, 450, 434,
133265
+ /* 940 */ 450, 816, 310, 906, 887, 889, 321, 450, 957, 958,
133266
+ /* 950 */ 708, 830, 775, 452, 451, 10, 10, 818, 10, 10,
133267
+ /* 960 */ 52, 52, 171, 170, 180, 225, 248, 10, 10, 339,
133268
+ /* 970 */ 701, 701, 233, 957, 958, 247, 982, 741, 450, 956,
133269
+ /* 980 */ 956, 425, 157, 980, 685, 981, 182, 912, 823, 823,
133270
+ /* 990 */ 823, 825, 19, 183, 324, 423, 132, 181, 51, 51,
133271
+ /* 1000 */ 715, 349, 348, 394, 256, 887, 334, 915, 983, 983,
133272
+ /* 1010 */ 830, 417, 824, 234, 198, 234, 818, 268, 326, 382,
133273
+ /* 1020 */ 120, 957, 958, 264, 177, 98, 98, 98, 98, 91,
133274
+ /* 1030 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133275
+ /* 1040 */ 351, 816, 416, 371, 120, 359, 816, 823, 823, 823,
133276
+ /* 1050 */ 775, 299, 916, 450, 368, 197, 196, 195, 358, 200,
133277
+ /* 1060 */ 175, 380, 9, 9, 450, 1287, 875, 714, 917, 450,
133278
+ /* 1070 */ 433, 237, 450, 36, 36, 132, 253, 450, 255, 450,
133279
+ /* 1080 */ 117, 450, 809, 362, 37, 37, 983, 983, 450, 12,
133280
+ /* 1090 */ 12, 330, 27, 27, 446, 331, 280, 38, 38, 39,
133281
+ /* 1100 */ 39, 40, 40, 1207, 450, 816, 335, 356, 41, 41,
133282
+ /* 1110 */ 450, 336, 450, 695, 450, 120, 450, 332, 133, 450,
133283
+ /* 1120 */ 268, 450, 269, 450, 42, 42, 450, 816, 254, 450,
133284
+ /* 1130 */ 28, 28, 29, 29, 31, 31, 43, 43, 450, 44,
133285
+ /* 1140 */ 44, 45, 45, 11, 11, 450, 46, 46, 450, 105,
133286
+ /* 1150 */ 105, 450, 748, 713, 450, 695, 450, 910, 47, 47,
133287
+ /* 1160 */ 450, 267, 450, 415, 450, 48, 48, 450, 33, 33,
133288
+ /* 1170 */ 386, 49, 49, 450, 50, 50, 34, 34, 450, 172,
133289
+ /* 1180 */ 122, 122, 123, 123, 124, 124, 450, 56, 56, 450,
133290
+ /* 1190 */ 120, 450, 345, 35, 35, 450, 790, 450, 106, 106,
133291
+ /* 1200 */ 450, 74, 450, 974, 450, 791, 53, 53, 432, 107,
133292
+ /* 1210 */ 107, 108, 108, 450, 272, 104, 104, 121, 121, 450,
133293
+ /* 1220 */ 119, 119, 112, 112, 111, 111, 450, 317, 996, 450,
133294
+ /* 1230 */ 118, 450, 162, 109, 109, 317, 935, 450, 896, 110,
133295
+ /* 1240 */ 110, 450, 895, 744, 688, 436, 55, 55, 20, 57,
133296
+ /* 1250 */ 57, 54, 54, 440, 444, 756, 385, 26, 26, 274,
133297
+ /* 1260 */ 755, 30, 30, 21, 672, 673, 674, 223, 175, 931,
133298
+ /* 1270 */ 814, 372, 319, 202, 202, 882, 120, 120, 120, 374,
133299
+ /* 1280 */ 826, 710, 202, 72, 276, 263, 120, 120, 74, 395,
133300
+ /* 1290 */ 278, 286, 208, 74, 718, 717, 725, 726, 892, 892,
133301
+ /* 1300 */ 167, 997, 285, 753, 729, 784, 77, 878, 202, 997,
133302
+ /* 1310 */ 208, 693, 891, 891, 116, 281, 782, 882, 390, 815,
133303
+ /* 1320 */ 762, 773, 826, 431, 302, 303, 822, 218, 696, 289,
133304
+ /* 1330 */ 690, 291, 293, 679, 678, 680, 950, 159, 316, 7,
133305
+ /* 1340 */ 364, 252, 259, 804, 909, 376, 400, 295, 308, 173,
133306
+ /* 1350 */ 435, 953, 168, 991, 135, 205, 926, 924, 59, 988,
133307
+ /* 1360 */ 62, 284, 880, 333, 879, 712, 144, 156, 130, 72,
133308
+ /* 1370 */ 366, 367, 393, 185, 189, 160, 383, 67, 389, 266,
133309
+ /* 1380 */ 137, 894, 774, 219, 154, 139, 190, 140, 391, 271,
133310
+ /* 1390 */ 191, 141, 142, 801, 681, 148, 811, 342, 322, 192,
133311
+ /* 1400 */ 406, 732, 911, 874, 723, 731, 323, 710, 730, 71,
133312
+ /* 1410 */ 704, 204, 283, 703, 6, 79, 421, 702, 965, 770,
133313
+ /* 1420 */ 297, 346, 426, 102, 722, 288, 73, 424, 213, 951,
133314
+ /* 1430 */ 771, 438, 22, 290, 687, 769, 442, 453, 239, 217,
133315
+ /* 1440 */ 214, 668, 125, 353, 126, 216, 454, 166, 676, 115,
133316
+ /* 1450 */ 675, 235, 244, 179, 670, 357, 810, 113, 890, 888,
133317
+ /* 1460 */ 292, 136, 128, 752, 304, 768, 294, 305, 138, 742,
133318
+ /* 1470 */ 306, 307, 127, 184, 860, 258, 905, 145, 143, 238,
133319
+ /* 1480 */ 63, 64, 65, 66, 240, 129, 908, 186, 187, 904,
133320
+ /* 1490 */ 8, 13, 188, 265, 897, 149, 202, 985, 388, 684,
133321
+ /* 1500 */ 150, 161, 392, 285, 193, 279, 151, 396, 68, 14,
133322
+ /* 1510 */ 401, 15, 327, 721, 328, 134, 69, 70, 236, 131,
133323
+ /* 1520 */ 829, 828, 858, 750, 16, 201, 754, 4, 783, 220,
133324
+ /* 1530 */ 414, 174, 222, 152, 77, 778, 74, 17, 18, 873,
133325
+ /* 1540 */ 859, 857, 914, 862, 913, 207, 206, 940, 163, 437,
133326
+ /* 1550 */ 946, 941, 164, 209, 210, 441, 861, 165, 312, 827,
133327
+ /* 1560 */ 694, 87, 1000, 309, 211, 1000, 1000, 1000, 1000, 1289,
133328
+ /* 1570 */ 1288,
132082133329
};
132083133330
static const YYCODETYPE yy_lookahead[] = {
132084133331
/* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
132085133332
/* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
132086133333
/* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
@@ -132091,285 +133338,295 @@
132091133338
/* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97,
132092133339
/* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28,
132093133340
/* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
132094133341
/* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
132095133342
/* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19,
132096
- /* 120 */ 137, 22, 139, 172, 173, 52, 53, 27, 28, 29,
133343
+ /* 120 */ 16, 22, 92, 172, 173, 52, 53, 27, 28, 29,
132097133344
/* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
132098133345
/* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49,
132099133346
/* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208,
132100133347
/* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32,
132101133348
/* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79,
132102133349
/* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132103
- /* 190 */ 53, 19, 0, 1, 2, 23, 97, 98, 193, 27,
133350
+ /* 190 */ 53, 19, 88, 157, 90, 23, 97, 98, 193, 27,
132104133351
/* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132105133352
/* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
132106
- /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 163,
132107
- /* 230 */ 23, 26, 190, 191, 27, 28, 29, 30, 31, 32,
133353
+ /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 172,
133354
+ /* 230 */ 23, 26, 119, 120, 27, 28, 29, 30, 31, 32,
132108133355
/* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
132109133356
/* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132110
- /* 260 */ 53, 19, 196, 22, 23, 23, 49, 26, 92, 27,
133357
+ /* 260 */ 53, 19, 22, 23, 228, 23, 26, 231, 152, 27,
132111133358
/* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132112133359
/* 280 */ 38, 39, 40, 41, 172, 43, 44, 45, 46, 47,
132113133360
/* 290 */ 48, 49, 50, 51, 52, 53, 19, 221, 222, 223,
132114
- /* 300 */ 23, 96, 119, 120, 27, 28, 29, 30, 31, 32,
132115
- /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 172,
133361
+ /* 300 */ 23, 96, 152, 172, 27, 28, 29, 30, 31, 32,
133362
+ /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 152,
132116133363
/* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132117
- /* 330 */ 53, 19, 152, 116, 221, 222, 223, 96, 121, 27,
133364
+ /* 330 */ 53, 19, 0, 1, 2, 23, 96, 190, 191, 27,
132118133365
/* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132119
- /* 350 */ 38, 39, 40, 41, 241, 43, 44, 45, 46, 47,
132120
- /* 360 */ 48, 49, 50, 51, 52, 53, 19, 157, 168, 169,
132121
- /* 370 */ 170, 22, 190, 191, 27, 28, 29, 30, 31, 32,
132122
- /* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 30,
133366
+ /* 350 */ 38, 39, 40, 41, 238, 43, 44, 45, 46, 47,
133367
+ /* 360 */ 48, 49, 50, 51, 52, 53, 19, 185, 218, 221,
133368
+ /* 370 */ 222, 223, 152, 152, 27, 28, 29, 30, 31, 32,
133369
+ /* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 241,
132123133370
/* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132124
- /* 400 */ 53, 19, 172, 152, 55, 56, 24, 247, 248, 27,
133371
+ /* 400 */ 53, 19, 152, 168, 169, 170, 22, 190, 191, 27,
132125133372
/* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132126133373
/* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
132127
- /* 430 */ 48, 49, 50, 51, 52, 53, 146, 147, 228, 179,
132128
- /* 440 */ 180, 231, 185, 19, 172, 173, 97, 98, 188, 26,
132129
- /* 450 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35,
132130
- /* 460 */ 36, 37, 38, 39, 40, 41, 107, 43, 44, 45,
132131
- /* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 207,
132132
- /* 480 */ 208, 30, 31, 32, 33, 138, 27, 28, 29, 30,
133374
+ /* 430 */ 48, 49, 50, 51, 52, 53, 19, 19, 218, 55,
133375
+ /* 440 */ 56, 24, 22, 152, 27, 28, 29, 30, 31, 32,
133376
+ /* 450 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 152,
133377
+ /* 460 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
133378
+ /* 470 */ 53, 250, 194, 195, 56, 55, 56, 55, 19, 172,
133379
+ /* 480 */ 173, 97, 98, 152, 206, 138, 27, 28, 29, 30,
132133133380
/* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
132134
- /* 500 */ 41, 250, 43, 44, 45, 46, 47, 48, 49, 50,
132135
- /* 510 */ 51, 52, 53, 19, 168, 169, 170, 7, 8, 9,
132136
- /* 520 */ 19, 152, 28, 29, 30, 31, 32, 33, 34, 35,
132137
- /* 530 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45,
132138
- /* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 108,
132139
- /* 550 */ 109, 110, 101, 130, 53, 152, 172, 173, 29, 30,
133381
+ /* 500 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50,
133382
+ /* 510 */ 51, 52, 53, 19, 207, 208, 152, 97, 98, 97,
133383
+ /* 520 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35,
133384
+ /* 530 */ 36, 37, 38, 39, 40, 41, 181, 43, 44, 45,
133385
+ /* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 30,
133386
+ /* 550 */ 31, 32, 33, 247, 248, 19, 152, 28, 29, 30,
132140133387
/* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
132141133388
/* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50,
132142
- /* 580 */ 51, 52, 53, 19, 20, 116, 22, 23, 169, 170,
132143
- /* 590 */ 121, 207, 85, 55, 56, 26, 19, 20, 101, 22,
132144
- /* 600 */ 99, 100, 101, 102, 103, 104, 105, 152, 152, 112,
132145
- /* 610 */ 210, 47, 48, 112, 152, 108, 109, 110, 54, 55,
132146
- /* 620 */ 56, 221, 222, 223, 47, 48, 119, 120, 172, 173,
132147
- /* 630 */ 66, 54, 55, 56, 152, 97, 98, 99, 148, 149,
132148
- /* 640 */ 102, 103, 104, 66, 154, 23, 156, 83, 26, 230,
132149
- /* 650 */ 152, 113, 152, 163, 172, 173, 92, 92, 21, 95,
132150
- /* 660 */ 83, 97, 98, 207, 208, 101, 152, 98, 186, 92,
132151
- /* 670 */ 172, 173, 95, 218, 97, 98, 152, 99, 101, 217,
132152
- /* 680 */ 102, 103, 104, 152, 119, 120, 196, 55, 56, 19,
132153
- /* 690 */ 20, 113, 22, 124, 163, 11, 132, 133, 134, 135,
132154
- /* 700 */ 136, 152, 152, 172, 173, 207, 208, 152, 152, 132,
132155
- /* 710 */ 133, 134, 135, 136, 164, 152, 84, 47, 48, 49,
132156
- /* 720 */ 98, 181, 152, 152, 54, 55, 56, 196, 91, 97,
132157
- /* 730 */ 98, 160, 218, 163, 244, 164, 66, 152, 207, 208,
132158
- /* 740 */ 103, 217, 172, 173, 19, 20, 124, 22, 193, 38,
132159
- /* 750 */ 39, 40, 41, 83, 43, 44, 45, 46, 47, 48,
132160
- /* 760 */ 49, 50, 51, 52, 53, 95, 196, 97, 98, 85,
132161
- /* 770 */ 152, 101, 47, 48, 181, 85, 92, 140, 193, 54,
132162
- /* 780 */ 55, 56, 92, 49, 195, 55, 56, 175, 163, 55,
132163
- /* 790 */ 56, 66, 108, 109, 110, 206, 163, 242, 108, 109,
132164
- /* 800 */ 110, 175, 132, 133, 134, 135, 136, 152, 83, 43,
132165
- /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
132166
- /* 820 */ 95, 196, 97, 98, 55, 56, 101, 97, 98, 196,
132167
- /* 830 */ 152, 97, 98, 221, 222, 223, 211, 212, 22, 23,
132168
- /* 840 */ 19, 20, 181, 22, 19, 152, 152, 221, 222, 223,
132169
- /* 850 */ 172, 173, 219, 19, 124, 30, 238, 132, 133, 134,
132170
- /* 860 */ 135, 136, 169, 170, 186, 232, 97, 98, 47, 48,
132171
- /* 870 */ 237, 152, 217, 152, 5, 54, 55, 56, 152, 10,
132172
- /* 880 */ 11, 12, 13, 14, 47, 48, 17, 66, 47, 48,
132173
- /* 890 */ 56, 172, 173, 124, 194, 195, 55, 56, 172, 173,
132174
- /* 900 */ 152, 152, 22, 152, 83, 186, 206, 108, 109, 110,
132175
- /* 910 */ 22, 23, 96, 152, 193, 12, 95, 152, 97, 98,
132176
- /* 920 */ 172, 173, 101, 230, 152, 164, 12, 47, 48, 60,
132177
- /* 930 */ 152, 62, 107, 207, 186, 55, 56, 112, 97, 98,
132178
- /* 940 */ 71, 100, 193, 152, 183, 152, 185, 152, 107, 152,
132179
- /* 950 */ 109, 82, 16, 132, 133, 134, 135, 136, 89, 152,
132180
- /* 960 */ 57, 92, 93, 172, 173, 172, 173, 172, 173, 132,
132181
- /* 970 */ 133, 57, 152, 132, 133, 95, 73, 97, 75, 55,
132182
- /* 980 */ 56, 101, 163, 114, 96, 245, 246, 73, 85, 75,
132183
- /* 990 */ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
132184
- /* 1000 */ 48, 49, 50, 51, 52, 53, 194, 195, 152, 171,
132185
- /* 1010 */ 141, 152, 132, 133, 134, 196, 225, 179, 206, 65,
132186
- /* 1020 */ 152, 97, 98, 152, 88, 152, 90, 152, 172, 173,
132187
- /* 1030 */ 152, 219, 78, 152, 152, 238, 152, 152, 219, 152,
132188
- /* 1040 */ 86, 152, 152, 172, 173, 238, 152, 172, 173, 152,
132189
- /* 1050 */ 172, 173, 152, 172, 173, 213, 237, 172, 173, 172,
132190
- /* 1060 */ 173, 172, 173, 211, 212, 111, 172, 173, 152, 172,
132191
- /* 1070 */ 173, 152, 172, 173, 152, 193, 140, 193, 152, 59,
132192
- /* 1080 */ 152, 152, 152, 63, 152, 16, 152, 152, 172, 173,
132193
- /* 1090 */ 152, 172, 173, 152, 172, 173, 152, 77, 172, 173,
132194
- /* 1100 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 250,
132195
- /* 1110 */ 172, 173, 61, 172, 173, 152, 172, 173, 152, 92,
132196
- /* 1120 */ 152, 70, 152, 152, 152, 26, 152, 100, 172, 173,
132197
- /* 1130 */ 152, 24, 152, 22, 152, 172, 173, 152, 172, 173,
132198
- /* 1140 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 152,
132199
- /* 1150 */ 172, 173, 172, 173, 172, 173, 152, 88, 152, 90,
132200
- /* 1160 */ 152, 55, 55, 152, 193, 152, 55, 152, 172, 173,
132201
- /* 1170 */ 26, 152, 163, 163, 152, 19, 172, 173, 172, 173,
132202
- /* 1180 */ 172, 173, 22, 172, 173, 172, 173, 172, 173, 55,
132203
- /* 1190 */ 193, 172, 173, 152, 172, 173, 166, 167, 166, 167,
132204
- /* 1200 */ 163, 163, 163, 97, 97, 196, 196, 163, 97, 55,
132205
- /* 1210 */ 23, 199, 56, 26, 22, 22, 24, 100, 101, 55,
132206
- /* 1220 */ 23, 209, 123, 26, 23, 23, 23, 26, 26, 26,
132207
- /* 1230 */ 37, 97, 152, 196, 196, 196, 23, 7, 8, 26,
132208
- /* 1240 */ 196, 23, 23, 152, 26, 26, 23, 132, 133, 26,
132209
- /* 1250 */ 106, 97, 132, 133, 23, 152, 152, 26, 210, 191,
132210
- /* 1260 */ 152, 97, 152, 234, 152, 152, 152, 233, 152, 210,
132211
- /* 1270 */ 152, 152, 210, 152, 152, 152, 152, 152, 152, 197,
132212
- /* 1280 */ 210, 198, 122, 150, 239, 201, 214, 214, 201, 239,
132213
- /* 1290 */ 214, 227, 200, 184, 198, 155, 67, 243, 122, 22,
132214
- /* 1300 */ 159, 159, 69, 176, 175, 175, 175, 240, 180, 159,
132215
- /* 1310 */ 220, 240, 27, 130, 18, 18, 159, 158, 220, 137,
132216
- /* 1320 */ 159, 189, 236, 158, 74, 159, 159, 158, 192, 192,
132217
- /* 1330 */ 192, 192, 235, 22, 189, 189, 201, 159, 158, 177,
132218
- /* 1340 */ 159, 107, 158, 76, 201, 177, 174, 174, 201, 174,
132219
- /* 1350 */ 106, 177, 182, 174, 107, 159, 22, 125, 159, 182,
132220
- /* 1360 */ 174, 176, 174, 174, 216, 216, 215, 215, 177, 216,
132221
- /* 1370 */ 215, 53, 137, 128, 216, 177, 127, 129, 215, 126,
132222
- /* 1380 */ 25, 13, 162, 26, 6, 161, 165, 165, 178, 153,
132223
- /* 1390 */ 153, 151, 151, 151, 151, 224, 4, 3, 22, 142,
132224
- /* 1400 */ 15, 94, 16, 178, 165, 205, 23, 202, 204, 203,
132225
- /* 1410 */ 201, 23, 120, 131, 111, 20, 226, 123, 125, 16,
132226
- /* 1420 */ 1, 123, 131, 229, 229, 111, 37, 37, 56, 64,
132227
- /* 1430 */ 122, 1, 5, 22, 107, 140, 80, 87, 26, 80,
132228
- /* 1440 */ 107, 72, 24, 20, 19, 105, 22, 112, 22, 79,
132229
- /* 1450 */ 22, 58, 23, 22, 79, 22, 249, 249, 246, 79,
132230
- /* 1460 */ 23, 23, 23, 116, 68, 22, 26, 23, 22, 56,
132231
- /* 1470 */ 122, 23, 23, 64, 22, 124, 26, 26, 64, 64,
132232
- /* 1480 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22,
132233
- /* 1490 */ 24, 1, 23, 22, 26, 122, 24, 23, 22, 122,
132234
- /* 1500 */ 23, 23, 22, 122, 122, 23, 15,
132235
-};
132236
-#define YY_SHIFT_USE_DFLT (1507)
132237
-#define YY_SHIFT_COUNT (442)
133389
+ /* 580 */ 51, 52, 53, 19, 168, 169, 170, 238, 19, 53,
133390
+ /* 590 */ 152, 172, 173, 29, 30, 31, 32, 33, 34, 35,
133391
+ /* 600 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45,
133392
+ /* 610 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 20,
133393
+ /* 620 */ 101, 22, 23, 169, 170, 56, 207, 85, 55, 56,
133394
+ /* 630 */ 23, 19, 20, 26, 22, 99, 100, 101, 102, 103,
133395
+ /* 640 */ 104, 105, 238, 152, 152, 210, 47, 48, 112, 152,
133396
+ /* 650 */ 108, 109, 110, 54, 55, 56, 221, 222, 223, 47,
133397
+ /* 660 */ 48, 119, 120, 172, 173, 66, 54, 55, 56, 152,
133398
+ /* 670 */ 97, 98, 99, 148, 149, 102, 103, 104, 66, 154,
133399
+ /* 680 */ 23, 156, 83, 26, 230, 152, 113, 152, 163, 194,
133400
+ /* 690 */ 195, 92, 92, 30, 95, 83, 97, 98, 207, 208,
133401
+ /* 700 */ 101, 206, 179, 180, 92, 172, 173, 95, 152, 97,
133402
+ /* 710 */ 98, 188, 99, 101, 219, 102, 103, 104, 152, 119,
133403
+ /* 720 */ 120, 196, 55, 56, 19, 20, 113, 22, 193, 163,
133404
+ /* 730 */ 11, 132, 133, 134, 135, 136, 24, 65, 172, 173,
133405
+ /* 740 */ 207, 208, 250, 152, 132, 133, 134, 135, 136, 193,
133406
+ /* 750 */ 78, 84, 47, 48, 49, 98, 199, 152, 86, 54,
133407
+ /* 760 */ 55, 56, 196, 152, 97, 98, 209, 55, 163, 244,
133408
+ /* 770 */ 107, 66, 152, 207, 208, 164, 175, 172, 173, 19,
133409
+ /* 780 */ 20, 124, 22, 111, 38, 39, 40, 41, 83, 43,
133410
+ /* 790 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
133411
+ /* 800 */ 95, 196, 97, 98, 85, 152, 101, 47, 48, 97,
133412
+ /* 810 */ 85, 92, 207, 193, 54, 55, 56, 92, 49, 175,
133413
+ /* 820 */ 55, 56, 221, 222, 223, 12, 66, 108, 109, 110,
133414
+ /* 830 */ 137, 163, 139, 108, 109, 110, 152, 132, 133, 134,
133415
+ /* 840 */ 135, 136, 152, 83, 43, 44, 45, 46, 47, 48,
133416
+ /* 850 */ 49, 50, 51, 52, 53, 95, 152, 97, 98, 55,
133417
+ /* 860 */ 56, 101, 97, 98, 196, 221, 222, 223, 146, 147,
133418
+ /* 870 */ 57, 171, 152, 22, 213, 19, 20, 49, 22, 179,
133419
+ /* 880 */ 108, 109, 110, 55, 56, 116, 73, 219, 75, 124,
133420
+ /* 890 */ 121, 152, 132, 133, 134, 135, 136, 193, 85, 152,
133421
+ /* 900 */ 232, 97, 98, 47, 48, 237, 55, 56, 55, 5,
133422
+ /* 910 */ 54, 55, 56, 193, 10, 11, 12, 13, 14, 172,
133423
+ /* 920 */ 173, 17, 66, 47, 48, 97, 98, 152, 124, 166,
133424
+ /* 930 */ 167, 55, 56, 186, 152, 152, 152, 22, 152, 83,
133425
+ /* 940 */ 152, 152, 160, 152, 169, 170, 164, 152, 97, 98,
133426
+ /* 950 */ 97, 95, 26, 97, 98, 172, 173, 101, 172, 173,
133427
+ /* 960 */ 172, 173, 47, 48, 60, 22, 62, 172, 173, 186,
133428
+ /* 970 */ 55, 56, 186, 97, 98, 71, 100, 193, 152, 55,
133429
+ /* 980 */ 56, 186, 152, 107, 21, 109, 82, 163, 132, 133,
133430
+ /* 990 */ 134, 135, 136, 89, 164, 207, 92, 93, 172, 173,
133431
+ /* 1000 */ 181, 47, 48, 19, 16, 230, 217, 12, 132, 133,
133432
+ /* 1010 */ 95, 163, 97, 183, 30, 185, 101, 152, 114, 152,
133433
+ /* 1020 */ 196, 97, 98, 152, 98, 38, 39, 40, 41, 42,
133434
+ /* 1030 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
133435
+ /* 1040 */ 53, 152, 152, 219, 196, 141, 152, 132, 133, 134,
133436
+ /* 1050 */ 124, 225, 57, 152, 91, 108, 109, 110, 193, 211,
133437
+ /* 1060 */ 212, 237, 172, 173, 152, 122, 103, 181, 73, 152,
133438
+ /* 1070 */ 75, 210, 152, 172, 173, 92, 88, 152, 90, 152,
133439
+ /* 1080 */ 22, 152, 163, 100, 172, 173, 132, 133, 152, 172,
133440
+ /* 1090 */ 173, 107, 172, 173, 166, 167, 112, 172, 173, 172,
133441
+ /* 1100 */ 173, 172, 173, 140, 152, 152, 217, 242, 172, 173,
133442
+ /* 1110 */ 152, 217, 152, 55, 152, 196, 152, 245, 246, 152,
133443
+ /* 1120 */ 152, 152, 152, 152, 172, 173, 152, 152, 140, 152,
133444
+ /* 1130 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 172,
133445
+ /* 1140 */ 173, 172, 173, 172, 173, 152, 172, 173, 152, 172,
133446
+ /* 1150 */ 173, 152, 195, 152, 152, 97, 152, 163, 172, 173,
133447
+ /* 1160 */ 152, 193, 152, 206, 152, 172, 173, 152, 172, 173,
133448
+ /* 1170 */ 217, 172, 173, 152, 172, 173, 172, 173, 152, 26,
133449
+ /* 1180 */ 172, 173, 172, 173, 172, 173, 152, 172, 173, 152,
133450
+ /* 1190 */ 196, 152, 217, 172, 173, 152, 61, 152, 172, 173,
133451
+ /* 1200 */ 152, 26, 152, 26, 152, 70, 172, 173, 191, 172,
133452
+ /* 1210 */ 173, 172, 173, 152, 152, 172, 173, 172, 173, 152,
133453
+ /* 1220 */ 172, 173, 172, 173, 172, 173, 152, 22, 23, 152,
133454
+ /* 1230 */ 22, 152, 24, 172, 173, 22, 23, 152, 59, 172,
133455
+ /* 1240 */ 173, 152, 63, 163, 163, 163, 172, 173, 22, 172,
133456
+ /* 1250 */ 173, 172, 173, 163, 163, 116, 77, 172, 173, 152,
133457
+ /* 1260 */ 121, 172, 173, 37, 7, 8, 9, 211, 212, 23,
133458
+ /* 1270 */ 23, 23, 26, 26, 26, 55, 196, 196, 196, 23,
133459
+ /* 1280 */ 55, 106, 26, 130, 152, 23, 196, 196, 26, 23,
133460
+ /* 1290 */ 23, 101, 26, 26, 100, 101, 7, 8, 132, 133,
133461
+ /* 1300 */ 123, 96, 112, 23, 152, 23, 26, 23, 26, 96,
133462
+ /* 1310 */ 26, 23, 132, 133, 26, 152, 152, 97, 234, 152,
133463
+ /* 1320 */ 152, 152, 97, 152, 152, 152, 152, 233, 152, 210,
133464
+ /* 1330 */ 152, 210, 210, 152, 152, 152, 152, 197, 150, 198,
133465
+ /* 1340 */ 214, 214, 239, 201, 201, 239, 176, 214, 200, 184,
133466
+ /* 1350 */ 227, 155, 198, 67, 243, 122, 159, 159, 240, 69,
133467
+ /* 1360 */ 240, 175, 175, 159, 175, 180, 22, 220, 27, 130,
133468
+ /* 1370 */ 18, 159, 18, 158, 158, 220, 159, 137, 74, 235,
133469
+ /* 1380 */ 189, 236, 159, 159, 22, 192, 158, 192, 177, 159,
133470
+ /* 1390 */ 158, 192, 192, 201, 159, 189, 189, 76, 177, 158,
133471
+ /* 1400 */ 107, 174, 201, 201, 182, 174, 177, 106, 174, 107,
133472
+ /* 1410 */ 174, 159, 174, 176, 22, 137, 125, 174, 174, 216,
133473
+ /* 1420 */ 159, 53, 126, 129, 182, 215, 128, 127, 25, 13,
133474
+ /* 1430 */ 216, 177, 26, 215, 162, 216, 177, 161, 229, 6,
133475
+ /* 1440 */ 153, 4, 165, 3, 165, 153, 151, 22, 151, 178,
133476
+ /* 1450 */ 151, 178, 142, 15, 151, 94, 120, 16, 23, 23,
133477
+ /* 1460 */ 215, 131, 111, 205, 204, 216, 215, 203, 123, 20,
133478
+ /* 1470 */ 202, 201, 165, 125, 224, 16, 1, 131, 123, 226,
133479
+ /* 1480 */ 37, 37, 37, 37, 229, 111, 56, 64, 122, 1,
133480
+ /* 1490 */ 5, 22, 107, 140, 80, 80, 26, 87, 72, 20,
133481
+ /* 1500 */ 107, 24, 19, 112, 105, 23, 22, 79, 22, 22,
133482
+ /* 1510 */ 79, 22, 249, 58, 249, 246, 22, 26, 79, 68,
133483
+ /* 1520 */ 23, 23, 23, 116, 22, 64, 23, 22, 56, 23,
133484
+ /* 1530 */ 26, 122, 23, 22, 26, 124, 26, 64, 64, 23,
133485
+ /* 1540 */ 23, 23, 23, 11, 23, 22, 26, 23, 22, 24,
133486
+ /* 1550 */ 1, 23, 22, 26, 122, 24, 23, 22, 15, 23,
133487
+ /* 1560 */ 23, 22, 251, 23, 122, 251, 251, 251, 251, 122,
133488
+ /* 1570 */ 122,
133489
+};
133490
+#define YY_SHIFT_USE_DFLT (1571)
133491
+#define YY_SHIFT_COUNT (455)
132238133492
#define YY_SHIFT_MIN (-94)
132239
-#define YY_SHIFT_MAX (1491)
133493
+#define YY_SHIFT_MAX (1549)
132240133494
static const short yy_shift_ofst[] = {
132241
- /* 0 */ 40, 564, 869, 577, 725, 725, 725, 725, 690, -19,
132242
- /* 10 */ 16, 16, 100, 725, 725, 725, 725, 725, 725, 725,
132243
- /* 20 */ 841, 841, 538, 507, 684, 565, 61, 137, 172, 207,
132244
- /* 30 */ 242, 277, 312, 347, 382, 424, 424, 424, 424, 424,
132245
- /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 424,
132246
- /* 50 */ 459, 424, 494, 529, 529, 670, 725, 725, 725, 725,
132247
- /* 60 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
132248
- /* 70 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
132249
- /* 80 */ 725, 725, 725, 725, 821, 725, 725, 725, 725, 725,
132250
- /* 90 */ 725, 725, 725, 725, 725, 725, 725, 725, 952, 711,
132251
- /* 100 */ 711, 711, 711, 711, 766, 23, 32, 924, 637, 825,
132252
- /* 110 */ 837, 837, 924, 73, 183, -51, 1507, 1507, 1507, 501,
132253
- /* 120 */ 501, 501, 903, 903, 632, 205, 241, 924, 924, 924,
132254
- /* 130 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132255
- /* 140 */ 924, 924, 924, 924, 924, 924, 924, 192, 1027, 1106,
132256
- /* 150 */ 1106, 183, 176, 176, 176, 176, 176, 176, 1507, 1507,
132257
- /* 160 */ 1507, 880, -94, -94, 578, 734, 99, 730, 769, 349,
132258
- /* 170 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132259
- /* 180 */ 924, 924, 924, 924, 924, 924, 924, 954, 954, 954,
132260
- /* 190 */ 924, 924, 622, 924, 924, 924, -18, 924, 924, 914,
132261
- /* 200 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132262
- /* 210 */ 441, 1020, 1107, 1107, 1107, 569, 45, 217, 510, 423,
132263
- /* 220 */ 834, 834, 1156, 423, 1156, 1144, 1187, 359, 1051, 834,
132264
- /* 230 */ -17, 1051, 1051, 1099, 469, 1192, 1229, 1176, 1176, 1233,
132265
- /* 240 */ 1233, 1176, 1277, 1285, 1183, 1296, 1296, 1296, 1296, 1176,
132266
- /* 250 */ 1297, 1183, 1277, 1285, 1285, 1183, 1176, 1297, 1182, 1250,
132267
- /* 260 */ 1176, 1176, 1297, 1311, 1176, 1297, 1176, 1297, 1311, 1234,
132268
- /* 270 */ 1234, 1234, 1267, 1311, 1234, 1244, 1234, 1267, 1234, 1234,
132269
- /* 280 */ 1232, 1247, 1232, 1247, 1232, 1247, 1232, 1247, 1176, 1334,
132270
- /* 290 */ 1176, 1235, 1311, 1318, 1318, 1311, 1248, 1253, 1245, 1249,
132271
- /* 300 */ 1183, 1355, 1357, 1368, 1368, 1378, 1378, 1378, 1378, 1507,
132272
- /* 310 */ 1507, 1507, 1507, 1507, 1507, 1507, 1507, 451, 936, 816,
132273
- /* 320 */ 888, 1069, 799, 1111, 1197, 1193, 1201, 1202, 1203, 1213,
132274
- /* 330 */ 1134, 1117, 1230, 497, 1218, 1219, 1154, 1223, 1115, 1120,
132275
- /* 340 */ 1231, 1164, 1160, 1392, 1394, 1376, 1257, 1385, 1307, 1386,
132276
- /* 350 */ 1383, 1388, 1292, 1282, 1303, 1294, 1395, 1293, 1403, 1419,
132277
- /* 360 */ 1298, 1291, 1389, 1390, 1314, 1372, 1365, 1308, 1430, 1427,
132278
- /* 370 */ 1411, 1327, 1295, 1356, 1412, 1359, 1350, 1369, 1333, 1418,
132279
- /* 380 */ 1423, 1425, 1335, 1340, 1424, 1370, 1426, 1428, 1429, 1431,
132280
- /* 390 */ 1375, 1393, 1433, 1380, 1396, 1437, 1438, 1439, 1347, 1443,
132281
- /* 400 */ 1444, 1446, 1440, 1348, 1448, 1449, 1413, 1409, 1452, 1351,
132282
- /* 410 */ 1450, 1414, 1451, 1415, 1457, 1450, 1458, 1459, 1460, 1461,
132283
- /* 420 */ 1462, 1464, 1473, 1465, 1467, 1466, 1468, 1469, 1471, 1472,
132284
- /* 430 */ 1468, 1474, 1476, 1477, 1478, 1480, 1373, 1377, 1381, 1382,
132285
- /* 440 */ 1482, 1491, 1490,
133495
+ /* 0 */ 40, 599, 904, 612, 760, 760, 760, 760, 725, -19,
133496
+ /* 10 */ 16, 16, 100, 760, 760, 760, 760, 760, 760, 760,
133497
+ /* 20 */ 876, 876, 573, 542, 719, 600, 61, 137, 172, 207,
133498
+ /* 30 */ 242, 277, 312, 347, 382, 417, 459, 459, 459, 459,
133499
+ /* 40 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459,
133500
+ /* 50 */ 459, 459, 459, 494, 459, 529, 564, 564, 705, 760,
133501
+ /* 60 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760,
133502
+ /* 70 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760,
133503
+ /* 80 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760,
133504
+ /* 90 */ 856, 760, 760, 760, 760, 760, 760, 760, 760, 760,
133505
+ /* 100 */ 760, 760, 760, 760, 987, 746, 746, 746, 746, 746,
133506
+ /* 110 */ 801, 23, 32, 924, 963, 984, 954, 954, 924, 73,
133507
+ /* 120 */ 113, -51, 1571, 1571, 1571, 536, 536, 536, 99, 99,
133508
+ /* 130 */ 813, 813, 667, 205, 240, 924, 924, 924, 924, 924,
133509
+ /* 140 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
133510
+ /* 150 */ 924, 924, 924, 924, 924, 332, 983, 422, 422, 113,
133511
+ /* 160 */ 30, 30, 30, 30, 30, 30, 1571, 1571, 1571, 915,
133512
+ /* 170 */ -94, -94, 384, 613, 828, 420, 765, 804, 851, 924,
133513
+ /* 180 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
133514
+ /* 190 */ 924, 924, 924, 924, 924, 672, 672, 672, 924, 924,
133515
+ /* 200 */ 657, 924, 924, 924, -18, 924, 924, 995, 924, 924,
133516
+ /* 210 */ 924, 924, 924, 924, 924, 924, 924, 924, 772, 1179,
133517
+ /* 220 */ 712, 712, 712, 926, 45, 769, 1257, 1153, 418, 418,
133518
+ /* 230 */ 569, 1153, 569, 1175, 607, 663, 1135, 418, 693, 1135,
133519
+ /* 240 */ 1135, 1177, 1139, 1208, 1286, 1233, 1233, 1290, 1290, 1233,
133520
+ /* 250 */ 1344, 1341, 1239, 1352, 1352, 1352, 1352, 1233, 1354, 1239,
133521
+ /* 260 */ 1344, 1341, 1341, 1239, 1233, 1354, 1240, 1304, 1233, 1233,
133522
+ /* 270 */ 1354, 1362, 1233, 1354, 1233, 1354, 1362, 1293, 1293, 1293,
133523
+ /* 280 */ 1321, 1362, 1293, 1301, 1293, 1321, 1293, 1293, 1291, 1302,
133524
+ /* 290 */ 1291, 1302, 1291, 1302, 1291, 1302, 1233, 1392, 1233, 1278,
133525
+ /* 300 */ 1362, 1368, 1368, 1362, 1294, 1296, 1298, 1300, 1239, 1403,
133526
+ /* 310 */ 1406, 1416, 1416, 1433, 1433, 1433, 1433, 1571, 1571, 1571,
133527
+ /* 320 */ 1571, 1571, 1571, 1571, 1571, 519, 988, 1205, 1213, 104,
133528
+ /* 330 */ 947, 1058, 1246, 1226, 1247, 1248, 1256, 1262, 1266, 1267,
133529
+ /* 340 */ 853, 1194, 1289, 1190, 1280, 1282, 1220, 1284, 1166, 1180,
133530
+ /* 350 */ 1288, 1225, 943, 1437, 1440, 1425, 1310, 1438, 1361, 1441,
133531
+ /* 360 */ 1435, 1436, 1336, 1330, 1351, 1345, 1449, 1348, 1459, 1475,
133532
+ /* 370 */ 1355, 1346, 1443, 1444, 1445, 1446, 1374, 1430, 1423, 1366,
133533
+ /* 380 */ 1488, 1485, 1469, 1385, 1353, 1414, 1470, 1415, 1410, 1426,
133534
+ /* 390 */ 1393, 1477, 1479, 1483, 1391, 1399, 1484, 1428, 1486, 1487,
133535
+ /* 400 */ 1482, 1489, 1431, 1455, 1494, 1439, 1451, 1497, 1498, 1499,
133536
+ /* 410 */ 1491, 1407, 1502, 1503, 1505, 1504, 1409, 1506, 1509, 1472,
133537
+ /* 420 */ 1461, 1511, 1411, 1508, 1473, 1510, 1474, 1516, 1508, 1517,
133538
+ /* 430 */ 1518, 1519, 1520, 1521, 1523, 1532, 1524, 1526, 1525, 1527,
133539
+ /* 440 */ 1528, 1530, 1531, 1527, 1533, 1535, 1536, 1537, 1539, 1432,
133540
+ /* 450 */ 1442, 1447, 1448, 1540, 1543, 1549,
132286133541
};
132287133542
#define YY_REDUCE_USE_DFLT (-130)
132288
-#define YY_REDUCE_COUNT (316)
133543
+#define YY_REDUCE_COUNT (324)
132289133544
#define YY_REDUCE_MIN (-129)
132290
-#define YY_REDUCE_MAX (1243)
133545
+#define YY_REDUCE_MAX (1307)
132291133546
static const short yy_reduce_ofst[] = {
132292
- /* 0 */ -29, 531, 490, 570, -49, 272, 456, 498, 633, 400,
132293
- /* 10 */ 612, 626, 113, 482, 678, 719, 384, 726, 748, 791,
132294
- /* 20 */ 419, 693, 761, 812, 819, 625, 76, 76, 76, 76,
133547
+ /* 0 */ -29, 566, 525, 605, -49, 307, 491, 533, 668, 435,
133548
+ /* 10 */ 601, 644, 148, 747, 783, 786, 419, 788, 795, 826,
133549
+ /* 20 */ 454, 775, 830, 495, 824, 848, 76, 76, 76, 76,
132295133550
/* 30 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132296133551
/* 40 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132297
- /* 50 */ 76, 76, 76, 76, 76, 793, 795, 856, 871, 875,
132298
- /* 60 */ 878, 881, 885, 887, 889, 894, 897, 900, 916, 919,
132299
- /* 70 */ 922, 926, 928, 930, 932, 934, 938, 941, 944, 956,
132300
- /* 80 */ 963, 966, 968, 970, 972, 974, 978, 980, 982, 996,
132301
- /* 90 */ 1004, 1006, 1008, 1011, 1013, 1015, 1019, 1022, 76, 76,
132302
- /* 100 */ 76, 76, 76, 76, 76, 76, 76, 555, 210, 260,
132303
- /* 110 */ 200, 346, 571, 76, 700, 76, 76, 76, 76, 838,
132304
- /* 120 */ 838, 838, 42, 182, 251, 160, 160, 550, 5, 455,
132305
- /* 130 */ 585, 721, 749, 882, 884, 971, 618, 462, 797, 514,
132306
- /* 140 */ 807, 524, 997, -129, 655, 859, 62, 290, 66, 1030,
132307
- /* 150 */ 1032, 589, 1009, 1010, 1037, 1038, 1039, 1044, 740, 852,
132308
- /* 160 */ 1012, 112, 147, 230, 257, 180, 369, 403, 500, 549,
132309
- /* 170 */ 556, 563, 694, 751, 765, 772, 778, 820, 868, 873,
132310
- /* 180 */ 890, 929, 935, 985, 1041, 1080, 1091, 540, 593, 661,
132311
- /* 190 */ 1103, 1104, 842, 1108, 1110, 1112, 1048, 1113, 1114, 1068,
132312
- /* 200 */ 1116, 1118, 1119, 180, 1121, 1122, 1123, 1124, 1125, 1126,
132313
- /* 210 */ 1029, 1034, 1059, 1062, 1070, 842, 1082, 1083, 1133, 1084,
132314
- /* 220 */ 1072, 1073, 1045, 1087, 1050, 1127, 1109, 1128, 1129, 1076,
132315
- /* 230 */ 1064, 1130, 1131, 1092, 1096, 1140, 1054, 1141, 1142, 1067,
132316
- /* 240 */ 1071, 1150, 1090, 1132, 1135, 1136, 1137, 1138, 1139, 1157,
132317
- /* 250 */ 1159, 1143, 1098, 1145, 1146, 1147, 1161, 1165, 1086, 1097,
132318
- /* 260 */ 1166, 1167, 1169, 1162, 1178, 1180, 1181, 1184, 1168, 1172,
132319
- /* 270 */ 1173, 1175, 1170, 1174, 1179, 1185, 1186, 1177, 1188, 1189,
132320
- /* 280 */ 1148, 1151, 1149, 1152, 1153, 1155, 1158, 1163, 1196, 1171,
132321
- /* 290 */ 1199, 1190, 1191, 1194, 1195, 1198, 1200, 1204, 1206, 1205,
132322
- /* 300 */ 1209, 1220, 1224, 1236, 1237, 1240, 1241, 1242, 1243, 1207,
132323
- /* 310 */ 1208, 1212, 1221, 1222, 1210, 1225, 1239,
133552
+ /* 50 */ 76, 76, 76, 76, 76, 76, 76, 76, 890, 901,
133553
+ /* 60 */ 912, 917, 920, 925, 927, 929, 936, 952, 958, 960,
133554
+ /* 70 */ 962, 964, 967, 969, 971, 974, 977, 986, 993, 996,
133555
+ /* 80 */ 999, 1002, 1004, 1008, 1010, 1012, 1015, 1021, 1026, 1034,
133556
+ /* 90 */ 1037, 1039, 1043, 1045, 1048, 1050, 1052, 1061, 1067, 1074,
133557
+ /* 100 */ 1077, 1079, 1085, 1089, 76, 76, 76, 76, 76, 76,
133558
+ /* 110 */ 76, 76, 76, 865, 36, 523, 235, 416, 782, 76,
133559
+ /* 120 */ 278, 76, 76, 76, 76, 700, 700, 700, 150, 220,
133560
+ /* 130 */ 147, 217, 221, 306, 306, 611, 5, 535, 556, 620,
133561
+ /* 140 */ 704, 720, 784, 116, 789, 349, 889, 894, 404, 953,
133562
+ /* 150 */ 968, -129, 975, 492, 62, 722, 919, 763, 928, 957,
133563
+ /* 160 */ 994, 1080, 1081, 1082, 1090, 1091, 872, 1056, 557, 57,
133564
+ /* 170 */ 112, 131, 167, 182, 250, 272, 291, 331, 364, 438,
133565
+ /* 180 */ 497, 517, 591, 653, 684, 690, 739, 791, 867, 871,
133566
+ /* 190 */ 970, 1062, 1107, 1132, 1152, 355, 819, 886, 1001, 1163,
133567
+ /* 200 */ 661, 1164, 1167, 1168, 861, 1169, 1171, 1017, 1172, 1173,
133568
+ /* 210 */ 1174, 250, 1176, 1178, 1181, 1182, 1183, 1184, 1084, 1094,
133569
+ /* 220 */ 1119, 1121, 1122, 661, 1140, 1141, 1188, 1142, 1126, 1127,
133570
+ /* 230 */ 1103, 1143, 1106, 1170, 1165, 1185, 1186, 1133, 1123, 1187,
133571
+ /* 240 */ 1189, 1148, 1154, 1196, 1111, 1197, 1198, 1118, 1120, 1204,
133572
+ /* 250 */ 1147, 1191, 1192, 1193, 1195, 1199, 1200, 1212, 1215, 1201,
133573
+ /* 260 */ 1155, 1206, 1207, 1202, 1217, 1216, 1145, 1144, 1223, 1224,
133574
+ /* 270 */ 1228, 1211, 1230, 1232, 1235, 1241, 1221, 1227, 1231, 1234,
133575
+ /* 280 */ 1222, 1229, 1236, 1237, 1238, 1242, 1243, 1244, 1203, 1210,
133576
+ /* 290 */ 1214, 1218, 1219, 1245, 1249, 1251, 1252, 1250, 1261, 1253,
133577
+ /* 300 */ 1254, 1209, 1255, 1259, 1258, 1260, 1264, 1268, 1270, 1272,
133578
+ /* 310 */ 1276, 1287, 1292, 1295, 1297, 1299, 1303, 1263, 1265, 1269,
133579
+ /* 320 */ 1277, 1279, 1271, 1273, 1307,
132324133580
};
132325133581
static const YYACTIONTYPE yy_default[] = {
132326
- /* 0 */ 1258, 1248, 1248, 1248, 1180, 1180, 1180, 1180, 1248, 1077,
132327
- /* 10 */ 1106, 1106, 1232, 1309, 1309, 1309, 1309, 1309, 1309, 1179,
132328
- /* 20 */ 1309, 1309, 1309, 1309, 1248, 1081, 1112, 1309, 1309, 1309,
132329
- /* 30 */ 1309, 1309, 1309, 1309, 1309, 1231, 1233, 1120, 1119, 1214,
132330
- /* 40 */ 1093, 1117, 1110, 1114, 1181, 1175, 1176, 1174, 1178, 1182,
132331
- /* 50 */ 1309, 1113, 1144, 1159, 1143, 1309, 1309, 1309, 1309, 1309,
132332
- /* 60 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132333
- /* 70 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132334
- /* 80 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132335
- /* 90 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1153, 1158,
132336
- /* 100 */ 1165, 1157, 1154, 1146, 1145, 1147, 1148, 1309, 1000, 1048,
132337
- /* 110 */ 1309, 1309, 1309, 1149, 1309, 1150, 1162, 1161, 1160, 1239,
132338
- /* 120 */ 1266, 1265, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132339
- /* 130 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132340
- /* 140 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1258, 1248, 1006,
132341
- /* 150 */ 1006, 1309, 1248, 1248, 1248, 1248, 1248, 1248, 1244, 1081,
132342
- /* 160 */ 1072, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132343
- /* 170 */ 1309, 1236, 1234, 1309, 1195, 1309, 1309, 1309, 1309, 1309,
132344
- /* 180 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132345
- /* 190 */ 1309, 1309, 1309, 1309, 1309, 1309, 1077, 1309, 1309, 1309,
132346
- /* 200 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1260,
132347
- /* 210 */ 1309, 1209, 1077, 1077, 1077, 1079, 1061, 1071, 985, 1116,
132348
- /* 220 */ 1095, 1095, 1298, 1116, 1298, 1023, 1280, 1020, 1106, 1095,
132349
- /* 230 */ 1177, 1106, 1106, 1078, 1071, 1309, 1301, 1086, 1086, 1300,
132350
- /* 240 */ 1300, 1086, 1125, 1051, 1116, 1057, 1057, 1057, 1057, 1086,
132351
- /* 250 */ 997, 1116, 1125, 1051, 1051, 1116, 1086, 997, 1213, 1295,
132352
- /* 260 */ 1086, 1086, 997, 1188, 1086, 997, 1086, 997, 1188, 1049,
132353
- /* 270 */ 1049, 1049, 1038, 1188, 1049, 1023, 1049, 1038, 1049, 1049,
132354
- /* 280 */ 1099, 1094, 1099, 1094, 1099, 1094, 1099, 1094, 1086, 1183,
132355
- /* 290 */ 1086, 1309, 1188, 1192, 1192, 1188, 1111, 1100, 1109, 1107,
132356
- /* 300 */ 1116, 1003, 1041, 1263, 1263, 1259, 1259, 1259, 1259, 1306,
132357
- /* 310 */ 1306, 1244, 1275, 1275, 1025, 1025, 1275, 1309, 1309, 1309,
132358
- /* 320 */ 1309, 1309, 1309, 1270, 1309, 1197, 1309, 1309, 1309, 1309,
132359
- /* 330 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132360
- /* 340 */ 1309, 1309, 1131, 1309, 981, 1241, 1309, 1309, 1240, 1309,
132361
- /* 350 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132362
- /* 360 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1297, 1309, 1309,
132363
- /* 370 */ 1309, 1309, 1309, 1309, 1212, 1211, 1309, 1309, 1309, 1309,
132364
- /* 380 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132365
- /* 390 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1063, 1309,
132366
- /* 400 */ 1309, 1309, 1284, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132367
- /* 410 */ 1108, 1309, 1101, 1309, 1309, 1288, 1309, 1309, 1309, 1309,
132368
- /* 420 */ 1309, 1309, 1309, 1309, 1309, 1309, 1250, 1309, 1309, 1309,
132369
- /* 430 */ 1249, 1309, 1309, 1309, 1309, 1309, 1133, 1309, 1132, 1136,
132370
- /* 440 */ 1309, 991, 1309,
133582
+ /* 0 */ 1278, 1268, 1268, 1268, 1200, 1200, 1200, 1200, 1268, 1094,
133583
+ /* 10 */ 1123, 1123, 1252, 1329, 1329, 1329, 1329, 1329, 1329, 1199,
133584
+ /* 20 */ 1329, 1329, 1329, 1329, 1268, 1098, 1129, 1329, 1329, 1329,
133585
+ /* 30 */ 1329, 1201, 1202, 1329, 1329, 1329, 1251, 1253, 1139, 1138,
133586
+ /* 40 */ 1137, 1136, 1234, 1110, 1134, 1127, 1131, 1201, 1195, 1196,
133587
+ /* 50 */ 1194, 1198, 1202, 1329, 1130, 1164, 1179, 1163, 1329, 1329,
133588
+ /* 60 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133589
+ /* 70 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133590
+ /* 80 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133591
+ /* 90 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133592
+ /* 100 */ 1329, 1329, 1329, 1329, 1173, 1178, 1185, 1177, 1174, 1166,
133593
+ /* 110 */ 1165, 1167, 1168, 1329, 1017, 1065, 1329, 1329, 1329, 1169,
133594
+ /* 120 */ 1329, 1170, 1182, 1181, 1180, 1259, 1286, 1285, 1329, 1329,
133595
+ /* 130 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133596
+ /* 140 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133597
+ /* 150 */ 1329, 1329, 1329, 1329, 1329, 1278, 1268, 1023, 1023, 1329,
133598
+ /* 160 */ 1268, 1268, 1268, 1268, 1268, 1268, 1264, 1098, 1089, 1329,
133599
+ /* 170 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133600
+ /* 180 */ 1256, 1254, 1329, 1215, 1329, 1329, 1329, 1329, 1329, 1329,
133601
+ /* 190 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133602
+ /* 200 */ 1329, 1329, 1329, 1329, 1094, 1329, 1329, 1329, 1329, 1329,
133603
+ /* 210 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1280, 1329, 1229,
133604
+ /* 220 */ 1094, 1094, 1094, 1096, 1078, 1088, 1002, 1133, 1112, 1112,
133605
+ /* 230 */ 1318, 1133, 1318, 1040, 1300, 1037, 1123, 1112, 1197, 1123,
133606
+ /* 240 */ 1123, 1095, 1088, 1329, 1321, 1103, 1103, 1320, 1320, 1103,
133607
+ /* 250 */ 1144, 1068, 1133, 1074, 1074, 1074, 1074, 1103, 1014, 1133,
133608
+ /* 260 */ 1144, 1068, 1068, 1133, 1103, 1014, 1233, 1315, 1103, 1103,
133609
+ /* 270 */ 1014, 1208, 1103, 1014, 1103, 1014, 1208, 1066, 1066, 1066,
133610
+ /* 280 */ 1055, 1208, 1066, 1040, 1066, 1055, 1066, 1066, 1116, 1111,
133611
+ /* 290 */ 1116, 1111, 1116, 1111, 1116, 1111, 1103, 1203, 1103, 1329,
133612
+ /* 300 */ 1208, 1212, 1212, 1208, 1128, 1117, 1126, 1124, 1133, 1020,
133613
+ /* 310 */ 1058, 1283, 1283, 1279, 1279, 1279, 1279, 1326, 1326, 1264,
133614
+ /* 320 */ 1295, 1295, 1042, 1042, 1295, 1329, 1329, 1329, 1329, 1329,
133615
+ /* 330 */ 1329, 1290, 1329, 1217, 1329, 1329, 1329, 1329, 1329, 1329,
133616
+ /* 340 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133617
+ /* 350 */ 1329, 1329, 1150, 1329, 998, 1261, 1329, 1329, 1260, 1329,
133618
+ /* 360 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133619
+ /* 370 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1317,
133620
+ /* 380 */ 1329, 1329, 1329, 1329, 1329, 1329, 1232, 1231, 1329, 1329,
133621
+ /* 390 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133622
+ /* 400 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133623
+ /* 410 */ 1329, 1080, 1329, 1329, 1329, 1304, 1329, 1329, 1329, 1329,
133624
+ /* 420 */ 1329, 1329, 1329, 1125, 1329, 1118, 1329, 1329, 1308, 1329,
133625
+ /* 430 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1270,
133626
+ /* 440 */ 1329, 1329, 1329, 1269, 1329, 1329, 1329, 1329, 1329, 1152,
133627
+ /* 450 */ 1329, 1151, 1155, 1329, 1008, 1329,
132371133628
};
132372133629
/********** End of lemon-generated parsing tables *****************************/
132373133630
132374133631
/* The next table maps tokens (terminal symbols) into fallback tokens.
132375133632
** If a construct like the following:
@@ -132775,199 +134032,202 @@
132775134032
/* 134 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
132776134033
/* 135 */ "where_opt ::=",
132777134034
/* 136 */ "where_opt ::= WHERE expr",
132778134035
/* 137 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
132779134036
/* 138 */ "setlist ::= setlist COMMA nm EQ expr",
132780
- /* 139 */ "setlist ::= nm EQ expr",
132781
- /* 140 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
132782
- /* 141 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
132783
- /* 142 */ "insert_cmd ::= INSERT orconf",
132784
- /* 143 */ "insert_cmd ::= REPLACE",
132785
- /* 144 */ "idlist_opt ::=",
132786
- /* 145 */ "idlist_opt ::= LP idlist RP",
132787
- /* 146 */ "idlist ::= idlist COMMA nm",
132788
- /* 147 */ "idlist ::= nm",
132789
- /* 148 */ "expr ::= LP expr RP",
132790
- /* 149 */ "term ::= NULL",
132791
- /* 150 */ "expr ::= ID|INDEXED",
132792
- /* 151 */ "expr ::= JOIN_KW",
132793
- /* 152 */ "expr ::= nm DOT nm",
132794
- /* 153 */ "expr ::= nm DOT nm DOT nm",
132795
- /* 154 */ "term ::= INTEGER|FLOAT|BLOB",
132796
- /* 155 */ "term ::= STRING",
132797
- /* 156 */ "expr ::= VARIABLE",
132798
- /* 157 */ "expr ::= expr COLLATE ID|STRING",
132799
- /* 158 */ "expr ::= CAST LP expr AS typetoken RP",
132800
- /* 159 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
132801
- /* 160 */ "expr ::= ID|INDEXED LP STAR RP",
132802
- /* 161 */ "term ::= CTIME_KW",
132803
- /* 162 */ "expr ::= expr AND expr",
132804
- /* 163 */ "expr ::= expr OR expr",
132805
- /* 164 */ "expr ::= expr LT|GT|GE|LE expr",
132806
- /* 165 */ "expr ::= expr EQ|NE expr",
132807
- /* 166 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
132808
- /* 167 */ "expr ::= expr PLUS|MINUS expr",
132809
- /* 168 */ "expr ::= expr STAR|SLASH|REM expr",
132810
- /* 169 */ "expr ::= expr CONCAT expr",
132811
- /* 170 */ "likeop ::= LIKE_KW|MATCH",
132812
- /* 171 */ "likeop ::= NOT LIKE_KW|MATCH",
132813
- /* 172 */ "expr ::= expr likeop expr",
132814
- /* 173 */ "expr ::= expr likeop expr ESCAPE expr",
132815
- /* 174 */ "expr ::= expr ISNULL|NOTNULL",
132816
- /* 175 */ "expr ::= expr NOT NULL",
132817
- /* 176 */ "expr ::= expr IS expr",
132818
- /* 177 */ "expr ::= expr IS NOT expr",
132819
- /* 178 */ "expr ::= NOT expr",
132820
- /* 179 */ "expr ::= BITNOT expr",
132821
- /* 180 */ "expr ::= MINUS expr",
132822
- /* 181 */ "expr ::= PLUS expr",
132823
- /* 182 */ "between_op ::= BETWEEN",
132824
- /* 183 */ "between_op ::= NOT BETWEEN",
132825
- /* 184 */ "expr ::= expr between_op expr AND expr",
132826
- /* 185 */ "in_op ::= IN",
132827
- /* 186 */ "in_op ::= NOT IN",
132828
- /* 187 */ "expr ::= expr in_op LP exprlist RP",
132829
- /* 188 */ "expr ::= LP select RP",
132830
- /* 189 */ "expr ::= expr in_op LP select RP",
132831
- /* 190 */ "expr ::= expr in_op nm dbnm paren_exprlist",
132832
- /* 191 */ "expr ::= EXISTS LP select RP",
132833
- /* 192 */ "expr ::= CASE case_operand case_exprlist case_else END",
132834
- /* 193 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
132835
- /* 194 */ "case_exprlist ::= WHEN expr THEN expr",
132836
- /* 195 */ "case_else ::= ELSE expr",
132837
- /* 196 */ "case_else ::=",
132838
- /* 197 */ "case_operand ::= expr",
132839
- /* 198 */ "case_operand ::=",
132840
- /* 199 */ "exprlist ::=",
132841
- /* 200 */ "nexprlist ::= nexprlist COMMA expr",
132842
- /* 201 */ "nexprlist ::= expr",
132843
- /* 202 */ "paren_exprlist ::=",
132844
- /* 203 */ "paren_exprlist ::= LP exprlist RP",
132845
- /* 204 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
132846
- /* 205 */ "uniqueflag ::= UNIQUE",
132847
- /* 206 */ "uniqueflag ::=",
132848
- /* 207 */ "eidlist_opt ::=",
132849
- /* 208 */ "eidlist_opt ::= LP eidlist RP",
132850
- /* 209 */ "eidlist ::= eidlist COMMA nm collate sortorder",
132851
- /* 210 */ "eidlist ::= nm collate sortorder",
132852
- /* 211 */ "collate ::=",
132853
- /* 212 */ "collate ::= COLLATE ID|STRING",
132854
- /* 213 */ "cmd ::= DROP INDEX ifexists fullname",
132855
- /* 214 */ "cmd ::= VACUUM",
132856
- /* 215 */ "cmd ::= VACUUM nm",
132857
- /* 216 */ "cmd ::= PRAGMA nm dbnm",
132858
- /* 217 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
132859
- /* 218 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
132860
- /* 219 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
132861
- /* 220 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
132862
- /* 221 */ "plus_num ::= PLUS INTEGER|FLOAT",
132863
- /* 222 */ "minus_num ::= MINUS INTEGER|FLOAT",
132864
- /* 223 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
132865
- /* 224 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
132866
- /* 225 */ "trigger_time ::= BEFORE",
132867
- /* 226 */ "trigger_time ::= AFTER",
132868
- /* 227 */ "trigger_time ::= INSTEAD OF",
132869
- /* 228 */ "trigger_time ::=",
132870
- /* 229 */ "trigger_event ::= DELETE|INSERT",
132871
- /* 230 */ "trigger_event ::= UPDATE",
132872
- /* 231 */ "trigger_event ::= UPDATE OF idlist",
132873
- /* 232 */ "when_clause ::=",
132874
- /* 233 */ "when_clause ::= WHEN expr",
132875
- /* 234 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
132876
- /* 235 */ "trigger_cmd_list ::= trigger_cmd SEMI",
132877
- /* 236 */ "trnm ::= nm DOT nm",
132878
- /* 237 */ "tridxby ::= INDEXED BY nm",
132879
- /* 238 */ "tridxby ::= NOT INDEXED",
132880
- /* 239 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
132881
- /* 240 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
132882
- /* 241 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
132883
- /* 242 */ "trigger_cmd ::= select",
132884
- /* 243 */ "expr ::= RAISE LP IGNORE RP",
132885
- /* 244 */ "expr ::= RAISE LP raisetype COMMA nm RP",
132886
- /* 245 */ "raisetype ::= ROLLBACK",
132887
- /* 246 */ "raisetype ::= ABORT",
132888
- /* 247 */ "raisetype ::= FAIL",
132889
- /* 248 */ "cmd ::= DROP TRIGGER ifexists fullname",
132890
- /* 249 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
132891
- /* 250 */ "cmd ::= DETACH database_kw_opt expr",
132892
- /* 251 */ "key_opt ::=",
132893
- /* 252 */ "key_opt ::= KEY expr",
132894
- /* 253 */ "cmd ::= REINDEX",
132895
- /* 254 */ "cmd ::= REINDEX nm dbnm",
132896
- /* 255 */ "cmd ::= ANALYZE",
132897
- /* 256 */ "cmd ::= ANALYZE nm dbnm",
132898
- /* 257 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
132899
- /* 258 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
132900
- /* 259 */ "add_column_fullname ::= fullname",
132901
- /* 260 */ "cmd ::= create_vtab",
132902
- /* 261 */ "cmd ::= create_vtab LP vtabarglist RP",
132903
- /* 262 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
132904
- /* 263 */ "vtabarg ::=",
132905
- /* 264 */ "vtabargtoken ::= ANY",
132906
- /* 265 */ "vtabargtoken ::= lp anylist RP",
132907
- /* 266 */ "lp ::= LP",
132908
- /* 267 */ "with ::=",
132909
- /* 268 */ "with ::= WITH wqlist",
132910
- /* 269 */ "with ::= WITH RECURSIVE wqlist",
132911
- /* 270 */ "wqlist ::= nm eidlist_opt AS LP select RP",
132912
- /* 271 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
132913
- /* 272 */ "input ::= cmdlist",
132914
- /* 273 */ "cmdlist ::= cmdlist ecmd",
132915
- /* 274 */ "cmdlist ::= ecmd",
132916
- /* 275 */ "ecmd ::= SEMI",
132917
- /* 276 */ "ecmd ::= explain cmdx SEMI",
132918
- /* 277 */ "explain ::=",
132919
- /* 278 */ "trans_opt ::=",
132920
- /* 279 */ "trans_opt ::= TRANSACTION",
132921
- /* 280 */ "trans_opt ::= TRANSACTION nm",
132922
- /* 281 */ "savepoint_opt ::= SAVEPOINT",
132923
- /* 282 */ "savepoint_opt ::=",
132924
- /* 283 */ "cmd ::= create_table create_table_args",
132925
- /* 284 */ "columnlist ::= columnlist COMMA columnname carglist",
132926
- /* 285 */ "columnlist ::= columnname carglist",
132927
- /* 286 */ "nm ::= ID|INDEXED",
132928
- /* 287 */ "nm ::= STRING",
132929
- /* 288 */ "nm ::= JOIN_KW",
132930
- /* 289 */ "typetoken ::= typename",
132931
- /* 290 */ "typename ::= ID|STRING",
132932
- /* 291 */ "signed ::= plus_num",
132933
- /* 292 */ "signed ::= minus_num",
132934
- /* 293 */ "carglist ::= carglist ccons",
132935
- /* 294 */ "carglist ::=",
132936
- /* 295 */ "ccons ::= NULL onconf",
132937
- /* 296 */ "conslist_opt ::= COMMA conslist",
132938
- /* 297 */ "conslist ::= conslist tconscomma tcons",
132939
- /* 298 */ "conslist ::= tcons",
132940
- /* 299 */ "tconscomma ::=",
132941
- /* 300 */ "defer_subclause_opt ::= defer_subclause",
132942
- /* 301 */ "resolvetype ::= raisetype",
132943
- /* 302 */ "selectnowith ::= oneselect",
132944
- /* 303 */ "oneselect ::= values",
132945
- /* 304 */ "sclp ::= selcollist COMMA",
132946
- /* 305 */ "as ::= ID|STRING",
132947
- /* 306 */ "expr ::= term",
132948
- /* 307 */ "exprlist ::= nexprlist",
132949
- /* 308 */ "nmnum ::= plus_num",
132950
- /* 309 */ "nmnum ::= nm",
132951
- /* 310 */ "nmnum ::= ON",
132952
- /* 311 */ "nmnum ::= DELETE",
132953
- /* 312 */ "nmnum ::= DEFAULT",
132954
- /* 313 */ "plus_num ::= INTEGER|FLOAT",
132955
- /* 314 */ "foreach_clause ::=",
132956
- /* 315 */ "foreach_clause ::= FOR EACH ROW",
132957
- /* 316 */ "trnm ::= nm",
132958
- /* 317 */ "tridxby ::=",
132959
- /* 318 */ "database_kw_opt ::= DATABASE",
132960
- /* 319 */ "database_kw_opt ::=",
132961
- /* 320 */ "kwcolumn_opt ::=",
132962
- /* 321 */ "kwcolumn_opt ::= COLUMNKW",
132963
- /* 322 */ "vtabarglist ::= vtabarg",
132964
- /* 323 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
132965
- /* 324 */ "vtabarg ::= vtabarg vtabargtoken",
132966
- /* 325 */ "anylist ::=",
132967
- /* 326 */ "anylist ::= anylist LP anylist RP",
132968
- /* 327 */ "anylist ::= anylist ANY",
134037
+ /* 139 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
134038
+ /* 140 */ "setlist ::= nm EQ expr",
134039
+ /* 141 */ "setlist ::= LP idlist RP EQ expr",
134040
+ /* 142 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
134041
+ /* 143 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
134042
+ /* 144 */ "insert_cmd ::= INSERT orconf",
134043
+ /* 145 */ "insert_cmd ::= REPLACE",
134044
+ /* 146 */ "idlist_opt ::=",
134045
+ /* 147 */ "idlist_opt ::= LP idlist RP",
134046
+ /* 148 */ "idlist ::= idlist COMMA nm",
134047
+ /* 149 */ "idlist ::= nm",
134048
+ /* 150 */ "expr ::= LP expr RP",
134049
+ /* 151 */ "term ::= NULL",
134050
+ /* 152 */ "expr ::= ID|INDEXED",
134051
+ /* 153 */ "expr ::= JOIN_KW",
134052
+ /* 154 */ "expr ::= nm DOT nm",
134053
+ /* 155 */ "expr ::= nm DOT nm DOT nm",
134054
+ /* 156 */ "term ::= INTEGER|FLOAT|BLOB",
134055
+ /* 157 */ "term ::= STRING",
134056
+ /* 158 */ "expr ::= VARIABLE",
134057
+ /* 159 */ "expr ::= expr COLLATE ID|STRING",
134058
+ /* 160 */ "expr ::= CAST LP expr AS typetoken RP",
134059
+ /* 161 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
134060
+ /* 162 */ "expr ::= ID|INDEXED LP STAR RP",
134061
+ /* 163 */ "term ::= CTIME_KW",
134062
+ /* 164 */ "expr ::= LP nexprlist COMMA expr RP",
134063
+ /* 165 */ "expr ::= expr AND expr",
134064
+ /* 166 */ "expr ::= expr OR expr",
134065
+ /* 167 */ "expr ::= expr LT|GT|GE|LE expr",
134066
+ /* 168 */ "expr ::= expr EQ|NE expr",
134067
+ /* 169 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
134068
+ /* 170 */ "expr ::= expr PLUS|MINUS expr",
134069
+ /* 171 */ "expr ::= expr STAR|SLASH|REM expr",
134070
+ /* 172 */ "expr ::= expr CONCAT expr",
134071
+ /* 173 */ "likeop ::= LIKE_KW|MATCH",
134072
+ /* 174 */ "likeop ::= NOT LIKE_KW|MATCH",
134073
+ /* 175 */ "expr ::= expr likeop expr",
134074
+ /* 176 */ "expr ::= expr likeop expr ESCAPE expr",
134075
+ /* 177 */ "expr ::= expr ISNULL|NOTNULL",
134076
+ /* 178 */ "expr ::= expr NOT NULL",
134077
+ /* 179 */ "expr ::= expr IS expr",
134078
+ /* 180 */ "expr ::= expr IS NOT expr",
134079
+ /* 181 */ "expr ::= NOT expr",
134080
+ /* 182 */ "expr ::= BITNOT expr",
134081
+ /* 183 */ "expr ::= MINUS expr",
134082
+ /* 184 */ "expr ::= PLUS expr",
134083
+ /* 185 */ "between_op ::= BETWEEN",
134084
+ /* 186 */ "between_op ::= NOT BETWEEN",
134085
+ /* 187 */ "expr ::= expr between_op expr AND expr",
134086
+ /* 188 */ "in_op ::= IN",
134087
+ /* 189 */ "in_op ::= NOT IN",
134088
+ /* 190 */ "expr ::= expr in_op LP exprlist RP",
134089
+ /* 191 */ "expr ::= LP select RP",
134090
+ /* 192 */ "expr ::= expr in_op LP select RP",
134091
+ /* 193 */ "expr ::= expr in_op nm dbnm paren_exprlist",
134092
+ /* 194 */ "expr ::= EXISTS LP select RP",
134093
+ /* 195 */ "expr ::= CASE case_operand case_exprlist case_else END",
134094
+ /* 196 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
134095
+ /* 197 */ "case_exprlist ::= WHEN expr THEN expr",
134096
+ /* 198 */ "case_else ::= ELSE expr",
134097
+ /* 199 */ "case_else ::=",
134098
+ /* 200 */ "case_operand ::= expr",
134099
+ /* 201 */ "case_operand ::=",
134100
+ /* 202 */ "exprlist ::=",
134101
+ /* 203 */ "nexprlist ::= nexprlist COMMA expr",
134102
+ /* 204 */ "nexprlist ::= expr",
134103
+ /* 205 */ "paren_exprlist ::=",
134104
+ /* 206 */ "paren_exprlist ::= LP exprlist RP",
134105
+ /* 207 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
134106
+ /* 208 */ "uniqueflag ::= UNIQUE",
134107
+ /* 209 */ "uniqueflag ::=",
134108
+ /* 210 */ "eidlist_opt ::=",
134109
+ /* 211 */ "eidlist_opt ::= LP eidlist RP",
134110
+ /* 212 */ "eidlist ::= eidlist COMMA nm collate sortorder",
134111
+ /* 213 */ "eidlist ::= nm collate sortorder",
134112
+ /* 214 */ "collate ::=",
134113
+ /* 215 */ "collate ::= COLLATE ID|STRING",
134114
+ /* 216 */ "cmd ::= DROP INDEX ifexists fullname",
134115
+ /* 217 */ "cmd ::= VACUUM",
134116
+ /* 218 */ "cmd ::= VACUUM nm",
134117
+ /* 219 */ "cmd ::= PRAGMA nm dbnm",
134118
+ /* 220 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
134119
+ /* 221 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
134120
+ /* 222 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
134121
+ /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
134122
+ /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
134123
+ /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
134124
+ /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
134125
+ /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
134126
+ /* 228 */ "trigger_time ::= BEFORE",
134127
+ /* 229 */ "trigger_time ::= AFTER",
134128
+ /* 230 */ "trigger_time ::= INSTEAD OF",
134129
+ /* 231 */ "trigger_time ::=",
134130
+ /* 232 */ "trigger_event ::= DELETE|INSERT",
134131
+ /* 233 */ "trigger_event ::= UPDATE",
134132
+ /* 234 */ "trigger_event ::= UPDATE OF idlist",
134133
+ /* 235 */ "when_clause ::=",
134134
+ /* 236 */ "when_clause ::= WHEN expr",
134135
+ /* 237 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
134136
+ /* 238 */ "trigger_cmd_list ::= trigger_cmd SEMI",
134137
+ /* 239 */ "trnm ::= nm DOT nm",
134138
+ /* 240 */ "tridxby ::= INDEXED BY nm",
134139
+ /* 241 */ "tridxby ::= NOT INDEXED",
134140
+ /* 242 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
134141
+ /* 243 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
134142
+ /* 244 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
134143
+ /* 245 */ "trigger_cmd ::= select",
134144
+ /* 246 */ "expr ::= RAISE LP IGNORE RP",
134145
+ /* 247 */ "expr ::= RAISE LP raisetype COMMA nm RP",
134146
+ /* 248 */ "raisetype ::= ROLLBACK",
134147
+ /* 249 */ "raisetype ::= ABORT",
134148
+ /* 250 */ "raisetype ::= FAIL",
134149
+ /* 251 */ "cmd ::= DROP TRIGGER ifexists fullname",
134150
+ /* 252 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
134151
+ /* 253 */ "cmd ::= DETACH database_kw_opt expr",
134152
+ /* 254 */ "key_opt ::=",
134153
+ /* 255 */ "key_opt ::= KEY expr",
134154
+ /* 256 */ "cmd ::= REINDEX",
134155
+ /* 257 */ "cmd ::= REINDEX nm dbnm",
134156
+ /* 258 */ "cmd ::= ANALYZE",
134157
+ /* 259 */ "cmd ::= ANALYZE nm dbnm",
134158
+ /* 260 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
134159
+ /* 261 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
134160
+ /* 262 */ "add_column_fullname ::= fullname",
134161
+ /* 263 */ "cmd ::= create_vtab",
134162
+ /* 264 */ "cmd ::= create_vtab LP vtabarglist RP",
134163
+ /* 265 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
134164
+ /* 266 */ "vtabarg ::=",
134165
+ /* 267 */ "vtabargtoken ::= ANY",
134166
+ /* 268 */ "vtabargtoken ::= lp anylist RP",
134167
+ /* 269 */ "lp ::= LP",
134168
+ /* 270 */ "with ::=",
134169
+ /* 271 */ "with ::= WITH wqlist",
134170
+ /* 272 */ "with ::= WITH RECURSIVE wqlist",
134171
+ /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
134172
+ /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
134173
+ /* 275 */ "input ::= cmdlist",
134174
+ /* 276 */ "cmdlist ::= cmdlist ecmd",
134175
+ /* 277 */ "cmdlist ::= ecmd",
134176
+ /* 278 */ "ecmd ::= SEMI",
134177
+ /* 279 */ "ecmd ::= explain cmdx SEMI",
134178
+ /* 280 */ "explain ::=",
134179
+ /* 281 */ "trans_opt ::=",
134180
+ /* 282 */ "trans_opt ::= TRANSACTION",
134181
+ /* 283 */ "trans_opt ::= TRANSACTION nm",
134182
+ /* 284 */ "savepoint_opt ::= SAVEPOINT",
134183
+ /* 285 */ "savepoint_opt ::=",
134184
+ /* 286 */ "cmd ::= create_table create_table_args",
134185
+ /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
134186
+ /* 288 */ "columnlist ::= columnname carglist",
134187
+ /* 289 */ "nm ::= ID|INDEXED",
134188
+ /* 290 */ "nm ::= STRING",
134189
+ /* 291 */ "nm ::= JOIN_KW",
134190
+ /* 292 */ "typetoken ::= typename",
134191
+ /* 293 */ "typename ::= ID|STRING",
134192
+ /* 294 */ "signed ::= plus_num",
134193
+ /* 295 */ "signed ::= minus_num",
134194
+ /* 296 */ "carglist ::= carglist ccons",
134195
+ /* 297 */ "carglist ::=",
134196
+ /* 298 */ "ccons ::= NULL onconf",
134197
+ /* 299 */ "conslist_opt ::= COMMA conslist",
134198
+ /* 300 */ "conslist ::= conslist tconscomma tcons",
134199
+ /* 301 */ "conslist ::= tcons",
134200
+ /* 302 */ "tconscomma ::=",
134201
+ /* 303 */ "defer_subclause_opt ::= defer_subclause",
134202
+ /* 304 */ "resolvetype ::= raisetype",
134203
+ /* 305 */ "selectnowith ::= oneselect",
134204
+ /* 306 */ "oneselect ::= values",
134205
+ /* 307 */ "sclp ::= selcollist COMMA",
134206
+ /* 308 */ "as ::= ID|STRING",
134207
+ /* 309 */ "expr ::= term",
134208
+ /* 310 */ "exprlist ::= nexprlist",
134209
+ /* 311 */ "nmnum ::= plus_num",
134210
+ /* 312 */ "nmnum ::= nm",
134211
+ /* 313 */ "nmnum ::= ON",
134212
+ /* 314 */ "nmnum ::= DELETE",
134213
+ /* 315 */ "nmnum ::= DEFAULT",
134214
+ /* 316 */ "plus_num ::= INTEGER|FLOAT",
134215
+ /* 317 */ "foreach_clause ::=",
134216
+ /* 318 */ "foreach_clause ::= FOR EACH ROW",
134217
+ /* 319 */ "trnm ::= nm",
134218
+ /* 320 */ "tridxby ::=",
134219
+ /* 321 */ "database_kw_opt ::= DATABASE",
134220
+ /* 322 */ "database_kw_opt ::=",
134221
+ /* 323 */ "kwcolumn_opt ::=",
134222
+ /* 324 */ "kwcolumn_opt ::= COLUMNKW",
134223
+ /* 325 */ "vtabarglist ::= vtabarg",
134224
+ /* 326 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
134225
+ /* 327 */ "vtabarg ::= vtabarg vtabargtoken",
134226
+ /* 328 */ "anylist ::=",
134227
+ /* 329 */ "anylist ::= anylist LP anylist RP",
134228
+ /* 330 */ "anylist ::= anylist ANY",
132969134229
};
132970134230
#endif /* NDEBUG */
132971134231
132972134232
132973134233
#if YYSTACKDEPTH<=0
@@ -133526,11 +134786,13 @@
133526134786
{ 149, 6 },
133527134787
{ 201, 0 },
133528134788
{ 201, 2 },
133529134789
{ 149, 8 },
133530134790
{ 218, 5 },
134791
+ { 218, 7 },
133531134792
{ 218, 3 },
134793
+ { 218, 5 },
133532134794
{ 149, 6 },
133533134795
{ 149, 7 },
133534134796
{ 219, 2 },
133535134797
{ 219, 1 },
133536134798
{ 220, 0 },
@@ -133549,10 +134811,11 @@
133549134811
{ 173, 3 },
133550134812
{ 173, 6 },
133551134813
{ 173, 5 },
133552134814
{ 173, 4 },
133553134815
{ 172, 1 },
134816
+ { 173, 5 },
133554134817
{ 173, 3 },
133555134818
{ 173, 3 },
133556134819
{ 173, 3 },
133557134820
{ 173, 3 },
133558134821
{ 173, 3 },
@@ -133836,11 +135099,11 @@
133836135099
case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
133837135100
case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
133838135101
case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
133839135102
case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
133840135103
case 90: /* distinct ::= */ yytestcase(yyruleno==90);
133841
- case 211: /* collate ::= */ yytestcase(yyruleno==211);
135104
+ case 214: /* collate ::= */ yytestcase(yyruleno==214);
133842135105
{yymsp[1].minor.yy194 = 0;}
133843135106
break;
133844135107
case 17: /* ifnotexists ::= IF NOT EXISTS */
133845135108
{yymsp[-2].minor.yy194 = 1;}
133846135109
break;
@@ -133975,18 +135238,18 @@
133975135238
case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
133976135239
{yymsp[-2].minor.yy194 = 0;}
133977135240
break;
133978135241
case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
133979135242
case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
133980
- case 142: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==142);
135243
+ case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144);
133981135244
{yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
133982135245
break;
133983135246
case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
133984135247
case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
133985
- case 183: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==183);
133986
- case 186: /* in_op ::= NOT IN */ yytestcase(yyruleno==186);
133987
- case 212: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==212);
135248
+ case 186: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==186);
135249
+ case 189: /* in_op ::= NOT IN */ yytestcase(yyruleno==189);
135250
+ case 215: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==215);
133988135251
{yymsp[-1].minor.yy194 = 1;}
133989135252
break;
133990135253
case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
133991135254
{yymsp[-1].minor.yy194 = 0;}
133992135255
break;
@@ -134018,11 +135281,11 @@
134018135281
break;
134019135282
case 72: /* resolvetype ::= IGNORE */
134020135283
{yymsp[0].minor.yy194 = OE_Ignore;}
134021135284
break;
134022135285
case 73: /* resolvetype ::= REPLACE */
134023
- case 143: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==143);
135286
+ case 145: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==145);
134024135287
{yymsp[0].minor.yy194 = OE_Replace;}
134025135288
break;
134026135289
case 74: /* cmd ::= DROP TABLE ifexists fullname */
134027135290
{
134028135291
sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);
@@ -134146,13 +135409,13 @@
134146135409
{yymsp[0].minor.yy194 = SF_All;}
134147135410
break;
134148135411
case 91: /* sclp ::= */
134149135412
case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
134150135413
case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
134151
- case 199: /* exprlist ::= */ yytestcase(yyruleno==199);
134152
- case 202: /* paren_exprlist ::= */ yytestcase(yyruleno==202);
134153
- case 207: /* eidlist_opt ::= */ yytestcase(yyruleno==207);
135414
+ case 202: /* exprlist ::= */ yytestcase(yyruleno==202);
135415
+ case 205: /* paren_exprlist ::= */ yytestcase(yyruleno==205);
135416
+ case 210: /* eidlist_opt ::= */ yytestcase(yyruleno==210);
134154135417
{yymsp[1].minor.yy148 = 0;}
134155135418
break;
134156135419
case 92: /* selcollist ::= sclp expr as */
134157135420
{
134158135421
yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
@@ -134174,12 +135437,12 @@
134174135437
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
134175135438
}
134176135439
break;
134177135440
case 95: /* as ::= AS nm */
134178135441
case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
134179
- case 221: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==221);
134180
- case 222: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==222);
135442
+ case 224: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==224);
135443
+ case 225: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==225);
134181135444
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
134182135445
break;
134183135446
case 97: /* from ::= */
134184135447
{yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
134185135448
break;
@@ -134258,18 +135521,18 @@
134258135521
{yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
134259135522
break;
134260135523
case 112: /* on_opt ::= ON expr */
134261135524
case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
134262135525
case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
134263
- case 195: /* case_else ::= ELSE expr */ yytestcase(yyruleno==195);
135526
+ case 198: /* case_else ::= ELSE expr */ yytestcase(yyruleno==198);
134264135527
{yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
134265135528
break;
134266135529
case 113: /* on_opt ::= */
134267135530
case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
134268135531
case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
134269
- case 196: /* case_else ::= */ yytestcase(yyruleno==196);
134270
- case 198: /* case_operand ::= */ yytestcase(yyruleno==198);
135532
+ case 199: /* case_else ::= */ yytestcase(yyruleno==199);
135533
+ case 201: /* case_operand ::= */ yytestcase(yyruleno==201);
134271135534
{yymsp[1].minor.yy72 = 0;}
134272135535
break;
134273135536
case 115: /* indexed_opt ::= INDEXED BY nm */
134274135537
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
134275135538
break;
@@ -134278,11 +135541,11 @@
134278135541
break;
134279135542
case 117: /* using_opt ::= USING LP idlist RP */
134280135543
{yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
134281135544
break;
134282135545
case 118: /* using_opt ::= */
134283
- case 144: /* idlist_opt ::= */ yytestcase(yyruleno==144);
135546
+ case 146: /* idlist_opt ::= */ yytestcase(yyruleno==146);
134284135547
{yymsp[1].minor.yy254 = 0;}
134285135548
break;
134286135549
case 120: /* orderby_opt ::= ORDER BY sortlist */
134287135550
case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
134288135551
{yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}
@@ -134339,69 +135602,79 @@
134339135602
{
134340135603
yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
134341135604
sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);
134342135605
}
134343135606
break;
134344
- case 139: /* setlist ::= nm EQ expr */
135607
+ case 139: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
135608
+{
135609
+ yymsp[-6].minor.yy148 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy148, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
135610
+}
135611
+ break;
135612
+ case 140: /* setlist ::= nm EQ expr */
134345135613
{
134346135614
yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
134347135615
sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);
134348135616
}
134349135617
yymsp[-2].minor.yy148 = yylhsminor.yy148;
134350135618
break;
134351
- case 140: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
135619
+ case 141: /* setlist ::= LP idlist RP EQ expr */
135620
+{
135621
+ yymsp[-4].minor.yy148 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
135622
+}
135623
+ break;
135624
+ case 142: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
134352135625
{
134353135626
sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
134354135627
sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);
134355135628
}
134356135629
break;
134357
- case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
135630
+ case 143: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
134358135631
{
134359135632
sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);
134360135633
sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);
134361135634
}
134362135635
break;
134363
- case 145: /* idlist_opt ::= LP idlist RP */
135636
+ case 147: /* idlist_opt ::= LP idlist RP */
134364135637
{yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
134365135638
break;
134366
- case 146: /* idlist ::= idlist COMMA nm */
135639
+ case 148: /* idlist ::= idlist COMMA nm */
134367135640
{yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
134368135641
break;
134369
- case 147: /* idlist ::= nm */
135642
+ case 149: /* idlist ::= nm */
134370135643
{yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
134371135644
break;
134372
- case 148: /* expr ::= LP expr RP */
135645
+ case 150: /* expr ::= LP expr RP */
134373135646
{spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
134374135647
break;
134375
- case 149: /* term ::= NULL */
134376
- case 154: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==154);
134377
- case 155: /* term ::= STRING */ yytestcase(yyruleno==155);
135648
+ case 151: /* term ::= NULL */
135649
+ case 156: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==156);
135650
+ case 157: /* term ::= STRING */ yytestcase(yyruleno==157);
134378135651
{spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
134379135652
break;
134380
- case 150: /* expr ::= ID|INDEXED */
134381
- case 151: /* expr ::= JOIN_KW */ yytestcase(yyruleno==151);
135653
+ case 152: /* expr ::= ID|INDEXED */
135654
+ case 153: /* expr ::= JOIN_KW */ yytestcase(yyruleno==153);
134382135655
{spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
134383135656
break;
134384
- case 152: /* expr ::= nm DOT nm */
135657
+ case 154: /* expr ::= nm DOT nm */
134385135658
{
134386135659
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
134387135660
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
134388135661
spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134389135662
yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
134390135663
}
134391135664
break;
134392
- case 153: /* expr ::= nm DOT nm DOT nm */
135665
+ case 155: /* expr ::= nm DOT nm DOT nm */
134393135666
{
134394135667
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
134395135668
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
134396135669
Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
134397135670
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
134398135671
spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134399135672
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
134400135673
}
134401135674
break;
134402
- case 156: /* expr ::= VARIABLE */
135675
+ case 158: /* expr ::= VARIABLE */
134403135676
{
134404135677
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
134405135678
spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
134406135679
sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr);
134407135680
}else{
@@ -134419,23 +135692,23 @@
134419135692
if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
134420135693
}
134421135694
}
134422135695
}
134423135696
break;
134424
- case 157: /* expr ::= expr COLLATE ID|STRING */
135697
+ case 159: /* expr ::= expr COLLATE ID|STRING */
134425135698
{
134426135699
yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
134427135700
yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134428135701
}
134429135702
break;
134430
- case 158: /* expr ::= CAST LP expr AS typetoken RP */
135703
+ case 160: /* expr ::= CAST LP expr AS typetoken RP */
134431135704
{
134432135705
spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134433135706
yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy190.pExpr, 0, &yymsp[-1].minor.yy0);
134434135707
}
134435135708
break;
134436
- case 159: /* expr ::= ID|INDEXED LP distinct exprlist RP */
135709
+ case 161: /* expr ::= ID|INDEXED LP distinct exprlist RP */
134437135710
{
134438135711
if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
134439135712
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
134440135713
}
134441135714
yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
@@ -134444,41 +135717,54 @@
134444135717
yylhsminor.yy190.pExpr->flags |= EP_Distinct;
134445135718
}
134446135719
}
134447135720
yymsp[-4].minor.yy190 = yylhsminor.yy190;
134448135721
break;
134449
- case 160: /* expr ::= ID|INDEXED LP STAR RP */
135722
+ case 162: /* expr ::= ID|INDEXED LP STAR RP */
134450135723
{
134451135724
yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
134452135725
spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
134453135726
}
134454135727
yymsp[-3].minor.yy190 = yylhsminor.yy190;
134455135728
break;
134456
- case 161: /* term ::= CTIME_KW */
135729
+ case 163: /* term ::= CTIME_KW */
134457135730
{
134458135731
yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
134459135732
spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
134460135733
}
134461135734
yymsp[0].minor.yy190 = yylhsminor.yy190;
134462135735
break;
134463
- case 162: /* expr ::= expr AND expr */
134464
- case 163: /* expr ::= expr OR expr */ yytestcase(yyruleno==163);
134465
- case 164: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==164);
134466
- case 165: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==165);
134467
- case 166: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==166);
134468
- case 167: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==167);
134469
- case 168: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==168);
134470
- case 169: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==169);
135736
+ case 164: /* expr ::= LP nexprlist COMMA expr RP */
135737
+{
135738
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy148, yymsp[-1].minor.yy190.pExpr);
135739
+ yylhsminor.yy190.pExpr = sqlite3PExpr(pParse, TK_VECTOR, 0, 0, 0);
135740
+ if( yylhsminor.yy190.pExpr ){
135741
+ yylhsminor.yy190.pExpr->x.pList = pList;
135742
+ spanSet(&yylhsminor.yy190, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0);
135743
+ }else{
135744
+ sqlite3ExprListDelete(pParse->db, pList);
135745
+ }
135746
+}
135747
+ yymsp[-4].minor.yy190 = yylhsminor.yy190;
135748
+ break;
135749
+ case 165: /* expr ::= expr AND expr */
135750
+ case 166: /* expr ::= expr OR expr */ yytestcase(yyruleno==166);
135751
+ case 167: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==167);
135752
+ case 168: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==168);
135753
+ case 169: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==169);
135754
+ case 170: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==170);
135755
+ case 171: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==171);
135756
+ case 172: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==172);
134471135757
{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
134472135758
break;
134473
- case 170: /* likeop ::= LIKE_KW|MATCH */
135759
+ case 173: /* likeop ::= LIKE_KW|MATCH */
134474135760
{yymsp[0].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy392.bNot = 0;/*A-overwrites-X*/}
134475135761
break;
134476
- case 171: /* likeop ::= NOT LIKE_KW|MATCH */
135762
+ case 174: /* likeop ::= NOT LIKE_KW|MATCH */
134477135763
{yymsp[-1].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy392.bNot = 1;}
134478135764
break;
134479
- case 172: /* expr ::= expr likeop expr */
135765
+ case 175: /* expr ::= expr likeop expr */
134480135766
{
134481135767
ExprList *pList;
134482135768
pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
134483135769
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr);
134484135770
yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy392.eOperator);
@@ -134485,11 +135771,11 @@
134485135771
exprNot(pParse, yymsp[-1].minor.yy392.bNot, &yymsp[-2].minor.yy190);
134486135772
yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134487135773
if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
134488135774
}
134489135775
break;
134490
- case 173: /* expr ::= expr likeop expr ESCAPE expr */
135776
+ case 176: /* expr ::= expr likeop expr ESCAPE expr */
134491135777
{
134492135778
ExprList *pList;
134493135779
pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134494135780
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr);
134495135781
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
@@ -134497,43 +135783,43 @@
134497135783
exprNot(pParse, yymsp[-3].minor.yy392.bNot, &yymsp[-4].minor.yy190);
134498135784
yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134499135785
if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
134500135786
}
134501135787
break;
134502
- case 174: /* expr ::= expr ISNULL|NOTNULL */
135788
+ case 177: /* expr ::= expr ISNULL|NOTNULL */
134503135789
{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
134504135790
break;
134505
- case 175: /* expr ::= expr NOT NULL */
135791
+ case 178: /* expr ::= expr NOT NULL */
134506135792
{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
134507135793
break;
134508
- case 176: /* expr ::= expr IS expr */
135794
+ case 179: /* expr ::= expr IS expr */
134509135795
{
134510135796
spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
134511135797
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
134512135798
}
134513135799
break;
134514
- case 177: /* expr ::= expr IS NOT expr */
135800
+ case 180: /* expr ::= expr IS NOT expr */
134515135801
{
134516135802
spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
134517135803
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
134518135804
}
134519135805
break;
134520
- case 178: /* expr ::= NOT expr */
134521
- case 179: /* expr ::= BITNOT expr */ yytestcase(yyruleno==179);
135806
+ case 181: /* expr ::= NOT expr */
135807
+ case 182: /* expr ::= BITNOT expr */ yytestcase(yyruleno==182);
134522135808
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134523135809
break;
134524
- case 180: /* expr ::= MINUS expr */
135810
+ case 183: /* expr ::= MINUS expr */
134525135811
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134526135812
break;
134527
- case 181: /* expr ::= PLUS expr */
135813
+ case 184: /* expr ::= PLUS expr */
134528135814
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134529135815
break;
134530
- case 182: /* between_op ::= BETWEEN */
134531
- case 185: /* in_op ::= IN */ yytestcase(yyruleno==185);
135816
+ case 185: /* between_op ::= BETWEEN */
135817
+ case 188: /* in_op ::= IN */ yytestcase(yyruleno==188);
134532135818
{yymsp[0].minor.yy194 = 0;}
134533135819
break;
134534
- case 184: /* expr ::= expr between_op expr AND expr */
135820
+ case 187: /* expr ::= expr between_op expr AND expr */
134535135821
{
134536135822
ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134537135823
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
134538135824
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134539135825
if( yymsp[-4].minor.yy190.pExpr ){
@@ -134543,11 +135829,11 @@
134543135829
}
134544135830
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134545135831
yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134546135832
}
134547135833
break;
134548
- case 187: /* expr ::= expr in_op LP exprlist RP */
135834
+ case 190: /* expr ::= expr in_op LP exprlist RP */
134549135835
{
134550135836
if( yymsp[-1].minor.yy148==0 ){
134551135837
/* Expressions of the form
134552135838
**
134553135839
** expr1 IN ()
@@ -134596,26 +135882,26 @@
134596135882
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134597135883
}
134598135884
yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134599135885
}
134600135886
break;
134601
- case 188: /* expr ::= LP select RP */
135887
+ case 191: /* expr ::= LP select RP */
134602135888
{
134603135889
spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134604135890
yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
134605135891
sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
134606135892
}
134607135893
break;
134608
- case 189: /* expr ::= expr in_op LP select RP */
135894
+ case 192: /* expr ::= expr in_op LP select RP */
134609135895
{
134610135896
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134611135897
sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
134612135898
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134613135899
yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134614135900
}
134615135901
break;
134616
- case 190: /* expr ::= expr in_op nm dbnm paren_exprlist */
135902
+ case 193: /* expr ::= expr in_op nm dbnm paren_exprlist */
134617135903
{
134618135904
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
134619135905
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
134620135906
if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
134621135907
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
@@ -134622,19 +135908,19 @@
134622135908
sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
134623135909
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134624135910
yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
134625135911
}
134626135912
break;
134627
- case 191: /* expr ::= EXISTS LP select RP */
135913
+ case 194: /* expr ::= EXISTS LP select RP */
134628135914
{
134629135915
Expr *p;
134630135916
spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134631135917
p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
134632135918
sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
134633135919
}
134634135920
break;
134635
- case 192: /* expr ::= CASE case_operand case_exprlist case_else END */
135921
+ case 195: /* expr ::= CASE case_operand case_exprlist case_else END */
134636135922
{
134637135923
spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
134638135924
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0, 0);
134639135925
if( yymsp[-4].minor.yy190.pExpr ){
134640135926
yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
@@ -134643,334 +135929,334 @@
134643135929
sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
134644135930
sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
134645135931
}
134646135932
}
134647135933
break;
134648
- case 193: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
135934
+ case 196: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
134649135935
{
134650135936
yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
134651135937
yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
134652135938
}
134653135939
break;
134654
- case 194: /* case_exprlist ::= WHEN expr THEN expr */
135940
+ case 197: /* case_exprlist ::= WHEN expr THEN expr */
134655135941
{
134656135942
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134657135943
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
134658135944
}
134659135945
break;
134660
- case 197: /* case_operand ::= expr */
135946
+ case 200: /* case_operand ::= expr */
134661135947
{yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
134662135948
break;
134663
- case 200: /* nexprlist ::= nexprlist COMMA expr */
135949
+ case 203: /* nexprlist ::= nexprlist COMMA expr */
134664135950
{yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
134665135951
break;
134666
- case 201: /* nexprlist ::= expr */
135952
+ case 204: /* nexprlist ::= expr */
134667135953
{yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
134668135954
break;
134669
- case 203: /* paren_exprlist ::= LP exprlist RP */
134670
- case 208: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==208);
135955
+ case 206: /* paren_exprlist ::= LP exprlist RP */
135956
+ case 211: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==211);
134671135957
{yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
134672135958
break;
134673
- case 204: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
135959
+ case 207: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
134674135960
{
134675135961
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
134676135962
sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
134677135963
&yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
134678135964
}
134679135965
break;
134680
- case 205: /* uniqueflag ::= UNIQUE */
134681
- case 246: /* raisetype ::= ABORT */ yytestcase(yyruleno==246);
135966
+ case 208: /* uniqueflag ::= UNIQUE */
135967
+ case 249: /* raisetype ::= ABORT */ yytestcase(yyruleno==249);
134682135968
{yymsp[0].minor.yy194 = OE_Abort;}
134683135969
break;
134684
- case 206: /* uniqueflag ::= */
135970
+ case 209: /* uniqueflag ::= */
134685135971
{yymsp[1].minor.yy194 = OE_None;}
134686135972
break;
134687
- case 209: /* eidlist ::= eidlist COMMA nm collate sortorder */
135973
+ case 212: /* eidlist ::= eidlist COMMA nm collate sortorder */
134688135974
{
134689135975
yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
134690135976
}
134691135977
break;
134692
- case 210: /* eidlist ::= nm collate sortorder */
135978
+ case 213: /* eidlist ::= nm collate sortorder */
134693135979
{
134694135980
yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
134695135981
}
134696135982
break;
134697
- case 213: /* cmd ::= DROP INDEX ifexists fullname */
135983
+ case 216: /* cmd ::= DROP INDEX ifexists fullname */
134698135984
{sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
134699135985
break;
134700
- case 214: /* cmd ::= VACUUM */
135986
+ case 217: /* cmd ::= VACUUM */
134701135987
{sqlite3Vacuum(pParse,0);}
134702135988
break;
134703
- case 215: /* cmd ::= VACUUM nm */
135989
+ case 218: /* cmd ::= VACUUM nm */
134704135990
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
134705135991
break;
134706
- case 216: /* cmd ::= PRAGMA nm dbnm */
135992
+ case 219: /* cmd ::= PRAGMA nm dbnm */
134707135993
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
134708135994
break;
134709
- case 217: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
135995
+ case 220: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
134710135996
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
134711135997
break;
134712
- case 218: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
135998
+ case 221: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
134713135999
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
134714136000
break;
134715
- case 219: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
136001
+ case 222: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
134716136002
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
134717136003
break;
134718
- case 220: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
136004
+ case 223: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
134719136005
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
134720136006
break;
134721
- case 223: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
136007
+ case 226: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
134722136008
{
134723136009
Token all;
134724136010
all.z = yymsp[-3].minor.yy0.z;
134725136011
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
134726136012
sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
134727136013
}
134728136014
break;
134729
- case 224: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
136015
+ case 227: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
134730136016
{
134731136017
sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
134732136018
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
134733136019
}
134734136020
break;
134735
- case 225: /* trigger_time ::= BEFORE */
136021
+ case 228: /* trigger_time ::= BEFORE */
134736136022
{ yymsp[0].minor.yy194 = TK_BEFORE; }
134737136023
break;
134738
- case 226: /* trigger_time ::= AFTER */
136024
+ case 229: /* trigger_time ::= AFTER */
134739136025
{ yymsp[0].minor.yy194 = TK_AFTER; }
134740136026
break;
134741
- case 227: /* trigger_time ::= INSTEAD OF */
136027
+ case 230: /* trigger_time ::= INSTEAD OF */
134742136028
{ yymsp[-1].minor.yy194 = TK_INSTEAD;}
134743136029
break;
134744
- case 228: /* trigger_time ::= */
136030
+ case 231: /* trigger_time ::= */
134745136031
{ yymsp[1].minor.yy194 = TK_BEFORE; }
134746136032
break;
134747
- case 229: /* trigger_event ::= DELETE|INSERT */
134748
- case 230: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==230);
136033
+ case 232: /* trigger_event ::= DELETE|INSERT */
136034
+ case 233: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==233);
134749136035
{yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
134750136036
break;
134751
- case 231: /* trigger_event ::= UPDATE OF idlist */
136037
+ case 234: /* trigger_event ::= UPDATE OF idlist */
134752136038
{yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
134753136039
break;
134754
- case 232: /* when_clause ::= */
134755
- case 251: /* key_opt ::= */ yytestcase(yyruleno==251);
136040
+ case 235: /* when_clause ::= */
136041
+ case 254: /* key_opt ::= */ yytestcase(yyruleno==254);
134756136042
{ yymsp[1].minor.yy72 = 0; }
134757136043
break;
134758
- case 233: /* when_clause ::= WHEN expr */
134759
- case 252: /* key_opt ::= KEY expr */ yytestcase(yyruleno==252);
136044
+ case 236: /* when_clause ::= WHEN expr */
136045
+ case 255: /* key_opt ::= KEY expr */ yytestcase(yyruleno==255);
134760136046
{ yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
134761136047
break;
134762
- case 234: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
136048
+ case 237: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
134763136049
{
134764136050
assert( yymsp[-2].minor.yy145!=0 );
134765136051
yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
134766136052
yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
134767136053
}
134768136054
break;
134769
- case 235: /* trigger_cmd_list ::= trigger_cmd SEMI */
136055
+ case 238: /* trigger_cmd_list ::= trigger_cmd SEMI */
134770136056
{
134771136057
assert( yymsp[-1].minor.yy145!=0 );
134772136058
yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
134773136059
}
134774136060
break;
134775
- case 236: /* trnm ::= nm DOT nm */
136061
+ case 239: /* trnm ::= nm DOT nm */
134776136062
{
134777136063
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
134778136064
sqlite3ErrorMsg(pParse,
134779136065
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
134780136066
"statements within triggers");
134781136067
}
134782136068
break;
134783
- case 237: /* tridxby ::= INDEXED BY nm */
136069
+ case 240: /* tridxby ::= INDEXED BY nm */
134784136070
{
134785136071
sqlite3ErrorMsg(pParse,
134786136072
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
134787136073
"within triggers");
134788136074
}
134789136075
break;
134790
- case 238: /* tridxby ::= NOT INDEXED */
136076
+ case 241: /* tridxby ::= NOT INDEXED */
134791136077
{
134792136078
sqlite3ErrorMsg(pParse,
134793136079
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
134794136080
"within triggers");
134795136081
}
134796136082
break;
134797
- case 239: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
136083
+ case 242: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
134798136084
{yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
134799136085
break;
134800
- case 240: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
136086
+ case 243: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
134801136087
{yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
134802136088
break;
134803
- case 241: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
136089
+ case 244: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
134804136090
{yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
134805136091
break;
134806
- case 242: /* trigger_cmd ::= select */
136092
+ case 245: /* trigger_cmd ::= select */
134807136093
{yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
134808136094
break;
134809
- case 243: /* expr ::= RAISE LP IGNORE RP */
136095
+ case 246: /* expr ::= RAISE LP IGNORE RP */
134810136096
{
134811136097
spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134812136098
yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
134813136099
if( yymsp[-3].minor.yy190.pExpr ){
134814136100
yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
134815136101
}
134816136102
}
134817136103
break;
134818
- case 244: /* expr ::= RAISE LP raisetype COMMA nm RP */
136104
+ case 247: /* expr ::= RAISE LP raisetype COMMA nm RP */
134819136105
{
134820136106
spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134821136107
yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
134822136108
if( yymsp[-5].minor.yy190.pExpr ) {
134823136109
yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
134824136110
}
134825136111
}
134826136112
break;
134827
- case 245: /* raisetype ::= ROLLBACK */
136113
+ case 248: /* raisetype ::= ROLLBACK */
134828136114
{yymsp[0].minor.yy194 = OE_Rollback;}
134829136115
break;
134830
- case 247: /* raisetype ::= FAIL */
136116
+ case 250: /* raisetype ::= FAIL */
134831136117
{yymsp[0].minor.yy194 = OE_Fail;}
134832136118
break;
134833
- case 248: /* cmd ::= DROP TRIGGER ifexists fullname */
136119
+ case 251: /* cmd ::= DROP TRIGGER ifexists fullname */
134834136120
{
134835136121
sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
134836136122
}
134837136123
break;
134838
- case 249: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
136124
+ case 252: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
134839136125
{
134840136126
sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
134841136127
}
134842136128
break;
134843
- case 250: /* cmd ::= DETACH database_kw_opt expr */
136129
+ case 253: /* cmd ::= DETACH database_kw_opt expr */
134844136130
{
134845136131
sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
134846136132
}
134847136133
break;
134848
- case 253: /* cmd ::= REINDEX */
136134
+ case 256: /* cmd ::= REINDEX */
134849136135
{sqlite3Reindex(pParse, 0, 0);}
134850136136
break;
134851
- case 254: /* cmd ::= REINDEX nm dbnm */
136137
+ case 257: /* cmd ::= REINDEX nm dbnm */
134852136138
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
134853136139
break;
134854
- case 255: /* cmd ::= ANALYZE */
136140
+ case 258: /* cmd ::= ANALYZE */
134855136141
{sqlite3Analyze(pParse, 0, 0);}
134856136142
break;
134857
- case 256: /* cmd ::= ANALYZE nm dbnm */
136143
+ case 259: /* cmd ::= ANALYZE nm dbnm */
134858136144
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
134859136145
break;
134860
- case 257: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
136146
+ case 260: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
134861136147
{
134862136148
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
134863136149
}
134864136150
break;
134865
- case 258: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
136151
+ case 261: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
134866136152
{
134867136153
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
134868136154
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
134869136155
}
134870136156
break;
134871
- case 259: /* add_column_fullname ::= fullname */
136157
+ case 262: /* add_column_fullname ::= fullname */
134872136158
{
134873136159
disableLookaside(pParse);
134874136160
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
134875136161
}
134876136162
break;
134877
- case 260: /* cmd ::= create_vtab */
136163
+ case 263: /* cmd ::= create_vtab */
134878136164
{sqlite3VtabFinishParse(pParse,0);}
134879136165
break;
134880
- case 261: /* cmd ::= create_vtab LP vtabarglist RP */
136166
+ case 264: /* cmd ::= create_vtab LP vtabarglist RP */
134881136167
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
134882136168
break;
134883
- case 262: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
136169
+ case 265: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
134884136170
{
134885136171
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
134886136172
}
134887136173
break;
134888
- case 263: /* vtabarg ::= */
136174
+ case 266: /* vtabarg ::= */
134889136175
{sqlite3VtabArgInit(pParse);}
134890136176
break;
134891
- case 264: /* vtabargtoken ::= ANY */
134892
- case 265: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==265);
134893
- case 266: /* lp ::= LP */ yytestcase(yyruleno==266);
136177
+ case 267: /* vtabargtoken ::= ANY */
136178
+ case 268: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==268);
136179
+ case 269: /* lp ::= LP */ yytestcase(yyruleno==269);
134894136180
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
134895136181
break;
134896
- case 267: /* with ::= */
136182
+ case 270: /* with ::= */
134897136183
{yymsp[1].minor.yy285 = 0;}
134898136184
break;
134899
- case 268: /* with ::= WITH wqlist */
136185
+ case 271: /* with ::= WITH wqlist */
134900136186
{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
134901136187
break;
134902
- case 269: /* with ::= WITH RECURSIVE wqlist */
136188
+ case 272: /* with ::= WITH RECURSIVE wqlist */
134903136189
{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
134904136190
break;
134905
- case 270: /* wqlist ::= nm eidlist_opt AS LP select RP */
136191
+ case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
134906136192
{
134907136193
yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
134908136194
}
134909136195
break;
134910
- case 271: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
136196
+ case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
134911136197
{
134912136198
yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
134913136199
}
134914136200
break;
134915136201
default:
134916
- /* (272) input ::= cmdlist */ yytestcase(yyruleno==272);
134917
- /* (273) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==273);
134918
- /* (274) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=274);
134919
- /* (275) ecmd ::= SEMI */ yytestcase(yyruleno==275);
134920
- /* (276) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==276);
134921
- /* (277) explain ::= */ yytestcase(yyruleno==277);
134922
- /* (278) trans_opt ::= */ yytestcase(yyruleno==278);
134923
- /* (279) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==279);
134924
- /* (280) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==280);
134925
- /* (281) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==281);
134926
- /* (282) savepoint_opt ::= */ yytestcase(yyruleno==282);
134927
- /* (283) cmd ::= create_table create_table_args */ yytestcase(yyruleno==283);
134928
- /* (284) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==284);
134929
- /* (285) columnlist ::= columnname carglist */ yytestcase(yyruleno==285);
134930
- /* (286) nm ::= ID|INDEXED */ yytestcase(yyruleno==286);
134931
- /* (287) nm ::= STRING */ yytestcase(yyruleno==287);
134932
- /* (288) nm ::= JOIN_KW */ yytestcase(yyruleno==288);
134933
- /* (289) typetoken ::= typename */ yytestcase(yyruleno==289);
134934
- /* (290) typename ::= ID|STRING */ yytestcase(yyruleno==290);
134935
- /* (291) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=291);
134936
- /* (292) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=292);
134937
- /* (293) carglist ::= carglist ccons */ yytestcase(yyruleno==293);
134938
- /* (294) carglist ::= */ yytestcase(yyruleno==294);
134939
- /* (295) ccons ::= NULL onconf */ yytestcase(yyruleno==295);
134940
- /* (296) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==296);
134941
- /* (297) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==297);
134942
- /* (298) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=298);
134943
- /* (299) tconscomma ::= */ yytestcase(yyruleno==299);
134944
- /* (300) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=300);
134945
- /* (301) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=301);
134946
- /* (302) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=302);
134947
- /* (303) oneselect ::= values */ yytestcase(yyruleno==303);
134948
- /* (304) sclp ::= selcollist COMMA */ yytestcase(yyruleno==304);
134949
- /* (305) as ::= ID|STRING */ yytestcase(yyruleno==305);
134950
- /* (306) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=306);
134951
- /* (307) exprlist ::= nexprlist */ yytestcase(yyruleno==307);
134952
- /* (308) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=308);
134953
- /* (309) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=309);
134954
- /* (310) nmnum ::= ON */ yytestcase(yyruleno==310);
134955
- /* (311) nmnum ::= DELETE */ yytestcase(yyruleno==311);
134956
- /* (312) nmnum ::= DEFAULT */ yytestcase(yyruleno==312);
134957
- /* (313) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==313);
134958
- /* (314) foreach_clause ::= */ yytestcase(yyruleno==314);
134959
- /* (315) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==315);
134960
- /* (316) trnm ::= nm */ yytestcase(yyruleno==316);
134961
- /* (317) tridxby ::= */ yytestcase(yyruleno==317);
134962
- /* (318) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==318);
134963
- /* (319) database_kw_opt ::= */ yytestcase(yyruleno==319);
134964
- /* (320) kwcolumn_opt ::= */ yytestcase(yyruleno==320);
134965
- /* (321) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==321);
134966
- /* (322) vtabarglist ::= vtabarg */ yytestcase(yyruleno==322);
134967
- /* (323) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==323);
134968
- /* (324) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==324);
134969
- /* (325) anylist ::= */ yytestcase(yyruleno==325);
134970
- /* (326) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==326);
134971
- /* (327) anylist ::= anylist ANY */ yytestcase(yyruleno==327);
136202
+ /* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
136203
+ /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
136204
+ /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
136205
+ /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
136206
+ /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
136207
+ /* (280) explain ::= */ yytestcase(yyruleno==280);
136208
+ /* (281) trans_opt ::= */ yytestcase(yyruleno==281);
136209
+ /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
136210
+ /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
136211
+ /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
136212
+ /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
136213
+ /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
136214
+ /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
136215
+ /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
136216
+ /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
136217
+ /* (290) nm ::= STRING */ yytestcase(yyruleno==290);
136218
+ /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
136219
+ /* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
136220
+ /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
136221
+ /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
136222
+ /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
136223
+ /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
136224
+ /* (297) carglist ::= */ yytestcase(yyruleno==297);
136225
+ /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
136226
+ /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
136227
+ /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
136228
+ /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
136229
+ /* (302) tconscomma ::= */ yytestcase(yyruleno==302);
136230
+ /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
136231
+ /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
136232
+ /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
136233
+ /* (306) oneselect ::= values */ yytestcase(yyruleno==306);
136234
+ /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
136235
+ /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
136236
+ /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
136237
+ /* (310) exprlist ::= nexprlist */ yytestcase(yyruleno==310);
136238
+ /* (311) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=311);
136239
+ /* (312) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=312);
136240
+ /* (313) nmnum ::= ON */ yytestcase(yyruleno==313);
136241
+ /* (314) nmnum ::= DELETE */ yytestcase(yyruleno==314);
136242
+ /* (315) nmnum ::= DEFAULT */ yytestcase(yyruleno==315);
136243
+ /* (316) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==316);
136244
+ /* (317) foreach_clause ::= */ yytestcase(yyruleno==317);
136245
+ /* (318) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==318);
136246
+ /* (319) trnm ::= nm */ yytestcase(yyruleno==319);
136247
+ /* (320) tridxby ::= */ yytestcase(yyruleno==320);
136248
+ /* (321) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==321);
136249
+ /* (322) database_kw_opt ::= */ yytestcase(yyruleno==322);
136250
+ /* (323) kwcolumn_opt ::= */ yytestcase(yyruleno==323);
136251
+ /* (324) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==324);
136252
+ /* (325) vtabarglist ::= vtabarg */ yytestcase(yyruleno==325);
136253
+ /* (326) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==326);
136254
+ /* (327) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==327);
136255
+ /* (328) anylist ::= */ yytestcase(yyruleno==328);
136256
+ /* (329) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==329);
136257
+ /* (330) anylist ::= anylist ANY */ yytestcase(yyruleno==330);
134972136258
break;
134973136259
/********** End reduce actions ************************************************/
134974136260
};
134975136261
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
134976136262
yygoto = yyRuleInfo[yyruleno].lhs;
@@ -138358,10 +139644,12 @@
138358139644
if( !sqlite3SafetyCheckOk(db) ){
138359139645
return SQLITE_MISUSE_BKPT;
138360139646
}
138361139647
#endif
138362139648
sqlite3_mutex_enter(db->mutex);
139649
+ if( mTrace==0 ) xTrace = 0;
139650
+ if( xTrace==0 ) mTrace = 0;
138363139651
db->mTrace = mTrace;
138364139652
db->xTrace = xTrace;
138365139653
db->pTraceArg = pArg;
138366139654
sqlite3_mutex_leave(db->mutex);
138367139655
return SQLITE_OK;
@@ -139468,15 +140756,24 @@
139468140756
** database schema yet. This is delayed until the first time the database
139469140757
** is accessed.
139470140758
*/
139471140759
sqlite3Error(db, SQLITE_OK);
139472140760
sqlite3RegisterPerConnectionBuiltinFunctions(db);
140761
+ rc = sqlite3_errcode(db);
140762
+
140763
+#ifdef SQLITE_ENABLE_FTS5
140764
+ /* Register any built-in FTS5 module before loading the automatic
140765
+ ** extensions. This allows automatic extensions to register FTS5
140766
+ ** tokenizers and auxiliary functions. */
140767
+ if( !db->mallocFailed && rc==SQLITE_OK ){
140768
+ rc = sqlite3Fts5Init(db);
140769
+ }
140770
+#endif
139473140771
139474140772
/* Load automatic extensions - extensions that have been registered
139475140773
** using the sqlite3_automatic_extension() API.
139476140774
*/
139477
- rc = sqlite3_errcode(db);
139478140775
if( rc==SQLITE_OK ){
139479140776
sqlite3AutoLoadExtensions(db);
139480140777
rc = sqlite3_errcode(db);
139481140778
if( rc!=SQLITE_OK ){
139482140779
goto opendb_out;
@@ -139499,16 +140796,10 @@
139499140796
139500140797
#ifdef SQLITE_ENABLE_FTS3 /* automatically defined by SQLITE_ENABLE_FTS4 */
139501140798
if( !db->mallocFailed && rc==SQLITE_OK ){
139502140799
rc = sqlite3Fts3Init(db);
139503140800
}
139504
-#endif
139505
-
139506
-#ifdef SQLITE_ENABLE_FTS5
139507
- if( !db->mallocFailed && rc==SQLITE_OK ){
139508
- rc = sqlite3Fts5Init(db);
139509
- }
139510140801
#endif
139511140802
139512140803
#ifdef SQLITE_ENABLE_ICU
139513140804
if( !db->mallocFailed && rc==SQLITE_OK ){
139514140805
rc = sqlite3IcuInit(db);
@@ -161530,11 +162821,11 @@
161530162821
161531162822
pCsr->iStrategy = idxNum;
161532162823
if( idxNum==1 ){
161533162824
/* Special case - lookup by rowid. */
161534162825
RtreeNode *pLeaf; /* Leaf on which the required cell resides */
161535
- RtreeSearchPoint *p; /* Search point for the the leaf */
162826
+ RtreeSearchPoint *p; /* Search point for the leaf */
161536162827
i64 iRowid = sqlite3_value_int64(argv[0]);
161537162828
i64 iNode = 0;
161538162829
rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
161539162830
if( rc==SQLITE_OK && pLeaf!=0 ){
161540162831
p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);
@@ -164566,11 +165857,11 @@
164566165857
**
164567165858
** Instead of the plain data_<target> naming scheme, RBU database tables
164568165859
** may also be named data<integer>_<target>, where <integer> is any sequence
164569165860
** of zero or more numeric characters (0-9). This can be significant because
164570165861
** tables within the RBU database are always processed in order sorted by
164571
-** name. By judicious selection of the the <integer> portion of the names
165862
+** name. By judicious selection of the <integer> portion of the names
164572165863
** of the RBU tables the user can therefore control the order in which they
164573165864
** are processed. This can be useful, for example, to ensure that "external
164574165865
** content" FTS4 tables are updated before their underlying content tables.
164575165866
**
164576165867
** If the target database table is a virtual table or a table that has no
@@ -180154,10 +181445,119 @@
180154181445
}
180155181446
}
180156181447
/*
180157181448
** End of highlight() implementation.
180158181449
**************************************************************************/
181450
+
181451
+/*
181452
+** Context object passed to the fts5SentenceFinderCb() function.
181453
+*/
181454
+typedef struct Fts5SFinder Fts5SFinder;
181455
+struct Fts5SFinder {
181456
+ int iPos; /* Current token position */
181457
+ int nFirstAlloc; /* Allocated size of aFirst[] */
181458
+ int nFirst; /* Number of entries in aFirst[] */
181459
+ int *aFirst; /* Array of first token in each sentence */
181460
+ const char *zDoc; /* Document being tokenized */
181461
+};
181462
+
181463
+/*
181464
+** Add an entry to the Fts5SFinder.aFirst[] array. Grow the array if
181465
+** necessary. Return SQLITE_OK if successful, or SQLITE_NOMEM if an
181466
+** error occurs.
181467
+*/
181468
+static int fts5SentenceFinderAdd(Fts5SFinder *p, int iAdd){
181469
+ if( p->nFirstAlloc==p->nFirst ){
181470
+ int nNew = p->nFirstAlloc ? p->nFirstAlloc*2 : 64;
181471
+ int *aNew;
181472
+
181473
+ aNew = (int*)sqlite3_realloc(p->aFirst, nNew*sizeof(int));
181474
+ if( aNew==0 ) return SQLITE_NOMEM;
181475
+ p->aFirst = aNew;
181476
+ p->nFirstAlloc = nNew;
181477
+ }
181478
+ p->aFirst[p->nFirst++] = iAdd;
181479
+ return SQLITE_OK;
181480
+}
181481
+
181482
+/*
181483
+** This function is an xTokenize() callback used by the auxiliary snippet()
181484
+** function. Its job is to identify tokens that are the first in a sentence.
181485
+** For each such token, an entry is added to the SFinder.aFirst[] array.
181486
+*/
181487
+static int fts5SentenceFinderCb(
181488
+ void *pContext, /* Pointer to HighlightContext object */
181489
+ int tflags, /* Mask of FTS5_TOKEN_* flags */
181490
+ const char *pToken, /* Buffer containing token */
181491
+ int nToken, /* Size of token in bytes */
181492
+ int iStartOff, /* Start offset of token */
181493
+ int iEndOff /* End offset of token */
181494
+){
181495
+ int rc = SQLITE_OK;
181496
+
181497
+ if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){
181498
+ Fts5SFinder *p = (Fts5SFinder*)pContext;
181499
+ if( p->iPos>0 ){
181500
+ int i;
181501
+ char c = 0;
181502
+ for(i=iStartOff-1; i>=0; i--){
181503
+ c = p->zDoc[i];
181504
+ if( c!=' ' && c!='\t' && c!='\n' && c!='\r' ) break;
181505
+ }
181506
+ if( i!=iStartOff-1 && (c=='.' || c==':') ){
181507
+ rc = fts5SentenceFinderAdd(p, p->iPos);
181508
+ }
181509
+ }else{
181510
+ rc = fts5SentenceFinderAdd(p, 0);
181511
+ }
181512
+ p->iPos++;
181513
+ }
181514
+ return rc;
181515
+}
181516
+
181517
+static int fts5SnippetScore(
181518
+ const Fts5ExtensionApi *pApi, /* API offered by current FTS version */
181519
+ Fts5Context *pFts, /* First arg to pass to pApi functions */
181520
+ int nDocsize, /* Size of column in tokens */
181521
+ unsigned char *aSeen, /* Array with one element per query phrase */
181522
+ int iCol, /* Column to score */
181523
+ int iPos, /* Starting offset to score */
181524
+ int nToken, /* Max tokens per snippet */
181525
+ int *pnScore, /* OUT: Score */
181526
+ int *piPos /* OUT: Adjusted offset */
181527
+){
181528
+ int rc;
181529
+ int i;
181530
+ int ip = 0;
181531
+ int ic = 0;
181532
+ int iOff = 0;
181533
+ int iFirst = -1;
181534
+ int nInst;
181535
+ int nScore = 0;
181536
+ int iLast = 0;
181537
+
181538
+ rc = pApi->xInstCount(pFts, &nInst);
181539
+ for(i=0; i<nInst && rc==SQLITE_OK; i++){
181540
+ rc = pApi->xInst(pFts, i, &ip, &ic, &iOff);
181541
+ if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<(iPos+nToken) ){
181542
+ nScore += (aSeen[ip] ? 1 : 1000);
181543
+ aSeen[ip] = 1;
181544
+ if( iFirst<0 ) iFirst = iOff;
181545
+ iLast = iOff + pApi->xPhraseSize(pFts, ip);
181546
+ }
181547
+ }
181548
+
181549
+ *pnScore = nScore;
181550
+ if( piPos ){
181551
+ int iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
181552
+ if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;
181553
+ if( iAdj<0 ) iAdj = 0;
181554
+ *piPos = iAdj;
181555
+ }
181556
+
181557
+ return rc;
181558
+}
180159181559
180160181560
/*
180161181561
** Implementation of snippet() function.
180162181562
*/
180163181563
static void fts5SnippetFunction(
@@ -180176,87 +181576,111 @@
180176181576
int i; /* Used to iterate through instances */
180177181577
int nPhrase; /* Number of phrases in query */
180178181578
unsigned char *aSeen; /* Array of "seen instance" flags */
180179181579
int iBestCol; /* Column containing best snippet */
180180181580
int iBestStart = 0; /* First token of best snippet */
180181
- int iBestLast; /* Last token of best snippet */
180182181581
int nBestScore = 0; /* Score of best snippet */
180183181582
int nColSize = 0; /* Total size of iBestCol in tokens */
181583
+ Fts5SFinder sFinder; /* Used to find the beginnings of sentences */
181584
+ int nCol;
180184181585
180185181586
if( nVal!=5 ){
180186181587
const char *zErr = "wrong number of arguments to function snippet()";
180187181588
sqlite3_result_error(pCtx, zErr, -1);
180188181589
return;
180189181590
}
180190181591
181592
+ nCol = pApi->xColumnCount(pFts);
180191181593
memset(&ctx, 0, sizeof(HighlightContext));
180192181594
iCol = sqlite3_value_int(apVal[0]);
180193181595
ctx.zOpen = (const char*)sqlite3_value_text(apVal[1]);
180194181596
ctx.zClose = (const char*)sqlite3_value_text(apVal[2]);
180195181597
zEllips = (const char*)sqlite3_value_text(apVal[3]);
180196181598
nToken = sqlite3_value_int(apVal[4]);
180197
- iBestLast = nToken-1;
180198181599
180199181600
iBestCol = (iCol>=0 ? iCol : 0);
180200181601
nPhrase = pApi->xPhraseCount(pFts);
180201181602
aSeen = sqlite3_malloc(nPhrase);
180202181603
if( aSeen==0 ){
180203181604
rc = SQLITE_NOMEM;
180204181605
}
180205
-
180206181606
if( rc==SQLITE_OK ){
180207181607
rc = pApi->xInstCount(pFts, &nInst);
180208181608
}
180209
- for(i=0; rc==SQLITE_OK && i<nInst; i++){
180210
- int ip, iSnippetCol, iStart;
180211
- memset(aSeen, 0, nPhrase);
180212
- rc = pApi->xInst(pFts, i, &ip, &iSnippetCol, &iStart);
180213
- if( rc==SQLITE_OK && (iCol<0 || iSnippetCol==iCol) ){
180214
- int nScore = 1000;
180215
- int iLast = iStart - 1 + pApi->xPhraseSize(pFts, ip);
180216
- int j;
180217
- aSeen[ip] = 1;
180218
-
180219
- for(j=i+1; rc==SQLITE_OK && j<nInst; j++){
180220
- int ic; int io; int iFinal;
180221
- rc = pApi->xInst(pFts, j, &ip, &ic, &io);
180222
- iFinal = io + pApi->xPhraseSize(pFts, ip) - 1;
180223
- if( rc==SQLITE_OK && ic==iSnippetCol && iLast<iStart+nToken ){
180224
- nScore += aSeen[ip] ? 1000 : 1;
180225
- aSeen[ip] = 1;
180226
- if( iFinal>iLast ) iLast = iFinal;
180227
- }
180228
- }
180229
-
180230
- if( rc==SQLITE_OK && nScore>nBestScore ){
180231
- iBestCol = iSnippetCol;
180232
- iBestStart = iStart;
180233
- iBestLast = iLast;
180234
- nBestScore = nScore;
180235
- }
180236
- }
180237
- }
180238
-
180239
- if( rc==SQLITE_OK ){
180240
- rc = pApi->xColumnSize(pFts, iBestCol, &nColSize);
180241
- }
181609
+
181610
+ memset(&sFinder, 0, sizeof(Fts5SFinder));
181611
+ for(i=0; i<nCol; i++){
181612
+ if( iCol<0 || iCol==i ){
181613
+ int nDoc;
181614
+ int nDocsize;
181615
+ int ii;
181616
+ sFinder.iPos = 0;
181617
+ sFinder.nFirst = 0;
181618
+ rc = pApi->xColumnText(pFts, i, &sFinder.zDoc, &nDoc);
181619
+ if( rc!=SQLITE_OK ) break;
181620
+ rc = pApi->xTokenize(pFts,
181621
+ sFinder.zDoc, nDoc, (void*)&sFinder,fts5SentenceFinderCb
181622
+ );
181623
+ if( rc!=SQLITE_OK ) break;
181624
+ rc = pApi->xColumnSize(pFts, i, &nDocsize);
181625
+ if( rc!=SQLITE_OK ) break;
181626
+
181627
+ for(ii=0; rc==SQLITE_OK && ii<nInst; ii++){
181628
+ int ip, ic, io;
181629
+ int iAdj;
181630
+ int nScore;
181631
+ int jj;
181632
+
181633
+ rc = pApi->xInst(pFts, ii, &ip, &ic, &io);
181634
+ if( ic!=i || rc!=SQLITE_OK ) continue;
181635
+ memset(aSeen, 0, nPhrase);
181636
+ rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,
181637
+ io, nToken, &nScore, &iAdj
181638
+ );
181639
+ if( rc==SQLITE_OK && nScore>nBestScore ){
181640
+ nBestScore = nScore;
181641
+ iBestCol = i;
181642
+ iBestStart = iAdj;
181643
+ nColSize = nDocsize;
181644
+ }
181645
+
181646
+ if( rc==SQLITE_OK && sFinder.nFirst && nDocsize>nToken ){
181647
+ for(jj=0; jj<(sFinder.nFirst-1); jj++){
181648
+ if( sFinder.aFirst[jj+1]>io ) break;
181649
+ }
181650
+
181651
+ if( sFinder.aFirst[jj]<io ){
181652
+ int nScore;
181653
+ memset(aSeen, 0, nPhrase);
181654
+ rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,
181655
+ sFinder.aFirst[jj], nToken, &nScore, 0
181656
+ );
181657
+
181658
+ nScore += (sFinder.aFirst[jj]==0 ? 120 : 100);
181659
+ if( rc==SQLITE_OK && nScore>nBestScore ){
181660
+ nBestScore = nScore;
181661
+ iBestCol = i;
181662
+ iBestStart = sFinder.aFirst[jj];
181663
+ nColSize = nDocsize;
181664
+ }
181665
+ }
181666
+ }
181667
+ }
181668
+ }
181669
+ }
181670
+
180242181671
if( rc==SQLITE_OK ){
180243181672
rc = pApi->xColumnText(pFts, iBestCol, &ctx.zIn, &ctx.nIn);
180244181673
}
181674
+ if( rc==SQLITE_OK && nColSize==0 ){
181675
+ rc = pApi->xColumnSize(pFts, iBestCol, &nColSize);
181676
+ }
180245181677
if( ctx.zIn ){
180246181678
if( rc==SQLITE_OK ){
180247181679
rc = fts5CInstIterInit(pApi, pFts, iBestCol, &ctx.iter);
180248181680
}
180249181681
180250
- if( (iBestStart+nToken-1)>iBestLast ){
180251
- iBestStart -= (iBestStart+nToken-1-iBestLast) / 2;
180252
- }
180253
- if( iBestStart+nToken>nColSize ){
180254
- iBestStart = nColSize - nToken;
180255
- }
180256
- if( iBestStart<0 ) iBestStart = 0;
180257
-
180258181682
ctx.iRangeStart = iBestStart;
180259181683
ctx.iRangeEnd = iBestStart + nToken - 1;
180260181684
180261181685
if( iBestStart>0 ){
180262181686
fts5HighlightAppend(&rc, &ctx, zEllips, -1);
@@ -180274,19 +181698,19 @@
180274181698
if( ctx.iRangeEnd>=(nColSize-1) ){
180275181699
fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);
180276181700
}else{
180277181701
fts5HighlightAppend(&rc, &ctx, zEllips, -1);
180278181702
}
180279
-
180280
- if( rc==SQLITE_OK ){
180281
- sqlite3_result_text(pCtx, (const char*)ctx.zOut, -1, SQLITE_TRANSIENT);
180282
- }else{
180283
- sqlite3_result_error_code(pCtx, rc);
180284
- }
180285
- sqlite3_free(ctx.zOut);
180286
- }
181703
+ }
181704
+ if( rc==SQLITE_OK ){
181705
+ sqlite3_result_text(pCtx, (const char*)ctx.zOut, -1, SQLITE_TRANSIENT);
181706
+ }else{
181707
+ sqlite3_result_error_code(pCtx, rc);
181708
+ }
181709
+ sqlite3_free(ctx.zOut);
180287181710
sqlite3_free(aSeen);
181711
+ sqlite3_free(sFinder.aFirst);
180288181712
}
180289181713
180290181714
/************************************************************************/
180291181715
180292181716
/*
@@ -194153,11 +195577,11 @@
194153195577
int nArg, /* Number of args */
194154195578
sqlite3_value **apUnused /* Function arguments */
194155195579
){
194156195580
assert( nArg==0 );
194157195581
UNUSED_PARAM2(nArg, apUnused);
194158
- sqlite3_result_text(pCtx, "fts5: 2016-08-20 18:06:14 9041ee4a6f0e8389297f887f1431ab5cfe783390", -1, SQLITE_TRANSIENT);
195582
+ sqlite3_result_text(pCtx, "fts5: 2016-08-08 14:21:10 c3cd543f3380475509d7bab9bb6c7858a8402457", -1, SQLITE_TRANSIENT);
194159195583
}
194160195584
194161195585
static int fts5Init(sqlite3 *db){
194162195586
static const sqlite3_module fts5Mod = {
194163195587
/* iVersion */ 2,
194164195588
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -380,11 +380,11 @@
380 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
381 ** [sqlite_version()] and [sqlite_source_id()].
382 */
383 #define SQLITE_VERSION "3.15.0"
384 #define SQLITE_VERSION_NUMBER 3015000
385 #define SQLITE_SOURCE_ID "2016-08-22 20:10:01 7839519349c7371cdb4e16a215eacd27004cbc62"
386
387 /*
388 ** CAPI3REF: Run-Time Library Version Numbers
389 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
390 **
@@ -9477,16 +9477,16 @@
9477 void **ppOut /* OUT: Buffer containing output changeset */
9478 );
9479
9480
9481 /*
9482 ** Changegroup handle.
9483 */
9484 typedef struct sqlite3_changegroup sqlite3_changegroup;
9485
9486 /*
9487 ** CAPI3REF: Combine two or more changesets into a single changeset.
9488 **
9489 ** An sqlite3_changegroup object is used to combine two or more changesets
9490 ** (or patchsets) into a single changeset (or patchset). A single changegroup
9491 ** object may combine changesets or patchsets, but not both. The output is
9492 ** always in the same format as the input.
@@ -9519,10 +9519,12 @@
9519 ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
9520 */
9521 int sqlite3changegroup_new(sqlite3_changegroup **pp);
9522
9523 /*
 
 
9524 ** Add all changes within the changeset (or patchset) in buffer pData (size
9525 ** nData bytes) to the changegroup.
9526 **
9527 ** If the buffer contains a patchset, then all prior calls to this function
9528 ** on the same changegroup object must also have specified patchsets. Or, if
@@ -9594,10 +9596,12 @@
9594 ** If no error occurs, SQLITE_OK is returned.
9595 */
9596 int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
9597
9598 /*
 
 
9599 ** Obtain a buffer containing a changeset (or patchset) representing the
9600 ** current contents of the changegroup. If the inputs to the changegroup
9601 ** were themselves changesets, the output is a changeset. Or, if the
9602 ** inputs were patchsets, the output is also a patchset.
9603 **
@@ -9622,11 +9626,11 @@
9622 int *pnData, /* OUT: Size of output buffer in bytes */
9623 void **ppData /* OUT: Pointer to output buffer */
9624 );
9625
9626 /*
9627 ** Delete a changegroup object.
9628 */
9629 void sqlite3changegroup_delete(sqlite3_changegroup*);
9630
9631 /*
9632 ** CAPI3REF: Apply A Changeset To A Database
@@ -11425,14 +11429,16 @@
11425 #define TK_AGG_FUNCTION 153
11426 #define TK_AGG_COLUMN 154
11427 #define TK_UMINUS 155
11428 #define TK_UPLUS 156
11429 #define TK_REGISTER 157
11430 #define TK_ASTERISK 158
11431 #define TK_SPAN 159
11432 #define TK_SPACE 160
11433 #define TK_ILLEGAL 161
 
 
11434
11435 /* The token codes above must all fit in 8 bits */
11436 #define TKFLG_MASK 0xff
11437
11438 /* Flags that can be added to a token code when it is not
@@ -12569,17 +12575,17 @@
12569 #define OP_Found 31 /* synopsis: key=r[P3@P4] */
12570 #define OP_SeekRowid 32 /* synopsis: intkey=r[P3] */
12571 #define OP_NotExists 33 /* synopsis: intkey=r[P3] */
12572 #define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
12573 #define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
12574 #define OP_Ne 36 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */
12575 #define OP_Eq 37 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */
12576 #define OP_Gt 38 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */
12577 #define OP_Le 39 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */
12578 #define OP_Lt 40 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */
12579 #define OP_Ge 41 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */
12580 #define OP_Last 42
12581 #define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
12582 #define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
12583 #define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
12584 #define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
12585 #define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -12586,119 +12592,120 @@
12586 #define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
12587 #define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
12588 #define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
12589 #define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
12590 #define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
12591 #define OP_SorterSort 53
12592 #define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12593 #define OP_Sort 55
12594 #define OP_Rewind 56
12595 #define OP_IdxLE 57 /* synopsis: key=r[P3@P4] */
12596 #define OP_IdxGT 58 /* synopsis: key=r[P3@P4] */
12597 #define OP_IdxLT 59 /* synopsis: key=r[P3@P4] */
12598 #define OP_IdxGE 60 /* synopsis: key=r[P3@P4] */
12599 #define OP_RowSetRead 61 /* synopsis: r[P3]=rowset(P1) */
12600 #define OP_RowSetTest 62 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12601 #define OP_Program 63
12602 #define OP_FkIfZero 64 /* synopsis: if fkctr[P1]==0 goto P2 */
12603 #define OP_IfPos 65 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12604 #define OP_IfNotZero 66 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12605 #define OP_DecrJumpZero 67 /* synopsis: if (--r[P1])==0 goto P2 */
12606 #define OP_IncrVacuum 68
12607 #define OP_VNext 69
12608 #define OP_Init 70 /* synopsis: Start at P2 */
12609 #define OP_Return 71
12610 #define OP_EndCoroutine 72
12611 #define OP_HaltIfNull 73 /* synopsis: if r[P3]=null halt */
12612 #define OP_Halt 74
12613 #define OP_Integer 75 /* synopsis: r[P2]=P1 */
12614 #define OP_Int64 76 /* synopsis: r[P2]=P4 */
12615 #define OP_String 77 /* synopsis: r[P2]='P4' (len=P1) */
12616 #define OP_Null 78 /* synopsis: r[P2..P3]=NULL */
12617 #define OP_SoftNull 79 /* synopsis: r[P1]=NULL */
12618 #define OP_Blob 80 /* synopsis: r[P2]=P4 (len=P1) */
12619 #define OP_Variable 81 /* synopsis: r[P2]=parameter(P1,P4) */
12620 #define OP_Move 82 /* synopsis: r[P2@P3]=r[P1@P3] */
12621 #define OP_Copy 83 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12622 #define OP_SCopy 84 /* synopsis: r[P2]=r[P1] */
12623 #define OP_IntCopy 85 /* synopsis: r[P2]=r[P1] */
12624 #define OP_ResultRow 86 /* synopsis: output=r[P1@P2] */
12625 #define OP_CollSeq 87
12626 #define OP_Function0 88 /* synopsis: r[P3]=func(r[P2@P5]) */
12627 #define OP_Function 89 /* synopsis: r[P3]=func(r[P2@P5]) */
12628 #define OP_AddImm 90 /* synopsis: r[P1]=r[P1]+P2 */
12629 #define OP_RealAffinity 91
12630 #define OP_Cast 92 /* synopsis: affinity(r[P1]) */
12631 #define OP_Permutation 93
12632 #define OP_Compare 94 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12633 #define OP_Column 95 /* synopsis: r[P3]=PX */
12634 #define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */
12635 #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12636 #define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12637 #define OP_Count 99 /* synopsis: r[P2]=count() */
12638 #define OP_ReadCookie 100
12639 #define OP_SetCookie 101
12640 #define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
12641 #define OP_OpenRead 103 /* synopsis: root=P2 iDb=P3 */
12642 #define OP_OpenWrite 104 /* synopsis: root=P2 iDb=P3 */
12643 #define OP_OpenAutoindex 105 /* synopsis: nColumn=P2 */
12644 #define OP_OpenEphemeral 106 /* synopsis: nColumn=P2 */
12645 #define OP_SorterOpen 107
12646 #define OP_SequenceTest 108 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12647 #define OP_OpenPseudo 109 /* synopsis: P3 columns in r[P2] */
12648 #define OP_Close 110
12649 #define OP_ColumnsUsed 111
12650 #define OP_Sequence 112 /* synopsis: r[P2]=cursor[P1].ctr++ */
12651 #define OP_NewRowid 113 /* synopsis: r[P2]=rowid */
12652 #define OP_Insert 114 /* synopsis: intkey=r[P3] data=r[P2] */
12653 #define OP_InsertInt 115 /* synopsis: intkey=P3 data=r[P2] */
12654 #define OP_Delete 116
12655 #define OP_ResetCount 117
12656 #define OP_SorterCompare 118 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12657 #define OP_SorterData 119 /* synopsis: r[P2]=data */
12658 #define OP_RowKey 120 /* synopsis: r[P2]=key */
12659 #define OP_RowData 121 /* synopsis: r[P2]=data */
12660 #define OP_Rowid 122 /* synopsis: r[P2]=rowid */
12661 #define OP_NullRow 123
12662 #define OP_SorterInsert 124
12663 #define OP_IdxInsert 125 /* synopsis: key=r[P2] */
12664 #define OP_IdxDelete 126 /* synopsis: key=r[P2@P3] */
12665 #define OP_Seek 127 /* synopsis: Move P3 to P1.rowid */
12666 #define OP_IdxRowid 128 /* synopsis: r[P2]=rowid */
12667 #define OP_Destroy 129
12668 #define OP_Clear 130
12669 #define OP_ResetSorter 131
12670 #define OP_CreateIndex 132 /* synopsis: r[P2]=root iDb=P1 */
12671 #define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12672 #define OP_CreateTable 134 /* synopsis: r[P2]=root iDb=P1 */
12673 #define OP_ParseSchema 135
12674 #define OP_LoadAnalysis 136
12675 #define OP_DropTable 137
12676 #define OP_DropIndex 138
12677 #define OP_DropTrigger 139
12678 #define OP_IntegrityCk 140
12679 #define OP_RowSetAdd 141 /* synopsis: rowset(P1)=r[P2] */
12680 #define OP_Param 142
12681 #define OP_FkCounter 143 /* synopsis: fkctr[P1]+=P2 */
12682 #define OP_MemMax 144 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12683 #define OP_OffsetLimit 145 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12684 #define OP_AggStep0 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12685 #define OP_AggStep 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12686 #define OP_AggFinal 148 /* synopsis: accum=r[P1] N=P2 */
12687 #define OP_Expire 149
12688 #define OP_TableLock 150 /* synopsis: iDb=P1 root=P2 write=P3 */
12689 #define OP_VBegin 151
12690 #define OP_VCreate 152
12691 #define OP_VDestroy 153
12692 #define OP_VOpen 154
12693 #define OP_VColumn 155 /* synopsis: r[P3]=vcolumn(P2) */
12694 #define OP_VRename 156
12695 #define OP_Pagecount 157
12696 #define OP_MaxPgcnt 158
12697 #define OP_CursorHint 159
12698 #define OP_Noop 160
12699 #define OP_Explain 161
 
12700
12701 /* Properties such as "out2" or "jump" that are specified in
12702 ** comments following the "case" for each opcode in the vdbe.c
12703 ** are encoded into bitvectors as follows:
12704 */
@@ -12714,32 +12721,32 @@
12714 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
12715 /* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
12716 /* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
12717 /* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
12718 /* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12719 /* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01,\
12720 /* 64 */ 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02,\
12721 /* 72 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
12722 /* 80 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12723 /* 88 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00,\
12724 /* 96 */ 0x00, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
12725 /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12726 /* 112 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12727 /* 120 */ 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00,\
12728 /* 128 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
12729 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00,\
12730 /* 144 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12731 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
12732 /* 160 */ 0x00, 0x00,}
12733
12734 /* The sqlite3P2Values() routine is able to run faster if it knows
12735 ** the value of the largest JUMP opcode. The smaller the maximum
12736 ** JUMP opcode the better, so the mkopcodeh.tcl script that
12737 ** generated this include file strives to group all JUMP opcodes
12738 ** together near the beginning of the list.
12739 */
12740 #define SQLITE_MX_JUMP_OPCODE 70 /* Maximum JUMP opcode */
12741
12742 /************** End of opcodes.h *********************************************/
12743 /************** Continuing where we left off in vdbe.h ***********************/
12744
12745 /*
@@ -14340,10 +14347,11 @@
14340 ** The SQLITE_NOTNULL flag is a combination of NULLEQ and JUMPIFNULL.
14341 ** It causes an assert() to fire if either operand to a comparison
14342 ** operator is NULL. It is added to certain comparison operators to
14343 ** prove that the operands are always NOT NULL.
14344 */
 
14345 #define SQLITE_JUMPIFNULL 0x10 /* jumps if either operand is NULL */
14346 #define SQLITE_STOREP2 0x20 /* Store result in reg[P2] rather than jump */
14347 #define SQLITE_NULLEQ 0x80 /* NULL=NULL */
14348 #define SQLITE_NOTNULL 0x90 /* Assert that operands are never NULL */
14349
@@ -14904,13 +14912,15 @@
14904 int nHeight; /* Height of the tree headed by this node */
14905 #endif
14906 int iTable; /* TK_COLUMN: cursor number of table holding column
14907 ** TK_REGISTER: register number
14908 ** TK_TRIGGER: 1 -> new, 0 -> old
14909 ** EP_Unlikely: 134217728 times likelihood */
 
14910 ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
14911 ** TK_VARIABLE: variable number (always >= 1). */
 
14912 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
14913 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
14914 u8 op2; /* TK_REGISTER: original value of Expr.op
14915 ** TK_COLUMN: the value of p5 for OP_Column
14916 ** TK_AGG_FUNCTION: nesting depth */
@@ -15387,11 +15397,11 @@
15387 ** An instance of this object describes where to put of the results of
15388 ** a SELECT statement.
15389 */
15390 struct SelectDest {
15391 u8 eDest; /* How to dispose of the results. On of SRT_* above. */
15392 char affSdst; /* Affinity used when eDest==SRT_Set */
15393 int iSDParm; /* A parameter used by the eDest disposal method */
15394 int iSdst; /* Base register where results are written */
15395 int nSdst; /* Number of registers allocated */
15396 ExprList *pOrderBy; /* Key columns for SRT_Queue and SRT_DistQueue */
15397 };
@@ -16119,10 +16129,11 @@
16119 SQLITE_PRIVATE void *sqlite3TestTextToPtr(const char*);
16120 #endif
16121
16122 #if defined(SQLITE_DEBUG)
16123 SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
 
16124 SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
16125 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
16126 SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8);
16127 #endif
16128
@@ -16150,10 +16161,11 @@
16150 SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);
16151 SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*);
16152 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*);
16153 SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
16154 SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
 
16155 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);
16156 SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
16157 SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
16158 SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
16159 SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
@@ -16485,10 +16497,11 @@
16485
16486 SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3*, Index*);
16487 SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int);
16488 SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);
16489 SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
 
16490 SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);
16491 SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8);
16492 SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);
16493 SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
16494 SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
@@ -16550,11 +16563,11 @@
16550 SQLITE_PRIVATE void sqlite3AlterFunctions(void);
16551 SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
16552 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
16553 SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
16554 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);
16555 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
16556 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
16557 SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
16558 SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
16559 SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
16560 SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*);
@@ -16604,17 +16617,25 @@
16604 SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
16605 SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
16606
16607 SQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);
16608 SQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
 
 
 
 
 
 
16609
16610 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
16611 SQLITE_PRIVATE void sqlite3AnalyzeFunctions(void);
16612 SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(Parse*,Index*,UnpackedRecord**,Expr*,u8,int,int*);
 
16613 SQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);
16614 SQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord*);
16615 SQLITE_PRIVATE int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);
 
16616 #endif
16617
16618 /*
16619 ** The interface to the LEMON-generated parser
16620 */
@@ -16763,11 +16784,11 @@
16763 ** Allowed flags for the 3rd parameter to sqlite3FindInIndex().
16764 */
16765 #define IN_INDEX_NOOP_OK 0x0001 /* OK to return IN_INDEX_NOOP */
16766 #define IN_INDEX_MEMBERSHIP 0x0002 /* IN operator used for membership test */
16767 #define IN_INDEX_LOOP 0x0004 /* IN operator used as a loop */
16768 SQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, u32, int*);
16769
16770 SQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
16771 SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *);
16772 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
16773 SQLITE_PRIVATE int sqlite3JournalCreate(sqlite3_file *);
@@ -16868,10 +16889,15 @@
16868
16869 #if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
16870 SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
16871 #endif
16872
 
 
 
 
 
16873 #endif /* SQLITEINT_H */
16874
16875 /************** End of sqliteInt.h *******************************************/
16876 /************** Begin file global.c ******************************************/
16877 /*
@@ -25882,11 +25908,11 @@
25882 }
25883 }
25884
25885
25886 /*
25887 ** Generate a human-readable description of a the Select object.
25888 */
25889 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
25890 int n = 0;
25891 int cnt = 0;
25892 pView = sqlite3TreeViewPush(pView, moreToFollow);
@@ -26212,10 +26238,19 @@
26212 case TK_MATCH: {
26213 sqlite3TreeViewLine(pView, "MATCH {%d:%d}%s",
26214 pExpr->iTable, pExpr->iColumn, zFlgs);
26215 sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
26216 break;
 
 
 
 
 
 
 
 
 
26217 }
26218 default: {
26219 sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
26220 break;
26221 }
@@ -26228,26 +26263,25 @@
26228 sqlite3TreeViewLine(pView, "%s%s", zUniOp, zFlgs);
26229 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
26230 }
26231 sqlite3TreeViewPop(pView);
26232 }
 
26233
26234 /*
26235 ** Generate a human-readable explanation of an expression list.
26236 */
26237 SQLITE_PRIVATE void sqlite3TreeViewExprList(
26238 TreeView *pView,
26239 const ExprList *pList,
26240 u8 moreToFollow,
26241 const char *zLabel
26242 ){
26243 int i;
26244 pView = sqlite3TreeViewPush(pView, moreToFollow);
26245 if( zLabel==0 || zLabel[0]==0 ) zLabel = "LIST";
26246 if( pList==0 ){
26247 sqlite3TreeViewLine(pView, "%s (empty)", zLabel);
26248 }else{
 
26249 sqlite3TreeViewLine(pView, "%s", zLabel);
26250 for(i=0; i<pList->nExpr; i++){
26251 int j = pList->a[i].u.x.iOrderByCol;
26252 if( j ){
26253 sqlite3TreeViewPush(pView, 0);
@@ -26255,10 +26289,19 @@
26255 }
26256 sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);
26257 if( j ) sqlite3TreeViewPop(pView);
26258 }
26259 }
 
 
 
 
 
 
 
 
 
26260 sqlite3TreeViewPop(pView);
26261 }
26262
26263 #endif /* SQLITE_DEBUG */
26264
@@ -29000,17 +29043,17 @@
29000 /* 31 */ "Found" OpHelp("key=r[P3@P4]"),
29001 /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"),
29002 /* 33 */ "NotExists" OpHelp("intkey=r[P3]"),
29003 /* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
29004 /* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
29005 /* 36 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"),
29006 /* 37 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"),
29007 /* 38 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"),
29008 /* 39 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"),
29009 /* 40 */ "Lt" OpHelp("if r[P1]<r[P3] goto P2"),
29010 /* 41 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"),
29011 /* 42 */ "Last" OpHelp(""),
29012 /* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
29013 /* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
29014 /* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
29015 /* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
29016 /* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -29017,119 +29060,120 @@
29017 /* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
29018 /* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
29019 /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
29020 /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
29021 /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
29022 /* 53 */ "SorterSort" OpHelp(""),
29023 /* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
29024 /* 55 */ "Sort" OpHelp(""),
29025 /* 56 */ "Rewind" OpHelp(""),
29026 /* 57 */ "IdxLE" OpHelp("key=r[P3@P4]"),
29027 /* 58 */ "IdxGT" OpHelp("key=r[P3@P4]"),
29028 /* 59 */ "IdxLT" OpHelp("key=r[P3@P4]"),
29029 /* 60 */ "IdxGE" OpHelp("key=r[P3@P4]"),
29030 /* 61 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
29031 /* 62 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
29032 /* 63 */ "Program" OpHelp(""),
29033 /* 64 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
29034 /* 65 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
29035 /* 66 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
29036 /* 67 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
29037 /* 68 */ "IncrVacuum" OpHelp(""),
29038 /* 69 */ "VNext" OpHelp(""),
29039 /* 70 */ "Init" OpHelp("Start at P2"),
29040 /* 71 */ "Return" OpHelp(""),
29041 /* 72 */ "EndCoroutine" OpHelp(""),
29042 /* 73 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
29043 /* 74 */ "Halt" OpHelp(""),
29044 /* 75 */ "Integer" OpHelp("r[P2]=P1"),
29045 /* 76 */ "Int64" OpHelp("r[P2]=P4"),
29046 /* 77 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
29047 /* 78 */ "Null" OpHelp("r[P2..P3]=NULL"),
29048 /* 79 */ "SoftNull" OpHelp("r[P1]=NULL"),
29049 /* 80 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29050 /* 81 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29051 /* 82 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29052 /* 83 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29053 /* 84 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29054 /* 85 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29055 /* 86 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29056 /* 87 */ "CollSeq" OpHelp(""),
29057 /* 88 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29058 /* 89 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29059 /* 90 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29060 /* 91 */ "RealAffinity" OpHelp(""),
29061 /* 92 */ "Cast" OpHelp("affinity(r[P1])"),
29062 /* 93 */ "Permutation" OpHelp(""),
29063 /* 94 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29064 /* 95 */ "Column" OpHelp("r[P3]=PX"),
29065 /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
29066 /* 97 */ "String8" OpHelp("r[P2]='P4'"),
29067 /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29068 /* 99 */ "Count" OpHelp("r[P2]=count()"),
29069 /* 100 */ "ReadCookie" OpHelp(""),
29070 /* 101 */ "SetCookie" OpHelp(""),
29071 /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29072 /* 103 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29073 /* 104 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29074 /* 105 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29075 /* 106 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29076 /* 107 */ "SorterOpen" OpHelp(""),
29077 /* 108 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29078 /* 109 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29079 /* 110 */ "Close" OpHelp(""),
29080 /* 111 */ "ColumnsUsed" OpHelp(""),
29081 /* 112 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29082 /* 113 */ "NewRowid" OpHelp("r[P2]=rowid"),
29083 /* 114 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29084 /* 115 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29085 /* 116 */ "Delete" OpHelp(""),
29086 /* 117 */ "ResetCount" OpHelp(""),
29087 /* 118 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29088 /* 119 */ "SorterData" OpHelp("r[P2]=data"),
29089 /* 120 */ "RowKey" OpHelp("r[P2]=key"),
29090 /* 121 */ "RowData" OpHelp("r[P2]=data"),
29091 /* 122 */ "Rowid" OpHelp("r[P2]=rowid"),
29092 /* 123 */ "NullRow" OpHelp(""),
29093 /* 124 */ "SorterInsert" OpHelp(""),
29094 /* 125 */ "IdxInsert" OpHelp("key=r[P2]"),
29095 /* 126 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29096 /* 127 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29097 /* 128 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29098 /* 129 */ "Destroy" OpHelp(""),
29099 /* 130 */ "Clear" OpHelp(""),
29100 /* 131 */ "ResetSorter" OpHelp(""),
29101 /* 132 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
29102 /* 133 */ "Real" OpHelp("r[P2]=P4"),
29103 /* 134 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29104 /* 135 */ "ParseSchema" OpHelp(""),
29105 /* 136 */ "LoadAnalysis" OpHelp(""),
29106 /* 137 */ "DropTable" OpHelp(""),
29107 /* 138 */ "DropIndex" OpHelp(""),
29108 /* 139 */ "DropTrigger" OpHelp(""),
29109 /* 140 */ "IntegrityCk" OpHelp(""),
29110 /* 141 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29111 /* 142 */ "Param" OpHelp(""),
29112 /* 143 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29113 /* 144 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29114 /* 145 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29115 /* 146 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29116 /* 147 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29117 /* 148 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29118 /* 149 */ "Expire" OpHelp(""),
29119 /* 150 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29120 /* 151 */ "VBegin" OpHelp(""),
29121 /* 152 */ "VCreate" OpHelp(""),
29122 /* 153 */ "VDestroy" OpHelp(""),
29123 /* 154 */ "VOpen" OpHelp(""),
29124 /* 155 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29125 /* 156 */ "VRename" OpHelp(""),
29126 /* 157 */ "Pagecount" OpHelp(""),
29127 /* 158 */ "MaxPgcnt" OpHelp(""),
29128 /* 159 */ "CursorHint" OpHelp(""),
29129 /* 160 */ "Noop" OpHelp(""),
29130 /* 161 */ "Explain" OpHelp(""),
 
29131 };
29132 return azName[i];
29133 }
29134 #endif
29135
@@ -52964,11 +53008,15 @@
52964 ** This function may return SQLITE_NOMEM if a memory allocation fails,
52965 ** or an IO error code if an IO error occurs while rolling back a
52966 ** savepoint. If no errors occur, SQLITE_OK is returned.
52967 */
52968 SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
52969 int rc = pPager->errCode; /* Return code */
 
 
 
 
52970
52971 assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
52972 assert( iSavepoint>=0 || op==SAVEPOINT_ROLLBACK );
52973
52974 if( rc==SQLITE_OK && iSavepoint<pPager->nSavepoint ){
@@ -53005,10 +53053,24 @@
53005 else if( pagerUseWal(pPager) || isOpen(pPager->jfd) ){
53006 PagerSavepoint *pSavepoint = (nNew==0)?0:&pPager->aSavepoint[nNew-1];
53007 rc = pagerPlaybackSavepoint(pPager, pSavepoint);
53008 assert(rc!=SQLITE_DONE);
53009 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53010 }
53011
53012 return rc;
53013 }
53014
@@ -68078,11 +68140,10 @@
68078 p->pSrcDb = pSrcDb;
68079 p->iNext = 1;
68080 p->isAttached = 0;
68081
68082 if( 0==p->pSrc || 0==p->pDest
68083 || setDestPgsz(p)==SQLITE_NOMEM
68084 || checkReadTransaction(pDestDb, p->pDest)!=SQLITE_OK
68085 ){
68086 /* One (or both) of the named databases did not exist or an OOM
68087 ** error was hit. Or there is a transaction open on the destination
68088 ** database. The error has already been written into the pDestDb
@@ -68266,26 +68327,36 @@
68266 rc = SQLITE_BUSY;
68267 }else{
68268 rc = SQLITE_OK;
68269 }
68270
68271 /* Lock the destination database, if it is not locked already. */
68272 if( SQLITE_OK==rc && p->bDestLocked==0
68273 && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2))
68274 ){
68275 p->bDestLocked = 1;
68276 sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);
68277 }
68278
68279 /* If there is no open read-transaction on the source database, open
68280 ** one now. If a transaction is opened here, then it will be closed
68281 ** before this function exits.
68282 */
68283 if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){
68284 rc = sqlite3BtreeBeginTrans(p->pSrc, 0);
68285 bCloseTrans = 1;
68286 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68287
68288 /* Do not allow backup if the destination database is in WAL mode
68289 ** and the page sizes are different between source and destination */
68290 pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);
68291 pgszDest = sqlite3BtreeGetPageSize(p->pDest);
@@ -70202,25 +70273,29 @@
70202 /*
70203 ** This function is used to allocate and populate UnpackedRecord
70204 ** structures intended to be compared against sample index keys stored
70205 ** in the sqlite_stat4 table.
70206 **
70207 ** A single call to this function attempts to populates field iVal (leftmost
70208 ** is 0 etc.) of the unpacked record with a value extracted from expression
70209 ** pExpr. Extraction of values is possible if:
70210 **
70211 ** * (pExpr==0). In this case the value is assumed to be an SQL NULL,
70212 **
70213 ** * The expression is a bound variable, and this is a reprepare, or
70214 **
70215 ** * The sqlite3ValueFromExpr() function is able to extract a value
70216 ** from the expression (i.e. the expression is a literal value).
70217 **
70218 ** If a value can be extracted, the affinity passed as the 5th argument
70219 ** is applied to it before it is copied into the UnpackedRecord. Output
70220 ** parameter *pbOk is set to true if a value is extracted, or false
70221 ** otherwise.
 
 
 
 
70222 **
70223 ** When this function is called, *ppRec must either point to an object
70224 ** allocated by an earlier call to this function, or must be NULL. If it
70225 ** is NULL and a value can be successfully extracted, a new UnpackedRecord
70226 ** is allocated (and *ppRec set to point to it) before returning.
@@ -70232,26 +70307,37 @@
70232 SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(
70233 Parse *pParse, /* Parse context */
70234 Index *pIdx, /* Index being probed */
70235 UnpackedRecord **ppRec, /* IN/OUT: Probe record */
70236 Expr *pExpr, /* The expression to extract a value from */
70237 u8 affinity, /* Affinity to use */
70238 int iVal, /* Array element to populate */
70239 int *pbOk /* OUT: True if value was extracted */
70240 ){
70241 int rc;
70242 sqlite3_value *pVal = 0;
70243 struct ValueNewStat4Ctx alloc;
70244
70245 alloc.pParse = pParse;
70246 alloc.pIdx = pIdx;
70247 alloc.ppRec = ppRec;
70248 alloc.iVal = iVal;
70249
70250 rc = stat4ValueFromExpr(pParse, pExpr, affinity, &alloc, &pVal);
70251 assert( pVal==0 || pVal->db==pParse->db );
70252 *pbOk = (pVal!=0);
 
 
 
 
 
 
 
 
 
 
 
70253 return rc;
70254 }
70255
70256 /*
70257 ** Attempt to extract a value from expression pExpr using the methods
@@ -71483,16 +71569,25 @@
71483 ){
71484 const char *zOpName;
71485 const char *zSynopsis;
71486 int nOpName;
71487 int ii, jj;
 
71488 zOpName = sqlite3OpcodeName(pOp->opcode);
71489 nOpName = sqlite3Strlen30(zOpName);
71490 if( zOpName[nOpName+1] ){
71491 int seenCom = 0;
71492 char c;
71493 zSynopsis = zOpName += nOpName + 1;
 
 
 
 
 
 
 
 
71494 for(ii=jj=0; jj<nTemp-1 && (c = zSynopsis[ii])!=0; ii++){
71495 if( c=='P' ){
71496 c = zSynopsis[++ii];
71497 if( c=='4' ){
71498 sqlite3_snprintf(nTemp-jj, zTemp+jj, "%s", zP4);
@@ -77732,11 +77827,11 @@
77732 #endif
77733 int rc = SQLITE_OK; /* Value to return */
77734 sqlite3 *db = p->db; /* The database */
77735 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
77736 u8 encoding = ENC(db); /* The database encoding */
77737 int iCompare = 0; /* Result of last OP_Compare operation */
77738 unsigned nVmStep = 0; /* Number of virtual machine steps */
77739 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
77740 unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
77741 #endif
77742 Mem *aMem = p->aMem; /* Copy of p->aMem */
@@ -78064,11 +78159,11 @@
78064 pOp = &aOp[pcDest];
78065 break;
78066 }
78067
78068 /* Opcode: HaltIfNull P1 P2 P3 P4 P5
78069 ** Synopsis: if r[P3]=null halt
78070 **
78071 ** Check the value in register P3. If it is NULL then Halt using
78072 ** parameter P1, P2, and P4 as if this were a Halt instruction. If the
78073 ** value in register P3 is not NULL, then this routine is a no-op.
78074 ** The P5 parameter should be 1.
@@ -78277,11 +78372,11 @@
78277 #endif
78278 break;
78279 }
78280
78281 /* Opcode: Null P1 P2 P3 * *
78282 ** Synopsis: r[P2..P3]=NULL
78283 **
78284 ** Write a NULL into registers P2. If P3 greater than P2, then also write
78285 ** NULL into register P3 and every register in between P2 and P3. If P3
78286 ** is less than P2 (typically P3 is zero) then only register P2 is
78287 ** set to NULL.
@@ -78306,11 +78401,11 @@
78306 }
78307 break;
78308 }
78309
78310 /* Opcode: SoftNull P1 * * * *
78311 ** Synopsis: r[P1]=NULL
78312 **
78313 ** Set register P1 to have the value NULL as seen by the OP_MakeRecord
78314 ** instruction, but do not free any string or blob memory associated with
78315 ** the register, so that if the value was a string or blob that was
78316 ** previously copied using OP_SCopy, the copies will continue to be valid.
@@ -78359,11 +78454,11 @@
78359 UPDATE_MAX_BLOBSIZE(pOut);
78360 break;
78361 }
78362
78363 /* Opcode: Move P1 P2 P3 * *
78364 ** Synopsis: r[P2@P3]=r[P1@P3]
78365 **
78366 ** Move the P3 values in register P1..P1+P3-1 over into
78367 ** registers P2..P2+P3-1. Registers P1..P1+P3-1 are
78368 ** left holding a NULL. It is an error for register ranges
78369 ** P1..P1+P3-1 and P2..P2+P3-1 to overlap. It is an error
@@ -78469,11 +78564,11 @@
78469 sqlite3VdbeMemSetInt64(pOut, pIn1->u.i);
78470 break;
78471 }
78472
78473 /* Opcode: ResultRow P1 P2 * * *
78474 ** Synopsis: output=r[P1@P2]
78475 **
78476 ** The registers P1 through P1+P2-1 contain a single row of
78477 ** results. This opcode causes the sqlite3_step() call to terminate
78478 ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt
78479 ** structure to provide access to the r(P1)..r(P1+P2-1) values as
@@ -78602,41 +78697,41 @@
78602 UPDATE_MAX_BLOBSIZE(pOut);
78603 break;
78604 }
78605
78606 /* Opcode: Add P1 P2 P3 * *
78607 ** Synopsis: r[P3]=r[P1]+r[P2]
78608 **
78609 ** Add the value in register P1 to the value in register P2
78610 ** and store the result in register P3.
78611 ** If either input is NULL, the result is NULL.
78612 */
78613 /* Opcode: Multiply P1 P2 P3 * *
78614 ** Synopsis: r[P3]=r[P1]*r[P2]
78615 **
78616 **
78617 ** Multiply the value in register P1 by the value in register P2
78618 ** and store the result in register P3.
78619 ** If either input is NULL, the result is NULL.
78620 */
78621 /* Opcode: Subtract P1 P2 P3 * *
78622 ** Synopsis: r[P3]=r[P2]-r[P1]
78623 **
78624 ** Subtract the value in register P1 from the value in register P2
78625 ** and store the result in register P3.
78626 ** If either input is NULL, the result is NULL.
78627 */
78628 /* Opcode: Divide P1 P2 P3 * *
78629 ** Synopsis: r[P3]=r[P2]/r[P1]
78630 **
78631 ** Divide the value in register P1 by the value in register P2
78632 ** and store the result in register P3 (P3=P2/P1). If the value in
78633 ** register P1 is zero, then the result is NULL. If either input is
78634 ** NULL, the result is NULL.
78635 */
78636 /* Opcode: Remainder P1 P2 P3 * *
78637 ** Synopsis: r[P3]=r[P2]%r[P1]
78638 **
78639 ** Compute the remainder after integer register P2 is divided by
78640 ** register P1 and store the result in register P3.
78641 ** If the value in register P1 is zero the result is NULL.
78642 ** If either operand is NULL, the result is NULL.
@@ -78865,33 +78960,33 @@
78865 UPDATE_MAX_BLOBSIZE(pCtx->pOut);
78866 break;
78867 }
78868
78869 /* Opcode: BitAnd P1 P2 P3 * *
78870 ** Synopsis: r[P3]=r[P1]&r[P2]
78871 **
78872 ** Take the bit-wise AND of the values in register P1 and P2 and
78873 ** store the result in register P3.
78874 ** If either input is NULL, the result is NULL.
78875 */
78876 /* Opcode: BitOr P1 P2 P3 * *
78877 ** Synopsis: r[P3]=r[P1]|r[P2]
78878 **
78879 ** Take the bit-wise OR of the values in register P1 and P2 and
78880 ** store the result in register P3.
78881 ** If either input is NULL, the result is NULL.
78882 */
78883 /* Opcode: ShiftLeft P1 P2 P3 * *
78884 ** Synopsis: r[P3]=r[P2]<<r[P1]
78885 **
78886 ** Shift the integer value in register P2 to the left by the
78887 ** number of bits specified by the integer in register P1.
78888 ** Store the result in register P3.
78889 ** If either input is NULL, the result is NULL.
78890 */
78891 /* Opcode: ShiftRight P1 P2 P3 * *
78892 ** Synopsis: r[P3]=r[P2]>>r[P1]
78893 **
78894 ** Shift the integer value in register P2 to the right by the
78895 ** number of bits specified by the integer in register P1.
78896 ** Store the result in register P3.
78897 ** If either input is NULL, the result is NULL.
@@ -78947,11 +79042,11 @@
78947 MemSetTypeFlag(pOut, MEM_Int);
78948 break;
78949 }
78950
78951 /* Opcode: AddImm P1 P2 * * *
78952 ** Synopsis: r[P1]=r[P1]+P2
78953 **
78954 ** Add the constant P2 to the value in register P1.
78955 ** The result is always an integer.
78956 **
78957 ** To force any register to be an integer, just add 0.
@@ -79039,18 +79134,65 @@
79039 if( rc ) goto abort_due_to_error;
79040 break;
79041 }
79042 #endif /* SQLITE_OMIT_CAST */
79043
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79044 /* Opcode: Lt P1 P2 P3 P4 P5
79045 ** Synopsis: if r[P1]<r[P3] goto P2
79046 **
79047 ** Compare the values in register P1 and P3. If reg(P3)<reg(P1) then
79048 ** jump to address P2.
 
79049 **
79050 ** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or
79051 ** reg(P3) is NULL then take the jump. If the SQLITE_JUMPIFNULL
79052 ** bit is clear then fall through if either operand is NULL.
79053 **
79054 ** The SQLITE_AFF_MASK portion of P5 must be an affinity character -
79055 ** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made
79056 ** to coerce both inputs according to this affinity before the
@@ -79066,60 +79208,27 @@
79066 ** P4 is used to do the comparison. If P4 is not specified then
79067 ** memcmp() is used to compare text string. If both values are
79068 ** numeric, then a numeric comparison is used. If the two values
79069 ** are of different types, then numbers are considered less than
79070 ** strings and strings are considered less than blobs.
79071 **
79072 ** If the SQLITE_STOREP2 bit of P5 is set, then do not jump. Instead,
79073 ** store a boolean result (either 0, or 1, or NULL) in register P2.
79074 **
79075 ** If the SQLITE_NULLEQ bit is set in P5, then NULL values are considered
79076 ** equal to one another, provided that they do not have their MEM_Cleared
79077 ** bit set.
79078 */
79079 /* Opcode: Ne P1 P2 P3 P4 P5
79080 ** Synopsis: if r[P1]!=r[P3] goto P2
79081 **
79082 ** This works just like the Lt opcode except that the jump is taken if
79083 ** the operands in registers P1 and P3 are not equal. See the Lt opcode for
79084 ** additional information.
79085 **
79086 ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
79087 ** true or false and is never NULL. If both operands are NULL then the result
79088 ** of comparison is false. If either operand is NULL then the result is true.
79089 ** If neither operand is NULL the result is the same as it would be if
79090 ** the SQLITE_NULLEQ flag were omitted from P5.
79091 */
79092 /* Opcode: Eq P1 P2 P3 P4 P5
79093 ** Synopsis: if r[P1]==r[P3] goto P2
79094 **
79095 ** This works just like the Lt opcode except that the jump is taken if
79096 ** the operands in registers P1 and P3 are equal.
79097 ** See the Lt opcode for additional information.
79098 **
79099 ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
79100 ** true or false and is never NULL. If both operands are NULL then the result
79101 ** of comparison is true. If either operand is NULL then the result is false.
79102 ** If neither operand is NULL the result is the same as it would be if
79103 ** the SQLITE_NULLEQ flag were omitted from P5.
79104 */
79105 /* Opcode: Le P1 P2 P3 P4 P5
79106 ** Synopsis: if r[P1]<=r[P3] goto P2
79107 **
79108 ** This works just like the Lt opcode except that the jump is taken if
79109 ** the content of register P3 is less than or equal to the content of
79110 ** register P1. See the Lt opcode for additional information.
79111 */
79112 /* Opcode: Gt P1 P2 P3 P4 P5
79113 ** Synopsis: if r[P1]>r[P3] goto P2
79114 **
79115 ** This works just like the Lt opcode except that the jump is taken if
79116 ** the content of register P3 is greater than the content of
79117 ** register P1. See the Lt opcode for additional information.
79118 */
79119 /* Opcode: Ge P1 P2 P3 P4 P5
79120 ** Synopsis: if r[P1]>=r[P3] goto P2
79121 **
79122 ** This works just like the Lt opcode except that the jump is taken if
79123 ** the content of register P3 is greater than or equal to the content of
79124 ** register P1. See the Lt opcode for additional information.
79125 */
@@ -79127,11 +79236,11 @@
79127 case OP_Ne: /* same as TK_NE, jump, in1, in3 */
79128 case OP_Lt: /* same as TK_LT, jump, in1, in3 */
79129 case OP_Le: /* same as TK_LE, jump, in1, in3 */
79130 case OP_Gt: /* same as TK_GT, jump, in1, in3 */
79131 case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
79132 int res; /* Result of the comparison of pIn1 against pIn3 */
79133 char affinity; /* Affinity to use for comparison */
79134 u16 flags1; /* Copy of initial value of pIn1->flags */
79135 u16 flags3; /* Copy of initial value of pIn3->flags */
79136
79137 pIn1 = &aMem[pOp->p1];
@@ -79150,21 +79259,22 @@
79150 assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 );
79151 if( (flags1&MEM_Null)!=0
79152 && (flags3&MEM_Null)!=0
79153 && (flags3&MEM_Cleared)==0
79154 ){
79155 res = 0; /* Results are equal */
79156 }else{
79157 res = 1; /* Results are not equal */
79158 }
79159 }else{
79160 /* SQLITE_NULLEQ is clear and at least one operand is NULL,
79161 ** then the result is always NULL.
79162 ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
79163 */
79164 if( pOp->p5 & SQLITE_STOREP2 ){
79165 pOut = &aMem[pOp->p2];
 
79166 memAboutToChange(p, pOut);
79167 MemSetTypeFlag(pOut, MEM_Null);
79168 REGISTER_TRACE(pOp->p2, pOut);
79169 }else{
79170 VdbeBranchTaken(2,3);
@@ -79214,16 +79324,16 @@
79214 flags3 &= ~MEM_Zero;
79215 }
79216 res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
79217 }
79218 switch( pOp->opcode ){
79219 case OP_Eq: res = res==0; break;
79220 case OP_Ne: res = res!=0; break;
79221 case OP_Lt: res = res<0; break;
79222 case OP_Le: res = res<=0; break;
79223 case OP_Gt: res = res>0; break;
79224 default: res = res>=0; break;
79225 }
79226
79227 /* Undo any changes made by applyAffinity() to the input registers. */
79228 assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
79229 pIn1->flags = flags1;
@@ -79230,22 +79340,58 @@
79230 assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );
79231 pIn3->flags = flags3;
79232
79233 if( pOp->p5 & SQLITE_STOREP2 ){
79234 pOut = &aMem[pOp->p2];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79235 memAboutToChange(p, pOut);
79236 MemSetTypeFlag(pOut, MEM_Int);
79237 pOut->u.i = res;
79238 REGISTER_TRACE(pOp->p2, pOut);
79239 }else{
79240 VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
79241 if( res ){
79242 goto jump_to_p2;
79243 }
79244 }
79245 break;
79246 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79247
79248 /* Opcode: Permutation * * * P4 *
79249 **
79250 ** Set the permutation used by the OP_Compare operator to be the array
79251 ** of integers in P4.
@@ -79492,11 +79638,11 @@
79492 }
79493 break;
79494 }
79495
79496 /* Opcode: IsNull P1 P2 * * *
79497 ** Synopsis: if r[P1]==NULL goto P2
79498 **
79499 ** Jump to P2 if the value in register P1 is NULL.
79500 */
79501 case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */
79502 pIn1 = &aMem[pOp->p1];
@@ -79520,11 +79666,11 @@
79520 }
79521 break;
79522 }
79523
79524 /* Opcode: Column P1 P2 P3 P4 P5
79525 ** Synopsis: r[P3]=PX
79526 **
79527 ** Interpret the data that cursor P1 points to as a structure built using
79528 ** the MakeRecord instruction. (See the MakeRecord opcode for additional
79529 ** information about the format of the data.) Extract the P2-th column
79530 ** from this record. If there are less that (P2+1)
@@ -81030,11 +81176,10 @@
81030 assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
81031 pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */
81032 }
81033 break;
81034 }
81035
81036
81037 /* Opcode: Found P1 P2 P3 P4 *
81038 ** Synopsis: key=r[P3@P4]
81039 **
81040 ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If
@@ -81463,11 +81608,11 @@
81463 **
81464 ** This instruction only works on tables. The equivalent instruction
81465 ** for indices is OP_IdxInsert.
81466 */
81467 /* Opcode: InsertInt P1 P2 P3 P4 P5
81468 ** Synopsis: intkey=P3 data=r[P2]
81469 **
81470 ** This works exactly like OP_Insert except that the key is the
81471 ** integer value P3, not the value of the integer stored in register P3.
81472 */
81473 case OP_Insert:
@@ -81694,11 +81839,11 @@
81694 p->nChange = 0;
81695 break;
81696 }
81697
81698 /* Opcode: SorterCompare P1 P2 P3 P4
81699 ** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2
81700 **
81701 ** P1 is a sorter cursor. This instruction compares a prefix of the
81702 ** record blob in register P3 against a prefix of the entry that
81703 ** the sorter cursor currently points to. Only the first P4 fields
81704 ** of r[P3] and the sorter record are compared.
@@ -82221,11 +82366,11 @@
82221 pC->cacheStatus = CACHE_STALE;
82222 break;
82223 }
82224
82225 /* Opcode: Seek P1 * P3 P4 *
82226 ** Synopsis: Move P3 to P1.rowid
82227 **
82228 ** P1 is an open index cursor and P3 is a cursor on the corresponding
82229 ** table. This opcode does a deferred seek of the P3 table cursor
82230 ** to the row that corresponds to the current row of P1.
82231 **
@@ -82728,11 +82873,11 @@
82728 break;
82729 }
82730 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
82731
82732 /* Opcode: RowSetAdd P1 P2 * * *
82733 ** Synopsis: rowset(P1)=r[P2]
82734 **
82735 ** Insert the integer value held by register P2 into a boolean index
82736 ** held in register P1.
82737 **
82738 ** An assertion fails if P2 is not an integer.
@@ -82748,11 +82893,11 @@
82748 sqlite3RowSetInsert(pIn1->u.pRowSet, pIn2->u.i);
82749 break;
82750 }
82751
82752 /* Opcode: RowSetRead P1 P2 P3 * *
82753 ** Synopsis: r[P3]=rowset(P1)
82754 **
82755 ** Extract the smallest value from boolean index P1 and put that value into
82756 ** register P3. Or, if boolean index P1 is initially empty, leave P3
82757 ** unchanged and jump to instruction P2.
82758 */
@@ -83927,11 +84072,11 @@
83927 }
83928 #endif
83929
83930
83931 /* Opcode: Init * P2 * P4 *
83932 ** Synopsis: Start at P2
83933 **
83934 ** Programs contain a single instance of this opcode as the very first
83935 ** opcode.
83936 **
83937 ** If tracing is enabled (by the sqlite3_trace()) interface, then
@@ -83987,12 +84132,12 @@
83987 ){
83988 sqlite3DebugPrintf("SQL-trace: %s\n", zTrace);
83989 }
83990 #endif /* SQLITE_DEBUG */
83991 #endif /* SQLITE_OMIT_TRACE */
83992 if( pOp->p2 ) goto jump_to_p2;
83993 break;
83994 }
83995
83996 #ifdef SQLITE_ENABLE_CURSOR_HINTS
83997 /* Opcode: CursorHint P1 * * P4 *
83998 **
@@ -88760,10 +88905,37 @@
88760 }
88761 case TK_VARIABLE: {
88762 notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
88763 break;
88764 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88765 }
88766 return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
88767 }
88768
88769 /*
@@ -89501,10 +89673,22 @@
89501 *************************************************************************
89502 ** This file contains routines used for analyzing expressions and
89503 ** for generating VDBE code that evaluates expressions in SQLite.
89504 */
89505 /* #include "sqliteInt.h" */
 
 
 
 
 
 
 
 
 
 
 
 
89506
89507 /*
89508 ** Return the 'affinity' of the expression pExpr if any.
89509 **
89510 ** If pExpr is a column, a reference to a column via an 'AS' alias,
@@ -89527,25 +89711,25 @@
89527 op = pExpr->op;
89528 if( op==TK_SELECT ){
89529 assert( pExpr->flags&EP_xIsSelect );
89530 return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
89531 }
 
89532 #ifndef SQLITE_OMIT_CAST
89533 if( op==TK_CAST ){
89534 assert( !ExprHasProperty(pExpr, EP_IntValue) );
89535 return sqlite3AffinityType(pExpr->u.zToken, 0);
89536 }
89537 #endif
89538 if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_REGISTER)
89539 && pExpr->pTab!=0
89540 ){
89541 /* op==TK_REGISTER && pExpr->pTab!=0 happens when pExpr was originally
89542 ** a TK_COLUMN but was previously evaluated and cached in a register */
89543 int j = pExpr->iColumn;
89544 if( j<0 ) return SQLITE_AFF_INTEGER;
89545 assert( pExpr->pTab && j<pExpr->pTab->nCol );
89546 return pExpr->pTab->aCol[j].affinity;
89547 }
89548 return pExpr->affinity;
89549 }
89550
89551 /*
@@ -89707,11 +89891,11 @@
89707 aff = sqlite3ExprAffinity(pExpr->pLeft);
89708 if( pExpr->pRight ){
89709 aff = sqlite3CompareAffinity(pExpr->pRight, aff);
89710 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
89711 aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);
89712 }else if( !aff ){
89713 aff = SQLITE_AFF_BLOB;
89714 }
89715 return aff;
89716 }
89717
@@ -89796,10 +89980,274 @@
89796 addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
89797 (void*)p4, P4_COLLSEQ);
89798 sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
89799 return addr;
89800 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89801
89802 #if SQLITE_MAX_EXPR_DEPTH>0
89803 /*
89804 ** Check that argument nHeight is less than or equal to the maximum
89805 ** expression depth allowed. If it is not, leave an error message in
@@ -90231,11 +90679,11 @@
90231 /* Sanity check: Assert that the IntValue is non-negative if it exists */
90232 assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );
90233 if( !ExprHasProperty(p, EP_TokenOnly) ){
90234 /* The Expr.x union is never used at the same time as Expr.pRight */
90235 assert( p->x.pList==0 || p->pRight==0 );
90236 sqlite3ExprDelete(db, p->pLeft);
90237 sqlite3ExprDelete(db, p->pRight);
90238 if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
90239 if( ExprHasProperty(p, EP_xIsSelect) ){
90240 sqlite3SelectDelete(db, p->x.pSelect);
90241 }else{
@@ -90439,11 +90887,15 @@
90439 if( pzBuffer ){
90440 *pzBuffer = zAlloc;
90441 }
90442 }else{
90443 if( !ExprHasProperty(p, EP_TokenOnly) ){
90444 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
 
 
 
 
90445 pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
90446 }
90447 }
90448 }
90449 return pNew;
@@ -90679,10 +91131,64 @@
90679 /* Avoid leaking memory if malloc has failed. */
90680 sqlite3ExprDelete(db, pExpr);
90681 sqlite3ExprListDelete(db, pList);
90682 return 0;
90683 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90684
90685 /*
90686 ** Set the sort order for the last element on the given ExprList.
90687 */
90688 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder){
@@ -91087,12 +91593,12 @@
91087 #ifndef SQLITE_OMIT_SUBQUERY
91088 static Select *isCandidateForInOpt(Expr *pX){
91089 Select *p;
91090 SrcList *pSrc;
91091 ExprList *pEList;
91092 Expr *pRes;
91093 Table *pTab;
 
91094 if( !ExprHasProperty(pX, EP_xIsSelect) ) return 0; /* Not a subquery */
91095 if( ExprHasProperty(pX, EP_VarSelect) ) return 0; /* Correlated subq */
91096 p = pX->x.pSelect;
91097 if( p->pPrior ) return 0; /* Not a compound SELECT */
91098 if( p->selFlags & (SF_Distinct|SF_Aggregate) ){
@@ -91111,14 +91617,17 @@
91111 pTab = pSrc->a[0].pTab;
91112 assert( pTab!=0 );
91113 assert( pTab->pSelect==0 ); /* FROM clause is not a view */
91114 if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */
91115 pEList = p->pEList;
91116 if( pEList->nExpr!=1 ) return 0; /* One column in the result set */
91117 pRes = pEList->a[0].pExpr;
91118 if( pRes->op!=TK_COLUMN ) return 0; /* Result is a column */
91119 assert( pRes->iTable==pSrc->a[0].iCursor ); /* Not a correlated subquery */
 
 
 
91120 return p;
91121 }
91122 #endif /* SQLITE_OMIT_SUBQUERY */
91123
91124 /*
@@ -91128,10 +91637,11 @@
91128 SQLITE_PRIVATE int sqlite3CodeOnce(Parse *pParse){
91129 Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */
91130 return sqlite3VdbeAddOp1(v, OP_Once, pParse->nOnce++);
91131 }
91132
 
91133 /*
91134 ** Generate code that checks the left-most column of index table iCur to see if
91135 ** it contains any NULL entries. Cause the register at regHasNull to be set
91136 ** to a non-NULL value if iCur contains no NULLs. Cause register regHasNull
91137 ** to be set to NULL if iCur contains one or more NULL values.
@@ -91143,10 +91653,11 @@
91143 sqlite3VdbeAddOp3(v, OP_Column, iCur, 0, regHasNull);
91144 sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
91145 VdbeComment((v, "first_entry_in(%d)", iCur));
91146 sqlite3VdbeJumpHere(v, addr1);
91147 }
 
91148
91149
91150 #ifndef SQLITE_OMIT_SUBQUERY
91151 /*
91152 ** The argument is an IN operator with a list (not a subquery) on the
@@ -91187,11 +91698,11 @@
91187 ** implemented as a sequence of comparisons.
91188 **
91189 ** An existing b-tree might be used if the RHS expression pX is a simple
91190 ** subquery such as:
91191 **
91192 ** SELECT <column> FROM <table>
91193 **
91194 ** If the RHS of the IN operator is a list or a more complex subquery, then
91195 ** an ephemeral table might need to be generated from the RHS and then
91196 ** pX->iTable made to point to the ephemeral table instead of an
91197 ** existing table.
@@ -91203,18 +91714,18 @@
91203 ** IN index will be used to loop over all values of the RHS of the
91204 ** IN operator.
91205 **
91206 ** When IN_INDEX_LOOP is used (and the b-tree will be used to iterate
91207 ** through the set members) then the b-tree must not contain duplicates.
91208 ** An epheremal table must be used unless the selected <column> is guaranteed
91209 ** to be unique - either because it is an INTEGER PRIMARY KEY or it
91210 ** has a UNIQUE constraint or UNIQUE index.
91211 **
91212 ** When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used
91213 ** for fast set membership tests) then an epheremal table must
91214 ** be used unless <column> is an INTEGER PRIMARY KEY or an index can
91215 ** be found with <column> as its left-most column.
91216 **
91217 ** If the IN_INDEX_NOOP_OK and IN_INDEX_MEMBERSHIP are both set and
91218 ** if the RHS of the IN operator is a list (not a subquery) then this
91219 ** routine might decide that creating an ephemeral b-tree for membership
91220 ** testing is too expensive and return IN_INDEX_NOOP. In that case, the
@@ -91231,98 +91742,190 @@
91231 **
91232 ** If a register is allocated and its location stored in *prRhsHasNull, then
91233 ** the value in that register will be NULL if the b-tree contains one or more
91234 ** NULL values, and it will be some non-NULL value if the b-tree contains no
91235 ** NULL values.
 
 
 
 
 
 
 
 
 
 
 
91236 */
91237 #ifndef SQLITE_OMIT_SUBQUERY
91238 SQLITE_PRIVATE int sqlite3FindInIndex(Parse *pParse, Expr *pX, u32 inFlags, int *prRhsHasNull){
 
 
 
 
 
 
91239 Select *p; /* SELECT to the right of IN operator */
91240 int eType = 0; /* Type of RHS table. IN_INDEX_* */
91241 int iTab = pParse->nTab++; /* Cursor of the RHS table */
91242 int mustBeUnique; /* True if RHS must be unique */
91243 Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */
91244
91245 assert( pX->op==TK_IN );
91246 mustBeUnique = (inFlags & IN_INDEX_LOOP)!=0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91247
91248 /* Check to see if an existing table or index can be used to
91249 ** satisfy the query. This is preferable to generating a new
91250 ** ephemeral table.
91251 */
91252 if( pParse->nErr==0 && (p = isCandidateForInOpt(pX))!=0 ){
91253 sqlite3 *db = pParse->db; /* Database connection */
91254 Table *pTab; /* Table <table>. */
91255 Expr *pExpr; /* Expression <column> */
91256 i16 iCol; /* Index of column <column> */
91257 i16 iDb; /* Database idx for pTab */
 
 
91258
91259 assert( p->pEList!=0 ); /* Because of isCandidateForInOpt(p) */
91260 assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */
91261 assert( p->pSrc!=0 ); /* Because of isCandidateForInOpt(p) */
91262 pTab = p->pSrc->a[0].pTab;
91263 pExpr = p->pEList->a[0].pExpr;
91264 iCol = (i16)pExpr->iColumn;
91265
91266 /* Code an OP_Transaction and OP_TableLock for <table>. */
91267 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
91268 sqlite3CodeVerifySchema(pParse, iDb);
91269 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
91270
91271 /* This function is only called from two places. In both cases the vdbe
91272 ** has already been allocated. So assume sqlite3GetVdbe() is always
91273 ** successful here.
91274 */
91275 assert(v);
91276 if( iCol<0 ){
91277 int iAddr = sqlite3CodeOnce(pParse);
91278 VdbeCoverage(v);
91279
91280 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
91281 eType = IN_INDEX_ROWID;
91282
91283 sqlite3VdbeJumpHere(v, iAddr);
91284 }else{
91285 Index *pIdx; /* Iterator variable */
91286
91287 /* The collation sequence used by the comparison. If an index is to
91288 ** be used in place of a temp-table, it must be ordered according
91289 ** to this collation sequence. */
91290 CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pExpr);
91291
91292 /* Check that the affinity that will be used to perform the
91293 ** comparison is the same as the affinity of the column. If
91294 ** it is not, it is not possible to use any index.
91295 */
91296 int affinity_ok = sqlite3IndexAffinityOk(pX, pTab->aCol[iCol].affinity);
91297
91298 for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){
91299 if( (pIdx->aiColumn[0]==iCol)
91300 && sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], 0)==pReq
91301 && (!mustBeUnique || (pIdx->nKeyCol==1 && IsUniqueIndex(pIdx)))
91302 ){
91303 int iAddr = sqlite3CodeOnce(pParse); VdbeCoverage(v);
91304 sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);
91305 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
91306 VdbeComment((v, "%s", pIdx->zName));
91307 assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
91308 eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
91309
91310 if( prRhsHasNull && !pTab->aCol[iCol].notNull ){
91311 #ifdef SQLITE_ENABLE_COLUMN_USED_MASK
91312 const i64 sOne = 1;
91313 sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed,
91314 iTab, 0, 0, (u8*)&sOne, P4_INT64);
91315 #endif
91316 *prRhsHasNull = ++pParse->nMem;
91317 sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);
91318 }
91319 sqlite3VdbeJumpHere(v, iAddr);
91320 }
91321 }
91322 }
91323 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91324
91325 /* If no preexisting index is available for the IN clause
91326 ** and IN_INDEX_NOOP is an allowed reply
91327 ** and the RHS of the IN operator is a list, not a subquery
91328 ** and the RHS is not constant or has two or fewer terms,
@@ -91334,11 +91937,10 @@
91334 && !ExprHasProperty(pX, EP_xIsSelect)
91335 && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2)
91336 ){
91337 eType = IN_INDEX_NOOP;
91338 }
91339
91340
91341 if( eType==0 ){
91342 /* Could not find an existing table or index to use as the RHS b-tree.
91343 ** We will have to generate an ephemeral table to do the job.
91344 */
@@ -91356,13 +91958,66 @@
91356 sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);
91357 pParse->nQueryLoop = savedNQueryLoop;
91358 }else{
91359 pX->iTable = iTab;
91360 }
 
 
 
 
 
 
91361 return eType;
91362 }
91363 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91364
91365 /*
91366 ** Generate code for scalar subqueries used as a subquery expression, EXISTS,
91367 ** or IN operators. Examples:
91368 **
@@ -91385,11 +92040,13 @@
91385 ** All this routine does is initialize the register given by rMayHaveNull
91386 ** to NULL. Calling routines will take care of changing this register
91387 ** value to non-NULL if the RHS is NULL-free.
91388 **
91389 ** For a SELECT or EXISTS operator, return the register that holds the
91390 ** result. For IN operators or if an error occurs, the return value is 0.
 
 
91391 */
91392 #ifndef SQLITE_OMIT_SUBQUERY
91393 SQLITE_PRIVATE int sqlite3CodeSubselect(
91394 Parse *pParse, /* Parsing context */
91395 Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
@@ -91400,12 +92057,12 @@
91400 int rReg = 0; /* Register storing resulting */
91401 Vdbe *v = sqlite3GetVdbe(pParse);
91402 if( NEVER(v==0) ) return 0;
91403 sqlite3ExprCachePush(pParse);
91404
91405 /* This code must be run in its entirety every time it is encountered
91406 ** if any of the following is true:
91407 **
91408 ** * The right-hand side is a correlated subquery
91409 ** * The right-hand side is an expression list containing variables
91410 ** * We are inside a trigger
91411 **
@@ -91427,21 +92084,22 @@
91427 }
91428 #endif
91429
91430 switch( pExpr->op ){
91431 case TK_IN: {
91432 char affinity; /* Affinity of the LHS of the IN */
91433 int addr; /* Address of OP_OpenEphemeral instruction */
91434 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
91435 KeyInfo *pKeyInfo = 0; /* Key information */
91436
91437 affinity = sqlite3ExprAffinity(pLeft);
 
 
91438
91439 /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
91440 ** expression it is handled the same way. An ephemeral table is
91441 ** filled with single-field index keys representing the results
91442 ** from the SELECT or the <exprlist>.
91443 **
91444 ** If the 'x' expression is a column value, or the SELECT...
91445 ** statement returns a column value, then the affinity of that
91446 ** column is used to build the index keys. If both 'x' and the
91447 ** SELECT... statement are columns, then numeric affinity is used
@@ -91448,54 +92106,67 @@
91448 ** if either column has NUMERIC or INTEGER affinity. If neither
91449 ** 'x' nor the SELECT... statement are columns, then numeric affinity
91450 ** is used.
91451 */
91452 pExpr->iTable = pParse->nTab++;
91453 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
91454 pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1, 1);
 
91455
91456 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
91457 /* Case 1: expr IN (SELECT ...)
91458 **
91459 ** Generate code to write the results of the select into the temporary
91460 ** table allocated and opened above.
91461 */
91462 Select *pSelect = pExpr->x.pSelect;
91463 SelectDest dest;
91464 ExprList *pEList;
91465
91466 assert( !isRowid );
91467 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
91468 dest.affSdst = (u8)affinity;
91469 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
91470 pSelect->iLimit = 0;
91471 testcase( pSelect->selFlags & SF_Distinct );
91472 testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
91473 if( sqlite3Select(pParse, pSelect, &dest) ){
91474 sqlite3KeyInfoUnref(pKeyInfo);
91475 return 0;
91476 }
91477 pEList = pSelect->pEList;
91478 assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
91479 assert( pEList!=0 );
91480 assert( pEList->nExpr>0 );
91481 assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
91482 pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
91483 pEList->a[0].pExpr);
 
 
 
 
 
 
 
 
 
 
 
91484 }else if( ALWAYS(pExpr->x.pList!=0) ){
91485 /* Case 2: expr IN (exprlist)
91486 **
91487 ** For each expression, build an index key from the evaluation and
91488 ** store it in the temporary table. If <expr> is a column, then use
91489 ** that columns affinity when building index keys. If <expr> is not
91490 ** a column, use numeric affinity.
91491 */
 
91492 int i;
91493 ExprList *pList = pExpr->x.pList;
91494 struct ExprList_item *pItem;
91495 int r1, r2, r3;
91496
 
91497 if( !affinity ){
91498 affinity = SQLITE_AFF_BLOB;
91499 }
91500 if( pKeyInfo ){
91501 assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
@@ -91547,30 +92218,41 @@
91547 }
91548
91549 case TK_EXISTS:
91550 case TK_SELECT:
91551 default: {
91552 /* If this has to be a scalar SELECT. Generate code to put the
91553 ** value of this select in a memory cell and record the number
91554 ** of the memory cell in iColumn. If this is an EXISTS, write
91555 ** an integer 0 (not exists) or 1 (exists) into a memory cell
91556 ** and record that memory cell in iColumn.
 
 
 
 
 
 
 
91557 */
91558 Select *pSel; /* SELECT statement to encode */
91559 SelectDest dest; /* How to deal with SELECt result */
 
91560
91561 testcase( pExpr->op==TK_EXISTS );
91562 testcase( pExpr->op==TK_SELECT );
91563 assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
91564
91565 assert( ExprHasProperty(pExpr, EP_xIsSelect) );
 
91566 pSel = pExpr->x.pSelect;
91567 sqlite3SelectDestInit(&dest, 0, ++pParse->nMem);
 
 
91568 if( pExpr->op==TK_SELECT ){
91569 dest.eDest = SRT_Mem;
91570 dest.iSdst = dest.iSDParm;
91571 sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iSDParm);
 
91572 VdbeComment((v, "Init subquery result"));
91573 }else{
91574 dest.eDest = SRT_Exists;
91575 sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
91576 VdbeComment((v, "Init EXISTS result"));
@@ -91599,66 +92281,147 @@
91599 sqlite3ExprCachePop(pParse);
91600
91601 return rReg;
91602 }
91603 #endif /* SQLITE_OMIT_SUBQUERY */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91604
91605 #ifndef SQLITE_OMIT_SUBQUERY
91606 /*
91607 ** Generate code for an IN expression.
91608 **
91609 ** x IN (SELECT ...)
91610 ** x IN (value, value, ...)
91611 **
91612 ** The left-hand side (LHS) is a scalar expression. The right-hand side (RHS)
91613 ** is an array of zero or more values. The expression is true if the LHS is
91614 ** contained within the RHS. The value of the expression is unknown (NULL)
91615 ** if the LHS is NULL or if the LHS is not contained within the RHS and the
91616 ** RHS contains one or more NULL values.
 
 
 
 
 
91617 **
91618 ** This routine generates code that jumps to destIfFalse if the LHS is not
91619 ** contained within the RHS. If due to NULLs we cannot determine if the LHS
91620 ** is contained in the RHS then jump to destIfNull. If the LHS is contained
91621 ** within the RHS then fall through.
 
 
 
91622 */
91623 static void sqlite3ExprCodeIN(
91624 Parse *pParse, /* Parsing and code generating context */
91625 Expr *pExpr, /* The IN expression */
91626 int destIfFalse, /* Jump here if LHS is not contained in the RHS */
91627 int destIfNull /* Jump here if the results are unknown due to NULLs */
91628 ){
91629 int rRhsHasNull = 0; /* Register that is true if RHS contains NULL values */
91630 char affinity; /* Comparison affinity to use */
91631 int eType; /* Type of the RHS */
91632 int r1; /* Temporary use register */
 
91633 Vdbe *v; /* Statement under construction */
 
 
 
 
 
 
 
 
 
 
 
91634
91635 /* Compute the RHS. After this step, the table with cursor
91636 ** pExpr->iTable will contains the values that make up the RHS.
91637 */
 
 
 
 
 
 
 
 
 
 
91638 v = pParse->pVdbe;
91639 assert( v!=0 ); /* OOM detected prior to this routine */
91640 VdbeNoopComment((v, "begin IN expr"));
91641 eType = sqlite3FindInIndex(pParse, pExpr,
91642 IN_INDEX_MEMBERSHIP | IN_INDEX_NOOP_OK,
91643 destIfFalse==destIfNull ? 0 : &rRhsHasNull);
91644
91645 /* Figure out the affinity to use to create a key from the results
91646 ** of the expression. affinityStr stores a static string suitable for
91647 ** P4 of OP_MakeRecord.
91648 */
91649 affinity = comparisonAffinity(pExpr);
91650
91651 /* Code the LHS, the <expr> from "<expr> IN (...)".
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91652 */
91653 sqlite3ExprCachePush(pParse);
91654 r1 = sqlite3GetTempReg(pParse);
91655 sqlite3ExprCode(pParse, pExpr->pLeft, r1);
 
 
 
 
 
 
 
 
 
 
91656
91657 /* If sqlite3FindInIndex() did not find or create an index that is
91658 ** suitable for evaluating the IN operator, then evaluate using a
91659 ** sequence of comparisons.
 
 
91660 */
91661 if( eType==IN_INDEX_NOOP ){
91662 ExprList *pList = pExpr->x.pList;
91663 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
91664 int labelOk = sqlite3VdbeMakeLabel(v);
@@ -91666,108 +92429,144 @@
91666 int regCkNull = 0;
91667 int ii;
91668 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
91669 if( destIfNull!=destIfFalse ){
91670 regCkNull = sqlite3GetTempReg(pParse);
91671 sqlite3VdbeAddOp3(v, OP_BitAnd, r1, r1, regCkNull);
91672 }
91673 for(ii=0; ii<pList->nExpr; ii++){
91674 r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);
91675 if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
91676 sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
91677 }
91678 if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
91679 sqlite3VdbeAddOp4(v, OP_Eq, r1, labelOk, r2,
91680 (void*)pColl, P4_COLLSEQ);
91681 VdbeCoverageIf(v, ii<pList->nExpr-1);
91682 VdbeCoverageIf(v, ii==pList->nExpr-1);
91683 sqlite3VdbeChangeP5(v, affinity);
91684 }else{
91685 assert( destIfNull==destIfFalse );
91686 sqlite3VdbeAddOp4(v, OP_Ne, r1, destIfFalse, r2,
91687 (void*)pColl, P4_COLLSEQ); VdbeCoverage(v);
91688 sqlite3VdbeChangeP5(v, affinity | SQLITE_JUMPIFNULL);
91689 }
91690 sqlite3ReleaseTempReg(pParse, regToFree);
91691 }
91692 if( regCkNull ){
91693 sqlite3VdbeAddOp2(v, OP_IsNull, regCkNull, destIfNull); VdbeCoverage(v);
91694 sqlite3VdbeGoto(v, destIfFalse);
91695 }
91696 sqlite3VdbeResolveLabel(v, labelOk);
91697 sqlite3ReleaseTempReg(pParse, regCkNull);
91698 }else{
91699
91700 /* If the LHS is NULL, then the result is either false or NULL depending
91701 ** on whether the RHS is empty or not, respectively.
91702 */
91703 if( sqlite3ExprCanBeNull(pExpr->pLeft) ){
91704 if( destIfNull==destIfFalse ){
91705 /* Shortcut for the common case where the false and NULL outcomes are
91706 ** the same. */
91707 sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull); VdbeCoverage(v);
91708 }else{
91709 int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, r1); VdbeCoverage(v);
91710 sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
91711 VdbeCoverage(v);
91712 sqlite3VdbeGoto(v, destIfNull);
91713 sqlite3VdbeJumpHere(v, addr1);
91714 }
91715 }
91716
91717 if( eType==IN_INDEX_ROWID ){
91718 /* In this case, the RHS is the ROWID of table b-tree
91719 */
91720 sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, r1);
91721 VdbeCoverage(v);
91722 }else{
91723 /* In this case, the RHS is an index b-tree.
91724 */
91725 sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, &affinity, 1);
91726
91727 /* If the set membership test fails, then the result of the
91728 ** "x IN (...)" expression must be either 0 or NULL. If the set
91729 ** contains no NULL values, then the result is 0. If the set
91730 ** contains one or more NULL values, then the result of the
91731 ** expression is also NULL.
91732 */
91733 assert( destIfFalse!=destIfNull || rRhsHasNull==0 );
91734 if( rRhsHasNull==0 ){
91735 /* This branch runs if it is known at compile time that the RHS
91736 ** cannot contain NULL values. This happens as the result
91737 ** of a "NOT NULL" constraint in the database schema.
91738 **
91739 ** Also run this branch if NULL is equivalent to FALSE
91740 ** for this particular IN operator.
91741 */
91742 sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse, r1, 1);
91743 VdbeCoverage(v);
91744 }else{
91745 /* In this branch, the RHS of the IN might contain a NULL and
91746 ** the presence of a NULL on the RHS makes a difference in the
91747 ** outcome.
91748 */
91749 int addr1;
91750
91751 /* First check to see if the LHS is contained in the RHS. If so,
91752 ** then the answer is TRUE the presence of NULLs in the RHS does
91753 ** not matter. If the LHS is not contained in the RHS, then the
91754 ** answer is NULL if the RHS contains NULLs and the answer is
91755 ** FALSE if the RHS is NULL-free.
91756 */
91757 addr1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, r1, 1);
91758 VdbeCoverage(v);
91759 sqlite3VdbeAddOp2(v, OP_IsNull, rRhsHasNull, destIfNull);
91760 VdbeCoverage(v);
91761 sqlite3VdbeGoto(v, destIfFalse);
91762 sqlite3VdbeJumpHere(v, addr1);
91763 }
91764 }
91765 }
91766 sqlite3ReleaseTempReg(pParse, r1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91767 sqlite3ExprCachePop(pParse);
91768 VdbeComment((v, "end IN expr"));
 
 
 
91769 }
91770 #endif /* SQLITE_OMIT_SUBQUERY */
91771
91772 #ifndef SQLITE_OMIT_FLOATING_POINT
91773 /*
@@ -92148,18 +92947,52 @@
92148 }
92149 #endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */
92150
92151
92152 /*
92153 ** Convert an expression node to a TK_REGISTER
 
 
92154 */
92155 static void exprToRegister(Expr *p, int iReg){
92156 p->op2 = p->op;
92157 p->op = TK_REGISTER;
92158 p->iTable = iReg;
92159 ExprClearProperty(p, EP_Skip);
92160 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92161
92162 /*
92163 ** Generate code into the current Vdbe to evaluate the given
92164 ** expression. Attempt to store the results in register "target".
92165 ** Return the register where results are stored.
@@ -92174,13 +93007,14 @@
92174 Vdbe *v = pParse->pVdbe; /* The VM under construction */
92175 int op; /* The opcode being coded */
92176 int inReg = target; /* Results stored in register inReg */
92177 int regFree1 = 0; /* If non-zero free this temporary register */
92178 int regFree2 = 0; /* If non-zero free this temporary register */
92179 int r1, r2, r3, r4; /* Various register numbers */
92180 sqlite3 *db = pParse->db; /* The database connection */
92181 Expr tempX; /* Temporary expression node */
 
92182
92183 assert( target>0 && target<=pParse->nMem );
92184 if( v==0 ){
92185 assert( pParse->db->mallocFailed );
92186 return 0;
@@ -92289,43 +93123,38 @@
92289 testcase( usedAsColumnCache(pParse, inReg, inReg) );
92290 sqlite3ExprCacheAffinityChange(pParse, inReg, 1);
92291 break;
92292 }
92293 #endif /* SQLITE_OMIT_CAST */
 
 
 
 
 
92294 case TK_LT:
92295 case TK_LE:
92296 case TK_GT:
92297 case TK_GE:
92298 case TK_NE:
92299 case TK_EQ: {
92300 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
92301 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
92302 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
92303 r1, r2, inReg, SQLITE_STOREP2);
92304 assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
92305 assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
92306 assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
92307 assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
92308 assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
92309 assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
92310 testcase( regFree1==0 );
92311 testcase( regFree2==0 );
92312 break;
92313 }
92314 case TK_IS:
92315 case TK_ISNOT: {
92316 testcase( op==TK_IS );
92317 testcase( op==TK_ISNOT );
92318 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
92319 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
92320 op = (op==TK_IS) ? TK_EQ : TK_NE;
92321 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
92322 r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ);
92323 VdbeCoverageIf(v, op==TK_EQ);
92324 VdbeCoverageIf(v, op==TK_NE);
92325 testcase( regFree1==0 );
92326 testcase( regFree2==0 );
92327 break;
92328 }
92329 case TK_AND:
92330 case TK_OR:
92331 case TK_PLUS:
@@ -92547,13 +93376,25 @@
92547 break;
92548 }
92549 #ifndef SQLITE_OMIT_SUBQUERY
92550 case TK_EXISTS:
92551 case TK_SELECT: {
 
92552 testcase( op==TK_EXISTS );
92553 testcase( op==TK_SELECT );
92554 inReg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
 
 
 
 
 
 
 
 
 
 
 
92555 break;
92556 }
92557 case TK_IN: {
92558 int destIfFalse = sqlite3VdbeMakeLabel(v);
92559 int destIfNull = sqlite3VdbeMakeLabel(v);
@@ -92578,32 +93419,11 @@
92578 ** X is stored in pExpr->pLeft.
92579 ** Y is stored in pExpr->pList->a[0].pExpr.
92580 ** Z is stored in pExpr->pList->a[1].pExpr.
92581 */
92582 case TK_BETWEEN: {
92583 Expr *pLeft = pExpr->pLeft;
92584 struct ExprList_item *pLItem = pExpr->x.pList->a;
92585 Expr *pRight = pLItem->pExpr;
92586
92587 r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);
92588 r2 = sqlite3ExprCodeTemp(pParse, pRight, &regFree2);
92589 testcase( regFree1==0 );
92590 testcase( regFree2==0 );
92591 r3 = sqlite3GetTempReg(pParse);
92592 r4 = sqlite3GetTempReg(pParse);
92593 codeCompare(pParse, pLeft, pRight, OP_Ge,
92594 r1, r2, r3, SQLITE_STOREP2); VdbeCoverage(v);
92595 pLItem++;
92596 pRight = pLItem->pExpr;
92597 sqlite3ReleaseTempReg(pParse, regFree2);
92598 r2 = sqlite3ExprCodeTemp(pParse, pRight, &regFree2);
92599 testcase( regFree2==0 );
92600 codeCompare(pParse, pLeft, pRight, OP_Le, r1, r2, r4, SQLITE_STOREP2);
92601 VdbeCoverage(v);
92602 sqlite3VdbeAddOp3(v, OP_And, r3, r4, target);
92603 sqlite3ReleaseTempReg(pParse, r3);
92604 sqlite3ReleaseTempReg(pParse, r4);
92605 break;
92606 }
92607 case TK_SPAN:
92608 case TK_COLLATE:
92609 case TK_UPLUS: {
@@ -92665,10 +93485,14 @@
92665 }
92666 #endif
92667 break;
92668 }
92669
 
 
 
 
92670
92671 /*
92672 ** Form A:
92673 ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END
92674 **
@@ -92708,12 +93532,13 @@
92708 nExpr = pEList->nExpr;
92709 endLabel = sqlite3VdbeMakeLabel(v);
92710 if( (pX = pExpr->pLeft)!=0 ){
92711 tempX = *pX;
92712 testcase( pX->op==TK_COLUMN );
92713 exprToRegister(&tempX, sqlite3ExprCodeTemp(pParse, pX, &regFree1));
92714 testcase( regFree1==0 );
 
92715 opCompare.op = TK_EQ;
92716 opCompare.pLeft = &tempX;
92717 pTest = &opCompare;
92718 /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
92719 ** The value in regFree1 might get SCopy-ed into the file result.
@@ -92988,24 +93813,37 @@
92988 **
92989 ** x>=y AND x<=z
92990 **
92991 ** Code it as such, taking care to do the common subexpression
92992 ** elimination of x.
 
 
 
 
 
 
 
 
92993 */
92994 static void exprCodeBetween(
92995 Parse *pParse, /* Parsing and code generating context */
92996 Expr *pExpr, /* The BETWEEN expression */
92997 int dest, /* Jump here if the jump is taken */
92998 int jumpIfTrue, /* Take the jump if the BETWEEN is true */
92999 int jumpIfNull /* Take the jump if the BETWEEN is NULL */
93000 ){
93001 Expr exprAnd; /* The AND operator in x>=y AND x<=z */
93002 Expr compLeft; /* The x>=y term */
93003 Expr compRight; /* The x<=z term */
93004 Expr exprX; /* The x subexpression */
93005 int regFree1 = 0; /* Temporary use register */
93006
 
 
 
 
 
93007 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
93008 exprX = *pExpr->pLeft;
93009 exprAnd.op = TK_AND;
93010 exprAnd.pLeft = &compLeft;
93011 exprAnd.pRight = &compRight;
@@ -93013,27 +93851,29 @@
93013 compLeft.pLeft = &exprX;
93014 compLeft.pRight = pExpr->x.pList->a[0].pExpr;
93015 compRight.op = TK_LE;
93016 compRight.pLeft = &exprX;
93017 compRight.pRight = pExpr->x.pList->a[1].pExpr;
93018 exprToRegister(&exprX, sqlite3ExprCodeTemp(pParse, &exprX, &regFree1));
93019 if( jumpIfTrue ){
93020 sqlite3ExprIfTrue(pParse, &exprAnd, dest, jumpIfNull);
93021 }else{
93022 sqlite3ExprIfFalse(pParse, &exprAnd, dest, jumpIfNull);
 
93023 }
93024 sqlite3ReleaseTempReg(pParse, regFree1);
93025
93026 /* Ensure adequate test coverage */
93027 testcase( jumpIfTrue==0 && jumpIfNull==0 && regFree1==0 );
93028 testcase( jumpIfTrue==0 && jumpIfNull==0 && regFree1!=0 );
93029 testcase( jumpIfTrue==0 && jumpIfNull!=0 && regFree1==0 );
93030 testcase( jumpIfTrue==0 && jumpIfNull!=0 && regFree1!=0 );
93031 testcase( jumpIfTrue!=0 && jumpIfNull==0 && regFree1==0 );
93032 testcase( jumpIfTrue!=0 && jumpIfNull==0 && regFree1!=0 );
93033 testcase( jumpIfTrue!=0 && jumpIfNull!=0 && regFree1==0 );
93034 testcase( jumpIfTrue!=0 && jumpIfNull!=0 && regFree1!=0 );
 
93035 }
93036
93037 /*
93038 ** Generate code for a boolean expression such that a jump is made
93039 ** to the label "dest" if the expression is true but execution
@@ -93094,10 +93934,11 @@
93094 case TK_LE:
93095 case TK_GT:
93096 case TK_GE:
93097 case TK_NE:
93098 case TK_EQ: {
 
93099 testcase( jumpIfNull==0 );
93100 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
93101 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
93102 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
93103 r1, r2, dest, jumpIfNull);
@@ -93126,11 +93967,11 @@
93126 testcase( regFree1==0 );
93127 break;
93128 }
93129 case TK_BETWEEN: {
93130 testcase( jumpIfNull==0 );
93131 exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull);
93132 break;
93133 }
93134 #ifndef SQLITE_OMIT_SUBQUERY
93135 case TK_IN: {
93136 int destIfFalse = sqlite3VdbeMakeLabel(v);
@@ -93140,10 +93981,11 @@
93140 sqlite3VdbeResolveLabel(v, destIfFalse);
93141 break;
93142 }
93143 #endif
93144 default: {
 
93145 if( exprAlwaysTrue(pExpr) ){
93146 sqlite3VdbeGoto(v, dest);
93147 }else if( exprAlwaysFalse(pExpr) ){
93148 /* No-op */
93149 }else{
@@ -93246,10 +94088,11 @@
93246 case TK_LE:
93247 case TK_GT:
93248 case TK_GE:
93249 case TK_NE:
93250 case TK_EQ: {
 
93251 testcase( jumpIfNull==0 );
93252 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
93253 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
93254 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
93255 r1, r2, dest, jumpIfNull);
@@ -93276,11 +94119,11 @@
93276 testcase( regFree1==0 );
93277 break;
93278 }
93279 case TK_BETWEEN: {
93280 testcase( jumpIfNull==0 );
93281 exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull);
93282 break;
93283 }
93284 #ifndef SQLITE_OMIT_SUBQUERY
93285 case TK_IN: {
93286 if( jumpIfNull ){
@@ -93292,10 +94135,11 @@
93292 }
93293 break;
93294 }
93295 #endif
93296 default: {
 
93297 if( exprAlwaysFalse(pExpr) ){
93298 sqlite3VdbeGoto(v, dest);
93299 }else if( exprAlwaysTrue(pExpr) ){
93300 /* no-op */
93301 }else{
@@ -93807,14 +94651,15 @@
93807 pParse->aTempReg[pParse->nTempReg++] = iReg;
93808 }
93809 }
93810
93811 /*
93812 ** Allocate or deallocate a block of nReg consecutive registers
93813 */
93814 SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
93815 int i, n;
 
93816 i = pParse->iRangeReg;
93817 n = pParse->nRangeReg;
93818 if( nReg<=n ){
93819 assert( !usedAsColumnCache(pParse, i, i+n-1) );
93820 pParse->iRangeReg += nReg;
@@ -93824,10 +94669,14 @@
93824 pParse->nMem += nReg;
93825 }
93826 return i;
93827 }
93828 SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
 
 
 
 
93829 sqlite3ExprCacheRemove(pParse, iReg, nReg);
93830 if( nReg>pParse->nRangeReg ){
93831 pParse->nRangeReg = nReg;
93832 pParse->iRangeReg = iReg;
93833 }
@@ -97568,12 +98417,12 @@
97568
97569 #if SQLITE_USER_AUTHENTICATION
97570 if( pParse->nTableLock>0 && db->init.busy==0 ){
97571 sqlite3UserAuthInit(db);
97572 if( db->auth.authLevel<UAUTH_User ){
97573 pParse->rc = SQLITE_AUTH_USER;
97574 sqlite3ErrorMsg(pParse, "user not authenticated");
 
97575 return;
97576 }
97577 }
97578 #endif
97579
@@ -108279,19 +109128,19 @@
108279 }
108280 if( piIdxCur ) *piIdxCur = iBase;
108281 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
108282 int iIdxCur = iBase++;
108283 assert( pIdx->pSchema==pTab->pSchema );
 
 
 
 
108284 if( aToOpen==0 || aToOpen[i+1] ){
108285 sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);
108286 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
108287 VdbeComment((v, "%s", pIdx->zName));
108288 }
108289 if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
108290 if( piDataCur ) *piDataCur = iIdxCur;
108291 }else{
108292 sqlite3VdbeChangeP5(v, p5);
 
108293 }
108294 }
108295 if( iBase>pParse->nTab ) pParse->nTab = iBase;
108296 return i;
108297 }
@@ -113611,11 +114460,11 @@
113611 ** Initialize a SelectDest structure.
113612 */
113613 SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){
113614 pDest->eDest = (u8)eDest;
113615 pDest->iSDParm = iParm;
113616 pDest->affSdst = 0;
113617 pDest->iSdst = 0;
113618 pDest->nSdst = 0;
113619 }
113620
113621
@@ -114182,34 +115031,10 @@
114182 sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);
114183 sqlite3VdbeAddOp2(v, OP_IdxInsert, iTab, r1);
114184 sqlite3ReleaseTempReg(pParse, r1);
114185 }
114186
114187 #ifndef SQLITE_OMIT_SUBQUERY
114188 /*
114189 ** Generate an error message when a SELECT is used within a subexpression
114190 ** (example: "a IN (SELECT * FROM table)") but it has more than 1 result
114191 ** column. We do this in a subroutine because the error used to occur
114192 ** in multiple places. (The error only occurs in one place now, but we
114193 ** retain the subroutine to minimize code disruption.)
114194 */
114195 static int checkForMultiColumnSelectError(
114196 Parse *pParse, /* Parse context. */
114197 SelectDest *pDest, /* Destination of SELECT results */
114198 int nExpr /* Number of result columns returned by SELECT */
114199 ){
114200 int eDest = pDest->eDest;
114201 if( nExpr>1 && (eDest==SRT_Mem || eDest==SRT_Set) ){
114202 sqlite3ErrorMsg(pParse, "only a single result allowed for "
114203 "a SELECT that is part of an expression");
114204 return 1;
114205 }else{
114206 return 0;
114207 }
114208 }
114209 #endif
114210
114211 /*
114212 ** This routine generates the code for the inside of the inner loop
114213 ** of a SELECT.
114214 **
114215 ** If srcTab is negative, then the pEList expressions
@@ -114415,23 +115240,23 @@
114415 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
114416 ** then there should be a single item on the stack. Write this
114417 ** item into the set table with bogus data.
114418 */
114419 case SRT_Set: {
114420 assert( nResultCol==1 );
114421 pDest->affSdst =
114422 sqlite3CompareAffinity(pEList->a[0].pExpr, pDest->affSdst);
114423 if( pSort ){
114424 /* At first glance you would think we could optimize out the
114425 ** ORDER BY in this case since the order of entries in the set
114426 ** does not matter. But there might be a LIMIT clause, in which
114427 ** case the order does matter */
114428 pushOntoSorter(pParse, pSort, p, regResult, regResult, 1, nPrefixReg);
 
114429 }else{
114430 int r1 = sqlite3GetTempReg(pParse);
114431 sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult,1,r1, &pDest->affSdst, 1);
114432 sqlite3ExprCacheAffinityChange(pParse, regResult, 1);
 
 
114433 sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1);
114434 sqlite3ReleaseTempReg(pParse, r1);
114435 }
114436 break;
114437 }
@@ -114443,17 +115268,18 @@
114443 /* The LIMIT clause will terminate the loop for us */
114444 break;
114445 }
114446
114447 /* If this is a scalar select that is part of an expression, then
114448 ** store the results in the appropriate memory cell and break out
114449 ** of the scan loop.
114450 */
114451 case SRT_Mem: {
114452 assert( nResultCol==1 );
114453 if( pSort ){
114454 pushOntoSorter(pParse, pSort, p, regResult, regResult, 1, nPrefixReg);
 
114455 }else{
114456 assert( regResult==iParm );
114457 /* The LIMIT clause will jump out of the loop for us */
114458 }
114459 break;
@@ -114764,18 +115590,18 @@
114764 sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
114765 sqlite3VdbeGoto(v, addrBreak);
114766 sqlite3VdbeResolveLabel(v, pSort->labelBkOut);
114767 }
114768 iTab = pSort->iECursor;
114769 if( eDest==SRT_Output || eDest==SRT_Coroutine ){
114770 regRowid = 0;
114771 regRow = pDest->iSdst;
114772 nSortData = nColumn;
114773 }else{
114774 regRowid = sqlite3GetTempReg(pParse);
114775 regRow = sqlite3GetTempReg(pParse);
114776 nSortData = 1;
114777 }
114778 nKey = pOrderBy->nExpr - pSort->nOBSat;
114779 if( pSort->sortFlags & SORTFLAG_UseSorter ){
114780 int regSortOut = ++pParse->nMem;
114781 iSortTab = pParse->nTab++;
@@ -114806,20 +115632,18 @@
114806 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
114807 break;
114808 }
114809 #ifndef SQLITE_OMIT_SUBQUERY
114810 case SRT_Set: {
114811 assert( nColumn==1 );
114812 sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, 1, regRowid,
114813 &pDest->affSdst, 1);
114814 sqlite3ExprCacheAffinityChange(pParse, regRow, 1);
114815 sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, regRowid);
114816 break;
114817 }
114818 case SRT_Mem: {
114819 assert( nColumn==1 );
114820 sqlite3ExprCodeMove(pParse, regRow, iParm, 1);
114821 /* The LIMIT clause will terminate the loop for us */
114822 break;
114823 }
114824 #endif
114825 default: {
@@ -114834,11 +115658,15 @@
114834 }
114835 break;
114836 }
114837 }
114838 if( regRowid ){
114839 sqlite3ReleaseTempReg(pParse, regRow);
 
 
 
 
114840 sqlite3ReleaseTempReg(pParse, regRowid);
114841 }
114842 /* The bottom of the loop
114843 */
114844 sqlite3VdbeResolveLabel(v, addrContinue);
@@ -115336,11 +116164,11 @@
115336 ** Get a VDBE for the given parser context. Create a new one if necessary.
115337 ** If an error occurs, return NULL and leave a message in pParse.
115338 */
115339 static SQLITE_NOINLINE Vdbe *allocVdbe(Parse *pParse){
115340 Vdbe *v = pParse->pVdbe = sqlite3VdbeCreate(pParse);
115341 if( v ) sqlite3VdbeAddOp0(v, OP_Init);
115342 if( pParse->pToplevel==0
115343 && OptimizationEnabled(pParse->db,SQLITE_FactorOutConst)
115344 ){
115345 pParse->okConstFactor = 1;
115346 }
@@ -116175,22 +117003,19 @@
116175 sqlite3ReleaseTempReg(pParse, r1);
116176 break;
116177 }
116178
116179 #ifndef SQLITE_OMIT_SUBQUERY
116180 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
116181 ** then there should be a single item on the stack. Write this
116182 ** item into the set table with bogus data.
116183 */
116184 case SRT_Set: {
116185 int r1;
116186 assert( pIn->nSdst==1 || pParse->nErr>0 );
116187 pDest->affSdst =
116188 sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affSdst);
116189 r1 = sqlite3GetTempReg(pParse);
116190 sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, 1, r1, &pDest->affSdst,1);
116191 sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1);
 
116192 sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iSDParm, r1);
116193 sqlite3ReleaseTempReg(pParse, r1);
116194 break;
116195 }
116196
@@ -118418,20 +119243,10 @@
118418 #if SELECTTRACE_ENABLED
118419 if( sqlite3SelectTrace & 0x100 ){
118420 SELECTTRACE(0x100,pParse,p, ("after name resolution:\n"));
118421 sqlite3TreeViewSelect(0, p, 0);
118422 }
118423 #endif
118424
118425
118426 /* If writing to memory or generating a set
118427 ** only a single column may be output.
118428 */
118429 #ifndef SQLITE_OMIT_SUBQUERY
118430 if( checkForMultiColumnSelectError(pParse, pDest, p->pEList->nExpr) ){
118431 goto select_end;
118432 }
118433 #endif
118434
118435 /* Try to flatten subqueries in the FROM clause up into the main query
118436 */
118437 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
@@ -122398,11 +123213,11 @@
122398
122399 /*
122400 ** This function is invoked by the vdbe to call the xCreate method
122401 ** of the virtual table named zTab in database iDb.
122402 **
122403 ** If an error occurs, *pzErr is set to point an an English language
122404 ** description of the error and an SQLITE_XXX error code is returned.
122405 ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr.
122406 */
122407 SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
122408 int rc = SQLITE_OK;
@@ -123099,10 +123914,12 @@
123099 LogEst rRun; /* Cost of running each loop */
123100 LogEst nOut; /* Estimated number of output rows */
123101 union {
123102 struct { /* Information for internal btree tables */
123103 u16 nEq; /* Number of equality constraints */
 
 
123104 Index *pIndex; /* Index used, or NULL */
123105 } btree;
123106 struct { /* Information for virtual tables */
123107 int idxNum; /* Index number */
123108 u8 needFree; /* True if sqlite3_free(idxStr) is needed */
@@ -123223,10 +124040,11 @@
123223 */
123224 struct WhereTerm {
123225 Expr *pExpr; /* Pointer to the subexpression that is this term */
123226 int iParent; /* Disable pWC->a[iParent] when this term disabled */
123227 int leftCursor; /* Cursor number of X in "X <op> <expr>" */
 
123228 union {
123229 int leftColumn; /* Column number of X in "X <op> <expr>" */
123230 WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
123231 WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
123232 } u;
@@ -123528,10 +124346,21 @@
123528
123529 /************** End of whereInt.h ********************************************/
123530 /************** Continuing where we left off in wherecode.c ******************/
123531
123532 #ifndef SQLITE_OMIT_EXPLAIN
 
 
 
 
 
 
 
 
 
 
 
123533 /*
123534 ** This routine is a helper for explainIndexRange() below
123535 **
123536 ** pStr holds the text of an expression that we are building up one term
123537 ** at a time. This routine adds a new term to the end of the expression.
@@ -123538,28 +124367,36 @@
123538 ** Terms are separated by AND so add the "AND" text for second and subsequent
123539 ** terms only.
123540 */
123541 static void explainAppendTerm(
123542 StrAccum *pStr, /* The text expression being built */
123543 int iTerm, /* Index of this term. First is zero */
123544 const char *zColumn, /* Name of the column */
 
 
123545 const char *zOp /* Name of the operator */
123546 ){
123547 if( iTerm ) sqlite3StrAccumAppend(pStr, " AND ", 5);
123548 sqlite3StrAccumAppendAll(pStr, zColumn);
 
 
 
 
 
 
 
 
 
 
123549 sqlite3StrAccumAppend(pStr, zOp, 1);
123550 sqlite3StrAccumAppend(pStr, "?", 1);
123551 }
123552
123553 /*
123554 ** Return the name of the i-th column of the pIdx index.
123555 */
123556 static const char *explainIndexColumnName(Index *pIdx, int i){
123557 i = pIdx->aiColumn[i];
123558 if( i==XN_EXPR ) return "<expr>";
123559 if( i==XN_ROWID ) return "rowid";
123560 return pIdx->pTable->aCol[i].zName;
123561 }
123562
123563 /*
123564 ** Argument pLevel describes a strategy for scanning table pTab. This
123565 ** function appends text to pStr that describes the subset of table
@@ -123588,16 +124425,15 @@
123588 sqlite3XPrintf(pStr, i>=nSkip ? "%s=?" : "ANY(%s)", z);
123589 }
123590
123591 j = i;
123592 if( pLoop->wsFlags&WHERE_BTM_LIMIT ){
123593 const char *z = explainIndexColumnName(pIndex, i);
123594 explainAppendTerm(pStr, i++, z, ">");
123595 }
123596 if( pLoop->wsFlags&WHERE_TOP_LIMIT ){
123597 const char *z = explainIndexColumnName(pIndex, j);
123598 explainAppendTerm(pStr, i, z, "<");
123599 }
123600 sqlite3StrAccumAppend(pStr, ")", 1);
123601 }
123602
123603 /*
@@ -123783,11 +124619,11 @@
123783 ** a conditional such that is only evaluated on the second pass of a
123784 ** LIKE-optimization loop, when scanning BLOBs instead of strings.
123785 */
123786 static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){
123787 int nLoop = 0;
123788 while( pTerm
123789 && (pTerm->wtFlags & TERM_CODED)==0
123790 && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
123791 && (pLevel->notReady & pTerm->prereqAll)==0
123792 ){
123793 if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){
@@ -123839,20 +124675,50 @@
123839 sqlite3VdbeAddOp4(v, OP_Affinity, base, n, 0, zAff, n);
123840 sqlite3ExprCacheAffinityChange(pParse, base, n);
123841 }
123842 }
123843
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123844
123845 /*
123846 ** Generate code for a single equality term of the WHERE clause. An equality
123847 ** term can be either X=expr or X IN (...). pTerm is the term to be
123848 ** coded.
123849 **
123850 ** The current value for the constraint is left in register iReg.
 
 
 
 
123851 **
123852 ** For a constraint of the form X=expr, the expression is evaluated and its
123853 ** result is left on the stack. For constraints of the form X IN (...)
123854 ** this routine sets up a loop that will iterate over all values of X.
123855 */
123856 static int codeEqualityTerm(
123857 Parse *pParse, /* The parsing context */
123858 WhereTerm *pTerm, /* The term of the WHERE clause to be coded */
@@ -123863,22 +124729,26 @@
123863 ){
123864 Expr *pX = pTerm->pExpr;
123865 Vdbe *v = pParse->pVdbe;
123866 int iReg; /* Register holding results */
123867
 
123868 assert( iTarget>0 );
123869 if( pX->op==TK_EQ || pX->op==TK_IS ){
123870 iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget);
123871 }else if( pX->op==TK_ISNULL ){
123872 iReg = iTarget;
123873 sqlite3VdbeAddOp2(v, OP_Null, 0, iReg);
123874 #ifndef SQLITE_OMIT_SUBQUERY
123875 }else{
123876 int eType;
123877 int iTab;
123878 struct InLoop *pIn;
123879 WhereLoop *pLoop = pLevel->pWLoop;
 
 
 
123880
123881 if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0
123882 && pLoop->u.btree.pIndex!=0
123883 && pLoop->u.btree.pIndex->aSortOrder[iEq]
123884 ){
@@ -123886,42 +124756,128 @@
123886 testcase( bRev );
123887 bRev = !bRev;
123888 }
123889 assert( pX->op==TK_IN );
123890 iReg = iTarget;
123891 eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123892 if( eType==IN_INDEX_INDEX_DESC ){
123893 testcase( bRev );
123894 bRev = !bRev;
123895 }
123896 iTab = pX->iTable;
123897 sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);
123898 VdbeCoverageIf(v, bRev);
123899 VdbeCoverageIf(v, !bRev);
123900 assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );
 
123901 pLoop->wsFlags |= WHERE_IN_ABLE;
123902 if( pLevel->u.in.nIn==0 ){
123903 pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
123904 }
123905 pLevel->u.in.nIn++;
 
 
123906 pLevel->u.in.aInLoop =
123907 sqlite3DbReallocOrFree(pParse->db, pLevel->u.in.aInLoop,
123908 sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn);
123909 pIn = pLevel->u.in.aInLoop;
123910 if( pIn ){
123911 pIn += pLevel->u.in.nIn - 1;
123912 pIn->iCur = iTab;
123913 if( eType==IN_INDEX_ROWID ){
123914 pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iReg);
123915 }else{
123916 pIn->addrInTop = sqlite3VdbeAddOp3(v, OP_Column, iTab, 0, iReg);
123917 }
123918 pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;
123919 sqlite3VdbeAddOp1(v, OP_IsNull, iReg); VdbeCoverage(v);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123920 }else{
123921 pLevel->u.in.nIn = 0;
123922 }
 
123923 #endif
123924 }
123925 disableTerm(pLevel, pTerm);
123926 return iReg;
123927 }
@@ -124043,13 +124999,19 @@
124043 regBase = r1;
124044 }else{
124045 sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);
124046 }
124047 }
124048 testcase( pTerm->eOperator & WO_ISNULL );
124049 testcase( pTerm->eOperator & WO_IN );
124050 if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){
 
 
 
 
 
 
124051 Expr *pRight = pTerm->pExpr->pRight;
124052 if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
124053 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
124054 VdbeCoverage(v);
124055 }
@@ -124367,10 +125329,43 @@
124367 }
124368 sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);
124369 }
124370 }
124371 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124372
124373 /*
124374 ** Generate code for the start of the iLevel-th loop in the WHERE clause
124375 ** implementation described by pWInfo.
124376 */
@@ -124463,11 +125458,12 @@
124463 if( NEVER(pTerm==0) ) continue;
124464 if( pTerm->eOperator & WO_IN ){
124465 codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
124466 addrNotFound = pLevel->addrNxt;
124467 }else{
124468 sqlite3ExprCode(pParse, pTerm->pExpr->pRight, iTarget);
 
124469 }
124470 }
124471 sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);
124472 sqlite3VdbeAddOp2(v, OP_Integer, nConstraint, iReg+1);
124473 sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrNotFound, iReg,
@@ -124577,10 +125573,11 @@
124577 }
124578 codeCursorHint(pTabItem, pWInfo, pLevel, pEnd);
124579 if( pStart ){
124580 Expr *pX; /* The expression that defines the start bound */
124581 int r1, rTemp; /* Registers for holding the start boundary */
 
124582
124583 /* The following constant maps TK_xx codes into corresponding
124584 ** seek opcodes. It depends on a particular ordering of TK_xx
124585 */
124586 const u8 aMoveOp[] = {
@@ -124596,20 +125593,27 @@
124596 assert( (pStart->wtFlags & TERM_VNULL)==0 );
124597 testcase( pStart->wtFlags & TERM_VIRTUAL );
124598 pX = pStart->pExpr;
124599 assert( pX!=0 );
124600 testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
124601 r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
124602 sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);
 
 
 
 
 
 
 
 
124603 VdbeComment((v, "pk"));
124604 VdbeCoverageIf(v, pX->op==TK_GT);
124605 VdbeCoverageIf(v, pX->op==TK_LE);
124606 VdbeCoverageIf(v, pX->op==TK_LT);
124607 VdbeCoverageIf(v, pX->op==TK_GE);
124608 sqlite3ExprCacheAffinityChange(pParse, r1, 1);
124609 sqlite3ReleaseTempReg(pParse, rTemp);
124610 disableTerm(pLevel, pStart);
124611 }else{
124612 sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrBrk);
124613 VdbeCoverageIf(v, bRev==0);
124614 VdbeCoverageIf(v, bRev!=0);
124615 }
@@ -124619,17 +125623,21 @@
124619 assert( pX!=0 );
124620 assert( (pEnd->wtFlags & TERM_VNULL)==0 );
124621 testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
124622 testcase( pEnd->wtFlags & TERM_VIRTUAL );
124623 memEndValue = ++pParse->nMem;
124624 sqlite3ExprCode(pParse, pX->pRight, memEndValue);
124625 if( pX->op==TK_LT || pX->op==TK_GT ){
 
 
124626 testOp = bRev ? OP_Le : OP_Ge;
124627 }else{
124628 testOp = bRev ? OP_Lt : OP_Gt;
124629 }
124630 disableTerm(pLevel, pEnd);
 
 
124631 }
124632 start = sqlite3VdbeCurrentAddr(v);
124633 pLevel->op = bRev ? OP_Prev : OP_Next;
124634 pLevel->p1 = iCur;
124635 pLevel->p2 = start;
@@ -124692,10 +125700,12 @@
124692 OP_IdxGT, /* 1: (end_constraints && !bRev && endEq) */
124693 OP_IdxLE, /* 2: (end_constraints && bRev && !endEq) */
124694 OP_IdxLT, /* 3: (end_constraints && bRev && endEq) */
124695 };
124696 u16 nEq = pLoop->u.btree.nEq; /* Number of == or IN terms */
 
 
124697 int regBase; /* Base register holding constraint values */
124698 WhereTerm *pRangeStart = 0; /* Inequality constraint at range start */
124699 WhereTerm *pRangeEnd = 0; /* Inequality constraint at range end */
124700 int startEq; /* True if range start uses ==, >= or <= */
124701 int endEq; /* True if range end uses ==, >= or <= */
@@ -124704,11 +125714,11 @@
124704 Index *pIdx; /* The index we will be using */
124705 int iIdxCur; /* The VDBE cursor for the index */
124706 int nExtraReg = 0; /* Number of extra registers needed */
124707 int op; /* Instruction opcode */
124708 char *zStartAff; /* Affinity for start of range constraint */
124709 char cEndAff = 0; /* Affinity for end of range constraint */
124710 u8 bSeekPastNull = 0; /* True to seek past initial nulls */
124711 u8 bStopAtNull = 0; /* Add condition to terminate at NULLs */
124712
124713 pIdx = pLoop->u.btree.pIndex;
124714 iIdxCur = pLevel->iIdxCur;
@@ -124738,18 +125748,18 @@
124738 ** of the range.
124739 */
124740 j = nEq;
124741 if( pLoop->wsFlags & WHERE_BTM_LIMIT ){
124742 pRangeStart = pLoop->aLTerm[j++];
124743 nExtraReg = 1;
124744 /* Like optimization range constraints always occur in pairs */
124745 assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 ||
124746 (pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 );
124747 }
124748 if( pLoop->wsFlags & WHERE_TOP_LIMIT ){
124749 pRangeEnd = pLoop->aLTerm[j++];
124750 nExtraReg = 1;
124751 #ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
124752 if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){
124753 assert( pRangeStart!=0 ); /* LIKE opt constraints */
124754 assert( pRangeStart->wtFlags & TERM_LIKEOPT ); /* occur in pairs */
124755 pLevel->iLikeRepCntr = (u32)++pParse->nMem;
@@ -124781,20 +125791,23 @@
124781 if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))
124782 || (bRev && pIdx->nKeyCol==nEq)
124783 ){
124784 SWAP(WhereTerm *, pRangeEnd, pRangeStart);
124785 SWAP(u8, bSeekPastNull, bStopAtNull);
 
124786 }
124787
124788 /* Generate code to evaluate all constraint terms using == or IN
124789 ** and store the values of those terms in an array of registers
124790 ** starting at regBase.
124791 */
124792 codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd);
124793 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
124794 assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
124795 if( zStartAff ) cEndAff = zStartAff[nEq];
 
 
124796 addrNxt = pLevel->addrNxt;
124797
124798 testcase( pRangeStart && (pRangeStart->eOperator & WO_LE)!=0 );
124799 testcase( pRangeStart && (pRangeStart->eOperator & WO_GE)!=0 );
124800 testcase( pRangeEnd && (pRangeEnd->eOperator & WO_LE)!=0 );
@@ -124805,31 +125818,28 @@
124805
124806 /* Seek the index cursor to the start of the range. */
124807 nConstraint = nEq;
124808 if( pRangeStart ){
124809 Expr *pRight = pRangeStart->pExpr->pRight;
124810 sqlite3ExprCode(pParse, pRight, regBase+nEq);
124811 whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);
124812 if( (pRangeStart->wtFlags & TERM_VNULL)==0
124813 && sqlite3ExprCanBeNull(pRight)
124814 ){
124815 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
124816 VdbeCoverage(v);
124817 }
124818 if( zStartAff ){
124819 if( sqlite3CompareAffinity(pRight, zStartAff[nEq])==SQLITE_AFF_BLOB){
124820 /* Since the comparison is to be performed with no conversions
124821 ** applied to the operands, set the affinity to apply to pRight to
124822 ** SQLITE_AFF_BLOB. */
124823 zStartAff[nEq] = SQLITE_AFF_BLOB;
124824 }
124825 if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
124826 zStartAff[nEq] = SQLITE_AFF_BLOB;
124827 }
124828 }
124829 nConstraint++;
124830 testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
124831 bSeekPastNull = 0;
124832 }else if( bSeekPastNull ){
124833 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
124834 nConstraint++;
124835 startEq = 0;
@@ -124858,31 +125868,39 @@
124858 */
124859 nConstraint = nEq;
124860 if( pRangeEnd ){
124861 Expr *pRight = pRangeEnd->pExpr->pRight;
124862 sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
124863 sqlite3ExprCode(pParse, pRight, regBase+nEq);
124864 whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
124865 if( (pRangeEnd->wtFlags & TERM_VNULL)==0
124866 && sqlite3ExprCanBeNull(pRight)
124867 ){
124868 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
124869 VdbeCoverage(v);
124870 }
124871 if( sqlite3CompareAffinity(pRight, cEndAff)!=SQLITE_AFF_BLOB
124872 && !sqlite3ExprNeedsNoAffinityChange(pRight, cEndAff)
124873 ){
124874 codeApplyAffinity(pParse, regBase+nEq, 1, &cEndAff);
 
124875 }
124876 nConstraint++;
124877 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );
 
 
 
 
 
 
124878 }else if( bStopAtNull ){
124879 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
124880 endEq = 0;
124881 nConstraint++;
124882 }
124883 sqlite3DbFree(db, zStartAff);
 
124884
124885 /* Top of the loop body */
124886 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
124887
124888 /* Check if the index cursor is past the end of the range. */
@@ -124894,12 +125912,10 @@
124894 testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
124895 testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
124896 }
124897
124898 /* Seek the table cursor, if required */
124899 disableTerm(pLevel, pRangeStart);
124900 disableTerm(pLevel, pRangeEnd);
124901 if( omitTable ){
124902 /* pIdx is a covering index. No need to access the main table. */
124903 }else if( HasRowid(pIdx->pTable) ){
124904 if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE)!=0 ){
124905 iRowidReg = ++pParse->nMem;
@@ -124919,13 +125935,11 @@
124919 }
124920 sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,
124921 iRowidReg, pPk->nKeyCol); VdbeCoverage(v);
124922 }
124923
124924 /* Record the instruction used to terminate the loop. Disable
124925 ** WHERE clause terms made redundant by the index range scan.
124926 */
124927 if( pLoop->wsFlags & WHERE_ONEROW ){
124928 pLevel->op = OP_Noop;
124929 }else if( bRev ){
124930 pLevel->op = OP_Prev;
124931 }else{
@@ -124998,11 +126012,11 @@
124998 int untestedTerms = 0; /* Some terms not completely tested */
124999 int ii; /* Loop counter */
125000 u16 wctrlFlags; /* Flags for sub-WHERE clause */
125001 Expr *pAndExpr = 0; /* An ".. AND (...)" expression */
125002 Table *pTab = pTabItem->pTab;
125003
125004 pTerm = pLoop->aLTerm[0];
125005 assert( pTerm!=0 );
125006 assert( pTerm->eOperator & WO_OR );
125007 assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );
125008 pOrWc = &pTerm->u.pOrInfo->wc;
@@ -125450,11 +126464,11 @@
125450 }
125451
125452 /*
125453 ** Return TRUE if the given operator is one of the operators that is
125454 ** allowed for an indexable WHERE clause term. The allowed operators are
125455 ** "=", "<", ">", "<=", ">=", "IN", and "IS NULL"
125456 */
125457 static int allowedOp(int op){
125458 assert( TK_GT>TK_EQ && TK_GT<TK_GE );
125459 assert( TK_LT>TK_EQ && TK_LT<TK_GE );
125460 assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -126178,26 +127192,39 @@
126178 ** Expression pExpr is one operand of a comparison operator that might
126179 ** be useful for indexing. This routine checks to see if pExpr appears
126180 ** in any index. Return TRUE (1) if pExpr is an indexed term and return
126181 ** FALSE (0) if not. If TRUE is returned, also set *piCur to the cursor
126182 ** number of the table that is indexed and *piColumn to the column number
126183 ** of the column that is indexed, or -2 if an expression is being indexed.
 
126184 **
126185 ** If pExpr is a TK_COLUMN column reference, then this routine always returns
126186 ** true even if that particular column is not indexed, because the column
126187 ** might be added to an automatic index later.
126188 */
126189 static int exprMightBeIndexed(
126190 SrcList *pFrom, /* The FROM clause */
 
126191 Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */
126192 Expr *pExpr, /* An operand of a comparison operator */
126193 int *piCur, /* Write the referenced table cursor number here */
126194 int *piColumn /* Write the referenced table column number here */
126195 ){
126196 Index *pIdx;
126197 int i;
126198 int iCur;
 
 
 
 
 
 
 
 
 
 
 
126199 if( pExpr->op==TK_COLUMN ){
126200 *piCur = pExpr->iTable;
126201 *piColumn = pExpr->iColumn;
126202 return 1;
126203 }
@@ -126206,14 +127233,14 @@
126206 for(i=0; mPrereq>1; i++, mPrereq>>=1){}
126207 iCur = pFrom->a[i].iCursor;
126208 for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
126209 if( pIdx->aColExpr==0 ) continue;
126210 for(i=0; i<pIdx->nKeyCol; i++){
126211 if( pIdx->aiColumn[i]!=(-2) ) continue;
126212 if( sqlite3ExprCompare(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
126213 *piCur = iCur;
126214 *piColumn = -2;
126215 return 1;
126216 }
126217 }
126218 }
126219 return 0;
@@ -126266,10 +127293,11 @@
126266 assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );
126267 prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);
126268 op = pExpr->op;
126269 if( op==TK_IN ){
126270 assert( pExpr->pRight==0 );
 
126271 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
126272 pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect);
126273 }else{
126274 pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);
126275 }
@@ -126292,22 +127320,30 @@
126292 if( allowedOp(op) ){
126293 int iCur, iColumn;
126294 Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);
126295 Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);
126296 u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;
126297 if( exprMightBeIndexed(pSrc, prereqLeft, pLeft, &iCur, &iColumn) ){
 
 
 
 
 
 
 
126298 pTerm->leftCursor = iCur;
126299 pTerm->u.leftColumn = iColumn;
126300 pTerm->eOperator = operatorMask(op) & opMask;
126301 }
126302 if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;
126303 if( pRight
126304 && exprMightBeIndexed(pSrc, pTerm->prereqRight, pRight, &iCur, &iColumn)
126305 ){
126306 WhereTerm *pNew;
126307 Expr *pDup;
126308 u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */
 
126309 if( pTerm->leftCursor>=0 ){
126310 int idxNew;
126311 pDup = sqlite3ExprDup(db, pExpr, 0);
126312 if( db->mallocFailed ){
126313 sqlite3ExprDelete(db, pDup);
@@ -126506,10 +127542,63 @@
126506 pTerm->wtFlags |= TERM_COPIED;
126507 pNewTerm->prereqAll = pTerm->prereqAll;
126508 }
126509 }
126510 #endif /* SQLITE_OMIT_VIRTUALTABLE */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126511
126512 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
126513 /* When sqlite_stat3 histogram data is available an operator of the
126514 ** form "x IS NOT NULL" can sometimes be evaluated more efficiently
126515 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
@@ -127546,20 +128635,22 @@
127546 static sqlite3_index_info *allocateIndexInfo(
127547 Parse *pParse,
127548 WhereClause *pWC,
127549 Bitmask mUnusable, /* Ignore terms with these prereqs */
127550 struct SrcList_item *pSrc,
127551 ExprList *pOrderBy
 
127552 ){
127553 int i, j;
127554 int nTerm;
127555 struct sqlite3_index_constraint *pIdxCons;
127556 struct sqlite3_index_orderby *pIdxOrderBy;
127557 struct sqlite3_index_constraint_usage *pUsage;
127558 WhereTerm *pTerm;
127559 int nOrderBy;
127560 sqlite3_index_info *pIdxInfo;
 
127561
127562 /* Count the number of possible WHERE clause constraints referring
127563 ** to this virtual table */
127564 for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
127565 if( pTerm->leftCursor != pSrc->iCursor ) continue;
@@ -127644,18 +128735,28 @@
127644 assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE );
127645 assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT );
127646 assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE );
127647 assert( WO_MATCH==SQLITE_INDEX_CONSTRAINT_MATCH );
127648 assert( pTerm->eOperator & (WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_MATCH) );
 
 
 
 
 
 
 
 
 
127649 j++;
127650 }
127651 for(i=0; i<nOrderBy; i++){
127652 Expr *pExpr = pOrderBy->a[i].pExpr;
127653 pIdxOrderBy[i].iColumn = pExpr->iColumn;
127654 pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;
127655 }
127656
 
127657 return pIdxInfo;
127658 }
127659
127660 /*
127661 ** The table object reference passed as the second argument to this function
@@ -127927,11 +129028,11 @@
127927
127928 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
127929 /*
127930 ** Return the affinity for a single column of an index.
127931 */
127932 static char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){
127933 assert( iCol>=0 && iCol<pIdx->nColumn );
127934 if( !pIdx->zColAff ){
127935 if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;
127936 }
127937 return pIdx->zColAff[iCol];
@@ -128104,11 +129205,12 @@
128104
128105 if( p->nSample>0 && nEq<p->nSampleCol ){
128106 if( nEq==pBuilder->nRecValid ){
128107 UnpackedRecord *pRec = pBuilder->pRec;
128108 tRowcnt a[2];
128109 u8 aff;
 
128110
128111 /* Variable iLower will be set to the estimate of the number of rows in
128112 ** the index that are less than the lower bound of the range query. The
128113 ** lower bound being the concatenation of $P and $L, where $P is the
128114 ** key-prefix formed by the nEq values matched against the nEq left-most
@@ -128134,12 +129236,10 @@
128134
128135 if( pRec ){
128136 testcase( pRec->nField!=pBuilder->nRecValid );
128137 pRec->nField = pBuilder->nRecValid;
128138 }
128139 aff = sqlite3IndexColumnAffinity(pParse->db, p, nEq);
128140 assert( nEq!=p->nKeyCol || aff==SQLITE_AFF_INTEGER );
128141 /* Determine iLower and iUpper using ($P) only. */
128142 if( nEq==0 ){
128143 iLower = 0;
128144 iUpper = p->nRowEst0;
128145 }else{
@@ -128154,36 +129254,41 @@
128154 assert( pUpper==0 || (pUpper->eOperator & (WO_LT|WO_LE))!=0 );
128155 assert( p->aSortOrder!=0 );
128156 if( p->aSortOrder[nEq] ){
128157 /* The roles of pLower and pUpper are swapped for a DESC index */
128158 SWAP(WhereTerm*, pLower, pUpper);
 
128159 }
128160
128161 /* If possible, improve on the iLower estimate using ($P:$L). */
128162 if( pLower ){
128163 int bOk; /* True if value is extracted from pExpr */
128164 Expr *pExpr = pLower->pExpr->pRight;
128165 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk);
128166 if( rc==SQLITE_OK && bOk ){
128167 tRowcnt iNew;
 
 
128168 iLwrIdx = whereKeyStats(pParse, p, pRec, 0, a);
128169 iNew = a[0] + ((pLower->eOperator & (WO_GT|WO_LE)) ? a[1] : 0);
128170 if( iNew>iLower ) iLower = iNew;
128171 nOut--;
128172 pLower = 0;
128173 }
128174 }
128175
128176 /* If possible, improve on the iUpper estimate using ($P:$U). */
128177 if( pUpper ){
128178 int bOk; /* True if value is extracted from pExpr */
128179 Expr *pExpr = pUpper->pExpr->pRight;
128180 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk);
128181 if( rc==SQLITE_OK && bOk ){
128182 tRowcnt iNew;
 
 
128183 iUprIdx = whereKeyStats(pParse, p, pRec, 1, a);
128184 iNew = a[0] + ((pUpper->eOperator & (WO_GT|WO_LE)) ? a[1] : 0);
128185 if( iNew<iUpper ) iUpper = iNew;
128186 nOut--;
128187 pUpper = 0;
128188 }
128189 }
@@ -128269,11 +129374,10 @@
128269 tRowcnt *pnRow /* Write the revised row estimate here */
128270 ){
128271 Index *p = pBuilder->pNew->u.btree.pIndex;
128272 int nEq = pBuilder->pNew->u.btree.nEq;
128273 UnpackedRecord *pRec = pBuilder->pRec;
128274 u8 aff; /* Column affinity */
128275 int rc; /* Subfunction return code */
128276 tRowcnt a[2]; /* Statistics */
128277 int bOk;
128278
128279 assert( nEq>=1 );
@@ -128293,12 +129397,11 @@
128293 if( nEq>=p->nColumn ){
128294 *pnRow = 1;
128295 return SQLITE_OK;
128296 }
128297
128298 aff = sqlite3IndexColumnAffinity(pParse->db, p, nEq-1);
128299 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq-1, &bOk);
128300 pBuilder->pRec = pRec;
128301 if( rc!=SQLITE_OK ) return rc;
128302 if( bOk==0 ) return SQLITE_NOTFOUND;
128303 pBuilder->nRecValid = nEq;
128304
@@ -128383,13 +129486,18 @@
128383 pTerm->u.pOrInfo->indexable);
128384 }else{
128385 sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
128386 }
128387 sqlite3DebugPrintf(
128388 "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\n",
128389 iTerm, pTerm, zType, zLeft, pTerm->truthProb,
128390 pTerm->eOperator, pTerm->wtFlags);
 
 
 
 
 
128391 sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
128392 }
128393 }
128394 #endif
128395
@@ -128906,10 +130014,76 @@
128906 }
128907 }
128908 }
128909 if( pLoop->nOut > nRow-iReduce ) pLoop->nOut = nRow - iReduce;
128910 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128911
128912 /*
128913 ** Adjust the cost C by the costMult facter T. This only occurs if
128914 ** compiled with -DSQLITE_ENABLE_COSTMULT
128915 */
@@ -128945,10 +130119,12 @@
128945 int opMask; /* Valid operators for constraints */
128946 WhereScan scan; /* Iterator for WHERE terms */
128947 Bitmask saved_prereq; /* Original value of pNew->prereq */
128948 u16 saved_nLTerm; /* Original value of pNew->nLTerm */
128949 u16 saved_nEq; /* Original value of pNew->u.btree.nEq */
 
 
128950 u16 saved_nSkip; /* Original value of pNew->nSkip */
128951 u32 saved_wsFlags; /* Original value of pNew->wsFlags */
128952 LogEst saved_nOut; /* Original value of pNew->nOut */
128953 int rc = SQLITE_OK; /* Return code */
128954 LogEst rSize; /* Number of rows in the table */
@@ -128961,17 +130137,20 @@
128961 assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );
128962 assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
128963 if( pNew->wsFlags & WHERE_BTM_LIMIT ){
128964 opMask = WO_LT|WO_LE;
128965 }else{
 
128966 opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
128967 }
128968 if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
128969
128970 assert( pNew->u.btree.nEq<pProbe->nColumn );
128971
128972 saved_nEq = pNew->u.btree.nEq;
 
 
128973 saved_nSkip = pNew->nSkip;
128974 saved_nLTerm = pNew->nLTerm;
128975 saved_wsFlags = pNew->wsFlags;
128976 saved_prereq = pNew->prereq;
128977 saved_nOut = pNew->nOut;
@@ -129011,10 +130190,12 @@
129011 continue;
129012 }
129013
129014 pNew->wsFlags = saved_wsFlags;
129015 pNew->u.btree.nEq = saved_nEq;
 
 
129016 pNew->nLTerm = saved_nLTerm;
129017 if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
129018 pNew->aLTerm[pNew->nLTerm++] = pTerm;
129019 pNew->prereq = (saved_prereq | pTerm->prereqRight) & ~pNew->maskSelf;
129020
@@ -129027,18 +130208,27 @@
129027 if( eOp & WO_IN ){
129028 Expr *pExpr = pTerm->pExpr;
129029 pNew->wsFlags |= WHERE_COLUMN_IN;
129030 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
129031 /* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */
 
129032 nIn = 46; assert( 46==sqlite3LogEst(25) );
 
 
 
 
 
 
 
 
 
129033 }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
129034 /* "x IN (value, value, ...)" */
129035 nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
 
 
129036 }
129037 assert( nIn>0 ); /* RHS always has 2 or more terms... The parser
129038 ** changes "x IN (?)" into "x=?". */
129039
129040 }else if( eOp & (WO_EQ|WO_IS) ){
129041 int iCol = pProbe->aiColumn[saved_nEq];
129042 pNew->wsFlags |= WHERE_COLUMN_EQ;
129043 assert( saved_nEq==pNew->u.btree.nEq );
129044 if( iCol==XN_ROWID
@@ -129054,10 +130244,13 @@
129054 pNew->wsFlags |= WHERE_COLUMN_NULL;
129055 }else if( eOp & (WO_GT|WO_GE) ){
129056 testcase( eOp & WO_GT );
129057 testcase( eOp & WO_GE );
129058 pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
 
 
 
129059 pBtm = pTerm;
129060 pTop = 0;
129061 if( pTerm->wtFlags & TERM_LIKEOPT ){
129062 /* Range contraints that come from the LIKE optimization are
129063 ** always used in pairs. */
@@ -129066,16 +130259,20 @@
129066 assert( pTop->wtFlags & TERM_LIKEOPT );
129067 assert( pTop->eOperator==WO_LT );
129068 if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
129069 pNew->aLTerm[pNew->nLTerm++] = pTop;
129070 pNew->wsFlags |= WHERE_TOP_LIMIT;
 
129071 }
129072 }else{
129073 assert( eOp & (WO_LT|WO_LE) );
129074 testcase( eOp & WO_LT );
129075 testcase( eOp & WO_LE );
129076 pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_TOP_LIMIT;
 
 
 
129077 pTop = pTerm;
129078 pBtm = (pNew->wsFlags & WHERE_BTM_LIMIT)!=0 ?
129079 pNew->aLTerm[pNew->nLTerm-2] : 0;
129080 }
129081
@@ -129171,10 +130368,12 @@
129171 pBuilder->nRecValid = nRecValid;
129172 #endif
129173 }
129174 pNew->prereq = saved_prereq;
129175 pNew->u.btree.nEq = saved_nEq;
 
 
129176 pNew->nSkip = saved_nSkip;
129177 pNew->wsFlags = saved_wsFlags;
129178 pNew->nOut = saved_nOut;
129179 pNew->nLTerm = saved_nLTerm;
129180
@@ -129292,11 +130491,11 @@
129292 return 0;
129293 }
129294
129295 /*
129296 ** Add all WhereLoop objects for a single table of the join where the table
129297 ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be
129298 ** a b-tree table, not a virtual table.
129299 **
129300 ** The costs (WhereLoop.rRun) of the b-tree loops added by this function
129301 ** are calculated as follows:
129302 **
@@ -129446,10 +130645,12 @@
129446 testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
129447 continue; /* Partial index inappropriate for this query */
129448 }
129449 rSize = pProbe->aiRowLogEst[0];
129450 pNew->u.btree.nEq = 0;
 
 
129451 pNew->nSkip = 0;
129452 pNew->nLTerm = 0;
129453 pNew->iSortIdx = 0;
129454 pNew->rSetup = 0;
129455 pNew->prereq = mPrereq;
@@ -129574,10 +130775,11 @@
129574 WhereLoopBuilder *pBuilder,
129575 Bitmask mPrereq, /* Mask of tables that must be used. */
129576 Bitmask mUsable, /* Mask of usable tables */
129577 u16 mExclude, /* Exclude terms using these operators */
129578 sqlite3_index_info *pIdxInfo, /* Populated object for xBestIndex */
 
129579 int *pbIn /* OUT: True if plan uses an IN(...) op */
129580 ){
129581 WhereClause *pWC = pBuilder->pWC;
129582 struct sqlite3_index_constraint *pIdxCons;
129583 struct sqlite3_index_constraint_usage *pUsage = pIdxInfo->aConstraintUsage;
@@ -129662,10 +130864,11 @@
129662 pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;
129663 *pbIn = 1; assert( (mExclude & WO_IN)==0 );
129664 }
129665 }
129666 }
 
129667
129668 pNew->nLTerm = mxTerm+1;
129669 assert( pNew->nLTerm<=pNew->nLSlot );
129670 pNew->u.vtab.idxNum = pIdxInfo->idxNum;
129671 pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr;
@@ -129735,19 +130938,21 @@
129735 sqlite3_index_info *p; /* Object to pass to xBestIndex() */
129736 int nConstraint; /* Number of constraints in p */
129737 int bIn; /* True if plan uses IN(...) operator */
129738 WhereLoop *pNew;
129739 Bitmask mBest; /* Tables used by best possible plan */
 
129740
129741 assert( (mPrereq & mUnusable)==0 );
129742 pWInfo = pBuilder->pWInfo;
129743 pParse = pWInfo->pParse;
129744 pWC = pBuilder->pWC;
129745 pNew = pBuilder->pNew;
129746 pSrc = &pWInfo->pTabList->a[pNew->iTab];
129747 assert( IsVirtual(pSrc->pTab) );
129748 p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy);
 
129749 if( p==0 ) return SQLITE_NOMEM_BKPT;
129750 pNew->rSetup = 0;
129751 pNew->wsFlags = WHERE_VIRTUALTABLE;
129752 pNew->nLTerm = 0;
129753 pNew->u.vtab.needFree = 0;
@@ -129757,11 +130962,11 @@
129757 return SQLITE_NOMEM_BKPT;
129758 }
129759
129760 /* First call xBestIndex() with all constraints usable. */
129761 WHERETRACE(0x40, (" VirtualOne: all usable\n"));
129762 rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, &bIn);
129763
129764 /* If the call to xBestIndex() with all terms enabled produced a plan
129765 ** that does not require any source tables (IOW: a plan with mBest==0),
129766 ** then there is no point in making any further calls to xBestIndex()
129767 ** since they will all return the same result (if the xBestIndex()
@@ -129774,11 +130979,12 @@
129774
129775 /* If the plan produced by the earlier call uses an IN(...) term, call
129776 ** xBestIndex again, this time with IN(...) terms disabled. */
129777 if( bIn ){
129778 WHERETRACE(0x40, (" VirtualOne: all usable w/o IN\n"));
129779 rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, WO_IN, p, &bIn);
 
129780 assert( bIn==0 );
129781 mBestNoIn = pNew->prereq & ~mPrereq;
129782 if( mBestNoIn==0 ){
129783 seenZero = 1;
129784 seenZeroNoIN = 1;
@@ -129800,11 +131006,12 @@
129800 mPrev = mNext;
129801 if( mNext==ALLBITS ) break;
129802 if( mNext==mBest || mNext==mBestNoIn ) continue;
129803 WHERETRACE(0x40, (" VirtualOne: mPrev=%04llx mNext=%04llx\n",
129804 (sqlite3_uint64)mPrev, (sqlite3_uint64)mNext));
129805 rc = whereLoopAddVirtualOne(pBuilder, mPrereq, mNext|mPrereq, 0, p, &bIn);
 
129806 if( pNew->prereq==mPrereq ){
129807 seenZero = 1;
129808 if( bIn==0 ) seenZeroNoIN = 1;
129809 }
129810 }
@@ -129812,20 +131019,22 @@
129812 /* If the calls to xBestIndex() in the above loop did not find a plan
129813 ** that requires no source tables at all (i.e. one guaranteed to be
129814 ** usable), make a call here with all source tables disabled */
129815 if( rc==SQLITE_OK && seenZero==0 ){
129816 WHERETRACE(0x40, (" VirtualOne: all disabled\n"));
129817 rc = whereLoopAddVirtualOne(pBuilder, mPrereq, mPrereq, 0, p, &bIn);
 
129818 if( bIn==0 ) seenZeroNoIN = 1;
129819 }
129820
129821 /* If the calls to xBestIndex() have so far failed to find a plan
129822 ** that requires no source tables at all and does not use an IN(...)
129823 ** operator, make a final call to obtain one here. */
129824 if( rc==SQLITE_OK && seenZeroNoIN==0 ){
129825 WHERETRACE(0x40, (" VirtualOne: all disabled and w/o IN\n"));
129826 rc = whereLoopAddVirtualOne(pBuilder, mPrereq, mPrereq, WO_IN, p, &bIn);
 
129827 }
129828 }
129829
129830 if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);
129831 sqlite3DbFree(pParse->db, p);
@@ -130121,10 +131330,18 @@
130121 if( pOBExpr->op!=TK_COLUMN ) continue;
130122 if( pOBExpr->iTable!=iCur ) continue;
130123 pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
130124 ~ready, eqOpMask, 0);
130125 if( pTerm==0 ) continue;
 
 
 
 
 
 
 
 
130126 if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){
130127 const char *z1, *z2;
130128 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
130129 if( !pColl ) pColl = db->pDfltColl;
130130 z1 = pColl->zName;
@@ -130157,24 +131374,46 @@
130157 ** that are not constrained by == or IN.
130158 */
130159 rev = revSet = 0;
130160 distinctColumns = 0;
130161 for(j=0; j<nColumn; j++){
130162 u8 bOnce; /* True to run the ORDER BY search loop */
130163
130164 /* Skip over == and IS and ISNULL terms.
130165 ** (Also skip IN terms when doing WHERE_ORDERBY_LIMIT processing)
130166 */
130167 if( j<pLoop->u.btree.nEq
130168 && pLoop->nSkip==0
130169 && ((i = pLoop->aLTerm[j]->eOperator) & eqOpMask)!=0
130170 ){
130171 if( i & WO_ISNULL ){
130172 testcase( isOrderDistinct );
130173 isOrderDistinct = 0;
130174 }
130175 continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130176 }
130177
130178 /* Get the column number in the table (iColumn) and sort order
130179 ** (revIdx) for the j-th column of the index.
130180 */
@@ -130199,11 +131438,10 @@
130199 }
130200
130201 /* Find the ORDER BY term that corresponds to the j-th column
130202 ** of the index and mark that ORDER BY term off
130203 */
130204 bOnce = 1;
130205 isMatch = 0;
130206 for(i=0; bOnce && i<nOrderBy; i++){
130207 if( MASKBIT(i) & obSat ) continue;
130208 pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
130209 testcase( wctrlFlags & WHERE_GROUPBY );
@@ -131393,14 +132631,16 @@
131393 struct InLoop *pIn;
131394 int j;
131395 sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
131396 for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
131397 sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
131398 sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
131399 VdbeCoverage(v);
131400 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
131401 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
 
 
131402 sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
131403 }
131404 }
131405 sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
131406 if( pLevel->addrSkip ){
@@ -131843,20 +133083,20 @@
131843 #define sqlite3ParserARG_SDECL Parse *pParse;
131844 #define sqlite3ParserARG_PDECL ,Parse *pParse
131845 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
131846 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
131847 #define YYFALLBACK 1
131848 #define YYNSTATE 443
131849 #define YYNRULE 328
131850 #define YY_MAX_SHIFT 442
131851 #define YY_MIN_SHIFTREDUCE 653
131852 #define YY_MAX_SHIFTREDUCE 980
131853 #define YY_MIN_REDUCE 981
131854 #define YY_MAX_REDUCE 1308
131855 #define YY_ERROR_ACTION 1309
131856 #define YY_ACCEPT_ACTION 1310
131857 #define YY_NO_ACTION 1311
131858 /************* End control #defines *******************************************/
131859
131860 /* Define the yytestcase() macro to be a no-op if is not already defined
131861 ** otherwise.
131862 **
@@ -131924,163 +133164,170 @@
131924 ** yy_reduce_ofst[] For each state, the offset into yy_action for
131925 ** shifting non-terminals after a reduce.
131926 ** yy_default[] Default action for each state.
131927 **
131928 *********** Begin parsing tables **********************************************/
131929 #define YY_ACTTAB_COUNT (1507)
131930 static const YYACTIONTYPE yy_action[] = {
131931 /* 0 */ 317, 814, 341, 808, 5, 195, 195, 802, 93, 94,
131932 /* 10 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131933 /* 20 */ 92, 92, 92, 293, 90, 90, 90, 90, 89, 89,
131934 /* 30 */ 88, 88, 88, 87, 341, 317, 958, 958, 807, 807,
131935 /* 40 */ 807, 928, 344, 93, 94, 84, 823, 823, 835, 838,
131936 /* 50 */ 827, 827, 91, 91, 92, 92, 92, 92, 328, 90,
131937 /* 60 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
131938 /* 70 */ 89, 89, 88, 88, 88, 87, 341, 776, 958, 958,
131939 /* 80 */ 317, 88, 88, 88, 87, 341, 777, 69, 93, 94,
131940 /* 90 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92,
131941 /* 100 */ 92, 92, 92, 437, 90, 90, 90, 90, 89, 89,
131942 /* 110 */ 88, 88, 88, 87, 341, 1310, 147, 147, 2, 317,
131943 /* 120 */ 76, 25, 74, 49, 49, 87, 341, 93, 94, 84,
131944 /* 130 */ 823, 823, 835, 838, 827, 827, 91, 91, 92, 92,
131945 /* 140 */ 92, 92, 95, 90, 90, 90, 90, 89, 89, 88,
131946 /* 150 */ 88, 88, 87, 341, 939, 939, 317, 260, 415, 400,
131947 /* 160 */ 398, 58, 737, 737, 93, 94, 84, 823, 823, 835,
131948 /* 170 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 57,
131949 /* 180 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131950 /* 190 */ 341, 317, 1253, 928, 344, 269, 940, 941, 242, 93,
131951 /* 200 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131952 /* 210 */ 92, 92, 92, 92, 293, 90, 90, 90, 90, 89,
131953 /* 220 */ 89, 88, 88, 88, 87, 341, 317, 919, 1303, 793,
131954 /* 230 */ 691, 1303, 724, 724, 93, 94, 84, 823, 823, 835,
131955 /* 240 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 337,
131956 /* 250 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131957 /* 260 */ 341, 317, 114, 919, 1304, 684, 395, 1304, 124, 93,
131958 /* 270 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131959 /* 280 */ 92, 92, 92, 92, 683, 90, 90, 90, 90, 89,
131960 /* 290 */ 89, 88, 88, 88, 87, 341, 317, 86, 83, 169,
131961 /* 300 */ 801, 917, 234, 399, 93, 94, 84, 823, 823, 835,
131962 /* 310 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 686,
131963 /* 320 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131964 /* 330 */ 341, 317, 436, 742, 86, 83, 169, 917, 741, 93,
131965 /* 340 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131966 /* 350 */ 92, 92, 92, 92, 902, 90, 90, 90, 90, 89,
131967 /* 360 */ 89, 88, 88, 88, 87, 341, 317, 321, 434, 434,
131968 /* 370 */ 434, 1, 722, 722, 93, 94, 84, 823, 823, 835,
131969 /* 380 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 190,
131970 /* 390 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87,
131971 /* 400 */ 341, 317, 685, 292, 939, 939, 150, 977, 310, 93,
131972 /* 410 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91,
131973 /* 420 */ 92, 92, 92, 92, 437, 90, 90, 90, 90, 89,
131974 /* 430 */ 89, 88, 88, 88, 87, 341, 926, 2, 372, 719,
131975 /* 440 */ 698, 369, 950, 317, 49, 49, 940, 941, 719, 177,
131976 /* 450 */ 72, 93, 94, 84, 823, 823, 835, 838, 827, 827,
131977 /* 460 */ 91, 91, 92, 92, 92, 92, 322, 90, 90, 90,
131978 /* 470 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 415,
131979 /* 480 */ 405, 824, 824, 836, 839, 75, 93, 82, 84, 823,
131980 /* 490 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131981 /* 500 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88,
131982 /* 510 */ 88, 87, 341, 317, 340, 340, 340, 658, 659, 660,
131983 /* 520 */ 333, 288, 94, 84, 823, 823, 835, 838, 827, 827,
131984 /* 530 */ 91, 91, 92, 92, 92, 92, 437, 90, 90, 90,
131985 /* 540 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 882,
131986 /* 550 */ 882, 375, 828, 66, 330, 409, 49, 49, 84, 823,
131987 /* 560 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92,
131988 /* 570 */ 92, 351, 90, 90, 90, 90, 89, 89, 88, 88,
131989 /* 580 */ 88, 87, 341, 80, 432, 742, 3, 1180, 351, 350,
131990 /* 590 */ 741, 334, 796, 939, 939, 761, 80, 432, 278, 3,
131991 /* 600 */ 204, 161, 279, 393, 274, 392, 191, 362, 437, 277,
131992 /* 610 */ 745, 77, 78, 272, 800, 254, 355, 243, 79, 342,
131993 /* 620 */ 342, 86, 83, 169, 77, 78, 234, 399, 49, 49,
131994 /* 630 */ 435, 79, 342, 342, 437, 940, 941, 186, 442, 655,
131995 /* 640 */ 390, 387, 386, 435, 235, 213, 108, 421, 761, 351,
131996 /* 650 */ 437, 385, 167, 732, 10, 10, 124, 124, 671, 814,
131997 /* 660 */ 421, 439, 438, 415, 414, 802, 362, 168, 327, 124,
131998 /* 670 */ 49, 49, 814, 219, 439, 438, 800, 186, 802, 326,
131999 /* 680 */ 390, 387, 386, 437, 1248, 1248, 23, 939, 939, 80,
132000 /* 690 */ 432, 385, 3, 761, 416, 876, 807, 807, 807, 809,
132001 /* 700 */ 19, 290, 149, 49, 49, 415, 396, 260, 910, 807,
132002 /* 710 */ 807, 807, 809, 19, 312, 237, 145, 77, 78, 746,
132003 /* 720 */ 168, 702, 437, 149, 79, 342, 342, 114, 358, 940,
132004 /* 730 */ 941, 302, 223, 397, 345, 313, 435, 260, 415, 417,
132005 /* 740 */ 858, 374, 31, 31, 80, 432, 761, 3, 348, 92,
132006 /* 750 */ 92, 92, 92, 421, 90, 90, 90, 90, 89, 89,
132007 /* 760 */ 88, 88, 88, 87, 341, 814, 114, 439, 438, 796,
132008 /* 770 */ 367, 802, 77, 78, 701, 796, 124, 1187, 220, 79,
132009 /* 780 */ 342, 342, 124, 747, 734, 939, 939, 775, 404, 939,
132010 /* 790 */ 939, 435, 254, 360, 253, 402, 895, 346, 254, 360,
132011 /* 800 */ 253, 774, 807, 807, 807, 809, 19, 800, 421, 90,
132012 /* 810 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341,
132013 /* 820 */ 814, 114, 439, 438, 939, 939, 802, 940, 941, 114,
132014 /* 830 */ 437, 940, 941, 86, 83, 169, 192, 166, 309, 979,
132015 /* 840 */ 70, 432, 700, 3, 382, 870, 238, 86, 83, 169,
132016 /* 850 */ 10, 10, 361, 406, 763, 190, 222, 807, 807, 807,
132017 /* 860 */ 809, 19, 870, 872, 329, 24, 940, 941, 77, 78,
132018 /* 870 */ 359, 437, 335, 260, 218, 79, 342, 342, 437, 307,
132019 /* 880 */ 306, 305, 207, 303, 339, 338, 668, 435, 339, 338,
132020 /* 890 */ 407, 10, 10, 762, 216, 216, 939, 939, 49, 49,
132021 /* 900 */ 437, 260, 97, 241, 421, 225, 402, 189, 188, 187,
132022 /* 910 */ 309, 918, 980, 149, 221, 898, 814, 868, 439, 438,
132023 /* 920 */ 10, 10, 802, 870, 915, 316, 898, 163, 162, 171,
132024 /* 930 */ 249, 240, 322, 410, 412, 687, 687, 272, 940, 941,
132025 /* 940 */ 239, 965, 901, 437, 226, 403, 226, 437, 963, 367,
132026 /* 950 */ 964, 173, 248, 807, 807, 807, 809, 19, 174, 367,
132027 /* 960 */ 899, 124, 172, 48, 48, 9, 9, 35, 35, 966,
132028 /* 970 */ 966, 899, 363, 966, 966, 814, 900, 808, 725, 939,
132029 /* 980 */ 939, 802, 895, 318, 980, 324, 125, 900, 726, 420,
132030 /* 990 */ 92, 92, 92, 92, 85, 90, 90, 90, 90, 89,
132031 /* 1000 */ 89, 88, 88, 88, 87, 341, 216, 216, 437, 946,
132032 /* 1010 */ 349, 292, 807, 807, 807, 114, 291, 693, 402, 705,
132033 /* 1020 */ 890, 940, 941, 437, 245, 889, 247, 437, 36, 36,
132034 /* 1030 */ 437, 353, 391, 437, 260, 252, 260, 437, 361, 437,
132035 /* 1040 */ 706, 437, 370, 12, 12, 224, 437, 27, 27, 437,
132036 /* 1050 */ 37, 37, 437, 38, 38, 752, 368, 39, 39, 28,
132037 /* 1060 */ 28, 29, 29, 215, 166, 331, 40, 40, 437, 41,
132038 /* 1070 */ 41, 437, 42, 42, 437, 866, 246, 731, 437, 879,
132039 /* 1080 */ 437, 256, 437, 878, 437, 267, 437, 261, 11, 11,
132040 /* 1090 */ 437, 43, 43, 437, 99, 99, 437, 373, 44, 44,
132041 /* 1100 */ 45, 45, 32, 32, 46, 46, 47, 47, 437, 426,
132042 /* 1110 */ 33, 33, 776, 116, 116, 437, 117, 117, 437, 124,
132043 /* 1120 */ 437, 777, 437, 260, 437, 957, 437, 352, 118, 118,
132044 /* 1130 */ 437, 195, 437, 111, 437, 53, 53, 264, 34, 34,
132045 /* 1140 */ 100, 100, 50, 50, 101, 101, 102, 102, 437, 260,
132046 /* 1150 */ 98, 98, 115, 115, 113, 113, 437, 262, 437, 265,
132047 /* 1160 */ 437, 943, 958, 437, 727, 437, 681, 437, 106, 106,
132048 /* 1170 */ 68, 437, 893, 730, 437, 365, 105, 105, 103, 103,
132049 /* 1180 */ 104, 104, 217, 52, 52, 54, 54, 51, 51, 694,
132050 /* 1190 */ 259, 26, 26, 266, 30, 30, 677, 323, 433, 323,
132051 /* 1200 */ 674, 423, 427, 943, 958, 114, 114, 431, 681, 865,
132052 /* 1210 */ 1277, 233, 366, 714, 112, 20, 154, 704, 703, 810,
132053 /* 1220 */ 914, 55, 159, 311, 798, 255, 383, 194, 68, 200,
132054 /* 1230 */ 21, 694, 268, 114, 114, 114, 270, 711, 712, 68,
132055 /* 1240 */ 114, 739, 770, 715, 71, 194, 861, 875, 875, 200,
132056 /* 1250 */ 696, 865, 874, 874, 679, 699, 273, 110, 229, 419,
132057 /* 1260 */ 768, 810, 799, 378, 748, 759, 418, 210, 294, 281,
132058 /* 1270 */ 295, 806, 283, 682, 676, 665, 664, 666, 933, 151,
132059 /* 1280 */ 285, 7, 1267, 308, 251, 790, 354, 244, 892, 364,
132060 /* 1290 */ 287, 422, 300, 164, 160, 936, 974, 127, 197, 137,
132061 /* 1300 */ 909, 907, 971, 388, 276, 863, 862, 56, 698, 325,
132062 /* 1310 */ 148, 59, 122, 66, 356, 381, 357, 176, 152, 62,
132063 /* 1320 */ 371, 130, 877, 181, 377, 760, 211, 182, 132, 133,
132064 /* 1330 */ 134, 135, 258, 146, 140, 795, 787, 263, 183, 379,
132065 /* 1340 */ 667, 394, 184, 332, 894, 314, 718, 717, 857, 716,
132066 /* 1350 */ 696, 315, 709, 690, 65, 196, 6, 408, 289, 708,
132067 /* 1360 */ 275, 689, 688, 948, 756, 757, 280, 282, 425, 755,
132068 /* 1370 */ 284, 336, 73, 67, 754, 429, 411, 96, 286, 413,
132069 /* 1380 */ 205, 934, 673, 22, 209, 440, 119, 120, 109, 206,
132070 /* 1390 */ 208, 441, 662, 661, 656, 843, 654, 343, 158, 236,
132071 /* 1400 */ 170, 347, 107, 227, 121, 738, 873, 298, 296, 297,
132072 /* 1410 */ 299, 871, 794, 128, 129, 728, 230, 131, 175, 250,
132073 /* 1420 */ 888, 136, 138, 231, 232, 139, 60, 61, 891, 178,
132074 /* 1430 */ 179, 887, 8, 13, 180, 257, 880, 968, 194, 141,
132075 /* 1440 */ 142, 376, 153, 670, 380, 185, 143, 277, 63, 384,
132076 /* 1450 */ 14, 707, 271, 15, 389, 64, 319, 320, 126, 228,
132077 /* 1460 */ 813, 812, 841, 736, 123, 16, 401, 740, 4, 769,
132078 /* 1470 */ 165, 212, 214, 193, 144, 764, 71, 68, 17, 18,
132079 /* 1480 */ 856, 842, 840, 897, 845, 896, 199, 198, 923, 155,
132080 /* 1490 */ 424, 929, 924, 156, 201, 202, 428, 844, 157, 203,
132081 /* 1500 */ 811, 680, 81, 1269, 1268, 301, 304,
 
 
 
 
 
 
 
132082 };
132083 static const YYCODETYPE yy_lookahead[] = {
132084 /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
132085 /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
132086 /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
@@ -132091,285 +133338,295 @@
132091 /* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97,
132092 /* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28,
132093 /* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
132094 /* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
132095 /* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19,
132096 /* 120 */ 137, 22, 139, 172, 173, 52, 53, 27, 28, 29,
132097 /* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
132098 /* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49,
132099 /* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208,
132100 /* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32,
132101 /* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79,
132102 /* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132103 /* 190 */ 53, 19, 0, 1, 2, 23, 97, 98, 193, 27,
132104 /* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132105 /* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
132106 /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 163,
132107 /* 230 */ 23, 26, 190, 191, 27, 28, 29, 30, 31, 32,
132108 /* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
132109 /* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132110 /* 260 */ 53, 19, 196, 22, 23, 23, 49, 26, 92, 27,
132111 /* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132112 /* 280 */ 38, 39, 40, 41, 172, 43, 44, 45, 46, 47,
132113 /* 290 */ 48, 49, 50, 51, 52, 53, 19, 221, 222, 223,
132114 /* 300 */ 23, 96, 119, 120, 27, 28, 29, 30, 31, 32,
132115 /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 172,
132116 /* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132117 /* 330 */ 53, 19, 152, 116, 221, 222, 223, 96, 121, 27,
132118 /* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132119 /* 350 */ 38, 39, 40, 41, 241, 43, 44, 45, 46, 47,
132120 /* 360 */ 48, 49, 50, 51, 52, 53, 19, 157, 168, 169,
132121 /* 370 */ 170, 22, 190, 191, 27, 28, 29, 30, 31, 32,
132122 /* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 30,
132123 /* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
132124 /* 400 */ 53, 19, 172, 152, 55, 56, 24, 247, 248, 27,
132125 /* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
132126 /* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
132127 /* 430 */ 48, 49, 50, 51, 52, 53, 146, 147, 228, 179,
132128 /* 440 */ 180, 231, 185, 19, 172, 173, 97, 98, 188, 26,
132129 /* 450 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35,
132130 /* 460 */ 36, 37, 38, 39, 40, 41, 107, 43, 44, 45,
132131 /* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 207,
132132 /* 480 */ 208, 30, 31, 32, 33, 138, 27, 28, 29, 30,
132133 /* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
132134 /* 500 */ 41, 250, 43, 44, 45, 46, 47, 48, 49, 50,
132135 /* 510 */ 51, 52, 53, 19, 168, 169, 170, 7, 8, 9,
132136 /* 520 */ 19, 152, 28, 29, 30, 31, 32, 33, 34, 35,
132137 /* 530 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45,
132138 /* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 108,
132139 /* 550 */ 109, 110, 101, 130, 53, 152, 172, 173, 29, 30,
132140 /* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
132141 /* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50,
132142 /* 580 */ 51, 52, 53, 19, 20, 116, 22, 23, 169, 170,
132143 /* 590 */ 121, 207, 85, 55, 56, 26, 19, 20, 101, 22,
132144 /* 600 */ 99, 100, 101, 102, 103, 104, 105, 152, 152, 112,
132145 /* 610 */ 210, 47, 48, 112, 152, 108, 109, 110, 54, 55,
132146 /* 620 */ 56, 221, 222, 223, 47, 48, 119, 120, 172, 173,
132147 /* 630 */ 66, 54, 55, 56, 152, 97, 98, 99, 148, 149,
132148 /* 640 */ 102, 103, 104, 66, 154, 23, 156, 83, 26, 230,
132149 /* 650 */ 152, 113, 152, 163, 172, 173, 92, 92, 21, 95,
132150 /* 660 */ 83, 97, 98, 207, 208, 101, 152, 98, 186, 92,
132151 /* 670 */ 172, 173, 95, 218, 97, 98, 152, 99, 101, 217,
132152 /* 680 */ 102, 103, 104, 152, 119, 120, 196, 55, 56, 19,
132153 /* 690 */ 20, 113, 22, 124, 163, 11, 132, 133, 134, 135,
132154 /* 700 */ 136, 152, 152, 172, 173, 207, 208, 152, 152, 132,
132155 /* 710 */ 133, 134, 135, 136, 164, 152, 84, 47, 48, 49,
132156 /* 720 */ 98, 181, 152, 152, 54, 55, 56, 196, 91, 97,
132157 /* 730 */ 98, 160, 218, 163, 244, 164, 66, 152, 207, 208,
132158 /* 740 */ 103, 217, 172, 173, 19, 20, 124, 22, 193, 38,
132159 /* 750 */ 39, 40, 41, 83, 43, 44, 45, 46, 47, 48,
132160 /* 760 */ 49, 50, 51, 52, 53, 95, 196, 97, 98, 85,
132161 /* 770 */ 152, 101, 47, 48, 181, 85, 92, 140, 193, 54,
132162 /* 780 */ 55, 56, 92, 49, 195, 55, 56, 175, 163, 55,
132163 /* 790 */ 56, 66, 108, 109, 110, 206, 163, 242, 108, 109,
132164 /* 800 */ 110, 175, 132, 133, 134, 135, 136, 152, 83, 43,
132165 /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
132166 /* 820 */ 95, 196, 97, 98, 55, 56, 101, 97, 98, 196,
132167 /* 830 */ 152, 97, 98, 221, 222, 223, 211, 212, 22, 23,
132168 /* 840 */ 19, 20, 181, 22, 19, 152, 152, 221, 222, 223,
132169 /* 850 */ 172, 173, 219, 19, 124, 30, 238, 132, 133, 134,
132170 /* 860 */ 135, 136, 169, 170, 186, 232, 97, 98, 47, 48,
132171 /* 870 */ 237, 152, 217, 152, 5, 54, 55, 56, 152, 10,
132172 /* 880 */ 11, 12, 13, 14, 47, 48, 17, 66, 47, 48,
132173 /* 890 */ 56, 172, 173, 124, 194, 195, 55, 56, 172, 173,
132174 /* 900 */ 152, 152, 22, 152, 83, 186, 206, 108, 109, 110,
132175 /* 910 */ 22, 23, 96, 152, 193, 12, 95, 152, 97, 98,
132176 /* 920 */ 172, 173, 101, 230, 152, 164, 12, 47, 48, 60,
132177 /* 930 */ 152, 62, 107, 207, 186, 55, 56, 112, 97, 98,
132178 /* 940 */ 71, 100, 193, 152, 183, 152, 185, 152, 107, 152,
132179 /* 950 */ 109, 82, 16, 132, 133, 134, 135, 136, 89, 152,
132180 /* 960 */ 57, 92, 93, 172, 173, 172, 173, 172, 173, 132,
132181 /* 970 */ 133, 57, 152, 132, 133, 95, 73, 97, 75, 55,
132182 /* 980 */ 56, 101, 163, 114, 96, 245, 246, 73, 85, 75,
132183 /* 990 */ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
132184 /* 1000 */ 48, 49, 50, 51, 52, 53, 194, 195, 152, 171,
132185 /* 1010 */ 141, 152, 132, 133, 134, 196, 225, 179, 206, 65,
132186 /* 1020 */ 152, 97, 98, 152, 88, 152, 90, 152, 172, 173,
132187 /* 1030 */ 152, 219, 78, 152, 152, 238, 152, 152, 219, 152,
132188 /* 1040 */ 86, 152, 152, 172, 173, 238, 152, 172, 173, 152,
132189 /* 1050 */ 172, 173, 152, 172, 173, 213, 237, 172, 173, 172,
132190 /* 1060 */ 173, 172, 173, 211, 212, 111, 172, 173, 152, 172,
132191 /* 1070 */ 173, 152, 172, 173, 152, 193, 140, 193, 152, 59,
132192 /* 1080 */ 152, 152, 152, 63, 152, 16, 152, 152, 172, 173,
132193 /* 1090 */ 152, 172, 173, 152, 172, 173, 152, 77, 172, 173,
132194 /* 1100 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 250,
132195 /* 1110 */ 172, 173, 61, 172, 173, 152, 172, 173, 152, 92,
132196 /* 1120 */ 152, 70, 152, 152, 152, 26, 152, 100, 172, 173,
132197 /* 1130 */ 152, 24, 152, 22, 152, 172, 173, 152, 172, 173,
132198 /* 1140 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 152,
132199 /* 1150 */ 172, 173, 172, 173, 172, 173, 152, 88, 152, 90,
132200 /* 1160 */ 152, 55, 55, 152, 193, 152, 55, 152, 172, 173,
132201 /* 1170 */ 26, 152, 163, 163, 152, 19, 172, 173, 172, 173,
132202 /* 1180 */ 172, 173, 22, 172, 173, 172, 173, 172, 173, 55,
132203 /* 1190 */ 193, 172, 173, 152, 172, 173, 166, 167, 166, 167,
132204 /* 1200 */ 163, 163, 163, 97, 97, 196, 196, 163, 97, 55,
132205 /* 1210 */ 23, 199, 56, 26, 22, 22, 24, 100, 101, 55,
132206 /* 1220 */ 23, 209, 123, 26, 23, 23, 23, 26, 26, 26,
132207 /* 1230 */ 37, 97, 152, 196, 196, 196, 23, 7, 8, 26,
132208 /* 1240 */ 196, 23, 23, 152, 26, 26, 23, 132, 133, 26,
132209 /* 1250 */ 106, 97, 132, 133, 23, 152, 152, 26, 210, 191,
132210 /* 1260 */ 152, 97, 152, 234, 152, 152, 152, 233, 152, 210,
132211 /* 1270 */ 152, 152, 210, 152, 152, 152, 152, 152, 152, 197,
132212 /* 1280 */ 210, 198, 122, 150, 239, 201, 214, 214, 201, 239,
132213 /* 1290 */ 214, 227, 200, 184, 198, 155, 67, 243, 122, 22,
132214 /* 1300 */ 159, 159, 69, 176, 175, 175, 175, 240, 180, 159,
132215 /* 1310 */ 220, 240, 27, 130, 18, 18, 159, 158, 220, 137,
132216 /* 1320 */ 159, 189, 236, 158, 74, 159, 159, 158, 192, 192,
132217 /* 1330 */ 192, 192, 235, 22, 189, 189, 201, 159, 158, 177,
132218 /* 1340 */ 159, 107, 158, 76, 201, 177, 174, 174, 201, 174,
132219 /* 1350 */ 106, 177, 182, 174, 107, 159, 22, 125, 159, 182,
132220 /* 1360 */ 174, 176, 174, 174, 216, 216, 215, 215, 177, 216,
132221 /* 1370 */ 215, 53, 137, 128, 216, 177, 127, 129, 215, 126,
132222 /* 1380 */ 25, 13, 162, 26, 6, 161, 165, 165, 178, 153,
132223 /* 1390 */ 153, 151, 151, 151, 151, 224, 4, 3, 22, 142,
132224 /* 1400 */ 15, 94, 16, 178, 165, 205, 23, 202, 204, 203,
132225 /* 1410 */ 201, 23, 120, 131, 111, 20, 226, 123, 125, 16,
132226 /* 1420 */ 1, 123, 131, 229, 229, 111, 37, 37, 56, 64,
132227 /* 1430 */ 122, 1, 5, 22, 107, 140, 80, 87, 26, 80,
132228 /* 1440 */ 107, 72, 24, 20, 19, 105, 22, 112, 22, 79,
132229 /* 1450 */ 22, 58, 23, 22, 79, 22, 249, 249, 246, 79,
132230 /* 1460 */ 23, 23, 23, 116, 68, 22, 26, 23, 22, 56,
132231 /* 1470 */ 122, 23, 23, 64, 22, 124, 26, 26, 64, 64,
132232 /* 1480 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22,
132233 /* 1490 */ 24, 1, 23, 22, 26, 122, 24, 23, 22, 122,
132234 /* 1500 */ 23, 23, 22, 122, 122, 23, 15,
132235 };
132236 #define YY_SHIFT_USE_DFLT (1507)
132237 #define YY_SHIFT_COUNT (442)
 
 
 
 
 
 
 
132238 #define YY_SHIFT_MIN (-94)
132239 #define YY_SHIFT_MAX (1491)
132240 static const short yy_shift_ofst[] = {
132241 /* 0 */ 40, 564, 869, 577, 725, 725, 725, 725, 690, -19,
132242 /* 10 */ 16, 16, 100, 725, 725, 725, 725, 725, 725, 725,
132243 /* 20 */ 841, 841, 538, 507, 684, 565, 61, 137, 172, 207,
132244 /* 30 */ 242, 277, 312, 347, 382, 424, 424, 424, 424, 424,
132245 /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 424,
132246 /* 50 */ 459, 424, 494, 529, 529, 670, 725, 725, 725, 725,
132247 /* 60 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
132248 /* 70 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725,
132249 /* 80 */ 725, 725, 725, 725, 821, 725, 725, 725, 725, 725,
132250 /* 90 */ 725, 725, 725, 725, 725, 725, 725, 725, 952, 711,
132251 /* 100 */ 711, 711, 711, 711, 766, 23, 32, 924, 637, 825,
132252 /* 110 */ 837, 837, 924, 73, 183, -51, 1507, 1507, 1507, 501,
132253 /* 120 */ 501, 501, 903, 903, 632, 205, 241, 924, 924, 924,
132254 /* 130 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132255 /* 140 */ 924, 924, 924, 924, 924, 924, 924, 192, 1027, 1106,
132256 /* 150 */ 1106, 183, 176, 176, 176, 176, 176, 176, 1507, 1507,
132257 /* 160 */ 1507, 880, -94, -94, 578, 734, 99, 730, 769, 349,
132258 /* 170 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132259 /* 180 */ 924, 924, 924, 924, 924, 924, 924, 954, 954, 954,
132260 /* 190 */ 924, 924, 622, 924, 924, 924, -18, 924, 924, 914,
132261 /* 200 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
132262 /* 210 */ 441, 1020, 1107, 1107, 1107, 569, 45, 217, 510, 423,
132263 /* 220 */ 834, 834, 1156, 423, 1156, 1144, 1187, 359, 1051, 834,
132264 /* 230 */ -17, 1051, 1051, 1099, 469, 1192, 1229, 1176, 1176, 1233,
132265 /* 240 */ 1233, 1176, 1277, 1285, 1183, 1296, 1296, 1296, 1296, 1176,
132266 /* 250 */ 1297, 1183, 1277, 1285, 1285, 1183, 1176, 1297, 1182, 1250,
132267 /* 260 */ 1176, 1176, 1297, 1311, 1176, 1297, 1176, 1297, 1311, 1234,
132268 /* 270 */ 1234, 1234, 1267, 1311, 1234, 1244, 1234, 1267, 1234, 1234,
132269 /* 280 */ 1232, 1247, 1232, 1247, 1232, 1247, 1232, 1247, 1176, 1334,
132270 /* 290 */ 1176, 1235, 1311, 1318, 1318, 1311, 1248, 1253, 1245, 1249,
132271 /* 300 */ 1183, 1355, 1357, 1368, 1368, 1378, 1378, 1378, 1378, 1507,
132272 /* 310 */ 1507, 1507, 1507, 1507, 1507, 1507, 1507, 451, 936, 816,
132273 /* 320 */ 888, 1069, 799, 1111, 1197, 1193, 1201, 1202, 1203, 1213,
132274 /* 330 */ 1134, 1117, 1230, 497, 1218, 1219, 1154, 1223, 1115, 1120,
132275 /* 340 */ 1231, 1164, 1160, 1392, 1394, 1376, 1257, 1385, 1307, 1386,
132276 /* 350 */ 1383, 1388, 1292, 1282, 1303, 1294, 1395, 1293, 1403, 1419,
132277 /* 360 */ 1298, 1291, 1389, 1390, 1314, 1372, 1365, 1308, 1430, 1427,
132278 /* 370 */ 1411, 1327, 1295, 1356, 1412, 1359, 1350, 1369, 1333, 1418,
132279 /* 380 */ 1423, 1425, 1335, 1340, 1424, 1370, 1426, 1428, 1429, 1431,
132280 /* 390 */ 1375, 1393, 1433, 1380, 1396, 1437, 1438, 1439, 1347, 1443,
132281 /* 400 */ 1444, 1446, 1440, 1348, 1448, 1449, 1413, 1409, 1452, 1351,
132282 /* 410 */ 1450, 1414, 1451, 1415, 1457, 1450, 1458, 1459, 1460, 1461,
132283 /* 420 */ 1462, 1464, 1473, 1465, 1467, 1466, 1468, 1469, 1471, 1472,
132284 /* 430 */ 1468, 1474, 1476, 1477, 1478, 1480, 1373, 1377, 1381, 1382,
132285 /* 440 */ 1482, 1491, 1490,
 
132286 };
132287 #define YY_REDUCE_USE_DFLT (-130)
132288 #define YY_REDUCE_COUNT (316)
132289 #define YY_REDUCE_MIN (-129)
132290 #define YY_REDUCE_MAX (1243)
132291 static const short yy_reduce_ofst[] = {
132292 /* 0 */ -29, 531, 490, 570, -49, 272, 456, 498, 633, 400,
132293 /* 10 */ 612, 626, 113, 482, 678, 719, 384, 726, 748, 791,
132294 /* 20 */ 419, 693, 761, 812, 819, 625, 76, 76, 76, 76,
132295 /* 30 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132296 /* 40 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
132297 /* 50 */ 76, 76, 76, 76, 76, 793, 795, 856, 871, 875,
132298 /* 60 */ 878, 881, 885, 887, 889, 894, 897, 900, 916, 919,
132299 /* 70 */ 922, 926, 928, 930, 932, 934, 938, 941, 944, 956,
132300 /* 80 */ 963, 966, 968, 970, 972, 974, 978, 980, 982, 996,
132301 /* 90 */ 1004, 1006, 1008, 1011, 1013, 1015, 1019, 1022, 76, 76,
132302 /* 100 */ 76, 76, 76, 76, 76, 76, 76, 555, 210, 260,
132303 /* 110 */ 200, 346, 571, 76, 700, 76, 76, 76, 76, 838,
132304 /* 120 */ 838, 838, 42, 182, 251, 160, 160, 550, 5, 455,
132305 /* 130 */ 585, 721, 749, 882, 884, 971, 618, 462, 797, 514,
132306 /* 140 */ 807, 524, 997, -129, 655, 859, 62, 290, 66, 1030,
132307 /* 150 */ 1032, 589, 1009, 1010, 1037, 1038, 1039, 1044, 740, 852,
132308 /* 160 */ 1012, 112, 147, 230, 257, 180, 369, 403, 500, 549,
132309 /* 170 */ 556, 563, 694, 751, 765, 772, 778, 820, 868, 873,
132310 /* 180 */ 890, 929, 935, 985, 1041, 1080, 1091, 540, 593, 661,
132311 /* 190 */ 1103, 1104, 842, 1108, 1110, 1112, 1048, 1113, 1114, 1068,
132312 /* 200 */ 1116, 1118, 1119, 180, 1121, 1122, 1123, 1124, 1125, 1126,
132313 /* 210 */ 1029, 1034, 1059, 1062, 1070, 842, 1082, 1083, 1133, 1084,
132314 /* 220 */ 1072, 1073, 1045, 1087, 1050, 1127, 1109, 1128, 1129, 1076,
132315 /* 230 */ 1064, 1130, 1131, 1092, 1096, 1140, 1054, 1141, 1142, 1067,
132316 /* 240 */ 1071, 1150, 1090, 1132, 1135, 1136, 1137, 1138, 1139, 1157,
132317 /* 250 */ 1159, 1143, 1098, 1145, 1146, 1147, 1161, 1165, 1086, 1097,
132318 /* 260 */ 1166, 1167, 1169, 1162, 1178, 1180, 1181, 1184, 1168, 1172,
132319 /* 270 */ 1173, 1175, 1170, 1174, 1179, 1185, 1186, 1177, 1188, 1189,
132320 /* 280 */ 1148, 1151, 1149, 1152, 1153, 1155, 1158, 1163, 1196, 1171,
132321 /* 290 */ 1199, 1190, 1191, 1194, 1195, 1198, 1200, 1204, 1206, 1205,
132322 /* 300 */ 1209, 1220, 1224, 1236, 1237, 1240, 1241, 1242, 1243, 1207,
132323 /* 310 */ 1208, 1212, 1221, 1222, 1210, 1225, 1239,
 
132324 };
132325 static const YYACTIONTYPE yy_default[] = {
132326 /* 0 */ 1258, 1248, 1248, 1248, 1180, 1180, 1180, 1180, 1248, 1077,
132327 /* 10 */ 1106, 1106, 1232, 1309, 1309, 1309, 1309, 1309, 1309, 1179,
132328 /* 20 */ 1309, 1309, 1309, 1309, 1248, 1081, 1112, 1309, 1309, 1309,
132329 /* 30 */ 1309, 1309, 1309, 1309, 1309, 1231, 1233, 1120, 1119, 1214,
132330 /* 40 */ 1093, 1117, 1110, 1114, 1181, 1175, 1176, 1174, 1178, 1182,
132331 /* 50 */ 1309, 1113, 1144, 1159, 1143, 1309, 1309, 1309, 1309, 1309,
132332 /* 60 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132333 /* 70 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132334 /* 80 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132335 /* 90 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1153, 1158,
132336 /* 100 */ 1165, 1157, 1154, 1146, 1145, 1147, 1148, 1309, 1000, 1048,
132337 /* 110 */ 1309, 1309, 1309, 1149, 1309, 1150, 1162, 1161, 1160, 1239,
132338 /* 120 */ 1266, 1265, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132339 /* 130 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132340 /* 140 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1258, 1248, 1006,
132341 /* 150 */ 1006, 1309, 1248, 1248, 1248, 1248, 1248, 1248, 1244, 1081,
132342 /* 160 */ 1072, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132343 /* 170 */ 1309, 1236, 1234, 1309, 1195, 1309, 1309, 1309, 1309, 1309,
132344 /* 180 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132345 /* 190 */ 1309, 1309, 1309, 1309, 1309, 1309, 1077, 1309, 1309, 1309,
132346 /* 200 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1260,
132347 /* 210 */ 1309, 1209, 1077, 1077, 1077, 1079, 1061, 1071, 985, 1116,
132348 /* 220 */ 1095, 1095, 1298, 1116, 1298, 1023, 1280, 1020, 1106, 1095,
132349 /* 230 */ 1177, 1106, 1106, 1078, 1071, 1309, 1301, 1086, 1086, 1300,
132350 /* 240 */ 1300, 1086, 1125, 1051, 1116, 1057, 1057, 1057, 1057, 1086,
132351 /* 250 */ 997, 1116, 1125, 1051, 1051, 1116, 1086, 997, 1213, 1295,
132352 /* 260 */ 1086, 1086, 997, 1188, 1086, 997, 1086, 997, 1188, 1049,
132353 /* 270 */ 1049, 1049, 1038, 1188, 1049, 1023, 1049, 1038, 1049, 1049,
132354 /* 280 */ 1099, 1094, 1099, 1094, 1099, 1094, 1099, 1094, 1086, 1183,
132355 /* 290 */ 1086, 1309, 1188, 1192, 1192, 1188, 1111, 1100, 1109, 1107,
132356 /* 300 */ 1116, 1003, 1041, 1263, 1263, 1259, 1259, 1259, 1259, 1306,
132357 /* 310 */ 1306, 1244, 1275, 1275, 1025, 1025, 1275, 1309, 1309, 1309,
132358 /* 320 */ 1309, 1309, 1309, 1270, 1309, 1197, 1309, 1309, 1309, 1309,
132359 /* 330 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132360 /* 340 */ 1309, 1309, 1131, 1309, 981, 1241, 1309, 1309, 1240, 1309,
132361 /* 350 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132362 /* 360 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1297, 1309, 1309,
132363 /* 370 */ 1309, 1309, 1309, 1309, 1212, 1211, 1309, 1309, 1309, 1309,
132364 /* 380 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132365 /* 390 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1063, 1309,
132366 /* 400 */ 1309, 1309, 1284, 1309, 1309, 1309, 1309, 1309, 1309, 1309,
132367 /* 410 */ 1108, 1309, 1101, 1309, 1309, 1288, 1309, 1309, 1309, 1309,
132368 /* 420 */ 1309, 1309, 1309, 1309, 1309, 1309, 1250, 1309, 1309, 1309,
132369 /* 430 */ 1249, 1309, 1309, 1309, 1309, 1309, 1133, 1309, 1132, 1136,
132370 /* 440 */ 1309, 991, 1309,
 
132371 };
132372 /********** End of lemon-generated parsing tables *****************************/
132373
132374 /* The next table maps tokens (terminal symbols) into fallback tokens.
132375 ** If a construct like the following:
@@ -132775,199 +134032,202 @@
132775 /* 134 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
132776 /* 135 */ "where_opt ::=",
132777 /* 136 */ "where_opt ::= WHERE expr",
132778 /* 137 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
132779 /* 138 */ "setlist ::= setlist COMMA nm EQ expr",
132780 /* 139 */ "setlist ::= nm EQ expr",
132781 /* 140 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
132782 /* 141 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
132783 /* 142 */ "insert_cmd ::= INSERT orconf",
132784 /* 143 */ "insert_cmd ::= REPLACE",
132785 /* 144 */ "idlist_opt ::=",
132786 /* 145 */ "idlist_opt ::= LP idlist RP",
132787 /* 146 */ "idlist ::= idlist COMMA nm",
132788 /* 147 */ "idlist ::= nm",
132789 /* 148 */ "expr ::= LP expr RP",
132790 /* 149 */ "term ::= NULL",
132791 /* 150 */ "expr ::= ID|INDEXED",
132792 /* 151 */ "expr ::= JOIN_KW",
132793 /* 152 */ "expr ::= nm DOT nm",
132794 /* 153 */ "expr ::= nm DOT nm DOT nm",
132795 /* 154 */ "term ::= INTEGER|FLOAT|BLOB",
132796 /* 155 */ "term ::= STRING",
132797 /* 156 */ "expr ::= VARIABLE",
132798 /* 157 */ "expr ::= expr COLLATE ID|STRING",
132799 /* 158 */ "expr ::= CAST LP expr AS typetoken RP",
132800 /* 159 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
132801 /* 160 */ "expr ::= ID|INDEXED LP STAR RP",
132802 /* 161 */ "term ::= CTIME_KW",
132803 /* 162 */ "expr ::= expr AND expr",
132804 /* 163 */ "expr ::= expr OR expr",
132805 /* 164 */ "expr ::= expr LT|GT|GE|LE expr",
132806 /* 165 */ "expr ::= expr EQ|NE expr",
132807 /* 166 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
132808 /* 167 */ "expr ::= expr PLUS|MINUS expr",
132809 /* 168 */ "expr ::= expr STAR|SLASH|REM expr",
132810 /* 169 */ "expr ::= expr CONCAT expr",
132811 /* 170 */ "likeop ::= LIKE_KW|MATCH",
132812 /* 171 */ "likeop ::= NOT LIKE_KW|MATCH",
132813 /* 172 */ "expr ::= expr likeop expr",
132814 /* 173 */ "expr ::= expr likeop expr ESCAPE expr",
132815 /* 174 */ "expr ::= expr ISNULL|NOTNULL",
132816 /* 175 */ "expr ::= expr NOT NULL",
132817 /* 176 */ "expr ::= expr IS expr",
132818 /* 177 */ "expr ::= expr IS NOT expr",
132819 /* 178 */ "expr ::= NOT expr",
132820 /* 179 */ "expr ::= BITNOT expr",
132821 /* 180 */ "expr ::= MINUS expr",
132822 /* 181 */ "expr ::= PLUS expr",
132823 /* 182 */ "between_op ::= BETWEEN",
132824 /* 183 */ "between_op ::= NOT BETWEEN",
132825 /* 184 */ "expr ::= expr between_op expr AND expr",
132826 /* 185 */ "in_op ::= IN",
132827 /* 186 */ "in_op ::= NOT IN",
132828 /* 187 */ "expr ::= expr in_op LP exprlist RP",
132829 /* 188 */ "expr ::= LP select RP",
132830 /* 189 */ "expr ::= expr in_op LP select RP",
132831 /* 190 */ "expr ::= expr in_op nm dbnm paren_exprlist",
132832 /* 191 */ "expr ::= EXISTS LP select RP",
132833 /* 192 */ "expr ::= CASE case_operand case_exprlist case_else END",
132834 /* 193 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
132835 /* 194 */ "case_exprlist ::= WHEN expr THEN expr",
132836 /* 195 */ "case_else ::= ELSE expr",
132837 /* 196 */ "case_else ::=",
132838 /* 197 */ "case_operand ::= expr",
132839 /* 198 */ "case_operand ::=",
132840 /* 199 */ "exprlist ::=",
132841 /* 200 */ "nexprlist ::= nexprlist COMMA expr",
132842 /* 201 */ "nexprlist ::= expr",
132843 /* 202 */ "paren_exprlist ::=",
132844 /* 203 */ "paren_exprlist ::= LP exprlist RP",
132845 /* 204 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
132846 /* 205 */ "uniqueflag ::= UNIQUE",
132847 /* 206 */ "uniqueflag ::=",
132848 /* 207 */ "eidlist_opt ::=",
132849 /* 208 */ "eidlist_opt ::= LP eidlist RP",
132850 /* 209 */ "eidlist ::= eidlist COMMA nm collate sortorder",
132851 /* 210 */ "eidlist ::= nm collate sortorder",
132852 /* 211 */ "collate ::=",
132853 /* 212 */ "collate ::= COLLATE ID|STRING",
132854 /* 213 */ "cmd ::= DROP INDEX ifexists fullname",
132855 /* 214 */ "cmd ::= VACUUM",
132856 /* 215 */ "cmd ::= VACUUM nm",
132857 /* 216 */ "cmd ::= PRAGMA nm dbnm",
132858 /* 217 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
132859 /* 218 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
132860 /* 219 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
132861 /* 220 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
132862 /* 221 */ "plus_num ::= PLUS INTEGER|FLOAT",
132863 /* 222 */ "minus_num ::= MINUS INTEGER|FLOAT",
132864 /* 223 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
132865 /* 224 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
132866 /* 225 */ "trigger_time ::= BEFORE",
132867 /* 226 */ "trigger_time ::= AFTER",
132868 /* 227 */ "trigger_time ::= INSTEAD OF",
132869 /* 228 */ "trigger_time ::=",
132870 /* 229 */ "trigger_event ::= DELETE|INSERT",
132871 /* 230 */ "trigger_event ::= UPDATE",
132872 /* 231 */ "trigger_event ::= UPDATE OF idlist",
132873 /* 232 */ "when_clause ::=",
132874 /* 233 */ "when_clause ::= WHEN expr",
132875 /* 234 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
132876 /* 235 */ "trigger_cmd_list ::= trigger_cmd SEMI",
132877 /* 236 */ "trnm ::= nm DOT nm",
132878 /* 237 */ "tridxby ::= INDEXED BY nm",
132879 /* 238 */ "tridxby ::= NOT INDEXED",
132880 /* 239 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
132881 /* 240 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
132882 /* 241 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
132883 /* 242 */ "trigger_cmd ::= select",
132884 /* 243 */ "expr ::= RAISE LP IGNORE RP",
132885 /* 244 */ "expr ::= RAISE LP raisetype COMMA nm RP",
132886 /* 245 */ "raisetype ::= ROLLBACK",
132887 /* 246 */ "raisetype ::= ABORT",
132888 /* 247 */ "raisetype ::= FAIL",
132889 /* 248 */ "cmd ::= DROP TRIGGER ifexists fullname",
132890 /* 249 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
132891 /* 250 */ "cmd ::= DETACH database_kw_opt expr",
132892 /* 251 */ "key_opt ::=",
132893 /* 252 */ "key_opt ::= KEY expr",
132894 /* 253 */ "cmd ::= REINDEX",
132895 /* 254 */ "cmd ::= REINDEX nm dbnm",
132896 /* 255 */ "cmd ::= ANALYZE",
132897 /* 256 */ "cmd ::= ANALYZE nm dbnm",
132898 /* 257 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
132899 /* 258 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
132900 /* 259 */ "add_column_fullname ::= fullname",
132901 /* 260 */ "cmd ::= create_vtab",
132902 /* 261 */ "cmd ::= create_vtab LP vtabarglist RP",
132903 /* 262 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
132904 /* 263 */ "vtabarg ::=",
132905 /* 264 */ "vtabargtoken ::= ANY",
132906 /* 265 */ "vtabargtoken ::= lp anylist RP",
132907 /* 266 */ "lp ::= LP",
132908 /* 267 */ "with ::=",
132909 /* 268 */ "with ::= WITH wqlist",
132910 /* 269 */ "with ::= WITH RECURSIVE wqlist",
132911 /* 270 */ "wqlist ::= nm eidlist_opt AS LP select RP",
132912 /* 271 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
132913 /* 272 */ "input ::= cmdlist",
132914 /* 273 */ "cmdlist ::= cmdlist ecmd",
132915 /* 274 */ "cmdlist ::= ecmd",
132916 /* 275 */ "ecmd ::= SEMI",
132917 /* 276 */ "ecmd ::= explain cmdx SEMI",
132918 /* 277 */ "explain ::=",
132919 /* 278 */ "trans_opt ::=",
132920 /* 279 */ "trans_opt ::= TRANSACTION",
132921 /* 280 */ "trans_opt ::= TRANSACTION nm",
132922 /* 281 */ "savepoint_opt ::= SAVEPOINT",
132923 /* 282 */ "savepoint_opt ::=",
132924 /* 283 */ "cmd ::= create_table create_table_args",
132925 /* 284 */ "columnlist ::= columnlist COMMA columnname carglist",
132926 /* 285 */ "columnlist ::= columnname carglist",
132927 /* 286 */ "nm ::= ID|INDEXED",
132928 /* 287 */ "nm ::= STRING",
132929 /* 288 */ "nm ::= JOIN_KW",
132930 /* 289 */ "typetoken ::= typename",
132931 /* 290 */ "typename ::= ID|STRING",
132932 /* 291 */ "signed ::= plus_num",
132933 /* 292 */ "signed ::= minus_num",
132934 /* 293 */ "carglist ::= carglist ccons",
132935 /* 294 */ "carglist ::=",
132936 /* 295 */ "ccons ::= NULL onconf",
132937 /* 296 */ "conslist_opt ::= COMMA conslist",
132938 /* 297 */ "conslist ::= conslist tconscomma tcons",
132939 /* 298 */ "conslist ::= tcons",
132940 /* 299 */ "tconscomma ::=",
132941 /* 300 */ "defer_subclause_opt ::= defer_subclause",
132942 /* 301 */ "resolvetype ::= raisetype",
132943 /* 302 */ "selectnowith ::= oneselect",
132944 /* 303 */ "oneselect ::= values",
132945 /* 304 */ "sclp ::= selcollist COMMA",
132946 /* 305 */ "as ::= ID|STRING",
132947 /* 306 */ "expr ::= term",
132948 /* 307 */ "exprlist ::= nexprlist",
132949 /* 308 */ "nmnum ::= plus_num",
132950 /* 309 */ "nmnum ::= nm",
132951 /* 310 */ "nmnum ::= ON",
132952 /* 311 */ "nmnum ::= DELETE",
132953 /* 312 */ "nmnum ::= DEFAULT",
132954 /* 313 */ "plus_num ::= INTEGER|FLOAT",
132955 /* 314 */ "foreach_clause ::=",
132956 /* 315 */ "foreach_clause ::= FOR EACH ROW",
132957 /* 316 */ "trnm ::= nm",
132958 /* 317 */ "tridxby ::=",
132959 /* 318 */ "database_kw_opt ::= DATABASE",
132960 /* 319 */ "database_kw_opt ::=",
132961 /* 320 */ "kwcolumn_opt ::=",
132962 /* 321 */ "kwcolumn_opt ::= COLUMNKW",
132963 /* 322 */ "vtabarglist ::= vtabarg",
132964 /* 323 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
132965 /* 324 */ "vtabarg ::= vtabarg vtabargtoken",
132966 /* 325 */ "anylist ::=",
132967 /* 326 */ "anylist ::= anylist LP anylist RP",
132968 /* 327 */ "anylist ::= anylist ANY",
 
 
 
132969 };
132970 #endif /* NDEBUG */
132971
132972
132973 #if YYSTACKDEPTH<=0
@@ -133526,11 +134786,13 @@
133526 { 149, 6 },
133527 { 201, 0 },
133528 { 201, 2 },
133529 { 149, 8 },
133530 { 218, 5 },
 
133531 { 218, 3 },
 
133532 { 149, 6 },
133533 { 149, 7 },
133534 { 219, 2 },
133535 { 219, 1 },
133536 { 220, 0 },
@@ -133549,10 +134811,11 @@
133549 { 173, 3 },
133550 { 173, 6 },
133551 { 173, 5 },
133552 { 173, 4 },
133553 { 172, 1 },
 
133554 { 173, 3 },
133555 { 173, 3 },
133556 { 173, 3 },
133557 { 173, 3 },
133558 { 173, 3 },
@@ -133836,11 +135099,11 @@
133836 case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
133837 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
133838 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
133839 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
133840 case 90: /* distinct ::= */ yytestcase(yyruleno==90);
133841 case 211: /* collate ::= */ yytestcase(yyruleno==211);
133842 {yymsp[1].minor.yy194 = 0;}
133843 break;
133844 case 17: /* ifnotexists ::= IF NOT EXISTS */
133845 {yymsp[-2].minor.yy194 = 1;}
133846 break;
@@ -133975,18 +135238,18 @@
133975 case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
133976 {yymsp[-2].minor.yy194 = 0;}
133977 break;
133978 case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
133979 case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
133980 case 142: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==142);
133981 {yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
133982 break;
133983 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
133984 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
133985 case 183: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==183);
133986 case 186: /* in_op ::= NOT IN */ yytestcase(yyruleno==186);
133987 case 212: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==212);
133988 {yymsp[-1].minor.yy194 = 1;}
133989 break;
133990 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
133991 {yymsp[-1].minor.yy194 = 0;}
133992 break;
@@ -134018,11 +135281,11 @@
134018 break;
134019 case 72: /* resolvetype ::= IGNORE */
134020 {yymsp[0].minor.yy194 = OE_Ignore;}
134021 break;
134022 case 73: /* resolvetype ::= REPLACE */
134023 case 143: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==143);
134024 {yymsp[0].minor.yy194 = OE_Replace;}
134025 break;
134026 case 74: /* cmd ::= DROP TABLE ifexists fullname */
134027 {
134028 sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);
@@ -134146,13 +135409,13 @@
134146 {yymsp[0].minor.yy194 = SF_All;}
134147 break;
134148 case 91: /* sclp ::= */
134149 case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
134150 case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
134151 case 199: /* exprlist ::= */ yytestcase(yyruleno==199);
134152 case 202: /* paren_exprlist ::= */ yytestcase(yyruleno==202);
134153 case 207: /* eidlist_opt ::= */ yytestcase(yyruleno==207);
134154 {yymsp[1].minor.yy148 = 0;}
134155 break;
134156 case 92: /* selcollist ::= sclp expr as */
134157 {
134158 yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
@@ -134174,12 +135437,12 @@
134174 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
134175 }
134176 break;
134177 case 95: /* as ::= AS nm */
134178 case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
134179 case 221: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==221);
134180 case 222: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==222);
134181 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
134182 break;
134183 case 97: /* from ::= */
134184 {yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
134185 break;
@@ -134258,18 +135521,18 @@
134258 {yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
134259 break;
134260 case 112: /* on_opt ::= ON expr */
134261 case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
134262 case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
134263 case 195: /* case_else ::= ELSE expr */ yytestcase(yyruleno==195);
134264 {yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
134265 break;
134266 case 113: /* on_opt ::= */
134267 case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
134268 case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
134269 case 196: /* case_else ::= */ yytestcase(yyruleno==196);
134270 case 198: /* case_operand ::= */ yytestcase(yyruleno==198);
134271 {yymsp[1].minor.yy72 = 0;}
134272 break;
134273 case 115: /* indexed_opt ::= INDEXED BY nm */
134274 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
134275 break;
@@ -134278,11 +135541,11 @@
134278 break;
134279 case 117: /* using_opt ::= USING LP idlist RP */
134280 {yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
134281 break;
134282 case 118: /* using_opt ::= */
134283 case 144: /* idlist_opt ::= */ yytestcase(yyruleno==144);
134284 {yymsp[1].minor.yy254 = 0;}
134285 break;
134286 case 120: /* orderby_opt ::= ORDER BY sortlist */
134287 case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
134288 {yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}
@@ -134339,69 +135602,79 @@
134339 {
134340 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
134341 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);
134342 }
134343 break;
134344 case 139: /* setlist ::= nm EQ expr */
 
 
 
 
 
134345 {
134346 yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
134347 sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);
134348 }
134349 yymsp[-2].minor.yy148 = yylhsminor.yy148;
134350 break;
134351 case 140: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
 
 
 
 
 
134352 {
134353 sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
134354 sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);
134355 }
134356 break;
134357 case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
134358 {
134359 sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);
134360 sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);
134361 }
134362 break;
134363 case 145: /* idlist_opt ::= LP idlist RP */
134364 {yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
134365 break;
134366 case 146: /* idlist ::= idlist COMMA nm */
134367 {yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
134368 break;
134369 case 147: /* idlist ::= nm */
134370 {yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
134371 break;
134372 case 148: /* expr ::= LP expr RP */
134373 {spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
134374 break;
134375 case 149: /* term ::= NULL */
134376 case 154: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==154);
134377 case 155: /* term ::= STRING */ yytestcase(yyruleno==155);
134378 {spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
134379 break;
134380 case 150: /* expr ::= ID|INDEXED */
134381 case 151: /* expr ::= JOIN_KW */ yytestcase(yyruleno==151);
134382 {spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
134383 break;
134384 case 152: /* expr ::= nm DOT nm */
134385 {
134386 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
134387 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
134388 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134389 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
134390 }
134391 break;
134392 case 153: /* expr ::= nm DOT nm DOT nm */
134393 {
134394 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
134395 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
134396 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
134397 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
134398 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134399 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
134400 }
134401 break;
134402 case 156: /* expr ::= VARIABLE */
134403 {
134404 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
134405 spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
134406 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr);
134407 }else{
@@ -134419,23 +135692,23 @@
134419 if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
134420 }
134421 }
134422 }
134423 break;
134424 case 157: /* expr ::= expr COLLATE ID|STRING */
134425 {
134426 yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
134427 yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134428 }
134429 break;
134430 case 158: /* expr ::= CAST LP expr AS typetoken RP */
134431 {
134432 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134433 yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy190.pExpr, 0, &yymsp[-1].minor.yy0);
134434 }
134435 break;
134436 case 159: /* expr ::= ID|INDEXED LP distinct exprlist RP */
134437 {
134438 if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
134439 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
134440 }
134441 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
@@ -134444,41 +135717,54 @@
134444 yylhsminor.yy190.pExpr->flags |= EP_Distinct;
134445 }
134446 }
134447 yymsp[-4].minor.yy190 = yylhsminor.yy190;
134448 break;
134449 case 160: /* expr ::= ID|INDEXED LP STAR RP */
134450 {
134451 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
134452 spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
134453 }
134454 yymsp[-3].minor.yy190 = yylhsminor.yy190;
134455 break;
134456 case 161: /* term ::= CTIME_KW */
134457 {
134458 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
134459 spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
134460 }
134461 yymsp[0].minor.yy190 = yylhsminor.yy190;
134462 break;
134463 case 162: /* expr ::= expr AND expr */
134464 case 163: /* expr ::= expr OR expr */ yytestcase(yyruleno==163);
134465 case 164: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==164);
134466 case 165: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==165);
134467 case 166: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==166);
134468 case 167: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==167);
134469 case 168: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==168);
134470 case 169: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==169);
 
 
 
 
 
 
 
 
 
 
 
 
 
134471 {spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
134472 break;
134473 case 170: /* likeop ::= LIKE_KW|MATCH */
134474 {yymsp[0].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy392.bNot = 0;/*A-overwrites-X*/}
134475 break;
134476 case 171: /* likeop ::= NOT LIKE_KW|MATCH */
134477 {yymsp[-1].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy392.bNot = 1;}
134478 break;
134479 case 172: /* expr ::= expr likeop expr */
134480 {
134481 ExprList *pList;
134482 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
134483 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr);
134484 yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy392.eOperator);
@@ -134485,11 +135771,11 @@
134485 exprNot(pParse, yymsp[-1].minor.yy392.bNot, &yymsp[-2].minor.yy190);
134486 yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134487 if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
134488 }
134489 break;
134490 case 173: /* expr ::= expr likeop expr ESCAPE expr */
134491 {
134492 ExprList *pList;
134493 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134494 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr);
134495 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
@@ -134497,43 +135783,43 @@
134497 exprNot(pParse, yymsp[-3].minor.yy392.bNot, &yymsp[-4].minor.yy190);
134498 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134499 if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
134500 }
134501 break;
134502 case 174: /* expr ::= expr ISNULL|NOTNULL */
134503 {spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
134504 break;
134505 case 175: /* expr ::= expr NOT NULL */
134506 {spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
134507 break;
134508 case 176: /* expr ::= expr IS expr */
134509 {
134510 spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
134511 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
134512 }
134513 break;
134514 case 177: /* expr ::= expr IS NOT expr */
134515 {
134516 spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
134517 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
134518 }
134519 break;
134520 case 178: /* expr ::= NOT expr */
134521 case 179: /* expr ::= BITNOT expr */ yytestcase(yyruleno==179);
134522 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134523 break;
134524 case 180: /* expr ::= MINUS expr */
134525 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134526 break;
134527 case 181: /* expr ::= PLUS expr */
134528 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
134529 break;
134530 case 182: /* between_op ::= BETWEEN */
134531 case 185: /* in_op ::= IN */ yytestcase(yyruleno==185);
134532 {yymsp[0].minor.yy194 = 0;}
134533 break;
134534 case 184: /* expr ::= expr between_op expr AND expr */
134535 {
134536 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134537 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
134538 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134539 if( yymsp[-4].minor.yy190.pExpr ){
@@ -134543,11 +135829,11 @@
134543 }
134544 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134545 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
134546 }
134547 break;
134548 case 187: /* expr ::= expr in_op LP exprlist RP */
134549 {
134550 if( yymsp[-1].minor.yy148==0 ){
134551 /* Expressions of the form
134552 **
134553 ** expr1 IN ()
@@ -134596,26 +135882,26 @@
134596 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134597 }
134598 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134599 }
134600 break;
134601 case 188: /* expr ::= LP select RP */
134602 {
134603 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134604 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
134605 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
134606 }
134607 break;
134608 case 189: /* expr ::= expr in_op LP select RP */
134609 {
134610 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
134611 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
134612 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134613 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
134614 }
134615 break;
134616 case 190: /* expr ::= expr in_op nm dbnm paren_exprlist */
134617 {
134618 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
134619 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
134620 if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
134621 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
@@ -134622,19 +135908,19 @@
134622 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
134623 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
134624 yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
134625 }
134626 break;
134627 case 191: /* expr ::= EXISTS LP select RP */
134628 {
134629 Expr *p;
134630 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
134631 p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
134632 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
134633 }
134634 break;
134635 case 192: /* expr ::= CASE case_operand case_exprlist case_else END */
134636 {
134637 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
134638 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0, 0);
134639 if( yymsp[-4].minor.yy190.pExpr ){
134640 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
@@ -134643,334 +135929,334 @@
134643 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
134644 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
134645 }
134646 }
134647 break;
134648 case 193: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
134649 {
134650 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
134651 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
134652 }
134653 break;
134654 case 194: /* case_exprlist ::= WHEN expr THEN expr */
134655 {
134656 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
134657 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
134658 }
134659 break;
134660 case 197: /* case_operand ::= expr */
134661 {yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
134662 break;
134663 case 200: /* nexprlist ::= nexprlist COMMA expr */
134664 {yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
134665 break;
134666 case 201: /* nexprlist ::= expr */
134667 {yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
134668 break;
134669 case 203: /* paren_exprlist ::= LP exprlist RP */
134670 case 208: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==208);
134671 {yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
134672 break;
134673 case 204: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
134674 {
134675 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
134676 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
134677 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
134678 }
134679 break;
134680 case 205: /* uniqueflag ::= UNIQUE */
134681 case 246: /* raisetype ::= ABORT */ yytestcase(yyruleno==246);
134682 {yymsp[0].minor.yy194 = OE_Abort;}
134683 break;
134684 case 206: /* uniqueflag ::= */
134685 {yymsp[1].minor.yy194 = OE_None;}
134686 break;
134687 case 209: /* eidlist ::= eidlist COMMA nm collate sortorder */
134688 {
134689 yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
134690 }
134691 break;
134692 case 210: /* eidlist ::= nm collate sortorder */
134693 {
134694 yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
134695 }
134696 break;
134697 case 213: /* cmd ::= DROP INDEX ifexists fullname */
134698 {sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
134699 break;
134700 case 214: /* cmd ::= VACUUM */
134701 {sqlite3Vacuum(pParse,0);}
134702 break;
134703 case 215: /* cmd ::= VACUUM nm */
134704 {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
134705 break;
134706 case 216: /* cmd ::= PRAGMA nm dbnm */
134707 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
134708 break;
134709 case 217: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
134710 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
134711 break;
134712 case 218: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
134713 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
134714 break;
134715 case 219: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
134716 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
134717 break;
134718 case 220: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
134719 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
134720 break;
134721 case 223: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
134722 {
134723 Token all;
134724 all.z = yymsp[-3].minor.yy0.z;
134725 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
134726 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
134727 }
134728 break;
134729 case 224: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
134730 {
134731 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
134732 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
134733 }
134734 break;
134735 case 225: /* trigger_time ::= BEFORE */
134736 { yymsp[0].minor.yy194 = TK_BEFORE; }
134737 break;
134738 case 226: /* trigger_time ::= AFTER */
134739 { yymsp[0].minor.yy194 = TK_AFTER; }
134740 break;
134741 case 227: /* trigger_time ::= INSTEAD OF */
134742 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
134743 break;
134744 case 228: /* trigger_time ::= */
134745 { yymsp[1].minor.yy194 = TK_BEFORE; }
134746 break;
134747 case 229: /* trigger_event ::= DELETE|INSERT */
134748 case 230: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==230);
134749 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
134750 break;
134751 case 231: /* trigger_event ::= UPDATE OF idlist */
134752 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
134753 break;
134754 case 232: /* when_clause ::= */
134755 case 251: /* key_opt ::= */ yytestcase(yyruleno==251);
134756 { yymsp[1].minor.yy72 = 0; }
134757 break;
134758 case 233: /* when_clause ::= WHEN expr */
134759 case 252: /* key_opt ::= KEY expr */ yytestcase(yyruleno==252);
134760 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
134761 break;
134762 case 234: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
134763 {
134764 assert( yymsp[-2].minor.yy145!=0 );
134765 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
134766 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
134767 }
134768 break;
134769 case 235: /* trigger_cmd_list ::= trigger_cmd SEMI */
134770 {
134771 assert( yymsp[-1].minor.yy145!=0 );
134772 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
134773 }
134774 break;
134775 case 236: /* trnm ::= nm DOT nm */
134776 {
134777 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
134778 sqlite3ErrorMsg(pParse,
134779 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
134780 "statements within triggers");
134781 }
134782 break;
134783 case 237: /* tridxby ::= INDEXED BY nm */
134784 {
134785 sqlite3ErrorMsg(pParse,
134786 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
134787 "within triggers");
134788 }
134789 break;
134790 case 238: /* tridxby ::= NOT INDEXED */
134791 {
134792 sqlite3ErrorMsg(pParse,
134793 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
134794 "within triggers");
134795 }
134796 break;
134797 case 239: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
134798 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
134799 break;
134800 case 240: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
134801 {yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
134802 break;
134803 case 241: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
134804 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
134805 break;
134806 case 242: /* trigger_cmd ::= select */
134807 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
134808 break;
134809 case 243: /* expr ::= RAISE LP IGNORE RP */
134810 {
134811 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134812 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
134813 if( yymsp[-3].minor.yy190.pExpr ){
134814 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
134815 }
134816 }
134817 break;
134818 case 244: /* expr ::= RAISE LP raisetype COMMA nm RP */
134819 {
134820 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
134821 yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
134822 if( yymsp[-5].minor.yy190.pExpr ) {
134823 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
134824 }
134825 }
134826 break;
134827 case 245: /* raisetype ::= ROLLBACK */
134828 {yymsp[0].minor.yy194 = OE_Rollback;}
134829 break;
134830 case 247: /* raisetype ::= FAIL */
134831 {yymsp[0].minor.yy194 = OE_Fail;}
134832 break;
134833 case 248: /* cmd ::= DROP TRIGGER ifexists fullname */
134834 {
134835 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
134836 }
134837 break;
134838 case 249: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
134839 {
134840 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
134841 }
134842 break;
134843 case 250: /* cmd ::= DETACH database_kw_opt expr */
134844 {
134845 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
134846 }
134847 break;
134848 case 253: /* cmd ::= REINDEX */
134849 {sqlite3Reindex(pParse, 0, 0);}
134850 break;
134851 case 254: /* cmd ::= REINDEX nm dbnm */
134852 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
134853 break;
134854 case 255: /* cmd ::= ANALYZE */
134855 {sqlite3Analyze(pParse, 0, 0);}
134856 break;
134857 case 256: /* cmd ::= ANALYZE nm dbnm */
134858 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
134859 break;
134860 case 257: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
134861 {
134862 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
134863 }
134864 break;
134865 case 258: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
134866 {
134867 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
134868 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
134869 }
134870 break;
134871 case 259: /* add_column_fullname ::= fullname */
134872 {
134873 disableLookaside(pParse);
134874 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
134875 }
134876 break;
134877 case 260: /* cmd ::= create_vtab */
134878 {sqlite3VtabFinishParse(pParse,0);}
134879 break;
134880 case 261: /* cmd ::= create_vtab LP vtabarglist RP */
134881 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
134882 break;
134883 case 262: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
134884 {
134885 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
134886 }
134887 break;
134888 case 263: /* vtabarg ::= */
134889 {sqlite3VtabArgInit(pParse);}
134890 break;
134891 case 264: /* vtabargtoken ::= ANY */
134892 case 265: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==265);
134893 case 266: /* lp ::= LP */ yytestcase(yyruleno==266);
134894 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
134895 break;
134896 case 267: /* with ::= */
134897 {yymsp[1].minor.yy285 = 0;}
134898 break;
134899 case 268: /* with ::= WITH wqlist */
134900 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
134901 break;
134902 case 269: /* with ::= WITH RECURSIVE wqlist */
134903 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
134904 break;
134905 case 270: /* wqlist ::= nm eidlist_opt AS LP select RP */
134906 {
134907 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
134908 }
134909 break;
134910 case 271: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
134911 {
134912 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
134913 }
134914 break;
134915 default:
134916 /* (272) input ::= cmdlist */ yytestcase(yyruleno==272);
134917 /* (273) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==273);
134918 /* (274) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=274);
134919 /* (275) ecmd ::= SEMI */ yytestcase(yyruleno==275);
134920 /* (276) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==276);
134921 /* (277) explain ::= */ yytestcase(yyruleno==277);
134922 /* (278) trans_opt ::= */ yytestcase(yyruleno==278);
134923 /* (279) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==279);
134924 /* (280) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==280);
134925 /* (281) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==281);
134926 /* (282) savepoint_opt ::= */ yytestcase(yyruleno==282);
134927 /* (283) cmd ::= create_table create_table_args */ yytestcase(yyruleno==283);
134928 /* (284) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==284);
134929 /* (285) columnlist ::= columnname carglist */ yytestcase(yyruleno==285);
134930 /* (286) nm ::= ID|INDEXED */ yytestcase(yyruleno==286);
134931 /* (287) nm ::= STRING */ yytestcase(yyruleno==287);
134932 /* (288) nm ::= JOIN_KW */ yytestcase(yyruleno==288);
134933 /* (289) typetoken ::= typename */ yytestcase(yyruleno==289);
134934 /* (290) typename ::= ID|STRING */ yytestcase(yyruleno==290);
134935 /* (291) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=291);
134936 /* (292) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=292);
134937 /* (293) carglist ::= carglist ccons */ yytestcase(yyruleno==293);
134938 /* (294) carglist ::= */ yytestcase(yyruleno==294);
134939 /* (295) ccons ::= NULL onconf */ yytestcase(yyruleno==295);
134940 /* (296) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==296);
134941 /* (297) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==297);
134942 /* (298) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=298);
134943 /* (299) tconscomma ::= */ yytestcase(yyruleno==299);
134944 /* (300) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=300);
134945 /* (301) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=301);
134946 /* (302) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=302);
134947 /* (303) oneselect ::= values */ yytestcase(yyruleno==303);
134948 /* (304) sclp ::= selcollist COMMA */ yytestcase(yyruleno==304);
134949 /* (305) as ::= ID|STRING */ yytestcase(yyruleno==305);
134950 /* (306) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=306);
134951 /* (307) exprlist ::= nexprlist */ yytestcase(yyruleno==307);
134952 /* (308) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=308);
134953 /* (309) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=309);
134954 /* (310) nmnum ::= ON */ yytestcase(yyruleno==310);
134955 /* (311) nmnum ::= DELETE */ yytestcase(yyruleno==311);
134956 /* (312) nmnum ::= DEFAULT */ yytestcase(yyruleno==312);
134957 /* (313) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==313);
134958 /* (314) foreach_clause ::= */ yytestcase(yyruleno==314);
134959 /* (315) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==315);
134960 /* (316) trnm ::= nm */ yytestcase(yyruleno==316);
134961 /* (317) tridxby ::= */ yytestcase(yyruleno==317);
134962 /* (318) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==318);
134963 /* (319) database_kw_opt ::= */ yytestcase(yyruleno==319);
134964 /* (320) kwcolumn_opt ::= */ yytestcase(yyruleno==320);
134965 /* (321) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==321);
134966 /* (322) vtabarglist ::= vtabarg */ yytestcase(yyruleno==322);
134967 /* (323) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==323);
134968 /* (324) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==324);
134969 /* (325) anylist ::= */ yytestcase(yyruleno==325);
134970 /* (326) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==326);
134971 /* (327) anylist ::= anylist ANY */ yytestcase(yyruleno==327);
134972 break;
134973 /********** End reduce actions ************************************************/
134974 };
134975 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
134976 yygoto = yyRuleInfo[yyruleno].lhs;
@@ -138358,10 +139644,12 @@
138358 if( !sqlite3SafetyCheckOk(db) ){
138359 return SQLITE_MISUSE_BKPT;
138360 }
138361 #endif
138362 sqlite3_mutex_enter(db->mutex);
 
 
138363 db->mTrace = mTrace;
138364 db->xTrace = xTrace;
138365 db->pTraceArg = pArg;
138366 sqlite3_mutex_leave(db->mutex);
138367 return SQLITE_OK;
@@ -139468,15 +140756,24 @@
139468 ** database schema yet. This is delayed until the first time the database
139469 ** is accessed.
139470 */
139471 sqlite3Error(db, SQLITE_OK);
139472 sqlite3RegisterPerConnectionBuiltinFunctions(db);
 
 
 
 
 
 
 
 
 
 
139473
139474 /* Load automatic extensions - extensions that have been registered
139475 ** using the sqlite3_automatic_extension() API.
139476 */
139477 rc = sqlite3_errcode(db);
139478 if( rc==SQLITE_OK ){
139479 sqlite3AutoLoadExtensions(db);
139480 rc = sqlite3_errcode(db);
139481 if( rc!=SQLITE_OK ){
139482 goto opendb_out;
@@ -139499,16 +140796,10 @@
139499
139500 #ifdef SQLITE_ENABLE_FTS3 /* automatically defined by SQLITE_ENABLE_FTS4 */
139501 if( !db->mallocFailed && rc==SQLITE_OK ){
139502 rc = sqlite3Fts3Init(db);
139503 }
139504 #endif
139505
139506 #ifdef SQLITE_ENABLE_FTS5
139507 if( !db->mallocFailed && rc==SQLITE_OK ){
139508 rc = sqlite3Fts5Init(db);
139509 }
139510 #endif
139511
139512 #ifdef SQLITE_ENABLE_ICU
139513 if( !db->mallocFailed && rc==SQLITE_OK ){
139514 rc = sqlite3IcuInit(db);
@@ -161530,11 +162821,11 @@
161530
161531 pCsr->iStrategy = idxNum;
161532 if( idxNum==1 ){
161533 /* Special case - lookup by rowid. */
161534 RtreeNode *pLeaf; /* Leaf on which the required cell resides */
161535 RtreeSearchPoint *p; /* Search point for the the leaf */
161536 i64 iRowid = sqlite3_value_int64(argv[0]);
161537 i64 iNode = 0;
161538 rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
161539 if( rc==SQLITE_OK && pLeaf!=0 ){
161540 p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);
@@ -164566,11 +165857,11 @@
164566 **
164567 ** Instead of the plain data_<target> naming scheme, RBU database tables
164568 ** may also be named data<integer>_<target>, where <integer> is any sequence
164569 ** of zero or more numeric characters (0-9). This can be significant because
164570 ** tables within the RBU database are always processed in order sorted by
164571 ** name. By judicious selection of the the <integer> portion of the names
164572 ** of the RBU tables the user can therefore control the order in which they
164573 ** are processed. This can be useful, for example, to ensure that "external
164574 ** content" FTS4 tables are updated before their underlying content tables.
164575 **
164576 ** If the target database table is a virtual table or a table that has no
@@ -180154,10 +181445,119 @@
180154 }
180155 }
180156 /*
180157 ** End of highlight() implementation.
180158 **************************************************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180159
180160 /*
180161 ** Implementation of snippet() function.
180162 */
180163 static void fts5SnippetFunction(
@@ -180176,87 +181576,111 @@
180176 int i; /* Used to iterate through instances */
180177 int nPhrase; /* Number of phrases in query */
180178 unsigned char *aSeen; /* Array of "seen instance" flags */
180179 int iBestCol; /* Column containing best snippet */
180180 int iBestStart = 0; /* First token of best snippet */
180181 int iBestLast; /* Last token of best snippet */
180182 int nBestScore = 0; /* Score of best snippet */
180183 int nColSize = 0; /* Total size of iBestCol in tokens */
 
 
180184
180185 if( nVal!=5 ){
180186 const char *zErr = "wrong number of arguments to function snippet()";
180187 sqlite3_result_error(pCtx, zErr, -1);
180188 return;
180189 }
180190
 
180191 memset(&ctx, 0, sizeof(HighlightContext));
180192 iCol = sqlite3_value_int(apVal[0]);
180193 ctx.zOpen = (const char*)sqlite3_value_text(apVal[1]);
180194 ctx.zClose = (const char*)sqlite3_value_text(apVal[2]);
180195 zEllips = (const char*)sqlite3_value_text(apVal[3]);
180196 nToken = sqlite3_value_int(apVal[4]);
180197 iBestLast = nToken-1;
180198
180199 iBestCol = (iCol>=0 ? iCol : 0);
180200 nPhrase = pApi->xPhraseCount(pFts);
180201 aSeen = sqlite3_malloc(nPhrase);
180202 if( aSeen==0 ){
180203 rc = SQLITE_NOMEM;
180204 }
180205
180206 if( rc==SQLITE_OK ){
180207 rc = pApi->xInstCount(pFts, &nInst);
180208 }
180209 for(i=0; rc==SQLITE_OK && i<nInst; i++){
180210 int ip, iSnippetCol, iStart;
180211 memset(aSeen, 0, nPhrase);
180212 rc = pApi->xInst(pFts, i, &ip, &iSnippetCol, &iStart);
180213 if( rc==SQLITE_OK && (iCol<0 || iSnippetCol==iCol) ){
180214 int nScore = 1000;
180215 int iLast = iStart - 1 + pApi->xPhraseSize(pFts, ip);
180216 int j;
180217 aSeen[ip] = 1;
180218
180219 for(j=i+1; rc==SQLITE_OK && j<nInst; j++){
180220 int ic; int io; int iFinal;
180221 rc = pApi->xInst(pFts, j, &ip, &ic, &io);
180222 iFinal = io + pApi->xPhraseSize(pFts, ip) - 1;
180223 if( rc==SQLITE_OK && ic==iSnippetCol && iLast<iStart+nToken ){
180224 nScore += aSeen[ip] ? 1000 : 1;
180225 aSeen[ip] = 1;
180226 if( iFinal>iLast ) iLast = iFinal;
180227 }
180228 }
180229
180230 if( rc==SQLITE_OK && nScore>nBestScore ){
180231 iBestCol = iSnippetCol;
180232 iBestStart = iStart;
180233 iBestLast = iLast;
180234 nBestScore = nScore;
180235 }
180236 }
180237 }
180238
180239 if( rc==SQLITE_OK ){
180240 rc = pApi->xColumnSize(pFts, iBestCol, &nColSize);
180241 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180242 if( rc==SQLITE_OK ){
180243 rc = pApi->xColumnText(pFts, iBestCol, &ctx.zIn, &ctx.nIn);
180244 }
 
 
 
180245 if( ctx.zIn ){
180246 if( rc==SQLITE_OK ){
180247 rc = fts5CInstIterInit(pApi, pFts, iBestCol, &ctx.iter);
180248 }
180249
180250 if( (iBestStart+nToken-1)>iBestLast ){
180251 iBestStart -= (iBestStart+nToken-1-iBestLast) / 2;
180252 }
180253 if( iBestStart+nToken>nColSize ){
180254 iBestStart = nColSize - nToken;
180255 }
180256 if( iBestStart<0 ) iBestStart = 0;
180257
180258 ctx.iRangeStart = iBestStart;
180259 ctx.iRangeEnd = iBestStart + nToken - 1;
180260
180261 if( iBestStart>0 ){
180262 fts5HighlightAppend(&rc, &ctx, zEllips, -1);
@@ -180274,19 +181698,19 @@
180274 if( ctx.iRangeEnd>=(nColSize-1) ){
180275 fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);
180276 }else{
180277 fts5HighlightAppend(&rc, &ctx, zEllips, -1);
180278 }
180279
180280 if( rc==SQLITE_OK ){
180281 sqlite3_result_text(pCtx, (const char*)ctx.zOut, -1, SQLITE_TRANSIENT);
180282 }else{
180283 sqlite3_result_error_code(pCtx, rc);
180284 }
180285 sqlite3_free(ctx.zOut);
180286 }
180287 sqlite3_free(aSeen);
 
180288 }
180289
180290 /************************************************************************/
180291
180292 /*
@@ -194153,11 +195577,11 @@
194153 int nArg, /* Number of args */
194154 sqlite3_value **apUnused /* Function arguments */
194155 ){
194156 assert( nArg==0 );
194157 UNUSED_PARAM2(nArg, apUnused);
194158 sqlite3_result_text(pCtx, "fts5: 2016-08-20 18:06:14 9041ee4a6f0e8389297f887f1431ab5cfe783390", -1, SQLITE_TRANSIENT);
194159 }
194160
194161 static int fts5Init(sqlite3 *db){
194162 static const sqlite3_module fts5Mod = {
194163 /* iVersion */ 2,
194164
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -380,11 +380,11 @@
380 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
381 ** [sqlite_version()] and [sqlite_source_id()].
382 */
383 #define SQLITE_VERSION "3.15.0"
384 #define SQLITE_VERSION_NUMBER 3015000
385 #define SQLITE_SOURCE_ID "2016-09-07 19:54:24 ddb5f0558c44569913d22781ab78f3e9b58d7aea"
386
387 /*
388 ** CAPI3REF: Run-Time Library Version Numbers
389 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
390 **
@@ -9477,16 +9477,16 @@
9477 void **ppOut /* OUT: Buffer containing output changeset */
9478 );
9479
9480
9481 /*
9482 ** CAPI3REF: Changegroup Handle
9483 */
9484 typedef struct sqlite3_changegroup sqlite3_changegroup;
9485
9486 /*
9487 ** CAPI3REF: Create A New Changegroup Object
9488 **
9489 ** An sqlite3_changegroup object is used to combine two or more changesets
9490 ** (or patchsets) into a single changeset (or patchset). A single changegroup
9491 ** object may combine changesets or patchsets, but not both. The output is
9492 ** always in the same format as the input.
@@ -9519,10 +9519,12 @@
9519 ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
9520 */
9521 int sqlite3changegroup_new(sqlite3_changegroup **pp);
9522
9523 /*
9524 ** CAPI3REF: Add A Changeset To A Changegroup
9525 **
9526 ** Add all changes within the changeset (or patchset) in buffer pData (size
9527 ** nData bytes) to the changegroup.
9528 **
9529 ** If the buffer contains a patchset, then all prior calls to this function
9530 ** on the same changegroup object must also have specified patchsets. Or, if
@@ -9594,10 +9596,12 @@
9596 ** If no error occurs, SQLITE_OK is returned.
9597 */
9598 int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
9599
9600 /*
9601 ** CAPI3REF: Obtain A Composite Changeset From A Changegroup
9602 **
9603 ** Obtain a buffer containing a changeset (or patchset) representing the
9604 ** current contents of the changegroup. If the inputs to the changegroup
9605 ** were themselves changesets, the output is a changeset. Or, if the
9606 ** inputs were patchsets, the output is also a patchset.
9607 **
@@ -9622,11 +9626,11 @@
9626 int *pnData, /* OUT: Size of output buffer in bytes */
9627 void **ppData /* OUT: Pointer to output buffer */
9628 );
9629
9630 /*
9631 ** CAPI3REF: Delete A Changegroup Object
9632 */
9633 void sqlite3changegroup_delete(sqlite3_changegroup*);
9634
9635 /*
9636 ** CAPI3REF: Apply A Changeset To A Database
@@ -11425,14 +11429,16 @@
11429 #define TK_AGG_FUNCTION 153
11430 #define TK_AGG_COLUMN 154
11431 #define TK_UMINUS 155
11432 #define TK_UPLUS 156
11433 #define TK_REGISTER 157
11434 #define TK_VECTOR 158
11435 #define TK_SELECT_COLUMN 159
11436 #define TK_ASTERISK 160
11437 #define TK_SPAN 161
11438 #define TK_SPACE 162
11439 #define TK_ILLEGAL 163
11440
11441 /* The token codes above must all fit in 8 bits */
11442 #define TKFLG_MASK 0xff
11443
11444 /* Flags that can be added to a token code when it is not
@@ -12569,17 +12575,17 @@
12575 #define OP_Found 31 /* synopsis: key=r[P3@P4] */
12576 #define OP_SeekRowid 32 /* synopsis: intkey=r[P3] */
12577 #define OP_NotExists 33 /* synopsis: intkey=r[P3] */
12578 #define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
12579 #define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
12580 #define OP_Ne 36 /* same as TK_NE, synopsis: IF r[P3]!=r[P1] */
12581 #define OP_Eq 37 /* same as TK_EQ, synopsis: IF r[P3]==r[P1] */
12582 #define OP_Gt 38 /* same as TK_GT, synopsis: IF r[P3]>r[P1] */
12583 #define OP_Le 39 /* same as TK_LE, synopsis: IF r[P3]<=r[P1] */
12584 #define OP_Lt 40 /* same as TK_LT, synopsis: IF r[P3]<r[P1] */
12585 #define OP_Ge 41 /* same as TK_GE, synopsis: IF r[P3]>=r[P1] */
12586 #define OP_ElseNotEq 42 /* same as TK_ESCAPE */
12587 #define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
12588 #define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
12589 #define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
12590 #define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
12591 #define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -12586,119 +12592,120 @@
12592 #define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
12593 #define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
12594 #define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
12595 #define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
12596 #define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
12597 #define OP_Last 53
12598 #define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12599 #define OP_SorterSort 55
12600 #define OP_Sort 56
12601 #define OP_Rewind 57
12602 #define OP_IdxLE 58 /* synopsis: key=r[P3@P4] */
12603 #define OP_IdxGT 59 /* synopsis: key=r[P3@P4] */
12604 #define OP_IdxLT 60 /* synopsis: key=r[P3@P4] */
12605 #define OP_IdxGE 61 /* synopsis: key=r[P3@P4] */
12606 #define OP_RowSetRead 62 /* synopsis: r[P3]=rowset(P1) */
12607 #define OP_RowSetTest 63 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12608 #define OP_Program 64
12609 #define OP_FkIfZero 65 /* synopsis: if fkctr[P1]==0 goto P2 */
12610 #define OP_IfPos 66 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12611 #define OP_IfNotZero 67 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
12612 #define OP_DecrJumpZero 68 /* synopsis: if (--r[P1])==0 goto P2 */
12613 #define OP_IncrVacuum 69
12614 #define OP_VNext 70
12615 #define OP_Init 71 /* synopsis: Start at P2 */
12616 #define OP_Return 72
12617 #define OP_EndCoroutine 73
12618 #define OP_HaltIfNull 74 /* synopsis: if r[P3]=null halt */
12619 #define OP_Halt 75
12620 #define OP_Integer 76 /* synopsis: r[P2]=P1 */
12621 #define OP_Int64 77 /* synopsis: r[P2]=P4 */
12622 #define OP_String 78 /* synopsis: r[P2]='P4' (len=P1) */
12623 #define OP_Null 79 /* synopsis: r[P2..P3]=NULL */
12624 #define OP_SoftNull 80 /* synopsis: r[P1]=NULL */
12625 #define OP_Blob 81 /* synopsis: r[P2]=P4 (len=P1) */
12626 #define OP_Variable 82 /* synopsis: r[P2]=parameter(P1,P4) */
12627 #define OP_Move 83 /* synopsis: r[P2@P3]=r[P1@P3] */
12628 #define OP_Copy 84 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12629 #define OP_SCopy 85 /* synopsis: r[P2]=r[P1] */
12630 #define OP_IntCopy 86 /* synopsis: r[P2]=r[P1] */
12631 #define OP_ResultRow 87 /* synopsis: output=r[P1@P2] */
12632 #define OP_CollSeq 88
12633 #define OP_Function0 89 /* synopsis: r[P3]=func(r[P2@P5]) */
12634 #define OP_Function 90 /* synopsis: r[P3]=func(r[P2@P5]) */
12635 #define OP_AddImm 91 /* synopsis: r[P1]=r[P1]+P2 */
12636 #define OP_RealAffinity 92
12637 #define OP_Cast 93 /* synopsis: affinity(r[P1]) */
12638 #define OP_Permutation 94
12639 #define OP_Compare 95 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12640 #define OP_Column 96 /* synopsis: r[P3]=PX */
12641 #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12642 #define OP_Affinity 98 /* synopsis: affinity(r[P1@P2]) */
12643 #define OP_MakeRecord 99 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12644 #define OP_Count 100 /* synopsis: r[P2]=count() */
12645 #define OP_ReadCookie 101
12646 #define OP_SetCookie 102
12647 #define OP_ReopenIdx 103 /* synopsis: root=P2 iDb=P3 */
12648 #define OP_OpenRead 104 /* synopsis: root=P2 iDb=P3 */
12649 #define OP_OpenWrite 105 /* synopsis: root=P2 iDb=P3 */
12650 #define OP_OpenAutoindex 106 /* synopsis: nColumn=P2 */
12651 #define OP_OpenEphemeral 107 /* synopsis: nColumn=P2 */
12652 #define OP_SorterOpen 108
12653 #define OP_SequenceTest 109 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12654 #define OP_OpenPseudo 110 /* synopsis: P3 columns in r[P2] */
12655 #define OP_Close 111
12656 #define OP_ColumnsUsed 112
12657 #define OP_Sequence 113 /* synopsis: r[P2]=cursor[P1].ctr++ */
12658 #define OP_NewRowid 114 /* synopsis: r[P2]=rowid */
12659 #define OP_Insert 115 /* synopsis: intkey=r[P3] data=r[P2] */
12660 #define OP_InsertInt 116 /* synopsis: intkey=P3 data=r[P2] */
12661 #define OP_Delete 117
12662 #define OP_ResetCount 118
12663 #define OP_SorterCompare 119 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12664 #define OP_SorterData 120 /* synopsis: r[P2]=data */
12665 #define OP_RowKey 121 /* synopsis: r[P2]=key */
12666 #define OP_RowData 122 /* synopsis: r[P2]=data */
12667 #define OP_Rowid 123 /* synopsis: r[P2]=rowid */
12668 #define OP_NullRow 124
12669 #define OP_SorterInsert 125
12670 #define OP_IdxInsert 126 /* synopsis: key=r[P2] */
12671 #define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */
12672 #define OP_Seek 128 /* synopsis: Move P3 to P1.rowid */
12673 #define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */
12674 #define OP_Destroy 130
12675 #define OP_Clear 131
12676 #define OP_ResetSorter 132
12677 #define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12678 #define OP_CreateIndex 134 /* synopsis: r[P2]=root iDb=P1 */
12679 #define OP_CreateTable 135 /* synopsis: r[P2]=root iDb=P1 */
12680 #define OP_ParseSchema 136
12681 #define OP_LoadAnalysis 137
12682 #define OP_DropTable 138
12683 #define OP_DropIndex 139
12684 #define OP_DropTrigger 140
12685 #define OP_IntegrityCk 141
12686 #define OP_RowSetAdd 142 /* synopsis: rowset(P1)=r[P2] */
12687 #define OP_Param 143
12688 #define OP_FkCounter 144 /* synopsis: fkctr[P1]+=P2 */
12689 #define OP_MemMax 145 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12690 #define OP_OffsetLimit 146 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12691 #define OP_AggStep0 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12692 #define OP_AggStep 148 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12693 #define OP_AggFinal 149 /* synopsis: accum=r[P1] N=P2 */
12694 #define OP_Expire 150
12695 #define OP_TableLock 151 /* synopsis: iDb=P1 root=P2 write=P3 */
12696 #define OP_VBegin 152
12697 #define OP_VCreate 153
12698 #define OP_VDestroy 154
12699 #define OP_VOpen 155
12700 #define OP_VColumn 156 /* synopsis: r[P3]=vcolumn(P2) */
12701 #define OP_VRename 157
12702 #define OP_Pagecount 158
12703 #define OP_MaxPgcnt 159
12704 #define OP_CursorHint 160
12705 #define OP_Noop 161
12706 #define OP_Explain 162
12707
12708 /* Properties such as "out2" or "jump" that are specified in
12709 ** comments following the "case" for each opcode in the vdbe.c
12710 ** are encoded into bitvectors as follows:
12711 */
@@ -12714,32 +12721,32 @@
12721 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
12722 /* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
12723 /* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
12724 /* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
12725 /* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12726 /* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b,\
12727 /* 64 */ 0x01, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01,\
12728 /* 72 */ 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10,\
12729 /* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00,\
12730 /* 88 */ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
12731 /* 96 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12732 /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12733 /* 112 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
12734 /* 120 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00,\
12735 /* 128 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10,\
12736 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10,\
12737 /* 144 */ 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,\
12738 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
12739 /* 160 */ 0x00, 0x00, 0x00,}
12740
12741 /* The sqlite3P2Values() routine is able to run faster if it knows
12742 ** the value of the largest JUMP opcode. The smaller the maximum
12743 ** JUMP opcode the better, so the mkopcodeh.tcl script that
12744 ** generated this include file strives to group all JUMP opcodes
12745 ** together near the beginning of the list.
12746 */
12747 #define SQLITE_MX_JUMP_OPCODE 71 /* Maximum JUMP opcode */
12748
12749 /************** End of opcodes.h *********************************************/
12750 /************** Continuing where we left off in vdbe.h ***********************/
12751
12752 /*
@@ -14340,10 +14347,11 @@
14347 ** The SQLITE_NOTNULL flag is a combination of NULLEQ and JUMPIFNULL.
14348 ** It causes an assert() to fire if either operand to a comparison
14349 ** operator is NULL. It is added to certain comparison operators to
14350 ** prove that the operands are always NOT NULL.
14351 */
14352 #define SQLITE_KEEPNULL 0x08 /* Used by vector == or <> */
14353 #define SQLITE_JUMPIFNULL 0x10 /* jumps if either operand is NULL */
14354 #define SQLITE_STOREP2 0x20 /* Store result in reg[P2] rather than jump */
14355 #define SQLITE_NULLEQ 0x80 /* NULL=NULL */
14356 #define SQLITE_NOTNULL 0x90 /* Assert that operands are never NULL */
14357
@@ -14904,13 +14912,15 @@
14912 int nHeight; /* Height of the tree headed by this node */
14913 #endif
14914 int iTable; /* TK_COLUMN: cursor number of table holding column
14915 ** TK_REGISTER: register number
14916 ** TK_TRIGGER: 1 -> new, 0 -> old
14917 ** EP_Unlikely: 134217728 times likelihood
14918 ** TK_SELECT: 1st register of result vector */
14919 ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
14920 ** TK_VARIABLE: variable number (always >= 1).
14921 ** TK_SELECT_COLUMN: column of the result vector */
14922 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
14923 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
14924 u8 op2; /* TK_REGISTER: original value of Expr.op
14925 ** TK_COLUMN: the value of p5 for OP_Column
14926 ** TK_AGG_FUNCTION: nesting depth */
@@ -15387,11 +15397,11 @@
15397 ** An instance of this object describes where to put of the results of
15398 ** a SELECT statement.
15399 */
15400 struct SelectDest {
15401 u8 eDest; /* How to dispose of the results. On of SRT_* above. */
15402 char *zAffSdst; /* Affinity used when eDest==SRT_Set */
15403 int iSDParm; /* A parameter used by the eDest disposal method */
15404 int iSdst; /* Base register where results are written */
15405 int nSdst; /* Number of registers allocated */
15406 ExprList *pOrderBy; /* Key columns for SRT_Queue and SRT_DistQueue */
15407 };
@@ -16119,10 +16129,11 @@
16129 SQLITE_PRIVATE void *sqlite3TestTextToPtr(const char*);
16130 #endif
16131
16132 #if defined(SQLITE_DEBUG)
16133 SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
16134 SQLITE_PRIVATE void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);
16135 SQLITE_PRIVATE void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
16136 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
16137 SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView*, const With*, u8);
16138 #endif
16139
@@ -16150,10 +16161,11 @@
16161 SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);
16162 SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*);
16163 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*);
16164 SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
16165 SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
16166 SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
16167 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);
16168 SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
16169 SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
16170 SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
16171 SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
@@ -16485,10 +16497,11 @@
16497
16498 SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3*, Index*);
16499 SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int);
16500 SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);
16501 SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
16502 SQLITE_PRIVATE char sqlite3TableColumnAffinity(Table*,int);
16503 SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);
16504 SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8);
16505 SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);
16506 SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
16507 SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
@@ -16550,11 +16563,11 @@
16563 SQLITE_PRIVATE void sqlite3AlterFunctions(void);
16564 SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
16565 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
16566 SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
16567 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);
16568 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
16569 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
16570 SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
16571 SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
16572 SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
16573 SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*);
@@ -16604,17 +16617,25 @@
16617 SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
16618 SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
16619
16620 SQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);
16621 SQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
16622
16623 #ifndef SQLITE_OMIT_SUBQUERY
16624 SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse*, Expr*);
16625 #else
16626 # define sqlite3ExprCheckIN(x,y) SQLITE_OK
16627 #endif
16628
16629 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
16630 SQLITE_PRIVATE void sqlite3AnalyzeFunctions(void);
16631 SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(
16632 Parse*,Index*,UnpackedRecord**,Expr*,int,int,int*);
16633 SQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);
16634 SQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord*);
16635 SQLITE_PRIVATE int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);
16636 SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3*, Index*, int);
16637 #endif
16638
16639 /*
16640 ** The interface to the LEMON-generated parser
16641 */
@@ -16763,11 +16784,11 @@
16784 ** Allowed flags for the 3rd parameter to sqlite3FindInIndex().
16785 */
16786 #define IN_INDEX_NOOP_OK 0x0001 /* OK to return IN_INDEX_NOOP */
16787 #define IN_INDEX_MEMBERSHIP 0x0002 /* IN operator used for membership test */
16788 #define IN_INDEX_LOOP 0x0004 /* IN operator used as a loop */
16789 SQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*);
16790
16791 SQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
16792 SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *);
16793 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
16794 SQLITE_PRIVATE int sqlite3JournalCreate(sqlite3_file *);
@@ -16868,10 +16889,15 @@
16889
16890 #if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
16891 SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
16892 #endif
16893
16894 SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr);
16895 SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);
16896 SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);
16897 SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);
16898
16899 #endif /* SQLITEINT_H */
16900
16901 /************** End of sqliteInt.h *******************************************/
16902 /************** Begin file global.c ******************************************/
16903 /*
@@ -25882,11 +25908,11 @@
25908 }
25909 }
25910
25911
25912 /*
25913 ** Generate a human-readable description of a Select object.
25914 */
25915 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
25916 int n = 0;
25917 int cnt = 0;
25918 pView = sqlite3TreeViewPush(pView, moreToFollow);
@@ -26212,10 +26238,19 @@
26238 case TK_MATCH: {
26239 sqlite3TreeViewLine(pView, "MATCH {%d:%d}%s",
26240 pExpr->iTable, pExpr->iColumn, zFlgs);
26241 sqlite3TreeViewExpr(pView, pExpr->pRight, 0);
26242 break;
26243 }
26244 case TK_VECTOR: {
26245 sqlite3TreeViewBareExprList(pView, pExpr->x.pList, "VECTOR");
26246 break;
26247 }
26248 case TK_SELECT_COLUMN: {
26249 sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn);
26250 sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);
26251 break;
26252 }
26253 default: {
26254 sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
26255 break;
26256 }
@@ -26228,26 +26263,25 @@
26263 sqlite3TreeViewLine(pView, "%s%s", zUniOp, zFlgs);
26264 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
26265 }
26266 sqlite3TreeViewPop(pView);
26267 }
26268
26269
26270 /*
26271 ** Generate a human-readable explanation of an expression list.
26272 */
26273 SQLITE_PRIVATE void sqlite3TreeViewBareExprList(
26274 TreeView *pView,
26275 const ExprList *pList,
 
26276 const char *zLabel
26277 ){
 
 
26278 if( zLabel==0 || zLabel[0]==0 ) zLabel = "LIST";
26279 if( pList==0 ){
26280 sqlite3TreeViewLine(pView, "%s (empty)", zLabel);
26281 }else{
26282 int i;
26283 sqlite3TreeViewLine(pView, "%s", zLabel);
26284 for(i=0; i<pList->nExpr; i++){
26285 int j = pList->a[i].u.x.iOrderByCol;
26286 if( j ){
26287 sqlite3TreeViewPush(pView, 0);
@@ -26255,10 +26289,19 @@
26289 }
26290 sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);
26291 if( j ) sqlite3TreeViewPop(pView);
26292 }
26293 }
26294 }
26295 SQLITE_PRIVATE void sqlite3TreeViewExprList(
26296 TreeView *pView,
26297 const ExprList *pList,
26298 u8 moreToFollow,
26299 const char *zLabel
26300 ){
26301 pView = sqlite3TreeViewPush(pView, moreToFollow);
26302 sqlite3TreeViewBareExprList(pView, pList, zLabel);
26303 sqlite3TreeViewPop(pView);
26304 }
26305
26306 #endif /* SQLITE_DEBUG */
26307
@@ -29000,17 +29043,17 @@
29043 /* 31 */ "Found" OpHelp("key=r[P3@P4]"),
29044 /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"),
29045 /* 33 */ "NotExists" OpHelp("intkey=r[P3]"),
29046 /* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
29047 /* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
29048 /* 36 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
29049 /* 37 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
29050 /* 38 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
29051 /* 39 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
29052 /* 40 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
29053 /* 41 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
29054 /* 42 */ "ElseNotEq" OpHelp(""),
29055 /* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
29056 /* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
29057 /* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
29058 /* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
29059 /* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -29017,119 +29060,120 @@
29060 /* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
29061 /* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
29062 /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
29063 /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
29064 /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
29065 /* 53 */ "Last" OpHelp(""),
29066 /* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
29067 /* 55 */ "SorterSort" OpHelp(""),
29068 /* 56 */ "Sort" OpHelp(""),
29069 /* 57 */ "Rewind" OpHelp(""),
29070 /* 58 */ "IdxLE" OpHelp("key=r[P3@P4]"),
29071 /* 59 */ "IdxGT" OpHelp("key=r[P3@P4]"),
29072 /* 60 */ "IdxLT" OpHelp("key=r[P3@P4]"),
29073 /* 61 */ "IdxGE" OpHelp("key=r[P3@P4]"),
29074 /* 62 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
29075 /* 63 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
29076 /* 64 */ "Program" OpHelp(""),
29077 /* 65 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
29078 /* 66 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
29079 /* 67 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"),
29080 /* 68 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
29081 /* 69 */ "IncrVacuum" OpHelp(""),
29082 /* 70 */ "VNext" OpHelp(""),
29083 /* 71 */ "Init" OpHelp("Start at P2"),
29084 /* 72 */ "Return" OpHelp(""),
29085 /* 73 */ "EndCoroutine" OpHelp(""),
29086 /* 74 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
29087 /* 75 */ "Halt" OpHelp(""),
29088 /* 76 */ "Integer" OpHelp("r[P2]=P1"),
29089 /* 77 */ "Int64" OpHelp("r[P2]=P4"),
29090 /* 78 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
29091 /* 79 */ "Null" OpHelp("r[P2..P3]=NULL"),
29092 /* 80 */ "SoftNull" OpHelp("r[P1]=NULL"),
29093 /* 81 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29094 /* 82 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29095 /* 83 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29096 /* 84 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29097 /* 85 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29098 /* 86 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29099 /* 87 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29100 /* 88 */ "CollSeq" OpHelp(""),
29101 /* 89 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29102 /* 90 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29103 /* 91 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29104 /* 92 */ "RealAffinity" OpHelp(""),
29105 /* 93 */ "Cast" OpHelp("affinity(r[P1])"),
29106 /* 94 */ "Permutation" OpHelp(""),
29107 /* 95 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29108 /* 96 */ "Column" OpHelp("r[P3]=PX"),
29109 /* 97 */ "String8" OpHelp("r[P2]='P4'"),
29110 /* 98 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
29111 /* 99 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29112 /* 100 */ "Count" OpHelp("r[P2]=count()"),
29113 /* 101 */ "ReadCookie" OpHelp(""),
29114 /* 102 */ "SetCookie" OpHelp(""),
29115 /* 103 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29116 /* 104 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29117 /* 105 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29118 /* 106 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29119 /* 107 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29120 /* 108 */ "SorterOpen" OpHelp(""),
29121 /* 109 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29122 /* 110 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29123 /* 111 */ "Close" OpHelp(""),
29124 /* 112 */ "ColumnsUsed" OpHelp(""),
29125 /* 113 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29126 /* 114 */ "NewRowid" OpHelp("r[P2]=rowid"),
29127 /* 115 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29128 /* 116 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29129 /* 117 */ "Delete" OpHelp(""),
29130 /* 118 */ "ResetCount" OpHelp(""),
29131 /* 119 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29132 /* 120 */ "SorterData" OpHelp("r[P2]=data"),
29133 /* 121 */ "RowKey" OpHelp("r[P2]=key"),
29134 /* 122 */ "RowData" OpHelp("r[P2]=data"),
29135 /* 123 */ "Rowid" OpHelp("r[P2]=rowid"),
29136 /* 124 */ "NullRow" OpHelp(""),
29137 /* 125 */ "SorterInsert" OpHelp(""),
29138 /* 126 */ "IdxInsert" OpHelp("key=r[P2]"),
29139 /* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29140 /* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29141 /* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29142 /* 130 */ "Destroy" OpHelp(""),
29143 /* 131 */ "Clear" OpHelp(""),
29144 /* 132 */ "ResetSorter" OpHelp(""),
29145 /* 133 */ "Real" OpHelp("r[P2]=P4"),
29146 /* 134 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
29147 /* 135 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29148 /* 136 */ "ParseSchema" OpHelp(""),
29149 /* 137 */ "LoadAnalysis" OpHelp(""),
29150 /* 138 */ "DropTable" OpHelp(""),
29151 /* 139 */ "DropIndex" OpHelp(""),
29152 /* 140 */ "DropTrigger" OpHelp(""),
29153 /* 141 */ "IntegrityCk" OpHelp(""),
29154 /* 142 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29155 /* 143 */ "Param" OpHelp(""),
29156 /* 144 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29157 /* 145 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29158 /* 146 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29159 /* 147 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29160 /* 148 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29161 /* 149 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29162 /* 150 */ "Expire" OpHelp(""),
29163 /* 151 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29164 /* 152 */ "VBegin" OpHelp(""),
29165 /* 153 */ "VCreate" OpHelp(""),
29166 /* 154 */ "VDestroy" OpHelp(""),
29167 /* 155 */ "VOpen" OpHelp(""),
29168 /* 156 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29169 /* 157 */ "VRename" OpHelp(""),
29170 /* 158 */ "Pagecount" OpHelp(""),
29171 /* 159 */ "MaxPgcnt" OpHelp(""),
29172 /* 160 */ "CursorHint" OpHelp(""),
29173 /* 161 */ "Noop" OpHelp(""),
29174 /* 162 */ "Explain" OpHelp(""),
29175 };
29176 return azName[i];
29177 }
29178 #endif
29179
@@ -52964,11 +53008,15 @@
53008 ** This function may return SQLITE_NOMEM if a memory allocation fails,
53009 ** or an IO error code if an IO error occurs while rolling back a
53010 ** savepoint. If no errors occur, SQLITE_OK is returned.
53011 */
53012 SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
53013 int rc = pPager->errCode;
53014
53015 #ifdef SQLITE_ENABLE_ZIPVFS
53016 if( op==SAVEPOINT_RELEASE ) rc = SQLITE_OK;
53017 #endif
53018
53019 assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
53020 assert( iSavepoint>=0 || op==SAVEPOINT_ROLLBACK );
53021
53022 if( rc==SQLITE_OK && iSavepoint<pPager->nSavepoint ){
@@ -53005,10 +53053,24 @@
53053 else if( pagerUseWal(pPager) || isOpen(pPager->jfd) ){
53054 PagerSavepoint *pSavepoint = (nNew==0)?0:&pPager->aSavepoint[nNew-1];
53055 rc = pagerPlaybackSavepoint(pPager, pSavepoint);
53056 assert(rc!=SQLITE_DONE);
53057 }
53058
53059 #ifdef SQLITE_ENABLE_ZIPVFS
53060 /* If the cache has been modified but the savepoint cannot be rolled
53061 ** back journal_mode=off, put the pager in the error state. This way,
53062 ** if the VFS used by this pager includes ZipVFS, the entire transaction
53063 ** can be rolled back at the ZipVFS level. */
53064 else if(
53065 pPager->journalMode==PAGER_JOURNALMODE_OFF
53066 && pPager->eState>=PAGER_WRITER_CACHEMOD
53067 ){
53068 pPager->errCode = SQLITE_ABORT;
53069 pPager->eState = PAGER_ERROR;
53070 }
53071 #endif
53072 }
53073
53074 return rc;
53075 }
53076
@@ -68078,11 +68140,10 @@
68140 p->pSrcDb = pSrcDb;
68141 p->iNext = 1;
68142 p->isAttached = 0;
68143
68144 if( 0==p->pSrc || 0==p->pDest
 
68145 || checkReadTransaction(pDestDb, p->pDest)!=SQLITE_OK
68146 ){
68147 /* One (or both) of the named databases did not exist or an OOM
68148 ** error was hit. Or there is a transaction open on the destination
68149 ** database. The error has already been written into the pDestDb
@@ -68266,26 +68327,36 @@
68327 rc = SQLITE_BUSY;
68328 }else{
68329 rc = SQLITE_OK;
68330 }
68331
 
 
 
 
 
 
 
 
68332 /* If there is no open read-transaction on the source database, open
68333 ** one now. If a transaction is opened here, then it will be closed
68334 ** before this function exits.
68335 */
68336 if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){
68337 rc = sqlite3BtreeBeginTrans(p->pSrc, 0);
68338 bCloseTrans = 1;
68339 }
68340
68341 /* If the destination database has not yet been locked (i.e. if this
68342 ** is the first call to backup_step() for the current backup operation),
68343 ** try to set its page size to the same as the source database. This
68344 ** is especially important on ZipVFS systems, as in that case it is
68345 ** not possible to create a database file that uses one page size by
68346 ** writing to it with another. */
68347 if( p->bDestLocked==0 && rc==SQLITE_OK && setDestPgsz(p)==SQLITE_NOMEM ){
68348 rc = SQLITE_NOMEM;
68349 }
68350
68351 /* Lock the destination database, if it is not locked already. */
68352 if( SQLITE_OK==rc && p->bDestLocked==0
68353 && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2))
68354 ){
68355 p->bDestLocked = 1;
68356 sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);
68357 }
68358
68359 /* Do not allow backup if the destination database is in WAL mode
68360 ** and the page sizes are different between source and destination */
68361 pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);
68362 pgszDest = sqlite3BtreeGetPageSize(p->pDest);
@@ -70202,25 +70273,29 @@
70273 /*
70274 ** This function is used to allocate and populate UnpackedRecord
70275 ** structures intended to be compared against sample index keys stored
70276 ** in the sqlite_stat4 table.
70277 **
70278 ** A single call to this function populates zero or more fields of the
70279 ** record starting with field iVal (fields are numbered from left to
70280 ** right starting with 0). A single field is populated if:
70281 **
70282 ** * (pExpr==0). In this case the value is assumed to be an SQL NULL,
70283 **
70284 ** * The expression is a bound variable, and this is a reprepare, or
70285 **
70286 ** * The sqlite3ValueFromExpr() function is able to extract a value
70287 ** from the expression (i.e. the expression is a literal value).
70288 **
70289 ** Or, if pExpr is a TK_VECTOR, one field is populated for each of the
70290 ** vector components that match either of the two latter criteria listed
70291 ** above.
70292 **
70293 ** Before any value is appended to the record, the affinity of the
70294 ** corresponding column within index pIdx is applied to it. Before
70295 ** this function returns, output parameter *pnExtract is set to the
70296 ** number of values appended to the record.
70297 **
70298 ** When this function is called, *ppRec must either point to an object
70299 ** allocated by an earlier call to this function, or must be NULL. If it
70300 ** is NULL and a value can be successfully extracted, a new UnpackedRecord
70301 ** is allocated (and *ppRec set to point to it) before returning.
@@ -70232,26 +70307,37 @@
70307 SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(
70308 Parse *pParse, /* Parse context */
70309 Index *pIdx, /* Index being probed */
70310 UnpackedRecord **ppRec, /* IN/OUT: Probe record */
70311 Expr *pExpr, /* The expression to extract a value from */
70312 int nElem, /* Maximum number of values to append */
70313 int iVal, /* Array element to populate */
70314 int *pnExtract /* OUT: Values appended to the record */
70315 ){
70316 int rc = SQLITE_OK;
70317 int nExtract = 0;
70318
70319 if( pExpr==0 || pExpr->op!=TK_SELECT ){
70320 int i;
70321 struct ValueNewStat4Ctx alloc;
70322
70323 alloc.pParse = pParse;
70324 alloc.pIdx = pIdx;
70325 alloc.ppRec = ppRec;
70326
70327 for(i=0; i<nElem; i++){
70328 sqlite3_value *pVal = 0;
70329 Expr *pElem = (pExpr ? sqlite3VectorFieldSubexpr(pExpr, i) : 0);
70330 u8 aff = sqlite3IndexColumnAffinity(pParse->db, pIdx, iVal+i);
70331 alloc.iVal = iVal+i;
70332 rc = stat4ValueFromExpr(pParse, pElem, aff, &alloc, &pVal);
70333 if( !pVal ) break;
70334 nExtract++;
70335 }
70336 }
70337
70338 *pnExtract = nExtract;
70339 return rc;
70340 }
70341
70342 /*
70343 ** Attempt to extract a value from expression pExpr using the methods
@@ -71483,16 +71569,25 @@
71569 ){
71570 const char *zOpName;
71571 const char *zSynopsis;
71572 int nOpName;
71573 int ii, jj;
71574 char zAlt[50];
71575 zOpName = sqlite3OpcodeName(pOp->opcode);
71576 nOpName = sqlite3Strlen30(zOpName);
71577 if( zOpName[nOpName+1] ){
71578 int seenCom = 0;
71579 char c;
71580 zSynopsis = zOpName += nOpName + 1;
71581 if( strncmp(zSynopsis,"IF ",3)==0 ){
71582 if( pOp->p5 & SQLITE_STOREP2 ){
71583 sqlite3_snprintf(sizeof(zAlt), zAlt, "r[P2] = (%s)", zSynopsis+3);
71584 }else{
71585 sqlite3_snprintf(sizeof(zAlt), zAlt, "if %s goto P2", zSynopsis+3);
71586 }
71587 zSynopsis = zAlt;
71588 }
71589 for(ii=jj=0; jj<nTemp-1 && (c = zSynopsis[ii])!=0; ii++){
71590 if( c=='P' ){
71591 c = zSynopsis[++ii];
71592 if( c=='4' ){
71593 sqlite3_snprintf(nTemp-jj, zTemp+jj, "%s", zP4);
@@ -77732,11 +77827,11 @@
77827 #endif
77828 int rc = SQLITE_OK; /* Value to return */
77829 sqlite3 *db = p->db; /* The database */
77830 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
77831 u8 encoding = ENC(db); /* The database encoding */
77832 int iCompare = 0; /* Result of last comparison */
77833 unsigned nVmStep = 0; /* Number of virtual machine steps */
77834 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
77835 unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
77836 #endif
77837 Mem *aMem = p->aMem; /* Copy of p->aMem */
@@ -78064,11 +78159,11 @@
78159 pOp = &aOp[pcDest];
78160 break;
78161 }
78162
78163 /* Opcode: HaltIfNull P1 P2 P3 P4 P5
78164 ** Synopsis: if r[P3]=null halt
78165 **
78166 ** Check the value in register P3. If it is NULL then Halt using
78167 ** parameter P1, P2, and P4 as if this were a Halt instruction. If the
78168 ** value in register P3 is not NULL, then this routine is a no-op.
78169 ** The P5 parameter should be 1.
@@ -78277,11 +78372,11 @@
78372 #endif
78373 break;
78374 }
78375
78376 /* Opcode: Null P1 P2 P3 * *
78377 ** Synopsis: r[P2..P3]=NULL
78378 **
78379 ** Write a NULL into registers P2. If P3 greater than P2, then also write
78380 ** NULL into register P3 and every register in between P2 and P3. If P3
78381 ** is less than P2 (typically P3 is zero) then only register P2 is
78382 ** set to NULL.
@@ -78306,11 +78401,11 @@
78401 }
78402 break;
78403 }
78404
78405 /* Opcode: SoftNull P1 * * * *
78406 ** Synopsis: r[P1]=NULL
78407 **
78408 ** Set register P1 to have the value NULL as seen by the OP_MakeRecord
78409 ** instruction, but do not free any string or blob memory associated with
78410 ** the register, so that if the value was a string or blob that was
78411 ** previously copied using OP_SCopy, the copies will continue to be valid.
@@ -78359,11 +78454,11 @@
78454 UPDATE_MAX_BLOBSIZE(pOut);
78455 break;
78456 }
78457
78458 /* Opcode: Move P1 P2 P3 * *
78459 ** Synopsis: r[P2@P3]=r[P1@P3]
78460 **
78461 ** Move the P3 values in register P1..P1+P3-1 over into
78462 ** registers P2..P2+P3-1. Registers P1..P1+P3-1 are
78463 ** left holding a NULL. It is an error for register ranges
78464 ** P1..P1+P3-1 and P2..P2+P3-1 to overlap. It is an error
@@ -78469,11 +78564,11 @@
78564 sqlite3VdbeMemSetInt64(pOut, pIn1->u.i);
78565 break;
78566 }
78567
78568 /* Opcode: ResultRow P1 P2 * * *
78569 ** Synopsis: output=r[P1@P2]
78570 **
78571 ** The registers P1 through P1+P2-1 contain a single row of
78572 ** results. This opcode causes the sqlite3_step() call to terminate
78573 ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt
78574 ** structure to provide access to the r(P1)..r(P1+P2-1) values as
@@ -78602,41 +78697,41 @@
78697 UPDATE_MAX_BLOBSIZE(pOut);
78698 break;
78699 }
78700
78701 /* Opcode: Add P1 P2 P3 * *
78702 ** Synopsis: r[P3]=r[P1]+r[P2]
78703 **
78704 ** Add the value in register P1 to the value in register P2
78705 ** and store the result in register P3.
78706 ** If either input is NULL, the result is NULL.
78707 */
78708 /* Opcode: Multiply P1 P2 P3 * *
78709 ** Synopsis: r[P3]=r[P1]*r[P2]
78710 **
78711 **
78712 ** Multiply the value in register P1 by the value in register P2
78713 ** and store the result in register P3.
78714 ** If either input is NULL, the result is NULL.
78715 */
78716 /* Opcode: Subtract P1 P2 P3 * *
78717 ** Synopsis: r[P3]=r[P2]-r[P1]
78718 **
78719 ** Subtract the value in register P1 from the value in register P2
78720 ** and store the result in register P3.
78721 ** If either input is NULL, the result is NULL.
78722 */
78723 /* Opcode: Divide P1 P2 P3 * *
78724 ** Synopsis: r[P3]=r[P2]/r[P1]
78725 **
78726 ** Divide the value in register P1 by the value in register P2
78727 ** and store the result in register P3 (P3=P2/P1). If the value in
78728 ** register P1 is zero, then the result is NULL. If either input is
78729 ** NULL, the result is NULL.
78730 */
78731 /* Opcode: Remainder P1 P2 P3 * *
78732 ** Synopsis: r[P3]=r[P2]%r[P1]
78733 **
78734 ** Compute the remainder after integer register P2 is divided by
78735 ** register P1 and store the result in register P3.
78736 ** If the value in register P1 is zero the result is NULL.
78737 ** If either operand is NULL, the result is NULL.
@@ -78865,33 +78960,33 @@
78960 UPDATE_MAX_BLOBSIZE(pCtx->pOut);
78961 break;
78962 }
78963
78964 /* Opcode: BitAnd P1 P2 P3 * *
78965 ** Synopsis: r[P3]=r[P1]&r[P2]
78966 **
78967 ** Take the bit-wise AND of the values in register P1 and P2 and
78968 ** store the result in register P3.
78969 ** If either input is NULL, the result is NULL.
78970 */
78971 /* Opcode: BitOr P1 P2 P3 * *
78972 ** Synopsis: r[P3]=r[P1]|r[P2]
78973 **
78974 ** Take the bit-wise OR of the values in register P1 and P2 and
78975 ** store the result in register P3.
78976 ** If either input is NULL, the result is NULL.
78977 */
78978 /* Opcode: ShiftLeft P1 P2 P3 * *
78979 ** Synopsis: r[P3]=r[P2]<<r[P1]
78980 **
78981 ** Shift the integer value in register P2 to the left by the
78982 ** number of bits specified by the integer in register P1.
78983 ** Store the result in register P3.
78984 ** If either input is NULL, the result is NULL.
78985 */
78986 /* Opcode: ShiftRight P1 P2 P3 * *
78987 ** Synopsis: r[P3]=r[P2]>>r[P1]
78988 **
78989 ** Shift the integer value in register P2 to the right by the
78990 ** number of bits specified by the integer in register P1.
78991 ** Store the result in register P3.
78992 ** If either input is NULL, the result is NULL.
@@ -78947,11 +79042,11 @@
79042 MemSetTypeFlag(pOut, MEM_Int);
79043 break;
79044 }
79045
79046 /* Opcode: AddImm P1 P2 * * *
79047 ** Synopsis: r[P1]=r[P1]+P2
79048 **
79049 ** Add the constant P2 to the value in register P1.
79050 ** The result is always an integer.
79051 **
79052 ** To force any register to be an integer, just add 0.
@@ -79039,18 +79134,65 @@
79134 if( rc ) goto abort_due_to_error;
79135 break;
79136 }
79137 #endif /* SQLITE_OMIT_CAST */
79138
79139 /* Opcode: Eq P1 P2 P3 P4 P5
79140 ** Synopsis: IF r[P3]==r[P1]
79141 **
79142 ** Compare the values in register P1 and P3. If reg(P3)==reg(P1) then
79143 ** jump to address P2. Or if the SQLITE_STOREP2 flag is set in P5, then
79144 ** store the result of comparison in register P2.
79145 **
79146 ** The SQLITE_AFF_MASK portion of P5 must be an affinity character -
79147 ** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made
79148 ** to coerce both inputs according to this affinity before the
79149 ** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric
79150 ** affinity is used. Note that the affinity conversions are stored
79151 ** back into the input registers P1 and P3. So this opcode can cause
79152 ** persistent changes to registers P1 and P3.
79153 **
79154 ** Once any conversions have taken place, and neither value is NULL,
79155 ** the values are compared. If both values are blobs then memcmp() is
79156 ** used to determine the results of the comparison. If both values
79157 ** are text, then the appropriate collating function specified in
79158 ** P4 is used to do the comparison. If P4 is not specified then
79159 ** memcmp() is used to compare text string. If both values are
79160 ** numeric, then a numeric comparison is used. If the two values
79161 ** are of different types, then numbers are considered less than
79162 ** strings and strings are considered less than blobs.
79163 **
79164 ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
79165 ** true or false and is never NULL. If both operands are NULL then the result
79166 ** of comparison is true. If either operand is NULL then the result is false.
79167 ** If neither operand is NULL the result is the same as it would be if
79168 ** the SQLITE_NULLEQ flag were omitted from P5.
79169 **
79170 ** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the
79171 ** content of r[P2] is only changed if the new value is NULL or 0 (false).
79172 ** In other words, a prior r[P2] value will not be overwritten by 1 (true).
79173 */
79174 /* Opcode: Ne P1 P2 P3 P4 P5
79175 ** Synopsis: IF r[P3]!=r[P1]
79176 **
79177 ** This works just like the Eq opcode except that the jump is taken if
79178 ** the operands in registers P1 and P3 are not equal. See the Eq opcode for
79179 ** additional information.
79180 **
79181 ** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the
79182 ** content of r[P2] is only changed if the new value is NULL or 1 (true).
79183 ** In other words, a prior r[P2] value will not be overwritten by 0 (false).
79184 */
79185 /* Opcode: Lt P1 P2 P3 P4 P5
79186 ** Synopsis: IF r[P3]<r[P1]
79187 **
79188 ** Compare the values in register P1 and P3. If reg(P3)<reg(P1) then
79189 ** jump to address P2. Or if the SQLITE_STOREP2 flag is set in P5 store
79190 ** the result of comparison (0 or 1 or NULL) into register P2.
79191 **
79192 ** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or
79193 ** reg(P3) is NULL then the take the jump. If the SQLITE_JUMPIFNULL
79194 ** bit is clear then fall through if either operand is NULL.
79195 **
79196 ** The SQLITE_AFF_MASK portion of P5 must be an affinity character -
79197 ** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made
79198 ** to coerce both inputs according to this affinity before the
@@ -79066,60 +79208,27 @@
79208 ** P4 is used to do the comparison. If P4 is not specified then
79209 ** memcmp() is used to compare text string. If both values are
79210 ** numeric, then a numeric comparison is used. If the two values
79211 ** are of different types, then numbers are considered less than
79212 ** strings and strings are considered less than blobs.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79213 */
79214 /* Opcode: Le P1 P2 P3 P4 P5
79215 ** Synopsis: IF r[P3]<=r[P1]
79216 **
79217 ** This works just like the Lt opcode except that the jump is taken if
79218 ** the content of register P3 is less than or equal to the content of
79219 ** register P1. See the Lt opcode for additional information.
79220 */
79221 /* Opcode: Gt P1 P2 P3 P4 P5
79222 ** Synopsis: IF r[P3]>r[P1]
79223 **
79224 ** This works just like the Lt opcode except that the jump is taken if
79225 ** the content of register P3 is greater than the content of
79226 ** register P1. See the Lt opcode for additional information.
79227 */
79228 /* Opcode: Ge P1 P2 P3 P4 P5
79229 ** Synopsis: IF r[P3]>=r[P1]
79230 **
79231 ** This works just like the Lt opcode except that the jump is taken if
79232 ** the content of register P3 is greater than or equal to the content of
79233 ** register P1. See the Lt opcode for additional information.
79234 */
@@ -79127,11 +79236,11 @@
79236 case OP_Ne: /* same as TK_NE, jump, in1, in3 */
79237 case OP_Lt: /* same as TK_LT, jump, in1, in3 */
79238 case OP_Le: /* same as TK_LE, jump, in1, in3 */
79239 case OP_Gt: /* same as TK_GT, jump, in1, in3 */
79240 case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
79241 int res, res2; /* Result of the comparison of pIn1 against pIn3 */
79242 char affinity; /* Affinity to use for comparison */
79243 u16 flags1; /* Copy of initial value of pIn1->flags */
79244 u16 flags3; /* Copy of initial value of pIn3->flags */
79245
79246 pIn1 = &aMem[pOp->p1];
@@ -79150,21 +79259,22 @@
79259 assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 );
79260 if( (flags1&MEM_Null)!=0
79261 && (flags3&MEM_Null)!=0
79262 && (flags3&MEM_Cleared)==0
79263 ){
79264 res = 0; /* Operands are equal */
79265 }else{
79266 res = 1; /* Operands are not equal */
79267 }
79268 }else{
79269 /* SQLITE_NULLEQ is clear and at least one operand is NULL,
79270 ** then the result is always NULL.
79271 ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
79272 */
79273 if( pOp->p5 & SQLITE_STOREP2 ){
79274 pOut = &aMem[pOp->p2];
79275 iCompare = 1; /* Operands are not equal */
79276 memAboutToChange(p, pOut);
79277 MemSetTypeFlag(pOut, MEM_Null);
79278 REGISTER_TRACE(pOp->p2, pOut);
79279 }else{
79280 VdbeBranchTaken(2,3);
@@ -79214,16 +79324,16 @@
79324 flags3 &= ~MEM_Zero;
79325 }
79326 res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
79327 }
79328 switch( pOp->opcode ){
79329 case OP_Eq: res2 = res==0; break;
79330 case OP_Ne: res2 = res; break;
79331 case OP_Lt: res2 = res<0; break;
79332 case OP_Le: res2 = res<=0; break;
79333 case OP_Gt: res2 = res>0; break;
79334 default: res2 = res>=0; break;
79335 }
79336
79337 /* Undo any changes made by applyAffinity() to the input registers. */
79338 assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
79339 pIn1->flags = flags1;
@@ -79230,22 +79340,58 @@
79340 assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );
79341 pIn3->flags = flags3;
79342
79343 if( pOp->p5 & SQLITE_STOREP2 ){
79344 pOut = &aMem[pOp->p2];
79345 iCompare = res;
79346 res2 = res2!=0; /* For this path res2 must be exactly 0 or 1 */
79347 if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){
79348 /* The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1
79349 ** and prevents OP_Ne from overwriting NULL with 0. This flag
79350 ** is only used in contexts where either:
79351 ** (1) op==OP_Eq && (r[P2]==NULL || r[P2]==0)
79352 ** (2) op==OP_Ne && (r[P2]==NULL || r[P2]==1)
79353 ** Therefore it is not necessary to check the content of r[P2] for
79354 ** NULL. */
79355 assert( pOp->opcode==OP_Ne || pOp->opcode==OP_Eq );
79356 assert( res2==0 || res2==1 );
79357 testcase( res2==0 && pOp->opcode==OP_Eq );
79358 testcase( res2==1 && pOp->opcode==OP_Eq );
79359 testcase( res2==0 && pOp->opcode==OP_Ne );
79360 testcase( res2==1 && pOp->opcode==OP_Ne );
79361 if( (pOp->opcode==OP_Eq)==res2 ) break;
79362 }
79363 memAboutToChange(p, pOut);
79364 MemSetTypeFlag(pOut, MEM_Int);
79365 pOut->u.i = res2;
79366 REGISTER_TRACE(pOp->p2, pOut);
79367 }else{
79368 VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
79369 if( res2 ){
79370 goto jump_to_p2;
79371 }
79372 }
79373 break;
79374 }
79375
79376 /* Opcode: ElseNotEq * P2 * * *
79377 **
79378 ** This opcode must immediately follow an Lt or Gt comparison operator.
79379 ** If the operands in that previous comparison had been used with an Eq
79380 ** operator and if the result of that Eq would be NULL or false (0), then
79381 ** then jump to P2. If the result of comparing the two previous operands
79382 ** using Eq would have been true (1), then fall through.
79383 */
79384 case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */
79385 assert( pOp>aOp );
79386 assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt );
79387 assert( pOp[-1].p5 & SQLITE_STOREP2 );
79388 VdbeBranchTaken(iCompare!=0, 2);
79389 if( iCompare!=0 ) goto jump_to_p2;
79390 break;
79391 }
79392
79393
79394 /* Opcode: Permutation * * * P4 *
79395 **
79396 ** Set the permutation used by the OP_Compare operator to be the array
79397 ** of integers in P4.
@@ -79492,11 +79638,11 @@
79638 }
79639 break;
79640 }
79641
79642 /* Opcode: IsNull P1 P2 * * *
79643 ** Synopsis: if r[P1]==NULL goto P2
79644 **
79645 ** Jump to P2 if the value in register P1 is NULL.
79646 */
79647 case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */
79648 pIn1 = &aMem[pOp->p1];
@@ -79520,11 +79666,11 @@
79666 }
79667 break;
79668 }
79669
79670 /* Opcode: Column P1 P2 P3 P4 P5
79671 ** Synopsis: r[P3]=PX
79672 **
79673 ** Interpret the data that cursor P1 points to as a structure built using
79674 ** the MakeRecord instruction. (See the MakeRecord opcode for additional
79675 ** information about the format of the data.) Extract the P2-th column
79676 ** from this record. If there are less that (P2+1)
@@ -81030,11 +81176,10 @@
81176 assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
81177 pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */
81178 }
81179 break;
81180 }
 
81181
81182 /* Opcode: Found P1 P2 P3 P4 *
81183 ** Synopsis: key=r[P3@P4]
81184 **
81185 ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If
@@ -81463,11 +81608,11 @@
81608 **
81609 ** This instruction only works on tables. The equivalent instruction
81610 ** for indices is OP_IdxInsert.
81611 */
81612 /* Opcode: InsertInt P1 P2 P3 P4 P5
81613 ** Synopsis: intkey=P3 data=r[P2]
81614 **
81615 ** This works exactly like OP_Insert except that the key is the
81616 ** integer value P3, not the value of the integer stored in register P3.
81617 */
81618 case OP_Insert:
@@ -81694,11 +81839,11 @@
81839 p->nChange = 0;
81840 break;
81841 }
81842
81843 /* Opcode: SorterCompare P1 P2 P3 P4
81844 ** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2
81845 **
81846 ** P1 is a sorter cursor. This instruction compares a prefix of the
81847 ** record blob in register P3 against a prefix of the entry that
81848 ** the sorter cursor currently points to. Only the first P4 fields
81849 ** of r[P3] and the sorter record are compared.
@@ -82221,11 +82366,11 @@
82366 pC->cacheStatus = CACHE_STALE;
82367 break;
82368 }
82369
82370 /* Opcode: Seek P1 * P3 P4 *
82371 ** Synopsis: Move P3 to P1.rowid
82372 **
82373 ** P1 is an open index cursor and P3 is a cursor on the corresponding
82374 ** table. This opcode does a deferred seek of the P3 table cursor
82375 ** to the row that corresponds to the current row of P1.
82376 **
@@ -82728,11 +82873,11 @@
82873 break;
82874 }
82875 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
82876
82877 /* Opcode: RowSetAdd P1 P2 * * *
82878 ** Synopsis: rowset(P1)=r[P2]
82879 **
82880 ** Insert the integer value held by register P2 into a boolean index
82881 ** held in register P1.
82882 **
82883 ** An assertion fails if P2 is not an integer.
@@ -82748,11 +82893,11 @@
82893 sqlite3RowSetInsert(pIn1->u.pRowSet, pIn2->u.i);
82894 break;
82895 }
82896
82897 /* Opcode: RowSetRead P1 P2 P3 * *
82898 ** Synopsis: r[P3]=rowset(P1)
82899 **
82900 ** Extract the smallest value from boolean index P1 and put that value into
82901 ** register P3. Or, if boolean index P1 is initially empty, leave P3
82902 ** unchanged and jump to instruction P2.
82903 */
@@ -83927,11 +84072,11 @@
84072 }
84073 #endif
84074
84075
84076 /* Opcode: Init * P2 * P4 *
84077 ** Synopsis: Start at P2
84078 **
84079 ** Programs contain a single instance of this opcode as the very first
84080 ** opcode.
84081 **
84082 ** If tracing is enabled (by the sqlite3_trace()) interface, then
@@ -83987,12 +84132,12 @@
84132 ){
84133 sqlite3DebugPrintf("SQL-trace: %s\n", zTrace);
84134 }
84135 #endif /* SQLITE_DEBUG */
84136 #endif /* SQLITE_OMIT_TRACE */
84137 assert( pOp->p2>0 );
84138 goto jump_to_p2;
84139 }
84140
84141 #ifdef SQLITE_ENABLE_CURSOR_HINTS
84142 /* Opcode: CursorHint P1 * * P4 *
84143 **
@@ -88760,10 +88905,37 @@
88905 }
88906 case TK_VARIABLE: {
88907 notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
88908 break;
88909 }
88910 case TK_EQ:
88911 case TK_NE:
88912 case TK_LT:
88913 case TK_LE:
88914 case TK_GT:
88915 case TK_GE:
88916 case TK_IS:
88917 case TK_ISNOT: {
88918 int nLeft, nRight;
88919 if( pParse->db->mallocFailed ) break;
88920 assert( pExpr->pRight!=0 );
88921 assert( pExpr->pLeft!=0 );
88922 nLeft = sqlite3ExprVectorSize(pExpr->pLeft);
88923 nRight = sqlite3ExprVectorSize(pExpr->pRight);
88924 if( nLeft!=nRight ){
88925 testcase( pExpr->op==TK_EQ );
88926 testcase( pExpr->op==TK_NE );
88927 testcase( pExpr->op==TK_LT );
88928 testcase( pExpr->op==TK_LE );
88929 testcase( pExpr->op==TK_GT );
88930 testcase( pExpr->op==TK_GE );
88931 testcase( pExpr->op==TK_IS );
88932 testcase( pExpr->op==TK_ISNOT );
88933 sqlite3ErrorMsg(pParse, "row value misused");
88934 }
88935 break;
88936 }
88937 }
88938 return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
88939 }
88940
88941 /*
@@ -89501,10 +89673,22 @@
89673 *************************************************************************
89674 ** This file contains routines used for analyzing expressions and
89675 ** for generating VDBE code that evaluates expressions in SQLite.
89676 */
89677 /* #include "sqliteInt.h" */
89678
89679 /* Forward declarations */
89680 static void exprCodeBetween(Parse*,Expr*,int,void(*)(Parse*,Expr*,int,int),int);
89681 static int exprCodeVector(Parse *pParse, Expr *p, int *piToFree);
89682
89683 /*
89684 ** Return the affinity character for a single column of a table.
89685 */
89686 SQLITE_PRIVATE char sqlite3TableColumnAffinity(Table *pTab, int iCol){
89687 assert( iCol<pTab->nCol );
89688 return iCol>=0 ? pTab->aCol[iCol].affinity : SQLITE_AFF_INTEGER;
89689 }
89690
89691 /*
89692 ** Return the 'affinity' of the expression pExpr if any.
89693 **
89694 ** If pExpr is a column, a reference to a column via an 'AS' alias,
@@ -89527,25 +89711,25 @@
89711 op = pExpr->op;
89712 if( op==TK_SELECT ){
89713 assert( pExpr->flags&EP_xIsSelect );
89714 return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
89715 }
89716 if( op==TK_REGISTER ) op = pExpr->op2;
89717 #ifndef SQLITE_OMIT_CAST
89718 if( op==TK_CAST ){
89719 assert( !ExprHasProperty(pExpr, EP_IntValue) );
89720 return sqlite3AffinityType(pExpr->u.zToken, 0);
89721 }
89722 #endif
89723 if( op==TK_AGG_COLUMN || op==TK_COLUMN ){
89724 return sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn);
89725 }
89726 if( op==TK_SELECT_COLUMN ){
89727 assert( pExpr->pLeft->flags&EP_xIsSelect );
89728 return sqlite3ExprAffinity(
89729 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
89730 );
 
89731 }
89732 return pExpr->affinity;
89733 }
89734
89735 /*
@@ -89707,11 +89891,11 @@
89891 aff = sqlite3ExprAffinity(pExpr->pLeft);
89892 if( pExpr->pRight ){
89893 aff = sqlite3CompareAffinity(pExpr->pRight, aff);
89894 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
89895 aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);
89896 }else if( NEVER(aff==0) ){
89897 aff = SQLITE_AFF_BLOB;
89898 }
89899 return aff;
89900 }
89901
@@ -89796,10 +89980,274 @@
89980 addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
89981 (void*)p4, P4_COLLSEQ);
89982 sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
89983 return addr;
89984 }
89985
89986 /*
89987 ** Return true if expression pExpr is a vector, or false otherwise.
89988 **
89989 ** A vector is defined as any expression that results in two or more
89990 ** columns of result. Every TK_VECTOR node is an vector because the
89991 ** parser will not generate a TK_VECTOR with fewer than two entries.
89992 ** But a TK_SELECT might be either a vector or a scalar. It is only
89993 ** considered a vector if it has two or more result columns.
89994 */
89995 SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr){
89996 return sqlite3ExprVectorSize(pExpr)>1;
89997 }
89998
89999 /*
90000 ** If the expression passed as the only argument is of type TK_VECTOR
90001 ** return the number of expressions in the vector. Or, if the expression
90002 ** is a sub-select, return the number of columns in the sub-select. For
90003 ** any other type of expression, return 1.
90004 */
90005 SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr){
90006 u8 op = pExpr->op;
90007 if( op==TK_REGISTER ) op = pExpr->op2;
90008 if( op==TK_VECTOR ){
90009 return pExpr->x.pList->nExpr;
90010 }else if( op==TK_SELECT ){
90011 return pExpr->x.pSelect->pEList->nExpr;
90012 }else{
90013 return 1;
90014 }
90015 }
90016
90017 #ifndef SQLITE_OMIT_SUBQUERY
90018 /*
90019 ** Return a pointer to a subexpression of pVector that is the i-th
90020 ** column of the vector (numbered starting with 0). The caller must
90021 ** ensure that i is within range.
90022 **
90023 ** If pVector is really a scalar (and "scalar" here includes subqueries
90024 ** that return a single column!) then return pVector unmodified.
90025 **
90026 ** pVector retains ownership of the returned subexpression.
90027 **
90028 ** If the vector is a (SELECT ...) then the expression returned is
90029 ** just the expression for the i-th term of the result set, and may
90030 ** not be ready for evaluation because the table cursor has not yet
90031 ** been positioned.
90032 */
90033 SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){
90034 assert( i<sqlite3ExprVectorSize(pVector) );
90035 if( sqlite3ExprIsVector(pVector) ){
90036 assert( pVector->op2==0 || pVector->op==TK_REGISTER );
90037 if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){
90038 return pVector->x.pSelect->pEList->a[i].pExpr;
90039 }else{
90040 return pVector->x.pList->a[i].pExpr;
90041 }
90042 }
90043 return pVector;
90044 }
90045 #endif /* !defined(SQLITE_OMIT_SUBQUERY) */
90046
90047 #ifndef SQLITE_OMIT_SUBQUERY
90048 /*
90049 ** Compute and return a new Expr object which when passed to
90050 ** sqlite3ExprCode() will generate all necessary code to compute
90051 ** the iField-th column of the vector expression pVector.
90052 **
90053 ** It is ok for pVector to be a scalar (as long as iField==0).
90054 ** In that case, this routine works like sqlite3ExprDup().
90055 **
90056 ** The caller owns the returned Expr object and is responsible for
90057 ** ensuring that the returned value eventually gets freed.
90058 **
90059 ** The caller retains ownership of pVector. If pVector is a TK_SELECT,
90060 ** then the returned object will reference pVector and so pVector must remain
90061 ** valid for the life of the returned object. If pVector is a TK_VECTOR
90062 ** or a scalar expression, then it can be deleted as soon as this routine
90063 ** returns.
90064 **
90065 ** A trick to cause a TK_SELECT pVector to be deleted together with
90066 ** the returned Expr object is to attach the pVector to the pRight field
90067 ** of the returned TK_SELECT_COLUMN Expr object.
90068 */
90069 SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(
90070 Parse *pParse, /* Parsing context */
90071 Expr *pVector, /* The vector. List of expressions or a sub-SELECT */
90072 int iField /* Which column of the vector to return */
90073 ){
90074 Expr *pRet;
90075 if( pVector->op==TK_SELECT ){
90076 assert( pVector->flags & EP_xIsSelect );
90077 /* The TK_SELECT_COLUMN Expr node:
90078 **
90079 ** pLeft: pVector containing TK_SELECT
90080 ** pRight: not used. But recursively deleted.
90081 ** iColumn: Index of a column in pVector
90082 ** pLeft->iTable: First in an array of register holding result, or 0
90083 ** if the result is not yet computed.
90084 **
90085 ** sqlite3ExprDelete() specifically skips the recursive delete of
90086 ** pLeft on TK_SELECT_COLUMN nodes. But pRight is followed, so pVector
90087 ** can be attached to pRight to cause this node to take ownership of
90088 ** pVector. Typically there will be multiple TK_SELECT_COLUMN nodes
90089 ** with the same pLeft pointer to the pVector, but only one of them
90090 ** will own the pVector.
90091 */
90092 pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0, 0);
90093 if( pRet ){
90094 pRet->iColumn = iField;
90095 pRet->pLeft = pVector;
90096 }
90097 assert( pRet==0 || pRet->iTable==0 );
90098 }else{
90099 if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
90100 pRet = sqlite3ExprDup(pParse->db, pVector, 0);
90101 }
90102 return pRet;
90103 }
90104 #endif /* !define(SQLITE_OMIT_SUBQUERY) */
90105
90106 /*
90107 ** If expression pExpr is of type TK_SELECT, generate code to evaluate
90108 ** it. Return the register in which the result is stored (or, if the
90109 ** sub-select returns more than one column, the first in an array
90110 ** of registers in which the result is stored).
90111 **
90112 ** If pExpr is not a TK_SELECT expression, return 0.
90113 */
90114 static int exprCodeSubselect(Parse *pParse, Expr *pExpr){
90115 int reg = 0;
90116 #ifndef SQLITE_OMIT_SUBQUERY
90117 if( pExpr->op==TK_SELECT ){
90118 reg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
90119 }
90120 #endif
90121 return reg;
90122 }
90123
90124 /*
90125 ** Argument pVector points to a vector expression - either a TK_VECTOR
90126 ** or TK_SELECT that returns more than one column. This function returns
90127 ** the register number of a register that contains the value of
90128 ** element iField of the vector.
90129 **
90130 ** If pVector is a TK_SELECT expression, then code for it must have
90131 ** already been generated using the exprCodeSubselect() routine. In this
90132 ** case parameter regSelect should be the first in an array of registers
90133 ** containing the results of the sub-select.
90134 **
90135 ** If pVector is of type TK_VECTOR, then code for the requested field
90136 ** is generated. In this case (*pRegFree) may be set to the number of
90137 ** a temporary register to be freed by the caller before returning.
90138 **
90139 ** Before returning, output parameter (*ppExpr) is set to point to the
90140 ** Expr object corresponding to element iElem of the vector.
90141 */
90142 static int exprVectorRegister(
90143 Parse *pParse, /* Parse context */
90144 Expr *pVector, /* Vector to extract element from */
90145 int iField, /* Field to extract from pVector */
90146 int regSelect, /* First in array of registers */
90147 Expr **ppExpr, /* OUT: Expression element */
90148 int *pRegFree /* OUT: Temp register to free */
90149 ){
90150 u8 op = pVector->op;
90151 assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT );
90152 if( op==TK_REGISTER ){
90153 *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField);
90154 return pVector->iTable+iField;
90155 }
90156 if( op==TK_SELECT ){
90157 *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;
90158 return regSelect+iField;
90159 }
90160 *ppExpr = pVector->x.pList->a[iField].pExpr;
90161 return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);
90162 }
90163
90164 /*
90165 ** Expression pExpr is a comparison between two vector values. Compute
90166 ** the result of the comparison (1, 0, or NULL) and write that
90167 ** result into register dest.
90168 **
90169 ** The caller must satisfy the following preconditions:
90170 **
90171 ** if pExpr->op==TK_IS: op==TK_EQ and p5==SQLITE_NULLEQ
90172 ** if pExpr->op==TK_ISNOT: op==TK_NE and p5==SQLITE_NULLEQ
90173 ** otherwise: op==pExpr->op and p5==0
90174 */
90175 static void codeVectorCompare(
90176 Parse *pParse, /* Code generator context */
90177 Expr *pExpr, /* The comparison operation */
90178 int dest, /* Write results into this register */
90179 u8 op, /* Comparison operator */
90180 u8 p5 /* SQLITE_NULLEQ or zero */
90181 ){
90182 Vdbe *v = pParse->pVdbe;
90183 Expr *pLeft = pExpr->pLeft;
90184 Expr *pRight = pExpr->pRight;
90185 int nLeft = sqlite3ExprVectorSize(pLeft);
90186 int i;
90187 int regLeft = 0;
90188 int regRight = 0;
90189 u8 opx = op;
90190 int addrDone = sqlite3VdbeMakeLabel(v);
90191
90192 assert( nLeft==sqlite3ExprVectorSize(pRight) );
90193 assert( pExpr->op==TK_EQ || pExpr->op==TK_NE
90194 || pExpr->op==TK_IS || pExpr->op==TK_ISNOT
90195 || pExpr->op==TK_LT || pExpr->op==TK_GT
90196 || pExpr->op==TK_LE || pExpr->op==TK_GE
90197 );
90198 assert( pExpr->op==op || (pExpr->op==TK_IS && op==TK_EQ)
90199 || (pExpr->op==TK_ISNOT && op==TK_NE) );
90200 assert( p5==0 || pExpr->op!=op );
90201 assert( p5==SQLITE_NULLEQ || pExpr->op==op );
90202
90203 p5 |= SQLITE_STOREP2;
90204 if( opx==TK_LE ) opx = TK_LT;
90205 if( opx==TK_GE ) opx = TK_GT;
90206
90207 regLeft = exprCodeSubselect(pParse, pLeft);
90208 regRight = exprCodeSubselect(pParse, pRight);
90209
90210 for(i=0; 1 /*Loop exits by "break"*/; i++){
90211 int regFree1 = 0, regFree2 = 0;
90212 Expr *pL, *pR;
90213 int r1, r2;
90214 assert( i>=0 && i<nLeft );
90215 if( i>0 ) sqlite3ExprCachePush(pParse);
90216 r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);
90217 r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);
90218 codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5);
90219 testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
90220 testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
90221 testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
90222 testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
90223 testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
90224 testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
90225 sqlite3ReleaseTempReg(pParse, regFree1);
90226 sqlite3ReleaseTempReg(pParse, regFree2);
90227 if( i>0 ) sqlite3ExprCachePop(pParse);
90228 if( i==nLeft-1 ){
90229 break;
90230 }
90231 if( opx==TK_EQ ){
90232 sqlite3VdbeAddOp2(v, OP_IfNot, dest, addrDone); VdbeCoverage(v);
90233 p5 |= SQLITE_KEEPNULL;
90234 }else if( opx==TK_NE ){
90235 sqlite3VdbeAddOp2(v, OP_If, dest, addrDone); VdbeCoverage(v);
90236 p5 |= SQLITE_KEEPNULL;
90237 }else{
90238 assert( op==TK_LT || op==TK_GT || op==TK_LE || op==TK_GE );
90239 sqlite3VdbeAddOp2(v, OP_ElseNotEq, 0, addrDone);
90240 VdbeCoverageIf(v, op==TK_LT);
90241 VdbeCoverageIf(v, op==TK_GT);
90242 VdbeCoverageIf(v, op==TK_LE);
90243 VdbeCoverageIf(v, op==TK_GE);
90244 if( i==nLeft-2 ) opx = op;
90245 }
90246 }
90247 sqlite3VdbeResolveLabel(v, addrDone);
90248 }
90249
90250 #if SQLITE_MAX_EXPR_DEPTH>0
90251 /*
90252 ** Check that argument nHeight is less than or equal to the maximum
90253 ** expression depth allowed. If it is not, leave an error message in
@@ -90231,11 +90679,11 @@
90679 /* Sanity check: Assert that the IntValue is non-negative if it exists */
90680 assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );
90681 if( !ExprHasProperty(p, EP_TokenOnly) ){
90682 /* The Expr.x union is never used at the same time as Expr.pRight */
90683 assert( p->x.pList==0 || p->pRight==0 );
90684 if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);
90685 sqlite3ExprDelete(db, p->pRight);
90686 if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);
90687 if( ExprHasProperty(p, EP_xIsSelect) ){
90688 sqlite3SelectDelete(db, p->x.pSelect);
90689 }else{
@@ -90439,11 +90887,15 @@
90887 if( pzBuffer ){
90888 *pzBuffer = zAlloc;
90889 }
90890 }else{
90891 if( !ExprHasProperty(p, EP_TokenOnly) ){
90892 if( pNew->op==TK_SELECT_COLUMN ){
90893 pNew->pLeft = p->pLeft;
90894 }else{
90895 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
90896 }
90897 pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
90898 }
90899 }
90900 }
90901 return pNew;
@@ -90679,10 +91131,64 @@
91131 /* Avoid leaking memory if malloc has failed. */
91132 sqlite3ExprDelete(db, pExpr);
91133 sqlite3ExprListDelete(db, pList);
91134 return 0;
91135 }
91136
91137 /*
91138 ** pColumns and pExpr form a vector assignment which is part of the SET
91139 ** clause of an UPDATE statement. Like this:
91140 **
91141 ** (a,b,c) = (expr1,expr2,expr3)
91142 ** Or: (a,b,c) = (SELECT x,y,z FROM ....)
91143 **
91144 ** For each term of the vector assignment, append new entries to the
91145 ** expression list pList. In the case of a subquery on the LHS, append
91146 ** TK_SELECT_COLUMN expressions.
91147 */
91148 SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(
91149 Parse *pParse, /* Parsing context */
91150 ExprList *pList, /* List to which to append. Might be NULL */
91151 IdList *pColumns, /* List of names of LHS of the assignment */
91152 Expr *pExpr /* Vector expression to be appended. Might be NULL */
91153 ){
91154 sqlite3 *db = pParse->db;
91155 int n;
91156 int i;
91157 int iFirst = pList ? pList->nExpr : 0;
91158 /* pColumns can only be NULL due to an OOM but an OOM will cause an
91159 ** exit prior to this routine being invoked */
91160 if( NEVER(pColumns==0) ) goto vector_append_error;
91161 if( pExpr==0 ) goto vector_append_error;
91162 n = sqlite3ExprVectorSize(pExpr);
91163 if( pColumns->nId!=n ){
91164 sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
91165 pColumns->nId, n);
91166 goto vector_append_error;
91167 }
91168 for(i=0; i<n; i++){
91169 Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);
91170 pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);
91171 if( pList ){
91172 assert( pList->nExpr==iFirst+i+1 );
91173 pList->a[pList->nExpr-1].zName = pColumns->a[i].zName;
91174 pColumns->a[i].zName = 0;
91175 }
91176 }
91177 if( pExpr->op==TK_SELECT ){
91178 if( pList && pList->a[iFirst].pExpr ){
91179 assert( pList->a[iFirst].pExpr->op==TK_SELECT_COLUMN );
91180 pList->a[iFirst].pExpr->pRight = pExpr;
91181 pExpr = 0;
91182 }
91183 }
91184
91185 vector_append_error:
91186 sqlite3ExprDelete(db, pExpr);
91187 sqlite3IdListDelete(db, pColumns);
91188 return pList;
91189 }
91190
91191 /*
91192 ** Set the sort order for the last element on the given ExprList.
91193 */
91194 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder){
@@ -91087,12 +91593,12 @@
91593 #ifndef SQLITE_OMIT_SUBQUERY
91594 static Select *isCandidateForInOpt(Expr *pX){
91595 Select *p;
91596 SrcList *pSrc;
91597 ExprList *pEList;
 
91598 Table *pTab;
91599 int i;
91600 if( !ExprHasProperty(pX, EP_xIsSelect) ) return 0; /* Not a subquery */
91601 if( ExprHasProperty(pX, EP_VarSelect) ) return 0; /* Correlated subq */
91602 p = pX->x.pSelect;
91603 if( p->pPrior ) return 0; /* Not a compound SELECT */
91604 if( p->selFlags & (SF_Distinct|SF_Aggregate) ){
@@ -91111,14 +91617,17 @@
91617 pTab = pSrc->a[0].pTab;
91618 assert( pTab!=0 );
91619 assert( pTab->pSelect==0 ); /* FROM clause is not a view */
91620 if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */
91621 pEList = p->pEList;
91622 assert( pEList!=0 );
91623 /* All SELECT results must be columns. */
91624 for(i=0; i<pEList->nExpr; i++){
91625 Expr *pRes = pEList->a[i].pExpr;
91626 if( pRes->op!=TK_COLUMN ) return 0;
91627 assert( pRes->iTable==pSrc->a[0].iCursor ); /* Not a correlated subquery */
91628 }
91629 return p;
91630 }
91631 #endif /* SQLITE_OMIT_SUBQUERY */
91632
91633 /*
@@ -91128,10 +91637,11 @@
91637 SQLITE_PRIVATE int sqlite3CodeOnce(Parse *pParse){
91638 Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */
91639 return sqlite3VdbeAddOp1(v, OP_Once, pParse->nOnce++);
91640 }
91641
91642 #ifndef SQLITE_OMIT_SUBQUERY
91643 /*
91644 ** Generate code that checks the left-most column of index table iCur to see if
91645 ** it contains any NULL entries. Cause the register at regHasNull to be set
91646 ** to a non-NULL value if iCur contains no NULLs. Cause register regHasNull
91647 ** to be set to NULL if iCur contains one or more NULL values.
@@ -91143,10 +91653,11 @@
91653 sqlite3VdbeAddOp3(v, OP_Column, iCur, 0, regHasNull);
91654 sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
91655 VdbeComment((v, "first_entry_in(%d)", iCur));
91656 sqlite3VdbeJumpHere(v, addr1);
91657 }
91658 #endif
91659
91660
91661 #ifndef SQLITE_OMIT_SUBQUERY
91662 /*
91663 ** The argument is an IN operator with a list (not a subquery) on the
@@ -91187,11 +91698,11 @@
91698 ** implemented as a sequence of comparisons.
91699 **
91700 ** An existing b-tree might be used if the RHS expression pX is a simple
91701 ** subquery such as:
91702 **
91703 ** SELECT <column1>, <column2>... FROM <table>
91704 **
91705 ** If the RHS of the IN operator is a list or a more complex subquery, then
91706 ** an ephemeral table might need to be generated from the RHS and then
91707 ** pX->iTable made to point to the ephemeral table instead of an
91708 ** existing table.
@@ -91203,18 +91714,18 @@
91714 ** IN index will be used to loop over all values of the RHS of the
91715 ** IN operator.
91716 **
91717 ** When IN_INDEX_LOOP is used (and the b-tree will be used to iterate
91718 ** through the set members) then the b-tree must not contain duplicates.
91719 ** An epheremal table must be used unless the selected columns are guaranteed
91720 ** to be unique - either because it is an INTEGER PRIMARY KEY or due to
91721 ** a UNIQUE constraint or index.
91722 **
91723 ** When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used
91724 ** for fast set membership tests) then an epheremal table must
91725 ** be used unless <columns> is a single INTEGER PRIMARY KEY column or an
91726 ** index can be found with the specified <columns> as its left-most.
91727 **
91728 ** If the IN_INDEX_NOOP_OK and IN_INDEX_MEMBERSHIP are both set and
91729 ** if the RHS of the IN operator is a list (not a subquery) then this
91730 ** routine might decide that creating an ephemeral b-tree for membership
91731 ** testing is too expensive and return IN_INDEX_NOOP. In that case, the
@@ -91231,98 +91742,190 @@
91742 **
91743 ** If a register is allocated and its location stored in *prRhsHasNull, then
91744 ** the value in that register will be NULL if the b-tree contains one or more
91745 ** NULL values, and it will be some non-NULL value if the b-tree contains no
91746 ** NULL values.
91747 **
91748 ** If the aiMap parameter is not NULL, it must point to an array containing
91749 ** one element for each column returned by the SELECT statement on the RHS
91750 ** of the IN(...) operator. The i'th entry of the array is populated with the
91751 ** offset of the index column that matches the i'th column returned by the
91752 ** SELECT. For example, if the expression and selected index are:
91753 **
91754 ** (?,?,?) IN (SELECT a, b, c FROM t1)
91755 ** CREATE INDEX i1 ON t1(b, c, a);
91756 **
91757 ** then aiMap[] is populated with {2, 0, 1}.
91758 */
91759 #ifndef SQLITE_OMIT_SUBQUERY
91760 SQLITE_PRIVATE int sqlite3FindInIndex(
91761 Parse *pParse, /* Parsing context */
91762 Expr *pX, /* The right-hand side (RHS) of the IN operator */
91763 u32 inFlags, /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */
91764 int *prRhsHasNull, /* Register holding NULL status. See notes */
91765 int *aiMap /* Mapping from Index fields to RHS fields */
91766 ){
91767 Select *p; /* SELECT to the right of IN operator */
91768 int eType = 0; /* Type of RHS table. IN_INDEX_* */
91769 int iTab = pParse->nTab++; /* Cursor of the RHS table */
91770 int mustBeUnique; /* True if RHS must be unique */
91771 Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */
91772
91773 assert( pX->op==TK_IN );
91774 mustBeUnique = (inFlags & IN_INDEX_LOOP)!=0;
91775
91776 /* If the RHS of this IN(...) operator is a SELECT, and if it matters
91777 ** whether or not the SELECT result contains NULL values, check whether
91778 ** or not NULL is actually possible (it may not be, for example, due
91779 ** to NOT NULL constraints in the schema). If no NULL values are possible,
91780 ** set prRhsHasNull to 0 before continuing. */
91781 if( prRhsHasNull && (pX->flags & EP_xIsSelect) ){
91782 int i;
91783 ExprList *pEList = pX->x.pSelect->pEList;
91784 for(i=0; i<pEList->nExpr; i++){
91785 if( sqlite3ExprCanBeNull(pEList->a[i].pExpr) ) break;
91786 }
91787 if( i==pEList->nExpr ){
91788 prRhsHasNull = 0;
91789 }
91790 }
91791
91792 /* Check to see if an existing table or index can be used to
91793 ** satisfy the query. This is preferable to generating a new
91794 ** ephemeral table. */
 
91795 if( pParse->nErr==0 && (p = isCandidateForInOpt(pX))!=0 ){
91796 sqlite3 *db = pParse->db; /* Database connection */
91797 Table *pTab; /* Table <table>. */
 
 
91798 i16 iDb; /* Database idx for pTab */
91799 ExprList *pEList = p->pEList;
91800 int nExpr = pEList->nExpr;
91801
91802 assert( p->pEList!=0 ); /* Because of isCandidateForInOpt(p) */
91803 assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */
91804 assert( p->pSrc!=0 ); /* Because of isCandidateForInOpt(p) */
91805 pTab = p->pSrc->a[0].pTab;
91806
 
 
91807 /* Code an OP_Transaction and OP_TableLock for <table>. */
91808 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
91809 sqlite3CodeVerifySchema(pParse, iDb);
91810 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
91811
91812 assert(v); /* sqlite3GetVdbe() has always been previously called */
91813 if( nExpr==1 && pEList->a[0].pExpr->iColumn<0 ){
91814 /* The "x IN (SELECT rowid FROM table)" case */
 
 
 
91815 int iAddr = sqlite3CodeOnce(pParse);
91816 VdbeCoverage(v);
91817
91818 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
91819 eType = IN_INDEX_ROWID;
91820
91821 sqlite3VdbeJumpHere(v, iAddr);
91822 }else{
91823 Index *pIdx; /* Iterator variable */
91824 int affinity_ok = 1;
91825 int i;
91826
91827 /* Check that the affinity that will be used to perform each
91828 ** comparison is the same as the affinity of each column in table
91829 ** on the RHS of the IN operator. If it not, it is not possible to
91830 ** use any index of the RHS table. */
91831 for(i=0; i<nExpr && affinity_ok; i++){
91832 Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);
91833 int iCol = pEList->a[i].pExpr->iColumn;
91834 char idxaff = sqlite3TableColumnAffinity(pTab,iCol); /* RHS table */
91835 char cmpaff = sqlite3CompareAffinity(pLhs, idxaff);
91836 testcase( cmpaff==SQLITE_AFF_BLOB );
91837 testcase( cmpaff==SQLITE_AFF_TEXT );
91838 switch( cmpaff ){
91839 case SQLITE_AFF_BLOB:
91840 break;
91841 case SQLITE_AFF_TEXT:
91842 /* sqlite3CompareAffinity() only returns TEXT if one side or the
91843 ** other has no affinity and the other side is TEXT. Hence,
91844 ** the only way for cmpaff to be TEXT is for idxaff to be TEXT
91845 ** and for the term on the LHS of the IN to have no affinity. */
91846 assert( idxaff==SQLITE_AFF_TEXT );
91847 break;
91848 default:
91849 affinity_ok = sqlite3IsNumericAffinity(idxaff);
91850 }
91851 }
91852
91853 if( affinity_ok ){
91854 /* Search for an existing index that will work for this IN operator */
91855 for(pIdx=pTab->pIndex; pIdx && eType==0; pIdx=pIdx->pNext){
91856 Bitmask colUsed; /* Columns of the index used */
91857 Bitmask mCol; /* Mask for the current column */
91858 if( pIdx->nColumn<nExpr ) continue;
91859 /* Maximum nColumn is BMS-2, not BMS-1, so that we can compute
91860 ** BITMASK(nExpr) without overflowing */
91861 testcase( pIdx->nColumn==BMS-2 );
91862 testcase( pIdx->nColumn==BMS-1 );
91863 if( pIdx->nColumn>=BMS-1 ) continue;
91864 if( mustBeUnique ){
91865 if( pIdx->nKeyCol>nExpr
91866 ||(pIdx->nColumn>nExpr && !IsUniqueIndex(pIdx))
91867 ){
91868 continue; /* This index is not unique over the IN RHS columns */
91869 }
91870 }
91871
91872 colUsed = 0; /* Columns of index used so far */
91873 for(i=0; i<nExpr; i++){
91874 Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);
91875 Expr *pRhs = pEList->a[i].pExpr;
91876 CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
91877 int j;
91878
91879 assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );
91880 for(j=0; j<nExpr; j++){
91881 if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
91882 assert( pIdx->azColl[j] );
91883 if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){
91884 continue;
91885 }
91886 break;
91887 }
91888 if( j==nExpr ) break;
91889 mCol = MASKBIT(j);
91890 if( mCol & colUsed ) break; /* Each column used only once */
91891 colUsed |= mCol;
91892 if( aiMap ) aiMap[i] = j;
91893 }
91894
91895 assert( i==nExpr || colUsed!=(MASKBIT(nExpr)-1) );
91896 if( colUsed==(MASKBIT(nExpr)-1) ){
91897 /* If we reach this point, that means the index pIdx is usable */
91898 int iAddr = sqlite3CodeOnce(pParse); VdbeCoverage(v);
91899 #ifndef SQLITE_OMIT_EXPLAIN
91900 sqlite3VdbeAddOp4(v, OP_Explain, 0, 0, 0,
91901 sqlite3MPrintf(db, "USING INDEX %s FOR IN-OPERATOR",pIdx->zName),
91902 P4_DYNAMIC);
91903 #endif
91904 sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);
91905 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
91906 VdbeComment((v, "%s", pIdx->zName));
91907 assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
91908 eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
91909
91910 if( prRhsHasNull ){
91911 *prRhsHasNull = ++pParse->nMem;
91912 #ifdef SQLITE_ENABLE_COLUMN_USED_MASK
91913 i64 mask = (1<<nExpr)-1;
91914 sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed,
91915 iTab, 0, 0, (u8*)&mask, P4_INT64);
91916 #endif
91917 if( nExpr==1 ){
91918 sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);
91919 }
91920 }
91921 sqlite3VdbeJumpHere(v, iAddr);
91922 }
91923 } /* End loop over indexes */
91924 } /* End if( affinity_ok ) */
91925 } /* End if not an rowid index */
91926 } /* End attempt to optimize using an index */
91927
91928 /* If no preexisting index is available for the IN clause
91929 ** and IN_INDEX_NOOP is an allowed reply
91930 ** and the RHS of the IN operator is a list, not a subquery
91931 ** and the RHS is not constant or has two or fewer terms,
@@ -91334,11 +91937,10 @@
91937 && !ExprHasProperty(pX, EP_xIsSelect)
91938 && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2)
91939 ){
91940 eType = IN_INDEX_NOOP;
91941 }
 
91942
91943 if( eType==0 ){
91944 /* Could not find an existing table or index to use as the RHS b-tree.
91945 ** We will have to generate an ephemeral table to do the job.
91946 */
@@ -91356,13 +91958,66 @@
91958 sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);
91959 pParse->nQueryLoop = savedNQueryLoop;
91960 }else{
91961 pX->iTable = iTab;
91962 }
91963
91964 if( aiMap && eType!=IN_INDEX_INDEX_ASC && eType!=IN_INDEX_INDEX_DESC ){
91965 int i, n;
91966 n = sqlite3ExprVectorSize(pX->pLeft);
91967 for(i=0; i<n; i++) aiMap[i] = i;
91968 }
91969 return eType;
91970 }
91971 #endif
91972
91973 #ifndef SQLITE_OMIT_SUBQUERY
91974 /*
91975 ** Argument pExpr is an (?, ?...) IN(...) expression. This
91976 ** function allocates and returns a nul-terminated string containing
91977 ** the affinities to be used for each column of the comparison.
91978 **
91979 ** It is the responsibility of the caller to ensure that the returned
91980 ** string is eventually freed using sqlite3DbFree().
91981 */
91982 static char *exprINAffinity(Parse *pParse, Expr *pExpr){
91983 Expr *pLeft = pExpr->pLeft;
91984 int nVal = sqlite3ExprVectorSize(pLeft);
91985 Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;
91986 char *zRet;
91987
91988 assert( pExpr->op==TK_IN );
91989 zRet = sqlite3DbMallocZero(pParse->db, nVal+1);
91990 if( zRet ){
91991 int i;
91992 for(i=0; i<nVal; i++){
91993 Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);
91994 char a = sqlite3ExprAffinity(pA);
91995 if( pSelect ){
91996 zRet[i] = sqlite3CompareAffinity(pSelect->pEList->a[i].pExpr, a);
91997 }else{
91998 zRet[i] = a;
91999 }
92000 }
92001 zRet[nVal] = '\0';
92002 }
92003 return zRet;
92004 }
92005 #endif
92006
92007 #ifndef SQLITE_OMIT_SUBQUERY
92008 /*
92009 ** Load the Parse object passed as the first argument with an error
92010 ** message of the form:
92011 **
92012 ** "sub-select returns N columns - expected M"
92013 */
92014 SQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){
92015 const char *zFmt = "sub-select returns %d columns - expected %d";
92016 sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect);
92017 }
92018 #endif
92019
92020 /*
92021 ** Generate code for scalar subqueries used as a subquery expression, EXISTS,
92022 ** or IN operators. Examples:
92023 **
@@ -91385,11 +92040,13 @@
92040 ** All this routine does is initialize the register given by rMayHaveNull
92041 ** to NULL. Calling routines will take care of changing this register
92042 ** value to non-NULL if the RHS is NULL-free.
92043 **
92044 ** For a SELECT or EXISTS operator, return the register that holds the
92045 ** result. For a multi-column SELECT, the result is stored in a contiguous
92046 ** array of registers and the return value is the register of the left-most
92047 ** result column. Return 0 for IN operators or if an error occurs.
92048 */
92049 #ifndef SQLITE_OMIT_SUBQUERY
92050 SQLITE_PRIVATE int sqlite3CodeSubselect(
92051 Parse *pParse, /* Parsing context */
92052 Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
@@ -91400,12 +92057,12 @@
92057 int rReg = 0; /* Register storing resulting */
92058 Vdbe *v = sqlite3GetVdbe(pParse);
92059 if( NEVER(v==0) ) return 0;
92060 sqlite3ExprCachePush(pParse);
92061
92062 /* The evaluation of the IN/EXISTS/SELECT must be repeated every time it
92063 ** is encountered if any of the following is true:
92064 **
92065 ** * The right-hand side is a correlated subquery
92066 ** * The right-hand side is an expression list containing variables
92067 ** * We are inside a trigger
92068 **
@@ -91427,21 +92084,22 @@
92084 }
92085 #endif
92086
92087 switch( pExpr->op ){
92088 case TK_IN: {
 
92089 int addr; /* Address of OP_OpenEphemeral instruction */
92090 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
92091 KeyInfo *pKeyInfo = 0; /* Key information */
92092 int nVal; /* Size of vector pLeft */
92093
92094 nVal = sqlite3ExprVectorSize(pLeft);
92095 assert( !isRowid || nVal==1 );
92096
92097 /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
92098 ** expression it is handled the same way. An ephemeral table is
92099 ** filled with index keys representing the results from the
92100 ** SELECT or the <exprlist>.
92101 **
92102 ** If the 'x' expression is a column value, or the SELECT...
92103 ** statement returns a column value, then the affinity of that
92104 ** column is used to build the index keys. If both 'x' and the
92105 ** SELECT... statement are columns, then numeric affinity is used
@@ -91448,54 +92106,67 @@
92106 ** if either column has NUMERIC or INTEGER affinity. If neither
92107 ** 'x' nor the SELECT... statement are columns, then numeric affinity
92108 ** is used.
92109 */
92110 pExpr->iTable = pParse->nTab++;
92111 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral,
92112 pExpr->iTable, (isRowid?0:nVal));
92113 pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, nVal, 1);
92114
92115 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
92116 /* Case 1: expr IN (SELECT ...)
92117 **
92118 ** Generate code to write the results of the select into the temporary
92119 ** table allocated and opened above.
92120 */
92121 Select *pSelect = pExpr->x.pSelect;
92122 ExprList *pEList = pSelect->pEList;
 
92123
92124 assert( !isRowid );
92125 /* If the LHS and RHS of the IN operator do not match, that
92126 ** error will have been caught long before we reach this point. */
92127 if( ALWAYS(pEList->nExpr==nVal) ){
92128 SelectDest dest;
92129 int i;
92130 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
92131 dest.zAffSdst = exprINAffinity(pParse, pExpr);
92132 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
92133 pSelect->iLimit = 0;
92134 testcase( pSelect->selFlags & SF_Distinct );
92135 testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
92136 if( sqlite3Select(pParse, pSelect, &dest) ){
92137 sqlite3DbFree(pParse->db, dest.zAffSdst);
92138 sqlite3KeyInfoUnref(pKeyInfo);
92139 return 0;
92140 }
92141 sqlite3DbFree(pParse->db, dest.zAffSdst);
92142 assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
92143 assert( pEList!=0 );
92144 assert( pEList->nExpr>0 );
92145 assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
92146 for(i=0; i<nVal; i++){
92147 Expr *p = sqlite3VectorFieldSubexpr(pLeft, i);
92148 pKeyInfo->aColl[i] = sqlite3BinaryCompareCollSeq(
92149 pParse, p, pEList->a[i].pExpr
92150 );
92151 }
92152 }
92153 }else if( ALWAYS(pExpr->x.pList!=0) ){
92154 /* Case 2: expr IN (exprlist)
92155 **
92156 ** For each expression, build an index key from the evaluation and
92157 ** store it in the temporary table. If <expr> is a column, then use
92158 ** that columns affinity when building index keys. If <expr> is not
92159 ** a column, use numeric affinity.
92160 */
92161 char affinity; /* Affinity of the LHS of the IN */
92162 int i;
92163 ExprList *pList = pExpr->x.pList;
92164 struct ExprList_item *pItem;
92165 int r1, r2, r3;
92166
92167 affinity = sqlite3ExprAffinity(pLeft);
92168 if( !affinity ){
92169 affinity = SQLITE_AFF_BLOB;
92170 }
92171 if( pKeyInfo ){
92172 assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
@@ -91547,30 +92218,41 @@
92218 }
92219
92220 case TK_EXISTS:
92221 case TK_SELECT:
92222 default: {
92223 /* Case 3: (SELECT ... FROM ...)
92224 ** or: EXISTS(SELECT ... FROM ...)
92225 **
92226 ** For a SELECT, generate code to put the values for all columns of
92227 ** the first row into an array of registers and return the index of
92228 ** the first register.
92229 **
92230 ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)
92231 ** into a register and return that register number.
92232 **
92233 ** In both cases, the query is augmented with "LIMIT 1". Any
92234 ** preexisting limit is discarded in place of the new LIMIT 1.
92235 */
92236 Select *pSel; /* SELECT statement to encode */
92237 SelectDest dest; /* How to deal with SELECT result */
92238 int nReg; /* Registers to allocate */
92239
92240 testcase( pExpr->op==TK_EXISTS );
92241 testcase( pExpr->op==TK_SELECT );
92242 assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
 
92243 assert( ExprHasProperty(pExpr, EP_xIsSelect) );
92244
92245 pSel = pExpr->x.pSelect;
92246 nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;
92247 sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);
92248 pParse->nMem += nReg;
92249 if( pExpr->op==TK_SELECT ){
92250 dest.eDest = SRT_Mem;
92251 dest.iSdst = dest.iSDParm;
92252 dest.nSdst = nReg;
92253 sqlite3VdbeAddOp3(v, OP_Null, 0, dest.iSDParm, dest.iSDParm+nReg-1);
92254 VdbeComment((v, "Init subquery result"));
92255 }else{
92256 dest.eDest = SRT_Exists;
92257 sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
92258 VdbeComment((v, "Init EXISTS result"));
@@ -91599,66 +92281,147 @@
92281 sqlite3ExprCachePop(pParse);
92282
92283 return rReg;
92284 }
92285 #endif /* SQLITE_OMIT_SUBQUERY */
92286
92287 #ifndef SQLITE_OMIT_SUBQUERY
92288 /*
92289 ** Expr pIn is an IN(...) expression. This function checks that the
92290 ** sub-select on the RHS of the IN() operator has the same number of
92291 ** columns as the vector on the LHS. Or, if the RHS of the IN() is not
92292 ** a sub-query, that the LHS is a vector of size 1.
92293 */
92294 SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){
92295 int nVector = sqlite3ExprVectorSize(pIn->pLeft);
92296 if( (pIn->flags & EP_xIsSelect) ){
92297 if( nVector!=pIn->x.pSelect->pEList->nExpr ){
92298 sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector);
92299 return 1;
92300 }
92301 }else if( nVector!=1 ){
92302 if( (pIn->pLeft->flags & EP_xIsSelect) ){
92303 sqlite3SubselectError(pParse, nVector, 1);
92304 }else{
92305 sqlite3ErrorMsg(pParse, "row value misused");
92306 }
92307 return 1;
92308 }
92309 return 0;
92310 }
92311 #endif
92312
92313 #ifndef SQLITE_OMIT_SUBQUERY
92314 /*
92315 ** Generate code for an IN expression.
92316 **
92317 ** x IN (SELECT ...)
92318 ** x IN (value, value, ...)
92319 **
92320 ** The left-hand side (LHS) is a scalar or vector expression. The
92321 ** right-hand side (RHS) is an array of zero or more scalar values, or a
92322 ** subquery. If the RHS is a subquery, the number of result columns must
92323 ** match the number of columns in the vector on the LHS. If the RHS is
92324 ** a list of values, the LHS must be a scalar.
92325 **
92326 ** The IN operator is true if the LHS value is contained within the RHS.
92327 ** The result is false if the LHS is definitely not in the RHS. The
92328 ** result is NULL if the presence of the LHS in the RHS cannot be
92329 ** determined due to NULLs.
92330 **
92331 ** This routine generates code that jumps to destIfFalse if the LHS is not
92332 ** contained within the RHS. If due to NULLs we cannot determine if the LHS
92333 ** is contained in the RHS then jump to destIfNull. If the LHS is contained
92334 ** within the RHS then fall through.
92335 **
92336 ** See the separate in-operator.md documentation file in the canonical
92337 ** SQLite source tree for additional information.
92338 */
92339 static void sqlite3ExprCodeIN(
92340 Parse *pParse, /* Parsing and code generating context */
92341 Expr *pExpr, /* The IN expression */
92342 int destIfFalse, /* Jump here if LHS is not contained in the RHS */
92343 int destIfNull /* Jump here if the results are unknown due to NULLs */
92344 ){
92345 int rRhsHasNull = 0; /* Register that is true if RHS contains NULL values */
 
92346 int eType; /* Type of the RHS */
92347 int rLhs; /* Register(s) holding the LHS values */
92348 int rLhsOrig; /* LHS values prior to reordering by aiMap[] */
92349 Vdbe *v; /* Statement under construction */
92350 int *aiMap = 0; /* Map from vector field to index column */
92351 char *zAff = 0; /* Affinity string for comparisons */
92352 int nVector; /* Size of vectors for this IN operator */
92353 int iDummy; /* Dummy parameter to exprCodeVector() */
92354 Expr *pLeft; /* The LHS of the IN operator */
92355 int i; /* loop counter */
92356 int destStep2; /* Where to jump when NULLs seen in step 2 */
92357 int destStep6 = 0; /* Start of code for Step 6 */
92358 int addrTruthOp; /* Address of opcode that determines the IN is true */
92359 int destNotNull; /* Jump here if a comparison is not true in step 6 */
92360 int addrTop; /* Top of the step-6 loop */
92361
92362 pLeft = pExpr->pLeft;
92363 if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
92364 zAff = exprINAffinity(pParse, pExpr);
92365 nVector = sqlite3ExprVectorSize(pExpr->pLeft);
92366 aiMap = (int*)sqlite3DbMallocZero(
92367 pParse->db, nVector*(sizeof(int) + sizeof(char)) + 1
92368 );
92369 if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error;
92370
92371 /* Attempt to compute the RHS. After this step, if anything other than
92372 ** IN_INDEX_NOOP is returned, the table opened ith cursor pExpr->iTable
92373 ** contains the values that make up the RHS. If IN_INDEX_NOOP is returned,
92374 ** the RHS has not yet been coded. */
92375 v = pParse->pVdbe;
92376 assert( v!=0 ); /* OOM detected prior to this routine */
92377 VdbeNoopComment((v, "begin IN expr"));
92378 eType = sqlite3FindInIndex(pParse, pExpr,
92379 IN_INDEX_MEMBERSHIP | IN_INDEX_NOOP_OK,
92380 destIfFalse==destIfNull ? 0 : &rRhsHasNull, aiMap);
92381
92382 assert( pParse->nErr || nVector==1 || eType==IN_INDEX_EPH
92383 || eType==IN_INDEX_INDEX_ASC || eType==IN_INDEX_INDEX_DESC
92384 );
92385 #ifdef SQLITE_DEBUG
92386 /* Confirm that aiMap[] contains nVector integer values between 0 and
92387 ** nVector-1. */
92388 for(i=0; i<nVector; i++){
92389 int j, cnt;
92390 for(cnt=j=0; j<nVector; j++) if( aiMap[j]==i ) cnt++;
92391 assert( cnt==1 );
92392 }
92393 #endif
92394
92395 /* Code the LHS, the <expr> from "<expr> IN (...)". If the LHS is a
92396 ** vector, then it is stored in an array of nVector registers starting
92397 ** at r1.
92398 **
92399 ** sqlite3FindInIndex() might have reordered the fields of the LHS vector
92400 ** so that the fields are in the same order as an existing index. The
92401 ** aiMap[] array contains a mapping from the original LHS field order to
92402 ** the field order that matches the RHS index.
92403 */
92404 sqlite3ExprCachePush(pParse);
92405 rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy);
92406 for(i=0; i<nVector && aiMap[i]==i; i++){} /* Are LHS fields reordered? */
92407 if( i==nVector ){
92408 /* LHS fields are not reordered */
92409 rLhs = rLhsOrig;
92410 }else{
92411 /* Need to reorder the LHS fields according to aiMap */
92412 rLhs = sqlite3GetTempRange(pParse, nVector);
92413 for(i=0; i<nVector; i++){
92414 sqlite3VdbeAddOp3(v, OP_Copy, rLhsOrig+i, rLhs+aiMap[i], 0);
92415 }
92416 }
92417
92418 /* If sqlite3FindInIndex() did not find or create an index that is
92419 ** suitable for evaluating the IN operator, then evaluate using a
92420 ** sequence of comparisons.
92421 **
92422 ** This is step (1) in the in-operator.md optimized algorithm.
92423 */
92424 if( eType==IN_INDEX_NOOP ){
92425 ExprList *pList = pExpr->x.pList;
92426 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
92427 int labelOk = sqlite3VdbeMakeLabel(v);
@@ -91666,108 +92429,144 @@
92429 int regCkNull = 0;
92430 int ii;
92431 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
92432 if( destIfNull!=destIfFalse ){
92433 regCkNull = sqlite3GetTempReg(pParse);
92434 sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull);
92435 }
92436 for(ii=0; ii<pList->nExpr; ii++){
92437 r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);
92438 if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
92439 sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
92440 }
92441 if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
92442 sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,
92443 (void*)pColl, P4_COLLSEQ);
92444 VdbeCoverageIf(v, ii<pList->nExpr-1);
92445 VdbeCoverageIf(v, ii==pList->nExpr-1);
92446 sqlite3VdbeChangeP5(v, zAff[0]);
92447 }else{
92448 assert( destIfNull==destIfFalse );
92449 sqlite3VdbeAddOp4(v, OP_Ne, rLhs, destIfFalse, r2,
92450 (void*)pColl, P4_COLLSEQ); VdbeCoverage(v);
92451 sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL);
92452 }
92453 sqlite3ReleaseTempReg(pParse, regToFree);
92454 }
92455 if( regCkNull ){
92456 sqlite3VdbeAddOp2(v, OP_IsNull, regCkNull, destIfNull); VdbeCoverage(v);
92457 sqlite3VdbeGoto(v, destIfFalse);
92458 }
92459 sqlite3VdbeResolveLabel(v, labelOk);
92460 sqlite3ReleaseTempReg(pParse, regCkNull);
92461 goto sqlite3ExprCodeIN_finished;
92462 }
92463
92464 /* Step 2: Check to see if the LHS contains any NULL columns. If the
92465 ** LHS does contain NULLs then the result must be either FALSE or NULL.
92466 ** We will then skip the binary search of the RHS.
92467 */
92468 if( destIfNull==destIfFalse ){
92469 destStep2 = destIfFalse;
92470 }else{
92471 destStep2 = destStep6 = sqlite3VdbeMakeLabel(v);
92472 }
92473 for(i=0; i<nVector; i++){
92474 Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
92475 if( sqlite3ExprCanBeNull(p) ){
92476 sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);
92477 VdbeCoverage(v);
92478 }
92479 }
92480
92481 /* Step 3. The LHS is now known to be non-NULL. Do the binary search
92482 ** of the RHS using the LHS as a probe. If found, the result is
92483 ** true.
92484 */
92485 if( eType==IN_INDEX_ROWID ){
92486 /* In this case, the RHS is the ROWID of table b-tree and so we also
92487 ** know that the RHS is non-NULL. Hence, we combine steps 3 and 4
92488 ** into a single opcode. */
92489 sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, rLhs);
92490 VdbeCoverage(v);
92491 addrTruthOp = sqlite3VdbeAddOp0(v, OP_Goto); /* Return True */
92492 }else{
92493 sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector);
92494 if( destIfFalse==destIfNull ){
92495 /* Combine Step 3 and Step 5 into a single opcode */
92496 sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse,
92497 rLhs, nVector); VdbeCoverage(v);
92498 goto sqlite3ExprCodeIN_finished;
92499 }
92500 /* Ordinary Step 3, for the case where FALSE and NULL are distinct */
92501 addrTruthOp = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0,
92502 rLhs, nVector); VdbeCoverage(v);
92503 }
92504
92505 /* Step 4. If the RHS is known to be non-NULL and we did not find
92506 ** an match on the search above, then the result must be FALSE.
92507 */
92508 if( rRhsHasNull && nVector==1 ){
92509 sqlite3VdbeAddOp2(v, OP_NotNull, rRhsHasNull, destIfFalse);
92510 VdbeCoverage(v);
92511 }
92512
92513 /* Step 5. If we do not care about the difference between NULL and
92514 ** FALSE, then just return false.
92515 */
92516 if( destIfFalse==destIfNull ) sqlite3VdbeGoto(v, destIfFalse);
92517
92518 /* Step 6: Loop through rows of the RHS. Compare each row to the LHS.
92519 ** If any comparison is NULL, then the result is NULL. If all
92520 ** comparisons are FALSE then the final result is FALSE.
92521 **
92522 ** For a scalar LHS, it is sufficient to check just the first row
92523 ** of the RHS.
92524 */
92525 if( destStep6 ) sqlite3VdbeResolveLabel(v, destStep6);
92526 addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
92527 VdbeCoverage(v);
92528 if( nVector>1 ){
92529 destNotNull = sqlite3VdbeMakeLabel(v);
92530 }else{
92531 /* For nVector==1, combine steps 6 and 7 by immediately returning
92532 ** FALSE if the first comparison is not NULL */
92533 destNotNull = destIfFalse;
92534 }
92535 for(i=0; i<nVector; i++){
92536 Expr *p;
92537 CollSeq *pColl;
92538 int r3 = sqlite3GetTempReg(pParse);
92539 p = sqlite3VectorFieldSubexpr(pLeft, i);
92540 pColl = sqlite3ExprCollSeq(pParse, p);
92541 sqlite3VdbeAddOp3(v, OP_Column, pExpr->iTable, i, r3);
92542 sqlite3VdbeAddOp4(v, OP_Ne, rLhs+i, destNotNull, r3,
92543 (void*)pColl, P4_COLLSEQ);
92544 VdbeCoverage(v);
92545 sqlite3ReleaseTempReg(pParse, r3);
92546 }
92547 sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);
92548 if( nVector>1 ){
92549 sqlite3VdbeResolveLabel(v, destNotNull);
92550 sqlite3VdbeAddOp2(v, OP_Next, pExpr->iTable, addrTop+1);
92551 VdbeCoverage(v);
92552
92553 /* Step 7: If we reach this point, we know that the result must
92554 ** be false. */
92555 sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse);
92556 }
92557
92558 /* Jumps here in order to return true. */
92559 sqlite3VdbeJumpHere(v, addrTruthOp);
92560
92561 sqlite3ExprCodeIN_finished:
92562 if( rLhs!=rLhsOrig ) sqlite3ReleaseTempReg(pParse, rLhs);
92563 sqlite3ExprCachePop(pParse);
92564 VdbeComment((v, "end IN expr"));
92565 sqlite3ExprCodeIN_oom_error:
92566 sqlite3DbFree(pParse->db, aiMap);
92567 sqlite3DbFree(pParse->db, zAff);
92568 }
92569 #endif /* SQLITE_OMIT_SUBQUERY */
92570
92571 #ifndef SQLITE_OMIT_FLOATING_POINT
92572 /*
@@ -92148,18 +92947,52 @@
92947 }
92948 #endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */
92949
92950
92951 /*
92952 ** Convert a scalar expression node to a TK_REGISTER referencing
92953 ** register iReg. The caller must ensure that iReg already contains
92954 ** the correct value for the expression.
92955 */
92956 static void exprToRegister(Expr *p, int iReg){
92957 p->op2 = p->op;
92958 p->op = TK_REGISTER;
92959 p->iTable = iReg;
92960 ExprClearProperty(p, EP_Skip);
92961 }
92962
92963 /*
92964 ** Evaluate an expression (either a vector or a scalar expression) and store
92965 ** the result in continguous temporary registers. Return the index of
92966 ** the first register used to store the result.
92967 **
92968 ** If the returned result register is a temporary scalar, then also write
92969 ** that register number into *piFreeable. If the returned result register
92970 ** is not a temporary or if the expression is a vector set *piFreeable
92971 ** to 0.
92972 */
92973 static int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){
92974 int iResult;
92975 int nResult = sqlite3ExprVectorSize(p);
92976 if( nResult==1 ){
92977 iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable);
92978 }else{
92979 *piFreeable = 0;
92980 if( p->op==TK_SELECT ){
92981 iResult = sqlite3CodeSubselect(pParse, p, 0, 0);
92982 }else{
92983 int i;
92984 iResult = pParse->nMem+1;
92985 pParse->nMem += nResult;
92986 for(i=0; i<nResult; i++){
92987 sqlite3ExprCode(pParse, p->x.pList->a[i].pExpr, i+iResult);
92988 }
92989 }
92990 }
92991 return iResult;
92992 }
92993
92994
92995 /*
92996 ** Generate code into the current Vdbe to evaluate the given
92997 ** expression. Attempt to store the results in register "target".
92998 ** Return the register where results are stored.
@@ -92174,13 +93007,14 @@
93007 Vdbe *v = pParse->pVdbe; /* The VM under construction */
93008 int op; /* The opcode being coded */
93009 int inReg = target; /* Results stored in register inReg */
93010 int regFree1 = 0; /* If non-zero free this temporary register */
93011 int regFree2 = 0; /* If non-zero free this temporary register */
93012 int r1, r2; /* Various register numbers */
93013 sqlite3 *db = pParse->db; /* The database connection */
93014 Expr tempX; /* Temporary expression node */
93015 int p5 = 0;
93016
93017 assert( target>0 && target<=pParse->nMem );
93018 if( v==0 ){
93019 assert( pParse->db->mallocFailed );
93020 return 0;
@@ -92289,43 +93123,38 @@
93123 testcase( usedAsColumnCache(pParse, inReg, inReg) );
93124 sqlite3ExprCacheAffinityChange(pParse, inReg, 1);
93125 break;
93126 }
93127 #endif /* SQLITE_OMIT_CAST */
93128 case TK_IS:
93129 case TK_ISNOT:
93130 op = (op==TK_IS) ? TK_EQ : TK_NE;
93131 p5 = SQLITE_NULLEQ;
93132 /* fall-through */
93133 case TK_LT:
93134 case TK_LE:
93135 case TK_GT:
93136 case TK_GE:
93137 case TK_NE:
93138 case TK_EQ: {
93139 Expr *pLeft = pExpr->pLeft;
93140 if( sqlite3ExprIsVector(pLeft) ){
93141 codeVectorCompare(pParse, pExpr, target, op, p5);
93142 }else{
93143 r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);
93144 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
93145 codeCompare(pParse, pLeft, pExpr->pRight, op,
93146 r1, r2, inReg, SQLITE_STOREP2 | p5);
93147 assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
93148 assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
93149 assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
93150 assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
93151 assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
93152 assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
93153 testcase( regFree1==0 );
93154 testcase( regFree2==0 );
93155 }
 
 
 
 
 
 
 
 
 
 
93156 break;
93157 }
93158 case TK_AND:
93159 case TK_OR:
93160 case TK_PLUS:
@@ -92547,13 +93376,25 @@
93376 break;
93377 }
93378 #ifndef SQLITE_OMIT_SUBQUERY
93379 case TK_EXISTS:
93380 case TK_SELECT: {
93381 int nCol;
93382 testcase( op==TK_EXISTS );
93383 testcase( op==TK_SELECT );
93384 if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){
93385 sqlite3SubselectError(pParse, nCol, 1);
93386 }else{
93387 inReg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
93388 }
93389 break;
93390 }
93391 case TK_SELECT_COLUMN: {
93392 if( pExpr->pLeft->iTable==0 ){
93393 pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft, 0, 0);
93394 }
93395 inReg = pExpr->pLeft->iTable + pExpr->iColumn;
93396 break;
93397 }
93398 case TK_IN: {
93399 int destIfFalse = sqlite3VdbeMakeLabel(v);
93400 int destIfNull = sqlite3VdbeMakeLabel(v);
@@ -92578,32 +93419,11 @@
93419 ** X is stored in pExpr->pLeft.
93420 ** Y is stored in pExpr->pList->a[0].pExpr.
93421 ** Z is stored in pExpr->pList->a[1].pExpr.
93422 */
93423 case TK_BETWEEN: {
93424 exprCodeBetween(pParse, pExpr, target, 0, 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93425 break;
93426 }
93427 case TK_SPAN:
93428 case TK_COLLATE:
93429 case TK_UPLUS: {
@@ -92665,10 +93485,14 @@
93485 }
93486 #endif
93487 break;
93488 }
93489
93490 case TK_VECTOR: {
93491 sqlite3ErrorMsg(pParse, "row value misused");
93492 break;
93493 }
93494
93495 /*
93496 ** Form A:
93497 ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END
93498 **
@@ -92708,12 +93532,13 @@
93532 nExpr = pEList->nExpr;
93533 endLabel = sqlite3VdbeMakeLabel(v);
93534 if( (pX = pExpr->pLeft)!=0 ){
93535 tempX = *pX;
93536 testcase( pX->op==TK_COLUMN );
93537 exprToRegister(&tempX, exprCodeVector(pParse, &tempX, &regFree1));
93538 testcase( regFree1==0 );
93539 memset(&opCompare, 0, sizeof(opCompare));
93540 opCompare.op = TK_EQ;
93541 opCompare.pLeft = &tempX;
93542 pTest = &opCompare;
93543 /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
93544 ** The value in regFree1 might get SCopy-ed into the file result.
@@ -92988,24 +93813,37 @@
93813 **
93814 ** x>=y AND x<=z
93815 **
93816 ** Code it as such, taking care to do the common subexpression
93817 ** elimination of x.
93818 **
93819 ** The xJumpIf parameter determines details:
93820 **
93821 ** NULL: Store the boolean result in reg[dest]
93822 ** sqlite3ExprIfTrue: Jump to dest if true
93823 ** sqlite3ExprIfFalse: Jump to dest if false
93824 **
93825 ** The jumpIfNull parameter is ignored if xJumpIf is NULL.
93826 */
93827 static void exprCodeBetween(
93828 Parse *pParse, /* Parsing and code generating context */
93829 Expr *pExpr, /* The BETWEEN expression */
93830 int dest, /* Jump destination or storage location */
93831 void (*xJump)(Parse*,Expr*,int,int), /* Action to take */
93832 int jumpIfNull /* Take the jump if the BETWEEN is NULL */
93833 ){
93834 Expr exprAnd; /* The AND operator in x>=y AND x<=z */
93835 Expr compLeft; /* The x>=y term */
93836 Expr compRight; /* The x<=z term */
93837 Expr exprX; /* The x subexpression */
93838 int regFree1 = 0; /* Temporary use register */
93839
93840
93841 memset(&compLeft, 0, sizeof(Expr));
93842 memset(&compRight, 0, sizeof(Expr));
93843 memset(&exprAnd, 0, sizeof(Expr));
93844
93845 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
93846 exprX = *pExpr->pLeft;
93847 exprAnd.op = TK_AND;
93848 exprAnd.pLeft = &compLeft;
93849 exprAnd.pRight = &compRight;
@@ -93013,27 +93851,29 @@
93851 compLeft.pLeft = &exprX;
93852 compLeft.pRight = pExpr->x.pList->a[0].pExpr;
93853 compRight.op = TK_LE;
93854 compRight.pLeft = &exprX;
93855 compRight.pRight = pExpr->x.pList->a[1].pExpr;
93856 exprToRegister(&exprX, exprCodeVector(pParse, &exprX, &regFree1));
93857 if( xJump ){
93858 xJump(pParse, &exprAnd, dest, jumpIfNull);
93859 }else{
93860 exprX.flags |= EP_FromJoin;
93861 sqlite3ExprCodeTarget(pParse, &exprAnd, dest);
93862 }
93863 sqlite3ReleaseTempReg(pParse, regFree1);
93864
93865 /* Ensure adequate test coverage */
93866 testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1==0 );
93867 testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1!=0 );
93868 testcase( xJump==sqlite3ExprIfTrue && jumpIfNull!=0 && regFree1==0 );
93869 testcase( xJump==sqlite3ExprIfTrue && jumpIfNull!=0 && regFree1!=0 );
93870 testcase( xJump==sqlite3ExprIfFalse && jumpIfNull==0 && regFree1==0 );
93871 testcase( xJump==sqlite3ExprIfFalse && jumpIfNull==0 && regFree1!=0 );
93872 testcase( xJump==sqlite3ExprIfFalse && jumpIfNull!=0 && regFree1==0 );
93873 testcase( xJump==sqlite3ExprIfFalse && jumpIfNull!=0 && regFree1!=0 );
93874 testcase( xJump==0 );
93875 }
93876
93877 /*
93878 ** Generate code for a boolean expression such that a jump is made
93879 ** to the label "dest" if the expression is true but execution
@@ -93094,10 +93934,11 @@
93934 case TK_LE:
93935 case TK_GT:
93936 case TK_GE:
93937 case TK_NE:
93938 case TK_EQ: {
93939 if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
93940 testcase( jumpIfNull==0 );
93941 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
93942 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
93943 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
93944 r1, r2, dest, jumpIfNull);
@@ -93126,11 +93967,11 @@
93967 testcase( regFree1==0 );
93968 break;
93969 }
93970 case TK_BETWEEN: {
93971 testcase( jumpIfNull==0 );
93972 exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfTrue, jumpIfNull);
93973 break;
93974 }
93975 #ifndef SQLITE_OMIT_SUBQUERY
93976 case TK_IN: {
93977 int destIfFalse = sqlite3VdbeMakeLabel(v);
@@ -93140,10 +93981,11 @@
93981 sqlite3VdbeResolveLabel(v, destIfFalse);
93982 break;
93983 }
93984 #endif
93985 default: {
93986 default_expr:
93987 if( exprAlwaysTrue(pExpr) ){
93988 sqlite3VdbeGoto(v, dest);
93989 }else if( exprAlwaysFalse(pExpr) ){
93990 /* No-op */
93991 }else{
@@ -93246,10 +94088,11 @@
94088 case TK_LE:
94089 case TK_GT:
94090 case TK_GE:
94091 case TK_NE:
94092 case TK_EQ: {
94093 if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;
94094 testcase( jumpIfNull==0 );
94095 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
94096 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
94097 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
94098 r1, r2, dest, jumpIfNull);
@@ -93276,11 +94119,11 @@
94119 testcase( regFree1==0 );
94120 break;
94121 }
94122 case TK_BETWEEN: {
94123 testcase( jumpIfNull==0 );
94124 exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfFalse, jumpIfNull);
94125 break;
94126 }
94127 #ifndef SQLITE_OMIT_SUBQUERY
94128 case TK_IN: {
94129 if( jumpIfNull ){
@@ -93292,10 +94135,11 @@
94135 }
94136 break;
94137 }
94138 #endif
94139 default: {
94140 default_expr:
94141 if( exprAlwaysFalse(pExpr) ){
94142 sqlite3VdbeGoto(v, dest);
94143 }else if( exprAlwaysTrue(pExpr) ){
94144 /* no-op */
94145 }else{
@@ -93807,14 +94651,15 @@
94651 pParse->aTempReg[pParse->nTempReg++] = iReg;
94652 }
94653 }
94654
94655 /*
94656 ** Allocate or deallocate a block of nReg consecutive registers.
94657 */
94658 SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
94659 int i, n;
94660 if( nReg==1 ) return sqlite3GetTempReg(pParse);
94661 i = pParse->iRangeReg;
94662 n = pParse->nRangeReg;
94663 if( nReg<=n ){
94664 assert( !usedAsColumnCache(pParse, i, i+n-1) );
94665 pParse->iRangeReg += nReg;
@@ -93824,10 +94669,14 @@
94669 pParse->nMem += nReg;
94670 }
94671 return i;
94672 }
94673 SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
94674 if( nReg==1 ){
94675 sqlite3ReleaseTempReg(pParse, iReg);
94676 return;
94677 }
94678 sqlite3ExprCacheRemove(pParse, iReg, nReg);
94679 if( nReg>pParse->nRangeReg ){
94680 pParse->nRangeReg = nReg;
94681 pParse->iRangeReg = iReg;
94682 }
@@ -97568,12 +98417,12 @@
98417
98418 #if SQLITE_USER_AUTHENTICATION
98419 if( pParse->nTableLock>0 && db->init.busy==0 ){
98420 sqlite3UserAuthInit(db);
98421 if( db->auth.authLevel<UAUTH_User ){
 
98422 sqlite3ErrorMsg(pParse, "user not authenticated");
98423 pParse->rc = SQLITE_AUTH_USER;
98424 return;
98425 }
98426 }
98427 #endif
98428
@@ -108279,19 +109128,19 @@
109128 }
109129 if( piIdxCur ) *piIdxCur = iBase;
109130 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
109131 int iIdxCur = iBase++;
109132 assert( pIdx->pSchema==pTab->pSchema );
109133 if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
109134 if( piDataCur ) *piDataCur = iIdxCur;
109135 p5 = 0;
109136 }
109137 if( aToOpen==0 || aToOpen[i+1] ){
109138 sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);
109139 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
 
 
 
 
 
109140 sqlite3VdbeChangeP5(v, p5);
109141 VdbeComment((v, "%s", pIdx->zName));
109142 }
109143 }
109144 if( iBase>pParse->nTab ) pParse->nTab = iBase;
109145 return i;
109146 }
@@ -113611,11 +114460,11 @@
114460 ** Initialize a SelectDest structure.
114461 */
114462 SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){
114463 pDest->eDest = (u8)eDest;
114464 pDest->iSDParm = iParm;
114465 pDest->zAffSdst = 0;
114466 pDest->iSdst = 0;
114467 pDest->nSdst = 0;
114468 }
114469
114470
@@ -114182,34 +115031,10 @@
115031 sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);
115032 sqlite3VdbeAddOp2(v, OP_IdxInsert, iTab, r1);
115033 sqlite3ReleaseTempReg(pParse, r1);
115034 }
115035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115036 /*
115037 ** This routine generates the code for the inside of the inner loop
115038 ** of a SELECT.
115039 **
115040 ** If srcTab is negative, then the pEList expressions
@@ -114415,23 +115240,23 @@
115240 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
115241 ** then there should be a single item on the stack. Write this
115242 ** item into the set table with bogus data.
115243 */
115244 case SRT_Set: {
 
 
 
115245 if( pSort ){
115246 /* At first glance you would think we could optimize out the
115247 ** ORDER BY in this case since the order of entries in the set
115248 ** does not matter. But there might be a LIMIT clause, in which
115249 ** case the order does matter */
115250 pushOntoSorter(
115251 pParse, pSort, p, regResult, regResult, nResultCol, nPrefixReg);
115252 }else{
115253 int r1 = sqlite3GetTempReg(pParse);
115254 assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol );
115255 sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, nResultCol,
115256 r1, pDest->zAffSdst, nResultCol);
115257 sqlite3ExprCacheAffinityChange(pParse, regResult, nResultCol);
115258 sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1);
115259 sqlite3ReleaseTempReg(pParse, r1);
115260 }
115261 break;
115262 }
@@ -114443,17 +115268,18 @@
115268 /* The LIMIT clause will terminate the loop for us */
115269 break;
115270 }
115271
115272 /* If this is a scalar select that is part of an expression, then
115273 ** store the results in the appropriate memory cell or array of
115274 ** memory cells and break out of the scan loop.
115275 */
115276 case SRT_Mem: {
115277 assert( nResultCol==pDest->nSdst );
115278 if( pSort ){
115279 pushOntoSorter(
115280 pParse, pSort, p, regResult, regResult, nResultCol, nPrefixReg);
115281 }else{
115282 assert( regResult==iParm );
115283 /* The LIMIT clause will jump out of the loop for us */
115284 }
115285 break;
@@ -114764,18 +115590,18 @@
115590 sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
115591 sqlite3VdbeGoto(v, addrBreak);
115592 sqlite3VdbeResolveLabel(v, pSort->labelBkOut);
115593 }
115594 iTab = pSort->iECursor;
115595 if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){
115596 regRowid = 0;
115597 regRow = pDest->iSdst;
115598 nSortData = nColumn;
115599 }else{
115600 regRowid = sqlite3GetTempReg(pParse);
115601 regRow = sqlite3GetTempRange(pParse, nColumn);
115602 nSortData = nColumn;
115603 }
115604 nKey = pOrderBy->nExpr - pSort->nOBSat;
115605 if( pSort->sortFlags & SORTFLAG_UseSorter ){
115606 int regSortOut = ++pParse->nMem;
115607 iSortTab = pParse->nTab++;
@@ -114806,20 +115632,18 @@
115632 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
115633 break;
115634 }
115635 #ifndef SQLITE_OMIT_SUBQUERY
115636 case SRT_Set: {
115637 assert( nColumn==sqlite3Strlen30(pDest->zAffSdst) );
115638 sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, nColumn, regRowid,
115639 pDest->zAffSdst, nColumn);
115640 sqlite3ExprCacheAffinityChange(pParse, regRow, nColumn);
115641 sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, regRowid);
115642 break;
115643 }
115644 case SRT_Mem: {
 
 
115645 /* The LIMIT clause will terminate the loop for us */
115646 break;
115647 }
115648 #endif
115649 default: {
@@ -114834,11 +115658,15 @@
115658 }
115659 break;
115660 }
115661 }
115662 if( regRowid ){
115663 if( eDest==SRT_Set ){
115664 sqlite3ReleaseTempRange(pParse, regRow, nColumn);
115665 }else{
115666 sqlite3ReleaseTempReg(pParse, regRow);
115667 }
115668 sqlite3ReleaseTempReg(pParse, regRowid);
115669 }
115670 /* The bottom of the loop
115671 */
115672 sqlite3VdbeResolveLabel(v, addrContinue);
@@ -115336,11 +116164,11 @@
116164 ** Get a VDBE for the given parser context. Create a new one if necessary.
116165 ** If an error occurs, return NULL and leave a message in pParse.
116166 */
116167 static SQLITE_NOINLINE Vdbe *allocVdbe(Parse *pParse){
116168 Vdbe *v = pParse->pVdbe = sqlite3VdbeCreate(pParse);
116169 if( v ) sqlite3VdbeAddOp2(v, OP_Init, 0, 1);
116170 if( pParse->pToplevel==0
116171 && OptimizationEnabled(pParse->db,SQLITE_FactorOutConst)
116172 ){
116173 pParse->okConstFactor = 1;
116174 }
@@ -116175,22 +117003,19 @@
117003 sqlite3ReleaseTempReg(pParse, r1);
117004 break;
117005 }
117006
117007 #ifndef SQLITE_OMIT_SUBQUERY
117008 /* If we are creating a set for an "expr IN (SELECT ...)".
 
 
117009 */
117010 case SRT_Set: {
117011 int r1;
117012 testcase( pIn->nSdst>1 );
 
 
117013 r1 = sqlite3GetTempReg(pParse);
117014 sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst,
117015 r1, pDest->zAffSdst, pIn->nSdst);
117016 sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);
117017 sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iSDParm, r1);
117018 sqlite3ReleaseTempReg(pParse, r1);
117019 break;
117020 }
117021
@@ -118418,20 +119243,10 @@
119243 #if SELECTTRACE_ENABLED
119244 if( sqlite3SelectTrace & 0x100 ){
119245 SELECTTRACE(0x100,pParse,p, ("after name resolution:\n"));
119246 sqlite3TreeViewSelect(0, p, 0);
119247 }
 
 
 
 
 
 
 
 
 
 
119248 #endif
119249
119250 /* Try to flatten subqueries in the FROM clause up into the main query
119251 */
119252 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
@@ -122398,11 +123213,11 @@
123213
123214 /*
123215 ** This function is invoked by the vdbe to call the xCreate method
123216 ** of the virtual table named zTab in database iDb.
123217 **
123218 ** If an error occurs, *pzErr is set to point to an English language
123219 ** description of the error and an SQLITE_XXX error code is returned.
123220 ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr.
123221 */
123222 SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
123223 int rc = SQLITE_OK;
@@ -123099,10 +123914,12 @@
123914 LogEst rRun; /* Cost of running each loop */
123915 LogEst nOut; /* Estimated number of output rows */
123916 union {
123917 struct { /* Information for internal btree tables */
123918 u16 nEq; /* Number of equality constraints */
123919 u16 nBtm; /* Size of BTM vector */
123920 u16 nTop; /* Size of TOP vector */
123921 Index *pIndex; /* Index used, or NULL */
123922 } btree;
123923 struct { /* Information for virtual tables */
123924 int idxNum; /* Index number */
123925 u8 needFree; /* True if sqlite3_free(idxStr) is needed */
@@ -123223,10 +124040,11 @@
124040 */
124041 struct WhereTerm {
124042 Expr *pExpr; /* Pointer to the subexpression that is this term */
124043 int iParent; /* Disable pWC->a[iParent] when this term disabled */
124044 int leftCursor; /* Cursor number of X in "X <op> <expr>" */
124045 int iField; /* Field in (?,?,?) IN (SELECT...) vector */
124046 union {
124047 int leftColumn; /* Column number of X in "X <op> <expr>" */
124048 WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
124049 WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
124050 } u;
@@ -123528,10 +124346,21 @@
124346
124347 /************** End of whereInt.h ********************************************/
124348 /************** Continuing where we left off in wherecode.c ******************/
124349
124350 #ifndef SQLITE_OMIT_EXPLAIN
124351
124352 /*
124353 ** Return the name of the i-th column of the pIdx index.
124354 */
124355 static const char *explainIndexColumnName(Index *pIdx, int i){
124356 i = pIdx->aiColumn[i];
124357 if( i==XN_EXPR ) return "<expr>";
124358 if( i==XN_ROWID ) return "rowid";
124359 return pIdx->pTable->aCol[i].zName;
124360 }
124361
124362 /*
124363 ** This routine is a helper for explainIndexRange() below
124364 **
124365 ** pStr holds the text of an expression that we are building up one term
124366 ** at a time. This routine adds a new term to the end of the expression.
@@ -123538,28 +124367,36 @@
124367 ** Terms are separated by AND so add the "AND" text for second and subsequent
124368 ** terms only.
124369 */
124370 static void explainAppendTerm(
124371 StrAccum *pStr, /* The text expression being built */
124372 Index *pIdx, /* Index to read column names from */
124373 int nTerm, /* Number of terms */
124374 int iTerm, /* Zero-based index of first term. */
124375 int bAnd, /* Non-zero to append " AND " */
124376 const char *zOp /* Name of the operator */
124377 ){
124378 int i;
124379
124380 assert( nTerm>=1 );
124381 if( bAnd ) sqlite3StrAccumAppend(pStr, " AND ", 5);
124382
124383 if( nTerm>1 ) sqlite3StrAccumAppend(pStr, "(", 1);
124384 for(i=0; i<nTerm; i++){
124385 if( i ) sqlite3StrAccumAppend(pStr, ",", 1);
124386 sqlite3StrAccumAppendAll(pStr, explainIndexColumnName(pIdx, iTerm+i));
124387 }
124388 if( nTerm>1 ) sqlite3StrAccumAppend(pStr, ")", 1);
124389
124390 sqlite3StrAccumAppend(pStr, zOp, 1);
124391
124392 if( nTerm>1 ) sqlite3StrAccumAppend(pStr, "(", 1);
124393 for(i=0; i<nTerm; i++){
124394 if( i ) sqlite3StrAccumAppend(pStr, ",", 1);
124395 sqlite3StrAccumAppend(pStr, "?", 1);
124396 }
124397 if( nTerm>1 ) sqlite3StrAccumAppend(pStr, ")", 1);
 
 
 
 
124398 }
124399
124400 /*
124401 ** Argument pLevel describes a strategy for scanning table pTab. This
124402 ** function appends text to pStr that describes the subset of table
@@ -123588,16 +124425,15 @@
124425 sqlite3XPrintf(pStr, i>=nSkip ? "%s=?" : "ANY(%s)", z);
124426 }
124427
124428 j = i;
124429 if( pLoop->wsFlags&WHERE_BTM_LIMIT ){
124430 explainAppendTerm(pStr, pIndex, pLoop->u.btree.nBtm, j, i, ">");
124431 i = 1;
124432 }
124433 if( pLoop->wsFlags&WHERE_TOP_LIMIT ){
124434 explainAppendTerm(pStr, pIndex, pLoop->u.btree.nTop, j, i, "<");
 
124435 }
124436 sqlite3StrAccumAppend(pStr, ")", 1);
124437 }
124438
124439 /*
@@ -123783,11 +124619,11 @@
124619 ** a conditional such that is only evaluated on the second pass of a
124620 ** LIKE-optimization loop, when scanning BLOBs instead of strings.
124621 */
124622 static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){
124623 int nLoop = 0;
124624 while( ALWAYS(pTerm!=0)
124625 && (pTerm->wtFlags & TERM_CODED)==0
124626 && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
124627 && (pLevel->notReady & pTerm->prereqAll)==0
124628 ){
124629 if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){
@@ -123839,20 +124675,50 @@
124675 sqlite3VdbeAddOp4(v, OP_Affinity, base, n, 0, zAff, n);
124676 sqlite3ExprCacheAffinityChange(pParse, base, n);
124677 }
124678 }
124679
124680 /*
124681 ** Expression pRight, which is the RHS of a comparison operation, is
124682 ** either a vector of n elements or, if n==1, a scalar expression.
124683 ** Before the comparison operation, affinity zAff is to be applied
124684 ** to the pRight values. This function modifies characters within the
124685 ** affinity string to SQLITE_AFF_BLOB if either:
124686 **
124687 ** * the comparison will be performed with no affinity, or
124688 ** * the affinity change in zAff is guaranteed not to change the value.
124689 */
124690 static void updateRangeAffinityStr(
124691 Parse *pParse, /* Parse context */
124692 Expr *pRight, /* RHS of comparison */
124693 int n, /* Number of vector elements in comparison */
124694 char *zAff /* Affinity string to modify */
124695 ){
124696 int i;
124697 for(i=0; i<n; i++){
124698 Expr *p = sqlite3VectorFieldSubexpr(pRight, i);
124699 if( sqlite3CompareAffinity(p, zAff[i])==SQLITE_AFF_BLOB
124700 || sqlite3ExprNeedsNoAffinityChange(p, zAff[i])
124701 ){
124702 zAff[i] = SQLITE_AFF_BLOB;
124703 }
124704 }
124705 }
124706
124707 /*
124708 ** Generate code for a single equality term of the WHERE clause. An equality
124709 ** term can be either X=expr or X IN (...). pTerm is the term to be
124710 ** coded.
124711 **
124712 ** The current value for the constraint is left in a register, the index
124713 ** of which is returned. An attempt is made store the result in iTarget but
124714 ** this is only guaranteed for TK_ISNULL and TK_IN constraints. If the
124715 ** constraint is a TK_EQ or TK_IS, then the current value might be left in
124716 ** some other register and it is the caller's responsibility to compensate.
124717 **
124718 ** For a constraint of the form X=expr, the expression is evaluated in
124719 ** straight-line code. For constraints of the form X IN (...)
124720 ** this routine sets up a loop that will iterate over all values of X.
124721 */
124722 static int codeEqualityTerm(
124723 Parse *pParse, /* The parsing context */
124724 WhereTerm *pTerm, /* The term of the WHERE clause to be coded */
@@ -123863,22 +124729,26 @@
124729 ){
124730 Expr *pX = pTerm->pExpr;
124731 Vdbe *v = pParse->pVdbe;
124732 int iReg; /* Register holding results */
124733
124734 assert( pLevel->pWLoop->aLTerm[iEq]==pTerm );
124735 assert( iTarget>0 );
124736 if( pX->op==TK_EQ || pX->op==TK_IS ){
124737 iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget);
124738 }else if( pX->op==TK_ISNULL ){
124739 iReg = iTarget;
124740 sqlite3VdbeAddOp2(v, OP_Null, 0, iReg);
124741 #ifndef SQLITE_OMIT_SUBQUERY
124742 }else{
124743 int eType = IN_INDEX_NOOP;
124744 int iTab;
124745 struct InLoop *pIn;
124746 WhereLoop *pLoop = pLevel->pWLoop;
124747 int i;
124748 int nEq = 0;
124749 int *aiMap = 0;
124750
124751 if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0
124752 && pLoop->u.btree.pIndex!=0
124753 && pLoop->u.btree.pIndex->aSortOrder[iEq]
124754 ){
@@ -123886,42 +124756,128 @@
124756 testcase( bRev );
124757 bRev = !bRev;
124758 }
124759 assert( pX->op==TK_IN );
124760 iReg = iTarget;
124761
124762 for(i=0; i<iEq; i++){
124763 if( pLoop->aLTerm[i] && pLoop->aLTerm[i]->pExpr==pX ){
124764 disableTerm(pLevel, pTerm);
124765 return iTarget;
124766 }
124767 }
124768 for(i=iEq;i<pLoop->nLTerm; i++){
124769 if( ALWAYS(pLoop->aLTerm[i]) && pLoop->aLTerm[i]->pExpr==pX ) nEq++;
124770 }
124771
124772 if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){
124773 eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0);
124774 }else{
124775 Select *pSelect = pX->x.pSelect;
124776 sqlite3 *db = pParse->db;
124777 ExprList *pOrigRhs = pSelect->pEList;
124778 ExprList *pOrigLhs = pX->pLeft->x.pList;
124779 ExprList *pRhs = 0; /* New Select.pEList for RHS */
124780 ExprList *pLhs = 0; /* New pX->pLeft vector */
124781
124782 for(i=iEq;i<pLoop->nLTerm; i++){
124783 if( pLoop->aLTerm[i]->pExpr==pX ){
124784 int iField = pLoop->aLTerm[i]->iField - 1;
124785 Expr *pNewRhs = sqlite3ExprDup(db, pOrigRhs->a[iField].pExpr, 0);
124786 Expr *pNewLhs = sqlite3ExprDup(db, pOrigLhs->a[iField].pExpr, 0);
124787
124788 pRhs = sqlite3ExprListAppend(pParse, pRhs, pNewRhs);
124789 pLhs = sqlite3ExprListAppend(pParse, pLhs, pNewLhs);
124790 }
124791 }
124792 if( !db->mallocFailed ){
124793 Expr *pLeft = pX->pLeft;
124794
124795 if( pSelect->pOrderBy ){
124796 /* If the SELECT statement has an ORDER BY clause, zero the
124797 ** iOrderByCol variables. These are set to non-zero when an
124798 ** ORDER BY term exactly matches one of the terms of the
124799 ** result-set. Since the result-set of the SELECT statement may
124800 ** have been modified or reordered, these variables are no longer
124801 ** set correctly. Since setting them is just an optimization,
124802 ** it's easiest just to zero them here. */
124803 ExprList *pOrderBy = pSelect->pOrderBy;
124804 for(i=0; i<pOrderBy->nExpr; i++){
124805 pOrderBy->a[i].u.x.iOrderByCol = 0;
124806 }
124807 }
124808
124809 /* Take care here not to generate a TK_VECTOR containing only a
124810 ** single value. Since the parser never creates such a vector, some
124811 ** of the subroutines do not handle this case. */
124812 if( pLhs->nExpr==1 ){
124813 pX->pLeft = pLhs->a[0].pExpr;
124814 }else{
124815 pLeft->x.pList = pLhs;
124816 aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int) * nEq);
124817 testcase( aiMap==0 );
124818 }
124819 pSelect->pEList = pRhs;
124820 eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap);
124821 testcase( aiMap!=0 && aiMap[0]!=0 );
124822 pSelect->pEList = pOrigRhs;
124823 pLeft->x.pList = pOrigLhs;
124824 pX->pLeft = pLeft;
124825 }
124826 sqlite3ExprListDelete(pParse->db, pLhs);
124827 sqlite3ExprListDelete(pParse->db, pRhs);
124828 }
124829
124830 if( eType==IN_INDEX_INDEX_DESC ){
124831 testcase( bRev );
124832 bRev = !bRev;
124833 }
124834 iTab = pX->iTable;
124835 sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);
124836 VdbeCoverageIf(v, bRev);
124837 VdbeCoverageIf(v, !bRev);
124838 assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );
124839
124840 pLoop->wsFlags |= WHERE_IN_ABLE;
124841 if( pLevel->u.in.nIn==0 ){
124842 pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
124843 }
124844
124845 i = pLevel->u.in.nIn;
124846 pLevel->u.in.nIn += nEq;
124847 pLevel->u.in.aInLoop =
124848 sqlite3DbReallocOrFree(pParse->db, pLevel->u.in.aInLoop,
124849 sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn);
124850 pIn = pLevel->u.in.aInLoop;
124851 if( pIn ){
124852 int iMap = 0; /* Index in aiMap[] */
124853 pIn += i;
124854 for(i=iEq;i<pLoop->nLTerm; i++){
124855 int iOut = iReg;
124856 if( pLoop->aLTerm[i]->pExpr==pX ){
124857 if( eType==IN_INDEX_ROWID ){
124858 assert( nEq==1 && i==iEq );
124859 pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iReg);
124860 }else{
124861 int iCol = aiMap ? aiMap[iMap++] : 0;
124862 iOut = iReg + i - iEq;
124863 pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut);
124864 }
124865 sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);
124866 if( i==iEq ){
124867 pIn->iCur = iTab;
124868 pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;
124869 }else{
124870 pIn->eEndLoopOp = OP_Noop;
124871 }
124872 pIn++;
124873 }
124874 }
124875 }else{
124876 pLevel->u.in.nIn = 0;
124877 }
124878 sqlite3DbFree(pParse->db, aiMap);
124879 #endif
124880 }
124881 disableTerm(pLevel, pTerm);
124882 return iReg;
124883 }
@@ -124043,13 +124999,19 @@
124999 regBase = r1;
125000 }else{
125001 sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);
125002 }
125003 }
125004 if( pTerm->eOperator & WO_IN ){
125005 if( pTerm->pExpr->flags & EP_xIsSelect ){
125006 /* No affinity ever needs to be (or should be) applied to a value
125007 ** from the RHS of an "? IN (SELECT ...)" expression. The
125008 ** sqlite3FindInIndex() routine has already ensured that the
125009 ** affinity of the comparison has been applied to the value. */
125010 if( zAff ) zAff[j] = SQLITE_AFF_BLOB;
125011 }
125012 }else if( (pTerm->eOperator & WO_ISNULL)==0 ){
125013 Expr *pRight = pTerm->pExpr->pRight;
125014 if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
125015 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
125016 VdbeCoverage(v);
125017 }
@@ -124367,10 +125329,43 @@
125329 }
125330 sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);
125331 }
125332 }
125333 }
125334
125335 /*
125336 ** If the expression passed as the second argument is a vector, generate
125337 ** code to write the first nReg elements of the vector into an array
125338 ** of registers starting with iReg.
125339 **
125340 ** If the expression is not a vector, then nReg must be passed 1. In
125341 ** this case, generate code to evaluate the expression and leave the
125342 ** result in register iReg.
125343 */
125344 static void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){
125345 assert( nReg>0 );
125346 if( sqlite3ExprIsVector(p) ){
125347 #ifndef SQLITE_OMIT_SUBQUERY
125348 if( (p->flags & EP_xIsSelect) ){
125349 Vdbe *v = pParse->pVdbe;
125350 int iSelect = sqlite3CodeSubselect(pParse, p, 0, 0);
125351 sqlite3VdbeAddOp3(v, OP_Copy, iSelect, iReg, nReg-1);
125352 }else
125353 #endif
125354 {
125355 int i;
125356 ExprList *pList = p->x.pList;
125357 assert( nReg<=pList->nExpr );
125358 for(i=0; i<nReg; i++){
125359 sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i);
125360 }
125361 }
125362 }else{
125363 assert( nReg==1 );
125364 sqlite3ExprCode(pParse, p, iReg);
125365 }
125366 }
125367
125368 /*
125369 ** Generate code for the start of the iLevel-th loop in the WHERE clause
125370 ** implementation described by pWInfo.
125371 */
@@ -124463,11 +125458,12 @@
125458 if( NEVER(pTerm==0) ) continue;
125459 if( pTerm->eOperator & WO_IN ){
125460 codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
125461 addrNotFound = pLevel->addrNxt;
125462 }else{
125463 Expr *pRight = pTerm->pExpr->pRight;
125464 codeExprOrVector(pParse, pRight, iTarget, 1);
125465 }
125466 }
125467 sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);
125468 sqlite3VdbeAddOp2(v, OP_Integer, nConstraint, iReg+1);
125469 sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrNotFound, iReg,
@@ -124577,10 +125573,11 @@
125573 }
125574 codeCursorHint(pTabItem, pWInfo, pLevel, pEnd);
125575 if( pStart ){
125576 Expr *pX; /* The expression that defines the start bound */
125577 int r1, rTemp; /* Registers for holding the start boundary */
125578 int op; /* Cursor seek operation */
125579
125580 /* The following constant maps TK_xx codes into corresponding
125581 ** seek opcodes. It depends on a particular ordering of TK_xx
125582 */
125583 const u8 aMoveOp[] = {
@@ -124596,20 +125593,27 @@
125593 assert( (pStart->wtFlags & TERM_VNULL)==0 );
125594 testcase( pStart->wtFlags & TERM_VIRTUAL );
125595 pX = pStart->pExpr;
125596 assert( pX!=0 );
125597 testcase( pStart->leftCursor!=iCur ); /* transitive constraints */
125598 if( sqlite3ExprIsVector(pX->pRight) ){
125599 r1 = rTemp = sqlite3GetTempReg(pParse);
125600 codeExprOrVector(pParse, pX->pRight, r1, 1);
125601 op = aMoveOp[(pX->op - TK_GT) | 0x0001];
125602 }else{
125603 r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);
125604 disableTerm(pLevel, pStart);
125605 op = aMoveOp[(pX->op - TK_GT)];
125606 }
125607 sqlite3VdbeAddOp3(v, op, iCur, addrBrk, r1);
125608 VdbeComment((v, "pk"));
125609 VdbeCoverageIf(v, pX->op==TK_GT);
125610 VdbeCoverageIf(v, pX->op==TK_LE);
125611 VdbeCoverageIf(v, pX->op==TK_LT);
125612 VdbeCoverageIf(v, pX->op==TK_GE);
125613 sqlite3ExprCacheAffinityChange(pParse, r1, 1);
125614 sqlite3ReleaseTempReg(pParse, rTemp);
 
125615 }else{
125616 sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrBrk);
125617 VdbeCoverageIf(v, bRev==0);
125618 VdbeCoverageIf(v, bRev!=0);
125619 }
@@ -124619,17 +125623,21 @@
125623 assert( pX!=0 );
125624 assert( (pEnd->wtFlags & TERM_VNULL)==0 );
125625 testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */
125626 testcase( pEnd->wtFlags & TERM_VIRTUAL );
125627 memEndValue = ++pParse->nMem;
125628 codeExprOrVector(pParse, pX->pRight, memEndValue, 1);
125629 if( 0==sqlite3ExprIsVector(pX->pRight)
125630 && (pX->op==TK_LT || pX->op==TK_GT)
125631 ){
125632 testOp = bRev ? OP_Le : OP_Ge;
125633 }else{
125634 testOp = bRev ? OP_Lt : OP_Gt;
125635 }
125636 if( 0==sqlite3ExprIsVector(pX->pRight) ){
125637 disableTerm(pLevel, pEnd);
125638 }
125639 }
125640 start = sqlite3VdbeCurrentAddr(v);
125641 pLevel->op = bRev ? OP_Prev : OP_Next;
125642 pLevel->p1 = iCur;
125643 pLevel->p2 = start;
@@ -124692,10 +125700,12 @@
125700 OP_IdxGT, /* 1: (end_constraints && !bRev && endEq) */
125701 OP_IdxLE, /* 2: (end_constraints && bRev && !endEq) */
125702 OP_IdxLT, /* 3: (end_constraints && bRev && endEq) */
125703 };
125704 u16 nEq = pLoop->u.btree.nEq; /* Number of == or IN terms */
125705 u16 nBtm = pLoop->u.btree.nBtm; /* Length of BTM vector */
125706 u16 nTop = pLoop->u.btree.nTop; /* Length of TOP vector */
125707 int regBase; /* Base register holding constraint values */
125708 WhereTerm *pRangeStart = 0; /* Inequality constraint at range start */
125709 WhereTerm *pRangeEnd = 0; /* Inequality constraint at range end */
125710 int startEq; /* True if range start uses ==, >= or <= */
125711 int endEq; /* True if range end uses ==, >= or <= */
@@ -124704,11 +125714,11 @@
125714 Index *pIdx; /* The index we will be using */
125715 int iIdxCur; /* The VDBE cursor for the index */
125716 int nExtraReg = 0; /* Number of extra registers needed */
125717 int op; /* Instruction opcode */
125718 char *zStartAff; /* Affinity for start of range constraint */
125719 char *zEndAff = 0; /* Affinity for end of range constraint */
125720 u8 bSeekPastNull = 0; /* True to seek past initial nulls */
125721 u8 bStopAtNull = 0; /* Add condition to terminate at NULLs */
125722
125723 pIdx = pLoop->u.btree.pIndex;
125724 iIdxCur = pLevel->iIdxCur;
@@ -124738,18 +125748,18 @@
125748 ** of the range.
125749 */
125750 j = nEq;
125751 if( pLoop->wsFlags & WHERE_BTM_LIMIT ){
125752 pRangeStart = pLoop->aLTerm[j++];
125753 nExtraReg = MAX(nExtraReg, pLoop->u.btree.nBtm);
125754 /* Like optimization range constraints always occur in pairs */
125755 assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 ||
125756 (pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 );
125757 }
125758 if( pLoop->wsFlags & WHERE_TOP_LIMIT ){
125759 pRangeEnd = pLoop->aLTerm[j++];
125760 nExtraReg = MAX(nExtraReg, pLoop->u.btree.nTop);
125761 #ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
125762 if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){
125763 assert( pRangeStart!=0 ); /* LIKE opt constraints */
125764 assert( pRangeStart->wtFlags & TERM_LIKEOPT ); /* occur in pairs */
125765 pLevel->iLikeRepCntr = (u32)++pParse->nMem;
@@ -124781,20 +125791,23 @@
125791 if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))
125792 || (bRev && pIdx->nKeyCol==nEq)
125793 ){
125794 SWAP(WhereTerm *, pRangeEnd, pRangeStart);
125795 SWAP(u8, bSeekPastNull, bStopAtNull);
125796 SWAP(u8, nBtm, nTop);
125797 }
125798
125799 /* Generate code to evaluate all constraint terms using == or IN
125800 ** and store the values of those terms in an array of registers
125801 ** starting at regBase.
125802 */
125803 codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd);
125804 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
125805 assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );
125806 if( zStartAff && nTop ){
125807 zEndAff = sqlite3DbStrDup(db, &zStartAff[nEq]);
125808 }
125809 addrNxt = pLevel->addrNxt;
125810
125811 testcase( pRangeStart && (pRangeStart->eOperator & WO_LE)!=0 );
125812 testcase( pRangeStart && (pRangeStart->eOperator & WO_GE)!=0 );
125813 testcase( pRangeEnd && (pRangeEnd->eOperator & WO_LE)!=0 );
@@ -124805,31 +125818,28 @@
125818
125819 /* Seek the index cursor to the start of the range. */
125820 nConstraint = nEq;
125821 if( pRangeStart ){
125822 Expr *pRight = pRangeStart->pExpr->pRight;
125823 codeExprOrVector(pParse, pRight, regBase+nEq, nBtm);
125824 whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);
125825 if( (pRangeStart->wtFlags & TERM_VNULL)==0
125826 && sqlite3ExprCanBeNull(pRight)
125827 ){
125828 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
125829 VdbeCoverage(v);
125830 }
125831 if( zStartAff ){
125832 updateRangeAffinityStr(pParse, pRight, nBtm, &zStartAff[nEq]);
125833 }
125834 nConstraint += nBtm;
125835 testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
125836 if( sqlite3ExprIsVector(pRight)==0 ){
125837 disableTerm(pLevel, pRangeStart);
125838 }else{
125839 startEq = 1;
125840 }
 
 
 
125841 bSeekPastNull = 0;
125842 }else if( bSeekPastNull ){
125843 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
125844 nConstraint++;
125845 startEq = 0;
@@ -124858,31 +125868,39 @@
125868 */
125869 nConstraint = nEq;
125870 if( pRangeEnd ){
125871 Expr *pRight = pRangeEnd->pExpr->pRight;
125872 sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
125873 codeExprOrVector(pParse, pRight, regBase+nEq, nTop);
125874 whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
125875 if( (pRangeEnd->wtFlags & TERM_VNULL)==0
125876 && sqlite3ExprCanBeNull(pRight)
125877 ){
125878 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
125879 VdbeCoverage(v);
125880 }
125881 if( zEndAff ){
125882 updateRangeAffinityStr(pParse, pRight, nTop, zEndAff);
125883 codeApplyAffinity(pParse, regBase+nEq, nTop, zEndAff);
125884 }else{
125885 assert( pParse->db->mallocFailed );
125886 }
125887 nConstraint += nTop;
125888 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );
125889
125890 if( sqlite3ExprIsVector(pRight)==0 ){
125891 disableTerm(pLevel, pRangeEnd);
125892 }else{
125893 endEq = 1;
125894 }
125895 }else if( bStopAtNull ){
125896 sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
125897 endEq = 0;
125898 nConstraint++;
125899 }
125900 sqlite3DbFree(db, zStartAff);
125901 sqlite3DbFree(db, zEndAff);
125902
125903 /* Top of the loop body */
125904 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
125905
125906 /* Check if the index cursor is past the end of the range. */
@@ -124894,12 +125912,10 @@
125912 testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
125913 testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
125914 }
125915
125916 /* Seek the table cursor, if required */
 
 
125917 if( omitTable ){
125918 /* pIdx is a covering index. No need to access the main table. */
125919 }else if( HasRowid(pIdx->pTable) ){
125920 if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE)!=0 ){
125921 iRowidReg = ++pParse->nMem;
@@ -124919,13 +125935,11 @@
125935 }
125936 sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,
125937 iRowidReg, pPk->nKeyCol); VdbeCoverage(v);
125938 }
125939
125940 /* Record the instruction used to terminate the loop. */
 
 
125941 if( pLoop->wsFlags & WHERE_ONEROW ){
125942 pLevel->op = OP_Noop;
125943 }else if( bRev ){
125944 pLevel->op = OP_Prev;
125945 }else{
@@ -124998,11 +126012,11 @@
126012 int untestedTerms = 0; /* Some terms not completely tested */
126013 int ii; /* Loop counter */
126014 u16 wctrlFlags; /* Flags for sub-WHERE clause */
126015 Expr *pAndExpr = 0; /* An ".. AND (...)" expression */
126016 Table *pTab = pTabItem->pTab;
126017
126018 pTerm = pLoop->aLTerm[0];
126019 assert( pTerm!=0 );
126020 assert( pTerm->eOperator & WO_OR );
126021 assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );
126022 pOrWc = &pTerm->u.pOrInfo->wc;
@@ -125450,11 +126464,11 @@
126464 }
126465
126466 /*
126467 ** Return TRUE if the given operator is one of the operators that is
126468 ** allowed for an indexable WHERE clause term. The allowed operators are
126469 ** "=", "<", ">", "<=", ">=", "IN", "IS", and "IS NULL"
126470 */
126471 static int allowedOp(int op){
126472 assert( TK_GT>TK_EQ && TK_GT<TK_GE );
126473 assert( TK_LT>TK_EQ && TK_LT<TK_GE );
126474 assert( TK_LE>TK_EQ && TK_LE<TK_GE );
@@ -126178,26 +127192,39 @@
127192 ** Expression pExpr is one operand of a comparison operator that might
127193 ** be useful for indexing. This routine checks to see if pExpr appears
127194 ** in any index. Return TRUE (1) if pExpr is an indexed term and return
127195 ** FALSE (0) if not. If TRUE is returned, also set *piCur to the cursor
127196 ** number of the table that is indexed and *piColumn to the column number
127197 ** of the column that is indexed, or XN_EXPR (-2) if an expression is being
127198 ** indexed.
127199 **
127200 ** If pExpr is a TK_COLUMN column reference, then this routine always returns
127201 ** true even if that particular column is not indexed, because the column
127202 ** might be added to an automatic index later.
127203 */
127204 static int exprMightBeIndexed(
127205 SrcList *pFrom, /* The FROM clause */
127206 int op, /* The specific comparison operator */
127207 Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */
127208 Expr *pExpr, /* An operand of a comparison operator */
127209 int *piCur, /* Write the referenced table cursor number here */
127210 int *piColumn /* Write the referenced table column number here */
127211 ){
127212 Index *pIdx;
127213 int i;
127214 int iCur;
127215
127216 /* If this expression is a vector to the left or right of a
127217 ** inequality constraint (>, <, >= or <=), perform the processing
127218 ** on the first element of the vector. */
127219 assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE );
127220 assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE );
127221 assert( op<=TK_GE );
127222 if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){
127223 pExpr = pExpr->x.pList->a[0].pExpr;
127224 }
127225
127226 if( pExpr->op==TK_COLUMN ){
127227 *piCur = pExpr->iTable;
127228 *piColumn = pExpr->iColumn;
127229 return 1;
127230 }
@@ -126206,14 +127233,14 @@
127233 for(i=0; mPrereq>1; i++, mPrereq>>=1){}
127234 iCur = pFrom->a[i].iCursor;
127235 for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
127236 if( pIdx->aColExpr==0 ) continue;
127237 for(i=0; i<pIdx->nKeyCol; i++){
127238 if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
127239 if( sqlite3ExprCompare(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
127240 *piCur = iCur;
127241 *piColumn = XN_EXPR;
127242 return 1;
127243 }
127244 }
127245 }
127246 return 0;
@@ -126266,10 +127293,11 @@
127293 assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );
127294 prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);
127295 op = pExpr->op;
127296 if( op==TK_IN ){
127297 assert( pExpr->pRight==0 );
127298 if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
127299 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
127300 pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect);
127301 }else{
127302 pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);
127303 }
@@ -126292,22 +127320,30 @@
127320 if( allowedOp(op) ){
127321 int iCur, iColumn;
127322 Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);
127323 Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);
127324 u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;
127325
127326 if( pTerm->iField>0 ){
127327 assert( op==TK_IN );
127328 assert( pLeft->op==TK_VECTOR );
127329 pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr;
127330 }
127331
127332 if( exprMightBeIndexed(pSrc, op, prereqLeft, pLeft, &iCur, &iColumn) ){
127333 pTerm->leftCursor = iCur;
127334 pTerm->u.leftColumn = iColumn;
127335 pTerm->eOperator = operatorMask(op) & opMask;
127336 }
127337 if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;
127338 if( pRight
127339 && exprMightBeIndexed(pSrc, op, pTerm->prereqRight, pRight, &iCur,&iColumn)
127340 ){
127341 WhereTerm *pNew;
127342 Expr *pDup;
127343 u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */
127344 assert( pTerm->iField==0 );
127345 if( pTerm->leftCursor>=0 ){
127346 int idxNew;
127347 pDup = sqlite3ExprDup(db, pExpr, 0);
127348 if( db->mallocFailed ){
127349 sqlite3ExprDelete(db, pDup);
@@ -126506,10 +127542,63 @@
127542 pTerm->wtFlags |= TERM_COPIED;
127543 pNewTerm->prereqAll = pTerm->prereqAll;
127544 }
127545 }
127546 #endif /* SQLITE_OMIT_VIRTUALTABLE */
127547
127548 /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create
127549 ** new terms for each component comparison - "a = ?" and "b = ?". The
127550 ** new terms completely replace the original vector comparison, which is
127551 ** no longer used.
127552 **
127553 ** This is only required if at least one side of the comparison operation
127554 ** is not a sub-select. */
127555 if( pWC->op==TK_AND
127556 && (pExpr->op==TK_EQ || pExpr->op==TK_IS)
127557 && sqlite3ExprIsVector(pExpr->pLeft)
127558 && ( (pExpr->pLeft->flags & EP_xIsSelect)==0
127559 || (pExpr->pRight->flags & EP_xIsSelect)==0
127560 )){
127561 int nLeft = sqlite3ExprVectorSize(pExpr->pLeft);
127562 int i;
127563 assert( nLeft==sqlite3ExprVectorSize(pExpr->pRight) );
127564 for(i=0; i<nLeft; i++){
127565 int idxNew;
127566 Expr *pNew;
127567 Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
127568 Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
127569
127570 pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight, 0);
127571 idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
127572 exprAnalyze(pSrc, pWC, idxNew);
127573 }
127574 pTerm = &pWC->a[idxTerm];
127575 pTerm->wtFlags = TERM_CODED|TERM_VIRTUAL; /* Disable the original */
127576 pTerm->eOperator = 0;
127577 }
127578
127579 /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
127580 ** a virtual term for each vector component. The expression object
127581 ** used by each such virtual term is pExpr (the full vector IN(...)
127582 ** expression). The WhereTerm.iField variable identifies the index within
127583 ** the vector on the LHS that the virtual term represents.
127584 **
127585 ** This only works if the RHS is a simple SELECT, not a compound
127586 */
127587 if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
127588 && pExpr->pLeft->op==TK_VECTOR
127589 && pExpr->x.pSelect->pPrior==0
127590 ){
127591 int i;
127592 for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
127593 int idxNew;
127594 idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
127595 pWC->a[idxNew].iField = i+1;
127596 exprAnalyze(pSrc, pWC, idxNew);
127597 markTermAsChild(pWC, idxNew, idxTerm);
127598 }
127599 }
127600
127601 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
127602 /* When sqlite_stat3 histogram data is available an operator of the
127603 ** form "x IS NOT NULL" can sometimes be evaluated more efficiently
127604 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
@@ -127546,20 +128635,22 @@
128635 static sqlite3_index_info *allocateIndexInfo(
128636 Parse *pParse,
128637 WhereClause *pWC,
128638 Bitmask mUnusable, /* Ignore terms with these prereqs */
128639 struct SrcList_item *pSrc,
128640 ExprList *pOrderBy,
128641 u16 *pmNoOmit /* Mask of terms not to omit */
128642 ){
128643 int i, j;
128644 int nTerm;
128645 struct sqlite3_index_constraint *pIdxCons;
128646 struct sqlite3_index_orderby *pIdxOrderBy;
128647 struct sqlite3_index_constraint_usage *pUsage;
128648 WhereTerm *pTerm;
128649 int nOrderBy;
128650 sqlite3_index_info *pIdxInfo;
128651 u16 mNoOmit = 0;
128652
128653 /* Count the number of possible WHERE clause constraints referring
128654 ** to this virtual table */
128655 for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
128656 if( pTerm->leftCursor != pSrc->iCursor ) continue;
@@ -127644,18 +128735,28 @@
128735 assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE );
128736 assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT );
128737 assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE );
128738 assert( WO_MATCH==SQLITE_INDEX_CONSTRAINT_MATCH );
128739 assert( pTerm->eOperator & (WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_MATCH) );
128740
128741 if( op & (WO_LT|WO_LE|WO_GT|WO_GE)
128742 && sqlite3ExprIsVector(pTerm->pExpr->pRight)
128743 ){
128744 if( i<16 ) mNoOmit |= (1 << i);
128745 if( op==WO_LT ) pIdxCons[j].op = WO_LE;
128746 if( op==WO_GT ) pIdxCons[j].op = WO_GE;
128747 }
128748
128749 j++;
128750 }
128751 for(i=0; i<nOrderBy; i++){
128752 Expr *pExpr = pOrderBy->a[i].pExpr;
128753 pIdxOrderBy[i].iColumn = pExpr->iColumn;
128754 pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;
128755 }
128756
128757 *pmNoOmit = mNoOmit;
128758 return pIdxInfo;
128759 }
128760
128761 /*
128762 ** The table object reference passed as the second argument to this function
@@ -127927,11 +129028,11 @@
129028
129029 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
129030 /*
129031 ** Return the affinity for a single column of an index.
129032 */
129033 SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){
129034 assert( iCol>=0 && iCol<pIdx->nColumn );
129035 if( !pIdx->zColAff ){
129036 if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;
129037 }
129038 return pIdx->zColAff[iCol];
@@ -128104,11 +129205,12 @@
129205
129206 if( p->nSample>0 && nEq<p->nSampleCol ){
129207 if( nEq==pBuilder->nRecValid ){
129208 UnpackedRecord *pRec = pBuilder->pRec;
129209 tRowcnt a[2];
129210 int nBtm = pLoop->u.btree.nBtm;
129211 int nTop = pLoop->u.btree.nTop;
129212
129213 /* Variable iLower will be set to the estimate of the number of rows in
129214 ** the index that are less than the lower bound of the range query. The
129215 ** lower bound being the concatenation of $P and $L, where $P is the
129216 ** key-prefix formed by the nEq values matched against the nEq left-most
@@ -128134,12 +129236,10 @@
129236
129237 if( pRec ){
129238 testcase( pRec->nField!=pBuilder->nRecValid );
129239 pRec->nField = pBuilder->nRecValid;
129240 }
 
 
129241 /* Determine iLower and iUpper using ($P) only. */
129242 if( nEq==0 ){
129243 iLower = 0;
129244 iUpper = p->nRowEst0;
129245 }else{
@@ -128154,36 +129254,41 @@
129254 assert( pUpper==0 || (pUpper->eOperator & (WO_LT|WO_LE))!=0 );
129255 assert( p->aSortOrder!=0 );
129256 if( p->aSortOrder[nEq] ){
129257 /* The roles of pLower and pUpper are swapped for a DESC index */
129258 SWAP(WhereTerm*, pLower, pUpper);
129259 SWAP(int, nBtm, nTop);
129260 }
129261
129262 /* If possible, improve on the iLower estimate using ($P:$L). */
129263 if( pLower ){
129264 int n; /* Values extracted from pExpr */
129265 Expr *pExpr = pLower->pExpr->pRight;
129266 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nBtm, nEq, &n);
129267 if( rc==SQLITE_OK && n ){
129268 tRowcnt iNew;
129269 u16 mask = WO_GT|WO_LE;
129270 if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);
129271 iLwrIdx = whereKeyStats(pParse, p, pRec, 0, a);
129272 iNew = a[0] + ((pLower->eOperator & mask) ? a[1] : 0);
129273 if( iNew>iLower ) iLower = iNew;
129274 nOut--;
129275 pLower = 0;
129276 }
129277 }
129278
129279 /* If possible, improve on the iUpper estimate using ($P:$U). */
129280 if( pUpper ){
129281 int n; /* Values extracted from pExpr */
129282 Expr *pExpr = pUpper->pExpr->pRight;
129283 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nTop, nEq, &n);
129284 if( rc==SQLITE_OK && n ){
129285 tRowcnt iNew;
129286 u16 mask = WO_GT|WO_LE;
129287 if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);
129288 iUprIdx = whereKeyStats(pParse, p, pRec, 1, a);
129289 iNew = a[0] + ((pUpper->eOperator & mask) ? a[1] : 0);
129290 if( iNew<iUpper ) iUpper = iNew;
129291 nOut--;
129292 pUpper = 0;
129293 }
129294 }
@@ -128269,11 +129374,10 @@
129374 tRowcnt *pnRow /* Write the revised row estimate here */
129375 ){
129376 Index *p = pBuilder->pNew->u.btree.pIndex;
129377 int nEq = pBuilder->pNew->u.btree.nEq;
129378 UnpackedRecord *pRec = pBuilder->pRec;
 
129379 int rc; /* Subfunction return code */
129380 tRowcnt a[2]; /* Statistics */
129381 int bOk;
129382
129383 assert( nEq>=1 );
@@ -128293,12 +129397,11 @@
129397 if( nEq>=p->nColumn ){
129398 *pnRow = 1;
129399 return SQLITE_OK;
129400 }
129401
129402 rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, 1, nEq-1, &bOk);
 
129403 pBuilder->pRec = pRec;
129404 if( rc!=SQLITE_OK ) return rc;
129405 if( bOk==0 ) return SQLITE_NOTFOUND;
129406 pBuilder->nRecValid = nEq;
129407
@@ -128383,13 +129486,18 @@
129486 pTerm->u.pOrInfo->indexable);
129487 }else{
129488 sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
129489 }
129490 sqlite3DebugPrintf(
129491 "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x",
129492 iTerm, pTerm, zType, zLeft, pTerm->truthProb,
129493 pTerm->eOperator, pTerm->wtFlags);
129494 if( pTerm->iField ){
129495 sqlite3DebugPrintf(" iField=%d\n", pTerm->iField);
129496 }else{
129497 sqlite3DebugPrintf("\n");
129498 }
129499 sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
129500 }
129501 }
129502 #endif
129503
@@ -128906,10 +130014,76 @@
130014 }
130015 }
130016 }
130017 if( pLoop->nOut > nRow-iReduce ) pLoop->nOut = nRow - iReduce;
130018 }
130019
130020 /*
130021 ** Term pTerm is a vector range comparison operation. The first comparison
130022 ** in the vector can be optimized using column nEq of the index. This
130023 ** function returns the total number of vector elements that can be used
130024 ** as part of the range comparison.
130025 **
130026 ** For example, if the query is:
130027 **
130028 ** WHERE a = ? AND (b, c, d) > (?, ?, ?)
130029 **
130030 ** and the index:
130031 **
130032 ** CREATE INDEX ... ON (a, b, c, d, e)
130033 **
130034 ** then this function would be invoked with nEq=1. The value returned in
130035 ** this case is 3.
130036 */
130037 int whereRangeVectorLen(
130038 Parse *pParse, /* Parsing context */
130039 int iCur, /* Cursor open on pIdx */
130040 Index *pIdx, /* The index to be used for a inequality constraint */
130041 int nEq, /* Number of prior equality constraints on same index */
130042 WhereTerm *pTerm /* The vector inequality constraint */
130043 ){
130044 int nCmp = sqlite3ExprVectorSize(pTerm->pExpr->pLeft);
130045 int i;
130046
130047 nCmp = MIN(nCmp, (pIdx->nColumn - nEq));
130048 for(i=1; i<nCmp; i++){
130049 /* Test if comparison i of pTerm is compatible with column (i+nEq)
130050 ** of the index. If not, exit the loop. */
130051 char aff; /* Comparison affinity */
130052 char idxaff = 0; /* Indexed columns affinity */
130053 CollSeq *pColl; /* Comparison collation sequence */
130054 Expr *pLhs = pTerm->pExpr->pLeft->x.pList->a[i].pExpr;
130055 Expr *pRhs = pTerm->pExpr->pRight;
130056 if( pRhs->flags & EP_xIsSelect ){
130057 pRhs = pRhs->x.pSelect->pEList->a[i].pExpr;
130058 }else{
130059 pRhs = pRhs->x.pList->a[i].pExpr;
130060 }
130061
130062 /* Check that the LHS of the comparison is a column reference to
130063 ** the right column of the right source table. And that the sort
130064 ** order of the index column is the same as the sort order of the
130065 ** leftmost index column. */
130066 if( pLhs->op!=TK_COLUMN
130067 || pLhs->iTable!=iCur
130068 || pLhs->iColumn!=pIdx->aiColumn[i+nEq]
130069 || pIdx->aSortOrder[i+nEq]!=pIdx->aSortOrder[nEq]
130070 ){
130071 break;
130072 }
130073
130074 testcase( pLhs->iColumn==XN_ROWID );
130075 aff = sqlite3CompareAffinity(pRhs, sqlite3ExprAffinity(pLhs));
130076 idxaff = sqlite3TableColumnAffinity(pIdx->pTable, pLhs->iColumn);
130077 if( aff!=idxaff ) break;
130078
130079 pColl = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
130080 if( pColl==0 ) break;
130081 if( sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;
130082 }
130083 return i;
130084 }
130085
130086 /*
130087 ** Adjust the cost C by the costMult facter T. This only occurs if
130088 ** compiled with -DSQLITE_ENABLE_COSTMULT
130089 */
@@ -128945,10 +130119,12 @@
130119 int opMask; /* Valid operators for constraints */
130120 WhereScan scan; /* Iterator for WHERE terms */
130121 Bitmask saved_prereq; /* Original value of pNew->prereq */
130122 u16 saved_nLTerm; /* Original value of pNew->nLTerm */
130123 u16 saved_nEq; /* Original value of pNew->u.btree.nEq */
130124 u16 saved_nBtm; /* Original value of pNew->u.btree.nBtm */
130125 u16 saved_nTop; /* Original value of pNew->u.btree.nTop */
130126 u16 saved_nSkip; /* Original value of pNew->nSkip */
130127 u32 saved_wsFlags; /* Original value of pNew->wsFlags */
130128 LogEst saved_nOut; /* Original value of pNew->nOut */
130129 int rc = SQLITE_OK; /* Return code */
130130 LogEst rSize; /* Number of rows in the table */
@@ -128961,17 +130137,20 @@
130137 assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );
130138 assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
130139 if( pNew->wsFlags & WHERE_BTM_LIMIT ){
130140 opMask = WO_LT|WO_LE;
130141 }else{
130142 assert( pNew->u.btree.nBtm==0 );
130143 opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
130144 }
130145 if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
130146
130147 assert( pNew->u.btree.nEq<pProbe->nColumn );
130148
130149 saved_nEq = pNew->u.btree.nEq;
130150 saved_nBtm = pNew->u.btree.nBtm;
130151 saved_nTop = pNew->u.btree.nTop;
130152 saved_nSkip = pNew->nSkip;
130153 saved_nLTerm = pNew->nLTerm;
130154 saved_wsFlags = pNew->wsFlags;
130155 saved_prereq = pNew->prereq;
130156 saved_nOut = pNew->nOut;
@@ -129011,10 +130190,12 @@
130190 continue;
130191 }
130192
130193 pNew->wsFlags = saved_wsFlags;
130194 pNew->u.btree.nEq = saved_nEq;
130195 pNew->u.btree.nBtm = saved_nBtm;
130196 pNew->u.btree.nTop = saved_nTop;
130197 pNew->nLTerm = saved_nLTerm;
130198 if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
130199 pNew->aLTerm[pNew->nLTerm++] = pTerm;
130200 pNew->prereq = (saved_prereq | pTerm->prereqRight) & ~pNew->maskSelf;
130201
@@ -129027,18 +130208,27 @@
130208 if( eOp & WO_IN ){
130209 Expr *pExpr = pTerm->pExpr;
130210 pNew->wsFlags |= WHERE_COLUMN_IN;
130211 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
130212 /* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */
130213 int i;
130214 nIn = 46; assert( 46==sqlite3LogEst(25) );
130215
130216 /* The expression may actually be of the form (x, y) IN (SELECT...).
130217 ** In this case there is a separate term for each of (x) and (y).
130218 ** However, the nIn multiplier should only be applied once, not once
130219 ** for each such term. The following loop checks that pTerm is the
130220 ** first such term in use, and sets nIn back to 0 if it is not. */
130221 for(i=0; i<pNew->nLTerm-1; i++){
130222 if( pNew->aLTerm[i]->pExpr==pExpr ) nIn = 0;
130223 }
130224 }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
130225 /* "x IN (value, value, ...)" */
130226 nIn = sqlite3LogEst(pExpr->x.pList->nExpr);
130227 assert( nIn>0 ); /* RHS always has 2 or more terms... The parser
130228 ** changes "x IN (?)" into "x=?". */
130229 }
 
 
 
130230 }else if( eOp & (WO_EQ|WO_IS) ){
130231 int iCol = pProbe->aiColumn[saved_nEq];
130232 pNew->wsFlags |= WHERE_COLUMN_EQ;
130233 assert( saved_nEq==pNew->u.btree.nEq );
130234 if( iCol==XN_ROWID
@@ -129054,10 +130244,13 @@
130244 pNew->wsFlags |= WHERE_COLUMN_NULL;
130245 }else if( eOp & (WO_GT|WO_GE) ){
130246 testcase( eOp & WO_GT );
130247 testcase( eOp & WO_GE );
130248 pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
130249 pNew->u.btree.nBtm = whereRangeVectorLen(
130250 pParse, pSrc->iCursor, pProbe, saved_nEq, pTerm
130251 );
130252 pBtm = pTerm;
130253 pTop = 0;
130254 if( pTerm->wtFlags & TERM_LIKEOPT ){
130255 /* Range contraints that come from the LIKE optimization are
130256 ** always used in pairs. */
@@ -129066,16 +130259,20 @@
130259 assert( pTop->wtFlags & TERM_LIKEOPT );
130260 assert( pTop->eOperator==WO_LT );
130261 if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
130262 pNew->aLTerm[pNew->nLTerm++] = pTop;
130263 pNew->wsFlags |= WHERE_TOP_LIMIT;
130264 pNew->u.btree.nTop = 1;
130265 }
130266 }else{
130267 assert( eOp & (WO_LT|WO_LE) );
130268 testcase( eOp & WO_LT );
130269 testcase( eOp & WO_LE );
130270 pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_TOP_LIMIT;
130271 pNew->u.btree.nTop = whereRangeVectorLen(
130272 pParse, pSrc->iCursor, pProbe, saved_nEq, pTerm
130273 );
130274 pTop = pTerm;
130275 pBtm = (pNew->wsFlags & WHERE_BTM_LIMIT)!=0 ?
130276 pNew->aLTerm[pNew->nLTerm-2] : 0;
130277 }
130278
@@ -129171,10 +130368,12 @@
130368 pBuilder->nRecValid = nRecValid;
130369 #endif
130370 }
130371 pNew->prereq = saved_prereq;
130372 pNew->u.btree.nEq = saved_nEq;
130373 pNew->u.btree.nBtm = saved_nBtm;
130374 pNew->u.btree.nTop = saved_nTop;
130375 pNew->nSkip = saved_nSkip;
130376 pNew->wsFlags = saved_wsFlags;
130377 pNew->nOut = saved_nOut;
130378 pNew->nLTerm = saved_nLTerm;
130379
@@ -129292,11 +130491,11 @@
130491 return 0;
130492 }
130493
130494 /*
130495 ** Add all WhereLoop objects for a single table of the join where the table
130496 ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be
130497 ** a b-tree table, not a virtual table.
130498 **
130499 ** The costs (WhereLoop.rRun) of the b-tree loops added by this function
130500 ** are calculated as follows:
130501 **
@@ -129446,10 +130645,12 @@
130645 testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
130646 continue; /* Partial index inappropriate for this query */
130647 }
130648 rSize = pProbe->aiRowLogEst[0];
130649 pNew->u.btree.nEq = 0;
130650 pNew->u.btree.nBtm = 0;
130651 pNew->u.btree.nTop = 0;
130652 pNew->nSkip = 0;
130653 pNew->nLTerm = 0;
130654 pNew->iSortIdx = 0;
130655 pNew->rSetup = 0;
130656 pNew->prereq = mPrereq;
@@ -129574,10 +130775,11 @@
130775 WhereLoopBuilder *pBuilder,
130776 Bitmask mPrereq, /* Mask of tables that must be used. */
130777 Bitmask mUsable, /* Mask of usable tables */
130778 u16 mExclude, /* Exclude terms using these operators */
130779 sqlite3_index_info *pIdxInfo, /* Populated object for xBestIndex */
130780 u16 mNoOmit, /* Do not omit these constraints */
130781 int *pbIn /* OUT: True if plan uses an IN(...) op */
130782 ){
130783 WhereClause *pWC = pBuilder->pWC;
130784 struct sqlite3_index_constraint *pIdxCons;
130785 struct sqlite3_index_constraint_usage *pUsage = pIdxInfo->aConstraintUsage;
@@ -129662,10 +130864,11 @@
130864 pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;
130865 *pbIn = 1; assert( (mExclude & WO_IN)==0 );
130866 }
130867 }
130868 }
130869 pNew->u.vtab.omitMask &= ~mNoOmit;
130870
130871 pNew->nLTerm = mxTerm+1;
130872 assert( pNew->nLTerm<=pNew->nLSlot );
130873 pNew->u.vtab.idxNum = pIdxInfo->idxNum;
130874 pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr;
@@ -129735,19 +130938,21 @@
130938 sqlite3_index_info *p; /* Object to pass to xBestIndex() */
130939 int nConstraint; /* Number of constraints in p */
130940 int bIn; /* True if plan uses IN(...) operator */
130941 WhereLoop *pNew;
130942 Bitmask mBest; /* Tables used by best possible plan */
130943 u16 mNoOmit;
130944
130945 assert( (mPrereq & mUnusable)==0 );
130946 pWInfo = pBuilder->pWInfo;
130947 pParse = pWInfo->pParse;
130948 pWC = pBuilder->pWC;
130949 pNew = pBuilder->pNew;
130950 pSrc = &pWInfo->pTabList->a[pNew->iTab];
130951 assert( IsVirtual(pSrc->pTab) );
130952 p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy,
130953 &mNoOmit);
130954 if( p==0 ) return SQLITE_NOMEM_BKPT;
130955 pNew->rSetup = 0;
130956 pNew->wsFlags = WHERE_VIRTUALTABLE;
130957 pNew->nLTerm = 0;
130958 pNew->u.vtab.needFree = 0;
@@ -129757,11 +130962,11 @@
130962 return SQLITE_NOMEM_BKPT;
130963 }
130964
130965 /* First call xBestIndex() with all constraints usable. */
130966 WHERETRACE(0x40, (" VirtualOne: all usable\n"));
130967 rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);
130968
130969 /* If the call to xBestIndex() with all terms enabled produced a plan
130970 ** that does not require any source tables (IOW: a plan with mBest==0),
130971 ** then there is no point in making any further calls to xBestIndex()
130972 ** since they will all return the same result (if the xBestIndex()
@@ -129774,11 +130979,12 @@
130979
130980 /* If the plan produced by the earlier call uses an IN(...) term, call
130981 ** xBestIndex again, this time with IN(...) terms disabled. */
130982 if( bIn ){
130983 WHERETRACE(0x40, (" VirtualOne: all usable w/o IN\n"));
130984 rc = whereLoopAddVirtualOne(
130985 pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn);
130986 assert( bIn==0 );
130987 mBestNoIn = pNew->prereq & ~mPrereq;
130988 if( mBestNoIn==0 ){
130989 seenZero = 1;
130990 seenZeroNoIN = 1;
@@ -129800,11 +131006,12 @@
131006 mPrev = mNext;
131007 if( mNext==ALLBITS ) break;
131008 if( mNext==mBest || mNext==mBestNoIn ) continue;
131009 WHERETRACE(0x40, (" VirtualOne: mPrev=%04llx mNext=%04llx\n",
131010 (sqlite3_uint64)mPrev, (sqlite3_uint64)mNext));
131011 rc = whereLoopAddVirtualOne(
131012 pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn);
131013 if( pNew->prereq==mPrereq ){
131014 seenZero = 1;
131015 if( bIn==0 ) seenZeroNoIN = 1;
131016 }
131017 }
@@ -129812,20 +131019,22 @@
131019 /* If the calls to xBestIndex() in the above loop did not find a plan
131020 ** that requires no source tables at all (i.e. one guaranteed to be
131021 ** usable), make a call here with all source tables disabled */
131022 if( rc==SQLITE_OK && seenZero==0 ){
131023 WHERETRACE(0x40, (" VirtualOne: all disabled\n"));
131024 rc = whereLoopAddVirtualOne(
131025 pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn);
131026 if( bIn==0 ) seenZeroNoIN = 1;
131027 }
131028
131029 /* If the calls to xBestIndex() have so far failed to find a plan
131030 ** that requires no source tables at all and does not use an IN(...)
131031 ** operator, make a final call to obtain one here. */
131032 if( rc==SQLITE_OK && seenZeroNoIN==0 ){
131033 WHERETRACE(0x40, (" VirtualOne: all disabled and w/o IN\n"));
131034 rc = whereLoopAddVirtualOne(
131035 pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn);
131036 }
131037 }
131038
131039 if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);
131040 sqlite3DbFree(pParse->db, p);
@@ -130121,10 +131330,18 @@
131330 if( pOBExpr->op!=TK_COLUMN ) continue;
131331 if( pOBExpr->iTable!=iCur ) continue;
131332 pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
131333 ~ready, eqOpMask, 0);
131334 if( pTerm==0 ) continue;
131335 if( pTerm->eOperator==WO_IN ){
131336 /* IN terms are only valid for sorting in the ORDER BY LIMIT
131337 ** optimization, and then only if they are actually used
131338 ** by the query plan */
131339 assert( wctrlFlags & WHERE_ORDERBY_LIMIT );
131340 for(j=0; j<pLoop->nLTerm && pTerm!=pLoop->aLTerm[j]; j++){}
131341 if( j>=pLoop->nLTerm ) continue;
131342 }
131343 if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){
131344 const char *z1, *z2;
131345 pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
131346 if( !pColl ) pColl = db->pDfltColl;
131347 z1 = pColl->zName;
@@ -130157,24 +131374,46 @@
131374 ** that are not constrained by == or IN.
131375 */
131376 rev = revSet = 0;
131377 distinctColumns = 0;
131378 for(j=0; j<nColumn; j++){
131379 u8 bOnce = 1; /* True to run the ORDER BY search loop */
131380
131381 assert( j>=pLoop->u.btree.nEq
131382 || (pLoop->aLTerm[j]==0)==(j<pLoop->nSkip)
131383 );
131384 if( j<pLoop->u.btree.nEq && j>=pLoop->nSkip ){
131385 u16 eOp = pLoop->aLTerm[j]->eOperator;
131386
131387 /* Skip over == and IS and ISNULL terms. (Also skip IN terms when
131388 ** doing WHERE_ORDERBY_LIMIT processing).
131389 **
131390 ** If the current term is a column of an ((?,?) IN (SELECT...))
131391 ** expression for which the SELECT returns more than one column,
131392 ** check that it is the only column used by this loop. Otherwise,
131393 ** if it is one of two or more, none of the columns can be
131394 ** considered to match an ORDER BY term. */
131395 if( (eOp & eqOpMask)!=0 ){
131396 if( eOp & WO_ISNULL ){
131397 testcase( isOrderDistinct );
131398 isOrderDistinct = 0;
131399 }
131400 continue;
131401 }else if( ALWAYS(eOp & WO_IN) ){
131402 /* ALWAYS() justification: eOp is an equality operator due to the
131403 ** j<pLoop->u.btree.nEq constraint above. Any equality other
131404 ** than WO_IN is captured by the previous "if". So this one
131405 ** always has to be WO_IN. */
131406 Expr *pX = pLoop->aLTerm[j]->pExpr;
131407 for(i=j+1; i<pLoop->u.btree.nEq; i++){
131408 if( pLoop->aLTerm[i]->pExpr==pX ){
131409 assert( (pLoop->aLTerm[i]->eOperator & WO_IN) );
131410 bOnce = 0;
131411 break;
131412 }
131413 }
131414 }
131415 }
131416
131417 /* Get the column number in the table (iColumn) and sort order
131418 ** (revIdx) for the j-th column of the index.
131419 */
@@ -130199,11 +131438,10 @@
131438 }
131439
131440 /* Find the ORDER BY term that corresponds to the j-th column
131441 ** of the index and mark that ORDER BY term off
131442 */
 
131443 isMatch = 0;
131444 for(i=0; bOnce && i<nOrderBy; i++){
131445 if( MASKBIT(i) & obSat ) continue;
131446 pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
131447 testcase( wctrlFlags & WHERE_GROUPBY );
@@ -131393,14 +132631,16 @@
132631 struct InLoop *pIn;
132632 int j;
132633 sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
132634 for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
132635 sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
132636 if( pIn->eEndLoopOp!=OP_Noop ){
132637 sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
132638 VdbeCoverage(v);
132639 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
132640 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
132641 }
132642 sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
132643 }
132644 }
132645 sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
132646 if( pLevel->addrSkip ){
@@ -131843,20 +133083,20 @@
133083 #define sqlite3ParserARG_SDECL Parse *pParse;
133084 #define sqlite3ParserARG_PDECL ,Parse *pParse
133085 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
133086 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
133087 #define YYFALLBACK 1
133088 #define YYNSTATE 456
133089 #define YYNRULE 331
133090 #define YY_MAX_SHIFT 455
133091 #define YY_MIN_SHIFTREDUCE 667
133092 #define YY_MAX_SHIFTREDUCE 997
133093 #define YY_MIN_REDUCE 998
133094 #define YY_MAX_REDUCE 1328
133095 #define YY_ERROR_ACTION 1329
133096 #define YY_ACCEPT_ACTION 1330
133097 #define YY_NO_ACTION 1331
133098 /************* End control #defines *******************************************/
133099
133100 /* Define the yytestcase() macro to be a no-op if is not already defined
133101 ** otherwise.
133102 **
@@ -131924,163 +133164,170 @@
133164 ** yy_reduce_ofst[] For each state, the offset into yy_action for
133165 ** shifting non-terminals after a reduce.
133166 ** yy_default[] Default action for each state.
133167 **
133168 *********** Begin parsing tables **********************************************/
133169 #define YY_ACTTAB_COUNT (1571)
133170 static const YYACTIONTYPE yy_action[] = {
133171 /* 0 */ 325, 830, 351, 824, 5, 203, 203, 818, 99, 100,
133172 /* 10 */ 90, 840, 840, 852, 855, 844, 844, 97, 97, 98,
133173 /* 20 */ 98, 98, 98, 301, 96, 96, 96, 96, 95, 95,
133174 /* 30 */ 94, 94, 94, 93, 351, 325, 975, 975, 823, 823,
133175 /* 40 */ 823, 945, 354, 99, 100, 90, 840, 840, 852, 855,
133176 /* 50 */ 844, 844, 97, 97, 98, 98, 98, 98, 338, 96,
133177 /* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
133178 /* 70 */ 95, 95, 94, 94, 94, 93, 351, 790, 975, 975,
133179 /* 80 */ 325, 94, 94, 94, 93, 351, 791, 75, 99, 100,
133180 /* 90 */ 90, 840, 840, 852, 855, 844, 844, 97, 97, 98,
133181 /* 100 */ 98, 98, 98, 450, 96, 96, 96, 96, 95, 95,
133182 /* 110 */ 94, 94, 94, 93, 351, 1330, 155, 155, 2, 325,
133183 /* 120 */ 275, 146, 132, 52, 52, 93, 351, 99, 100, 90,
133184 /* 130 */ 840, 840, 852, 855, 844, 844, 97, 97, 98, 98,
133185 /* 140 */ 98, 98, 101, 96, 96, 96, 96, 95, 95, 94,
133186 /* 150 */ 94, 94, 93, 351, 956, 956, 325, 268, 428, 413,
133187 /* 160 */ 411, 61, 751, 751, 99, 100, 90, 840, 840, 852,
133188 /* 170 */ 855, 844, 844, 97, 97, 98, 98, 98, 98, 60,
133189 /* 180 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133190 /* 190 */ 351, 325, 270, 329, 273, 277, 957, 958, 250, 99,
133191 /* 200 */ 100, 90, 840, 840, 852, 855, 844, 844, 97, 97,
133192 /* 210 */ 98, 98, 98, 98, 301, 96, 96, 96, 96, 95,
133193 /* 220 */ 95, 94, 94, 94, 93, 351, 325, 936, 1323, 697,
133194 /* 230 */ 705, 1323, 242, 412, 99, 100, 90, 840, 840, 852,
133195 /* 240 */ 855, 844, 844, 97, 97, 98, 98, 98, 98, 347,
133196 /* 250 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133197 /* 260 */ 351, 325, 936, 1324, 384, 698, 1324, 381, 379, 99,
133198 /* 270 */ 100, 90, 840, 840, 852, 855, 844, 844, 97, 97,
133199 /* 280 */ 98, 98, 98, 98, 700, 96, 96, 96, 96, 95,
133200 /* 290 */ 95, 94, 94, 94, 93, 351, 325, 92, 89, 178,
133201 /* 300 */ 831, 934, 373, 699, 99, 100, 90, 840, 840, 852,
133202 /* 310 */ 855, 844, 844, 97, 97, 98, 98, 98, 98, 375,
133203 /* 320 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133204 /* 330 */ 351, 325, 1273, 945, 354, 817, 934, 738, 738, 99,
133205 /* 340 */ 100, 90, 840, 840, 852, 855, 844, 844, 97, 97,
133206 /* 350 */ 98, 98, 98, 98, 230, 96, 96, 96, 96, 95,
133207 /* 360 */ 95, 94, 94, 94, 93, 351, 325, 967, 227, 92,
133208 /* 370 */ 89, 178, 373, 300, 99, 100, 90, 840, 840, 852,
133209 /* 380 */ 855, 844, 844, 97, 97, 98, 98, 98, 98, 919,
133210 /* 390 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133211 /* 400 */ 351, 325, 449, 447, 447, 447, 147, 736, 736, 99,
133212 /* 410 */ 100, 90, 840, 840, 852, 855, 844, 844, 97, 97,
133213 /* 420 */ 98, 98, 98, 98, 296, 96, 96, 96, 96, 95,
133214 /* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 956,
133215 /* 440 */ 956, 158, 25, 422, 99, 100, 90, 840, 840, 852,
133216 /* 450 */ 855, 844, 844, 97, 97, 98, 98, 98, 98, 450,
133217 /* 460 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133218 /* 470 */ 351, 443, 224, 224, 420, 956, 956, 960, 325, 52,
133219 /* 480 */ 52, 957, 958, 176, 415, 78, 99, 100, 90, 840,
133220 /* 490 */ 840, 852, 855, 844, 844, 97, 97, 98, 98, 98,
133221 /* 500 */ 98, 379, 96, 96, 96, 96, 95, 95, 94, 94,
133222 /* 510 */ 94, 93, 351, 325, 428, 418, 298, 957, 958, 960,
133223 /* 520 */ 81, 99, 88, 90, 840, 840, 852, 855, 844, 844,
133224 /* 530 */ 97, 97, 98, 98, 98, 98, 716, 96, 96, 96,
133225 /* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 841,
133226 /* 550 */ 841, 853, 856, 994, 318, 343, 379, 100, 90, 840,
133227 /* 560 */ 840, 852, 855, 844, 844, 97, 97, 98, 98, 98,
133228 /* 570 */ 98, 450, 96, 96, 96, 96, 95, 95, 94, 94,
133229 /* 580 */ 94, 93, 351, 325, 350, 350, 350, 260, 377, 340,
133230 /* 590 */ 927, 52, 52, 90, 840, 840, 852, 855, 844, 844,
133231 /* 600 */ 97, 97, 98, 98, 98, 98, 361, 96, 96, 96,
133232 /* 610 */ 96, 95, 95, 94, 94, 94, 93, 351, 86, 445,
133233 /* 620 */ 845, 3, 1200, 361, 360, 378, 344, 812, 956, 956,
133234 /* 630 */ 1297, 86, 445, 728, 3, 212, 169, 287, 405, 282,
133235 /* 640 */ 404, 199, 232, 450, 300, 759, 83, 84, 280, 245,
133236 /* 650 */ 262, 365, 251, 85, 352, 352, 92, 89, 178, 83,
133237 /* 660 */ 84, 242, 412, 52, 52, 448, 85, 352, 352, 246,
133238 /* 670 */ 957, 958, 194, 455, 669, 402, 399, 398, 448, 243,
133239 /* 680 */ 221, 114, 434, 775, 361, 450, 397, 268, 746, 224,
133240 /* 690 */ 224, 132, 132, 198, 830, 434, 452, 451, 428, 427,
133241 /* 700 */ 818, 415, 733, 712, 132, 52, 52, 830, 268, 452,
133242 /* 710 */ 451, 733, 194, 818, 363, 402, 399, 398, 450, 1268,
133243 /* 720 */ 1268, 23, 956, 956, 86, 445, 397, 3, 228, 429,
133244 /* 730 */ 893, 823, 823, 823, 825, 19, 203, 719, 52, 52,
133245 /* 740 */ 428, 408, 439, 249, 823, 823, 823, 825, 19, 229,
133246 /* 750 */ 403, 153, 83, 84, 760, 177, 241, 450, 720, 85,
133247 /* 760 */ 352, 352, 120, 157, 957, 958, 58, 975, 409, 355,
133248 /* 770 */ 330, 448, 268, 428, 430, 320, 789, 32, 32, 86,
133249 /* 780 */ 445, 775, 3, 341, 98, 98, 98, 98, 434, 96,
133250 /* 790 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
133251 /* 800 */ 830, 120, 452, 451, 812, 885, 818, 83, 84, 975,
133252 /* 810 */ 812, 132, 410, 918, 85, 352, 352, 132, 407, 788,
133253 /* 820 */ 956, 956, 92, 89, 178, 915, 448, 262, 370, 261,
133254 /* 830 */ 82, 912, 80, 262, 370, 261, 932, 823, 823, 823,
133255 /* 840 */ 825, 19, 257, 434, 96, 96, 96, 96, 95, 95,
133256 /* 850 */ 94, 94, 94, 93, 351, 830, 268, 452, 451, 956,
133257 /* 860 */ 956, 818, 957, 958, 120, 92, 89, 178, 943, 2,
133258 /* 870 */ 916, 963, 268, 1, 766, 76, 445, 761, 3, 707,
133259 /* 880 */ 899, 899, 387, 956, 956, 756, 917, 371, 739, 777,
133260 /* 890 */ 755, 907, 823, 823, 823, 825, 19, 883, 740, 450,
133261 /* 900 */ 24, 957, 958, 83, 84, 369, 956, 956, 708, 226,
133262 /* 910 */ 85, 352, 352, 745, 315, 314, 313, 215, 311, 10,
133263 /* 920 */ 10, 682, 448, 349, 348, 957, 958, 887, 776, 691,
133264 /* 930 */ 331, 956, 956, 337, 157, 450, 268, 103, 450, 434,
133265 /* 940 */ 450, 816, 310, 906, 887, 889, 321, 450, 957, 958,
133266 /* 950 */ 708, 830, 775, 452, 451, 10, 10, 818, 10, 10,
133267 /* 960 */ 52, 52, 171, 170, 180, 225, 248, 10, 10, 339,
133268 /* 970 */ 701, 701, 233, 957, 958, 247, 982, 741, 450, 956,
133269 /* 980 */ 956, 425, 157, 980, 685, 981, 182, 912, 823, 823,
133270 /* 990 */ 823, 825, 19, 183, 324, 423, 132, 181, 51, 51,
133271 /* 1000 */ 715, 349, 348, 394, 256, 887, 334, 915, 983, 983,
133272 /* 1010 */ 830, 417, 824, 234, 198, 234, 818, 268, 326, 382,
133273 /* 1020 */ 120, 957, 958, 264, 177, 98, 98, 98, 98, 91,
133274 /* 1030 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
133275 /* 1040 */ 351, 816, 416, 371, 120, 359, 816, 823, 823, 823,
133276 /* 1050 */ 775, 299, 916, 450, 368, 197, 196, 195, 358, 200,
133277 /* 1060 */ 175, 380, 9, 9, 450, 1287, 875, 714, 917, 450,
133278 /* 1070 */ 433, 237, 450, 36, 36, 132, 253, 450, 255, 450,
133279 /* 1080 */ 117, 450, 809, 362, 37, 37, 983, 983, 450, 12,
133280 /* 1090 */ 12, 330, 27, 27, 446, 331, 280, 38, 38, 39,
133281 /* 1100 */ 39, 40, 40, 1207, 450, 816, 335, 356, 41, 41,
133282 /* 1110 */ 450, 336, 450, 695, 450, 120, 450, 332, 133, 450,
133283 /* 1120 */ 268, 450, 269, 450, 42, 42, 450, 816, 254, 450,
133284 /* 1130 */ 28, 28, 29, 29, 31, 31, 43, 43, 450, 44,
133285 /* 1140 */ 44, 45, 45, 11, 11, 450, 46, 46, 450, 105,
133286 /* 1150 */ 105, 450, 748, 713, 450, 695, 450, 910, 47, 47,
133287 /* 1160 */ 450, 267, 450, 415, 450, 48, 48, 450, 33, 33,
133288 /* 1170 */ 386, 49, 49, 450, 50, 50, 34, 34, 450, 172,
133289 /* 1180 */ 122, 122, 123, 123, 124, 124, 450, 56, 56, 450,
133290 /* 1190 */ 120, 450, 345, 35, 35, 450, 790, 450, 106, 106,
133291 /* 1200 */ 450, 74, 450, 974, 450, 791, 53, 53, 432, 107,
133292 /* 1210 */ 107, 108, 108, 450, 272, 104, 104, 121, 121, 450,
133293 /* 1220 */ 119, 119, 112, 112, 111, 111, 450, 317, 996, 450,
133294 /* 1230 */ 118, 450, 162, 109, 109, 317, 935, 450, 896, 110,
133295 /* 1240 */ 110, 450, 895, 744, 688, 436, 55, 55, 20, 57,
133296 /* 1250 */ 57, 54, 54, 440, 444, 756, 385, 26, 26, 274,
133297 /* 1260 */ 755, 30, 30, 21, 672, 673, 674, 223, 175, 931,
133298 /* 1270 */ 814, 372, 319, 202, 202, 882, 120, 120, 120, 374,
133299 /* 1280 */ 826, 710, 202, 72, 276, 263, 120, 120, 74, 395,
133300 /* 1290 */ 278, 286, 208, 74, 718, 717, 725, 726, 892, 892,
133301 /* 1300 */ 167, 997, 285, 753, 729, 784, 77, 878, 202, 997,
133302 /* 1310 */ 208, 693, 891, 891, 116, 281, 782, 882, 390, 815,
133303 /* 1320 */ 762, 773, 826, 431, 302, 303, 822, 218, 696, 289,
133304 /* 1330 */ 690, 291, 293, 679, 678, 680, 950, 159, 316, 7,
133305 /* 1340 */ 364, 252, 259, 804, 909, 376, 400, 295, 308, 173,
133306 /* 1350 */ 435, 953, 168, 991, 135, 205, 926, 924, 59, 988,
133307 /* 1360 */ 62, 284, 880, 333, 879, 712, 144, 156, 130, 72,
133308 /* 1370 */ 366, 367, 393, 185, 189, 160, 383, 67, 389, 266,
133309 /* 1380 */ 137, 894, 774, 219, 154, 139, 190, 140, 391, 271,
133310 /* 1390 */ 191, 141, 142, 801, 681, 148, 811, 342, 322, 192,
133311 /* 1400 */ 406, 732, 911, 874, 723, 731, 323, 710, 730, 71,
133312 /* 1410 */ 704, 204, 283, 703, 6, 79, 421, 702, 965, 770,
133313 /* 1420 */ 297, 346, 426, 102, 722, 288, 73, 424, 213, 951,
133314 /* 1430 */ 771, 438, 22, 290, 687, 769, 442, 453, 239, 217,
133315 /* 1440 */ 214, 668, 125, 353, 126, 216, 454, 166, 676, 115,
133316 /* 1450 */ 675, 235, 244, 179, 670, 357, 810, 113, 890, 888,
133317 /* 1460 */ 292, 136, 128, 752, 304, 768, 294, 305, 138, 742,
133318 /* 1470 */ 306, 307, 127, 184, 860, 258, 905, 145, 143, 238,
133319 /* 1480 */ 63, 64, 65, 66, 240, 129, 908, 186, 187, 904,
133320 /* 1490 */ 8, 13, 188, 265, 897, 149, 202, 985, 388, 684,
133321 /* 1500 */ 150, 161, 392, 285, 193, 279, 151, 396, 68, 14,
133322 /* 1510 */ 401, 15, 327, 721, 328, 134, 69, 70, 236, 131,
133323 /* 1520 */ 829, 828, 858, 750, 16, 201, 754, 4, 783, 220,
133324 /* 1530 */ 414, 174, 222, 152, 77, 778, 74, 17, 18, 873,
133325 /* 1540 */ 859, 857, 914, 862, 913, 207, 206, 940, 163, 437,
133326 /* 1550 */ 946, 941, 164, 209, 210, 441, 861, 165, 312, 827,
133327 /* 1560 */ 694, 87, 1000, 309, 211, 1000, 1000, 1000, 1000, 1289,
133328 /* 1570 */ 1288,
133329 };
133330 static const YYCODETYPE yy_lookahead[] = {
133331 /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
133332 /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
133333 /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
@@ -132091,285 +133338,295 @@
133338 /* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97,
133339 /* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28,
133340 /* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
133341 /* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
133342 /* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19,
133343 /* 120 */ 16, 22, 92, 172, 173, 52, 53, 27, 28, 29,
133344 /* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
133345 /* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49,
133346 /* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208,
133347 /* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32,
133348 /* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79,
133349 /* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
133350 /* 190 */ 53, 19, 88, 157, 90, 23, 97, 98, 193, 27,
133351 /* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
133352 /* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
133353 /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 172,
133354 /* 230 */ 23, 26, 119, 120, 27, 28, 29, 30, 31, 32,
133355 /* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187,
133356 /* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
133357 /* 260 */ 53, 19, 22, 23, 228, 23, 26, 231, 152, 27,
133358 /* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
133359 /* 280 */ 38, 39, 40, 41, 172, 43, 44, 45, 46, 47,
133360 /* 290 */ 48, 49, 50, 51, 52, 53, 19, 221, 222, 223,
133361 /* 300 */ 23, 96, 152, 172, 27, 28, 29, 30, 31, 32,
133362 /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 152,
133363 /* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
133364 /* 330 */ 53, 19, 0, 1, 2, 23, 96, 190, 191, 27,
133365 /* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
133366 /* 350 */ 38, 39, 40, 41, 238, 43, 44, 45, 46, 47,
133367 /* 360 */ 48, 49, 50, 51, 52, 53, 19, 185, 218, 221,
133368 /* 370 */ 222, 223, 152, 152, 27, 28, 29, 30, 31, 32,
133369 /* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 241,
133370 /* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
133371 /* 400 */ 53, 19, 152, 168, 169, 170, 22, 190, 191, 27,
133372 /* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
133373 /* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47,
133374 /* 430 */ 48, 49, 50, 51, 52, 53, 19, 19, 218, 55,
133375 /* 440 */ 56, 24, 22, 152, 27, 28, 29, 30, 31, 32,
133376 /* 450 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 152,
133377 /* 460 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
133378 /* 470 */ 53, 250, 194, 195, 56, 55, 56, 55, 19, 172,
133379 /* 480 */ 173, 97, 98, 152, 206, 138, 27, 28, 29, 30,
133380 /* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
133381 /* 500 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50,
133382 /* 510 */ 51, 52, 53, 19, 207, 208, 152, 97, 98, 97,
133383 /* 520 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35,
133384 /* 530 */ 36, 37, 38, 39, 40, 41, 181, 43, 44, 45,
133385 /* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 30,
133386 /* 550 */ 31, 32, 33, 247, 248, 19, 152, 28, 29, 30,
133387 /* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
133388 /* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50,
133389 /* 580 */ 51, 52, 53, 19, 168, 169, 170, 238, 19, 53,
133390 /* 590 */ 152, 172, 173, 29, 30, 31, 32, 33, 34, 35,
133391 /* 600 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45,
133392 /* 610 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 20,
133393 /* 620 */ 101, 22, 23, 169, 170, 56, 207, 85, 55, 56,
133394 /* 630 */ 23, 19, 20, 26, 22, 99, 100, 101, 102, 103,
133395 /* 640 */ 104, 105, 238, 152, 152, 210, 47, 48, 112, 152,
133396 /* 650 */ 108, 109, 110, 54, 55, 56, 221, 222, 223, 47,
133397 /* 660 */ 48, 119, 120, 172, 173, 66, 54, 55, 56, 152,
133398 /* 670 */ 97, 98, 99, 148, 149, 102, 103, 104, 66, 154,
133399 /* 680 */ 23, 156, 83, 26, 230, 152, 113, 152, 163, 194,
133400 /* 690 */ 195, 92, 92, 30, 95, 83, 97, 98, 207, 208,
133401 /* 700 */ 101, 206, 179, 180, 92, 172, 173, 95, 152, 97,
133402 /* 710 */ 98, 188, 99, 101, 219, 102, 103, 104, 152, 119,
133403 /* 720 */ 120, 196, 55, 56, 19, 20, 113, 22, 193, 163,
133404 /* 730 */ 11, 132, 133, 134, 135, 136, 24, 65, 172, 173,
133405 /* 740 */ 207, 208, 250, 152, 132, 133, 134, 135, 136, 193,
133406 /* 750 */ 78, 84, 47, 48, 49, 98, 199, 152, 86, 54,
133407 /* 760 */ 55, 56, 196, 152, 97, 98, 209, 55, 163, 244,
133408 /* 770 */ 107, 66, 152, 207, 208, 164, 175, 172, 173, 19,
133409 /* 780 */ 20, 124, 22, 111, 38, 39, 40, 41, 83, 43,
133410 /* 790 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
133411 /* 800 */ 95, 196, 97, 98, 85, 152, 101, 47, 48, 97,
133412 /* 810 */ 85, 92, 207, 193, 54, 55, 56, 92, 49, 175,
133413 /* 820 */ 55, 56, 221, 222, 223, 12, 66, 108, 109, 110,
133414 /* 830 */ 137, 163, 139, 108, 109, 110, 152, 132, 133, 134,
133415 /* 840 */ 135, 136, 152, 83, 43, 44, 45, 46, 47, 48,
133416 /* 850 */ 49, 50, 51, 52, 53, 95, 152, 97, 98, 55,
133417 /* 860 */ 56, 101, 97, 98, 196, 221, 222, 223, 146, 147,
133418 /* 870 */ 57, 171, 152, 22, 213, 19, 20, 49, 22, 179,
133419 /* 880 */ 108, 109, 110, 55, 56, 116, 73, 219, 75, 124,
133420 /* 890 */ 121, 152, 132, 133, 134, 135, 136, 193, 85, 152,
133421 /* 900 */ 232, 97, 98, 47, 48, 237, 55, 56, 55, 5,
133422 /* 910 */ 54, 55, 56, 193, 10, 11, 12, 13, 14, 172,
133423 /* 920 */ 173, 17, 66, 47, 48, 97, 98, 152, 124, 166,
133424 /* 930 */ 167, 55, 56, 186, 152, 152, 152, 22, 152, 83,
133425 /* 940 */ 152, 152, 160, 152, 169, 170, 164, 152, 97, 98,
133426 /* 950 */ 97, 95, 26, 97, 98, 172, 173, 101, 172, 173,
133427 /* 960 */ 172, 173, 47, 48, 60, 22, 62, 172, 173, 186,
133428 /* 970 */ 55, 56, 186, 97, 98, 71, 100, 193, 152, 55,
133429 /* 980 */ 56, 186, 152, 107, 21, 109, 82, 163, 132, 133,
133430 /* 990 */ 134, 135, 136, 89, 164, 207, 92, 93, 172, 173,
133431 /* 1000 */ 181, 47, 48, 19, 16, 230, 217, 12, 132, 133,
133432 /* 1010 */ 95, 163, 97, 183, 30, 185, 101, 152, 114, 152,
133433 /* 1020 */ 196, 97, 98, 152, 98, 38, 39, 40, 41, 42,
133434 /* 1030 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
133435 /* 1040 */ 53, 152, 152, 219, 196, 141, 152, 132, 133, 134,
133436 /* 1050 */ 124, 225, 57, 152, 91, 108, 109, 110, 193, 211,
133437 /* 1060 */ 212, 237, 172, 173, 152, 122, 103, 181, 73, 152,
133438 /* 1070 */ 75, 210, 152, 172, 173, 92, 88, 152, 90, 152,
133439 /* 1080 */ 22, 152, 163, 100, 172, 173, 132, 133, 152, 172,
133440 /* 1090 */ 173, 107, 172, 173, 166, 167, 112, 172, 173, 172,
133441 /* 1100 */ 173, 172, 173, 140, 152, 152, 217, 242, 172, 173,
133442 /* 1110 */ 152, 217, 152, 55, 152, 196, 152, 245, 246, 152,
133443 /* 1120 */ 152, 152, 152, 152, 172, 173, 152, 152, 140, 152,
133444 /* 1130 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 172,
133445 /* 1140 */ 173, 172, 173, 172, 173, 152, 172, 173, 152, 172,
133446 /* 1150 */ 173, 152, 195, 152, 152, 97, 152, 163, 172, 173,
133447 /* 1160 */ 152, 193, 152, 206, 152, 172, 173, 152, 172, 173,
133448 /* 1170 */ 217, 172, 173, 152, 172, 173, 172, 173, 152, 26,
133449 /* 1180 */ 172, 173, 172, 173, 172, 173, 152, 172, 173, 152,
133450 /* 1190 */ 196, 152, 217, 172, 173, 152, 61, 152, 172, 173,
133451 /* 1200 */ 152, 26, 152, 26, 152, 70, 172, 173, 191, 172,
133452 /* 1210 */ 173, 172, 173, 152, 152, 172, 173, 172, 173, 152,
133453 /* 1220 */ 172, 173, 172, 173, 172, 173, 152, 22, 23, 152,
133454 /* 1230 */ 22, 152, 24, 172, 173, 22, 23, 152, 59, 172,
133455 /* 1240 */ 173, 152, 63, 163, 163, 163, 172, 173, 22, 172,
133456 /* 1250 */ 173, 172, 173, 163, 163, 116, 77, 172, 173, 152,
133457 /* 1260 */ 121, 172, 173, 37, 7, 8, 9, 211, 212, 23,
133458 /* 1270 */ 23, 23, 26, 26, 26, 55, 196, 196, 196, 23,
133459 /* 1280 */ 55, 106, 26, 130, 152, 23, 196, 196, 26, 23,
133460 /* 1290 */ 23, 101, 26, 26, 100, 101, 7, 8, 132, 133,
133461 /* 1300 */ 123, 96, 112, 23, 152, 23, 26, 23, 26, 96,
133462 /* 1310 */ 26, 23, 132, 133, 26, 152, 152, 97, 234, 152,
133463 /* 1320 */ 152, 152, 97, 152, 152, 152, 152, 233, 152, 210,
133464 /* 1330 */ 152, 210, 210, 152, 152, 152, 152, 197, 150, 198,
133465 /* 1340 */ 214, 214, 239, 201, 201, 239, 176, 214, 200, 184,
133466 /* 1350 */ 227, 155, 198, 67, 243, 122, 159, 159, 240, 69,
133467 /* 1360 */ 240, 175, 175, 159, 175, 180, 22, 220, 27, 130,
133468 /* 1370 */ 18, 159, 18, 158, 158, 220, 159, 137, 74, 235,
133469 /* 1380 */ 189, 236, 159, 159, 22, 192, 158, 192, 177, 159,
133470 /* 1390 */ 158, 192, 192, 201, 159, 189, 189, 76, 177, 158,
133471 /* 1400 */ 107, 174, 201, 201, 182, 174, 177, 106, 174, 107,
133472 /* 1410 */ 174, 159, 174, 176, 22, 137, 125, 174, 174, 216,
133473 /* 1420 */ 159, 53, 126, 129, 182, 215, 128, 127, 25, 13,
133474 /* 1430 */ 216, 177, 26, 215, 162, 216, 177, 161, 229, 6,
133475 /* 1440 */ 153, 4, 165, 3, 165, 153, 151, 22, 151, 178,
133476 /* 1450 */ 151, 178, 142, 15, 151, 94, 120, 16, 23, 23,
133477 /* 1460 */ 215, 131, 111, 205, 204, 216, 215, 203, 123, 20,
133478 /* 1470 */ 202, 201, 165, 125, 224, 16, 1, 131, 123, 226,
133479 /* 1480 */ 37, 37, 37, 37, 229, 111, 56, 64, 122, 1,
133480 /* 1490 */ 5, 22, 107, 140, 80, 80, 26, 87, 72, 20,
133481 /* 1500 */ 107, 24, 19, 112, 105, 23, 22, 79, 22, 22,
133482 /* 1510 */ 79, 22, 249, 58, 249, 246, 22, 26, 79, 68,
133483 /* 1520 */ 23, 23, 23, 116, 22, 64, 23, 22, 56, 23,
133484 /* 1530 */ 26, 122, 23, 22, 26, 124, 26, 64, 64, 23,
133485 /* 1540 */ 23, 23, 23, 11, 23, 22, 26, 23, 22, 24,
133486 /* 1550 */ 1, 23, 22, 26, 122, 24, 23, 22, 15, 23,
133487 /* 1560 */ 23, 22, 251, 23, 122, 251, 251, 251, 251, 122,
133488 /* 1570 */ 122,
133489 };
133490 #define YY_SHIFT_USE_DFLT (1571)
133491 #define YY_SHIFT_COUNT (455)
133492 #define YY_SHIFT_MIN (-94)
133493 #define YY_SHIFT_MAX (1549)
133494 static const short yy_shift_ofst[] = {
133495 /* 0 */ 40, 599, 904, 612, 760, 760, 760, 760, 725, -19,
133496 /* 10 */ 16, 16, 100, 760, 760, 760, 760, 760, 760, 760,
133497 /* 20 */ 876, 876, 573, 542, 719, 600, 61, 137, 172, 207,
133498 /* 30 */ 242, 277, 312, 347, 382, 417, 459, 459, 459, 459,
133499 /* 40 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459,
133500 /* 50 */ 459, 459, 459, 494, 459, 529, 564, 564, 705, 760,
133501 /* 60 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760,
133502 /* 70 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760,
133503 /* 80 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760,
133504 /* 90 */ 856, 760, 760, 760, 760, 760, 760, 760, 760, 760,
133505 /* 100 */ 760, 760, 760, 760, 987, 746, 746, 746, 746, 746,
133506 /* 110 */ 801, 23, 32, 924, 963, 984, 954, 954, 924, 73,
133507 /* 120 */ 113, -51, 1571, 1571, 1571, 536, 536, 536, 99, 99,
133508 /* 130 */ 813, 813, 667, 205, 240, 924, 924, 924, 924, 924,
133509 /* 140 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
133510 /* 150 */ 924, 924, 924, 924, 924, 332, 983, 422, 422, 113,
133511 /* 160 */ 30, 30, 30, 30, 30, 30, 1571, 1571, 1571, 915,
133512 /* 170 */ -94, -94, 384, 613, 828, 420, 765, 804, 851, 924,
133513 /* 180 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924,
133514 /* 190 */ 924, 924, 924, 924, 924, 672, 672, 672, 924, 924,
133515 /* 200 */ 657, 924, 924, 924, -18, 924, 924, 995, 924, 924,
133516 /* 210 */ 924, 924, 924, 924, 924, 924, 924, 924, 772, 1179,
133517 /* 220 */ 712, 712, 712, 926, 45, 769, 1257, 1153, 418, 418,
133518 /* 230 */ 569, 1153, 569, 1175, 607, 663, 1135, 418, 693, 1135,
133519 /* 240 */ 1135, 1177, 1139, 1208, 1286, 1233, 1233, 1290, 1290, 1233,
133520 /* 250 */ 1344, 1341, 1239, 1352, 1352, 1352, 1352, 1233, 1354, 1239,
133521 /* 260 */ 1344, 1341, 1341, 1239, 1233, 1354, 1240, 1304, 1233, 1233,
133522 /* 270 */ 1354, 1362, 1233, 1354, 1233, 1354, 1362, 1293, 1293, 1293,
133523 /* 280 */ 1321, 1362, 1293, 1301, 1293, 1321, 1293, 1293, 1291, 1302,
133524 /* 290 */ 1291, 1302, 1291, 1302, 1291, 1302, 1233, 1392, 1233, 1278,
133525 /* 300 */ 1362, 1368, 1368, 1362, 1294, 1296, 1298, 1300, 1239, 1403,
133526 /* 310 */ 1406, 1416, 1416, 1433, 1433, 1433, 1433, 1571, 1571, 1571,
133527 /* 320 */ 1571, 1571, 1571, 1571, 1571, 519, 988, 1205, 1213, 104,
133528 /* 330 */ 947, 1058, 1246, 1226, 1247, 1248, 1256, 1262, 1266, 1267,
133529 /* 340 */ 853, 1194, 1289, 1190, 1280, 1282, 1220, 1284, 1166, 1180,
133530 /* 350 */ 1288, 1225, 943, 1437, 1440, 1425, 1310, 1438, 1361, 1441,
133531 /* 360 */ 1435, 1436, 1336, 1330, 1351, 1345, 1449, 1348, 1459, 1475,
133532 /* 370 */ 1355, 1346, 1443, 1444, 1445, 1446, 1374, 1430, 1423, 1366,
133533 /* 380 */ 1488, 1485, 1469, 1385, 1353, 1414, 1470, 1415, 1410, 1426,
133534 /* 390 */ 1393, 1477, 1479, 1483, 1391, 1399, 1484, 1428, 1486, 1487,
133535 /* 400 */ 1482, 1489, 1431, 1455, 1494, 1439, 1451, 1497, 1498, 1499,
133536 /* 410 */ 1491, 1407, 1502, 1503, 1505, 1504, 1409, 1506, 1509, 1472,
133537 /* 420 */ 1461, 1511, 1411, 1508, 1473, 1510, 1474, 1516, 1508, 1517,
133538 /* 430 */ 1518, 1519, 1520, 1521, 1523, 1532, 1524, 1526, 1525, 1527,
133539 /* 440 */ 1528, 1530, 1531, 1527, 1533, 1535, 1536, 1537, 1539, 1432,
133540 /* 450 */ 1442, 1447, 1448, 1540, 1543, 1549,
133541 };
133542 #define YY_REDUCE_USE_DFLT (-130)
133543 #define YY_REDUCE_COUNT (324)
133544 #define YY_REDUCE_MIN (-129)
133545 #define YY_REDUCE_MAX (1307)
133546 static const short yy_reduce_ofst[] = {
133547 /* 0 */ -29, 566, 525, 605, -49, 307, 491, 533, 668, 435,
133548 /* 10 */ 601, 644, 148, 747, 783, 786, 419, 788, 795, 826,
133549 /* 20 */ 454, 775, 830, 495, 824, 848, 76, 76, 76, 76,
133550 /* 30 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
133551 /* 40 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
133552 /* 50 */ 76, 76, 76, 76, 76, 76, 76, 76, 890, 901,
133553 /* 60 */ 912, 917, 920, 925, 927, 929, 936, 952, 958, 960,
133554 /* 70 */ 962, 964, 967, 969, 971, 974, 977, 986, 993, 996,
133555 /* 80 */ 999, 1002, 1004, 1008, 1010, 1012, 1015, 1021, 1026, 1034,
133556 /* 90 */ 1037, 1039, 1043, 1045, 1048, 1050, 1052, 1061, 1067, 1074,
133557 /* 100 */ 1077, 1079, 1085, 1089, 76, 76, 76, 76, 76, 76,
133558 /* 110 */ 76, 76, 76, 865, 36, 523, 235, 416, 782, 76,
133559 /* 120 */ 278, 76, 76, 76, 76, 700, 700, 700, 150, 220,
133560 /* 130 */ 147, 217, 221, 306, 306, 611, 5, 535, 556, 620,
133561 /* 140 */ 704, 720, 784, 116, 789, 349, 889, 894, 404, 953,
133562 /* 150 */ 968, -129, 975, 492, 62, 722, 919, 763, 928, 957,
133563 /* 160 */ 994, 1080, 1081, 1082, 1090, 1091, 872, 1056, 557, 57,
133564 /* 170 */ 112, 131, 167, 182, 250, 272, 291, 331, 364, 438,
133565 /* 180 */ 497, 517, 591, 653, 684, 690, 739, 791, 867, 871,
133566 /* 190 */ 970, 1062, 1107, 1132, 1152, 355, 819, 886, 1001, 1163,
133567 /* 200 */ 661, 1164, 1167, 1168, 861, 1169, 1171, 1017, 1172, 1173,
133568 /* 210 */ 1174, 250, 1176, 1178, 1181, 1182, 1183, 1184, 1084, 1094,
133569 /* 220 */ 1119, 1121, 1122, 661, 1140, 1141, 1188, 1142, 1126, 1127,
133570 /* 230 */ 1103, 1143, 1106, 1170, 1165, 1185, 1186, 1133, 1123, 1187,
133571 /* 240 */ 1189, 1148, 1154, 1196, 1111, 1197, 1198, 1118, 1120, 1204,
133572 /* 250 */ 1147, 1191, 1192, 1193, 1195, 1199, 1200, 1212, 1215, 1201,
133573 /* 260 */ 1155, 1206, 1207, 1202, 1217, 1216, 1145, 1144, 1223, 1224,
133574 /* 270 */ 1228, 1211, 1230, 1232, 1235, 1241, 1221, 1227, 1231, 1234,
133575 /* 280 */ 1222, 1229, 1236, 1237, 1238, 1242, 1243, 1244, 1203, 1210,
133576 /* 290 */ 1214, 1218, 1219, 1245, 1249, 1251, 1252, 1250, 1261, 1253,
133577 /* 300 */ 1254, 1209, 1255, 1259, 1258, 1260, 1264, 1268, 1270, 1272,
133578 /* 310 */ 1276, 1287, 1292, 1295, 1297, 1299, 1303, 1263, 1265, 1269,
133579 /* 320 */ 1277, 1279, 1271, 1273, 1307,
133580 };
133581 static const YYACTIONTYPE yy_default[] = {
133582 /* 0 */ 1278, 1268, 1268, 1268, 1200, 1200, 1200, 1200, 1268, 1094,
133583 /* 10 */ 1123, 1123, 1252, 1329, 1329, 1329, 1329, 1329, 1329, 1199,
133584 /* 20 */ 1329, 1329, 1329, 1329, 1268, 1098, 1129, 1329, 1329, 1329,
133585 /* 30 */ 1329, 1201, 1202, 1329, 1329, 1329, 1251, 1253, 1139, 1138,
133586 /* 40 */ 1137, 1136, 1234, 1110, 1134, 1127, 1131, 1201, 1195, 1196,
133587 /* 50 */ 1194, 1198, 1202, 1329, 1130, 1164, 1179, 1163, 1329, 1329,
133588 /* 60 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133589 /* 70 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133590 /* 80 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133591 /* 90 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133592 /* 100 */ 1329, 1329, 1329, 1329, 1173, 1178, 1185, 1177, 1174, 1166,
133593 /* 110 */ 1165, 1167, 1168, 1329, 1017, 1065, 1329, 1329, 1329, 1169,
133594 /* 120 */ 1329, 1170, 1182, 1181, 1180, 1259, 1286, 1285, 1329, 1329,
133595 /* 130 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133596 /* 140 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133597 /* 150 */ 1329, 1329, 1329, 1329, 1329, 1278, 1268, 1023, 1023, 1329,
133598 /* 160 */ 1268, 1268, 1268, 1268, 1268, 1268, 1264, 1098, 1089, 1329,
133599 /* 170 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133600 /* 180 */ 1256, 1254, 1329, 1215, 1329, 1329, 1329, 1329, 1329, 1329,
133601 /* 190 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133602 /* 200 */ 1329, 1329, 1329, 1329, 1094, 1329, 1329, 1329, 1329, 1329,
133603 /* 210 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1280, 1329, 1229,
133604 /* 220 */ 1094, 1094, 1094, 1096, 1078, 1088, 1002, 1133, 1112, 1112,
133605 /* 230 */ 1318, 1133, 1318, 1040, 1300, 1037, 1123, 1112, 1197, 1123,
133606 /* 240 */ 1123, 1095, 1088, 1329, 1321, 1103, 1103, 1320, 1320, 1103,
133607 /* 250 */ 1144, 1068, 1133, 1074, 1074, 1074, 1074, 1103, 1014, 1133,
133608 /* 260 */ 1144, 1068, 1068, 1133, 1103, 1014, 1233, 1315, 1103, 1103,
133609 /* 270 */ 1014, 1208, 1103, 1014, 1103, 1014, 1208, 1066, 1066, 1066,
133610 /* 280 */ 1055, 1208, 1066, 1040, 1066, 1055, 1066, 1066, 1116, 1111,
133611 /* 290 */ 1116, 1111, 1116, 1111, 1116, 1111, 1103, 1203, 1103, 1329,
133612 /* 300 */ 1208, 1212, 1212, 1208, 1128, 1117, 1126, 1124, 1133, 1020,
133613 /* 310 */ 1058, 1283, 1283, 1279, 1279, 1279, 1279, 1326, 1326, 1264,
133614 /* 320 */ 1295, 1295, 1042, 1042, 1295, 1329, 1329, 1329, 1329, 1329,
133615 /* 330 */ 1329, 1290, 1329, 1217, 1329, 1329, 1329, 1329, 1329, 1329,
133616 /* 340 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133617 /* 350 */ 1329, 1329, 1150, 1329, 998, 1261, 1329, 1329, 1260, 1329,
133618 /* 360 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133619 /* 370 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1317,
133620 /* 380 */ 1329, 1329, 1329, 1329, 1329, 1329, 1232, 1231, 1329, 1329,
133621 /* 390 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133622 /* 400 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
133623 /* 410 */ 1329, 1080, 1329, 1329, 1329, 1304, 1329, 1329, 1329, 1329,
133624 /* 420 */ 1329, 1329, 1329, 1125, 1329, 1118, 1329, 1329, 1308, 1329,
133625 /* 430 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1270,
133626 /* 440 */ 1329, 1329, 1329, 1269, 1329, 1329, 1329, 1329, 1329, 1152,
133627 /* 450 */ 1329, 1151, 1155, 1329, 1008, 1329,
133628 };
133629 /********** End of lemon-generated parsing tables *****************************/
133630
133631 /* The next table maps tokens (terminal symbols) into fallback tokens.
133632 ** If a construct like the following:
@@ -132775,199 +134032,202 @@
134032 /* 134 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
134033 /* 135 */ "where_opt ::=",
134034 /* 136 */ "where_opt ::= WHERE expr",
134035 /* 137 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
134036 /* 138 */ "setlist ::= setlist COMMA nm EQ expr",
134037 /* 139 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
134038 /* 140 */ "setlist ::= nm EQ expr",
134039 /* 141 */ "setlist ::= LP idlist RP EQ expr",
134040 /* 142 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
134041 /* 143 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
134042 /* 144 */ "insert_cmd ::= INSERT orconf",
134043 /* 145 */ "insert_cmd ::= REPLACE",
134044 /* 146 */ "idlist_opt ::=",
134045 /* 147 */ "idlist_opt ::= LP idlist RP",
134046 /* 148 */ "idlist ::= idlist COMMA nm",
134047 /* 149 */ "idlist ::= nm",
134048 /* 150 */ "expr ::= LP expr RP",
134049 /* 151 */ "term ::= NULL",
134050 /* 152 */ "expr ::= ID|INDEXED",
134051 /* 153 */ "expr ::= JOIN_KW",
134052 /* 154 */ "expr ::= nm DOT nm",
134053 /* 155 */ "expr ::= nm DOT nm DOT nm",
134054 /* 156 */ "term ::= INTEGER|FLOAT|BLOB",
134055 /* 157 */ "term ::= STRING",
134056 /* 158 */ "expr ::= VARIABLE",
134057 /* 159 */ "expr ::= expr COLLATE ID|STRING",
134058 /* 160 */ "expr ::= CAST LP expr AS typetoken RP",
134059 /* 161 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
134060 /* 162 */ "expr ::= ID|INDEXED LP STAR RP",
134061 /* 163 */ "term ::= CTIME_KW",
134062 /* 164 */ "expr ::= LP nexprlist COMMA expr RP",
134063 /* 165 */ "expr ::= expr AND expr",
134064 /* 166 */ "expr ::= expr OR expr",
134065 /* 167 */ "expr ::= expr LT|GT|GE|LE expr",
134066 /* 168 */ "expr ::= expr EQ|NE expr",
134067 /* 169 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
134068 /* 170 */ "expr ::= expr PLUS|MINUS expr",
134069 /* 171 */ "expr ::= expr STAR|SLASH|REM expr",
134070 /* 172 */ "expr ::= expr CONCAT expr",
134071 /* 173 */ "likeop ::= LIKE_KW|MATCH",
134072 /* 174 */ "likeop ::= NOT LIKE_KW|MATCH",
134073 /* 175 */ "expr ::= expr likeop expr",
134074 /* 176 */ "expr ::= expr likeop expr ESCAPE expr",
134075 /* 177 */ "expr ::= expr ISNULL|NOTNULL",
134076 /* 178 */ "expr ::= expr NOT NULL",
134077 /* 179 */ "expr ::= expr IS expr",
134078 /* 180 */ "expr ::= expr IS NOT expr",
134079 /* 181 */ "expr ::= NOT expr",
134080 /* 182 */ "expr ::= BITNOT expr",
134081 /* 183 */ "expr ::= MINUS expr",
134082 /* 184 */ "expr ::= PLUS expr",
134083 /* 185 */ "between_op ::= BETWEEN",
134084 /* 186 */ "between_op ::= NOT BETWEEN",
134085 /* 187 */ "expr ::= expr between_op expr AND expr",
134086 /* 188 */ "in_op ::= IN",
134087 /* 189 */ "in_op ::= NOT IN",
134088 /* 190 */ "expr ::= expr in_op LP exprlist RP",
134089 /* 191 */ "expr ::= LP select RP",
134090 /* 192 */ "expr ::= expr in_op LP select RP",
134091 /* 193 */ "expr ::= expr in_op nm dbnm paren_exprlist",
134092 /* 194 */ "expr ::= EXISTS LP select RP",
134093 /* 195 */ "expr ::= CASE case_operand case_exprlist case_else END",
134094 /* 196 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
134095 /* 197 */ "case_exprlist ::= WHEN expr THEN expr",
134096 /* 198 */ "case_else ::= ELSE expr",
134097 /* 199 */ "case_else ::=",
134098 /* 200 */ "case_operand ::= expr",
134099 /* 201 */ "case_operand ::=",
134100 /* 202 */ "exprlist ::=",
134101 /* 203 */ "nexprlist ::= nexprlist COMMA expr",
134102 /* 204 */ "nexprlist ::= expr",
134103 /* 205 */ "paren_exprlist ::=",
134104 /* 206 */ "paren_exprlist ::= LP exprlist RP",
134105 /* 207 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
134106 /* 208 */ "uniqueflag ::= UNIQUE",
134107 /* 209 */ "uniqueflag ::=",
134108 /* 210 */ "eidlist_opt ::=",
134109 /* 211 */ "eidlist_opt ::= LP eidlist RP",
134110 /* 212 */ "eidlist ::= eidlist COMMA nm collate sortorder",
134111 /* 213 */ "eidlist ::= nm collate sortorder",
134112 /* 214 */ "collate ::=",
134113 /* 215 */ "collate ::= COLLATE ID|STRING",
134114 /* 216 */ "cmd ::= DROP INDEX ifexists fullname",
134115 /* 217 */ "cmd ::= VACUUM",
134116 /* 218 */ "cmd ::= VACUUM nm",
134117 /* 219 */ "cmd ::= PRAGMA nm dbnm",
134118 /* 220 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
134119 /* 221 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
134120 /* 222 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
134121 /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
134122 /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
134123 /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
134124 /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
134125 /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
134126 /* 228 */ "trigger_time ::= BEFORE",
134127 /* 229 */ "trigger_time ::= AFTER",
134128 /* 230 */ "trigger_time ::= INSTEAD OF",
134129 /* 231 */ "trigger_time ::=",
134130 /* 232 */ "trigger_event ::= DELETE|INSERT",
134131 /* 233 */ "trigger_event ::= UPDATE",
134132 /* 234 */ "trigger_event ::= UPDATE OF idlist",
134133 /* 235 */ "when_clause ::=",
134134 /* 236 */ "when_clause ::= WHEN expr",
134135 /* 237 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
134136 /* 238 */ "trigger_cmd_list ::= trigger_cmd SEMI",
134137 /* 239 */ "trnm ::= nm DOT nm",
134138 /* 240 */ "tridxby ::= INDEXED BY nm",
134139 /* 241 */ "tridxby ::= NOT INDEXED",
134140 /* 242 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
134141 /* 243 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
134142 /* 244 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
134143 /* 245 */ "trigger_cmd ::= select",
134144 /* 246 */ "expr ::= RAISE LP IGNORE RP",
134145 /* 247 */ "expr ::= RAISE LP raisetype COMMA nm RP",
134146 /* 248 */ "raisetype ::= ROLLBACK",
134147 /* 249 */ "raisetype ::= ABORT",
134148 /* 250 */ "raisetype ::= FAIL",
134149 /* 251 */ "cmd ::= DROP TRIGGER ifexists fullname",
134150 /* 252 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
134151 /* 253 */ "cmd ::= DETACH database_kw_opt expr",
134152 /* 254 */ "key_opt ::=",
134153 /* 255 */ "key_opt ::= KEY expr",
134154 /* 256 */ "cmd ::= REINDEX",
134155 /* 257 */ "cmd ::= REINDEX nm dbnm",
134156 /* 258 */ "cmd ::= ANALYZE",
134157 /* 259 */ "cmd ::= ANALYZE nm dbnm",
134158 /* 260 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
134159 /* 261 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
134160 /* 262 */ "add_column_fullname ::= fullname",
134161 /* 263 */ "cmd ::= create_vtab",
134162 /* 264 */ "cmd ::= create_vtab LP vtabarglist RP",
134163 /* 265 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
134164 /* 266 */ "vtabarg ::=",
134165 /* 267 */ "vtabargtoken ::= ANY",
134166 /* 268 */ "vtabargtoken ::= lp anylist RP",
134167 /* 269 */ "lp ::= LP",
134168 /* 270 */ "with ::=",
134169 /* 271 */ "with ::= WITH wqlist",
134170 /* 272 */ "with ::= WITH RECURSIVE wqlist",
134171 /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
134172 /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
134173 /* 275 */ "input ::= cmdlist",
134174 /* 276 */ "cmdlist ::= cmdlist ecmd",
134175 /* 277 */ "cmdlist ::= ecmd",
134176 /* 278 */ "ecmd ::= SEMI",
134177 /* 279 */ "ecmd ::= explain cmdx SEMI",
134178 /* 280 */ "explain ::=",
134179 /* 281 */ "trans_opt ::=",
134180 /* 282 */ "trans_opt ::= TRANSACTION",
134181 /* 283 */ "trans_opt ::= TRANSACTION nm",
134182 /* 284 */ "savepoint_opt ::= SAVEPOINT",
134183 /* 285 */ "savepoint_opt ::=",
134184 /* 286 */ "cmd ::= create_table create_table_args",
134185 /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
134186 /* 288 */ "columnlist ::= columnname carglist",
134187 /* 289 */ "nm ::= ID|INDEXED",
134188 /* 290 */ "nm ::= STRING",
134189 /* 291 */ "nm ::= JOIN_KW",
134190 /* 292 */ "typetoken ::= typename",
134191 /* 293 */ "typename ::= ID|STRING",
134192 /* 294 */ "signed ::= plus_num",
134193 /* 295 */ "signed ::= minus_num",
134194 /* 296 */ "carglist ::= carglist ccons",
134195 /* 297 */ "carglist ::=",
134196 /* 298 */ "ccons ::= NULL onconf",
134197 /* 299 */ "conslist_opt ::= COMMA conslist",
134198 /* 300 */ "conslist ::= conslist tconscomma tcons",
134199 /* 301 */ "conslist ::= tcons",
134200 /* 302 */ "tconscomma ::=",
134201 /* 303 */ "defer_subclause_opt ::= defer_subclause",
134202 /* 304 */ "resolvetype ::= raisetype",
134203 /* 305 */ "selectnowith ::= oneselect",
134204 /* 306 */ "oneselect ::= values",
134205 /* 307 */ "sclp ::= selcollist COMMA",
134206 /* 308 */ "as ::= ID|STRING",
134207 /* 309 */ "expr ::= term",
134208 /* 310 */ "exprlist ::= nexprlist",
134209 /* 311 */ "nmnum ::= plus_num",
134210 /* 312 */ "nmnum ::= nm",
134211 /* 313 */ "nmnum ::= ON",
134212 /* 314 */ "nmnum ::= DELETE",
134213 /* 315 */ "nmnum ::= DEFAULT",
134214 /* 316 */ "plus_num ::= INTEGER|FLOAT",
134215 /* 317 */ "foreach_clause ::=",
134216 /* 318 */ "foreach_clause ::= FOR EACH ROW",
134217 /* 319 */ "trnm ::= nm",
134218 /* 320 */ "tridxby ::=",
134219 /* 321 */ "database_kw_opt ::= DATABASE",
134220 /* 322 */ "database_kw_opt ::=",
134221 /* 323 */ "kwcolumn_opt ::=",
134222 /* 324 */ "kwcolumn_opt ::= COLUMNKW",
134223 /* 325 */ "vtabarglist ::= vtabarg",
134224 /* 326 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
134225 /* 327 */ "vtabarg ::= vtabarg vtabargtoken",
134226 /* 328 */ "anylist ::=",
134227 /* 329 */ "anylist ::= anylist LP anylist RP",
134228 /* 330 */ "anylist ::= anylist ANY",
134229 };
134230 #endif /* NDEBUG */
134231
134232
134233 #if YYSTACKDEPTH<=0
@@ -133526,11 +134786,13 @@
134786 { 149, 6 },
134787 { 201, 0 },
134788 { 201, 2 },
134789 { 149, 8 },
134790 { 218, 5 },
134791 { 218, 7 },
134792 { 218, 3 },
134793 { 218, 5 },
134794 { 149, 6 },
134795 { 149, 7 },
134796 { 219, 2 },
134797 { 219, 1 },
134798 { 220, 0 },
@@ -133549,10 +134811,11 @@
134811 { 173, 3 },
134812 { 173, 6 },
134813 { 173, 5 },
134814 { 173, 4 },
134815 { 172, 1 },
134816 { 173, 5 },
134817 { 173, 3 },
134818 { 173, 3 },
134819 { 173, 3 },
134820 { 173, 3 },
134821 { 173, 3 },
@@ -133836,11 +135099,11 @@
135099 case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
135100 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
135101 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
135102 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
135103 case 90: /* distinct ::= */ yytestcase(yyruleno==90);
135104 case 214: /* collate ::= */ yytestcase(yyruleno==214);
135105 {yymsp[1].minor.yy194 = 0;}
135106 break;
135107 case 17: /* ifnotexists ::= IF NOT EXISTS */
135108 {yymsp[-2].minor.yy194 = 1;}
135109 break;
@@ -133975,18 +135238,18 @@
135238 case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
135239 {yymsp[-2].minor.yy194 = 0;}
135240 break;
135241 case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
135242 case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
135243 case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144);
135244 {yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
135245 break;
135246 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
135247 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
135248 case 186: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==186);
135249 case 189: /* in_op ::= NOT IN */ yytestcase(yyruleno==189);
135250 case 215: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==215);
135251 {yymsp[-1].minor.yy194 = 1;}
135252 break;
135253 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
135254 {yymsp[-1].minor.yy194 = 0;}
135255 break;
@@ -134018,11 +135281,11 @@
135281 break;
135282 case 72: /* resolvetype ::= IGNORE */
135283 {yymsp[0].minor.yy194 = OE_Ignore;}
135284 break;
135285 case 73: /* resolvetype ::= REPLACE */
135286 case 145: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==145);
135287 {yymsp[0].minor.yy194 = OE_Replace;}
135288 break;
135289 case 74: /* cmd ::= DROP TABLE ifexists fullname */
135290 {
135291 sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);
@@ -134146,13 +135409,13 @@
135409 {yymsp[0].minor.yy194 = SF_All;}
135410 break;
135411 case 91: /* sclp ::= */
135412 case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
135413 case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
135414 case 202: /* exprlist ::= */ yytestcase(yyruleno==202);
135415 case 205: /* paren_exprlist ::= */ yytestcase(yyruleno==205);
135416 case 210: /* eidlist_opt ::= */ yytestcase(yyruleno==210);
135417 {yymsp[1].minor.yy148 = 0;}
135418 break;
135419 case 92: /* selcollist ::= sclp expr as */
135420 {
135421 yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
@@ -134174,12 +135437,12 @@
135437 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
135438 }
135439 break;
135440 case 95: /* as ::= AS nm */
135441 case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
135442 case 224: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==224);
135443 case 225: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==225);
135444 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
135445 break;
135446 case 97: /* from ::= */
135447 {yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
135448 break;
@@ -134258,18 +135521,18 @@
135521 {yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
135522 break;
135523 case 112: /* on_opt ::= ON expr */
135524 case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
135525 case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
135526 case 198: /* case_else ::= ELSE expr */ yytestcase(yyruleno==198);
135527 {yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
135528 break;
135529 case 113: /* on_opt ::= */
135530 case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
135531 case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
135532 case 199: /* case_else ::= */ yytestcase(yyruleno==199);
135533 case 201: /* case_operand ::= */ yytestcase(yyruleno==201);
135534 {yymsp[1].minor.yy72 = 0;}
135535 break;
135536 case 115: /* indexed_opt ::= INDEXED BY nm */
135537 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
135538 break;
@@ -134278,11 +135541,11 @@
135541 break;
135542 case 117: /* using_opt ::= USING LP idlist RP */
135543 {yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
135544 break;
135545 case 118: /* using_opt ::= */
135546 case 146: /* idlist_opt ::= */ yytestcase(yyruleno==146);
135547 {yymsp[1].minor.yy254 = 0;}
135548 break;
135549 case 120: /* orderby_opt ::= ORDER BY sortlist */
135550 case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
135551 {yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}
@@ -134339,69 +135602,79 @@
135602 {
135603 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
135604 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);
135605 }
135606 break;
135607 case 139: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
135608 {
135609 yymsp[-6].minor.yy148 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy148, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
135610 }
135611 break;
135612 case 140: /* setlist ::= nm EQ expr */
135613 {
135614 yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
135615 sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);
135616 }
135617 yymsp[-2].minor.yy148 = yylhsminor.yy148;
135618 break;
135619 case 141: /* setlist ::= LP idlist RP EQ expr */
135620 {
135621 yymsp[-4].minor.yy148 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
135622 }
135623 break;
135624 case 142: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
135625 {
135626 sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
135627 sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);
135628 }
135629 break;
135630 case 143: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
135631 {
135632 sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);
135633 sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);
135634 }
135635 break;
135636 case 147: /* idlist_opt ::= LP idlist RP */
135637 {yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
135638 break;
135639 case 148: /* idlist ::= idlist COMMA nm */
135640 {yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
135641 break;
135642 case 149: /* idlist ::= nm */
135643 {yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
135644 break;
135645 case 150: /* expr ::= LP expr RP */
135646 {spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
135647 break;
135648 case 151: /* term ::= NULL */
135649 case 156: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==156);
135650 case 157: /* term ::= STRING */ yytestcase(yyruleno==157);
135651 {spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
135652 break;
135653 case 152: /* expr ::= ID|INDEXED */
135654 case 153: /* expr ::= JOIN_KW */ yytestcase(yyruleno==153);
135655 {spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
135656 break;
135657 case 154: /* expr ::= nm DOT nm */
135658 {
135659 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
135660 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
135661 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
135662 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
135663 }
135664 break;
135665 case 155: /* expr ::= nm DOT nm DOT nm */
135666 {
135667 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
135668 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
135669 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
135670 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
135671 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
135672 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
135673 }
135674 break;
135675 case 158: /* expr ::= VARIABLE */
135676 {
135677 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
135678 spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
135679 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr);
135680 }else{
@@ -134419,23 +135692,23 @@
135692 if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
135693 }
135694 }
135695 }
135696 break;
135697 case 159: /* expr ::= expr COLLATE ID|STRING */
135698 {
135699 yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
135700 yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
135701 }
135702 break;
135703 case 160: /* expr ::= CAST LP expr AS typetoken RP */
135704 {
135705 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
135706 yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy190.pExpr, 0, &yymsp[-1].minor.yy0);
135707 }
135708 break;
135709 case 161: /* expr ::= ID|INDEXED LP distinct exprlist RP */
135710 {
135711 if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
135712 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
135713 }
135714 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
@@ -134444,41 +135717,54 @@
135717 yylhsminor.yy190.pExpr->flags |= EP_Distinct;
135718 }
135719 }
135720 yymsp[-4].minor.yy190 = yylhsminor.yy190;
135721 break;
135722 case 162: /* expr ::= ID|INDEXED LP STAR RP */
135723 {
135724 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
135725 spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
135726 }
135727 yymsp[-3].minor.yy190 = yylhsminor.yy190;
135728 break;
135729 case 163: /* term ::= CTIME_KW */
135730 {
135731 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
135732 spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
135733 }
135734 yymsp[0].minor.yy190 = yylhsminor.yy190;
135735 break;
135736 case 164: /* expr ::= LP nexprlist COMMA expr RP */
135737 {
135738 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy148, yymsp[-1].minor.yy190.pExpr);
135739 yylhsminor.yy190.pExpr = sqlite3PExpr(pParse, TK_VECTOR, 0, 0, 0);
135740 if( yylhsminor.yy190.pExpr ){
135741 yylhsminor.yy190.pExpr->x.pList = pList;
135742 spanSet(&yylhsminor.yy190, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0);
135743 }else{
135744 sqlite3ExprListDelete(pParse->db, pList);
135745 }
135746 }
135747 yymsp[-4].minor.yy190 = yylhsminor.yy190;
135748 break;
135749 case 165: /* expr ::= expr AND expr */
135750 case 166: /* expr ::= expr OR expr */ yytestcase(yyruleno==166);
135751 case 167: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==167);
135752 case 168: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==168);
135753 case 169: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==169);
135754 case 170: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==170);
135755 case 171: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==171);
135756 case 172: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==172);
135757 {spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
135758 break;
135759 case 173: /* likeop ::= LIKE_KW|MATCH */
135760 {yymsp[0].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy392.bNot = 0;/*A-overwrites-X*/}
135761 break;
135762 case 174: /* likeop ::= NOT LIKE_KW|MATCH */
135763 {yymsp[-1].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy392.bNot = 1;}
135764 break;
135765 case 175: /* expr ::= expr likeop expr */
135766 {
135767 ExprList *pList;
135768 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
135769 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr);
135770 yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy392.eOperator);
@@ -134485,11 +135771,11 @@
135771 exprNot(pParse, yymsp[-1].minor.yy392.bNot, &yymsp[-2].minor.yy190);
135772 yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
135773 if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
135774 }
135775 break;
135776 case 176: /* expr ::= expr likeop expr ESCAPE expr */
135777 {
135778 ExprList *pList;
135779 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
135780 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr);
135781 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
@@ -134497,43 +135783,43 @@
135783 exprNot(pParse, yymsp[-3].minor.yy392.bNot, &yymsp[-4].minor.yy190);
135784 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
135785 if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
135786 }
135787 break;
135788 case 177: /* expr ::= expr ISNULL|NOTNULL */
135789 {spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
135790 break;
135791 case 178: /* expr ::= expr NOT NULL */
135792 {spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
135793 break;
135794 case 179: /* expr ::= expr IS expr */
135795 {
135796 spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
135797 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
135798 }
135799 break;
135800 case 180: /* expr ::= expr IS NOT expr */
135801 {
135802 spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
135803 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
135804 }
135805 break;
135806 case 181: /* expr ::= NOT expr */
135807 case 182: /* expr ::= BITNOT expr */ yytestcase(yyruleno==182);
135808 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
135809 break;
135810 case 183: /* expr ::= MINUS expr */
135811 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
135812 break;
135813 case 184: /* expr ::= PLUS expr */
135814 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
135815 break;
135816 case 185: /* between_op ::= BETWEEN */
135817 case 188: /* in_op ::= IN */ yytestcase(yyruleno==188);
135818 {yymsp[0].minor.yy194 = 0;}
135819 break;
135820 case 187: /* expr ::= expr between_op expr AND expr */
135821 {
135822 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
135823 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
135824 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0, 0);
135825 if( yymsp[-4].minor.yy190.pExpr ){
@@ -134543,11 +135829,11 @@
135829 }
135830 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
135831 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
135832 }
135833 break;
135834 case 190: /* expr ::= expr in_op LP exprlist RP */
135835 {
135836 if( yymsp[-1].minor.yy148==0 ){
135837 /* Expressions of the form
135838 **
135839 ** expr1 IN ()
@@ -134596,26 +135882,26 @@
135882 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
135883 }
135884 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
135885 }
135886 break;
135887 case 191: /* expr ::= LP select RP */
135888 {
135889 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
135890 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
135891 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
135892 }
135893 break;
135894 case 192: /* expr ::= expr in_op LP select RP */
135895 {
135896 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
135897 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
135898 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
135899 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
135900 }
135901 break;
135902 case 193: /* expr ::= expr in_op nm dbnm paren_exprlist */
135903 {
135904 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
135905 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
135906 if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
135907 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0);
@@ -134622,19 +135908,19 @@
135908 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
135909 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
135910 yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
135911 }
135912 break;
135913 case 194: /* expr ::= EXISTS LP select RP */
135914 {
135915 Expr *p;
135916 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
135917 p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
135918 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
135919 }
135920 break;
135921 case 195: /* expr ::= CASE case_operand case_exprlist case_else END */
135922 {
135923 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
135924 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0, 0);
135925 if( yymsp[-4].minor.yy190.pExpr ){
135926 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
@@ -134643,334 +135929,334 @@
135929 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
135930 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
135931 }
135932 }
135933 break;
135934 case 196: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
135935 {
135936 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
135937 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
135938 }
135939 break;
135940 case 197: /* case_exprlist ::= WHEN expr THEN expr */
135941 {
135942 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
135943 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
135944 }
135945 break;
135946 case 200: /* case_operand ::= expr */
135947 {yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
135948 break;
135949 case 203: /* nexprlist ::= nexprlist COMMA expr */
135950 {yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
135951 break;
135952 case 204: /* nexprlist ::= expr */
135953 {yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
135954 break;
135955 case 206: /* paren_exprlist ::= LP exprlist RP */
135956 case 211: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==211);
135957 {yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
135958 break;
135959 case 207: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
135960 {
135961 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
135962 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
135963 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
135964 }
135965 break;
135966 case 208: /* uniqueflag ::= UNIQUE */
135967 case 249: /* raisetype ::= ABORT */ yytestcase(yyruleno==249);
135968 {yymsp[0].minor.yy194 = OE_Abort;}
135969 break;
135970 case 209: /* uniqueflag ::= */
135971 {yymsp[1].minor.yy194 = OE_None;}
135972 break;
135973 case 212: /* eidlist ::= eidlist COMMA nm collate sortorder */
135974 {
135975 yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
135976 }
135977 break;
135978 case 213: /* eidlist ::= nm collate sortorder */
135979 {
135980 yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
135981 }
135982 break;
135983 case 216: /* cmd ::= DROP INDEX ifexists fullname */
135984 {sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
135985 break;
135986 case 217: /* cmd ::= VACUUM */
135987 {sqlite3Vacuum(pParse,0);}
135988 break;
135989 case 218: /* cmd ::= VACUUM nm */
135990 {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
135991 break;
135992 case 219: /* cmd ::= PRAGMA nm dbnm */
135993 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
135994 break;
135995 case 220: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
135996 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
135997 break;
135998 case 221: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
135999 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
136000 break;
136001 case 222: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
136002 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
136003 break;
136004 case 223: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
136005 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
136006 break;
136007 case 226: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
136008 {
136009 Token all;
136010 all.z = yymsp[-3].minor.yy0.z;
136011 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
136012 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
136013 }
136014 break;
136015 case 227: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
136016 {
136017 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
136018 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
136019 }
136020 break;
136021 case 228: /* trigger_time ::= BEFORE */
136022 { yymsp[0].minor.yy194 = TK_BEFORE; }
136023 break;
136024 case 229: /* trigger_time ::= AFTER */
136025 { yymsp[0].minor.yy194 = TK_AFTER; }
136026 break;
136027 case 230: /* trigger_time ::= INSTEAD OF */
136028 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
136029 break;
136030 case 231: /* trigger_time ::= */
136031 { yymsp[1].minor.yy194 = TK_BEFORE; }
136032 break;
136033 case 232: /* trigger_event ::= DELETE|INSERT */
136034 case 233: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==233);
136035 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
136036 break;
136037 case 234: /* trigger_event ::= UPDATE OF idlist */
136038 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
136039 break;
136040 case 235: /* when_clause ::= */
136041 case 254: /* key_opt ::= */ yytestcase(yyruleno==254);
136042 { yymsp[1].minor.yy72 = 0; }
136043 break;
136044 case 236: /* when_clause ::= WHEN expr */
136045 case 255: /* key_opt ::= KEY expr */ yytestcase(yyruleno==255);
136046 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
136047 break;
136048 case 237: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
136049 {
136050 assert( yymsp[-2].minor.yy145!=0 );
136051 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
136052 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
136053 }
136054 break;
136055 case 238: /* trigger_cmd_list ::= trigger_cmd SEMI */
136056 {
136057 assert( yymsp[-1].minor.yy145!=0 );
136058 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
136059 }
136060 break;
136061 case 239: /* trnm ::= nm DOT nm */
136062 {
136063 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
136064 sqlite3ErrorMsg(pParse,
136065 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
136066 "statements within triggers");
136067 }
136068 break;
136069 case 240: /* tridxby ::= INDEXED BY nm */
136070 {
136071 sqlite3ErrorMsg(pParse,
136072 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
136073 "within triggers");
136074 }
136075 break;
136076 case 241: /* tridxby ::= NOT INDEXED */
136077 {
136078 sqlite3ErrorMsg(pParse,
136079 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
136080 "within triggers");
136081 }
136082 break;
136083 case 242: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
136084 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
136085 break;
136086 case 243: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
136087 {yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
136088 break;
136089 case 244: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
136090 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
136091 break;
136092 case 245: /* trigger_cmd ::= select */
136093 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
136094 break;
136095 case 246: /* expr ::= RAISE LP IGNORE RP */
136096 {
136097 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
136098 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
136099 if( yymsp[-3].minor.yy190.pExpr ){
136100 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
136101 }
136102 }
136103 break;
136104 case 247: /* expr ::= RAISE LP raisetype COMMA nm RP */
136105 {
136106 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
136107 yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
136108 if( yymsp[-5].minor.yy190.pExpr ) {
136109 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
136110 }
136111 }
136112 break;
136113 case 248: /* raisetype ::= ROLLBACK */
136114 {yymsp[0].minor.yy194 = OE_Rollback;}
136115 break;
136116 case 250: /* raisetype ::= FAIL */
136117 {yymsp[0].minor.yy194 = OE_Fail;}
136118 break;
136119 case 251: /* cmd ::= DROP TRIGGER ifexists fullname */
136120 {
136121 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
136122 }
136123 break;
136124 case 252: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
136125 {
136126 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
136127 }
136128 break;
136129 case 253: /* cmd ::= DETACH database_kw_opt expr */
136130 {
136131 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
136132 }
136133 break;
136134 case 256: /* cmd ::= REINDEX */
136135 {sqlite3Reindex(pParse, 0, 0);}
136136 break;
136137 case 257: /* cmd ::= REINDEX nm dbnm */
136138 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
136139 break;
136140 case 258: /* cmd ::= ANALYZE */
136141 {sqlite3Analyze(pParse, 0, 0);}
136142 break;
136143 case 259: /* cmd ::= ANALYZE nm dbnm */
136144 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
136145 break;
136146 case 260: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
136147 {
136148 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
136149 }
136150 break;
136151 case 261: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
136152 {
136153 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
136154 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
136155 }
136156 break;
136157 case 262: /* add_column_fullname ::= fullname */
136158 {
136159 disableLookaside(pParse);
136160 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
136161 }
136162 break;
136163 case 263: /* cmd ::= create_vtab */
136164 {sqlite3VtabFinishParse(pParse,0);}
136165 break;
136166 case 264: /* cmd ::= create_vtab LP vtabarglist RP */
136167 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
136168 break;
136169 case 265: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
136170 {
136171 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
136172 }
136173 break;
136174 case 266: /* vtabarg ::= */
136175 {sqlite3VtabArgInit(pParse);}
136176 break;
136177 case 267: /* vtabargtoken ::= ANY */
136178 case 268: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==268);
136179 case 269: /* lp ::= LP */ yytestcase(yyruleno==269);
136180 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
136181 break;
136182 case 270: /* with ::= */
136183 {yymsp[1].minor.yy285 = 0;}
136184 break;
136185 case 271: /* with ::= WITH wqlist */
136186 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
136187 break;
136188 case 272: /* with ::= WITH RECURSIVE wqlist */
136189 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
136190 break;
136191 case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
136192 {
136193 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
136194 }
136195 break;
136196 case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
136197 {
136198 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
136199 }
136200 break;
136201 default:
136202 /* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
136203 /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
136204 /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
136205 /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
136206 /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
136207 /* (280) explain ::= */ yytestcase(yyruleno==280);
136208 /* (281) trans_opt ::= */ yytestcase(yyruleno==281);
136209 /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
136210 /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
136211 /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
136212 /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
136213 /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
136214 /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
136215 /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
136216 /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
136217 /* (290) nm ::= STRING */ yytestcase(yyruleno==290);
136218 /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
136219 /* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
136220 /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
136221 /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
136222 /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
136223 /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
136224 /* (297) carglist ::= */ yytestcase(yyruleno==297);
136225 /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
136226 /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
136227 /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
136228 /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
136229 /* (302) tconscomma ::= */ yytestcase(yyruleno==302);
136230 /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
136231 /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
136232 /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
136233 /* (306) oneselect ::= values */ yytestcase(yyruleno==306);
136234 /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
136235 /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
136236 /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
136237 /* (310) exprlist ::= nexprlist */ yytestcase(yyruleno==310);
136238 /* (311) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=311);
136239 /* (312) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=312);
136240 /* (313) nmnum ::= ON */ yytestcase(yyruleno==313);
136241 /* (314) nmnum ::= DELETE */ yytestcase(yyruleno==314);
136242 /* (315) nmnum ::= DEFAULT */ yytestcase(yyruleno==315);
136243 /* (316) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==316);
136244 /* (317) foreach_clause ::= */ yytestcase(yyruleno==317);
136245 /* (318) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==318);
136246 /* (319) trnm ::= nm */ yytestcase(yyruleno==319);
136247 /* (320) tridxby ::= */ yytestcase(yyruleno==320);
136248 /* (321) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==321);
136249 /* (322) database_kw_opt ::= */ yytestcase(yyruleno==322);
136250 /* (323) kwcolumn_opt ::= */ yytestcase(yyruleno==323);
136251 /* (324) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==324);
136252 /* (325) vtabarglist ::= vtabarg */ yytestcase(yyruleno==325);
136253 /* (326) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==326);
136254 /* (327) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==327);
136255 /* (328) anylist ::= */ yytestcase(yyruleno==328);
136256 /* (329) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==329);
136257 /* (330) anylist ::= anylist ANY */ yytestcase(yyruleno==330);
136258 break;
136259 /********** End reduce actions ************************************************/
136260 };
136261 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
136262 yygoto = yyRuleInfo[yyruleno].lhs;
@@ -138358,10 +139644,12 @@
139644 if( !sqlite3SafetyCheckOk(db) ){
139645 return SQLITE_MISUSE_BKPT;
139646 }
139647 #endif
139648 sqlite3_mutex_enter(db->mutex);
139649 if( mTrace==0 ) xTrace = 0;
139650 if( xTrace==0 ) mTrace = 0;
139651 db->mTrace = mTrace;
139652 db->xTrace = xTrace;
139653 db->pTraceArg = pArg;
139654 sqlite3_mutex_leave(db->mutex);
139655 return SQLITE_OK;
@@ -139468,15 +140756,24 @@
140756 ** database schema yet. This is delayed until the first time the database
140757 ** is accessed.
140758 */
140759 sqlite3Error(db, SQLITE_OK);
140760 sqlite3RegisterPerConnectionBuiltinFunctions(db);
140761 rc = sqlite3_errcode(db);
140762
140763 #ifdef SQLITE_ENABLE_FTS5
140764 /* Register any built-in FTS5 module before loading the automatic
140765 ** extensions. This allows automatic extensions to register FTS5
140766 ** tokenizers and auxiliary functions. */
140767 if( !db->mallocFailed && rc==SQLITE_OK ){
140768 rc = sqlite3Fts5Init(db);
140769 }
140770 #endif
140771
140772 /* Load automatic extensions - extensions that have been registered
140773 ** using the sqlite3_automatic_extension() API.
140774 */
 
140775 if( rc==SQLITE_OK ){
140776 sqlite3AutoLoadExtensions(db);
140777 rc = sqlite3_errcode(db);
140778 if( rc!=SQLITE_OK ){
140779 goto opendb_out;
@@ -139499,16 +140796,10 @@
140796
140797 #ifdef SQLITE_ENABLE_FTS3 /* automatically defined by SQLITE_ENABLE_FTS4 */
140798 if( !db->mallocFailed && rc==SQLITE_OK ){
140799 rc = sqlite3Fts3Init(db);
140800 }
 
 
 
 
 
 
140801 #endif
140802
140803 #ifdef SQLITE_ENABLE_ICU
140804 if( !db->mallocFailed && rc==SQLITE_OK ){
140805 rc = sqlite3IcuInit(db);
@@ -161530,11 +162821,11 @@
162821
162822 pCsr->iStrategy = idxNum;
162823 if( idxNum==1 ){
162824 /* Special case - lookup by rowid. */
162825 RtreeNode *pLeaf; /* Leaf on which the required cell resides */
162826 RtreeSearchPoint *p; /* Search point for the leaf */
162827 i64 iRowid = sqlite3_value_int64(argv[0]);
162828 i64 iNode = 0;
162829 rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
162830 if( rc==SQLITE_OK && pLeaf!=0 ){
162831 p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);
@@ -164566,11 +165857,11 @@
165857 **
165858 ** Instead of the plain data_<target> naming scheme, RBU database tables
165859 ** may also be named data<integer>_<target>, where <integer> is any sequence
165860 ** of zero or more numeric characters (0-9). This can be significant because
165861 ** tables within the RBU database are always processed in order sorted by
165862 ** name. By judicious selection of the <integer> portion of the names
165863 ** of the RBU tables the user can therefore control the order in which they
165864 ** are processed. This can be useful, for example, to ensure that "external
165865 ** content" FTS4 tables are updated before their underlying content tables.
165866 **
165867 ** If the target database table is a virtual table or a table that has no
@@ -180154,10 +181445,119 @@
181445 }
181446 }
181447 /*
181448 ** End of highlight() implementation.
181449 **************************************************************************/
181450
181451 /*
181452 ** Context object passed to the fts5SentenceFinderCb() function.
181453 */
181454 typedef struct Fts5SFinder Fts5SFinder;
181455 struct Fts5SFinder {
181456 int iPos; /* Current token position */
181457 int nFirstAlloc; /* Allocated size of aFirst[] */
181458 int nFirst; /* Number of entries in aFirst[] */
181459 int *aFirst; /* Array of first token in each sentence */
181460 const char *zDoc; /* Document being tokenized */
181461 };
181462
181463 /*
181464 ** Add an entry to the Fts5SFinder.aFirst[] array. Grow the array if
181465 ** necessary. Return SQLITE_OK if successful, or SQLITE_NOMEM if an
181466 ** error occurs.
181467 */
181468 static int fts5SentenceFinderAdd(Fts5SFinder *p, int iAdd){
181469 if( p->nFirstAlloc==p->nFirst ){
181470 int nNew = p->nFirstAlloc ? p->nFirstAlloc*2 : 64;
181471 int *aNew;
181472
181473 aNew = (int*)sqlite3_realloc(p->aFirst, nNew*sizeof(int));
181474 if( aNew==0 ) return SQLITE_NOMEM;
181475 p->aFirst = aNew;
181476 p->nFirstAlloc = nNew;
181477 }
181478 p->aFirst[p->nFirst++] = iAdd;
181479 return SQLITE_OK;
181480 }
181481
181482 /*
181483 ** This function is an xTokenize() callback used by the auxiliary snippet()
181484 ** function. Its job is to identify tokens that are the first in a sentence.
181485 ** For each such token, an entry is added to the SFinder.aFirst[] array.
181486 */
181487 static int fts5SentenceFinderCb(
181488 void *pContext, /* Pointer to HighlightContext object */
181489 int tflags, /* Mask of FTS5_TOKEN_* flags */
181490 const char *pToken, /* Buffer containing token */
181491 int nToken, /* Size of token in bytes */
181492 int iStartOff, /* Start offset of token */
181493 int iEndOff /* End offset of token */
181494 ){
181495 int rc = SQLITE_OK;
181496
181497 if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){
181498 Fts5SFinder *p = (Fts5SFinder*)pContext;
181499 if( p->iPos>0 ){
181500 int i;
181501 char c = 0;
181502 for(i=iStartOff-1; i>=0; i--){
181503 c = p->zDoc[i];
181504 if( c!=' ' && c!='\t' && c!='\n' && c!='\r' ) break;
181505 }
181506 if( i!=iStartOff-1 && (c=='.' || c==':') ){
181507 rc = fts5SentenceFinderAdd(p, p->iPos);
181508 }
181509 }else{
181510 rc = fts5SentenceFinderAdd(p, 0);
181511 }
181512 p->iPos++;
181513 }
181514 return rc;
181515 }
181516
181517 static int fts5SnippetScore(
181518 const Fts5ExtensionApi *pApi, /* API offered by current FTS version */
181519 Fts5Context *pFts, /* First arg to pass to pApi functions */
181520 int nDocsize, /* Size of column in tokens */
181521 unsigned char *aSeen, /* Array with one element per query phrase */
181522 int iCol, /* Column to score */
181523 int iPos, /* Starting offset to score */
181524 int nToken, /* Max tokens per snippet */
181525 int *pnScore, /* OUT: Score */
181526 int *piPos /* OUT: Adjusted offset */
181527 ){
181528 int rc;
181529 int i;
181530 int ip = 0;
181531 int ic = 0;
181532 int iOff = 0;
181533 int iFirst = -1;
181534 int nInst;
181535 int nScore = 0;
181536 int iLast = 0;
181537
181538 rc = pApi->xInstCount(pFts, &nInst);
181539 for(i=0; i<nInst && rc==SQLITE_OK; i++){
181540 rc = pApi->xInst(pFts, i, &ip, &ic, &iOff);
181541 if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<(iPos+nToken) ){
181542 nScore += (aSeen[ip] ? 1 : 1000);
181543 aSeen[ip] = 1;
181544 if( iFirst<0 ) iFirst = iOff;
181545 iLast = iOff + pApi->xPhraseSize(pFts, ip);
181546 }
181547 }
181548
181549 *pnScore = nScore;
181550 if( piPos ){
181551 int iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
181552 if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;
181553 if( iAdj<0 ) iAdj = 0;
181554 *piPos = iAdj;
181555 }
181556
181557 return rc;
181558 }
181559
181560 /*
181561 ** Implementation of snippet() function.
181562 */
181563 static void fts5SnippetFunction(
@@ -180176,87 +181576,111 @@
181576 int i; /* Used to iterate through instances */
181577 int nPhrase; /* Number of phrases in query */
181578 unsigned char *aSeen; /* Array of "seen instance" flags */
181579 int iBestCol; /* Column containing best snippet */
181580 int iBestStart = 0; /* First token of best snippet */
 
181581 int nBestScore = 0; /* Score of best snippet */
181582 int nColSize = 0; /* Total size of iBestCol in tokens */
181583 Fts5SFinder sFinder; /* Used to find the beginnings of sentences */
181584 int nCol;
181585
181586 if( nVal!=5 ){
181587 const char *zErr = "wrong number of arguments to function snippet()";
181588 sqlite3_result_error(pCtx, zErr, -1);
181589 return;
181590 }
181591
181592 nCol = pApi->xColumnCount(pFts);
181593 memset(&ctx, 0, sizeof(HighlightContext));
181594 iCol = sqlite3_value_int(apVal[0]);
181595 ctx.zOpen = (const char*)sqlite3_value_text(apVal[1]);
181596 ctx.zClose = (const char*)sqlite3_value_text(apVal[2]);
181597 zEllips = (const char*)sqlite3_value_text(apVal[3]);
181598 nToken = sqlite3_value_int(apVal[4]);
 
181599
181600 iBestCol = (iCol>=0 ? iCol : 0);
181601 nPhrase = pApi->xPhraseCount(pFts);
181602 aSeen = sqlite3_malloc(nPhrase);
181603 if( aSeen==0 ){
181604 rc = SQLITE_NOMEM;
181605 }
 
181606 if( rc==SQLITE_OK ){
181607 rc = pApi->xInstCount(pFts, &nInst);
181608 }
181609
181610 memset(&sFinder, 0, sizeof(Fts5SFinder));
181611 for(i=0; i<nCol; i++){
181612 if( iCol<0 || iCol==i ){
181613 int nDoc;
181614 int nDocsize;
181615 int ii;
181616 sFinder.iPos = 0;
181617 sFinder.nFirst = 0;
181618 rc = pApi->xColumnText(pFts, i, &sFinder.zDoc, &nDoc);
181619 if( rc!=SQLITE_OK ) break;
181620 rc = pApi->xTokenize(pFts,
181621 sFinder.zDoc, nDoc, (void*)&sFinder,fts5SentenceFinderCb
181622 );
181623 if( rc!=SQLITE_OK ) break;
181624 rc = pApi->xColumnSize(pFts, i, &nDocsize);
181625 if( rc!=SQLITE_OK ) break;
181626
181627 for(ii=0; rc==SQLITE_OK && ii<nInst; ii++){
181628 int ip, ic, io;
181629 int iAdj;
181630 int nScore;
181631 int jj;
181632
181633 rc = pApi->xInst(pFts, ii, &ip, &ic, &io);
181634 if( ic!=i || rc!=SQLITE_OK ) continue;
181635 memset(aSeen, 0, nPhrase);
181636 rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,
181637 io, nToken, &nScore, &iAdj
181638 );
181639 if( rc==SQLITE_OK && nScore>nBestScore ){
181640 nBestScore = nScore;
181641 iBestCol = i;
181642 iBestStart = iAdj;
181643 nColSize = nDocsize;
181644 }
181645
181646 if( rc==SQLITE_OK && sFinder.nFirst && nDocsize>nToken ){
181647 for(jj=0; jj<(sFinder.nFirst-1); jj++){
181648 if( sFinder.aFirst[jj+1]>io ) break;
181649 }
181650
181651 if( sFinder.aFirst[jj]<io ){
181652 int nScore;
181653 memset(aSeen, 0, nPhrase);
181654 rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,
181655 sFinder.aFirst[jj], nToken, &nScore, 0
181656 );
181657
181658 nScore += (sFinder.aFirst[jj]==0 ? 120 : 100);
181659 if( rc==SQLITE_OK && nScore>nBestScore ){
181660 nBestScore = nScore;
181661 iBestCol = i;
181662 iBestStart = sFinder.aFirst[jj];
181663 nColSize = nDocsize;
181664 }
181665 }
181666 }
181667 }
181668 }
181669 }
181670
181671 if( rc==SQLITE_OK ){
181672 rc = pApi->xColumnText(pFts, iBestCol, &ctx.zIn, &ctx.nIn);
181673 }
181674 if( rc==SQLITE_OK && nColSize==0 ){
181675 rc = pApi->xColumnSize(pFts, iBestCol, &nColSize);
181676 }
181677 if( ctx.zIn ){
181678 if( rc==SQLITE_OK ){
181679 rc = fts5CInstIterInit(pApi, pFts, iBestCol, &ctx.iter);
181680 }
181681
 
 
 
 
 
 
 
 
181682 ctx.iRangeStart = iBestStart;
181683 ctx.iRangeEnd = iBestStart + nToken - 1;
181684
181685 if( iBestStart>0 ){
181686 fts5HighlightAppend(&rc, &ctx, zEllips, -1);
@@ -180274,19 +181698,19 @@
181698 if( ctx.iRangeEnd>=(nColSize-1) ){
181699 fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);
181700 }else{
181701 fts5HighlightAppend(&rc, &ctx, zEllips, -1);
181702 }
181703 }
181704 if( rc==SQLITE_OK ){
181705 sqlite3_result_text(pCtx, (const char*)ctx.zOut, -1, SQLITE_TRANSIENT);
181706 }else{
181707 sqlite3_result_error_code(pCtx, rc);
181708 }
181709 sqlite3_free(ctx.zOut);
 
181710 sqlite3_free(aSeen);
181711 sqlite3_free(sFinder.aFirst);
181712 }
181713
181714 /************************************************************************/
181715
181716 /*
@@ -194153,11 +195577,11 @@
195577 int nArg, /* Number of args */
195578 sqlite3_value **apUnused /* Function arguments */
195579 ){
195580 assert( nArg==0 );
195581 UNUSED_PARAM2(nArg, apUnused);
195582 sqlite3_result_text(pCtx, "fts5: 2016-08-08 14:21:10 c3cd543f3380475509d7bab9bb6c7858a8402457", -1, SQLITE_TRANSIENT);
195583 }
195584
195585 static int fts5Init(sqlite3 *db){
195586 static const sqlite3_module fts5Mod = {
195587 /* iVersion */ 2,
195588
+8 -4
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -120,11 +120,11 @@
120120
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
121121
** [sqlite_version()] and [sqlite_source_id()].
122122
*/
123123
#define SQLITE_VERSION "3.15.0"
124124
#define SQLITE_VERSION_NUMBER 3015000
125
-#define SQLITE_SOURCE_ID "2016-08-22 20:10:01 7839519349c7371cdb4e16a215eacd27004cbc62"
125
+#define SQLITE_SOURCE_ID "2016-09-07 19:54:24 ddb5f0558c44569913d22781ab78f3e9b58d7aea"
126126
127127
/*
128128
** CAPI3REF: Run-Time Library Version Numbers
129129
** KEYWORDS: sqlite3_version, sqlite3_sourceid
130130
**
@@ -9217,16 +9217,16 @@
92179217
void **ppOut /* OUT: Buffer containing output changeset */
92189218
);
92199219
92209220
92219221
/*
9222
-** Changegroup handle.
9222
+** CAPI3REF: Changegroup Handle
92239223
*/
92249224
typedef struct sqlite3_changegroup sqlite3_changegroup;
92259225
92269226
/*
9227
-** CAPI3REF: Combine two or more changesets into a single changeset.
9227
+** CAPI3REF: Create A New Changegroup Object
92289228
**
92299229
** An sqlite3_changegroup object is used to combine two or more changesets
92309230
** (or patchsets) into a single changeset (or patchset). A single changegroup
92319231
** object may combine changesets or patchsets, but not both. The output is
92329232
** always in the same format as the input.
@@ -9259,10 +9259,12 @@
92599259
** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
92609260
*/
92619261
int sqlite3changegroup_new(sqlite3_changegroup **pp);
92629262
92639263
/*
9264
+** CAPI3REF: Add A Changeset To A Changegroup
9265
+**
92649266
** Add all changes within the changeset (or patchset) in buffer pData (size
92659267
** nData bytes) to the changegroup.
92669268
**
92679269
** If the buffer contains a patchset, then all prior calls to this function
92689270
** on the same changegroup object must also have specified patchsets. Or, if
@@ -9334,10 +9336,12 @@
93349336
** If no error occurs, SQLITE_OK is returned.
93359337
*/
93369338
int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
93379339
93389340
/*
9341
+** CAPI3REF: Obtain A Composite Changeset From A Changegroup
9342
+**
93399343
** Obtain a buffer containing a changeset (or patchset) representing the
93409344
** current contents of the changegroup. If the inputs to the changegroup
93419345
** were themselves changesets, the output is a changeset. Or, if the
93429346
** inputs were patchsets, the output is also a patchset.
93439347
**
@@ -9362,11 +9366,11 @@
93629366
int *pnData, /* OUT: Size of output buffer in bytes */
93639367
void **ppData /* OUT: Pointer to output buffer */
93649368
);
93659369
93669370
/*
9367
-** Delete a changegroup object.
9371
+** CAPI3REF: Delete A Changegroup Object
93689372
*/
93699373
void sqlite3changegroup_delete(sqlite3_changegroup*);
93709374
93719375
/*
93729376
** CAPI3REF: Apply A Changeset To A Database
93739377
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -120,11 +120,11 @@
120 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
121 ** [sqlite_version()] and [sqlite_source_id()].
122 */
123 #define SQLITE_VERSION "3.15.0"
124 #define SQLITE_VERSION_NUMBER 3015000
125 #define SQLITE_SOURCE_ID "2016-08-22 20:10:01 7839519349c7371cdb4e16a215eacd27004cbc62"
126
127 /*
128 ** CAPI3REF: Run-Time Library Version Numbers
129 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
130 **
@@ -9217,16 +9217,16 @@
9217 void **ppOut /* OUT: Buffer containing output changeset */
9218 );
9219
9220
9221 /*
9222 ** Changegroup handle.
9223 */
9224 typedef struct sqlite3_changegroup sqlite3_changegroup;
9225
9226 /*
9227 ** CAPI3REF: Combine two or more changesets into a single changeset.
9228 **
9229 ** An sqlite3_changegroup object is used to combine two or more changesets
9230 ** (or patchsets) into a single changeset (or patchset). A single changegroup
9231 ** object may combine changesets or patchsets, but not both. The output is
9232 ** always in the same format as the input.
@@ -9259,10 +9259,12 @@
9259 ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
9260 */
9261 int sqlite3changegroup_new(sqlite3_changegroup **pp);
9262
9263 /*
 
 
9264 ** Add all changes within the changeset (or patchset) in buffer pData (size
9265 ** nData bytes) to the changegroup.
9266 **
9267 ** If the buffer contains a patchset, then all prior calls to this function
9268 ** on the same changegroup object must also have specified patchsets. Or, if
@@ -9334,10 +9336,12 @@
9334 ** If no error occurs, SQLITE_OK is returned.
9335 */
9336 int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
9337
9338 /*
 
 
9339 ** Obtain a buffer containing a changeset (or patchset) representing the
9340 ** current contents of the changegroup. If the inputs to the changegroup
9341 ** were themselves changesets, the output is a changeset. Or, if the
9342 ** inputs were patchsets, the output is also a patchset.
9343 **
@@ -9362,11 +9366,11 @@
9362 int *pnData, /* OUT: Size of output buffer in bytes */
9363 void **ppData /* OUT: Pointer to output buffer */
9364 );
9365
9366 /*
9367 ** Delete a changegroup object.
9368 */
9369 void sqlite3changegroup_delete(sqlite3_changegroup*);
9370
9371 /*
9372 ** CAPI3REF: Apply A Changeset To A Database
9373
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -120,11 +120,11 @@
120 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
121 ** [sqlite_version()] and [sqlite_source_id()].
122 */
123 #define SQLITE_VERSION "3.15.0"
124 #define SQLITE_VERSION_NUMBER 3015000
125 #define SQLITE_SOURCE_ID "2016-09-07 19:54:24 ddb5f0558c44569913d22781ab78f3e9b58d7aea"
126
127 /*
128 ** CAPI3REF: Run-Time Library Version Numbers
129 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
130 **
@@ -9217,16 +9217,16 @@
9217 void **ppOut /* OUT: Buffer containing output changeset */
9218 );
9219
9220
9221 /*
9222 ** CAPI3REF: Changegroup Handle
9223 */
9224 typedef struct sqlite3_changegroup sqlite3_changegroup;
9225
9226 /*
9227 ** CAPI3REF: Create A New Changegroup Object
9228 **
9229 ** An sqlite3_changegroup object is used to combine two or more changesets
9230 ** (or patchsets) into a single changeset (or patchset). A single changegroup
9231 ** object may combine changesets or patchsets, but not both. The output is
9232 ** always in the same format as the input.
@@ -9259,10 +9259,12 @@
9259 ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
9260 */
9261 int sqlite3changegroup_new(sqlite3_changegroup **pp);
9262
9263 /*
9264 ** CAPI3REF: Add A Changeset To A Changegroup
9265 **
9266 ** Add all changes within the changeset (or patchset) in buffer pData (size
9267 ** nData bytes) to the changegroup.
9268 **
9269 ** If the buffer contains a patchset, then all prior calls to this function
9270 ** on the same changegroup object must also have specified patchsets. Or, if
@@ -9334,10 +9336,12 @@
9336 ** If no error occurs, SQLITE_OK is returned.
9337 */
9338 int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
9339
9340 /*
9341 ** CAPI3REF: Obtain A Composite Changeset From A Changegroup
9342 **
9343 ** Obtain a buffer containing a changeset (or patchset) representing the
9344 ** current contents of the changegroup. If the inputs to the changegroup
9345 ** were themselves changesets, the output is a changeset. Or, if the
9346 ** inputs were patchsets, the output is also a patchset.
9347 **
@@ -9362,11 +9366,11 @@
9366 int *pnData, /* OUT: Size of output buffer in bytes */
9367 void **ppData /* OUT: Pointer to output buffer */
9368 );
9369
9370 /*
9371 ** CAPI3REF: Delete A Changegroup Object
9372 */
9373 void sqlite3changegroup_delete(sqlite3_changegroup*);
9374
9375 /*
9376 ** CAPI3REF: Apply A Changeset To A Database
9377
+2 -2
--- src/zip.c
+++ src/zip.c
@@ -464,17 +464,17 @@
464464
** Generate a ZIP archive for a checkin specified by the uuid= query parameter.
465465
** Return that ZIP archive as the HTTP reply content.
466466
**
467467
** Query parameters:
468468
**
469
-** name=NAME[.tar.gz] The base name of the output file. The default
469
+** name=NAME[.zip] The base name of the output file. The default
470470
** value is a configuration parameter in the project
471471
** settings. A prefix of the name, omitting the extension,
472472
** is used as the top-most directory name.
473473
474474
**
475
-** uuid=TAG The check-in that is turned into a tarball.
475
+** uuid=TAG The check-in that is turned into a ZIP file.
476476
** Defaults to "trunk".
477477
**
478478
** in=PATTERN Only include files that match the comma-separate
479479
** list of GLOB patterns in PATTERN, as with ex=
480480
**
481481
--- src/zip.c
+++ src/zip.c
@@ -464,17 +464,17 @@
464 ** Generate a ZIP archive for a checkin specified by the uuid= query parameter.
465 ** Return that ZIP archive as the HTTP reply content.
466 **
467 ** Query parameters:
468 **
469 ** name=NAME[.tar.gz] The base name of the output file. The default
470 ** value is a configuration parameter in the project
471 ** settings. A prefix of the name, omitting the extension,
472 ** is used as the top-most directory name.
473
474 **
475 ** uuid=TAG The check-in that is turned into a tarball.
476 ** Defaults to "trunk".
477 **
478 ** in=PATTERN Only include files that match the comma-separate
479 ** list of GLOB patterns in PATTERN, as with ex=
480 **
481
--- src/zip.c
+++ src/zip.c
@@ -464,17 +464,17 @@
464 ** Generate a ZIP archive for a checkin specified by the uuid= query parameter.
465 ** Return that ZIP archive as the HTTP reply content.
466 **
467 ** Query parameters:
468 **
469 ** name=NAME[.zip] The base name of the output file. The default
470 ** value is a configuration parameter in the project
471 ** settings. A prefix of the name, omitting the extension,
472 ** is used as the top-most directory name.
473
474 **
475 ** uuid=TAG The check-in that is turned into a ZIP file.
476 ** Defaults to "trunk".
477 **
478 ** in=PATTERN Only include files that match the comma-separate
479 ** list of GLOB patterns in PATTERN, as with ex=
480 **
481

Keyboard Shortcuts

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