SQLite

Check-in [ef58f163b0]
Login

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

Overview
Comment:Do not delete tables with the same name when dropping triggers. Ticket #430. (CVS 1074)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ef58f163b08d13f8e9b69459bd83e0bf9d5b404b
User & Date: drh 2003-08-16 12:37:52.000
Context
2003-08-16
13:10
Make the compile work under cygwin. Tickets #327, #213, #316, #322, #349, #373, and #429. (CVS 1075) (check-in: 7d8d3252df user: drh tags: trunk)
12:37
Do not delete tables with the same name when dropping triggers. Ticket #430. (CVS 1074) (check-in: ef58f163b0 user: drh tags: trunk)
2003-08-15
13:24
Fix a segfault that occurs in the VACUUM command if run on an empty database with the EMPTY_RESULT_CALLBACKS pragma enabled. Ticket #427. (CVS 1073) (check-in: 3563e9cf9d user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/trigger.c.
446
447
448
449
450
451
452
453
454
455
456

457
458
459
460
461
462
463
464
465
466
467
#endif

  /* Generate code to destroy the database record of the trigger.
  */
  if( pTable!=0 && !nested && (v = sqliteGetVdbe(pParse))!=0 ){
    int base;
    static VdbeOp dropTrigger[] = {
      { OP_Rewind,     0, ADDR(8),  0},
      { OP_String,     0, 0,        0}, /* 1 */
      { OP_MemStore,   1, 1,        0},
      { OP_MemLoad,    1, 0,        0}, /* 3 */

      { OP_Column,     0, 1,        0},
      { OP_Ne,         0, ADDR(7),  0},
      { OP_Delete,     0, 0,        0},
      { OP_Next,       0, ADDR(3),  0}, /* 7 */
    };

    sqliteBeginWriteOperation(pParse, 0, 0);
    sqliteOpenMasterTable(v, pTrigger->iDb);
    base = sqliteVdbeAddOpList(v,  ArraySize(dropTrigger), dropTrigger);
    sqliteVdbeChangeP3(v, base+1, pTrigger->name, 0);
    if( pTrigger->iDb==0 ){







|

|
|
>
|
|

|







446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
#endif

  /* Generate code to destroy the database record of the trigger.
  */
  if( pTable!=0 && !nested && (v = sqliteGetVdbe(pParse))!=0 ){
    int base;
    static VdbeOp dropTrigger[] = {
      { OP_Rewind,     0, ADDR(9),  0},
      { OP_String,     0, 0,        0}, /* 1 */
      { OP_Column,     0, 1,        0},
      { OP_Ne,         0, ADDR(8),  0},
      { OP_String,     0, 0,        "trigger"},
      { OP_Column,     0, 0,        0},
      { OP_Ne,         0, ADDR(8),  0},
      { OP_Delete,     0, 0,        0},
      { OP_Next,       0, ADDR(1),  0}, /* 8 */
    };

    sqliteBeginWriteOperation(pParse, 0, 0);
    sqliteOpenMasterTable(v, pTrigger->iDb);
    base = sqliteVdbeAddOpList(v,  ArraySize(dropTrigger), dropTrigger);
    sqliteVdbeChangeP3(v, base+1, pTrigger->name, 0);
    if( pTrigger->iDb==0 ){
Changes to src/vdbe.c.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.235 2003/07/27 17:16:07 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** The makefile scans this source file and creates the following







|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.236 2003/08/16 12:37:52 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** The makefile scans this source file and creates the following
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
  char *tz;
  VERIFY( if( from<0 ) goto not_enough_stack; )
  Deephemeralize(p, from);
  ts = aStack[from];
  tz = zStack[from];
  Deephemeralize(p, to);
  for(i=from; i<to; i++){
    Deephemeralize(p, i);
    aStack[i] = aStack[i+1];
    assert( (aStack[i].flags & STK_Ephem)==0 );
    if( aStack[i].flags & (STK_Dyn|STK_Static) ){
      zStack[i] = zStack[i+1];
    }else{
      zStack[i] = aStack[i].z;
    }







|







1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
  char *tz;
  VERIFY( if( from<0 ) goto not_enough_stack; )
  Deephemeralize(p, from);
  ts = aStack[from];
  tz = zStack[from];
  Deephemeralize(p, to);
  for(i=from; i<to; i++){
    Deephemeralize(p, i+1);
    aStack[i] = aStack[i+1];
    assert( (aStack[i].flags & STK_Ephem)==0 );
    if( aStack[i].flags & (STK_Dyn|STK_Static) ){
      zStack[i] = zStack[i+1];
    }else{
      zStack[i] = aStack[i].z;
    }
Changes to test/trigger1.test.
304
305
306
307
308
309
310











































311
312
  sqlite db test.db
  execsql {
    SELECT * FROM t2;
  };
} {3 4 7 8}

integrity_check trigger-5.1












































finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
  sqlite db test.db
  execsql {
    SELECT * FROM t2;
  };
} {3 4 7 8}

integrity_check trigger-5.1

# Create a trigger with the same name as a table.  Make sure the
# trigger works.  Then drop the trigger.  Make sure the table is
# still there.
#
do_test trigger-6.1 {
  execsql {SELECT type, name FROM sqlite_master}
} {view v1 table t2}
do_test trigger-6.2 {
  execsql {
    CREATE TRIGGER t2 BEFORE DELETE ON t2 BEGIN
      SELECT RAISE(ABORT,'deletes are not allows');
    END;
    SELECT type, name FROM sqlite_master;
  }
} {view v1 table t2 trigger t2}
do_test trigger-6.3 {
  catchsql {DELETE FROM t2}
} {1 {deletes are not allows}}
do_test trigger-6.4 {
  execsql {SELECT * FROM t2}
} {3 4 7 8}
do_test trigger-6.5 {
  db close
  sqlite db test.db
  execsql {SELECT type, name FROM sqlite_master}
} {view v1 table t2 trigger t2}
do_test trigger-6.6 {
  execsql {
    DROP TRIGGER t2;
    SELECT type, name FROM sqlite_master;
  }
} {view v1 table t2}
do_test trigger-6.7 {
  execsql {SELECT * FROM t2}
} {3 4 7 8}
do_test trigger-6.8 {
  db close
  sqlite db test.db
  execsql {SELECT * FROM t2}
} {3 4 7 8}

integrity_check trigger-7.1    

finish_test