Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Partial fix for ticket #49. The correct result is computed, but now we have a memory leak. I'm not sure if the memory leak was pre-existing or a result of this change. (CVS 581) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
4d27ee411902a197cd72416ca9da9197 |
User & Date: | drh 2002-05-23 12:50:18.000 |
Context
2002-05-23
| ||
13:15 | Fix for ticket #50. (CVS 582) (check-in: 82b74a494a user: drh tags: trunk) | |
12:50 | Partial fix for ticket #49. The correct result is computed, but now we have a memory leak. I'm not sure if the memory leak was pre-existing or a result of this change. (CVS 581) (check-in: 4d27ee4119 user: drh tags: trunk) | |
02:09 | Fix some places where a malloc() failure would lead to a segfault. (CVS 580) (check-in: 01ad352c3c user: drh tags: trunk) | |
Changes
Changes to src/delete.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle DELETE FROM statements. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle DELETE FROM statements. ** ** $Id: delete.c,v 1.35 2002/05/23 12:50:18 drh Exp $ */ #include "sqliteInt.h" /* ** Given a table name, find the corresponding table and make sure the ** table is writeable. Generate an error and return NULL if not. If |
︙ | ︙ | |||
328 329 330 331 332 333 334 | */ void sqliteGenerateRowDelete( Vdbe *v, /* Generate code into this VDBE */ Table *pTab, /* Table containing the row to be deleted */ int base, /* Cursor number for the table */ int count /* Increment the row change counter */ ){ | > | > | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | */ void sqliteGenerateRowDelete( Vdbe *v, /* Generate code into this VDBE */ Table *pTab, /* Table containing the row to be deleted */ int base, /* Cursor number for the table */ int count /* Increment the row change counter */ ){ int addr; addr = sqliteVdbeAddOp(v, OP_NotExists, base, 0); sqliteGenerateRowIndexDelete(v, pTab, base, 0); sqliteVdbeAddOp(v, OP_Delete, base, count); sqliteVdbeChangeP2(v, addr, sqliteVdbeCurrentAddr(v)); } /* ** This routine generates VDBE code that causes the deletion of all ** index entries associated with a single row of a single table. ** ** The VDBE must be in a particular state when this routine is called. |
︙ | ︙ |
Changes to src/update.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** ** $Id: update.c,v 1.41 2002/05/23 12:50:19 drh Exp $ */ #include "sqliteInt.h" /* ** Process an UPDATE statement. */ void sqliteUpdate( |
︙ | ︙ | |||
283 284 285 286 287 288 289 | */ if( !row_triggers_exist ){ int ii; sqliteVdbeAddOp(v, OP_ListRewind, 0, 0); addr = sqliteVdbeAddOp(v, OP_ListRead, 0, 0); sqliteVdbeAddOp(v, OP_Dup, 0, 0); } | | | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | */ if( !row_triggers_exist ){ int ii; sqliteVdbeAddOp(v, OP_ListRewind, 0, 0); addr = sqliteVdbeAddOp(v, OP_ListRead, 0, 0); sqliteVdbeAddOp(v, OP_Dup, 0, 0); } sqliteVdbeAddOp(v, OP_NotExists, base, addr); /* If the record number will change, push the record number as it ** will be after the update. (The old record number is currently ** on top of the stack.) */ if( chngRecno ){ if( pTab->iPKey<0 || (j = aXRef[pTab->iPKey])<0 ){ |
︙ | ︙ |
Changes to test/trigger1.test.
︙ | ︙ | |||
106 107 108 109 110 111 112 | catchsql { CREATE TRIGGER tr1 AFTER UPDATE ON sqlite_master BEGIN SELECT * FROM sqlite_master; END; } } {1 {cannot create trigger on system table: sqlite_master}} | > > > > > | > > > > > > > > > > | | > > | > > > > > > > > > > | | > | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | catchsql { CREATE TRIGGER tr1 AFTER UPDATE ON sqlite_master BEGIN SELECT * FROM sqlite_master; END; } } {1 {cannot create trigger on system table: sqlite_master}} # Check to make sure that a DELETE statement within the body of # a trigger does not mess up the DELETE that caused the trigger to # run in the first place. # do_test trig_cd-1.10 { execsql { create table t1(a,b); insert into t1 values(1,'a'); insert into t1 values(2,'b'); insert into t1 values(3,'c'); insert into t1 values(4,'d'); create trigger r1 after delete on t1 for each row begin delete from t1 WHERE a=old.a+2; end; delete from t1 where a in (1,3); select * from t1; drop table t1; } } {2 b 4 d} do_test trig_cd-1.11 { execsql { create table t1(a,b); insert into t1 values(1,'a'); insert into t1 values(2,'b'); insert into t1 values(3,'c'); insert into t1 values(4,'d'); create trigger r1 after update on t1 for each row begin delete from t1 WHERE a=old.a+2; end; update t1 set b='x-' || b where a in (1,3); select * from t1; drop table t1; } } {1 x-a 2 b 4 d} finish_test |