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/utils/adt/ruleutils.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/backend/utils/adt/ruleutils.c') diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 2c15bf916b9..bcdfe313b6b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * back to source text * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.108 2002/06/13 03:40:49 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.109 2002/07/04 15:24:07 thomas Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -1626,6 +1626,21 @@ get_rule_expr(Node *node, deparse_context *context) get_oper_expr(expr, context); break; + case DISTINCT_EXPR: + appendStringInfoChar(buf, '('); + Assert(length(args) == 2); + { + /* binary operator */ + Node *arg1 = (Node *) lfirst(args); + Node *arg2 = (Node *) lsecond(args); + + get_rule_expr(arg1, context); + appendStringInfo(buf, " IS DISTINCT FROM "); + get_rule_expr(arg2, context); + } + appendStringInfoChar(buf, ')'); + break; + case FUNC_EXPR: get_func_expr(expr, context); break; -- cgit v1.2.3