Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Save the position of any open cursors before a rollback. (CVS 3026) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
32d45bcf746e7e926b8cc8bd038d66e7 |
User & Date: | danielk1977 2006-01-24 14:21:24.000 |
Context
2006-01-24
| ||
16:37 | Handle errors in saving cursor positions during a rollback by aborting all active statements. (CVS 3027) (check-in: 5df9f022bf user: danielk1977 tags: trunk) | |
14:21 | Save the position of any open cursors before a rollback. (CVS 3026) (check-in: 32d45bcf74 user: danielk1977 tags: trunk) | |
13:09 | Return code was being dropped because of overridden variable in OP_IsUnique. Fix this and the test logic problem that hid it. (CVS 3025) (check-in: c30705a00d user: danielk1977 tags: trunk) | |
Changes
Changes to src/btree.c.
1 2 3 4 5 6 7 8 9 10 11 | /* ** 2004 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** 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. ** ************************************************************************* | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* ** 2004 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** 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. ** ************************************************************************* ** $Id: btree.c,v 1.310 2006/01/24 14:21:24 danielk1977 Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to ** ** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: ** "Sorting And Searching", pages 473-480. Addison-Wesley ** Publishing Company, Reading, Massachusetts. |
︙ | ︙ | |||
556 557 558 559 560 561 562 | ** with root-page iRoot. Usually, this is called just before cursor ** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()). */ static int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){ BtCursor *p; if( sqlite3ThreadDataReadOnly()->useSharedData ){ for(p=pBt->pCursor; p; p=p->pNext){ | > | | 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | ** with root-page iRoot. Usually, this is called just before cursor ** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()). */ static int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){ BtCursor *p; if( sqlite3ThreadDataReadOnly()->useSharedData ){ for(p=pBt->pCursor; p; p=p->pNext){ if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) && p->eState==CURSOR_VALID ){ int rc = saveCursorPosition(p); if( SQLITE_OK!=rc ){ return rc; } } } } |
︙ | ︙ | |||
2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 | ** are no active cursors, it also releases the read lock. */ int sqlite3BtreeRollback(Btree *p){ int rc = SQLITE_OK; BtShared *pBt = p->pBt; MemPage *pPage1; btreeIntegrity(p); unlockAllTables(p); if( p->inTrans==TRANS_WRITE ){ assert( TRANS_WRITE==pBt->inTransaction ); rc = sqlite3pager_rollback(pBt->pPager); | > > > > | 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 | ** are no active cursors, it also releases the read lock. */ int sqlite3BtreeRollback(Btree *p){ int rc = SQLITE_OK; BtShared *pBt = p->pBt; MemPage *pPage1; rc = saveAllCursors(pBt, 0, 0); if( rc!=SQLITE_OK ){ return rc; } btreeIntegrity(p); unlockAllTables(p); if( p->inTrans==TRANS_WRITE ){ assert( TRANS_WRITE==pBt->inTransaction ); rc = sqlite3pager_rollback(pBt->pPager); |
︙ | ︙ |
Changes to test/shared2.test.
1 2 3 4 5 6 7 8 9 10 11 | # 2005 January 19 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # 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. # #*********************************************************************** # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 2005 January 19 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # 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. # #*********************************************************************** # # $Id: shared2.test,v 1.3 2006/01/24 14:21:24 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl db close ifcapable !shared_cache { finish_test |
︙ | ︙ | |||
74 75 76 77 78 79 80 81 82 83 | DELETE FROM numbers; } db1 } } list $a $count } {32 64} db1 close db2 close | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 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 128 129 130 131 | DELETE FROM numbers; } db1 } } list $a $count } {32 64} # Rollback data into or out of a table while a read-uncommitted # cursor is scanning it. # do_test shared2-2.1 { execsql { INSERT INTO numbers VALUES(1, 'Medium length text field'); INSERT INTO numbers VALUES(2, 'Medium length text field'); INSERT INTO numbers VALUES(3, 'Medium length text field'); INSERT INTO numbers VALUES(4, 'Medium length text field'); BEGIN; DELETE FROM numbers WHERE (a%2)=0; } db1 set res [list] db2 eval { SELECT a FROM numbers ORDER BY a; } { lappend res $a if {$a==3} { execsql {ROLLBACK} db1 } } set res } {1 3 4} do_test shared2-2.2 { execsql { BEGIN; INSERT INTO numbers VALUES(5, 'Medium length text field'); INSERT INTO numbers VALUES(6, 'Medium length text field'); } db1 set res [list] db2 eval { SELECT a FROM numbers ORDER BY a; } { lappend res $a if {$a==5} { execsql {ROLLBACK} db1 } } set res } {1 2 3 4 5} db1 close db2 close do_test shared2-3.2 { sqlite3_thread_cleanup sqlite3_enable_shared_cache 1 } {0} sqlite3_enable_shared_cache $::enable_shared_cache finish_test |