From 68d9fbeb5511d846ce3a6f66b8955d3ca55a4b76 Mon Sep 17 00:00:00 2001 From: "Thomas G. Lockhart" Date: Thu, 4 Jul 2002 15:24:11 +0000 Subject: Implement the IS DISTINCT FROM operator per SQL99. Reused the Expr node to hold DISTINCT which strongly resembles the existing OP info. Define DISTINCT_EXPR which strongly resembles the existing OPER_EXPR opType, but with handling for NULLs required by SQL99. We have explicit support for single-element DISTINCT comparisons all the way through to the executor. But, multi-element DISTINCTs are handled by expanding into a comparison tree in gram.y as is done for other row comparisons. Per discussions, it might be desirable to move this into one or more purpose-built nodes to be handled in the backend. Define the optional ROW keyword and token per SQL99. This allows single-element row constructs, which were formerly disallowed due to shift/reduce conflicts with parenthesized a_expr clauses. Define the SQL99 TREAT() function. Currently, use as a synonym for CAST(). --- src/backend/parser/parse_expr.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/backend/parser/parse_expr.c') diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index f911238ecce..ac4a5b6e5f3 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.119 2002/06/20 20:29:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.120 2002/07/04 15:24:01 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -271,6 +271,17 @@ transformExpr(ParseState *pstate, Node *expr) result = (Node *) expr; } break; + case DISTINCT: + { + Node *lexpr = transformExpr(pstate, + a->lexpr); + Node *rexpr = transformExpr(pstate, + a->rexpr); + result = (Node *) make_op(a->name, + lexpr, + rexpr); + ((Expr *)result)->opType = DISTINCT_EXPR; + } } break; } -- cgit v1.2.3