mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Add tests to e_delete.test.
FossilOrigin-Name: fab3b383bb2c4764a56811f22ff4c783441918e8
This commit is contained in:
@ -2322,6 +2322,12 @@ splitnode_out:
|
||||
** If node pLeaf is not the root of the r-tree and its pParent pointer is
|
||||
** still NULL, load all ancestor nodes of pLeaf into memory and populate
|
||||
** the pLeaf->pParent chain all the way up to the root node.
|
||||
**
|
||||
** This operation is required when a row is deleted (or updated - an update
|
||||
** is implemented as a delete followed by an insert). SQLite provides the
|
||||
** rowid of the row to delete, which can be used to find the leaf on which
|
||||
** the entry resides (argument pLeaf). Once the leaf is located, this
|
||||
** function is called to determine its ancestry.
|
||||
*/
|
||||
static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){
|
||||
int rc = SQLITE_OK;
|
||||
@ -2331,8 +2337,15 @@ static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){
|
||||
sqlite3_bind_int64(pRtree->pReadParent, 1, pChild->iNode);
|
||||
rc = sqlite3_step(pRtree->pReadParent);
|
||||
if( rc==SQLITE_ROW ){
|
||||
RtreeNode *pTest;
|
||||
i64 iNode = sqlite3_column_int64(pRtree->pReadParent, 0);
|
||||
RtreeNode *pTest; /* Used to test for reference loops */
|
||||
i64 iNode; /* Node number of parent node */
|
||||
|
||||
/* Before setting pChild->pParent, test that we are not creating a
|
||||
** loop of references (as we would if, say, pChild==pParent). We don't
|
||||
** want to do this as it leads to a memory leak when trying to delete
|
||||
** the referenced counted node structures.
|
||||
*/
|
||||
iNode = sqlite3_column_int64(pRtree->pReadParent, 0);
|
||||
for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent);
|
||||
if( !pTest ){
|
||||
rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent);
|
||||
|
@ -24,6 +24,7 @@ proc create_t1 {} {
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
PRAGMA page_size = 1024;
|
||||
CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2, y1, y2);
|
||||
}
|
||||
}
|
||||
@ -73,7 +74,6 @@ proc set_entry_count {tbl nodeno {newvalue ""}} {
|
||||
}
|
||||
|
||||
|
||||
|
||||
proc do_corruption_tests {prefix args} {
|
||||
set testarray [lindex $args end]
|
||||
set errormsg {database disk image is malformed}
|
||||
@ -213,6 +213,7 @@ do_execsql_test rtreeA-6.1.0 {
|
||||
} {}
|
||||
do_corruption_tests rtreeA-6.1 {
|
||||
1 "DELETE FROM t1 WHERE rowid = 5"
|
||||
2 "UPDATE t1 SET x1=x1+1, x2=x2+1"
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user