Fossil SCM

Update the built-in SQLite to 3.8.4 beta.

drh 2014-03-05 19:07 trunk
Commit f0773f6370059a21e11d59e74abf785127489555
2 files changed +44 -68 +1 -1
+44 -68
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -189,11 +189,11 @@
189189
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
190190
** [sqlite_version()] and [sqlite_source_id()].
191191
*/
192192
#define SQLITE_VERSION "3.8.4"
193193
#define SQLITE_VERSION_NUMBER 3008004
194
-#define SQLITE_SOURCE_ID "2014-03-04 13:18:23 9830c343bc954b828f6ca752f8ae63e2c0a980c1"
194
+#define SQLITE_SOURCE_ID "2014-03-05 19:04:46 0723effc9ccae7c660fb847b36ce9324e0cb5042"
195195
196196
/*
197197
** CAPI3REF: Run-Time Library Version Numbers
198198
** KEYWORDS: sqlite3_version, sqlite3_sourceid
199199
**
@@ -11385,12 +11385,12 @@
1138511385
**
1138611386
** In the colUsed field, the high-order bit (bit 63) is set if the table
1138711387
** contains more than 63 columns and the 64-th or later column is used.
1138811388
*/
1138911389
struct SrcList {
11390
- u8 nSrc; /* Number of tables or subqueries in the FROM clause */
11391
- u8 nAlloc; /* Number of entries allocated in a[] below */
11390
+ int nSrc; /* Number of tables or subqueries in the FROM clause */
11391
+ u32 nAlloc; /* Number of entries allocated in a[] below */
1139211392
struct SrcList_item {
1139311393
Schema *pSchema; /* Schema to which this item is fixed */
1139411394
char *zDatabase; /* Name of database holding this table */
1139511395
char *zName; /* Name of the table */
1139611396
char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */
@@ -13418,10 +13418,13 @@
1341813418
#ifdef SQLITE_OMIT_COMPLETE
1341913419
"OMIT_COMPLETE",
1342013420
#endif
1342113421
#ifdef SQLITE_OMIT_COMPOUND_SELECT
1342213422
"OMIT_COMPOUND_SELECT",
13423
+#endif
13424
+#ifdef SQLITE_OMIT_CTE
13425
+ "OMIT_CTE",
1342313426
#endif
1342413427
#ifdef SQLITE_OMIT_DATETIME_FUNCS
1342513428
"OMIT_DATETIME_FUNCS",
1342613429
#endif
1342713430
#ifdef SQLITE_OMIT_DECLTYPE
@@ -13803,11 +13806,10 @@
1380313806
RowSet *pRowSet; /* Used only when flags==MEM_RowSet */
1380413807
VdbeFrame *pFrame; /* Used when flags==MEM_Frame */
1380513808
} u;
1380613809
int n; /* Number of characters in string value, excluding '\0' */
1380713810
u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
13808
- u8 memType; /* Lower 5 bits of flags */
1380913811
u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
1381013812
#ifdef SQLITE_DEBUG
1381113813
Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
1381213814
void *pFiller; /* So that sizeof(Mem) is a multiple of 8 */
1381313815
#endif
@@ -13830,10 +13832,11 @@
1383013832
#define MEM_Null 0x0001 /* Value is NULL */
1383113833
#define MEM_Str 0x0002 /* Value is a string */
1383213834
#define MEM_Int 0x0004 /* Value is an integer */
1383313835
#define MEM_Real 0x0008 /* Value is a real number */
1383413836
#define MEM_Blob 0x0010 /* Value is a BLOB */
13837
+#define MEM_AffMask 0x001f /* Mask of affinity bits */
1383513838
#define MEM_RowSet 0x0020 /* Value is a RowSet object */
1383613839
#define MEM_Frame 0x0040 /* Value is a VdbeFrame object */
1383713840
#define MEM_Undefined 0x0080 /* Value is undefined */
1383813841
#define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
1383913842
#define MEM_TypeMask 0x01ff /* Mask of type bits */
@@ -14069,12 +14072,10 @@
1406914072
SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
1407014073
SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
1407114074
SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
1407214075
SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
1407314076
SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
14074
-#define sqlite3VdbeMemStoreType(X) (X)->memType = (u8)((X)->flags&0x1f)
14075
-/* void sqlite3VdbeMemStoreType(Mem *pMem); */
1407614077
SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
1407714078
1407814079
SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *);
1407914080
SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
1408014081
SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
@@ -55372,11 +55373,11 @@
5537255373
lwr = 0;
5537355374
upr = pPage->nCell-1;
5537455375
assert( biasRight==0 || biasRight==1 );
5537555376
idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
5537655377
pCur->aiIdx[pCur->iPage] = (u16)idx;
55377
- if( pPage->intKey ){
55378
+ if( xRecordCompare==0 ){
5537855379
for(;;){
5537955380
i64 nCellKey;
5538055381
pCell = findCell(pPage, idx) + pPage->childPtrSize;
5538155382
if( pPage->hasData ){
5538255383
while( 0x80 <= *(pCell++) ){
@@ -60120,10 +60121,11 @@
6012060121
sqlite3DbFree(pMem->db, pMem->zMalloc);
6012160122
pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
6012260123
}
6012360124
if( pMem->zMalloc==0 ){
6012460125
VdbeMemRelease(pMem);
60126
+ pMem->z = 0;
6012560127
pMem->flags = MEM_Null;
6012660128
return SQLITE_NOMEM;
6012760129
}
6012860130
}
6012960131
@@ -60318,11 +60320,11 @@
6031860320
}
6031960321
6032060322
/*
6032160323
** Release any memory held by the Mem. This may leave the Mem in an
6032260324
** inconsistent state, for example with (Mem.z==0) and
60323
-** (Mem.memType==MEM_Str).
60325
+** (Mem.flags==MEM_Str).
6032460326
*/
6032560327
SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){
6032660328
assert( sqlite3VdbeCheckMemInvariants(p) );
6032760329
VdbeMemRelease(p);
6032860330
if( p->zMalloc ){
@@ -60510,11 +60512,10 @@
6051060512
}
6051160513
if( pMem->flags & MEM_RowSet ){
6051260514
sqlite3RowSetClear(pMem->u.pRowSet);
6051360515
}
6051460516
MemSetTypeFlag(pMem, MEM_Null);
60515
- pMem->memType = MEM_Null;
6051660517
}
6051760518
SQLITE_PRIVATE void sqlite3ValueSetNull(sqlite3_value *p){
6051860519
sqlite3VdbeMemSetNull((Mem*)p);
6051960520
}
6052060521
@@ -60523,11 +60524,10 @@
6052360524
** n containing all zeros.
6052460525
*/
6052560526
SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){
6052660527
sqlite3VdbeMemRelease(pMem);
6052760528
pMem->flags = MEM_Blob|MEM_Zero;
60528
- pMem->memType = MEM_Blob;
6052960529
pMem->n = 0;
6053060530
if( n<0 ) n = 0;
6053160531
pMem->u.nZero = n;
6053260532
pMem->enc = SQLITE_UTF8;
6053360533
@@ -60546,11 +60546,10 @@
6054660546
*/
6054760547
SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
6054860548
sqlite3VdbeMemRelease(pMem);
6054960549
pMem->u.i = val;
6055060550
pMem->flags = MEM_Int;
60551
- pMem->memType = MEM_Int;
6055260551
}
6055360552
6055460553
#ifndef SQLITE_OMIT_FLOATING_POINT
6055560554
/*
6055660555
** Delete any previous value and set the value stored in *pMem to val,
@@ -60561,11 +60560,10 @@
6056160560
sqlite3VdbeMemSetNull(pMem);
6056260561
}else{
6056360562
sqlite3VdbeMemRelease(pMem);
6056460563
pMem->r = val;
6056560564
pMem->flags = MEM_Real;
60566
- pMem->memType = MEM_Real;
6056760565
}
6056860566
}
6056960567
#endif
6057060568
6057160569
/*
@@ -60770,11 +60768,10 @@
6077060768
}
6077160769
6077260770
pMem->n = nByte;
6077360771
pMem->flags = flags;
6077460772
pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);
60775
- pMem->memType = flags&0x1f;
6077660773
6077760774
#ifndef SQLITE_OMIT_UTF16
6077860775
if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){
6077960776
return SQLITE_NOMEM;
6078060777
}
@@ -60836,11 +60833,10 @@
6083660833
}
6083760834
if( rc==SQLITE_OK ){
6083860835
pMem->z[amt] = 0;
6083960836
pMem->z[amt+1] = 0;
6084060837
pMem->flags = MEM_Blob|MEM_Term;
60841
- pMem->memType = MEM_Blob;
6084260838
pMem->n = (int)amt;
6084360839
}else{
6084460840
sqlite3VdbeMemRelease(pMem);
6084560841
}
6084660842
}
@@ -60899,11 +60895,10 @@
6089960895
*/
6090060896
SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *db){
6090160897
Mem *p = sqlite3DbMallocZero(db, sizeof(*p));
6090260898
if( p ){
6090360899
p->flags = MEM_Null;
60904
- p->memType = MEM_Null;
6090560900
p->db = db;
6090660901
}
6090760902
return p;
6090860903
}
6090960904
@@ -60948,11 +60943,10 @@
6094860943
assert( pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField==nCol );
6094960944
assert( pRec->pKeyInfo->enc==ENC(db) );
6095060945
pRec->aMem = (Mem *)((u8*)pRec + ROUND8(sizeof(UnpackedRecord)));
6095160946
for(i=0; i<nCol; i++){
6095260947
pRec->aMem[i].flags = MEM_Null;
60953
- pRec->aMem[i].memType = MEM_Null;
6095460948
pRec->aMem[i].db = db;
6095560949
}
6095660950
}else{
6095760951
sqlite3DbFree(db, pRec);
6095860952
pRec = 0;
@@ -61021,11 +61015,10 @@
6102161015
sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);
6102261016
}else{
6102361017
zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
6102461018
if( zVal==0 ) goto no_mem;
6102561019
sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
61026
- if( op==TK_FLOAT ) pVal->memType = MEM_Real;
6102761020
}
6102861021
if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){
6102961022
sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);
6103061023
}else{
6103161024
sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);
@@ -61039,13 +61032,13 @@
6103961032
if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal)
6104061033
&& pVal!=0
6104161034
){
6104261035
sqlite3VdbeMemNumerify(pVal);
6104361036
if( pVal->u.i==SMALLEST_INT64 ){
61044
- pVal->flags &= MEM_Int;
61037
+ pVal->flags &= ~MEM_Int;
6104561038
pVal->flags |= MEM_Real;
61046
- pVal->r = (double)LARGEST_INT64;
61039
+ pVal->r = (double)SMALLEST_INT64;
6104761040
}else{
6104861041
pVal->u.i = -pVal->u.i;
6104961042
}
6105061043
pVal->r = -pVal->r;
6105161044
sqlite3ValueApplyAffinity(pVal, affinity, enc);
@@ -61067,13 +61060,10 @@
6106761060
sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
6106861061
0, SQLITE_DYNAMIC);
6106961062
}
6107061063
#endif
6107161064
61072
- if( pVal ){
61073
- sqlite3VdbeMemStoreType(pVal);
61074
- }
6107561065
*ppVal = pVal;
6107661066
return rc;
6107761067
6107861068
no_mem:
6107961069
db->mallocFailed = 1;
@@ -61233,11 +61223,10 @@
6123361223
rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
6123461224
if( rc==SQLITE_OK ){
6123561225
sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
6123661226
}
6123761227
pVal->db = pParse->db;
61238
- sqlite3VdbeMemStoreType((Mem*)pVal);
6123961228
}
6124061229
}
6124161230
}else{
6124261231
rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, &alloc);
6124361232
}
@@ -62668,19 +62657,17 @@
6266862657
}
6266962658
pOp = &apSub[j]->aOp[i];
6267062659
}
6267162660
if( p->explain==1 ){
6267262661
pMem->flags = MEM_Int;
62673
- pMem->memType = MEM_Int;
6267462662
pMem->u.i = i; /* Program counter */
6267562663
pMem++;
6267662664
6267762665
pMem->flags = MEM_Static|MEM_Str|MEM_Term;
6267862666
pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
6267962667
assert( pMem->z!=0 );
6268062668
pMem->n = sqlite3Strlen30(pMem->z);
62681
- pMem->memType = MEM_Str;
6268262669
pMem->enc = SQLITE_UTF8;
6268362670
pMem++;
6268462671
6268562672
/* When an OP_Program opcode is encounter (the only opcode that has
6268662673
** a P4_SUBPROGRAM argument), expand the size of the array of subprograms
@@ -62702,21 +62689,18 @@
6270262689
}
6270362690
}
6270462691
6270562692
pMem->flags = MEM_Int;
6270662693
pMem->u.i = pOp->p1; /* P1 */
62707
- pMem->memType = MEM_Int;
6270862694
pMem++;
6270962695
6271062696
pMem->flags = MEM_Int;
6271162697
pMem->u.i = pOp->p2; /* P2 */
62712
- pMem->memType = MEM_Int;
6271362698
pMem++;
6271462699
6271562700
pMem->flags = MEM_Int;
6271662701
pMem->u.i = pOp->p3; /* P3 */
62717
- pMem->memType = MEM_Int;
6271862702
pMem++;
6271962703
6272062704
if( sqlite3VdbeMemGrow(pMem, 32, 0) ){ /* P4 */
6272162705
assert( p->db->mallocFailed );
6272262706
return SQLITE_ERROR;
@@ -62728,11 +62712,10 @@
6272862712
}else{
6272962713
assert( pMem->z!=0 );
6273062714
pMem->n = sqlite3Strlen30(pMem->z);
6273162715
pMem->enc = SQLITE_UTF8;
6273262716
}
62733
- pMem->memType = MEM_Str;
6273462717
pMem++;
6273562718
6273662719
if( p->explain==1 ){
6273762720
if( sqlite3VdbeMemGrow(pMem, 4, 0) ){
6273862721
assert( p->db->mallocFailed );
@@ -62739,11 +62722,10 @@
6273962722
return SQLITE_ERROR;
6274062723
}
6274162724
pMem->flags = MEM_Str|MEM_Term;
6274262725
pMem->n = 2;
6274362726
sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */
62744
- pMem->memType = MEM_Str;
6274562727
pMem->enc = SQLITE_UTF8;
6274662728
pMem++;
6274762729
6274862730
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
6274962731
if( sqlite3VdbeMemGrow(pMem, 500, 0) ){
@@ -62750,15 +62732,13 @@
6275062732
assert( p->db->mallocFailed );
6275162733
return SQLITE_ERROR;
6275262734
}
6275362735
pMem->flags = MEM_Str|MEM_Term;
6275462736
pMem->n = displayComment(pOp, zP4, pMem->z, 500);
62755
- pMem->memType = MEM_Str;
6275662737
pMem->enc = SQLITE_UTF8;
6275762738
#else
6275862739
pMem->flags = MEM_Null; /* Comment */
62759
- pMem->memType = MEM_Null;
6276062740
#endif
6276162741
}
6276262742
6276362743
p->nResColumn = 8 - 4*(p->explain-1);
6276462744
p->pResultSet = &p->aMem[1];
@@ -64844,13 +64824,14 @@
6484464824
6484564825
if( rc!=0 ){
6484664826
if( pKeyInfo->aSortOrder[i] ){
6484764827
rc = -rc;
6484864828
}
64849
- assert( CORRUPT_DB
64829
+ assert( CORRUPT_DB
6485064830
|| (rc<0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)<0)
6485164831
|| (rc>0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)>0)
64832
+ || pKeyInfo->db->mallocFailed
6485264833
);
6485364834
assert( mem1.zMalloc==0 ); /* See comment below */
6485464835
return rc;
6485564836
}
6485664837
@@ -65241,11 +65222,10 @@
6524165222
if( 0==(pMem->flags & MEM_Null) ){
6524265223
sqlite3_value *pRet = sqlite3ValueNew(v->db);
6524365224
if( pRet ){
6524465225
sqlite3VdbeMemCopy((Mem *)pRet, pMem);
6524565226
sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
65246
- sqlite3VdbeMemStoreType((Mem *)pRet);
6524765227
}
6524865228
return pRet;
6524965229
}
6525065230
}
6525165231
return 0;
@@ -65415,11 +65395,10 @@
6541565395
*/
6541665396
SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){
6541765397
Mem *p = (Mem*)pVal;
6541865398
if( p->flags & (MEM_Blob|MEM_Str) ){
6541965399
sqlite3VdbeMemExpandBlob(p);
65420
- p->flags &= ~MEM_Str;
6542165400
p->flags |= MEM_Blob;
6542265401
return p->n ? p->z : 0;
6542365402
}else{
6542465403
return sqlite3_value_text(pVal);
6542565404
}
@@ -65486,11 +65465,11 @@
6548665465
SQLITE_INTEGER, /* 0x1c */
6548765466
SQLITE_NULL, /* 0x1d */
6548865467
SQLITE_INTEGER, /* 0x1e */
6548965468
SQLITE_NULL, /* 0x1f */
6549065469
};
65491
- return aType[pVal->memType&0x1f];
65470
+ return aType[pVal->flags&MEM_AffMask];
6549265471
}
6549365472
6549465473
/**************************** sqlite3_result_ *******************************
6549565474
** The following routines are used by user-defined functions to specify
6549665475
** the function result.
@@ -66007,10 +65986,34 @@
6600765986
Vdbe *pVm = (Vdbe *)pStmt;
6600865987
if( pVm==0 || pVm->pResultSet==0 ) return 0;
6600965988
return pVm->nResColumn;
6601065989
}
6601165990
65991
+/*
65992
+** Return a pointer to static memory containing an SQL NULL value.
65993
+*/
65994
+static const Mem *columnNullValue(void){
65995
+ /* Even though the Mem structure contains an element
65996
+ ** of type i64, on certain architectures (x86) with certain compiler
65997
+ ** switches (-Os), gcc may align this Mem object on a 4-byte boundary
65998
+ ** instead of an 8-byte one. This all works fine, except that when
65999
+ ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s
66000
+ ** that a Mem structure is located on an 8-byte boundary. To prevent
66001
+ ** these assert()s from failing, when building with SQLITE_DEBUG defined
66002
+ ** using gcc, we force nullMem to be 8-byte aligned using the magical
66003
+ ** __attribute__((aligned(8))) macro. */
66004
+ static const Mem nullMem
66005
+#if defined(SQLITE_DEBUG) && defined(__GNUC__)
66006
+ __attribute__((aligned(8)))
66007
+#endif
66008
+ = {0, "", (double)0, {0}, 0, MEM_Null, 0,
66009
+#ifdef SQLITE_DEBUG
66010
+ 0, 0, /* pScopyFrom, pFiller */
66011
+#endif
66012
+ 0, 0 };
66013
+ return &nullMem;
66014
+}
6601266015
6601366016
/*
6601466017
** Check to see if column iCol of the given statement is valid. If
6601566018
** it is, return a pointer to the Mem for the value of that column.
6601666019
** If iCol is not valid, return a pointer to a Mem which has a value
@@ -66023,36 +66026,15 @@
6602366026
pVm = (Vdbe *)pStmt;
6602466027
if( pVm && pVm->pResultSet!=0 && i<pVm->nResColumn && i>=0 ){
6602566028
sqlite3_mutex_enter(pVm->db->mutex);
6602666029
pOut = &pVm->pResultSet[i];
6602766030
}else{
66028
- /* If the value passed as the second argument is out of range, return
66029
- ** a pointer to the following static Mem object which contains the
66030
- ** value SQL NULL. Even though the Mem structure contains an element
66031
- ** of type i64, on certain architectures (x86) with certain compiler
66032
- ** switches (-Os), gcc may align this Mem object on a 4-byte boundary
66033
- ** instead of an 8-byte one. This all works fine, except that when
66034
- ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s
66035
- ** that a Mem structure is located on an 8-byte boundary. To prevent
66036
- ** these assert()s from failing, when building with SQLITE_DEBUG defined
66037
- ** using gcc, we force nullMem to be 8-byte aligned using the magical
66038
- ** __attribute__((aligned(8))) macro. */
66039
- static const Mem nullMem
66040
-#if defined(SQLITE_DEBUG) && defined(__GNUC__)
66041
- __attribute__((aligned(8)))
66042
-#endif
66043
- = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0,
66044
-#ifdef SQLITE_DEBUG
66045
- 0, 0, /* pScopyFrom, pFiller */
66046
-#endif
66047
- 0, 0 };
66048
-
6604966031
if( pVm && ALWAYS(pVm->db) ){
6605066032
sqlite3_mutex_enter(pVm->db->mutex);
6605166033
sqlite3Error(pVm->db, SQLITE_RANGE, 0);
6605266034
}
66053
- pOut = (Mem*)&nullMem;
66035
+ pOut = (Mem*)columnNullValue();
6605466036
}
6605566037
return pOut;
6605666038
}
6605766039
6605866040
/*
@@ -67228,11 +67210,10 @@
6722867210
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
6722967211
int eType = sqlite3_value_type(pVal);
6723067212
if( eType==SQLITE_TEXT ){
6723167213
Mem *pMem = (Mem*)pVal;
6723267214
applyNumericAffinity(pMem);
67233
- sqlite3VdbeMemStoreType(pMem);
6723467215
eType = sqlite3_value_type(pVal);
6723567216
}
6723667217
return eType;
6723767218
}
6723867219
@@ -68267,11 +68248,10 @@
6826768248
assert( memIsValid(&pMem[i]) );
6826868249
Deephemeralize(&pMem[i]);
6826968250
assert( (pMem[i].flags & MEM_Ephem)==0
6827068251
|| (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
6827168252
sqlite3VdbeMemNulTerminate(&pMem[i]);
68272
- sqlite3VdbeMemStoreType(&pMem[i]);
6827368253
REGISTER_TRACE(pOp->p1+i, &pMem[i]);
6827468254
}
6827568255
if( db->mallocFailed ) goto no_mem;
6827668256
6827768257
/* Return SQLITE_ROW
@@ -68513,11 +68493,10 @@
6851368493
pArg = &aMem[pOp->p2];
6851468494
for(i=0; i<n; i++, pArg++){
6851568495
assert( memIsValid(pArg) );
6851668496
apVal[i] = pArg;
6851768497
Deephemeralize(pArg);
68518
- sqlite3VdbeMemStoreType(pArg);
6851968498
REGISTER_TRACE(pOp->p2+i, pArg);
6852068499
}
6852168500
6852268501
assert( pOp->p4type==P4_FUNCDEF );
6852368502
ctx.pFunc = pOp->p4.pFunc;
@@ -72518,11 +72497,10 @@
7251872497
assert( apVal || n==0 );
7251972498
for(i=0; i<n; i++, pRec++){
7252072499
assert( memIsValid(pRec) );
7252172500
apVal[i] = pRec;
7252272501
memAboutToChange(p, pRec);
72523
- sqlite3VdbeMemStoreType(pRec);
7252472502
}
7252572503
ctx.pFunc = pOp->p4.pFunc;
7252672504
assert( pOp->p3>0 && pOp->p3<=(p->nMem-p->nCursor) );
7252772505
ctx.pMem = pMem = &aMem[pOp->p3];
7252872506
pMem->n++;
@@ -72952,11 +72930,10 @@
7295272930
{
7295372931
res = 0;
7295472932
apArg = p->apArg;
7295572933
for(i = 0; i<nArg; i++){
7295672934
apArg[i] = &pArgc[i+1];
72957
- sqlite3VdbeMemStoreType(apArg[i]);
7295872935
}
7295972936
7296072937
p->inVtabMethod = 1;
7296172938
rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
7296272939
p->inVtabMethod = 0;
@@ -73159,11 +73136,10 @@
7315973136
apArg = p->apArg;
7316073137
pX = &aMem[pOp->p3];
7316173138
for(i=0; i<nArg; i++){
7316273139
assert( memIsValid(pX) );
7316373140
memAboutToChange(p, pX);
73164
- sqlite3VdbeMemStoreType(pX);
7316573141
apArg[i] = pX;
7316673142
pX++;
7316773143
}
7316873144
db->vtabOnConflict = pOp->p5;
7316973145
rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);
@@ -88183,11 +88159,11 @@
8818388159
assert( nExtra>=1 );
8818488160
assert( pSrc!=0 );
8818588161
assert( iStart<=pSrc->nSrc );
8818688162
8818788163
/* Allocate additional space if needed */
88188
- if( pSrc->nSrc+nExtra>pSrc->nAlloc ){
88164
+ if( (u32)pSrc->nSrc+nExtra>pSrc->nAlloc ){
8818988165
SrcList *pNew;
8819088166
int nAlloc = pSrc->nSrc+nExtra;
8819188167
int nGot;
8819288168
pNew = sqlite3DbRealloc(db, pSrc,
8819388169
sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );
@@ -88195,19 +88171,19 @@
8819588171
assert( db->mallocFailed );
8819688172
return pSrc;
8819788173
}
8819888174
pSrc = pNew;
8819988175
nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1;
88200
- pSrc->nAlloc = (u8)nGot;
88176
+ pSrc->nAlloc = nGot;
8820188177
}
8820288178
8820388179
/* Move existing slots that come after the newly inserted slots
8820488180
** out of the way */
8820588181
for(i=pSrc->nSrc-1; i>=iStart; i--){
8820688182
pSrc->a[i+nExtra] = pSrc->a[i];
8820788183
}
88208
- pSrc->nSrc += (i8)nExtra;
88184
+ pSrc->nSrc += nExtra;
8820988185
8821088186
/* Zero the newly allocated slots */
8821188187
memset(&pSrc->a[iStart], 0, sizeof(pSrc->a[0])*nExtra);
8821288188
for(i=iStart; i<iStart+nExtra; i++){
8821388189
pSrc->a[i].iCursor = -1;
@@ -101494,11 +101470,11 @@
101494101470
for(j=cnt=0; j<i; j++){
101495101471
if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){
101496101472
char *zNewName;
101497101473
int k;
101498101474
for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){}
101499
- if( zName[k]==':' ) nName = k;
101475
+ if( k>=0 && zName[k]==':' ) nName = k;
101500101476
zName[nName] = 0;
101501101477
zNewName = sqlite3MPrintf(db, "%s:%d", zName, ++cnt);
101502101478
sqlite3DbFree(db, zName);
101503101479
zName = zNewName;
101504101480
j = -1;
101505101481
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -189,11 +189,11 @@
189 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
190 ** [sqlite_version()] and [sqlite_source_id()].
191 */
192 #define SQLITE_VERSION "3.8.4"
193 #define SQLITE_VERSION_NUMBER 3008004
194 #define SQLITE_SOURCE_ID "2014-03-04 13:18:23 9830c343bc954b828f6ca752f8ae63e2c0a980c1"
195
196 /*
197 ** CAPI3REF: Run-Time Library Version Numbers
198 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
199 **
@@ -11385,12 +11385,12 @@
11385 **
11386 ** In the colUsed field, the high-order bit (bit 63) is set if the table
11387 ** contains more than 63 columns and the 64-th or later column is used.
11388 */
11389 struct SrcList {
11390 u8 nSrc; /* Number of tables or subqueries in the FROM clause */
11391 u8 nAlloc; /* Number of entries allocated in a[] below */
11392 struct SrcList_item {
11393 Schema *pSchema; /* Schema to which this item is fixed */
11394 char *zDatabase; /* Name of database holding this table */
11395 char *zName; /* Name of the table */
11396 char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */
@@ -13418,10 +13418,13 @@
13418 #ifdef SQLITE_OMIT_COMPLETE
13419 "OMIT_COMPLETE",
13420 #endif
13421 #ifdef SQLITE_OMIT_COMPOUND_SELECT
13422 "OMIT_COMPOUND_SELECT",
 
 
 
13423 #endif
13424 #ifdef SQLITE_OMIT_DATETIME_FUNCS
13425 "OMIT_DATETIME_FUNCS",
13426 #endif
13427 #ifdef SQLITE_OMIT_DECLTYPE
@@ -13803,11 +13806,10 @@
13803 RowSet *pRowSet; /* Used only when flags==MEM_RowSet */
13804 VdbeFrame *pFrame; /* Used when flags==MEM_Frame */
13805 } u;
13806 int n; /* Number of characters in string value, excluding '\0' */
13807 u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
13808 u8 memType; /* Lower 5 bits of flags */
13809 u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
13810 #ifdef SQLITE_DEBUG
13811 Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
13812 void *pFiller; /* So that sizeof(Mem) is a multiple of 8 */
13813 #endif
@@ -13830,10 +13832,11 @@
13830 #define MEM_Null 0x0001 /* Value is NULL */
13831 #define MEM_Str 0x0002 /* Value is a string */
13832 #define MEM_Int 0x0004 /* Value is an integer */
13833 #define MEM_Real 0x0008 /* Value is a real number */
13834 #define MEM_Blob 0x0010 /* Value is a BLOB */
 
13835 #define MEM_RowSet 0x0020 /* Value is a RowSet object */
13836 #define MEM_Frame 0x0040 /* Value is a VdbeFrame object */
13837 #define MEM_Undefined 0x0080 /* Value is undefined */
13838 #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
13839 #define MEM_TypeMask 0x01ff /* Mask of type bits */
@@ -14069,12 +14072,10 @@
14069 SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
14070 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
14071 SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
14072 SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
14073 SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
14074 #define sqlite3VdbeMemStoreType(X) (X)->memType = (u8)((X)->flags&0x1f)
14075 /* void sqlite3VdbeMemStoreType(Mem *pMem); */
14076 SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
14077
14078 SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *);
14079 SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
14080 SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
@@ -55372,11 +55373,11 @@
55372 lwr = 0;
55373 upr = pPage->nCell-1;
55374 assert( biasRight==0 || biasRight==1 );
55375 idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
55376 pCur->aiIdx[pCur->iPage] = (u16)idx;
55377 if( pPage->intKey ){
55378 for(;;){
55379 i64 nCellKey;
55380 pCell = findCell(pPage, idx) + pPage->childPtrSize;
55381 if( pPage->hasData ){
55382 while( 0x80 <= *(pCell++) ){
@@ -60120,10 +60121,11 @@
60120 sqlite3DbFree(pMem->db, pMem->zMalloc);
60121 pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
60122 }
60123 if( pMem->zMalloc==0 ){
60124 VdbeMemRelease(pMem);
 
60125 pMem->flags = MEM_Null;
60126 return SQLITE_NOMEM;
60127 }
60128 }
60129
@@ -60318,11 +60320,11 @@
60318 }
60319
60320 /*
60321 ** Release any memory held by the Mem. This may leave the Mem in an
60322 ** inconsistent state, for example with (Mem.z==0) and
60323 ** (Mem.memType==MEM_Str).
60324 */
60325 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){
60326 assert( sqlite3VdbeCheckMemInvariants(p) );
60327 VdbeMemRelease(p);
60328 if( p->zMalloc ){
@@ -60510,11 +60512,10 @@
60510 }
60511 if( pMem->flags & MEM_RowSet ){
60512 sqlite3RowSetClear(pMem->u.pRowSet);
60513 }
60514 MemSetTypeFlag(pMem, MEM_Null);
60515 pMem->memType = MEM_Null;
60516 }
60517 SQLITE_PRIVATE void sqlite3ValueSetNull(sqlite3_value *p){
60518 sqlite3VdbeMemSetNull((Mem*)p);
60519 }
60520
@@ -60523,11 +60524,10 @@
60523 ** n containing all zeros.
60524 */
60525 SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){
60526 sqlite3VdbeMemRelease(pMem);
60527 pMem->flags = MEM_Blob|MEM_Zero;
60528 pMem->memType = MEM_Blob;
60529 pMem->n = 0;
60530 if( n<0 ) n = 0;
60531 pMem->u.nZero = n;
60532 pMem->enc = SQLITE_UTF8;
60533
@@ -60546,11 +60546,10 @@
60546 */
60547 SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
60548 sqlite3VdbeMemRelease(pMem);
60549 pMem->u.i = val;
60550 pMem->flags = MEM_Int;
60551 pMem->memType = MEM_Int;
60552 }
60553
60554 #ifndef SQLITE_OMIT_FLOATING_POINT
60555 /*
60556 ** Delete any previous value and set the value stored in *pMem to val,
@@ -60561,11 +60560,10 @@
60561 sqlite3VdbeMemSetNull(pMem);
60562 }else{
60563 sqlite3VdbeMemRelease(pMem);
60564 pMem->r = val;
60565 pMem->flags = MEM_Real;
60566 pMem->memType = MEM_Real;
60567 }
60568 }
60569 #endif
60570
60571 /*
@@ -60770,11 +60768,10 @@
60770 }
60771
60772 pMem->n = nByte;
60773 pMem->flags = flags;
60774 pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);
60775 pMem->memType = flags&0x1f;
60776
60777 #ifndef SQLITE_OMIT_UTF16
60778 if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){
60779 return SQLITE_NOMEM;
60780 }
@@ -60836,11 +60833,10 @@
60836 }
60837 if( rc==SQLITE_OK ){
60838 pMem->z[amt] = 0;
60839 pMem->z[amt+1] = 0;
60840 pMem->flags = MEM_Blob|MEM_Term;
60841 pMem->memType = MEM_Blob;
60842 pMem->n = (int)amt;
60843 }else{
60844 sqlite3VdbeMemRelease(pMem);
60845 }
60846 }
@@ -60899,11 +60895,10 @@
60899 */
60900 SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *db){
60901 Mem *p = sqlite3DbMallocZero(db, sizeof(*p));
60902 if( p ){
60903 p->flags = MEM_Null;
60904 p->memType = MEM_Null;
60905 p->db = db;
60906 }
60907 return p;
60908 }
60909
@@ -60948,11 +60943,10 @@
60948 assert( pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField==nCol );
60949 assert( pRec->pKeyInfo->enc==ENC(db) );
60950 pRec->aMem = (Mem *)((u8*)pRec + ROUND8(sizeof(UnpackedRecord)));
60951 for(i=0; i<nCol; i++){
60952 pRec->aMem[i].flags = MEM_Null;
60953 pRec->aMem[i].memType = MEM_Null;
60954 pRec->aMem[i].db = db;
60955 }
60956 }else{
60957 sqlite3DbFree(db, pRec);
60958 pRec = 0;
@@ -61021,11 +61015,10 @@
61021 sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);
61022 }else{
61023 zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
61024 if( zVal==0 ) goto no_mem;
61025 sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
61026 if( op==TK_FLOAT ) pVal->memType = MEM_Real;
61027 }
61028 if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){
61029 sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);
61030 }else{
61031 sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);
@@ -61039,13 +61032,13 @@
61039 if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal)
61040 && pVal!=0
61041 ){
61042 sqlite3VdbeMemNumerify(pVal);
61043 if( pVal->u.i==SMALLEST_INT64 ){
61044 pVal->flags &= MEM_Int;
61045 pVal->flags |= MEM_Real;
61046 pVal->r = (double)LARGEST_INT64;
61047 }else{
61048 pVal->u.i = -pVal->u.i;
61049 }
61050 pVal->r = -pVal->r;
61051 sqlite3ValueApplyAffinity(pVal, affinity, enc);
@@ -61067,13 +61060,10 @@
61067 sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
61068 0, SQLITE_DYNAMIC);
61069 }
61070 #endif
61071
61072 if( pVal ){
61073 sqlite3VdbeMemStoreType(pVal);
61074 }
61075 *ppVal = pVal;
61076 return rc;
61077
61078 no_mem:
61079 db->mallocFailed = 1;
@@ -61233,11 +61223,10 @@
61233 rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
61234 if( rc==SQLITE_OK ){
61235 sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
61236 }
61237 pVal->db = pParse->db;
61238 sqlite3VdbeMemStoreType((Mem*)pVal);
61239 }
61240 }
61241 }else{
61242 rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, &alloc);
61243 }
@@ -62668,19 +62657,17 @@
62668 }
62669 pOp = &apSub[j]->aOp[i];
62670 }
62671 if( p->explain==1 ){
62672 pMem->flags = MEM_Int;
62673 pMem->memType = MEM_Int;
62674 pMem->u.i = i; /* Program counter */
62675 pMem++;
62676
62677 pMem->flags = MEM_Static|MEM_Str|MEM_Term;
62678 pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
62679 assert( pMem->z!=0 );
62680 pMem->n = sqlite3Strlen30(pMem->z);
62681 pMem->memType = MEM_Str;
62682 pMem->enc = SQLITE_UTF8;
62683 pMem++;
62684
62685 /* When an OP_Program opcode is encounter (the only opcode that has
62686 ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms
@@ -62702,21 +62689,18 @@
62702 }
62703 }
62704
62705 pMem->flags = MEM_Int;
62706 pMem->u.i = pOp->p1; /* P1 */
62707 pMem->memType = MEM_Int;
62708 pMem++;
62709
62710 pMem->flags = MEM_Int;
62711 pMem->u.i = pOp->p2; /* P2 */
62712 pMem->memType = MEM_Int;
62713 pMem++;
62714
62715 pMem->flags = MEM_Int;
62716 pMem->u.i = pOp->p3; /* P3 */
62717 pMem->memType = MEM_Int;
62718 pMem++;
62719
62720 if( sqlite3VdbeMemGrow(pMem, 32, 0) ){ /* P4 */
62721 assert( p->db->mallocFailed );
62722 return SQLITE_ERROR;
@@ -62728,11 +62712,10 @@
62728 }else{
62729 assert( pMem->z!=0 );
62730 pMem->n = sqlite3Strlen30(pMem->z);
62731 pMem->enc = SQLITE_UTF8;
62732 }
62733 pMem->memType = MEM_Str;
62734 pMem++;
62735
62736 if( p->explain==1 ){
62737 if( sqlite3VdbeMemGrow(pMem, 4, 0) ){
62738 assert( p->db->mallocFailed );
@@ -62739,11 +62722,10 @@
62739 return SQLITE_ERROR;
62740 }
62741 pMem->flags = MEM_Str|MEM_Term;
62742 pMem->n = 2;
62743 sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */
62744 pMem->memType = MEM_Str;
62745 pMem->enc = SQLITE_UTF8;
62746 pMem++;
62747
62748 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
62749 if( sqlite3VdbeMemGrow(pMem, 500, 0) ){
@@ -62750,15 +62732,13 @@
62750 assert( p->db->mallocFailed );
62751 return SQLITE_ERROR;
62752 }
62753 pMem->flags = MEM_Str|MEM_Term;
62754 pMem->n = displayComment(pOp, zP4, pMem->z, 500);
62755 pMem->memType = MEM_Str;
62756 pMem->enc = SQLITE_UTF8;
62757 #else
62758 pMem->flags = MEM_Null; /* Comment */
62759 pMem->memType = MEM_Null;
62760 #endif
62761 }
62762
62763 p->nResColumn = 8 - 4*(p->explain-1);
62764 p->pResultSet = &p->aMem[1];
@@ -64844,13 +64824,14 @@
64844
64845 if( rc!=0 ){
64846 if( pKeyInfo->aSortOrder[i] ){
64847 rc = -rc;
64848 }
64849 assert( CORRUPT_DB
64850 || (rc<0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)<0)
64851 || (rc>0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)>0)
 
64852 );
64853 assert( mem1.zMalloc==0 ); /* See comment below */
64854 return rc;
64855 }
64856
@@ -65241,11 +65222,10 @@
65241 if( 0==(pMem->flags & MEM_Null) ){
65242 sqlite3_value *pRet = sqlite3ValueNew(v->db);
65243 if( pRet ){
65244 sqlite3VdbeMemCopy((Mem *)pRet, pMem);
65245 sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
65246 sqlite3VdbeMemStoreType((Mem *)pRet);
65247 }
65248 return pRet;
65249 }
65250 }
65251 return 0;
@@ -65415,11 +65395,10 @@
65415 */
65416 SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){
65417 Mem *p = (Mem*)pVal;
65418 if( p->flags & (MEM_Blob|MEM_Str) ){
65419 sqlite3VdbeMemExpandBlob(p);
65420 p->flags &= ~MEM_Str;
65421 p->flags |= MEM_Blob;
65422 return p->n ? p->z : 0;
65423 }else{
65424 return sqlite3_value_text(pVal);
65425 }
@@ -65486,11 +65465,11 @@
65486 SQLITE_INTEGER, /* 0x1c */
65487 SQLITE_NULL, /* 0x1d */
65488 SQLITE_INTEGER, /* 0x1e */
65489 SQLITE_NULL, /* 0x1f */
65490 };
65491 return aType[pVal->memType&0x1f];
65492 }
65493
65494 /**************************** sqlite3_result_ *******************************
65495 ** The following routines are used by user-defined functions to specify
65496 ** the function result.
@@ -66007,10 +65986,34 @@
66007 Vdbe *pVm = (Vdbe *)pStmt;
66008 if( pVm==0 || pVm->pResultSet==0 ) return 0;
66009 return pVm->nResColumn;
66010 }
66011
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66012
66013 /*
66014 ** Check to see if column iCol of the given statement is valid. If
66015 ** it is, return a pointer to the Mem for the value of that column.
66016 ** If iCol is not valid, return a pointer to a Mem which has a value
@@ -66023,36 +66026,15 @@
66023 pVm = (Vdbe *)pStmt;
66024 if( pVm && pVm->pResultSet!=0 && i<pVm->nResColumn && i>=0 ){
66025 sqlite3_mutex_enter(pVm->db->mutex);
66026 pOut = &pVm->pResultSet[i];
66027 }else{
66028 /* If the value passed as the second argument is out of range, return
66029 ** a pointer to the following static Mem object which contains the
66030 ** value SQL NULL. Even though the Mem structure contains an element
66031 ** of type i64, on certain architectures (x86) with certain compiler
66032 ** switches (-Os), gcc may align this Mem object on a 4-byte boundary
66033 ** instead of an 8-byte one. This all works fine, except that when
66034 ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s
66035 ** that a Mem structure is located on an 8-byte boundary. To prevent
66036 ** these assert()s from failing, when building with SQLITE_DEBUG defined
66037 ** using gcc, we force nullMem to be 8-byte aligned using the magical
66038 ** __attribute__((aligned(8))) macro. */
66039 static const Mem nullMem
66040 #if defined(SQLITE_DEBUG) && defined(__GNUC__)
66041 __attribute__((aligned(8)))
66042 #endif
66043 = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0,
66044 #ifdef SQLITE_DEBUG
66045 0, 0, /* pScopyFrom, pFiller */
66046 #endif
66047 0, 0 };
66048
66049 if( pVm && ALWAYS(pVm->db) ){
66050 sqlite3_mutex_enter(pVm->db->mutex);
66051 sqlite3Error(pVm->db, SQLITE_RANGE, 0);
66052 }
66053 pOut = (Mem*)&nullMem;
66054 }
66055 return pOut;
66056 }
66057
66058 /*
@@ -67228,11 +67210,10 @@
67228 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
67229 int eType = sqlite3_value_type(pVal);
67230 if( eType==SQLITE_TEXT ){
67231 Mem *pMem = (Mem*)pVal;
67232 applyNumericAffinity(pMem);
67233 sqlite3VdbeMemStoreType(pMem);
67234 eType = sqlite3_value_type(pVal);
67235 }
67236 return eType;
67237 }
67238
@@ -68267,11 +68248,10 @@
68267 assert( memIsValid(&pMem[i]) );
68268 Deephemeralize(&pMem[i]);
68269 assert( (pMem[i].flags & MEM_Ephem)==0
68270 || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
68271 sqlite3VdbeMemNulTerminate(&pMem[i]);
68272 sqlite3VdbeMemStoreType(&pMem[i]);
68273 REGISTER_TRACE(pOp->p1+i, &pMem[i]);
68274 }
68275 if( db->mallocFailed ) goto no_mem;
68276
68277 /* Return SQLITE_ROW
@@ -68513,11 +68493,10 @@
68513 pArg = &aMem[pOp->p2];
68514 for(i=0; i<n; i++, pArg++){
68515 assert( memIsValid(pArg) );
68516 apVal[i] = pArg;
68517 Deephemeralize(pArg);
68518 sqlite3VdbeMemStoreType(pArg);
68519 REGISTER_TRACE(pOp->p2+i, pArg);
68520 }
68521
68522 assert( pOp->p4type==P4_FUNCDEF );
68523 ctx.pFunc = pOp->p4.pFunc;
@@ -72518,11 +72497,10 @@
72518 assert( apVal || n==0 );
72519 for(i=0; i<n; i++, pRec++){
72520 assert( memIsValid(pRec) );
72521 apVal[i] = pRec;
72522 memAboutToChange(p, pRec);
72523 sqlite3VdbeMemStoreType(pRec);
72524 }
72525 ctx.pFunc = pOp->p4.pFunc;
72526 assert( pOp->p3>0 && pOp->p3<=(p->nMem-p->nCursor) );
72527 ctx.pMem = pMem = &aMem[pOp->p3];
72528 pMem->n++;
@@ -72952,11 +72930,10 @@
72952 {
72953 res = 0;
72954 apArg = p->apArg;
72955 for(i = 0; i<nArg; i++){
72956 apArg[i] = &pArgc[i+1];
72957 sqlite3VdbeMemStoreType(apArg[i]);
72958 }
72959
72960 p->inVtabMethod = 1;
72961 rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
72962 p->inVtabMethod = 0;
@@ -73159,11 +73136,10 @@
73159 apArg = p->apArg;
73160 pX = &aMem[pOp->p3];
73161 for(i=0; i<nArg; i++){
73162 assert( memIsValid(pX) );
73163 memAboutToChange(p, pX);
73164 sqlite3VdbeMemStoreType(pX);
73165 apArg[i] = pX;
73166 pX++;
73167 }
73168 db->vtabOnConflict = pOp->p5;
73169 rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);
@@ -88183,11 +88159,11 @@
88183 assert( nExtra>=1 );
88184 assert( pSrc!=0 );
88185 assert( iStart<=pSrc->nSrc );
88186
88187 /* Allocate additional space if needed */
88188 if( pSrc->nSrc+nExtra>pSrc->nAlloc ){
88189 SrcList *pNew;
88190 int nAlloc = pSrc->nSrc+nExtra;
88191 int nGot;
88192 pNew = sqlite3DbRealloc(db, pSrc,
88193 sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );
@@ -88195,19 +88171,19 @@
88195 assert( db->mallocFailed );
88196 return pSrc;
88197 }
88198 pSrc = pNew;
88199 nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1;
88200 pSrc->nAlloc = (u8)nGot;
88201 }
88202
88203 /* Move existing slots that come after the newly inserted slots
88204 ** out of the way */
88205 for(i=pSrc->nSrc-1; i>=iStart; i--){
88206 pSrc->a[i+nExtra] = pSrc->a[i];
88207 }
88208 pSrc->nSrc += (i8)nExtra;
88209
88210 /* Zero the newly allocated slots */
88211 memset(&pSrc->a[iStart], 0, sizeof(pSrc->a[0])*nExtra);
88212 for(i=iStart; i<iStart+nExtra; i++){
88213 pSrc->a[i].iCursor = -1;
@@ -101494,11 +101470,11 @@
101494 for(j=cnt=0; j<i; j++){
101495 if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){
101496 char *zNewName;
101497 int k;
101498 for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){}
101499 if( zName[k]==':' ) nName = k;
101500 zName[nName] = 0;
101501 zNewName = sqlite3MPrintf(db, "%s:%d", zName, ++cnt);
101502 sqlite3DbFree(db, zName);
101503 zName = zNewName;
101504 j = -1;
101505
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -189,11 +189,11 @@
189 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
190 ** [sqlite_version()] and [sqlite_source_id()].
191 */
192 #define SQLITE_VERSION "3.8.4"
193 #define SQLITE_VERSION_NUMBER 3008004
194 #define SQLITE_SOURCE_ID "2014-03-05 19:04:46 0723effc9ccae7c660fb847b36ce9324e0cb5042"
195
196 /*
197 ** CAPI3REF: Run-Time Library Version Numbers
198 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
199 **
@@ -11385,12 +11385,12 @@
11385 **
11386 ** In the colUsed field, the high-order bit (bit 63) is set if the table
11387 ** contains more than 63 columns and the 64-th or later column is used.
11388 */
11389 struct SrcList {
11390 int nSrc; /* Number of tables or subqueries in the FROM clause */
11391 u32 nAlloc; /* Number of entries allocated in a[] below */
11392 struct SrcList_item {
11393 Schema *pSchema; /* Schema to which this item is fixed */
11394 char *zDatabase; /* Name of database holding this table */
11395 char *zName; /* Name of the table */
11396 char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */
@@ -13418,10 +13418,13 @@
13418 #ifdef SQLITE_OMIT_COMPLETE
13419 "OMIT_COMPLETE",
13420 #endif
13421 #ifdef SQLITE_OMIT_COMPOUND_SELECT
13422 "OMIT_COMPOUND_SELECT",
13423 #endif
13424 #ifdef SQLITE_OMIT_CTE
13425 "OMIT_CTE",
13426 #endif
13427 #ifdef SQLITE_OMIT_DATETIME_FUNCS
13428 "OMIT_DATETIME_FUNCS",
13429 #endif
13430 #ifdef SQLITE_OMIT_DECLTYPE
@@ -13803,11 +13806,10 @@
13806 RowSet *pRowSet; /* Used only when flags==MEM_RowSet */
13807 VdbeFrame *pFrame; /* Used when flags==MEM_Frame */
13808 } u;
13809 int n; /* Number of characters in string value, excluding '\0' */
13810 u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
 
13811 u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
13812 #ifdef SQLITE_DEBUG
13813 Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
13814 void *pFiller; /* So that sizeof(Mem) is a multiple of 8 */
13815 #endif
@@ -13830,10 +13832,11 @@
13832 #define MEM_Null 0x0001 /* Value is NULL */
13833 #define MEM_Str 0x0002 /* Value is a string */
13834 #define MEM_Int 0x0004 /* Value is an integer */
13835 #define MEM_Real 0x0008 /* Value is a real number */
13836 #define MEM_Blob 0x0010 /* Value is a BLOB */
13837 #define MEM_AffMask 0x001f /* Mask of affinity bits */
13838 #define MEM_RowSet 0x0020 /* Value is a RowSet object */
13839 #define MEM_Frame 0x0040 /* Value is a VdbeFrame object */
13840 #define MEM_Undefined 0x0080 /* Value is undefined */
13841 #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
13842 #define MEM_TypeMask 0x01ff /* Mask of type bits */
@@ -14069,12 +14072,10 @@
14072 SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
14073 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
14074 SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
14075 SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
14076 SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
 
 
14077 SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
14078
14079 SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *);
14080 SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
14081 SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
@@ -55372,11 +55373,11 @@
55373 lwr = 0;
55374 upr = pPage->nCell-1;
55375 assert( biasRight==0 || biasRight==1 );
55376 idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
55377 pCur->aiIdx[pCur->iPage] = (u16)idx;
55378 if( xRecordCompare==0 ){
55379 for(;;){
55380 i64 nCellKey;
55381 pCell = findCell(pPage, idx) + pPage->childPtrSize;
55382 if( pPage->hasData ){
55383 while( 0x80 <= *(pCell++) ){
@@ -60120,10 +60121,11 @@
60121 sqlite3DbFree(pMem->db, pMem->zMalloc);
60122 pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
60123 }
60124 if( pMem->zMalloc==0 ){
60125 VdbeMemRelease(pMem);
60126 pMem->z = 0;
60127 pMem->flags = MEM_Null;
60128 return SQLITE_NOMEM;
60129 }
60130 }
60131
@@ -60318,11 +60320,11 @@
60320 }
60321
60322 /*
60323 ** Release any memory held by the Mem. This may leave the Mem in an
60324 ** inconsistent state, for example with (Mem.z==0) and
60325 ** (Mem.flags==MEM_Str).
60326 */
60327 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){
60328 assert( sqlite3VdbeCheckMemInvariants(p) );
60329 VdbeMemRelease(p);
60330 if( p->zMalloc ){
@@ -60510,11 +60512,10 @@
60512 }
60513 if( pMem->flags & MEM_RowSet ){
60514 sqlite3RowSetClear(pMem->u.pRowSet);
60515 }
60516 MemSetTypeFlag(pMem, MEM_Null);
 
60517 }
60518 SQLITE_PRIVATE void sqlite3ValueSetNull(sqlite3_value *p){
60519 sqlite3VdbeMemSetNull((Mem*)p);
60520 }
60521
@@ -60523,11 +60524,10 @@
60524 ** n containing all zeros.
60525 */
60526 SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){
60527 sqlite3VdbeMemRelease(pMem);
60528 pMem->flags = MEM_Blob|MEM_Zero;
 
60529 pMem->n = 0;
60530 if( n<0 ) n = 0;
60531 pMem->u.nZero = n;
60532 pMem->enc = SQLITE_UTF8;
60533
@@ -60546,11 +60546,10 @@
60546 */
60547 SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
60548 sqlite3VdbeMemRelease(pMem);
60549 pMem->u.i = val;
60550 pMem->flags = MEM_Int;
 
60551 }
60552
60553 #ifndef SQLITE_OMIT_FLOATING_POINT
60554 /*
60555 ** Delete any previous value and set the value stored in *pMem to val,
@@ -60561,11 +60560,10 @@
60560 sqlite3VdbeMemSetNull(pMem);
60561 }else{
60562 sqlite3VdbeMemRelease(pMem);
60563 pMem->r = val;
60564 pMem->flags = MEM_Real;
 
60565 }
60566 }
60567 #endif
60568
60569 /*
@@ -60770,11 +60768,10 @@
60768 }
60769
60770 pMem->n = nByte;
60771 pMem->flags = flags;
60772 pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);
 
60773
60774 #ifndef SQLITE_OMIT_UTF16
60775 if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){
60776 return SQLITE_NOMEM;
60777 }
@@ -60836,11 +60833,10 @@
60833 }
60834 if( rc==SQLITE_OK ){
60835 pMem->z[amt] = 0;
60836 pMem->z[amt+1] = 0;
60837 pMem->flags = MEM_Blob|MEM_Term;
 
60838 pMem->n = (int)amt;
60839 }else{
60840 sqlite3VdbeMemRelease(pMem);
60841 }
60842 }
@@ -60899,11 +60895,10 @@
60895 */
60896 SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *db){
60897 Mem *p = sqlite3DbMallocZero(db, sizeof(*p));
60898 if( p ){
60899 p->flags = MEM_Null;
 
60900 p->db = db;
60901 }
60902 return p;
60903 }
60904
@@ -60948,11 +60943,10 @@
60943 assert( pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField==nCol );
60944 assert( pRec->pKeyInfo->enc==ENC(db) );
60945 pRec->aMem = (Mem *)((u8*)pRec + ROUND8(sizeof(UnpackedRecord)));
60946 for(i=0; i<nCol; i++){
60947 pRec->aMem[i].flags = MEM_Null;
 
60948 pRec->aMem[i].db = db;
60949 }
60950 }else{
60951 sqlite3DbFree(db, pRec);
60952 pRec = 0;
@@ -61021,11 +61015,10 @@
61015 sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);
61016 }else{
61017 zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
61018 if( zVal==0 ) goto no_mem;
61019 sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
 
61020 }
61021 if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){
61022 sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);
61023 }else{
61024 sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);
@@ -61039,13 +61032,13 @@
61032 if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal)
61033 && pVal!=0
61034 ){
61035 sqlite3VdbeMemNumerify(pVal);
61036 if( pVal->u.i==SMALLEST_INT64 ){
61037 pVal->flags &= ~MEM_Int;
61038 pVal->flags |= MEM_Real;
61039 pVal->r = (double)SMALLEST_INT64;
61040 }else{
61041 pVal->u.i = -pVal->u.i;
61042 }
61043 pVal->r = -pVal->r;
61044 sqlite3ValueApplyAffinity(pVal, affinity, enc);
@@ -61067,13 +61060,10 @@
61060 sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
61061 0, SQLITE_DYNAMIC);
61062 }
61063 #endif
61064
 
 
 
61065 *ppVal = pVal;
61066 return rc;
61067
61068 no_mem:
61069 db->mallocFailed = 1;
@@ -61233,11 +61223,10 @@
61223 rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
61224 if( rc==SQLITE_OK ){
61225 sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
61226 }
61227 pVal->db = pParse->db;
 
61228 }
61229 }
61230 }else{
61231 rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, &alloc);
61232 }
@@ -62668,19 +62657,17 @@
62657 }
62658 pOp = &apSub[j]->aOp[i];
62659 }
62660 if( p->explain==1 ){
62661 pMem->flags = MEM_Int;
 
62662 pMem->u.i = i; /* Program counter */
62663 pMem++;
62664
62665 pMem->flags = MEM_Static|MEM_Str|MEM_Term;
62666 pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
62667 assert( pMem->z!=0 );
62668 pMem->n = sqlite3Strlen30(pMem->z);
 
62669 pMem->enc = SQLITE_UTF8;
62670 pMem++;
62671
62672 /* When an OP_Program opcode is encounter (the only opcode that has
62673 ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms
@@ -62702,21 +62689,18 @@
62689 }
62690 }
62691
62692 pMem->flags = MEM_Int;
62693 pMem->u.i = pOp->p1; /* P1 */
 
62694 pMem++;
62695
62696 pMem->flags = MEM_Int;
62697 pMem->u.i = pOp->p2; /* P2 */
 
62698 pMem++;
62699
62700 pMem->flags = MEM_Int;
62701 pMem->u.i = pOp->p3; /* P3 */
 
62702 pMem++;
62703
62704 if( sqlite3VdbeMemGrow(pMem, 32, 0) ){ /* P4 */
62705 assert( p->db->mallocFailed );
62706 return SQLITE_ERROR;
@@ -62728,11 +62712,10 @@
62712 }else{
62713 assert( pMem->z!=0 );
62714 pMem->n = sqlite3Strlen30(pMem->z);
62715 pMem->enc = SQLITE_UTF8;
62716 }
 
62717 pMem++;
62718
62719 if( p->explain==1 ){
62720 if( sqlite3VdbeMemGrow(pMem, 4, 0) ){
62721 assert( p->db->mallocFailed );
@@ -62739,11 +62722,10 @@
62722 return SQLITE_ERROR;
62723 }
62724 pMem->flags = MEM_Str|MEM_Term;
62725 pMem->n = 2;
62726 sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */
 
62727 pMem->enc = SQLITE_UTF8;
62728 pMem++;
62729
62730 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
62731 if( sqlite3VdbeMemGrow(pMem, 500, 0) ){
@@ -62750,15 +62732,13 @@
62732 assert( p->db->mallocFailed );
62733 return SQLITE_ERROR;
62734 }
62735 pMem->flags = MEM_Str|MEM_Term;
62736 pMem->n = displayComment(pOp, zP4, pMem->z, 500);
 
62737 pMem->enc = SQLITE_UTF8;
62738 #else
62739 pMem->flags = MEM_Null; /* Comment */
 
62740 #endif
62741 }
62742
62743 p->nResColumn = 8 - 4*(p->explain-1);
62744 p->pResultSet = &p->aMem[1];
@@ -64844,13 +64824,14 @@
64824
64825 if( rc!=0 ){
64826 if( pKeyInfo->aSortOrder[i] ){
64827 rc = -rc;
64828 }
64829 assert( CORRUPT_DB
64830 || (rc<0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)<0)
64831 || (rc>0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)>0)
64832 || pKeyInfo->db->mallocFailed
64833 );
64834 assert( mem1.zMalloc==0 ); /* See comment below */
64835 return rc;
64836 }
64837
@@ -65241,11 +65222,10 @@
65222 if( 0==(pMem->flags & MEM_Null) ){
65223 sqlite3_value *pRet = sqlite3ValueNew(v->db);
65224 if( pRet ){
65225 sqlite3VdbeMemCopy((Mem *)pRet, pMem);
65226 sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
 
65227 }
65228 return pRet;
65229 }
65230 }
65231 return 0;
@@ -65415,11 +65395,10 @@
65395 */
65396 SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){
65397 Mem *p = (Mem*)pVal;
65398 if( p->flags & (MEM_Blob|MEM_Str) ){
65399 sqlite3VdbeMemExpandBlob(p);
 
65400 p->flags |= MEM_Blob;
65401 return p->n ? p->z : 0;
65402 }else{
65403 return sqlite3_value_text(pVal);
65404 }
@@ -65486,11 +65465,11 @@
65465 SQLITE_INTEGER, /* 0x1c */
65466 SQLITE_NULL, /* 0x1d */
65467 SQLITE_INTEGER, /* 0x1e */
65468 SQLITE_NULL, /* 0x1f */
65469 };
65470 return aType[pVal->flags&MEM_AffMask];
65471 }
65472
65473 /**************************** sqlite3_result_ *******************************
65474 ** The following routines are used by user-defined functions to specify
65475 ** the function result.
@@ -66007,10 +65986,34 @@
65986 Vdbe *pVm = (Vdbe *)pStmt;
65987 if( pVm==0 || pVm->pResultSet==0 ) return 0;
65988 return pVm->nResColumn;
65989 }
65990
65991 /*
65992 ** Return a pointer to static memory containing an SQL NULL value.
65993 */
65994 static const Mem *columnNullValue(void){
65995 /* Even though the Mem structure contains an element
65996 ** of type i64, on certain architectures (x86) with certain compiler
65997 ** switches (-Os), gcc may align this Mem object on a 4-byte boundary
65998 ** instead of an 8-byte one. This all works fine, except that when
65999 ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s
66000 ** that a Mem structure is located on an 8-byte boundary. To prevent
66001 ** these assert()s from failing, when building with SQLITE_DEBUG defined
66002 ** using gcc, we force nullMem to be 8-byte aligned using the magical
66003 ** __attribute__((aligned(8))) macro. */
66004 static const Mem nullMem
66005 #if defined(SQLITE_DEBUG) && defined(__GNUC__)
66006 __attribute__((aligned(8)))
66007 #endif
66008 = {0, "", (double)0, {0}, 0, MEM_Null, 0,
66009 #ifdef SQLITE_DEBUG
66010 0, 0, /* pScopyFrom, pFiller */
66011 #endif
66012 0, 0 };
66013 return &nullMem;
66014 }
66015
66016 /*
66017 ** Check to see if column iCol of the given statement is valid. If
66018 ** it is, return a pointer to the Mem for the value of that column.
66019 ** If iCol is not valid, return a pointer to a Mem which has a value
@@ -66023,36 +66026,15 @@
66026 pVm = (Vdbe *)pStmt;
66027 if( pVm && pVm->pResultSet!=0 && i<pVm->nResColumn && i>=0 ){
66028 sqlite3_mutex_enter(pVm->db->mutex);
66029 pOut = &pVm->pResultSet[i];
66030 }else{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66031 if( pVm && ALWAYS(pVm->db) ){
66032 sqlite3_mutex_enter(pVm->db->mutex);
66033 sqlite3Error(pVm->db, SQLITE_RANGE, 0);
66034 }
66035 pOut = (Mem*)columnNullValue();
66036 }
66037 return pOut;
66038 }
66039
66040 /*
@@ -67228,11 +67210,10 @@
67210 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
67211 int eType = sqlite3_value_type(pVal);
67212 if( eType==SQLITE_TEXT ){
67213 Mem *pMem = (Mem*)pVal;
67214 applyNumericAffinity(pMem);
 
67215 eType = sqlite3_value_type(pVal);
67216 }
67217 return eType;
67218 }
67219
@@ -68267,11 +68248,10 @@
68248 assert( memIsValid(&pMem[i]) );
68249 Deephemeralize(&pMem[i]);
68250 assert( (pMem[i].flags & MEM_Ephem)==0
68251 || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );
68252 sqlite3VdbeMemNulTerminate(&pMem[i]);
 
68253 REGISTER_TRACE(pOp->p1+i, &pMem[i]);
68254 }
68255 if( db->mallocFailed ) goto no_mem;
68256
68257 /* Return SQLITE_ROW
@@ -68513,11 +68493,10 @@
68493 pArg = &aMem[pOp->p2];
68494 for(i=0; i<n; i++, pArg++){
68495 assert( memIsValid(pArg) );
68496 apVal[i] = pArg;
68497 Deephemeralize(pArg);
 
68498 REGISTER_TRACE(pOp->p2+i, pArg);
68499 }
68500
68501 assert( pOp->p4type==P4_FUNCDEF );
68502 ctx.pFunc = pOp->p4.pFunc;
@@ -72518,11 +72497,10 @@
72497 assert( apVal || n==0 );
72498 for(i=0; i<n; i++, pRec++){
72499 assert( memIsValid(pRec) );
72500 apVal[i] = pRec;
72501 memAboutToChange(p, pRec);
 
72502 }
72503 ctx.pFunc = pOp->p4.pFunc;
72504 assert( pOp->p3>0 && pOp->p3<=(p->nMem-p->nCursor) );
72505 ctx.pMem = pMem = &aMem[pOp->p3];
72506 pMem->n++;
@@ -72952,11 +72930,10 @@
72930 {
72931 res = 0;
72932 apArg = p->apArg;
72933 for(i = 0; i<nArg; i++){
72934 apArg[i] = &pArgc[i+1];
 
72935 }
72936
72937 p->inVtabMethod = 1;
72938 rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
72939 p->inVtabMethod = 0;
@@ -73159,11 +73136,10 @@
73136 apArg = p->apArg;
73137 pX = &aMem[pOp->p3];
73138 for(i=0; i<nArg; i++){
73139 assert( memIsValid(pX) );
73140 memAboutToChange(p, pX);
 
73141 apArg[i] = pX;
73142 pX++;
73143 }
73144 db->vtabOnConflict = pOp->p5;
73145 rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);
@@ -88183,11 +88159,11 @@
88159 assert( nExtra>=1 );
88160 assert( pSrc!=0 );
88161 assert( iStart<=pSrc->nSrc );
88162
88163 /* Allocate additional space if needed */
88164 if( (u32)pSrc->nSrc+nExtra>pSrc->nAlloc ){
88165 SrcList *pNew;
88166 int nAlloc = pSrc->nSrc+nExtra;
88167 int nGot;
88168 pNew = sqlite3DbRealloc(db, pSrc,
88169 sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );
@@ -88195,19 +88171,19 @@
88171 assert( db->mallocFailed );
88172 return pSrc;
88173 }
88174 pSrc = pNew;
88175 nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1;
88176 pSrc->nAlloc = nGot;
88177 }
88178
88179 /* Move existing slots that come after the newly inserted slots
88180 ** out of the way */
88181 for(i=pSrc->nSrc-1; i>=iStart; i--){
88182 pSrc->a[i+nExtra] = pSrc->a[i];
88183 }
88184 pSrc->nSrc += nExtra;
88185
88186 /* Zero the newly allocated slots */
88187 memset(&pSrc->a[iStart], 0, sizeof(pSrc->a[0])*nExtra);
88188 for(i=iStart; i<iStart+nExtra; i++){
88189 pSrc->a[i].iCursor = -1;
@@ -101494,11 +101470,11 @@
101470 for(j=cnt=0; j<i; j++){
101471 if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){
101472 char *zNewName;
101473 int k;
101474 for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){}
101475 if( k>=0 && zName[k]==':' ) nName = k;
101476 zName[nName] = 0;
101477 zNewName = sqlite3MPrintf(db, "%s:%d", zName, ++cnt);
101478 sqlite3DbFree(db, zName);
101479 zName = zNewName;
101480 j = -1;
101481
+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.4"
111111
#define SQLITE_VERSION_NUMBER 3008004
112
-#define SQLITE_SOURCE_ID "2014-03-04 13:18:23 9830c343bc954b828f6ca752f8ae63e2c0a980c1"
112
+#define SQLITE_SOURCE_ID "2014-03-05 19:04:46 0723effc9ccae7c660fb847b36ce9324e0cb5042"
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.4"
111 #define SQLITE_VERSION_NUMBER 3008004
112 #define SQLITE_SOURCE_ID "2014-03-04 13:18:23 9830c343bc954b828f6ca752f8ae63e2c0a980c1"
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.4"
111 #define SQLITE_VERSION_NUMBER 3008004
112 #define SQLITE_SOURCE_ID "2014-03-05 19:04:46 0723effc9ccae7c660fb847b36ce9324e0cb5042"
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