mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
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.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.200 2003/06/27 14:45:28 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.201 2003/06/29 00:33:43 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -287,6 +287,27 @@ _equalDistinctExpr(DistinctExpr *a, DistinctExpr *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalScalarArrayOpExpr(ScalarArrayOpExpr *a, ScalarArrayOpExpr *b)
|
||||
{
|
||||
COMPARE_SCALAR_FIELD(opno);
|
||||
/*
|
||||
* Special-case opfuncid: it is allowable for it to differ if one
|
||||
* node contains zero and the other doesn't. This just means that the
|
||||
* one node isn't as far along in the parse/plan pipeline and hasn't
|
||||
* had the opfuncid cache filled yet.
|
||||
*/
|
||||
if (a->opfuncid != b->opfuncid &&
|
||||
a->opfuncid != 0 &&
|
||||
b->opfuncid != 0)
|
||||
return false;
|
||||
|
||||
COMPARE_SCALAR_FIELD(useOr);
|
||||
COMPARE_NODE_FIELD(args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalBoolExpr(BoolExpr *a, BoolExpr *b)
|
||||
{
|
||||
@@ -1661,6 +1682,9 @@ equal(void *a, void *b)
|
||||
case T_DistinctExpr:
|
||||
retval = _equalDistinctExpr(a, b);
|
||||
break;
|
||||
case T_ScalarArrayOpExpr:
|
||||
retval = _equalScalarArrayOpExpr(a, b);
|
||||
break;
|
||||
case T_BoolExpr:
|
||||
retval = _equalBoolExpr(a, b);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user