On Wed, Mar 07, 2012 at 08:58:27PM +0100, Steinar Midtskogen scratched on the wall: > I've created a module which will take a table as an argument. In > Xconnect it will run a query on that table. Then I accidently used > the name of the virtual table in the argument list: > > CREATE VIRTUAL TABLE v USING my_module(v); > > which seems to have triggered an infinite call loop. I suppose what's > going on is that when Xconnect
It should be xCreate() if it is a new table. > tries to run a query on that table, > SQLite will try to create the virtual table again, and then loops and > quickly overflows the stack. I doubt that is what is happening. More likely, the query is blocking in some way. SQLite would never automatically create a non-existent table you tried to access. How would it know what to create? I'm also not sure the VT name is valid until xCreate/xConnect has returned. What happens if you attempt to create a VT that references a non-existent table? Are you sure you're checking all the return values from the queires issued inside xCreate/xConnect? > Is this a SQLite bug, or should the virtual table code somehow detect > that the user is trying to create a virtual table using itself? Or > should the user be blamed? Hard to say until you figure out exactly what is going on. Still, I would put the blame on the VT code. Most VTs don't operate on existing tables, so there isn't any type of sanity checking. Allowing the user do do something dumb is an application bug. It is easy enough to check if the table that's being created and the arguments match. > In my opinion the cleanest approach would be that SQLite itself > determines that it has nested too deeply and gives an error. Except I doubt it is nesting or looping. There might be some argument that a VT's name shouldn't be valid inside the xConnect() call, but I'm not convinced it is without digging a bit more. VTs are very advance pieces of code. SQLite provides very little protection from dumb code when you're interfacing at that low a level. Preventing dumb stuff is pretty much always up to the VT code. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users