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

Commitfbd26d6

Browse files
committed
Arrange that no database accesses are attempted during parser() --- this
took some rejiggering of typename and ACL parsing, as well as movingparse_analyze call out of parser(). Restructure postgres.c processingso that parse analysis and rewrite are skipped when in abort-transactionstate. Only COMMIT and ABORT statements will be processed beyond the rawparser() phase. This addresses problem of parser failing with database accesserrors while in aborted state (see pghackers discussions around 7/28/00).Also fix some bugs with COMMIT/ABORT statements appearing in the middle ofa single query input string.Function, operator, and aggregate arguments/results can now use fullTypeName production, in particular foo[] for array types.DROP OPERATOR and COMMENT ON OPERATOR were broken for unary operators.Allow CREATE AGGREGATE to accept unquoted numeric constants for initcond.
1 parent4837270 commitfbd26d6

File tree

20 files changed

+768
-750
lines changed

20 files changed

+768
-750
lines changed

‎src/backend/catalog/pg_proc.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.48 2000/08/21 20:55:31 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.49 2000/10/07 00:58:15 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -93,35 +93,34 @@ ProcedureCreate(char *procedureName,
9393
MemSet(typev,0,FUNC_MAX_ARGS*sizeof(Oid));
9494
foreach(x,argList)
9595
{
96-
Value*t=lfirst(x);
96+
TypeName*t= (TypeName*)lfirst(x);
97+
char*typnam=TypeNameToInternalName(t);
9798

9899
if (parameterCount >=FUNC_MAX_ARGS)
99100
elog(ERROR,"Procedures cannot take more than %d arguments",
100101
FUNC_MAX_ARGS);
101102

102-
if (strcmp(strVal(t),"opaque")==0)
103+
if (strcmp(typnam,"opaque")==0)
103104
{
104105
if (languageObjectId==SQLlanguageId)
105106
elog(ERROR,"ProcedureCreate: sql functions cannot take type \"opaque\"");
106-
toid=0;
107+
toid=InvalidOid;
107108
}
108109
else
109110
{
110-
toid=TypeGet(strVal(t),&defined);
111+
toid=TypeGet(typnam,&defined);
111112

112113
if (!OidIsValid(toid))
113-
{
114114
elog(ERROR,"ProcedureCreate: arg type '%s' is not defined",
115-
strVal(t));
116-
}
117-
115+
typnam);
118116
if (!defined)
119-
{
120117
elog(NOTICE,"ProcedureCreate: arg type '%s' is only a shell",
121-
strVal(t));
122-
}
118+
typnam);
123119
}
124120

121+
if (t->setof)
122+
elog(ERROR,"ProcedureCreate: functions cannot accept set arguments");
123+
125124
typev[parameterCount++]=toid;
126125
}
127126

@@ -178,7 +177,7 @@ ProcedureCreate(char *procedureName,
178177
{
179178
if (languageObjectId==SQLlanguageId)
180179
elog(ERROR,"ProcedureCreate: sql functions cannot return type \"opaque\"");
181-
typeObjectId=0;
180+
typeObjectId=InvalidOid;
182181
}
183182
else
184183
{
@@ -194,10 +193,8 @@ ProcedureCreate(char *procedureName,
194193
returnTypeName);
195194
}
196195
elseif (!defined)
197-
{
198196
elog(NOTICE,"ProcedureCreate: return type '%s' is only a shell",
199197
returnTypeName);
200-
}
201198
}
202199

203200
/*
@@ -212,7 +209,6 @@ ProcedureCreate(char *procedureName,
212209
elog(ERROR,"method %s already an attribute of type %s",
213210
procedureName,strVal(lfirst(argList)));
214211

215-
216212
/*
217213
* If this is a postquel procedure, we parse it here in order to be
218214
* sure that it contains no syntax errors.We should store the plan

‎src/backend/commands/comment.c

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include"commands/comment.h"
2626
#include"miscadmin.h"
2727
#include"parser/parse.h"
28+
#include"parser/parse_expr.h"
29+
#include"parser/parse_func.h"
2830
#include"rewrite/rewriteRemove.h"
2931
#include"utils/acl.h"
3032
#include"utils/fmgroids.h"
@@ -46,7 +48,7 @@ static void CommentAttribute(char *relation, char *attrib, char *comment);
4648
staticvoidCommentDatabase(char*database,char*comment);
4749
staticvoidCommentRewrite(char*rule,char*comment);
4850
staticvoidCommentType(char*type,char*comment);
49-
staticvoidCommentAggregate(char*aggregate,char*aggtype,char*comment);
51+
staticvoidCommentAggregate(char*aggregate,List*arguments,char*comment);
5052
staticvoidCommentProc(char*function,List*arguments,char*comment);
5153
staticvoidCommentOperator(char*opname,List*arguments,char*comment);
5254
staticvoidCommentTrigger(char*trigger,char*relation,char*comments);
@@ -92,7 +94,7 @@ CommentObject(int objtype, char *objname, char *objproperty,
9294
CommentType(objname,comment);
9395
break;
9496
case (AGGREGATE):
95-
CommentAggregate(objname,objproperty,comment);
97+
CommentAggregate(objname,objlist,comment);
9698
break;
9799
case (FUNCTION):
98100
CommentProc(objname,objlist,comment);
@@ -544,21 +546,23 @@ CommentType(char *type, char *comment)
544546
*/
545547

546548
staticvoid
547-
CommentAggregate(char*aggregate,char*argument,char*comment)
549+
CommentAggregate(char*aggregate,List*arguments,char*comment)
548550
{
549-
551+
TypeName*aggtype= (TypeName*)lfirst(arguments);
552+
char*aggtypename=NULL;
550553
HeapTupleaggtuple;
551554
Oidbaseoid,
552555
oid;
553556
booldefined;
554557

555558
/*** First, attempt to determine the base aggregate oid ***/
556559

557-
if (argument)
560+
if (aggtype)
558561
{
559-
baseoid=TypeGet(argument,&defined);
562+
aggtypename=TypeNameToInternalName(aggtype);
563+
baseoid=TypeGet(aggtypename,&defined);
560564
if (!OidIsValid(baseoid))
561-
elog(ERROR,"aggregatetype '%s' does not exist",argument);
565+
elog(ERROR,"type '%s' does not exist",aggtypename);
562566
}
563567
else
564568
baseoid=0;
@@ -568,10 +572,10 @@ CommentAggregate(char *aggregate, char *argument, char *comment)
568572
#ifndefNO_SECURITY
569573
if (!pg_aggr_ownercheck(GetUserId(),aggregate,baseoid))
570574
{
571-
if (argument)
575+
if (aggtypename)
572576
{
573577
elog(ERROR,"you are not permitted to comment on aggregate '%s' %s '%s'",
574-
aggregate,"with type",argument);
578+
aggregate,"with type",aggtypename);
575579
}
576580
else
577581
{
@@ -587,10 +591,10 @@ CommentAggregate(char *aggregate, char *argument, char *comment)
587591
ObjectIdGetDatum(baseoid),0,0);
588592
if (!HeapTupleIsValid(aggtuple))
589593
{
590-
if (argument)
594+
if (aggtypename)
591595
{
592596
elog(ERROR,"aggregate type '%s' does not exist for aggregate '%s'",
593-
argument,aggregate);
597+
aggtypename,aggregate);
594598
}
595599
else
596600
elog(ERROR,"aggregate '%s' does not exist",aggregate);
@@ -622,7 +626,6 @@ CommentProc(char *function, List *arguments, char *comment)
622626
functuple;
623627
Oidoid,
624628
argoids[FUNC_MAX_ARGS];
625-
char*argument;
626629
inti,
627630
argcount;
628631

@@ -635,18 +638,20 @@ CommentProc(char *function, List *arguments, char *comment)
635638
FUNC_MAX_ARGS);
636639
for (i=0;i<argcount;i++)
637640
{
638-
argument=strVal(lfirst(arguments));
641+
TypeName*t= (TypeName*)lfirst(arguments);
642+
char*typnam=TypeNameToInternalName(t);
643+
639644
arguments=lnext(arguments);
640-
if (strcmp(argument,"opaque")==0)
641-
argoids[i]=0;
645+
646+
if (strcmp(typnam,"opaque")==0)
647+
argoids[i]=InvalidOid;
642648
else
643649
{
644650
argtuple=SearchSysCacheTuple(TYPENAME,
645-
PointerGetDatum(argument),
651+
PointerGetDatum(typnam),
646652
0,0,0);
647653
if (!HeapTupleIsValid(argtuple))
648-
elog(ERROR,"function argument type '%s' does not exist",
649-
argument);
654+
elog(ERROR,"CommentProc: type '%s' not found",typnam);
650655
argoids[i]=argtuple->t_data->t_oid;
651656
}
652657
}
@@ -664,10 +669,9 @@ CommentProc(char *function, List *arguments, char *comment)
664669
functuple=SearchSysCacheTuple(PROCNAME,PointerGetDatum(function),
665670
Int32GetDatum(argcount),
666671
PointerGetDatum(argoids),0);
667-
668672
if (!HeapTupleIsValid(functuple))
669-
elog(ERROR,"function '%s' with the supplied %s does not exist",
670-
function,"argument list");
673+
func_error("CommentProc",function,argcount,argoids,NULL);
674+
671675
oid=functuple->t_data->t_oid;
672676

673677
/*** Call CreateComments() to create/drop the comments ***/
@@ -691,23 +695,24 @@ CommentProc(char *function, List *arguments, char *comment)
691695
staticvoid
692696
CommentOperator(char*opername,List*arguments,char*comment)
693697
{
694-
698+
TypeName*typenode1= (TypeName*)lfirst(arguments);
699+
TypeName*typenode2= (TypeName*)lsecond(arguments);
700+
charoprtype=0,
701+
*lefttype=NULL,
702+
*righttype=NULL;
695703
Form_pg_operatordata;
696704
HeapTupleoptuple;
697705
Oidoid,
698706
leftoid=InvalidOid,
699707
rightoid=InvalidOid;
700708
booldefined;
701-
charoprtype=0,
702-
*lefttype=NULL,
703-
*righttype=NULL;
704709

705710
/*** Initialize our left and right argument types ***/
706711

707-
if (lfirst(arguments)!=NULL)
708-
lefttype=strVal(lfirst(arguments));
709-
if (lsecond(arguments)!=NULL)
710-
righttype=strVal(lsecond(arguments));
712+
if (typenode1!=NULL)
713+
lefttype=TypeNameToInternalName(typenode1);
714+
if (typenode2!=NULL)
715+
righttype=TypeNameToInternalName(typenode2);
711716

712717
/*** Attempt to fetch the left oid, if specified ***/
713718

@@ -732,9 +737,9 @@ CommentOperator(char *opername, List *arguments, char *comment)
732737
if (OidIsValid(leftoid)&& (OidIsValid(rightoid)))
733738
oprtype='b';
734739
elseif (OidIsValid(leftoid))
735-
oprtype='l';
736-
elseif (OidIsValid(rightoid))
737740
oprtype='r';
741+
elseif (OidIsValid(rightoid))
742+
oprtype='l';
738743
else
739744
elog(ERROR,"operator '%s' is of an illegal type'",opername);
740745

@@ -769,7 +774,6 @@ CommentOperator(char *opername, List *arguments, char *comment)
769774
/*** Call CreateComments() to create/drop the comments ***/
770775

771776
CreateComments(oid,comment);
772-
773777
}
774778

775779
/*------------------------------------------------------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp