summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2022-01-14 10:46:49 +0100
committerPeter Eisentraut <peter@eisentraut.org>2022-01-17 10:38:23 +0100
commit941460fcf731a32e6a90691508d5cfa3d1f8eeaf (patch)
tree2de0be4abcf7db131607ce9ba590a8040c16d6e3 /src/include
parentca86a63d207aca1f52ff13a1ce13854681d1bbf9 (diff)
Add Boolean node
Before, SQL-level boolean constants were represented by a string with a cast, and internal Boolean values in DDL commands were usually represented by Integer nodes. This takes the place of both of these uses, making the intent clearer and having some amount of type safety. Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/8c1a2e37-c68d-703c-5a83-7a6077f4f997@enterprisedb.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/nodes.h1
-rw-r--r--src/include/nodes/parsenodes.h1
-rw-r--r--src/include/nodes/value.h8
3 files changed, 10 insertions, 0 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 28cf5aefcae..f9ddafd3459 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -292,6 +292,7 @@ typedef enum NodeTag
*/
T_Integer,
T_Float,
+ T_Boolean,
T_String,
T_BitString,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 413e7c85a1e..3e9bdc781f9 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -304,6 +304,7 @@ typedef struct A_Const
Node node;
Integer ival;
Float fval;
+ Boolean boolval;
String sval;
BitString bsval;
} val;
diff --git a/src/include/nodes/value.h b/src/include/nodes/value.h
index 442cc19fcba..eaf937051c3 100644
--- a/src/include/nodes/value.h
+++ b/src/include/nodes/value.h
@@ -48,6 +48,12 @@ typedef struct Float
char *fval;
} Float;
+typedef struct Boolean
+{
+ NodeTag type;
+ bool boolval;
+} Boolean;
+
typedef struct String
{
NodeTag type;
@@ -62,10 +68,12 @@ typedef struct BitString
#define intVal(v) (castNode(Integer, v)->ival)
#define floatVal(v) atof(castNode(Float, v)->fval)
+#define boolVal(v) (castNode(Boolean, v)->boolval)
#define strVal(v) (castNode(String, v)->sval)
extern Integer *makeInteger(int i);
extern Float *makeFloat(char *numericStr);
+extern Boolean *makeBoolean(bool var);
extern String *makeString(char *str);
extern BitString *makeBitString(char *str);