On Thu, Jun 28, 2012 at 4:32 PM, Simon Slavin <slav...@bigfraud.org> wrote:
> I think SQLite4 will need to support AUTOINCREMENT for INTEGERs because so 
> many SQL users will assume that it's supported.

Sure.  At least for UNIQUE and PRIMARY KEY fields it's possible with
reasonable semantics.  *Assuming* b-trees.  For hash-type tables it's
slightly harder.

> But the use of AUTOINCREMENT for key fields is really something more like 
> 'always be able to generate a unique value'.  There's no reason, for 
> instance, why it shouldn't work for a TEXT column or even a BLOB.  So support 
> for it can be presented like the max() function: find the highest value so 
> far, and use it to generate one a little higher. You could even expose a 
> genuine SQLite4 aggregate function for it, and insist that anyone who defines 
> a new column type supply the function to be used to generate the next value.

Interesting idea.  max() might be slow unless it means "last for the
expression's collation".  Just seek to the end of the b-tree for the
keys for the column in question, then generate a new key that would
sort right after it.

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

Reply via email to