Re: LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?
От | Bruce Momjian |
---|---|
Тема | Re: LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1? |
Дата | |
Msg-id | 200204180343.g3I3hJO03562@candle.pha.pa.us обсуждение исходный текст |
Ответ на | LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1? (Magnus Enbom <dot@rockstorm.se>) |
Список | pgsql-sql |
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). gram.y has the ordering listed below. We could add extra productions to allow the ordering to vary. However, that will introduce a shift/reduce conflict. It is amazing that we got LIMIT/OFFSET backwards, and not UPDATE/LIMIT is backwards too, at least in relation to MySQL. Ideas? --------------------------------------------------------------------------- select_no_parens: simple_select { $$ = $1; } | select_clause sort_clause opt_for_update_clauseopt_select_limit { insertSelectOptions((SelectStmt *) $1, $2, $3, nth(0, $4), nth(1, $4)); $$ = $1; } | select_clause for_update_clauseopt_select_limit { insertSelectOptions((SelectStmt *) $1, NIL, $2, nth(0, $3), nth(1, $3)); $$ = $1; } | select_clause select_limit { insertSelectOptions((SelectStmt *) $1, NIL, NIL, nth(0, $2), nth(1,$2)); $$ = $1; } -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
В списке pgsql-sql по дате отправления: