1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-08 03:22:21 +03:00

Modify FifoRead and FifoWrite to work exclusively with memory cells. (CVS 4676)

FossilOrigin-Name: 2c913908a47e7ace7d964067e3566d232ee2d494
This commit is contained in:
danielk1977
2008-01-04 13:57:26 +00:00
parent 96cb76fc7a
commit dd2fb29be8
5 changed files with 37 additions and 44 deletions

View File

@@ -1,5 +1,5 @@
C Modify\sthe\scode\sgenerated\sfor\sa\sDELETE\sto\suse\sregisters\sinstead\sof\sthe\svdbe\sstack.\s(CVS\s4675) C Modify\sFifoRead\sand\sFifoWrite\sto\swork\sexclusively\swith\smemory\scells.\s(CVS\s4676)
D 2008-01-04T13:24:29 D 2008-01-04T13:57:26
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
@@ -90,7 +90,7 @@ F src/build.c b7874b45716fa56e6fd1291ffb0b97a55e470728
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0 F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131 F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
F src/date.c 49c5a6d2de6c12000905b4d36868b07d3011bbf6 F src/date.c 49c5a6d2de6c12000905b4d36868b07d3011bbf6
F src/delete.c 36193a3a10e636d3ee4fe1fdfac57982d5471623 F src/delete.c 5601acbbad10e0a6190e6d1822a776ad058c661d
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
F src/expr.c e60ee4f48194469bf7b101fb7a14e56abea3daa4 F src/expr.c e60ee4f48194469bf7b101fb7a14e56abea3daa4
F src/func.c 996071cf0af9d967e58b69fce1909555059ebc7d F src/func.c 996071cf0af9d967e58b69fce1909555059ebc7d
@@ -164,11 +164,11 @@ 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 713b501b12ea41bf0297a2cf78f7d954c4a25d13 F src/trigger.c 713b501b12ea41bf0297a2cf78f7d954c4a25d13
F src/update.c a68e11e766376bf0fbec93d70c9389c4c502dd55 F src/update.c eaacf59269bd076adca6fab6f5d16ce53419380b
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 55e1a0541f87e2c73fa4c4d73649c3d6cd39b9a3 F src/vdbe.c c562e01b491b589f6e0f830bec7ab1507d1ac844
F src/vdbe.h bb128757b84280504a1243c450fd13ead248ede5 F src/vdbe.h bb128757b84280504a1243c450fd13ead248ede5
F src/vdbeInt.h 869d0f550354c1364dde1d3611d770bd1c767505 F src/vdbeInt.h 869d0f550354c1364dde1d3611d770bd1c767505
F src/vdbeapi.c f14174843bf4be2c9afdf2ef48b61e7c3ac62d7c F src/vdbeapi.c f14174843bf4be2c9afdf2ef48b61e7c3ac62d7c
@@ -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 8bb9f970dd71cbf19e45774fc822aa1efebc1724 P 173f281334d340290e1978abea5d1ea804141910
R 991771337c0268b312b29969927e9c60 R 94a66c73f79f80d8b0a98041731b34af
U danielk1977 U danielk1977
Z 58a58785d108e95cb589bb5d4ad7f5cb Z fb5d354c01f2e7900c511aa6a77f6954

View File

@@ -1 +1 @@
173f281334d340290e1978abea5d1ea804141910 2c913908a47e7ace7d964067e3566d232ee2d494

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** in order to generate code for DELETE FROM statements. ** in order to generate code for DELETE FROM statements.
** **
** $Id: delete.c,v 1.145 2008/01/04 13:24:29 danielk1977 Exp $ ** $Id: delete.c,v 1.146 2008/01/04 13:57:26 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -232,18 +232,20 @@ void sqlite3DeleteFrom(
sqlite3BeginWriteOperation(pParse, triggers_exist, iDb); sqlite3BeginWriteOperation(pParse, triggers_exist, iDb);
if( triggers_exist ){ if( triggers_exist ){
int orconf = ((pParse->trigStack)?pParse->trigStack->orconf:OE_Default);
int iGoto = sqlite3VdbeAddOp0(v, OP_Goto); int iGoto = sqlite3VdbeAddOp0(v, OP_Goto);
addr = sqlite3VdbeMakeLabel(v); addr = sqlite3VdbeMakeLabel(v);
iBeginBeforeTrigger = sqlite3VdbeCurrentAddr(v); iBeginBeforeTrigger = sqlite3VdbeCurrentAddr(v);
(void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_BEFORE, pTab, (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_BEFORE, pTab,
-1, oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default, -1, oldIdx, orconf, addr, &old_col_mask, 0);
addr, &old_col_mask, 0);
iEndBeforeTrigger = sqlite3VdbeAddOp0(v, OP_Goto); iEndBeforeTrigger = sqlite3VdbeAddOp0(v, OP_Goto);
iBeginAfterTrigger = sqlite3VdbeCurrentAddr(v); iBeginAfterTrigger = sqlite3VdbeCurrentAddr(v);
(void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_AFTER, pTab, -1, (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_AFTER, pTab, -1,
oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default, oldIdx, orconf, addr, &old_col_mask, 0);
addr, &old_col_mask, 0);
iEndAfterTrigger = sqlite3VdbeAddOp0(v, OP_Goto); iEndAfterTrigger = sqlite3VdbeAddOp0(v, OP_Goto);
sqlite3VdbeJumpHere(v, iGoto); sqlite3VdbeJumpHere(v, iGoto);
} }
@@ -299,7 +301,7 @@ void sqlite3DeleteFrom(
** the table and pick which records to delete. ** the table and pick which records to delete.
*/ */
else{ else{
int iRowid = ++pParse->nMem; /* Used for storing value read from fifo */ int iRowid = ++pParse->nMem; /* Used for storing rowid values. */
/* Begin the database scan /* Begin the database scan
*/ */
@@ -308,8 +310,8 @@ void sqlite3DeleteFrom(
/* Remember the rowid of every item to be deleted. /* Remember the rowid of every item to be deleted.
*/ */
sqlite3VdbeAddOp1(v, IsVirtual(pTab) ? OP_VRowid : OP_Rowid, iCur); sqlite3VdbeAddOp2(v, IsVirtual(pTab) ? OP_VRowid : OP_Rowid, iCur, iRowid);
sqlite3VdbeAddOp0(v, OP_FifoWrite); sqlite3VdbeAddOp1(v, OP_FifoWrite, iRowid);
if( db->flags & SQLITE_CountRows ){ if( db->flags & SQLITE_CountRows ){
sqlite3VdbeAddOp2(v, OP_MemIncr, 1, memCnt); sqlite3VdbeAddOp2(v, OP_MemIncr, 1, memCnt);
} }

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle UPDATE statements. ** to handle UPDATE statements.
** **
** $Id: update.c,v 1.155 2008/01/03 23:44:53 drh Exp $ ** $Id: update.c,v 1.156 2008/01/04 13:57:26 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -106,6 +106,7 @@ void sqlite3Update(
int iDb; /* Database containing the table being updated */ int iDb; /* Database containing the table being updated */
int memCnt = 0; /* Memory cell used for counting rows changed */ int memCnt = 0; /* Memory cell used for counting rows changed */
int mem1; /* Memory address storing the rowid for next row to update */ int mem1; /* Memory address storing the rowid for next row to update */
int iRowid; /* Memory address storing rowids */
#ifndef SQLITE_OMIT_TRIGGER #ifndef SQLITE_OMIT_TRIGGER
int isView; /* Trying to update a view */ int isView; /* Trying to update a view */
@@ -343,8 +344,9 @@ void sqlite3Update(
/* Remember the rowid of every item to be updated. /* Remember the rowid of every item to be updated.
*/ */
sqlite3VdbeAddOp2(v, IsVirtual(pTab) ? OP_VRowid : OP_Rowid, iCur, 0); iRowid = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_FifoWrite, 0, 0); sqlite3VdbeAddOp2(v, IsVirtual(pTab) ? OP_VRowid : OP_Rowid, iCur, iRowid);
sqlite3VdbeAddOp2(v, OP_FifoWrite, iRowid, 0);
/* End the database scan loop. /* End the database scan loop.
*/ */
@@ -384,7 +386,6 @@ void sqlite3Update(
assert( pParse->nTab>iCur+i+1 ); assert( pParse->nTab>iCur+i+1 );
} }
} }
} }
/* Jump back to this point if a trigger encounters an IGNORE constraint. */ /* Jump back to this point if a trigger encounters an IGNORE constraint. */
@@ -393,14 +394,13 @@ void sqlite3Update(
} }
/* Top of the update loop */ /* Top of the update loop */
addr = sqlite3VdbeAddOp2(v, OP_FifoRead, 0, 0); addr = sqlite3VdbeAddOp2(v, OP_FifoRead, iRowid, 0);
sqlite3VdbeAddOp2(v, OP_StackDepth, -1, 0); sqlite3VdbeAddOp2(v, OP_StackDepth, -1, 0);
sqlite3VdbeAddOp2(v, OP_MemStore, mem1, 0);
if( triggers_exist ){ if( triggers_exist ){
/* Make cursor iCur point to the record that is being updated. /* Make cursor iCur point to the record that is being updated.
*/ */
sqlite3VdbeAddOp2(v, OP_NotExists, iCur, addr); sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, iRowid);
/* Generate the OLD table /* Generate the OLD table
*/ */
@@ -445,10 +445,6 @@ void sqlite3Update(
sqlite3VdbeAddOp2(v, OP_Goto, 0, iBeginBeforeTrigger); sqlite3VdbeAddOp2(v, OP_Goto, 0, iBeginBeforeTrigger);
sqlite3VdbeJumpHere(v, iEndBeforeTrigger); sqlite3VdbeJumpHere(v, iEndBeforeTrigger);
if( !isView ){
sqlite3VdbeAddOp2(v, OP_MemLoad, mem1, 0);
}
} }
if( !isView && !IsVirtual(pTab) ){ if( !isView && !IsVirtual(pTab) ){
@@ -459,8 +455,8 @@ void sqlite3Update(
** Also, the old data is needed to delete the old index entries. ** Also, the old data is needed to delete the old index entries.
** So make the cursor point at the old record. ** So make the cursor point at the old record.
*/ */
sqlite3VdbeAddOp2(v, OP_NotExists, iCur, addr); sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, iRowid);
sqlite3VdbeAddOp2(v, OP_MemLoad, mem1, 0); sqlite3VdbeAddOp2(v, OP_MemLoad, iRowid, 0);
/* If the record number will change, push the record number as it /* If the record number will change, push the record number as it
** will be after the update. (The old record number is currently ** will be after the update. (The old record number is currently

View File

@@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing ** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code. ** commenting and indentation practices when changing or adding code.
** **
** $Id: vdbe.c,v 1.675 2008/01/04 13:24:29 danielk1977 Exp $ ** $Id: vdbe.c,v 1.676 2008/01/04 13:57:26 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -4523,18 +4523,17 @@ case OP_IntegrityCk: {
} }
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */ #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
/* Opcode: FifoWrite * * * /* Opcode: FifoWrite P1 * *
** **
** Write the integer on the top of the stack into the Fifo. ** Write the integer from memory cell P1 into the Fifo.
*/ */
case OP_FifoWrite: { /* no-push */ case OP_FifoWrite: { /* no-push */
assert( pTos>=p->aStack ); Mem *pReg = &p->aMem[pOp->p1];
sqlite3VdbeMemIntegerify(pTos); assert( pOp->p1>0 && pOp->p1<=p->nMem );
if( sqlite3VdbeFifoPush(&p->sFifo, pTos->u.i)==SQLITE_NOMEM ){ sqlite3VdbeMemIntegerify(pReg);
if( sqlite3VdbeFifoPush(&p->sFifo, pReg->u.i)==SQLITE_NOMEM ){
goto no_mem; goto no_mem;
} }
assert( (pTos->flags & MEM_Dyn)==0 );
pTos--;
break; break;
} }
@@ -4553,12 +4552,8 @@ case OP_FifoRead: {
if( sqlite3VdbeFifoPop(&p->sFifo, &v)==SQLITE_DONE ){ if( sqlite3VdbeFifoPop(&p->sFifo, &v)==SQLITE_DONE ){
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
}else{ }else{
Mem *pOut; Mem *pOut = &p->aMem[pOp->p1];
if( pOp->p1 ){ assert( pOp->p1>0 && pOp->p1<=p->nMem );
pOut = &p->aMem[pOp->p1];
}else{
pOut = ++pTos;
}
sqlite3VdbeMemSetInt64(pOut, v); sqlite3VdbeMemSetInt64(pOut, v);
} }
break; break;