On Fri, Sep 21, 2012 at 11:44:09PM +0200, Jörgen Hägglund scratched on the wall:
> I tried creating a super simple test which just return "default" > values on all calls. > This is the order my functions are being called: > xCreate (enter function) > xCreate (exit function) > xConnect (enter function) > xConnect (exit function) > At this point I get an access violation in SQLite3.dll (reading of > address 00000008) > I have tried everything I can think of, but this is how far I get. Did you allocate a sqlite3_vtab structure and pass it back? You also need to set *errMsg and (*vtab)->zErrMsg to NULL. > I then tried a simple test in VS2010 where I include sqlite3.h (that > is, no DLL). > Using the same calls/queries as in Delphi, I get this order of calls: > xConnect (enter function) > xConnect (exit function) > xDisconnect (enter function) > xDisconnect (exit function) > xConnect (enter function) > xConnect (exit function) > xCommit (enter function) > xCommit (exit function) > xBestIndex (enter function) > xBestIndex (exit function) > And here the application crashes sending Windows to search for a solution. That's really odd since, xBestIndex is one of the functions that can do absolutly nothing but return, and everything should still work. > The SQL statement used to create my virtual table, in both cases, is: > CREATE TABLE x (Severity TEXT, Source TEXT, IP TEXT, Message TEXT) > > And, finally, both cases are run against a newly created database. > > Does anyone have any ideas to what I'm doing wrong? Virtual tables are powerful and advanced. There are no safe-guards or double-checks in the code, as there are with some of the more basic interfaces. SQLite expects your code to be perfect, and if it isn't, it will likely crash. Make sure you read the docs very, very carefully and do *exactly* what they say. Make no assumptions. > Anyone having some source of how to implement a really simple > virtual table (in any language)? There is a fairly large chapter in "Using SQLite" that attempts to cover virtual tables in some detail. It also goes through two full examples. Even if you don't want to buy the book, you can download the example code here: http://shop.oreilly.com/product/9780596521196.do Just use the "Download Example Code" link on the right side of the page. Have a look at the examples from chapter 10. > I am aware of that I am uncertain of how to implement xBestIndex, > but that is my next headache, I guess... :) Yeah, xBestIndex takes a bit to wrap your head around, but don't worry about it too much. Unless you're writing a VT that provides a specialized index, you can usually just ignore it and get the basic VT working with table scans before you worry about making the VT index aware. A lot of the VT modules I write don't use xBestIndex. -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