# # patch "ChangeLog" # from [0d0d192fb860b82bf2e1dbcd49ab0c66083de496] # to [761dabbd4c8dd35b2910a18ca311488514961a04] # # patch "sqlite/analyze.c" # from [43a2d91242bdd71b6c299378f6b11e896ee5e43d] # to [21a4cd125bedd3cb15857595c45c2a49c0556d26] # # patch "sqlite/build.c" # from [74653e045581bfbadb8b35a0cb38a62f4a2c850e] # to [aa9591839c00731370c1ba53a9c0045f70d764c4] # # patch "sqlite/delete.c" # from [16a0e19460b14d219f39ff5c7a9eef808aa1969c] # to [29dac493f4d83b05f91233b116827c133bcdab72] # # patch "sqlite/expr.c" # from [b8dbd5a30e80b83b0c1e137dcfcd687bd5d2b76c] # to [bb2cf5d5b065eaa23d5ae2620f6de0568768147d] # # patch "sqlite/insert.c" # from [484c73bc1309f283a31baa0e114f3ee980536397] # to [1f51566d7cf4b243a2792f5fda37343d6e9377fa] # # patch "sqlite/opcodes.c" # from [8b23c96979492cba740a2e3c67f6646e8b323b12] # to [9855bca95408a841cfbeb92135596bc18d7c034a] # # patch "sqlite/opcodes.h" # from [1848e78f249e09e0b773754679d6584412f8900f] # to [9918b6dfce41b2465940c5f6631afd418584dfb3] # # patch "sqlite/os_unix.c" # from [c86cf43b7ca9200e6fb7bc202ad2cc7da2f69367] # to [407dd07818d13807c396acf3f7570af81cbb666c] # # patch "sqlite/os_win.c" # from [ed03a35b2894f9b99840415f941a9f8594dea756] # to [fbccc85e7011174068c27d54256746321a1f0059] # # patch "sqlite/pager.h" # from [17b13225abd93c1e9f470060f40a21b9edb5a164] # to [e7b41ce8e7b5f629d456708b7ad9a8c8ede37140] # # patch "sqlite/pragma.c" # from [6d773e25e8af13ef0820531ad2793417f8a8959d] # to [126149668aa7086e86cfa3e32c8523513c19dd63] # # patch "sqlite/select.c" # from [9ef1dddd436e1ea86a6bf64ae0ed71bf4a0b894f] # to [034c7f7447b8711f85bef578a437ea12ca7cac53] # # patch "sqlite/sqlite3.h" # from [d1ab08a3d92270801782adad0dad0f31d6df7761] # to [2c4119e974bd9182eb3597fbd6343c5e1c4bcb74] # # patch "sqlite/sqliteInt.h" # from [e78a7c53a97a2e5d8d6370b6836b2921124ac26f] # to [0606b9cc31efabadf5b3d40478c193fa89fa6662] # # patch "sqlite/update.c" # from [c2716c2115533ffae3d08bf8853aaba4f970f37e] # to [ac506fb7400158f826ec6c3a0dbe65e7ed3928d5] # # patch "sqlite/vdbe.c" # from [de007d59f036fcd1b89a7d4172aa0d028e8689eb] # to [3f1adcf4535dd35e4244d19d332fb6b515491c0d] # # patch "sqlite/vdbe.h" # from [c8e105979fc7aaf5b8004e9621904e3bd096dfa2] # to [8729a4ee16ff9aeab2af9667df3cf300ff978e13] # # patch "sqlite/vdbeInt.h" # from [3dd2a29c7b0a55404c35f93caae81fb42f4cb70a] # to [7bedbb9553a10e86b53f75d99e197f3f00a732bf] # # patch "sqlite/vdbeaux.c" # from [57a6ced8417bdc6f06c391d9c560ecbbed644ef3] # to [2b728d82cf2095386a90051b66e7faf1a143f27d] # # patch "sqlite/vdbemem.c" # from [fea0744936008831daa17cdc75056c3ca1469690] # to [ff426ff6e72aa3f0300a56ec8c7f18099be96b43] # # patch "sqlite/where.c" # from [1cc55c9aa142c7ef09b427f5fd0bf0488e365fc4] # to [3ed72ca029b3010a76e3a41b7b02ec1bdf849f00] # ======================================================================== --- ChangeLog 0d0d192fb860b82bf2e1dbcd49ab0c66083de496 +++ ChangeLog 761dabbd4c8dd35b2910a18ca311488514961a04 @@ -1,3 +1,7 @@ +2005-09-25 Matthew Gregan + + * sqlite/*: Update in-tree SQLite from 3.2.6 to 3.2.7. + 2005-09-25 Matt Johnston * ui.cc: fallback to the default locale if locale("") fails. ======================================================================== --- sqlite/analyze.c 43a2d91242bdd71b6c299378f6b11e896ee5e43d +++ sqlite/analyze.c 21a4cd125bedd3cb15857595c45c2a49c0556d26 @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code associated with the ANALYZE command. ** -** @(#) $Id: analyze.c,v 1.8 2005/09/10 22:40:54 drh Exp $ +** @(#) $Id: analyze.c,v 1.9 2005/09/20 17:42:23 drh Exp $ */ #ifndef SQLITE_OMIT_ANALYZE #include "sqliteInt.h" @@ -127,13 +127,11 @@ ** Cells iMem through iMem+nCol are initialized to 0. The others ** are initialized to NULL. */ - sqlite3VdbeAddOp(v, OP_Integer, 0, 0); for(i=0; i<=nCol; i++){ - sqlite3VdbeAddOp(v, OP_MemStore, iMem+i, i==nCol); + sqlite3VdbeAddOp(v, OP_MemInt, 0, iMem+i); } - sqlite3VdbeAddOp(v, OP_Null, 0, 0); for(i=0; i @@ -76,7 +76,7 @@ if( pParse->cookieGoto>0 ){ u32 mask; int iDb; - sqlite3VdbeChangeP2(v, pParse->cookieGoto-1, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, pParse->cookieGoto-1); for(iDb=0, mask=1; iDbnDb; mask<<=1, iDb++){ if( (mask & pParse->cookieMask)==0 ) continue; sqlite3VdbeAddOp(v, OP_Transaction, iDb, (mask & pParse->writeMask)!=0); @@ -2002,7 +2002,7 @@ } sqlite3VdbeAddOp(v, OP_IdxInsert, iIdx, 0); sqlite3VdbeAddOp(v, OP_Next, iTab, addr1+1); - sqlite3VdbeChangeP2(v, addr1, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, addr1); sqlite3VdbeAddOp(v, OP_Close, iTab, 0); sqlite3VdbeAddOp(v, OP_Close, iIdx, 0); } ======================================================================== --- sqlite/delete.c 16a0e19460b14d219f39ff5c7a9eef808aa1969c +++ sqlite/delete.c 29dac493f4d83b05f91233b116827c133bcdab72 @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** in order to generate code for DELETE FROM statements. ** -** $Id: delete.c,v 1.110 2005/09/08 01:58:43 drh Exp $ +** $Id: delete.c,v 1.111 2005/09/20 17:42:23 drh Exp $ */ #include "sqliteInt.h" @@ -380,7 +380,7 @@ addr = sqlite3VdbeAddOp(v, OP_NotExists, iCur, 0); sqlite3GenerateRowIndexDelete(db, v, pTab, iCur, 0); sqlite3VdbeAddOp(v, OP_Delete, iCur, (count?OPFLAG_NCHANGE:0)); - sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, addr); } /* ======================================================================== --- sqlite/expr.c b8dbd5a30e80b83b0c1e137dcfcd687bd5d2b76c +++ sqlite/expr.c bb2cf5d5b065eaa23d5ae2620f6de0568768147d @@ -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.228 2005/09/16 02:38:10 drh Exp $ +** $Id: expr.c,v 1.230 2005/09/23 21:11:54 drh Exp $ */ #include "sqliteInt.h" #include @@ -548,6 +548,8 @@ pNew->iOffset = -1; pNew->isResolved = p->isResolved; pNew->isAgg = p->isAgg; + pNew->usesVirt = 0; + pNew->disallowOrderBy = 0; pNew->pRightmost = 0; pNew->addrOpenVirt[0] = -1; pNew->addrOpenVirt[1] = -1; @@ -1292,8 +1294,7 @@ sqlite3VdbeAddOp(v, OP_MemLoad, mem, 0); testAddr = sqlite3VdbeAddOp(v, OP_If, 0, 0); assert( testAddr>0 || sqlite3_malloc_failed ); - sqlite3VdbeAddOp(v, OP_Integer, 1, 0); - sqlite3VdbeAddOp(v, OP_MemStore, mem, 1); + sqlite3VdbeAddOp(v, OP_MemInt, 1, mem); } switch( pExpr->op ){ @@ -1367,7 +1368,7 @@ if( testAddr>0 && !sqlite3ExprIsConstant(pE2) ){ VdbeOp *aOp = sqlite3VdbeGetOp(v, testAddr-1); int i; - for(i=0; i<4; i++){ + for(i=0; i<3; i++){ aOp[i].opcode = OP_Noop; } testAddr = 0; @@ -1409,7 +1410,7 @@ } if( testAddr ){ - sqlite3VdbeChangeP2(v, testAddr, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, testAddr); } return; } @@ -1709,7 +1710,6 @@ case TK_CASE: { int expr_end_label; int jumpInst; - int addr; int nExpr; int i; ExprList *pEList; @@ -1737,8 +1737,7 @@ } sqlite3ExprCode(pParse, aListelem[i+1].pExpr); sqlite3VdbeAddOp(v, OP_Goto, 0, expr_end_label); - addr = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeChangeP2(v, jumpInst, addr); + sqlite3VdbeJumpHere(v, jumpInst); } if( pExpr->pLeft ){ sqlite3VdbeAddOp(v, OP_Pop, 1, 0); @@ -1905,7 +1904,7 @@ codeCompare(pParse, pLeft, pRight, OP_Le, dest, jumpIfNull); sqlite3VdbeAddOp(v, OP_Integer, 0, 0); - sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, addr); sqlite3VdbeAddOp(v, OP_Pop, 1, 0); break; } ======================================================================== --- sqlite/insert.c 484c73bc1309f283a31baa0e114f3ee980536397 +++ sqlite/insert.c 1f51566d7cf4b243a2792f5fda37343d6e9377fa @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** -** $Id: insert.c,v 1.142 2005/07/21 18:23:20 drh Exp $ +** $Id: insert.c,v 1.143 2005/09/20 17:42:23 drh Exp $ */ #include "sqliteInt.h" @@ -372,13 +372,13 @@ ** of the program jumps to it. Create the temporary table, then jump ** back up and execute the SELECT code above. */ - sqlite3VdbeChangeP2(v, iInitCode, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, iInitCode); sqlite3VdbeAddOp(v, OP_OpenVirtual, srcTab, 0); sqlite3VdbeAddOp(v, OP_SetNumColumns, srcTab, nColumn); sqlite3VdbeAddOp(v, OP_Goto, 0, iSelectLoop); sqlite3VdbeResolveLabel(v, iCleanup); }else{ - sqlite3VdbeChangeP2(v, iInitCode, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, iInitCode); } }else{ /* This is the case if the data for the INSERT is coming from a VALUES @@ -470,8 +470,7 @@ */ if( db->flags & SQLITE_CountRows ){ iCntMem = pParse->nMem++; - sqlite3VdbeAddOp(v, OP_Integer, 0, 0); - sqlite3VdbeAddOp(v, OP_MemStore, iCntMem, 1); + sqlite3VdbeAddOp(v, OP_MemInt, 0, iCntMem); } /* Open tables and indices if there are no row triggers */ @@ -817,7 +816,6 @@ Index *pIdx; int seenReplace = 0; int jumpInst1=0, jumpInst2; - int contAddr; int hasTwoRowids = (isUpdate && rowidChng); v = sqlite3GetVdbe(pParse); @@ -867,7 +865,7 @@ break; } } - sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, addr); } /* Test all CHECK constraints @@ -921,10 +919,9 @@ break; } } - contAddr = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeChangeP2(v, jumpInst2, contAddr); + sqlite3VdbeJumpHere(v, jumpInst2); if( isUpdate ){ - sqlite3VdbeChangeP2(v, jumpInst1, contAddr); + sqlite3VdbeJumpHere(v, jumpInst1); sqlite3VdbeAddOp(v, OP_Dup, nCol+1, 1); sqlite3VdbeAddOp(v, OP_MoveGe, base, 0); } @@ -1018,11 +1015,10 @@ break; } } - contAddr = sqlite3VdbeCurrentAddr(v); #if NULL_DISTINCT_FOR_UNIQUE - sqlite3VdbeChangeP2(v, jumpInst1, contAddr); + sqlite3VdbeJumpHere(v, jumpInst1); #endif - sqlite3VdbeChangeP2(v, jumpInst2, contAddr); + sqlite3VdbeJumpHere(v, jumpInst2); } } ======================================================================== --- sqlite/opcodes.c 8b23c96979492cba740a2e3c67f6646e8b323b12 +++ sqlite/opcodes.c 9855bca95408a841cfbeb92135596bc18d7c034a @@ -46,34 +46,34 @@ /* 42 */ "Gosub", /* 43 */ "Integer", /* 44 */ "ToNumeric", - /* 45 */ "Prev", - /* 46 */ "CreateTable", - /* 47 */ "Last", - /* 48 */ "IdxRowid", - /* 49 */ "MakeIdxRec", - /* 50 */ "ResetCount", - /* 51 */ "FifoWrite", - /* 52 */ "Callback", - /* 53 */ "ContextPush", - /* 54 */ "DropTrigger", - /* 55 */ "DropIndex", - /* 56 */ "IdxGE", - /* 57 */ "IdxDelete", - /* 58 */ "Vacuum", - /* 59 */ "MoveLe", - /* 60 */ "IfNot", - /* 61 */ "DropTable", - /* 62 */ "MakeRecord", - /* 63 */ "ToBlob", - /* 64 */ "Delete", - /* 65 */ "AggFinal", - /* 66 */ "Dup", + /* 45 */ "MemInt", + /* 46 */ "Prev", + /* 47 */ "CreateTable", + /* 48 */ "Last", + /* 49 */ "IdxRowid", + /* 50 */ "MakeIdxRec", + /* 51 */ "ResetCount", + /* 52 */ "FifoWrite", + /* 53 */ "Callback", + /* 54 */ "ContextPush", + /* 55 */ "DropTrigger", + /* 56 */ "DropIndex", + /* 57 */ "IdxGE", + /* 58 */ "IdxDelete", + /* 59 */ "Vacuum", + /* 60 */ "MoveLe", + /* 61 */ "IfNot", + /* 62 */ "DropTable", + /* 63 */ "MakeRecord", + /* 64 */ "ToBlob", + /* 65 */ "Delete", + /* 66 */ "AggFinal", /* 67 */ "Or", /* 68 */ "And", /* 69 */ "Not", - /* 70 */ "Goto", - /* 71 */ "FifoRead", - /* 72 */ "Clear", + /* 70 */ "Dup", + /* 71 */ "Goto", + /* 72 */ "FifoRead", /* 73 */ "IsNull", /* 74 */ "NotNull", /* 75 */ "Ne", @@ -82,7 +82,7 @@ /* 78 */ "Le", /* 79 */ "Lt", /* 80 */ "Ge", - /* 81 */ "IdxGT", + /* 81 */ "Clear", /* 82 */ "BitAnd", /* 83 */ "BitOr", /* 84 */ "ShiftLeft", @@ -94,38 +94,38 @@ /* 90 */ "Remainder", /* 91 */ "Concat", /* 92 */ "Negative", - /* 93 */ "MoveLt", + /* 93 */ "IdxGT", /* 94 */ "BitNot", /* 95 */ "String8", - /* 96 */ "VerifyCookie", - /* 97 */ "AggStep", - /* 98 */ "Pull", - /* 99 */ "ToText", - /* 100 */ "SetNumColumns", - /* 101 */ "AbsValue", - /* 102 */ "Transaction", - /* 103 */ "ContextPop", - /* 104 */ "Next", - /* 105 */ "IdxInsert", - /* 106 */ "Distinct", - /* 107 */ "Insert", - /* 108 */ "Destroy", - /* 109 */ "ReadCookie", - /* 110 */ "ForceInt", - /* 111 */ "LoadAnalysis", - /* 112 */ "OpenVirtual", - /* 113 */ "Explain", - /* 114 */ "OpenPseudo", - /* 115 */ "Null", - /* 116 */ "Blob", - /* 117 */ "MemStore", - /* 118 */ "Rewind", - /* 119 */ "MoveGe", - /* 120 */ "Found", - /* 121 */ "NullRow", - /* 122 */ "NotUsed_122", - /* 123 */ "NotUsed_123", - /* 124 */ "NotUsed_124", + /* 96 */ "MoveLt", + /* 97 */ "VerifyCookie", + /* 98 */ "AggStep", + /* 99 */ "Pull", + /* 100 */ "ToText", + /* 101 */ "SetNumColumns", + /* 102 */ "AbsValue", + /* 103 */ "Transaction", + /* 104 */ "ContextPop", + /* 105 */ "Next", + /* 106 */ "IdxInsert", + /* 107 */ "Distinct", + /* 108 */ "Insert", + /* 109 */ "Destroy", + /* 110 */ "ReadCookie", + /* 111 */ "ForceInt", + /* 112 */ "LoadAnalysis", + /* 113 */ "OpenVirtual", + /* 114 */ "Explain", + /* 115 */ "OpenPseudo", + /* 116 */ "Null", + /* 117 */ "Blob", + /* 118 */ "MemStore", + /* 119 */ "Rewind", + /* 120 */ "MoveGe", + /* 121 */ "MemMove", + /* 122 */ "MemNull", + /* 123 */ "Found", + /* 124 */ "NullRow", /* 125 */ "NotUsed_125", /* 126 */ "NotUsed_126", /* 127 */ "NotUsed_127", ======================================================================== --- sqlite/opcodes.h 1848e78f249e09e0b773754679d6584412f8900f +++ sqlite/opcodes.h 9918b6dfce41b2465940c5f6631afd418584dfb3 @@ -57,77 +57,77 @@ #define OP_Divide 89 /* same as TK_SLASH */ #define OP_Integer 43 #define OP_ToNumeric 44 -#define OP_Prev 45 +#define OP_MemInt 45 +#define OP_Prev 46 #define OP_Concat 91 /* same as TK_CONCAT */ #define OP_BitAnd 82 /* same as TK_BITAND */ -#define OP_CreateTable 46 -#define OP_Last 47 +#define OP_CreateTable 47 +#define OP_Last 48 #define OP_IsNull 73 /* same as TK_ISNULL */ -#define OP_IdxRowid 48 -#define OP_MakeIdxRec 49 +#define OP_IdxRowid 49 +#define OP_MakeIdxRec 50 #define OP_ShiftRight 85 /* same as TK_RSHIFT */ -#define OP_ResetCount 50 -#define OP_FifoWrite 51 -#define OP_Callback 52 -#define OP_ContextPush 53 -#define OP_DropTrigger 54 -#define OP_DropIndex 55 -#define OP_IdxGE 56 -#define OP_IdxDelete 57 -#define OP_Vacuum 58 -#define OP_MoveLe 59 -#define OP_IfNot 60 -#define OP_DropTable 61 -#define OP_MakeRecord 62 -#define OP_ToBlob 63 -#define OP_Delete 64 -#define OP_AggFinal 65 +#define OP_ResetCount 51 +#define OP_FifoWrite 52 +#define OP_Callback 53 +#define OP_ContextPush 54 +#define OP_DropTrigger 55 +#define OP_DropIndex 56 +#define OP_IdxGE 57 +#define OP_IdxDelete 58 +#define OP_Vacuum 59 +#define OP_MoveLe 60 +#define OP_IfNot 61 +#define OP_DropTable 62 +#define OP_MakeRecord 63 +#define OP_ToBlob 64 +#define OP_Delete 65 +#define OP_AggFinal 66 #define OP_ShiftLeft 84 /* same as TK_LSHIFT */ -#define OP_Dup 66 -#define OP_Goto 70 -#define OP_FifoRead 71 -#define OP_Clear 72 -#define OP_IdxGT 81 -#define OP_MoveLt 93 +#define OP_Dup 70 +#define OP_Goto 71 +#define OP_FifoRead 72 +#define OP_Clear 81 +#define OP_IdxGT 93 +#define OP_MoveLt 96 #define OP_Le 78 /* same as TK_LE */ -#define OP_VerifyCookie 96 -#define OP_AggStep 97 -#define OP_Pull 98 -#define OP_ToText 99 +#define OP_VerifyCookie 97 +#define OP_AggStep 98 +#define OP_Pull 99 +#define OP_ToText 100 #define OP_Not 69 /* same as TK_NOT */ -#define OP_SetNumColumns 100 -#define OP_AbsValue 101 -#define OP_Transaction 102 +#define OP_SetNumColumns 101 +#define OP_AbsValue 102 +#define OP_Transaction 103 #define OP_Negative 92 /* same as TK_UMINUS */ #define OP_Ne 75 /* same as TK_NE */ -#define OP_ContextPop 103 +#define OP_ContextPop 104 #define OP_BitOr 83 /* same as TK_BITOR */ -#define OP_Next 104 -#define OP_IdxInsert 105 -#define OP_Distinct 106 +#define OP_Next 105 +#define OP_IdxInsert 106 +#define OP_Distinct 107 #define OP_Lt 79 /* same as TK_LT */ -#define OP_Insert 107 -#define OP_Destroy 108 -#define OP_ReadCookie 109 -#define OP_ForceInt 110 -#define OP_LoadAnalysis 111 -#define OP_OpenVirtual 112 -#define OP_Explain 113 -#define OP_OpenPseudo 114 -#define OP_Null 115 -#define OP_Blob 116 +#define OP_Insert 108 +#define OP_Destroy 109 +#define OP_ReadCookie 110 +#define OP_ForceInt 111 +#define OP_LoadAnalysis 112 +#define OP_OpenVirtual 113 +#define OP_Explain 114 +#define OP_OpenPseudo 115 +#define OP_Null 116 +#define OP_Blob 117 #define OP_Add 86 /* same as TK_PLUS */ -#define OP_MemStore 117 -#define OP_Rewind 118 -#define OP_MoveGe 119 +#define OP_MemStore 118 +#define OP_Rewind 119 +#define OP_MoveGe 120 #define OP_BitNot 94 /* same as TK_BITNOT */ -#define OP_Found 120 -#define OP_NullRow 121 +#define OP_MemMove 121 +#define OP_MemNull 122 +#define OP_Found 123 +#define OP_NullRow 124 /* The following opcode values are never used */ -#define OP_NotUsed_122 122 -#define OP_NotUsed_123 123 -#define OP_NotUsed_124 124 #define OP_NotUsed_125 125 #define OP_NotUsed_126 126 #define OP_NotUsed_127 127 @@ -139,11 +139,11 @@ #define NOPUSH_MASK_0 65368 #define NOPUSH_MASK_1 47898 -#define NOPUSH_MASK_2 47069 -#define NOPUSH_MASK_3 49148 -#define NOPUSH_MASK_4 65403 +#define NOPUSH_MASK_2 22493 +#define NOPUSH_MASK_3 32761 +#define NOPUSH_MASK_4 65215 #define NOPUSH_MASK_5 30719 -#define NOPUSH_MASK_6 53215 -#define NOPUSH_MASK_7 997 +#define NOPUSH_MASK_6 40895 +#define NOPUSH_MASK_7 6603 #define NOPUSH_MASK_8 0 #define NOPUSH_MASK_9 0 ======================================================================== --- sqlite/os_unix.c c86cf43b7ca9200e6fb7bc202ad2cc7da2f69367 +++ sqlite/os_unix.c 407dd07818d13807c396acf3f7570af81cbb666c @@ -828,10 +828,13 @@ /* If the FULLSYNC failed, try to do a normal fsync() */ if( rc ) rc = fsync(fd); -#else +#else /* if !defined(F_FULLSYNC) */ +#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO>0 if( dataOnly ){ rc = fdatasync(fd); - }else{ + }else +#endif /* _POSIX_SYNCHRONIZED_IO > 0 */ + { rc = fsync(fd); } #endif /* defined(F_FULLFSYNC) */ ======================================================================== --- sqlite/os_win.c ed03a35b2894f9b99840415f941a9f8594dea756 +++ sqlite/os_win.c fbccc85e7011174068c27d54256746321a1f0059 @@ -466,6 +466,13 @@ } /* +** Some microsoft compilers lack this definition. +*/ +#ifndef INVALID_SET_FILE_POINTER +# define INVALID_SET_FILE_POINTER ((DWORD)-1) +#endif + +/* ** Move the read/write pointer in a file. */ int sqlite3OsSeek(OsFile *id, i64 offset){ ======================================================================== --- sqlite/pager.h 17b13225abd93c1e9f470060f40a21b9edb5a164 +++ sqlite/pager.h e7b41ce8e7b5f629d456708b7ad9a8c8ede37140 @@ -13,7 +13,7 @@ ** subsystem. The page cache subsystem reads and writes a file a page ** at a time and provides a journal for rollback. ** -** @(#) $Id: pager.h,v 1.45 2005/08/27 16:36:49 drh Exp $ +** @(#) $Id: pager.h,v 1.46 2005/09/19 19:05:21 drh Exp $ */ /* @@ -34,7 +34,7 @@ ** reasonable, like 1024. */ #ifndef SQLITE_MAX_PAGE_SIZE -# define SQLITE_MAX_PAGE_SIZE 8192 +# define SQLITE_MAX_PAGE_SIZE 32768 #endif /* ======================================================================== --- sqlite/pragma.c 6d773e25e8af13ef0820531ad2793417f8a8959d +++ sqlite/pragma.c 126149668aa7086e86cfa3e32c8523513c19dd63 @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.99 2005/09/17 16:36:56 drh Exp $ +** $Id: pragma.c,v 1.100 2005/09/20 17:42:23 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -626,14 +626,6 @@ if( sqlite3StrICmp(zLeft, "integrity_check")==0 ){ int i, j, addr; - /* Code that initializes the integrity check program. Set the - ** error count 0 - */ - static const VdbeOpList initCode[] = { - { OP_Integer, 0, 0, 0}, - { OP_MemStore, 0, 1, 0}, - }; - /* Code that appears at the end of the integrity check. If no error ** messages have been generated, output OK. Otherwise output the ** error message @@ -650,7 +642,7 @@ if( sqlite3ReadSchema(pParse) ) goto pragma_out; sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, "integrity_check", P3_STATIC); - sqlite3VdbeAddOpList(v, ArraySize(initCode), initCode); + sqlite3VdbeAddOp(v, OP_MemInt, 0, 0); /* Initialize error count to 0 */ /* Do an integrity check on each database file */ for(i=0; inDb; i++){ @@ -696,8 +688,7 @@ if( pTab->pIndex==0 ) continue; sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead); - sqlite3VdbeAddOp(v, OP_Integer, 0, 0); - sqlite3VdbeAddOp(v, OP_MemStore, 1, 1); + sqlite3VdbeAddOp(v, OP_MemInt, 0, 1); loopTop = sqlite3VdbeAddOp(v, OP_Rewind, 1, 0); sqlite3VdbeAddOp(v, OP_MemIncr, 1, 0); for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ @@ -715,39 +706,38 @@ jmp2 = sqlite3VdbeAddOp(v, OP_Found, j+2, 0); addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr); sqlite3VdbeChangeP3(v, addr+4, pIdx->zName, P3_STATIC); - sqlite3VdbeChangeP2(v, jmp2, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, jmp2); } sqlite3VdbeAddOp(v, OP_Next, 1, loopTop+1); - sqlite3VdbeChangeP2(v, loopTop, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, loopTop); for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ static const VdbeOpList cntIdx[] = { - { OP_Integer, 0, 0, 0}, - { OP_MemStore, 2, 1, 0}, - { OP_Rewind, 0, 0, 0}, /* 2 */ + { OP_MemInt, 0, 2, 0}, + { OP_Rewind, 0, 0, 0}, /* 1 */ { OP_MemIncr, 2, 0, 0}, - { OP_Next, 0, 0, 0}, /* 4 */ + { OP_Next, 0, 0, 0}, /* 3 */ { OP_MemLoad, 1, 0, 0}, { OP_MemLoad, 2, 0, 0}, - { OP_Eq, 0, 0, 0}, /* 7 */ + { OP_Eq, 0, 0, 0}, /* 6 */ { OP_MemIncr, 0, 0, 0}, { OP_String8, 0, 0, "wrong # of entries in index "}, - { OP_String8, 0, 0, 0}, /* 10 */ + { OP_String8, 0, 0, 0}, /* 9 */ { OP_Concat, 0, 0, 0}, { OP_Callback, 1, 0, 0}, }; if( pIdx->tnum==0 ) continue; addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx); - sqlite3VdbeChangeP1(v, addr+2, j+2); - sqlite3VdbeChangeP2(v, addr+2, addr+5); - sqlite3VdbeChangeP1(v, addr+4, j+2); - sqlite3VdbeChangeP2(v, addr+4, addr+3); - sqlite3VdbeChangeP2(v, addr+7, addr+ArraySize(cntIdx)); - sqlite3VdbeChangeP3(v, addr+10, pIdx->zName, P3_STATIC); + sqlite3VdbeChangeP1(v, addr+1, j+2); + sqlite3VdbeChangeP2(v, addr+1, addr+4); + sqlite3VdbeChangeP1(v, addr+3, j+2); + sqlite3VdbeChangeP2(v, addr+3, addr+2); + sqlite3VdbeJumpHere(v, addr+6); + sqlite3VdbeChangeP3(v, addr+9, pIdx->zName, P3_STATIC); } } } addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode); - sqlite3VdbeChangeP2(v, addr+2, addr+ArraySize(endCode)); + sqlite3VdbeJumpHere(v, addr+2); }else #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ ======================================================================== --- sqlite/select.c 9ef1dddd436e1ea86a6bf64ae0ed71bf4a0b894f +++ sqlite/select.c 034c7f7447b8711f85bef578a437ea12ca7cac53 @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.269 2005/09/12 23:03:17 drh Exp $ +** $Id: select.c,v 1.276 2005/09/20 18:13:24 drh Exp $ */ #include "sqliteInt.h" @@ -179,6 +179,7 @@ const char *zAlias1, /* Alias for first table. May be NULL */ const Table *pTab2, /* Second table */ const char *zAlias2, /* Alias for second table. May be NULL */ + int iRightJoinTable, /* VDBE cursor for the right table */ Expr **ppExpr /* Add the equality term to this expression */ ){ Expr *pE1a, *pE1b, *pE1c; @@ -199,11 +200,14 @@ pE2c = sqlite3Expr(TK_DOT, pE2b, pE2a, 0); pE = sqlite3Expr(TK_EQ, pE1c, pE2c, 0); ExprSetProperty(pE, EP_FromJoin); + pE->iRightJoinTable = iRightJoinTable; *ppExpr = sqlite3ExprAnd(*ppExpr, pE); } /* ** Set the EP_FromJoin property on all terms of the given expression. +** And set the Expr.iRightJoinTable to iTable for every term in the +** expression. ** ** The EP_FromJoin property is used on terms of an expression to tell ** the LEFT OUTER JOIN processing logic that this term is part of the @@ -211,11 +215,26 @@ ** of the more general WHERE clause. These terms are moved over to the ** WHERE clause during join processing but we need to remember that they ** originated in the ON or USING clause. +** +** The Expr.iRightJoinTable tells the WHERE clause processing that the +** expression depends on table iRightJoinTable even if that table is not +** explicitly mentioned in the expression. That information is needed +** for cases like this: +** +** SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5 +** +** The where clause needs to defer the handling of the t1.x=5 +** term until after the t2 loop of the join. In that way, a +** NULL t2 row will be inserted whenever t1.x!=5. If we do not +** defer the handling of t1.x=5, it will be processed immediately +** after the t1 loop and rows with t1.x!=5 will never appear in +** the output, which is incorrect. */ -static void setJoinExpr(Expr *p){ +static void setJoinExpr(Expr *p, int iTable){ while( p ){ ExprSetProperty(p, EP_FromJoin); - setJoinExpr(p->pLeft); + p->iRightJoinTable = iTable; + setJoinExpr(p->pLeft, iTable); p = p->pRight; } } @@ -262,7 +281,9 @@ char *zName = pLeftTab->aCol[j].zName; if( columnIndex(pRightTab, zName)>=0 ){ addWhereTerm(zName, pLeftTab, pLeft->zAlias, - pRightTab, pRight->zAlias, &p->pWhere); + pRightTab, pRight->zAlias, + pRight->iCursor, &p->pWhere); + } } } @@ -279,7 +300,7 @@ ** an AND operator. */ if( pLeft->pOn ){ - setJoinExpr(pLeft->pOn); + setJoinExpr(pLeft->pOn, pRight->iCursor); p->pWhere = sqlite3ExprAnd(p->pWhere, pLeft->pOn); pLeft->pOn = 0; } @@ -301,7 +322,8 @@ return 1; } addWhereTerm(zName, pLeftTab, pLeft->zAlias, - pRightTab, pRight->zAlias, &p->pWhere); + pRightTab, pRight->zAlias, + pRight->iCursor, &p->pWhere); } } } @@ -521,7 +543,7 @@ sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, &aff, 1); sqlite3VdbeAddOp(v, OP_IdxInsert, (iParm&0x0000FFFF), 0); } - sqlite3VdbeChangeP2(v, addr2, sqlite3VdbeCurrentAddr(v)); + sqlite3VdbeJumpHere(v, addr2); break; } @@ -1571,6 +1593,7 @@ } p->pPrior = 0; p->pOrderBy = 0; + p->disallowOrderBy = pOrderBy!=0; pLimit = p->pLimit; p->pLimit = 0; pOffset = p->pOffset; @@ -1786,6 +1809,7 @@ assert( p->addrOpenVirt[2]>=0 ); addr = p->addrOpenVirt[2]; sqlite3VdbeChangeP2(v, addr, p->pEList->nExpr+2); + pKeyInfo->nField = pOrderBy->nExpr; sqlite3VdbeChangeP3(v, addr, (char*)pKeyInfo, P3_KEYINFO_HANDOFF); pKeyInfo = 0; generateSortTail(pParse, p, v, p->pEList->nExpr, eDest, iParm); @@ -1970,7 +1994,7 @@ return 0; } if( p->isDistinct && subqueryIsAgg ) return 0; - if( p->pOrderBy && pSub->pOrderBy ) return 0; + if( (p->disallowOrderBy || p->pOrderBy) && pSub->pOrderBy ) return 0; /* Restriction 3: If the subquery is a join, make sure the subquery is ** not used as the right operand of an outer join. Examples of why this @@ -2424,17 +2448,15 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ Vdbe *v = pParse->pVdbe; int i; - int addr; struct AggInfo_func *pFunc; if( pAggInfo->nFunc+pAggInfo->nColumn==0 ){ return; } - sqlite3VdbeAddOp(v, OP_Null, 0, 0); for(i=0; inColumn; i++){ - addr = sqlite3VdbeAddOp(v, OP_MemStore, pAggInfo->aCol[i].iMem, 0); + sqlite3VdbeAddOp(v, OP_MemNull, pAggInfo->aCol[i].iMem, 0); } for(pFunc=pAggInfo->aFunc, i=0; inFunc; i++, pFunc++){ - addr = sqlite3VdbeAddOp(v, OP_MemStore, pFunc->iMem, 0); + sqlite3VdbeAddOp(v, OP_MemNull, pFunc->iMem, 0); if( pFunc->iDistinct>=0 ){ Expr *pE = pFunc->pExpr; if( pE->pList==0 || pE->pList->nExpr!=1 ){ @@ -2448,7 +2470,6 @@ } } } - sqlite3VdbeChangeP2(v, addr, 1); } /* @@ -2762,9 +2783,10 @@ /* Initialize the memory cell to NULL for SRT_Mem or 0 for SRT_Exists */ - if( eDest==SRT_Mem || eDest==SRT_Exists ){ - sqlite3VdbeAddOp(v, eDest==SRT_Mem ? OP_Null : OP_Integer, 0, 0); - sqlite3VdbeAddOp(v, OP_MemStore, iParm, 1); + if( eDest==SRT_Mem ){ + sqlite3VdbeAddOp(v, OP_MemNull, iParm, 0); + }else if( eDest==SRT_Exists ){ + sqlite3VdbeAddOp(v, OP_MemInt, 0, iParm); } /* Open a virtual index to use for the distinct set. @@ -2828,6 +2850,7 @@ int addrProcessRow; /* Code to process a single input row */ int addrEnd; /* End of all processing */ int addrSortingIdx; /* The OP_OpenVirtual for the sorting index */ + int addrReset; /* Subroutine for resetting the accumulator */ addrEnd = sqlite3VdbeMakeLabel(v); @@ -2891,11 +2914,10 @@ pParse->nMem += pGroupBy->nExpr; iBMem = pParse->nMem; pParse->nMem += pGroupBy->nExpr; - sqlite3VdbeAddOp(v, OP_Integer, 0, 0); - sqlite3VdbeAddOp(v, OP_MemStore, iAbortFlag, 0); - sqlite3VdbeAddOp(v, OP_MemStore, iUseFlag, 1); - sqlite3VdbeAddOp(v, OP_Null, 0, 0); - sqlite3VdbeAddOp(v, OP_MemStore, iAMem, 1); + sqlite3VdbeAddOp(v, OP_MemInt, 0, iAbortFlag); + VdbeComment((v, "# clear abort flag")); + sqlite3VdbeAddOp(v, OP_MemInt, 0, iUseFlag); + VdbeComment((v, "# indicate accumulator empty")); sqlite3VdbeAddOp(v, OP_Goto, 0, addrInitializeLoop); /* Generate a subroutine that outputs a single row of the result @@ -2906,10 +2928,12 @@ ** order to signal the caller to abort. */ addrSetAbort = sqlite3VdbeCurrentAddr(v); - sqlite3VdbeAddOp(v, OP_MemIncr, iAbortFlag, 0); + sqlite3VdbeAddOp(v, OP_MemInt, 1, iAbortFlag); + VdbeComment((v, "# set abort flag")); sqlite3VdbeAddOp(v, OP_Return, 0, 0); addrOutputRow = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp(v, OP_IfMemPos, iUseFlag, addrOutputRow+2); + VdbeComment((v, "# Groupby result generator entry point")); sqlite3VdbeAddOp(v, OP_Return, 0, 0); finalizeAggFunctions(pParse, &sAggInfo); if( pHaving ){ @@ -2922,13 +2946,21 @@ goto select_end; } sqlite3VdbeAddOp(v, OP_Return, 0, 0); + VdbeComment((v, "# end groupby result generator")); + /* Generate a subroutine that will reset the group-by accumulator + */ + addrReset = sqlite3VdbeCurrentAddr(v); + resetAccumulator(pParse, &sAggInfo); + sqlite3VdbeAddOp(v, OP_Return, 0, 0); + /* Begin a loop that will extract all source rows in GROUP BY order. ** This might involve two separate loops with an OP_Sort in between, or ** it might be a single loop that uses an index to extract information ** in the right order to begin with. */ sqlite3VdbeResolveLabel(v, addrInitializeLoop); + sqlite3VdbeAddOp(v, OP_Gosub, 0, addrReset); pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, &pGroupBy); if( pWInfo==0 ) goto select_end; if( pGroupBy==0 ){ @@ -2962,6 +2994,7 @@ sqlite3VdbeAddOp(v, OP_IdxInsert, sAggInfo.sortingIdx, 0); sqlite3WhereEnd(pWInfo); sqlite3VdbeAddOp(v, OP_Sort, sAggInfo.sortingIdx, addrEnd); + VdbeComment((v, "# GROUP BY sort")); sAggInfo.useSortingIdx = 1; } @@ -2986,9 +3019,9 @@ } sqlite3VdbeAddOp(v, OP_MemLoad, iAMem+j, 0); if( j==0 ){ - sqlite3VdbeAddOp(v, OP_Eq, 0, addrProcessRow); + sqlite3VdbeAddOp(v, OP_Eq, 0x200, addrProcessRow); }else{ - sqlite3VdbeAddOp(v, OP_Ne, 0x100, addrGroupByChange); + sqlite3VdbeAddOp(v, OP_Ne, 0x200, addrGroupByChange); } sqlite3VdbeChangeP3(v, -1, (void*)pKeyInfo->aColl[j], P3_COLLSEQ); } @@ -3004,19 +3037,22 @@ */ sqlite3VdbeResolveLabel(v, addrGroupByChange); for(j=0; jnExpr; j++){ - sqlite3VdbeAddOp(v, OP_MemLoad, iBMem+j, 0); - sqlite3VdbeAddOp(v, OP_MemStore, iAMem+j, 1); + sqlite3VdbeAddOp(v, OP_MemMove, iAMem+j, iBMem+j); } sqlite3VdbeAddOp(v, OP_Gosub, 0, addrOutputRow); + VdbeComment((v, "# output one row")); sqlite3VdbeAddOp(v, OP_IfMemPos, iAbortFlag, addrEnd); - resetAccumulator(pParse, &sAggInfo); + VdbeComment((v, "# check abort flag")); + sqlite3VdbeAddOp(v, OP_Gosub, 0, addrReset); + VdbeComment((v, "# reset accumulator")); /* Update the aggregate accumulators based on the content of ** the current row */ sqlite3VdbeResolveLabel(v, addrProcessRow); updateAccumulator(pParse, &sAggInfo); - sqlite3VdbeAddOp(v, OP_MemIncr, iUseFlag, 0); + sqlite3VdbeAddOp(v, OP_MemInt, 1, iUseFlag); + VdbeComment((v, "# indicate data in accumulator")); /* End of the loop */ @@ -3030,6 +3066,7 @@ /* Output the final row of result */ sqlite3VdbeAddOp(v, OP_Gosub, 0, addrOutputRow); + VdbeComment((v, "# output final row")); } /* endif pGroupBy */ else { ======================================================================== --- sqlite/sqlite3.h d1ab08a3d92270801782adad0dad0f31d6df7761 +++ sqlite/sqlite3.h 2c4119e974bd9182eb3597fbd6343c5e1c4bcb74 @@ -31,7 +31,7 @@ #ifdef SQLITE_VERSION # undef SQLITE_VERSION #endif -#define SQLITE_VERSION "3.2.6" +#define SQLITE_VERSION "3.2.7" /* ** The format of the version string is "X.Y.Z", where @@ -48,7 +48,7 @@ #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif -#define SQLITE_VERSION_NUMBER 3002006 +#define SQLITE_VERSION_NUMBER 3002007 /* ** The version string is also compiled into the library so that a program ======================================================================== --- sqlite/sqliteInt.h e78a7c53a97a2e5d8d6370b6836b2921124ac26f +++ sqlite/sqliteInt.h 0606b9cc31efabadf5b3d40478c193fa89fa6662 @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.419 2005/09/17 15:20:27 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.421 2005/09/19 21:05:49 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -904,6 +904,7 @@ ** iColumn-th field of the iTable-th table. */ AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ int iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ + int iRightJoinTable; /* If EP_FromJoin, the right table of the join */ Select *pSelect; /* When the expression is a sub-select. Also the ** right side of " IN (