SQLite

Check-in [d6a7bf80cf]
Login

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

Overview
Comment:Update test case for opening SHM files read/write on a read-only connection so that they are only attempted on Darwin with SQLITE_ENABLE_PRESIST_WAL.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA1: d6a7bf80cfb0cdca2bd684adfaba2c3e8053f8a4
User & Date: drh 2016-11-26 20:12:40.118
Context
2016-11-26
20:44
Merge all recent trunk changes, and especially the new sqlite3_snapshot_recover() interface. (check-in: 41a3af5443 user: drh tags: apple-osx)
20:12
Update test case for opening SHM files read/write on a read-only connection so that they are only attempted on Darwin with SQLITE_ENABLE_PRESIST_WAL. (check-in: d6a7bf80cf user: drh tags: apple-osx)
2016-11-17
14:02
When opening the *-shm file for a readonly database, try to open it in read-write mode before falling back to readonly. This is in case some other read/write connection within the same process uses the same file descriptor. (check-in: a07c581e88 user: dan tags: apple-osx)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/walro.test.
302
303
304
305
306
307
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365


366
367
    code1 { db close }
    code1 { tv delete }
  } {}
}

forcedelete $shmpath




#----------------------------------------------------------------------------

catch {db2 close}
reset_db
do_execsql_test 3.1 {
  CREATE TABLE t1(a, b);
  PRAGMA journal_mode = wal;
  INSERT INTO t1 VALUES(1, 2);
} {wal}
db_save
db close
db_restore

sqlite3 db test.db -readonly 1

do_execsql_test 3.2 { SELECT * FROM t1 } {1 2}
do_catchsql_test 3.3 { 
  INSERT INTO t1 VALUES(3, 4) 
} {1 {attempt to write a readonly database}}

sqlite3 db2 test.db
do_test 3.4 { 
  db2 eval { INSERT INTO t1 VALUES(3, 4) }
} {}
do_execsql_test 3.5 { SELECT * FROM t1 } {1 2 3 4}

db close
db2 close
db_restore
file attributes $shmpath -permissions r--r--r--
sqlite3 db test.db -readonly 1
do_execsql_test 3.6 { SELECT * FROM t1 } {1 2}

db close
db_restore
file attributes $shmpath -permissions r--r--r--
sqlite3 db test.db
do_test 3.7 {
  catchsql { SELECT * FROM t1 } 
} {1 {unable to open database file}}

db close
db_restore
file attributes $shmpath -permissions r--r--r--
sqlite3 db test.db -readonly 1
do_execsql_test 3.8 { SELECT * FROM t1 } {1 2}

sqlite3 db2 test.db
do_test 3.9 { db2 eval { SELECT * FROM t1 } } {1 2}
do_test 3.10 { 
  catchsql { INSERT INTO t1 VALUES(3, 4) } db2 
} {1 {attempt to write a readonly database}}

catch { db close }
catch { db2 close }

forcedelete $shmpath



finish_test







>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
|

302
303
304
305
306
307
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
    code1 { db close }
    code1 { tv delete }
  } {}
}

forcedelete $shmpath

if {$tcl_platform(os)=="Darwin"} {
  ifcapable enable_persist_wal {

    #--------------------------------------------------------------------------
    
    catch {db2 close}
    reset_db
    do_execsql_test 3.1 {
      CREATE TABLE t1(a, b);
      PRAGMA journal_mode = wal;
      INSERT INTO t1 VALUES(1, 2);
    } {wal}
    db_save
    db close
    db_restore
    
    sqlite3 db test.db -readonly 1
    
    do_execsql_test 3.2 { SELECT * FROM t1 } {1 2}
    do_catchsql_test 3.3 { 
      INSERT INTO t1 VALUES(3, 4) 
    } {1 {attempt to write a readonly database}}
    
    sqlite3 db2 test.db
    do_test 3.4 { 
      db2 eval { INSERT INTO t1 VALUES(3, 4) }
    } {}
    do_execsql_test 3.5 { SELECT * FROM t1 } {1 2 3 4}
    
    db close
    db2 close
    db_restore
    file attributes $shmpath -permissions r--r--r--
    sqlite3 db test.db -readonly 1
    do_execsql_test 3.6 { SELECT * FROM t1 } {1 2}
    
    db close
    db_restore
    file attributes $shmpath -permissions r--r--r--
    sqlite3 db test.db
    do_test 3.7 {
      catchsql { SELECT * FROM t1 } 
    } {1 {unable to open database file}}
    
    db close
    db_restore
    file attributes $shmpath -permissions r--r--r--
    sqlite3 db test.db -readonly 1
    do_execsql_test 3.8 { SELECT * FROM t1 } {1 2}
    
    sqlite3 db2 test.db
    do_test 3.9 { db2 eval { SELECT * FROM t1 } } {1 2}
    do_test 3.10 { 
      catchsql { INSERT INTO t1 VALUES(3, 4) } db2 
    } {1 {attempt to write a readonly database}}
    
    catch { db close }
    catch { db2 close }
    
    forcedelete $shmpath
  } ;# endif capable enable_persist_wal
} ;# endif os Darwin
    
finish_test