From 582e22a8c3cf5698aefe0933fe627b4223a62527 Mon Sep 17 00:00:00 2001
From: Michael Meskes <meskes@postgresql.org>
Date: Sat, 17 Mar 2007 19:27:12 +0000
Subject: [PATCH] Simplified sortby rule

---
 src/backend/parser/gram.y | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 1ce7170040..22d03f0b23 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.581 2007/03/13 00:33:41 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.582 2007/03/17 19:27:12 meskes Exp $
  *
  * HISTORY
  *	  AUTHOR			DATE			MAJOR EVENT
@@ -3869,8 +3869,8 @@ opt_class:	any_name								{ $$ = $1; }
 		;
 
 opt_asc_desc: ASC							{ $$ = SORTBY_ASC; }
-			| DESC							{ $$ = SORTBY_DESC; }
-			| /*EMPTY*/						{ $$ = SORTBY_DEFAULT; }
+			| DESC						{ $$ = SORTBY_DESC; }
+			| /*EMPTY*/					{ $$ = SORTBY_DEFAULT; }
 		;
 
 opt_nulls_order: NULLS_FIRST				{ $$ = SORTBY_NULLS_FIRST; }
@@ -5982,30 +5982,14 @@ sortby:		a_expr USING qual_all_Op opt_nulls_order
 					$$->sortby_nulls = $4;
 					$$->useOp = $3;
 				}
-			| a_expr ASC opt_nulls_order
+			| a_expr opt_asc_desc opt_nulls_order
 				{
 					$$ = makeNode(SortBy);
 					$$->node = $1;
-					$$->sortby_dir = SORTBY_ASC;
+					$$->sortby_dir = $2;
 					$$->sortby_nulls = $3;
 					$$->useOp = NIL;
 				}
-			| a_expr DESC opt_nulls_order
-				{
-					$$ = makeNode(SortBy);
-					$$->node = $1;
-					$$->sortby_dir = SORTBY_DESC;
-					$$->sortby_nulls = $3;
-					$$->useOp = NIL;
-				}
-			| a_expr opt_nulls_order
-				{
-					$$ = makeNode(SortBy);
-					$$->node = $1;
-					$$->sortby_dir = SORTBY_DEFAULT;
-					$$->sortby_nulls = $2;
-					$$->useOp = NIL;
-				}
 		;
 
 
-- 
2.40.0