Subject | Re: [firebird-support] Getting a unique value from a generator |
---|---|
Author | Mitchell Peek |
Post date | 2005-05-12T19:39:56Z |
helen or someone will reply later and tell me how wrong I am ;), but....
First, it isn't really possible for 2 users to execute the statement at
the *exact* same time, one has to come before the other... but anyway....
Generators operate outside of user transactions. Test it. A rollback
leaves the generator as it was whether you rollback or commit.
Therefore, it isn't possible for the same value to be returned if you
assume they are the only two statements going on. However, if there
were a third user such that the execution occurred in this manner....
user 1
SELECT GEN_ID(EXPORTLOCK_SEQ, -1)
FROM RDB$DATABASE;
user 2
SELECT GEN_ID(EXPORTLOCK_SEQ, 1)
FROM RDB$DATABASE
user 3
SELECT GEN_ID(EXPORTLOCK_SEQ, -1)
FROM RDB$DATABASE
then users 1 and 3 will get the same value.
Is this a possibility?
Peter Ypenburg wrote:
First, it isn't really possible for 2 users to execute the statement at
the *exact* same time, one has to come before the other... but anyway....
Generators operate outside of user transactions. Test it. A rollback
leaves the generator as it was whether you rollback or commit.
Therefore, it isn't possible for the same value to be returned if you
assume they are the only two statements going on. However, if there
were a third user such that the execution occurred in this manner....
user 1
SELECT GEN_ID(EXPORTLOCK_SEQ, -1)
FROM RDB$DATABASE;
user 2
SELECT GEN_ID(EXPORTLOCK_SEQ, 1)
FROM RDB$DATABASE
user 3
SELECT GEN_ID(EXPORTLOCK_SEQ, -1)
FROM RDB$DATABASE
then users 1 and 3 will get the same value.
Is this a possibility?
Peter Ypenburg wrote:
>Hi There,
>
>Is it possible for two users who run the following SQL at the exact same
>time (each in their own transaction) to get the same value back from a
>generator. The SQL is as follows:
>
>SELECT GEN_ID(EXPORTLOCK_SEQ, -1)
>FROM RDB$DATABASE
>
>Thanks.
>
>Peter Ypenburg
>AGM: Product Development
>Barloworld Optimus
>Tel +2711 286 1587 Fax +2711 286 1630 Cell +2782 789 9167
>www.barloworldoptimus.com
>
>Disclaimer
>
>The information transmitted is the property of Barloworld Optimus Pty (Ltd)
>and is intended only for the person or entity to which it is addressed and
>may contain confidential and/or privileged material. Statements and opinions
>expressed in this e-mail may not represent those of the company. Any review,
>retransmission, dissemination and other use of, or taking of any action in
>reliance upon, this information by persons or entities other than the
>intended recipient is prohibited. If you received this in error, please
>contact the sender immediately and delete the material from any computer.
>
>
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Visit http://firebird.sourceforge.net and click the Resources item
>on the main (top) menu. Try Knowledgebase and FAQ links !
>
>Also search the knowledgebases at http://www.ibphoenix.com
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>