/ Check-in [f7ce74b2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Modify the fix for #2244 to avoid using a vdbe label. (CVS 3653)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f7ce74b22ab739b8c8599cdc605aa9da1f5b5be5
User & Date: danielk1977 2007-02-21 17:04:04
Context
2007-02-22
23:06
Make the depth of the pushdown automaton stack generated by lemon changable at compile-time using -DYYSTACKDEPTH=<number>. (CVS 3654) check-in: d8845ac1 user: drh tags: trunk
2007-02-21
17:04
Modify the fix for #2244 to avoid using a vdbe label. (CVS 3653) check-in: f7ce74b2 user: danielk1977 tags: trunk
16:52
Fix for an UPDATE on a virtual table when the WHERE clause matches zero rows. Ticket #2244. (CVS 3652) check-in: 43bf7978 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/update.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle UPDATE statements.
    14     14   **
    15         -** $Id: update.c,v 1.135 2007/02/21 16:52:12 danielk1977 Exp $
           15  +** $Id: update.c,v 1.136 2007/02/21 17:04:04 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   #ifndef SQLITE_OMIT_VIRTUALTABLE
    20     20   /* Forward declaration */
    21     21   static void updateVirtualTable(
    22     22     Parse *pParse,       /* The parsing context */
................................................................................
   564    564     Vdbe *v = pParse->pVdbe;  /* Virtual machine under construction */
   565    565     ExprList *pEList = 0;     /* The result set of the SELECT statement */
   566    566     Select *pSelect = 0;      /* The SELECT statement */
   567    567     Expr *pExpr;              /* Temporary expression */
   568    568     int ephemTab;             /* Table holding the result of the SELECT */
   569    569     int i;                    /* Loop counter */
   570    570     int addr;                 /* Address of top of loop */
   571         -  int iLabel;               /* Vdbe label used by the OP_Rewind op */
   572    571   
   573    572     /* Construct the SELECT statement that will find the new values for
   574    573     ** all updated rows. 
   575    574     */
   576    575     pEList = sqlite3ExprListAppend(0, sqlite3CreateIdExpr("_rowid_"), 0);
   577    576     if( pRowid ){
   578    577       pEList = sqlite3ExprListAppend(pEList, sqlite3ExprDup(pRowid), 0);
................................................................................
   599    598     */
   600    599     sqlite3Select(pParse, pSelect, SRT_Table, ephemTab, 0, 0, 0, 0);
   601    600   
   602    601     /*
   603    602     ** Generate code to scan the ephemeral table and call VDelete and
   604    603     ** VInsert
   605    604     */
   606         -  iLabel = sqlite3VdbeMakeLabel(v);
   607         -  sqlite3VdbeAddOp(v, OP_Rewind, ephemTab, iLabel);
          605  +  sqlite3VdbeAddOp(v, OP_Rewind, ephemTab, 0);
   608    606     addr = sqlite3VdbeCurrentAddr(v);
   609    607     sqlite3VdbeAddOp(v, OP_Column,  ephemTab, 0);
   610    608     if( pRowid ){
   611    609       sqlite3VdbeAddOp(v, OP_Column, ephemTab, 1);
   612    610     }else{
   613    611       sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
   614    612     }
................................................................................
   615    613     for(i=0; i<pTab->nCol; i++){
   616    614       sqlite3VdbeAddOp(v, OP_Column, ephemTab, i+1+(pRowid!=0));
   617    615     }
   618    616     pParse->pVirtualLock = pTab;
   619    617     sqlite3VdbeOp3(v, OP_VUpdate, 0, pTab->nCol+2, 
   620    618                        (const char*)pTab->pVtab, P3_VTAB);
   621    619     sqlite3VdbeAddOp(v, OP_Next, ephemTab, addr);
   622         -  sqlite3VdbeResolveLabel(v, iLabel);
          620  +  sqlite3VdbeJumpHere(v, addr-1);
   623    621     sqlite3VdbeAddOp(v, OP_Close, ephemTab, 0);
   624    622   
   625    623     /* Cleanup */
   626    624     sqlite3SelectDelete(pSelect);  
   627    625   }
   628    626   #endif /* SQLITE_OMIT_VIRTUALTABLE */