diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-26 22:05:42 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-26 22:05:42 +0000 |
commit | 943b396245bd699a66c894c5e11303b3ef93ac7b (patch) | |
tree | a08720e308259beb253e4b4b21f2f08e391a4d9f /src/backend/utils/adt/ruleutils.c | |
parent | d395aecffad7cc6bd043e2d81a1bed5b3fe2f5fa (diff) |
Add Oracle-compatible GREATEST and LEAST functions. Pavel Stehule
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bc3e774d640..0bd1d73eae1 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * back to source text * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.200 2005/06/05 00:38:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.201 2005/06/26 22:05:40 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -2781,6 +2781,7 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) case T_ArrayExpr: case T_RowExpr: case T_CoalesceExpr: + case T_MinMaxExpr: case T_NullIfExpr: case T_Aggref: case T_FuncExpr: @@ -2886,10 +2887,11 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) case T_BoolExpr: /* lower precedence */ case T_ArrayRef: /* other separators */ case T_ArrayExpr: /* other separators */ - case T_RowExpr: /* other separators */ + case T_RowExpr: /* other separators */ case T_CoalesceExpr: /* own parentheses */ + case T_MinMaxExpr: /* own parentheses */ case T_NullIfExpr: /* other separators */ - case T_Aggref: /* own parentheses */ + case T_Aggref: /* own parentheses */ case T_CaseExpr: /* other separators */ return true; default: @@ -2933,10 +2935,11 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) } case T_ArrayRef: /* other separators */ case T_ArrayExpr: /* other separators */ - case T_RowExpr: /* other separators */ + case T_RowExpr: /* other separators */ case T_CoalesceExpr: /* own parentheses */ + case T_MinMaxExpr: /* own parentheses */ case T_NullIfExpr: /* other separators */ - case T_Aggref: /* own parentheses */ + case T_Aggref: /* own parentheses */ case T_CaseExpr: /* other separators */ return true; default: @@ -3491,6 +3494,24 @@ get_rule_expr(Node *node, deparse_context *context, } break; + case T_MinMaxExpr: + { + MinMaxExpr *minmaxexpr = (MinMaxExpr *) node; + + switch (minmaxexpr->op) + { + case IS_GREATEST: + appendStringInfo(buf, "GREATEST("); + break; + case IS_LEAST: + appendStringInfo(buf, "LEAST("); + break; + } + get_rule_expr((Node *) minmaxexpr->args, context, true); + appendStringInfoChar(buf, ')'); + } + break; + case T_NullIfExpr: { NullIfExpr *nullifexpr = (NullIfExpr *) node; @@ -4109,7 +4130,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) bool need_paren_on_right; need_paren_on_right = PRETTY_PAREN(context) && - !IsA(j->rarg, RangeTblRef) && + !IsA(j->rarg, RangeTblRef) && !(IsA(j->rarg, JoinExpr) && ((JoinExpr*) j->rarg)->alias != NULL); if (!PRETTY_PAREN(context) || j->alias != NULL) |