1
0

tkt3080.test 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # 2008 April 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. #
  12. # Ticket #3080
  13. #
  14. # Make sure that application-defined functions are able to recursively
  15. # invoke SQL statements that create and drop virtual tables.
  16. #
  17. # $Id: tkt3080.test,v 1.2 2008/11/05 16:37:35 drh Exp $
  18. #
  19. set testdir [file dirname $argv0]
  20. source $testdir/tester.tcl
  21. do_test tkt3080.1 {
  22. db function execsql execsql
  23. db eval {
  24. SELECT execsql('CREATE TABLE t1(x)');
  25. }
  26. execsql {SELECT name FROM sqlite_master}
  27. } {t1}
  28. do_test tkt3080.2 {
  29. db eval {
  30. INSERT INTO t1 VALUES('CREATE TABLE t2(y);');
  31. SELECT execsql(x) FROM t1;
  32. }
  33. db eval {
  34. SELECT name FROM sqlite_master;
  35. }
  36. } {t1 t2}
  37. do_test tkt3080.3 {
  38. execsql {
  39. INSERT INTO t1 VALUES('CREATE TABLE t3(z); DROP TABLE t3;');
  40. }
  41. catchsql {
  42. SELECT execsql(x) FROM t1 WHERE rowid=2;
  43. }
  44. } {1 {database table is locked}}
  45. do_test tkt3080.4 {
  46. db eval {
  47. SELECT name FROM sqlite_master;
  48. }
  49. } {t1 t2 t3}
  50. ifcapable vtab {
  51. register_echo_module [sqlite3_connection_pointer db]
  52. do_test tkt3080.10 {
  53. set sql {
  54. CREATE VIRTUAL TABLE t4 USING echo(t2);
  55. INSERT INTO t4 VALUES(123);
  56. DROP TABLE t4;
  57. }
  58. execsql {
  59. DELETE FROM t1;
  60. INSERT INTO t1 VALUES($sql);
  61. }
  62. db eval {
  63. SELECT execsql(x) FROM t1
  64. }
  65. execsql {SELECT name FROM sqlite_master}
  66. } {t1 t2 t3}
  67. do_test tkt3080.11 {
  68. execsql {SELECT * FROM t2}
  69. } {123}
  70. }
  71. finish_test