Posted to tcl by schelte at Wed Jul 12 15:31:07 GMT 2017view raw

  1. puts [package require sqlite3]
  2.  
  3. proc bla {data} {
  4. after 200 [list [info coroutine]]
  5. yield
  6. }
  7.  
  8. sqlite3 db :memory:
  9. db function bla bla
  10. db eval {
  11. create table foo (
  12. data text
  13. );
  14. create temp trigger insert_foo after insert on foo
  15. begin
  16. select bla(new.data);
  17. end;
  18. }
  19.  
  20. coroutine main try {
  21. db eval {insert into foo values('something')}
  22. } on error {str opts} {
  23. puts stderr [dict get $opts -errorinfo]
  24. } finally {
  25. exit
  26. }
  27.  
  28. vwait forever
  29.  
  30. Produces:
  31. 3.13.0
  32. cannot yield: C stack busy
  33. while executing
  34. "yield"
  35. (procedure "bla" line 3)
  36. invoked from within
  37. "bla something"
  38. invoked from within
  39. "db eval {insert into foo values('something')}"
  40. ("try" body line 2)
  41.