List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:March 15 1999 4:58pm
Subject:Re: Auto-Increment
View as plain text  
>>>>> "Oliver" == Oliver Artelt <oli@stripped> writes:

Oliver> On Sun, 14 Mar 1999, Tauren Mills wrote:

>> 
>> 
>> After reading the manual, I have a question about Auto-Increment...
>> 
>> The manual says that I can use this query to find out the value of the most
>> recent AUTO_INCREMENT field:
>> 
>> SELECT * FROM tbl_name WHERE auto_col IS NULL
>> 
Oliver> Lock the table before your INSERT and SELECT statement. Another way is to
Oliver> stamp the rows yourself, e.g. functions related to RPC.

Oliver> oli.

Hi!

No, there is no need to lock the rows in the above case.

The above query is automaticly transformed to:

SELECT * FROM tbl_name WHERE auto_col = LAST_INSERT_ID()

and the LAST_INSERT_ID() variable is thread safe (will not be affected 
by other clients)

Regards,
Monty
Thread
Auto-IncrementTauren Mills15 Mar
  • Re: Auto-IncrementOliver Artelt15 Mar
    • Re: Auto-IncrementMichael Widenius15 Mar