/ Check-in [1a757ba1]
Login

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

Overview
Comment:Fixed stack growth in delete trigger on views (tkt #1169) (CVS 2442)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:1a757ba13292577d01bd7b66811bcfd6748b9f7e
User & Date: kwel 2005-04-08 16:07:48
Context
2005-04-08
16:08
Fixed stack growth in update trigger on views (tkt #1169) (CVS 2443) check-in: 99fcd556 user: kwel tags: trunk
16:07
Fixed stack growth in delete trigger on views (tkt #1169) (CVS 2442) check-in: 1a757ba1 user: kwel tags: trunk
2005-04-03
23:54
Apply Tcl 'nullvalue' patch from Stefan Finzel. (CVS 2441) check-in: 9906ae37 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/delete.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   ** in order to generate code for DELETE FROM statements.
    14     14   **
    15         -** $Id: delete.c,v 1.102 2005/03/16 12:15:21 danielk1977 Exp $
           15  +** $Id: delete.c,v 1.103 2005/04/08 16:07:48 kwel Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Look up every table that is named in pSrc.  If any table is not found,
    21     21   ** add an error message to pParse->zErrMsg and return NULL.  If all tables
    22     22   ** are found, return a pointer to the last table.
................................................................................
   260    260       end = sqlite3VdbeMakeLabel(v);
   261    261   
   262    262       /* This is the beginning of the delete loop when there are
   263    263       ** row triggers.
   264    264       */
   265    265       if( triggers_exist ){
   266    266         addr = sqlite3VdbeAddOp(v, OP_ListRead, 0, end);
   267         -      sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
   268    267         if( !isView ){
          268  +        sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
   269    269           sqlite3OpenTableForReading(v, iCur, pTab);
   270    270         }
   271    271         sqlite3VdbeAddOp(v, OP_MoveGe, iCur, 0);
   272    272         sqlite3VdbeAddOp(v, OP_Recno, iCur, 0);
   273    273         sqlite3VdbeAddOp(v, OP_RowData, iCur, 0);
   274    274         sqlite3VdbeAddOp(v, OP_PutIntKey, oldIdx, 0);
   275    275         if( !isView ){
   276    276           sqlite3VdbeAddOp(v, OP_Close, iCur, 0);
   277    277         }
   278    278   
   279    279         (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_BEFORE, pTab,
   280    280             -1, oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,
   281         -	  addr);
          281  +          addr);
   282    282       }
   283    283   
   284    284       if( !isView ){
   285    285         /* Open cursors for the table we are deleting from and all its
   286    286         ** indices.  If there are row triggers, this happens inside the
   287    287         ** OP_ListRead loop because the cursor have to all be closed
   288    288         ** before the trigger fires.  If there are no row triggers, the
................................................................................
   308    308           for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
   309    309             sqlite3VdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);
   310    310           }
   311    311           sqlite3VdbeAddOp(v, OP_Close, iCur, 0);
   312    312         }
   313    313         (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_AFTER, pTab, -1,
   314    314             oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,
   315         -	  addr);
          315  +          addr);
   316    316       }
   317    317   
   318    318       /* End of the delete loop */
   319    319       sqlite3VdbeAddOp(v, OP_Goto, 0, addr);
   320    320       sqlite3VdbeResolveLabel(v, end);
   321    321       sqlite3VdbeAddOp(v, OP_ListReset, 0, 0);
   322    322