diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-19 22:39:12 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-19 22:39:12 +0000 |
commit | 116d2bba7eeaf25c544bc187e3ad2a8677a9a22c (patch) | |
tree | c77a6b20a3acdbb6e25a1fc4a561c0e839ddbb1e /src/backend/utils/adt/ruleutils.c | |
parent | 8c30aca2ba1a48d38b1206f8559d1dc6b65c5ca7 (diff) | |
download | postgresql-116d2bba7eeaf25c544bc187e3ad2a8677a9a22c.tar.gz postgresql-116d2bba7eeaf25c544bc187e3ad2a8677a9a22c.zip |
Add IS UNKNOWN, IS NOT UNKNOWN boolean tests, fix the existing boolean
tests to return the correct results per SQL9x when given NULL inputs.
Reimplement these tests as well as IS [NOT] NULL to have their own
expression node types, instead of depending on special functions.
From Joe Conway, with a little help from Tom Lane.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 76 |
1 files changed, 55 insertions, 21 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 5635b90a9fb..ae1a8c1fb18 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.77 2001/04/18 17:04:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.78 2001/06/19 22:39:12 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -52,7 +52,6 @@ #include "parser/parse_expr.h" #include "parser/parsetree.h" #include "rewrite/rewriteManip.h" -#include "utils/fmgroids.h" #include "utils/lsyscache.h" @@ -1948,6 +1947,60 @@ get_rule_expr(Node *node, deparse_context *context) } break; + case T_NullTest: + { + NullTest *ntest = (NullTest *) node; + + appendStringInfo(buf, "(("); + get_rule_expr(ntest->arg, context); + switch (ntest->nulltesttype) + { + case IS_NULL: + appendStringInfo(buf, ") IS NULL)"); + break; + case IS_NOT_NULL: + appendStringInfo(buf, ") IS NOT NULL)"); + break; + default: + elog(ERROR, "get_rule_expr: unexpected nulltesttype %d", + (int) ntest->nulltesttype); + } + } + break; + + case T_BooleanTest: + { + BooleanTest *btest = (BooleanTest *) node; + + appendStringInfo(buf, "(("); + get_rule_expr(btest->arg, context); + switch (btest->booltesttype) + { + case IS_TRUE: + appendStringInfo(buf, ") IS TRUE)"); + break; + case IS_NOT_TRUE: + appendStringInfo(buf, ") IS NOT TRUE)"); + break; + case IS_FALSE: + appendStringInfo(buf, ") IS FALSE)"); + break; + case IS_NOT_FALSE: + appendStringInfo(buf, ") IS NOT FALSE)"); + break; + case IS_UNKNOWN: + appendStringInfo(buf, ") IS UNKNOWN)"); + break; + case IS_NOT_UNKNOWN: + appendStringInfo(buf, ") IS NOT UNKNOWN)"); + break; + default: + elog(ERROR, "get_rule_expr: unexpected booltesttype %d", + (int) btest->booltesttype); + } + } + break; + case T_SubLink: get_sublink_expr(node, context); break; @@ -1979,25 +2032,6 @@ get_func_expr(Expr *expr, deparse_context *context) char *sep; /* - * nullvalue() and nonnullvalue() should get turned into special - * syntax - */ - if (funcoid == F_NULLVALUE) - { - appendStringInfoChar(buf, '('); - get_rule_expr((Node *) lfirst(expr->args), context); - appendStringInfo(buf, " ISNULL)"); - return; - } - if (funcoid == F_NONNULLVALUE) - { - appendStringInfoChar(buf, '('); - get_rule_expr((Node *) lfirst(expr->args), context); - appendStringInfo(buf, " NOTNULL)"); - return; - } - - /* * Get the functions pg_proc tuple */ proctup = SearchSysCache(PROCOID, |