CommentProc was careless about too many arguments.
authorTom Lane
Wed, 12 Jan 2000 04:59:41 +0000 (04:59 +0000)
committerTom Lane
Wed, 12 Jan 2000 04:59:41 +0000 (04:59 +0000)
src/backend/commands/comment.c

index d560d7862125879b0e27c74d59024b5933ccf4c9..93feb9e8054f8cd2cfc28e757fcb86ec19730994 100644 (file)
@@ -101,10 +101,11 @@ void CommentObject(int objtype, char *objname, char *objproperty,
     CommentTrigger(objname, objproperty, comment);
     break;
   default:
-    elog(ERROR, "An attempt was made to comment on a unkown type: %i",
+    elog(ERROR, "An attempt was made to comment on a unknown type: %i",
     objtype);
   }
 
+
 }
 
 /*------------------------------------------------------------------
@@ -586,64 +587,62 @@ void CommentAggregate(char *aggregate, char *argument, char *comment) {
  *------------------------------------------------------------------
 */
 
-void CommentProc(char *function, List *arguments, char *comment) {
-
-  HeapTuple argtuple, functuple;
-  Oid oid, argoids[FUNC_MAX_ARGS];
-  char *user, *argument;
-  int i, argcount;
-
-  /*** First, initialize function's argument list with their type oids ***/
-
-  argcount = length(arguments);
-  if (argcount > 0) {
-    MemSet(argoids, 0, FUNC_MAX_ARGS * sizeof(Oid));
-    for (i = 0; i < argcount; i++) {
-      argument = strVal(lfirst(arguments));
-      arguments = lnext(arguments);
-      if (strcmp(argument, "opaque") == 0) {
-   argoids[i] = 0;
-      } else {
-   argtuple = SearchSysCacheTuple(TYPENAME, PointerGetDatum(argument),
-                      0, 0, 0);
-   if (!HeapTupleIsValid(argtuple)) {
-     elog(ERROR, "function argument type '%s' does not exist",
-          argument);
-   }
-   argoids[i] = argtuple->t_data->t_oid;
-      }
+void CommentProc(char *function, List *arguments, char *comment)
+{
+   HeapTuple argtuple, functuple;
+   Oid oid, argoids[FUNC_MAX_ARGS];
+   char *user, *argument;
+   int i, argcount;
+
+   /*** First, initialize function's argument list with their type oids ***/
+
+   MemSet(argoids, 0, FUNC_MAX_ARGS * sizeof(Oid));
+   argcount = length(arguments);
+   if (argcount > FUNC_MAX_ARGS)
+       elog(ERROR, "functions cannot have more than %d arguments",
+            FUNC_MAX_ARGS);
+   for (i = 0; i < argcount; i++) {
+       argument = strVal(lfirst(arguments));
+       arguments = lnext(arguments);
+       if (strcmp(argument, "opaque") == 0)
+       {
+           argoids[i] = 0;
+       }
+       else
+       {
+           argtuple = SearchSysCacheTuple(TYPENAME,
+                                          PointerGetDatum(argument),
+                                          0, 0, 0);
+           if (!HeapTupleIsValid(argtuple))
+               elog(ERROR, "function argument type '%s' does not exist",
+                    argument);
+           argoids[i] = argtuple->t_data->t_oid;
+       }
     }
-  }
-
-  /*** Now, validate the user's ability to comment on this function ***/
-
-  #ifndef NO_SECURITY
-  user = GetPgUserName();
-  if (!pg_func_ownercheck(user, function, argcount, argoids)) {
-    elog(ERROR, "you are not permitted to comment on function '%s'",
-    function);
-  }
-  #endif
-
-  /*** Now, find the corresponding oid for this procedure ***/
 
-  functuple = SearchSysCacheTuple(PROCNAME, PointerGetDatum(function),
-                 Int32GetDatum(argcount),
-                 PointerGetDatum(argoids), 0);
+   /*** Now, validate the user's ability to comment on this function ***/
 
-  /*** Deallocate our argument oids and check the function tuple ***/
+#ifndef NO_SECURITY
+   user = GetPgUserName();
+   if (!pg_func_ownercheck(user, function, argcount, argoids))
+       elog(ERROR, "you are not permitted to comment on function '%s'",
+            function);
+#endif
 
-  if (!HeapTupleIsValid(functuple)) {
-    elog(ERROR, "function '%s' with the supplied %s does not exist",
-    function, "argument list");
-  }
+   /*** Now, find the corresponding oid for this procedure ***/
 
-  oid = functuple->t_data->t_oid;
+   functuple = SearchSysCacheTuple(PROCNAME, PointerGetDatum(function),
+                                   Int32GetDatum(argcount),
+                                   PointerGetDatum(argoids), 0);
 
-  /*** Call CreateComments() to create/drop the comments ***/
+   if (!HeapTupleIsValid(functuple))
+       elog(ERROR, "function '%s' with the supplied %s does not exist",
+            function, "argument list");
+   oid = functuple->t_data->t_oid;
 
-  CreateComments(oid, comment);
+   /*** Call CreateComments() to create/drop the comments ***/
 
+   CreateComments(oid, comment);
 }
 
 /*------------------------------------------------------------------