Fix notice message from DROP FUNCTION IF EXISTS, and improve message
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 25 Sep 2006 15:17:34 +0000 (15:17 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 25 Sep 2006 15:17:34 +0000 (15:17 +0000)
for DROP AGGREGATE IF EXISTS.  Per report from Teodor.

src/backend/commands/aggregatecmds.c
src/backend/commands/functioncmds.c
src/backend/parser/parse_type.c
src/include/parser/parse_type.h

index cb4dfee77e26b56eb8c5e7bfea4371efbe39b922..79a021cabc9fc43c03d22a5b0af2d8529f53655e 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.38 2006/07/27 19:52:04 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.39 2006/09/25 15:17:34 tgl Exp $
  *
  * DESCRIPTION
  *       The "DefineFoo" routines take the parse tree and pick out the
@@ -219,8 +219,9 @@ RemoveAggregate(RemoveFuncStmt *stmt)
        {
                /* we only get here if stmt->missing_ok is true */
                ereport(NOTICE,
-                               (errmsg("aggregate %s does not exist ... skipping",
-                                               NameListToString(stmt->name))));
+                               (errmsg("aggregate %s(%s) does not exist ... skipping",
+                                               NameListToString(aggName),
+                                               TypeNameListToString(aggArgs))));
                return;
        }
 
index 7dd46dcff5cca7a59a6af277e263f78c2e4b0ae1..fd081d5b1ad76c59e4ac4198349a571ae1033ba1 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.76 2006/07/14 14:52:18 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.77 2006/09/25 15:17:34 tgl Exp $
  *
  * DESCRIPTION
  *       These routines take the parse tree and pick out the
@@ -686,16 +686,16 @@ RemoveFunction(RemoveFuncStmt *stmt)
         * Find the function, do permissions and validity checks
         */
        funcOid = LookupFuncNameTypeNames(functionName, argTypes, stmt->missing_ok);
-       if (stmt->missing_ok &&!OidIsValid(funcOid)) 
+       if (!OidIsValid(funcOid)) 
        {
+               /* can only get here if stmt->missing_ok */
                ereport(NOTICE,
                                (errmsg("function %s(%s) does not exist ... skipping",
                                                NameListToString(functionName),
-                                               NameListToString(argTypes))));
+                                               TypeNameListToString(argTypes))));
                return;
        }
 
-
        tup = SearchSysCache(PROCOID,
                                                 ObjectIdGetDatum(funcOid),
                                                 0, 0, 0);
@@ -1409,8 +1409,6 @@ DropCast(DropCastStmt *stmt)
                return;
        }
 
-                       
-
        /* Permission check */
        if (!pg_type_ownercheck(sourcetypeid, GetUserId())
                && !pg_type_ownercheck(targettypeid, GetUserId()))
index a12aea6c38aa4f3040e025b53e71aaa74f0f5f8e..45666d88809f5a1e893a14a6d5a1cc0f35bb8c61 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.83 2006/08/02 01:59:47 joe Exp $
+ *       $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.84 2006/09/25 15:17:34 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -141,19 +141,16 @@ LookupTypeName(ParseState *pstate, const TypeName *typename)
 }
 
 /*
- * TypeNameToString
- *             Produce a string representing the name of a TypeName.
+ * appendTypeNameToBuffer
+ *             Append a string representing the name of a TypeName to a StringInfo.
+ *             This is the shared guts of TypeNameToString and TypeNameListToString.
  *
  * NB: this must work on TypeNames that do not describe any actual type;
  * it is mostly used for reporting lookup errors.
  */
-char *
-TypeNameToString(const TypeName *typename)
+static void
+appendTypeNameToBuffer(const TypeName *typename, StringInfo string)
 {
-       StringInfoData string;
-
-       initStringInfo(&string);
-
        if (typename->names != NIL)
        {
                /* Emit possibly-qualified name as-is */
@@ -162,14 +159,14 @@ TypeNameToString(const TypeName *typename)
                foreach(l, typename->names)
                {
                        if (l != list_head(typename->names))
-                               appendStringInfoChar(&string, '.');
-                       appendStringInfoString(&string, strVal(lfirst(l)));
+                               appendStringInfoChar(string, '.');
+                       appendStringInfoString(string, strVal(lfirst(l)));
                }
        }
        else
        {
                /* Look up internally-specified type */
-               appendStringInfoString(&string, format_type_be(typename->typeid));
+               appendStringInfoString(string, format_type_be(typename->typeid));
        }
 
        /*
@@ -177,11 +174,49 @@ TypeNameToString(const TypeName *typename)
         * LookupTypeName
         */
        if (typename->pct_type)
-               appendStringInfoString(&string, "%TYPE");
+               appendStringInfoString(string, "%TYPE");
 
        if (typename->arrayBounds != NIL)
-               appendStringInfoString(&string, "[]");
+               appendStringInfoString(string, "[]");
+}
+
+/*
+ * TypeNameToString
+ *             Produce a string representing the name of a TypeName.
+ *
+ * NB: this must work on TypeNames that do not describe any actual type;
+ * it is mostly used for reporting lookup errors.
+ */
+char *
+TypeNameToString(const TypeName *typename)
+{
+       StringInfoData string;
+
+       initStringInfo(&string);
+       appendTypeNameToBuffer(typename, &string);
+       return string.data;
+}
+
+/*
+ * TypeNameListToString
+ *             Produce a string representing the name(s) of a List of TypeNames
+ */
+char *
+TypeNameListToString(List *typenames)
+{
+       StringInfoData string;
+       ListCell   *l;
 
+       initStringInfo(&string);
+       foreach(l, typenames)
+       {
+               TypeName *typename = (TypeName *) lfirst(l);
+
+               Assert(IsA(typename, TypeName));
+               if (l != list_head(typenames))
+                       appendStringInfoChar(&string, ',');
+               appendTypeNameToBuffer(typename, &string);
+       }
        return string.data;
 }
 
index 62c02370deb29f64a06fe1b07b9787acc8ef168a..0d2cf087d15fa506a5d5eba2495c7b2b0bbf8d72 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/parser/parse_type.h,v 1.32 2006/03/14 22:48:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/parser/parse_type.h,v 1.33 2006/09/25 15:17:34 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,6 +22,7 @@ typedef HeapTuple Type;
 
 extern Oid     LookupTypeName(ParseState *pstate, const TypeName *typename);
 extern char *TypeNameToString(const TypeName *typename);
+extern char *TypeNameListToString(List *typenames);
 extern Oid     typenameTypeId(ParseState *pstate, const TypeName *typename);
 extern Type typenameType(ParseState *pstate, const TypeName *typename);