Check out this: http://www.mysql.com/doc/L/O/LOCK_TABLES.html

User 1 must do a 'write lock' on the table, before calling the insert
statement. Then User 2's qery will have to wait till User 1 calls Unlock.

USER 1  ===> WRITE LOCK
>
> USER 1  ===> INSERT
>              STOP <== due to process scheduling
>
> USER 2  ===> INSERT (this query will have to wait until the table is
inlocked
>              SELECT last_insert_id();
>
> USER 1  ===> SELECT last_insert_id();
>
USER 1  ===> UNLOCK

USER 2's query will be executed

> It's the race condition, I am talking about.

There won't be a race condition.

>
> > and retrieve the returned value
> >
> > or
> >
>
> > $last_thread_id = mysql_insert_id();
> > This function will not work properly if the auto-incrementing column
> > is
> > BigInt, because PHP does not have a BigInt equivalent. Int or smaller
> > works
> > fine.
> >
> > Brent
> >
> >
> >




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to