SQLite Forum

Troubleshooting corrupt indexes
Login
> I'm sure this custom function could conceivably cause this sort of error if it weren't properly deterministic

The function has to be more than simply deterministic. It has to obey all of the following restrictions lined out [in the docs][1]:

1.    If A==B then B==A.
2.    If A==B and B==C then A==C.
3.    If A<B THEN B>A.
4.    If A<B and B<C then A<C. 

If your collation function doesn't obey them all, corruption is possible.

[1]: https://sqlite.org/c3ref/create_collation.html