Dennis Cote <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > > > > >Hmmm... In the later versions of sqlite with 64-bit ROWID values, doesn't it > >treat them as unsigned? It sure seems that autoincremented rowid values > >should always be positive...??? > > > > > > > No, SQLite treats them as 64 bit signed integers. The first 2^63 values > are positive, the next 2^63 values are negative. The problem I was > alluding to is, that the code that is extracting the range limited > values from SQLite into its own 32 integer values may treat those values > as signed 32 bit integers which will wrap to negative values after 2^31 > rows are inserted. if you are sorting by this id number, suddenly the > newest row has the lowest id not the largest id. SQLite itself will have > the same problem but only after 2^63 rows are inserted (and we don't > have enough time to wait for that to ever happen, its just too large a > number). >
The rowid does *not* wrap if you specify AUTOINCREMENT. Once the maximum rowid is used, all subsequent insert attempts return SQLITE_FULL. The regression test suite contains a test for this. Different rules apply if you do not use AUTOINCREMENT. There is a #define that may interest the original poster. If you compile with -DSQLITE_32BIT_ROWID=1, then rowids are limited to 32 bits. This feature is not particularly well tested (actually, I'm not sure it is tested at all) but it might work. It is worth a try, I suppose. -- D. Richard Hipp <[EMAIL PROTECTED]>