/ Check-in [8021b4c8]
Login

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

Overview
Comment:Simplification of the DROP TRIGGER logic using sqlite3NestedParse() instead of hand-coded VDBE code. This is a manual cherry-pick of the key change from check-in [c80bbf14b365d].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8021b4c8139ba56d6b1e2e26aeec4f9bf77f37c9
User & Date: drh 2015-12-09 16:26:38
Context
2015-12-09
17:23
Further simplifications to the VDBE code generation logic that flow out of the previous check-in. check-in: 6a5dfe85 user: drh tags: trunk
16:26
Simplification of the DROP TRIGGER logic using sqlite3NestedParse() instead of hand-coded VDBE code. This is a manual cherry-pick of the key change from check-in [c80bbf14b365d]. check-in: 8021b4c8 user: drh tags: trunk
2015-12-08
16:58
Changes to avoid undefined behavior in memset() and memcpy() and in the comparisons of pointers from different allocations. All problems are found by analysis tools - none have been seen in the wild. check-in: 901d0b8f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/trigger.c.

   555    555     }
   556    556   #endif
   557    557   
   558    558     /* Generate code to destroy the database record of the trigger.
   559    559     */
   560    560     assert( pTable!=0 );
   561    561     if( (v = sqlite3GetVdbe(pParse))!=0 ){
   562         -    int base;
   563         -    static const int iLn = VDBE_OFFSET_LINENO(2);
   564         -    static const VdbeOpList dropTrigger[] = {
   565         -      { OP_Rewind,     0, ADDR(9),  0},
   566         -      { OP_String8,    0, 1,        0}, /* 1 */
   567         -      { OP_Column,     0, 1,        2},
   568         -      { OP_Ne,         2, ADDR(8),  1},
   569         -      { OP_String8,    0, 1,        0}, /* 4: "trigger" */
   570         -      { OP_Column,     0, 0,        2},
   571         -      { OP_Ne,         2, ADDR(8),  1},
   572         -      { OP_Delete,     0, 0,        0},
   573         -      { OP_Next,       0, ADDR(1),  0}, /* 8 */
   574         -    };
   575         -
   576         -    sqlite3BeginWriteOperation(pParse, 0, iDb);
   577         -    sqlite3OpenMasterTable(pParse, iDb);
   578         -    base = sqlite3VdbeAddOpList(v,  ArraySize(dropTrigger), dropTrigger, iLn);
   579         -    sqlite3VdbeChangeP4(v, base+1, pTrigger->zName, P4_TRANSIENT);
   580         -    sqlite3VdbeChangeP4(v, base+4, "trigger", P4_STATIC);
          562  +    sqlite3NestedParse(pParse,
          563  +       "DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'",
          564  +       db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pTrigger->zName
          565  +    );
   581    566       sqlite3ChangeCookie(pParse, iDb);
   582         -    sqlite3VdbeAddOp2(v, OP_Close, 0, 0);
   583    567       sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);
   584         -    if( pParse->nMem<3 ){
   585         -      pParse->nMem = 3;
   586         -    }
   587    568     }
   588    569   }
   589    570   
   590    571   /*
   591    572   ** Remove a trigger from the hash tables of the sqlite* pointer.
   592    573   */
   593    574   void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){