diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/delete.c | 4 | ||||
-rw-r--r-- | src/expr.c | 29 | ||||
-rw-r--r-- | src/sqliteInt.h | 1 | ||||
-rw-r--r-- | src/update.c | 5 |
4 files changed, 26 insertions, 13 deletions
diff --git a/src/delete.c b/src/delete.c index 9e99a4d46..9608dc2f5 100644 --- a/src/delete.c +++ b/src/delete.c @@ -508,9 +508,7 @@ void sqlite3GenerateRowDelete( sqlite3VdbeAddOp2(v, OP_Copy, iRowid, iOld); for(iCol=0; iCol<pTab->nCol; iCol++){ if( mask==0xffffffff || mask&(1<<iCol) ){ - int iTarget = iOld + iCol + 1; - sqlite3VdbeAddOp3(v, OP_Column, iCur, iCol, iTarget); - sqlite3ColumnDefault(v, pTab, iCol, iTarget); + sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, iOld+iCol+1); } } diff --git a/src/expr.c b/src/expr.c index f82f6d429..b77697961 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2083,6 +2083,27 @@ static void sqlite3ExprCachePinRegister(Parse *pParse, int iReg){ } /* +** Generate code to extract the value of the iCol-th column of a table. +*/ +void sqlite3ExprCodeGetColumnOfTable( + Vdbe *v, /* The VDBE under construction */ + Table *pTab, /* The table containing the value */ + int iTabCur, /* The cursor for this table */ + int iCol, /* Index of the column to extract */ + int regOut /* Extract the valud into this register */ +){ + if( iCol<0 || iCol==pTab->iPKey ){ + sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut); + }else{ + int op = IsVirtual(pTab) ? OP_VColumn : OP_Column; + sqlite3VdbeAddOp3(v, op, iTabCur, iCol, regOut); + } + if( iCol>=0 ){ + sqlite3ColumnDefault(v, pTab, iCol, regOut); + } +} + +/* ** Generate code that will extract the iColumn-th column from ** table pTab and store the column value in a register. An effort ** is made to store the column value in register iReg, but this is @@ -2110,13 +2131,7 @@ int sqlite3ExprCodeGetColumn( } } assert( v!=0 ); - if( iColumn<0 ){ - sqlite3VdbeAddOp2(v, OP_Rowid, iTable, iReg); - }else if( ALWAYS(pTab!=0) ){ - int op = IsVirtual(pTab) ? OP_VColumn : OP_Column; - sqlite3VdbeAddOp3(v, op, iTable, iColumn, iReg); - sqlite3ColumnDefault(v, pTab, iColumn, iReg); - } + sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg); sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg); return iReg; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 2eae78f60..2fa474c60 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2669,6 +2669,7 @@ void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16); void sqlite3WhereEnd(WhereInfo*); int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int); +void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); void sqlite3ExprCodeMove(Parse*, int, int, int); void sqlite3ExprCodeCopy(Parse*, int, int, int); void sqlite3ExprCacheStore(Parse*, int, int, int); diff --git a/src/update.c b/src/update.c index 66bf8ca9f..3c82c2704 100644 --- a/src/update.c +++ b/src/update.c @@ -8,7 +8,7 @@ ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** -************************************************************************* +sqlite************************************************************************* ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. */ @@ -396,8 +396,7 @@ void sqlite3Update( ); for(i=0; i<pTab->nCol; i++){ if( aXRef[i]<0 || oldmask==0xffffffff || (oldmask & (1<<i)) ){ - sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regOld+i); - sqlite3ColumnDefault(v, pTab, i, regOld+i); + sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOld+i); }else{ sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i); } |