| OLD | NEW |
| 1 # 2008 October 29 | 1 # 2008 October 29 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 # file. Result: SQLITE_OK. | 39 # file. Result: SQLITE_OK. |
| 40 # | 40 # |
| 41 do_test tkt3457-1.1 { | 41 do_test tkt3457-1.1 { |
| 42 execsql { | 42 execsql { |
| 43 CREATE TABLE t1(a, b, c); | 43 CREATE TABLE t1(a, b, c); |
| 44 INSERT INTO t1 VALUES(1, 2, 3); | 44 INSERT INTO t1 VALUES(1, 2, 3); |
| 45 BEGIN; | 45 BEGIN; |
| 46 INSERT INTO t1 VALUES(4, 5, 6); | 46 INSERT INTO t1 VALUES(4, 5, 6); |
| 47 } | 47 } |
| 48 | 48 |
| 49 file copy -force test.db bak.db | 49 forcecopy test.db bak.db |
| 50 file copy -force test.db-journal bak.db-journal | 50 forcecopy test.db-journal bak.db-journal |
| 51 | 51 |
| 52 # Fix the first journal-header in the journal-file. Because the | 52 # Fix the first journal-header in the journal-file. Because the |
| 53 # journal file has not yet been synced, the 8-byte magic string at the | 53 # journal file has not yet been synced, the 8-byte magic string at the |
| 54 # start of the first journal-header has not been written by SQLite. | 54 # start of the first journal-header has not been written by SQLite. |
| 55 # So write it now. | 55 # So write it now. |
| 56 set fd [open bak.db-journal a+] | 56 set fd [open bak.db-journal a+] |
| 57 fconfigure $fd -encoding binary -translation binary | 57 fconfigure $fd -encoding binary -translation binary |
| 58 seek $fd 0 | 58 seek $fd 0 |
| 59 puts -nonewline $fd "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7" | 59 puts -nonewline $fd "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7" |
| 60 close $fd | 60 close $fd |
| 61 | 61 |
| 62 execsql COMMIT | 62 execsql COMMIT |
| 63 } {} | 63 } {} |
| 64 | 64 |
| 65 # Disable fchmod to make sure SQLite itself does not try to change the |
| 66 # permission bits on us |
| 67 # |
| 68 catch { |
| 69 test_syscall install fchmod |
| 70 test_syscall fault 1 1 |
| 71 } |
| 72 |
| 65 do_test tkt3457-1.2 { | 73 do_test tkt3457-1.2 { |
| 66 file copy -force bak.db-journal test.db-journal | 74 forcecopy bak.db-journal test.db-journal |
| 67 file attributes test.db-journal -permissions --------- | 75 file attributes test.db-journal -permissions --------- |
| 68 catchsql { SELECT * FROM t1 } | 76 catchsql { SELECT * FROM t1 } |
| 69 } {1 {unable to open database file}} | 77 } {1 {unable to open database file}} |
| 70 do_test tkt3457-1.3 { | 78 do_test tkt3457-1.3 { |
| 71 file copy -force bak.db-journal test.db-journal | 79 forcecopy bak.db-journal test.db-journal |
| 72 file attributes test.db-journal -permissions -w--w--w- | 80 file attributes test.db-journal -permissions -w--w--w- |
| 73 catchsql { SELECT * FROM t1 } | 81 catchsql { SELECT * FROM t1 } |
| 74 } {1 {unable to open database file}} | 82 } {1 {unable to open database file}} |
| 75 do_test tkt3457-1.4 { | 83 do_test tkt3457-1.4 { |
| 76 file copy -force bak.db-journal test.db-journal | 84 forcecopy bak.db-journal test.db-journal |
| 77 file attributes test.db-journal -permissions r--r--r-- | 85 file attributes test.db-journal -permissions r--r--r-- |
| 78 catchsql { SELECT * FROM t1 } | 86 catchsql { SELECT * FROM t1 } |
| 79 } {1 {unable to open database file}} | 87 } {1 {unable to open database file}} |
| 80 | 88 |
| 81 do_test tkt3457-1.5 { | 89 do_test tkt3457-1.5 { |
| 82 file copy -force bak.db-journal test.db-journal | 90 forcecopy bak.db-journal test.db-journal |
| 83 file attributes test.db-journal -permissions rw-rw-rw- | 91 file attributes test.db-journal -permissions rw-rw-rw- |
| 84 catchsql { SELECT * FROM t1 } | 92 catchsql { SELECT * FROM t1 } |
| 85 } {0 {1 2 3 4 5 6}} | 93 } {0 {1 2 3 4 5 6}} |
| 86 | 94 |
| 95 # Reenable fchmod |
| 96 catch { |
| 97 test_syscall uninstall |
| 98 test_syscall fault 0 0 |
| 99 } |
| 100 |
| 87 finish_test | 101 finish_test |
| OLD | NEW |