Re: [sqlite] bounded id

2017-03-15 Thread Clemens Ladisch
Jan Danielsson wrote:
> I can't make the rowid a uint32_t, but that's essentially the
> behavior I'm looking for

CREATE TABLE transfers (
ID  INTEGER PRIMARY KEY  CHECK (ID BETWEEN 0 AND 4294967295),
[...]
);

But if you want the values to wrap around after old ones have been
deleted, you have to implement it yourself.  (A random search is
efficient as long as the set of actually used IDs is sparse.)


Regards,
Clemens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] bounded id

2017-03-15 Thread Jan Danielsson
Hello,

   I have a wire-protocol which uses an uint32_t to identify transfers,
and each of the transfers is represented by a row in a table in an
sqlite database.

   I can't make the rowid a uint32_t, but that's essentially the
behavior I'm looking for -- I'd like to be able to insert a new row into
the table, then ask for the last inserted row id and use that identifier
in the wire-protocol.  Are there any good options to accomplish this
[limit the auto-assigned identifier]?

   The obvious solution is to record-keep identifiers outside of the
database, but the sqlite database is responsible for assigning other
other identifiers; it would be nice not to break that abstraction if
possible.

-- 
Kind regards,
Jan Danielsson

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users