openv2.test 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # 2007 Sep 3
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  6. # May you do good and not evil.
  7. # May you find forgiveness for yourself and forgive others.
  8. # May you share freely, never taking more than you give.
  9. #
  10. #***********************************************************************
  11. #
  12. # Tests on the sqlite3_open_v2() interface.
  13. #
  14. # $Id: openv2.test,v 1.2 2009/06/11 17:32:45 drh Exp $
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. db close
  18. forcedelete test.db test.db-journal
  19. do_test openv2-1.1 {
  20. set rc [catch {sqlite3 db test.db -create 0} msg]
  21. lappend rc $msg
  22. } {1 {unable to open database file}}
  23. do_test openv2-1.2 {
  24. info commands db
  25. } {}
  26. do_test openv2-1.3 {
  27. sqlite3 db test.db
  28. db eval {CREATE TABLE t1(x)}
  29. db close
  30. sqlite3 db test.db -readonly 1
  31. db eval {SELECT name FROM sqlite_master}
  32. } {t1}
  33. do_test openv2-1.4 {
  34. catchsql {
  35. INSERT INTO t1 VALUES(123)
  36. }
  37. } {1 {attempt to write a readonly database}}
  38. # Ticket #3908
  39. # Honor SQLITE_OPEN_READONLY even on an in-memory database, even though
  40. # this is pointless.
  41. #
  42. do_test openv2-2.1 {
  43. db close
  44. sqlite3 db :memory: -readonly 1
  45. db eval {SELECT * FROM sqlite_master}
  46. } {}
  47. do_test openv2-2.2 {
  48. catchsql {CREATE TABLE t1(x)}
  49. } {1 {attempt to write a readonly database}}
  50. finish_test