SQLite

Check-in [9ca2c50770]
Login

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

Overview
Comment:Detect when the test scripts are being run as root and issue an appropriate error message. (CVS 740)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9ca2c507704f85446d873d5e8429554f2ad4df9e
User & Date: drh 2002-09-02 12:14:51.000
Context
2002-09-02
14:11
Add documentation on NULL handling in SQLite versus other SQL database engines. (CVS 741) (check-in: dd8867fc47 user: drh tags: trunk)
12:14
Detect when the test scripts are being run as root and issue an appropriate error message. (CVS 740) (check-in: 9ca2c50770 user: drh tags: trunk)
2002-09-01
23:20
Relax the locking requirements on BTree cursors. Any number of read and write cursors can be open at the same time now, but a write cannot occur as long as one or more read cursors are open.

Before this change, one or more read cursors could be open on a table, or a single write cursor, but not both. Both policies have the same desirable effect: they prevent writes to a table while a sequential scan of that table is underway. But the new policy is a little less restrictive. Both policies prevent an UPDATE from occurring inside a SELECT (which is what we want) but the new policy allows a SELECT to occur inside an UPDATE. (CVS 739) (check-in: 8c2a083698 user: drh tags: trunk)

Changes
Unified Diff Ignore Whitespace Patch
Changes to test/btree.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2001 September 15
#
# 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.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is btree database backend
#
# $Id: btree.test,v 1.12 2002/02/19 13:39:23 drh Exp $


set testdir [file dirname $argv0]
source $testdir/tester.tcl

if {[info commands btree_open]!=""} {














|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2001 September 15
#
# 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.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is btree database backend
#
# $Id: btree.test,v 1.13 2002/09/02 12:14:51 drh Exp $


set testdir [file dirname $argv0]
source $testdir/tester.tcl

if {[info commands btree_open]!=""} {

340
341
342
343
344
345
346

347
348
349
350
351
352
353
  btree_close $::b1
  set ::b1 [btree_open test1.bt]
  set ::c1 [btree_cursor $::b1 2 1]
  lindex [btree_pager_stats $::b1] 1
} {2}
do_test btree-4.9 {
  set r {}

  while 1 {
    set key [btree_key $::c1]
    if {$key==""} break
    lappend r $key
    lappend r [btree_data $::c1]
    btree_next $::c1
  }







>







340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
  btree_close $::b1
  set ::b1 [btree_open test1.bt]
  set ::c1 [btree_cursor $::b1 2 1]
  lindex [btree_pager_stats $::b1] 1
} {2}
do_test btree-4.9 {
  set r {}
  btree_first $::c1
  while 1 {
    set key [btree_key $::c1]
    if {$key==""} break
    lappend r $key
    lappend r [btree_data $::c1]
    btree_next $::c1
  }
Changes to test/temptable.test.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for temporary tables and indices.
#
# $Id: temptable.test,v 1.7 2002/06/25 01:09:12 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Create an alternative connection to the database
#
do_test temptable-1.0 {







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for temporary tables and indices.
#
# $Id: temptable.test,v 1.8 2002/09/02 12:14:51 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Create an alternative connection to the database
#
do_test temptable-1.0 {
308
309
310
311
312
313
314



315
316
317
318
319



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335



336
337
338
339
340
341
342
  }
} {xyzzy}
do_test temptable-6.2 {
  db close
  catch {file attributes test.db -permissions 0444}
  catch {file attributes test.db -readonly 1}
  sqlite db test.db



  execsql {
    SELECT * FROM t8;
  }
} {xyzzy}
do_test temptable-6.3 {



  catchsql {
    CREATE TABLE t9(x,y);
  }
} {1 {attempt to write a readonly database}}
do_test temptable-6.4 {
  catchsql {
    CREATE TEMP TABLE t9(x,y);
  }
} {0 {}}
do_test temptable-6.5 {
  catchsql {
    INSERT INTO t9 VALUES(1,2);
    SELECT * FROM t9;
  }
} {0 {1 2}}
do_test temptable-6.6 {



  catchsql {
    INSERT INTO t8 VALUES('hello');
    SELECT * FROM t8;
  }
} {1 {attempt to write a readonly database}}
do_test temptable-6.7 {
  catchsql {







>
>
>





>
>
>
















>
>
>







308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
  }
} {xyzzy}
do_test temptable-6.2 {
  db close
  catch {file attributes test.db -permissions 0444}
  catch {file attributes test.db -readonly 1}
  sqlite db test.db
  if {[file writable test.db]} {
    error "Unable to make the database file test.db readonly - rerun this test as an unprivileged user"
  }
  execsql {
    SELECT * FROM t8;
  }
} {xyzzy}
do_test temptable-6.3 {
  if {[file writable test.db]} {
    error "Unable to make the database file test.db readonly - rerun this test as an unprivileged user"
  }
  catchsql {
    CREATE TABLE t9(x,y);
  }
} {1 {attempt to write a readonly database}}
do_test temptable-6.4 {
  catchsql {
    CREATE TEMP TABLE t9(x,y);
  }
} {0 {}}
do_test temptable-6.5 {
  catchsql {
    INSERT INTO t9 VALUES(1,2);
    SELECT * FROM t9;
  }
} {0 {1 2}}
do_test temptable-6.6 {
  if {[file writable test.db]} {
    error "Unable to make the database file test.db readonly - rerun this test as an unprivileged user"
  }
  catchsql {
    INSERT INTO t8 VALUES('hello');
    SELECT * FROM t8;
  }
} {1 {attempt to write a readonly database}}
do_test temptable-6.7 {
  catchsql {
Changes to test/version.test.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the ability of the library to detect
# past or future file format version numbers and respond appropriately.
#
# $Id: version.test,v 1.7 2002/08/29 23:59:50 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Current file format version
set VX 4








|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the ability of the library to detect
# past or future file format version numbers and respond appropriately.
#
# $Id: version.test,v 1.8 2002/09/02 12:14:51 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Current file format version
set VX 4

173
174
175
176
177
178
179



180
181
182
183
184
185
186
  set m2 [lreplace $::meta 2 2 2]
  btree_begin_transaction $::bt
  eval btree_update_meta $::bt $m2
  btree_commit $::bt
  btree_close $::bt
  catch {file attributes test.db -permissions 0444}
  catch {file attributes test.db -readonly 1}



  set rc [catch {sqlite db test.db} msg]
  lappend rc $msg
} {1 {unable to upgrade database to the version 2.6 format: attempt to write a readonly database}}
do_test version-2.2 {
  file delete -force test.db
  set fd [open test.db w]
  set txt "This is not a valid database file\n"







>
>
>







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
  set m2 [lreplace $::meta 2 2 2]
  btree_begin_transaction $::bt
  eval btree_update_meta $::bt $m2
  btree_commit $::bt
  btree_close $::bt
  catch {file attributes test.db -permissions 0444}
  catch {file attributes test.db -readonly 1}
  if {[file writable test.db]} {
    error "Unable to make the database file test.db readonly - rerun this test as an unprivileged user"
  }
  set rc [catch {sqlite db test.db} msg]
  lappend rc $msg
} {1 {unable to upgrade database to the version 2.6 format: attempt to write a readonly database}}
do_test version-2.2 {
  file delete -force test.db
  set fd [open test.db w]
  set txt "This is not a valid database file\n"