# # # patch "sqlite/btree.c" # from [2023a8371bd23c300571a4ce9673b8859c44be36] # to [960bf64baa4d2bdb96019698e60d0b7763bf4e7e] # # patch "sqlite/expr.c" # from [2c32c546006627d70a7b941b318489980fd1912e] # to [2f0f9f89efe9170e5e6ca5d5e93a9d5896fff5ac] # # patch "sqlite/legacy.c" # from [2631df6a861f830d6b1c0fe92b9fdd745b2c0cd6] # to [c05a599a37f703ed1e66fdb5df60c2db65f29e71] # # patch "sqlite/loadext.c" # from [146fb9b9dc6133e763888d710205c32ebf8eeca2] # to [afe4f4755dc49c36ef505748bbdddecb9f1d02a2] # # patch "sqlite/prepare.c" # from [37207b2b2ccb41d379b01dd62231686bcc48ef1f] # to [4cb9c9eb926e8baf5652ca4b4f2416f53f5b5370] # # patch "sqlite/sqlite3.h" # from [2f5f4c4929cbb430496c3338bca309d0f2b9d980] # to [6dcafd84bc51a2510ec2d8ef94f024d36b0e1a00] # # patch "sqlite/vdbe.c" # from [cf7808e8db2e5d1547e898ce29531295183ede6e] # to [814dab208a156250bc5e77f827f4e0c8ad734820] # # patch "sqlite/vtab.c" # from [24d7b1507a744f3f06b279a874f353548d798f34] # to [89a0d5f39c1beba65a77fdb4d507b831fc5e6baf] # # patch "sqlite/where.c" # from [fce0dad6b230eb7ea844e8b8667c074d07e3fdd5] # to [0f17b7bed2ce50ba450e8f436d5ec8b420c4ab3f] # ============================================================ --- sqlite/btree.c 2023a8371bd23c300571a4ce9673b8859c44be36 +++ sqlite/btree.c 960bf64baa4d2bdb96019698e60d0b7763bf4e7e @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.355 2007/04/13 02:14:30 drh Exp $ +** $Id: btree.c,v 1.358 2007/04/24 17:35:59 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to @@ -1870,7 +1870,10 @@ static int lockBtree(BtShared *pBt){ if( memcmp(page1, zMagicHeader, 16)!=0 ){ goto page1_init_failed; } - if( page1[18]>1 || page1[19]>1 ){ + if( page1[18]>1 ){ + pBt->readOnly = 1; + } + if( page1[19]>1 ){ goto page1_init_failed; } pageSize = get2byte(&page1[16]); @@ -2068,11 +2071,15 @@ int sqlite3BtreeBeginTrans(Btree *p, int if( pBt->pPage1==0 ){ rc = lockBtree(pBt); } - + if( rc==SQLITE_OK && wrflag ){ - rc = sqlite3PagerBegin(pBt->pPage1->pDbPage, wrflag>1); - if( rc==SQLITE_OK ){ - rc = newDatabase(pBt); + if( pBt->readOnly ){ + rc = SQLITE_READONLY; + }else{ + rc = sqlite3PagerBegin(pBt->pPage1->pDbPage, wrflag>1); + if( rc==SQLITE_OK ){ + rc = newDatabase(pBt); + } } } @@ -2782,6 +2789,9 @@ int sqlite3BtreeCursor( if( rc!=SQLITE_OK ){ return rc; } + if( pBt->readOnly && wrFlag ){ + return SQLITE_READONLY; + } } pCur = sqliteMalloc( sizeof(*pCur) ); if( pCur==0 ){ @@ -3519,26 +3529,22 @@ int sqlite3BtreeNext(BtCursor *pCur, int int rc; MemPage *pPage; -#ifndef SQLITE_OMIT_SHARED_CACHE rc = restoreOrClearCursorPosition(pCur); if( rc!=SQLITE_OK ){ return rc; } -#endif assert( pRes!=0 ); pPage = pCur->pPage; if( CURSOR_INVALID==pCur->eState ){ *pRes = 1; return SQLITE_OK; } -#ifndef SQLITE_OMIT_SHARED_CACHE if( pCur->skip>0 ){ pCur->skip = 0; *pRes = 0; return SQLITE_OK; } pCur->skip = 0; -#endif assert( pPage->isInit ); assert( pCur->idxnCell ); @@ -3589,24 +3595,20 @@ int sqlite3BtreePrevious(BtCursor *pCur, Pgno pgno; MemPage *pPage; -#ifndef SQLITE_OMIT_SHARED_CACHE rc = restoreOrClearCursorPosition(pCur); if( rc!=SQLITE_OK ){ return rc; } -#endif if( CURSOR_INVALID==pCur->eState ){ *pRes = 1; return SQLITE_OK; } -#ifndef SQLITE_OMIT_SHARED_CACHE if( pCur->skip<0 ){ pCur->skip = 0; *pRes = 0; return SQLITE_OK; } pCur->skip = 0; -#endif pPage = pCur->pPage; assert( pPage->isInit ); ============================================================ --- sqlite/expr.c 2c32c546006627d70a7b941b318489980fd1912e +++ sqlite/expr.c 2f0f9f89efe9170e5e6ca5d5e93a9d5896fff5ac @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.284 2007/04/13 16:06:33 drh Exp $ +** $Id: expr.c,v 1.285 2007/04/18 17:07:58 drh Exp $ */ #include "sqliteInt.h" #include @@ -237,12 +237,12 @@ Expr *sqlite3Expr(int op, Expr *pLeft, E }else if( pLeft ){ if( pRight ){ sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span); - if( pRight->flags && EP_ExpCollate ){ + if( pRight->flags & EP_ExpCollate ){ pNew->flags |= EP_ExpCollate; pNew->pColl = pRight->pColl; } } - if( pLeft->flags && EP_ExpCollate ){ + if( pLeft->flags & EP_ExpCollate ){ pNew->flags |= EP_ExpCollate; pNew->pColl = pLeft->pColl; } ============================================================ --- sqlite/legacy.c 2631df6a861f830d6b1c0fe92b9fdd745b2c0cd6 +++ sqlite/legacy.c c05a599a37f703ed1e66fdb5df60c2db65f29e71 @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: legacy.c,v 1.16 2006/09/15 07:28:50 drh Exp $ +** $Id: legacy.c,v 1.17 2007/04/25 11:28:17 drh Exp $ */ #include "sqliteInt.h" @@ -44,7 +44,6 @@ int sqlite3_exec( char **azCols = 0; int nRetry = 0; - int nChange = 0; int nCallback; if( zSql==0 ) return SQLITE_OK; @@ -64,7 +63,6 @@ int sqlite3_exec( continue; } - db->nChange += nChange; nCallback = 0; nCol = sqlite3_column_count(pStmt); @@ -101,9 +99,6 @@ int sqlite3_exec( if( rc!=SQLITE_ROW ){ rc = sqlite3_finalize(pStmt); pStmt = 0; - if( db->pVdbe==0 ){ - nChange = db->nChange; - } if( rc!=SQLITE_SCHEMA ){ nRetry = 0; zSql = zLeftover; ============================================================ --- sqlite/loadext.c 146fb9b9dc6133e763888d710205c32ebf8eeca2 +++ sqlite/loadext.c afe4f4755dc49c36ef505748bbdddecb9f1d02a2 @@ -37,28 +37,32 @@ #endif #ifdef SQLITE_OMIT_AUTHORIZATION -# define sqlite3_set_authorizer 0 +# define sqlite3_set_authorizer 0 #endif #ifdef SQLITE_OMIT_UTF16 -# define sqlite3_bind_text16 0 -# define sqlite3_collation_needed16 0 -# define sqlite3_column_decltype16 0 -# define sqlite3_column_name16 0 -# define sqlite3_column_text16 0 -# define sqlite3_complete16 0 -# define sqlite3_create_collation16 0 -# define sqlite3_create_function16 0 -# define sqlite3_errmsg16 0 -# define sqlite3_open16 0 -# define sqlite3_prepare16 0 -# define sqlite3_result_error16 0 -# define sqlite3_result_text16 0 -# define sqlite3_result_text16be 0 -# define sqlite3_result_text16le 0 -# define sqlite3_value_text16 0 -# define sqlite3_value_text16be 0 -# define sqlite3_value_text16le 0 +# define sqlite3_bind_text16 0 +# define sqlite3_collation_needed16 0 +# define sqlite3_column_decltype16 0 +# define sqlite3_column_name16 0 +# define sqlite3_column_text16 0 +# define sqlite3_complete16 0 +# define sqlite3_create_collation16 0 +# define sqlite3_create_function16 0 +# define sqlite3_errmsg16 0 +# define sqlite3_open16 0 +# define sqlite3_prepare16 0 +# define sqlite3_prepare16_v2 0 +# define sqlite3_result_error16 0 +# define sqlite3_result_text16 0 +# define sqlite3_result_text16be 0 +# define sqlite3_result_text16le 0 +# define sqlite3_value_text16 0 +# define sqlite3_value_text16be 0 +# define sqlite3_value_text16le 0 +# define sqlite3_column_database_name16 0 +# define sqlite3_column_table_name16 0 +# define sqlite3_column_origin_name16 0 #endif #ifdef SQLITE_OMIT_COMPLETE ============================================================ --- sqlite/prepare.c 37207b2b2ccb41d379b01dd62231686bcc48ef1f +++ sqlite/prepare.c 4cb9c9eb926e8baf5652ca4b4f2416f53f5b5370 @@ -13,7 +13,7 @@ ** interface, and routines that contribute to loading the database schema ** from disk. ** -** $Id: prepare.c,v 1.45 2007/03/26 22:05:02 drh Exp $ +** $Id: prepare.c,v 1.46 2007/04/19 11:09:01 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -537,13 +537,15 @@ int sqlite3Prepare( if( sqlite3SafetyOff(db) ){ rc = SQLITE_MISUSE; } - if( rc==SQLITE_OK ){ - if( saveSqlFlag ){ - sqlite3VdbeSetSql(sParse.pVdbe, zSql, sParse.zTail - zSql); - } - *ppStmt = (sqlite3_stmt*)sParse.pVdbe; - }else if( sParse.pVdbe ){ + + if( saveSqlFlag ){ + sqlite3VdbeSetSql(sParse.pVdbe, zSql, sParse.zTail - zSql); + } + if( rc!=SQLITE_OK || sqlite3MallocFailed() ){ sqlite3_finalize((sqlite3_stmt*)sParse.pVdbe); + assert(!(*ppStmt)); + }else{ + *ppStmt = (sqlite3_stmt*)sParse.pVdbe; } if( zErrMsg ){ ============================================================ --- sqlite/sqlite3.h 2f5f4c4929cbb430496c3338bca309d0f2b9d980 +++ sqlite/sqlite3.h 6dcafd84bc51a2510ec2d8ef94f024d36b0e1a00 @@ -31,7 +31,7 @@ extern "C" { #ifdef SQLITE_VERSION # undef SQLITE_VERSION #endif -#define SQLITE_VERSION "3.3.16" +#define SQLITE_VERSION "3.3.17" /* ** The format of the version string is "X.Y.Z", where @@ -48,7 +48,7 @@ extern "C" { #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif -#define SQLITE_VERSION_NUMBER 3003016 +#define SQLITE_VERSION_NUMBER 3003017 /* ** The version string is also compiled into the library so that a program ============================================================ --- sqlite/vdbe.c cf7808e8db2e5d1547e898ce29531295183ede6e +++ sqlite/vdbe.c 814dab208a156250bc5e77f827f4e0c8ad734820 @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.600 2007/04/17 08:32:34 danielk1977 Exp $ +** $Id: vdbe.c,v 1.601 2007/04/18 16:45:24 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -2369,7 +2369,11 @@ case OP_AutoCommit: { /* no-push * return SQLITE_BUSY; } } - return SQLITE_DONE; + if( p->rc==SQLITE_OK ){ + return SQLITE_DONE; + }else{ + return SQLITE_ERROR; + } }else{ sqlite3SetString(&p->zErrMsg, (!i)?"cannot start a transaction within a transaction":( ============================================================ --- sqlite/vtab.c 24d7b1507a744f3f06b279a874f353548d798f34 +++ sqlite/vtab.c 89a0d5f39c1beba65a77fdb4d507b831fc5e6baf @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to help implement virtual tables. ** -** $Id: vtab.c,v 1.42 2007/04/18 14:24:34 danielk1977 Exp $ +** $Id: vtab.c,v 1.45 2007/04/19 14:48:37 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_VIRTUALTABLE #include "sqliteInt.h" @@ -132,10 +132,12 @@ void sqlite3VtabBeginParse( int iDb; /* The database the table is being created in */ Table *pTable; /* The new virtual table */ +#ifndef SQLITE_OMIT_SHARED_CACHE if( sqlite3ThreadDataReadOnly()->useSharedData ){ sqlite3ErrorMsg(pParse, "Cannot use virtual tables in shared-cache mode"); return; } +#endif sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, 0); pTable = pParse->pNewTable; @@ -531,16 +533,18 @@ static void callFinaliser(sqlite3 *db, i */ static void callFinaliser(sqlite3 *db, int offset){ int i; - for(i=0; inVTrans && db->aVTrans[i]; i++){ - sqlite3_vtab *pVtab = db->aVTrans[i]; - int (*x)(sqlite3_vtab *); - x = *(int (**)(sqlite3_vtab *))((char *)pVtab->pModule + offset); - if( x ) x(pVtab); - sqlite3VtabUnlock(db, pVtab); + if( db->aVTrans ){ + for(i=0; inVTrans && db->aVTrans[i]; i++){ + sqlite3_vtab *pVtab = db->aVTrans[i]; + int (*x)(sqlite3_vtab *); + x = *(int (**)(sqlite3_vtab *))((char *)pVtab->pModule + offset); + if( x ) x(pVtab); + sqlite3VtabUnlock(db, pVtab); + } + sqliteFree(db->aVTrans); + db->nVTrans = 0; + db->aVTrans = 0; } - sqliteFree(db->aVTrans); - db->nVTrans = 0; - db->aVTrans = 0; } /* ============================================================ --- sqlite/where.c fce0dad6b230eb7ea844e8b8667c074d07e3fdd5 +++ sqlite/where.c 0f17b7bed2ce50ba450e8f436d5ec8b420c4ab3f @@ -16,7 +16,7 @@ ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** -** $Id: where.c,v 1.246 2007/04/06 01:04:40 drh Exp $ +** $Id: where.c,v 1.247 2007/04/20 12:22:02 drh Exp $ */ #include "sqliteInt.h" @@ -26,11 +26,6 @@ #define BMS (sizeof(Bitmask)*8) /* -** Determine the number of elements in an array. -*/ -#define ARRAYSIZE(X) (sizeof(X)/sizeof(X[0])) - -/* ** Trace output macros */ #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) @@ -195,7 +190,7 @@ static void whereClauseInit( pWC->pParse = pParse; pWC->pMaskSet = pMaskSet; pWC->nTerm = 0; - pWC->nSlot = ARRAYSIZE(pWC->aStatic); + pWC->nSlot = ArraySize(pWC->aStatic); pWC->a = pWC->aStatic; } @@ -310,7 +305,7 @@ static void createMask(ExprMaskSet *pMas ** array will never overflow. */ static void createMask(ExprMaskSet *pMaskSet, int iCursor){ - assert( pMaskSet->n < ARRAYSIZE(pMaskSet->ix) ); + assert( pMaskSet->n < ArraySize(pMaskSet->ix) ); pMaskSet->ix[pMaskSet->n++] = iCursor; }