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