From 116d2bba7eeaf25c544bc187e3ad2a8677a9a22c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 19 Jun 2001 22:39:12 +0000 Subject: 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. --- src/backend/nodes/readfuncs.c | 56 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'src/backend/nodes/readfuncs.c') diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index a83f0b64dbf..2f0dec048b3 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.110 2001/06/05 05:26:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.111 2001/06/19 22:39:11 tgl Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -859,6 +859,56 @@ _readCaseWhen(void) return local_node; } +/* ---------------- + * _readNullTest + * + * NullTest is a subclass of Node + * ---------------- + */ +static NullTest * +_readNullTest(void) +{ + NullTest *local_node; + char *token; + int length; + + local_node = makeNode(NullTest); + + token = pg_strtok(&length); /* eat :arg */ + local_node->arg = nodeRead(true); /* now read it */ + + token = pg_strtok(&length); /* eat :nulltesttype */ + token = pg_strtok(&length); /* get nulltesttype */ + local_node->nulltesttype = (NullTestType) atoi(token); + + return local_node; +} + +/* ---------------- + * _readBooleanTest + * + * BooleanTest is a subclass of Node + * ---------------- + */ +static BooleanTest * +_readBooleanTest(void) +{ + BooleanTest *local_node; + char *token; + int length; + + local_node = makeNode(BooleanTest); + + token = pg_strtok(&length); /* eat :arg */ + local_node->arg = nodeRead(true); /* now read it */ + + token = pg_strtok(&length); /* eat :booltesttype */ + token = pg_strtok(&length); /* get booltesttype */ + local_node->booltesttype = (BoolTestType) atoi(token); + + return local_node; +} + /* ---------------- * _readVar * @@ -1966,6 +2016,10 @@ parsePlanString(void) return_value = _readCaseExpr(); else if (length == 4 && strncmp(token, "WHEN", length) == 0) return_value = _readCaseWhen(); + else if (length == 8 && strncmp(token, "NULLTEST", length) == 0) + return_value = _readNullTest(); + else if (length == 11 && strncmp(token, "BOOLEANTEST", length) == 0) + return_value = _readBooleanTest(); else elog(ERROR, "badly formatted planstring \"%.10s\"...", token); -- cgit v1.2.3