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

When materializing a view for an UPDATE or DELETE make use of the WHERE

clause to limit the number of rows materialized.  Ticket #2938. (CVS 4782)

FossilOrigin-Name: 5ab71c3a79cac04cb2c576f83a62218d05571006
This commit is contained in:
drh
2008-02-12 16:52:14 +00:00
parent 8e5b5f8e54
commit 0f35a6b529
7 changed files with 305 additions and 46 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.170 2008/01/19 03:35:59 drh Exp $
** $Id: update.c,v 1.171 2008/02/12 16:52:14 drh Exp $
*/
#include "sqliteInt.h"
@@ -289,13 +289,6 @@ void sqlite3Update(
}
#endif
/* Resolve the column names in all the expressions in the
** WHERE clause.
*/
if( sqlite3ExprResolveNames(&sNC, pWhere) ){
goto update_cleanup;
}
/* Start the view context
*/
if( isView ){
@@ -335,14 +328,15 @@ void sqlite3Update(
** a ephemeral table.
*/
if( isView ){
Select *pView;
SelectDest dest;
sqlite3MaterializeView(pParse, pTab->pSelect, pWhere,
old_col_mask|new_col_mask, iCur);
}
pView = sqlite3SelectDup(db, pTab->pSelect);
sqlite3SelectMask(pParse, pView, old_col_mask|new_col_mask);
sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);
sqlite3Select(pParse, pView, &dest, 0, 0, 0, 0);
sqlite3SelectDelete(pView);
/* Resolve the column names in all the expressions in the
** WHERE clause.
*/
if( sqlite3ExprResolveNames(&sNC, pWhere) ){
goto update_cleanup;
}
/* Begin the database scan