Jean-Christophe Deschamps wrote:
> I need to have a context* for use inside a collation function (to
> report possible memory allocation errors for instance), but the spec
> for collation doesn't give me a context pointer, only an
> sqlite3*.

I'm not sure where you are seeing this. The collation function doesn't 
have a sqlite3* parameter - it takes a void*. sqlite3_create_collation 
also has a void* parameter, stores it, and passes it along to the 
collation function every time it's called. That's how you typically pass 
any context information to your collation function.

> Now when I encounter, say, a malloc error, what should I do before
> returning from the collation invokation?

SQLite doesn't seem prepared to handle the case of a collation function 
failing. When this happens, to maintain database integrity, any 
transaction in progress should be rolled back immediately. You should be 
able to do that with sqlite3_interrupt, or you could instruct the 
calling code in some way to do that.

It would be best, of course, to write your collation function in such a 
way that it can't fail.

Igor Tandetnik



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to