Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6477a8

Browse files
committed
Combine several DROP variants into generic DropStmt
Combine DROP of FOREIGN DATA WRAPPER, SERVER, POLICY, RULE, and TRIGGERinto generic DropStmt grammar.Reviewed-by: Jim Nasby <Jim.Nasby@BlueTreble.com>Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
1 parent583f6c4 commite6477a8

File tree

3 files changed

+35
-142
lines changed

3 files changed

+35
-142
lines changed

‎doc/src/sgml/ref/drop_foreign_data_wrapper.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ PostgreSQL documentation
2121

2222
<refsynopsisdiv>
2323
<synopsis>
24-
DROP FOREIGN DATA WRAPPER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
24+
DROP FOREIGN DATA WRAPPER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
2525
</synopsis>
2626
</refsynopsisdiv>
2727

‎doc/src/sgml/ref/drop_server.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ PostgreSQL documentation
2121

2222
<refsynopsisdiv>
2323
<synopsis>
24-
DROP SERVER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
24+
DROP SERVER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
2525
</synopsis>
2626
</refsynopsisdiv>
2727

‎src/backend/parser/gram.y

Lines changed: 33 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
263263
CreateUserStmtCreateUserMappingStmtCreateRoleStmtCreatePolicyStmt
264264
CreatedbStmtDeclareCursorStmtDefineStmtDeleteStmtDiscardStmtDoStmt
265265
DropGroupStmtDropOpClassStmtDropOpFamilyStmtDropPLangStmtDropStmt
266-
DropAssertStmtDropTrigStmtDropRuleStmtDropCastStmtDropRoleStmt
267-
DropPolicyStmtDropUserStmtDropdbStmtDropTableSpaceStmtDropFdwStmt
266+
DropAssertStmtDropCastStmtDropRoleStmt
267+
DropUserStmtDropdbStmtDropTableSpaceStmt
268268
DropTransformStmt
269-
DropForeignServerStmtDropUserMappingStmtExplainStmtFetchStmt
269+
DropUserMappingStmtExplainStmtFetchStmt
270270
GrantStmtGrantRoleStmtImportForeignSchemaStmtIndexStmtInsertStmt
271271
ListenStmtLoadStmtLockStmtNotifyStmtExplainableStmtPreparableStmt
272272
CreateFunctionStmtAlterFunctionStmtReindexStmtRemoveAggrStmt
@@ -440,7 +440,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
440440
%type<boolean>copy_fromopt_program
441441

442442
%type<ival>opt_columneventcursor_optionsopt_holdopt_set_data
443-
%type<objtype>drop_type_any_namedrop_type_name
443+
%type<objtype>drop_type_any_namedrop_type_namedrop_type_name_on_any_name
444444
comment_type_any_namecomment_type_name
445445
security_label_type_any_namesecurity_label_type_name
446446

@@ -885,20 +885,15 @@ stmt :
885885
|DoStmt
886886
|DropAssertStmt
887887
|DropCastStmt
888-
|DropFdwStmt
889-
|DropForeignServerStmt
890888
|DropGroupStmt
891889
|DropOpClassStmt
892890
|DropOpFamilyStmt
893891
|DropOwnedStmt
894-
|DropPolicyStmt
895892
|DropPLangStmt
896-
|DropRuleStmt
897893
|DropStmt
898894
|DropSubscriptionStmt
899895
|DropTableSpaceStmt
900896
|DropTransformStmt
901-
|DropTrigStmt
902897
|DropRoleStmt
903898
|DropUserStmt
904899
|DropUserMappingStmt
@@ -4511,35 +4506,6 @@ opt_fdw_options:
45114506
|/*EMPTY*/{$$ = NIL; }
45124507
;
45134508

4514-
/*****************************************************************************
4515-
*
4516-
*QUERY :
4517-
*DROP FOREIGN DATA WRAPPER name
4518-
*
4519-
****************************************************************************/
4520-
4521-
DropFdwStmt:DROPFOREIGNDATA_PWRAPPERnameopt_drop_behavior
4522-
{
4523-
DropStmt *n = makeNode(DropStmt);
4524-
n->removeType = OBJECT_FDW;
4525-
n->objects = list_make1(makeString($5));
4526-
n->missing_ok =false;
4527-
n->behavior =$6;
4528-
n->concurrent =false;
4529-
$$ = (Node *) n;
4530-
}
4531-
|DROPFOREIGNDATA_PWRAPPERIF_PEXISTSnameopt_drop_behavior
4532-
{
4533-
DropStmt *n = makeNode(DropStmt);
4534-
n->removeType = OBJECT_FDW;
4535-
n->objects = list_make1(makeString($7));
4536-
n->missing_ok =true;
4537-
n->behavior =$8;
4538-
n->concurrent =false;
4539-
$$ = (Node *) n;
4540-
}
4541-
;
4542-
45434509
/*****************************************************************************
45444510
*
45454511
*QUERY :
@@ -4671,35 +4637,6 @@ opt_foreign_server_version:
46714637
|/*EMPTY*/{$$ =NULL; }
46724638
;
46734639

4674-
/*****************************************************************************
4675-
*
4676-
*QUERY :
4677-
*DROP SERVER name
4678-
*
4679-
****************************************************************************/
4680-
4681-
DropForeignServerStmt:DROPSERVERnameopt_drop_behavior
4682-
{
4683-
DropStmt *n = makeNode(DropStmt);
4684-
n->removeType = OBJECT_FOREIGN_SERVER;
4685-
n->objects = list_make1(makeString($3));
4686-
n->missing_ok =false;
4687-
n->behavior =$4;
4688-
n->concurrent =false;
4689-
$$ = (Node *) n;
4690-
}
4691-
|DROPSERVERIF_PEXISTSnameopt_drop_behavior
4692-
{
4693-
DropStmt *n = makeNode(DropStmt);
4694-
n->removeType = OBJECT_FOREIGN_SERVER;
4695-
n->objects = list_make1(makeString($5));
4696-
n->missing_ok =true;
4697-
n->behavior =$6;
4698-
n->concurrent =false;
4699-
$$ = (Node *) n;
4700-
}
4701-
;
4702-
47034640
/*****************************************************************************
47044641
*
47054642
*QUERY :
@@ -4975,7 +4912,6 @@ AlterUserMappingStmt: ALTER USER MAPPING FOR auth_ident SERVER name alter_generi
49754912
*[USING (qual)] [WITH CHECK (with check qual)]
49764913
*ALTER POLICY name ON table [TO role, ...]
49774914
*[USING (qual)] [WITH CHECK (with check qual)]
4978-
*DROP POLICY name ON table
49794915
*
49804916
*****************************************************************************/
49814917

@@ -5010,29 +4946,6 @@ AlterPolicyStmt:
50104946
}
50114947
;
50124948

5013-
DropPolicyStmt:
5014-
DROPPOLICYnameONany_nameopt_drop_behavior
5015-
{
5016-
DropStmt *n = makeNode(DropStmt);
5017-
n->removeType = OBJECT_POLICY;
5018-
n->objects = list_make1(lappend($5, makeString($3)));
5019-
n->behavior =$6;
5020-
n->missing_ok =false;
5021-
n->concurrent =false;
5022-
$$ = (Node *) n;
5023-
}
5024-
|DROPPOLICYIF_PEXISTSnameONany_nameopt_drop_behavior
5025-
{
5026-
DropStmt *n = makeNode(DropStmt);
5027-
n->removeType = OBJECT_POLICY;
5028-
n->objects = list_make1(lappend($7, makeString($5)));
5029-
n->behavior =$8;
5030-
n->missing_ok =true;
5031-
n->concurrent =false;
5032-
$$ = (Node *) n;
5033-
}
5034-
;
5035-
50364949
RowSecurityOptionalExpr:
50374950
USING'('a_expr')'{$$ =$3; }
50384951
|/* EMPTY*/{$$ =NULL; }
@@ -5105,7 +5018,6 @@ CreateAmStmt: CREATE ACCESS METHOD name TYPE_P INDEX HANDLER handler_name
51055018
*
51065019
*QUERIES :
51075020
*CREATE TRIGGER ...
5108-
*DROP TRIGGER ...
51095021
*
51105022
*****************************************************************************/
51115023

@@ -5332,30 +5244,6 @@ ConstraintAttributeElem:
53325244
;
53335245

53345246

5335-
DropTrigStmt:
5336-
DROPTRIGGERnameONany_nameopt_drop_behavior
5337-
{
5338-
DropStmt *n = makeNode(DropStmt);
5339-
n->removeType = OBJECT_TRIGGER;
5340-
n->objects = list_make1(lappend($5, makeString($3)));
5341-
n->behavior =$6;
5342-
n->missing_ok =false;
5343-
n->concurrent =false;
5344-
$$ = (Node *) n;
5345-
}
5346-
|DROPTRIGGERIF_PEXISTSnameONany_nameopt_drop_behavior
5347-
{
5348-
DropStmt *n = makeNode(DropStmt);
5349-
n->removeType = OBJECT_TRIGGER;
5350-
n->objects = list_make1(lappend($7, makeString($5)));
5351-
n->behavior =$8;
5352-
n->missing_ok =true;
5353-
n->concurrent =false;
5354-
$$ = (Node *) n;
5355-
}
5356-
;
5357-
5358-
53595247
/*****************************************************************************
53605248
*
53615249
*QUERIES :
@@ -6034,6 +5922,26 @@ DropStmt:DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
60345922
n->concurrent =false;
60355923
$$ = (Node *)n;
60365924
}
5925+
|DROPdrop_type_name_on_any_namenameONany_nameopt_drop_behavior
5926+
{
5927+
DropStmt *n = makeNode(DropStmt);
5928+
n->removeType =$2;
5929+
n->objects = list_make1(lappend($5, makeString($3)));
5930+
n->behavior =$6;
5931+
n->missing_ok =false;
5932+
n->concurrent =false;
5933+
$$ = (Node *) n;
5934+
}
5935+
|DROPdrop_type_name_on_any_nameIF_PEXISTSnameONany_nameopt_drop_behavior
5936+
{
5937+
DropStmt *n = makeNode(DropStmt);
5938+
n->removeType =$2;
5939+
n->objects = list_make1(lappend($7, makeString($5)));
5940+
n->behavior =$8;
5941+
n->missing_ok =true;
5942+
n->concurrent =false;
5943+
$$ = (Node *) n;
5944+
}
60375945
|DROPTYPE_Ptype_name_listopt_drop_behavior
60385946
{
60395947
DropStmt *n = makeNode(DropStmt);
@@ -6117,8 +6025,17 @@ drop_type_name:
61176025
ACCESSMETHOD{$$ = OBJECT_ACCESS_METHOD; }
61186026
|EVENTTRIGGER{$$ = OBJECT_EVENT_TRIGGER; }
61196027
|EXTENSION{$$ = OBJECT_EXTENSION; }
6028+
|FOREIGNDATA_PWRAPPER{$$ = OBJECT_FDW; }
61206029
|PUBLICATION{$$ = OBJECT_PUBLICATION; }
61216030
|SCHEMA{$$ = OBJECT_SCHEMA; }
6031+
|SERVER{$$ = OBJECT_FOREIGN_SERVER; }
6032+
;
6033+
6034+
/* object types attached to a table*/
6035+
drop_type_name_on_any_name:
6036+
POLICY{$$ = OBJECT_POLICY; }
6037+
|RULE{$$ = OBJECT_RULE; }
6038+
|TRIGGER{$$ = OBJECT_TRIGGER; }
61226039
;
61236040

61246041
any_name_list:
@@ -9277,30 +9194,6 @@ opt_instead:
92779194
;
92789195

92799196

9280-
DropRuleStmt:
9281-
DROPRULEnameONany_nameopt_drop_behavior
9282-
{
9283-
DropStmt *n = makeNode(DropStmt);
9284-
n->removeType = OBJECT_RULE;
9285-
n->objects = list_make1(lappend($5, makeString($3)));
9286-
n->behavior =$6;
9287-
n->missing_ok =false;
9288-
n->concurrent =false;
9289-
$$ = (Node *) n;
9290-
}
9291-
|DROPRULEIF_PEXISTSnameONany_nameopt_drop_behavior
9292-
{
9293-
DropStmt *n = makeNode(DropStmt);
9294-
n->removeType = OBJECT_RULE;
9295-
n->objects = list_make1(lappend($7, makeString($5)));
9296-
n->behavior =$8;
9297-
n->missing_ok =true;
9298-
n->concurrent =false;
9299-
$$ = (Node *) n;
9300-
}
9301-
;
9302-
9303-
93049197
/*****************************************************************************
93059198
*
93069199
*QUERY:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp