Re: Practical question.

Поиск
Список
Период
Сортировка
От Joshua D. Drake
Тема Re: Practical question.
Дата
Msg-id 45FA1C30.9080800@commandprompt.com
обсуждение исходный текст
Ответ на Re: Practical question.  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Practical question.
Список pgsql-general
Tom Lane wrote:
> louis gonzales <gonzales@linuxlouis.net> writes:
>> As an example:
>> insertX which initiates the trigger reads the 'nextvalue' from the
>> sequence and begins to create the associcated table
>> insertY happens almost at the same time, so that it gets the same
>> 'nextvalue' from the sequence

That won't happen because of isolation :). When InsertX increments the
sequence, it is forever incremented, so when InsertY increments it gets
the next value... e.g;

CREATE TABLE foo(id serial);

Transaction 1:
BEGIN;
INSERT INTO foo(id) VALUES (DEFAULT);
id now == 1

Transaction 2:
BEGIN;
INSERT INTO foo(id) VALUES (DEFAULT);
id now == 2

Transaction 1;
COMMIT;

Transaction 2;
COMMIT;

Even if Transaction 1 were to rollback, it has already incremented the
sequence so the next transaction would get 3.

Joshua D. Drake



>
> [ blink... ]  Whatever makes you think that could happen?
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>


--

      === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive  PostgreSQL solutions since 1997
             http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/


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

Предыдущее
От: louis gonzales
Дата:
Сообщение: Re: Practical question.
Следующее
От: louis gonzales
Дата:
Сообщение: Re: Practical question.