Re: LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: magnus(dot)enbom(at)rockstorm(dot)se
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?
Date: 2002-08-26 00:31:12
Message-ID: 200208260031.g7Q0VCC24924@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql


I found this email from April. It properly points out that our
LIMIT/FOR UPDATE ordering doesn't match MySQL's, and MySQL's looks more
correct, specifically that the FOR UPDATE is after the LIMIT. Our
grammar is:

| select_clause sort_clause opt_for_update_clause opt_select_limit

How do we want to deal with this? I tried allowing both orderings with
the attached patch but got:

bison -y -d gram.y
conflicts: 4 shift/reduce, 5 reduce/reduce

---------------------------------------------------------------------------

Magnus Enbom wrote:
> Hi,
>
> I've just been hit by a small but annoying difference between postgres(7.2)
> and mysql(4.x).
> In postgresql you do:
>
> SELECT * FROM table FOR UPDATE LIMIT 1;
>
> and in mysql you do:
>
> SELECT * FROM table LIMIT 1 FOR UPDATE;
>
> Is it possible for postgres to accept the mysql syntax as well?
> It's not that many databases that implement LIMIT, so it would be nice if the
> ones that do have the same syntax(or can accept each others variants).
>
> -- Magnus
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 977 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message J. R. Nield 2002-08-26 01:35:24 Re: Database Caching
Previous Message Bruce Momjian 2002-08-26 00:15:45 Re: Database Caching

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Tille 2002-08-26 06:26:03 Re: Separating data sets in a table
Previous Message Mark Stosberg 2002-08-25 21:45:36 Re: how to refer to tables in another database( or schema)