Fix pg_dump bug in the database-level collation patch. "datcollate" and
[PostgreSQL.git] / src / include / nodes / value.h
blob14134a2765137c7acd4b8131431cabd7cada1d56
1 /*-------------------------------------------------------------------------
3 * value.h
4 * interface for Value nodes
7 * Copyright (c) 2003-2008, PostgreSQL Global Development Group
9 * $PostgreSQL$
11 *-------------------------------------------------------------------------
14 #ifndef VALUE_H
15 #define VALUE_H
17 #include "nodes/nodes.h"
19 /*----------------------
20 * Value node
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 *----------------------
42 typedef struct Value
44 NodeTag type; /* tag appropriately (eg. T_String) */
45 union ValUnion
47 long ival; /* machine integer */
48 char *str; /* string */
49 } val;
50 } Value;
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);
61 #endif /* VALUE_H */