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

Commit8acc568

Browse files
committed
CommentProc was careless about too many arguments.
1 parent421d4f9 commit8acc568

File tree

1 file changed

+50
-51
lines changed

1 file changed

+50
-51
lines changed

‎src/backend/commands/comment.c

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ void CommentObject(int objtype, char *objname, char *objproperty,
101101
CommentTrigger(objname,objproperty,comment);
102102
break;
103103
default:
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",
105105
objtype);
106106
}
107107

108+
108109
}
109110

110111
/*------------------------------------------------------------------
@@ -586,64 +587,62 @@ void CommentAggregate(char *aggregate, char *argument, char *comment) {
586587
*------------------------------------------------------------------
587588
*/
588589

589-
voidCommentProc(char*function,List*arguments,char*comment) {
590-
591-
HeapTupleargtuple,functuple;
592-
Oidoid,argoids[FUNC_MAX_ARGS];
593-
char*user,*argument;
594-
inti,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+
voidCommentProc(char*function,List*arguments,char*comment)
591+
{
592+
HeapTupleargtuple,functuple;
593+
Oidoid,argoids[FUNC_MAX_ARGS];
594+
char*user,*argument;
595+
inti,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-
#ifndefNO_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+
#ifndefNO_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
/*------------------------------------------------------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp