pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Cc: magnus.enbom@rockstorm.se, Jan Wieck <JanWieck@Yahoo.com>
Cc: PostgreSQL-development <pgsql-hackers@postgreSQL.org>
Subject: Re: [SQL] LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?
Date: Tue, 27 Aug 2002 22:45:24 -0400 (EDT)
Message-ID: <200208280245.g7S2jO803463@candle.pha.pa.us> (raw )
In-Reply-To: <GNELIHDDFBOCMGBFGEFOMEOMCDAA.chriskl@familyhealth.com.au >
OK, patch attached. It was actually easier than I thought. We have to
decide if we are going to remove the old syntax in 7.4.
Regression tests pass. No doc updates yet.
---------------------------------------------------------------------------
Christopher Kings-Lynne wrote:
> > OK, no one has commented on this, so I guess I am going to have to guess
> > the group's preference.
> >
> > My guess, seeing as very few probably use LIMIT and FOR UPDATE together,
> > is to swap them and document it in the release notes. Was I correct in
> > my guess?
>
> I'm sure very few people do it - but are you sure you can't just allow both
> syntaxes?
>
> Chris
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Attachments:
/pgpatches/for_update (text/plain, 3.1K) download
Index: src/backend/parser/gram.y
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/parser/gram.y,v
retrieving revision 2.361
diff -c -c -r2.361 gram.y
*** src/backend/parser/gram.y 27 Aug 2002 04:55:08 -0000 2.361
--- src/backend/parser/gram.y 28 Aug 2002 02:42:16 -0000
***************
*** 208,215 ****
func_args_list, func_as, createfunc_opt_list
oper_argtypes, RuleActionList, RuleActionMulti,
opt_column_list, columnList, opt_name_list,
! sort_clause, sortby_list, index_params, index_list,
! name_list, from_clause, from_list, opt_array_bounds,
qualified_name_list, any_name, any_name_list,
any_operator, expr_list, dotted_name, attrs,
target_list, update_target_list, insert_column_list,
--- 208,215 ----
func_args_list, func_as, createfunc_opt_list
oper_argtypes, RuleActionList, RuleActionMulti,
opt_column_list, columnList, opt_name_list,
! sort_clause, opt_sort_clause, sortby_list, index_params,
! index_list,name_list, from_clause, from_list, opt_array_bounds,
qualified_name_list, any_name, any_name_list,
any_operator, expr_list, dotted_name, attrs,
target_list, update_target_list, insert_column_list,
***************
*** 4180,4203 ****
| '(' select_with_parens ')' { $$ = $2; }
;
select_no_parens:
simple_select { $$ = $1; }
! | select_clause sort_clause opt_for_update_clause opt_select_limit
{
! insertSelectOptions((SelectStmt *) $1, $2, $3,
! nth(0, $4), nth(1, $4));
$$ = $1;
}
! | select_clause for_update_clause opt_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;
}
;
--- 4180,4208 ----
| '(' select_with_parens ')' { $$ = $2; }
;
+ /*
+ * FOR UPDATE may be before or after LIMIT/OFFSET.
+ * In <=7.2.X, LIMIT/OFFSET had to be after FOR UPDATE
+ * In >7.3.X, LIMIT/OFFSET will have to be before FOR UPDATE
+ */
select_no_parens:
simple_select { $$ = $1; }
! | select_clause sort_clause
{
! insertSelectOptions((SelectStmt *) $1, $2, NIL,
! NULL, NULL);
$$ = $1;
}
! | select_clause opt_sort_clause for_update_clause opt_select_limit
{
! insertSelectOptions((SelectStmt *) $1, $2, $3,
! nth(0, $4), nth(1, $4));
$$ = $1;
}
! | select_clause opt_sort_clause select_limit opt_for_update_clause
{
! insertSelectOptions((SelectStmt *) $1, $2, $4,
! nth(0, $3), nth(1, $3));
$$ = $1;
}
;
***************
*** 4332,4337 ****
--- 4337,4347 ----
DISTINCT { $$ = makeList1(NIL); }
| DISTINCT ON '(' expr_list ')' { $$ = $4; }
| ALL { $$ = NIL; }
+ | /*EMPTY*/ { $$ = NIL; }
+ ;
+
+ opt_sort_clause:
+ sort_clause { $$ = $1;}
| /*EMPTY*/ { $$ = NIL; }
;
view thread (43+ messages) latest in thread
Message-ID: <200208280245.g7S2jO803463@candle.pha.pa.us>
Permalink: ../200208280245.g7S2jO803463@candle.pha.pa.us/
Also on: postgresql.org/message-id/200208280245.g7S2jO803463@candle.pha.pa.us
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: pgman@candle.pha.pa.us, chriskl@familyhealth.com.au, JanWieck@Yahoo.com, pgsql-hackers@postgreSQL.org
Subject: Re: [SQL] LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?
In-Reply-To: <200208280245.g7S2jO803463@candle.pha.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox