mirror of
https://github.com/sqlite/sqlite.git
synced 2025-10-27 08:52:26 +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:
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user