tkt-f7b4edec.test 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # 2011 March 18
  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
  14. # [f7b4edece25c994857dc139207f55a53c8319fae] has been fixed.
  15. #
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. # Open two database connections to the same database file in
  19. # shared cache mode. Create update hooks that will fire on
  20. # each connection.
  21. #
  22. db close
  23. set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
  24. sqlite3 db1 test.db
  25. sqlite3 db2 test.db
  26. unset -nocomplain HOOKS
  27. set HOOKS {}
  28. proc update_hook {args} { lappend ::HOOKS $args }
  29. db1 update_hook update_hook
  30. db2 update_hook update_hook
  31. # Create a prepared statement
  32. #
  33. do_test tkt-f7b4edec-1 {
  34. execsql { CREATE TABLE t1(x, y); } db1
  35. execsql { INSERT INTO t1 VALUES(1, 2) } db1
  36. set ::HOOKS
  37. } {{INSERT main t1 1}}
  38. # In the second database connection cause the schema to be reparsed
  39. # without changing the schema cookie.
  40. #
  41. set HOOKS {}
  42. do_test tkt-f7b4edec-2 {
  43. execsql {
  44. BEGIN;
  45. DROP TABLE t1;
  46. CREATE TABLE t1(x, y);
  47. ROLLBACK;
  48. } db2
  49. set ::HOOKS
  50. } {}
  51. # Rerun the prepared statement that was created prior to the
  52. # schema reparse. Verify that the update-hook gives the correct
  53. # output.
  54. #
  55. set HOOKS {}
  56. do_test tkt-f7b4edec-3 {
  57. execsql { INSERT INTO t1 VALUES(1, 2) } db1
  58. set ::HOOKS
  59. } {{INSERT main t1 2}}
  60. # Be sure to restore the original shared-cache mode setting before
  61. # returning.
  62. #
  63. db1 close
  64. db2 close
  65. sqlite3_enable_shared_cache $::enable_shared_cache
  66. finish_test