~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),
2385.1.1 by Olaf van der Spek
Refactor lex_string_t
903
    comment(null_lex_string()),
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
904
    key_start(0),
905
    part_of_key(0),
906
    part_of_key_not_clustered(0),
907
    part_of_sortkey(0),
908
    unireg_check(unireg_check_arg),
909
    field_length(length_arg),
2134.1.2 by Brian Aker
Init the field class correctly.
910
    flags(null_ptr ? 0: NOT_NULL_FLAG),
911
    field_index(0),
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
912
    null_bit(null_bit_arg),
913
    is_created_from_null_item(false)
1 by brian
clean slate
914
{
915
}
916
2181.2.4 by Brian Aker
Create CONST on additional Field methods.
917
void Field::hash(uint32_t *nr, uint32_t *nr2) const
1 by brian
clean slate
918
{
919
  if (is_null())
920
  {
921
    *nr^= (*nr << 1) | 1;
922
  }
923
  else
924
  {
438.1.13 by Brian Aker
uint cleanup.
925
    uint32_t len= pack_length();
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
926
    const charset_info_st * const cs= charset();
1 by brian
clean slate
927
    cs->coll->hash_sort(cs, ptr, len, nr, nr2);
928
  }
929
}
930
931
void Field::copy_from_tmp(int row_offset)
932
{
933
  memcpy(ptr,ptr+row_offset,pack_length());
934
  if (null_ptr)
935
  {
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
936
    *null_ptr= (unsigned char) ((null_ptr[0] &
937
                                 (unsigned char) ~(uint32_t) null_bit) |
938
                                (null_ptr[row_offset] &
939
                                 (unsigned char) null_bit));
1 by brian
clean slate
940
  }
941
}
942
1996.2.1 by Brian Aker
uuid type code.
943
int Field::store_and_check(enum_check_fields check_level,
944
                           const char *to, 
945
                           uint32_t length,
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
946
                           const charset_info_st * const cs)
1996.2.1 by Brian Aker
uuid type code.
947
1 by brian
clean slate
948
{
949
  enum_check_fields old_check_level= table->in_use->count_cuted_fields;
950
  table->in_use->count_cuted_fields= check_level;
2318.6.12 by Olaf van der Spek
Refactor
951
  int res= store(to, length, cs);
1 by brian
clean slate
952
  table->in_use->count_cuted_fields= old_check_level;
953
  return res;
954
}
955
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
956
unsigned char *Field::pack(unsigned char *to, const unsigned char *from, uint32_t max_length, bool)
1 by brian
clean slate
957
{
205 by Brian Aker
uint32 -> uin32_t
958
  uint32_t length= pack_length();
1 by brian
clean slate
959
  set_if_smaller(length, max_length);
960
  memcpy(to, from, length);
961
  return to+length;
962
}
963
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
964
unsigned char *Field::pack(unsigned char *to, const unsigned char *from)
965
{
2318.6.12 by Olaf van der Spek
Refactor
966
  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.
967
}
968
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
969
const unsigned char *Field::unpack(unsigned char* to,
970
                                   const unsigned char *from, 
971
                                   uint32_t param_data,
972
                                   bool)
1 by brian
clean slate
973
{
438.1.13 by Brian Aker
uint cleanup.
974
  uint32_t length=pack_length();
1 by brian
clean slate
975
  int from_type= 0;
976
  /*
977
    If from length is > 255, it has encoded data in the upper bits. Need
978
    to mask it out.
979
  */
980
  if (param_data > 255)
981
  {
982
    from_type= (param_data & 0xff00) >> 8U;  // real_type.
983
    param_data= param_data & 0x00ff;        // length.
984
  }
985
986
  if ((param_data == 0) ||
987
      (length == param_data) ||
988
      (from_type != real_type()))
989
  {
990
    memcpy(to, from, length);
991
    return from+length;
992
  }
993
438.1.13 by Brian Aker
uint cleanup.
994
  uint32_t len= (param_data && (param_data < length)) ?
520.1.28 by Monty Taylor
Reverted too-big formatting change.
995
            param_data : length;
1 by brian
clean slate
996
997
  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.
998
  return (from + len);
1 by brian
clean slate
999
}
1000
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1001
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.
1002
{
2318.6.13 by Olaf van der Spek
Refactor
1003
  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.
1004
}
1005
2181.2.1 by Brian Aker
Protect all of the val_* methods from modification.
1006
type::Decimal *Field::val_decimal(type::Decimal *) const
1 by brian
clean slate
1007
{
1008
  /* This never have to be called */
2318.6.12 by Olaf van der Spek
Refactor
1009
  assert(false);
1 by brian
clean slate
1010
  return 0;
1011
}
1012
1013
1052.2.4 by Nathan Williams
No actual code changes. Changed Send_field to SendField to be consistent with coding standards.
1014
void Field::make_field(SendField *field)
1 by brian
clean slate
1015
{
1532.1.15 by Brian Aker
Partial encapsulation of TableShare from Table.
1016
  if (orig_table && orig_table->getShare()->getSchemaName() && *orig_table->getShare()->getSchemaName())
1 by brian
clean slate
1017
  {
1835.1.3 by Brian Aker
Fix variable such that we no longer pass share to varstring on creation.
1018
    field->db_name= orig_table->getShare()->getSchemaName();
1019
    field->org_table_name= orig_table->getShare()->getTableName();
1 by brian
clean slate
1020
  }
1021
  else
1022
    field->org_table_name= field->db_name= "";
1023
  if (orig_table)
1024
  {
1669.2.6 by Brian Aker
First pass through encapsulating getAlias() from table.
1025
    field->table_name= orig_table->getAlias();
1 by brian
clean slate
1026
    field->org_col_name= field_name;
1027
  }
1028
  else
1029
  {
1030
    field->table_name= "";
1031
    field->org_col_name= "";
1032
  }
1033
  field->col_name= field_name;
1034
  field->charsetnr= charset()->number;
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1035
  field->length= field_length;
1036
  field->type= type();
1037
  field->flags= table->maybe_null ? (flags & ~NOT_NULL_FLAG) : flags;
1 by brian
clean slate
1038
  field->decimals= 0;
1039
}
1040
2030.1.4 by Brian Aker
Change my_decimal to Decimal
1041
int64_t Field::convert_decimal2int64_t(const type::Decimal *val, bool, int *err)
1 by brian
clean slate
1042
{
152 by Brian Aker
longlong replacement
1043
  int64_t i;
2034.2.1 by Brian Aker
Move class_decimal2int to a method on Decimal.
1044
  if (warn_if_overflow(val->val_int32(E_DEC_ERROR &
508 by Brian Aker
Second pass on unsigned
1045
                                      ~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED,
2034.2.1 by Brian Aker
Move class_decimal2int to a method on Decimal.
1046
                                      false, &i)))
1 by brian
clean slate
1047
  {
163 by Brian Aker
Merge Monty's code.
1048
    i= (val->sign() ? INT64_MIN : INT64_MAX);
1 by brian
clean slate
1049
    *err= 1;
1050
  }
1051
  return i;
1052
}
1053
1539.1.6 by Brian Aker
Update for Join structure changes.
1054
uint32_t Field::fill_cache_field(CacheField *copy)
1 by brian
clean slate
1055
{
438.1.13 by Brian Aker
uint cleanup.
1056
  uint32_t store_length;
1 by brian
clean slate
1057
  copy->str=ptr;
1058
  copy->length=pack_length();
1059
  copy->blob_field=0;
1060
  if (flags & BLOB_FLAG)
1061
  {
1062
    copy->blob_field=(Field_blob*) this;
1063
    copy->strip=0;
2134.1.4 by Brian Aker
Simple encapsulation for table.
1064
    copy->length-= table->getShare()->sizeBlobPtr();
1 by brian
clean slate
1065
    return copy->length;
1066
  }
1067
  else
1068
  {
1069
    copy->strip=0;
1070
    store_length= 0;
1071
  }
1072
  return copy->length+ store_length;
1073
}
1074
2181.2.1 by Brian Aker
Protect all of the val_* methods from modification.
1075
bool Field::get_date(type::Time &ltime, uint32_t fuzzydate) const
1 by brian
clean slate
1076
{
2137.1.9 by Brian Aker
Remove current_session usage in one location (we have the table's session to
1077
  char buff[type::Time::MAX_STRING_LENGTH];
2318.6.12 by Olaf van der Spek
Refactor
1078
  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
1079
1080
  assert(getTable() and getTable()->getSession());
1081
2318.6.12 by Olaf van der Spek
Refactor
1082
  String* res= val_str_internal(&tmp);
2318.6.13 by Olaf van der Spek
Refactor
1083
  return not res or str_to_datetime_with_warn(getTable()->getSession(), res->ptr(), res->length(), &ltime, fuzzydate) <= type::DRIZZLE_TIMESTAMP_ERROR;
1 by brian
clean slate
1084
}
1085
2181.2.3 by Brian Aker
Further commit const on field.
1086
bool Field::get_time(type::Time &ltime) const
1 by brian
clean slate
1087
{
2137.1.9 by Brian Aker
Remove current_session usage in one location (we have the table's session to
1088
  char buff[type::Time::MAX_STRING_LENGTH];
2318.6.12 by Olaf van der Spek
Refactor
1089
  String tmp(buff,sizeof(buff),&my_charset_bin);
1996.2.1 by Brian Aker
uuid type code.
1090
2318.6.12 by Olaf van der Spek
Refactor
1091
  String* res= val_str_internal(&tmp);
2318.6.13 by Olaf van der Spek
Refactor
1092
  return not res or str_to_time_with_warn(getTable()->getSession(), res->ptr(), res->length(), &ltime);
1 by brian
clean slate
1093
}
1094
2104.2.7 by Brian Aker
Fix store_time to take reference.
1095
int Field::store_time(type::Time &ltime, type::timestamp_t)
1 by brian
clean slate
1096
{
2088.8.11 by Brian Aker
Fix additional output, swaps for the valus.
1097
  String tmp;
2104.2.7 by Brian Aker
Fix store_time to take reference.
1098
  ltime.convert(tmp);
2088.8.11 by Brian Aker
Fix additional output, swaps for the valus.
1099
  return store(tmp.ptr(), tmp.length(), &my_charset_bin);
1 by brian
clean slate
1100
}
1101
1235.1.12 by Brian Aker
Clean up index interface before moving to SE.
1102
bool Field::optimize_range(uint32_t idx, uint32_t)
1 by brian
clean slate
1103
{
1235.1.14 by Brian Aker
Final move of index flags up to Engine (new interface still needed).
1104
  return test(table->index_flags(idx) & HA_READ_RANGE);
1 by brian
clean slate
1105
}
1106
1253.1.3 by Monty Taylor
MEM_ROOT == memory::Root
1107
Field *Field::new_field(memory::Root *root, Table *new_table, bool)
1 by brian
clean slate
1108
{
2318.6.24 by Olaf van der Spek
Refactor
1109
  Field* tmp= (Field*) root->memdup(this,size_of());
1 by brian
clean slate
1110
  if (tmp->table->maybe_null)
1111
    tmp->flags&= ~NOT_NULL_FLAG;
1112
  tmp->table= new_table;
1005.2.6 by Monty Taylor
Re-added bitset<> as a replacement for Bitmap<>
1113
  tmp->key_start.reset();
1114
  tmp->part_of_key.reset();
1115
  tmp->part_of_sortkey.reset();
1 by brian
clean slate
1116
  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.
1117
  tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG | BINARY_FLAG | ENUM_FLAG);
1 by brian
clean slate
1118
  tmp->reset_fields();
1119
  return tmp;
1120
}
1121
1253.1.3 by Monty Taylor
MEM_ROOT == memory::Root
1122
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.
1123
                            unsigned char *new_ptr,
1124
                            unsigned char *new_null_ptr,
438.1.13 by Brian Aker
uint cleanup.
1125
                            uint32_t new_null_bit)
1 by brian
clean slate
1126
{
2318.6.12 by Olaf van der Spek
Refactor
1127
  Field *tmp= new_field(root, new_table, table == new_table);
1128
  tmp->ptr= new_ptr;
1129
  tmp->null_ptr= new_null_ptr;
1130
  tmp->null_bit= new_null_bit;
1 by brian
clean slate
1131
  return tmp;
1132
}
1133
1253.1.3 by Monty Taylor
MEM_ROOT == memory::Root
1134
Field *Field::clone(memory::Root *root, Table *new_table)
1 by brian
clean slate
1135
{
2318.6.24 by Olaf van der Spek
Refactor
1136
  Field *tmp= (Field*) root->memdup(this,size_of());
2318.6.12 by Olaf van der Spek
Refactor
1137
  tmp->init(new_table);
1138
  tmp->move_field_offset((ptrdiff_t) (new_table->getInsertRecord() - new_table->getDefaultValues()));
1 by brian
clean slate
1139
  return tmp;
1140
}
1141
1052.2.3 by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards.
1142
uint32_t Field::is_equal(CreateField *new_field_ptr)
1 by brian
clean slate
1143
{
2318.6.12 by Olaf van der Spek
Refactor
1144
  return new_field_ptr->sql_type == real_type();
1 by brian
clean slate
1145
}
1146
1147
bool Field::eq_def(Field *field)
1148
{
2318.6.13 by Olaf van der Spek
Refactor
1149
  return real_type() == field->real_type() && charset() == field->charset() && pack_length() == field->pack_length();
1 by brian
clean slate
1150
}
1151
1152
bool Field_enum::eq_def(Field *field)
1153
{
1154
  if (!Field::eq_def(field))
1155
    return 0;
2046.2.1 by Brian Aker
First pass on micro timestamp.
1156
1 by brian
clean slate
1157
  TYPELIB *from_lib=((Field_enum*) field)->typelib;
1158
1159
  if (typelib->count < from_lib->count)
1160
    return 0;
2046.2.1 by Brian Aker
First pass on micro timestamp.
1161
438.1.13 by Brian Aker
uint cleanup.
1162
  for (uint32_t i=0 ; i < from_lib->count ; i++)
2046.2.1 by Brian Aker
First pass on micro timestamp.
1163
  {
1 by brian
clean slate
1164
    if (my_strnncoll(field_charset,
2318.6.12 by Olaf van der Spek
Refactor
1165
                     (const unsigned char*)typelib->type_names[i], strlen(typelib->type_names[i]),
1166
                     (const unsigned char*)from_lib->type_names[i], strlen(from_lib->type_names[i])))
1 by brian
clean slate
1167
      return 0;
2046.2.1 by Brian Aker
First pass on micro timestamp.
1168
  }
1169
1 by brian
clean slate
1170
  return 1;
1171
}
1172
205 by Brian Aker
uint32 -> uin32_t
1173
uint32_t calc_pack_length(enum_field_types type,uint32_t length)
1 by brian
clean slate
1174
{
2318.6.12 by Olaf van der Spek
Refactor
1175
  switch (type) 
1176
  {
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
1177
  case DRIZZLE_TYPE_VARCHAR: return (length + (length < 256 ? 1: 2));
1996.2.1 by Brian Aker
uuid type code.
1178
  case DRIZZLE_TYPE_UUID: return field::Uuid::max_string_length();
2046.2.1 by Brian Aker
First pass on micro timestamp.
1179
  case DRIZZLE_TYPE_MICROTIME: return field::Microtime::max_string_length();
1180
  case DRIZZLE_TYPE_TIMESTAMP: return field::Epoch::max_string_length();
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
1181
  case DRIZZLE_TYPE_BOOLEAN: return field::Boolean::max_string_length();
2398.1.1 by Muhammad Umair
merge lp:~mumair/drizzle/drizzle-IPv6Address
1182
  case DRIZZLE_TYPE_IPV6: return field::IPv6::max_string_length();
1782.4.2 by Brian Aker
Convert date from 3 byte to 4 byte.
1183
  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
1184
  case DRIZZLE_TYPE_ENUM:
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
1185
  case DRIZZLE_TYPE_LONG: return 4;
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
1186
  case DRIZZLE_TYPE_DOUBLE: return sizeof(double);
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
1187
  case DRIZZLE_TYPE_TIME:
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
1188
  case DRIZZLE_TYPE_DATETIME:
520.1.28 by Monty Taylor
Reverted too-big formatting change.
1189
  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.
1190
  case DRIZZLE_TYPE_NULL: return 0;
1191
  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
1192
  case DRIZZLE_TYPE_DECIMAL:
1999.4.11 by Brian Aker
Fix issues with some columns incorrectly reporting NULL if they were of
1193
                          break;
1 by brian
clean slate
1194
  }
1996.2.1 by Brian Aker
uuid type code.
1195
1196
  assert(0);
1197
  abort();
1 by brian
clean slate
1198
}
1199
438.1.13 by Brian Aker
uint cleanup.
1200
uint32_t pack_length_to_packflag(uint32_t type)
1 by brian
clean slate
1201
{
2318.6.12 by Olaf van der Spek
Refactor
1202
  switch (type) 
1203
  {
2318.6.13 by Olaf van der Spek
Refactor
1204
  case 1: return 1 << FIELDFLAG_PACK_SHIFT;
1205
  case 2: assert(0);
1206
  case 3: assert(0);
1207
  case 4: return f_settype(DRIZZLE_TYPE_LONG);
1208
  case 8: return f_settype(DRIZZLE_TYPE_LONGLONG);
1 by brian
clean slate
1209
  }
2318.6.13 by Olaf van der Spek
Refactor
1210
  assert(false);
520.1.28 by Monty Taylor
Reverted too-big formatting change.
1211
  return 0;					// This shouldn't happen
1 by brian
clean slate
1212
}
1213
1214
/*****************************************************************************
1215
 Warning handling
1216
*****************************************************************************/
1217
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1218
bool Field::set_warning(DRIZZLE_ERROR::enum_warning_level level,
2087.3.1 by Brian Aker
Entire convert over to time_t.
1219
                        drizzled::error_t code,
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1220
                        int cuted_increment)
1 by brian
clean slate
1221
{
1222
  /*
1223
    If this field was created only for type conversion purposes it
1224
    will have table == NULL.
1225
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
1226
  Session *session= table ? table->in_use : current_session;
1227
  if (session->count_cuted_fields)
1 by brian
clean slate
1228
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
1229
    session->cuted_fields+= cuted_increment;
1230
    push_warning_printf(session, level, code, ER(code), field_name,
1231
                        session->row_count);
1 by brian
clean slate
1232
    return 0;
1233
  }
261.4.1 by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR.
1234
  return level >= DRIZZLE_ERROR::WARN_LEVEL_WARN;
1 by brian
clean slate
1235
}
1236
1237
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1238
void Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level,
2087.3.1 by Brian Aker
Entire convert over to time_t.
1239
                                 drizzled::error_t code,
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1240
                                 const char *str, 
1241
                                 uint32_t str_length,
2088.8.9 by Brian Aker
Merge in namespace of enum.
1242
                                 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.
1243
                                 int cuted_increment)
1 by brian
clean slate
1244
{
2114.5.1 by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in
1245
  Session *session= (getTable() and getTable()->getSession()) ? getTable()->getSession() : current_session;
1246
2114.5.2 by Brian Aker
Just remove second ecapsulated method call.
1247
  if ((session->abortOnWarning() and
261.4.1 by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR.
1248
       level >= DRIZZLE_ERROR::WARN_LEVEL_WARN) ||
1 by brian
clean slate
1249
      set_warning(level, code, cuted_increment))
520.1.22 by Brian Aker
Second pass of thd cleanup
1250
    make_truncated_value_warning(session, level, str, str_length, ts_type,
1 by brian
clean slate
1251
                                 field_name);
1252
}
1253
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1254
void Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level, 
2087.3.1 by Brian Aker
Entire convert over to time_t.
1255
                                 drizzled::error_t code,
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1256
                                 int64_t nr, 
2088.8.9 by Brian Aker
Merge in namespace of enum.
1257
                                 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.
1258
                                 int cuted_increment)
1 by brian
clean slate
1259
{
2114.5.1 by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in
1260
  Session *session= (getTable() and getTable()->getSession()) ? getTable()->getSession() : current_session;
1261
2114.5.2 by Brian Aker
Just remove second ecapsulated method call.
1262
  if (session->abortOnWarning() or
1 by brian
clean slate
1263
      set_warning(level, code, cuted_increment))
1264
  {
2148.5.3 by Brian Aker
Remove hard coded array for numbers (this also fixes a couple of spots where
1265
    char str_nr[DECIMAL_LONGLONG_DIGITS];
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
1266
    char *str_end= internal::int64_t10_to_str(nr, str_nr, -10);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
1267
    make_truncated_value_warning(session, level, str_nr, (uint32_t) (str_end - str_nr),
1 by brian
clean slate
1268
                                 ts_type, field_name);
1269
  }
1270
}
1271
1055.2.6 by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file.
1272
void Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level,
2087.3.1 by Brian Aker
Entire convert over to time_t.
1273
                                 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.
1274
                                 double nr, 
2088.8.9 by Brian Aker
Merge in namespace of enum.
1275
                                 type::timestamp_t ts_type)
1 by brian
clean slate
1276
{
2114.5.1 by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in
1277
  Session *session= (getTable() and getTable()->getSession()) ? getTable()->getSession() : current_session;
1278
2114.5.2 by Brian Aker
Just remove second ecapsulated method call.
1279
  if (session->abortOnWarning() or
1 by brian
clean slate
1280
      set_warning(level, code, 1))
1281
  {
1282
    /* DBL_DIG is enough to print '-[digits].E+###' */
1283
    char str_nr[DBL_DIG + 8];
1366.1.11 by Siddharth Prakash Singh
sprintf->snprintf continued
1284
    uint32_t str_len= snprintf(str_nr, sizeof(str_nr), "%g", nr);
520.1.22 by Brian Aker
Second pass of thd cleanup
1285
    make_truncated_value_warning(session, level, str_nr, str_len, ts_type,
1 by brian
clean slate
1286
                                 field_name);
1287
  }
1288
}
575.4.7 by Monty Taylor
More header cleanup.
1289
2181.2.2 by Brian Aker
This fixes DEBUG based compiles.
1290
bool Field::isReadSet() const 
1003.1.6 by Brian Aker
Added interface for field to get read/write on its own.
1291
{ 
1003.1.12 by Brian Aker
Begin of abstract out the bitmap from direct reference.
1292
  return table->isReadSet(field_index); 
1003.1.6 by Brian Aker
Added interface for field to get read/write on its own.
1293
}
1294
1003.1.9 by Brian Aker
Patches for Jay (aka name changes)
1295
bool Field::isWriteSet()
1003.1.6 by Brian Aker
Added interface for field to get read/write on its own.
1296
{ 
1003.1.12 by Brian Aker
Begin of abstract out the bitmap from direct reference.
1297
  return table->isWriteSet(field_index); 
1003.1.6 by Brian Aker
Added interface for field to get read/write on its own.
1298
}
1089.1.3 by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix
1299
1300
void Field::setReadSet(bool arg)
1301
{
1302
  if (arg)
1303
    table->setReadSet(field_index);
1304
  else
1039.5.42 by Jay Pipes
Splits out the previously aggregated all.test case into separate test
1305
    table->clearReadSet(field_index);
1089.1.3 by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix
1306
}
1307
1308
void Field::setWriteSet(bool arg)
1309
{
1310
  if (arg)
1311
    table->setWriteSet(field_index);
1312
  else
1039.5.42 by Jay Pipes
Splits out the previously aggregated all.test case into separate test
1313
    table->clearWriteSet(field_index);
1089.1.3 by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix
1314
}
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
1315
2016.1.2 by Brian Aker
Fix for Solaris
1316
void Field::pack_num(uint64_t arg, unsigned char *destination)
1317
{
1318
  if (not destination)
1319
    destination= ptr;
1320
2016.1.7 by Brian Aker
Remove MyISAM flip bit, and make sure that we only pass in a good time_t to
1321
  int64_tstore(destination, arg);
2016.1.2 by Brian Aker
Fix for Solaris
1322
}
1323
2046.2.3 by Brian Aker
Add basic tests for microtime.
1324
void Field::pack_num(uint32_t arg, unsigned char *destination)
1325
{
1326
  if (not destination)
1327
    destination= ptr;
1328
1329
  longstore(destination, arg);
1330
}
1331
2016.1.2 by Brian Aker
Fix for Solaris
1332
uint64_t Field::unpack_num(uint64_t &destination, const unsigned char *arg) const
1333
{
1334
  if (not arg)
1335
    arg= ptr;
1336
2016.1.7 by Brian Aker
Remove MyISAM flip bit, and make sure that we only pass in a good time_t to
1337
  int64_tget(destination, arg);
2016.1.2 by Brian Aker
Fix for Solaris
1338
1339
  return destination;
1340
}
1341
2046.2.3 by Brian Aker
Add basic tests for microtime.
1342
uint32_t Field::unpack_num(uint32_t &destination, const unsigned char *arg) const
1343
{
1344
  if (not arg)
1345
    arg= ptr;
1346
1347
  longget(destination, arg);
1348
1349
  return destination;
1350
}
1351
1992.5.1 by Brian Aker
Additional cerr output bits for a few classes (Item, Field,...)
1352
std::ostream& operator<<(std::ostream& output, const Field &field)
1353
{
1354
  output << "Field:(";
1355
  output <<  field.field_name;
1356
  output << ", ";
1357
  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
1358
  output << ", { ";
1359
1360
  if (field.flags & NOT_NULL_FLAG)
1361
    output << " NOT_NULL";
1362
1363
  if (field.flags & PRI_KEY_FLAG)
1364
    output << ", PRIMARY KEY";
1365
1366
  if (field.flags & UNIQUE_KEY_FLAG)
1367
    output << ", UNIQUE KEY";
1368
1369
  if (field.flags & MULTIPLE_KEY_FLAG)
1370
    output << ", MULTIPLE KEY";
1371
1372
  if (field.flags & BLOB_FLAG)
1373
    output << ", BLOB";
1374
1375
  if (field.flags & UNSIGNED_FLAG)
1376
    output << ", UNSIGNED";
1377
1378
  if (field.flags & BINARY_FLAG)
1379
    output << ", BINARY";
1380
  output << "}, ";
1992.5.1 by Brian Aker
Additional cerr output bits for a few classes (Item, Field,...)
1381
  output << ")";
1382
1383
  return output;  // for multiple << operators.
1384
}
1385
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
1386
} /* namespace drizzled */