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

Fix for an UPDATE on a virtual table when the WHERE clause matches zero rows.

Ticket #2244. (CVS 3652)

FossilOrigin-Name: 43bf797842f00a104f5c5619ad3215edddfc641b
This commit is contained in:
danielk1977
2007-02-21 16:52:12 +00:00
parent 0d5359b9d8
commit b77ff0139e
4 changed files with 38 additions and 12 deletions

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle UPDATE statements.
**
** $Id: update.c,v 1.134 2007/02/07 01:06:53 drh Exp $
** $Id: update.c,v 1.135 2007/02/21 16:52:12 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -568,6 +568,7 @@ static void updateVirtualTable(
int ephemTab; /* Table holding the result of the SELECT */
int i; /* Loop counter */
int addr; /* Address of top of loop */
int iLabel; /* Vdbe label used by the OP_Rewind op */
/* Construct the SELECT statement that will find the new values for
** all updated rows.
@@ -602,7 +603,8 @@ static void updateVirtualTable(
** Generate code to scan the ephemeral table and call VDelete and
** VInsert
*/
sqlite3VdbeAddOp(v, OP_Rewind, ephemTab, 0);
iLabel = sqlite3VdbeMakeLabel(v);
sqlite3VdbeAddOp(v, OP_Rewind, ephemTab, iLabel);
addr = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp(v, OP_Column, ephemTab, 0);
if( pRowid ){
@@ -617,6 +619,7 @@ static void updateVirtualTable(
sqlite3VdbeOp3(v, OP_VUpdate, 0, pTab->nCol+2,
(const char*)pTab->pVtab, P3_VTAB);
sqlite3VdbeAddOp(v, OP_Next, ephemTab, addr);
sqlite3VdbeResolveLabel(v, iLabel);
sqlite3VdbeAddOp(v, OP_Close, ephemTab, 0);
/* Cleanup */