SQLite

Check-in [1e1321ee98]
Login

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

Overview
Comment:Fix a faulty assert() in sqlite3BtreeBeginTrans() that may fail in shared-cache mode.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1e1321ee985370c2b7e5bd64286bb4d7704b5a30
User & Date: dan 2013-09-26 11:04:33.317
References
2013-09-26
15:21
Obtain the required shared-cache write-lock when executing "DELETE FROM tbl" statements. Fix for [1e1321ee98]. (check-in: 1f8f4fdf3f user: dan tags: trunk)
Context
2013-09-26
15:21
Obtain the required shared-cache write-lock when executing "DELETE FROM tbl" statements. Fix for [1e1321ee98]. (check-in: 1f8f4fdf3f user: dan tags: trunk)
11:04
Fix a faulty assert() in sqlite3BtreeBeginTrans() that may fail in shared-cache mode. (check-in: 1e1321ee98 user: dan tags: trunk)
2013-09-18
11:16
Test that the unicode61 tokenchars= and separators= options work with the fts3tokenize virtual table. (check-in: ed24051462 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
  /* If the btree is already in a write-transaction, or it
  ** is already in a read-transaction and a read-transaction
  ** is requested, this is a no-op.
  */
  if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){
    goto trans_begun;
  }
  assert( IfNotOmitAV(pBt->bDoTruncate)==0 );

  /* Write transactions are not possible on a read-only database */
  if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){
    rc = SQLITE_READONLY;
    goto trans_begun;
  }








|







2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
  /* If the btree is already in a write-transaction, or it
  ** is already in a read-transaction and a read-transaction
  ** is requested, this is a no-op.
  */
  if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){
    goto trans_begun;
  }
  assert( pBt->inTransaction==TRANS_WRITE || IfNotOmitAV(pBt->bDoTruncate)==0 );

  /* Write transactions are not possible on a read-only database */
  if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){
    rc = SQLITE_READONLY;
    goto trans_begun;
  }

Changes to test/shared3.test.
9
10
11
12
13
14
15

16
17
18
19
20
21
22
#
#***********************************************************************
#
# $Id: shared3.test,v 1.4 2008/08/20 14:49:25 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]







>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
#
# $Id: shared3.test,v 1.4 2008/08/20 14:49:25 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix shared3
db close

ifcapable !shared_cache {
  finish_test
  return
}
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
98
99
100
101
102
103
104
105

































106
107

  catch { sqlite3 db3 $alternative_name }
  catchsql {select count(*) from sqlite_master} db3
} {1 {database is locked}}

db1 close
db2 close
db3 close


































sqlite3_enable_shared_cache $::enable_shared_cache
finish_test









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
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
132
133
134
135
136
137
138
139
140
141
142
  catch { sqlite3 db3 $alternative_name }
  catchsql {select count(*) from sqlite_master} db3
} {1 {database is locked}}

db1 close
db2 close
db3 close

#-------------------------------------------------------------------------
# At one point this was causing a faulty assert to fail.
#
forcedelete test.db
sqlite3 db test.db
sqlite3 db2 test.db
do_execsql_test 3.1 {
  PRAGMA auto_vacuum = 2;
  CREATE TABLE t1(x, y);
  INSERT INTO t1 VALUES(randomblob(500), randomblob(500));
  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
}
do_test 3.2 {
  execsql { SELECT count(*) FROM sqlite_master } db2
} {1}
do_execsql_test 3.3 {
  BEGIN;
    DELETE FROM t1 WHERE 1;
    PRAGMA incremental_vacuum;
} {}
do_test 3.4 {
  execsql { SELECT count(*) FROM sqlite_master } db2
} {1}
do_test 3.5 {
  execsql { COMMIT }
} {}

sqlite3_enable_shared_cache $::enable_shared_cache
finish_test