List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:April 5 2002 6:13pm
Subject:LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?
View as plain text  
Hi!

>>>>> "Magnus" == Magnus Enbom <dot@stripped> writes:

Magnus> Hi,
Magnus> I've just been hit by a small but annoying difference between postgres(7.2) 
Magnus> and MySQL(4.x).
Magnus> To get the first row of a table and lock it, you do

Magnus> SELECT * FROM table FOR UPDATE LIMIT 1;

Magnus> in postgres, and 

Magnus> SELECT * FROM table LIMIT 1 FOR UPDATE;

Magnus> in MySQL(with innodb). 

Magnus> Is it possible for MySQL to accept the postgres syntax as well?
Magnus> It's not that many databases that implement LIMIT, so it would be nice if the
Magnus> ones that do have the same syntax(or can accept each others variants).

I will check if we can fix this for 4.0.x
(I took a quick look at this, but could not find an obvious way to do
this without extending sql_yacc.yy a lot)

(This will however not make LIMIT PostgreSQL compliant as PostgreSQL,
because of a bug introduces by the guy who tried to copy the LIMIT
functionally from MySQL to PostgreSQL and accidently swapped the
meaning of the 2 version argument of LIMIT :(  )

Regards,
Monty
Thread
LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?Magnus Enbom4 Apr
  • LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?Michael Widenius5 Apr