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