Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a problem causing the sqlite_master entry corresponding to a virtual table to be removed by a DROP TABLE even if the call to the vtabs xDestroy() method failed. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0140f6dbfbea93eadcd7f727d84064a0 |
User & Date: | dan 2018-12-28 17:45:08.487 |
Context
2018-12-28
| ||
18:09 | Fix another problem with loading the structure record from a corrupt fts5 database. (check-in: c4d44542d2 user: dan tags: trunk) | |
17:45 | Fix a problem causing the sqlite_master entry corresponding to a virtual table to be removed by a DROP TABLE even if the call to the vtabs xDestroy() method failed. (check-in: 0140f6dbfb user: dan tags: trunk) | |
14:33 | Avoid an undefined left-shift operation in fts5 caused by malformed utf-8 text. (check-in: c3a3a11194 user: dan tags: trunk) | |
Changes
Changes to src/build.c.
︙ | ︙ | |||
2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 | } /* Remove the table entry from SQLite's internal schema and modify ** the schema cookie. */ if( IsVirtual(pTab) ){ sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0); } sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0); sqlite3ChangeCookie(pParse, iDb); sqliteViewResetAll(db, iDb); } /* | > | 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 | } /* Remove the table entry from SQLite's internal schema and modify ** the schema cookie. */ if( IsVirtual(pTab) ){ sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0); sqlite3MayAbort(pParse); } sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0); sqlite3ChangeCookie(pParse, iDb); sqliteViewResetAll(db, iDb); } /* |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 | ** P4 is the name of a virtual table in database P1. Call the xDestroy method ** of that table. */ case OP_VDestroy: { db->nVDestroy++; rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z); db->nVDestroy--; if( rc ) goto abort_due_to_error; break; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VOpen P1 * * P4 * | > | 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 | ** P4 is the name of a virtual table in database P1. Call the xDestroy method ** of that table. */ case OP_VDestroy: { db->nVDestroy++; rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z); db->nVDestroy--; assert( p->errorAction==OE_Abort && p->usesStmtJournal ); if( rc ) goto abort_due_to_error; break; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VOpen P1 * * P4 * |
︙ | ︙ |
Changes to src/vdbeaux.c.
︙ | ︙ | |||
599 600 601 602 603 604 605 606 607 608 609 610 611 612 | VdbeOpIter sIter; memset(&sIter, 0, sizeof(sIter)); sIter.v = v; while( (pOp = opIterNext(&sIter))!=0 ){ int opcode = pOp->opcode; if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename || ((opcode==OP_Halt || opcode==OP_HaltIfNull) && ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort)) ){ hasAbort = 1; break; } if( opcode==OP_CreateBtree && pOp->p3==BTREE_INTKEY ) hasCreateTable = 1; | > | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | VdbeOpIter sIter; memset(&sIter, 0, sizeof(sIter)); sIter.v = v; while( (pOp = opIterNext(&sIter))!=0 ){ int opcode = pOp->opcode; if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename || opcode==OP_VDestroy || ((opcode==OP_Halt || opcode==OP_HaltIfNull) && ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort)) ){ hasAbort = 1; break; } if( opcode==OP_CreateBtree && pOp->p3==BTREE_INTKEY ) hasCreateTable = 1; |
︙ | ︙ |
Added test/vtabdrop.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | # 2018 December 28 # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # # The tests in this file test edge cases surrounding DROP TABLE on # virtual tables. # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !vtab { finish_test ; return } source $testdir/fts3_common.tcl source $testdir/malloc_common.tcl set testprefix vtabdrop #------------------------------------------------------------------------- # Test that if a DROP TABLE is executed against an rtree table, but the # xDestroy() call fails, the rtree table is not dropped, the sqlite_master # table is not modified and the internal schema remains intact. # ifcapable rtree { do_execsql_test 1.0 { CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2); CREATE TABLE t1(x, y); INSERT INTO t1 VALUES(1, 2); } do_test 1.1 { execsql { BEGIN; INSERT INTO t1 VALUES(3, 4); } db eval { SELECT * FROM t1 } { catchsql { DROP TABLE rt } } execsql COMMIT } {} do_execsql_test 1.2 { SELECT name FROM sqlite_master ORDER BY 1; SELECT * FROM t1; SELECT * FROM rt; } {rt rt_node rt_parent rt_rowid t1 1 2 3 4} db close sqlite3 db test.db do_execsql_test 1.3 { SELECT name FROM sqlite_master ORDER BY 1; } {rt rt_node rt_parent rt_rowid t1} } #------------------------------------------------------------------------- # Same as tests 1.*, except with fts5 instead of rtree. # ifcapable fts5 { reset_db do_execsql_test 2.0 { CREATE VIRTUAL TABLE ft USING fts5(x); CREATE TABLE t1(x, y); INSERT INTO t1 VALUES(1, 2); } do_test 2.1 { execsql { BEGIN; INSERT INTO t1 VALUES(3, 4); } db eval { SELECT * FROM t1 } { catchsql { DROP TABLE ft } } execsql COMMIT } {} do_execsql_test 2.2 { SELECT name FROM sqlite_master ORDER BY 1; } {ft ft_config ft_content ft_data ft_docsize ft_idx t1} db close sqlite3 db test.db do_execsql_test 2.3 { SELECT name FROM sqlite_master ORDER BY 1; } {ft ft_config ft_content ft_data ft_docsize ft_idx t1} } #------------------------------------------------------------------------- # Same as tests 1.*, except with fts3 instead of rtree. # ifcapable fts3 { reset_db do_execsql_test 2.0 { CREATE VIRTUAL TABLE ft USING fts3(x); CREATE TABLE t1(x, y); INSERT INTO t1 VALUES(1, 2); } do_test 2.1 { execsql { BEGIN; INSERT INTO t1 VALUES(3, 4); } db eval { SELECT * FROM t1 } { catchsql { DROP TABLE ft } } execsql COMMIT } {} do_execsql_test 2.2 { SELECT name FROM sqlite_master ORDER BY 1; } {ft ft_content ft_segdir ft_segments sqlite_autoindex_ft_segdir_1 t1} db close sqlite3 db test.db do_execsql_test 2.3 { SELECT name FROM sqlite_master ORDER BY 1; } {ft ft_content ft_segdir ft_segments sqlite_autoindex_ft_segdir_1 t1} } finish_test |