Fossil SCM

Get capabilities fix et al.

andybradford 2013-08-09 04:38 ssh-shared-account merge
Commit ebafd0c335da492d64e7e4a7088b8d3166849d4a
--- src/login.c
+++ src/login.c
@@ -1046,10 +1046,11 @@
10461046
** Zeroes out g.perm and calls login_set_capabilities(zCap,flags).
10471047
*/
10481048
void login_replace_capabilities(const char *zCap, unsigned flags){
10491049
memset(&g.perm, 0, sizeof(g.perm));
10501050
login_set_capabilities(zCap, flags);
1051
+ login_anon_once = 1;
10511052
}
10521053
10531054
/*
10541055
** If the current login lacks any of the capabilities listed in
10551056
** the input, then return 0. If all capabilities are present, then
10561057
--- src/login.c
+++ src/login.c
@@ -1046,10 +1046,11 @@
1046 ** Zeroes out g.perm and calls login_set_capabilities(zCap,flags).
1047 */
1048 void login_replace_capabilities(const char *zCap, unsigned flags){
1049 memset(&g.perm, 0, sizeof(g.perm));
1050 login_set_capabilities(zCap, flags);
 
1051 }
1052
1053 /*
1054 ** If the current login lacks any of the capabilities listed in
1055 ** the input, then return 0. If all capabilities are present, then
1056
--- src/login.c
+++ src/login.c
@@ -1046,10 +1046,11 @@
1046 ** Zeroes out g.perm and calls login_set_capabilities(zCap,flags).
1047 */
1048 void login_replace_capabilities(const char *zCap, unsigned flags){
1049 memset(&g.perm, 0, sizeof(g.perm));
1050 login_set_capabilities(zCap, flags);
1051 login_anon_once = 1;
1052 }
1053
1054 /*
1055 ** If the current login lacks any of the capabilities listed in
1056 ** the input, then return 0. If all capabilities are present, then
1057
+398 -373
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -656,11 +656,11 @@
656656
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657657
** [sqlite_version()] and [sqlite_source_id()].
658658
*/
659659
#define SQLITE_VERSION "3.8.0"
660660
#define SQLITE_VERSION_NUMBER 3008000
661
-#define SQLITE_SOURCE_ID "2013-08-05 12:31:41 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4"
661
+#define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084"
662662
663663
/*
664664
** CAPI3REF: Run-Time Library Version Numbers
665665
** KEYWORDS: sqlite3_version, sqlite3_sourceid
666666
**
@@ -8943,155 +8943,155 @@
89438943
*/
89448944
/************** Include opcodes.h in the middle of vdbe.h ********************/
89458945
/************** Begin file opcodes.h *****************************************/
89468946
/* Automatically generated. Do not edit */
89478947
/* See the mkopcodeh.awk script for details */
8948
-#define OP_Goto 1
8949
-#define OP_Gosub 2
8950
-#define OP_Return 3
8951
-#define OP_Yield 4
8952
-#define OP_HaltIfNull 5
8953
-#define OP_Halt 6
8954
-#define OP_Integer 7
8955
-#define OP_Int64 8
8956
-#define OP_Real 130 /* same as TK_FLOAT */
8957
-#define OP_String8 94 /* same as TK_STRING */
8958
-#define OP_String 9
8959
-#define OP_Null 10
8960
-#define OP_Blob 11
8961
-#define OP_Variable 12
8962
-#define OP_Move 13
8963
-#define OP_Copy 14
8964
-#define OP_SCopy 15
8965
-#define OP_ResultRow 16
8966
-#define OP_Concat 91 /* same as TK_CONCAT */
8948
+#define OP_Function 1
8949
+#define OP_Savepoint 2
8950
+#define OP_AutoCommit 3
8951
+#define OP_Transaction 4
8952
+#define OP_SorterNext 5
8953
+#define OP_Prev 6
8954
+#define OP_Next 7
8955
+#define OP_AggStep 8
8956
+#define OP_Checkpoint 9
8957
+#define OP_JournalMode 10
8958
+#define OP_Vacuum 11
8959
+#define OP_VFilter 12
8960
+#define OP_VUpdate 13
8961
+#define OP_Goto 14
8962
+#define OP_Gosub 15
8963
+#define OP_Return 16
8964
+#define OP_Yield 17
8965
+#define OP_HaltIfNull 18
8966
+#define OP_Not 19 /* same as TK_NOT */
8967
+#define OP_Halt 20
8968
+#define OP_Integer 21
8969
+#define OP_Int64 22
8970
+#define OP_String 23
8971
+#define OP_Null 24
8972
+#define OP_Blob 25
8973
+#define OP_Variable 26
8974
+#define OP_Move 27
8975
+#define OP_Copy 28
8976
+#define OP_SCopy 29
8977
+#define OP_ResultRow 30
8978
+#define OP_CollSeq 31
8979
+#define OP_AddImm 32
8980
+#define OP_MustBeInt 33
8981
+#define OP_RealAffinity 34
8982
+#define OP_Permutation 35
8983
+#define OP_Compare 36
8984
+#define OP_Jump 37
8985
+#define OP_Once 38
8986
+#define OP_If 39
8987
+#define OP_IfNot 40
8988
+#define OP_Column 41
8989
+#define OP_Affinity 42
8990
+#define OP_MakeRecord 43
8991
+#define OP_Count 44
8992
+#define OP_ReadCookie 45
8993
+#define OP_SetCookie 46
8994
+#define OP_VerifyCookie 47
8995
+#define OP_OpenRead 48
8996
+#define OP_OpenWrite 49
8997
+#define OP_OpenAutoindex 50
8998
+#define OP_OpenEphemeral 51
8999
+#define OP_SorterOpen 52
9000
+#define OP_OpenPseudo 53
9001
+#define OP_Close 54
9002
+#define OP_SeekLt 55
9003
+#define OP_SeekLe 56
9004
+#define OP_SeekGe 57
9005
+#define OP_SeekGt 58
9006
+#define OP_Seek 59
9007
+#define OP_NotFound 60
9008
+#define OP_Found 61
9009
+#define OP_IsUnique 62
9010
+#define OP_NotExists 63
9011
+#define OP_Sequence 64
9012
+#define OP_NewRowid 65
9013
+#define OP_Insert 66
9014
+#define OP_InsertInt 67
9015
+#define OP_Or 68 /* same as TK_OR */
9016
+#define OP_And 69 /* same as TK_AND */
9017
+#define OP_Delete 70
9018
+#define OP_ResetCount 71
9019
+#define OP_SorterCompare 72
9020
+#define OP_IsNull 73 /* same as TK_ISNULL */
9021
+#define OP_NotNull 74 /* same as TK_NOTNULL */
9022
+#define OP_Ne 75 /* same as TK_NE */
9023
+#define OP_Eq 76 /* same as TK_EQ */
9024
+#define OP_Gt 77 /* same as TK_GT */
9025
+#define OP_Le 78 /* same as TK_LE */
9026
+#define OP_Lt 79 /* same as TK_LT */
9027
+#define OP_Ge 80 /* same as TK_GE */
9028
+#define OP_SorterData 81
9029
+#define OP_BitAnd 82 /* same as TK_BITAND */
9030
+#define OP_BitOr 83 /* same as TK_BITOR */
9031
+#define OP_ShiftLeft 84 /* same as TK_LSHIFT */
9032
+#define OP_ShiftRight 85 /* same as TK_RSHIFT */
89679033
#define OP_Add 86 /* same as TK_PLUS */
89689034
#define OP_Subtract 87 /* same as TK_MINUS */
89699035
#define OP_Multiply 88 /* same as TK_STAR */
89709036
#define OP_Divide 89 /* same as TK_SLASH */
89719037
#define OP_Remainder 90 /* same as TK_REM */
8972
-#define OP_CollSeq 17
8973
-#define OP_Function 18
8974
-#define OP_BitAnd 82 /* same as TK_BITAND */
8975
-#define OP_BitOr 83 /* same as TK_BITOR */
8976
-#define OP_ShiftLeft 84 /* same as TK_LSHIFT */
8977
-#define OP_ShiftRight 85 /* same as TK_RSHIFT */
8978
-#define OP_AddImm 20
8979
-#define OP_MustBeInt 21
8980
-#define OP_RealAffinity 22
9038
+#define OP_Concat 91 /* same as TK_CONCAT */
9039
+#define OP_RowKey 92
9040
+#define OP_BitNot 93 /* same as TK_BITNOT */
9041
+#define OP_String8 94 /* same as TK_STRING */
9042
+#define OP_RowData 95
9043
+#define OP_Rowid 96
9044
+#define OP_NullRow 97
9045
+#define OP_Last 98
9046
+#define OP_SorterSort 99
9047
+#define OP_Sort 100
9048
+#define OP_Rewind 101
9049
+#define OP_SorterInsert 102
9050
+#define OP_IdxInsert 103
9051
+#define OP_IdxDelete 104
9052
+#define OP_IdxRowid 105
9053
+#define OP_IdxLT 106
9054
+#define OP_IdxGE 107
9055
+#define OP_Destroy 108
9056
+#define OP_Clear 109
9057
+#define OP_CreateIndex 110
9058
+#define OP_CreateTable 111
9059
+#define OP_ParseSchema 112
9060
+#define OP_LoadAnalysis 113
9061
+#define OP_DropTable 114
9062
+#define OP_DropIndex 115
9063
+#define OP_DropTrigger 116
9064
+#define OP_IntegrityCk 117
9065
+#define OP_RowSetAdd 118
9066
+#define OP_RowSetRead 119
9067
+#define OP_RowSetTest 120
9068
+#define OP_Program 121
9069
+#define OP_Param 122
9070
+#define OP_FkCounter 123
9071
+#define OP_FkIfZero 124
9072
+#define OP_MemMax 125
9073
+#define OP_IfPos 126
9074
+#define OP_IfNeg 127
9075
+#define OP_IfZero 128
9076
+#define OP_AggFinal 129
9077
+#define OP_Real 130 /* same as TK_FLOAT */
9078
+#define OP_IncrVacuum 131
9079
+#define OP_Expire 132
9080
+#define OP_TableLock 133
9081
+#define OP_VBegin 134
9082
+#define OP_VCreate 135
9083
+#define OP_VDestroy 136
9084
+#define OP_VOpen 137
9085
+#define OP_VColumn 138
9086
+#define OP_VNext 139
9087
+#define OP_VRename 140
89819088
#define OP_ToText 141 /* same as TK_TO_TEXT */
89829089
#define OP_ToBlob 142 /* same as TK_TO_BLOB */
89839090
#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
89849091
#define OP_ToInt 144 /* same as TK_TO_INT */
89859092
#define OP_ToReal 145 /* same as TK_TO_REAL */
8986
-#define OP_Eq 76 /* same as TK_EQ */
8987
-#define OP_Ne 75 /* same as TK_NE */
8988
-#define OP_Lt 79 /* same as TK_LT */
8989
-#define OP_Le 78 /* same as TK_LE */
8990
-#define OP_Gt 77 /* same as TK_GT */
8991
-#define OP_Ge 80 /* same as TK_GE */
8992
-#define OP_Permutation 23
8993
-#define OP_Compare 24
8994
-#define OP_Jump 25
8995
-#define OP_And 69 /* same as TK_AND */
8996
-#define OP_Or 68 /* same as TK_OR */
8997
-#define OP_Not 19 /* same as TK_NOT */
8998
-#define OP_BitNot 93 /* same as TK_BITNOT */
8999
-#define OP_Once 26
9000
-#define OP_If 27
9001
-#define OP_IfNot 28
9002
-#define OP_IsNull 73 /* same as TK_ISNULL */
9003
-#define OP_NotNull 74 /* same as TK_NOTNULL */
9004
-#define OP_Column 29
9005
-#define OP_Affinity 30
9006
-#define OP_MakeRecord 31
9007
-#define OP_Count 32
9008
-#define OP_Savepoint 33
9009
-#define OP_AutoCommit 34
9010
-#define OP_Transaction 35
9011
-#define OP_ReadCookie 36
9012
-#define OP_SetCookie 37
9013
-#define OP_VerifyCookie 38
9014
-#define OP_OpenRead 39
9015
-#define OP_OpenWrite 40
9016
-#define OP_OpenAutoindex 41
9017
-#define OP_OpenEphemeral 42
9018
-#define OP_SorterOpen 43
9019
-#define OP_OpenPseudo 44
9020
-#define OP_Close 45
9021
-#define OP_SeekLt 46
9022
-#define OP_SeekLe 47
9023
-#define OP_SeekGe 48
9024
-#define OP_SeekGt 49
9025
-#define OP_Seek 50
9026
-#define OP_NotFound 51
9027
-#define OP_Found 52
9028
-#define OP_IsUnique 53
9029
-#define OP_NotExists 54
9030
-#define OP_Sequence 55
9031
-#define OP_NewRowid 56
9032
-#define OP_Insert 57
9033
-#define OP_InsertInt 58
9034
-#define OP_Delete 59
9035
-#define OP_ResetCount 60
9036
-#define OP_SorterCompare 61
9037
-#define OP_SorterData 62
9038
-#define OP_RowKey 63
9039
-#define OP_RowData 64
9040
-#define OP_Rowid 65
9041
-#define OP_NullRow 66
9042
-#define OP_Last 67
9043
-#define OP_SorterSort 70
9044
-#define OP_Sort 71
9045
-#define OP_Rewind 72
9046
-#define OP_SorterNext 81
9047
-#define OP_Prev 92
9048
-#define OP_Next 95
9049
-#define OP_SorterInsert 96
9050
-#define OP_IdxInsert 97
9051
-#define OP_IdxDelete 98
9052
-#define OP_IdxRowid 99
9053
-#define OP_IdxLT 100
9054
-#define OP_IdxGE 101
9055
-#define OP_Destroy 102
9056
-#define OP_Clear 103
9057
-#define OP_CreateIndex 104
9058
-#define OP_CreateTable 105
9059
-#define OP_ParseSchema 106
9060
-#define OP_LoadAnalysis 107
9061
-#define OP_DropTable 108
9062
-#define OP_DropIndex 109
9063
-#define OP_DropTrigger 110
9064
-#define OP_IntegrityCk 111
9065
-#define OP_RowSetAdd 112
9066
-#define OP_RowSetRead 113
9067
-#define OP_RowSetTest 114
9068
-#define OP_Program 115
9069
-#define OP_Param 116
9070
-#define OP_FkCounter 117
9071
-#define OP_FkIfZero 118
9072
-#define OP_MemMax 119
9073
-#define OP_IfPos 120
9074
-#define OP_IfNeg 121
9075
-#define OP_IfZero 122
9076
-#define OP_AggStep 123
9077
-#define OP_AggFinal 124
9078
-#define OP_Checkpoint 125
9079
-#define OP_JournalMode 126
9080
-#define OP_Vacuum 127
9081
-#define OP_IncrVacuum 128
9082
-#define OP_Expire 129
9083
-#define OP_TableLock 131
9084
-#define OP_VBegin 132
9085
-#define OP_VCreate 133
9086
-#define OP_VDestroy 134
9087
-#define OP_VOpen 135
9088
-#define OP_VFilter 136
9089
-#define OP_VColumn 137
9090
-#define OP_VNext 138
9091
-#define OP_VRename 139
9092
-#define OP_VUpdate 140
90939093
#define OP_Pagecount 146
90949094
#define OP_MaxPgcnt 147
90959095
#define OP_Trace 148
90969096
#define OP_Noop 149
90979097
#define OP_Explain 150
@@ -9107,28 +9107,28 @@
91079107
#define OPFLG_IN2 0x0008 /* in2: P2 is an input */
91089108
#define OPFLG_IN3 0x0010 /* in3: P3 is an input */
91099109
#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
91109110
#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
91119111
#define OPFLG_INITIALIZER {\
9112
-/* 0 */ 0x00, 0x01, 0x01, 0x04, 0x04, 0x10, 0x00, 0x02,\
9113
-/* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x24,\
9114
-/* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\
9115
-/* 24 */ 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00,\
9116
-/* 32 */ 0x02, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00,\
9117
-/* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\
9118
-/* 48 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x02,\
9119
-/* 56 */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9120
-/* 64 */ 0x00, 0x02, 0x00, 0x01, 0x4c, 0x4c, 0x01, 0x01,\
9121
-/* 72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9122
-/* 80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9123
-/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x01,\
9124
-/* 96 */ 0x08, 0x08, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\
9125
-/* 104 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9126
-/* 112 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\
9127
-/* 120 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,\
9128
-/* 128 */ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
9129
-/* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\
9112
+/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
9113
+/* 8 */ 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01,\
9114
+/* 16 */ 0x04, 0x04, 0x10, 0x24, 0x00, 0x02, 0x02, 0x02,\
9115
+/* 24 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x24, 0x00, 0x00,\
9116
+/* 32 */ 0x04, 0x05, 0x04, 0x00, 0x00, 0x01, 0x01, 0x05,\
9117
+/* 40 */ 0x05, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,\
9118
+/* 48 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,\
9119
+/* 56 */ 0x11, 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11,\
9120
+/* 64 */ 0x02, 0x02, 0x00, 0x00, 0x4c, 0x4c, 0x00, 0x00,\
9121
+/* 72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9122
+/* 80 */ 0x15, 0x00, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9123
+/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x00, 0x24, 0x02, 0x00,\
9124
+/* 96 */ 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08,\
9125
+/* 104 */ 0x00, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02,\
9126
+/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\
9127
+/* 120 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x08, 0x05, 0x05,\
9128
+/* 128 */ 0x05, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,\
9129
+/* 136 */ 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04,\
91309130
/* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}
91319131
91329132
/************** End of opcodes.h *********************************************/
91339133
/************** Continuing where we left off in vdbe.h ***********************/
91349134
@@ -10672,16 +10672,20 @@
1067210672
1067310673
/*
1067410674
** An instance of the following structure is passed as the first
1067510675
** argument to sqlite3VdbeKeyCompare and is used to control the
1067610676
** comparison of the two index keys.
10677
+**
10678
+** Note that aSortOrder[] and aColl[] have nField+1 slots. There
10679
+** are nField slots for the columns of an index then one extra slot
10680
+** for the rowid at the end.
1067710681
*/
1067810682
struct KeyInfo {
1067910683
sqlite3 *db; /* The database connection */
1068010684
u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
10681
- u16 nField; /* Number of entries in aColl[] */
10682
- u8 *aSortOrder; /* Sort order for each column. May be NULL */
10685
+ u16 nField; /* Maximum index for aColl[] and aSortOrder[] */
10686
+ u8 *aSortOrder; /* Sort order for each column. */
1068310687
CollSeq *aColl[1]; /* Collating sequence for each term of the key */
1068410688
};
1068510689
1068610690
/*
1068710691
** An instance of the following structure holds information about a
@@ -11282,10 +11286,11 @@
1128211286
#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
1128311287
#define SF_UseSorter 0x0040 /* Sort using a sorter */
1128411288
#define SF_Values 0x0080 /* Synthesized from VALUES clause */
1128511289
#define SF_Materialize 0x0100 /* Force materialization of views */
1128611290
#define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
11291
+#define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
1128711292
1128811293
1128911294
/*
1129011295
** The results of a select can be distributed in several ways. The
1129111296
** "SRT" prefix means "SELECT Result Type".
@@ -11403,10 +11408,11 @@
1140311408
u8 nTempInUse; /* Number of aTempReg[] currently checked out */
1140411409
u8 nColCache; /* Number of entries in aColCache[] */
1140511410
u8 iColCache; /* Next entry in aColCache[] to replace */
1140611411
u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
1140711412
u8 mayAbort; /* True if statement may throw an ABORT exception */
11413
+ u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
1140811414
int aTempReg[8]; /* Holding area for temporary registers */
1140911415
int nRangeReg; /* Size of the temporary register block */
1141011416
int iRangeReg; /* First register in temporary register block */
1141111417
int nErr; /* Number of errors seen */
1141211418
int nTab; /* Number of previously allocated VDBE cursors */
@@ -12294,10 +12300,11 @@
1229412300
SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
1229512301
SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
1229612302
SQLITE_PRIVATE void sqlite3SchemaClear(void *);
1229712303
SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
1229812304
SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
12305
+SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int);
1229912306
SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
1230012307
SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
1230112308
void (*)(sqlite3_context*,int,sqlite3_value **),
1230212309
void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
1230312310
FuncDestructor *pDestructor
@@ -22693,91 +22700,91 @@
2269322700
/* Automatically generated. Do not edit */
2269422701
/* See the mkopcodec.awk script for details. */
2269522702
#if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
2269622703
SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
2269722704
static const char *const azName[] = { "?",
22698
- /* 1 */ "Goto",
22699
- /* 2 */ "Gosub",
22700
- /* 3 */ "Return",
22701
- /* 4 */ "Yield",
22702
- /* 5 */ "HaltIfNull",
22703
- /* 6 */ "Halt",
22704
- /* 7 */ "Integer",
22705
- /* 8 */ "Int64",
22706
- /* 9 */ "String",
22707
- /* 10 */ "Null",
22708
- /* 11 */ "Blob",
22709
- /* 12 */ "Variable",
22710
- /* 13 */ "Move",
22711
- /* 14 */ "Copy",
22712
- /* 15 */ "SCopy",
22713
- /* 16 */ "ResultRow",
22714
- /* 17 */ "CollSeq",
22715
- /* 18 */ "Function",
22705
+ /* 1 */ "Function",
22706
+ /* 2 */ "Savepoint",
22707
+ /* 3 */ "AutoCommit",
22708
+ /* 4 */ "Transaction",
22709
+ /* 5 */ "SorterNext",
22710
+ /* 6 */ "Prev",
22711
+ /* 7 */ "Next",
22712
+ /* 8 */ "AggStep",
22713
+ /* 9 */ "Checkpoint",
22714
+ /* 10 */ "JournalMode",
22715
+ /* 11 */ "Vacuum",
22716
+ /* 12 */ "VFilter",
22717
+ /* 13 */ "VUpdate",
22718
+ /* 14 */ "Goto",
22719
+ /* 15 */ "Gosub",
22720
+ /* 16 */ "Return",
22721
+ /* 17 */ "Yield",
22722
+ /* 18 */ "HaltIfNull",
2271622723
/* 19 */ "Not",
22717
- /* 20 */ "AddImm",
22718
- /* 21 */ "MustBeInt",
22719
- /* 22 */ "RealAffinity",
22720
- /* 23 */ "Permutation",
22721
- /* 24 */ "Compare",
22722
- /* 25 */ "Jump",
22723
- /* 26 */ "Once",
22724
- /* 27 */ "If",
22725
- /* 28 */ "IfNot",
22726
- /* 29 */ "Column",
22727
- /* 30 */ "Affinity",
22728
- /* 31 */ "MakeRecord",
22729
- /* 32 */ "Count",
22730
- /* 33 */ "Savepoint",
22731
- /* 34 */ "AutoCommit",
22732
- /* 35 */ "Transaction",
22733
- /* 36 */ "ReadCookie",
22734
- /* 37 */ "SetCookie",
22735
- /* 38 */ "VerifyCookie",
22736
- /* 39 */ "OpenRead",
22737
- /* 40 */ "OpenWrite",
22738
- /* 41 */ "OpenAutoindex",
22739
- /* 42 */ "OpenEphemeral",
22740
- /* 43 */ "SorterOpen",
22741
- /* 44 */ "OpenPseudo",
22742
- /* 45 */ "Close",
22743
- /* 46 */ "SeekLt",
22744
- /* 47 */ "SeekLe",
22745
- /* 48 */ "SeekGe",
22746
- /* 49 */ "SeekGt",
22747
- /* 50 */ "Seek",
22748
- /* 51 */ "NotFound",
22749
- /* 52 */ "Found",
22750
- /* 53 */ "IsUnique",
22751
- /* 54 */ "NotExists",
22752
- /* 55 */ "Sequence",
22753
- /* 56 */ "NewRowid",
22754
- /* 57 */ "Insert",
22755
- /* 58 */ "InsertInt",
22756
- /* 59 */ "Delete",
22757
- /* 60 */ "ResetCount",
22758
- /* 61 */ "SorterCompare",
22759
- /* 62 */ "SorterData",
22760
- /* 63 */ "RowKey",
22761
- /* 64 */ "RowData",
22762
- /* 65 */ "Rowid",
22763
- /* 66 */ "NullRow",
22764
- /* 67 */ "Last",
22724
+ /* 20 */ "Halt",
22725
+ /* 21 */ "Integer",
22726
+ /* 22 */ "Int64",
22727
+ /* 23 */ "String",
22728
+ /* 24 */ "Null",
22729
+ /* 25 */ "Blob",
22730
+ /* 26 */ "Variable",
22731
+ /* 27 */ "Move",
22732
+ /* 28 */ "Copy",
22733
+ /* 29 */ "SCopy",
22734
+ /* 30 */ "ResultRow",
22735
+ /* 31 */ "CollSeq",
22736
+ /* 32 */ "AddImm",
22737
+ /* 33 */ "MustBeInt",
22738
+ /* 34 */ "RealAffinity",
22739
+ /* 35 */ "Permutation",
22740
+ /* 36 */ "Compare",
22741
+ /* 37 */ "Jump",
22742
+ /* 38 */ "Once",
22743
+ /* 39 */ "If",
22744
+ /* 40 */ "IfNot",
22745
+ /* 41 */ "Column",
22746
+ /* 42 */ "Affinity",
22747
+ /* 43 */ "MakeRecord",
22748
+ /* 44 */ "Count",
22749
+ /* 45 */ "ReadCookie",
22750
+ /* 46 */ "SetCookie",
22751
+ /* 47 */ "VerifyCookie",
22752
+ /* 48 */ "OpenRead",
22753
+ /* 49 */ "OpenWrite",
22754
+ /* 50 */ "OpenAutoindex",
22755
+ /* 51 */ "OpenEphemeral",
22756
+ /* 52 */ "SorterOpen",
22757
+ /* 53 */ "OpenPseudo",
22758
+ /* 54 */ "Close",
22759
+ /* 55 */ "SeekLt",
22760
+ /* 56 */ "SeekLe",
22761
+ /* 57 */ "SeekGe",
22762
+ /* 58 */ "SeekGt",
22763
+ /* 59 */ "Seek",
22764
+ /* 60 */ "NotFound",
22765
+ /* 61 */ "Found",
22766
+ /* 62 */ "IsUnique",
22767
+ /* 63 */ "NotExists",
22768
+ /* 64 */ "Sequence",
22769
+ /* 65 */ "NewRowid",
22770
+ /* 66 */ "Insert",
22771
+ /* 67 */ "InsertInt",
2276522772
/* 68 */ "Or",
2276622773
/* 69 */ "And",
22767
- /* 70 */ "SorterSort",
22768
- /* 71 */ "Sort",
22769
- /* 72 */ "Rewind",
22774
+ /* 70 */ "Delete",
22775
+ /* 71 */ "ResetCount",
22776
+ /* 72 */ "SorterCompare",
2277022777
/* 73 */ "IsNull",
2277122778
/* 74 */ "NotNull",
2277222779
/* 75 */ "Ne",
2277322780
/* 76 */ "Eq",
2277422781
/* 77 */ "Gt",
2277522782
/* 78 */ "Le",
2277622783
/* 79 */ "Lt",
2277722784
/* 80 */ "Ge",
22778
- /* 81 */ "SorterNext",
22785
+ /* 81 */ "SorterData",
2277922786
/* 82 */ "BitAnd",
2278022787
/* 83 */ "BitOr",
2278122788
/* 84 */ "ShiftLeft",
2278222789
/* 85 */ "ShiftRight",
2278322790
/* 86 */ "Add",
@@ -22784,59 +22791,59 @@
2278422791
/* 87 */ "Subtract",
2278522792
/* 88 */ "Multiply",
2278622793
/* 89 */ "Divide",
2278722794
/* 90 */ "Remainder",
2278822795
/* 91 */ "Concat",
22789
- /* 92 */ "Prev",
22796
+ /* 92 */ "RowKey",
2279022797
/* 93 */ "BitNot",
2279122798
/* 94 */ "String8",
22792
- /* 95 */ "Next",
22793
- /* 96 */ "SorterInsert",
22794
- /* 97 */ "IdxInsert",
22795
- /* 98 */ "IdxDelete",
22796
- /* 99 */ "IdxRowid",
22797
- /* 100 */ "IdxLT",
22798
- /* 101 */ "IdxGE",
22799
- /* 102 */ "Destroy",
22800
- /* 103 */ "Clear",
22801
- /* 104 */ "CreateIndex",
22802
- /* 105 */ "CreateTable",
22803
- /* 106 */ "ParseSchema",
22804
- /* 107 */ "LoadAnalysis",
22805
- /* 108 */ "DropTable",
22806
- /* 109 */ "DropIndex",
22807
- /* 110 */ "DropTrigger",
22808
- /* 111 */ "IntegrityCk",
22809
- /* 112 */ "RowSetAdd",
22810
- /* 113 */ "RowSetRead",
22811
- /* 114 */ "RowSetTest",
22812
- /* 115 */ "Program",
22813
- /* 116 */ "Param",
22814
- /* 117 */ "FkCounter",
22815
- /* 118 */ "FkIfZero",
22816
- /* 119 */ "MemMax",
22817
- /* 120 */ "IfPos",
22818
- /* 121 */ "IfNeg",
22819
- /* 122 */ "IfZero",
22820
- /* 123 */ "AggStep",
22821
- /* 124 */ "AggFinal",
22822
- /* 125 */ "Checkpoint",
22823
- /* 126 */ "JournalMode",
22824
- /* 127 */ "Vacuum",
22825
- /* 128 */ "IncrVacuum",
22826
- /* 129 */ "Expire",
22799
+ /* 95 */ "RowData",
22800
+ /* 96 */ "Rowid",
22801
+ /* 97 */ "NullRow",
22802
+ /* 98 */ "Last",
22803
+ /* 99 */ "SorterSort",
22804
+ /* 100 */ "Sort",
22805
+ /* 101 */ "Rewind",
22806
+ /* 102 */ "SorterInsert",
22807
+ /* 103 */ "IdxInsert",
22808
+ /* 104 */ "IdxDelete",
22809
+ /* 105 */ "IdxRowid",
22810
+ /* 106 */ "IdxLT",
22811
+ /* 107 */ "IdxGE",
22812
+ /* 108 */ "Destroy",
22813
+ /* 109 */ "Clear",
22814
+ /* 110 */ "CreateIndex",
22815
+ /* 111 */ "CreateTable",
22816
+ /* 112 */ "ParseSchema",
22817
+ /* 113 */ "LoadAnalysis",
22818
+ /* 114 */ "DropTable",
22819
+ /* 115 */ "DropIndex",
22820
+ /* 116 */ "DropTrigger",
22821
+ /* 117 */ "IntegrityCk",
22822
+ /* 118 */ "RowSetAdd",
22823
+ /* 119 */ "RowSetRead",
22824
+ /* 120 */ "RowSetTest",
22825
+ /* 121 */ "Program",
22826
+ /* 122 */ "Param",
22827
+ /* 123 */ "FkCounter",
22828
+ /* 124 */ "FkIfZero",
22829
+ /* 125 */ "MemMax",
22830
+ /* 126 */ "IfPos",
22831
+ /* 127 */ "IfNeg",
22832
+ /* 128 */ "IfZero",
22833
+ /* 129 */ "AggFinal",
2282722834
/* 130 */ "Real",
22828
- /* 131 */ "TableLock",
22829
- /* 132 */ "VBegin",
22830
- /* 133 */ "VCreate",
22831
- /* 134 */ "VDestroy",
22832
- /* 135 */ "VOpen",
22833
- /* 136 */ "VFilter",
22834
- /* 137 */ "VColumn",
22835
- /* 138 */ "VNext",
22836
- /* 139 */ "VRename",
22837
- /* 140 */ "VUpdate",
22835
+ /* 131 */ "IncrVacuum",
22836
+ /* 132 */ "Expire",
22837
+ /* 133 */ "TableLock",
22838
+ /* 134 */ "VBegin",
22839
+ /* 135 */ "VCreate",
22840
+ /* 136 */ "VDestroy",
22841
+ /* 137 */ "VOpen",
22842
+ /* 138 */ "VColumn",
22843
+ /* 139 */ "VNext",
22844
+ /* 140 */ "VRename",
2283822845
/* 141 */ "ToText",
2283922846
/* 142 */ "ToBlob",
2284022847
/* 143 */ "ToNumeric",
2284122848
/* 144 */ "ToInt",
2284222849
/* 145 */ "ToReal",
@@ -60361,44 +60368,64 @@
6036160368
p->readOnly = 1;
6036260369
p->bIsReader = 0;
6036360370
for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
6036460371
u8 opcode = pOp->opcode;
6036560372
60366
- pOp->opflags = sqlite3OpcodeProperty[opcode];
60367
- if( opcode==OP_Function || opcode==OP_AggStep ){
60368
- if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60369
- }else if( opcode==OP_Transaction ){
60370
- if( pOp->p2!=0 ) p->readOnly = 0;
60371
- p->bIsReader = 1;
60372
- }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
60373
- p->bIsReader = 1;
60374
- }else if( opcode==OP_Vacuum
60375
- || opcode==OP_JournalMode
60373
+ /* NOTE: Be sure to update mkopcodeh.awk when adding or removing
60374
+ ** cases from this switch! */
60375
+ switch( opcode ){
60376
+ case OP_Function:
60377
+ case OP_AggStep: {
60378
+ if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60379
+ break;
60380
+ }
60381
+ case OP_Transaction: {
60382
+ if( pOp->p2!=0 ) p->readOnly = 0;
60383
+ /* fall thru */
60384
+ }
60385
+ case OP_AutoCommit:
60386
+ case OP_Savepoint: {
60387
+ p->bIsReader = 1;
60388
+ break;
60389
+ }
6037660390
#ifndef SQLITE_OMIT_WAL
60377
- || opcode==OP_Checkpoint
60391
+ case OP_Checkpoint:
6037860392
#endif
60379
- ){
60380
- p->readOnly = 0;
60381
- p->bIsReader = 1;
60393
+ case OP_Vacuum:
60394
+ case OP_JournalMode: {
60395
+ p->readOnly = 0;
60396
+ p->bIsReader = 1;
60397
+ break;
60398
+ }
6038260399
#ifndef SQLITE_OMIT_VIRTUALTABLE
60383
- }else if( opcode==OP_VUpdate ){
60384
- if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60385
- }else if( opcode==OP_VFilter ){
60386
- int n;
60387
- assert( p->nOp - i >= 3 );
60388
- assert( pOp[-1].opcode==OP_Integer );
60389
- n = pOp[-1].p1;
60390
- if( n>nMaxArgs ) nMaxArgs = n;
60391
-#endif
60392
- }else if( opcode==OP_Next || opcode==OP_SorterNext ){
60393
- pOp->p4.xAdvance = sqlite3BtreeNext;
60394
- pOp->p4type = P4_ADVANCE;
60395
- }else if( opcode==OP_Prev ){
60396
- pOp->p4.xAdvance = sqlite3BtreePrevious;
60397
- pOp->p4type = P4_ADVANCE;
60398
- }
60399
-
60400
+ case OP_VUpdate: {
60401
+ if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60402
+ break;
60403
+ }
60404
+ case OP_VFilter: {
60405
+ int n;
60406
+ assert( p->nOp - i >= 3 );
60407
+ assert( pOp[-1].opcode==OP_Integer );
60408
+ n = pOp[-1].p1;
60409
+ if( n>nMaxArgs ) nMaxArgs = n;
60410
+ break;
60411
+ }
60412
+#endif
60413
+ case OP_Next:
60414
+ case OP_SorterNext: {
60415
+ pOp->p4.xAdvance = sqlite3BtreeNext;
60416
+ pOp->p4type = P4_ADVANCE;
60417
+ break;
60418
+ }
60419
+ case OP_Prev: {
60420
+ pOp->p4.xAdvance = sqlite3BtreePrevious;
60421
+ pOp->p4type = P4_ADVANCE;
60422
+ break;
60423
+ }
60424
+ }
60425
+
60426
+ pOp->opflags = sqlite3OpcodeProperty[opcode];
6040060427
if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
6040160428
assert( -1-pOp->p2<p->nLabel );
6040260429
pOp->p2 = aLabel[-1-pOp->p2];
6040360430
}
6040460431
}
@@ -60683,24 +60710,17 @@
6068360710
pOp->p4type = P4_INT32;
6068460711
}else if( zP4==0 ){
6068560712
pOp->p4.p = 0;
6068660713
pOp->p4type = P4_NOTUSED;
6068760714
}else if( n==P4_KEYINFO ){
60688
- KeyInfo *pKeyInfo;
60689
- int nField, nByte;
60690
-
60691
- nField = ((KeyInfo*)zP4)->nField;
60692
- nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField;
60693
- pKeyInfo = sqlite3DbMallocRaw(0, nByte);
60694
- pOp->p4.pKeyInfo = pKeyInfo;
60695
- if( pKeyInfo ){
60696
- u8 *aSortOrder;
60697
- memcpy((char*)pKeyInfo, zP4, nByte - nField);
60698
- aSortOrder = pKeyInfo->aSortOrder;
60699
- assert( aSortOrder!=0 );
60700
- pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField];
60701
- memcpy(pKeyInfo->aSortOrder, aSortOrder, nField);
60715
+ KeyInfo *pOrig, *pNew;
60716
+
60717
+ pOrig = (KeyInfo*)zP4;
60718
+ pOp->p4.pKeyInfo = pNew = sqlite3KeyInfoAlloc(db, pOrig->nField);
60719
+ if( pNew ){
60720
+ memcpy(pNew->aColl, pOrig->aColl, pOrig->nField*sizeof(pNew->aColl[0]));
60721
+ memcpy(pNew->aSortOrder, pOrig->aSortOrder, pOrig->nField);
6070260722
pOp->p4type = P4_KEYINFO;
6070360723
}else{
6070460724
p->db->mallocFailed = 1;
6070560725
pOp->p4type = P4_NOTUSED;
6070660726
}
@@ -62947,11 +62967,10 @@
6294762967
){
6294862968
u32 d1; /* Offset into aKey[] of next data element */
6294962969
u32 idx1; /* Offset into aKey[] of next header element */
6295062970
u32 szHdr1; /* Number of bytes in header */
6295162971
int i = 0;
62952
- int nField;
6295362972
int rc = 0;
6295462973
const unsigned char *aKey1 = (const unsigned char *)pKey1;
6295562974
KeyInfo *pKeyInfo;
6295662975
Mem mem1;
6295762976
@@ -62970,32 +62989,42 @@
6297062989
*/
6297162990
/* mem1.u.i = 0; // not needed, here to silence compiler warning */
6297262991
6297362992
idx1 = getVarint32(aKey1, szHdr1);
6297462993
d1 = szHdr1;
62975
- nField = pKeyInfo->nField;
62994
+ assert( pKeyInfo->nField+1>=pPKey2->nField );
6297662995
assert( pKeyInfo->aSortOrder!=0 );
6297762996
while( idx1<szHdr1 && i<pPKey2->nField ){
6297862997
u32 serial_type1;
6297962998
6298062999
/* Read the serial types for the next element in each key. */
6298163000
idx1 += getVarint32( aKey1+idx1, serial_type1 );
62982
- if( d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 ) break;
63001
+
63002
+ /* Verify that there is enough key space remaining to avoid
63003
+ ** a buffer overread. The "d1+serial_type1+2" subexpression will
63004
+ ** always be greater than or equal to the amount of required key space.
63005
+ ** Use that approximation to avoid the more expensive call to
63006
+ ** sqlite3VdbeSerialTypeLen() in the common case.
63007
+ */
63008
+ if( d1+serial_type1+2>(u32)nKey1
63009
+ && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1
63010
+ ){
63011
+ break;
63012
+ }
6298363013
6298463014
/* Extract the values to be compared.
6298563015
*/
6298663016
d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
6298763017
6298863018
/* Do the comparison
6298963019
*/
62990
- rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
62991
- i<nField ? pKeyInfo->aColl[i] : 0);
63020
+ rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);
6299263021
if( rc!=0 ){
6299363022
assert( mem1.zMalloc==0 ); /* See comment below */
6299463023
6299563024
/* Invert the result if we are using DESC sort order. */
62996
- if( i<nField && pKeyInfo->aSortOrder[i] ){
63025
+ if( pKeyInfo->aSortOrder[i] ){
6299763026
rc = -rc;
6299863027
}
6299963028
6300063029
/* If the PREFIX_SEARCH flag is set and all fields except the final
6300163030
** rowid field were equal, then clear the PREFIX_SEARCH flag and set
@@ -65475,11 +65504,11 @@
6547565504
u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
6547665505
u8 encoding = ENC(db); /* The database encoding */
6547765506
int iCompare = 0; /* Result of last OP_Compare operation */
6547865507
unsigned nVmStep = 0; /* Number of virtual machine steps */
6547965508
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65480
- unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
65509
+ unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
6548165510
#endif
6548265511
Mem *aMem = p->aMem; /* Copy of p->aMem */
6548365512
Mem *pIn1 = 0; /* 1st input operand */
6548465513
Mem *pIn2 = 0; /* 2nd input operand */
6548565514
Mem *pIn3 = 0; /* 3rd input operand */
@@ -77063,14 +77092,13 @@
7706377092
#endif
7706477093
7706577094
switch( pExpr->op ){
7706677095
case TK_IN: {
7706777096
char affinity; /* Affinity of the LHS of the IN */
77068
- KeyInfo keyInfo; /* Keyinfo for the generated table */
77069
- static u8 sortOrder = 0; /* Fake aSortOrder for keyInfo */
7707077097
int addr; /* Address of OP_OpenEphemeral instruction */
7707177098
Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
77099
+ KeyInfo *pKeyInfo = 0; /* Key information */
7707277100
7707377101
if( rMayHaveNull ){
7707477102
sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);
7707577103
}
7707677104
@@ -77090,13 +77118,11 @@
7709077118
** is used.
7709177119
*/
7709277120
pExpr->iTable = pParse->nTab++;
7709377121
addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
7709477122
if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
77095
- memset(&keyInfo, 0, sizeof(keyInfo));
77096
- keyInfo.nField = 1;
77097
- keyInfo.aSortOrder = &sortOrder;
77123
+ pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1);
7709877124
7709977125
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
7710077126
/* Case 1: expr IN (SELECT ...)
7710177127
**
7710277128
** Generate code to write the results of the select into the temporary
@@ -77109,15 +77135,16 @@
7710977135
sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
7711077136
dest.affSdst = (u8)affinity;
7711177137
assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
7711277138
pExpr->x.pSelect->iLimit = 0;
7711377139
if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
77140
+ sqlite3DbFree(pParse->db, pKeyInfo);
7711477141
return 0;
7711577142
}
7711677143
pEList = pExpr->x.pSelect->pEList;
77117
- if( ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77118
- keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
77144
+ if( pKeyInfo && ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77145
+ pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
7711977146
pEList->a[0].pExpr);
7712077147
}
7712177148
}else if( ALWAYS(pExpr->x.pList!=0) ){
7712277149
/* Case 2: expr IN (exprlist)
7712377150
**
@@ -77132,12 +77159,13 @@
7713277159
int r1, r2, r3;
7713377160
7713477161
if( !affinity ){
7713577162
affinity = SQLITE_AFF_NONE;
7713677163
}
77137
- keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77138
- keyInfo.aSortOrder = &sortOrder;
77164
+ if( pKeyInfo ){
77165
+ pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77166
+ }
7713977167
7714077168
/* Loop through each expression in <exprlist>. */
7714177169
r1 = sqlite3GetTempReg(pParse);
7714277170
r2 = sqlite3GetTempReg(pParse);
7714377171
sqlite3VdbeAddOp2(v, OP_Null, 0, r2);
@@ -77172,12 +77200,12 @@
7717277200
}
7717377201
}
7717477202
sqlite3ReleaseTempReg(pParse, r1);
7717577203
sqlite3ReleaseTempReg(pParse, r2);
7717677204
}
77177
- if( !isRowid ){
77178
- sqlite3VdbeChangeP4(v, addr, (void *)&keyInfo, P4_KEYINFO);
77205
+ if( pKeyInfo ){
77206
+ sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO_HANDOFF);
7717977207
}
7718077208
break;
7718177209
}
7718277210
7718377211
case TK_EXISTS:
@@ -86192,29 +86220,24 @@
8619286220
** the error.
8619386221
*/
8619486222
SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
8619586223
int i;
8619686224
int nCol = pIdx->nColumn;
86197
- int nBytes = sizeof(KeyInfo) + (nCol-1)*sizeof(CollSeq*) + nCol;
86198
- sqlite3 *db = pParse->db;
86199
- KeyInfo *pKey = (KeyInfo *)sqlite3DbMallocZero(db, nBytes);
86200
-
86201
- if( pKey ){
86202
- pKey->db = pParse->db;
86203
- pKey->aSortOrder = (u8 *)&(pKey->aColl[nCol]);
86204
- assert( &pKey->aSortOrder[nCol]==&(((u8 *)pKey)[nBytes]) );
86225
+ KeyInfo *pKey;
86226
+
86227
+ pKey = sqlite3KeyInfoAlloc(pParse->db, nCol);
86228
+ if( pKey ){
8620586229
for(i=0; i<nCol; i++){
8620686230
char *zColl = pIdx->azColl[i];
8620786231
assert( zColl );
8620886232
pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);
8620986233
pKey->aSortOrder[i] = pIdx->aSortOrder[i];
8621086234
}
86211
- pKey->nField = (u16)nCol;
8621286235
}
8621386236
8621486237
if( pParse->nErr ){
86215
- sqlite3DbFree(db, pKey);
86238
+ sqlite3DbFree(pParse->db, pKey);
8621686239
pKey = 0;
8621786240
}
8621886241
return pKey;
8621986242
}
8622086243
@@ -97148,10 +97171,29 @@
9714897171
*/
9714997172
if( pOrderBy==0 && p->iLimit ){
9715097173
sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
9715197174
}
9715297175
}
97176
+
97177
+/*
97178
+** Allocate a KeyInfo object sufficient for an index of N columns.
97179
+**
97180
+** Actually, always allocate one extra column for the rowid at the end
97181
+** of the index. So the KeyInfo returned will have space sufficient for
97182
+** N+1 columns.
97183
+*/
97184
+SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N){
97185
+ KeyInfo *p = sqlite3DbMallocZero(db,
97186
+ sizeof(KeyInfo) + (N+1)*(sizeof(CollSeq*)+1));
97187
+ if( p ){
97188
+ p->aSortOrder = (u8*)&p->aColl[N+1];
97189
+ p->nField = (u16)N;
97190
+ p->enc = ENC(db);
97191
+ p->db = db;
97192
+ }
97193
+ return p;
97194
+}
9715397195
9715497196
/*
9715597197
** Given an expression list, generate a KeyInfo structure that records
9715697198
** the collating sequence for each expression in that expression list.
9715797199
**
@@ -97165,29 +97207,23 @@
9716597207
** function is responsible for seeing that this structure is eventually
9716697208
** freed. Add the KeyInfo structure to the P4 field of an opcode using
9716797209
** P4_KEYINFO_HANDOFF is the usual way of dealing with this.
9716897210
*/
9716997211
static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){
97170
- sqlite3 *db = pParse->db;
9717197212
int nExpr;
9717297213
KeyInfo *pInfo;
9717397214
struct ExprList_item *pItem;
97215
+ sqlite3 *db = pParse->db;
9717497216
int i;
9717597217
9717697218
nExpr = pList->nExpr;
97177
- pInfo = sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(sizeof(CollSeq*)+1) );
97219
+ pInfo = sqlite3KeyInfoAlloc(db, nExpr);
9717897220
if( pInfo ){
97179
- pInfo->aSortOrder = (u8*)&pInfo->aColl[nExpr];
97180
- pInfo->nField = (u16)nExpr;
97181
- pInfo->enc = ENC(db);
97182
- pInfo->db = db;
9718397221
for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
9718497222
CollSeq *pColl;
9718597223
pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
97186
- if( !pColl ){
97187
- pColl = db->pDfltColl;
97188
- }
97224
+ if( !pColl ) pColl = db->pDfltColl;
9718997225
pInfo->aColl[i] = pColl;
9719097226
pInfo->aSortOrder[i] = pItem->sortOrder;
9719197227
}
9719297228
}
9719397229
return pInfo;
@@ -98289,27 +98325,21 @@
9828998325
CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
9829098326
int nCol; /* Number of columns in result set */
9829198327
9829298328
assert( p->pRightmost==p );
9829398329
nCol = p->pEList->nExpr;
98294
- pKeyInfo = sqlite3DbMallocZero(db,
98295
- sizeof(*pKeyInfo)+nCol*(sizeof(CollSeq*) + 1));
98330
+ pKeyInfo = sqlite3KeyInfoAlloc(db, nCol);
9829698331
if( !pKeyInfo ){
9829798332
rc = SQLITE_NOMEM;
9829898333
goto multi_select_end;
9829998334
}
98300
-
98301
- pKeyInfo->enc = ENC(db);
98302
- pKeyInfo->nField = (u16)nCol;
98303
-
9830498335
for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){
9830598336
*apColl = multiSelectCollSeq(pParse, p, i);
9830698337
if( 0==*apColl ){
9830798338
*apColl = db->pDfltColl;
9830898339
}
9830998340
}
98310
- pKeyInfo->aSortOrder = (u8*)apColl;
9831198341
9831298342
for(pLoop=p; pLoop; pLoop=pLoop->pPrior){
9831398343
for(i=0; i<2; i++){
9831498344
int addr = pLoop->addrOpenEphm[i];
9831598345
if( addr<0 ){
@@ -98674,16 +98704,12 @@
9867498704
struct ExprList_item *pItem;
9867598705
for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
9867698706
assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr );
9867798707
aPermute[i] = pItem->iOrderByCol - 1;
9867898708
}
98679
- pKeyMerge =
98680
- sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq*)+1));
98709
+ pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy);
9868198710
if( pKeyMerge ){
98682
- pKeyMerge->aSortOrder = (u8*)&pKeyMerge->aColl[nOrderBy];
98683
- pKeyMerge->nField = (u16)nOrderBy;
98684
- pKeyMerge->enc = ENC(db);
9868598711
for(i=0; i<nOrderBy; i++){
9868698712
CollSeq *pColl;
9868798713
Expr *pTerm = pOrderBy->a[i].pExpr;
9868898714
if( pTerm->flags & EP_Collate ){
9868998715
pColl = sqlite3ExprCollSeq(pParse, pTerm);
@@ -98716,16 +98742,12 @@
9871698742
int nExpr = p->pEList->nExpr;
9871798743
assert( nOrderBy>=nExpr || db->mallocFailed );
9871898744
regPrev = pParse->nMem+1;
9871998745
pParse->nMem += nExpr+1;
9872098746
sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);
98721
- pKeyDup = sqlite3DbMallocZero(db,
98722
- sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq*)+1) );
98747
+ pKeyDup = sqlite3KeyInfoAlloc(db, nExpr);
9872398748
if( pKeyDup ){
98724
- pKeyDup->aSortOrder = (u8*)&pKeyDup->aColl[nExpr];
98725
- pKeyDup->nField = (u16)nExpr;
98726
- pKeyDup->enc = ENC(db);
9872798749
for(i=0; i<nExpr; i++){
9872898750
pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
9872998751
pKeyDup->aSortOrder[i] = 0;
9873098752
}
9873198753
}
@@ -99987,14 +100009,16 @@
99987100009
** and/or pParse->db->mallocFailed.
99988100010
*/
99989100011
static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
99990100012
Walker w;
99991100013
memset(&w, 0, sizeof(w));
99992
- w.xSelectCallback = convertCompoundSelectToSubquery;
99993100014
w.xExprCallback = exprWalkNoop;
99994100015
w.pParse = pParse;
99995
- sqlite3WalkSelect(&w, pSelect);
100016
+ if( pParse->hasCompound ){
100017
+ w.xSelectCallback = convertCompoundSelectToSubquery;
100018
+ sqlite3WalkSelect(&w, pSelect);
100019
+ }
99996100020
w.xSelectCallback = selectExpander;
99997100021
sqlite3WalkSelect(&w, pSelect);
99998100022
}
99999100023
100000100024
@@ -113204,10 +113228,11 @@
113204113228
case 114: /* select ::= select multiselect_op oneselect */
113205113229
{
113206113230
if( yymsp[0].minor.yy159 ){
113207113231
yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
113208113232
yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
113233
+ if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1;
113209113234
}else{
113210113235
sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
113211113236
}
113212113237
yygotominor.yy159 = yymsp[0].minor.yy159;
113213113238
}
113214113239
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -656,11 +656,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.8.0"
660 #define SQLITE_VERSION_NUMBER 3008000
661 #define SQLITE_SOURCE_ID "2013-08-05 12:31:41 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -8943,155 +8943,155 @@
8943 */
8944 /************** Include opcodes.h in the middle of vdbe.h ********************/
8945 /************** Begin file opcodes.h *****************************************/
8946 /* Automatically generated. Do not edit */
8947 /* See the mkopcodeh.awk script for details */
8948 #define OP_Goto 1
8949 #define OP_Gosub 2
8950 #define OP_Return 3
8951 #define OP_Yield 4
8952 #define OP_HaltIfNull 5
8953 #define OP_Halt 6
8954 #define OP_Integer 7
8955 #define OP_Int64 8
8956 #define OP_Real 130 /* same as TK_FLOAT */
8957 #define OP_String8 94 /* same as TK_STRING */
8958 #define OP_String 9
8959 #define OP_Null 10
8960 #define OP_Blob 11
8961 #define OP_Variable 12
8962 #define OP_Move 13
8963 #define OP_Copy 14
8964 #define OP_SCopy 15
8965 #define OP_ResultRow 16
8966 #define OP_Concat 91 /* same as TK_CONCAT */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8967 #define OP_Add 86 /* same as TK_PLUS */
8968 #define OP_Subtract 87 /* same as TK_MINUS */
8969 #define OP_Multiply 88 /* same as TK_STAR */
8970 #define OP_Divide 89 /* same as TK_SLASH */
8971 #define OP_Remainder 90 /* same as TK_REM */
8972 #define OP_CollSeq 17
8973 #define OP_Function 18
8974 #define OP_BitAnd 82 /* same as TK_BITAND */
8975 #define OP_BitOr 83 /* same as TK_BITOR */
8976 #define OP_ShiftLeft 84 /* same as TK_LSHIFT */
8977 #define OP_ShiftRight 85 /* same as TK_RSHIFT */
8978 #define OP_AddImm 20
8979 #define OP_MustBeInt 21
8980 #define OP_RealAffinity 22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8981 #define OP_ToText 141 /* same as TK_TO_TEXT */
8982 #define OP_ToBlob 142 /* same as TK_TO_BLOB */
8983 #define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
8984 #define OP_ToInt 144 /* same as TK_TO_INT */
8985 #define OP_ToReal 145 /* same as TK_TO_REAL */
8986 #define OP_Eq 76 /* same as TK_EQ */
8987 #define OP_Ne 75 /* same as TK_NE */
8988 #define OP_Lt 79 /* same as TK_LT */
8989 #define OP_Le 78 /* same as TK_LE */
8990 #define OP_Gt 77 /* same as TK_GT */
8991 #define OP_Ge 80 /* same as TK_GE */
8992 #define OP_Permutation 23
8993 #define OP_Compare 24
8994 #define OP_Jump 25
8995 #define OP_And 69 /* same as TK_AND */
8996 #define OP_Or 68 /* same as TK_OR */
8997 #define OP_Not 19 /* same as TK_NOT */
8998 #define OP_BitNot 93 /* same as TK_BITNOT */
8999 #define OP_Once 26
9000 #define OP_If 27
9001 #define OP_IfNot 28
9002 #define OP_IsNull 73 /* same as TK_ISNULL */
9003 #define OP_NotNull 74 /* same as TK_NOTNULL */
9004 #define OP_Column 29
9005 #define OP_Affinity 30
9006 #define OP_MakeRecord 31
9007 #define OP_Count 32
9008 #define OP_Savepoint 33
9009 #define OP_AutoCommit 34
9010 #define OP_Transaction 35
9011 #define OP_ReadCookie 36
9012 #define OP_SetCookie 37
9013 #define OP_VerifyCookie 38
9014 #define OP_OpenRead 39
9015 #define OP_OpenWrite 40
9016 #define OP_OpenAutoindex 41
9017 #define OP_OpenEphemeral 42
9018 #define OP_SorterOpen 43
9019 #define OP_OpenPseudo 44
9020 #define OP_Close 45
9021 #define OP_SeekLt 46
9022 #define OP_SeekLe 47
9023 #define OP_SeekGe 48
9024 #define OP_SeekGt 49
9025 #define OP_Seek 50
9026 #define OP_NotFound 51
9027 #define OP_Found 52
9028 #define OP_IsUnique 53
9029 #define OP_NotExists 54
9030 #define OP_Sequence 55
9031 #define OP_NewRowid 56
9032 #define OP_Insert 57
9033 #define OP_InsertInt 58
9034 #define OP_Delete 59
9035 #define OP_ResetCount 60
9036 #define OP_SorterCompare 61
9037 #define OP_SorterData 62
9038 #define OP_RowKey 63
9039 #define OP_RowData 64
9040 #define OP_Rowid 65
9041 #define OP_NullRow 66
9042 #define OP_Last 67
9043 #define OP_SorterSort 70
9044 #define OP_Sort 71
9045 #define OP_Rewind 72
9046 #define OP_SorterNext 81
9047 #define OP_Prev 92
9048 #define OP_Next 95
9049 #define OP_SorterInsert 96
9050 #define OP_IdxInsert 97
9051 #define OP_IdxDelete 98
9052 #define OP_IdxRowid 99
9053 #define OP_IdxLT 100
9054 #define OP_IdxGE 101
9055 #define OP_Destroy 102
9056 #define OP_Clear 103
9057 #define OP_CreateIndex 104
9058 #define OP_CreateTable 105
9059 #define OP_ParseSchema 106
9060 #define OP_LoadAnalysis 107
9061 #define OP_DropTable 108
9062 #define OP_DropIndex 109
9063 #define OP_DropTrigger 110
9064 #define OP_IntegrityCk 111
9065 #define OP_RowSetAdd 112
9066 #define OP_RowSetRead 113
9067 #define OP_RowSetTest 114
9068 #define OP_Program 115
9069 #define OP_Param 116
9070 #define OP_FkCounter 117
9071 #define OP_FkIfZero 118
9072 #define OP_MemMax 119
9073 #define OP_IfPos 120
9074 #define OP_IfNeg 121
9075 #define OP_IfZero 122
9076 #define OP_AggStep 123
9077 #define OP_AggFinal 124
9078 #define OP_Checkpoint 125
9079 #define OP_JournalMode 126
9080 #define OP_Vacuum 127
9081 #define OP_IncrVacuum 128
9082 #define OP_Expire 129
9083 #define OP_TableLock 131
9084 #define OP_VBegin 132
9085 #define OP_VCreate 133
9086 #define OP_VDestroy 134
9087 #define OP_VOpen 135
9088 #define OP_VFilter 136
9089 #define OP_VColumn 137
9090 #define OP_VNext 138
9091 #define OP_VRename 139
9092 #define OP_VUpdate 140
9093 #define OP_Pagecount 146
9094 #define OP_MaxPgcnt 147
9095 #define OP_Trace 148
9096 #define OP_Noop 149
9097 #define OP_Explain 150
@@ -9107,28 +9107,28 @@
9107 #define OPFLG_IN2 0x0008 /* in2: P2 is an input */
9108 #define OPFLG_IN3 0x0010 /* in3: P3 is an input */
9109 #define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
9110 #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
9111 #define OPFLG_INITIALIZER {\
9112 /* 0 */ 0x00, 0x01, 0x01, 0x04, 0x04, 0x10, 0x00, 0x02,\
9113 /* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x24,\
9114 /* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\
9115 /* 24 */ 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00,\
9116 /* 32 */ 0x02, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00,\
9117 /* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\
9118 /* 48 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x02,\
9119 /* 56 */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9120 /* 64 */ 0x00, 0x02, 0x00, 0x01, 0x4c, 0x4c, 0x01, 0x01,\
9121 /* 72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9122 /* 80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9123 /* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x01,\
9124 /* 96 */ 0x08, 0x08, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\
9125 /* 104 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9126 /* 112 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\
9127 /* 120 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,\
9128 /* 128 */ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
9129 /* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\
9130 /* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}
9131
9132 /************** End of opcodes.h *********************************************/
9133 /************** Continuing where we left off in vdbe.h ***********************/
9134
@@ -10672,16 +10672,20 @@
10672
10673 /*
10674 ** An instance of the following structure is passed as the first
10675 ** argument to sqlite3VdbeKeyCompare and is used to control the
10676 ** comparison of the two index keys.
 
 
 
 
10677 */
10678 struct KeyInfo {
10679 sqlite3 *db; /* The database connection */
10680 u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
10681 u16 nField; /* Number of entries in aColl[] */
10682 u8 *aSortOrder; /* Sort order for each column. May be NULL */
10683 CollSeq *aColl[1]; /* Collating sequence for each term of the key */
10684 };
10685
10686 /*
10687 ** An instance of the following structure holds information about a
@@ -11282,10 +11286,11 @@
11282 #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
11283 #define SF_UseSorter 0x0040 /* Sort using a sorter */
11284 #define SF_Values 0x0080 /* Synthesized from VALUES clause */
11285 #define SF_Materialize 0x0100 /* Force materialization of views */
11286 #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
 
11287
11288
11289 /*
11290 ** The results of a select can be distributed in several ways. The
11291 ** "SRT" prefix means "SELECT Result Type".
@@ -11403,10 +11408,11 @@
11403 u8 nTempInUse; /* Number of aTempReg[] currently checked out */
11404 u8 nColCache; /* Number of entries in aColCache[] */
11405 u8 iColCache; /* Next entry in aColCache[] to replace */
11406 u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
11407 u8 mayAbort; /* True if statement may throw an ABORT exception */
 
11408 int aTempReg[8]; /* Holding area for temporary registers */
11409 int nRangeReg; /* Size of the temporary register block */
11410 int iRangeReg; /* First register in temporary register block */
11411 int nErr; /* Number of errors seen */
11412 int nTab; /* Number of previously allocated VDBE cursors */
@@ -12294,10 +12300,11 @@
12294 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
12295 SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
12296 SQLITE_PRIVATE void sqlite3SchemaClear(void *);
12297 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
12298 SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
 
12299 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
12300 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
12301 void (*)(sqlite3_context*,int,sqlite3_value **),
12302 void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
12303 FuncDestructor *pDestructor
@@ -22693,91 +22700,91 @@
22693 /* Automatically generated. Do not edit */
22694 /* See the mkopcodec.awk script for details. */
22695 #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
22696 SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
22697 static const char *const azName[] = { "?",
22698 /* 1 */ "Goto",
22699 /* 2 */ "Gosub",
22700 /* 3 */ "Return",
22701 /* 4 */ "Yield",
22702 /* 5 */ "HaltIfNull",
22703 /* 6 */ "Halt",
22704 /* 7 */ "Integer",
22705 /* 8 */ "Int64",
22706 /* 9 */ "String",
22707 /* 10 */ "Null",
22708 /* 11 */ "Blob",
22709 /* 12 */ "Variable",
22710 /* 13 */ "Move",
22711 /* 14 */ "Copy",
22712 /* 15 */ "SCopy",
22713 /* 16 */ "ResultRow",
22714 /* 17 */ "CollSeq",
22715 /* 18 */ "Function",
22716 /* 19 */ "Not",
22717 /* 20 */ "AddImm",
22718 /* 21 */ "MustBeInt",
22719 /* 22 */ "RealAffinity",
22720 /* 23 */ "Permutation",
22721 /* 24 */ "Compare",
22722 /* 25 */ "Jump",
22723 /* 26 */ "Once",
22724 /* 27 */ "If",
22725 /* 28 */ "IfNot",
22726 /* 29 */ "Column",
22727 /* 30 */ "Affinity",
22728 /* 31 */ "MakeRecord",
22729 /* 32 */ "Count",
22730 /* 33 */ "Savepoint",
22731 /* 34 */ "AutoCommit",
22732 /* 35 */ "Transaction",
22733 /* 36 */ "ReadCookie",
22734 /* 37 */ "SetCookie",
22735 /* 38 */ "VerifyCookie",
22736 /* 39 */ "OpenRead",
22737 /* 40 */ "OpenWrite",
22738 /* 41 */ "OpenAutoindex",
22739 /* 42 */ "OpenEphemeral",
22740 /* 43 */ "SorterOpen",
22741 /* 44 */ "OpenPseudo",
22742 /* 45 */ "Close",
22743 /* 46 */ "SeekLt",
22744 /* 47 */ "SeekLe",
22745 /* 48 */ "SeekGe",
22746 /* 49 */ "SeekGt",
22747 /* 50 */ "Seek",
22748 /* 51 */ "NotFound",
22749 /* 52 */ "Found",
22750 /* 53 */ "IsUnique",
22751 /* 54 */ "NotExists",
22752 /* 55 */ "Sequence",
22753 /* 56 */ "NewRowid",
22754 /* 57 */ "Insert",
22755 /* 58 */ "InsertInt",
22756 /* 59 */ "Delete",
22757 /* 60 */ "ResetCount",
22758 /* 61 */ "SorterCompare",
22759 /* 62 */ "SorterData",
22760 /* 63 */ "RowKey",
22761 /* 64 */ "RowData",
22762 /* 65 */ "Rowid",
22763 /* 66 */ "NullRow",
22764 /* 67 */ "Last",
22765 /* 68 */ "Or",
22766 /* 69 */ "And",
22767 /* 70 */ "SorterSort",
22768 /* 71 */ "Sort",
22769 /* 72 */ "Rewind",
22770 /* 73 */ "IsNull",
22771 /* 74 */ "NotNull",
22772 /* 75 */ "Ne",
22773 /* 76 */ "Eq",
22774 /* 77 */ "Gt",
22775 /* 78 */ "Le",
22776 /* 79 */ "Lt",
22777 /* 80 */ "Ge",
22778 /* 81 */ "SorterNext",
22779 /* 82 */ "BitAnd",
22780 /* 83 */ "BitOr",
22781 /* 84 */ "ShiftLeft",
22782 /* 85 */ "ShiftRight",
22783 /* 86 */ "Add",
@@ -22784,59 +22791,59 @@
22784 /* 87 */ "Subtract",
22785 /* 88 */ "Multiply",
22786 /* 89 */ "Divide",
22787 /* 90 */ "Remainder",
22788 /* 91 */ "Concat",
22789 /* 92 */ "Prev",
22790 /* 93 */ "BitNot",
22791 /* 94 */ "String8",
22792 /* 95 */ "Next",
22793 /* 96 */ "SorterInsert",
22794 /* 97 */ "IdxInsert",
22795 /* 98 */ "IdxDelete",
22796 /* 99 */ "IdxRowid",
22797 /* 100 */ "IdxLT",
22798 /* 101 */ "IdxGE",
22799 /* 102 */ "Destroy",
22800 /* 103 */ "Clear",
22801 /* 104 */ "CreateIndex",
22802 /* 105 */ "CreateTable",
22803 /* 106 */ "ParseSchema",
22804 /* 107 */ "LoadAnalysis",
22805 /* 108 */ "DropTable",
22806 /* 109 */ "DropIndex",
22807 /* 110 */ "DropTrigger",
22808 /* 111 */ "IntegrityCk",
22809 /* 112 */ "RowSetAdd",
22810 /* 113 */ "RowSetRead",
22811 /* 114 */ "RowSetTest",
22812 /* 115 */ "Program",
22813 /* 116 */ "Param",
22814 /* 117 */ "FkCounter",
22815 /* 118 */ "FkIfZero",
22816 /* 119 */ "MemMax",
22817 /* 120 */ "IfPos",
22818 /* 121 */ "IfNeg",
22819 /* 122 */ "IfZero",
22820 /* 123 */ "AggStep",
22821 /* 124 */ "AggFinal",
22822 /* 125 */ "Checkpoint",
22823 /* 126 */ "JournalMode",
22824 /* 127 */ "Vacuum",
22825 /* 128 */ "IncrVacuum",
22826 /* 129 */ "Expire",
22827 /* 130 */ "Real",
22828 /* 131 */ "TableLock",
22829 /* 132 */ "VBegin",
22830 /* 133 */ "VCreate",
22831 /* 134 */ "VDestroy",
22832 /* 135 */ "VOpen",
22833 /* 136 */ "VFilter",
22834 /* 137 */ "VColumn",
22835 /* 138 */ "VNext",
22836 /* 139 */ "VRename",
22837 /* 140 */ "VUpdate",
22838 /* 141 */ "ToText",
22839 /* 142 */ "ToBlob",
22840 /* 143 */ "ToNumeric",
22841 /* 144 */ "ToInt",
22842 /* 145 */ "ToReal",
@@ -60361,44 +60368,64 @@
60361 p->readOnly = 1;
60362 p->bIsReader = 0;
60363 for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
60364 u8 opcode = pOp->opcode;
60365
60366 pOp->opflags = sqlite3OpcodeProperty[opcode];
60367 if( opcode==OP_Function || opcode==OP_AggStep ){
60368 if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60369 }else if( opcode==OP_Transaction ){
60370 if( pOp->p2!=0 ) p->readOnly = 0;
60371 p->bIsReader = 1;
60372 }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
60373 p->bIsReader = 1;
60374 }else if( opcode==OP_Vacuum
60375 || opcode==OP_JournalMode
 
 
 
 
 
 
 
60376 #ifndef SQLITE_OMIT_WAL
60377 || opcode==OP_Checkpoint
60378 #endif
60379 ){
60380 p->readOnly = 0;
60381 p->bIsReader = 1;
 
 
 
60382 #ifndef SQLITE_OMIT_VIRTUALTABLE
60383 }else if( opcode==OP_VUpdate ){
60384 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60385 }else if( opcode==OP_VFilter ){
60386 int n;
60387 assert( p->nOp - i >= 3 );
60388 assert( pOp[-1].opcode==OP_Integer );
60389 n = pOp[-1].p1;
60390 if( n>nMaxArgs ) nMaxArgs = n;
60391 #endif
60392 }else if( opcode==OP_Next || opcode==OP_SorterNext ){
60393 pOp->p4.xAdvance = sqlite3BtreeNext;
60394 pOp->p4type = P4_ADVANCE;
60395 }else if( opcode==OP_Prev ){
60396 pOp->p4.xAdvance = sqlite3BtreePrevious;
60397 pOp->p4type = P4_ADVANCE;
60398 }
60399
 
 
 
 
 
 
 
 
 
 
60400 if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
60401 assert( -1-pOp->p2<p->nLabel );
60402 pOp->p2 = aLabel[-1-pOp->p2];
60403 }
60404 }
@@ -60683,24 +60710,17 @@
60683 pOp->p4type = P4_INT32;
60684 }else if( zP4==0 ){
60685 pOp->p4.p = 0;
60686 pOp->p4type = P4_NOTUSED;
60687 }else if( n==P4_KEYINFO ){
60688 KeyInfo *pKeyInfo;
60689 int nField, nByte;
60690
60691 nField = ((KeyInfo*)zP4)->nField;
60692 nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField;
60693 pKeyInfo = sqlite3DbMallocRaw(0, nByte);
60694 pOp->p4.pKeyInfo = pKeyInfo;
60695 if( pKeyInfo ){
60696 u8 *aSortOrder;
60697 memcpy((char*)pKeyInfo, zP4, nByte - nField);
60698 aSortOrder = pKeyInfo->aSortOrder;
60699 assert( aSortOrder!=0 );
60700 pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField];
60701 memcpy(pKeyInfo->aSortOrder, aSortOrder, nField);
60702 pOp->p4type = P4_KEYINFO;
60703 }else{
60704 p->db->mallocFailed = 1;
60705 pOp->p4type = P4_NOTUSED;
60706 }
@@ -62947,11 +62967,10 @@
62947 ){
62948 u32 d1; /* Offset into aKey[] of next data element */
62949 u32 idx1; /* Offset into aKey[] of next header element */
62950 u32 szHdr1; /* Number of bytes in header */
62951 int i = 0;
62952 int nField;
62953 int rc = 0;
62954 const unsigned char *aKey1 = (const unsigned char *)pKey1;
62955 KeyInfo *pKeyInfo;
62956 Mem mem1;
62957
@@ -62970,32 +62989,42 @@
62970 */
62971 /* mem1.u.i = 0; // not needed, here to silence compiler warning */
62972
62973 idx1 = getVarint32(aKey1, szHdr1);
62974 d1 = szHdr1;
62975 nField = pKeyInfo->nField;
62976 assert( pKeyInfo->aSortOrder!=0 );
62977 while( idx1<szHdr1 && i<pPKey2->nField ){
62978 u32 serial_type1;
62979
62980 /* Read the serial types for the next element in each key. */
62981 idx1 += getVarint32( aKey1+idx1, serial_type1 );
62982 if( d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 ) break;
 
 
 
 
 
 
 
 
 
 
 
62983
62984 /* Extract the values to be compared.
62985 */
62986 d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
62987
62988 /* Do the comparison
62989 */
62990 rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
62991 i<nField ? pKeyInfo->aColl[i] : 0);
62992 if( rc!=0 ){
62993 assert( mem1.zMalloc==0 ); /* See comment below */
62994
62995 /* Invert the result if we are using DESC sort order. */
62996 if( i<nField && pKeyInfo->aSortOrder[i] ){
62997 rc = -rc;
62998 }
62999
63000 /* If the PREFIX_SEARCH flag is set and all fields except the final
63001 ** rowid field were equal, then clear the PREFIX_SEARCH flag and set
@@ -65475,11 +65504,11 @@
65475 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65476 u8 encoding = ENC(db); /* The database encoding */
65477 int iCompare = 0; /* Result of last OP_Compare operation */
65478 unsigned nVmStep = 0; /* Number of virtual machine steps */
65479 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65480 unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
65481 #endif
65482 Mem *aMem = p->aMem; /* Copy of p->aMem */
65483 Mem *pIn1 = 0; /* 1st input operand */
65484 Mem *pIn2 = 0; /* 2nd input operand */
65485 Mem *pIn3 = 0; /* 3rd input operand */
@@ -77063,14 +77092,13 @@
77063 #endif
77064
77065 switch( pExpr->op ){
77066 case TK_IN: {
77067 char affinity; /* Affinity of the LHS of the IN */
77068 KeyInfo keyInfo; /* Keyinfo for the generated table */
77069 static u8 sortOrder = 0; /* Fake aSortOrder for keyInfo */
77070 int addr; /* Address of OP_OpenEphemeral instruction */
77071 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
 
77072
77073 if( rMayHaveNull ){
77074 sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);
77075 }
77076
@@ -77090,13 +77118,11 @@
77090 ** is used.
77091 */
77092 pExpr->iTable = pParse->nTab++;
77093 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
77094 if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
77095 memset(&keyInfo, 0, sizeof(keyInfo));
77096 keyInfo.nField = 1;
77097 keyInfo.aSortOrder = &sortOrder;
77098
77099 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
77100 /* Case 1: expr IN (SELECT ...)
77101 **
77102 ** Generate code to write the results of the select into the temporary
@@ -77109,15 +77135,16 @@
77109 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
77110 dest.affSdst = (u8)affinity;
77111 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
77112 pExpr->x.pSelect->iLimit = 0;
77113 if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
 
77114 return 0;
77115 }
77116 pEList = pExpr->x.pSelect->pEList;
77117 if( ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77118 keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
77119 pEList->a[0].pExpr);
77120 }
77121 }else if( ALWAYS(pExpr->x.pList!=0) ){
77122 /* Case 2: expr IN (exprlist)
77123 **
@@ -77132,12 +77159,13 @@
77132 int r1, r2, r3;
77133
77134 if( !affinity ){
77135 affinity = SQLITE_AFF_NONE;
77136 }
77137 keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77138 keyInfo.aSortOrder = &sortOrder;
 
77139
77140 /* Loop through each expression in <exprlist>. */
77141 r1 = sqlite3GetTempReg(pParse);
77142 r2 = sqlite3GetTempReg(pParse);
77143 sqlite3VdbeAddOp2(v, OP_Null, 0, r2);
@@ -77172,12 +77200,12 @@
77172 }
77173 }
77174 sqlite3ReleaseTempReg(pParse, r1);
77175 sqlite3ReleaseTempReg(pParse, r2);
77176 }
77177 if( !isRowid ){
77178 sqlite3VdbeChangeP4(v, addr, (void *)&keyInfo, P4_KEYINFO);
77179 }
77180 break;
77181 }
77182
77183 case TK_EXISTS:
@@ -86192,29 +86220,24 @@
86192 ** the error.
86193 */
86194 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
86195 int i;
86196 int nCol = pIdx->nColumn;
86197 int nBytes = sizeof(KeyInfo) + (nCol-1)*sizeof(CollSeq*) + nCol;
86198 sqlite3 *db = pParse->db;
86199 KeyInfo *pKey = (KeyInfo *)sqlite3DbMallocZero(db, nBytes);
86200
86201 if( pKey ){
86202 pKey->db = pParse->db;
86203 pKey->aSortOrder = (u8 *)&(pKey->aColl[nCol]);
86204 assert( &pKey->aSortOrder[nCol]==&(((u8 *)pKey)[nBytes]) );
86205 for(i=0; i<nCol; i++){
86206 char *zColl = pIdx->azColl[i];
86207 assert( zColl );
86208 pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);
86209 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
86210 }
86211 pKey->nField = (u16)nCol;
86212 }
86213
86214 if( pParse->nErr ){
86215 sqlite3DbFree(db, pKey);
86216 pKey = 0;
86217 }
86218 return pKey;
86219 }
86220
@@ -97148,10 +97171,29 @@
97148 */
97149 if( pOrderBy==0 && p->iLimit ){
97150 sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
97151 }
97152 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97153
97154 /*
97155 ** Given an expression list, generate a KeyInfo structure that records
97156 ** the collating sequence for each expression in that expression list.
97157 **
@@ -97165,29 +97207,23 @@
97165 ** function is responsible for seeing that this structure is eventually
97166 ** freed. Add the KeyInfo structure to the P4 field of an opcode using
97167 ** P4_KEYINFO_HANDOFF is the usual way of dealing with this.
97168 */
97169 static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){
97170 sqlite3 *db = pParse->db;
97171 int nExpr;
97172 KeyInfo *pInfo;
97173 struct ExprList_item *pItem;
 
97174 int i;
97175
97176 nExpr = pList->nExpr;
97177 pInfo = sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(sizeof(CollSeq*)+1) );
97178 if( pInfo ){
97179 pInfo->aSortOrder = (u8*)&pInfo->aColl[nExpr];
97180 pInfo->nField = (u16)nExpr;
97181 pInfo->enc = ENC(db);
97182 pInfo->db = db;
97183 for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
97184 CollSeq *pColl;
97185 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
97186 if( !pColl ){
97187 pColl = db->pDfltColl;
97188 }
97189 pInfo->aColl[i] = pColl;
97190 pInfo->aSortOrder[i] = pItem->sortOrder;
97191 }
97192 }
97193 return pInfo;
@@ -98289,27 +98325,21 @@
98289 CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
98290 int nCol; /* Number of columns in result set */
98291
98292 assert( p->pRightmost==p );
98293 nCol = p->pEList->nExpr;
98294 pKeyInfo = sqlite3DbMallocZero(db,
98295 sizeof(*pKeyInfo)+nCol*(sizeof(CollSeq*) + 1));
98296 if( !pKeyInfo ){
98297 rc = SQLITE_NOMEM;
98298 goto multi_select_end;
98299 }
98300
98301 pKeyInfo->enc = ENC(db);
98302 pKeyInfo->nField = (u16)nCol;
98303
98304 for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){
98305 *apColl = multiSelectCollSeq(pParse, p, i);
98306 if( 0==*apColl ){
98307 *apColl = db->pDfltColl;
98308 }
98309 }
98310 pKeyInfo->aSortOrder = (u8*)apColl;
98311
98312 for(pLoop=p; pLoop; pLoop=pLoop->pPrior){
98313 for(i=0; i<2; i++){
98314 int addr = pLoop->addrOpenEphm[i];
98315 if( addr<0 ){
@@ -98674,16 +98704,12 @@
98674 struct ExprList_item *pItem;
98675 for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
98676 assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr );
98677 aPermute[i] = pItem->iOrderByCol - 1;
98678 }
98679 pKeyMerge =
98680 sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq*)+1));
98681 if( pKeyMerge ){
98682 pKeyMerge->aSortOrder = (u8*)&pKeyMerge->aColl[nOrderBy];
98683 pKeyMerge->nField = (u16)nOrderBy;
98684 pKeyMerge->enc = ENC(db);
98685 for(i=0; i<nOrderBy; i++){
98686 CollSeq *pColl;
98687 Expr *pTerm = pOrderBy->a[i].pExpr;
98688 if( pTerm->flags & EP_Collate ){
98689 pColl = sqlite3ExprCollSeq(pParse, pTerm);
@@ -98716,16 +98742,12 @@
98716 int nExpr = p->pEList->nExpr;
98717 assert( nOrderBy>=nExpr || db->mallocFailed );
98718 regPrev = pParse->nMem+1;
98719 pParse->nMem += nExpr+1;
98720 sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);
98721 pKeyDup = sqlite3DbMallocZero(db,
98722 sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq*)+1) );
98723 if( pKeyDup ){
98724 pKeyDup->aSortOrder = (u8*)&pKeyDup->aColl[nExpr];
98725 pKeyDup->nField = (u16)nExpr;
98726 pKeyDup->enc = ENC(db);
98727 for(i=0; i<nExpr; i++){
98728 pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
98729 pKeyDup->aSortOrder[i] = 0;
98730 }
98731 }
@@ -99987,14 +100009,16 @@
99987 ** and/or pParse->db->mallocFailed.
99988 */
99989 static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
99990 Walker w;
99991 memset(&w, 0, sizeof(w));
99992 w.xSelectCallback = convertCompoundSelectToSubquery;
99993 w.xExprCallback = exprWalkNoop;
99994 w.pParse = pParse;
99995 sqlite3WalkSelect(&w, pSelect);
 
 
 
99996 w.xSelectCallback = selectExpander;
99997 sqlite3WalkSelect(&w, pSelect);
99998 }
99999
100000
@@ -113204,10 +113228,11 @@
113204 case 114: /* select ::= select multiselect_op oneselect */
113205 {
113206 if( yymsp[0].minor.yy159 ){
113207 yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
113208 yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
 
113209 }else{
113210 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
113211 }
113212 yygotominor.yy159 = yymsp[0].minor.yy159;
113213 }
113214
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -656,11 +656,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.8.0"
660 #define SQLITE_VERSION_NUMBER 3008000
661 #define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -8943,155 +8943,155 @@
8943 */
8944 /************** Include opcodes.h in the middle of vdbe.h ********************/
8945 /************** Begin file opcodes.h *****************************************/
8946 /* Automatically generated. Do not edit */
8947 /* See the mkopcodeh.awk script for details */
8948 #define OP_Function 1
8949 #define OP_Savepoint 2
8950 #define OP_AutoCommit 3
8951 #define OP_Transaction 4
8952 #define OP_SorterNext 5
8953 #define OP_Prev 6
8954 #define OP_Next 7
8955 #define OP_AggStep 8
8956 #define OP_Checkpoint 9
8957 #define OP_JournalMode 10
8958 #define OP_Vacuum 11
8959 #define OP_VFilter 12
8960 #define OP_VUpdate 13
8961 #define OP_Goto 14
8962 #define OP_Gosub 15
8963 #define OP_Return 16
8964 #define OP_Yield 17
8965 #define OP_HaltIfNull 18
8966 #define OP_Not 19 /* same as TK_NOT */
8967 #define OP_Halt 20
8968 #define OP_Integer 21
8969 #define OP_Int64 22
8970 #define OP_String 23
8971 #define OP_Null 24
8972 #define OP_Blob 25
8973 #define OP_Variable 26
8974 #define OP_Move 27
8975 #define OP_Copy 28
8976 #define OP_SCopy 29
8977 #define OP_ResultRow 30
8978 #define OP_CollSeq 31
8979 #define OP_AddImm 32
8980 #define OP_MustBeInt 33
8981 #define OP_RealAffinity 34
8982 #define OP_Permutation 35
8983 #define OP_Compare 36
8984 #define OP_Jump 37
8985 #define OP_Once 38
8986 #define OP_If 39
8987 #define OP_IfNot 40
8988 #define OP_Column 41
8989 #define OP_Affinity 42
8990 #define OP_MakeRecord 43
8991 #define OP_Count 44
8992 #define OP_ReadCookie 45
8993 #define OP_SetCookie 46
8994 #define OP_VerifyCookie 47
8995 #define OP_OpenRead 48
8996 #define OP_OpenWrite 49
8997 #define OP_OpenAutoindex 50
8998 #define OP_OpenEphemeral 51
8999 #define OP_SorterOpen 52
9000 #define OP_OpenPseudo 53
9001 #define OP_Close 54
9002 #define OP_SeekLt 55
9003 #define OP_SeekLe 56
9004 #define OP_SeekGe 57
9005 #define OP_SeekGt 58
9006 #define OP_Seek 59
9007 #define OP_NotFound 60
9008 #define OP_Found 61
9009 #define OP_IsUnique 62
9010 #define OP_NotExists 63
9011 #define OP_Sequence 64
9012 #define OP_NewRowid 65
9013 #define OP_Insert 66
9014 #define OP_InsertInt 67
9015 #define OP_Or 68 /* same as TK_OR */
9016 #define OP_And 69 /* same as TK_AND */
9017 #define OP_Delete 70
9018 #define OP_ResetCount 71
9019 #define OP_SorterCompare 72
9020 #define OP_IsNull 73 /* same as TK_ISNULL */
9021 #define OP_NotNull 74 /* same as TK_NOTNULL */
9022 #define OP_Ne 75 /* same as TK_NE */
9023 #define OP_Eq 76 /* same as TK_EQ */
9024 #define OP_Gt 77 /* same as TK_GT */
9025 #define OP_Le 78 /* same as TK_LE */
9026 #define OP_Lt 79 /* same as TK_LT */
9027 #define OP_Ge 80 /* same as TK_GE */
9028 #define OP_SorterData 81
9029 #define OP_BitAnd 82 /* same as TK_BITAND */
9030 #define OP_BitOr 83 /* same as TK_BITOR */
9031 #define OP_ShiftLeft 84 /* same as TK_LSHIFT */
9032 #define OP_ShiftRight 85 /* same as TK_RSHIFT */
9033 #define OP_Add 86 /* same as TK_PLUS */
9034 #define OP_Subtract 87 /* same as TK_MINUS */
9035 #define OP_Multiply 88 /* same as TK_STAR */
9036 #define OP_Divide 89 /* same as TK_SLASH */
9037 #define OP_Remainder 90 /* same as TK_REM */
9038 #define OP_Concat 91 /* same as TK_CONCAT */
9039 #define OP_RowKey 92
9040 #define OP_BitNot 93 /* same as TK_BITNOT */
9041 #define OP_String8 94 /* same as TK_STRING */
9042 #define OP_RowData 95
9043 #define OP_Rowid 96
9044 #define OP_NullRow 97
9045 #define OP_Last 98
9046 #define OP_SorterSort 99
9047 #define OP_Sort 100
9048 #define OP_Rewind 101
9049 #define OP_SorterInsert 102
9050 #define OP_IdxInsert 103
9051 #define OP_IdxDelete 104
9052 #define OP_IdxRowid 105
9053 #define OP_IdxLT 106
9054 #define OP_IdxGE 107
9055 #define OP_Destroy 108
9056 #define OP_Clear 109
9057 #define OP_CreateIndex 110
9058 #define OP_CreateTable 111
9059 #define OP_ParseSchema 112
9060 #define OP_LoadAnalysis 113
9061 #define OP_DropTable 114
9062 #define OP_DropIndex 115
9063 #define OP_DropTrigger 116
9064 #define OP_IntegrityCk 117
9065 #define OP_RowSetAdd 118
9066 #define OP_RowSetRead 119
9067 #define OP_RowSetTest 120
9068 #define OP_Program 121
9069 #define OP_Param 122
9070 #define OP_FkCounter 123
9071 #define OP_FkIfZero 124
9072 #define OP_MemMax 125
9073 #define OP_IfPos 126
9074 #define OP_IfNeg 127
9075 #define OP_IfZero 128
9076 #define OP_AggFinal 129
9077 #define OP_Real 130 /* same as TK_FLOAT */
9078 #define OP_IncrVacuum 131
9079 #define OP_Expire 132
9080 #define OP_TableLock 133
9081 #define OP_VBegin 134
9082 #define OP_VCreate 135
9083 #define OP_VDestroy 136
9084 #define OP_VOpen 137
9085 #define OP_VColumn 138
9086 #define OP_VNext 139
9087 #define OP_VRename 140
9088 #define OP_ToText 141 /* same as TK_TO_TEXT */
9089 #define OP_ToBlob 142 /* same as TK_TO_BLOB */
9090 #define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
9091 #define OP_ToInt 144 /* same as TK_TO_INT */
9092 #define OP_ToReal 145 /* same as TK_TO_REAL */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9093 #define OP_Pagecount 146
9094 #define OP_MaxPgcnt 147
9095 #define OP_Trace 148
9096 #define OP_Noop 149
9097 #define OP_Explain 150
@@ -9107,28 +9107,28 @@
9107 #define OPFLG_IN2 0x0008 /* in2: P2 is an input */
9108 #define OPFLG_IN3 0x0010 /* in3: P3 is an input */
9109 #define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
9110 #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
9111 #define OPFLG_INITIALIZER {\
9112 /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
9113 /* 8 */ 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01,\
9114 /* 16 */ 0x04, 0x04, 0x10, 0x24, 0x00, 0x02, 0x02, 0x02,\
9115 /* 24 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x24, 0x00, 0x00,\
9116 /* 32 */ 0x04, 0x05, 0x04, 0x00, 0x00, 0x01, 0x01, 0x05,\
9117 /* 40 */ 0x05, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,\
9118 /* 48 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,\
9119 /* 56 */ 0x11, 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11,\
9120 /* 64 */ 0x02, 0x02, 0x00, 0x00, 0x4c, 0x4c, 0x00, 0x00,\
9121 /* 72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
9122 /* 80 */ 0x15, 0x00, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
9123 /* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x00, 0x24, 0x02, 0x00,\
9124 /* 96 */ 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08,\
9125 /* 104 */ 0x00, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02,\
9126 /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\
9127 /* 120 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x08, 0x05, 0x05,\
9128 /* 128 */ 0x05, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,\
9129 /* 136 */ 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04,\
9130 /* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}
9131
9132 /************** End of opcodes.h *********************************************/
9133 /************** Continuing where we left off in vdbe.h ***********************/
9134
@@ -10672,16 +10672,20 @@
10672
10673 /*
10674 ** An instance of the following structure is passed as the first
10675 ** argument to sqlite3VdbeKeyCompare and is used to control the
10676 ** comparison of the two index keys.
10677 **
10678 ** Note that aSortOrder[] and aColl[] have nField+1 slots. There
10679 ** are nField slots for the columns of an index then one extra slot
10680 ** for the rowid at the end.
10681 */
10682 struct KeyInfo {
10683 sqlite3 *db; /* The database connection */
10684 u8 enc; /* Text encoding - one of the SQLITE_UTF* values */
10685 u16 nField; /* Maximum index for aColl[] and aSortOrder[] */
10686 u8 *aSortOrder; /* Sort order for each column. */
10687 CollSeq *aColl[1]; /* Collating sequence for each term of the key */
10688 };
10689
10690 /*
10691 ** An instance of the following structure holds information about a
@@ -11282,10 +11286,11 @@
11286 #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
11287 #define SF_UseSorter 0x0040 /* Sort using a sorter */
11288 #define SF_Values 0x0080 /* Synthesized from VALUES clause */
11289 #define SF_Materialize 0x0100 /* Force materialization of views */
11290 #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
11291 #define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
11292
11293
11294 /*
11295 ** The results of a select can be distributed in several ways. The
11296 ** "SRT" prefix means "SELECT Result Type".
@@ -11403,10 +11408,11 @@
11408 u8 nTempInUse; /* Number of aTempReg[] currently checked out */
11409 u8 nColCache; /* Number of entries in aColCache[] */
11410 u8 iColCache; /* Next entry in aColCache[] to replace */
11411 u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
11412 u8 mayAbort; /* True if statement may throw an ABORT exception */
11413 u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
11414 int aTempReg[8]; /* Holding area for temporary registers */
11415 int nRangeReg; /* Size of the temporary register block */
11416 int iRangeReg; /* First register in temporary register block */
11417 int nErr; /* Number of errors seen */
11418 int nTab; /* Number of previously allocated VDBE cursors */
@@ -12294,10 +12300,11 @@
12300 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
12301 SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
12302 SQLITE_PRIVATE void sqlite3SchemaClear(void *);
12303 SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
12304 SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
12305 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int);
12306 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
12307 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
12308 void (*)(sqlite3_context*,int,sqlite3_value **),
12309 void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
12310 FuncDestructor *pDestructor
@@ -22693,91 +22700,91 @@
22700 /* Automatically generated. Do not edit */
22701 /* See the mkopcodec.awk script for details. */
22702 #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)
22703 SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
22704 static const char *const azName[] = { "?",
22705 /* 1 */ "Function",
22706 /* 2 */ "Savepoint",
22707 /* 3 */ "AutoCommit",
22708 /* 4 */ "Transaction",
22709 /* 5 */ "SorterNext",
22710 /* 6 */ "Prev",
22711 /* 7 */ "Next",
22712 /* 8 */ "AggStep",
22713 /* 9 */ "Checkpoint",
22714 /* 10 */ "JournalMode",
22715 /* 11 */ "Vacuum",
22716 /* 12 */ "VFilter",
22717 /* 13 */ "VUpdate",
22718 /* 14 */ "Goto",
22719 /* 15 */ "Gosub",
22720 /* 16 */ "Return",
22721 /* 17 */ "Yield",
22722 /* 18 */ "HaltIfNull",
22723 /* 19 */ "Not",
22724 /* 20 */ "Halt",
22725 /* 21 */ "Integer",
22726 /* 22 */ "Int64",
22727 /* 23 */ "String",
22728 /* 24 */ "Null",
22729 /* 25 */ "Blob",
22730 /* 26 */ "Variable",
22731 /* 27 */ "Move",
22732 /* 28 */ "Copy",
22733 /* 29 */ "SCopy",
22734 /* 30 */ "ResultRow",
22735 /* 31 */ "CollSeq",
22736 /* 32 */ "AddImm",
22737 /* 33 */ "MustBeInt",
22738 /* 34 */ "RealAffinity",
22739 /* 35 */ "Permutation",
22740 /* 36 */ "Compare",
22741 /* 37 */ "Jump",
22742 /* 38 */ "Once",
22743 /* 39 */ "If",
22744 /* 40 */ "IfNot",
22745 /* 41 */ "Column",
22746 /* 42 */ "Affinity",
22747 /* 43 */ "MakeRecord",
22748 /* 44 */ "Count",
22749 /* 45 */ "ReadCookie",
22750 /* 46 */ "SetCookie",
22751 /* 47 */ "VerifyCookie",
22752 /* 48 */ "OpenRead",
22753 /* 49 */ "OpenWrite",
22754 /* 50 */ "OpenAutoindex",
22755 /* 51 */ "OpenEphemeral",
22756 /* 52 */ "SorterOpen",
22757 /* 53 */ "OpenPseudo",
22758 /* 54 */ "Close",
22759 /* 55 */ "SeekLt",
22760 /* 56 */ "SeekLe",
22761 /* 57 */ "SeekGe",
22762 /* 58 */ "SeekGt",
22763 /* 59 */ "Seek",
22764 /* 60 */ "NotFound",
22765 /* 61 */ "Found",
22766 /* 62 */ "IsUnique",
22767 /* 63 */ "NotExists",
22768 /* 64 */ "Sequence",
22769 /* 65 */ "NewRowid",
22770 /* 66 */ "Insert",
22771 /* 67 */ "InsertInt",
22772 /* 68 */ "Or",
22773 /* 69 */ "And",
22774 /* 70 */ "Delete",
22775 /* 71 */ "ResetCount",
22776 /* 72 */ "SorterCompare",
22777 /* 73 */ "IsNull",
22778 /* 74 */ "NotNull",
22779 /* 75 */ "Ne",
22780 /* 76 */ "Eq",
22781 /* 77 */ "Gt",
22782 /* 78 */ "Le",
22783 /* 79 */ "Lt",
22784 /* 80 */ "Ge",
22785 /* 81 */ "SorterData",
22786 /* 82 */ "BitAnd",
22787 /* 83 */ "BitOr",
22788 /* 84 */ "ShiftLeft",
22789 /* 85 */ "ShiftRight",
22790 /* 86 */ "Add",
@@ -22784,59 +22791,59 @@
22791 /* 87 */ "Subtract",
22792 /* 88 */ "Multiply",
22793 /* 89 */ "Divide",
22794 /* 90 */ "Remainder",
22795 /* 91 */ "Concat",
22796 /* 92 */ "RowKey",
22797 /* 93 */ "BitNot",
22798 /* 94 */ "String8",
22799 /* 95 */ "RowData",
22800 /* 96 */ "Rowid",
22801 /* 97 */ "NullRow",
22802 /* 98 */ "Last",
22803 /* 99 */ "SorterSort",
22804 /* 100 */ "Sort",
22805 /* 101 */ "Rewind",
22806 /* 102 */ "SorterInsert",
22807 /* 103 */ "IdxInsert",
22808 /* 104 */ "IdxDelete",
22809 /* 105 */ "IdxRowid",
22810 /* 106 */ "IdxLT",
22811 /* 107 */ "IdxGE",
22812 /* 108 */ "Destroy",
22813 /* 109 */ "Clear",
22814 /* 110 */ "CreateIndex",
22815 /* 111 */ "CreateTable",
22816 /* 112 */ "ParseSchema",
22817 /* 113 */ "LoadAnalysis",
22818 /* 114 */ "DropTable",
22819 /* 115 */ "DropIndex",
22820 /* 116 */ "DropTrigger",
22821 /* 117 */ "IntegrityCk",
22822 /* 118 */ "RowSetAdd",
22823 /* 119 */ "RowSetRead",
22824 /* 120 */ "RowSetTest",
22825 /* 121 */ "Program",
22826 /* 122 */ "Param",
22827 /* 123 */ "FkCounter",
22828 /* 124 */ "FkIfZero",
22829 /* 125 */ "MemMax",
22830 /* 126 */ "IfPos",
22831 /* 127 */ "IfNeg",
22832 /* 128 */ "IfZero",
22833 /* 129 */ "AggFinal",
22834 /* 130 */ "Real",
22835 /* 131 */ "IncrVacuum",
22836 /* 132 */ "Expire",
22837 /* 133 */ "TableLock",
22838 /* 134 */ "VBegin",
22839 /* 135 */ "VCreate",
22840 /* 136 */ "VDestroy",
22841 /* 137 */ "VOpen",
22842 /* 138 */ "VColumn",
22843 /* 139 */ "VNext",
22844 /* 140 */ "VRename",
22845 /* 141 */ "ToText",
22846 /* 142 */ "ToBlob",
22847 /* 143 */ "ToNumeric",
22848 /* 144 */ "ToInt",
22849 /* 145 */ "ToReal",
@@ -60361,44 +60368,64 @@
60368 p->readOnly = 1;
60369 p->bIsReader = 0;
60370 for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
60371 u8 opcode = pOp->opcode;
60372
60373 /* NOTE: Be sure to update mkopcodeh.awk when adding or removing
60374 ** cases from this switch! */
60375 switch( opcode ){
60376 case OP_Function:
60377 case OP_AggStep: {
60378 if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60379 break;
60380 }
60381 case OP_Transaction: {
60382 if( pOp->p2!=0 ) p->readOnly = 0;
60383 /* fall thru */
60384 }
60385 case OP_AutoCommit:
60386 case OP_Savepoint: {
60387 p->bIsReader = 1;
60388 break;
60389 }
60390 #ifndef SQLITE_OMIT_WAL
60391 case OP_Checkpoint:
60392 #endif
60393 case OP_Vacuum:
60394 case OP_JournalMode: {
60395 p->readOnly = 0;
60396 p->bIsReader = 1;
60397 break;
60398 }
60399 #ifndef SQLITE_OMIT_VIRTUALTABLE
60400 case OP_VUpdate: {
60401 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60402 break;
60403 }
60404 case OP_VFilter: {
60405 int n;
60406 assert( p->nOp - i >= 3 );
60407 assert( pOp[-1].opcode==OP_Integer );
60408 n = pOp[-1].p1;
60409 if( n>nMaxArgs ) nMaxArgs = n;
60410 break;
60411 }
60412 #endif
60413 case OP_Next:
60414 case OP_SorterNext: {
60415 pOp->p4.xAdvance = sqlite3BtreeNext;
60416 pOp->p4type = P4_ADVANCE;
60417 break;
60418 }
60419 case OP_Prev: {
60420 pOp->p4.xAdvance = sqlite3BtreePrevious;
60421 pOp->p4type = P4_ADVANCE;
60422 break;
60423 }
60424 }
60425
60426 pOp->opflags = sqlite3OpcodeProperty[opcode];
60427 if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
60428 assert( -1-pOp->p2<p->nLabel );
60429 pOp->p2 = aLabel[-1-pOp->p2];
60430 }
60431 }
@@ -60683,24 +60710,17 @@
60710 pOp->p4type = P4_INT32;
60711 }else if( zP4==0 ){
60712 pOp->p4.p = 0;
60713 pOp->p4type = P4_NOTUSED;
60714 }else if( n==P4_KEYINFO ){
60715 KeyInfo *pOrig, *pNew;
60716
60717 pOrig = (KeyInfo*)zP4;
60718 pOp->p4.pKeyInfo = pNew = sqlite3KeyInfoAlloc(db, pOrig->nField);
60719 if( pNew ){
60720 memcpy(pNew->aColl, pOrig->aColl, pOrig->nField*sizeof(pNew->aColl[0]));
60721 memcpy(pNew->aSortOrder, pOrig->aSortOrder, pOrig->nField);
 
 
 
 
 
 
 
60722 pOp->p4type = P4_KEYINFO;
60723 }else{
60724 p->db->mallocFailed = 1;
60725 pOp->p4type = P4_NOTUSED;
60726 }
@@ -62947,11 +62967,10 @@
62967 ){
62968 u32 d1; /* Offset into aKey[] of next data element */
62969 u32 idx1; /* Offset into aKey[] of next header element */
62970 u32 szHdr1; /* Number of bytes in header */
62971 int i = 0;
 
62972 int rc = 0;
62973 const unsigned char *aKey1 = (const unsigned char *)pKey1;
62974 KeyInfo *pKeyInfo;
62975 Mem mem1;
62976
@@ -62970,32 +62989,42 @@
62989 */
62990 /* mem1.u.i = 0; // not needed, here to silence compiler warning */
62991
62992 idx1 = getVarint32(aKey1, szHdr1);
62993 d1 = szHdr1;
62994 assert( pKeyInfo->nField+1>=pPKey2->nField );
62995 assert( pKeyInfo->aSortOrder!=0 );
62996 while( idx1<szHdr1 && i<pPKey2->nField ){
62997 u32 serial_type1;
62998
62999 /* Read the serial types for the next element in each key. */
63000 idx1 += getVarint32( aKey1+idx1, serial_type1 );
63001
63002 /* Verify that there is enough key space remaining to avoid
63003 ** a buffer overread. The "d1+serial_type1+2" subexpression will
63004 ** always be greater than or equal to the amount of required key space.
63005 ** Use that approximation to avoid the more expensive call to
63006 ** sqlite3VdbeSerialTypeLen() in the common case.
63007 */
63008 if( d1+serial_type1+2>(u32)nKey1
63009 && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1
63010 ){
63011 break;
63012 }
63013
63014 /* Extract the values to be compared.
63015 */
63016 d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
63017
63018 /* Do the comparison
63019 */
63020 rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);
 
63021 if( rc!=0 ){
63022 assert( mem1.zMalloc==0 ); /* See comment below */
63023
63024 /* Invert the result if we are using DESC sort order. */
63025 if( pKeyInfo->aSortOrder[i] ){
63026 rc = -rc;
63027 }
63028
63029 /* If the PREFIX_SEARCH flag is set and all fields except the final
63030 ** rowid field were equal, then clear the PREFIX_SEARCH flag and set
@@ -65475,11 +65504,11 @@
65504 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65505 u8 encoding = ENC(db); /* The database encoding */
65506 int iCompare = 0; /* Result of last OP_Compare operation */
65507 unsigned nVmStep = 0; /* Number of virtual machine steps */
65508 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
65509 unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */
65510 #endif
65511 Mem *aMem = p->aMem; /* Copy of p->aMem */
65512 Mem *pIn1 = 0; /* 1st input operand */
65513 Mem *pIn2 = 0; /* 2nd input operand */
65514 Mem *pIn3 = 0; /* 3rd input operand */
@@ -77063,14 +77092,13 @@
77092 #endif
77093
77094 switch( pExpr->op ){
77095 case TK_IN: {
77096 char affinity; /* Affinity of the LHS of the IN */
 
 
77097 int addr; /* Address of OP_OpenEphemeral instruction */
77098 Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
77099 KeyInfo *pKeyInfo = 0; /* Key information */
77100
77101 if( rMayHaveNull ){
77102 sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);
77103 }
77104
@@ -77090,13 +77118,11 @@
77118 ** is used.
77119 */
77120 pExpr->iTable = pParse->nTab++;
77121 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
77122 if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
77123 pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1);
 
 
77124
77125 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
77126 /* Case 1: expr IN (SELECT ...)
77127 **
77128 ** Generate code to write the results of the select into the temporary
@@ -77109,15 +77135,16 @@
77135 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
77136 dest.affSdst = (u8)affinity;
77137 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
77138 pExpr->x.pSelect->iLimit = 0;
77139 if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
77140 sqlite3DbFree(pParse->db, pKeyInfo);
77141 return 0;
77142 }
77143 pEList = pExpr->x.pSelect->pEList;
77144 if( pKeyInfo && ALWAYS(pEList!=0 && pEList->nExpr>0) ){
77145 pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
77146 pEList->a[0].pExpr);
77147 }
77148 }else if( ALWAYS(pExpr->x.pList!=0) ){
77149 /* Case 2: expr IN (exprlist)
77150 **
@@ -77132,12 +77159,13 @@
77159 int r1, r2, r3;
77160
77161 if( !affinity ){
77162 affinity = SQLITE_AFF_NONE;
77163 }
77164 if( pKeyInfo ){
77165 pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
77166 }
77167
77168 /* Loop through each expression in <exprlist>. */
77169 r1 = sqlite3GetTempReg(pParse);
77170 r2 = sqlite3GetTempReg(pParse);
77171 sqlite3VdbeAddOp2(v, OP_Null, 0, r2);
@@ -77172,12 +77200,12 @@
77200 }
77201 }
77202 sqlite3ReleaseTempReg(pParse, r1);
77203 sqlite3ReleaseTempReg(pParse, r2);
77204 }
77205 if( pKeyInfo ){
77206 sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO_HANDOFF);
77207 }
77208 break;
77209 }
77210
77211 case TK_EXISTS:
@@ -86192,29 +86220,24 @@
86220 ** the error.
86221 */
86222 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
86223 int i;
86224 int nCol = pIdx->nColumn;
86225 KeyInfo *pKey;
86226
86227 pKey = sqlite3KeyInfoAlloc(pParse->db, nCol);
86228 if( pKey ){
 
 
 
 
86229 for(i=0; i<nCol; i++){
86230 char *zColl = pIdx->azColl[i];
86231 assert( zColl );
86232 pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);
86233 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
86234 }
 
86235 }
86236
86237 if( pParse->nErr ){
86238 sqlite3DbFree(pParse->db, pKey);
86239 pKey = 0;
86240 }
86241 return pKey;
86242 }
86243
@@ -97148,10 +97171,29 @@
97171 */
97172 if( pOrderBy==0 && p->iLimit ){
97173 sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
97174 }
97175 }
97176
97177 /*
97178 ** Allocate a KeyInfo object sufficient for an index of N columns.
97179 **
97180 ** Actually, always allocate one extra column for the rowid at the end
97181 ** of the index. So the KeyInfo returned will have space sufficient for
97182 ** N+1 columns.
97183 */
97184 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N){
97185 KeyInfo *p = sqlite3DbMallocZero(db,
97186 sizeof(KeyInfo) + (N+1)*(sizeof(CollSeq*)+1));
97187 if( p ){
97188 p->aSortOrder = (u8*)&p->aColl[N+1];
97189 p->nField = (u16)N;
97190 p->enc = ENC(db);
97191 p->db = db;
97192 }
97193 return p;
97194 }
97195
97196 /*
97197 ** Given an expression list, generate a KeyInfo structure that records
97198 ** the collating sequence for each expression in that expression list.
97199 **
@@ -97165,29 +97207,23 @@
97207 ** function is responsible for seeing that this structure is eventually
97208 ** freed. Add the KeyInfo structure to the P4 field of an opcode using
97209 ** P4_KEYINFO_HANDOFF is the usual way of dealing with this.
97210 */
97211 static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){
 
97212 int nExpr;
97213 KeyInfo *pInfo;
97214 struct ExprList_item *pItem;
97215 sqlite3 *db = pParse->db;
97216 int i;
97217
97218 nExpr = pList->nExpr;
97219 pInfo = sqlite3KeyInfoAlloc(db, nExpr);
97220 if( pInfo ){
 
 
 
 
97221 for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
97222 CollSeq *pColl;
97223 pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
97224 if( !pColl ) pColl = db->pDfltColl;
 
 
97225 pInfo->aColl[i] = pColl;
97226 pInfo->aSortOrder[i] = pItem->sortOrder;
97227 }
97228 }
97229 return pInfo;
@@ -98289,27 +98325,21 @@
98325 CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */
98326 int nCol; /* Number of columns in result set */
98327
98328 assert( p->pRightmost==p );
98329 nCol = p->pEList->nExpr;
98330 pKeyInfo = sqlite3KeyInfoAlloc(db, nCol);
 
98331 if( !pKeyInfo ){
98332 rc = SQLITE_NOMEM;
98333 goto multi_select_end;
98334 }
 
 
 
 
98335 for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){
98336 *apColl = multiSelectCollSeq(pParse, p, i);
98337 if( 0==*apColl ){
98338 *apColl = db->pDfltColl;
98339 }
98340 }
 
98341
98342 for(pLoop=p; pLoop; pLoop=pLoop->pPrior){
98343 for(i=0; i<2; i++){
98344 int addr = pLoop->addrOpenEphm[i];
98345 if( addr<0 ){
@@ -98674,16 +98704,12 @@
98704 struct ExprList_item *pItem;
98705 for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
98706 assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr );
98707 aPermute[i] = pItem->iOrderByCol - 1;
98708 }
98709 pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy);
 
98710 if( pKeyMerge ){
 
 
 
98711 for(i=0; i<nOrderBy; i++){
98712 CollSeq *pColl;
98713 Expr *pTerm = pOrderBy->a[i].pExpr;
98714 if( pTerm->flags & EP_Collate ){
98715 pColl = sqlite3ExprCollSeq(pParse, pTerm);
@@ -98716,16 +98742,12 @@
98742 int nExpr = p->pEList->nExpr;
98743 assert( nOrderBy>=nExpr || db->mallocFailed );
98744 regPrev = pParse->nMem+1;
98745 pParse->nMem += nExpr+1;
98746 sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);
98747 pKeyDup = sqlite3KeyInfoAlloc(db, nExpr);
 
98748 if( pKeyDup ){
 
 
 
98749 for(i=0; i<nExpr; i++){
98750 pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
98751 pKeyDup->aSortOrder[i] = 0;
98752 }
98753 }
@@ -99987,14 +100009,16 @@
100009 ** and/or pParse->db->mallocFailed.
100010 */
100011 static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
100012 Walker w;
100013 memset(&w, 0, sizeof(w));
 
100014 w.xExprCallback = exprWalkNoop;
100015 w.pParse = pParse;
100016 if( pParse->hasCompound ){
100017 w.xSelectCallback = convertCompoundSelectToSubquery;
100018 sqlite3WalkSelect(&w, pSelect);
100019 }
100020 w.xSelectCallback = selectExpander;
100021 sqlite3WalkSelect(&w, pSelect);
100022 }
100023
100024
@@ -113204,10 +113228,11 @@
113228 case 114: /* select ::= select multiselect_op oneselect */
113229 {
113230 if( yymsp[0].minor.yy159 ){
113231 yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
113232 yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
113233 if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1;
113234 }else{
113235 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
113236 }
113237 yygotominor.yy159 = yymsp[0].minor.yy159;
113238 }
113239
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.0"
111111
#define SQLITE_VERSION_NUMBER 3008000
112
-#define SQLITE_SOURCE_ID "2013-08-05 12:31:41 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4"
112
+#define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-08-05 12:31:41 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-08-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
+2 -2
--- src/timeline.c
+++ src/timeline.c
@@ -2073,11 +2073,11 @@
20732073
if(!nCount) continue /* arguable! Possible? */;
20742074
rowClass = ++nRowNumber % 2;
20752075
nEventTotal += nCount;
20762076
@<tr class='row%d(rowClass)'>
20772077
@ <td>
2078
- @ <a href="?view=bymonth&user=%h(zUser)" target="_new">%h(zUser)</a>
2078
+ @ <a href="?view=bymonth&user=%h(zUser)">%h(zUser)</a>
20792079
@ </td><td>%d(nCount)</td>
20802080
@ <td>
20812081
@ <div class='statistics-report-graph-line'
20822082
@ style='height:16px;width:%d(nSize)%%;'>
20832083
@ </div></td>
@@ -2223,11 +2223,11 @@
22232223
void stats_report_page(){
22242224
HQuery url; /* URL for various branch links */
22252225
const char * zView = P("view"); /* Which view/report to show. */
22262226
const char *zUserName = P("user");
22272227
if(!zUserName) zUserName = P("u");
2228
- url_initialize(&url, "stats_report");
2228
+ url_initialize(&url, "reports");
22292229
22302230
if(zUserName && *zUserName){
22312231
url_add_parameter(&url,"user", zUserName);
22322232
timeline_submenu(&url, "(Remove User Flag)", "view", zView, "user");
22332233
}
22342234
--- src/timeline.c
+++ src/timeline.c
@@ -2073,11 +2073,11 @@
2073 if(!nCount) continue /* arguable! Possible? */;
2074 rowClass = ++nRowNumber % 2;
2075 nEventTotal += nCount;
2076 @<tr class='row%d(rowClass)'>
2077 @ <td>
2078 @ <a href="?view=bymonth&user=%h(zUser)" target="_new">%h(zUser)</a>
2079 @ </td><td>%d(nCount)</td>
2080 @ <td>
2081 @ <div class='statistics-report-graph-line'
2082 @ style='height:16px;width:%d(nSize)%%;'>
2083 @ </div></td>
@@ -2223,11 +2223,11 @@
2223 void stats_report_page(){
2224 HQuery url; /* URL for various branch links */
2225 const char * zView = P("view"); /* Which view/report to show. */
2226 const char *zUserName = P("user");
2227 if(!zUserName) zUserName = P("u");
2228 url_initialize(&url, "stats_report");
2229
2230 if(zUserName && *zUserName){
2231 url_add_parameter(&url,"user", zUserName);
2232 timeline_submenu(&url, "(Remove User Flag)", "view", zView, "user");
2233 }
2234
--- src/timeline.c
+++ src/timeline.c
@@ -2073,11 +2073,11 @@
2073 if(!nCount) continue /* arguable! Possible? */;
2074 rowClass = ++nRowNumber % 2;
2075 nEventTotal += nCount;
2076 @<tr class='row%d(rowClass)'>
2077 @ <td>
2078 @ <a href="?view=bymonth&user=%h(zUser)">%h(zUser)</a>
2079 @ </td><td>%d(nCount)</td>
2080 @ <td>
2081 @ <div class='statistics-report-graph-line'
2082 @ style='height:16px;width:%d(nSize)%%;'>
2083 @ </div></td>
@@ -2223,11 +2223,11 @@
2223 void stats_report_page(){
2224 HQuery url; /* URL for various branch links */
2225 const char * zView = P("view"); /* Which view/report to show. */
2226 const char *zUserName = P("user");
2227 if(!zUserName) zUserName = P("u");
2228 url_initialize(&url, "reports");
2229
2230 if(zUserName && *zUserName){
2231 url_add_parameter(&url,"user", zUserName);
2232 timeline_submenu(&url, "(Remove User Flag)", "view", zView, "user");
2233 }
2234

Keyboard Shortcuts

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