1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +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

@ -1,5 +1,5 @@
C Add\scomments\sto\sthe\stop\sof\skeywordhash.h.\s(CVS\s3651)
D 2007-02-21T16:44:33
C Fix\sfor\san\sUPDATE\son\sa\svirtual\stable\swhen\sthe\sWHERE\sclause\smatches\szero\srows.\nTicket\s#2244.\s(CVS\s3652)
D 2007-02-21T16:52:12
F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -117,7 +117,7 @@ F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c
F src/test_tclvar.c 315e77c17f128ff8c06b38c08617fd07c825a95b
F src/tokenize.c bb1732ef2b6fc2143f93ff28a45d3dcb04c1d396
F src/trigger.c 8c55d31876013ed4e97ee7ce24478fbe00db49bb
F src/update.c bdfcf3600f129bd5f06094781ab41cd7b7f5ab25
F src/update.c 9a05e12b25fdd004aacd404e416e3310946910c5
F src/utf.c 67ecb1032bc0b42c105e88d65ef9d9f626eb0e1f
F src/util.c 91d4cb189476906639ae611927d939691d1365f6
F src/vacuum.c b4569b08aaa5afb141af3f76d0315745db4e9e4b
@ -346,7 +346,7 @@ F test/vacuum.test cf839fc3ff24d601057319bbb5c700ce9c8e0fb0
F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
F test/view.test 852bd4101e6d171c46ad682eb5c5faf662b2eba4
F test/vtab1.test 03c4ad3180b78866993ef56af9d3b7c145ea4e4d
F test/vtab1.test bbfeb479bc851993403d7f08cf071b34d0e3b4c2
F test/vtab2.test 94bb3bf691ac10e34cf7dad46b1cf94b861d513c
F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587
F test/vtab4.test a9d7104d41a787754a734740d7aa61c807a69f87
@ -432,7 +432,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P b18a758a8fbd4b286ae3475af26f290d8cd583f0
R 566ea5b1e0dfed2e2d241f4a3621febf
U drh
Z 7bc0929710516af4b73ecceb079cfb42
P 0aa9ed5bbfb756967a6f761c5fc2f274a5466e2d
R 98e0805557833324ac0d74cfb90c7da0
U danielk1977
Z e3ab03cd2238ee707de29025b46b5b2c

View File

@ -1 +1 @@
0aa9ed5bbfb756967a6f761c5fc2f274a5466e2d
43bf797842f00a104f5c5619ad3215edddfc641b

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 */

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.39 2007/01/09 14:01:14 drh Exp $
# $Id: vtab1.test,v 1.40 2007/02/21 16:52:12 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -889,6 +889,29 @@ do_test vtab1.11-5 {
SELECT glob(a,'2') FROM e
}
} {{2 1} {2 2}}
# See ticket #2244
#
do_test vtab1.2244-1 {
execsql {
CREATE TABLE t2244(a, b);
CREATE VIRTUAL TABLE t2244e USING echo(t2244);
INSERT INTO t2244 VALUES('AA', 'BB');
INSERT INTO t2244 VALUES('CC', 'DD');
SELECT rowid, * FROM t2244e;
}
} {1 AA BB 2 CC DD}
do_test vtab1.2244-2 {
execsql {
SELECT * FROM t2244e WHERE rowid = 10;
}
} {}
do_test vtab1.2244-3 {
execsql {
UPDATE t2244e SET a = 'hello world' WHERE 0;
SELECT rowid, * FROM t2244e;
}
} {1 AA BB 2 CC DD}
unset -nocomplain echo_module_begin_fail
finish_test