133f4e02aSdrh# 2007 Sep 3 233f4e02aSdrh# 333f4e02aSdrh# The author disclaims copyright to this source code. In place of 433f4e02aSdrh# a legal notice, here is a blessing: 533f4e02aSdrh# 633f4e02aSdrh# May you do good and not evil. 733f4e02aSdrh# May you find forgiveness for yourself and forgive others. 833f4e02aSdrh# May you share freely, never taking more than you give. 933f4e02aSdrh# 1033f4e02aSdrh#*********************************************************************** 1133f4e02aSdrh# 1233f4e02aSdrh# Tests on the sqlite3_open_v2() interface. 1333f4e02aSdrh# 14aed24608Sdrh# $Id: openv2.test,v 1.2 2009/06/11 17:32:45 drh Exp $ 1533f4e02aSdrh 1633f4e02aSdrhset testdir [file dirname $argv0] 1733f4e02aSdrhsource $testdir/tester.tcl 1833f4e02aSdrh 1933f4e02aSdrhdb close 20*fda06befSmistachkinforcedelete test.db test.db-journal 2133f4e02aSdrhdo_test openv2-1.1 { 2233f4e02aSdrh set rc [catch {sqlite3 db test.db -create 0} msg] 2333f4e02aSdrh lappend rc $msg 2433f4e02aSdrh} {1 {unable to open database file}} 2533f4e02aSdrhdo_test openv2-1.2 { 2633f4e02aSdrh info commands db 2733f4e02aSdrh} {} 2833f4e02aSdrhdo_test openv2-1.3 { 2933f4e02aSdrh sqlite3 db test.db 3033f4e02aSdrh db eval {CREATE TABLE t1(x)} 3133f4e02aSdrh db close 3233f4e02aSdrh sqlite3 db test.db -readonly 1 3333f4e02aSdrh db eval {SELECT name FROM sqlite_master} 3433f4e02aSdrh} {t1} 3533f4e02aSdrhdo_test openv2-1.4 { 3633f4e02aSdrh catchsql { 3733f4e02aSdrh INSERT INTO t1 VALUES(123) 3833f4e02aSdrh } 3933f4e02aSdrh} {1 {attempt to write a readonly database}} 4033f4e02aSdrh 41aed24608Sdrh# Ticket #3908 42aed24608Sdrh# Honor SQLITE_OPEN_READONLY even on an in-memory database, even though 43aed24608Sdrh# this is pointless. 44aed24608Sdrh# 45aed24608Sdrhdo_test openv2-2.1 { 46aed24608Sdrh db close 47aed24608Sdrh sqlite3 db :memory: -readonly 1 48aed24608Sdrh db eval {SELECT * FROM sqlite_master} 49aed24608Sdrh} {} 50aed24608Sdrhdo_test openv2-2.2 { 51aed24608Sdrh catchsql {CREATE TABLE t1(x)} 52aed24608Sdrh} {1 {attempt to write a readonly database}} 53aed24608Sdrh 54aed24608Sdrh 5533f4e02aSdrhfinish_test 56