Joe Conway wrote:
Tom Lane wrote:
Joe Conway [EMAIL PROTECTED] writes:
Included in the patch, I changed SQL language functions so that they
could be declared with and use polymorphic types.
I'm not convinced that will work ... in particular, does the parsetree
get fixed correctly when a SQL function is inlined?
So I'd propose that we put another check in inline_function(), and
reject attempts to inline functions with polymorphic arguments. The
other bases are already covered and we already have the proc tuple
available in inline_function(). Sound OK?
Here's another copy of the polymorphic (aggregates + SQL functions)
patch. This one includes the proposed chage above to ensure polymorphic
SQL functions do not get inlined. They can be successfully simplified by
evaluate_function() when appropriate, as I showed in the last post.
Otherwise, it should be the same. Still compiles clean and passes all
regression tests.
Please apply.
Thanks,
Joe
Index: src/backend/catalog/pg_aggregate.c
===
RCS file: /opt/src/cvs/pgsql-server/src/backend/catalog/pg_aggregate.c,v
retrieving revision 1.58
diff -c -r1.58 pg_aggregate.c
*** src/backend/catalog/pg_aggregate.c 25 Jun 2003 21:30:25 - 1.58
--- src/backend/catalog/pg_aggregate.c 29 Jun 2003 19:17:47 -
***
*** 50,59
Oid finalfn = InvalidOid; /* can be omitted */
Oid finaltype;
Oid fnArgs[FUNC_MAX_ARGS];
! int nargs;
Oid procOid;
TupleDesc tupDesc;
int i;
ObjectAddress myself,
referenced;
--- 50,65
Oid finalfn = InvalidOid; /* can be omitted */
Oid finaltype;
Oid fnArgs[FUNC_MAX_ARGS];
! int nargs_transfn;
! int nargs_finalfn;
Oid procOid;
TupleDesc tupDesc;
int i;
+ Oid rettype;
+ Oid*true_oid_array_transfn;
+ Oid*true_oid_array_finalfn;
+ boolretset;
+ FuncDetailCode fdresult;
ObjectAddress myself,
referenced;
***
*** 68,91
MemSet(fnArgs, 0, FUNC_MAX_ARGS * sizeof(Oid));
fnArgs[0] = aggTransType;
if (aggBaseType == ANYOID)
! nargs = 1;
else
{
fnArgs[1] = aggBaseType;
! nargs = 2;
}
! transfn = LookupFuncName(aggtransfnName, nargs, fnArgs);
if (!OidIsValid(transfn))
! func_error(AggregateCreate, aggtransfnName, nargs, fnArgs, NULL);
tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(transfn),
0, 0, 0);
if (!HeapTupleIsValid(tup))
! func_error(AggregateCreate, aggtransfnName, nargs, fnArgs, NULL);
proc = (Form_pg_proc) GETSTRUCT(tup);
- if (proc-prorettype != aggTransType)
- elog(ERROR, return type of transition function %s is not %s,
-NameListToString(aggtransfnName), format_type_be(aggTransType));
/*
* If the transfn is strict and the initval is NULL, make sure input
--- 74,137
MemSet(fnArgs, 0, FUNC_MAX_ARGS * sizeof(Oid));
fnArgs[0] = aggTransType;
if (aggBaseType == ANYOID)
! nargs_transfn = 1;
else
{
fnArgs[1] = aggBaseType;
! nargs_transfn = 2;
}
!
! /*
!* func_get_detail looks up the function in the catalogs, does
!* disambiguation for polymorphic functions, handles inheritance, and
!* returns the funcid and type and set or singleton status of the
!* function's return value. it also returns the true argument types
!* to the function.
!*/
! fdresult = func_get_detail(aggtransfnName, NIL, nargs_transfn, fnArgs,
! transfn, rettype, retset,
! true_oid_array_transfn);
!
! /* only valid case is a normal function */
! if (fdresult != FUNCDETAIL_NORMAL)
! func_error(AggregateCreate, aggtransfnName, nargs_transfn, fnArgs,
NULL);
!
if (!OidIsValid(transfn))
! func_error(AggregateCreate, aggtransfnName, nargs_transfn, fnArgs,
NULL);
!
! /*
!* enforce consistency with ANYARRAY and ANYELEMENT argument
!* and return types, possibly modifying return type along the way
!*/
! rettype = enforce_generic_type_consistency(fnArgs,