From 6e07709760a29d8dbfb93b9846c905bd40689082 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 28 Dec 2005 01:30:02 +0000 Subject: 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. --- src/backend/nodes/outfuncs.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/backend/nodes/outfuncs.c') diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index aa5fd99db8..b60eab31fd 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.265 2005/12/20 02:30:35 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.266 2005/12/28 01:29:59 tgl Exp $ * * NOTES * Every node type that can appear in stored rules' parsetrees *must* @@ -736,10 +736,8 @@ _outSubLink(StringInfo str, SubLink *node) WRITE_NODE_TYPE("SUBLINK"); WRITE_ENUM_FIELD(subLinkType, SubLinkType); - WRITE_BOOL_FIELD(useOr); - WRITE_NODE_FIELD(lefthand); + WRITE_NODE_FIELD(testexpr); WRITE_NODE_FIELD(operName); - WRITE_NODE_FIELD(operOids); WRITE_NODE_FIELD(subselect); } @@ -749,8 +747,7 @@ _outSubPlan(StringInfo str, SubPlan *node) WRITE_NODE_TYPE("SUBPLAN"); WRITE_ENUM_FIELD(subLinkType, SubLinkType); - WRITE_BOOL_FIELD(useOr); - WRITE_NODE_FIELD(exprs); + WRITE_NODE_FIELD(testexpr); WRITE_NODE_FIELD(paramIds); WRITE_NODE_FIELD(plan); WRITE_INT_FIELD(plan_id); @@ -855,6 +852,18 @@ _outRowExpr(StringInfo str, RowExpr *node) WRITE_ENUM_FIELD(row_format, CoercionForm); } +static void +_outRowCompareExpr(StringInfo str, RowCompareExpr *node) +{ + WRITE_NODE_TYPE("ROWCOMPARE"); + + WRITE_ENUM_FIELD(rctype, RowCompareType); + WRITE_NODE_FIELD(opnos); + WRITE_NODE_FIELD(opclasses); + WRITE_NODE_FIELD(largs); + WRITE_NODE_FIELD(rargs); +} + static void _outCoalesceExpr(StringInfo str, CoalesceExpr *node) { @@ -1936,6 +1945,9 @@ _outNode(StringInfo str, void *obj) case T_RowExpr: _outRowExpr(str, obj); break; + case T_RowCompareExpr: + _outRowCompareExpr(str, obj); + break; case T_CoalesceExpr: _outCoalesceExpr(str, obj); break; -- cgit v1.2.1