List:Internals« Previous MessageNext Message »
From:Sergei Golubchik Date:August 11 2008 12:22pm
Subject:Re: Can we disable REPLACE stmt in MySQL if SE can't support it ?
View as plain text  
Hi!

On Aug 11, Rick James wrote:
> If it is actually expanded outside the engine, is there an issue of it
> not being atomic?  Seems like some other thread could slip in and
> change the data such that the last step(s) hit a conflict.

There should not be. MySQL achieves it by locking the table it works on
with an exclusive lock. Similarly a client cannot see half of the update
or insert ... select.

If a storage engine decided to weaken the lock level, it can do that -
but in that case the engine becomes responsible for statement
isolation. Basically any engine that support page- or row-level locking
do that (weaken the lock level and enforce isolation internally).

An engine can also, if it so chooses, to weaken the lock level and NOT
to enforce the proper isolation - we cannot do anything against it.
It'll be a bug in the engine. Or a feature, in certain applications.
Anyway, in that case a race condition that you describe is possible.

Regards / Mit vielen Grüssen,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  Principal Software Engineer/Server Architect
/_/  /_/\_, /___/\___\_\___/  Sun Microsystems GmbH, HRB München 161028
       <___/                  Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Häring
Thread
Can we disable REPLACE stmt in MySQL if SE can't support it ?Krunal Bauskar11 Aug
  • Re: Can we disable REPLACE stmt in MySQL if SE can't support it ?Sergei Golubchik11 Aug
    • RE: Can we disable REPLACE stmt in MySQL if SE can't support it ?Rick James11 Aug
      • Re: Can we disable REPLACE stmt in MySQL if SE can't support it ?Sergei Golubchik11 Aug