@@ -1003,9 +1003,12 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
10031003
10041004 if (stmt -> is_procedure )
10051005 {
1006+ /*
1007+ * Sometime in the future, procedures might be allowed to return
1008+ * results; for now, they all return VOID.
1009+ */
10061010 Assert (!stmt -> returnType );
1007-
1008- prorettype = InvalidOid ;
1011+ prorettype = VOIDOID ;
10091012 returnsSet = false;
10101013 }
10111014 else if (stmt -> returnType )
@@ -1097,8 +1100,7 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
10971100 languageValidator ,
10981101 prosrc_str , /* converted to text later */
10991102 probin_str , /* converted to text later */
1100- false, /* not an aggregate */
1101- isWindowFunc ,
1103+ stmt -> is_procedure ? PROKIND_PROCEDURE : (isWindowFunc ? PROKIND_WINDOW : PROKIND_FUNCTION ),
11021104 security ,
11031105 isLeakProof ,
11041106 isStrict ,
@@ -1126,7 +1128,7 @@ RemoveFunctionById(Oid funcOid)
11261128{
11271129 Relation relation ;
11281130 HeapTuple tup ;
1129- bool isagg ;
1131+ char prokind ;
11301132
11311133 /*
11321134 * Delete the pg_proc tuple.
@@ -1137,7 +1139,7 @@ RemoveFunctionById(Oid funcOid)
11371139 if (!HeapTupleIsValid (tup )) /* should not happen */
11381140 elog (ERROR , "cache lookup failed for function %u" , funcOid );
11391141
1140- isagg = ((Form_pg_proc ) GETSTRUCT (tup ))-> proisagg ;
1142+ prokind = ((Form_pg_proc ) GETSTRUCT (tup ))-> prokind ;
11411143
11421144 CatalogTupleDelete (relation , & tup -> t_self );
11431145
@@ -1148,7 +1150,7 @@ RemoveFunctionById(Oid funcOid)
11481150 /*
11491151 * If there's a pg_aggregate tuple, delete that too.
11501152 */
1151- if (isagg )
1153+ if (prokind == PROKIND_AGGREGATE )
11521154 {
11531155 relation = heap_open (AggregateRelationId , RowExclusiveLock );
11541156
@@ -1203,13 +1205,13 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
12031205 aclcheck_error (ACLCHECK_NOT_OWNER , stmt -> objtype ,
12041206 NameListToString (stmt -> func -> objname ));
12051207
1206- if (procForm -> proisagg )
1208+ if (procForm -> prokind == PROKIND_AGGREGATE )
12071209 ereport (ERROR ,
12081210 (errcode (ERRCODE_WRONG_OBJECT_TYPE ),
12091211 errmsg ("\"%s\" is an aggregate function" ,
12101212 NameListToString (stmt -> func -> objname ))));
12111213
1212- is_procedure = (procForm -> prorettype == InvalidOid );
1214+ is_procedure = (procForm -> prokind == PROKIND_PROCEDURE );
12131215
12141216 /* Examine requested actions. */
12151217 foreach (l , stmt -> actions )
@@ -1525,14 +1527,10 @@ CreateCast(CreateCastStmt *stmt)
15251527 (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
15261528 errmsg ("cast function must not be volatile" )));
15271529#endif
1528- if (procstruct -> proisagg )
1530+ if (procstruct -> prokind != PROKIND_FUNCTION )
15291531 ereport (ERROR ,
15301532 (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
1531- errmsg ("cast function must not be an aggregate function" )));
1532- if (procstruct -> proiswindow )
1533- ereport (ERROR ,
1534- (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
1535- errmsg ("cast function must not be a window function" )));
1533+ errmsg ("cast function must be a normal function" )));
15361534 if (procstruct -> proretset )
15371535 ereport (ERROR ,
15381536 (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
@@ -1777,14 +1775,10 @@ check_transform_function(Form_pg_proc procstruct)
17771775 ereport (ERROR ,
17781776 (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
17791777 errmsg ("transform function must not be volatile" )));
1780- if (procstruct -> proisagg )
1781- ereport (ERROR ,
1782- (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
1783- errmsg ("transform function must not be an aggregate function" )));
1784- if (procstruct -> proiswindow )
1778+ if (procstruct -> prokind != PROKIND_FUNCTION )
17851779 ereport (ERROR ,
17861780 (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
1787- errmsg ("transform function must not be a window function" )));
1781+ errmsg ("transform function must be a normal function" )));
17881782 if (procstruct -> proretset )
17891783 ereport (ERROR ,
17901784 (errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
0 commit comments