From aa0192b1ed1b16b26e1835a6383ac836ad181cf0 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 28 Dec 2016 12:00:00 -0500
Subject: [PATCH 6/6] Combine DROP FDW and DROP SERVER grammar into generic
 DropStmt

---
 doc/src/sgml/ref/drop_foreign_data_wrapper.sgml |  2 +-
 doc/src/sgml/ref/drop_server.sgml               |  2 +-
 src/backend/parser/gram.y                       | 66 ++-----------------------
 3 files changed, 6 insertions(+), 64 deletions(-)

diff --git a/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml b/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
index 824d72c176..702cc021db 100644
--- a/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
+++ b/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
@@ -21,7 +21,7 @@
 
  <refsynopsisdiv>
 <synopsis>
-DROP FOREIGN DATA WRAPPER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
+DROP FOREIGN DATA WRAPPER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
 </synopsis>
  </refsynopsisdiv>
 
diff --git a/doc/src/sgml/ref/drop_server.sgml b/doc/src/sgml/ref/drop_server.sgml
index f08dd7767d..42acdd41dc 100644
--- a/doc/src/sgml/ref/drop_server.sgml
+++ b/doc/src/sgml/ref/drop_server.sgml
@@ -21,7 +21,7 @@
 
  <refsynopsisdiv>
 <synopsis>
-DROP SERVER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
+DROP SERVER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
 </synopsis>
  </refsynopsisdiv>
 
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 1eacdf1e82..7a9f76151d 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -255,9 +255,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 		CreatedbStmt DeclareCursorStmt DefineStmt DeleteStmt DiscardStmt DoStmt
 		DropGroupStmt DropOpClassStmt DropOpFamilyStmt DropPLangStmt DropStmt
 		DropAssertStmt DropTrigStmt DropRuleStmt DropCastStmt DropRoleStmt
-		DropPolicyStmt DropUserStmt DropdbStmt DropTableSpaceStmt DropFdwStmt
+		DropPolicyStmt DropUserStmt DropdbStmt DropTableSpaceStmt
 		DropTransformStmt
-		DropForeignServerStmt DropUserMappingStmt ExplainStmt FetchStmt
+		DropUserMappingStmt ExplainStmt FetchStmt
 		GrantStmt GrantRoleStmt ImportForeignSchemaStmt IndexStmt InsertStmt
 		ListenStmt LoadStmt LockStmt NotifyStmt ExplainableStmt PreparableStmt
 		CreateFunctionStmt AlterFunctionStmt ReindexStmt RemoveAggrStmt
@@ -850,8 +850,6 @@ stmt :
 			| DoStmt
 			| DropAssertStmt
 			| DropCastStmt
-			| DropFdwStmt
-			| DropForeignServerStmt
 			| DropGroupStmt
 			| DropOpClassStmt
 			| DropOpFamilyStmt
@@ -4476,35 +4474,6 @@ opt_fdw_options:
 /*****************************************************************************
  *
  *		QUERY :
- *				DROP FOREIGN DATA WRAPPER name
- *
- ****************************************************************************/
-
-DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
-				{
-					DropStmt *n = makeNode(DropStmt);
-					n->removeType = OBJECT_FDW;
-					n->objects = list_make1(makeString($5));
-					n->missing_ok = false;
-					n->behavior = $6;
-					n->concurrent = false;
-					$$ = (Node *) n;
-				}
-				|  DROP FOREIGN DATA_P WRAPPER IF_P EXISTS name opt_drop_behavior
-				{
-					DropStmt *n = makeNode(DropStmt);
-					n->removeType = OBJECT_FDW;
-					n->objects = list_make1(makeString($7));
-					n->missing_ok = true;
-					n->behavior = $8;
-					n->concurrent = false;
-					$$ = (Node *) n;
-				}
-		;
-
-/*****************************************************************************
- *
- *		QUERY :
  *				ALTER FOREIGN DATA WRAPPER name options
  *
  ****************************************************************************/
@@ -4636,35 +4605,6 @@ opt_foreign_server_version:
 /*****************************************************************************
  *
  *		QUERY :
- *				DROP SERVER name
- *
- ****************************************************************************/
-
-DropForeignServerStmt: DROP SERVER name opt_drop_behavior
-				{
-					DropStmt *n = makeNode(DropStmt);
-					n->removeType = OBJECT_FOREIGN_SERVER;
-					n->objects = list_make1(makeString($3));
-					n->missing_ok = false;
-					n->behavior = $4;
-					n->concurrent = false;
-					$$ = (Node *) n;
-				}
-				|  DROP SERVER IF_P EXISTS name opt_drop_behavior
-				{
-					DropStmt *n = makeNode(DropStmt);
-					n->removeType = OBJECT_FOREIGN_SERVER;
-					n->objects = list_make1(makeString($5));
-					n->missing_ok = true;
-					n->behavior = $6;
-					n->concurrent = false;
-					$$ = (Node *) n;
-				}
-		;
-
-/*****************************************************************************
- *
- *		QUERY :
  *				ALTER SERVER name [VERSION] [OPTIONS]
  *
  ****************************************************************************/
@@ -6052,7 +5992,9 @@ drop_type1:	TABLE									{ $$ = OBJECT_TABLE; }
 drop_type2: ACCESS METHOD							{ $$ = OBJECT_ACCESS_METHOD; }
 			| EVENT TRIGGER							{ $$ = OBJECT_EVENT_TRIGGER; }
 			| EXTENSION								{ $$ = OBJECT_EXTENSION; }
+			| FOREIGN DATA_P WRAPPER				{ $$ = OBJECT_FDW; }
 			| SCHEMA								{ $$ = OBJECT_SCHEMA; }
+			| SERVER								{ $$ = OBJECT_FOREIGN_SERVER; }
 		;
 
 any_name_list:
-- 
2.11.0

