mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Code cleanup and simplification. Three new Mem opcodes added.
The sqlite3VdbeJumpHere function added. (CVS 2730) FossilOrigin-Name: 2471957feee57538e5e1e50a704a337f0927d10e
This commit is contained in:
36
manifest
36
manifest
@@ -1,5 +1,5 @@
|
||||
C Cleanup\sthe\simplementation\sand\sthe\sdocumentation\sof\sthe\snew\s0x200\sP1\sflag\non\sthe\sVDBE\scomparison\soperands.\s(CVS\s2729)
|
||||
D 2005-09-20T13:55:18
|
||||
C Code\scleanup\sand\ssimplification.\s\sThree\snew\sMem\sopcodes\sadded.\nThe\ssqlite3VdbeJumpHere\sfunction\sadded.\s(CVS\s2730)
|
||||
D 2005-09-20T17:42:23
|
||||
F Makefile.in 12784cdce5ffc8dfb707300c34e4f1eb3b8a14f1
|
||||
F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@@ -29,22 +29,22 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
|
||||
F sqlite3.def c413e514217736884254739a105c8c942fdf0c2f
|
||||
F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
|
||||
F src/alter.c 26d755f2143719dd3f5b8aaf6cbe3c7f95332528
|
||||
F src/analyze.c 43a2d91242bdd71b6c299378f6b11e896ee5e43d
|
||||
F src/analyze.c 21a4cd125bedd3cb15857595c45c2a49c0556d26
|
||||
F src/attach.c 4b21689700a72ae281fa85dbaff06b2a62bd49ee
|
||||
F src/auth.c 31e2304bef67f44d635655f44234387ea7d21454
|
||||
F src/btree.c 236126155d5607da945d33514218cbec762d887e
|
||||
F src/btree.h 1ed561263ca0e335bc3e81d761c9d5ff8c22f61e
|
||||
F src/build.c 74653e045581bfbadb8b35a0cb38a62f4a2c850e
|
||||
F src/build.c aa9591839c00731370c1ba53a9c0045f70d764c4
|
||||
F src/callback.c 9a1162c8f9dae9fad6d548339669aacb5f6cf76b
|
||||
F src/complete.c 4de937dfdd4c79a501772ab2035b26082f337a79
|
||||
F src/date.c 7444b0900a28da77e57e3337a636873cff0ae940
|
||||
F src/delete.c 16a0e19460b14d219f39ff5c7a9eef808aa1969c
|
||||
F src/delete.c 29dac493f4d83b05f91233b116827c133bcdab72
|
||||
F src/experimental.c 50c1e3b34f752f4ac10c36f287db095c2b61766d
|
||||
F src/expr.c b8dbd5a30e80b83b0c1e137dcfcd687bd5d2b76c
|
||||
F src/expr.c b549a39a3c32920cf2b5f5e7fca841ad420405f2
|
||||
F src/func.c f63d417248808ff2632a3b576536abffcc21d858
|
||||
F src/hash.c 2b1b13f7400e179631c83a1be0c664608c8f021f
|
||||
F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
|
||||
F src/insert.c 484c73bc1309f283a31baa0e114f3ee980536397
|
||||
F src/insert.c 1f51566d7cf4b243a2792f5fda37343d6e9377fa
|
||||
F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b
|
||||
F src/main.c 422014201f22aa17b96c76650163178a91a825af
|
||||
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
|
||||
@@ -59,11 +59,11 @@ F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
||||
F src/pager.c adbb27f13ac75cd5bc29a3d84803e0cab1edfa88
|
||||
F src/pager.h e7b41ce8e7b5f629d456708b7ad9a8c8ede37140
|
||||
F src/parse.y 5602d5cb894dda2932bf50b7e88782a4440ae3ae
|
||||
F src/pragma.c 6d773e25e8af13ef0820531ad2793417f8a8959d
|
||||
F src/pragma.c 126149668aa7086e86cfa3e32c8523513c19dd63
|
||||
F src/prepare.c fc098db25d2a121affb08686cf04833fd50452d4
|
||||
F src/printf.c bd421c1ad5e01013c89af63c60eab02852ccd15e
|
||||
F src/random.c 90adff4e73a3b249eb4f1fc2a6ff9cf78c7233a4
|
||||
F src/select.c 4a5271874f43d641d273eb6b88f77ab1c289f3c1
|
||||
F src/select.c 240f456bc85e60e21b9d16a4b1ac09d6266b340f
|
||||
F src/shell.c 3596c1e559b82663057940d19ba533ad421c7dd3
|
||||
F src/sqlite.h.in 461b2535550cf77aedfd44385da11ef7d63e57a2
|
||||
F src/sqliteInt.h 53daa72541b4336c5e89773cf39717ed695bd523
|
||||
@@ -76,18 +76,18 @@ F src/test4.c a8fd681e139e1c61f22a77d07fc3a99cb28fff3f
|
||||
F src/test5.c 64f08b2a50ef371a1bd68ff206829e7b1b9997f5
|
||||
F src/tokenize.c e1faf5637f3f4f90933785a0ecf64595f3ac3530
|
||||
F src/trigger.c f51dec15921629591cb98bf2e350018e268b109a
|
||||
F src/update.c c2716c2115533ffae3d08bf8853aaba4f970f37e
|
||||
F src/update.c ac506fb7400158f826ec6c3a0dbe65e7ed3928d5
|
||||
F src/utf.c bda5eb85039ef16f2d17004c1e18c96e1ab0a80c
|
||||
F src/util.c 55caaffbb2716f9928ab452d20f3e9cbbeab872d
|
||||
F src/vacuum.c 829d9e1a6d7c094b80e0899686670932eafd768c
|
||||
F src/vdbe.c ae89c05fa7663c470aefafcb5aa40b6797c8eb37
|
||||
F src/vdbe.h c8e105979fc7aaf5b8004e9621904e3bd096dfa2
|
||||
F src/vdbe.c 3f1adcf4535dd35e4244d19d332fb6b515491c0d
|
||||
F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
|
||||
F src/vdbeInt.h 7bedbb9553a10e86b53f75d99e197f3f00a732bf
|
||||
F src/vdbeapi.c 85bbe1d0243a89655433d60711b4bd71979b59cd
|
||||
F src/vdbeaux.c 57a6ced8417bdc6f06c391d9c560ecbbed644ef3
|
||||
F src/vdbeaux.c 2b728d82cf2095386a90051b66e7faf1a143f27d
|
||||
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
|
||||
F src/vdbemem.c fea0744936008831daa17cdc75056c3ca1469690
|
||||
F src/where.c 363b4fb0aee9fe69367ceaab0974dafa4e4ab900
|
||||
F src/vdbemem.c ff426ff6e72aa3f0300a56ec8c7f18099be96b43
|
||||
F src/where.c 3ed72ca029b3010a76e3a41b7b02ec1bdf849f00
|
||||
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
|
||||
F test/all.test 7f0988442ab811dfa41793b5b550f5828ce316f3
|
||||
F test/alter.test 9d6837a3d946b73df692b7cef2a7644d2e2f6bc6
|
||||
@@ -311,7 +311,7 @@ F www/tclsqlite.tcl ddcf912ea48695603c8ed7efb29f0812ef8d1b49
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||
P d9b0c9705379a8b3a28a83bb29fc1cd688fe184e
|
||||
R 9a4465a95bd3c4612d23f7531e305890
|
||||
P f22d0f64a0b9100e16746fb800efa508d286e40e
|
||||
R 3effef3e7ca21a06e1bfa94b9c1adaf9
|
||||
U drh
|
||||
Z da619a304c4dc568252b01796a7d376e
|
||||
Z 30993b6d59068461f41957a47370eeb7
|
||||
|
@@ -1 +1 @@
|
||||
f22d0f64a0b9100e16746fb800efa508d286e40e
|
||||
2471957feee57538e5e1e50a704a337f0927d10e
|
@@ -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 @@ static void analyzeOneTable(
|
||||
** 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<nCol; i++){
|
||||
sqlite3VdbeAddOp(v, OP_MemStore, iMem+nCol+i+1, i==nCol-1);
|
||||
sqlite3VdbeAddOp(v, OP_MemNull, iMem+nCol+i+1, 0);
|
||||
}
|
||||
|
||||
/* Do the analysis.
|
||||
@@ -198,7 +196,7 @@ static void analyzeOneTable(
|
||||
}
|
||||
sqlite3VdbeOp3(v, OP_MakeRecord, 3, 0, "ttt", 0);
|
||||
sqlite3VdbeAddOp(v, OP_Insert, iStatCur, 0);
|
||||
sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v));
|
||||
sqlite3VdbeJumpHere(v, addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,7 @@
|
||||
** COMMIT
|
||||
** ROLLBACK
|
||||
**
|
||||
** $Id: build.c,v 1.350 2005/09/16 02:48:02 drh Exp $
|
||||
** $Id: build.c,v 1.351 2005/09/20 17:42:23 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@@ -76,7 +76,7 @@ void sqlite3FinishCoding(Parse *pParse){
|
||||
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; iDb<db->nDb; mask<<=1, iDb++){
|
||||
if( (mask & pParse->cookieMask)==0 ) continue;
|
||||
sqlite3VdbeAddOp(v, OP_Transaction, iDb, (mask & pParse->writeMask)!=0);
|
||||
@@ -2002,7 +2002,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@@ -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 @@ void sqlite3GenerateRowDelete(
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
15
src/expr.c
15
src/expr.c
@@ -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.229 2005/09/20 17:42:23 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@@ -1292,8 +1292,7 @@ void sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
|
||||
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 +1366,7 @@ void sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
|
||||
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 +1408,7 @@ void sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
|
||||
}
|
||||
|
||||
if( testAddr ){
|
||||
sqlite3VdbeChangeP2(v, testAddr, sqlite3VdbeCurrentAddr(v));
|
||||
sqlite3VdbeJumpHere(v, testAddr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1709,7 +1708,6 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
|
||||
case TK_CASE: {
|
||||
int expr_end_label;
|
||||
int jumpInst;
|
||||
int addr;
|
||||
int nExpr;
|
||||
int i;
|
||||
ExprList *pEList;
|
||||
@@ -1737,8 +1735,7 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
|
||||
}
|
||||
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 +1902,7 @@ void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
|
||||
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;
|
||||
}
|
||||
|
22
src/insert.c
22
src/insert.c
@@ -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 @@ void sqlite3Insert(
|
||||
** 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 @@ void sqlite3Insert(
|
||||
*/
|
||||
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 @@ void sqlite3GenerateConstraintChecks(
|
||||
Index *pIdx;
|
||||
int seenReplace = 0;
|
||||
int jumpInst1=0, jumpInst2;
|
||||
int contAddr;
|
||||
int hasTwoRowids = (isUpdate && rowidChng);
|
||||
|
||||
v = sqlite3GetVdbe(pParse);
|
||||
@@ -867,7 +865,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
break;
|
||||
}
|
||||
}
|
||||
sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v));
|
||||
sqlite3VdbeJumpHere(v, addr);
|
||||
}
|
||||
|
||||
/* Test all CHECK constraints
|
||||
@@ -921,10 +919,9 @@ void sqlite3GenerateConstraintChecks(
|
||||
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 @@ void sqlite3GenerateConstraintChecks(
|
||||
break;
|
||||
}
|
||||
}
|
||||
contAddr = sqlite3VdbeCurrentAddr(v);
|
||||
#if NULL_DISTINCT_FOR_UNIQUE
|
||||
sqlite3VdbeChangeP2(v, jumpInst1, contAddr);
|
||||
sqlite3VdbeJumpHere(v, jumpInst1);
|
||||
#endif
|
||||
sqlite3VdbeChangeP2(v, jumpInst2, contAddr);
|
||||
sqlite3VdbeJumpHere(v, jumpInst2);
|
||||
}
|
||||
}
|
||||
|
||||
|
44
src/pragma.c
44
src/pragma.c
@@ -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 @@ void sqlite3Pragma(
|
||||
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 @@ void sqlite3Pragma(
|
||||
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; i<db->nDb; i++){
|
||||
@@ -696,8 +688,7 @@ void sqlite3Pragma(
|
||||
|
||||
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 @@ void sqlite3Pragma(
|
||||
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 */
|
||||
|
||||
|
29
src/select.c
29
src/select.c
@@ -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.274 2005/09/20 13:55:18 drh Exp $
|
||||
** $Id: select.c,v 1.275 2005/09/20 17:42:23 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -543,7 +543,7 @@ static int selectInnerLoop(
|
||||
sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, &aff, 1);
|
||||
sqlite3VdbeAddOp(v, OP_IdxInsert, (iParm&0x0000FFFF), 0);
|
||||
}
|
||||
sqlite3VdbeChangeP2(v, addr2, sqlite3VdbeCurrentAddr(v));
|
||||
sqlite3VdbeJumpHere(v, addr2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2448,17 +2448,15 @@ int sqlite3SelectResolve(
|
||||
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; i<pAggInfo->nColumn; 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; i<pAggInfo->nFunc; 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 ){
|
||||
@@ -2472,7 +2470,6 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
|
||||
}
|
||||
}
|
||||
}
|
||||
sqlite3VdbeChangeP2(v, addr, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2786,9 +2783,10 @@ int sqlite3Select(
|
||||
|
||||
/* 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.
|
||||
@@ -2916,11 +2914,9 @@ int sqlite3Select(
|
||||
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);
|
||||
sqlite3VdbeAddOp(v, OP_MemInt, 0, iUseFlag);
|
||||
sqlite3VdbeAddOp(v, OP_MemNull, iAMem, 0);
|
||||
sqlite3VdbeAddOp(v, OP_Goto, 0, addrInitializeLoop);
|
||||
|
||||
/* Generate a subroutine that outputs a single row of the result
|
||||
@@ -3036,8 +3032,7 @@ int sqlite3Select(
|
||||
*/
|
||||
sqlite3VdbeResolveLabel(v, addrGroupByChange);
|
||||
for(j=0; j<pGroupBy->nExpr; 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);
|
||||
sqlite3VdbeAddOp(v, OP_IfMemPos, iAbortFlag, addrEnd);
|
||||
|
@@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle UPDATE statements.
|
||||
**
|
||||
** $Id: update.c,v 1.111 2005/09/08 01:58:43 drh Exp $
|
||||
** $Id: update.c,v 1.112 2005/09/20 17:42:23 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -469,7 +469,7 @@ void sqlite3Update(
|
||||
** all record selected by the WHERE clause have been updated.
|
||||
*/
|
||||
sqlite3VdbeAddOp(v, OP_Goto, 0, addr);
|
||||
sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v));
|
||||
sqlite3VdbeJumpHere(v, addr);
|
||||
|
||||
/* Close all tables if there were no FOR EACH ROW triggers */
|
||||
if( !triggers_exist ){
|
||||
|
35
src/vdbe.c
35
src/vdbe.c
@@ -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.490 2005/09/20 13:55:18 drh Exp $
|
||||
** $Id: vdbe.c,v 1.491 2005/09/20 17:42:23 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@@ -4177,6 +4177,39 @@ case OP_IfMemPos: { /* no-push */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: MemNull P1 * *
|
||||
**
|
||||
** Store a NULL in memory cell P1
|
||||
*/
|
||||
case OP_MemNull: {
|
||||
assert( pOp->p1>=0 && pOp->p1<p->nMem );
|
||||
sqlite3VdbeMemSetNull(&p->aMem[pOp->p1]);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: MemInt P1 P2 *
|
||||
**
|
||||
** Store the integer value P1 in memory cell P2.
|
||||
*/
|
||||
case OP_MemInt: {
|
||||
assert( pOp->p2>=0 && pOp->p2<p->nMem );
|
||||
sqlite3VdbeMemSetInt64(&p->aMem[pOp->p2], pOp->p1);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: MemMove P1 P2 *
|
||||
**
|
||||
** Move the content of memory cell P2 over to memory cell P1.
|
||||
** Any prior content of P1 is erased. Memory cell P2 is left
|
||||
** containing a NULL.
|
||||
*/
|
||||
case OP_MemMove: {
|
||||
assert( pOp->p1>=0 && pOp->p1<p->nMem );
|
||||
assert( pOp->p2>=0 && pOp->p2<p->nMem );
|
||||
rc = sqlite3VdbeMemMove(&p->aMem[pOp->p1], &p->aMem[pOp->p2]);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: AggStep P1 P2 P3
|
||||
**
|
||||
** Execute the step function for an aggregate. The
|
||||
|
@@ -15,7 +15,7 @@
|
||||
** or VDBE. The VDBE implements an abstract machine that runs a
|
||||
** simple program to access and modify the underlying database.
|
||||
**
|
||||
** $Id: vdbe.h,v 1.98 2005/09/07 21:22:47 drh Exp $
|
||||
** $Id: vdbe.h,v 1.99 2005/09/20 17:42:23 drh Exp $
|
||||
*/
|
||||
#ifndef _SQLITE_VDBE_H_
|
||||
#define _SQLITE_VDBE_H_
|
||||
@@ -104,6 +104,7 @@ int sqlite3VdbeOp3(Vdbe*,int,int,int,const char *zP3,int);
|
||||
int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp);
|
||||
void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
|
||||
void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
|
||||
void sqlite3VdbeJumpHere(Vdbe*, int addr);
|
||||
void sqlite3VdbeChangeP3(Vdbe*, int addr, const char *zP1, int N);
|
||||
VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
|
||||
int sqlite3VdbeMakeLabel(Vdbe*);
|
||||
|
@@ -351,6 +351,13 @@ void sqlite3VdbeChangeP2(Vdbe *p, int addr, int val){
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Change teh P2 operand of instruction addr so that it points to
|
||||
** the address of the next instruction to be coded.
|
||||
*/
|
||||
void sqlite3VdbeJumpHere(Vdbe *p, int addr){
|
||||
sqlite3VdbeChangeP2(p, addr, p->nOp);
|
||||
}
|
||||
|
||||
/*
|
||||
** Delete a P3 value if necessary.
|
||||
|
@@ -317,6 +317,7 @@ void sqlite3VdbeMemSetNull(Mem *pMem){
|
||||
sqlite3VdbeMemRelease(pMem);
|
||||
pMem->flags = MEM_Null;
|
||||
pMem->type = SQLITE_NULL;
|
||||
pMem->n = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
12
src/where.c
12
src/where.c
@@ -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.178 2005/09/20 08:47:20 drh Exp $
|
||||
** $Id: where.c,v 1.179 2005/09/20 17:42:23 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -1597,8 +1597,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||
if( pLevel->iFrom>0 && (pTabItem[-1].jointype & JT_LEFT)!=0 ){
|
||||
if( !pParse->nMem ) pParse->nMem++;
|
||||
pLevel->iLeftJoin = pParse->nMem++;
|
||||
sqlite3VdbeAddOp(v, OP_Null, 0, 0);
|
||||
sqlite3VdbeAddOp(v, OP_MemStore, pLevel->iLeftJoin, 1);
|
||||
sqlite3VdbeAddOp(v, OP_MemInt, 0, pLevel->iLeftJoin);
|
||||
VdbeComment((v, "# init LEFT JOIN no-match flag"));
|
||||
}
|
||||
|
||||
@@ -1878,8 +1877,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||
*/
|
||||
if( pLevel->iLeftJoin ){
|
||||
pLevel->top = sqlite3VdbeCurrentAddr(v);
|
||||
sqlite3VdbeAddOp(v, OP_Integer, 1, 0);
|
||||
sqlite3VdbeAddOp(v, OP_MemStore, pLevel->iLeftJoin, 1);
|
||||
sqlite3VdbeAddOp(v, OP_MemInt, 1, pLevel->iLeftJoin);
|
||||
VdbeComment((v, "# record LEFT JOIN hit"));
|
||||
for(pTerm=wc.a, j=0; j<wc.nTerm; j++, pTerm++){
|
||||
if( pTerm->flags & (TERM_VIRTUAL|TERM_CODED) ) continue;
|
||||
@@ -1981,13 +1979,13 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
}
|
||||
if( pLevel->iLeftJoin ){
|
||||
int addr;
|
||||
addr = sqlite3VdbeAddOp(v, OP_MemLoad, pLevel->iLeftJoin, 0);
|
||||
sqlite3VdbeAddOp(v, OP_NotNull, 1, addr+4 + (pLevel->iIdxCur>=0));
|
||||
addr = sqlite3VdbeAddOp(v, OP_IfMemPos, pLevel->iLeftJoin, 0);
|
||||
sqlite3VdbeAddOp(v, OP_NullRow, pTabList->a[i].iCursor, 0);
|
||||
if( pLevel->iIdxCur>=0 ){
|
||||
sqlite3VdbeAddOp(v, OP_NullRow, pLevel->iIdxCur, 0);
|
||||
}
|
||||
sqlite3VdbeAddOp(v, OP_Goto, 0, pLevel->top);
|
||||
sqlite3VdbeJumpHere(v, addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user