~drizzle-trunk/drizzle/development

520.1.25 by Monty Taylor
Removed the split.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
2023.2.1 by Brian Aker
Merge in BOOL type.
4
 *  Copyright (C) 2010 Brian Aker
520.1.25 by Monty Taylor
Removed the split.
5
 *  Copyright (C) 2008 MySQL
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  (at your option) any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
 */
1 by brian
clean slate
21
22
/**
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
23
 * @file This file implements the Field class and API
24
 */
1 by brian
clean slate
25
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
26
#include <config.h>
1502.3.1 by iwamatsu at nigauri
Add cstdio include to files needing it. Fixes the build on some debian
27
#include <cstdio>
1 by brian
clean slate
28
#include <errno.h>
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
29
#include <float.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
30
#include <drizzled/sql_select.h>
31
#include <drizzled/error.h>
32
#include <drizzled/field/str.h>
33
#include <drizzled/field/num.h>
34
#include <drizzled/field/blob.h>
35
#include <drizzled/field/boolean.h>
36
#include <drizzled/field/enum.h>
37
#include <drizzled/field/null.h>
38
#include <drizzled/field/date.h>
39
#include <drizzled/field/decimal.h>
40
#include <drizzled/field/real.h>
41
#include <drizzled/field/double.h>
42
#include <drizzled/field/int32.h>
43
#include <drizzled/field/int64.h>
44
#include <drizzled/field/num.h>
45
#include <drizzled/field/time.h>
46
#include <drizzled/field/epoch.h>
47
#include <drizzled/field/datetime.h>
48
#include <drizzled/field/microtime.h>
49
#include <drizzled/field/varstring.h>
50
#include <drizzled/field/uuid.h>
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
51
#include <drizzled/field/ipv6.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
52
#include <drizzled/time_functions.h>
53
#include <drizzled/internal/m_string.h>
2154.2.18 by Brian Aker
Merge in all changes for include files.
54
#include <drizzled/table.h>
55
#include <drizzled/util/test.h>
56
#include <drizzled/session.h>
2154.2.24 by Brian Aker
Merge in all changes for current_session, etc.
57
#include <drizzled/current_session.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
58
#include <drizzled/display.h>
2151.5.10 by Olaf van der Spek
merge trunk
59
#include <drizzled/typelib.h>
2318.8.3 by Olaf van der Spek
CreateField includes
60
#include <drizzled/create_field.h>
1992.5.1 by Brian Aker
Additional cerr output bits for a few classes (Item, Field,...)
61
2318.6.12 by Olaf van der Spek
Refactor
62
namespace drizzled {
1253.1.3 by Monty Taylor
MEM_ROOT == memory::Root
63
1 by brian
clean slate
64
/*****************************************************************************
65
  Instansiate templates and static variables
66
*****************************************************************************/
67
520.1.25 by Monty Taylor
Removed the split.
68
static enum_field_types
1996.2.1 by Brian Aker
uuid type code.
69
field_types_merge_rules [enum_field_types_size][enum_field_types_size]=
1 by brian
clean slate
70
{
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
71
  /* DRIZZLE_TYPE_LONG -> */
72
  {
520.1.25 by Monty Taylor
Removed the split.
73
    //DRIZZLE_TYPE_LONG
74
    DRIZZLE_TYPE_LONG,
75
    //DRIZZLE_TYPE_DOUBLE
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
76
    DRIZZLE_TYPE_DOUBLE,
520.1.25 by Monty Taylor
Removed the split.
77
    //DRIZZLE_TYPE_NULL
78
    DRIZZLE_TYPE_LONG,
79
    //DRIZZLE_TYPE_TIMESTAMP
80
    DRIZZLE_TYPE_VARCHAR,
81
    //DRIZZLE_TYPE_LONGLONG
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
82
    DRIZZLE_TYPE_LONGLONG,
520.1.25 by Monty Taylor
Removed the split.
83
    //DRIZZLE_TYPE_DATETIME
84
    DRIZZLE_TYPE_VARCHAR,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
85
    //DRIZZLE_TYPE_DATE
520.1.25 by Monty Taylor
Removed the split.
86
    DRIZZLE_TYPE_VARCHAR,
87
    //DRIZZLE_TYPE_VARCHAR
88
    DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
89
    //DRIZZLE_TYPE_DECIMAL
90
    DRIZZLE_TYPE_DECIMAL,
520.1.25 by Monty Taylor
Removed the split.
91
    //DRIZZLE_TYPE_ENUM
92
    DRIZZLE_TYPE_VARCHAR,
93
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
94
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
95
    //DRIZZLE_TYPE_TIME
96
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
97
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
98
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
99
    //DRIZZLE_TYPE_UUID
100
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
101
    //DRIZZLE_TYPE_MICROTIME
102
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
103
    //DRIZZLE_TYPE_IPV6
104
    DRIZZLE_TYPE_VARCHAR,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
105
  },
106
  /* DRIZZLE_TYPE_DOUBLE -> */
107
  {
520.1.25 by Monty Taylor
Removed the split.
108
    //DRIZZLE_TYPE_LONG
109
    DRIZZLE_TYPE_DOUBLE,
110
    //DRIZZLE_TYPE_DOUBLE
111
    DRIZZLE_TYPE_DOUBLE,
112
    //DRIZZLE_TYPE_NULL
113
    DRIZZLE_TYPE_DOUBLE,
114
    //DRIZZLE_TYPE_TIMESTAMP
115
    DRIZZLE_TYPE_VARCHAR,
116
    //DRIZZLE_TYPE_LONGLONG
117
    DRIZZLE_TYPE_DOUBLE,
118
    //DRIZZLE_TYPE_DATETIME
119
    DRIZZLE_TYPE_VARCHAR,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
120
    //DRIZZLE_TYPE_DATE
520.1.25 by Monty Taylor
Removed the split.
121
    DRIZZLE_TYPE_VARCHAR,
122
    //DRIZZLE_TYPE_VARCHAR
123
    DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
124
    //DRIZZLE_TYPE_DECIMAL
520.1.25 by Monty Taylor
Removed the split.
125
    DRIZZLE_TYPE_DOUBLE,
126
    //DRIZZLE_TYPE_ENUM
127
    DRIZZLE_TYPE_VARCHAR,
128
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
129
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
130
    //DRIZZLE_TYPE_TIME
131
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
132
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
133
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
134
    //DRIZZLE_TYPE_UUID
135
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
136
    //DRIZZLE_TYPE_MICROTIME
137
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
138
    //DRIZZLE_TYPE_IPV6
139
    DRIZZLE_TYPE_VARCHAR,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
140
  },
141
  /* DRIZZLE_TYPE_NULL -> */
142
  {
520.1.25 by Monty Taylor
Removed the split.
143
    //DRIZZLE_TYPE_LONG
398 by Brian Aker
Remove short.
144
    DRIZZLE_TYPE_LONG,
520.1.25 by Monty Taylor
Removed the split.
145
    //DRIZZLE_TYPE_DOUBLE
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
146
    DRIZZLE_TYPE_DOUBLE,
520.1.25 by Monty Taylor
Removed the split.
147
    //DRIZZLE_TYPE_NULL
148
    DRIZZLE_TYPE_NULL,
149
    //DRIZZLE_TYPE_TIMESTAMP
150
    DRIZZLE_TYPE_TIMESTAMP,
151
    //DRIZZLE_TYPE_LONGLONG
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
152
    DRIZZLE_TYPE_LONGLONG,
520.1.25 by Monty Taylor
Removed the split.
153
    //DRIZZLE_TYPE_DATETIME
222 by Brian Aker
Remove YEAR field type
154
    DRIZZLE_TYPE_DATETIME,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
155
    //DRIZZLE_TYPE_DATE
156
    DRIZZLE_TYPE_DATE,
520.1.25 by Monty Taylor
Removed the split.
157
    //DRIZZLE_TYPE_VARCHAR
158
    DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
159
    //DRIZZLE_TYPE_DECIMAL
160
    DRIZZLE_TYPE_DECIMAL,
520.1.25 by Monty Taylor
Removed the split.
161
    //DRIZZLE_TYPE_ENUM
162
    DRIZZLE_TYPE_ENUM,
163
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
164
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
165
    //DRIZZLE_TYPE_TIME
166
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
167
    //DRIZZLE_TYPE_BOOLEAN
168
    DRIZZLE_TYPE_BOOLEAN,
1996.2.1 by Brian Aker
uuid type code.
169
    //DRIZZLE_TYPE_UUID
170
    DRIZZLE_TYPE_UUID,
2046.2.1 by Brian Aker
First pass on micro timestamp.
171
    //DRIZZLE_TYPE_MICROTIME
172
    DRIZZLE_TYPE_MICROTIME,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
173
    //DRIZZLE_TYPE_IPV6
174
    DRIZZLE_TYPE_VARCHAR,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
175
  },
176
  /* DRIZZLE_TYPE_TIMESTAMP -> */
177
  {
520.1.25 by Monty Taylor
Removed the split.
178
    //DRIZZLE_TYPE_LONG
179
    DRIZZLE_TYPE_VARCHAR,
180
    //DRIZZLE_TYPE_DOUBLE
181
    DRIZZLE_TYPE_VARCHAR,
182
    //DRIZZLE_TYPE_NULL
183
    DRIZZLE_TYPE_TIMESTAMP,
184
    //DRIZZLE_TYPE_TIMESTAMP
185
    DRIZZLE_TYPE_TIMESTAMP,
186
    //DRIZZLE_TYPE_LONGLONG
187
    DRIZZLE_TYPE_VARCHAR,
188
    //DRIZZLE_TYPE_DATETIME
189
    DRIZZLE_TYPE_DATETIME,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
190
    //DRIZZLE_TYPE_DATE
191
    DRIZZLE_TYPE_DATE,
520.1.25 by Monty Taylor
Removed the split.
192
    //DRIZZLE_TYPE_VARCHAR
193
    DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
194
    //DRIZZLE_TYPE_DECIMAL
520.1.25 by Monty Taylor
Removed the split.
195
    DRIZZLE_TYPE_VARCHAR,
196
    //DRIZZLE_TYPE_ENUM
197
    DRIZZLE_TYPE_VARCHAR,
198
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
199
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
200
    //DRIZZLE_TYPE_TIME
201
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
202
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
203
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
204
    //DRIZZLE_TYPE_UUID
205
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
206
    //DRIZZLE_TYPE_MICROTIME
207
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
208
    //DRIZZLE_TYPE_IPV6
209
    DRIZZLE_TYPE_VARCHAR,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
210
  },
211
  /* DRIZZLE_TYPE_LONGLONG -> */
212
  {
520.1.25 by Monty Taylor
Removed the split.
213
    //DRIZZLE_TYPE_LONG
214
    DRIZZLE_TYPE_LONGLONG,
215
    //DRIZZLE_TYPE_DOUBLE
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
216
    DRIZZLE_TYPE_DOUBLE,
520.1.25 by Monty Taylor
Removed the split.
217
    //DRIZZLE_TYPE_NULL
218
    DRIZZLE_TYPE_LONGLONG,
219
    //DRIZZLE_TYPE_TIMESTAMP
220
    DRIZZLE_TYPE_VARCHAR,
221
    //DRIZZLE_TYPE_LONGLONG
222
    DRIZZLE_TYPE_LONGLONG,
223
    //DRIZZLE_TYPE_DATETIME
224
    DRIZZLE_TYPE_VARCHAR,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
225
    //DRIZZLE_TYPE_DATE
226
    DRIZZLE_TYPE_DATE,
520.1.25 by Monty Taylor
Removed the split.
227
    //DRIZZLE_TYPE_VARCHAR
228
    DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
229
    //DRIZZLE_TYPE_DECIMAL DRIZZLE_TYPE_ENUM
230
    DRIZZLE_TYPE_DECIMAL,
520.1.25 by Monty Taylor
Removed the split.
231
    DRIZZLE_TYPE_VARCHAR,
232
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
233
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
234
    //DRIZZLE_TYPE_TIME
235
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
236
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
237
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
238
    //DRIZZLE_TYPE_UUID
239
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
240
    //DRIZZLE_TYPE_MICROTIME
241
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
242
    //DRIZZLE_TYPE_IPV6
243
    DRIZZLE_TYPE_VARCHAR,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
244
  },
245
  /* DRIZZLE_TYPE_DATETIME -> */
246
  {
520.1.25 by Monty Taylor
Removed the split.
247
    //DRIZZLE_TYPE_LONG
248
    DRIZZLE_TYPE_VARCHAR,
249
    //DRIZZLE_TYPE_DOUBLE
250
    DRIZZLE_TYPE_VARCHAR,
251
    //DRIZZLE_TYPE_NULL
252
    DRIZZLE_TYPE_DATETIME,
253
    //DRIZZLE_TYPE_TIMESTAMP
254
    DRIZZLE_TYPE_DATETIME,
255
    //DRIZZLE_TYPE_LONGLONG
256
    DRIZZLE_TYPE_VARCHAR,
257
    //DRIZZLE_TYPE_DATETIME
258
    DRIZZLE_TYPE_DATETIME,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
259
    //DRIZZLE_TYPE_DATE
260
    DRIZZLE_TYPE_DATE,
520.1.25 by Monty Taylor
Removed the split.
261
    //DRIZZLE_TYPE_VARCHAR
262
    DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
263
    //DRIZZLE_TYPE_DECIMAL
520.1.25 by Monty Taylor
Removed the split.
264
    DRIZZLE_TYPE_VARCHAR,
265
    //DRIZZLE_TYPE_ENUM
266
    DRIZZLE_TYPE_VARCHAR,
267
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
268
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
269
    //DRIZZLE_TYPE_TIME
270
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
271
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
272
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
273
    //DRIZZLE_TYPE_UUID
274
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
275
    //DRIZZLE_TYPE_MICROTIME
276
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
277
    //DRIZZLE_TYPE_IPV6
278
    DRIZZLE_TYPE_VARCHAR,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
279
  },
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
280
  /* DRIZZLE_TYPE_DATE -> */
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
281
  {
520.1.25 by Monty Taylor
Removed the split.
282
    //DRIZZLE_TYPE_LONG
283
    DRIZZLE_TYPE_VARCHAR,
284
    //DRIZZLE_TYPE_DOUBLE
285
    DRIZZLE_TYPE_VARCHAR,
286
    //DRIZZLE_TYPE_NULL
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
287
    DRIZZLE_TYPE_DATE,
520.1.25 by Monty Taylor
Removed the split.
288
    //DRIZZLE_TYPE_TIMESTAMP
289
    DRIZZLE_TYPE_DATETIME,
290
    //DRIZZLE_TYPE_LONGLONG
291
    DRIZZLE_TYPE_VARCHAR,
292
    //DRIZZLE_TYPE_DATETIME
293
    DRIZZLE_TYPE_DATETIME,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
294
    //DRIZZLE_TYPE_DATE
295
    DRIZZLE_TYPE_DATE,
520.1.25 by Monty Taylor
Removed the split.
296
    //DRIZZLE_TYPE_VARCHAR
297
    DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
298
    //DRIZZLE_TYPE_DECIMAL
520.1.25 by Monty Taylor
Removed the split.
299
    DRIZZLE_TYPE_VARCHAR,
300
    //DRIZZLE_TYPE_ENUM
301
    DRIZZLE_TYPE_VARCHAR,
302
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
303
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
304
    //DRIZZLE_TYPE_TIME
305
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
306
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
307
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
308
    //DRIZZLE_TYPE_UUID
309
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
310
    //DRIZZLE_TYPE_MICROTIME
311
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
312
    //DRIZZLE_TYPE_IPV6
313
    DRIZZLE_TYPE_VARCHAR,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
314
  },
315
  /* DRIZZLE_TYPE_VARCHAR -> */
316
  {
520.1.25 by Monty Taylor
Removed the split.
317
    //DRIZZLE_TYPE_LONG
318
    DRIZZLE_TYPE_VARCHAR,
319
    //DRIZZLE_TYPE_DOUBLE
320
    DRIZZLE_TYPE_VARCHAR,
321
    //DRIZZLE_TYPE_NULL
322
    DRIZZLE_TYPE_VARCHAR,
323
    //DRIZZLE_TYPE_TIMESTAMP
324
    DRIZZLE_TYPE_VARCHAR,
325
    //DRIZZLE_TYPE_LONGLONG
326
    DRIZZLE_TYPE_VARCHAR,
327
    //DRIZZLE_TYPE_DATETIME
328
    DRIZZLE_TYPE_VARCHAR,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
329
    //DRIZZLE_TYPE_DATE
520.1.25 by Monty Taylor
Removed the split.
330
    DRIZZLE_TYPE_VARCHAR,
331
    //DRIZZLE_TYPE_VARCHAR
332
    DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
333
    //DRIZZLE_TYPE_DECIMAL
520.1.25 by Monty Taylor
Removed the split.
334
    DRIZZLE_TYPE_VARCHAR,
335
    //DRIZZLE_TYPE_ENUM
336
    DRIZZLE_TYPE_VARCHAR,
337
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
338
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
339
    //DRIZZLE_TYPE_TIME
340
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
341
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
342
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
343
    //DRIZZLE_TYPE_UUID
344
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
345
    //DRIZZLE_TYPE_MICROTIME
346
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
347
    //DRIZZLE_TYPE_IPV6
348
    DRIZZLE_TYPE_VARCHAR,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
349
  },
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
350
  /* DRIZZLE_TYPE_DECIMAL -> */
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
351
  {
520.1.25 by Monty Taylor
Removed the split.
352
    //DRIZZLE_TYPE_LONG
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
353
    DRIZZLE_TYPE_DECIMAL,
520.1.25 by Monty Taylor
Removed the split.
354
    //DRIZZLE_TYPE_DOUBLE
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
355
    DRIZZLE_TYPE_DOUBLE,
520.1.25 by Monty Taylor
Removed the split.
356
    //DRIZZLE_TYPE_NULL
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
357
    DRIZZLE_TYPE_DECIMAL,
520.1.25 by Monty Taylor
Removed the split.
358
    //DRIZZLE_TYPE_TIMESTAMP
359
    DRIZZLE_TYPE_VARCHAR,
360
    //DRIZZLE_TYPE_LONGLONG
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
361
    DRIZZLE_TYPE_DECIMAL,
520.1.25 by Monty Taylor
Removed the split.
362
    //DRIZZLE_TYPE_DATETIME
363
    DRIZZLE_TYPE_VARCHAR,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
364
    //DRIZZLE_TYPE_DATE
520.1.25 by Monty Taylor
Removed the split.
365
    DRIZZLE_TYPE_VARCHAR,
366
    //DRIZZLE_TYPE_VARCHAR
367
    DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
368
    //DRIZZLE_TYPE_DECIMAL
369
    DRIZZLE_TYPE_DECIMAL,
520.1.25 by Monty Taylor
Removed the split.
370
    //DRIZZLE_TYPE_ENUM
371
    DRIZZLE_TYPE_VARCHAR,
372
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
373
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
374
    //DRIZZLE_TYPE_TIME
375
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
376
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
377
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
378
    //DRIZZLE_TYPE_UUID
379
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
380
    //DRIZZLE_TYPE_MICROTIME
381
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
382
    //DRIZZLE_TYPE_IPV6
383
    DRIZZLE_TYPE_VARCHAR,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
384
  },
385
  /* DRIZZLE_TYPE_ENUM -> */
386
  {
520.1.25 by Monty Taylor
Removed the split.
387
    //DRIZZLE_TYPE_LONG
388
    DRIZZLE_TYPE_VARCHAR,
389
    //DRIZZLE_TYPE_DOUBLE
390
    DRIZZLE_TYPE_VARCHAR,
391
    //DRIZZLE_TYPE_NULL
392
    DRIZZLE_TYPE_ENUM,
393
    //DRIZZLE_TYPE_TIMESTAMP
394
    DRIZZLE_TYPE_VARCHAR,
395
    //DRIZZLE_TYPE_LONGLONG
396
    DRIZZLE_TYPE_VARCHAR,
397
    //DRIZZLE_TYPE_DATETIME
398
    DRIZZLE_TYPE_VARCHAR,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
399
    //DRIZZLE_TYPE_DATE
520.1.25 by Monty Taylor
Removed the split.
400
    DRIZZLE_TYPE_VARCHAR,
401
    //DRIZZLE_TYPE_VARCHAR
402
    DRIZZLE_TYPE_VARCHAR,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
403
    //DRIZZLE_TYPE_DECIMAL
520.1.25 by Monty Taylor
Removed the split.
404
    DRIZZLE_TYPE_VARCHAR,
405
    //DRIZZLE_TYPE_ENUM
406
    DRIZZLE_TYPE_VARCHAR,
407
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
408
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
409
    //DRIZZLE_TYPE_TIME
410
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
411
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
412
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
413
    //DRIZZLE_TYPE_UUID
414
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
415
    //DRIZZLE_TYPE_MICROTIME
416
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
417
    //DRIZZLE_TYPE_IPV6
418
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
419
   },
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
420
  /* DRIZZLE_TYPE_BLOB -> */
421
  {
520.1.25 by Monty Taylor
Removed the split.
422
    //DRIZZLE_TYPE_LONG
423
    DRIZZLE_TYPE_BLOB,
424
    //DRIZZLE_TYPE_DOUBLE
425
    DRIZZLE_TYPE_BLOB,
426
    //DRIZZLE_TYPE_NULL
427
    DRIZZLE_TYPE_BLOB,
428
    //DRIZZLE_TYPE_TIMESTAMP
429
    DRIZZLE_TYPE_BLOB,
430
    //DRIZZLE_TYPE_LONGLONG
431
    DRIZZLE_TYPE_BLOB,
432
    //DRIZZLE_TYPE_DATETIME
433
    DRIZZLE_TYPE_BLOB,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
434
    //DRIZZLE_TYPE_DATE
520.1.25 by Monty Taylor
Removed the split.
435
    DRIZZLE_TYPE_BLOB,
436
    //DRIZZLE_TYPE_VARCHAR
437
    DRIZZLE_TYPE_BLOB,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
438
    //DRIZZLE_TYPE_DECIMAL
520.1.25 by Monty Taylor
Removed the split.
439
    DRIZZLE_TYPE_BLOB,
440
    //DRIZZLE_TYPE_ENUM
441
    DRIZZLE_TYPE_BLOB,
442
    //DRIZZLE_TYPE_BLOB
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
443
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
444
    //DRIZZLE_TYPE_TIME
445
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
446
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
447
    DRIZZLE_TYPE_VARCHAR,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
448
    //DRIZZLE_TYPE_UUID
449
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
450
    //DRIZZLE_TYPE_MICROTIME
451
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
452
    //DRIZZLE_TYPE_IPV6
453
    DRIZZLE_TYPE_VARCHAR,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
454
  },
455
  /* DRIZZLE_TYPE_TIME -> */
456
  {
457
    //DRIZZLE_TYPE_LONG
458
    DRIZZLE_TYPE_VARCHAR,
459
    //DRIZZLE_TYPE_DOUBLE
460
    DRIZZLE_TYPE_VARCHAR,
461
    //DRIZZLE_TYPE_NULL
462
    DRIZZLE_TYPE_TIME,
463
    //DRIZZLE_TYPE_TIMESTAMP
464
    DRIZZLE_TYPE_VARCHAR,
465
    //DRIZZLE_TYPE_LONGLONG
466
    DRIZZLE_TYPE_VARCHAR,
467
    //DRIZZLE_TYPE_DATETIME
468
    DRIZZLE_TYPE_VARCHAR,
469
    //DRIZZLE_TYPE_DATE
470
    DRIZZLE_TYPE_VARCHAR,
471
    //DRIZZLE_TYPE_VARCHAR
472
    DRIZZLE_TYPE_VARCHAR,
473
    //DRIZZLE_TYPE_DECIMAL
474
    DRIZZLE_TYPE_VARCHAR,
475
    //DRIZZLE_TYPE_VARCHAR,
476
    DRIZZLE_TYPE_VARCHAR,
477
    //DRIZZLE_TYPE_BLOB
478
    DRIZZLE_TYPE_BLOB,
479
    //DRIZZLE_TYPE_TIME
480
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
481
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
482
    DRIZZLE_TYPE_VARCHAR,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
483
    //DRIZZLE_TYPE_UUID
484
    DRIZZLE_TYPE_UUID,
2046.2.1 by Brian Aker
First pass on micro timestamp.
485
    //DRIZZLE_TYPE_MICROTIME
486
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
487
    //DRIZZLE_TYPE_IPV6
488
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
489
  },
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
490
  /* DRIZZLE_TYPE_BOOLEAN -> */
2023.2.1 by Brian Aker
Merge in BOOL type.
491
  {
492
    //DRIZZLE_TYPE_LONG
493
    DRIZZLE_TYPE_VARCHAR,
494
    //DRIZZLE_TYPE_DOUBLE
495
    DRIZZLE_TYPE_VARCHAR,
496
    //DRIZZLE_TYPE_NULL
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
497
    DRIZZLE_TYPE_BOOLEAN,
2023.2.1 by Brian Aker
Merge in BOOL type.
498
    //DRIZZLE_TYPE_TIMESTAMP
499
    DRIZZLE_TYPE_VARCHAR,
500
    //DRIZZLE_TYPE_LONGLONG
501
    DRIZZLE_TYPE_VARCHAR,
502
    //DRIZZLE_TYPE_DATETIME
503
    DRIZZLE_TYPE_VARCHAR,
504
    //DRIZZLE_TYPE_DATE
505
    DRIZZLE_TYPE_VARCHAR,
506
    //DRIZZLE_TYPE_VARCHAR
507
    DRIZZLE_TYPE_VARCHAR,
508
    //DRIZZLE_TYPE_DECIMAL
509
    DRIZZLE_TYPE_VARCHAR,
510
    //DRIZZLE_TYPE_VARCHAR,
511
    DRIZZLE_TYPE_VARCHAR,
512
    //DRIZZLE_TYPE_BLOB
513
    DRIZZLE_TYPE_BLOB,
514
    //DRIZZLE_TYPE_TIME
515
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
516
    //DRIZZLE_TYPE_BOOLEAN
517
    DRIZZLE_TYPE_BOOLEAN,
2023.2.1 by Brian Aker
Merge in BOOL type.
518
    //DRIZZLE_TYPE_UUID
519
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
520
    //DRIZZLE_TYPE_MICROTIME
521
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
522
    //DRIZZLE_TYPE_IPV6
523
    DRIZZLE_TYPE_VARCHAR,
2023.2.1 by Brian Aker
Merge in BOOL type.
524
  },
1996.2.1 by Brian Aker
uuid type code.
525
  /* DRIZZLE_TYPE_UUID -> */
526
  {
527
    //DRIZZLE_TYPE_LONG
528
    DRIZZLE_TYPE_VARCHAR,
529
    //DRIZZLE_TYPE_DOUBLE
530
    DRIZZLE_TYPE_VARCHAR,
531
    //DRIZZLE_TYPE_NULL
532
    DRIZZLE_TYPE_UUID,
533
    //DRIZZLE_TYPE_TIMESTAMP
534
    DRIZZLE_TYPE_VARCHAR,
535
    //DRIZZLE_TYPE_LONGLONG
536
    DRIZZLE_TYPE_VARCHAR,
537
    //DRIZZLE_TYPE_DATETIME
538
    DRIZZLE_TYPE_VARCHAR,
539
    //DRIZZLE_TYPE_DATE
540
    DRIZZLE_TYPE_VARCHAR,
541
    //DRIZZLE_TYPE_VARCHAR
542
    DRIZZLE_TYPE_VARCHAR,
543
    //DRIZZLE_TYPE_DECIMAL
544
    DRIZZLE_TYPE_VARCHAR,
545
    //DRIZZLE_TYPE_VARCHAR,
546
    DRIZZLE_TYPE_VARCHAR,
547
    //DRIZZLE_TYPE_BLOB
548
    DRIZZLE_TYPE_BLOB,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
549
    //DRIZZLE_TYPE_TIME
550
    DRIZZLE_TYPE_TIME,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
551
    //DRIZZLE_TYPE_BOOLEAN
2023.2.1 by Brian Aker
Merge in BOOL type.
552
    DRIZZLE_TYPE_VARCHAR,
1996.2.1 by Brian Aker
uuid type code.
553
    //DRIZZLE_TYPE_UUID
554
    DRIZZLE_TYPE_UUID,
2046.2.1 by Brian Aker
First pass on micro timestamp.
555
    //DRIZZLE_TYPE_MICROTIME
556
    DRIZZLE_TYPE_VARCHAR,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
557
    //DRIZZLE_TYPE_IPV6
558
    DRIZZLE_TYPE_VARCHAR,
2046.2.1 by Brian Aker
First pass on micro timestamp.
559
  },
560
  /* DRIZZLE_TYPE_MICROTIME -> */
561
  {
562
    //DRIZZLE_TYPE_LONG
563
    DRIZZLE_TYPE_VARCHAR,
564
    //DRIZZLE_TYPE_DOUBLE
565
    DRIZZLE_TYPE_VARCHAR,
566
    //DRIZZLE_TYPE_NULL
567
    DRIZZLE_TYPE_MICROTIME,
568
    //DRIZZLE_TYPE_TIMESTAMP
569
    DRIZZLE_TYPE_VARCHAR,
570
    //DRIZZLE_TYPE_LONGLONG
571
    DRIZZLE_TYPE_VARCHAR,
572
    //DRIZZLE_TYPE_DATETIME
573
    DRIZZLE_TYPE_VARCHAR,
574
    //DRIZZLE_TYPE_DATE
575
    DRIZZLE_TYPE_VARCHAR,
576
    //DRIZZLE_TYPE_VARCHAR
577
    DRIZZLE_TYPE_VARCHAR,
578
    //DRIZZLE_TYPE_DECIMAL
579
    DRIZZLE_TYPE_VARCHAR,
580
    //DRIZZLE_TYPE_VARCHAR,
581
    DRIZZLE_TYPE_VARCHAR,
582
    //DRIZZLE_TYPE_BLOB
583
    DRIZZLE_TYPE_BLOB,
584
    //DRIZZLE_TYPE_TIME
585
    DRIZZLE_TYPE_TIME,
586
    //DRIZZLE_TYPE_BOOLEAN
587
    DRIZZLE_TYPE_VARCHAR,
588
    //DRIZZLE_TYPE_UUID
589
    DRIZZLE_TYPE_UUID,
590
    //DRIZZLE_TYPE_MICROTIME
591
    DRIZZLE_TYPE_MICROTIME,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
592
    //DRIZZLE_TYPE_IPV6
593
    DRIZZLE_TYPE_VARCHAR,
594
  },
595
  /* DRIZZLE_TYPE_IPV6 -> */
596
  {
597
    //DRIZZLE_TYPE_LONG
598
    DRIZZLE_TYPE_VARCHAR,
599
    //DRIZZLE_TYPE_DOUBLE
600
    DRIZZLE_TYPE_VARCHAR,
601
    //DRIZZLE_TYPE_NULL
602
    DRIZZLE_TYPE_IPV6,
603
    //DRIZZLE_TYPE_TIMESTAMP
604
    DRIZZLE_TYPE_VARCHAR,
605
    //DRIZZLE_TYPE_LONGLONG
606
    DRIZZLE_TYPE_VARCHAR,
607
    //DRIZZLE_TYPE_DATETIME
608
    DRIZZLE_TYPE_VARCHAR,
609
    //DRIZZLE_TYPE_DATE
610
    DRIZZLE_TYPE_VARCHAR,
611
    //DRIZZLE_TYPE_VARCHAR
612
    DRIZZLE_TYPE_VARCHAR,
613
    //DRIZZLE_TYPE_DECIMAL
614
    DRIZZLE_TYPE_VARCHAR,
615
    //DRIZZLE_TYPE_VARCHAR,
616
    DRIZZLE_TYPE_VARCHAR,
617
    //DRIZZLE_TYPE_BLOB
618
    DRIZZLE_TYPE_BLOB,
619
    //DRIZZLE_TYPE_TIME
620
    DRIZZLE_TYPE_TIME,
621
    //DRIZZLE_TYPE_BOOLEAN
622
    DRIZZLE_TYPE_VARCHAR,
623
    //DRIZZLE_TYPE_UUID
624
    DRIZZLE_TYPE_UUID,
625
    //DRIZZLE_TYPE_MICROTIME
626
    DRIZZLE_TYPE_MICROTIME,
627
    //DRIZZLE_TYPE_IPV6
628
    DRIZZLE_TYPE_VARCHAR,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
629
  },
1 by brian
clean slate
630
};
631
1996.2.1 by Brian Aker
uuid type code.
632
static Item_result field_types_result_type [enum_field_types_size]=
1 by brian
clean slate
633
{
398 by Brian Aker
Remove short.
634
  //DRIZZLE_TYPE_LONG
635
  INT_RESULT,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
636
  //DRIZZLE_TYPE_DOUBLE
166 by Brian Aker
Removal of FLOAT type
637
  REAL_RESULT,
520.1.26 by Monty Taylor
Fixed some formatting.
638
  //DRIZZLE_TYPE_NULL
639
  STRING_RESULT,
640
  //DRIZZLE_TYPE_TIMESTAMP
641
  STRING_RESULT,
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
642
  //DRIZZLE_TYPE_LONGLONG
167 by Brian Aker
Remove old 3byte int
643
  INT_RESULT,
222 by Brian Aker
Remove YEAR field type
644
  //DRIZZLE_TYPE_DATETIME
645
  STRING_RESULT,
575.5.1 by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code
646
  //DRIZZLE_TYPE_DATE
520.1.26 by Monty Taylor
Fixed some formatting.
647
  STRING_RESULT,
648
  //DRIZZLE_TYPE_VARCHAR
649
  STRING_RESULT,
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
650
  //DRIZZLE_TYPE_DECIMAL   
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
651
  DECIMAL_RESULT,           
652
  //DRIZZLE_TYPE_ENUM
653
  STRING_RESULT,
240 by Brian Aker
Removed old/dead VARCHAR type from pre-5.0
654
  //DRIZZLE_TYPE_BLOB
655
  STRING_RESULT,
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
656
  //DRIZZLE_TYPE_TIME
657
  STRING_RESULT,
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
658
  //DRIZZLE_TYPE_BOOLEAN
2023.2.3 by Brian Aker
Merge in fixes for DD to make use of BOOLEAN as a type.
659
  STRING_RESULT,
1996.2.1 by Brian Aker
uuid type code.
660
  //DRIZZLE_TYPE_UUID
661
  STRING_RESULT,
2046.2.1 by Brian Aker
First pass on micro timestamp.
662
  //DRIZZLE_TYPE_MICROTIME
663
  STRING_RESULT,
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
664
  //DRIZZLE_TYPE_IPV6
665
  STRING_RESULT,
1 by brian
clean slate
666
};
667
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
668
bool test_if_important_data(const charset_info_st * const cs, 
1055.2.7 by Jay Pipes
More documentation cleanup for Field class
669
                            const char *str,
670
                            const char *strend)
1 by brian
clean slate
671
{
672
  if (cs != &my_charset_bin)
673
    str+= cs->cset->scan(cs, str, strend, MY_SEQ_SPACES);
674
  return (str < strend);
675
}
676
1241.9.51 by Monty Taylor
More mysys stuff out of headers.
677
void *Field::operator new(size_t size)
678
{
1253.1.6 by Monty Taylor
Moved mem_root functions into drizzled::memory:: namespace.
679
  return memory::sql_alloc(size);
1241.9.51 by Monty Taylor
More mysys stuff out of headers.
680
}
681
1253.1.3 by Monty Taylor
MEM_ROOT == memory::Root
682
void *Field::operator new(size_t size, memory::Root *mem_root)
1241.9.51 by Monty Taylor
More mysys stuff out of headers.
683
{
2318.6.40 by Olaf van der Spek
Refactor
684
  return mem_root->alloc(size);
1241.9.51 by Monty Taylor
More mysys stuff out of headers.
685
}
686
1055.2.9 by Jay Pipes
Removes dead get_blob_type_from_length() function. We only have one type of BLOB now...
687
enum_field_types Field::field_type_merge(enum_field_types a,
688
                                         enum_field_types b)
689
{
1996.2.1 by Brian Aker
uuid type code.
690
  assert(a < enum_field_types_size);
691
  assert(b < enum_field_types_size);
1055.2.9 by Jay Pipes
Removes dead get_blob_type_from_length() function. We only have one type of BLOB now...
692
  return field_types_merge_rules[a][b];
693
}
694
1 by brian
clean slate
695
Item_result Field::result_merge_type(enum_field_types field_type)
696
{
1996.2.1 by Brian Aker
uuid type code.
697
  assert(field_type < enum_field_types_size);
520.1.25 by Monty Taylor
Removed the split.
698
  return field_types_result_type[field_type];
1 by brian
clean slate
699
}
700
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
701
bool Field::eq(Field *field)
702
{
703
  return (ptr == field->ptr && null_ptr == field->null_ptr &&
704
          null_bit == field->null_bit);
705
}
706
707
uint32_t Field::pack_length() const
708
{
709
  return field_length;
710
}
711
712
uint32_t Field::pack_length_in_rec() const
713
{
714
  return pack_length();
715
}
716
717
uint32_t Field::data_length()
718
{
719
  return pack_length();
720
}
721
722
uint32_t Field::used_length()
723
{
724
  return pack_length();
725
}
726
727
uint32_t Field::sort_length() const
728
{
729
  return pack_length();
730
}
731
732
uint32_t Field::max_data_length() const
733
{
734
  return pack_length();
735
}
736
737
int Field::reset(void)
738
{
739
  memset(ptr, 0, pack_length());
740
  return 0;
741
}
742
743
void Field::reset_fields()
744
{}
745
746
void Field::set_default()
747
{
1672.3.6 by Brian Aker
First pass in encapsulating row
748
  ptrdiff_t l_offset= (ptrdiff_t) (table->getDefaultValues() - table->getInsertRecord());
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
749
  memcpy(ptr, ptr + l_offset, pack_length());
750
  if (null_ptr)
751
    *null_ptr= ((*null_ptr & (unsigned char) ~null_bit) | (null_ptr[l_offset] & null_bit));
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
752
1055.2.2 by Jay Pipes
Cleanup of style, indentation, and documentation of Table class members. Removed 5 or 6 dead Table member variables.
753
  if (this == table->next_number_field)
754
    table->auto_increment_field_not_null= false;
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
755
}
756
757
bool Field::binary() const
758
{
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
759
  return true;
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
760
}
761
762
bool Field::zero_pack() const
763
{
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
764
  return true;
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
765
}
766
767
enum ha_base_keytype Field::key_type() const
768
{
769
  return HA_KEYTYPE_BINARY;
770
}
771
772
uint32_t Field::key_length() const
773
{
774
  return pack_length();
775
}
776
777
enum_field_types Field::real_type() const
778
{
779
  return type();
780
}
781
782
int Field::cmp_max(const unsigned char *a, const unsigned char *b, uint32_t)
783
{
784
  return cmp(a, b);
785
}
786
787
int Field::cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t)
788
{
789
  return memcmp(a,b,pack_length());
790
}
791
792
int Field::cmp_offset(uint32_t row_offset)
793
{
794
  return cmp(ptr,ptr+row_offset);
795
}
796
797
int Field::cmp_binary_offset(uint32_t row_offset)
798
{
799
  return cmp_binary(ptr, ptr+row_offset);
800
}
801
802
int Field::key_cmp(const unsigned char *a,const unsigned char *b)
803
{
804
  return cmp(a, b);
805
}
806
807
int Field::key_cmp(const unsigned char *str, uint32_t)
808
{
809
  return cmp(ptr,str);
810
}
811
812
uint32_t Field::decimals() const
813
{
814
  return 0;
815
}
816
2181.2.3 by Brian Aker
Further commit const on field.
817
bool Field::is_null(ptrdiff_t row_offset) const
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
818
{
2318.6.12 by Olaf van der Spek
Refactor
819
  return null_ptr ? (null_ptr[row_offset] & null_bit ? true : false) : table->null_row;
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
820
}
821
2181.2.4 by Brian Aker
Create CONST on additional Field methods.
822
bool Field::is_real_null(ptrdiff_t row_offset) const
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
823
{
2318.6.13 by Olaf van der Spek
Refactor
824
  return null_ptr && (null_ptr[row_offset] & null_bit);
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
825
}
826
2181.2.4 by Brian Aker
Create CONST on additional Field methods.
827
bool Field::is_null_in_record(const unsigned char *record) const
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
828
{
2318.6.13 by Olaf van der Spek
Refactor
829
  return null_ptr && test(record[(uint32_t) (null_ptr -table->getInsertRecord())] & null_bit);
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
830
}
831
2181.2.4 by Brian Aker
Create CONST on additional Field methods.
832
bool Field::is_null_in_record_with_offset(ptrdiff_t with_offset) const
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
833
{
2318.6.13 by Olaf van der Spek
Refactor
834
  return null_ptr && test(null_ptr[with_offset] & null_bit);
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
835
}
836
1122.2.12 by Monty Taylor
Removed the silly my_ptrdiff_t typedef.
837
void Field::set_null(ptrdiff_t row_offset)
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
838
{
839
  if (null_ptr)
840
    null_ptr[row_offset]|= null_bit;
841
}
842
1122.2.12 by Monty Taylor
Removed the silly my_ptrdiff_t typedef.
843
void Field::set_notnull(ptrdiff_t row_offset)
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
844
{
845
  if (null_ptr)
846
    null_ptr[row_offset]&= (unsigned char) ~null_bit;
847
}
848
2181.2.4 by Brian Aker
Create CONST on additional Field methods.
849
bool Field::maybe_null(void) const
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
850
{
851
  return null_ptr != 0 || table->maybe_null;
852
}
853
2181.2.4 by Brian Aker
Create CONST on additional Field methods.
854
bool Field::real_maybe_null(void) const
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
855
{
856
  return null_ptr != 0;
857
}
858
1 by brian
clean slate
859
bool Field::type_can_have_key_part(enum enum_field_types type)
860
{
2318.6.12 by Olaf van der Spek
Refactor
861
  switch (type) 
862
  {
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
863
  case DRIZZLE_TYPE_VARCHAR:
864
  case DRIZZLE_TYPE_BLOB:
51.1.56 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on field.h/cc
865
    return true;
1 by brian
clean slate
866
  default:
51.1.56 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on field.h/cc
867
    return false;
1 by brian
clean slate
868
  }
869
}
870
871
int Field::warn_if_overflow(int op_result)
872
{
873
  if (op_result == E_DEC_OVERFLOW)
874
  {
261.4.1 by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR.
875
    set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
876
    return E_DEC_OVERFLOW;
1 by brian
clean slate
877
  }
878
  if (op_result == E_DEC_TRUNCATED)
879
  {
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
880
    set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
881
    return E_DEC_TRUNCATED;
1 by brian
clean slate
882
  }
883
  return 0;
884
}
885
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
886
void Field::init(Table *table_arg)
887
{
888
  orig_table= table= table_arg;
889
}
890
1 by brian
clean slate
891
/// This is used as a table name when the table structure is not set up
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
892
Field::Field(unsigned char *ptr_arg,
893
             uint32_t length_arg,
894
             unsigned char *null_ptr_arg,
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
895
             unsigned char null_bit_arg,
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
896
             utype unireg_check_arg, 
2134.1.2 by Brian Aker
Init the field class correctly.
897
             const char *field_name_arg) :
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
898
    ptr(ptr_arg),
899
    null_ptr(null_ptr_arg),
900
    table(NULL),
901
    orig_table(NULL),
902
    field_name(field_name_arg),
903
    key_start(0),
904
    part_of_key(0),
905
    part_of_key_not_clustered(0),
906
    part_of_sortkey(0),
907
    unireg_check(unireg_check_arg),
908
    field_length(length_arg),
2134.1.2 by Brian Aker
Init the field class correctly.
909
    flags(null_ptr ? 0: NOT_NULL_FLAG),
910
    field_index(0),
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
911
    null_bit(null_bit_arg),
912
    is_created_from_null_item(false)
1 by brian
clean slate
913
{
914
}
915
2181.2.4 by Brian Aker
Create CONST on additional Field methods.
916
void Field::hash(uint32_t *nr, uint32_t *nr2) const
1 by brian
clean slate
917
{
918
  if (is_null())
919
  {
920
    *nr^= (*nr << 1) | 1;
921
  }
922
  else
923
  {
438.1.13 by Brian Aker
uint cleanup.
924
    uint32_t len= pack_length();
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
925
    const charset_info_st * const cs= charset();
1 by brian
clean slate
926
    cs->coll->hash_sort(cs, ptr, len, nr, nr2);
927
  }
928
}
929
930
void Field::copy_from_tmp(int row_offset)
931
{
932
  memcpy(ptr,ptr+row_offset,pack_length());
933
  if (null_ptr)
934
  {
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
935
    *null_ptr= (unsigned char) ((null_ptr[0] &
936
                                 (unsigned char) ~(uint32_t) null_bit) |
937
                                (null_ptr[row_offset] &
938
                                 (unsigned char) null_bit));
1 by brian
clean slate
939
  }
940
}
941
1996.2.1 by Brian Aker
uuid type code.
942
int Field::store_and_check(enum_check_fields check_level,
943
                           const char *to, 
944
                           uint32_t length,
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
945
                           const charset_info_st * const cs)
1996.2.1 by Brian Aker
uuid type code.
946
1 by brian
clean slate
947
{
948
  enum_check_fields old_check_level= table->in_use->count_cuted_fields;
949
  table->in_use->count_cuted_fields= check_level;
2318.6.12 by Olaf van der Spek
Refactor
950
  int res= store(to, length, cs);
1 by brian
clean slate
951
  table->in_use->count_cuted_fields= old_check_level;
952
  return res;
953
}
954
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
955
unsigned char *Field::pack(unsigned char *to, const unsigned char *from, uint32_t max_length, bool)
1 by brian
clean slate
956
{
205 by Brian Aker
uint32 -> uin32_t
957
  uint32_t length= pack_length();
1 by brian
clean slate
958
  set_if_smaller(length, max_length);
959
  memcpy(to, from, length);
960
  return to+length;
961
}
962
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
963
unsigned char *Field::pack(unsigned char *to, const unsigned char *from)
964
{
2318.6.12 by Olaf van der Spek
Refactor
965
  return this->pack(to, from, UINT32_MAX, table->getShare()->db_low_byte_first);
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
966
}
967
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
968
const unsigned char *Field::unpack(unsigned char* to,
969
                                   const unsigned char *from, 
970
                                   uint32_t param_data,
971
                                   bool)
1 by brian
clean slate
972
{
438.1.13 by Brian Aker
uint cleanup.
973
  uint32_t length=pack_length();
1 by brian
clean slate
974
  int from_type= 0;
975
  /*
976
    If from length is > 255, it has encoded data in the upper bits. Need
977
    to mask it out.
978
  */
979
  if (param_data > 255)
980
  {
981
    from_type= (param_data & 0xff00) >> 8U;  // real_type.
982
    param_data= param_data & 0x00ff;        // length.
983
  }
984
985
  if ((param_data == 0) ||
986
      (length == param_data) ||
987
      (from_type != real_type()))
988
  {
989
    memcpy(to, from, length);
990
    return from+length;
991
  }
992
438.1.13 by Brian Aker
uint cleanup.
993
  uint32_t len= (param_data && (param_data < length)) ?
520.1.28 by Monty Taylor
Reverted too-big formatting change.
994
            param_data : length;
1 by brian
clean slate
995
996
  memcpy(to, from, param_data > length ? length : len);
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
997
  return (from + len);
1 by brian
clean slate
998
}
999
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1000
const unsigned char *Field::unpack(unsigned char* to, const unsigned char *from)
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
1001
{
2318.6.13 by Olaf van der Spek
Refactor
1002
  return unpack(to, from, 0, table->getShare()->db_low_byte_first);
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
1003
}
1004
2181.2.1 by Brian Aker
Protect all of the val_* methods from modification.
1005
type::Decimal *Field::val_decimal(type::Decimal *) const
1 by brian
clean slate
1006
{
1007
  /* This never have to be called */
2318.6.12 by Olaf van der Spek
Refactor
1008
  assert(false);
1 by brian
clean slate
1009
  return 0;
1010
}
1011
1012
1052.2.4 by Nathan Williams
No actual code changes. Changed Send_field to SendField to be consistent with coding standards.
1013
void Field::make_field(SendField *field)
1 by brian
clean slate
1014
{
1532.1.15 by Brian Aker
Partial encapsulation of TableShare from Table.
1015
  if (orig_table && orig_table->getShare()->getSchemaName() && *orig_table->getShare()->getSchemaName())
1 by brian
clean slate
1016
  {
1835.1.3 by Brian Aker
Fix variable such that we no longer pass share to varstring on creation.
1017
    field->db_name= orig_table->getShare()->getSchemaName();
1018
    field->org_table_name= orig_table->getShare()->getTableName();
1 by brian
clean slate
1019
  }
1020
  else
1021
    field->org_table_name= field->db_name= "";
1022
  if (orig_table)
1023
  {
1669.2.6 by Brian Aker
First pass through encapsulating getAlias() from table.
1024
    field->table_name= orig_table->getAlias();
1 by brian
clean slate
1025
    field->org_col_name= field_name;
1026
  }
1027
  else
1028
  {
1029
    field->table_name= "";
1030
    field->org_col_name= "";
1031
  }
1032
  field->col_name= field_name;
1033
  field->charsetnr= charset()->number;
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1034
  field->length= field_length;
1035
  field->type= type();
1036
  field->flags= table->maybe_null ? (flags & ~NOT_NULL_FLAG) : flags;
1 by brian
clean slate
1037
  field->decimals= 0;
1038
}
1039
2030.1.4 by Brian Aker
Change my_decimal to Decimal
1040
int64_t Field::convert_decimal2int64_t(const type::Decimal *val, bool, int *err)
1 by brian
clean slate
1041
{
152 by Brian Aker
longlong replacement
1042
  int64_t i;
2034.2.1 by Brian Aker
Move class_decimal2int to a method on Decimal.
1043
  if (warn_if_overflow(val->val_int32(E_DEC_ERROR &
508 by Brian Aker
Second pass on unsigned
1044
                                      ~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED,
2034.2.1 by Brian Aker
Move class_decimal2int to a method on Decimal.
1045
                                      false, &i)))
1 by brian
clean slate
1046
  {
163 by Brian Aker
Merge Monty's code.
1047
    i= (val->sign() ? INT64_MIN : INT64_MAX);
1 by brian
clean slate
1048
    *err= 1;
1049
  }
1050
  return i;
1051
}
1052
1539.1.6 by Brian Aker
Update for Join structure changes.
1053
uint32_t Field::fill_cache_field(CacheField *copy)
1 by brian
clean slate
1054
{
438.1.13 by Brian Aker
uint cleanup.
1055
  uint32_t store_length;
1 by brian
clean slate
1056
  copy->str=ptr;
1057
  copy->length=pack_length();
1058
  copy->blob_field=0;
1059
  if (flags & BLOB_FLAG)
1060
  {
1061
    copy->blob_field=(Field_blob*) this;
1062
    copy->strip=0;
2134.1.4 by Brian Aker
Simple encapsulation for table.
1063
    copy->length-= table->getShare()->sizeBlobPtr();
1 by brian
clean slate
1064
    return copy->length;
1065
  }
1066
  else
1067
  {
1068
    copy->strip=0;
1069
    store_length= 0;
1070
  }
1071
  return copy->length+ store_length;
1072
}
1073
2181.2.1 by Brian Aker
Protect all of the val_* methods from modification.
1074
bool Field::get_date(type::Time &ltime, uint32_t fuzzydate) const
1 by brian
clean slate
1075
{
2137.1.9 by Brian Aker
Remove current_session usage in one location (we have the table's session to
1076
  char buff[type::Time::MAX_STRING_LENGTH];
2318.6.12 by Olaf van der Spek
Refactor
1077
  String tmp(buff,sizeof(buff),&my_charset_bin);
2114.5.1 by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in
1078
1079
  assert(getTable() and getTable()->getSession());
1080
2318.6.12 by Olaf van der Spek
Refactor
1081
  String* res= val_str_internal(&tmp);
2440.2.23 by Olaf van der Spek
Use str_ref
1082
  return not res or str_to_datetime_with_warn(*getTable()->getSession(), *res, ltime, fuzzydate) <= type::DRIZZLE_TIMESTAMP_ERROR;
1 by brian
clean slate
1083
}
1084
2181.2.3 by Brian Aker
Further commit const on field.
1085
bool Field::get_time(type::Time &ltime) const
1 by brian
clean slate
1086
{
2137.1.9 by Brian Aker
Remove current_session usage in one location (we have the table's session to
1087
  char buff[type::Time::MAX_STRING_LENGTH];
2318.6.12 by Olaf van der Spek
Refactor
1088
  String tmp(buff,sizeof(buff),&my_charset_bin);
1996.2.1 by Brian Aker
uuid type code.
1089
2318.6.12 by Olaf van der Spek
Refactor
1090
  String* res= val_str_internal(&tmp);
2440.2.23 by Olaf van der Spek
Use str_ref
1091
  return not res or str_to_time_with_warn(*getTable()->getSession(), *res, ltime);
1 by brian
clean slate
1092
}
1093
2104.2.7 by Brian Aker
Fix store_time to take reference.
1094
int Field::store_time(type::Time &ltime, type::timestamp_t)
1 by brian
clean slate
1095
{
2088.8.11 by Brian Aker
Fix additional output, swaps for the valus.
1096
  String tmp;
2104.2.7 by Brian Aker
Fix store_time to take reference.
1097
  ltime.convert(tmp);
2088.8.11 by Brian Aker
Fix additional output, swaps for the valus.
1098
  return store(tmp.ptr(), tmp.length(), &my_charset_bin);
1 by brian
clean slate
1099
}
1100
1235.1.12 by Brian Aker
Clean up index interface before moving to SE.
1101
bool Field::optimize_range(uint32_t idx, uint32_t)
1 by brian
clean slate
1102
{
1235.1.14 by Brian Aker
Final move of index flags up to Engine (new interface still needed).
1103
  return test(table->index_flags(idx) & HA_READ_RANGE);
1 by brian
clean slate
1104
}
1105
1253.1.3 by Monty Taylor
MEM_ROOT == memory::Root
1106
Field *Field::new_field(memory::Root *root, Table *new_table, bool)
1 by brian
clean slate
1107
{
2318.6.24 by Olaf van der Spek
Refactor
1108
  Field* tmp= (Field*) root->memdup(this,size_of());
1 by brian
clean slate
1109
  if (tmp->table->maybe_null)
1110
    tmp->flags&= ~NOT_NULL_FLAG;
1111
  tmp->table= new_table;
1005.2.6 by Monty Taylor
Re-added bitset<> as a replacement for Bitmap<>
1112
  tmp->key_start.reset();
1113
  tmp->part_of_key.reset();
1114
  tmp->part_of_sortkey.reset();
1 by brian
clean slate
1115
  tmp->unireg_check= Field::NONE;
1315.2.15 by Stewart Smith
remove the now unused SET_FLAG define. We don't have the SET field type, and this flag was never set.
1116
  tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG | BINARY_FLAG | ENUM_FLAG);
1 by brian
clean slate
1117
  tmp->reset_fields();
1118
  return tmp;
1119
}
1120
1253.1.3 by Monty Taylor
MEM_ROOT == memory::Root
1121
Field *Field::new_key_field(memory::Root *root, Table *new_table,
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1122
                            unsigned char *new_ptr,
1123
                            unsigned char *new_null_ptr,
438.1.13 by Brian Aker
uint cleanup.
1124
                            uint32_t new_null_bit)
1 by brian
clean slate
1125
{
2318.6.12 by Olaf van der Spek
Refactor
1126
  Field *tmp= new_field(root, new_table, table == new_table);
1127
  tmp->ptr= new_ptr;
1128
  tmp->null_ptr= new_null_ptr;
1129
  tmp->null_bit= new_null_bit;
1 by brian
clean slate
1130
  return tmp;
1131
}
1132
1253.1.3 by Monty Taylor
MEM_ROOT == memory::Root
1133
Field *Field::clone(memory::Root *root, Table *new_table)
1 by brian
clean slate
1134
{
2318.6.24 by Olaf van der Spek
Refactor
1135
  Field *tmp= (Field*) root->memdup(this,size_of());
2318.6.12 by Olaf van der Spek
Refactor
1136
  tmp->init(new_table);
1137
  tmp->move_field_offset((ptrdiff_t) (new_table->getInsertRecord() - new_table->getDefaultValues()));
1 by brian
clean slate
1138
  return tmp;
1139
}
1140
1052.2.3 by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards.
1141
uint32_t Field::is_equal(CreateField *new_field_ptr)
1 by brian
clean slate
1142
{
2318.6.12 by Olaf van der Spek
Refactor
1143
  return new_field_ptr->sql_type == real_type();
1 by brian
clean slate
1144
}
1145
1146
bool Field::eq_def(Field *field)
1147
{
2318.6.13 by Olaf van der Spek
Refactor
1148
  return real_type() == field->real_type() && charset() == field->charset() && pack_length() == field->pack_length();
1 by brian
clean slate
1149
}
1150
1151
bool Field_enum::eq_def(Field *field)
1152
{
1153
  if (!Field::eq_def(field))
1154
    return 0;
2046.2.1 by Brian Aker
First pass on micro timestamp.
1155
1 by brian
clean slate
1156
  TYPELIB *from_lib=((Field_enum*) field)->typelib;
1157
1158
  if (typelib->count < from_lib->count)
1159
    return 0;
2046.2.1 by Brian Aker
First pass on micro timestamp.
1160
438.1.13 by Brian Aker
uint cleanup.
1161
  for (uint32_t i=0 ; i < from_lib->count ; i++)
2046.2.1 by Brian Aker
First pass on micro timestamp.
1162
  {
1 by brian
clean slate
1163
    if (my_strnncoll(field_charset,
2318.6.12 by Olaf van der Spek
Refactor
1164
                     (const unsigned char*)typelib->type_names[i], strlen(typelib->type_names[i]),
1165
                     (const unsigned char*)from_lib->type_names[i], strlen(from_lib->type_names[i])))
1 by brian
clean slate
1166
      return 0;
2046.2.1 by Brian Aker
First pass on micro timestamp.
1167
  }
1168
1 by brian
clean slate
1169
  return 1;
1170
}
1171
205 by Brian Aker
uint32 -> uin32_t
1172
uint32_t calc_pack_length(enum_field_types type,uint32_t length)
1 by brian
clean slate
1173
{
2318.6.12 by Olaf van der Spek
Refactor
1174
  switch (type) 
1175
  {
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
1176
  case DRIZZLE_TYPE_VARCHAR: return (length + (length < 256 ? 1: 2));
1996.2.1 by Brian Aker
uuid type code.
1177
  case DRIZZLE_TYPE_UUID: return field::Uuid::max_string_length();
2046.2.1 by Brian Aker
First pass on micro timestamp.
1178
  case DRIZZLE_TYPE_MICROTIME: return field::Microtime::max_string_length();
1179
  case DRIZZLE_TYPE_TIMESTAMP: return field::Epoch::max_string_length();
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
1180
  case DRIZZLE_TYPE_BOOLEAN: return field::Boolean::max_string_length();
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
1181
  case DRIZZLE_TYPE_IPV6: return field::IPv6::max_string_length();
1782.4.2 by Brian Aker
Convert date from 3 byte to 4 byte.
1182
  case DRIZZLE_TYPE_DATE:
1782.4.4 by Brian Aker
Fix enum at being an intefer (which is what PG did, and it saves on
1183
  case DRIZZLE_TYPE_ENUM:
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
1184
  case DRIZZLE_TYPE_LONG: return 4;
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
1185
  case DRIZZLE_TYPE_DOUBLE: return sizeof(double);
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
1186
  case DRIZZLE_TYPE_TIME:
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
1187
  case DRIZZLE_TYPE_DATETIME:
520.1.28 by Monty Taylor
Reverted too-big formatting change.
1188
  case DRIZZLE_TYPE_LONGLONG: return 8;	/* Don't crash if no int64_t */
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
1189
  case DRIZZLE_TYPE_NULL: return 0;
1190
  case DRIZZLE_TYPE_BLOB: return 4 + portable_sizeof_char_ptr;
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
1191
  case DRIZZLE_TYPE_DECIMAL:
1999.4.11 by Brian Aker
Fix issues with some columns incorrectly reporting NULL if they were of
1192
                          break;
1 by brian
clean slate
1193
  }
1996.2.1 by Brian Aker
uuid type code.
1194
1195
  assert(0);
1196
  abort();
1 by brian
clean slate
1197
}
1198
438.1.13 by Brian Aker
uint cleanup.
1199
uint32_t pack_length_to_packflag(uint32_t type)
1 by brian
clean slate
1200
{
2318.6.12 by Olaf van der Spek
Refactor
1201
  switch (type) 
1202
  {
2318.6.13 by Olaf van der Spek
Refactor
1203
  case 1: return 1 << FIELDFLAG_PACK_SHIFT;
1204
  case 2: assert(0);
1205
  case 3: assert(0);
1206
  case 4: return f_settype(DRIZZLE_TYPE_LONG);
1207
  case 8: return f_settype(DRIZZLE_TYPE_LONGLONG);
1 by brian
clean slate
1208
  }
2318.6.13 by Olaf van der Spek
Refactor
1209
  assert(false);
520.1.28 by Monty Taylor
Reverted too-big formatting change.
1210
  return 0;					// This shouldn't happen
1 by brian
clean slate
1211
}
1212
1213
/*****************************************************************************
1214
 Warning handling
1215
*****************************************************************************/
1216
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1217
bool Field::set_warning(DRIZZLE_ERROR::enum_warning_level level,
2087.3.1 by Brian Aker
Entire convert over to time_t.
1218
                        drizzled::error_t code,
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1219
                        int cuted_increment)
1 by brian
clean slate
1220
{
1221
  /*
1222
    If this field was created only for type conversion purposes it
1223
    will have table == NULL.
1224
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
1225
  Session *session= table ? table->in_use : current_session;
1226
  if (session->count_cuted_fields)
1 by brian
clean slate
1227
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
1228
    session->cuted_fields+= cuted_increment;
1229
    push_warning_printf(session, level, code, ER(code), field_name,
1230
                        session->row_count);
1 by brian
clean slate
1231
    return 0;
1232
  }
261.4.1 by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR.
1233
  return level >= DRIZZLE_ERROR::WARN_LEVEL_WARN;
1 by brian
clean slate
1234
}
1235
1236
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1237
void Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level,
2087.3.1 by Brian Aker
Entire convert over to time_t.
1238
                                 drizzled::error_t code,
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1239
                                 const char *str, 
1240
                                 uint32_t str_length,
2088.8.9 by Brian Aker
Merge in namespace of enum.
1241
                                 type::timestamp_t ts_type, 
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1242
                                 int cuted_increment)
1 by brian
clean slate
1243
{
2114.5.1 by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in
1244
  Session *session= (getTable() and getTable()->getSession()) ? getTable()->getSession() : current_session;
1245
2114.5.2 by Brian Aker
Just remove second ecapsulated method call.
1246
  if ((session->abortOnWarning() and
261.4.1 by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR.
1247
       level >= DRIZZLE_ERROR::WARN_LEVEL_WARN) ||
1 by brian
clean slate
1248
      set_warning(level, code, cuted_increment))
2440.2.23 by Olaf van der Spek
Use str_ref
1249
    make_truncated_value_warning(*session, level, str_ref(str, str_length), ts_type, field_name);
1 by brian
clean slate
1250
}
1251
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1252
void Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level, 
2087.3.1 by Brian Aker
Entire convert over to time_t.
1253
                                 drizzled::error_t code,
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1254
                                 int64_t nr, 
2088.8.9 by Brian Aker
Merge in namespace of enum.
1255
                                 type::timestamp_t ts_type,
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1256
                                 int cuted_increment)
1 by brian
clean slate
1257
{
2114.5.1 by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in
1258
  Session *session= (getTable() and getTable()->getSession()) ? getTable()->getSession() : current_session;
1259
2114.5.2 by Brian Aker
Just remove second ecapsulated method call.
1260
  if (session->abortOnWarning() or
1 by brian
clean slate
1261
      set_warning(level, code, cuted_increment))
1262
  {
2148.5.3 by Brian Aker
Remove hard coded array for numbers (this also fixes a couple of spots where
1263
    char str_nr[DECIMAL_LONGLONG_DIGITS];
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
1264
    char *str_end= internal::int64_t10_to_str(nr, str_nr, -10);
2440.2.23 by Olaf van der Spek
Use str_ref
1265
    make_truncated_value_warning(*session, level, str_ref(str_nr, (uint32_t) (str_end - str_nr)), ts_type, field_name);
1 by brian
clean slate
1266
  }
1267
}
1268
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1269
void Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level,
2087.3.1 by Brian Aker
Entire convert over to time_t.
1270
                                 const drizzled::error_t code,
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1271
                                 double nr, 
2088.8.9 by Brian Aker
Merge in namespace of enum.
1272
                                 type::timestamp_t ts_type)
1 by brian
clean slate
1273
{
2114.5.1 by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in
1274
  Session *session= (getTable() and getTable()->getSession()) ? getTable()->getSession() : current_session;
1275
2114.5.2 by Brian Aker
Just remove second ecapsulated method call.
1276
  if (session->abortOnWarning() or
1 by brian
clean slate
1277
      set_warning(level, code, 1))
1278
  {
1279
    /* DBL_DIG is enough to print '-[digits].E+###' */
1280
    char str_nr[DBL_DIG + 8];
1366.1.11 by Siddharth Prakash Singh
sprintf->snprintf continued
1281
    uint32_t str_len= snprintf(str_nr, sizeof(str_nr), "%g", nr);
2440.2.23 by Olaf van der Spek
Use str_ref
1282
    make_truncated_value_warning(*session, level, str_ref(str_nr, str_len), ts_type, field_name);
1 by brian
clean slate
1283
  }
1284
}
575.4.7 by Monty Taylor
More header cleanup.
1285
2181.2.2 by Brian Aker
This fixes DEBUG based compiles.
1286
bool Field::isReadSet() const 
1003.1.6 by Brian Aker
Added interface for field to get read/write on its own.
1287
{ 
1003.1.12 by Brian Aker
Begin of abstract out the bitmap from direct reference.
1288
  return table->isReadSet(field_index); 
1003.1.6 by Brian Aker
Added interface for field to get read/write on its own.
1289
}
1290
1003.1.9 by Brian Aker
Patches for Jay (aka name changes)
1291
bool Field::isWriteSet()
1003.1.6 by Brian Aker
Added interface for field to get read/write on its own.
1292
{ 
1003.1.12 by Brian Aker
Begin of abstract out the bitmap from direct reference.
1293
  return table->isWriteSet(field_index); 
1003.1.6 by Brian Aker
Added interface for field to get read/write on its own.
1294
}
1089.1.3 by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix
1295
1296
void Field::setReadSet(bool arg)
1297
{
1298
  if (arg)
1299
    table->setReadSet(field_index);
1300
  else
1039.5.42 by Jay Pipes
Splits out the previously aggregated all.test case into separate test
1301
    table->clearReadSet(field_index);
1089.1.3 by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix
1302
}
1303
1304
void Field::setWriteSet(bool arg)
1305
{
1306
  if (arg)
1307
    table->setWriteSet(field_index);
1308
  else
1039.5.42 by Jay Pipes
Splits out the previously aggregated all.test case into separate test
1309
    table->clearWriteSet(field_index);
1089.1.3 by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix
1310
}
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
1311
2016.1.2 by Brian Aker
Fix for Solaris
1312
void Field::pack_num(uint64_t arg, unsigned char *destination)
1313
{
1314
  if (not destination)
1315
    destination= ptr;
1316
2016.1.7 by Brian Aker
Remove MyISAM flip bit, and make sure that we only pass in a good time_t to
1317
  int64_tstore(destination, arg);
2016.1.2 by Brian Aker
Fix for Solaris
1318
}
1319
2046.2.3 by Brian Aker
Add basic tests for microtime.
1320
void Field::pack_num(uint32_t arg, unsigned char *destination)
1321
{
1322
  if (not destination)
1323
    destination= ptr;
1324
1325
  longstore(destination, arg);
1326
}
1327
2016.1.2 by Brian Aker
Fix for Solaris
1328
uint64_t Field::unpack_num(uint64_t &destination, const unsigned char *arg) const
1329
{
1330
  if (not arg)
1331
    arg= ptr;
1332
2016.1.7 by Brian Aker
Remove MyISAM flip bit, and make sure that we only pass in a good time_t to
1333
  int64_tget(destination, arg);
2016.1.2 by Brian Aker
Fix for Solaris
1334
1335
  return destination;
1336
}
1337
2046.2.3 by Brian Aker
Add basic tests for microtime.
1338
uint32_t Field::unpack_num(uint32_t &destination, const unsigned char *arg) const
1339
{
1340
  if (not arg)
1341
    arg= ptr;
1342
1343
  longget(destination, arg);
1344
1345
  return destination;
1346
}
1347
1992.5.1 by Brian Aker
Additional cerr output bits for a few classes (Item, Field,...)
1348
std::ostream& operator<<(std::ostream& output, const Field &field)
1349
{
1350
  output << "Field:(";
1351
  output <<  field.field_name;
1352
  output << ", ";
1353
  output << drizzled::display::type(field.real_type());
2008.2.4 by Brian Aker
Merge in additional fixes for sign, plus alter table, plus TIME on
1354
  output << ", { ";
1355
1356
  if (field.flags & NOT_NULL_FLAG)
1357
    output << " NOT_NULL";
1358
1359
  if (field.flags & PRI_KEY_FLAG)
1360
    output << ", PRIMARY KEY";
1361
1362
  if (field.flags & UNIQUE_KEY_FLAG)
1363
    output << ", UNIQUE KEY";
1364
1365
  if (field.flags & MULTIPLE_KEY_FLAG)
1366
    output << ", MULTIPLE KEY";
1367
1368
  if (field.flags & BLOB_FLAG)
1369
    output << ", BLOB";
1370
1371
  if (field.flags & UNSIGNED_FLAG)
1372
    output << ", UNSIGNED";
1373
1374
  if (field.flags & BINARY_FLAG)
1375
    output << ", BINARY";
1376
  output << "}, ";
1992.5.1 by Brian Aker
Additional cerr output bits for a few classes (Item, Field,...)
1377
  output << ")";
1378
1379
  return output;  // for multiple << operators.
1380
}
1381
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
1382
} /* namespace drizzled */