Dnia 2014-01-08, śro o godzinie 03:02 +0100, Sylvain "Gugli" Guglielmi
pisze:
> I can have something like "UPDATE `roster-items` SET
> `object-sequence`=`object-sequence`+1" but his break uniqueness in the
> table.
I come from PostgreSQL, so explicitly handled sequences is natural to
me:
UPDATE "roster-items" SET "object-sequence" = nextval('object-sequence')
> I haven't found any easy ways to do something similar with
> LAST_INSERT_ID() or AUTO_INCREMENT in MySQL, hence my question.
StackOverflow [1] suggests a convoluted solution:
SELECT Auto_increment FROM information_schema.tables WHERE
table_name='the_table_you_want';
Not pretty.
I think you should be fine with manual increment or
MAX(`object-sequence`)+1
> Just to check : you're talking about the pools in "pool.h".
Yes.
> Maybe at one point it'll be better to use pools for roster items too (item,
> item->name,
> item->groups and its content). I've not yet profiled anything, but this
> may be a way to improve speed when loading user data for packet delivery
> (without having to code 2 load-user events).
I will gladly accept code submission if you decide to do it. :-)
[1]
http://stackoverflow.com/questions/12271235/mysql-query-next-sequence-number-for-mysql-auto-incremented-field
--
Tomasz Sterna @ http://abadcafe.pl/ @ http://www.xiaoka.com/