aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-07-01 00:04:39 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-07-01 00:04:39 +0000
commitd6d07a0eeabc8dfa6f8803193c2896d3e2e53a3c (patch)
tree72c5bf24d290111ad02b96f470055f9498689a5f /src/backend/utils
parent71e9f3b07f2f993492233dc2fff0566acc70eb64 (diff)
downloadpostgresql-d6d07a0eeabc8dfa6f8803193c2896d3e2e53a3c.tar.gz
postgresql-d6d07a0eeabc8dfa6f8803193c2896d3e2e53a3c.zip
SQL functions can have arguments and results declared ANYARRAY or
ANYELEMENT. The effect is to postpone typechecking of the function body until runtime. Documentation is still lacking. Original patch by Joe Conway, modified to postpone type checking by Tom Lane.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/array_userfuncs.c6
-rw-r--r--src/backend/utils/adt/arrayfuncs.c4
-rw-r--r--src/backend/utils/fmgr/fmgr.c21
3 files changed, 17 insertions, 14 deletions
diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c
index 3aa70b0d332..6c28b211ceb 100644
--- a/src/backend/utils/adt/array_userfuncs.c
+++ b/src/backend/utils/adt/array_userfuncs.c
@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.4 2003/06/27 00:33:25 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.5 2003/07/01 00:04:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -37,8 +37,8 @@ array_push(PG_FUNCTION_ARGS)
int16 typlen;
bool typbyval;
char typalign;
- Oid arg0_typeid = get_fn_expr_argtype(fcinfo, 0);
- Oid arg1_typeid = get_fn_expr_argtype(fcinfo, 1);
+ Oid arg0_typeid = get_fn_expr_argtype(fcinfo->flinfo, 0);
+ Oid arg1_typeid = get_fn_expr_argtype(fcinfo->flinfo, 1);
Oid arg0_elemid;
Oid arg1_elemid;
ArrayMetaState *my_extra;
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 808353a63d4..d0a876a877b 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.92 2003/06/27 00:33:25 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.93 2003/07/01 00:04:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2792,7 +2792,7 @@ array_type_coerce(PG_FUNCTION_ARGS)
if (my_extra->srctype != src_elem_type)
{
- Oid tgt_type = get_fn_expr_rettype(fcinfo);
+ Oid tgt_type = get_fn_expr_rettype(fmgr_info);
Oid tgt_elem_type;
Oid funcId;
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index 0d69ac1083e..04e72e53413 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.71 2003/06/29 00:33:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.72 2003/07/01 00:04:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1616,16 +1616,19 @@ pg_detoast_datum_slice(struct varlena * datum, int32 first, int32 count)
/*-------------------------------------------------------------------------
* Support routines for extracting info from fn_expr parse tree
+ *
+ * These are needed by polymorphic functions, which accept multiple possible
+ * input types and need help from the parser to know what they've got.
*-------------------------------------------------------------------------
*/
/*
- * Get the OID of the function return type
+ * Get the actual type OID of the function return type
*
* Returns InvalidOid if information is not available
*/
Oid
-get_fn_expr_rettype(FunctionCallInfo fcinfo)
+get_fn_expr_rettype(FmgrInfo *flinfo)
{
Node *expr;
@@ -1633,21 +1636,21 @@ get_fn_expr_rettype(FunctionCallInfo fcinfo)
* can't return anything useful if we have no FmgrInfo or if
* its fn_expr node has not been initialized
*/
- if (!fcinfo || !fcinfo->flinfo || !fcinfo->flinfo->fn_expr)
+ if (!flinfo || !flinfo->fn_expr)
return InvalidOid;
- expr = fcinfo->flinfo->fn_expr;
+ expr = flinfo->fn_expr;
return exprType(expr);
}
/*
- * Get the type OID of a specific function argument (counting from 0)
+ * Get the actual type OID of a specific function argument (counting from 0)
*
* Returns InvalidOid if information is not available
*/
Oid
-get_fn_expr_argtype(FunctionCallInfo fcinfo, int argnum)
+get_fn_expr_argtype(FmgrInfo *flinfo, int argnum)
{
Node *expr;
List *args;
@@ -1657,10 +1660,10 @@ get_fn_expr_argtype(FunctionCallInfo fcinfo, int argnum)
* can't return anything useful if we have no FmgrInfo or if
* its fn_expr node has not been initialized
*/
- if (!fcinfo || !fcinfo->flinfo || !fcinfo->flinfo->fn_expr)
+ if (!flinfo || !flinfo->fn_expr)
return InvalidOid;
- expr = fcinfo->flinfo->fn_expr;
+ expr = flinfo->fn_expr;
if (IsA(expr, FuncExpr))
args = ((FuncExpr *) expr)->args;