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 |
*
|
|
4 |
* Copyright (C) 2008 MySQL
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
1
by brian
clean slate |
20 |
|
21 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
22 |
@file
|
1
by brian
clean slate |
23 |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
24 |
@brief
|
25 |
This file implements classes defined in field.h
|
|
1
by brian
clean slate |
26 |
*/
|
243.1.17
by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.) |
27 |
#include <drizzled/server_includes.h> |
1
by brian
clean slate |
28 |
#include "sql_select.h" |
29 |
#include <errno.h> |
|
549
by Monty Taylor
Took gettext.h out of header files. |
30 |
#include <drizzled/error.h> |
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
31 |
#include <drizzled/virtual_column_info.h> |
584.5.1
by Monty Taylor
Removed field includes from field.h. |
32 |
#include <drizzled/field/str.h> |
33 |
#include <drizzled/field/longstr.h> |
|
34 |
#include <drizzled/field/num.h> |
|
35 |
#include <drizzled/field/blob.h> |
|
36 |
#include <drizzled/field/enum.h> |
|
37 |
#include <drizzled/field/null.h> |
|
38 |
#include <drizzled/field/date.h> |
|
670.1.1
by Monty Taylor
Renamed fdecimal.* to decimal.*. Let's see how many things we can break! |
39 |
#include <drizzled/field/decimal.h> |
584.5.1
by Monty Taylor
Removed field includes from field.h. |
40 |
#include <drizzled/field/real.h> |
41 |
#include <drizzled/field/double.h> |
|
42 |
#include <drizzled/field/long.h> |
|
43 |
#include <drizzled/field/int64_t.h> |
|
44 |
#include <drizzled/field/num.h> |
|
45 |
#include <drizzled/field/timestamp.h> |
|
46 |
#include <drizzled/field/datetime.h> |
|
47 |
#include <drizzled/field/varstring.h> |
|
1
by brian
clean slate |
48 |
|
49 |
||
50 |
/*****************************************************************************
|
|
51 |
Instansiate templates and static variables
|
|
52 |
*****************************************************************************/
|
|
53 |
||
54 |
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
|
|
55 |
template class List<Create_field>; |
|
56 |
template class List_iterator<Create_field>; |
|
57 |
#endif
|
|
58 |
||
59 |
||
520.1.25
by Monty Taylor
Removed the split. |
60 |
static enum_field_types |
61 |
field_types_merge_rules [DRIZZLE_TYPE_MAX+1][DRIZZLE_TYPE_MAX+1]= |
|
1
by brian
clean slate |
62 |
{
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
63 |
/* DRIZZLE_TYPE_TINY -> */
|
64 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
65 |
//DRIZZLE_TYPE_TINY
|
520.1.24
by Monty Taylor
Fixed the TINY=1 bit. |
66 |
DRIZZLE_TYPE_TINY, |
520.1.25
by Monty Taylor
Removed the split. |
67 |
//DRIZZLE_TYPE_LONG
|
398
by Brian Aker
Remove short. |
68 |
DRIZZLE_TYPE_LONG, |
520.1.25
by Monty Taylor
Removed the split. |
69 |
//DRIZZLE_TYPE_DOUBLE
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
70 |
DRIZZLE_TYPE_DOUBLE, |
520.1.25
by Monty Taylor
Removed the split. |
71 |
//DRIZZLE_TYPE_NULL
|
72 |
DRIZZLE_TYPE_TINY, |
|
73 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
74 |
DRIZZLE_TYPE_VARCHAR, |
|
75 |
//DRIZZLE_TYPE_LONGLONG
|
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
76 |
DRIZZLE_TYPE_LONGLONG, |
520.1.25
by Monty Taylor
Removed the split. |
77 |
//DRIZZLE_TYPE_DATETIME
|
78 |
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 |
79 |
//DRIZZLE_TYPE_DATE
|
520.1.25
by Monty Taylor
Removed the split. |
80 |
DRIZZLE_TYPE_VARCHAR, |
81 |
//DRIZZLE_TYPE_VARCHAR
|
|
82 |
DRIZZLE_TYPE_VARCHAR, |
|
83 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
84 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
85 |
//DRIZZLE_TYPE_NEWDECIMAL
|
86 |
DRIZZLE_TYPE_NEWDECIMAL, |
|
87 |
//DRIZZLE_TYPE_ENUM
|
|
88 |
DRIZZLE_TYPE_VARCHAR, |
|
89 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
90 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
91 |
},
|
92 |
/* DRIZZLE_TYPE_LONG -> */
|
|
93 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
94 |
//DRIZZLE_TYPE_TINY
|
95 |
DRIZZLE_TYPE_LONG, |
|
96 |
//DRIZZLE_TYPE_LONG
|
|
97 |
DRIZZLE_TYPE_LONG, |
|
98 |
//DRIZZLE_TYPE_DOUBLE
|
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
99 |
DRIZZLE_TYPE_DOUBLE, |
520.1.25
by Monty Taylor
Removed the split. |
100 |
//DRIZZLE_TYPE_NULL
|
101 |
DRIZZLE_TYPE_LONG, |
|
102 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
103 |
DRIZZLE_TYPE_VARCHAR, |
|
104 |
//DRIZZLE_TYPE_LONGLONG
|
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
105 |
DRIZZLE_TYPE_LONGLONG, |
520.1.25
by Monty Taylor
Removed the split. |
106 |
//DRIZZLE_TYPE_DATETIME
|
107 |
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 |
108 |
//DRIZZLE_TYPE_DATE
|
520.1.25
by Monty Taylor
Removed the split. |
109 |
DRIZZLE_TYPE_VARCHAR, |
110 |
//DRIZZLE_TYPE_VARCHAR
|
|
111 |
DRIZZLE_TYPE_VARCHAR, |
|
112 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
113 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
114 |
//DRIZZLE_TYPE_NEWDECIMAL
|
115 |
DRIZZLE_TYPE_NEWDECIMAL, |
|
116 |
//DRIZZLE_TYPE_ENUM
|
|
117 |
DRIZZLE_TYPE_VARCHAR, |
|
118 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
119 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
120 |
},
|
121 |
/* DRIZZLE_TYPE_DOUBLE -> */
|
|
122 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
123 |
//DRIZZLE_TYPE_TINY
|
124 |
DRIZZLE_TYPE_DOUBLE, |
|
125 |
//DRIZZLE_TYPE_LONG
|
|
126 |
DRIZZLE_TYPE_DOUBLE, |
|
127 |
//DRIZZLE_TYPE_DOUBLE
|
|
128 |
DRIZZLE_TYPE_DOUBLE, |
|
129 |
//DRIZZLE_TYPE_NULL
|
|
130 |
DRIZZLE_TYPE_DOUBLE, |
|
131 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
132 |
DRIZZLE_TYPE_VARCHAR, |
|
133 |
//DRIZZLE_TYPE_LONGLONG
|
|
134 |
DRIZZLE_TYPE_DOUBLE, |
|
135 |
//DRIZZLE_TYPE_DATETIME
|
|
136 |
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 |
137 |
//DRIZZLE_TYPE_DATE
|
520.1.25
by Monty Taylor
Removed the split. |
138 |
DRIZZLE_TYPE_VARCHAR, |
139 |
//DRIZZLE_TYPE_VARCHAR
|
|
140 |
DRIZZLE_TYPE_VARCHAR, |
|
141 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
142 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
143 |
//DRIZZLE_TYPE_NEWDECIMAL
|
144 |
DRIZZLE_TYPE_DOUBLE, |
|
145 |
//DRIZZLE_TYPE_ENUM
|
|
146 |
DRIZZLE_TYPE_VARCHAR, |
|
147 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
148 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
149 |
},
|
150 |
/* DRIZZLE_TYPE_NULL -> */
|
|
151 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
152 |
//DRIZZLE_TYPE_TINY
|
520.1.24
by Monty Taylor
Fixed the TINY=1 bit. |
153 |
DRIZZLE_TYPE_TINY, |
520.1.25
by Monty Taylor
Removed the split. |
154 |
//DRIZZLE_TYPE_LONG
|
398
by Brian Aker
Remove short. |
155 |
DRIZZLE_TYPE_LONG, |
520.1.25
by Monty Taylor
Removed the split. |
156 |
//DRIZZLE_TYPE_DOUBLE
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
157 |
DRIZZLE_TYPE_DOUBLE, |
520.1.25
by Monty Taylor
Removed the split. |
158 |
//DRIZZLE_TYPE_NULL
|
159 |
DRIZZLE_TYPE_NULL, |
|
160 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
161 |
DRIZZLE_TYPE_TIMESTAMP, |
|
162 |
//DRIZZLE_TYPE_LONGLONG
|
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
163 |
DRIZZLE_TYPE_LONGLONG, |
520.1.25
by Monty Taylor
Removed the split. |
164 |
//DRIZZLE_TYPE_DATETIME
|
222
by Brian Aker
Remove YEAR field type |
165 |
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 |
166 |
//DRIZZLE_TYPE_DATE
|
167 |
DRIZZLE_TYPE_DATE, |
|
520.1.25
by Monty Taylor
Removed the split. |
168 |
//DRIZZLE_TYPE_VARCHAR
|
169 |
DRIZZLE_TYPE_VARCHAR, |
|
170 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
171 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
172 |
//DRIZZLE_TYPE_NEWDECIMAL
|
173 |
DRIZZLE_TYPE_NEWDECIMAL, |
|
174 |
//DRIZZLE_TYPE_ENUM
|
|
175 |
DRIZZLE_TYPE_ENUM, |
|
176 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
177 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
178 |
},
|
179 |
/* DRIZZLE_TYPE_TIMESTAMP -> */
|
|
180 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
181 |
//DRIZZLE_TYPE_TINY
|
182 |
DRIZZLE_TYPE_VARCHAR, |
|
183 |
//DRIZZLE_TYPE_LONG
|
|
184 |
DRIZZLE_TYPE_VARCHAR, |
|
185 |
//DRIZZLE_TYPE_DOUBLE
|
|
186 |
DRIZZLE_TYPE_VARCHAR, |
|
187 |
//DRIZZLE_TYPE_NULL
|
|
188 |
DRIZZLE_TYPE_TIMESTAMP, |
|
189 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
190 |
DRIZZLE_TYPE_TIMESTAMP, |
|
191 |
//DRIZZLE_TYPE_LONGLONG
|
|
192 |
DRIZZLE_TYPE_VARCHAR, |
|
193 |
//DRIZZLE_TYPE_DATETIME
|
|
194 |
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 |
195 |
//DRIZZLE_TYPE_DATE
|
196 |
DRIZZLE_TYPE_DATE, |
|
520.1.25
by Monty Taylor
Removed the split. |
197 |
//DRIZZLE_TYPE_VARCHAR
|
198 |
DRIZZLE_TYPE_VARCHAR, |
|
199 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
200 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
201 |
//DRIZZLE_TYPE_NEWDECIMAL
|
202 |
DRIZZLE_TYPE_VARCHAR, |
|
203 |
//DRIZZLE_TYPE_ENUM
|
|
204 |
DRIZZLE_TYPE_VARCHAR, |
|
205 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
206 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
207 |
},
|
208 |
/* DRIZZLE_TYPE_LONGLONG -> */
|
|
209 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
210 |
//DRIZZLE_TYPE_TINY
|
211 |
DRIZZLE_TYPE_LONGLONG, |
|
212 |
//DRIZZLE_TYPE_LONG
|
|
213 |
DRIZZLE_TYPE_LONGLONG, |
|
214 |
//DRIZZLE_TYPE_DOUBLE
|
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
215 |
DRIZZLE_TYPE_DOUBLE, |
520.1.25
by Monty Taylor
Removed the split. |
216 |
//DRIZZLE_TYPE_NULL
|
217 |
DRIZZLE_TYPE_LONGLONG, |
|
218 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
219 |
DRIZZLE_TYPE_VARCHAR, |
|
220 |
//DRIZZLE_TYPE_LONGLONG
|
|
221 |
DRIZZLE_TYPE_LONGLONG, |
|
222 |
//DRIZZLE_TYPE_DATETIME
|
|
223 |
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 |
224 |
//DRIZZLE_TYPE_DATE
|
225 |
DRIZZLE_TYPE_DATE, |
|
520.1.25
by Monty Taylor
Removed the split. |
226 |
//DRIZZLE_TYPE_VARCHAR
|
227 |
DRIZZLE_TYPE_VARCHAR, |
|
228 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
229 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
230 |
//DRIZZLE_TYPE_NEWDECIMAL
|
231 |
//DRIZZLE_TYPE_ENUM
|
|
232 |
DRIZZLE_TYPE_NEWDECIMAL, |
|
233 |
DRIZZLE_TYPE_VARCHAR, |
|
234 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
235 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
236 |
},
|
237 |
/* DRIZZLE_TYPE_DATETIME -> */
|
|
238 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
239 |
//DRIZZLE_TYPE_TINY
|
240 |
DRIZZLE_TYPE_VARCHAR, |
|
241 |
//DRIZZLE_TYPE_LONG
|
|
242 |
DRIZZLE_TYPE_VARCHAR, |
|
243 |
//DRIZZLE_TYPE_DOUBLE
|
|
244 |
DRIZZLE_TYPE_VARCHAR, |
|
245 |
//DRIZZLE_TYPE_NULL
|
|
246 |
DRIZZLE_TYPE_DATETIME, |
|
247 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
248 |
DRIZZLE_TYPE_DATETIME, |
|
249 |
//DRIZZLE_TYPE_LONGLONG
|
|
250 |
DRIZZLE_TYPE_VARCHAR, |
|
251 |
//DRIZZLE_TYPE_DATETIME
|
|
252 |
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 |
253 |
//DRIZZLE_TYPE_DATE
|
254 |
DRIZZLE_TYPE_DATE, |
|
520.1.25
by Monty Taylor
Removed the split. |
255 |
//DRIZZLE_TYPE_VARCHAR
|
256 |
DRIZZLE_TYPE_VARCHAR, |
|
257 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
258 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
259 |
//DRIZZLE_TYPE_NEWDECIMAL
|
260 |
DRIZZLE_TYPE_VARCHAR, |
|
261 |
//DRIZZLE_TYPE_ENUM
|
|
262 |
DRIZZLE_TYPE_VARCHAR, |
|
263 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
264 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
265 |
},
|
575.5.1
by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code |
266 |
/* DRIZZLE_TYPE_DATE -> */
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
267 |
{
|
520.1.25
by Monty Taylor
Removed the split. |
268 |
//DRIZZLE_TYPE_TINY
|
269 |
DRIZZLE_TYPE_VARCHAR, |
|
270 |
//DRIZZLE_TYPE_LONG
|
|
271 |
DRIZZLE_TYPE_VARCHAR, |
|
272 |
//DRIZZLE_TYPE_DOUBLE
|
|
273 |
DRIZZLE_TYPE_VARCHAR, |
|
274 |
//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 |
275 |
DRIZZLE_TYPE_DATE, |
520.1.25
by Monty Taylor
Removed the split. |
276 |
//DRIZZLE_TYPE_TIMESTAMP
|
277 |
DRIZZLE_TYPE_DATETIME, |
|
278 |
//DRIZZLE_TYPE_LONGLONG
|
|
279 |
DRIZZLE_TYPE_VARCHAR, |
|
280 |
//DRIZZLE_TYPE_DATETIME
|
|
281 |
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 |
282 |
//DRIZZLE_TYPE_DATE
|
283 |
DRIZZLE_TYPE_DATE, |
|
520.1.25
by Monty Taylor
Removed the split. |
284 |
//DRIZZLE_TYPE_VARCHAR
|
285 |
DRIZZLE_TYPE_VARCHAR, |
|
286 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
287 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
288 |
//DRIZZLE_TYPE_NEWDECIMAL
|
289 |
DRIZZLE_TYPE_VARCHAR, |
|
290 |
//DRIZZLE_TYPE_ENUM
|
|
291 |
DRIZZLE_TYPE_VARCHAR, |
|
292 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
293 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
294 |
},
|
295 |
/* DRIZZLE_TYPE_VARCHAR -> */
|
|
296 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
297 |
//DRIZZLE_TYPE_TINY
|
298 |
DRIZZLE_TYPE_VARCHAR, |
|
299 |
//DRIZZLE_TYPE_LONG
|
|
300 |
DRIZZLE_TYPE_VARCHAR, |
|
301 |
//DRIZZLE_TYPE_DOUBLE
|
|
302 |
DRIZZLE_TYPE_VARCHAR, |
|
303 |
//DRIZZLE_TYPE_NULL
|
|
304 |
DRIZZLE_TYPE_VARCHAR, |
|
305 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
306 |
DRIZZLE_TYPE_VARCHAR, |
|
307 |
//DRIZZLE_TYPE_LONGLONG
|
|
308 |
DRIZZLE_TYPE_VARCHAR, |
|
309 |
//DRIZZLE_TYPE_DATETIME
|
|
310 |
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 |
311 |
//DRIZZLE_TYPE_DATE
|
520.1.25
by Monty Taylor
Removed the split. |
312 |
DRIZZLE_TYPE_VARCHAR, |
313 |
//DRIZZLE_TYPE_VARCHAR
|
|
314 |
DRIZZLE_TYPE_VARCHAR, |
|
315 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
316 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
317 |
//DRIZZLE_TYPE_NEWDECIMAL
|
318 |
DRIZZLE_TYPE_VARCHAR, |
|
319 |
//DRIZZLE_TYPE_ENUM
|
|
320 |
DRIZZLE_TYPE_VARCHAR, |
|
321 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
322 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
323 |
},
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
324 |
/* DRIZZLE_TYPE_VIRTUAL -> */
|
325 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
326 |
//DRIZZLE_TYPE_TINY
|
327 |
DRIZZLE_TYPE_VIRTUAL, |
|
328 |
//DRIZZLE_TYPE_LONG
|
|
329 |
DRIZZLE_TYPE_VIRTUAL, |
|
330 |
//DRIZZLE_TYPE_DOUBLE
|
|
331 |
DRIZZLE_TYPE_VIRTUAL, |
|
332 |
//DRIZZLE_TYPE_NULL
|
|
333 |
DRIZZLE_TYPE_VIRTUAL, |
|
334 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
335 |
DRIZZLE_TYPE_VIRTUAL, |
|
336 |
//DRIZZLE_TYPE_LONGLONG
|
|
337 |
DRIZZLE_TYPE_VIRTUAL, |
|
338 |
//DRIZZLE_TYPE_DATETIME
|
|
339 |
DRIZZLE_TYPE_VIRTUAL, |
|
575.5.1
by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code |
340 |
//DRIZZLE_TYPE_DATE
|
520.1.25
by Monty Taylor
Removed the split. |
341 |
DRIZZLE_TYPE_VIRTUAL, |
342 |
//DRIZZLE_TYPE_VARCHAR
|
|
343 |
DRIZZLE_TYPE_VIRTUAL, |
|
344 |
//DRIZZLE_TYPE_VIRTUAL
|
|
345 |
DRIZZLE_TYPE_VIRTUAL, |
|
346 |
//DRIZZLE_TYPE_NEWDECIMAL
|
|
347 |
DRIZZLE_TYPE_VIRTUAL, |
|
348 |
//DRIZZLE_TYPE_ENUM
|
|
349 |
DRIZZLE_TYPE_VIRTUAL, |
|
350 |
//DRIZZLE_TYPE_BLOB
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
351 |
DRIZZLE_TYPE_VIRTUAL, |
352 |
},
|
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
353 |
/* DRIZZLE_TYPE_NEWDECIMAL -> */
|
354 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
355 |
//DRIZZLE_TYPE_TINY
|
356 |
DRIZZLE_TYPE_NEWDECIMAL, |
|
357 |
//DRIZZLE_TYPE_LONG
|
|
358 |
DRIZZLE_TYPE_NEWDECIMAL, |
|
359 |
//DRIZZLE_TYPE_DOUBLE
|
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
360 |
DRIZZLE_TYPE_DOUBLE, |
520.1.25
by Monty Taylor
Removed the split. |
361 |
//DRIZZLE_TYPE_NULL
|
362 |
DRIZZLE_TYPE_NEWDECIMAL, |
|
363 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
364 |
DRIZZLE_TYPE_VARCHAR, |
|
365 |
//DRIZZLE_TYPE_LONGLONG
|
|
366 |
DRIZZLE_TYPE_NEWDECIMAL, |
|
367 |
//DRIZZLE_TYPE_DATETIME
|
|
368 |
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 |
369 |
//DRIZZLE_TYPE_DATE
|
520.1.25
by Monty Taylor
Removed the split. |
370 |
DRIZZLE_TYPE_VARCHAR, |
371 |
//DRIZZLE_TYPE_VARCHAR
|
|
372 |
DRIZZLE_TYPE_VARCHAR, |
|
373 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
374 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
375 |
//DRIZZLE_TYPE_NEWDECIMAL
|
376 |
DRIZZLE_TYPE_NEWDECIMAL, |
|
377 |
//DRIZZLE_TYPE_ENUM
|
|
378 |
DRIZZLE_TYPE_VARCHAR, |
|
379 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
380 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
381 |
},
|
382 |
/* DRIZZLE_TYPE_ENUM -> */
|
|
383 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
384 |
//DRIZZLE_TYPE_TINY
|
385 |
DRIZZLE_TYPE_VARCHAR, |
|
386 |
//DRIZZLE_TYPE_LONG
|
|
387 |
DRIZZLE_TYPE_VARCHAR, |
|
388 |
//DRIZZLE_TYPE_DOUBLE
|
|
389 |
DRIZZLE_TYPE_VARCHAR, |
|
390 |
//DRIZZLE_TYPE_NULL
|
|
391 |
DRIZZLE_TYPE_ENUM, |
|
392 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
393 |
DRIZZLE_TYPE_VARCHAR, |
|
394 |
//DRIZZLE_TYPE_LONGLONG
|
|
395 |
DRIZZLE_TYPE_VARCHAR, |
|
396 |
//DRIZZLE_TYPE_DATETIME
|
|
397 |
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 |
398 |
//DRIZZLE_TYPE_DATE
|
520.1.25
by Monty Taylor
Removed the split. |
399 |
DRIZZLE_TYPE_VARCHAR, |
400 |
//DRIZZLE_TYPE_VARCHAR
|
|
401 |
DRIZZLE_TYPE_VARCHAR, |
|
402 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
403 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
404 |
//DRIZZLE_TYPE_NEWDECIMAL
|
405 |
DRIZZLE_TYPE_VARCHAR, |
|
406 |
//DRIZZLE_TYPE_ENUM
|
|
407 |
DRIZZLE_TYPE_VARCHAR, |
|
408 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
409 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
410 |
},
|
411 |
/* DRIZZLE_TYPE_BLOB -> */
|
|
412 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
413 |
//DRIZZLE_TYPE_TINY
|
414 |
DRIZZLE_TYPE_BLOB, |
|
415 |
//DRIZZLE_TYPE_LONG
|
|
416 |
DRIZZLE_TYPE_BLOB, |
|
417 |
//DRIZZLE_TYPE_DOUBLE
|
|
418 |
DRIZZLE_TYPE_BLOB, |
|
419 |
//DRIZZLE_TYPE_NULL
|
|
420 |
DRIZZLE_TYPE_BLOB, |
|
421 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
422 |
DRIZZLE_TYPE_BLOB, |
|
423 |
//DRIZZLE_TYPE_LONGLONG
|
|
424 |
DRIZZLE_TYPE_BLOB, |
|
425 |
//DRIZZLE_TYPE_DATETIME
|
|
426 |
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 |
427 |
//DRIZZLE_TYPE_DATE
|
520.1.25
by Monty Taylor
Removed the split. |
428 |
DRIZZLE_TYPE_BLOB, |
429 |
//DRIZZLE_TYPE_VARCHAR
|
|
430 |
DRIZZLE_TYPE_BLOB, |
|
431 |
//DRIZZLE_TYPE_VIRTUAL
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
432 |
DRIZZLE_TYPE_VIRTUAL, |
520.1.25
by Monty Taylor
Removed the split. |
433 |
//DRIZZLE_TYPE_NEWDECIMAL
|
434 |
DRIZZLE_TYPE_BLOB, |
|
435 |
//DRIZZLE_TYPE_ENUM
|
|
436 |
DRIZZLE_TYPE_BLOB, |
|
437 |
//DRIZZLE_TYPE_BLOB
|
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
438 |
DRIZZLE_TYPE_BLOB, |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
439 |
},
|
1
by brian
clean slate |
440 |
};
|
441 |
||
442 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
443 |
Return type of which can carry value of both given types in UNION result.
|
444 |
||
445 |
@param a type for merging
|
|
446 |
@param b type for merging
|
|
447 |
||
448 |
@return
|
|
449 |
type of field
|
|
1
by brian
clean slate |
450 |
*/
|
451 |
||
452 |
enum_field_types Field::field_type_merge(enum_field_types a, |
|
453 |
enum_field_types b) |
|
454 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
455 |
assert(a <= DRIZZLE_TYPE_MAX); |
456 |
assert(b <= DRIZZLE_TYPE_MAX); |
|
457 |
return field_types_merge_rules[a][b]; |
|
1
by brian
clean slate |
458 |
}
|
459 |
||
460 |
||
520.1.25
by Monty Taylor
Removed the split. |
461 |
static Item_result field_types_result_type [DRIZZLE_TYPE_MAX+1]= |
1
by brian
clean slate |
462 |
{
|
520.1.24
by Monty Taylor
Fixed the TINY=1 bit. |
463 |
//DRIZZLE_TYPE_TINY
|
464 |
INT_RESULT, |
|
398
by Brian Aker
Remove short. |
465 |
//DRIZZLE_TYPE_LONG
|
466 |
INT_RESULT, |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
467 |
//DRIZZLE_TYPE_DOUBLE
|
166
by Brian Aker
Removal of FLOAT type |
468 |
REAL_RESULT, |
520.1.26
by Monty Taylor
Fixed some formatting. |
469 |
//DRIZZLE_TYPE_NULL
|
470 |
STRING_RESULT, |
|
471 |
//DRIZZLE_TYPE_TIMESTAMP
|
|
472 |
STRING_RESULT, |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
473 |
//DRIZZLE_TYPE_LONGLONG
|
167
by Brian Aker
Remove old 3byte int |
474 |
INT_RESULT, |
222
by Brian Aker
Remove YEAR field type |
475 |
//DRIZZLE_TYPE_DATETIME
|
476 |
STRING_RESULT, |
|
575.5.1
by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code |
477 |
//DRIZZLE_TYPE_DATE
|
520.1.26
by Monty Taylor
Fixed some formatting. |
478 |
STRING_RESULT, |
479 |
//DRIZZLE_TYPE_VARCHAR
|
|
480 |
STRING_RESULT, |
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
481 |
//DRIZZLE_TYPE_VIRTUAL
|
482 |
STRING_RESULT, |
|
896.5.1
by Jay Pipes
Removes the TIME column type and related time functions. |
483 |
//DRIZZLE_TYPE_NEWDECIMAL
|
484 |
DECIMAL_RESULT, |
|
485 |
//DRIZZLE_TYPE_ENUM
|
|
486 |
STRING_RESULT, |
|
240
by Brian Aker
Removed old/dead VARCHAR type from pre-5.0 |
487 |
//DRIZZLE_TYPE_BLOB
|
488 |
STRING_RESULT, |
|
1
by brian
clean slate |
489 |
};
|
490 |
||
491 |
||
492 |
/*
|
|
493 |
Test if the given string contains important data:
|
|
494 |
not spaces for character string,
|
|
495 |
or any data for binary string.
|
|
496 |
||
497 |
SYNOPSIS
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
498 |
test_if_important_data()
|
499 |
cs Character set
|
|
500 |
str String to test
|
|
501 |
strend String end
|
|
1
by brian
clean slate |
502 |
|
503 |
RETURN
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
504 |
false - If string does not have important data
|
505 |
true - If string has some important data
|
|
1
by brian
clean slate |
506 |
*/
|
507 |
||
483.1.4
by Lee
break out Field_longstr |
508 |
bool
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
509 |
test_if_important_data(const CHARSET_INFO * const cs, const char *str, |
510 |
const char *strend) |
|
1
by brian
clean slate |
511 |
{
|
512 |
if (cs != &my_charset_bin) |
|
513 |
str+= cs->cset->scan(cs, str, strend, MY_SEQ_SPACES); |
|
514 |
return (str < strend); |
|
515 |
}
|
|
516 |
||
517 |
||
518 |
Item_result Field::result_merge_type(enum_field_types field_type) |
|
519 |
{
|
|
520.1.25
by Monty Taylor
Removed the split. |
520 |
assert(field_type <= DRIZZLE_TYPE_MAX); |
521 |
return field_types_result_type[field_type]; |
|
1
by brian
clean slate |
522 |
}
|
523 |
||
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
524 |
|
525 |
bool Field::eq(Field *field) |
|
526 |
{
|
|
527 |
return (ptr == field->ptr && null_ptr == field->null_ptr && |
|
528 |
null_bit == field->null_bit); |
|
529 |
}
|
|
530 |
||
531 |
||
532 |
uint32_t Field::pack_length() const |
|
533 |
{
|
|
534 |
return field_length; |
|
535 |
}
|
|
536 |
||
537 |
||
538 |
uint32_t Field::pack_length_in_rec() const |
|
539 |
{
|
|
540 |
return pack_length(); |
|
541 |
}
|
|
542 |
||
543 |
||
544 |
uint32_t Field::pack_length_from_metadata(uint32_t field_metadata) |
|
545 |
{
|
|
546 |
return field_metadata; |
|
547 |
}
|
|
548 |
||
549 |
||
550 |
uint32_t Field::row_pack_length() |
|
551 |
{
|
|
552 |
return 0; |
|
553 |
}
|
|
554 |
||
555 |
||
556 |
int Field::save_field_metadata(unsigned char *first_byte) |
|
557 |
{
|
|
558 |
return do_save_field_metadata(first_byte); |
|
559 |
}
|
|
560 |
||
561 |
||
562 |
uint32_t Field::data_length() |
|
563 |
{
|
|
564 |
return pack_length(); |
|
565 |
}
|
|
566 |
||
567 |
||
568 |
uint32_t Field::used_length() |
|
569 |
{
|
|
570 |
return pack_length(); |
|
571 |
}
|
|
572 |
||
573 |
||
574 |
uint32_t Field::sort_length() const |
|
575 |
{
|
|
576 |
return pack_length(); |
|
577 |
}
|
|
578 |
||
579 |
||
580 |
uint32_t Field::max_data_length() const |
|
581 |
{
|
|
582 |
return pack_length(); |
|
583 |
}
|
|
584 |
||
585 |
||
586 |
int Field::reset(void) |
|
587 |
{
|
|
588 |
memset(ptr, 0, pack_length()); |
|
589 |
return 0; |
|
590 |
}
|
|
591 |
||
592 |
||
593 |
void Field::reset_fields() |
|
594 |
{}
|
|
595 |
||
596 |
||
597 |
void Field::set_default() |
|
598 |
{
|
|
599 |
my_ptrdiff_t l_offset= (my_ptrdiff_t) (table->getDefaultValues() - table->record[0]); |
|
600 |
memcpy(ptr, ptr + l_offset, pack_length()); |
|
601 |
if (null_ptr) |
|
602 |
*null_ptr= ((*null_ptr & (unsigned char) ~null_bit) | (null_ptr[l_offset] & null_bit)); |
|
603 |
}
|
|
604 |
||
605 |
||
606 |
bool Field::binary() const |
|
607 |
{
|
|
608 |
return 1; |
|
609 |
}
|
|
610 |
||
611 |
||
612 |
bool Field::zero_pack() const |
|
613 |
{
|
|
614 |
return 1; |
|
615 |
}
|
|
616 |
||
617 |
||
618 |
enum ha_base_keytype Field::key_type() const |
|
619 |
{
|
|
620 |
return HA_KEYTYPE_BINARY; |
|
621 |
}
|
|
622 |
||
623 |
||
624 |
uint32_t Field::key_length() const |
|
625 |
{
|
|
626 |
return pack_length(); |
|
627 |
}
|
|
628 |
||
629 |
||
630 |
enum_field_types Field::real_type() const |
|
631 |
{
|
|
632 |
return type(); |
|
633 |
}
|
|
634 |
||
635 |
||
636 |
int Field::cmp_max(const unsigned char *a, const unsigned char *b, uint32_t) |
|
637 |
{
|
|
638 |
return cmp(a, b); |
|
639 |
}
|
|
640 |
||
641 |
||
642 |
int Field::cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t) |
|
643 |
{
|
|
644 |
return memcmp(a,b,pack_length()); |
|
645 |
}
|
|
646 |
||
647 |
||
648 |
int Field::cmp_offset(uint32_t row_offset) |
|
649 |
{
|
|
650 |
return cmp(ptr,ptr+row_offset); |
|
651 |
}
|
|
652 |
||
653 |
||
654 |
int Field::cmp_binary_offset(uint32_t row_offset) |
|
655 |
{
|
|
656 |
return cmp_binary(ptr, ptr+row_offset); |
|
657 |
}
|
|
658 |
||
659 |
||
660 |
int Field::key_cmp(const unsigned char *a,const unsigned char *b) |
|
661 |
{
|
|
662 |
return cmp(a, b); |
|
663 |
}
|
|
664 |
||
665 |
||
666 |
int Field::key_cmp(const unsigned char *str, uint32_t) |
|
667 |
{
|
|
668 |
return cmp(ptr,str); |
|
669 |
}
|
|
670 |
||
671 |
||
672 |
uint32_t Field::decimals() const |
|
673 |
{
|
|
674 |
return 0; |
|
675 |
}
|
|
676 |
||
677 |
||
678 |
bool Field::is_null(my_ptrdiff_t row_offset) |
|
679 |
{
|
|
680 |
return null_ptr ? |
|
681 |
(null_ptr[row_offset] & null_bit ? true : false) : |
|
682 |
table->null_row; |
|
683 |
}
|
|
684 |
||
685 |
||
686 |
bool Field::is_real_null(my_ptrdiff_t row_offset) |
|
687 |
{
|
|
688 |
return null_ptr ? (null_ptr[row_offset] & null_bit ? true : false) : false; |
|
689 |
}
|
|
690 |
||
691 |
||
692 |
bool Field::is_null_in_record(const unsigned char *record) |
|
693 |
{
|
|
694 |
if (!null_ptr) |
|
695 |
return false; |
|
696 |
return test(record[(uint32_t) (null_ptr -table->record[0])] & |
|
697 |
null_bit); |
|
698 |
}
|
|
699 |
||
700 |
||
779.3.10
by Monty Taylor
Turned on -Wshadow. |
701 |
bool Field::is_null_in_record_with_offset(my_ptrdiff_t with_offset) |
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
702 |
{
|
703 |
if (!null_ptr) |
|
704 |
return false; |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
705 |
return 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. |
706 |
}
|
707 |
||
708 |
||
709 |
void Field::set_null(my_ptrdiff_t row_offset) |
|
710 |
{
|
|
711 |
if (null_ptr) |
|
712 |
null_ptr[row_offset]|= null_bit; |
|
713 |
}
|
|
714 |
||
715 |
||
716 |
void Field::set_notnull(my_ptrdiff_t row_offset) |
|
717 |
{
|
|
718 |
if (null_ptr) |
|
719 |
null_ptr[row_offset]&= (unsigned char) ~null_bit; |
|
720 |
}
|
|
721 |
||
722 |
||
723 |
bool Field::maybe_null(void) |
|
724 |
{
|
|
725 |
return null_ptr != 0 || table->maybe_null; |
|
726 |
}
|
|
727 |
||
728 |
||
729 |
bool Field::real_maybe_null(void) |
|
730 |
{
|
|
731 |
return null_ptr != 0; |
|
732 |
}
|
|
733 |
||
734 |
||
735 |
size_t Field::last_null_byte() const |
|
736 |
{
|
|
737 |
size_t bytes= do_last_null_byte(); |
|
738 |
assert(bytes <= table->getNullBytes()); |
|
739 |
return bytes; |
|
740 |
}
|
|
741 |
||
742 |
||
1
by brian
clean slate |
743 |
/*****************************************************************************
|
744 |
Static help functions
|
|
745 |
*****************************************************************************/
|
|
746 |
||
747 |
bool Field::type_can_have_key_part(enum enum_field_types type) |
|
748 |
{
|
|
749 |
switch (type) { |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
750 |
case DRIZZLE_TYPE_VARCHAR: |
751 |
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 |
752 |
return true; |
1
by brian
clean slate |
753 |
default: |
51.1.56
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on field.h/cc |
754 |
return false; |
1
by brian
clean slate |
755 |
}
|
756 |
}
|
|
757 |
||
758 |
||
759 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
760 |
Process decimal library return codes and issue warnings for overflow and
|
761 |
truncation.
|
|
762 |
||
763 |
@param op_result decimal library return code (E_DEC_* see include/decimal.h)
|
|
764 |
||
765 |
@retval
|
|
766 |
1 there was overflow
|
|
767 |
@retval
|
|
768 |
0 no error or some other errors except overflow
|
|
1
by brian
clean slate |
769 |
*/
|
770 |
||
771 |
int Field::warn_if_overflow(int op_result) |
|
772 |
{
|
|
773 |
if (op_result == E_DEC_OVERFLOW) |
|
774 |
{
|
|
261.4.1
by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR. |
775 |
set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1
by brian
clean slate |
776 |
return 1; |
777 |
}
|
|
778 |
if (op_result == E_DEC_TRUNCATED) |
|
779 |
{
|
|
261.4.1
by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR. |
780 |
set_warning(DRIZZLE_ERROR::WARN_LEVEL_NOTE, ER_WARN_DATA_TRUNCATED, 1); |
1
by brian
clean slate |
781 |
/* We return 0 here as this is not a critical issue */
|
782 |
}
|
|
783 |
return 0; |
|
784 |
}
|
|
785 |
||
786 |
||
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
787 |
void Field::init(Table *table_arg) |
788 |
{
|
|
789 |
orig_table= table= table_arg; |
|
790 |
table_name= &table_arg->alias; |
|
791 |
}
|
|
792 |
||
793 |
||
1
by brian
clean slate |
794 |
#ifdef NOT_USED
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
795 |
static bool test_if_real(const char *str,int length, const CHARSET_INFO * const cs) |
1
by brian
clean slate |
796 |
{
|
797 |
cs= system_charset_info; // QQ move test_if_real into CHARSET_INFO struct |
|
798 |
||
799 |
while (length && my_isspace(cs,*str)) |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
800 |
{ // Allow start space |
1
by brian
clean slate |
801 |
length--; str++; |
802 |
}
|
|
803 |
if (!length) |
|
804 |
return 0; |
|
805 |
if (*str == '+' || *str == '-') |
|
806 |
{
|
|
807 |
length--; str++; |
|
808 |
if (!length || !(my_isdigit(cs,*str) || *str == '.')) |
|
809 |
return 0; |
|
810 |
}
|
|
811 |
while (length && my_isdigit(cs,*str)) |
|
812 |
{
|
|
813 |
length--; str++; |
|
814 |
}
|
|
815 |
if (!length) |
|
816 |
return 1; |
|
817 |
if (*str == '.') |
|
818 |
{
|
|
819 |
length--; str++; |
|
820 |
while (length && my_isdigit(cs,*str)) |
|
821 |
{
|
|
822 |
length--; str++; |
|
823 |
}
|
|
824 |
}
|
|
825 |
if (!length) |
|
826 |
return 1; |
|
827 |
if (*str == 'E' || *str == 'e') |
|
828 |
{
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
829 |
if (length < 3 || (str[1] != '+' && str[1] != '-') || |
1
by brian
clean slate |
830 |
!my_isdigit(cs,str[2])) |
831 |
return 0; |
|
832 |
length-=3; |
|
833 |
str+=3; |
|
834 |
while (length && my_isdigit(cs,*str)) |
|
835 |
{
|
|
836 |
length--; str++; |
|
837 |
}
|
|
838 |
}
|
|
839 |
for (; length ; length--, str++) |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
840 |
{ // Allow end space |
1
by brian
clean slate |
841 |
if (!my_isspace(cs,*str)) |
842 |
return 0; |
|
843 |
}
|
|
844 |
return 1; |
|
845 |
}
|
|
846 |
#endif
|
|
847 |
||
848 |
||
849 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
850 |
Interpret field value as an integer but return the result as a string.
|
1
by brian
clean slate |
851 |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
852 |
This is used for printing bit_fields as numbers while debugging.
|
1
by brian
clean slate |
853 |
*/
|
854 |
||
275
by Brian Aker
Full removal of my_bool from central server. |
855 |
String *Field::val_int_as_str(String *val_buffer, bool unsigned_val) |
1
by brian
clean slate |
856 |
{
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
857 |
const CHARSET_INFO * const cs= &my_charset_bin; |
438.1.13
by Brian Aker
uint cleanup. |
858 |
uint32_t length; |
152
by Brian Aker
longlong replacement |
859 |
int64_t value= val_int(); |
1
by brian
clean slate |
860 |
|
861 |
if (val_buffer->alloc(MY_INT64_NUM_DECIMAL_DIGITS)) |
|
862 |
return 0; |
|
438.1.13
by Brian Aker
uint cleanup. |
863 |
length= (uint32_t) (*cs->cset->int64_t10_to_str)(cs, (char*) val_buffer->ptr(), |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
864 |
MY_INT64_NUM_DECIMAL_DIGITS, |
865 |
unsigned_val ? 10 : -10, |
|
866 |
value); |
|
1
by brian
clean slate |
867 |
val_buffer->length(length); |
868 |
return val_buffer; |
|
869 |
}
|
|
870 |
||
871 |
||
872 |
/// This is used as a table name when the table structure is not set up
|
|
481
by Brian Aker
Remove all of uchar. |
873 |
Field::Field(unsigned char *ptr_arg,uint32_t length_arg,unsigned char *null_ptr_arg, |
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
874 |
unsigned char null_bit_arg, |
875 |
utype unireg_check_arg, const char *field_name_arg) |
|
1
by brian
clean slate |
876 |
:ptr(ptr_arg), null_ptr(null_ptr_arg), |
877 |
table(0), orig_table(0), table_name(0), |
|
878 |
field_name(field_name_arg), |
|
879 |
key_start(0), part_of_key(0), part_of_key_not_clustered(0), |
|
880 |
part_of_sortkey(0), unireg_check(unireg_check_arg), |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
881 |
field_length(length_arg), null_bit(null_bit_arg), |
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
882 |
is_created_from_null_item(false), |
883 |
vcol_info(NULL), is_stored(true) |
|
1
by brian
clean slate |
884 |
{
|
885 |
flags=null_ptr ? 0: NOT_NULL_FLAG; |
|
886 |
comment.str= (char*) ""; |
|
887 |
comment.length=0; |
|
888 |
field_index= 0; |
|
889 |
}
|
|
890 |
||
891 |
||
290
by Brian Aker
Update for ulong change over. |
892 |
void Field::hash(uint32_t *nr, uint32_t *nr2) |
1
by brian
clean slate |
893 |
{
|
894 |
if (is_null()) |
|
895 |
{
|
|
896 |
*nr^= (*nr << 1) | 1; |
|
897 |
}
|
|
898 |
else
|
|
899 |
{
|
|
438.1.13
by Brian Aker
uint cleanup. |
900 |
uint32_t len= pack_length(); |
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
901 |
const CHARSET_INFO * const cs= charset(); |
1
by brian
clean slate |
902 |
cs->coll->hash_sort(cs, ptr, len, nr, nr2); |
903 |
}
|
|
904 |
}
|
|
905 |
||
906 |
size_t
|
|
907 |
Field::do_last_null_byte() const |
|
908 |
{
|
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
909 |
assert(null_ptr == NULL || null_ptr >= table->record[0]); |
1
by brian
clean slate |
910 |
if (null_ptr) |
911 |
return (size_t) (null_ptr - table->record[0]) + 1; |
|
912 |
return LAST_NULL_BYTE_UNDEF; |
|
913 |
}
|
|
914 |
||
915 |
||
916 |
void Field::copy_from_tmp(int row_offset) |
|
917 |
{
|
|
918 |
memcpy(ptr,ptr+row_offset,pack_length()); |
|
919 |
if (null_ptr) |
|
920 |
{
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
921 |
*null_ptr= (unsigned char) ((null_ptr[0] & |
922 |
(unsigned char) ~(uint32_t) null_bit) | |
|
923 |
(null_ptr[row_offset] & |
|
924 |
(unsigned char) null_bit)); |
|
1
by brian
clean slate |
925 |
}
|
926 |
}
|
|
927 |
||
928 |
/**
|
|
929 |
Check to see if field size is compatible with destination.
|
|
930 |
||
931 |
This method is used in row-based replication to verify that the slave's
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
932 |
field size is less than or equal to the master's field size. The
|
1
by brian
clean slate |
933 |
encoded field metadata (from the master or source) is decoded and compared
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
934 |
to the size of this field (the slave or destination).
|
1
by brian
clean slate |
935 |
|
936 |
@param field_metadata Encoded size in field metadata
|
|
937 |
||
938 |
@retval 0 if this field's size is < the source field's size
|
|
939 |
@retval 1 if this field's size is >= the source field's size
|
|
940 |
*/
|
|
438.1.13
by Brian Aker
uint cleanup. |
941 |
int Field::compatible_field_size(uint32_t field_metadata) |
1
by brian
clean slate |
942 |
{
|
438.1.13
by Brian Aker
uint cleanup. |
943 |
uint32_t const source_size= pack_length_from_metadata(field_metadata); |
944 |
uint32_t const destination_size= row_pack_length(); |
|
1
by brian
clean slate |
945 |
return (source_size <= destination_size); |
946 |
}
|
|
947 |
||
948 |
||
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
949 |
int Field::store(const char *to, uint32_t length, |
950 |
const CHARSET_INFO * const cs, |
|
1
by brian
clean slate |
951 |
enum_check_fields check_level) |
952 |
{
|
|
953 |
int res; |
|
954 |
enum_check_fields old_check_level= table->in_use->count_cuted_fields; |
|
955 |
table->in_use->count_cuted_fields= check_level; |
|
956 |
res= store(to, length, cs); |
|
957 |
table->in_use->count_cuted_fields= old_check_level; |
|
958 |
return res; |
|
959 |
}
|
|
960 |
||
961 |
||
962 |
/**
|
|
963 |
Pack the field into a format suitable for storage and transfer.
|
|
964 |
||
965 |
To implement packing functionality, only the virtual function
|
|
966 |
should be overridden. The other functions are just convenience
|
|
967 |
functions and hence should not be overridden.
|
|
968 |
||
969 |
The value of <code>low_byte_first</code> is dependent on how the
|
|
970 |
packed data is going to be used: for local use, e.g., temporary
|
|
971 |
store on disk or in memory, use the native format since that is
|
|
972 |
faster. For data that is going to be transfered to other machines
|
|
973 |
(e.g., when writing data to the binary log), data should always be
|
|
974 |
stored in little-endian format.
|
|
975 |
||
976 |
@note The default method for packing fields just copy the raw bytes
|
|
977 |
of the record into the destination, but never more than
|
|
978 |
<code>max_length</code> characters.
|
|
979 |
||
980 |
@param to
|
|
981 |
Pointer to memory area where representation of field should be put.
|
|
982 |
||
983 |
@param from
|
|
984 |
Pointer to memory area where record representation of field is
|
|
985 |
stored.
|
|
986 |
||
987 |
@param max_length
|
|
988 |
Maximum length of the field, as given in the column definition. For
|
|
989 |
example, for <code>CHAR(1000)</code>, the <code>max_length</code>
|
|
990 |
is 1000. This information is sometimes needed to decide how to pack
|
|
991 |
the data.
|
|
992 |
||
993 |
@param low_byte_first
|
|
51.1.56
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on field.h/cc |
994 |
@c true if integers should be stored little-endian, @c false if
|
1
by brian
clean slate |
995 |
native format should be used. Note that for little-endian machines,
|
996 |
the value of this flag is a moot point since the native format is
|
|
997 |
little-endian.
|
|
998 |
*/
|
|
481
by Brian Aker
Remove all of uchar. |
999 |
unsigned char * |
1000 |
Field::pack(unsigned char *to, const unsigned char *from, uint32_t max_length, |
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1001 |
bool) |
1
by brian
clean slate |
1002 |
{
|
205
by Brian Aker
uint32 -> uin32_t |
1003 |
uint32_t length= pack_length(); |
1
by brian
clean slate |
1004 |
set_if_smaller(length, max_length); |
1005 |
memcpy(to, from, length); |
|
1006 |
return to+length; |
|
1007 |
}
|
|
1008 |
||
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
1009 |
|
1010 |
unsigned char *Field::pack(unsigned char *to, const unsigned char *from) |
|
1011 |
{
|
|
1012 |
unsigned char *result= this->pack(to, from, UINT32_MAX, |
|
1013 |
table->s->db_low_byte_first); |
|
1014 |
return(result); |
|
1015 |
}
|
|
1016 |
||
1017 |
||
1
by brian
clean slate |
1018 |
/**
|
1019 |
Unpack a field from row data.
|
|
1020 |
||
1021 |
This method is used to unpack a field from a master whose size of
|
|
1022 |
the field is less than that of the slave.
|
|
1023 |
||
1024 |
The <code>param_data</code> parameter is a two-byte integer (stored
|
|
1025 |
in the least significant 16 bits of the unsigned integer) usually
|
|
1026 |
consisting of two parts: the real type in the most significant byte
|
|
1027 |
and a original pack length in the least significant byte.
|
|
1028 |
||
1029 |
The exact layout of the <code>param_data</code> field is given by
|
|
1030 |
the <code>Table_map_log_event::save_field_metadata()</code>.
|
|
1031 |
||
1032 |
This is the default method for unpacking a field. It just copies
|
|
1033 |
the memory block in byte order (of original pack length bytes or
|
|
1034 |
length of field, whichever is smaller).
|
|
1035 |
||
1036 |
@param to Destination of the data
|
|
1037 |
@param from Source of the data
|
|
1038 |
@param param_data Real type and original pack length of the field
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1039 |
data
|
1
by brian
clean slate |
1040 |
|
1041 |
@param low_byte_first
|
|
1042 |
If this flag is @c true, all composite entities (e.g., lengths)
|
|
1043 |
should be unpacked in little-endian format; otherwise, the entities
|
|
1044 |
are unpacked in native order.
|
|
1045 |
||
1046 |
@return New pointer into memory based on from + length of the data
|
|
1047 |
*/
|
|
481
by Brian Aker
Remove all of uchar. |
1048 |
const unsigned char * |
1049 |
Field::unpack(unsigned char* to, const unsigned char *from, uint32_t param_data, |
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1050 |
bool) |
1
by brian
clean slate |
1051 |
{
|
438.1.13
by Brian Aker
uint cleanup. |
1052 |
uint32_t length=pack_length(); |
1
by brian
clean slate |
1053 |
int from_type= 0; |
1054 |
/*
|
|
1055 |
If from length is > 255, it has encoded data in the upper bits. Need
|
|
1056 |
to mask it out.
|
|
1057 |
*/
|
|
1058 |
if (param_data > 255) |
|
1059 |
{
|
|
1060 |
from_type= (param_data & 0xff00) >> 8U; // real_type. |
|
1061 |
param_data= param_data & 0x00ff; // length. |
|
1062 |
}
|
|
1063 |
||
1064 |
if ((param_data == 0) || |
|
1065 |
(length == param_data) || |
|
1066 |
(from_type != real_type())) |
|
1067 |
{
|
|
1068 |
memcpy(to, from, length); |
|
1069 |
return from+length; |
|
1070 |
}
|
|
1071 |
||
438.1.13
by Brian Aker
uint cleanup. |
1072 |
uint32_t len= (param_data && (param_data < length)) ? |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1073 |
param_data : length; |
1
by brian
clean slate |
1074 |
|
1075 |
memcpy(to, from, param_data > length ? length : len); |
|
1076 |
return from+len; |
|
1077 |
}
|
|
1078 |
||
1079 |
||
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
1080 |
const unsigned char *Field::unpack(unsigned char* to, |
1081 |
const unsigned char *from) |
|
1082 |
{
|
|
1083 |
const unsigned char *result= unpack(to, from, 0U, |
|
1084 |
table->s->db_low_byte_first); |
|
1085 |
return(result); |
|
1086 |
}
|
|
1087 |
||
1088 |
||
1089 |
uint32_t Field::packed_col_length(const unsigned char *, uint32_t length) |
|
1090 |
{
|
|
1091 |
return length; |
|
1092 |
}
|
|
1093 |
||
1094 |
||
1095 |
int Field::pack_cmp(const unsigned char *a, const unsigned char *b, |
|
1096 |
uint32_t, bool) |
|
1097 |
{
|
|
1098 |
return cmp(a,b); |
|
1099 |
}
|
|
1100 |
||
1101 |
||
1102 |
int Field::pack_cmp(const unsigned char *b, uint32_t, bool) |
|
1103 |
{
|
|
1104 |
return cmp(ptr,b); |
|
1105 |
}
|
|
1106 |
||
1107 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1108 |
my_decimal *Field::val_decimal(my_decimal *) |
1
by brian
clean slate |
1109 |
{
|
1110 |
/* This never have to be called */
|
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
1111 |
assert(0); |
1
by brian
clean slate |
1112 |
return 0; |
1113 |
}
|
|
1114 |
||
1115 |
||
1116 |
void Field::make_field(Send_field *field) |
|
1117 |
{
|
|
1118 |
if (orig_table && orig_table->s->db.str && *orig_table->s->db.str) |
|
1119 |
{
|
|
1120 |
field->db_name= orig_table->s->db.str; |
|
1121 |
field->org_table_name= orig_table->s->table_name.str; |
|
1122 |
}
|
|
1123 |
else
|
|
1124 |
field->org_table_name= field->db_name= ""; |
|
1125 |
if (orig_table) |
|
1126 |
{
|
|
1127 |
field->table_name= orig_table->alias; |
|
1128 |
field->org_col_name= field_name; |
|
1129 |
}
|
|
1130 |
else
|
|
1131 |
{
|
|
1132 |
field->table_name= ""; |
|
1133 |
field->org_col_name= ""; |
|
1134 |
}
|
|
1135 |
field->col_name= field_name; |
|
1136 |
field->charsetnr= charset()->number; |
|
1137 |
field->length=field_length; |
|
1138 |
field->type=type(); |
|
1139 |
field->flags=table->maybe_null ? (flags & ~NOT_NULL_FLAG) : flags; |
|
1140 |
field->decimals= 0; |
|
1141 |
}
|
|
1142 |
||
1143 |
||
1144 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1145 |
Conversion from decimal to int64_t with checking overflow and
|
1146 |
setting correct value (min/max) in case of overflow.
|
|
1147 |
||
1148 |
@param val value which have to be converted
|
|
1149 |
@param unsigned_flag type of integer in which we convert val
|
|
1150 |
@param err variable to pass error code
|
|
1151 |
||
1152 |
@return
|
|
1153 |
value converted from val
|
|
1
by brian
clean slate |
1154 |
*/
|
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1155 |
int64_t Field::convert_decimal2int64_t(const my_decimal *val, bool, int *err) |
1
by brian
clean slate |
1156 |
{
|
152
by Brian Aker
longlong replacement |
1157 |
int64_t i; |
508
by Brian Aker
Second pass on unsigned |
1158 |
if (warn_if_overflow(my_decimal2int(E_DEC_ERROR & |
1159 |
~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED, |
|
1160 |
val, false, &i))) |
|
1
by brian
clean slate |
1161 |
{
|
163
by Brian Aker
Merge Monty's code. |
1162 |
i= (val->sign() ? INT64_MIN : INT64_MAX); |
1
by brian
clean slate |
1163 |
*err= 1; |
1164 |
}
|
|
1165 |
return i; |
|
1166 |
}
|
|
1167 |
||
438.1.13
by Brian Aker
uint cleanup. |
1168 |
uint32_t Field::fill_cache_field(CACHE_FIELD *copy) |
1
by brian
clean slate |
1169 |
{
|
438.1.13
by Brian Aker
uint cleanup. |
1170 |
uint32_t store_length; |
1
by brian
clean slate |
1171 |
copy->str=ptr; |
1172 |
copy->length=pack_length(); |
|
1173 |
copy->blob_field=0; |
|
1174 |
if (flags & BLOB_FLAG) |
|
1175 |
{
|
|
1176 |
copy->blob_field=(Field_blob*) this; |
|
1177 |
copy->strip=0; |
|
1178 |
copy->length-= table->s->blob_ptr_size; |
|
1179 |
return copy->length; |
|
1180 |
}
|
|
1181 |
else
|
|
1182 |
{
|
|
1183 |
copy->strip=0; |
|
1184 |
store_length= 0; |
|
1185 |
}
|
|
1186 |
return copy->length+ store_length; |
|
1187 |
}
|
|
1188 |
||
1189 |
||
438.1.13
by Brian Aker
uint cleanup. |
1190 |
bool Field::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate) |
1
by brian
clean slate |
1191 |
{
|
1192 |
char buff[40]; |
|
1193 |
String tmp(buff,sizeof(buff),&my_charset_bin),*res; |
|
1194 |
if (!(res=val_str(&tmp)) || |
|
1195 |
str_to_datetime_with_warn(res->ptr(), res->length(), |
|
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
1196 |
ltime, fuzzydate) <= DRIZZLE_TIMESTAMP_ERROR) |
1
by brian
clean slate |
1197 |
return 1; |
1198 |
return 0; |
|
1199 |
}
|
|
1200 |
||
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
1201 |
bool Field::get_time(DRIZZLE_TIME *ltime) |
1
by brian
clean slate |
1202 |
{
|
1203 |
char buff[40]; |
|
1204 |
String tmp(buff,sizeof(buff),&my_charset_bin),*res; |
|
1205 |
if (!(res=val_str(&tmp)) || |
|
1206 |
str_to_time_with_warn(res->ptr(), res->length(), ltime)) |
|
1207 |
return 1; |
|
1208 |
return 0; |
|
1209 |
}
|
|
1210 |
||
1211 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1212 |
This is called when storing a date in a string.
|
1
by brian
clean slate |
1213 |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1214 |
@note
|
1215 |
Needs to be changed if/when we want to support different time formats.
|
|
1
by brian
clean slate |
1216 |
*/
|
1217 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1218 |
int Field::store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type) |
1
by brian
clean slate |
1219 |
{
|
1220 |
char buff[MAX_DATE_STRING_REP_LENGTH]; |
|
438.1.13
by Brian Aker
uint cleanup. |
1221 |
uint32_t length= (uint32_t) my_TIME_to_str(ltime, buff); |
1
by brian
clean slate |
1222 |
return store(buff, length, &my_charset_bin); |
1223 |
}
|
|
1224 |
||
1225 |
||
438.1.13
by Brian Aker
uint cleanup. |
1226 |
bool Field::optimize_range(uint32_t idx, uint32_t part) |
1
by brian
clean slate |
1227 |
{
|
1228 |
return test(table->file->index_flags(idx, part, 1) & HA_READ_RANGE); |
|
1229 |
}
|
|
1230 |
||
1231 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1232 |
Field *Field::new_field(MEM_ROOT *root, Table *new_table, bool) |
1
by brian
clean slate |
1233 |
{
|
1234 |
Field *tmp; |
|
1235 |
if (!(tmp= (Field*) memdup_root(root,(char*) this,size_of()))) |
|
1236 |
return 0; |
|
1237 |
||
1238 |
if (tmp->table->maybe_null) |
|
1239 |
tmp->flags&= ~NOT_NULL_FLAG; |
|
1240 |
tmp->table= new_table; |
|
1241 |
tmp->key_start.init(0); |
|
1242 |
tmp->part_of_key.init(0); |
|
1243 |
tmp->part_of_sortkey.init(0); |
|
1244 |
tmp->unireg_check= Field::NONE; |
|
216
by Brian Aker
Remove completely ZEROFILL |
1245 |
tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG | BINARY_FLAG | ENUM_FLAG | SET_FLAG); |
1
by brian
clean slate |
1246 |
tmp->reset_fields(); |
1247 |
return tmp; |
|
1248 |
}
|
|
1249 |
||
1250 |
||
327.1.1
by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure). |
1251 |
Field *Field::new_key_field(MEM_ROOT *root, Table *new_table, |
481
by Brian Aker
Remove all of uchar. |
1252 |
unsigned char *new_ptr, unsigned char *new_null_ptr, |
438.1.13
by Brian Aker
uint cleanup. |
1253 |
uint32_t new_null_bit) |
1
by brian
clean slate |
1254 |
{
|
1255 |
Field *tmp; |
|
1256 |
if ((tmp= new_field(root, new_table, table == new_table))) |
|
1257 |
{
|
|
1258 |
tmp->ptr= new_ptr; |
|
1259 |
tmp->null_ptr= new_null_ptr; |
|
1260 |
tmp->null_bit= new_null_bit; |
|
1261 |
}
|
|
1262 |
return tmp; |
|
1263 |
}
|
|
1264 |
||
1265 |
||
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
1266 |
/* This is used to generate a field in Table from TABLE_SHARE */
|
1
by brian
clean slate |
1267 |
|
327.1.1
by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure). |
1268 |
Field *Field::clone(MEM_ROOT *root, Table *new_table) |
1
by brian
clean slate |
1269 |
{
|
1270 |
Field *tmp; |
|
1271 |
if ((tmp= (Field*) memdup_root(root,(char*) this,size_of()))) |
|
1272 |
{
|
|
1273 |
tmp->init(new_table); |
|
1274 |
tmp->move_field_offset((my_ptrdiff_t) (new_table->record[0] - |
|
1275 |
new_table->s->default_values)); |
|
1276 |
}
|
|
1277 |
return tmp; |
|
1278 |
}
|
|
1279 |
||
1280 |
||
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1281 |
uint32_t Field::is_equal(Create_field *new_field_ptr) |
1
by brian
clean slate |
1282 |
{
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1283 |
return (new_field_ptr->sql_type == real_type()); |
1
by brian
clean slate |
1284 |
}
|
1285 |
||
1286 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1287 |
@retval
|
1288 |
1 if the fields are equally defined
|
|
1289 |
@retval
|
|
1290 |
0 if the fields are unequally defined
|
|
1
by brian
clean slate |
1291 |
*/
|
1292 |
||
1293 |
bool Field::eq_def(Field *field) |
|
1294 |
{
|
|
1295 |
if (real_type() != field->real_type() || charset() != field->charset() || |
|
1296 |
pack_length() != field->pack_length()) |
|
1297 |
return 0; |
|
1298 |
return 1; |
|
1299 |
}
|
|
1300 |
||
1301 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1302 |
@return
|
1303 |
returns 1 if the fields are equally defined
|
|
1
by brian
clean slate |
1304 |
*/
|
1305 |
bool Field_enum::eq_def(Field *field) |
|
1306 |
{
|
|
1307 |
if (!Field::eq_def(field)) |
|
1308 |
return 0; |
|
1309 |
TYPELIB *from_lib=((Field_enum*) field)->typelib; |
|
1310 |
||
1311 |
if (typelib->count < from_lib->count) |
|
1312 |
return 0; |
|
438.1.13
by Brian Aker
uint cleanup. |
1313 |
for (uint32_t i=0 ; i < from_lib->count ; i++) |
1
by brian
clean slate |
1314 |
if (my_strnncoll(field_charset, |
481
by Brian Aker
Remove all of uchar. |
1315 |
(const unsigned char*)typelib->type_names[i], |
1
by brian
clean slate |
1316 |
strlen(typelib->type_names[i]), |
481
by Brian Aker
Remove all of uchar. |
1317 |
(const unsigned char*)from_lib->type_names[i], |
1
by brian
clean slate |
1318 |
strlen(from_lib->type_names[i]))) |
1319 |
return 0; |
|
1320 |
return 1; |
|
1321 |
}
|
|
1322 |
||
1323 |
/*****************************************************************************
|
|
1324 |
Handling of field and Create_field
|
|
1325 |
*****************************************************************************/
|
|
1326 |
||
1327 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1328 |
Convert create_field::length from number of characters to number of bytes.
|
1
by brian
clean slate |
1329 |
*/
|
1330 |
||
1331 |
void Create_field::create_length_to_internal_length(void) |
|
1332 |
{
|
|
1333 |
switch (sql_type) { |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1334 |
case DRIZZLE_TYPE_BLOB: |
1335 |
case DRIZZLE_TYPE_VARCHAR: |
|
1
by brian
clean slate |
1336 |
length*= charset->mbmaxlen; |
1337 |
key_length= length; |
|
1338 |
pack_length= calc_pack_length(sql_type, length); |
|
1339 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1340 |
case DRIZZLE_TYPE_ENUM: |
869.1.24
by Stewart Smith
Generate all the info needed to get a record size on proto read instead of FRM create time. |
1341 |
/* Pack_length already calculated in ::init() */
|
1
by brian
clean slate |
1342 |
length*= charset->mbmaxlen; |
1343 |
key_length= pack_length; |
|
1344 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1345 |
case DRIZZLE_TYPE_NEWDECIMAL: |
1
by brian
clean slate |
1346 |
key_length= pack_length= |
1347 |
my_decimal_get_binary_size(my_decimal_length_to_precision(length, |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1348 |
decimals, |
1349 |
flags & |
|
1350 |
UNSIGNED_FLAG), |
|
1351 |
decimals); |
|
1
by brian
clean slate |
1352 |
break; |
1353 |
default: |
|
1354 |
key_length= pack_length= calc_pack_length(sql_type, length); |
|
1355 |
break; |
|
1356 |
}
|
|
1357 |
}
|
|
1358 |
||
1359 |
||
1360 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1361 |
Init for a tmp table field. To be extended if need be.
|
1
by brian
clean slate |
1362 |
*/
|
1363 |
void Create_field::init_for_tmp_table(enum_field_types sql_type_arg, |
|
205
by Brian Aker
uint32 -> uin32_t |
1364 |
uint32_t length_arg, uint32_t decimals_arg, |
1
by brian
clean slate |
1365 |
bool maybe_null, bool is_unsigned) |
1366 |
{
|
|
1367 |
field_name= ""; |
|
1368 |
sql_type= sql_type_arg; |
|
1369 |
char_length= length= length_arg;; |
|
1370 |
unireg_check= Field::NONE; |
|
1371 |
interval= 0; |
|
1372 |
charset= &my_charset_bin; |
|
1373 |
pack_flag= (FIELDFLAG_NUMBER | |
|
1374 |
((decimals_arg & FIELDFLAG_MAX_DEC) << FIELDFLAG_DEC_SHIFT) | |
|
1375 |
(maybe_null ? FIELDFLAG_MAYBE_NULL : 0) | |
|
1376 |
(is_unsigned ? 0 : FIELDFLAG_DECIMAL)); |
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
1377 |
vcol_info= NULL; |
1378 |
is_stored= true; |
|
1
by brian
clean slate |
1379 |
}
|
1380 |
||
1381 |
||
1382 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1383 |
Initialize field definition for create.
|
1384 |
||
1385 |
@param session Thread handle
|
|
1386 |
@param fld_name Field name
|
|
1387 |
@param fld_type Field type
|
|
1388 |
@param fld_length Field length
|
|
1389 |
@param fld_decimals Decimal (if any)
|
|
1390 |
@param fld_type_modifier Additional type information
|
|
1391 |
@param fld_default_value Field default value (if any)
|
|
1392 |
@param fld_on_update_value The value of ON UPDATE clause
|
|
1393 |
@param fld_comment Field comment
|
|
1394 |
@param fld_change Field change
|
|
1395 |
@param fld_interval_list Interval list (if any)
|
|
1396 |
@param fld_charset Field charset
|
|
1397 |
@param fld_vcol_info Virtual column data
|
|
1398 |
||
1399 |
@retval
|
|
1400 |
false on success
|
|
1401 |
@retval
|
|
1402 |
true on error
|
|
1
by brian
clean slate |
1403 |
*/
|
1404 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1405 |
bool Create_field::init(Session *, char *fld_name, enum_field_types fld_type, |
1
by brian
clean slate |
1406 |
char *fld_length, char *fld_decimals, |
438.1.13
by Brian Aker
uint cleanup. |
1407 |
uint32_t fld_type_modifier, Item *fld_default_value, |
1
by brian
clean slate |
1408 |
Item *fld_on_update_value, LEX_STRING *fld_comment, |
1409 |
char *fld_change, List<String> *fld_interval_list, |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1410 |
const CHARSET_INFO * const fld_charset, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1411 |
uint32_t, enum column_format_type column_format_in, |
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
1412 |
virtual_column_info *fld_vcol_info) |
1
by brian
clean slate |
1413 |
{
|
438.1.13
by Brian Aker
uint cleanup. |
1414 |
uint32_t sign_len, allowed_type_modifier= 0; |
290
by Brian Aker
Update for ulong change over. |
1415 |
uint32_t max_field_charlength= MAX_FIELD_CHARLENGTH; |
1
by brian
clean slate |
1416 |
|
1417 |
field= 0; |
|
1418 |
field_name= fld_name; |
|
1419 |
def= fld_default_value; |
|
1420 |
flags= fld_type_modifier; |
|
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1421 |
flags|= (((uint32_t)column_format_in & COLUMN_FORMAT_MASK) << COLUMN_FORMAT_FLAGS); |
1
by brian
clean slate |
1422 |
unireg_check= (fld_type_modifier & AUTO_INCREMENT_FLAG ? |
1423 |
Field::NEXT_NUMBER : Field::NONE); |
|
438.1.13
by Brian Aker
uint cleanup. |
1424 |
decimals= fld_decimals ? (uint32_t)atoi(fld_decimals) : 0; |
1
by brian
clean slate |
1425 |
if (decimals >= NOT_FIXED_DEC) |
1426 |
{
|
|
1427 |
my_error(ER_TOO_BIG_SCALE, MYF(0), decimals, fld_name, |
|
1428 |
NOT_FIXED_DEC-1); |
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
1429 |
return(true); |
1
by brian
clean slate |
1430 |
}
|
1431 |
||
1432 |
sql_type= fld_type; |
|
1433 |
length= 0; |
|
1434 |
change= fld_change; |
|
1435 |
interval= 0; |
|
1436 |
pack_length= key_length= 0; |
|
1437 |
charset= fld_charset; |
|
1438 |
interval_list.empty(); |
|
1439 |
||
1440 |
comment= *fld_comment; |
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
1441 |
vcol_info= fld_vcol_info; |
1442 |
is_stored= true; |
|
1443 |
||
1444 |
/* Initialize data for a virtual field */
|
|
1445 |
if (fld_type == DRIZZLE_TYPE_VIRTUAL) |
|
1446 |
{
|
|
1447 |
assert(vcol_info && vcol_info->expr_item); |
|
1448 |
is_stored= vcol_info->get_field_stored(); |
|
1449 |
/*
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1450 |
Perform per item-type checks to determine if the expression is
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
1451 |
allowed for a virtual column.
|
1452 |
Note that validation of the specific function is done later in
|
|
1453 |
procedures open_table_from_share and fix_fields_vcol_func
|
|
1454 |
*/
|
|
1455 |
switch (vcol_info->expr_item->type()) { |
|
1456 |
case Item::FUNC_ITEM: |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1457 |
if (((Item_func *)vcol_info->expr_item)->functype() == Item_func::FUNC_SP) |
1458 |
{
|
|
1459 |
my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), field_name); |
|
1460 |
return(true); |
|
1461 |
}
|
|
1462 |
break; |
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
1463 |
case Item::COPY_STR_ITEM: |
1464 |
case Item::FIELD_AVG_ITEM: |
|
1465 |
case Item::PROC_ITEM: |
|
1466 |
case Item::REF_ITEM: |
|
1467 |
case Item::FIELD_STD_ITEM: |
|
1468 |
case Item::FIELD_VARIANCE_ITEM: |
|
1469 |
case Item::INSERT_VALUE_ITEM: |
|
1470 |
case Item::SUBSELECT_ITEM: |
|
1471 |
case Item::CACHE_ITEM: |
|
1472 |
case Item::TYPE_HOLDER: |
|
1473 |
case Item::PARAM_ITEM: |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1474 |
my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), field_name); |
1475 |
return true; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1476 |
default: |
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
1477 |
// Continue with the field creation
|
1478 |
break; |
|
1479 |
}
|
|
1480 |
/*
|
|
1481 |
Make a field created for the real type.
|
|
1482 |
Note that "real" and virtual fields differ from each other
|
|
1483 |
only by Field::vcol_info, which is always 0 for normal columns.
|
|
1484 |
vcol_info is updated for fields later in procedure open_binary_frm.
|
|
1485 |
*/
|
|
1486 |
sql_type= fld_type= vcol_info->get_real_type(); |
|
1487 |
}
|
|
1488 |
||
1
by brian
clean slate |
1489 |
/*
|
1490 |
Set NO_DEFAULT_VALUE_FLAG if this field doesn't have a default value and
|
|
1491 |
it is NOT NULL, not an AUTO_INCREMENT field and not a TIMESTAMP.
|
|
1492 |
*/
|
|
1493 |
if (!fld_default_value && !(fld_type_modifier & AUTO_INCREMENT_FLAG) && |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1494 |
(fld_type_modifier & NOT_NULL_FLAG) && fld_type != DRIZZLE_TYPE_TIMESTAMP) |
1
by brian
clean slate |
1495 |
flags|= NO_DEFAULT_VALUE_FLAG; |
1496 |
||
438.1.13
by Brian Aker
uint cleanup. |
1497 |
if (fld_length && !(length= (uint32_t) atoi(fld_length))) |
1
by brian
clean slate |
1498 |
fld_length= 0; /* purecov: inspected */ |
1499 |
sign_len= fld_type_modifier & UNSIGNED_FLAG ? 0 : 1; |
|
1500 |
||
1501 |
switch (fld_type) { |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1502 |
case DRIZZLE_TYPE_TINY: |
1
by brian
clean slate |
1503 |
if (!fld_length) |
1504 |
length= MAX_TINYINT_WIDTH+sign_len; |
|
1505 |
allowed_type_modifier= AUTO_INCREMENT_FLAG; |
|
1506 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1507 |
case DRIZZLE_TYPE_LONG: |
1
by brian
clean slate |
1508 |
if (!fld_length) |
1509 |
length= MAX_INT_WIDTH+sign_len; |
|
1510 |
allowed_type_modifier= AUTO_INCREMENT_FLAG; |
|
1511 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1512 |
case DRIZZLE_TYPE_LONGLONG: |
1
by brian
clean slate |
1513 |
if (!fld_length) |
1514 |
length= MAX_BIGINT_WIDTH; |
|
1515 |
allowed_type_modifier= AUTO_INCREMENT_FLAG; |
|
1516 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1517 |
case DRIZZLE_TYPE_NULL: |
1
by brian
clean slate |
1518 |
break; |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1519 |
case DRIZZLE_TYPE_NEWDECIMAL: |
1
by brian
clean slate |
1520 |
my_decimal_trim(&length, &decimals); |
1521 |
if (length > DECIMAL_MAX_PRECISION) |
|
1522 |
{
|
|
1523 |
my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name, |
|
1524 |
DECIMAL_MAX_PRECISION); |
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
1525 |
return(true); |
1
by brian
clean slate |
1526 |
}
|
1527 |
if (length < decimals) |
|
1528 |
{
|
|
1529 |
my_error(ER_M_BIGGER_THAN_D, MYF(0), fld_name); |
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
1530 |
return(true); |
1
by brian
clean slate |
1531 |
}
|
1532 |
length= |
|
1533 |
my_decimal_precision_to_length(length, decimals, |
|
1534 |
fld_type_modifier & UNSIGNED_FLAG); |
|
1535 |
pack_length= |
|
1536 |
my_decimal_get_binary_size(length, decimals); |
|
1537 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1538 |
case DRIZZLE_TYPE_VARCHAR: |
1
by brian
clean slate |
1539 |
/*
|
1540 |
Long VARCHAR's are automaticly converted to blobs in mysql_prepare_table
|
|
1541 |
if they don't have a default value
|
|
1542 |
*/
|
|
1543 |
max_field_charlength= MAX_FIELD_VARCHARLENGTH; |
|
1544 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1545 |
case DRIZZLE_TYPE_BLOB: |
1
by brian
clean slate |
1546 |
if (fld_default_value) |
1547 |
{
|
|
1548 |
/* Allow empty as default value. */
|
|
1549 |
String str,*res; |
|
1550 |
res= fld_default_value->val_str(&str); |
|
896.3.4
by Stewart Smith
Create default_values record from proto instead of reading from FRM. assert if different to FRM. |
1551 |
if (res->length()) |
1552 |
{
|
|
1553 |
my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), |
|
1554 |
fld_name); |
|
1555 |
return(true); |
|
1556 |
}
|
|
1557 |
||
1
by brian
clean slate |
1558 |
}
|
1559 |
flags|= BLOB_FLAG; |
|
1560 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1561 |
case DRIZZLE_TYPE_DOUBLE: |
1
by brian
clean slate |
1562 |
allowed_type_modifier= AUTO_INCREMENT_FLAG; |
1563 |
if (!fld_length && !fld_decimals) |
|
1564 |
{
|
|
1565 |
length= DBL_DIG+7; |
|
1566 |
decimals= NOT_FIXED_DEC; |
|
1567 |
}
|
|
1568 |
if (length < decimals && |
|
1569 |
decimals != NOT_FIXED_DEC) |
|
1570 |
{
|
|
1571 |
my_error(ER_M_BIGGER_THAN_D, MYF(0), fld_name); |
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
1572 |
return(true); |
1
by brian
clean slate |
1573 |
}
|
1574 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1575 |
case DRIZZLE_TYPE_TIMESTAMP: |
1
by brian
clean slate |
1576 |
if (!fld_length) |
1577 |
{
|
|
1578 |
/* Compressed date YYYYMMDDHHMMSS */
|
|
1579 |
length= MAX_DATETIME_COMPRESSED_WIDTH; |
|
1580 |
}
|
|
1581 |
else if (length != MAX_DATETIME_WIDTH) |
|
1582 |
{
|
|
1583 |
/*
|
|
1584 |
We support only even TIMESTAMP lengths less or equal than 14
|
|
1585 |
and 19 as length of 4.1 compatible representation.
|
|
1586 |
*/
|
|
1587 |
length= ((length+1)/2)*2; /* purecov: inspected */ |
|
398.1.4
by Monty Taylor
Renamed max/min. |
1588 |
length= cmin(length, (uint32_t)MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */ |
1
by brian
clean slate |
1589 |
}
|
216
by Brian Aker
Remove completely ZEROFILL |
1590 |
flags|= UNSIGNED_FLAG; |
1
by brian
clean slate |
1591 |
if (fld_default_value) |
1592 |
{
|
|
1593 |
/* Grammar allows only NOW() value for ON UPDATE clause */
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1594 |
if (fld_default_value->type() == Item::FUNC_ITEM && |
1
by brian
clean slate |
1595 |
((Item_func*)fld_default_value)->functype() == Item_func::NOW_FUNC) |
1596 |
{
|
|
1597 |
unireg_check= (fld_on_update_value ? Field::TIMESTAMP_DNUN_FIELD: |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1598 |
Field::TIMESTAMP_DN_FIELD); |
1
by brian
clean slate |
1599 |
/*
|
1600 |
We don't need default value any longer moreover it is dangerous.
|
|
1601 |
Everything handled by unireg_check further.
|
|
1602 |
*/
|
|
1603 |
def= 0; |
|
1604 |
}
|
|
1605 |
else
|
|
1606 |
unireg_check= (fld_on_update_value ? Field::TIMESTAMP_UN_FIELD: |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1607 |
Field::NONE); |
1
by brian
clean slate |
1608 |
}
|
1609 |
else
|
|
1610 |
{
|
|
1611 |
/*
|
|
1612 |
If we have default TIMESTAMP NOT NULL column without explicit DEFAULT
|
|
1613 |
or ON UPDATE values then for the sake of compatiblity we should treat
|
|
1614 |
this column as having DEFAULT NOW() ON UPDATE NOW() (when we don't
|
|
1615 |
have another TIMESTAMP column with auto-set option before this one)
|
|
1616 |
or DEFAULT 0 (in other cases).
|
|
1617 |
So here we are setting TIMESTAMP_OLD_FIELD only temporary, and will
|
|
1618 |
replace this value by TIMESTAMP_DNUN_FIELD or NONE later when
|
|
1619 |
information about all TIMESTAMP fields in table will be availiable.
|
|
1620 |
||
1621 |
If we have TIMESTAMP NULL column without explicit DEFAULT value
|
|
1622 |
we treat it as having DEFAULT NULL attribute.
|
|
1623 |
*/
|
|
1624 |
unireg_check= (fld_on_update_value ? Field::TIMESTAMP_UN_FIELD : |
|
1625 |
(flags & NOT_NULL_FLAG ? Field::TIMESTAMP_OLD_FIELD : |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1626 |
Field::NONE)); |
1
by brian
clean slate |
1627 |
}
|
1628 |
break; |
|
575.5.1
by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code |
1629 |
case DRIZZLE_TYPE_DATE: |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1630 |
length= 10; |
1631 |
break; |
|
1632 |
case DRIZZLE_TYPE_DATETIME: |
|
1
by brian
clean slate |
1633 |
length= MAX_DATETIME_WIDTH; |
1634 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1635 |
case DRIZZLE_TYPE_ENUM: |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1636 |
{
|
869.1.24
by Stewart Smith
Generate all the info needed to get a record size on proto read instead of FRM create time. |
1637 |
/* Should be safe. */
|
1638 |
pack_length= get_enum_pack_length(fld_interval_list->elements); |
|
1639 |
||
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1640 |
List_iterator<String> it(*fld_interval_list); |
1641 |
String *tmp; |
|
1642 |
while ((tmp= it++)) |
|
1643 |
interval_list.push_back(tmp); |
|
1644 |
length= 1; /* See comment for DRIZZLE_TYPE_SET above. */ |
|
1645 |
break; |
|
1646 |
}
|
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
1647 |
case DRIZZLE_TYPE_VIRTUAL: // Must not happen |
1648 |
assert(0); |
|
1
by brian
clean slate |
1649 |
}
|
1650 |
/* Remember the value of length */
|
|
1651 |
char_length= length; |
|
1652 |
||
1653 |
if (!(flags & BLOB_FLAG) && |
|
325
by Brian Aker
Remove SET |
1654 |
((length > max_field_charlength && |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1655 |
fld_type != DRIZZLE_TYPE_ENUM && |
1656 |
(fld_type != DRIZZLE_TYPE_VARCHAR || fld_default_value)) || |
|
241
by Brian Aker
First pass of CHAR removal. |
1657 |
(!length && fld_type != DRIZZLE_TYPE_VARCHAR))) |
1
by brian
clean slate |
1658 |
{
|
241
by Brian Aker
First pass of CHAR removal. |
1659 |
my_error((fld_type == DRIZZLE_TYPE_VARCHAR) ? ER_TOO_BIG_FIELDLENGTH : ER_TOO_BIG_DISPLAYWIDTH, |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1660 |
MYF(0), |
1661 |
fld_name, max_field_charlength); /* purecov: inspected */ |
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
1662 |
return(true); |
1
by brian
clean slate |
1663 |
}
|
1664 |
fld_type_modifier&= AUTO_INCREMENT_FLAG; |
|
1665 |
if ((~allowed_type_modifier) & fld_type_modifier) |
|
1666 |
{
|
|
1667 |
my_error(ER_WRONG_FIELD_SPEC, MYF(0), fld_name); |
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
1668 |
return(true); |
1
by brian
clean slate |
1669 |
}
|
1670 |
||
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
1671 |
return(false); /* success */ |
1
by brian
clean slate |
1672 |
}
|
1673 |
||
1674 |
||
575.1.2
by Monty Taylor
Changed a bunch of __attribute__((unused)) to removing the parameter name instead. |
1675 |
enum_field_types get_blob_type_from_length(uint32_t) |
1
by brian
clean slate |
1676 |
{
|
1677 |
enum_field_types type; |
|
114
by Brian Aker
More cleanup around Drizzle types. |
1678 |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1679 |
type= DRIZZLE_TYPE_BLOB; |
114
by Brian Aker
More cleanup around Drizzle types. |
1680 |
|
1
by brian
clean slate |
1681 |
return type; |
1682 |
}
|
|
1683 |
||
1684 |
||
1685 |
/*
|
|
1686 |
Make a field from the .frm file info
|
|
1687 |
*/
|
|
1688 |
||
205
by Brian Aker
uint32 -> uin32_t |
1689 |
uint32_t calc_pack_length(enum_field_types type,uint32_t length) |
1
by brian
clean slate |
1690 |
{
|
1691 |
switch (type) { |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1692 |
case DRIZZLE_TYPE_VARCHAR: return (length + (length < 256 ? 1: 2)); |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1693 |
case DRIZZLE_TYPE_TINY : return 1; |
896.5.1
by Jay Pipes
Removes the TIME column type and related time functions. |
1694 |
case DRIZZLE_TYPE_DATE: return 3; |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1695 |
case DRIZZLE_TYPE_TIMESTAMP: |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1696 |
case DRIZZLE_TYPE_LONG : return 4; |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1697 |
case DRIZZLE_TYPE_DOUBLE: return sizeof(double); |
1698 |
case DRIZZLE_TYPE_DATETIME: |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1699 |
case DRIZZLE_TYPE_LONGLONG: return 8; /* Don't crash if no int64_t */ |
1700 |
case DRIZZLE_TYPE_NULL : return 0; |
|
1701 |
case DRIZZLE_TYPE_BLOB: return 4+portable_sizeof_char_ptr; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1702 |
case DRIZZLE_TYPE_ENUM: |
1703 |
case DRIZZLE_TYPE_NEWDECIMAL: |
|
907.3.5
by Monty Taylor
Fixed new 64-bit caused solaris warnings. |
1704 |
abort(); |
779.3.53
by Monty Taylor
Revert the fail. |
1705 |
default: |
1706 |
return 0; |
|
1
by brian
clean slate |
1707 |
}
|
1708 |
}
|
|
1709 |
||
1710 |
||
438.1.13
by Brian Aker
uint cleanup. |
1711 |
uint32_t pack_length_to_packflag(uint32_t type) |
1
by brian
clean slate |
1712 |
{
|
1713 |
switch (type) { |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1714 |
case 1: return 1 << FIELDFLAG_PACK_SHIFT; |
1715 |
case 2: assert(1); |
|
1716 |
case 3: assert(1); |
|
1717 |
case 4: return f_settype((uint32_t) DRIZZLE_TYPE_LONG); |
|
1718 |
case 8: return f_settype((uint32_t) DRIZZLE_TYPE_LONGLONG); |
|
1
by brian
clean slate |
1719 |
}
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1720 |
return 0; // This shouldn't happen |
1
by brian
clean slate |
1721 |
}
|
1722 |
||
1723 |
||
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1724 |
Field *make_field(TABLE_SHARE *share, MEM_ROOT *root, |
1725 |
unsigned char *ptr, uint32_t field_length, |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1726 |
unsigned char *null_pos, unsigned char null_bit, |
1727 |
uint32_t pack_flag, |
|
1728 |
enum_field_types field_type, |
|
1729 |
const CHARSET_INFO * field_charset, |
|
1730 |
Field::utype unireg_check, |
|
1731 |
TYPELIB *interval, |
|
1732 |
const char *field_name) |
|
1
by brian
clean slate |
1733 |
{
|
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1734 |
if(!root) |
1735 |
root= current_mem_root(); |
|
1736 |
||
1
by brian
clean slate |
1737 |
if (!f_maybe_null(pack_flag)) |
1738 |
{
|
|
1739 |
null_pos=0; |
|
1740 |
null_bit=0; |
|
1741 |
}
|
|
1742 |
else
|
|
1743 |
{
|
|
481
by Brian Aker
Remove all of uchar. |
1744 |
null_bit= ((unsigned char) 1) << null_bit; |
1
by brian
clean slate |
1745 |
}
|
1746 |
||
1747 |
switch (field_type) { |
|
575.5.1
by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code |
1748 |
case DRIZZLE_TYPE_DATE: |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1749 |
case DRIZZLE_TYPE_DATETIME: |
1750 |
case DRIZZLE_TYPE_TIMESTAMP: |
|
1
by brian
clean slate |
1751 |
field_charset= &my_charset_bin; |
1752 |
default: break; |
|
1753 |
}
|
|
1754 |
||
1755 |
if (f_is_alpha(pack_flag)) |
|
1756 |
{
|
|
1757 |
if (!f_is_packed(pack_flag)) |
|
1758 |
{
|
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1759 |
if (field_type == DRIZZLE_TYPE_VARCHAR) |
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1760 |
return new (root) Field_varstring(ptr,field_length, |
1
by brian
clean slate |
1761 |
HA_VARCHAR_PACKLENGTH(field_length), |
1762 |
null_pos,null_bit, |
|
1763 |
unireg_check, field_name, |
|
1764 |
share, |
|
1765 |
field_charset); |
|
1766 |
return 0; // Error |
|
1767 |
}
|
|
1768 |
||
438.1.13
by Brian Aker
uint cleanup. |
1769 |
uint32_t pack_length=calc_pack_length((enum_field_types) |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1770 |
f_packtype(pack_flag), |
1771 |
field_length); |
|
1
by brian
clean slate |
1772 |
|
1773 |
if (f_is_blob(pack_flag)) |
|
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1774 |
return new (root) Field_blob(ptr,null_pos,null_bit, |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1775 |
unireg_check, field_name, share, |
1776 |
pack_length, field_charset); |
|
1
by brian
clean slate |
1777 |
if (interval) |
1778 |
{
|
|
1779 |
if (f_is_enum(pack_flag)) |
|
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1780 |
{
|
1781 |
return new (root) Field_enum(ptr,field_length,null_pos,null_bit, |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1782 |
unireg_check, field_name, |
1783 |
get_enum_pack_length(interval->count), |
|
1784 |
interval, field_charset); |
|
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1785 |
}
|
1
by brian
clean slate |
1786 |
}
|
1787 |
}
|
|
1788 |
||
1789 |
switch (field_type) { |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1790 |
case DRIZZLE_TYPE_NEWDECIMAL: |
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1791 |
return new (root) Field_new_decimal(ptr,field_length,null_pos,null_bit, |
1
by brian
clean slate |
1792 |
unireg_check, field_name, |
1793 |
f_decimals(pack_flag), |
|
216
by Brian Aker
Remove completely ZEROFILL |
1794 |
f_is_decimal_precision(pack_flag) != 0, |
1
by brian
clean slate |
1795 |
f_is_dec(pack_flag) == 0); |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1796 |
case DRIZZLE_TYPE_DOUBLE: |
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1797 |
return new (root) Field_double(ptr,field_length,null_pos,null_bit, |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1798 |
unireg_check, field_name, |
1799 |
f_decimals(pack_flag), |
|
1800 |
false, |
|
1801 |
f_is_dec(pack_flag)== 0); |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1802 |
case DRIZZLE_TYPE_TINY: |
513
by Brian Aker
Removed Field_tiny class |
1803 |
assert(0); |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1804 |
case DRIZZLE_TYPE_LONG: |
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1805 |
return new (root) Field_long(ptr,field_length,null_pos,null_bit, |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1806 |
unireg_check, field_name, |
1807 |
false, |
|
1808 |
f_is_dec(pack_flag) == 0); |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1809 |
case DRIZZLE_TYPE_LONGLONG: |
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1810 |
return new (root) Field_int64_t(ptr,field_length,null_pos,null_bit, |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1811 |
unireg_check, field_name, |
1812 |
false, |
|
1813 |
f_is_dec(pack_flag) == 0); |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1814 |
case DRIZZLE_TYPE_TIMESTAMP: |
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1815 |
return new (root) Field_timestamp(ptr,field_length, null_pos, null_bit, |
1
by brian
clean slate |
1816 |
unireg_check, field_name, share, |
1817 |
field_charset); |
|
575.5.1
by David Axmark
Changed NEWDATE to DATE. One failing test but I think its somewhere else in the code |
1818 |
case DRIZZLE_TYPE_DATE: |
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1819 |
return new (root) Field_date(ptr,null_pos,null_bit, |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1820 |
unireg_check, field_name, field_charset); |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1821 |
case DRIZZLE_TYPE_DATETIME: |
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1822 |
return new (root) Field_datetime(ptr,null_pos,null_bit, |
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1823 |
unireg_check, field_name, field_charset); |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1824 |
case DRIZZLE_TYPE_NULL: |
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1825 |
return new (root) Field_null(ptr, field_length, unireg_check, field_name, |
1
by brian
clean slate |
1826 |
field_charset); |
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
1827 |
case DRIZZLE_TYPE_VIRTUAL: // Must not happen |
1828 |
assert(0); |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1829 |
default: // Impossible (Wrong version) |
1
by brian
clean slate |
1830 |
break; |
1831 |
}
|
|
1832 |
return 0; |
|
1833 |
}
|
|
1834 |
||
1835 |
||
1836 |
/** Create a field suitable for create of table. */
|
|
1837 |
||
1838 |
Create_field::Create_field(Field *old_field,Field *orig_field) |
|
1839 |
{
|
|
1840 |
field= old_field; |
|
1841 |
field_name=change=old_field->field_name; |
|
1842 |
length= old_field->field_length; |
|
1843 |
flags= old_field->flags; |
|
1844 |
unireg_check=old_field->unireg_check; |
|
1845 |
pack_length=old_field->pack_length(); |
|
1846 |
key_length= old_field->key_length(); |
|
1847 |
sql_type= old_field->real_type(); |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1848 |
charset= old_field->charset(); // May be NULL ptr |
1
by brian
clean slate |
1849 |
comment= old_field->comment; |
1850 |
decimals= old_field->decimals(); |
|
383.7.1
by Andrey Zhakov
Initial submit of code and tests |
1851 |
vcol_info= old_field->vcol_info; |
1852 |
is_stored= old_field->is_stored; |
|
1
by brian
clean slate |
1853 |
|
1854 |
/* Fix if the original table had 4 byte pointer blobs */
|
|
1855 |
if (flags & BLOB_FLAG) |
|
1856 |
pack_length= (pack_length- old_field->table->s->blob_ptr_size + |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1857 |
portable_sizeof_char_ptr); |
1
by brian
clean slate |
1858 |
|
1859 |
switch (sql_type) { |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1860 |
case DRIZZLE_TYPE_BLOB: |
1861 |
sql_type= DRIZZLE_TYPE_BLOB; |
|
1
by brian
clean slate |
1862 |
length/= charset->mbmaxlen; |
1863 |
key_length/= charset->mbmaxlen; |
|
1864 |
break; |
|
1865 |
/* Change CHAR -> VARCHAR if dynamic record length */
|
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1866 |
case DRIZZLE_TYPE_ENUM: |
1867 |
case DRIZZLE_TYPE_VARCHAR: |
|
1
by brian
clean slate |
1868 |
/* This is corrected in create_length_to_internal_length */
|
1869 |
length= (length+charset->mbmaxlen-1) / charset->mbmaxlen; |
|
1870 |
break; |
|
1871 |
default: |
|
1872 |
break; |
|
1873 |
}
|
|
1874 |
||
1875 |
if (flags & (ENUM_FLAG | SET_FLAG)) |
|
1876 |
interval= ((Field_enum*) old_field)->typelib; |
|
1877 |
else
|
|
1878 |
interval=0; |
|
1879 |
def=0; |
|
1880 |
char_length= length; |
|
1881 |
||
896.3.6
by Stewart Smith
Read Fields out of proto instead of FRM. |
1882 |
if (!(flags & (NO_DEFAULT_VALUE_FLAG )) && |
1
by brian
clean slate |
1883 |
old_field->ptr && orig_field && |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1884 |
(sql_type != DRIZZLE_TYPE_TIMESTAMP || /* set def only if */ |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1885 |
old_field->table->timestamp_field != old_field || /* timestamp field */ |
1
by brian
clean slate |
1886 |
unireg_check == Field::TIMESTAMP_UN_FIELD)) /* has default val */ |
1887 |
{
|
|
1888 |
my_ptrdiff_t diff; |
|
1889 |
||
1890 |
/* Get the value from default_values */
|
|
1891 |
diff= (my_ptrdiff_t) (orig_field->table->s->default_values- |
|
1892 |
orig_field->table->record[0]); |
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1893 |
orig_field->move_field_offset(diff); // Points now at default_values |
1
by brian
clean slate |
1894 |
if (!orig_field->is_real_null()) |
1895 |
{
|
|
1896 |
char buff[MAX_FIELD_WIDTH], *pos; |
|
1897 |
String tmp(buff, sizeof(buff), charset), *res; |
|
1898 |
res= orig_field->val_str(&tmp); |
|
1899 |
pos= (char*) sql_strmake(res->ptr(), res->length()); |
|
1900 |
def= new Item_string(pos, res->length(), charset); |
|
1901 |
}
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1902 |
orig_field->move_field_offset(-diff); // Back to record[0] |
1
by brian
clean slate |
1903 |
}
|
1904 |
}
|
|
1905 |
||
1906 |
||
1907 |
/*****************************************************************************
|
|
1908 |
Warning handling
|
|
1909 |
*****************************************************************************/
|
|
1910 |
||
1911 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1912 |
Produce warning or note about data saved into field.
|
1913 |
||
1914 |
@param level - level of message (Note/Warning/Error)
|
|
1915 |
@param code - error code of message to be produced
|
|
1916 |
@param cuted_increment - whenever we should increase cut fields count or not
|
|
1917 |
||
1918 |
@note
|
|
1919 |
This function won't produce warning and increase cut fields counter
|
|
1920 |
if count_cuted_fields == CHECK_FIELD_IGNORE for current thread.
|
|
1921 |
||
1922 |
if count_cuted_fields == CHECK_FIELD_IGNORE then we ignore notes.
|
|
1923 |
This allows us to avoid notes in optimisation, like convert_constant_item().
|
|
1924 |
||
1925 |
@retval
|
|
1926 |
1 if count_cuted_fields == CHECK_FIELD_IGNORE and error level is not NOTE
|
|
1927 |
@retval
|
|
1928 |
0 otherwise
|
|
1
by brian
clean slate |
1929 |
*/
|
1930 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1931 |
bool
|
438.1.13
by Brian Aker
uint cleanup. |
1932 |
Field::set_warning(DRIZZLE_ERROR::enum_warning_level level, uint32_t code, |
1
by brian
clean slate |
1933 |
int cuted_increment) |
1934 |
{
|
|
1935 |
/*
|
|
1936 |
If this field was created only for type conversion purposes it
|
|
1937 |
will have table == NULL.
|
|
1938 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1939 |
Session *session= table ? table->in_use : current_session; |
1940 |
if (session->count_cuted_fields) |
|
1
by brian
clean slate |
1941 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1942 |
session->cuted_fields+= cuted_increment; |
1943 |
push_warning_printf(session, level, code, ER(code), field_name, |
|
1944 |
session->row_count); |
|
1
by brian
clean slate |
1945 |
return 0; |
1946 |
}
|
|
261.4.1
by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR. |
1947 |
return level >= DRIZZLE_ERROR::WARN_LEVEL_WARN; |
1
by brian
clean slate |
1948 |
}
|
1949 |
||
1950 |
||
1951 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1952 |
Produce warning or note about datetime string data saved into field.
|
1953 |
||
1954 |
@param level level of message (Note/Warning/Error)
|
|
1955 |
@param code error code of message to be produced
|
|
1956 |
@param str string value which we tried to save
|
|
1957 |
@param str_length length of string which we tried to save
|
|
1958 |
@param ts_type type of datetime value (datetime/date/time)
|
|
1959 |
@param cuted_increment whenever we should increase cut fields count or not
|
|
1960 |
||
1961 |
@note
|
|
1962 |
This function will always produce some warning but won't increase cut
|
|
1963 |
fields counter if count_cuted_fields ==FIELD_CHECK_IGNORE for current
|
|
1964 |
thread.
|
|
1
by brian
clean slate |
1965 |
*/
|
1966 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1967 |
void
|
1968 |
Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level, |
|
1969 |
unsigned int code, |
|
1970 |
const char *str, uint32_t str_length, |
|
398.1.1
by Monty Taylor
Remove typedef enum enum_drizzle_timestamp_type timestamp_type; |
1971 |
enum enum_drizzle_timestamp_type ts_type, int cuted_increment) |
1
by brian
clean slate |
1972 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1973 |
Session *session= table ? table->in_use : current_session; |
1974 |
if ((session->really_abort_on_warning() && |
|
261.4.1
by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR. |
1975 |
level >= DRIZZLE_ERROR::WARN_LEVEL_WARN) || |
1
by brian
clean slate |
1976 |
set_warning(level, code, cuted_increment)) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1977 |
make_truncated_value_warning(session, level, str, str_length, ts_type, |
1
by brian
clean slate |
1978 |
field_name); |
1979 |
}
|
|
1980 |
||
1981 |
||
1982 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
1983 |
Produce warning or note about integer datetime value saved into field.
|
1984 |
||
1985 |
@param level level of message (Note/Warning/Error)
|
|
1986 |
@param code error code of message to be produced
|
|
1987 |
@param nr numeric value which we tried to save
|
|
1988 |
@param ts_type type of datetime value (datetime/date/time)
|
|
1989 |
@param cuted_increment whenever we should increase cut fields count or not
|
|
1990 |
||
1991 |
@note
|
|
1992 |
This function will always produce some warning but won't increase cut
|
|
1993 |
fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current
|
|
1994 |
thread.
|
|
1
by brian
clean slate |
1995 |
*/
|
1996 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1997 |
void
|
1998 |
Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level, uint32_t code, |
|
398.1.1
by Monty Taylor
Remove typedef enum enum_drizzle_timestamp_type timestamp_type; |
1999 |
int64_t nr, enum enum_drizzle_timestamp_type ts_type, |
1
by brian
clean slate |
2000 |
int cuted_increment) |
2001 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2002 |
Session *session= table ? table->in_use : current_session; |
2003 |
if (session->really_abort_on_warning() || |
|
1
by brian
clean slate |
2004 |
set_warning(level, code, cuted_increment)) |
2005 |
{
|
|
2006 |
char str_nr[22]; |
|
152
by Brian Aker
longlong replacement |
2007 |
char *str_end= int64_t10_to_str(nr, str_nr, -10); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2008 |
make_truncated_value_warning(session, level, str_nr, (uint32_t) (str_end - str_nr), |
1
by brian
clean slate |
2009 |
ts_type, field_name); |
2010 |
}
|
|
2011 |
}
|
|
2012 |
||
2013 |
||
2014 |
/**
|
|
520.1.28
by Monty Taylor
Reverted too-big formatting change. |
2015 |
Produce warning or note about double datetime data saved into field.
|
2016 |
||
2017 |
@param level level of message (Note/Warning/Error)
|
|
2018 |
@param code error code of message to be produced
|
|
2019 |
@param nr double value which we tried to save
|
|
2020 |
@param ts_type type of datetime value (datetime/date/time)
|
|
2021 |
||
2022 |
@note
|
|
2023 |
This function will always produce some warning but won't increase cut
|
|
2024 |
fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current
|
|
2025 |
thread.
|
|
1
by brian
clean slate |
2026 |
*/
|
2027 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2028 |
void
|
2029 |
Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level, const uint32_t code, |
|
398.1.1
by Monty Taylor
Remove typedef enum enum_drizzle_timestamp_type timestamp_type; |
2030 |
double nr, enum enum_drizzle_timestamp_type ts_type) |
1
by brian
clean slate |
2031 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2032 |
Session *session= table ? table->in_use : current_session; |
2033 |
if (session->really_abort_on_warning() || |
|
1
by brian
clean slate |
2034 |
set_warning(level, code, 1)) |
2035 |
{
|
|
2036 |
/* DBL_DIG is enough to print '-[digits].E+###' */
|
|
2037 |
char str_nr[DBL_DIG + 8]; |
|
438.1.13
by Brian Aker
uint cleanup. |
2038 |
uint32_t str_len= sprintf(str_nr, "%g", nr); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
2039 |
make_truncated_value_warning(session, level, str_nr, str_len, ts_type, |
1
by brian
clean slate |
2040 |
field_name); |
2041 |
}
|
|
2042 |
}
|
|
575.4.7
by Monty Taylor
More header cleanup. |
2043 |