mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
Implement SQL-compliant treatment of row comparisons for < <= > >= cases
(previously we only did = and <> correctly). Also, allow row comparisons with any operators that are in btree opclasses, not only those with these specific names. This gets rid of a whole lot of indefensible assumptions about the behavior of particular operators based on their names ... though it's still true that IN and NOT IN expand to "= ANY". The patch adds a RowCompareExpr expression node type, and makes some changes in the representation of ANY/ALL/ROWCOMPARE SubLinks so that they can share code with RowCompareExpr. I have not yet done anything about making RowCompareExpr an indexable operator, but will look at that soon. initdb forced due to changes in stored rules.
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.323 2005/12/20 02:30:35 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.324 2005/12/28 01:29:59 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -862,10 +862,8 @@ _copySubLink(SubLink *from)
|
||||
SubLink *newnode = makeNode(SubLink);
|
||||
|
||||
COPY_SCALAR_FIELD(subLinkType);
|
||||
COPY_SCALAR_FIELD(useOr);
|
||||
COPY_NODE_FIELD(lefthand);
|
||||
COPY_NODE_FIELD(testexpr);
|
||||
COPY_NODE_FIELD(operName);
|
||||
COPY_NODE_FIELD(operOids);
|
||||
COPY_NODE_FIELD(subselect);
|
||||
|
||||
return newnode;
|
||||
@ -880,8 +878,7 @@ _copySubPlan(SubPlan *from)
|
||||
SubPlan *newnode = makeNode(SubPlan);
|
||||
|
||||
COPY_SCALAR_FIELD(subLinkType);
|
||||
COPY_SCALAR_FIELD(useOr);
|
||||
COPY_NODE_FIELD(exprs);
|
||||
COPY_NODE_FIELD(testexpr);
|
||||
COPY_NODE_FIELD(paramIds);
|
||||
COPY_NODE_FIELD(plan);
|
||||
COPY_SCALAR_FIELD(plan_id);
|
||||
@ -1033,6 +1030,23 @@ _copyRowExpr(RowExpr *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyRowCompareExpr
|
||||
*/
|
||||
static RowCompareExpr *
|
||||
_copyRowCompareExpr(RowCompareExpr *from)
|
||||
{
|
||||
RowCompareExpr *newnode = makeNode(RowCompareExpr);
|
||||
|
||||
COPY_SCALAR_FIELD(rctype);
|
||||
COPY_NODE_FIELD(opnos);
|
||||
COPY_NODE_FIELD(opclasses);
|
||||
COPY_NODE_FIELD(largs);
|
||||
COPY_NODE_FIELD(rargs);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyCoalesceExpr
|
||||
*/
|
||||
@ -2876,6 +2890,9 @@ copyObject(void *from)
|
||||
case T_RowExpr:
|
||||
retval = _copyRowExpr(from);
|
||||
break;
|
||||
case T_RowCompareExpr:
|
||||
retval = _copyRowCompareExpr(from);
|
||||
break;
|
||||
case T_CoalesceExpr:
|
||||
retval = _copyCoalesceExpr(from);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user