Re: [BUGS] probably a bug of data-type serial

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема Re: [BUGS] probably a bug of data-type serial
Дата
Msg-id 200110181836.OAA11037@smtp6.mindspring.com
обсуждение исходный текст
Список pgsql-patches
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> This is intentional. If the sequence number were to roll
> back, then a later transaction trying to get the next sequence
> number would have to wait to determine if you've rolled back
> before getting the number. Sequences are defined to try to
> give unique, increasing numbers, not actually sequential ones.

I often have the need for unique, sequential numbers, so I
do the following:

1. Create a table to store the value, usually as an integer column
2. Lock that table in exclusive mode
3. Grab the current value with a select statement
4. Try and do something with the value, usually involving
   sticking the value into anoter table
5. If it fails, simply exit
6. If it succeeds, do an update and increase the value by one
7. Commit (and unlock the table)

Question: is this the best way to do this? I am being careful
so nobody accesses the particular table without using the
logic above.

Thanks,
Greg Sabino Mullane
greg@turnstep.com
PGP Key: 0x14964AC8 200110171428

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iQA/AwUBO88hrLybkGcUlkrIEQKHWACg4oH4zuV40UGDrr3irh20SW/BkmUAoO5W
FpndyZQj7Joj5/6eXA2w35g3
=dIeb
-----END PGP SIGNATURE-----


В списке pgsql-patches по дате отправления:

Предыдущее
От: "Greg Sabino Mullane"
Дата:
Сообщение: Re: Showing index details with \d on psql
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Ant configuration