summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-06-19 22:39:12 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-06-19 22:39:12 +0000
commit116d2bba7eeaf25c544bc187e3ad2a8677a9a22c (patch)
treec77a6b20a3acdbb6e25a1fc4a561c0e839ddbb1e /src/include
parent8c30aca2ba1a48d38b1206f8559d1dc6b65c5ca7 (diff)
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/include')
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/nodes/nodes.h6
-rw-r--r--src/include/nodes/parsenodes.h51
-rw-r--r--src/include/parser/parse_coerce.h4
4 files changed, 55 insertions, 10 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 91feaec19e2..c34655308e0 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catversion.h,v 1.83 2001/06/16 18:59:31 tgl Exp $
+ * $Id: catversion.h,v 1.84 2001/06/19 22:39:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200106161
+#define CATALOG_VERSION_NO 200106191
#endif
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index d62583c4d23..fe2d0357848 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodes.h,v 1.90 2001/06/09 23:21:55 petere Exp $
+ * $Id: nodes.h,v 1.91 2001/06/19 22:39:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -218,8 +218,8 @@ typedef enum NodeTag
T_RangeTblEntry,
T_SortClause,
T_GroupClause,
- T_SubSelectXXX, /* not used anymore; tag# available */
- T_oldJoinExprXXX, /* not used anymore; tag# available */
+ T_NullTest,
+ T_BooleanTest,
T_CaseExpr,
T_CaseWhen,
T_RowMarkXXX, /* not used anymore; tag# available */
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index fe2d1bb7ffe..43e64b6ad5f 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.131 2001/06/09 23:21:55 petere Exp $
+ * $Id: parsenodes.h,v 1.132 2001/06/19 22:39:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -983,9 +983,8 @@ typedef struct ParamNo
typedef struct A_Expr
{
NodeTag type;
- int oper; /* type of operation
- * {OP,OR,AND,NOT,ISNULL,NOTNULL} */
- char *opname; /* name of operator/function */
+ int oper; /* type of operation (OP,OR,AND,NOT) */
+ char *opname; /* name of operator */
Node *lexpr; /* left argument */
Node *rexpr; /* right argument */
} A_Expr;
@@ -1054,6 +1053,50 @@ typedef struct CaseWhen
Node *result; /* substitution result */
} CaseWhen;
+/* ----------------
+ * NullTest
+ *
+ * NullTest represents the operation of testing a value for NULLness.
+ * Currently, we only support scalar input values, but eventually a
+ * row-constructor input should be supported.
+ * The appropriate test is performed and returned as a boolean Datum.
+ * ----------------
+ */
+
+typedef enum NullTestType
+{
+ IS_NULL, IS_NOT_NULL
+} NullTestType;
+
+typedef struct NullTest
+{
+ NodeTag type;
+ Node *arg; /* input expression */
+ NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
+} NullTest;
+
+/* ----------------
+ * BooleanTest
+ *
+ * BooleanTest represents the operation of determining whether a boolean
+ * is TRUE, FALSE, or UNKNOWN (ie, NULL). All six meaningful combinations
+ * are supported. Note that a NULL input does *not* cause a NULL result.
+ * The appropriate test is performed and returned as a boolean Datum.
+ * ----------------
+ */
+
+typedef enum BoolTestType
+{
+ IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN
+} BoolTestType;
+
+typedef struct BooleanTest
+{
+ NodeTag type;
+ Node *arg; /* input expression */
+ BoolTestType booltesttype; /* test type */
+} BooleanTest;
+
/*
* ColumnDef - column definition (used in various creates)
*
diff --git a/src/include/parser/parse_coerce.h b/src/include/parser/parse_coerce.h
index f81a3be8307..1f508b1eae0 100644
--- a/src/include/parser/parse_coerce.h
+++ b/src/include/parser/parse_coerce.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_coerce.h,v 1.28 2001/05/22 16:37:17 petere Exp $
+ * $Id: parse_coerce.h,v 1.29 2001/06/19 22:39:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -136,6 +136,8 @@ extern Node *coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
extern Node *coerce_type_typmod(ParseState *pstate, Node *node,
Oid targetTypeId, int32 atttypmod);
+extern bool coerce_to_boolean(ParseState *pstate, Node **pnode);
+
extern Oid select_common_type(List *typeids, const char *context);
extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
Oid targetTypeId,