mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Account for read-uncommitted cursors in sqlite3BtreeClearTable(). (CVS 2977)
FossilOrigin-Name: 950798326860de40926e82e10134f09e6ea86245
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
# This file contains test cases focused on the two memory-management APIs,
|
||||
# sqlite3_soft_heap_limit() and sqlite3_release_memory().
|
||||
#
|
||||
# $Id: malloc5.test,v 1.6 2006/01/16 15:32:23 danielk1977 Exp $
|
||||
# $Id: malloc5.test,v 1.7 2006/01/19 08:43:32 danielk1977 Exp $
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# NOTES ON EXPECTED BEHAVIOUR
|
||||
@@ -192,6 +192,7 @@ do_test malloc5-4.1 {
|
||||
}
|
||||
execsql {COMMIT;}
|
||||
set ::nMaxBytes [sqlite_malloc_outstanding -maxbytes]
|
||||
if {$::nMaxBytes==""} {set ::nMaxBytes 1000001}
|
||||
expr $::nMaxBytes > 1000000
|
||||
} {1}
|
||||
do_test malloc5-4.2 {
|
||||
@@ -204,6 +205,7 @@ do_test malloc5-4.2 {
|
||||
}
|
||||
execsql {COMMIT;}
|
||||
set ::nMaxBytes [sqlite_malloc_outstanding -maxbytes]
|
||||
if {$::nMaxBytes==""} {set ::nMaxBytes 0}
|
||||
expr $::nMaxBytes <= 100000
|
||||
} {1}
|
||||
do_test malloc5-4.3 {
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# $Id: shared.test,v 1.18 2006/01/19 07:18:15 danielk1977 Exp $
|
||||
# $Id: shared.test,v 1.19 2006/01/19 08:43:32 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -60,6 +60,9 @@ incr av
|
||||
# are attached in different orders to different handles.
|
||||
# shared-6.*: Locking, UNION ALL queries and sub-queries.
|
||||
# shared-7.*: Autovacuum and shared-cache.
|
||||
# shared-8.*: Tests related to the text encoding of shared-cache databases.
|
||||
# shared-9.*: TEMP triggers and shared-cache databases.
|
||||
# shared-10.*: Tests of sqlite3_close().
|
||||
#
|
||||
|
||||
do_test shared-$av.1.1 {
|
||||
|
85
test/shared2.test
Normal file
85
test/shared2.test
Normal file
@@ -0,0 +1,85 @@
|
||||
# 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.1 2006/01/19 08:43:32 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
db close
|
||||
|
||||
ifcapable !shared_cache {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
|
||||
|
||||
|
||||
# Test that if we delete all rows from a table any read-uncommitted
|
||||
# cursors are correctly invalidated. Test on both table and index btrees.
|
||||
do_test shared2-1.1 {
|
||||
sqlite3 db1 test.db
|
||||
sqlite3 db2 test.db
|
||||
|
||||
# Set up some data. Table "numbers" has 64 rows after this block
|
||||
# is executed.
|
||||
execsql {
|
||||
BEGIN;
|
||||
CREATE TABLE numbers(a PRIMARY KEY, b);
|
||||
INSERT INTO numbers(oid) VALUES(NULL);
|
||||
INSERT INTO numbers(oid) SELECT NULL FROM numbers;
|
||||
INSERT INTO numbers(oid) SELECT NULL FROM numbers;
|
||||
INSERT INTO numbers(oid) SELECT NULL FROM numbers;
|
||||
INSERT INTO numbers(oid) SELECT NULL FROM numbers;
|
||||
INSERT INTO numbers(oid) SELECT NULL FROM numbers;
|
||||
INSERT INTO numbers(oid) SELECT NULL FROM numbers;
|
||||
UPDATE numbers set a = oid, b = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
COMMIT;
|
||||
} db1
|
||||
} {}
|
||||
do_test shared2-1.2 {
|
||||
# Put connection 2 in read-uncommitted mode and start a SELECT on table
|
||||
# 'numbers'. Half way through the SELECT, use connection 1 to delete the
|
||||
# contents of this table.
|
||||
execsql {
|
||||
pragma read_uncommitted = 1;
|
||||
} db2
|
||||
set count [execsql {SELECT count(*) FROM numbers} db2]
|
||||
db2 eval {SELECT a FROM numbers ORDER BY oid} {
|
||||
if {$a==32} {
|
||||
execsql {
|
||||
BEGIN;
|
||||
DELETE FROM numbers;
|
||||
} db1
|
||||
}
|
||||
}
|
||||
list $a $count
|
||||
} {32 64}
|
||||
do_test shared2-1.3 {
|
||||
# Same test as 1.2, except scan using the index this time.
|
||||
execsql {
|
||||
ROLLBACK;
|
||||
} db1
|
||||
set count [execsql {SELECT count(*) FROM numbers} db2]
|
||||
db2 eval {SELECT a, b FROM numbers ORDER BY a} {
|
||||
if {$a==32} {
|
||||
execsql {
|
||||
DELETE FROM numbers;
|
||||
} db1
|
||||
}
|
||||
}
|
||||
list $a $count
|
||||
} {32 64}
|
||||
|
||||
db1 close
|
||||
db2 close
|
||||
|
||||
sqlite3_enable_shared_cache $::enable_shared_cache
|
||||
finish_test
|
Reference in New Issue
Block a user