Fossil SCM

Add extra quoted to system() calls on windows. Ticket [8d073be8808b]. Also update to the latest SQLite.

drh 2009-09-10 23:00 trunk
Commit aeaee1f38512181e15be7520ab7d629eb63d2422
+21 -2
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -171,11 +171,12 @@
171171
}
172172
if( zExternalCommand==0 ){
173173
internalDiff=1;
174174
}
175175
blob_zero(&cmd);
176
- blob_appendf(&cmd, "%s ", zExternalCommand);
176
+ shell_escape(&cmd, zExternalCommand);
177
+ blob_append(&cmd, " ", 1);
177178
}
178179
zFile = g.argv[g.argc-1];
179180
file_tree_name(zFile, &fname, 1);
180181
181182
blob_zero(&vname);
@@ -208,12 +209,30 @@
208209
blob_write_to_file(&record, blob_str(&vname));
209210
blob_reset(&record);
210211
shell_escape(&cmd, blob_str(&vname));
211212
blob_appendf(&cmd, " ");
212213
shell_escape(&cmd, zFile);
213
- system(blob_str(&cmd));
214
+ portable_system(blob_str(&cmd));
214215
unlink(blob_str(&vname));
215216
blob_reset(&vname);
216217
blob_reset(&cmd);
217218
}
218219
blob_reset(&fname);
219220
}
221
+
222
+/*
223
+** This function implements a cross-platform "system()" interface.
224
+*/
225
+void portable_system(char *zOrigCmd){
226
+#ifdef __MINGW32__
227
+ /* On windows, we have to put double-quotes around the entire command.
228
+ ** Who knows why - this is just the way windows works.
229
+ */
230
+ char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
231
+ system(zNewCmd);
232
+ free(zNewCmd);
233
+#else
234
+ /* On unix, evaluate the command directly.
235
+ */
236
+ system(zOrigCmd);
237
+#endif
238
+}
220239
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -171,11 +171,12 @@
171 }
172 if( zExternalCommand==0 ){
173 internalDiff=1;
174 }
175 blob_zero(&cmd);
176 blob_appendf(&cmd, "%s ", zExternalCommand);
 
177 }
178 zFile = g.argv[g.argc-1];
179 file_tree_name(zFile, &fname, 1);
180
181 blob_zero(&vname);
@@ -208,12 +209,30 @@
208 blob_write_to_file(&record, blob_str(&vname));
209 blob_reset(&record);
210 shell_escape(&cmd, blob_str(&vname));
211 blob_appendf(&cmd, " ");
212 shell_escape(&cmd, zFile);
213 system(blob_str(&cmd));
214 unlink(blob_str(&vname));
215 blob_reset(&vname);
216 blob_reset(&cmd);
217 }
218 blob_reset(&fname);
219 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -171,11 +171,12 @@
171 }
172 if( zExternalCommand==0 ){
173 internalDiff=1;
174 }
175 blob_zero(&cmd);
176 shell_escape(&cmd, zExternalCommand);
177 blob_append(&cmd, " ", 1);
178 }
179 zFile = g.argv[g.argc-1];
180 file_tree_name(zFile, &fname, 1);
181
182 blob_zero(&vname);
@@ -208,12 +209,30 @@
209 blob_write_to_file(&record, blob_str(&vname));
210 blob_reset(&record);
211 shell_escape(&cmd, blob_str(&vname));
212 blob_appendf(&cmd, " ");
213 shell_escape(&cmd, zFile);
214 portable_system(blob_str(&cmd));
215 unlink(blob_str(&vname));
216 blob_reset(&vname);
217 blob_reset(&cmd);
218 }
219 blob_reset(&fname);
220 }
221
222 /*
223 ** This function implements a cross-platform "system()" interface.
224 */
225 void portable_system(char *zOrigCmd){
226 #ifdef __MINGW32__
227 /* On windows, we have to put double-quotes around the entire command.
228 ** Who knows why - this is just the way windows works.
229 */
230 char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
231 system(zNewCmd);
232 free(zNewCmd);
233 #else
234 /* On unix, evaluate the command directly.
235 */
236 system(zOrigCmd);
237 #endif
238 }
239
--- src/http_transport.c
+++ src/http_transport.c
@@ -162,15 +162,11 @@
162162
char *zCmd;
163163
fclose(transport.pFile);
164164
zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1",
165165
g.argv[0], g.urlName, transport.zOutFile, transport.zInFile
166166
);
167
-#ifdef __MINGW32__
168
- /* Quote the entire command to work around goofiness in system() on
169
- ** on windows. Ticket [40df1ced7e] */
170
- zCmd = mprintf("\"%z\"", zCmd);
171
-#endif
167
+ portable_system(zCmd);
172168
system(zCmd);
173169
free(zCmd);
174170
transport.pFile = fopen(transport.zInFile, "rb");
175171
}
176172
}
177173
--- src/http_transport.c
+++ src/http_transport.c
@@ -162,15 +162,11 @@
162 char *zCmd;
163 fclose(transport.pFile);
164 zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1",
165 g.argv[0], g.urlName, transport.zOutFile, transport.zInFile
166 );
167 #ifdef __MINGW32__
168 /* Quote the entire command to work around goofiness in system() on
169 ** on windows. Ticket [40df1ced7e] */
170 zCmd = mprintf("\"%z\"", zCmd);
171 #endif
172 system(zCmd);
173 free(zCmd);
174 transport.pFile = fopen(transport.zInFile, "rb");
175 }
176 }
177
--- src/http_transport.c
+++ src/http_transport.c
@@ -162,15 +162,11 @@
162 char *zCmd;
163 fclose(transport.pFile);
164 zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1",
165 g.argv[0], g.urlName, transport.zOutFile, transport.zInFile
166 );
167 portable_system(zCmd);
 
 
 
 
168 system(zCmd);
169 free(zCmd);
170 transport.pFile = fopen(transport.zInFile, "rb");
171 }
172 }
173
+96 -37
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -15,11 +15,11 @@
1515
** of the embedded sqlite3.h header file.) Additional code files may be needed
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
20
-** This amalgamation was generated on 2009-09-09 16:11:06 UTC.
20
+** This amalgamation was generated on 2009-09-10 22:23:14 UTC.
2121
*/
2222
#define SQLITE_CORE 1
2323
#define SQLITE_AMALGAMATION 1
2424
#ifndef SQLITE_PRIVATE
2525
# define SQLITE_PRIVATE static
@@ -275,11 +275,15 @@
275275
276276
/*
277277
** Maximum depth of recursion for triggers.
278278
*/
279279
#ifndef SQLITE_MAX_TRIGGER_DEPTH
280
+#if defined(SQLITE_SMALL_STACK)
281
+# define SQLITE_MAX_TRIGGER_DEPTH 10
282
+#else
280283
# define SQLITE_MAX_TRIGGER_DEPTH 1000
284
+#endif
281285
#endif
282286
283287
/************** End of sqliteLimit.h *****************************************/
284288
/************** Continuing where we left off in sqliteInt.h ******************/
285289
@@ -643,11 +647,11 @@
643647
**
644648
** Requirements: [H10011] [H10014]
645649
*/
646650
#define SQLITE_VERSION "3.6.18"
647651
#define SQLITE_VERSION_NUMBER 3006018
648
-#define SQLITE_SOURCE_ID "2009-09-09 16:10:51 f0c72a53c5d57d7487b48a06a40816153f47aaac"
652
+#define SQLITE_SOURCE_ID "2009-09-10 20:23:30 f42ec993ac9d42ca31305f26b09924108c36d9f4"
649653
650654
/*
651655
** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
652656
** KEYWORDS: sqlite3_version
653657
**
@@ -7506,11 +7510,11 @@
75067510
SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int,int,int);
75077511
SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
75087512
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
75097513
SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
75107514
#ifdef SQLITE_DEBUG
7511
-SQLITE_PRIVATE int sqlite3VdbeMayAbort(Vdbe*);
7515
+SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *, int);
75127516
SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe*,FILE*);
75137517
#endif
75147518
SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);
75157519
SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
75167520
SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
@@ -11373,11 +11377,11 @@
1137311377
x.s = s;
1137411378
}
1137511379
x.tz = 0;
1137611380
x.validJD = 0;
1137711381
computeJD(&x);
11378
- t = x.iJD/1000 - 21086676*(i64)10000;
11382
+ t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
1137911383
#ifdef HAVE_LOCALTIME_R
1138011384
{
1138111385
struct tm sLocal;
1138211386
localtime_r(&t, &sLocal);
1138311387
y.Y = sLocal.tm_year + 1900;
@@ -14368,10 +14372,20 @@
1436814372
** This file contains code that is common across all mutex implementations.
1436914373
1437014374
**
1437114375
** $Id: mutex.c,v 1.31 2009/07/16 18:21:18 drh Exp $
1437214376
*/
14377
+
14378
+#if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT)
14379
+/*
14380
+** For debugging purposes, record when the mutex subsystem is initialized
14381
+** and uninitialized so that we can assert() if there is an attempt to
14382
+** allocate a mutex while the system is uninitialized.
14383
+*/
14384
+static SQLITE_WSD int mutexIsInit = 0;
14385
+#endif /* SQLITE_DEBUG */
14386
+
1437314387
1437414388
#ifndef SQLITE_MUTEX_OMIT
1437514389
/*
1437614390
** Initialize the mutex system.
1437714391
*/
@@ -14392,10 +14406,14 @@
1439214406
sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree));
1439314407
pTo->xMutexAlloc = pFrom->xMutexAlloc;
1439414408
}
1439514409
rc = sqlite3GlobalConfig.mutex.xMutexInit();
1439614410
}
14411
+
14412
+#ifdef SQLITE_DEBUG
14413
+ GLOBAL(int, mutexIsInit) = 1;
14414
+#endif
1439714415
1439814416
return rc;
1439914417
}
1440014418
1440114419
/*
@@ -14405,10 +14423,15 @@
1440514423
SQLITE_PRIVATE int sqlite3MutexEnd(void){
1440614424
int rc = SQLITE_OK;
1440714425
if( sqlite3GlobalConfig.mutex.xMutexEnd ){
1440814426
rc = sqlite3GlobalConfig.mutex.xMutexEnd();
1440914427
}
14428
+
14429
+#ifdef SQLITE_DEBUG
14430
+ GLOBAL(int, mutexIsInit) = 0;
14431
+#endif
14432
+
1441014433
return rc;
1441114434
}
1441214435
1441314436
/*
1441414437
** Retrieve a pointer to a static mutex or allocate a new dynamic one.
@@ -14422,10 +14445,11 @@
1442214445
1442314446
SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int id){
1442414447
if( !sqlite3GlobalConfig.bCoreMutex ){
1442514448
return 0;
1442614449
}
14450
+ assert( GLOBAL(int, mutexIsInit) );
1442714451
return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
1442814452
}
1442914453
1443014454
/*
1443114455
** Free a dynamic mutex.
@@ -22403,11 +22427,21 @@
2240322427
}
2240422428
if( pOpen->pNext ){
2240522429
assert( pOpen->pNext->pPrev==pOpen );
2240622430
pOpen->pNext->pPrev = pOpen->pPrev;
2240722431
}
22408
- assert( !pOpen->pUnused );
22432
+#if SQLITE_THREADSAFE && defined(__linux__)
22433
+ assert( !pOpen->pUnused || threadsOverrideEachOthersLocks==0 );
22434
+#endif
22435
+
22436
+ /* If pOpen->pUnused is not null, then memory and file-descriptors
22437
+ ** are leaked.
22438
+ **
22439
+ ** This will only happen if, under Linuxthreads, the user has opened
22440
+ ** a transaction in one thread, then attempts to close the database
22441
+ ** handle from another thread (without first unlocking the db file).
22442
+ ** This is a misuse. */
2240922443
sqlite3_free(pOpen);
2241022444
}
2241122445
}
2241222446
}
2241322447
@@ -27555,21 +27589,21 @@
2755527589
2755627590
if (!pFile->hMutex) return TRUE;
2755727591
winceMutexAcquire(pFile->hMutex);
2755827592
2755927593
/* Wanting an exclusive lock? */
27560
- if (dwFileOffsetLow == SHARED_FIRST
27561
- && nNumberOfBytesToLockLow == SHARED_SIZE){
27594
+ if (dwFileOffsetLow == (DWORD)SHARED_FIRST
27595
+ && nNumberOfBytesToLockLow == (DWORD)SHARED_SIZE){
2756227596
if (pFile->shared->nReaders == 0 && pFile->shared->bExclusive == 0){
2756327597
pFile->shared->bExclusive = TRUE;
2756427598
pFile->local.bExclusive = TRUE;
2756527599
bReturn = TRUE;
2756627600
}
2756727601
}
2756827602
2756927603
/* Want a read-only lock? */
27570
- else if (dwFileOffsetLow == SHARED_FIRST &&
27604
+ else if (dwFileOffsetLow == (DWORD)SHARED_FIRST &&
2757127605
nNumberOfBytesToLockLow == 1){
2757227606
if (pFile->shared->bExclusive == 0){
2757327607
pFile->local.nReaders ++;
2757427608
if (pFile->local.nReaders == 1){
2757527609
pFile->shared->nReaders ++;
@@ -27577,21 +27611,21 @@
2757727611
bReturn = TRUE;
2757827612
}
2757927613
}
2758027614
2758127615
/* Want a pending lock? */
27582
- else if (dwFileOffsetLow == PENDING_BYTE && nNumberOfBytesToLockLow == 1){
27616
+ else if (dwFileOffsetLow == (DWORD)PENDING_BYTE && nNumberOfBytesToLockLow == 1){
2758327617
/* If no pending lock has been acquired, then acquire it */
2758427618
if (pFile->shared->bPending == 0) {
2758527619
pFile->shared->bPending = TRUE;
2758627620
pFile->local.bPending = TRUE;
2758727621
bReturn = TRUE;
2758827622
}
2758927623
}
2759027624
2759127625
/* Want a reserved lock? */
27592
- else if (dwFileOffsetLow == RESERVED_BYTE && nNumberOfBytesToLockLow == 1){
27626
+ else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE && nNumberOfBytesToLockLow == 1){
2759327627
if (pFile->shared->bReserved == 0) {
2759427628
pFile->shared->bReserved = TRUE;
2759527629
pFile->local.bReserved = TRUE;
2759627630
bReturn = TRUE;
2759727631
}
@@ -27619,22 +27653,22 @@
2761927653
2762027654
if (!pFile->hMutex) return TRUE;
2762127655
winceMutexAcquire(pFile->hMutex);
2762227656
2762327657
/* Releasing a reader lock or an exclusive lock */
27624
- if (dwFileOffsetLow == SHARED_FIRST){
27658
+ if (dwFileOffsetLow == (DWORD)SHARED_FIRST){
2762527659
/* Did we have an exclusive lock? */
2762627660
if (pFile->local.bExclusive){
27627
- assert(nNumberOfBytesToUnlockLow == SHARED_SIZE);
27661
+ assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE);
2762827662
pFile->local.bExclusive = FALSE;
2762927663
pFile->shared->bExclusive = FALSE;
2763027664
bReturn = TRUE;
2763127665
}
2763227666
2763327667
/* Did we just have a reader lock? */
2763427668
else if (pFile->local.nReaders){
27635
- assert(nNumberOfBytesToUnlockLow == 1);
27669
+ assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE || nNumberOfBytesToUnlockLow == 1);
2763627670
pFile->local.nReaders --;
2763727671
if (pFile->local.nReaders == 0)
2763827672
{
2763927673
pFile->shared->nReaders --;
2764027674
}
@@ -27641,19 +27675,19 @@
2764127675
bReturn = TRUE;
2764227676
}
2764327677
}
2764427678
2764527679
/* Releasing a pending lock */
27646
- else if (dwFileOffsetLow == PENDING_BYTE && nNumberOfBytesToUnlockLow == 1){
27680
+ else if (dwFileOffsetLow == (DWORD)PENDING_BYTE && nNumberOfBytesToUnlockLow == 1){
2764727681
if (pFile->local.bPending){
2764827682
pFile->local.bPending = FALSE;
2764927683
pFile->shared->bPending = FALSE;
2765027684
bReturn = TRUE;
2765127685
}
2765227686
}
2765327687
/* Releasing a reserved lock */
27654
- else if (dwFileOffsetLow == RESERVED_BYTE && nNumberOfBytesToUnlockLow == 1){
27688
+ else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE && nNumberOfBytesToUnlockLow == 1){
2765527689
if (pFile->local.bReserved) {
2765627690
pFile->local.bReserved = FALSE;
2765727691
pFile->shared->bReserved = FALSE;
2765827692
bReturn = TRUE;
2765927693
}
@@ -27677,13 +27711,13 @@
2767727711
UNUSED_PARAMETER(dwReserved);
2767827712
UNUSED_PARAMETER(nNumberOfBytesToLockHigh);
2767927713
2768027714
/* If the caller wants a shared read lock, forward this call
2768127715
** to winceLockFile */
27682
- if (lpOverlapped->Offset == SHARED_FIRST &&
27716
+ if (lpOverlapped->Offset == (DWORD)SHARED_FIRST &&
2768327717
dwFlags == 1 &&
27684
- nNumberOfBytesToLockLow == SHARED_SIZE){
27718
+ nNumberOfBytesToLockLow == (DWORD)SHARED_SIZE){
2768527719
return winceLockFile(phFile, SHARED_FIRST, 0, 1, 0);
2768627720
}
2768727721
return FALSE;
2768827722
}
2768927723
/*
@@ -47373,11 +47407,11 @@
4737347407
4737447408
return pRet;
4737547409
}
4737647410
4737747411
/*
47378
-** Return true if the program stored in the VM passed as an argument may
47412
+** Check if the program stored in the VM associated with pParse may
4737947413
** throw an ABORT exception (causing the statement, but not transaction
4738047414
** to be rolled back). This condition is true if the main program or any
4738147415
** sub-programs contains any of the following:
4738247416
**
4738347417
** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
@@ -47384,14 +47418,19 @@
4738447418
** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
4738547419
** * OP_Destroy
4738647420
** * OP_VUpdate
4738747421
** * OP_VRename
4738847422
**
47389
-** This function is only used as part of an assert() statement.
47423
+** Then check that the value of Parse.mayAbort is true if an
47424
+** ABORT may be thrown, or false otherwise. Return true if it does
47425
+** match, or false otherwise. This function is intended to be used as
47426
+** part of an assert statement in the compiler. Similar to:
47427
+**
47428
+** assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) );
4739047429
*/
47391
-SQLITE_PRIVATE int sqlite3VdbeMayAbort(Vdbe *v){
47392
- int mayAbort = 0;
47430
+SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
47431
+ int hasAbort = 0;
4739347432
Op *pOp;
4739447433
VdbeOpIter sIter;
4739547434
memset(&sIter, 0, sizeof(sIter));
4739647435
sIter.v = v;
4739747436
@@ -47399,17 +47438,22 @@
4739947438
int opcode = pOp->opcode;
4740047439
if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
4740147440
|| ((opcode==OP_Halt || opcode==OP_HaltIfNull)
4740247441
&& (pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
4740347442
){
47404
- mayAbort = 1;
47443
+ hasAbort = 1;
4740547444
break;
4740647445
}
4740747446
}
47408
-
4740947447
sqlite3DbFree(v->db, sIter.apSub);
47410
- return mayAbort;
47448
+
47449
+ /* Return true if hasAbort==mayAbort. Or if a malloc failure occured.
47450
+ ** If malloc failed, then the while() loop above may not have iterated
47451
+ ** through all opcodes and hasAbort may be set incorrectly. Return
47452
+ ** true for this case to prevent the assert() in the callers frame
47453
+ ** from failing. */
47454
+ return ( v->db->mallocFailed || hasAbort==mayAbort );
4741147455
}
4741247456
#endif
4741347457
4741447458
/*
4741547459
** Loop through the program looking for P2 values that are negative
@@ -48365,11 +48409,11 @@
4836548409
int nVar, /* Number of '?' see in the SQL statement */
4836648410
int nMem, /* Number of memory cells to allocate */
4836748411
int nCursor, /* Number of cursors to allocate */
4836848412
int nArg, /* Maximum number of args in SubPrograms */
4836948413
int isExplain, /* True if the EXPLAIN keywords is present */
48370
- int usesStmtJournal /* True to set Vdbe.usesStmtJournal */
48414
+ int usesStmtJournal /* True to set Vdbe.usesStmtJournal */
4837148415
){
4837248416
int n;
4837348417
sqlite3 *db = p->db;
4837448418
4837548419
assert( p!=0 );
@@ -48401,11 +48445,11 @@
4840148445
if( nVar>=0 && ALWAYS(db->mallocFailed==0) ){
4840248446
u8 *zCsr = (u8 *)&p->aOp[p->nOp];
4840348447
u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc];
4840448448
int nByte;
4840548449
resolveP2Values(p, &nArg);
48406
- p->usesStmtJournal = usesStmtJournal;
48450
+ p->usesStmtJournal = (u8)usesStmtJournal;
4840748451
if( isExplain && nMem<10 ){
4840848452
nMem = 10;
4840948453
}
4841048454
memset(zCsr, 0, zEnd-zCsr);
4841148455
zCsr += (zCsr - (u8*)0)&7;
@@ -55382,18 +55426,22 @@
5538255426
}
5538355427
}
5538455428
5538555429
#ifndef SQLITE_OMIT_AUTOINCREMENT
5538655430
if( pOp->p3 ){
55431
+ /* Assert that P3 is a valid memory cell. */
55432
+ assert( pOp->p3>0 );
5538755433
if( p->pFrame ){
5538855434
for(u.be.pFrame=p->pFrame; u.be.pFrame->pParent; u.be.pFrame=u.be.pFrame->pParent);
55435
+ /* Assert that P3 is a valid memory cell. */
55436
+ assert( pOp->p3<=u.be.pFrame->nMem );
5538955437
u.be.pMem = &u.be.pFrame->aMem[pOp->p3];
5539055438
}else{
55439
+ /* Assert that P3 is a valid memory cell. */
55440
+ assert( pOp->p3<=p->nMem );
5539155441
u.be.pMem = &p->aMem[pOp->p3];
5539255442
}
55393
- /* Assert that P3 is a valid memory cell. */
55394
- assert( pOp->p3>0 && pOp->p3<=(p->pFrame ? u.be.pFrame->nMem : p->nMem) );
5539555443
5539655444
REGISTER_TRACE(pOp->p3, u.be.pMem);
5539755445
sqlite3VdbeMemIntegerify(u.be.pMem);
5539855446
assert( (u.be.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
5539955447
if( u.be.pMem->u.i==MAX_ROWID || u.be.pC->useRandomRowid ){
@@ -65441,11 +65489,12 @@
6544165489
6544265490
/* Begin by generating some termination code at the end of the
6544365491
** vdbe program
6544465492
*/
6544565493
v = sqlite3GetVdbe(pParse);
65446
- assert( pParse->isMultiWrite==0 || sqlite3VdbeMayAbort(v)==pParse->mayAbort );
65494
+ assert( !pParse->isMultiWrite
65495
+ || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));
6544765496
if( v ){
6544865497
sqlite3VdbeAddOp0(v, OP_Halt);
6544965498
6545065499
/* The cookie mask contains one bit for each database file open.
6545165500
** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are
@@ -77658,11 +77707,11 @@
7765877707
Table *pTab = 0; /* Table structure column is extracted from */
7765977708
Select *pS = 0; /* Select the column is extracted from */
7766077709
int iCol = pExpr->iColumn; /* Index of column in pTab */
7766177710
testcase( pExpr->op==TK_AGG_COLUMN );
7766277711
testcase( pExpr->op==TK_COLUMN );
77663
- while( ALWAYS(pNC) && !pTab ){
77712
+ while( pNC && !pTab ){
7766477713
SrcList *pTabList = pNC->pSrcList;
7766577714
for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);
7766677715
if( j<pTabList->nSrc ){
7766777716
pTab = pTabList->a[j].pTab;
7766877717
pS = pTabList->a[j].pSelect;
@@ -77669,22 +77718,32 @@
7766977718
}else{
7767077719
pNC = pNC->pNext;
7767177720
}
7767277721
}
7767377722
77674
- if( NEVER(pTab==0) ){
77723
+ if( pTab==0 ){
7767577724
/* At one time, code such as "SELECT new.x" within a trigger would
7767677725
** cause this condition to run. Since then, we have restructured how
7767777726
** trigger code is generated and so this condition is no longer
77678
- ** possible. But it seems prudent to keep the test in place in
77679
- ** case something else changes.
77680
- */
77681
- zType = "TEXT";
77727
+ ** possible. However, it can still be true for statements like
77728
+ ** the following:
77729
+ **
77730
+ ** CREATE TABLE t1(col INTEGER);
77731
+ ** SELECT (SELECT t1.col) FROM FROM t1;
77732
+ **
77733
+ ** when columnType() is called on the expression "t1.col" in the
77734
+ ** sub-select. In this case, set the column type to NULL, even
77735
+ ** though it should really be "INTEGER".
77736
+ **
77737
+ ** This is not a problem, as the column type of "t1.col" is never
77738
+ ** used. When columnType() is called on the expression
77739
+ ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT
77740
+ ** branch below. */
7768277741
break;
7768377742
}
7768477743
77685
- assert( pTab );
77744
+ assert( pTab && pExpr->pTab==pTab );
7768677745
if( pS ){
7768777746
/* The "table" is actually a sub-select or a view in the FROM clause
7768877747
** of the SELECT statement. Return the declaration type and origin
7768977748
** data for the result-set column of the sub-select.
7769077749
*/
@@ -77694,11 +77753,11 @@
7769477753
** test case misc2.2.2) - it always evaluates to NULL.
7769577754
*/
7769677755
NameContext sNC;
7769777756
Expr *p = pS->pEList->a[iCol].pExpr;
7769877757
sNC.pSrcList = pS->pSrc;
77699
- sNC.pNext = 0;
77758
+ sNC.pNext = pNC;
7770077759
sNC.pParse = pNC->pParse;
7770177760
zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol);
7770277761
}
7770377762
}else if( ALWAYS(pTab->pSchema) ){
7770477763
/* A real table */
7770577764
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -15,11 +15,11 @@
15 ** of the embedded sqlite3.h header file.) Additional code files may be needed
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** This amalgamation was generated on 2009-09-09 16:11:06 UTC.
21 */
22 #define SQLITE_CORE 1
23 #define SQLITE_AMALGAMATION 1
24 #ifndef SQLITE_PRIVATE
25 # define SQLITE_PRIVATE static
@@ -275,11 +275,15 @@
275
276 /*
277 ** Maximum depth of recursion for triggers.
278 */
279 #ifndef SQLITE_MAX_TRIGGER_DEPTH
 
 
 
280 # define SQLITE_MAX_TRIGGER_DEPTH 1000
 
281 #endif
282
283 /************** End of sqliteLimit.h *****************************************/
284 /************** Continuing where we left off in sqliteInt.h ******************/
285
@@ -643,11 +647,11 @@
643 **
644 ** Requirements: [H10011] [H10014]
645 */
646 #define SQLITE_VERSION "3.6.18"
647 #define SQLITE_VERSION_NUMBER 3006018
648 #define SQLITE_SOURCE_ID "2009-09-09 16:10:51 f0c72a53c5d57d7487b48a06a40816153f47aaac"
649
650 /*
651 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
652 ** KEYWORDS: sqlite3_version
653 **
@@ -7506,11 +7510,11 @@
7506 SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int,int,int);
7507 SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
7508 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
7509 SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
7510 #ifdef SQLITE_DEBUG
7511 SQLITE_PRIVATE int sqlite3VdbeMayAbort(Vdbe*);
7512 SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe*,FILE*);
7513 #endif
7514 SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);
7515 SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
7516 SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
@@ -11373,11 +11377,11 @@
11373 x.s = s;
11374 }
11375 x.tz = 0;
11376 x.validJD = 0;
11377 computeJD(&x);
11378 t = x.iJD/1000 - 21086676*(i64)10000;
11379 #ifdef HAVE_LOCALTIME_R
11380 {
11381 struct tm sLocal;
11382 localtime_r(&t, &sLocal);
11383 y.Y = sLocal.tm_year + 1900;
@@ -14368,10 +14372,20 @@
14368 ** This file contains code that is common across all mutex implementations.
14369
14370 **
14371 ** $Id: mutex.c,v 1.31 2009/07/16 18:21:18 drh Exp $
14372 */
 
 
 
 
 
 
 
 
 
 
14373
14374 #ifndef SQLITE_MUTEX_OMIT
14375 /*
14376 ** Initialize the mutex system.
14377 */
@@ -14392,10 +14406,14 @@
14392 sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree));
14393 pTo->xMutexAlloc = pFrom->xMutexAlloc;
14394 }
14395 rc = sqlite3GlobalConfig.mutex.xMutexInit();
14396 }
 
 
 
 
14397
14398 return rc;
14399 }
14400
14401 /*
@@ -14405,10 +14423,15 @@
14405 SQLITE_PRIVATE int sqlite3MutexEnd(void){
14406 int rc = SQLITE_OK;
14407 if( sqlite3GlobalConfig.mutex.xMutexEnd ){
14408 rc = sqlite3GlobalConfig.mutex.xMutexEnd();
14409 }
 
 
 
 
 
14410 return rc;
14411 }
14412
14413 /*
14414 ** Retrieve a pointer to a static mutex or allocate a new dynamic one.
@@ -14422,10 +14445,11 @@
14422
14423 SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int id){
14424 if( !sqlite3GlobalConfig.bCoreMutex ){
14425 return 0;
14426 }
 
14427 return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
14428 }
14429
14430 /*
14431 ** Free a dynamic mutex.
@@ -22403,11 +22427,21 @@
22403 }
22404 if( pOpen->pNext ){
22405 assert( pOpen->pNext->pPrev==pOpen );
22406 pOpen->pNext->pPrev = pOpen->pPrev;
22407 }
22408 assert( !pOpen->pUnused );
 
 
 
 
 
 
 
 
 
 
22409 sqlite3_free(pOpen);
22410 }
22411 }
22412 }
22413
@@ -27555,21 +27589,21 @@
27555
27556 if (!pFile->hMutex) return TRUE;
27557 winceMutexAcquire(pFile->hMutex);
27558
27559 /* Wanting an exclusive lock? */
27560 if (dwFileOffsetLow == SHARED_FIRST
27561 && nNumberOfBytesToLockLow == SHARED_SIZE){
27562 if (pFile->shared->nReaders == 0 && pFile->shared->bExclusive == 0){
27563 pFile->shared->bExclusive = TRUE;
27564 pFile->local.bExclusive = TRUE;
27565 bReturn = TRUE;
27566 }
27567 }
27568
27569 /* Want a read-only lock? */
27570 else if (dwFileOffsetLow == SHARED_FIRST &&
27571 nNumberOfBytesToLockLow == 1){
27572 if (pFile->shared->bExclusive == 0){
27573 pFile->local.nReaders ++;
27574 if (pFile->local.nReaders == 1){
27575 pFile->shared->nReaders ++;
@@ -27577,21 +27611,21 @@
27577 bReturn = TRUE;
27578 }
27579 }
27580
27581 /* Want a pending lock? */
27582 else if (dwFileOffsetLow == PENDING_BYTE && nNumberOfBytesToLockLow == 1){
27583 /* If no pending lock has been acquired, then acquire it */
27584 if (pFile->shared->bPending == 0) {
27585 pFile->shared->bPending = TRUE;
27586 pFile->local.bPending = TRUE;
27587 bReturn = TRUE;
27588 }
27589 }
27590
27591 /* Want a reserved lock? */
27592 else if (dwFileOffsetLow == RESERVED_BYTE && nNumberOfBytesToLockLow == 1){
27593 if (pFile->shared->bReserved == 0) {
27594 pFile->shared->bReserved = TRUE;
27595 pFile->local.bReserved = TRUE;
27596 bReturn = TRUE;
27597 }
@@ -27619,22 +27653,22 @@
27619
27620 if (!pFile->hMutex) return TRUE;
27621 winceMutexAcquire(pFile->hMutex);
27622
27623 /* Releasing a reader lock or an exclusive lock */
27624 if (dwFileOffsetLow == SHARED_FIRST){
27625 /* Did we have an exclusive lock? */
27626 if (pFile->local.bExclusive){
27627 assert(nNumberOfBytesToUnlockLow == SHARED_SIZE);
27628 pFile->local.bExclusive = FALSE;
27629 pFile->shared->bExclusive = FALSE;
27630 bReturn = TRUE;
27631 }
27632
27633 /* Did we just have a reader lock? */
27634 else if (pFile->local.nReaders){
27635 assert(nNumberOfBytesToUnlockLow == 1);
27636 pFile->local.nReaders --;
27637 if (pFile->local.nReaders == 0)
27638 {
27639 pFile->shared->nReaders --;
27640 }
@@ -27641,19 +27675,19 @@
27641 bReturn = TRUE;
27642 }
27643 }
27644
27645 /* Releasing a pending lock */
27646 else if (dwFileOffsetLow == PENDING_BYTE && nNumberOfBytesToUnlockLow == 1){
27647 if (pFile->local.bPending){
27648 pFile->local.bPending = FALSE;
27649 pFile->shared->bPending = FALSE;
27650 bReturn = TRUE;
27651 }
27652 }
27653 /* Releasing a reserved lock */
27654 else if (dwFileOffsetLow == RESERVED_BYTE && nNumberOfBytesToUnlockLow == 1){
27655 if (pFile->local.bReserved) {
27656 pFile->local.bReserved = FALSE;
27657 pFile->shared->bReserved = FALSE;
27658 bReturn = TRUE;
27659 }
@@ -27677,13 +27711,13 @@
27677 UNUSED_PARAMETER(dwReserved);
27678 UNUSED_PARAMETER(nNumberOfBytesToLockHigh);
27679
27680 /* If the caller wants a shared read lock, forward this call
27681 ** to winceLockFile */
27682 if (lpOverlapped->Offset == SHARED_FIRST &&
27683 dwFlags == 1 &&
27684 nNumberOfBytesToLockLow == SHARED_SIZE){
27685 return winceLockFile(phFile, SHARED_FIRST, 0, 1, 0);
27686 }
27687 return FALSE;
27688 }
27689 /*
@@ -47373,11 +47407,11 @@
47373
47374 return pRet;
47375 }
47376
47377 /*
47378 ** Return true if the program stored in the VM passed as an argument may
47379 ** throw an ABORT exception (causing the statement, but not transaction
47380 ** to be rolled back). This condition is true if the main program or any
47381 ** sub-programs contains any of the following:
47382 **
47383 ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
@@ -47384,14 +47418,19 @@
47384 ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
47385 ** * OP_Destroy
47386 ** * OP_VUpdate
47387 ** * OP_VRename
47388 **
47389 ** This function is only used as part of an assert() statement.
 
 
 
 
 
47390 */
47391 SQLITE_PRIVATE int sqlite3VdbeMayAbort(Vdbe *v){
47392 int mayAbort = 0;
47393 Op *pOp;
47394 VdbeOpIter sIter;
47395 memset(&sIter, 0, sizeof(sIter));
47396 sIter.v = v;
47397
@@ -47399,17 +47438,22 @@
47399 int opcode = pOp->opcode;
47400 if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
47401 || ((opcode==OP_Halt || opcode==OP_HaltIfNull)
47402 && (pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
47403 ){
47404 mayAbort = 1;
47405 break;
47406 }
47407 }
47408
47409 sqlite3DbFree(v->db, sIter.apSub);
47410 return mayAbort;
 
 
 
 
 
 
47411 }
47412 #endif
47413
47414 /*
47415 ** Loop through the program looking for P2 values that are negative
@@ -48365,11 +48409,11 @@
48365 int nVar, /* Number of '?' see in the SQL statement */
48366 int nMem, /* Number of memory cells to allocate */
48367 int nCursor, /* Number of cursors to allocate */
48368 int nArg, /* Maximum number of args in SubPrograms */
48369 int isExplain, /* True if the EXPLAIN keywords is present */
48370 int usesStmtJournal /* True to set Vdbe.usesStmtJournal */
48371 ){
48372 int n;
48373 sqlite3 *db = p->db;
48374
48375 assert( p!=0 );
@@ -48401,11 +48445,11 @@
48401 if( nVar>=0 && ALWAYS(db->mallocFailed==0) ){
48402 u8 *zCsr = (u8 *)&p->aOp[p->nOp];
48403 u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc];
48404 int nByte;
48405 resolveP2Values(p, &nArg);
48406 p->usesStmtJournal = usesStmtJournal;
48407 if( isExplain && nMem<10 ){
48408 nMem = 10;
48409 }
48410 memset(zCsr, 0, zEnd-zCsr);
48411 zCsr += (zCsr - (u8*)0)&7;
@@ -55382,18 +55426,22 @@
55382 }
55383 }
55384
55385 #ifndef SQLITE_OMIT_AUTOINCREMENT
55386 if( pOp->p3 ){
 
 
55387 if( p->pFrame ){
55388 for(u.be.pFrame=p->pFrame; u.be.pFrame->pParent; u.be.pFrame=u.be.pFrame->pParent);
 
 
55389 u.be.pMem = &u.be.pFrame->aMem[pOp->p3];
55390 }else{
 
 
55391 u.be.pMem = &p->aMem[pOp->p3];
55392 }
55393 /* Assert that P3 is a valid memory cell. */
55394 assert( pOp->p3>0 && pOp->p3<=(p->pFrame ? u.be.pFrame->nMem : p->nMem) );
55395
55396 REGISTER_TRACE(pOp->p3, u.be.pMem);
55397 sqlite3VdbeMemIntegerify(u.be.pMem);
55398 assert( (u.be.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
55399 if( u.be.pMem->u.i==MAX_ROWID || u.be.pC->useRandomRowid ){
@@ -65441,11 +65489,12 @@
65441
65442 /* Begin by generating some termination code at the end of the
65443 ** vdbe program
65444 */
65445 v = sqlite3GetVdbe(pParse);
65446 assert( pParse->isMultiWrite==0 || sqlite3VdbeMayAbort(v)==pParse->mayAbort );
 
65447 if( v ){
65448 sqlite3VdbeAddOp0(v, OP_Halt);
65449
65450 /* The cookie mask contains one bit for each database file open.
65451 ** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are
@@ -77658,11 +77707,11 @@
77658 Table *pTab = 0; /* Table structure column is extracted from */
77659 Select *pS = 0; /* Select the column is extracted from */
77660 int iCol = pExpr->iColumn; /* Index of column in pTab */
77661 testcase( pExpr->op==TK_AGG_COLUMN );
77662 testcase( pExpr->op==TK_COLUMN );
77663 while( ALWAYS(pNC) && !pTab ){
77664 SrcList *pTabList = pNC->pSrcList;
77665 for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);
77666 if( j<pTabList->nSrc ){
77667 pTab = pTabList->a[j].pTab;
77668 pS = pTabList->a[j].pSelect;
@@ -77669,22 +77718,32 @@
77669 }else{
77670 pNC = pNC->pNext;
77671 }
77672 }
77673
77674 if( NEVER(pTab==0) ){
77675 /* At one time, code such as "SELECT new.x" within a trigger would
77676 ** cause this condition to run. Since then, we have restructured how
77677 ** trigger code is generated and so this condition is no longer
77678 ** possible. But it seems prudent to keep the test in place in
77679 ** case something else changes.
77680 */
77681 zType = "TEXT";
 
 
 
 
 
 
 
 
 
 
77682 break;
77683 }
77684
77685 assert( pTab );
77686 if( pS ){
77687 /* The "table" is actually a sub-select or a view in the FROM clause
77688 ** of the SELECT statement. Return the declaration type and origin
77689 ** data for the result-set column of the sub-select.
77690 */
@@ -77694,11 +77753,11 @@
77694 ** test case misc2.2.2) - it always evaluates to NULL.
77695 */
77696 NameContext sNC;
77697 Expr *p = pS->pEList->a[iCol].pExpr;
77698 sNC.pSrcList = pS->pSrc;
77699 sNC.pNext = 0;
77700 sNC.pParse = pNC->pParse;
77701 zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol);
77702 }
77703 }else if( ALWAYS(pTab->pSchema) ){
77704 /* A real table */
77705
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -15,11 +15,11 @@
15 ** of the embedded sqlite3.h header file.) Additional code files may be needed
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** This amalgamation was generated on 2009-09-10 22:23:14 UTC.
21 */
22 #define SQLITE_CORE 1
23 #define SQLITE_AMALGAMATION 1
24 #ifndef SQLITE_PRIVATE
25 # define SQLITE_PRIVATE static
@@ -275,11 +275,15 @@
275
276 /*
277 ** Maximum depth of recursion for triggers.
278 */
279 #ifndef SQLITE_MAX_TRIGGER_DEPTH
280 #if defined(SQLITE_SMALL_STACK)
281 # define SQLITE_MAX_TRIGGER_DEPTH 10
282 #else
283 # define SQLITE_MAX_TRIGGER_DEPTH 1000
284 #endif
285 #endif
286
287 /************** End of sqliteLimit.h *****************************************/
288 /************** Continuing where we left off in sqliteInt.h ******************/
289
@@ -643,11 +647,11 @@
647 **
648 ** Requirements: [H10011] [H10014]
649 */
650 #define SQLITE_VERSION "3.6.18"
651 #define SQLITE_VERSION_NUMBER 3006018
652 #define SQLITE_SOURCE_ID "2009-09-10 20:23:30 f42ec993ac9d42ca31305f26b09924108c36d9f4"
653
654 /*
655 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
656 ** KEYWORDS: sqlite3_version
657 **
@@ -7506,11 +7510,11 @@
7510 SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int,int,int);
7511 SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
7512 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
7513 SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
7514 #ifdef SQLITE_DEBUG
7515 SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *, int);
7516 SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe*,FILE*);
7517 #endif
7518 SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);
7519 SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
7520 SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);
@@ -11373,11 +11377,11 @@
11377 x.s = s;
11378 }
11379 x.tz = 0;
11380 x.validJD = 0;
11381 computeJD(&x);
11382 t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
11383 #ifdef HAVE_LOCALTIME_R
11384 {
11385 struct tm sLocal;
11386 localtime_r(&t, &sLocal);
11387 y.Y = sLocal.tm_year + 1900;
@@ -14368,10 +14372,20 @@
14372 ** This file contains code that is common across all mutex implementations.
14373
14374 **
14375 ** $Id: mutex.c,v 1.31 2009/07/16 18:21:18 drh Exp $
14376 */
14377
14378 #if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT)
14379 /*
14380 ** For debugging purposes, record when the mutex subsystem is initialized
14381 ** and uninitialized so that we can assert() if there is an attempt to
14382 ** allocate a mutex while the system is uninitialized.
14383 */
14384 static SQLITE_WSD int mutexIsInit = 0;
14385 #endif /* SQLITE_DEBUG */
14386
14387
14388 #ifndef SQLITE_MUTEX_OMIT
14389 /*
14390 ** Initialize the mutex system.
14391 */
@@ -14392,10 +14406,14 @@
14406 sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree));
14407 pTo->xMutexAlloc = pFrom->xMutexAlloc;
14408 }
14409 rc = sqlite3GlobalConfig.mutex.xMutexInit();
14410 }
14411
14412 #ifdef SQLITE_DEBUG
14413 GLOBAL(int, mutexIsInit) = 1;
14414 #endif
14415
14416 return rc;
14417 }
14418
14419 /*
@@ -14405,10 +14423,15 @@
14423 SQLITE_PRIVATE int sqlite3MutexEnd(void){
14424 int rc = SQLITE_OK;
14425 if( sqlite3GlobalConfig.mutex.xMutexEnd ){
14426 rc = sqlite3GlobalConfig.mutex.xMutexEnd();
14427 }
14428
14429 #ifdef SQLITE_DEBUG
14430 GLOBAL(int, mutexIsInit) = 0;
14431 #endif
14432
14433 return rc;
14434 }
14435
14436 /*
14437 ** Retrieve a pointer to a static mutex or allocate a new dynamic one.
@@ -14422,10 +14445,11 @@
14445
14446 SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int id){
14447 if( !sqlite3GlobalConfig.bCoreMutex ){
14448 return 0;
14449 }
14450 assert( GLOBAL(int, mutexIsInit) );
14451 return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
14452 }
14453
14454 /*
14455 ** Free a dynamic mutex.
@@ -22403,11 +22427,21 @@
22427 }
22428 if( pOpen->pNext ){
22429 assert( pOpen->pNext->pPrev==pOpen );
22430 pOpen->pNext->pPrev = pOpen->pPrev;
22431 }
22432 #if SQLITE_THREADSAFE && defined(__linux__)
22433 assert( !pOpen->pUnused || threadsOverrideEachOthersLocks==0 );
22434 #endif
22435
22436 /* If pOpen->pUnused is not null, then memory and file-descriptors
22437 ** are leaked.
22438 **
22439 ** This will only happen if, under Linuxthreads, the user has opened
22440 ** a transaction in one thread, then attempts to close the database
22441 ** handle from another thread (without first unlocking the db file).
22442 ** This is a misuse. */
22443 sqlite3_free(pOpen);
22444 }
22445 }
22446 }
22447
@@ -27555,21 +27589,21 @@
27589
27590 if (!pFile->hMutex) return TRUE;
27591 winceMutexAcquire(pFile->hMutex);
27592
27593 /* Wanting an exclusive lock? */
27594 if (dwFileOffsetLow == (DWORD)SHARED_FIRST
27595 && nNumberOfBytesToLockLow == (DWORD)SHARED_SIZE){
27596 if (pFile->shared->nReaders == 0 && pFile->shared->bExclusive == 0){
27597 pFile->shared->bExclusive = TRUE;
27598 pFile->local.bExclusive = TRUE;
27599 bReturn = TRUE;
27600 }
27601 }
27602
27603 /* Want a read-only lock? */
27604 else if (dwFileOffsetLow == (DWORD)SHARED_FIRST &&
27605 nNumberOfBytesToLockLow == 1){
27606 if (pFile->shared->bExclusive == 0){
27607 pFile->local.nReaders ++;
27608 if (pFile->local.nReaders == 1){
27609 pFile->shared->nReaders ++;
@@ -27577,21 +27611,21 @@
27611 bReturn = TRUE;
27612 }
27613 }
27614
27615 /* Want a pending lock? */
27616 else if (dwFileOffsetLow == (DWORD)PENDING_BYTE && nNumberOfBytesToLockLow == 1){
27617 /* If no pending lock has been acquired, then acquire it */
27618 if (pFile->shared->bPending == 0) {
27619 pFile->shared->bPending = TRUE;
27620 pFile->local.bPending = TRUE;
27621 bReturn = TRUE;
27622 }
27623 }
27624
27625 /* Want a reserved lock? */
27626 else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE && nNumberOfBytesToLockLow == 1){
27627 if (pFile->shared->bReserved == 0) {
27628 pFile->shared->bReserved = TRUE;
27629 pFile->local.bReserved = TRUE;
27630 bReturn = TRUE;
27631 }
@@ -27619,22 +27653,22 @@
27653
27654 if (!pFile->hMutex) return TRUE;
27655 winceMutexAcquire(pFile->hMutex);
27656
27657 /* Releasing a reader lock or an exclusive lock */
27658 if (dwFileOffsetLow == (DWORD)SHARED_FIRST){
27659 /* Did we have an exclusive lock? */
27660 if (pFile->local.bExclusive){
27661 assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE);
27662 pFile->local.bExclusive = FALSE;
27663 pFile->shared->bExclusive = FALSE;
27664 bReturn = TRUE;
27665 }
27666
27667 /* Did we just have a reader lock? */
27668 else if (pFile->local.nReaders){
27669 assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE || nNumberOfBytesToUnlockLow == 1);
27670 pFile->local.nReaders --;
27671 if (pFile->local.nReaders == 0)
27672 {
27673 pFile->shared->nReaders --;
27674 }
@@ -27641,19 +27675,19 @@
27675 bReturn = TRUE;
27676 }
27677 }
27678
27679 /* Releasing a pending lock */
27680 else if (dwFileOffsetLow == (DWORD)PENDING_BYTE && nNumberOfBytesToUnlockLow == 1){
27681 if (pFile->local.bPending){
27682 pFile->local.bPending = FALSE;
27683 pFile->shared->bPending = FALSE;
27684 bReturn = TRUE;
27685 }
27686 }
27687 /* Releasing a reserved lock */
27688 else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE && nNumberOfBytesToUnlockLow == 1){
27689 if (pFile->local.bReserved) {
27690 pFile->local.bReserved = FALSE;
27691 pFile->shared->bReserved = FALSE;
27692 bReturn = TRUE;
27693 }
@@ -27677,13 +27711,13 @@
27711 UNUSED_PARAMETER(dwReserved);
27712 UNUSED_PARAMETER(nNumberOfBytesToLockHigh);
27713
27714 /* If the caller wants a shared read lock, forward this call
27715 ** to winceLockFile */
27716 if (lpOverlapped->Offset == (DWORD)SHARED_FIRST &&
27717 dwFlags == 1 &&
27718 nNumberOfBytesToLockLow == (DWORD)SHARED_SIZE){
27719 return winceLockFile(phFile, SHARED_FIRST, 0, 1, 0);
27720 }
27721 return FALSE;
27722 }
27723 /*
@@ -47373,11 +47407,11 @@
47407
47408 return pRet;
47409 }
47410
47411 /*
47412 ** Check if the program stored in the VM associated with pParse may
47413 ** throw an ABORT exception (causing the statement, but not transaction
47414 ** to be rolled back). This condition is true if the main program or any
47415 ** sub-programs contains any of the following:
47416 **
47417 ** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
@@ -47384,14 +47418,19 @@
47418 ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
47419 ** * OP_Destroy
47420 ** * OP_VUpdate
47421 ** * OP_VRename
47422 **
47423 ** Then check that the value of Parse.mayAbort is true if an
47424 ** ABORT may be thrown, or false otherwise. Return true if it does
47425 ** match, or false otherwise. This function is intended to be used as
47426 ** part of an assert statement in the compiler. Similar to:
47427 **
47428 ** assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) );
47429 */
47430 SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
47431 int hasAbort = 0;
47432 Op *pOp;
47433 VdbeOpIter sIter;
47434 memset(&sIter, 0, sizeof(sIter));
47435 sIter.v = v;
47436
@@ -47399,17 +47438,22 @@
47438 int opcode = pOp->opcode;
47439 if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
47440 || ((opcode==OP_Halt || opcode==OP_HaltIfNull)
47441 && (pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
47442 ){
47443 hasAbort = 1;
47444 break;
47445 }
47446 }
 
47447 sqlite3DbFree(v->db, sIter.apSub);
47448
47449 /* Return true if hasAbort==mayAbort. Or if a malloc failure occured.
47450 ** If malloc failed, then the while() loop above may not have iterated
47451 ** through all opcodes and hasAbort may be set incorrectly. Return
47452 ** true for this case to prevent the assert() in the callers frame
47453 ** from failing. */
47454 return ( v->db->mallocFailed || hasAbort==mayAbort );
47455 }
47456 #endif
47457
47458 /*
47459 ** Loop through the program looking for P2 values that are negative
@@ -48365,11 +48409,11 @@
48409 int nVar, /* Number of '?' see in the SQL statement */
48410 int nMem, /* Number of memory cells to allocate */
48411 int nCursor, /* Number of cursors to allocate */
48412 int nArg, /* Maximum number of args in SubPrograms */
48413 int isExplain, /* True if the EXPLAIN keywords is present */
48414 int usesStmtJournal /* True to set Vdbe.usesStmtJournal */
48415 ){
48416 int n;
48417 sqlite3 *db = p->db;
48418
48419 assert( p!=0 );
@@ -48401,11 +48445,11 @@
48445 if( nVar>=0 && ALWAYS(db->mallocFailed==0) ){
48446 u8 *zCsr = (u8 *)&p->aOp[p->nOp];
48447 u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc];
48448 int nByte;
48449 resolveP2Values(p, &nArg);
48450 p->usesStmtJournal = (u8)usesStmtJournal;
48451 if( isExplain && nMem<10 ){
48452 nMem = 10;
48453 }
48454 memset(zCsr, 0, zEnd-zCsr);
48455 zCsr += (zCsr - (u8*)0)&7;
@@ -55382,18 +55426,22 @@
55426 }
55427 }
55428
55429 #ifndef SQLITE_OMIT_AUTOINCREMENT
55430 if( pOp->p3 ){
55431 /* Assert that P3 is a valid memory cell. */
55432 assert( pOp->p3>0 );
55433 if( p->pFrame ){
55434 for(u.be.pFrame=p->pFrame; u.be.pFrame->pParent; u.be.pFrame=u.be.pFrame->pParent);
55435 /* Assert that P3 is a valid memory cell. */
55436 assert( pOp->p3<=u.be.pFrame->nMem );
55437 u.be.pMem = &u.be.pFrame->aMem[pOp->p3];
55438 }else{
55439 /* Assert that P3 is a valid memory cell. */
55440 assert( pOp->p3<=p->nMem );
55441 u.be.pMem = &p->aMem[pOp->p3];
55442 }
 
 
55443
55444 REGISTER_TRACE(pOp->p3, u.be.pMem);
55445 sqlite3VdbeMemIntegerify(u.be.pMem);
55446 assert( (u.be.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
55447 if( u.be.pMem->u.i==MAX_ROWID || u.be.pC->useRandomRowid ){
@@ -65441,11 +65489,12 @@
65489
65490 /* Begin by generating some termination code at the end of the
65491 ** vdbe program
65492 */
65493 v = sqlite3GetVdbe(pParse);
65494 assert( !pParse->isMultiWrite
65495 || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));
65496 if( v ){
65497 sqlite3VdbeAddOp0(v, OP_Halt);
65498
65499 /* The cookie mask contains one bit for each database file open.
65500 ** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are
@@ -77658,11 +77707,11 @@
77707 Table *pTab = 0; /* Table structure column is extracted from */
77708 Select *pS = 0; /* Select the column is extracted from */
77709 int iCol = pExpr->iColumn; /* Index of column in pTab */
77710 testcase( pExpr->op==TK_AGG_COLUMN );
77711 testcase( pExpr->op==TK_COLUMN );
77712 while( pNC && !pTab ){
77713 SrcList *pTabList = pNC->pSrcList;
77714 for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);
77715 if( j<pTabList->nSrc ){
77716 pTab = pTabList->a[j].pTab;
77717 pS = pTabList->a[j].pSelect;
@@ -77669,22 +77718,32 @@
77718 }else{
77719 pNC = pNC->pNext;
77720 }
77721 }
77722
77723 if( pTab==0 ){
77724 /* At one time, code such as "SELECT new.x" within a trigger would
77725 ** cause this condition to run. Since then, we have restructured how
77726 ** trigger code is generated and so this condition is no longer
77727 ** possible. However, it can still be true for statements like
77728 ** the following:
77729 **
77730 ** CREATE TABLE t1(col INTEGER);
77731 ** SELECT (SELECT t1.col) FROM FROM t1;
77732 **
77733 ** when columnType() is called on the expression "t1.col" in the
77734 ** sub-select. In this case, set the column type to NULL, even
77735 ** though it should really be "INTEGER".
77736 **
77737 ** This is not a problem, as the column type of "t1.col" is never
77738 ** used. When columnType() is called on the expression
77739 ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT
77740 ** branch below. */
77741 break;
77742 }
77743
77744 assert( pTab && pExpr->pTab==pTab );
77745 if( pS ){
77746 /* The "table" is actually a sub-select or a view in the FROM clause
77747 ** of the SELECT statement. Return the declaration type and origin
77748 ** data for the result-set column of the sub-select.
77749 */
@@ -77694,11 +77753,11 @@
77753 ** test case misc2.2.2) - it always evaluates to NULL.
77754 */
77755 NameContext sNC;
77756 Expr *p = pS->pEList->a[iCol].pExpr;
77757 sNC.pSrcList = pS->pSrc;
77758 sNC.pNext = pNC;
77759 sNC.pParse = pNC->pParse;
77760 zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol);
77761 }
77762 }else if( ALWAYS(pTab->pSchema) ){
77763 /* A real table */
77764
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -119,11 +119,11 @@
119119
**
120120
** Requirements: [H10011] [H10014]
121121
*/
122122
#define SQLITE_VERSION "3.6.18"
123123
#define SQLITE_VERSION_NUMBER 3006018
124
-#define SQLITE_SOURCE_ID "2009-09-09 16:10:51 f0c72a53c5d57d7487b48a06a40816153f47aaac"
124
+#define SQLITE_SOURCE_ID "2009-09-10 19:20:03 e9d064bd9318c2bc9248df948f71fd30f24525eb"
125125
126126
/*
127127
** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
128128
** KEYWORDS: sqlite3_version
129129
**
130130
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -119,11 +119,11 @@
119 **
120 ** Requirements: [H10011] [H10014]
121 */
122 #define SQLITE_VERSION "3.6.18"
123 #define SQLITE_VERSION_NUMBER 3006018
124 #define SQLITE_SOURCE_ID "2009-09-09 16:10:51 f0c72a53c5d57d7487b48a06a40816153f47aaac"
125
126 /*
127 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
128 ** KEYWORDS: sqlite3_version
129 **
130
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -119,11 +119,11 @@
119 **
120 ** Requirements: [H10011] [H10014]
121 */
122 #define SQLITE_VERSION "3.6.18"
123 #define SQLITE_VERSION_NUMBER 3006018
124 #define SQLITE_SOURCE_ID "2009-09-10 19:20:03 e9d064bd9318c2bc9248df948f71fd30f24525eb"
125
126 /*
127 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
128 ** KEYWORDS: sqlite3_version
129 **
130

Keyboard Shortcuts

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