summaryrefslogtreecommitdiff
path: root/src/backend/utils/fmgr
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-06-29 00:33:44 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-06-29 00:33:44 +0000
commitbee217924d51af8cf0411167bfc8a7eb55122577 (patch)
treeab6d3f311de5fd6b415e0bdf032205ed503ba95c /src/backend/utils/fmgr
parentdf7618020b3845a51d1ba80cb9abfc6df5dfeaff (diff)
downloadpostgresql-bee217924d51af8cf0411167bfc8a7eb55122577.tar.gz
Support expressions of the form 'scalar op ANY (array)' and
'scalar op ALL (array)', where the operator is applied between the lefthand scalar and each element of the array. The operator must yield boolean; the result of the construct is the OR or AND of the per-element results, respectively. Original coding by Joe Conway, after an idea of Peter's. Rewritten by Tom to keep the implementation strictly separate from subqueries.
Diffstat (limited to 'src/backend/utils/fmgr')
-rw-r--r--src/backend/utils/fmgr/fmgr.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index e161bd1e59..0d69ac1083 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.70 2003/06/25 21:30:32 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.71 2003/06/29 00:33:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1651,6 +1651,7 @@ get_fn_expr_argtype(FunctionCallInfo fcinfo, int argnum)
{
Node *expr;
List *args;
+ Oid argtype;
/*
* can't return anything useful if we have no FmgrInfo or if
@@ -1665,11 +1666,27 @@ get_fn_expr_argtype(FunctionCallInfo fcinfo, int argnum)
args = ((FuncExpr *) expr)->args;
else if (IsA(expr, OpExpr))
args = ((OpExpr *) expr)->args;
+ else if (IsA(expr, DistinctExpr))
+ args = ((DistinctExpr *) expr)->args;
+ else if (IsA(expr, ScalarArrayOpExpr))
+ args = ((ScalarArrayOpExpr *) expr)->args;
+ else if (IsA(expr, NullIfExpr))
+ args = ((NullIfExpr *) expr)->args;
else
return InvalidOid;
if (argnum < 0 || argnum >= length(args))
return InvalidOid;
- return exprType((Node *) nth(argnum, args));
+ argtype = exprType((Node *) nth(argnum, args));
+
+ /*
+ * special hack for ScalarArrayOpExpr: what the underlying function
+ * will actually get passed is the element type of the array.
+ */
+ if (IsA(expr, ScalarArrayOpExpr) &&
+ argnum == 1)
+ argtype = get_element_type(argtype);
+
+ return argtype;
}