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);
}
+
}
/*------------------------------------------------------------------
*------------------------------------------------------------------
*/
-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);
}
/*------------------------------------------------------------------