2010-07-15 18:59:37 +04:00
|
|
|
# 2010 July 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.
|
|
|
|
#
|
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
source $testdir/lock_common.tcl
|
|
|
|
source $testdir/malloc_common.tcl
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# If a connection is required to create a journal file, it creates it with
|
|
|
|
# the same file-system permissions as the database file itself. Test this.
|
|
|
|
#
|
2018-01-13 16:07:49 +03:00
|
|
|
if {$::tcl_platform(platform) == "unix"
|
|
|
|
&& [atomic_batch_write test.db]==0
|
|
|
|
} {
|
2010-07-15 18:59:37 +04:00
|
|
|
|
2012-02-14 00:16:37 +04:00
|
|
|
# Changed on 2012-02-13: umask is deliberately ignored for -wal, -journal,
|
|
|
|
# and -shm files.
|
|
|
|
#set umask [exec /bin/sh -c umask]
|
2010-07-15 18:59:37 +04:00
|
|
|
faultsim_delete_and_reopen
|
|
|
|
do_test journal3-1.1 { execsql { CREATE TABLE tx(y, z) } } {}
|
|
|
|
|
|
|
|
foreach {tn permissions} {
|
|
|
|
1 00644
|
|
|
|
2 00666
|
|
|
|
3 00600
|
|
|
|
4 00755
|
|
|
|
} {
|
|
|
|
db close
|
2012-02-14 00:16:37 +04:00
|
|
|
#set effective [format %.5o [expr $permissions & ~$umask]]
|
2019-11-25 07:15:33 +03:00
|
|
|
set res "/[regsub {^00} $permissions {0.}]/"
|
2019-04-12 19:25:42 +03:00
|
|
|
if {$tcl_version>=8.7} {
|
|
|
|
regsub {^00} $permissions {0o} permissions
|
|
|
|
}
|
2012-02-14 00:16:37 +04:00
|
|
|
set effective $permissions
|
2010-07-15 18:59:37 +04:00
|
|
|
do_test journal3-1.2.$tn.1 {
|
2011-08-02 04:57:34 +04:00
|
|
|
catch { forcedelete test.db-journal }
|
2010-07-15 18:59:37 +04:00
|
|
|
file attributes test.db -permissions $permissions
|
|
|
|
file attributes test.db -permissions
|
2019-11-25 07:15:33 +03:00
|
|
|
} $res
|
2010-07-15 18:59:37 +04:00
|
|
|
do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0}
|
|
|
|
do_test journal3-1.2.$tn.3 {
|
|
|
|
sqlite3 db test.db
|
|
|
|
execsql {
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO tx DEFAULT VALUES;
|
|
|
|
}
|
|
|
|
file exists test.db-journal
|
|
|
|
} {1}
|
|
|
|
do_test journal3-1.2.$tn.4 {
|
|
|
|
file attr test.db-journal -perm
|
2019-11-25 07:15:33 +03:00
|
|
|
} $res
|
2010-07-15 18:59:37 +04:00
|
|
|
do_execsql_test journal3-1.2.$tn.5 { ROLLBACK } {}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
finish_test
|