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

Commit583f6c4

Browse files
committed
Allow dropping multiple functions at once
The generic drop support already supported dropping multiple objects ofthe same kind at once. But the previous representationof function signatures across two grammar symbols and structure membersmade this cumbersome to do for functions, so it was not supported. Nowthat function signatures are represented by a single structure, it'strivial to add this support. Same for aggregates and operators.Reviewed-by: Jim Nasby <Jim.Nasby@BlueTreble.com>Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
1 parent2ca64c6 commit583f6c4

File tree

6 files changed

+52
-21
lines changed

6 files changed

+52
-21
lines changed

‎doc/src/sgml/ref/drop_aggregate.sgml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ PostgreSQL documentation
2121

2222
<refsynopsisdiv>
2323
<synopsis>
24-
DROP AGGREGATE [ IF EXISTS ] <replaceable>name</replaceable> ( <replaceable>aggregate_signature</replaceable> ) [ CASCADE | RESTRICT ]
24+
DROP AGGREGATE [ IF EXISTS ] <replaceable>name</replaceable> ( <replaceable>aggregate_signature</replaceable> ) [, ...] [ CASCADE | RESTRICT ]
2525

2626
<phrase>where <replaceable>aggregate_signature</replaceable> is:</phrase>
2727

@@ -155,7 +155,14 @@ DROP AGGREGATE myavg(integer);
155155
DROP AGGREGATE myrank(VARIADIC "any" ORDER BY VARIADIC "any");
156156
</programlisting>
157157
</para>
158-
</refsect1>
158+
159+
<para>
160+
To remove multiple aggregate functions in one command:
161+
<programlisting>
162+
DROP AGGREGATE myavg(integer), myavg(bigint);
163+
</programlisting>
164+
</para>
165+
</refsect1>
159166

160167
<refsect1>
161168
<title>Compatibility</title>

‎doc/src/sgml/ref/drop_function.sgml

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

2222
<refsynopsisdiv>
2323
<synopsis>
24-
DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] )
24+
DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) [, ...]
2525
[ CASCADE | RESTRICT ]
2626
</synopsis>
2727
</refsynopsisdiv>
@@ -134,6 +134,12 @@ DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> (
134134

135135
<programlisting>
136136
DROP FUNCTION sqrt(integer);
137+
</programlisting></para>
138+
139+
<para>
140+
Drop multiple functions in one command:
141+
<programlisting>
142+
DROP FUNCTION sqrt(integer), sqrt(bigint);
137143
</programlisting></para>
138144
</refsect1>
139145

‎doc/src/sgml/ref/drop_operator.sgml

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

2222
<refsynopsisdiv>
2323
<synopsis>
24-
DROP OPERATOR [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> ( { <replaceable class="PARAMETER">left_type</replaceable> | NONE } , { <replaceable class="PARAMETER">right_type</replaceable> | NONE } ) [ CASCADE | RESTRICT ]
24+
DROP OPERATOR [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> ( { <replaceable class="PARAMETER">left_type</replaceable> | NONE } , { <replaceable class="PARAMETER">right_type</replaceable> | NONE } ) [, ...] [ CASCADE | RESTRICT ]
2525
</synopsis>
2626
</refsynopsisdiv>
2727

@@ -125,6 +125,12 @@ DROP OPERATOR ~ (none, bit);
125125
for type <type>bigint</type>:
126126
<programlisting>
127127
DROP OPERATOR ! (bigint, none);
128+
</programlisting></para>
129+
130+
<para>
131+
Remove multiple operators in one command:
132+
<programlisting>
133+
DROP OPERATOR ~ (none, bit), ! (bigint, none);
128134
</programlisting></para>
129135
</refsect1>
130136

‎src/backend/parser/gram.y

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
358358
%type<list>privilegesprivilege_list
359359
%type<privtarget>privilege_target
360360
%type<objwithargs>function_with_argtypesaggregate_with_argtypesoperator_with_argtypes
361-
%type<list>function_with_argtypes_list
361+
%type<list>function_with_argtypes_listaggregate_with_argtypes_listoperator_with_argtypes_list
362362
%type<ival>defacl_privilege_target
363363
%type<defelt>DefACLOption
364364
%type<list>DefACLOptionList
@@ -7495,6 +7495,12 @@ aggregate_with_argtypes:
74957495
}
74967496
;
74977497

7498+
aggregate_with_argtypes_list:
7499+
aggregate_with_argtypes{$$ = list_make1($1); }
7500+
|aggregate_with_argtypes_list','aggregate_with_argtypes
7501+
{$$ = lappend($1,$3); }
7502+
;
7503+
74987504
createfunc_opt_list:
74997505
/* Must be at least one to prevent conflict*/
75007506
createfunc_opt_item{$$ = list_make1($1); }
@@ -7676,21 +7682,21 @@ opt_restrict:
76767682
*****************************************************************************/
76777683

76787684
RemoveFuncStmt:
7679-
DROPFUNCTIONfunction_with_argtypesopt_drop_behavior
7685+
DROPFUNCTIONfunction_with_argtypes_listopt_drop_behavior
76807686
{
76817687
DropStmt *n = makeNode(DropStmt);
76827688
n->removeType = OBJECT_FUNCTION;
7683-
n->objects =list_make1($3);
7689+
n->objects =$3;
76847690
n->behavior =$4;
76857691
n->missing_ok =false;
76867692
n->concurrent =false;
76877693
$$ = (Node *)n;
76887694
}
7689-
|DROPFUNCTIONIF_PEXISTSfunction_with_argtypesopt_drop_behavior
7695+
|DROPFUNCTIONIF_PEXISTSfunction_with_argtypes_listopt_drop_behavior
76907696
{
76917697
DropStmt *n = makeNode(DropStmt);
76927698
n->removeType = OBJECT_FUNCTION;
7693-
n->objects =list_make1($5);
7699+
n->objects =$5;
76947700
n->behavior =$6;
76957701
n->missing_ok =true;
76967702
n->concurrent =false;
@@ -7699,21 +7705,21 @@ RemoveFuncStmt:
76997705
;
77007706

77017707
RemoveAggrStmt:
7702-
DROPAGGREGATEaggregate_with_argtypesopt_drop_behavior
7708+
DROPAGGREGATEaggregate_with_argtypes_listopt_drop_behavior
77037709
{
77047710
DropStmt *n = makeNode(DropStmt);
77057711
n->removeType = OBJECT_AGGREGATE;
7706-
n->objects =list_make1($3);
7712+
n->objects =$3;
77077713
n->behavior =$4;
77087714
n->missing_ok =false;
77097715
n->concurrent =false;
77107716
$$ = (Node *)n;
77117717
}
7712-
|DROPAGGREGATEIF_PEXISTSaggregate_with_argtypesopt_drop_behavior
7718+
|DROPAGGREGATEIF_PEXISTSaggregate_with_argtypes_listopt_drop_behavior
77137719
{
77147720
DropStmt *n = makeNode(DropStmt);
77157721
n->removeType = OBJECT_AGGREGATE;
7716-
n->objects =list_make1($5);
7722+
n->objects =$5;
77177723
n->behavior =$6;
77187724
n->missing_ok =true;
77197725
n->concurrent =false;
@@ -7722,21 +7728,21 @@ RemoveAggrStmt:
77227728
;
77237729

77247730
RemoveOperStmt:
7725-
DROPOPERATORoperator_with_argtypesopt_drop_behavior
7731+
DROPOPERATORoperator_with_argtypes_listopt_drop_behavior
77267732
{
77277733
DropStmt *n = makeNode(DropStmt);
77287734
n->removeType = OBJECT_OPERATOR;
7729-
n->objects =list_make1($3);
7735+
n->objects =$3;
77307736
n->behavior =$4;
77317737
n->missing_ok =false;
77327738
n->concurrent =false;
77337739
$$ = (Node *)n;
77347740
}
7735-
|DROPOPERATORIF_PEXISTSoperator_with_argtypesopt_drop_behavior
7741+
|DROPOPERATORIF_PEXISTSoperator_with_argtypes_listopt_drop_behavior
77367742
{
77377743
DropStmt *n = makeNode(DropStmt);
77387744
n->removeType = OBJECT_OPERATOR;
7739-
n->objects =list_make1($5);
7745+
n->objects =$5;
77407746
n->behavior =$6;
77417747
n->missing_ok =true;
77427748
n->concurrent =false;
@@ -7768,6 +7774,12 @@ any_operator:
77687774
{$$ = lcons(makeString($1),$3); }
77697775
;
77707776

7777+
operator_with_argtypes_list:
7778+
operator_with_argtypes{$$ = list_make1($1); }
7779+
|operator_with_argtypes_list','operator_with_argtypes
7780+
{$$ = lappend($1,$3); }
7781+
;
7782+
77717783
operator_with_argtypes:
77727784
any_operatoroper_argtypes
77737785
{

‎src/test/regress/expected/create_function_3.out

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,10 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
217217
functest_is_3 | 2 | b |
218218
(7 rows)
219219

220+
DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
220221
-- Cleanups
221222
DROP SCHEMA temp_func_test CASCADE;
222-
NOTICE: drop cascades to19 other objects
223+
NOTICE: drop cascades to16 other objects
223224
DETAIL: drop cascades to function functest_a_1(text,date)
224225
drop cascades to function functest_a_2(text[])
225226
drop cascades to function functest_a_3()
@@ -236,8 +237,5 @@ drop cascades to function functext_f_1(integer)
236237
drop cascades to function functext_f_2(integer)
237238
drop cascades to function functext_f_3(integer)
238239
drop cascades to function functext_f_4(integer)
239-
drop cascades to function functest_is_1(integer,integer,text)
240-
drop cascades to function functest_is_2(integer)
241-
drop cascades to function functest_is_3(integer)
242240
DROP USER regress_unpriv_user;
243241
RESET search_path;

‎src/test/regress/sql/create_function_3.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
156156
WHERE routine_schema='temp_func_test'AND routine_name ~'^functest_is_'
157157
ORDER BY1,2;
158158

159+
DROPFUNCTION functest_IS_1(int,int,text), functest_IS_2(int), functest_IS_3(int);
160+
159161

160162
-- Cleanups
161163
DROPSCHEMA temp_func_test CASCADE;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp