@@ -101,10 +101,11 @@ void CommentObject(int objtype, char *objname, char *objproperty,
101101CommentTrigger (objname ,objproperty ,comment );
102102break ;
103103default :
104- elog (ERROR ,"An attempt was made to comment on aunkown type: %i" ,
104+ elog (ERROR ,"An attempt was made to comment on aunknown type: %i" ,
105105objtype );
106106 }
107107
108+
108109}
109110
110111/*------------------------------------------------------------------
@@ -586,64 +587,62 @@ void CommentAggregate(char *aggregate, char *argument, char *comment) {
586587 *------------------------------------------------------------------
587588*/
588589
589- void CommentProc (char * function ,List * arguments ,char * comment ) {
590-
591- HeapTuple argtuple ,functuple ;
592- Oid oid ,argoids [FUNC_MAX_ARGS ];
593- char * user ,* argument ;
594- int i ,argcount ;
595-
596- /*** First, initialize function's argument list with their type oids ***/
597-
598- argcount = length (arguments );
599- if (argcount > 0 ) {
600- MemSet (argoids ,0 ,FUNC_MAX_ARGS * sizeof (Oid ));
601- for (i = 0 ;i < argcount ;i ++ ) {
602- argument = strVal (lfirst (arguments ));
603- arguments = lnext (arguments );
604- if (strcmp (argument ,"opaque" )== 0 ) {
605- argoids [i ]= 0 ;
606- }else {
607- argtuple = SearchSysCacheTuple (TYPENAME ,PointerGetDatum (argument ),
608- 0 ,0 ,0 );
609- if (!HeapTupleIsValid (argtuple )) {
610- elog (ERROR ,"function argument type '%s' does not exist" ,
611- argument );
612- }
613- argoids [i ]= argtuple -> t_data -> t_oid ;
614- }
590+ void CommentProc (char * function ,List * arguments ,char * comment )
591+ {
592+ HeapTuple argtuple ,functuple ;
593+ Oid oid ,argoids [FUNC_MAX_ARGS ];
594+ char * user ,* argument ;
595+ int i ,argcount ;
596+
597+ /*** First, initialize function's argument list with their type oids ***/
598+
599+ MemSet (argoids ,0 ,FUNC_MAX_ARGS * sizeof (Oid ));
600+ argcount = length (arguments );
601+ if (argcount > FUNC_MAX_ARGS )
602+ elog (ERROR ,"functions cannot have more than %d arguments" ,
603+ FUNC_MAX_ARGS );
604+ for (i = 0 ;i < argcount ;i ++ ) {
605+ argument = strVal (lfirst (arguments ));
606+ arguments = lnext (arguments );
607+ if (strcmp (argument ,"opaque" )== 0 )
608+ {
609+ argoids [i ]= 0 ;
610+ }
611+ else
612+ {
613+ argtuple = SearchSysCacheTuple (TYPENAME ,
614+ PointerGetDatum (argument ),
615+ 0 ,0 ,0 );
616+ if (!HeapTupleIsValid (argtuple ))
617+ elog (ERROR ,"function argument type '%s' does not exist" ,
618+ argument );
619+ argoids [i ]= argtuple -> t_data -> t_oid ;
620+ }
615621 }
616- }
617-
618- /*** Now, validate the user's ability to comment on this function ***/
619-
620- #ifndef NO_SECURITY
621- user = GetPgUserName ();
622- if (!pg_func_ownercheck (user ,function ,argcount ,argoids )) {
623- elog (ERROR ,"you are not permitted to comment on function '%s'" ,
624- function );
625- }
626- #endif
627-
628- /*** Now, find the corresponding oid for this procedure ***/
629622
630- functuple = SearchSysCacheTuple (PROCNAME ,PointerGetDatum (function ),
631- Int32GetDatum (argcount ),
632- PointerGetDatum (argoids ),0 );
623+ /*** Now, validate the user's ability to comment on this function ***/
633624
634- /*** Deallocate our argument oids and check the function tuple ***/
625+ #ifndef NO_SECURITY
626+ user = GetPgUserName ();
627+ if (!pg_func_ownercheck (user ,function ,argcount ,argoids ))
628+ elog (ERROR ,"you are not permitted to comment on function '%s'" ,
629+ function );
630+ #endif
635631
636- if (!HeapTupleIsValid (functuple )) {
637- elog (ERROR ,"function '%s' with the supplied %s does not exist" ,
638- function ,"argument list" );
639- }
632+ /*** Now, find the corresponding oid for this procedure ***/
640633
641- oid = functuple -> t_data -> t_oid ;
634+ functuple = SearchSysCacheTuple (PROCNAME ,PointerGetDatum (function ),
635+ Int32GetDatum (argcount ),
636+ PointerGetDatum (argoids ),0 );
642637
643- /*** Call CreateComments() to create/drop the comments ***/
638+ if (!HeapTupleIsValid (functuple ))
639+ elog (ERROR ,"function '%s' with the supplied %s does not exist" ,
640+ function ,"argument list" );
641+ oid = functuple -> t_data -> t_oid ;
644642
645- CreateComments (oid , comment );
643+ /*** Call CreateComments() to create/drop the comments ***/
646644
645+ CreateComments (oid ,comment );
647646}
648647
649648/*------------------------------------------------------------------