1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Revamp sqlite3VdbeAddOpList() so that the structure holds integer values

for P1, P2, and P3. (CVS 4661)

FossilOrigin-Name: 4dc507d87b242619fe32606452227900e16a6de7
This commit is contained in:
drh
2008-01-03 01:28:59 +00:00
parent 66a5167b47
commit 2400345a32
6 changed files with 37 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
C Refactoring\sthe\sVM.\s\sThe\sP3\sparameter\sis\schanged\sto\sP4.\s\sA\sP5\sparameter\sis\nadded\s(though\snot\scurrently\sused.)\s\sAdd\sroutines\ssqlite3VdbeAddOpX()\swhere\nX\sis\sone\sof\s0,\s1,\s2,\s3,\sor\s4.\s(CVS\s4660) C Revamp\ssqlite3VdbeAddOpList()\sso\sthat\sthe\sstructure\sholds\sinteger\svalues\nfor\sP1,\sP2,\sand\sP3.\s(CVS\s4661)
D 2008-01-03T00:01:24 D 2008-01-03T01:28:59
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9 F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -127,7 +127,7 @@ F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c 0cb6ccea4b9615627d61d7c4417cedc45776d429 F src/pager.c 0cb6ccea4b9615627d61d7c4417cedc45776d429
F src/pager.h f504f7ae84060fee0416a853e368d3d113c3d6fa F src/pager.h f504f7ae84060fee0416a853e368d3d113c3d6fa
F src/parse.y 2ae06e8d3190faace49c5b82e7cea1fc60d084a1 F src/parse.y 2ae06e8d3190faace49c5b82e7cea1fc60d084a1
F src/pragma.c 036e49b88c4f5079a8d9d536a7cc2928583f163f F src/pragma.c 61b9d171a6d53d36a77c66cb921d47a5c09a8441
F src/prepare.c 31ce0903040ec6f71da10c74869e10137890d981 F src/prepare.c 31ce0903040ec6f71da10c74869e10137890d981
F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910 F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
F src/random.c 4a22746501bf36b0a088c66e38dde5daba6a35da F src/random.c 4a22746501bf36b0a088c66e38dde5daba6a35da
@@ -163,16 +163,16 @@ F src/test_server.c a6ece6c835e7eae835054124e09e947e422b1ac5
F src/test_tclvar.c b2d1115e4d489179d3f029e765211b2ad527ba59 F src/test_tclvar.c b2d1115e4d489179d3f029e765211b2ad527ba59
F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730 F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730
F src/tokenize.c a4e04438c11fed2c67ec47fe3edbef9cca2d1b48 F src/tokenize.c a4e04438c11fed2c67ec47fe3edbef9cca2d1b48
F src/trigger.c 3267e5d6e3c1e8b688db5844278d71acc0f00996 F src/trigger.c e7642cf61056655905aaba8db1ca51d299a1003b
F src/update.c 39ac597c81b1d7d0396d5571d620bfa694f21151 F src/update.c 39ac597c81b1d7d0396d5571d620bfa694f21151
F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736 F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736
F src/util.c 05f31144bbd3f1a24f4139ae029c42545cb72624 F src/util.c 05f31144bbd3f1a24f4139ae029c42545cb72624
F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0 F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0
F src/vdbe.c fd5f6fc98eda1c1664cb1bfd09479ec3fb642139 F src/vdbe.c fd5f6fc98eda1c1664cb1bfd09479ec3fb642139
F src/vdbe.h c50dd0ad14ae4a2cc0b69f61263dcc732274d231 F src/vdbe.h 0d29000e30e60714f8de9fd4373ec8569c728e07
F src/vdbeInt.h 2985f1369273e635898cf5952237efcb3fdb21f3 F src/vdbeInt.h 2985f1369273e635898cf5952237efcb3fdb21f3
F src/vdbeapi.c bf615ff2cf2b121f1609cbadd4f52720289733b5 F src/vdbeapi.c bf615ff2cf2b121f1609cbadd4f52720289733b5
F src/vdbeaux.c 5601e73eaf893c14effb0b2fd921128b605d83c3 F src/vdbeaux.c cd0a3f702bb90a76adba3581005a9dc7853565f9
F src/vdbeblob.c 82f51cdf9b0c0af729732fde48c824e498c0a1ca F src/vdbeblob.c 82f51cdf9b0c0af729732fde48c824e498c0a1ca
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6 F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
F src/vdbemem.c 123994fcd344993d2fb050a83b91b341bbbd08b4 F src/vdbemem.c 123994fcd344993d2fb050a83b91b341bbbd08b4
@@ -603,7 +603,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P ad528735e41ce2ec2e680b12e562d4ddb6650985 P 027875e4d4c4bd7686dc880c6917a968049b2fec
R ace653b10b899d3bff1e4800e5ac3a83 R bafbb97261d5cb777f4a74b378e386c4
U drh U drh
Z fe84d7f6c2377b705fae1be2a7ddde3c Z 286f034de62a5f2d303f92883ddc5640

View File

@@ -1 +1 @@
027875e4d4c4bd7686dc880c6917a968049b2fec 4dc507d87b242619fe32606452227900e16a6de7

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** This file contains code used to implement the PRAGMA command. ** This file contains code used to implement the PRAGMA command.
** **
** $Id: pragma.c,v 1.155 2008/01/03 00:01:24 drh Exp $ ** $Id: pragma.c,v 1.156 2008/01/03 01:28:59 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -833,7 +833,7 @@ void sqlite3Pragma(
{ OP_MemLoad, 0, 0, 0}, { OP_MemLoad, 0, 0, 0},
{ OP_Integer, 0, 0, 0}, { OP_Integer, 0, 0, 0},
{ OP_Ne, 0, 0, 0}, /* 2 */ { OP_Ne, 0, 0, 0}, /* 2 */
{ OP_String8, 0, 0, "ok"}, { OP_String8, 0, 0, 0}, /* 3 */
{ OP_Callback, 1, 0, 0}, { OP_Callback, 1, 0, 0},
}; };
@@ -910,9 +910,9 @@ void sqlite3Pragma(
int jmp2; int jmp2;
static const VdbeOpList idxErr[] = { static const VdbeOpList idxErr[] = {
{ OP_MemIncr, -1, 0, 0}, { OP_MemIncr, -1, 0, 0},
{ OP_String8, 0, 0, "rowid "}, { OP_String8, 0, 0, 0}, /* 1 */
{ OP_Rowid, 1, 0, 0}, { OP_Rowid, 1, 0, 0},
{ OP_String8, 0, 0, " missing from index "}, { OP_String8, 0, 0, 0}, /* 3 */
{ OP_String8, 0, 0, 0}, /* 4 */ { OP_String8, 0, 0, 0}, /* 4 */
{ OP_Concat, 2, 0, 0}, { OP_Concat, 2, 0, 0},
{ OP_Callback, 1, 0, 0}, { OP_Callback, 1, 0, 0},
@@ -920,6 +920,8 @@ void sqlite3Pragma(
sqlite3GenerateIndexKey(v, pIdx, 1); sqlite3GenerateIndexKey(v, pIdx, 1);
jmp2 = sqlite3VdbeAddOp2(v, OP_Found, j+2, 0); jmp2 = sqlite3VdbeAddOp2(v, OP_Found, j+2, 0);
addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr); addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_STATIC); sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_STATIC);
sqlite3VdbeJumpHere(v, jmp2); sqlite3VdbeJumpHere(v, jmp2);
} }
@@ -935,7 +937,7 @@ void sqlite3Pragma(
{ OP_MemLoad, 2, 0, 0}, { OP_MemLoad, 2, 0, 0},
{ OP_Eq, 0, 0, 0}, /* 6 */ { OP_Eq, 0, 0, 0}, /* 6 */
{ OP_MemIncr, -1, 0, 0}, { OP_MemIncr, -1, 0, 0},
{ OP_String8, 0, 0, "wrong # of entries in index "}, { OP_String8, 0, 0, 0}, /* 8 */
{ OP_String8, 0, 0, 0}, /* 9 */ { OP_String8, 0, 0, 0}, /* 9 */
{ OP_Concat, 0, 0, 0}, { OP_Concat, 0, 0, 0},
{ OP_Callback, 1, 0, 0}, { OP_Callback, 1, 0, 0},
@@ -950,12 +952,15 @@ void sqlite3Pragma(
sqlite3VdbeChangeP1(v, addr+3, j+2); sqlite3VdbeChangeP1(v, addr+3, j+2);
sqlite3VdbeChangeP2(v, addr+3, addr+2); sqlite3VdbeChangeP2(v, addr+3, addr+2);
sqlite3VdbeJumpHere(v, addr+6); sqlite3VdbeJumpHere(v, addr+6);
sqlite3VdbeChangeP4(v, addr+8,
"wrong # of entries in index ", P4_STATIC);
sqlite3VdbeChangeP4(v, addr+9, pIdx->zName, P4_STATIC); sqlite3VdbeChangeP4(v, addr+9, pIdx->zName, P4_STATIC);
} }
} }
} }
addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode); addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
sqlite3VdbeChangeP1(v, addr+1, mxErr); sqlite3VdbeChangeP1(v, addr+1, mxErr);
sqlite3VdbeChangeP4(v, addr+3, "ok", P4_STATIC);
sqlite3VdbeJumpHere(v, addr+2); sqlite3VdbeJumpHere(v, addr+2);
}else }else
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */ #endif /* SQLITE_OMIT_INTEGRITY_CHECK */

View File

@@ -229,14 +229,14 @@ void sqlite3FinishTrigger(
if( !db->init.busy ){ if( !db->init.busy ){
static const VdbeOpList insertTrig[] = { static const VdbeOpList insertTrig[] = {
{ OP_NewRowid, 0, 0, 0 }, { OP_NewRowid, 0, 0, 0 },
{ OP_String8, 0, 0, "trigger" }, { OP_String8, 0, 0, 0 }, /* 1: "trigger" */
{ OP_String8, 0, 0, 0 }, /* 2: trigger name */ { OP_String8, 0, 0, 0 }, /* 2: trigger name */
{ OP_String8, 0, 0, 0 }, /* 3: table name */ { OP_String8, 0, 0, 0 }, /* 3: table name */
{ OP_Integer, 0, 0, 0 }, { OP_Integer, 0, 0, 0 },
{ OP_String8, 0, 0, "CREATE TRIGGER "}, { OP_String8, 0, 0, 0 }, /* 5: "CREATE TRIGGER " */
{ OP_String8, 0, 0, 0 }, /* 6: SQL */ { OP_String8, 0, 0, 0 }, /* 6: SQL */
{ OP_Concat, 0, 0, 0 }, { OP_Concat, 0, 0, 0 },
{ OP_MakeRecord, 5, 0, "aaada" }, { OP_MakeRecord, 5, 0, 0 }, /* 8: "aaada" */
{ OP_Insert, 0, 0, 0 }, { OP_Insert, 0, 0, 0 },
}; };
int addr; int addr;
@@ -248,9 +248,12 @@ void sqlite3FinishTrigger(
sqlite3BeginWriteOperation(pParse, 0, iDb); sqlite3BeginWriteOperation(pParse, 0, iDb);
sqlite3OpenMasterTable(pParse, iDb); sqlite3OpenMasterTable(pParse, iDb);
addr = sqlite3VdbeAddOpList(v, ArraySize(insertTrig), insertTrig); addr = sqlite3VdbeAddOpList(v, ArraySize(insertTrig), insertTrig);
sqlite3VdbeChangeP4(v, addr+1, "trigger", P4_STATIC);
sqlite3VdbeChangeP4(v, addr+2, pTrig->name, 0); sqlite3VdbeChangeP4(v, addr+2, pTrig->name, 0);
sqlite3VdbeChangeP4(v, addr+3, pTrig->table, 0); sqlite3VdbeChangeP4(v, addr+3, pTrig->table, 0);
sqlite3VdbeChangeP4(v, addr+5, "CREATE TRIGGER ", P4_STATIC);
sqlite3VdbeChangeP4(v, addr+6, (char*)pAll->z, pAll->n); sqlite3VdbeChangeP4(v, addr+6, (char*)pAll->z, pAll->n);
sqlite3VdbeChangeP4(v, addr+8, "aaada", P4_STATIC);
sqlite3ChangeCookie(db, v, iDb); sqlite3ChangeCookie(db, v, iDb);
sqlite3VdbeAddOp2(v, OP_Close, 0, 0); sqlite3VdbeAddOp2(v, OP_Close, 0, 0);
sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, sqlite3MPrintf( sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, sqlite3MPrintf(
@@ -538,7 +541,7 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){
{ OP_String8, 0, 0, 0}, /* 1 */ { OP_String8, 0, 0, 0}, /* 1 */
{ OP_Column, 0, 1, 0}, { OP_Column, 0, 1, 0},
{ OP_Ne, 0, ADDR(8), 0}, { OP_Ne, 0, ADDR(8), 0},
{ OP_String8, 0, 0, "trigger"}, { OP_String8, 0, 0, 0}, /* 4: "trigger" */
{ OP_Column, 0, 0, 0}, { OP_Column, 0, 0, 0},
{ OP_Ne, 0, ADDR(8), 0}, { OP_Ne, 0, ADDR(8), 0},
{ OP_Delete, 0, 0, 0}, { OP_Delete, 0, 0, 0},
@@ -549,6 +552,7 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){
sqlite3OpenMasterTable(pParse, iDb); sqlite3OpenMasterTable(pParse, iDb);
base = sqlite3VdbeAddOpList(v, ArraySize(dropTrigger), dropTrigger); base = sqlite3VdbeAddOpList(v, ArraySize(dropTrigger), dropTrigger);
sqlite3VdbeChangeP4(v, base+1, pTrigger->name, 0); sqlite3VdbeChangeP4(v, base+1, pTrigger->name, 0);
sqlite3VdbeChangeP4(v, base+4, "trigger", P4_STATIC);
sqlite3ChangeCookie(db, v, iDb); sqlite3ChangeCookie(db, v, iDb);
sqlite3VdbeAddOp2(v, OP_Close, 0, 0); sqlite3VdbeAddOp2(v, OP_Close, 0, 0);
sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->name, 0); sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->name, 0);

View File

@@ -15,7 +15,7 @@
** or VDBE. The VDBE implements an abstract machine that runs a ** or VDBE. The VDBE implements an abstract machine that runs a
** simple program to access and modify the underlying database. ** simple program to access and modify the underlying database.
** **
** $Id: vdbe.h,v 1.118 2008/01/03 00:01:25 drh Exp $ ** $Id: vdbe.h,v 1.119 2008/01/03 01:28:59 drh Exp $
*/ */
#ifndef _SQLITE_VDBE_H_ #ifndef _SQLITE_VDBE_H_
#define _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_
@@ -62,8 +62,9 @@ typedef struct VdbeOp VdbeOp;
struct VdbeOpList { struct VdbeOpList {
u8 opcode; /* What operation to perform */ u8 opcode; /* What operation to perform */
signed char p1; /* First operand */ signed char p1; /* First operand */
short int p2; /* Second parameter (often the jump destination) */ signed char p2; /* Second parameter (often the jump destination) */
char *p3; /* Third parameter */ signed char p3; /* Third parameter */
char *p4; /* Fourth parameter */
}; };
typedef struct VdbeOpList VdbeOpList; typedef struct VdbeOpList VdbeOpList;

View File

@@ -397,8 +397,10 @@ int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp){
pOut->opcode = pIn->opcode; pOut->opcode = pIn->opcode;
pOut->p1 = pIn->p1; pOut->p1 = pIn->p1;
pOut->p2 = p2<0 ? addr + ADDR(p2) : p2; pOut->p2 = p2<0 ? addr + ADDR(p2) : p2;
pOut->p4.p = pIn->p3; pOut->p3 = pIn->p3;
pOut->p4type = pIn->p3 ? P4_STATIC : P4_NOTUSED; pOut->p4type = P4_NOTUSED;
pOut->p4.p = 0;
pOut->p5 = 0;
#ifdef SQLITE_DEBUG #ifdef SQLITE_DEBUG
if( sqlite3_vdbe_addop_trace ){ if( sqlite3_vdbe_addop_trace ){
sqlite3VdbePrintOp(0, i+addr, &p->aOp[i+addr]); sqlite3VdbePrintOp(0, i+addr, &p->aOp[i+addr]);