aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-10-15 19:21:51 +0000
committerdrh <drh@noemail.net>2015-10-15 19:21:51 +0000
commitce78bc6e7ed51ea1f4452b77f4415331b7c1ff23 (patch)
tree877fb72fc7058cde5f6e52dd7cac09c1f5ecedfd /src/expr.c
parentfed7ac6f04fd2e314c90eec1f744e01429b09e95 (diff)
downloadsqlite-ce78bc6e7ed51ea1f4452b77f4415331b7c1ff23.tar.gz
sqlite-ce78bc6e7ed51ea1f4452b77f4415331b7c1ff23.zip
Enhance the use of the column cache for UPDATE statements, making them
more efficient for the case where a column is modified to be an expression of other unmodified columns. FossilOrigin-Name: 871e091df651b2275a672c35ff938bd4b6db0d7f
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/expr.c b/src/expr.c
index b39dea2ea..a93bab991 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -2481,9 +2481,12 @@ void sqlite3ExprCodeGetColumnOfTable(
/*
** 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
-** not guaranteed. The location of the column value is returned.
+** table pTab and store the column value in a register.
+**
+** An effort is made to store the column value in register iReg. This
+** is not garanteeed for GetColumn() - the result can be stored in
+** any register. But the result is guaranteed to land in register iReg
+** for GetColumnToReg().
**
** There must be an open cursor to pTab in iTable when this routine
** is called. If iColumn<0 then code is generated that extracts the rowid.
@@ -2494,7 +2497,7 @@ int sqlite3ExprCodeGetColumn(
int iColumn, /* Index of the table column */
int iTable, /* The cursor pointing to the table */
int iReg, /* Store results here */
- u8 p5 /* P5 value for OP_Column */
+ u8 p5 /* P5 value for OP_Column + FLAGS */
){
Vdbe *v = pParse->pVdbe;
int i;
@@ -2516,6 +2519,17 @@ int sqlite3ExprCodeGetColumn(
}
return iReg;
}
+void sqlite3ExprCodeGetColumnToReg(
+ Parse *pParse, /* Parsing and code generating context */
+ Table *pTab, /* Description of the table we are reading from */
+ int iColumn, /* Index of the table column */
+ int iTable, /* The cursor pointing to the table */
+ int iReg /* Store results here */
+){
+ int r1 = sqlite3ExprCodeGetColumn(pParse, pTab, iColumn, iTable, iReg, 0);
+ if( r1!=iReg ) sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, r1, iReg);
+}
+
/*
** Clear all column cache entries.