1 /*-------------------------------------------------------------------------
4 * interface for Value nodes
7 * Copyright (c) 2003-2013, PostgreSQL Global Development Group
9 * src/include/nodes/value.h
11 *-------------------------------------------------------------------------
17 #include "nodes/nodes.h"
19 /*----------------------
22 * The same Value struct is used for five node types: T_Integer,
23 * T_Float, T_String, T_BitString, T_Null.
25 * Integral values are actually represented by a machine integer,
26 * but both floats and strings are represented as strings.
27 * Using T_Float as the node type simply indicates that
28 * the contents of the string look like a valid numeric literal.
30 * (Before Postgres 7.0, we used a double to represent T_Float,
31 * but that creates loss-of-precision problems when the value is
32 * ultimately destined to be converted to NUMERIC. Since Value nodes
33 * are only used in the parsing process, not for runtime data, it's
34 * better to use the more general representation.)
36 * Note that an integer-looking string will get lexed as T_Float if
37 * the value is too large to fit in a 'long'.
39 * Nulls, of course, don't need the value part at all.
40 *----------------------
44 NodeTag type; /* tag appropriately (eg. T_String) */
47 long ival; /* machine integer */
48 char *str; /* string */
52 #define intVal(v) (((Value *)(v))->val.ival)
53 #define floatVal(v) atof(((Value *)(v))->val.str)
54 #define strVal(v) (((Value *)(v))->val.str)
56 extern Value *makeInteger(long i);
57 extern Value *makeFloat(char *numericStr);
58 extern Value *makeString(char *str);
59 extern Value *makeBitString(char *str);