tkt1873.test 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # 2006 June 27
  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. # This file implements regression tests for SQLite library.
  12. #
  13. # This file implements tests to verify that ticket #1873 has been
  14. # fixed.
  15. #
  16. #
  17. # $Id: tkt1873.test,v 1.2 2007/10/09 08:29:33 danielk1977 Exp $
  18. set testdir [file dirname $argv0]
  19. source $testdir/tester.tcl
  20. ifcapable !attach {
  21. finish_test
  22. return
  23. }
  24. forcedelete test2.db test2.db-journal
  25. do_test tkt1873-1.1 {
  26. execsql {
  27. CREATE TABLE t1(x, y);
  28. ATTACH 'test2.db' AS aux;
  29. CREATE TABLE aux.t2(x, y);
  30. INSERT INTO t1 VALUES(1, 2);
  31. INSERT INTO t1 VALUES(3, 4);
  32. INSERT INTO t2 VALUES(5, 6);
  33. INSERT INTO t2 VALUES(7, 8);
  34. }
  35. } {}
  36. do_test tkt1873-1.2 {
  37. set rc [catch {
  38. db eval {SELECT * FROM t2 LIMIT 1} {
  39. db eval {DETACH aux}
  40. }
  41. } msg]
  42. list $rc $msg
  43. } {1 {database aux is locked}}
  44. do_test tkt1873-1.3 {
  45. set rc [catch {
  46. db eval {SELECT * FROM t1 LIMIT 1} {
  47. db eval {DETACH aux}
  48. }
  49. } msg]
  50. list $rc $msg
  51. } {0 {}}
  52. do_test tkt1873-1.4 {
  53. catchsql {
  54. select * from t2;
  55. }
  56. } {1 {no such table: t2}}
  57. do_test tkt1873-1.5 {
  58. catchsql {
  59. ATTACH 'test2.db' AS aux;
  60. select * from t2;
  61. }
  62. } {0 {5 6 7 8}}
  63. finish_test