]> git.8kb.co.uk Git - pgpool-ii/pgpool-ii_2.2.5/blob - parser/value.h
Attempt to send a proper failure message to frontend when authentication
[pgpool-ii/pgpool-ii_2.2.5] / parser / value.h
1 /*-------------------------------------------------------------------------
2  *
3  * value.h
4  *        interface for Value nodes
5  *
6  *
7  * Portions Copyright (c) 2003-2008, PgPool Global Development Group
8  * Copyright (c) 2003-2007, PostgreSQL Global Development Group
9  *
10  * $PostgreSQL: pgsql/src/include/nodes/value.h,v 1.6 2007/01/05 22:19:56 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14
15 #ifndef VALUE_H
16 #define VALUE_H
17
18 #include "nodes.h"
19
20 /*----------------------
21  *              Value node
22  *
23  * The same Value struct is used for five node types: T_Integer,
24  * T_Float, T_String, T_BitString, T_Null.
25  *
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.
30  *
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.)
36  *
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'.
39  *
40  * Nulls, of course, don't need the value part at all.
41  *----------------------
42  */
43 typedef struct Value
44 {
45         NodeTag         type;                   /* tag appropriately (eg. T_String) */
46         union ValUnion
47         {
48                 long            ival;           /* machine integer */
49                 char       *str;                /* string */
50         }                       val;
51 } Value;
52
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)
56
57 extern Value *makeInteger(long i);
58 extern Value *makeFloat(char *numericStr);
59 extern Value *makeString(char *str);
60 extern Value *makeBitString(char *str);
61
62 #endif   /* VALUE_H */