Fossil SCM

Update to the SQLite 3.8.3 beta in order to better test the SQLite beta.

drh 2014-01-27 16:11 trunk
Commit 22262e75533d4485f0a3f8e7537ae688de5c6e9b
2 files changed +82 -52 +1 -1
+82 -52
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135135
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136136
** [sqlite_version()] and [sqlite_source_id()].
137137
*/
138138
#define SQLITE_VERSION "3.8.3"
139139
#define SQLITE_VERSION_NUMBER 3008003
140
-#define SQLITE_SOURCE_ID "2014-01-22 18:31:27 dea2ca6a159d5dcfd8deceedf1c2a73fb4ac1cfc"
140
+#define SQLITE_SOURCE_ID "2014-01-27 15:02:07 be1acb610f7e594b417dd8409b7a7aa8f3af5f77"
141141
142142
/*
143143
** CAPI3REF: Run-Time Library Version Numbers
144144
** KEYWORDS: sqlite3_version, sqlite3_sourceid
145145
**
@@ -11303,10 +11303,11 @@
1130311303
1130411304
/*
1130511305
** A bit in a Bitmask
1130611306
*/
1130711307
#define MASKBIT(n) (((Bitmask)1)<<(n))
11308
+#define MASKBIT32(n) (((unsigned int)1)<<(n))
1130811309
1130911310
/*
1131011311
** The following structure describes the FROM clause of a SELECT statement.
1131111312
** Each table or subquery in the FROM clause is a separate element of
1131211313
** the SrcList.a[] array.
@@ -22605,11 +22606,12 @@
2260522606
2260622607
/*
2260722608
** Read or write a four-byte big-endian integer value.
2260822609
*/
2260922610
SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){
22610
- return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
22611
+ testcase( p[0]&0x80 );
22612
+ return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
2261122613
}
2261222614
SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){
2261322615
p[0] = (u8)(v>>24);
2261422616
p[1] = (u8)(v>>16);
2261522617
p[2] = (u8)(v>>8);
@@ -22946,11 +22948,11 @@
2294622948
2294722949
/*
2294822950
** The hashing function.
2294922951
*/
2295022952
static unsigned int strHash(const char *z, int nKey){
22951
- int h = 0;
22953
+ unsigned int h = 0;
2295222954
assert( nKey>=0 );
2295322955
while( nKey > 0 ){
2295422956
h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++];
2295522957
nKey--;
2295622958
}
@@ -27650,11 +27652,11 @@
2765027652
2765127653
/* Update the global lock state and do debug tracing */
2765227654
#ifdef SQLITE_DEBUG
2765327655
{ u16 mask;
2765427656
OSTRACE(("SHM-LOCK "));
27655
- mask = ofst>31 ? 0xffffffff : (1<<(ofst+n)) - (1<<ofst);
27657
+ mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<<ofst);
2765627658
if( rc==SQLITE_OK ){
2765727659
if( lockType==F_UNLCK ){
2765827660
OSTRACE(("unlock %d ok", ofst));
2765927661
pShmNode->exclMask &= ~mask;
2766027662
pShmNode->sharedMask &= ~mask;
@@ -38426,10 +38428,11 @@
3842638428
unsigned int nPinned;
3842738429
PCache1 *pCache = (PCache1 *)p;
3842838430
PGroup *pGroup;
3842938431
PgHdr1 *pPage = 0;
3843038432
38433
+ assert( offsetof(PgHdr1,page)==0 );
3843138434
assert( pCache->bPurgeable || createFlag!=1 );
3843238435
assert( pCache->bPurgeable || pCache->nMin==0 );
3843338436
assert( pCache->bPurgeable==0 || pCache->nMin==10 );
3843438437
assert( pCache->nMin==0 || pCache->bPurgeable );
3843538438
pcache1EnterMutex(pGroup = pCache->pGroup);
@@ -38531,11 +38534,11 @@
3853138534
fetch_out:
3853238535
if( pPage && iKey>pCache->iMaxKey ){
3853338536
pCache->iMaxKey = iKey;
3853438537
}
3853538538
pcache1LeaveMutex(pGroup);
38536
- return &pPage->page;
38539
+ return (sqlite3_pcache_page*)pPage;
3853738540
}
3853838541
3853938542
3854038543
/*
3854138544
** Implementation of the sqlite3_pcache.xUnpin method.
@@ -60498,11 +60501,11 @@
6049860501
#endif /* SQLITE_DEBUG */
6049960502
6050060503
/*
6050160504
** Size of struct Mem not including the Mem.zMalloc member.
6050260505
*/
60503
-#define MEMCELLSIZE (size_t)(&(((Mem *)0)->zMalloc))
60506
+#define MEMCELLSIZE offsetof(Mem,zMalloc)
6050460507
6050560508
/*
6050660509
** Make an shallow copy of pFrom into pTo. Prior contents of
6050760510
** pTo are freed. The pFrom->z field is not duplicated. If
6050860511
** pFrom->z is used, then pTo->z points to the same thing as pFrom->z
@@ -63902,12 +63905,13 @@
6390263905
SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
6390363906
AuxData **pp = &pVdbe->pAuxData;
6390463907
while( *pp ){
6390563908
AuxData *pAux = *pp;
6390663909
if( (iOp<0)
63907
- || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
63910
+ || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg))))
6390863911
){
63912
+ testcase( pAux->iArg==31 );
6390963913
if( pAux->xDelete ){
6391063914
pAux->xDelete(pAux->pAux);
6391163915
}
6391263916
*pp = pAux->pNext;
6391363917
sqlite3DbFree(pVdbe->db, pAux);
@@ -64218,10 +64222,13 @@
6421864222
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
6421964223
const unsigned char *buf, /* Buffer to deserialize from */
6422064224
u32 serial_type, /* Serial type to deserialize */
6422164225
Mem *pMem /* Memory cell to write value into */
6422264226
){
64227
+ u64 x;
64228
+ u32 y;
64229
+ int i;
6422364230
switch( serial_type ){
6422464231
case 10: /* Reserved for future use */
6422564232
case 11: /* Reserved for future use */
6422664233
case 0: { /* NULL */
6422764234
pMem->flags = MEM_Null;
@@ -64231,36 +64238,37 @@
6423164238
pMem->u.i = (signed char)buf[0];
6423264239
pMem->flags = MEM_Int;
6423364240
return 1;
6423464241
}
6423564242
case 2: { /* 2-byte signed integer */
64236
- pMem->u.i = (((signed char)buf[0])<<8) | buf[1];
64243
+ i = 256*(signed char)buf[0] | buf[1];
64244
+ pMem->u.i = (i64)i;
6423764245
pMem->flags = MEM_Int;
6423864246
return 2;
6423964247
}
6424064248
case 3: { /* 3-byte signed integer */
64241
- pMem->u.i = (((signed char)buf[0])<<16) | (buf[1]<<8) | buf[2];
64249
+ i = 65536*(signed char)buf[0] | (buf[1]<<8) | buf[2];
64250
+ pMem->u.i = (i64)i;
6424264251
pMem->flags = MEM_Int;
6424364252
return 3;
6424464253
}
6424564254
case 4: { /* 4-byte signed integer */
64246
- pMem->u.i = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
64255
+ y = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
64256
+ pMem->u.i = (i64)*(int*)&y;
6424764257
pMem->flags = MEM_Int;
6424864258
return 4;
6424964259
}
6425064260
case 5: { /* 6-byte signed integer */
64251
- u64 x = (((signed char)buf[0])<<8) | buf[1];
64252
- u32 y = (buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5];
64261
+ x = 256*(signed char)buf[0] + buf[1];
64262
+ y = ((unsigned)buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5];
6425364263
x = (x<<32) | y;
6425464264
pMem->u.i = *(i64*)&x;
6425564265
pMem->flags = MEM_Int;
6425664266
return 6;
6425764267
}
6425864268
case 6: /* 8-byte signed integer */
6425964269
case 7: { /* IEEE floating point */
64260
- u64 x;
64261
- u32 y;
6426264270
#if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT)
6426364271
/* Verify that integers and floating point values use the same
6426464272
** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is
6426564273
** defined that 64-bit floating point values really are mixed
6426664274
** endian.
@@ -64269,13 +64277,12 @@
6426964277
static const double r1 = 1.0;
6427064278
u64 t2 = t1;
6427164279
swapMixedEndianFloat(t2);
6427264280
assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
6427364281
#endif
64274
-
64275
- x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
64276
- y = (buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7];
64282
+ x = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
64283
+ y = ((unsigned)buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7];
6427764284
x = (x<<32) | y;
6427864285
if( serial_type==6 ){
6427964286
pMem->u.i = *(i64*)&x;
6428064287
pMem->flags = MEM_Int;
6428164288
}else{
@@ -72600,11 +72607,11 @@
7260072607
#ifdef SQLITE_USE_FCNTL_TRACE
7260172608
zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
7260272609
if( zTrace ){
7260372610
int i;
7260472611
for(i=0; i<db->nDb; i++){
72605
- if( ((1<<i) & p->btreeMask)==0 ) continue;
72612
+ if( MASKBIT(i) & p->btreeMask)==0 ) continue;
7260672613
sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace);
7260772614
}
7260872615
}
7260972616
#endif /* SQLITE_USE_FCNTL_TRACE */
7261072617
#ifdef SQLITE_DEBUG
@@ -79067,11 +79074,11 @@
7906779074
ExprList *pFarg; /* List of function arguments */
7906879075
int nFarg; /* Number of function arguments */
7906979076
FuncDef *pDef; /* The function definition object */
7907079077
int nId; /* Length of the function name in bytes */
7907179078
const char *zId; /* The function name */
79072
- int constMask = 0; /* Mask of function arguments that are constant */
79079
+ u32 constMask = 0; /* Mask of function arguments that are constant */
7907379080
int i; /* Loop counter */
7907479081
u8 enc = ENC(db); /* The text encoding used by this database */
7907579082
CollSeq *pColl = 0; /* A collating sequence */
7907679083
7907779084
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
@@ -79118,11 +79125,12 @@
7911879125
break;
7911979126
}
7912079127
7912179128
for(i=0; i<nFarg; i++){
7912279129
if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
79123
- constMask |= (1<<i);
79130
+ testcase( i==31 );
79131
+ constMask |= MASKBIT32(i);
7912479132
}
7912579133
if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){
7912679134
pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);
7912779135
}
7912879136
}
@@ -89474,11 +89482,12 @@
8947489482
8947589483
/* Populate the OLD.* pseudo-table register array. These values will be
8947689484
** used by any BEFORE and AFTER triggers that exist. */
8947789485
sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);
8947889486
for(iCol=0; iCol<pTab->nCol; iCol++){
89479
- if( mask==0xffffffff || mask&(1<<iCol) ){
89487
+ testcase( mask!=0xffffffff && iCol==31 );
89488
+ if( mask==0xffffffff || (mask & MASKBIT32(iCol))!=0 ){
8948089489
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1);
8948189490
}
8948289491
}
8948389492
8948489493
/* Invoke BEFORE DELETE trigger programs. */
@@ -89794,11 +89803,11 @@
8979489803
UNUSED_PARAMETER(argc);
8979589804
switch( sqlite3_value_type(argv[0]) ){
8979689805
case SQLITE_INTEGER: {
8979789806
i64 iVal = sqlite3_value_int64(argv[0]);
8979889807
if( iVal<0 ){
89799
- if( (iVal<<1)==0 ){
89808
+ if( iVal==SMALLEST_INT64 ){
8980089809
/* IMP: R-31676-45509 If X is the integer -9223372036854775808
8980189810
** then abs(X) throws an integer overflow error since there is no
8980289811
** equivalent positive 64-bit two complement value. */
8980389812
sqlite3_result_error(context, "integer overflow", -1);
8980489813
return;
@@ -100257,10 +100266,11 @@
100257100266
** on a second ephemeral index that holds all values every previously
100258100267
** added to the queue. Only add this new value if it has never before
100259100268
** been added */
100260100269
addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, r3, 0);
100261100270
sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3);
100271
+ sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
100262100272
}
100263100273
for(i=0; i<nKey; i++){
100264100274
sqlite3VdbeAddOp2(v, OP_SCopy,
100265100275
regResult + pSO->a[i].u.x.iOrderByCol - 1,
100266100276
r2+i);
@@ -101167,11 +101177,48 @@
101167101177
if( pRet==0 && iCol<p->pEList->nExpr ){
101168101178
pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);
101169101179
}
101170101180
return pRet;
101171101181
}
101172
-#endif /* SQLITE_OMIT_COMPOUND_SELECT */
101182
+
101183
+/*
101184
+** The select statement passed as the second parameter is a compound SELECT
101185
+** with an ORDER BY clause. This function allocates and returns a KeyInfo
101186
+** structure suitable for implementing the ORDER BY.
101187
+**
101188
+** Space to hold the KeyInfo structure is obtained from malloc. The calling
101189
+** function is responsible for ensuring that this structure is eventually
101190
+** freed.
101191
+*/
101192
+static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){
101193
+ ExprList *pOrderBy = p->pOrderBy;
101194
+ int nOrderBy = p->pOrderBy->nExpr;
101195
+ sqlite3 *db = pParse->db;
101196
+ KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1);
101197
+ if( pRet ){
101198
+ int i;
101199
+ for(i=0; i<nOrderBy; i++){
101200
+ struct ExprList_item *pItem = &pOrderBy->a[i];
101201
+ Expr *pTerm = pItem->pExpr;
101202
+ CollSeq *pColl;
101203
+
101204
+ if( pTerm->flags & EP_Collate ){
101205
+ pColl = sqlite3ExprCollSeq(pParse, pTerm);
101206
+ }else{
101207
+ pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1);
101208
+ if( pColl==0 ) pColl = db->pDfltColl;
101209
+ pOrderBy->a[i].pExpr =
101210
+ sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);
101211
+ }
101212
+ assert( sqlite3KeyInfoIsWriteable(pRet) );
101213
+ pRet->aColl[i] = pColl;
101214
+ pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder;
101215
+ }
101216
+ }
101217
+
101218
+ return pRet;
101219
+}
101173101220
101174101221
#ifndef SQLITE_OMIT_CTE
101175101222
/*
101176101223
** This routine generates VDBE code to compute the content of a WITH RECURSIVE
101177101224
** query of the form:
@@ -101241,23 +101288,20 @@
101241101288
pOffset = p->pOffset;
101242101289
regLimit = p->iLimit;
101243101290
regOffset = p->iOffset;
101244101291
p->pLimit = p->pOffset = 0;
101245101292
p->iLimit = p->iOffset = 0;
101293
+ pOrderBy = p->pOrderBy;
101246101294
101247101295
/* Locate the cursor number of the Current table */
101248101296
for(i=0; ALWAYS(i<pSrc->nSrc); i++){
101249101297
if( pSrc->a[i].isRecursive ){
101250101298
iCurrent = pSrc->a[i].iCursor;
101251101299
break;
101252101300
}
101253101301
}
101254101302
101255
- /* Detach the ORDER BY clause from the compound SELECT */
101256
- pOrderBy = p->pOrderBy;
101257
- p->pOrderBy = 0;
101258
-
101259101303
/* Allocate cursors numbers for Queue and Distinct. The cursor number for
101260101304
** the Distinct table must be exactly one greater than Queue in order
101261101305
** for the SRT_DistTable and SRT_DistQueue destinations to work. */
101262101306
iQueue = pParse->nTab++;
101263101307
if( p->op==TK_UNION ){
@@ -101270,11 +101314,11 @@
101270101314
101271101315
/* Allocate cursors for Current, Queue, and Distinct. */
101272101316
regCurrent = ++pParse->nMem;
101273101317
sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol);
101274101318
if( pOrderBy ){
101275
- KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pOrderBy, 1);
101319
+ KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1);
101276101320
sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0,
101277101321
(char*)pKeyInfo, P4_KEYINFO);
101278101322
destQueue.pOrderBy = pOrderBy;
101279101323
}else{
101280101324
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol);
@@ -101282,10 +101326,13 @@
101282101326
VdbeComment((v, "Queue table"));
101283101327
if( iDistinct ){
101284101328
p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0);
101285101329
p->selFlags |= SF_UsesEphemeral;
101286101330
}
101331
+
101332
+ /* Detach the ORDER BY clause from the compound SELECT */
101333
+ p->pOrderBy = 0;
101287101334
101288101335
/* Store the results of the setup-query in Queue. */
101289101336
rc = sqlite3Select(pParse, pSetup, &destQueue);
101290101337
if( rc ) goto end_of_recursive_query;
101291101338
@@ -101325,21 +101372,20 @@
101325101372
p->pOrderBy = pOrderBy;
101326101373
p->pLimit = pLimit;
101327101374
p->pOffset = pOffset;
101328101375
return;
101329101376
}
101330
-#endif
101377
+#endif /* SQLITE_OMIT_CTE */
101331101378
101332101379
/* Forward references */
101333101380
static int multiSelectOrderBy(
101334101381
Parse *pParse, /* Parsing context */
101335101382
Select *p, /* The right-most of SELECTs to be coded */
101336101383
SelectDest *pDest /* What to do with query results */
101337101384
);
101338101385
101339101386
101340
-#ifndef SQLITE_OMIT_COMPOUND_SELECT
101341101387
/*
101342101388
** This routine is called to process a compound query form from
101343101389
** two or more separate queries using UNION, UNION ALL, EXCEPT, or
101344101390
** INTERSECT
101345101391
**
@@ -102067,28 +102113,11 @@
102067102113
for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
102068102114
assert( pItem->u.x.iOrderByCol>0
102069102115
&& pItem->u.x.iOrderByCol<=p->pEList->nExpr );
102070102116
aPermute[i] = pItem->u.x.iOrderByCol - 1;
102071102117
}
102072
- pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy, 1);
102073
- if( pKeyMerge ){
102074
- for(i=0; i<nOrderBy; i++){
102075
- CollSeq *pColl;
102076
- Expr *pTerm = pOrderBy->a[i].pExpr;
102077
- if( pTerm->flags & EP_Collate ){
102078
- pColl = sqlite3ExprCollSeq(pParse, pTerm);
102079
- }else{
102080
- pColl = multiSelectCollSeq(pParse, p, aPermute[i]);
102081
- if( pColl==0 ) pColl = db->pDfltColl;
102082
- pOrderBy->a[i].pExpr =
102083
- sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);
102084
- }
102085
- assert( sqlite3KeyInfoIsWriteable(pKeyMerge) );
102086
- pKeyMerge->aColl[i] = pColl;
102087
- pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder;
102088
- }
102089
- }
102118
+ pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);
102090102119
}else{
102091102120
pKeyMerge = 0;
102092102121
}
102093102122
102094102123
/* Reattach the ORDER BY clause to the query.
@@ -106561,13 +106590,14 @@
106561106590
oldmask |= sqlite3TriggerColmask(pParse,
106562106591
pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError
106563106592
);
106564106593
for(i=0; i<pTab->nCol; i++){
106565106594
if( oldmask==0xffffffff
106566
- || (i<32 && (oldmask & (1<<i)))
106595
+ || (i<32 && (oldmask & MASKBIT32(i))!=0)
106567106596
|| (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0
106568106597
){
106598
+ testcase( oldmask!=0xffffffff && i==31 );
106569106599
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i);
106570106600
}else{
106571106601
sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);
106572106602
}
106573106603
}
@@ -106598,11 +106628,11 @@
106598106628
sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
106599106629
}else{
106600106630
j = aXRef[i];
106601106631
if( j>=0 ){
106602106632
sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
106603
- }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask&(1<<i)) ){
106633
+ }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){
106604106634
/* This branch loads the value of a column that will not be changed
106605106635
** into a register. This is done if there are no BEFORE triggers, or
106606106636
** if there are one or more BEFORE triggers that use this value via
106607106637
** a new.* reference in a trigger program.
106608106638
*/
@@ -131671,17 +131701,17 @@
131671131701
/*
131672131702
** Hash and comparison functions when the mode is FTS3_HASH_STRING
131673131703
*/
131674131704
static int fts3StrHash(const void *pKey, int nKey){
131675131705
const char *z = (const char *)pKey;
131676
- int h = 0;
131706
+ unsigned h = 0;
131677131707
if( nKey<=0 ) nKey = (int) strlen(z);
131678131708
while( nKey > 0 ){
131679131709
h = (h<<3) ^ h ^ *z++;
131680131710
nKey--;
131681131711
}
131682
- return h & 0x7fffffff;
131712
+ return (int)(h & 0x7fffffff);
131683131713
}
131684131714
static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){
131685131715
if( n1!=n2 ) return 1;
131686131716
return strncmp((const char*)pKey1,(const char*)pKey2,n1);
131687131717
}
131688131718
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136 ** [sqlite_version()] and [sqlite_source_id()].
137 */
138 #define SQLITE_VERSION "3.8.3"
139 #define SQLITE_VERSION_NUMBER 3008003
140 #define SQLITE_SOURCE_ID "2014-01-22 18:31:27 dea2ca6a159d5dcfd8deceedf1c2a73fb4ac1cfc"
141
142 /*
143 ** CAPI3REF: Run-Time Library Version Numbers
144 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
145 **
@@ -11303,10 +11303,11 @@
11303
11304 /*
11305 ** A bit in a Bitmask
11306 */
11307 #define MASKBIT(n) (((Bitmask)1)<<(n))
 
11308
11309 /*
11310 ** The following structure describes the FROM clause of a SELECT statement.
11311 ** Each table or subquery in the FROM clause is a separate element of
11312 ** the SrcList.a[] array.
@@ -22605,11 +22606,12 @@
22605
22606 /*
22607 ** Read or write a four-byte big-endian integer value.
22608 */
22609 SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){
22610 return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
 
22611 }
22612 SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){
22613 p[0] = (u8)(v>>24);
22614 p[1] = (u8)(v>>16);
22615 p[2] = (u8)(v>>8);
@@ -22946,11 +22948,11 @@
22946
22947 /*
22948 ** The hashing function.
22949 */
22950 static unsigned int strHash(const char *z, int nKey){
22951 int h = 0;
22952 assert( nKey>=0 );
22953 while( nKey > 0 ){
22954 h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++];
22955 nKey--;
22956 }
@@ -27650,11 +27652,11 @@
27650
27651 /* Update the global lock state and do debug tracing */
27652 #ifdef SQLITE_DEBUG
27653 { u16 mask;
27654 OSTRACE(("SHM-LOCK "));
27655 mask = ofst>31 ? 0xffffffff : (1<<(ofst+n)) - (1<<ofst);
27656 if( rc==SQLITE_OK ){
27657 if( lockType==F_UNLCK ){
27658 OSTRACE(("unlock %d ok", ofst));
27659 pShmNode->exclMask &= ~mask;
27660 pShmNode->sharedMask &= ~mask;
@@ -38426,10 +38428,11 @@
38426 unsigned int nPinned;
38427 PCache1 *pCache = (PCache1 *)p;
38428 PGroup *pGroup;
38429 PgHdr1 *pPage = 0;
38430
 
38431 assert( pCache->bPurgeable || createFlag!=1 );
38432 assert( pCache->bPurgeable || pCache->nMin==0 );
38433 assert( pCache->bPurgeable==0 || pCache->nMin==10 );
38434 assert( pCache->nMin==0 || pCache->bPurgeable );
38435 pcache1EnterMutex(pGroup = pCache->pGroup);
@@ -38531,11 +38534,11 @@
38531 fetch_out:
38532 if( pPage && iKey>pCache->iMaxKey ){
38533 pCache->iMaxKey = iKey;
38534 }
38535 pcache1LeaveMutex(pGroup);
38536 return &pPage->page;
38537 }
38538
38539
38540 /*
38541 ** Implementation of the sqlite3_pcache.xUnpin method.
@@ -60498,11 +60501,11 @@
60498 #endif /* SQLITE_DEBUG */
60499
60500 /*
60501 ** Size of struct Mem not including the Mem.zMalloc member.
60502 */
60503 #define MEMCELLSIZE (size_t)(&(((Mem *)0)->zMalloc))
60504
60505 /*
60506 ** Make an shallow copy of pFrom into pTo. Prior contents of
60507 ** pTo are freed. The pFrom->z field is not duplicated. If
60508 ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z
@@ -63902,12 +63905,13 @@
63902 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
63903 AuxData **pp = &pVdbe->pAuxData;
63904 while( *pp ){
63905 AuxData *pAux = *pp;
63906 if( (iOp<0)
63907 || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg))))
63908 ){
 
63909 if( pAux->xDelete ){
63910 pAux->xDelete(pAux->pAux);
63911 }
63912 *pp = pAux->pNext;
63913 sqlite3DbFree(pVdbe->db, pAux);
@@ -64218,10 +64222,13 @@
64218 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
64219 const unsigned char *buf, /* Buffer to deserialize from */
64220 u32 serial_type, /* Serial type to deserialize */
64221 Mem *pMem /* Memory cell to write value into */
64222 ){
 
 
 
64223 switch( serial_type ){
64224 case 10: /* Reserved for future use */
64225 case 11: /* Reserved for future use */
64226 case 0: { /* NULL */
64227 pMem->flags = MEM_Null;
@@ -64231,36 +64238,37 @@
64231 pMem->u.i = (signed char)buf[0];
64232 pMem->flags = MEM_Int;
64233 return 1;
64234 }
64235 case 2: { /* 2-byte signed integer */
64236 pMem->u.i = (((signed char)buf[0])<<8) | buf[1];
 
64237 pMem->flags = MEM_Int;
64238 return 2;
64239 }
64240 case 3: { /* 3-byte signed integer */
64241 pMem->u.i = (((signed char)buf[0])<<16) | (buf[1]<<8) | buf[2];
 
64242 pMem->flags = MEM_Int;
64243 return 3;
64244 }
64245 case 4: { /* 4-byte signed integer */
64246 pMem->u.i = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
 
64247 pMem->flags = MEM_Int;
64248 return 4;
64249 }
64250 case 5: { /* 6-byte signed integer */
64251 u64 x = (((signed char)buf[0])<<8) | buf[1];
64252 u32 y = (buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5];
64253 x = (x<<32) | y;
64254 pMem->u.i = *(i64*)&x;
64255 pMem->flags = MEM_Int;
64256 return 6;
64257 }
64258 case 6: /* 8-byte signed integer */
64259 case 7: { /* IEEE floating point */
64260 u64 x;
64261 u32 y;
64262 #if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT)
64263 /* Verify that integers and floating point values use the same
64264 ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is
64265 ** defined that 64-bit floating point values really are mixed
64266 ** endian.
@@ -64269,13 +64277,12 @@
64269 static const double r1 = 1.0;
64270 u64 t2 = t1;
64271 swapMixedEndianFloat(t2);
64272 assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
64273 #endif
64274
64275 x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
64276 y = (buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7];
64277 x = (x<<32) | y;
64278 if( serial_type==6 ){
64279 pMem->u.i = *(i64*)&x;
64280 pMem->flags = MEM_Int;
64281 }else{
@@ -72600,11 +72607,11 @@
72600 #ifdef SQLITE_USE_FCNTL_TRACE
72601 zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
72602 if( zTrace ){
72603 int i;
72604 for(i=0; i<db->nDb; i++){
72605 if( ((1<<i) & p->btreeMask)==0 ) continue;
72606 sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace);
72607 }
72608 }
72609 #endif /* SQLITE_USE_FCNTL_TRACE */
72610 #ifdef SQLITE_DEBUG
@@ -79067,11 +79074,11 @@
79067 ExprList *pFarg; /* List of function arguments */
79068 int nFarg; /* Number of function arguments */
79069 FuncDef *pDef; /* The function definition object */
79070 int nId; /* Length of the function name in bytes */
79071 const char *zId; /* The function name */
79072 int constMask = 0; /* Mask of function arguments that are constant */
79073 int i; /* Loop counter */
79074 u8 enc = ENC(db); /* The text encoding used by this database */
79075 CollSeq *pColl = 0; /* A collating sequence */
79076
79077 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
@@ -79118,11 +79125,12 @@
79118 break;
79119 }
79120
79121 for(i=0; i<nFarg; i++){
79122 if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
79123 constMask |= (1<<i);
 
79124 }
79125 if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){
79126 pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);
79127 }
79128 }
@@ -89474,11 +89482,12 @@
89474
89475 /* Populate the OLD.* pseudo-table register array. These values will be
89476 ** used by any BEFORE and AFTER triggers that exist. */
89477 sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);
89478 for(iCol=0; iCol<pTab->nCol; iCol++){
89479 if( mask==0xffffffff || mask&(1<<iCol) ){
 
89480 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1);
89481 }
89482 }
89483
89484 /* Invoke BEFORE DELETE trigger programs. */
@@ -89794,11 +89803,11 @@
89794 UNUSED_PARAMETER(argc);
89795 switch( sqlite3_value_type(argv[0]) ){
89796 case SQLITE_INTEGER: {
89797 i64 iVal = sqlite3_value_int64(argv[0]);
89798 if( iVal<0 ){
89799 if( (iVal<<1)==0 ){
89800 /* IMP: R-31676-45509 If X is the integer -9223372036854775808
89801 ** then abs(X) throws an integer overflow error since there is no
89802 ** equivalent positive 64-bit two complement value. */
89803 sqlite3_result_error(context, "integer overflow", -1);
89804 return;
@@ -100257,10 +100266,11 @@
100257 ** on a second ephemeral index that holds all values every previously
100258 ** added to the queue. Only add this new value if it has never before
100259 ** been added */
100260 addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, r3, 0);
100261 sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3);
 
100262 }
100263 for(i=0; i<nKey; i++){
100264 sqlite3VdbeAddOp2(v, OP_SCopy,
100265 regResult + pSO->a[i].u.x.iOrderByCol - 1,
100266 r2+i);
@@ -101167,11 +101177,48 @@
101167 if( pRet==0 && iCol<p->pEList->nExpr ){
101168 pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);
101169 }
101170 return pRet;
101171 }
101172 #endif /* SQLITE_OMIT_COMPOUND_SELECT */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101173
101174 #ifndef SQLITE_OMIT_CTE
101175 /*
101176 ** This routine generates VDBE code to compute the content of a WITH RECURSIVE
101177 ** query of the form:
@@ -101241,23 +101288,20 @@
101241 pOffset = p->pOffset;
101242 regLimit = p->iLimit;
101243 regOffset = p->iOffset;
101244 p->pLimit = p->pOffset = 0;
101245 p->iLimit = p->iOffset = 0;
 
101246
101247 /* Locate the cursor number of the Current table */
101248 for(i=0; ALWAYS(i<pSrc->nSrc); i++){
101249 if( pSrc->a[i].isRecursive ){
101250 iCurrent = pSrc->a[i].iCursor;
101251 break;
101252 }
101253 }
101254
101255 /* Detach the ORDER BY clause from the compound SELECT */
101256 pOrderBy = p->pOrderBy;
101257 p->pOrderBy = 0;
101258
101259 /* Allocate cursors numbers for Queue and Distinct. The cursor number for
101260 ** the Distinct table must be exactly one greater than Queue in order
101261 ** for the SRT_DistTable and SRT_DistQueue destinations to work. */
101262 iQueue = pParse->nTab++;
101263 if( p->op==TK_UNION ){
@@ -101270,11 +101314,11 @@
101270
101271 /* Allocate cursors for Current, Queue, and Distinct. */
101272 regCurrent = ++pParse->nMem;
101273 sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol);
101274 if( pOrderBy ){
101275 KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pOrderBy, 1);
101276 sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0,
101277 (char*)pKeyInfo, P4_KEYINFO);
101278 destQueue.pOrderBy = pOrderBy;
101279 }else{
101280 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol);
@@ -101282,10 +101326,13 @@
101282 VdbeComment((v, "Queue table"));
101283 if( iDistinct ){
101284 p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0);
101285 p->selFlags |= SF_UsesEphemeral;
101286 }
 
 
 
101287
101288 /* Store the results of the setup-query in Queue. */
101289 rc = sqlite3Select(pParse, pSetup, &destQueue);
101290 if( rc ) goto end_of_recursive_query;
101291
@@ -101325,21 +101372,20 @@
101325 p->pOrderBy = pOrderBy;
101326 p->pLimit = pLimit;
101327 p->pOffset = pOffset;
101328 return;
101329 }
101330 #endif
101331
101332 /* Forward references */
101333 static int multiSelectOrderBy(
101334 Parse *pParse, /* Parsing context */
101335 Select *p, /* The right-most of SELECTs to be coded */
101336 SelectDest *pDest /* What to do with query results */
101337 );
101338
101339
101340 #ifndef SQLITE_OMIT_COMPOUND_SELECT
101341 /*
101342 ** This routine is called to process a compound query form from
101343 ** two or more separate queries using UNION, UNION ALL, EXCEPT, or
101344 ** INTERSECT
101345 **
@@ -102067,28 +102113,11 @@
102067 for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
102068 assert( pItem->u.x.iOrderByCol>0
102069 && pItem->u.x.iOrderByCol<=p->pEList->nExpr );
102070 aPermute[i] = pItem->u.x.iOrderByCol - 1;
102071 }
102072 pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy, 1);
102073 if( pKeyMerge ){
102074 for(i=0; i<nOrderBy; i++){
102075 CollSeq *pColl;
102076 Expr *pTerm = pOrderBy->a[i].pExpr;
102077 if( pTerm->flags & EP_Collate ){
102078 pColl = sqlite3ExprCollSeq(pParse, pTerm);
102079 }else{
102080 pColl = multiSelectCollSeq(pParse, p, aPermute[i]);
102081 if( pColl==0 ) pColl = db->pDfltColl;
102082 pOrderBy->a[i].pExpr =
102083 sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);
102084 }
102085 assert( sqlite3KeyInfoIsWriteable(pKeyMerge) );
102086 pKeyMerge->aColl[i] = pColl;
102087 pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder;
102088 }
102089 }
102090 }else{
102091 pKeyMerge = 0;
102092 }
102093
102094 /* Reattach the ORDER BY clause to the query.
@@ -106561,13 +106590,14 @@
106561 oldmask |= sqlite3TriggerColmask(pParse,
106562 pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError
106563 );
106564 for(i=0; i<pTab->nCol; i++){
106565 if( oldmask==0xffffffff
106566 || (i<32 && (oldmask & (1<<i)))
106567 || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0
106568 ){
 
106569 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i);
106570 }else{
106571 sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);
106572 }
106573 }
@@ -106598,11 +106628,11 @@
106598 sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
106599 }else{
106600 j = aXRef[i];
106601 if( j>=0 ){
106602 sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
106603 }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask&(1<<i)) ){
106604 /* This branch loads the value of a column that will not be changed
106605 ** into a register. This is done if there are no BEFORE triggers, or
106606 ** if there are one or more BEFORE triggers that use this value via
106607 ** a new.* reference in a trigger program.
106608 */
@@ -131671,17 +131701,17 @@
131671 /*
131672 ** Hash and comparison functions when the mode is FTS3_HASH_STRING
131673 */
131674 static int fts3StrHash(const void *pKey, int nKey){
131675 const char *z = (const char *)pKey;
131676 int h = 0;
131677 if( nKey<=0 ) nKey = (int) strlen(z);
131678 while( nKey > 0 ){
131679 h = (h<<3) ^ h ^ *z++;
131680 nKey--;
131681 }
131682 return h & 0x7fffffff;
131683 }
131684 static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){
131685 if( n1!=n2 ) return 1;
131686 return strncmp((const char*)pKey1,(const char*)pKey2,n1);
131687 }
131688
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136 ** [sqlite_version()] and [sqlite_source_id()].
137 */
138 #define SQLITE_VERSION "3.8.3"
139 #define SQLITE_VERSION_NUMBER 3008003
140 #define SQLITE_SOURCE_ID "2014-01-27 15:02:07 be1acb610f7e594b417dd8409b7a7aa8f3af5f77"
141
142 /*
143 ** CAPI3REF: Run-Time Library Version Numbers
144 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
145 **
@@ -11303,10 +11303,11 @@
11303
11304 /*
11305 ** A bit in a Bitmask
11306 */
11307 #define MASKBIT(n) (((Bitmask)1)<<(n))
11308 #define MASKBIT32(n) (((unsigned int)1)<<(n))
11309
11310 /*
11311 ** The following structure describes the FROM clause of a SELECT statement.
11312 ** Each table or subquery in the FROM clause is a separate element of
11313 ** the SrcList.a[] array.
@@ -22605,11 +22606,12 @@
22606
22607 /*
22608 ** Read or write a four-byte big-endian integer value.
22609 */
22610 SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){
22611 testcase( p[0]&0x80 );
22612 return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
22613 }
22614 SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){
22615 p[0] = (u8)(v>>24);
22616 p[1] = (u8)(v>>16);
22617 p[2] = (u8)(v>>8);
@@ -22946,11 +22948,11 @@
22948
22949 /*
22950 ** The hashing function.
22951 */
22952 static unsigned int strHash(const char *z, int nKey){
22953 unsigned int h = 0;
22954 assert( nKey>=0 );
22955 while( nKey > 0 ){
22956 h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++];
22957 nKey--;
22958 }
@@ -27650,11 +27652,11 @@
27652
27653 /* Update the global lock state and do debug tracing */
27654 #ifdef SQLITE_DEBUG
27655 { u16 mask;
27656 OSTRACE(("SHM-LOCK "));
27657 mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<<ofst);
27658 if( rc==SQLITE_OK ){
27659 if( lockType==F_UNLCK ){
27660 OSTRACE(("unlock %d ok", ofst));
27661 pShmNode->exclMask &= ~mask;
27662 pShmNode->sharedMask &= ~mask;
@@ -38426,10 +38428,11 @@
38428 unsigned int nPinned;
38429 PCache1 *pCache = (PCache1 *)p;
38430 PGroup *pGroup;
38431 PgHdr1 *pPage = 0;
38432
38433 assert( offsetof(PgHdr1,page)==0 );
38434 assert( pCache->bPurgeable || createFlag!=1 );
38435 assert( pCache->bPurgeable || pCache->nMin==0 );
38436 assert( pCache->bPurgeable==0 || pCache->nMin==10 );
38437 assert( pCache->nMin==0 || pCache->bPurgeable );
38438 pcache1EnterMutex(pGroup = pCache->pGroup);
@@ -38531,11 +38534,11 @@
38534 fetch_out:
38535 if( pPage && iKey>pCache->iMaxKey ){
38536 pCache->iMaxKey = iKey;
38537 }
38538 pcache1LeaveMutex(pGroup);
38539 return (sqlite3_pcache_page*)pPage;
38540 }
38541
38542
38543 /*
38544 ** Implementation of the sqlite3_pcache.xUnpin method.
@@ -60498,11 +60501,11 @@
60501 #endif /* SQLITE_DEBUG */
60502
60503 /*
60504 ** Size of struct Mem not including the Mem.zMalloc member.
60505 */
60506 #define MEMCELLSIZE offsetof(Mem,zMalloc)
60507
60508 /*
60509 ** Make an shallow copy of pFrom into pTo. Prior contents of
60510 ** pTo are freed. The pFrom->z field is not duplicated. If
60511 ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z
@@ -63902,12 +63905,13 @@
63905 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
63906 AuxData **pp = &pVdbe->pAuxData;
63907 while( *pp ){
63908 AuxData *pAux = *pp;
63909 if( (iOp<0)
63910 || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg))))
63911 ){
63912 testcase( pAux->iArg==31 );
63913 if( pAux->xDelete ){
63914 pAux->xDelete(pAux->pAux);
63915 }
63916 *pp = pAux->pNext;
63917 sqlite3DbFree(pVdbe->db, pAux);
@@ -64218,10 +64222,13 @@
64222 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
64223 const unsigned char *buf, /* Buffer to deserialize from */
64224 u32 serial_type, /* Serial type to deserialize */
64225 Mem *pMem /* Memory cell to write value into */
64226 ){
64227 u64 x;
64228 u32 y;
64229 int i;
64230 switch( serial_type ){
64231 case 10: /* Reserved for future use */
64232 case 11: /* Reserved for future use */
64233 case 0: { /* NULL */
64234 pMem->flags = MEM_Null;
@@ -64231,36 +64238,37 @@
64238 pMem->u.i = (signed char)buf[0];
64239 pMem->flags = MEM_Int;
64240 return 1;
64241 }
64242 case 2: { /* 2-byte signed integer */
64243 i = 256*(signed char)buf[0] | buf[1];
64244 pMem->u.i = (i64)i;
64245 pMem->flags = MEM_Int;
64246 return 2;
64247 }
64248 case 3: { /* 3-byte signed integer */
64249 i = 65536*(signed char)buf[0] | (buf[1]<<8) | buf[2];
64250 pMem->u.i = (i64)i;
64251 pMem->flags = MEM_Int;
64252 return 3;
64253 }
64254 case 4: { /* 4-byte signed integer */
64255 y = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
64256 pMem->u.i = (i64)*(int*)&y;
64257 pMem->flags = MEM_Int;
64258 return 4;
64259 }
64260 case 5: { /* 6-byte signed integer */
64261 x = 256*(signed char)buf[0] + buf[1];
64262 y = ((unsigned)buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5];
64263 x = (x<<32) | y;
64264 pMem->u.i = *(i64*)&x;
64265 pMem->flags = MEM_Int;
64266 return 6;
64267 }
64268 case 6: /* 8-byte signed integer */
64269 case 7: { /* IEEE floating point */
 
 
64270 #if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT)
64271 /* Verify that integers and floating point values use the same
64272 ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is
64273 ** defined that 64-bit floating point values really are mixed
64274 ** endian.
@@ -64269,13 +64277,12 @@
64277 static const double r1 = 1.0;
64278 u64 t2 = t1;
64279 swapMixedEndianFloat(t2);
64280 assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
64281 #endif
64282 x = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
64283 y = ((unsigned)buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7];
 
64284 x = (x<<32) | y;
64285 if( serial_type==6 ){
64286 pMem->u.i = *(i64*)&x;
64287 pMem->flags = MEM_Int;
64288 }else{
@@ -72600,11 +72607,11 @@
72607 #ifdef SQLITE_USE_FCNTL_TRACE
72608 zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
72609 if( zTrace ){
72610 int i;
72611 for(i=0; i<db->nDb; i++){
72612 if( MASKBIT(i) & p->btreeMask)==0 ) continue;
72613 sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace);
72614 }
72615 }
72616 #endif /* SQLITE_USE_FCNTL_TRACE */
72617 #ifdef SQLITE_DEBUG
@@ -79067,11 +79074,11 @@
79074 ExprList *pFarg; /* List of function arguments */
79075 int nFarg; /* Number of function arguments */
79076 FuncDef *pDef; /* The function definition object */
79077 int nId; /* Length of the function name in bytes */
79078 const char *zId; /* The function name */
79079 u32 constMask = 0; /* Mask of function arguments that are constant */
79080 int i; /* Loop counter */
79081 u8 enc = ENC(db); /* The text encoding used by this database */
79082 CollSeq *pColl = 0; /* A collating sequence */
79083
79084 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
@@ -79118,11 +79125,12 @@
79125 break;
79126 }
79127
79128 for(i=0; i<nFarg; i++){
79129 if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
79130 testcase( i==31 );
79131 constMask |= MASKBIT32(i);
79132 }
79133 if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){
79134 pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);
79135 }
79136 }
@@ -89474,11 +89482,12 @@
89482
89483 /* Populate the OLD.* pseudo-table register array. These values will be
89484 ** used by any BEFORE and AFTER triggers that exist. */
89485 sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);
89486 for(iCol=0; iCol<pTab->nCol; iCol++){
89487 testcase( mask!=0xffffffff && iCol==31 );
89488 if( mask==0xffffffff || (mask & MASKBIT32(iCol))!=0 ){
89489 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1);
89490 }
89491 }
89492
89493 /* Invoke BEFORE DELETE trigger programs. */
@@ -89794,11 +89803,11 @@
89803 UNUSED_PARAMETER(argc);
89804 switch( sqlite3_value_type(argv[0]) ){
89805 case SQLITE_INTEGER: {
89806 i64 iVal = sqlite3_value_int64(argv[0]);
89807 if( iVal<0 ){
89808 if( iVal==SMALLEST_INT64 ){
89809 /* IMP: R-31676-45509 If X is the integer -9223372036854775808
89810 ** then abs(X) throws an integer overflow error since there is no
89811 ** equivalent positive 64-bit two complement value. */
89812 sqlite3_result_error(context, "integer overflow", -1);
89813 return;
@@ -100257,10 +100266,11 @@
100266 ** on a second ephemeral index that holds all values every previously
100267 ** added to the queue. Only add this new value if it has never before
100268 ** been added */
100269 addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, r3, 0);
100270 sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3);
100271 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
100272 }
100273 for(i=0; i<nKey; i++){
100274 sqlite3VdbeAddOp2(v, OP_SCopy,
100275 regResult + pSO->a[i].u.x.iOrderByCol - 1,
100276 r2+i);
@@ -101167,11 +101177,48 @@
101177 if( pRet==0 && iCol<p->pEList->nExpr ){
101178 pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);
101179 }
101180 return pRet;
101181 }
101182
101183 /*
101184 ** The select statement passed as the second parameter is a compound SELECT
101185 ** with an ORDER BY clause. This function allocates and returns a KeyInfo
101186 ** structure suitable for implementing the ORDER BY.
101187 **
101188 ** Space to hold the KeyInfo structure is obtained from malloc. The calling
101189 ** function is responsible for ensuring that this structure is eventually
101190 ** freed.
101191 */
101192 static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){
101193 ExprList *pOrderBy = p->pOrderBy;
101194 int nOrderBy = p->pOrderBy->nExpr;
101195 sqlite3 *db = pParse->db;
101196 KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1);
101197 if( pRet ){
101198 int i;
101199 for(i=0; i<nOrderBy; i++){
101200 struct ExprList_item *pItem = &pOrderBy->a[i];
101201 Expr *pTerm = pItem->pExpr;
101202 CollSeq *pColl;
101203
101204 if( pTerm->flags & EP_Collate ){
101205 pColl = sqlite3ExprCollSeq(pParse, pTerm);
101206 }else{
101207 pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1);
101208 if( pColl==0 ) pColl = db->pDfltColl;
101209 pOrderBy->a[i].pExpr =
101210 sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);
101211 }
101212 assert( sqlite3KeyInfoIsWriteable(pRet) );
101213 pRet->aColl[i] = pColl;
101214 pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder;
101215 }
101216 }
101217
101218 return pRet;
101219 }
101220
101221 #ifndef SQLITE_OMIT_CTE
101222 /*
101223 ** This routine generates VDBE code to compute the content of a WITH RECURSIVE
101224 ** query of the form:
@@ -101241,23 +101288,20 @@
101288 pOffset = p->pOffset;
101289 regLimit = p->iLimit;
101290 regOffset = p->iOffset;
101291 p->pLimit = p->pOffset = 0;
101292 p->iLimit = p->iOffset = 0;
101293 pOrderBy = p->pOrderBy;
101294
101295 /* Locate the cursor number of the Current table */
101296 for(i=0; ALWAYS(i<pSrc->nSrc); i++){
101297 if( pSrc->a[i].isRecursive ){
101298 iCurrent = pSrc->a[i].iCursor;
101299 break;
101300 }
101301 }
101302
 
 
 
 
101303 /* Allocate cursors numbers for Queue and Distinct. The cursor number for
101304 ** the Distinct table must be exactly one greater than Queue in order
101305 ** for the SRT_DistTable and SRT_DistQueue destinations to work. */
101306 iQueue = pParse->nTab++;
101307 if( p->op==TK_UNION ){
@@ -101270,11 +101314,11 @@
101314
101315 /* Allocate cursors for Current, Queue, and Distinct. */
101316 regCurrent = ++pParse->nMem;
101317 sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol);
101318 if( pOrderBy ){
101319 KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1);
101320 sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0,
101321 (char*)pKeyInfo, P4_KEYINFO);
101322 destQueue.pOrderBy = pOrderBy;
101323 }else{
101324 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol);
@@ -101282,10 +101326,13 @@
101326 VdbeComment((v, "Queue table"));
101327 if( iDistinct ){
101328 p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0);
101329 p->selFlags |= SF_UsesEphemeral;
101330 }
101331
101332 /* Detach the ORDER BY clause from the compound SELECT */
101333 p->pOrderBy = 0;
101334
101335 /* Store the results of the setup-query in Queue. */
101336 rc = sqlite3Select(pParse, pSetup, &destQueue);
101337 if( rc ) goto end_of_recursive_query;
101338
@@ -101325,21 +101372,20 @@
101372 p->pOrderBy = pOrderBy;
101373 p->pLimit = pLimit;
101374 p->pOffset = pOffset;
101375 return;
101376 }
101377 #endif /* SQLITE_OMIT_CTE */
101378
101379 /* Forward references */
101380 static int multiSelectOrderBy(
101381 Parse *pParse, /* Parsing context */
101382 Select *p, /* The right-most of SELECTs to be coded */
101383 SelectDest *pDest /* What to do with query results */
101384 );
101385
101386
 
101387 /*
101388 ** This routine is called to process a compound query form from
101389 ** two or more separate queries using UNION, UNION ALL, EXCEPT, or
101390 ** INTERSECT
101391 **
@@ -102067,28 +102113,11 @@
102113 for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
102114 assert( pItem->u.x.iOrderByCol>0
102115 && pItem->u.x.iOrderByCol<=p->pEList->nExpr );
102116 aPermute[i] = pItem->u.x.iOrderByCol - 1;
102117 }
102118 pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102119 }else{
102120 pKeyMerge = 0;
102121 }
102122
102123 /* Reattach the ORDER BY clause to the query.
@@ -106561,13 +106590,14 @@
106590 oldmask |= sqlite3TriggerColmask(pParse,
106591 pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError
106592 );
106593 for(i=0; i<pTab->nCol; i++){
106594 if( oldmask==0xffffffff
106595 || (i<32 && (oldmask & MASKBIT32(i))!=0)
106596 || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0
106597 ){
106598 testcase( oldmask!=0xffffffff && i==31 );
106599 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i);
106600 }else{
106601 sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);
106602 }
106603 }
@@ -106598,11 +106628,11 @@
106628 sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
106629 }else{
106630 j = aXRef[i];
106631 if( j>=0 ){
106632 sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
106633 }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){
106634 /* This branch loads the value of a column that will not be changed
106635 ** into a register. This is done if there are no BEFORE triggers, or
106636 ** if there are one or more BEFORE triggers that use this value via
106637 ** a new.* reference in a trigger program.
106638 */
@@ -131671,17 +131701,17 @@
131701 /*
131702 ** Hash and comparison functions when the mode is FTS3_HASH_STRING
131703 */
131704 static int fts3StrHash(const void *pKey, int nKey){
131705 const char *z = (const char *)pKey;
131706 unsigned h = 0;
131707 if( nKey<=0 ) nKey = (int) strlen(z);
131708 while( nKey > 0 ){
131709 h = (h<<3) ^ h ^ *z++;
131710 nKey--;
131711 }
131712 return (int)(h & 0x7fffffff);
131713 }
131714 static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){
131715 if( n1!=n2 ) return 1;
131716 return strncmp((const char*)pKey1,(const char*)pKey2,n1);
131717 }
131718
+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.3"
111111
#define SQLITE_VERSION_NUMBER 3008003
112
-#define SQLITE_SOURCE_ID "2014-01-22 18:31:27 dea2ca6a159d5dcfd8deceedf1c2a73fb4ac1cfc"
112
+#define SQLITE_SOURCE_ID "2014-01-27 15:02:07 be1acb610f7e594b417dd8409b7a7aa8f3af5f77"
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.3"
111 #define SQLITE_VERSION_NUMBER 3008003
112 #define SQLITE_SOURCE_ID "2014-01-22 18:31:27 dea2ca6a159d5dcfd8deceedf1c2a73fb4ac1cfc"
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.3"
111 #define SQLITE_VERSION_NUMBER 3008003
112 #define SQLITE_SOURCE_ID "2014-01-27 15:02:07 be1acb610f7e594b417dd8409b7a7aa8f3af5f77"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118

Keyboard Shortcuts

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