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