ocsigenserver icon indicating copy to clipboard operation
ocsigenserver copied to clipboard

Ocsipersist_sqlite assumption about ROWIDs

Open smondet opened this issue 10 years ago • 4 comments

Hi

this function db_iter_step (https://github.com/ocsigen/ocsigenserver/blob/master/src/extensions/ocsipersist-sqlite/ocsipersist.ml#L161) seems to assume that Sqlite's select statement returns increasing ROWID values.

I can't find that in Sqlite's documentation, how are we sure of that?

There is that warning in the documentation:

Important warning: this iterator may not iter on all data of the table if another thread is modifying it in the same time. Nonetheless, it should not miss more than a very few data from time to time, except if the table is very old (at least 9 223 372 036 854 775 807 insertions).

Maybe related to someone's hidden knowledge? :)

smondet avatar Jan 05 '15 22:01 smondet

I don't remember this. May be @kerneis has an idea?

balat avatar Jan 06 '15 12:01 balat

Looking at the seminal commit for ocsipersist_sqlite (d9e7c1fd3ac121cfaf6d10fe32e9757d7ba9c0c6), it looks like this code is mine indeed. But I can't remember the reasoning behind it. Probably something I found in a doc, but it might have changed in the meantime. And it was the very first time I used SQLite, so I may have been wrong too. Sorry.

kerneis avatar Jan 08 '15 09:01 kerneis

After some Googling, note that adding AUTOINCREMENT would ensure the correctness of this assumption (but I'm not saying you should use it, it has other drawbacks): https://www.sqlite.org/autoinc.html

kerneis avatar Jan 08 '15 09:01 kerneis

Oh no sorry, I'm confused. The issue here is with select, not insert.

kerneis avatar Jan 08 '15 10:01 kerneis