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

Commitc232c8a

Browse files
committed
Fix notice message from DROP FUNCTION IF EXISTS, and improve message
for DROP AGGREGATE IF EXISTS. Per report from Teodor.
1 parent0c858bd commitc232c8a

File tree

4 files changed

+59
-24
lines changed

4 files changed

+59
-24
lines changed

‎src/backend/commands/aggregatecmds.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.38 2006/07/27 19:52:04 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.39 2006/09/25 15:17:34 tgl Exp $
1313
*
1414
* DESCRIPTION
1515
* The "DefineFoo" routines take the parse tree and pick out the
@@ -219,8 +219,9 @@ RemoveAggregate(RemoveFuncStmt *stmt)
219219
{
220220
/* we only get here if stmt->missing_ok is true */
221221
ereport(NOTICE,
222-
(errmsg("aggregate %s does not exist ... skipping",
223-
NameListToString(stmt->name))));
222+
(errmsg("aggregate %s(%s) does not exist ... skipping",
223+
NameListToString(aggName),
224+
TypeNameListToString(aggArgs))));
224225
return;
225226
}
226227

‎src/backend/commands/functioncmds.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.76 2006/07/14 14:52:18 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.77 2006/09/25 15:17:34 tgl Exp $
1414
*
1515
* DESCRIPTION
1616
* These routines take the parse tree and pick out the
@@ -686,16 +686,16 @@ RemoveFunction(RemoveFuncStmt *stmt)
686686
* Find the function, do permissions and validity checks
687687
*/
688688
funcOid=LookupFuncNameTypeNames(functionName,argTypes,stmt->missing_ok);
689-
if (stmt->missing_ok&&!OidIsValid(funcOid))
689+
if (!OidIsValid(funcOid))
690690
{
691+
/* can only get here if stmt->missing_ok */
691692
ereport(NOTICE,
692693
(errmsg("function %s(%s) does not exist ... skipping",
693694
NameListToString(functionName),
694-
NameListToString(argTypes))));
695+
TypeNameListToString(argTypes))));
695696
return;
696697
}
697698

698-
699699
tup=SearchSysCache(PROCOID,
700700
ObjectIdGetDatum(funcOid),
701701
0,0,0);
@@ -1409,8 +1409,6 @@ DropCast(DropCastStmt *stmt)
14091409
return;
14101410
}
14111411

1412-
1413-
14141412
/* Permission check */
14151413
if (!pg_type_ownercheck(sourcetypeid,GetUserId())
14161414
&& !pg_type_ownercheck(targettypeid,GetUserId()))

‎src/backend/parser/parse_type.c

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.83 2006/08/02 01:59:47 joe Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.84 2006/09/25 15:17:34 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -141,19 +141,16 @@ LookupTypeName(ParseState *pstate, const TypeName *typename)
141141
}
142142

143143
/*
144-
* TypeNameToString
145-
*Produce a string representing the name of a TypeName.
144+
* appendTypeNameToBuffer
145+
*Append a string representing the name of a TypeName to a StringInfo.
146+
*This is the shared guts of TypeNameToString and TypeNameListToString.
146147
*
147148
* NB: this must work on TypeNames that do not describe any actual type;
148149
* it is mostly used for reporting lookup errors.
149150
*/
150-
char*
151-
TypeNameToString(constTypeName*typename)
151+
staticvoid
152+
appendTypeNameToBuffer(constTypeName*typename,StringInfostring)
152153
{
153-
StringInfoDatastring;
154-
155-
initStringInfo(&string);
156-
157154
if (typename->names!=NIL)
158155
{
159156
/* Emit possibly-qualified name as-is */
@@ -162,26 +159,64 @@ TypeNameToString(const TypeName *typename)
162159
foreach(l,typename->names)
163160
{
164161
if (l!=list_head(typename->names))
165-
appendStringInfoChar(&string,'.');
166-
appendStringInfoString(&string,strVal(lfirst(l)));
162+
appendStringInfoChar(string,'.');
163+
appendStringInfoString(string,strVal(lfirst(l)));
167164
}
168165
}
169166
else
170167
{
171168
/* Look up internally-specified type */
172-
appendStringInfoString(&string,format_type_be(typename->typeid));
169+
appendStringInfoString(string,format_type_be(typename->typeid));
173170
}
174171

175172
/*
176173
* Add decoration as needed, but only for fields considered by
177174
* LookupTypeName
178175
*/
179176
if (typename->pct_type)
180-
appendStringInfoString(&string,"%TYPE");
177+
appendStringInfoString(string,"%TYPE");
181178

182179
if (typename->arrayBounds!=NIL)
183-
appendStringInfoString(&string,"[]");
180+
appendStringInfoString(string,"[]");
181+
}
182+
183+
/*
184+
* TypeNameToString
185+
*Produce a string representing the name of a TypeName.
186+
*
187+
* NB: this must work on TypeNames that do not describe any actual type;
188+
* it is mostly used for reporting lookup errors.
189+
*/
190+
char*
191+
TypeNameToString(constTypeName*typename)
192+
{
193+
StringInfoDatastring;
194+
195+
initStringInfo(&string);
196+
appendTypeNameToBuffer(typename,&string);
197+
returnstring.data;
198+
}
199+
200+
/*
201+
* TypeNameListToString
202+
*Produce a string representing the name(s) of a List of TypeNames
203+
*/
204+
char*
205+
TypeNameListToString(List*typenames)
206+
{
207+
StringInfoDatastring;
208+
ListCell*l;
184209

210+
initStringInfo(&string);
211+
foreach(l,typenames)
212+
{
213+
TypeName*typename= (TypeName*)lfirst(l);
214+
215+
Assert(IsA(typename,TypeName));
216+
if (l!=list_head(typenames))
217+
appendStringInfoChar(&string,',');
218+
appendTypeNameToBuffer(typename,&string);
219+
}
185220
returnstring.data;
186221
}
187222

‎src/include/parser/parse_type.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/parser/parse_type.h,v 1.32 2006/03/14 22:48:22 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/parser/parse_type.h,v 1.33 2006/09/25 15:17:34 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -22,6 +22,7 @@ typedef HeapTuple Type;
2222

2323
externOidLookupTypeName(ParseState*pstate,constTypeName*typename);
2424
externchar*TypeNameToString(constTypeName*typename);
25+
externchar*TypeNameListToString(List*typenames);
2526
externOidtypenameTypeId(ParseState*pstate,constTypeName*typename);
2627
externTypetypenameType(ParseState*pstate,constTypeName*typename);
2728

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp