Merge lp:~tsarev/percona-server/18205_05_slave_type_conversions_error_on_truncate.patch into lp:percona-server/rnt-5.1
- 18205_05_slave_type_conversions_error_on_truncate.patch
- Merge into rnt-5.1
Proposed by
Oleg Tsarev
Status: | Merged |
---|---|
Approved by: | Laurynas Biveinis |
Approved revision: | no longer in the source branch. |
Merged at revision: | 214 |
Proposed branch: | lp:~tsarev/percona-server/18205_05_slave_type_conversions_error_on_truncate.patch |
Merge into: | lp:percona-server/rnt-5.1 |
Prerequisite: | lp:~tsarev/percona-server/18205_04_wl5151.patch |
Diff against target: |
4120 lines (+1336/-760) 1 file modified
patches/slave_type_conversions_error_on_truncate.patch (+1336/-760) |
To merge this branch: | bzr merge lp:~tsarev/percona-server/18205_05_slave_type_conversions_error_on_truncate.patch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Laurynas Biveinis (community) | Approve | ||
Review via email: mp+92709@code.launchpad.net |
Commit message
Description of the change
Fixed code policy in slave_type_
(issue 18205 - prepare lp:percona-server/rnt-5.1 patches to merge to lp:percona-server/5.1)
after merge this fix to lp:percona-server/rnt-5.1 I will propose for merge it to lp:percona-server/5.1
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'patches/slave_type_conversions_error_on_truncate.patch' |
2 | --- patches/slave_type_conversions_error_on_truncate.patch 2012-02-15 02:50:23 +0000 |
3 | +++ patches/slave_type_conversions_error_on_truncate.patch 2012-02-15 02:50:23 +0000 |
4 | @@ -5,141 +5,168 @@ |
5 | #!!! notice !!! |
6 | # Any small change to this file in the main branch |
7 | # should be done or reviewed by the maintainer! |
8 | ---- /dev/null |
9 | -+++ b/patch_info/slave_type_conversions_error_on_truncate.info |
10 | -@@ -0,0 +1,6 @@ |
11 | -+File=slave_type_concversions_error_on_truncate.info |
12 | -+Name=slave type conversions - error on truncate |
13 | -+Version=1.0 |
14 | -+Author=Percona <info@percona.com> |
15 | -+License=GPL |
16 | -+Comment= |
17 | --- a/sql/field.cc |
18 | +++ b/sql/field.cc |
19 | -@@ -1123,15 +1123,17 @@ |
20 | +@@ -1123,15 +1123,24 @@ |
21 | 2 error: garbage at the end of string. |
22 | */ |
23 | |
24 | -int Field_num::check_int(CHARSET_INFO *cs, const char *str, int length, |
25 | - const char *int_end, int error) |
26 | -+int Field_num::check_int_truncated(CHARSET_INFO *cs, const char *str, int length, |
27 | -+ const char *int_end, int error,bool *truncated) |
28 | ++int Field_num::check_int_truncated(CHARSET_INFO *cs, const char *str, |
29 | ++ int length, const char *int_end, int error, |
30 | ++ bool *truncated) |
31 | { |
32 | -+ if (truncated) { *truncated= false; } |
33 | ++ if (truncated) |
34 | ++ { |
35 | ++ *truncated= false; |
36 | ++ } |
37 | /* Test if we get an empty string or wrong integer */ |
38 | if (str == int_end || error == MY_ERRNO_EDOM) |
39 | { |
40 | char buff[128]; |
41 | String tmp(buff, (uint32) sizeof(buff), system_charset_info); |
42 | tmp.copy(str, length, system_charset_info); |
43 | -+ if (truncated) { *truncated= true; } |
44 | ++ if (truncated) |
45 | ++ { |
46 | ++ *truncated= true; |
47 | ++ } |
48 | push_warning_printf(table->in_use, MYSQL_ERROR::WARN_LEVEL_WARN, |
49 | ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, |
50 | ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), |
51 | -@@ -1142,6 +1144,7 @@ |
52 | +@@ -1142,6 +1151,10 @@ |
53 | /* Test if we have garbage at the end of the given string. */ |
54 | if (test_if_important_data(cs, int_end, str + length)) |
55 | { |
56 | -+ if (truncated) { *truncated= true; } |
57 | ++ if (truncated) |
58 | ++ { |
59 | ++ *truncated= true; |
60 | ++ } |
61 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); |
62 | return 2; |
63 | } |
64 | -@@ -1172,10 +1175,11 @@ |
65 | +@@ -1172,10 +1185,15 @@ |
66 | 1 error |
67 | */ |
68 | |
69 | -bool Field_num::get_int(CHARSET_INFO *cs, const char *from, uint len, |
70 | +- longlong *rnd, ulonglong unsigned_max, |
71 | +- longlong signed_min, longlong signed_max) |
72 | +bool Field_num::get_int_truncated(CHARSET_INFO *cs, const char *from, uint len, |
73 | - longlong *rnd, ulonglong unsigned_max, |
74 | -- longlong signed_min, longlong signed_max) |
75 | -+ longlong signed_min, longlong signed_max,bool *truncated) |
76 | ++ longlong *rnd, ulonglong unsigned_max, |
77 | ++ longlong signed_min, longlong signed_max, |
78 | ++ bool *truncated) |
79 | { |
80 | -+ if (truncated) { *truncated= false; } |
81 | ++ if (truncated) |
82 | ++ { |
83 | ++ *truncated= false; |
84 | ++ } |
85 | char *end; |
86 | int error; |
87 | |
88 | -@@ -1210,6 +1214,7 @@ |
89 | +@@ -1210,6 +1228,10 @@ |
90 | return 0; |
91 | |
92 | out_of_range: |
93 | -+ if (truncated) { *truncated= true; } |
94 | ++ if (truncated) |
95 | ++ { |
96 | ++ *truncated= true; |
97 | ++ } |
98 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
99 | return 1; |
100 | } |
101 | -@@ -1226,8 +1231,9 @@ |
102 | +@@ -1226,8 +1248,9 @@ |
103 | 0 no error or some other errors except overflow |
104 | */ |
105 | |
106 | -int Field::warn_if_overflow(int op_result) |
107 | +int Field::warn_if_overflow_truncated(int op_result, bool *truncated) |
108 | { |
109 | -+ if_overflow_truncated(op_result,truncated); |
110 | ++ if_overflow_truncated(op_result, truncated); |
111 | if (op_result == E_DEC_OVERFLOW) |
112 | { |
113 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
114 | -@@ -1609,29 +1615,31 @@ |
115 | +@@ -1609,29 +1632,42 @@ |
116 | @return |
117 | value converted from val |
118 | */ |
119 | -longlong Field::convert_decimal2longlong(const my_decimal *val, |
120 | - bool unsigned_flag, int *err) |
121 | +longlong Field::convert_decimal2longlong_truncated(const my_decimal *val, |
122 | -+ bool unsigned_flag, int *err, bool *truncated) |
123 | ++ bool unsigned_flag, int *err, |
124 | ++ bool *truncated) |
125 | { |
126 | -+ if (truncated) { *truncated= false; } |
127 | ++ if (truncated) |
128 | ++ { |
129 | ++ *truncated= false; |
130 | ++ } |
131 | longlong i; |
132 | if (unsigned_flag) |
133 | { |
134 | if (val->sign()) |
135 | { |
136 | -+ if (truncated) { *truncated= true; } |
137 | ++ if (truncated) |
138 | ++ { |
139 | ++ *truncated= true; |
140 | ++ } |
141 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
142 | i= 0; |
143 | *err= 1; |
144 | } |
145 | - else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR & |
146 | +- ~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED, |
147 | +- val, TRUE, &i))) |
148 | + else if (warn_if_overflow_truncated(my_decimal2int(E_DEC_ERROR & |
149 | - ~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED, |
150 | -- val, TRUE, &i))) |
151 | -+ val, TRUE, &i),truncated)) |
152 | ++ ~E_DEC_OVERFLOW & |
153 | ++ ~E_DEC_TRUNCATED, |
154 | ++ val, TRUE, &i), |
155 | ++ truncated)) |
156 | { |
157 | i= ~(longlong) 0; |
158 | *err= 1; |
159 | } |
160 | } |
161 | - else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR & |
162 | +- ~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED, |
163 | +- val, FALSE, &i))) |
164 | + else if (warn_if_overflow_truncated(my_decimal2int(E_DEC_ERROR & |
165 | - ~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED, |
166 | -- val, FALSE, &i))) |
167 | -+ val, FALSE, &i),truncated)) |
168 | ++ ~E_DEC_OVERFLOW & |
169 | ++ ~E_DEC_TRUNCATED, |
170 | ++ val, FALSE, &i), |
171 | ++ truncated)) |
172 | { |
173 | i= (val->sign() ? LONGLONG_MIN : LONGLONG_MAX); |
174 | *err= 1; |
175 | -@@ -1654,12 +1662,15 @@ |
176 | +@@ -1654,12 +1690,19 @@ |
177 | !=0 error |
178 | */ |
179 | |
180 | -int Field_num::store_decimal(const my_decimal *val) |
181 | -+int Field_num::store_decimal_truncated(const my_decimal *val,bool *truncated) |
182 | ++int Field_num::store_decimal_truncated(const my_decimal *val, bool *truncated) |
183 | { |
184 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
185 | - int err= 0; |
186 | +- int err= 0; |
187 | - longlong i= convert_decimal2longlong(val, unsigned_flag, &err); |
188 | - return test(err | store(i, unsigned_flag)); |
189 | -+ longlong i= convert_decimal2longlong_truncated(val, unsigned_flag, &err,truncated); |
190 | -+ bool truncated2 = false; |
191 | -+ int result= test(err | store_truncated(i, unsigned_flag,&truncated2)); |
192 | -+ if (truncated) { *truncated= (*truncated) || truncated2; } |
193 | ++ int err= 0; |
194 | ++ longlong i= convert_decimal2longlong_truncated(val, unsigned_flag, |
195 | ++ &err, truncated); |
196 | ++ bool truncated2= false; |
197 | ++ int result= test(err | store_truncated(i, unsigned_flag, &truncated2)); |
198 | ++ if (truncated) |
199 | ++ { |
200 | ++ *truncated= *truncated || truncated2; |
201 | ++ } |
202 | + return result; |
203 | } |
204 | |
205 | |
206 | -@@ -1726,14 +1737,17 @@ |
207 | +@@ -1726,14 +1769,20 @@ |
208 | !=0 error |
209 | */ |
210 | |
211 | -int Field_str::store_decimal(const my_decimal *d) |
212 | -+int Field_str::store_decimal_truncated(const my_decimal *d,bool *truncated) |
213 | ++int Field_str::store_decimal_truncated(const my_decimal *d, bool *truncated) |
214 | { |
215 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
216 | double val; |
217 | @@ -147,216 +174,288 @@ |
218 | - int err= warn_if_overflow(my_decimal2double(E_DEC_FATAL_ERROR & |
219 | - ~E_DEC_OVERFLOW, d, &val)); |
220 | - return err | store(val); |
221 | -+ int err= warn_if_overflow_truncated(my_decimal2double(E_DEC_FATAL_ERROR & |
222 | -+ ~E_DEC_OVERFLOW, d, &val),truncated); |
223 | ++ int err= my_decimal2double(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, d, &val); |
224 | ++ err= warn_if_overflow_truncated(err, truncated); |
225 | + bool truncated2= false; |
226 | -+ int result = err | store_truncated(val,&truncated2); |
227 | -+ if (truncated) { *truncated= (*truncated) || truncated2; } |
228 | ++ int result= err | store_truncated(val, &truncated2); |
229 | ++ if (truncated) |
230 | ++ { |
231 | ++ *truncated= (*truncated) || truncated2; |
232 | ++ } |
233 | + return result; |
234 | } |
235 | |
236 | |
237 | -@@ -1929,8 +1943,9 @@ |
238 | +@@ -1929,8 +1979,13 @@ |
239 | } |
240 | |
241 | |
242 | -int Field_decimal::store(const char *from_arg, uint len, CHARSET_INFO *cs) |
243 | -+int Field_decimal::store_truncated(const char *from_arg, uint len, CHARSET_INFO *cs,bool *truncated) |
244 | ++int Field_decimal::store_truncated(const char *from_arg, uint len, |
245 | ++ CHARSET_INFO *cs, bool *truncated) |
246 | { |
247 | -+ if (truncated) { *truncated= false; } |
248 | ++ if (truncated) |
249 | ++ { |
250 | ++ *truncated= false; |
251 | ++ } |
252 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
253 | char buff[STRING_BUFFER_USUAL_SIZE]; |
254 | String tmp(buff,sizeof(buff), &my_charset_bin); |
255 | -@@ -2003,6 +2018,7 @@ |
256 | +@@ -2003,6 +2058,10 @@ |
257 | from++; |
258 | if (from == end) |
259 | { |
260 | -+ if (truncated) { *truncated= true; } |
261 | ++ if (truncated) |
262 | ++ { |
263 | ++ *truncated= true; |
264 | ++ } |
265 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); |
266 | is_cuted_fields_incr=1; |
267 | } |
268 | -@@ -2018,6 +2034,7 @@ |
269 | +@@ -2018,6 +2077,10 @@ |
270 | { |
271 | if (sign_char=='-') |
272 | { |
273 | -+ if (truncated) { *truncated= true; } |
274 | ++ if (truncated) |
275 | ++ { |
276 | ++ *truncated= true; |
277 | ++ } |
278 | Field_decimal::overflow(1); |
279 | return 1; |
280 | } |
281 | -@@ -2079,6 +2096,7 @@ |
282 | +@@ -2079,6 +2142,10 @@ |
283 | for (;from != end && my_isspace(&my_charset_bin, *from); from++) ; |
284 | if (from != end) // If still something left, warn |
285 | { |
286 | -+ if (truncated) { *truncated= true; } |
287 | ++ if (truncated) |
288 | ++ { |
289 | ++ *truncated= true; |
290 | ++ } |
291 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); |
292 | is_cuted_fields_incr=1; |
293 | } |
294 | -@@ -2163,6 +2181,7 @@ |
295 | +@@ -2163,6 +2230,10 @@ |
296 | if (field_length < tmp_uint + (int) (sign_char == '-')) |
297 | { |
298 | // too big number, change to max or min number |
299 | -+ if (truncated) { *truncated= true; } |
300 | ++ if (truncated) |
301 | ++ { |
302 | ++ *truncated= true; |
303 | ++ } |
304 | Field_decimal::overflow(sign_char == '-'); |
305 | return 1; |
306 | } |
307 | -@@ -2257,8 +2276,11 @@ |
308 | +@@ -2257,8 +2328,14 @@ |
309 | if (tmp_char != '0') // Losing a non zero digit ? |
310 | { |
311 | if (!is_cuted_fields_incr) |
312 | + { |
313 | -+ if (truncated) { *truncated= true; } |
314 | ++ if (truncated) |
315 | ++ { |
316 | ++ *truncated= true; |
317 | ++ } |
318 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
319 | WARN_DATA_TRUNCATED, 1); |
320 | + } |
321 | return 0; |
322 | } |
323 | continue; |
324 | -@@ -2280,6 +2302,7 @@ |
325 | +@@ -2280,6 +2357,10 @@ |
326 | This is a note, not a warning, as we don't want to abort |
327 | when we cut decimals in strict mode |
328 | */ |
329 | -+ if (truncated) { *truncated= true; } |
330 | ++ if (truncated) |
331 | ++ { |
332 | ++ *truncated= true; |
333 | ++ } |
334 | set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1); |
335 | } |
336 | return 0; |
337 | -@@ -2295,17 +2318,20 @@ |
338 | +@@ -2295,17 +2376,29 @@ |
339 | } |
340 | |
341 | |
342 | -int Field_decimal::store(double nr) |
343 | -+int Field_decimal::store_truncated(double nr,bool *truncated) |
344 | ++int Field_decimal::store_truncated(double nr, bool *truncated) |
345 | { |
346 | -+ if (truncated) { *truncated= false; } |
347 | ++ if (truncated) |
348 | ++ { |
349 | ++ *truncated= false; |
350 | ++ } |
351 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
352 | if (unsigned_flag && nr < 0) |
353 | { |
354 | -+ if (truncated) { *truncated= true; } |
355 | ++ if (truncated) |
356 | ++ { |
357 | ++ *truncated= true; |
358 | ++ } |
359 | overflow(1); |
360 | return 1; |
361 | } |
362 | |
363 | if (!isfinite(nr)) // Handle infinity as special case |
364 | { |
365 | -+ if (truncated) { *truncated= true; } |
366 | ++ if (truncated) |
367 | ++ { |
368 | ++ *truncated= true; |
369 | ++ } |
370 | overflow(nr < 0.0); |
371 | return 1; |
372 | } |
373 | -@@ -2340,8 +2366,9 @@ |
374 | +@@ -2340,8 +2433,12 @@ |
375 | } |
376 | |
377 | |
378 | -int Field_decimal::store(longlong nr, bool unsigned_val) |
379 | -+int Field_decimal::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
380 | ++int Field_decimal::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
381 | { |
382 | -+ if (truncated) { *truncated= false; } |
383 | ++ if (truncated) |
384 | ++ { |
385 | ++ *truncated= false; |
386 | ++ } |
387 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
388 | char buff[22]; |
389 | uint length, int_part; |
390 | -@@ -2350,6 +2377,7 @@ |
391 | +@@ -2350,6 +2447,10 @@ |
392 | |
393 | if (nr < 0 && unsigned_flag && !unsigned_val) |
394 | { |
395 | -+ if (truncated) { *truncated= true; } |
396 | ++ if (truncated) |
397 | ++ { |
398 | ++ *truncated= true; |
399 | ++ } |
400 | overflow(1); |
401 | return 1; |
402 | } |
403 | -@@ -2620,8 +2648,9 @@ |
404 | +@@ -2620,8 +2721,13 @@ |
405 | 1 error |
406 | */ |
407 | |
408 | -bool Field_new_decimal::store_value(const my_decimal *decimal_value) |
409 | -+bool Field_new_decimal::store_value_truncated(const my_decimal *decimal_value,bool *truncated) |
410 | ++bool Field_new_decimal::store_value_truncated(const my_decimal *decimal_value, |
411 | ++ bool *truncated) |
412 | { |
413 | -+ if (truncated) { *truncated= false; } |
414 | ++ if (truncated) |
415 | ++ { |
416 | ++ *truncated= false; |
417 | ++ } |
418 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
419 | int error= 0; |
420 | DBUG_ENTER("Field_new_decimal::store_value"); |
421 | -@@ -2636,6 +2665,7 @@ |
422 | +@@ -2636,6 +2742,10 @@ |
423 | if (unsigned_flag && decimal_value->sign()) |
424 | { |
425 | DBUG_PRINT("info", ("unsigned overflow")); |
426 | -+ if (truncated) { *truncated= true; } |
427 | ++ if (truncated) |
428 | ++ { |
429 | ++ *truncated= true; |
430 | ++ } |
431 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
432 | error= 1; |
433 | decimal_value= &decimal_zero; |
434 | -@@ -2649,8 +2679,8 @@ |
435 | +@@ -2649,8 +2759,11 @@ |
436 | } |
437 | #endif |
438 | |
439 | - if (warn_if_overflow(my_decimal2binary(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, |
440 | - decimal_value, ptr, precision, dec))) |
441 | -+ if (warn_if_overflow_truncated(my_decimal2binary(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, |
442 | -+ decimal_value, ptr, precision, dec),truncated)) |
443 | ++ if (warn_if_overflow_truncated(my_decimal2binary(E_DEC_FATAL_ERROR & |
444 | ++ ~E_DEC_OVERFLOW, |
445 | ++ decimal_value, ptr, |
446 | ++ precision, dec), |
447 | ++ truncated)) |
448 | { |
449 | my_decimal buff; |
450 | DBUG_PRINT("info", ("overflow")); |
451 | -@@ -2664,9 +2694,10 @@ |
452 | +@@ -2664,9 +2777,14 @@ |
453 | } |
454 | |
455 | |
456 | -int Field_new_decimal::store(const char *from, uint length, |
457 | - CHARSET_INFO *charset_arg) |
458 | +int Field_new_decimal::store_truncated(const char *from, uint length, |
459 | -+ CHARSET_INFO *charset_arg,bool *truncated) |
460 | ++ CHARSET_INFO *charset_arg, |
461 | ++ bool *truncated) |
462 | { |
463 | -+ if (truncated) { *truncated= false; } |
464 | ++ if (truncated) |
465 | ++ { |
466 | ++ *truncated= false; |
467 | ++ } |
468 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
469 | int err; |
470 | my_decimal decimal_value; |
471 | -@@ -2682,6 +2713,7 @@ |
472 | +@@ -2682,6 +2800,10 @@ |
473 | String from_as_str; |
474 | from_as_str.copy(from, length, &my_charset_bin); |
475 | |
476 | -+ if (truncated) { *truncated= true; } |
477 | ++ if (truncated) |
478 | ++ { |
479 | ++ *truncated= true; |
480 | ++ } |
481 | push_warning_printf(table->in_use, MYSQL_ERROR::WARN_LEVEL_ERROR, |
482 | ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, |
483 | ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), |
484 | -@@ -2693,9 +2725,11 @@ |
485 | +@@ -2693,9 +2815,17 @@ |
486 | |
487 | switch (err) { |
488 | case E_DEC_TRUNCATED: |
489 | -+ if (truncated) { *truncated= true; } |
490 | ++ if (truncated) |
491 | ++ { |
492 | ++ *truncated= true; |
493 | ++ } |
494 | set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1); |
495 | break; |
496 | case E_DEC_OVERFLOW: |
497 | -+ if (truncated) { *truncated= true; } |
498 | ++ if (truncated) |
499 | ++ { |
500 | ++ *truncated= true; |
501 | ++ } |
502 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
503 | set_value_on_overflow(&decimal_value, decimal_value.sign()); |
504 | break; |
505 | -@@ -2721,7 +2755,9 @@ |
506 | +@@ -2721,7 +2851,12 @@ |
507 | DBUG_PRINT("enter", ("value: %s", |
508 | dbug_decimal_as_string(dbug_buff, &decimal_value))); |
509 | #endif |
510 | - store_value(&decimal_value); |
511 | + bool truncated2= false; |
512 | -+ store_value_truncated(&decimal_value,&truncated2); |
513 | -+ if (truncated) { *truncated = (*truncated) || truncated2; } |
514 | ++ store_value_truncated(&decimal_value, &truncated2); |
515 | ++ if (truncated) |
516 | ++ { |
517 | ++ *truncated= (*truncated) || truncated2; |
518 | ++ } |
519 | DBUG_RETURN(err); |
520 | } |
521 | |
522 | -@@ -2732,8 +2768,9 @@ |
523 | +@@ -2732,8 +2867,12 @@ |
524 | will return E_DEC_TRUNCATED always correctly |
525 | */ |
526 | |
527 | -int Field_new_decimal::store(double nr) |
528 | -+int Field_new_decimal::store_truncated(double nr,bool *truncated) |
529 | ++int Field_new_decimal::store_truncated(double nr, bool *truncated) |
530 | { |
531 | -+ if (truncated) { *truncated= false; } |
532 | ++ if (truncated) |
533 | ++ { |
534 | ++ *truncated= false; |
535 | ++ } |
536 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
537 | my_decimal decimal_value; |
538 | int err; |
539 | -@@ -2745,30 +2782,40 @@ |
540 | +@@ -2745,30 +2884,53 @@ |
541 | TODO: fix following when double2my_decimal when double2decimal |
542 | will return E_DEC_TRUNCATED always correctly |
543 | */ |
544 | -+ if_overflow_truncated(err,truncated); |
545 | ++ if_overflow_truncated(err, truncated); |
546 | if (!err) |
547 | { |
548 | double nr2; |
549 | my_decimal2double(E_DEC_FATAL_ERROR, &decimal_value, &nr2); |
550 | if (nr2 != nr) |
551 | + { |
552 | -+ if (truncated) { *truncated= true; } |
553 | ++ if (truncated) |
554 | ++ { |
555 | ++ *truncated= true; |
556 | ++ } |
557 | err= E_DEC_TRUNCATED; |
558 | + } |
559 | } |
560 | @@ -364,7 +463,10 @@ |
561 | { |
562 | if (check_overflow(err)) |
563 | + { |
564 | -+ if (truncated) { *truncated= true; } |
565 | ++ if (truncated) |
566 | ++ { |
567 | ++ *truncated= true; |
568 | ++ } |
569 | set_value_on_overflow(&decimal_value, decimal_value.sign()); |
570 | + } |
571 | /* Only issue a warning if store_value doesn't issue an warning */ |
572 | @@ -372,121 +474,150 @@ |
573 | } |
574 | - if (store_value(&decimal_value)) |
575 | + bool truncated2= false; |
576 | -+ if (store_value_truncated(&decimal_value,&truncated2)) |
577 | ++ if (store_value_truncated(&decimal_value, &truncated2)) |
578 | err= 1; |
579 | else if (err && !table->in_use->got_warning) |
580 | -- err= warn_if_overflow(err); |
581 | -+ err= warn_if_overflow(err);; |
582 | -+ if (truncated) { *truncated= (*truncated) || truncated2; }; |
583 | + err= warn_if_overflow(err); |
584 | ++ if (truncated) |
585 | ++ { |
586 | ++ *truncated= (*truncated) || truncated2; |
587 | ++ } |
588 | DBUG_RETURN(err); |
589 | } |
590 | |
591 | |
592 | -int Field_new_decimal::store(longlong nr, bool unsigned_val) |
593 | -+int Field_new_decimal::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
594 | ++int Field_new_decimal::store_truncated(longlong nr, bool unsigned_val, |
595 | ++ bool *truncated) |
596 | { |
597 | -+ if (truncated) { *truncated= false; } |
598 | ++ if (truncated) |
599 | ++ { |
600 | ++ *truncated= false; |
601 | ++ } |
602 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
603 | my_decimal decimal_value; |
604 | int err; |
605 | -@@ -2777,22 +2824,27 @@ |
606 | +@@ -2777,22 +2938,31 @@ |
607 | nr, unsigned_val, &decimal_value))) |
608 | { |
609 | if (check_overflow(err)) |
610 | + { |
611 | set_value_on_overflow(&decimal_value, decimal_value.sign()); |
612 | + } |
613 | -+ if_overflow_truncated(err,truncated); |
614 | ++ if_overflow_truncated(err, truncated); |
615 | /* Only issue a warning if store_value doesn't issue an warning */ |
616 | table->in_use->got_warning= 0; |
617 | } |
618 | - if (store_value(&decimal_value)) |
619 | + bool truncated2= false; |
620 | -+ if (store_value_truncated(&decimal_value,&truncated2)) |
621 | ++ if (store_value_truncated(&decimal_value, &truncated2)) |
622 | err= 1; |
623 | else if (err && !table->in_use->got_warning) |
624 | err= warn_if_overflow(err); |
625 | -+ if (truncated) { *truncated= (*truncated) || truncated2; } |
626 | ++ if (truncated) |
627 | ++ { |
628 | ++ *truncated= (*truncated) || truncated2; |
629 | ++ } |
630 | return err; |
631 | } |
632 | |
633 | |
634 | -int Field_new_decimal::store_decimal(const my_decimal *decimal_value) |
635 | -+int Field_new_decimal::store_decimal_truncated(const my_decimal *decimal_value,bool *truncated) |
636 | ++int Field_new_decimal::store_decimal_truncated(const my_decimal *decimal_value, |
637 | ++ bool *truncated) |
638 | { |
639 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
640 | - return store_value(decimal_value); |
641 | -+ return store_value_truncated(decimal_value,truncated); |
642 | ++ return store_value_truncated(decimal_value, truncated); |
643 | } |
644 | |
645 | |
646 | -@@ -3023,20 +3075,21 @@ |
647 | +@@ -3023,20 +3193,25 @@ |
648 | ** tiny int |
649 | ****************************************************************************/ |
650 | |
651 | -int Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs) |
652 | -+int Field_tiny::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
653 | ++int Field_tiny::store_truncated(const char *from, uint len, CHARSET_INFO *cs, |
654 | ++ bool *truncated) |
655 | { |
656 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
657 | int error; |
658 | longlong rnd; |
659 | |
660 | - error= get_int(cs, from, len, &rnd, 255, -128, 127); |
661 | -+ error= get_int_truncated(cs, from, len, &rnd, 255, -128, 127,truncated); |
662 | ++ error= get_int_truncated(cs, from, len, &rnd, 255, -128, 127, truncated); |
663 | ptr[0]= unsigned_flag ? (char) (ulonglong) rnd : (char) rnd; |
664 | return error; |
665 | } |
666 | |
667 | |
668 | -int Field_tiny::store(double nr) |
669 | -+int Field_tiny::store_truncated(double nr,bool *truncated) |
670 | ++int Field_tiny::store_truncated(double nr, bool *truncated) |
671 | { |
672 | -+ if (truncated) { *truncated= false; } |
673 | ++ if (truncated) |
674 | ++ { |
675 | ++ *truncated= false; |
676 | ++ } |
677 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
678 | int error= 0; |
679 | nr=rint(nr); |
680 | -@@ -3045,12 +3098,14 @@ |
681 | +@@ -3045,12 +3220,20 @@ |
682 | if (nr < 0.0) |
683 | { |
684 | *ptr=0; |
685 | -+ if (truncated) { *truncated= true; } |
686 | ++ if (truncated) |
687 | ++ { |
688 | ++ *truncated= true; |
689 | ++ } |
690 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
691 | error= 1; |
692 | } |
693 | else if (nr > 255.0) |
694 | { |
695 | *ptr=(char) 255; |
696 | -+ if (truncated) { *truncated= true; } |
697 | ++ if (truncated) |
698 | ++ { |
699 | ++ *truncated= true; |
700 | ++ } |
701 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
702 | error= 1; |
703 | } |
704 | -@@ -3062,12 +3117,14 @@ |
705 | +@@ -3062,12 +3245,20 @@ |
706 | if (nr < -128.0) |
707 | { |
708 | *ptr= (char) -128; |
709 | -+ if (truncated) { *truncated= true; } |
710 | ++ if (truncated) |
711 | ++ { |
712 | ++ *truncated= true; |
713 | ++ } |
714 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
715 | error= 1; |
716 | } |
717 | else if (nr > 127.0) |
718 | { |
719 | *ptr=127; |
720 | -+ if (truncated) { *truncated= true; } |
721 | ++ if (truncated) |
722 | ++ { |
723 | ++ *truncated= true; |
724 | ++ } |
725 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
726 | error= 1; |
727 | } |
728 | -@@ -3078,8 +3135,9 @@ |
729 | +@@ -3078,8 +3269,12 @@ |
730 | } |
731 | |
732 | |
733 | -int Field_tiny::store(longlong nr, bool unsigned_val) |
734 | +int Field_tiny::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
735 | { |
736 | -+ if (truncated) { *truncated= false; } |
737 | ++ if (truncated) |
738 | ++ { |
739 | ++ *truncated= false; |
740 | ++ } |
741 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
742 | int error= 0; |
743 | |
744 | -@@ -3088,13 +3146,11 @@ |
745 | +@@ -3088,13 +3283,11 @@ |
746 | if (nr < 0 && !unsigned_val) |
747 | { |
748 | *ptr= 0; |
749 | @@ -500,7 +631,7 @@ |
750 | error= 1; |
751 | } |
752 | else |
753 | -@@ -3107,18 +3163,21 @@ |
754 | +@@ -3107,18 +3300,24 @@ |
755 | if (nr < -128) |
756 | { |
757 | *ptr= (char) -128; |
758 | @@ -519,17 +650,21 @@ |
759 | + if (1 == error) |
760 | + { |
761 | + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
762 | -+ if (truncated) { *truncated= true; } |
763 | ++ if (truncated) |
764 | ++ { |
765 | ++ *truncated= true; |
766 | ++ } |
767 | + } |
768 | return error; |
769 | } |
770 | |
771 | -@@ -3198,14 +3257,14 @@ |
772 | +@@ -3198,14 +3397,16 @@ |
773 | Field type short int (2 byte) |
774 | ****************************************************************************/ |
775 | |
776 | -int Field_short::store(const char *from,uint len,CHARSET_INFO *cs) |
777 | -+int Field_short::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
778 | ++int Field_short::store_truncated(const char *from, uint len, CHARSET_INFO *cs, |
779 | ++ bool *truncated) |
780 | { |
781 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
782 | int store_tmp; |
783 | @@ -537,63 +672,82 @@ |
784 | longlong rnd; |
785 | |
786 | - error= get_int(cs, from, len, &rnd, UINT_MAX16, INT_MIN16, INT_MAX16); |
787 | -+ error= get_int_truncated(cs, from, len, &rnd, UINT_MAX16, INT_MIN16, INT_MAX16,truncated); |
788 | ++ error= get_int_truncated(cs, from, len, &rnd, UINT_MAX16, INT_MIN16, |
789 | ++ INT_MAX16, truncated); |
790 | store_tmp= unsigned_flag ? (int) (ulonglong) rnd : (int) rnd; |
791 | #ifdef WORDS_BIGENDIAN |
792 | if (table->s->db_low_byte_first) |
793 | -@@ -3219,8 +3278,9 @@ |
794 | +@@ -3219,8 +3420,12 @@ |
795 | } |
796 | |
797 | |
798 | -int Field_short::store(double nr) |
799 | -+int Field_short::store_truncated(double nr,bool *truncated) |
800 | ++int Field_short::store_truncated(double nr, bool *truncated) |
801 | { |
802 | -+ if (truncated) { *truncated= false; } |
803 | ++ if (truncated) |
804 | ++ { |
805 | ++ *truncated= false; |
806 | ++ } |
807 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
808 | int error= 0; |
809 | int16 res; |
810 | -@@ -3230,12 +3290,14 @@ |
811 | +@@ -3230,12 +3435,20 @@ |
812 | if (nr < 0) |
813 | { |
814 | res=0; |
815 | -+ if (truncated) { *truncated= true; } |
816 | ++ if (truncated) |
817 | ++ { |
818 | ++ *truncated= true; |
819 | ++ } |
820 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
821 | error= 1; |
822 | } |
823 | else if (nr > (double) UINT_MAX16) |
824 | { |
825 | res=(int16) UINT_MAX16; |
826 | -+ if (truncated) { *truncated= true; } |
827 | ++ if (truncated) |
828 | ++ { |
829 | ++ *truncated= true; |
830 | ++ } |
831 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
832 | error= 1; |
833 | } |
834 | -@@ -3247,12 +3309,14 @@ |
835 | +@@ -3247,12 +3460,20 @@ |
836 | if (nr < (double) INT_MIN16) |
837 | { |
838 | res=INT_MIN16; |
839 | -+ if (truncated) { *truncated= true; } |
840 | ++ if (truncated) |
841 | ++ { |
842 | ++ *truncated= true; |
843 | ++ } |
844 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
845 | error= 1; |
846 | } |
847 | else if (nr > (double) INT_MAX16) |
848 | { |
849 | res=INT_MAX16; |
850 | -+ if (truncated) { *truncated= true; } |
851 | ++ if (truncated) |
852 | ++ { |
853 | ++ *truncated= true; |
854 | ++ } |
855 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
856 | error= 1; |
857 | } |
858 | -@@ -3271,8 +3335,9 @@ |
859 | +@@ -3271,8 +3492,12 @@ |
860 | } |
861 | |
862 | |
863 | -int Field_short::store(longlong nr, bool unsigned_val) |
864 | +int Field_short::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
865 | { |
866 | -+ if (truncated) { *truncated= false; } |
867 | ++ if (truncated) |
868 | ++ { |
869 | ++ *truncated= false; |
870 | ++ } |
871 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
872 | int error= 0; |
873 | int16 res; |
874 | -@@ -3282,13 +3347,11 @@ |
875 | +@@ -3282,13 +3507,11 @@ |
876 | if (nr < 0L && !unsigned_val) |
877 | { |
878 | res=0; |
879 | @@ -607,7 +761,7 @@ |
880 | error= 1; |
881 | } |
882 | else |
883 | -@@ -3302,13 +3365,11 @@ |
884 | +@@ -3302,13 +3525,11 @@ |
885 | if (nr < INT_MIN16) |
886 | { |
887 | res=INT_MIN16; |
888 | @@ -621,24 +775,28 @@ |
889 | error= 1; |
890 | } |
891 | else |
892 | -@@ -3322,6 +3383,11 @@ |
893 | +@@ -3322,6 +3543,14 @@ |
894 | else |
895 | #endif |
896 | shortstore(ptr,res); |
897 | + if (1 == error) |
898 | + { |
899 | + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
900 | -+ if (truncated) { *truncated= true; } |
901 | ++ if (truncated) |
902 | ++ { |
903 | ++ *truncated= true; |
904 | ++ } |
905 | + } |
906 | return error; |
907 | } |
908 | |
909 | -@@ -3445,22 +3511,23 @@ |
910 | +@@ -3445,22 +3674,27 @@ |
911 | Field type medium int (3 byte) |
912 | ****************************************************************************/ |
913 | |
914 | -int Field_medium::store(const char *from,uint len,CHARSET_INFO *cs) |
915 | -+int Field_medium::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
916 | ++int Field_medium::store_truncated(const char *from, uint len, CHARSET_INFO *cs, |
917 | ++ bool *truncated) |
918 | { |
919 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
920 | int store_tmp; |
921 | @@ -646,7 +804,7 @@ |
922 | longlong rnd; |
923 | |
924 | - error= get_int(cs, from, len, &rnd, UINT_MAX24, INT_MIN24, INT_MAX24); |
925 | -+ error= get_int_truncated(cs, from, len, &rnd, UINT_MAX24, INT_MIN24, INT_MAX24,truncated); |
926 | ++ error= get_int_truncated(cs, from, len, &rnd, UINT_MAX24, INT_MIN24, INT_MAX24, truncated); |
927 | store_tmp= unsigned_flag ? (int) (ulonglong) rnd : (int) rnd; |
928 | int3store(ptr, store_tmp); |
929 | return error; |
930 | @@ -654,13 +812,16 @@ |
931 | |
932 | |
933 | -int Field_medium::store(double nr) |
934 | -+int Field_medium::store_truncated(double nr,bool *truncated) |
935 | ++int Field_medium::store_truncated(double nr, bool *truncated) |
936 | { |
937 | -+ if (truncated) { *truncated= false; } |
938 | ++ if (truncated) |
939 | ++ { |
940 | ++ *truncated= false; |
941 | ++ } |
942 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
943 | int error= 0; |
944 | nr=rint(nr); |
945 | -@@ -3469,14 +3536,12 @@ |
946 | +@@ -3469,14 +3703,12 @@ |
947 | if (nr < 0) |
948 | { |
949 | int3store(ptr,0); |
950 | @@ -675,7 +836,7 @@ |
951 | error= 1; |
952 | } |
953 | else |
954 | -@@ -3488,25 +3553,29 @@ |
955 | +@@ -3488,25 +3720,35 @@ |
956 | { |
957 | long tmp=(long) INT_MIN24; |
958 | int3store(ptr,tmp); |
959 | @@ -694,7 +855,10 @@ |
960 | } |
961 | + if(1 == error) |
962 | + { |
963 | -+ if (truncated) { *truncated= true; } |
964 | ++ if (truncated) |
965 | ++ { |
966 | ++ *truncated= true; |
967 | ++ } |
968 | + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
969 | + } |
970 | return error; |
971 | @@ -704,11 +868,14 @@ |
972 | -int Field_medium::store(longlong nr, bool unsigned_val) |
973 | +int Field_medium::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
974 | { |
975 | -+ if (truncated) { *truncated= false; } |
976 | ++ if (truncated) |
977 | ++ { |
978 | ++ *truncated= false; |
979 | ++ } |
980 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
981 | int error= 0; |
982 | |
983 | -@@ -3515,14 +3584,12 @@ |
984 | +@@ -3515,14 +3757,12 @@ |
985 | if (nr < 0 && !unsigned_val) |
986 | { |
987 | int3store(ptr,0); |
988 | @@ -723,7 +890,7 @@ |
989 | error= 1; |
990 | } |
991 | else |
992 | -@@ -3537,19 +3604,22 @@ |
993 | +@@ -3537,19 +3777,25 @@ |
994 | { |
995 | long tmp= (long) INT_MIN24; |
996 | int3store(ptr,tmp); |
997 | @@ -743,17 +910,21 @@ |
998 | + if (1 == error) |
999 | + { |
1000 | + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1001 | -+ if (truncated) { *truncated= true; } |
1002 | ++ if (truncated) |
1003 | ++ { |
1004 | ++ *truncated= true; |
1005 | ++ } |
1006 | + } |
1007 | return error; |
1008 | } |
1009 | |
1010 | -@@ -3635,14 +3705,14 @@ |
1011 | +@@ -3635,14 +3881,16 @@ |
1012 | ** long int |
1013 | ****************************************************************************/ |
1014 | |
1015 | -int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) |
1016 | -+int Field_long::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
1017 | ++int Field_long::store_truncated(const char *from, uint len, CHARSET_INFO *cs, |
1018 | ++ bool *truncated) |
1019 | { |
1020 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1021 | long store_tmp; |
1022 | @@ -761,22 +932,26 @@ |
1023 | longlong rnd; |
1024 | |
1025 | - error= get_int(cs, from, len, &rnd, UINT_MAX32, INT_MIN32, INT_MAX32); |
1026 | -+ error= get_int_truncated(cs, from, len, &rnd, UINT_MAX32, INT_MIN32, INT_MAX32,truncated); |
1027 | ++ error= get_int_truncated(cs, from, len, &rnd, UINT_MAX32, INT_MIN32, |
1028 | ++ INT_MAX32, truncated); |
1029 | store_tmp= unsigned_flag ? (long) (ulonglong) rnd : (long) rnd; |
1030 | #ifdef WORDS_BIGENDIAN |
1031 | if (table->s->db_low_byte_first) |
1032 | -@@ -3656,8 +3726,9 @@ |
1033 | +@@ -3656,8 +3904,12 @@ |
1034 | } |
1035 | |
1036 | |
1037 | -int Field_long::store(double nr) |
1038 | -+int Field_long::store_truncated(double nr,bool *truncated) |
1039 | ++int Field_long::store_truncated(double nr, bool *truncated) |
1040 | { |
1041 | -+ if (truncated) { *truncated= false; } |
1042 | ++ if (truncated) |
1043 | ++ { |
1044 | ++ *truncated= false; |
1045 | ++ } |
1046 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1047 | int error= 0; |
1048 | int32 res; |
1049 | -@@ -3672,7 +3743,6 @@ |
1050 | +@@ -3672,7 +3924,6 @@ |
1051 | else if (nr > (double) UINT_MAX32) |
1052 | { |
1053 | res= UINT_MAX32; |
1054 | @@ -784,302 +959,389 @@ |
1055 | error= 1; |
1056 | } |
1057 | else |
1058 | -@@ -3693,8 +3763,11 @@ |
1059 | +@@ -3693,8 +3944,14 @@ |
1060 | else |
1061 | res=(int32) (longlong) nr; |
1062 | } |
1063 | - if (error) |
1064 | + if (1 == error) |
1065 | + { |
1066 | -+ if (truncated) { *truncated= true; } |
1067 | ++ if (truncated) |
1068 | ++ { |
1069 | ++ *truncated= true; |
1070 | ++ } |
1071 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1072 | + } |
1073 | |
1074 | #ifdef WORDS_BIGENDIAN |
1075 | if (table->s->db_low_byte_first) |
1076 | -@@ -3708,8 +3781,9 @@ |
1077 | +@@ -3708,8 +3965,12 @@ |
1078 | } |
1079 | |
1080 | |
1081 | -int Field_long::store(longlong nr, bool unsigned_val) |
1082 | +int Field_long::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
1083 | { |
1084 | -+ if (truncated) { *truncated= false; } |
1085 | ++ if (truncated) |
1086 | ++ { |
1087 | ++ *truncated= false; |
1088 | ++ } |
1089 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1090 | int error= 0; |
1091 | int32 res; |
1092 | -@@ -3746,8 +3820,11 @@ |
1093 | +@@ -3746,8 +4007,14 @@ |
1094 | else |
1095 | res=(int32) nr; |
1096 | } |
1097 | - if (error) |
1098 | + if (1 == error) |
1099 | + { |
1100 | -+ if (truncated) { *truncated= true; } |
1101 | ++ if (truncated) |
1102 | ++ { |
1103 | ++ *truncated= true; |
1104 | ++ } |
1105 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1106 | + } |
1107 | |
1108 | #ifdef WORDS_BIGENDIAN |
1109 | if (table->s->db_low_byte_first) |
1110 | -@@ -3882,8 +3959,9 @@ |
1111 | +@@ -3882,8 +4149,13 @@ |
1112 | Field type longlong int (8 bytes) |
1113 | ****************************************************************************/ |
1114 | |
1115 | -int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs) |
1116 | -+int Field_longlong::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
1117 | ++int Field_longlong::store_truncated(const char *from, uint len, |
1118 | ++ CHARSET_INFO *cs, bool *truncated) |
1119 | { |
1120 | -+ if (truncated) { *truncated= false; } |
1121 | ++ if (truncated) |
1122 | ++ { |
1123 | ++ *truncated= false; |
1124 | ++ } |
1125 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1126 | int error= 0; |
1127 | char *end; |
1128 | -@@ -3892,11 +3970,12 @@ |
1129 | +@@ -3892,11 +4164,15 @@ |
1130 | tmp= cs->cset->strntoull10rnd(cs,from,len,unsigned_flag,&end,&error); |
1131 | if (error == MY_ERRNO_ERANGE) |
1132 | { |
1133 | -+ if (truncated) { *truncated= true; } |
1134 | ++ if (truncated) |
1135 | ++ { |
1136 | ++ *truncated= true; |
1137 | ++ } |
1138 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1139 | error= 1; |
1140 | } |
1141 | else if (table->in_use->count_cuted_fields && |
1142 | - check_int(cs, from, len, end, error)) |
1143 | -+ check_int_truncated(cs, from, len, end, error,truncated)) |
1144 | ++ check_int_truncated(cs, from, len, end, error, truncated)) |
1145 | error= 1; |
1146 | else |
1147 | error= 0; |
1148 | -@@ -3912,8 +3991,9 @@ |
1149 | +@@ -3912,8 +4188,12 @@ |
1150 | } |
1151 | |
1152 | |
1153 | -int Field_longlong::store(double nr) |
1154 | -+int Field_longlong::store_truncated(double nr,bool *truncated) |
1155 | ++int Field_longlong::store_truncated(double nr, bool *truncated) |
1156 | { |
1157 | -+ if (truncated) { *truncated= false; } |
1158 | ++ if (truncated) |
1159 | ++ { |
1160 | ++ *truncated= false; |
1161 | ++ } |
1162 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1163 | int error= 0; |
1164 | longlong res; |
1165 | -@@ -3950,7 +4030,10 @@ |
1166 | +@@ -3950,7 +4230,13 @@ |
1167 | res=(longlong) nr; |
1168 | } |
1169 | if (error) |
1170 | + { |
1171 | -+ if (truncated) { *truncated= true; } |
1172 | ++ if (truncated) |
1173 | ++ { |
1174 | ++ *truncated= true; |
1175 | ++ } |
1176 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1177 | + } |
1178 | |
1179 | #ifdef WORDS_BIGENDIAN |
1180 | if (table->s->db_low_byte_first) |
1181 | -@@ -3964,8 +4047,9 @@ |
1182 | +@@ -3964,8 +4250,12 @@ |
1183 | } |
1184 | |
1185 | |
1186 | -int Field_longlong::store(longlong nr, bool unsigned_val) |
1187 | +int Field_longlong::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
1188 | { |
1189 | -+ if (truncated) { *truncated= false; } |
1190 | ++ if (truncated) |
1191 | ++ { |
1192 | ++ *truncated= false; |
1193 | ++ } |
1194 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1195 | int error= 0; |
1196 | |
1197 | -@@ -3979,6 +4063,7 @@ |
1198 | +@@ -3979,6 +4269,10 @@ |
1199 | { |
1200 | nr= unsigned_flag ? (ulonglong) 0 : (ulonglong) LONGLONG_MAX; |
1201 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1202 | -+ if (truncated) { *truncated= true; } |
1203 | ++ if (truncated) |
1204 | ++ { |
1205 | ++ *truncated= true; |
1206 | ++ } |
1207 | error= 1; |
1208 | } |
1209 | } |
1210 | -@@ -4173,27 +4258,31 @@ |
1211 | +@@ -4173,27 +4467,41 @@ |
1212 | single precision float |
1213 | ****************************************************************************/ |
1214 | |
1215 | -int Field_float::store(const char *from,uint len,CHARSET_INFO *cs) |
1216 | -+int Field_float::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
1217 | ++int Field_float::store_truncated(const char *from, uint len, CHARSET_INFO* cs, |
1218 | ++ bool *truncated) |
1219 | { |
1220 | -+ if (truncated) { *truncated= false; } |
1221 | ++ if (truncated) |
1222 | ++ { |
1223 | ++ *truncated= false; |
1224 | ++ } |
1225 | int error; |
1226 | char *end; |
1227 | double nr= my_strntod(cs,(char*) from,len,&end,&error); |
1228 | if (error || (!len || ((uint) (end-from) != len && |
1229 | table->in_use->count_cuted_fields))) |
1230 | { |
1231 | -+ if (truncated) { *truncated= true; } |
1232 | ++ if (truncated) |
1233 | ++ { |
1234 | ++ *truncated= true; |
1235 | ++ } |
1236 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1237 | (error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); |
1238 | error= error ? 1 : 2; |
1239 | } |
1240 | - Field_float::store(nr); |
1241 | + bool truncated2= false; |
1242 | -+ Field_float::store_truncated(nr,&truncated2); |
1243 | -+ if (truncated) { *truncated= (*truncated) || truncated2; } |
1244 | ++ Field_float::store_truncated(nr, &truncated2); |
1245 | ++ if (truncated) |
1246 | ++ { |
1247 | ++ *truncated= (*truncated) || truncated2; |
1248 | ++ } |
1249 | return error; |
1250 | } |
1251 | |
1252 | |
1253 | -int Field_float::store(double nr) |
1254 | -+int Field_float::store_truncated(double nr,bool *truncated) |
1255 | ++int Field_float::store_truncated(double nr, bool *truncated) |
1256 | { |
1257 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1258 | - int error= truncate(&nr, FLT_MAX); |
1259 | -+ int error= truncate_truncated(&nr, FLT_MAX,truncated); |
1260 | ++ int error= truncate_truncated(&nr, FLT_MAX, truncated); |
1261 | float j= (float)nr; |
1262 | |
1263 | #ifdef WORDS_BIGENDIAN |
1264 | -@@ -4208,10 +4297,10 @@ |
1265 | +@@ -4208,10 +4516,12 @@ |
1266 | } |
1267 | |
1268 | |
1269 | -int Field_float::store(longlong nr, bool unsigned_val) |
1270 | -+int Field_float::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
1271 | ++int Field_float::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
1272 | { |
1273 | - return Field_float::store(unsigned_val ? ulonglong2double((ulonglong) nr) : |
1274 | - (double) nr); |
1275 | -+ return Field_float::store_truncated(unsigned_val ? ulonglong2double((ulonglong) nr) : |
1276 | -+ (double) nr,truncated); |
1277 | ++ return Field_float::store_truncated(unsigned_val ? |
1278 | ++ ulonglong2double((ulonglong) nr) : |
1279 | ++ (double) nr, |
1280 | ++ truncated); |
1281 | } |
1282 | |
1283 | |
1284 | -@@ -4435,27 +4524,31 @@ |
1285 | +@@ -4435,27 +4745,41 @@ |
1286 | double precision floating point numbers |
1287 | ****************************************************************************/ |
1288 | |
1289 | -int Field_double::store(const char *from,uint len,CHARSET_INFO *cs) |
1290 | -+int Field_double::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
1291 | ++int Field_double::store_truncated(const char *from, uint len, CHARSET_INFO *cs, |
1292 | ++ bool *truncated) |
1293 | { |
1294 | -+ if (truncated) { *truncated= false; } |
1295 | ++ if (truncated) |
1296 | ++ { |
1297 | ++ *truncated= false; |
1298 | ++ } |
1299 | int error; |
1300 | char *end; |
1301 | double nr= my_strntod(cs,(char*) from, len, &end, &error); |
1302 | if (error || (!len || ((uint) (end-from) != len && |
1303 | table->in_use->count_cuted_fields))) |
1304 | { |
1305 | -+ if (truncated) { *truncated= true; } |
1306 | ++ if (truncated) |
1307 | ++ { |
1308 | ++ *truncated= true; |
1309 | ++ } |
1310 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1311 | (error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); |
1312 | error= error ? 1 : 2; |
1313 | } |
1314 | - Field_double::store(nr); |
1315 | + bool truncated2= false; |
1316 | -+ Field_double::store_truncated(nr,&truncated2); |
1317 | -+ if (truncated) { *truncated= (*truncated) || truncated2; } |
1318 | ++ Field_double::store_truncated(nr, &truncated2); |
1319 | ++ if (truncated) |
1320 | ++ { |
1321 | ++ *truncated= (*truncated) || truncated2; |
1322 | ++ } |
1323 | return error; |
1324 | } |
1325 | |
1326 | |
1327 | -int Field_double::store(double nr) |
1328 | -+int Field_double::store_truncated(double nr,bool *truncated) |
1329 | ++int Field_double::store_truncated(double nr, bool *truncated) |
1330 | { |
1331 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1332 | - int error= truncate(&nr, DBL_MAX); |
1333 | -+ int error= truncate_truncated(&nr, DBL_MAX,truncated); |
1334 | ++ int error= truncate_truncated(&nr, DBL_MAX, truncated); |
1335 | |
1336 | #ifdef WORDS_BIGENDIAN |
1337 | if (table->s->db_low_byte_first) |
1338 | -@@ -4469,10 +4562,10 @@ |
1339 | +@@ -4469,10 +4793,12 @@ |
1340 | } |
1341 | |
1342 | |
1343 | -int Field_double::store(longlong nr, bool unsigned_val) |
1344 | -+int Field_double::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
1345 | ++int Field_double::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
1346 | { |
1347 | - return Field_double::store(unsigned_val ? ulonglong2double((ulonglong) nr) : |
1348 | - (double) nr); |
1349 | -+ return Field_double::store_truncated(unsigned_val ? ulonglong2double((ulonglong) nr) : |
1350 | -+ (double) nr,truncated); |
1351 | ++ return Field_double::store_truncated(unsigned_val ? |
1352 | ++ ulonglong2double((ulonglong) nr) : |
1353 | ++ (double) nr, |
1354 | ++ truncated); |
1355 | } |
1356 | |
1357 | /* |
1358 | -@@ -4481,8 +4574,9 @@ |
1359 | +@@ -4481,8 +4807,13 @@ |
1360 | Also ensure that the argument is within [-max_value; max_value] range. |
1361 | */ |
1362 | |
1363 | -int Field_real::truncate(double *nr, double max_value) |
1364 | -+int Field_real::truncate_truncated(double *nr, double max_value,bool *truncated) |
1365 | ++int Field_real::truncate_truncated(double *nr, double max_value, |
1366 | ++ bool *truncated) |
1367 | { |
1368 | -+ if (truncated) { *truncated= false; } |
1369 | ++ if (truncated) |
1370 | ++ { |
1371 | ++ *truncated= false; |
1372 | ++ } |
1373 | int error= 1; |
1374 | double res= *nr; |
1375 | |
1376 | -@@ -4490,12 +4584,14 @@ |
1377 | +@@ -4490,12 +4820,20 @@ |
1378 | { |
1379 | res= 0; |
1380 | set_null(); |
1381 | -+ if (truncated) { *truncated= true; } |
1382 | ++ if (truncated) |
1383 | ++ { |
1384 | ++ *truncated= true; |
1385 | ++ } |
1386 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1387 | goto end; |
1388 | } |
1389 | else if (unsigned_flag && res < 0) |
1390 | { |
1391 | res= 0; |
1392 | -+ if (truncated) { *truncated= true; } |
1393 | ++ if (truncated) |
1394 | ++ { |
1395 | ++ *truncated= true; |
1396 | ++ } |
1397 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1398 | goto end; |
1399 | } |
1400 | -@@ -4517,11 +4613,13 @@ |
1401 | +@@ -4516,12 +4854,20 @@ |
1402 | + |
1403 | if (res < -max_value) |
1404 | { |
1405 | - res= -max_value; |
1406 | -+ if (truncated) { *truncated= true; } |
1407 | - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1408 | +- res= -max_value; |
1409 | +- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1410 | ++ res= -max_value; |
1411 | ++ if (truncated) |
1412 | ++ { |
1413 | ++ *truncated= true; |
1414 | ++ } |
1415 | ++ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1416 | } |
1417 | else if (res > max_value) |
1418 | { |
1419 | res= max_value; |
1420 | -+ if (truncated) { *truncated= true; } |
1421 | ++ if (truncated) |
1422 | ++ { |
1423 | ++ *truncated= true; |
1424 | ++ } |
1425 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1426 | } |
1427 | else |
1428 | -@@ -4533,11 +4631,11 @@ |
1429 | +@@ -4533,11 +4879,11 @@ |
1430 | } |
1431 | |
1432 | |
1433 | -int Field_real::store_decimal(const my_decimal *dm) |
1434 | -+int Field_real::store_decimal_truncated(const my_decimal *dm,bool *truncated) |
1435 | ++int Field_real::store_decimal_truncated(const my_decimal *dm, bool *truncated) |
1436 | { |
1437 | double dbl; |
1438 | my_decimal2double(E_DEC_FATAL_ERROR, dm, &dbl); |
1439 | - return store(dbl); |
1440 | -+ return store_truncated(dbl,truncated); |
1441 | ++ return store_truncated(dbl, truncated); |
1442 | } |
1443 | |
1444 | double Field_double::val_real(void) |
1445 | -@@ -4879,8 +4977,9 @@ |
1446 | +@@ -4879,8 +5225,13 @@ |
1447 | } |
1448 | |
1449 | |
1450 | -int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) |
1451 | -+int Field_timestamp::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
1452 | ++int Field_timestamp::store_truncated(const char *from, uint len, |
1453 | ++ CHARSET_INFO *cs, bool *truncated) |
1454 | { |
1455 | -+ if (truncated) { *truncated= false; } |
1456 | ++ if (truncated) |
1457 | ++ { |
1458 | ++ *truncated= false; |
1459 | ++ } |
1460 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1461 | MYSQL_TIME l_time; |
1462 | my_time_t tmp= 0; |
1463 | -@@ -4899,6 +4998,7 @@ |
1464 | +@@ -4899,6 +5250,10 @@ |
1465 | if (error || !have_smth_to_conv) |
1466 | { |
1467 | error= 1; |
1468 | -+ if (truncated) { *truncated= true; } |
1469 | ++ if (truncated) |
1470 | ++ { |
1471 | ++ *truncated= true; |
1472 | ++ } |
1473 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, |
1474 | from, len, MYSQL_TIMESTAMP_DATETIME, 1); |
1475 | } |
1476 | -@@ -4908,6 +5008,7 @@ |
1477 | +@@ -4908,6 +5263,10 @@ |
1478 | { |
1479 | if (!(tmp= TIME_to_timestamp(thd, &l_time, &in_dst_time_gap))) |
1480 | { |
1481 | -+ if (truncated) { *truncated= true; } |
1482 | ++ if (truncated) |
1483 | ++ { |
1484 | ++ *truncated= true; |
1485 | ++ } |
1486 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1487 | ER_WARN_DATA_OUT_OF_RANGE, |
1488 | from, len, MYSQL_TIMESTAMP_DATETIME, !error); |
1489 | -@@ -4926,24 +5027,29 @@ |
1490 | +@@ -4926,24 +5285,41 @@ |
1491 | } |
1492 | |
1493 | |
1494 | -int Field_timestamp::store(double nr) |
1495 | -+int Field_timestamp::store_truncated(double nr,bool *truncated) |
1496 | ++int Field_timestamp::store_truncated(double nr, bool *truncated) |
1497 | { |
1498 | -+ if (truncated) { *truncated= false; } |
1499 | ++ if (truncated) |
1500 | ++ { |
1501 | ++ *truncated= false; |
1502 | ++ } |
1503 | int error= 0; |
1504 | if (nr < 0 || nr > 99991231235959.0) |
1505 | { |
1506 | -+ if (truncated) { *truncated= true; } |
1507 | ++ if (truncated) |
1508 | ++ { |
1509 | ++ *truncated= true; |
1510 | ++ } |
1511 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1512 | ER_WARN_DATA_OUT_OF_RANGE, |
1513 | nr, MYSQL_TIMESTAMP_DATETIME); |
1514 | @@ -1087,34 +1349,46 @@ |
1515 | error= 1; |
1516 | } |
1517 | - error|= Field_timestamp::store((longlong) rint(nr), FALSE); |
1518 | -+ bool truncated2 = false; |
1519 | -+ error|= Field_timestamp::store_truncated((longlong) rint(nr), FALSE,&truncated2); |
1520 | -+ if (truncated) { *truncated= (*truncated) || truncated2; } |
1521 | ++ bool truncated2= false; |
1522 | ++ error|= Field_timestamp::store_truncated((longlong) rint(nr), FALSE, &truncated2); |
1523 | ++ if (truncated) |
1524 | ++ { |
1525 | ++ *truncated= (*truncated) || truncated2; |
1526 | ++ } |
1527 | return error; |
1528 | } |
1529 | |
1530 | |
1531 | -int Field_timestamp::store(longlong nr, bool unsigned_val) |
1532 | -+int Field_timestamp::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
1533 | ++int Field_timestamp::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
1534 | { |
1535 | -+ if (truncated) { *truncated= false; } |
1536 | ++ if (truncated) |
1537 | ++ { |
1538 | ++ *truncated= false; |
1539 | ++ } |
1540 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1541 | MYSQL_TIME l_time; |
1542 | my_time_t timestamp= 0; |
1543 | -@@ -4964,6 +5070,7 @@ |
1544 | +@@ -4964,6 +5340,10 @@ |
1545 | { |
1546 | if (!(timestamp= TIME_to_timestamp(thd, &l_time, &in_dst_time_gap))) |
1547 | { |
1548 | -+ if (truncated) { *truncated= true; } |
1549 | ++ if (truncated) |
1550 | ++ { |
1551 | ++ *truncated= true; |
1552 | ++ } |
1553 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1554 | ER_WARN_DATA_OUT_OF_RANGE, |
1555 | nr, MYSQL_TIMESTAMP_DATETIME, 1); |
1556 | -@@ -4977,9 +5084,12 @@ |
1557 | +@@ -4977,9 +5357,15 @@ |
1558 | error= 1; |
1559 | } |
1560 | } else if (error) |
1561 | + { |
1562 | -+ if (truncated) { *truncated= true; } |
1563 | ++ if (truncated) |
1564 | ++ { |
1565 | ++ *truncated= true; |
1566 | ++ } |
1567 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1568 | WARN_DATA_TRUNCATED, |
1569 | nr, MYSQL_TIMESTAMP_DATETIME, 1); |
1570 | @@ -1122,224 +1396,296 @@ |
1571 | |
1572 | store_timestamp(timestamp); |
1573 | return error; |
1574 | -@@ -5189,8 +5299,9 @@ |
1575 | +@@ -5189,8 +5575,13 @@ |
1576 | ** Stored as a 3 byte unsigned int |
1577 | ****************************************************************************/ |
1578 | |
1579 | -int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) |
1580 | -+int Field_time::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
1581 | ++int Field_time::store_truncated(const char *from, uint len, CHARSET_INFO *cs, |
1582 | ++ bool *truncated) |
1583 | { |
1584 | -+ if (truncated) { *truncated= false; } |
1585 | ++ if (truncated) |
1586 | ++ { |
1587 | ++ *truncated= false; |
1588 | ++ } |
1589 | MYSQL_TIME ltime; |
1590 | long tmp; |
1591 | int error= 0; |
1592 | -@@ -5200,6 +5311,7 @@ |
1593 | +@@ -5200,6 +5591,10 @@ |
1594 | { |
1595 | tmp=0L; |
1596 | error= 2; |
1597 | -+ if (truncated) { *truncated= true; } |
1598 | ++ if (truncated) |
1599 | ++ { |
1600 | ++ *truncated= true; |
1601 | ++ } |
1602 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, |
1603 | from, len, MYSQL_TIMESTAMP_TIME, 1); |
1604 | } |
1605 | -@@ -5207,6 +5319,7 @@ |
1606 | +@@ -5207,6 +5602,10 @@ |
1607 | { |
1608 | if (warning & MYSQL_TIME_WARN_TRUNCATED) |
1609 | { |
1610 | -+ if (truncated) { *truncated= true; } |
1611 | ++ if (truncated) |
1612 | ++ { |
1613 | ++ *truncated= true; |
1614 | ++ } |
1615 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1616 | WARN_DATA_TRUNCATED, |
1617 | from, len, MYSQL_TIMESTAMP_TIME, 1); |
1618 | -@@ -5214,6 +5327,7 @@ |
1619 | +@@ -5214,6 +5613,10 @@ |
1620 | } |
1621 | if (warning & MYSQL_TIME_WARN_OUT_OF_RANGE) |
1622 | { |
1623 | -+ if (truncated) { *truncated= true; } |
1624 | ++ if (truncated) |
1625 | ++ { |
1626 | ++ *truncated= true; |
1627 | ++ } |
1628 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1629 | ER_WARN_DATA_OUT_OF_RANGE, |
1630 | from, len, MYSQL_TIMESTAMP_TIME, !error); |
1631 | -@@ -5241,14 +5355,16 @@ |
1632 | +@@ -5241,14 +5644,22 @@ |
1633 | } |
1634 | |
1635 | |
1636 | -int Field_time::store(double nr) |
1637 | -+int Field_time::store_truncated(double nr,bool *truncated) |
1638 | ++int Field_time::store_truncated(double nr, bool *truncated) |
1639 | { |
1640 | -+ if (truncated) { *truncated= false; } |
1641 | ++ if (truncated) |
1642 | ++ { |
1643 | ++ *truncated= false; |
1644 | ++ } |
1645 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1646 | long tmp; |
1647 | int error= 0; |
1648 | if (nr > (double)TIME_MAX_VALUE) |
1649 | { |
1650 | tmp= TIME_MAX_VALUE; |
1651 | -+ if (truncated) { *truncated= true; } |
1652 | ++ if (truncated) |
1653 | ++ { |
1654 | ++ *truncated= true; |
1655 | ++ } |
1656 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1657 | ER_WARN_DATA_OUT_OF_RANGE, nr, MYSQL_TIMESTAMP_TIME); |
1658 | error= 1; |
1659 | -@@ -5256,6 +5372,7 @@ |
1660 | +@@ -5256,6 +5667,10 @@ |
1661 | else if (nr < (double)-TIME_MAX_VALUE) |
1662 | { |
1663 | tmp= -TIME_MAX_VALUE; |
1664 | -+ if (truncated) { *truncated= true; } |
1665 | ++ if (truncated) |
1666 | ++ { |
1667 | ++ *truncated= true; |
1668 | ++ } |
1669 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1670 | ER_WARN_DATA_OUT_OF_RANGE, nr, MYSQL_TIMESTAMP_TIME); |
1671 | error= 1; |
1672 | -@@ -5268,6 +5385,7 @@ |
1673 | +@@ -5268,6 +5683,10 @@ |
1674 | if (tmp % 100 > 59 || tmp/100 % 100 > 59) |
1675 | { |
1676 | tmp=0; |
1677 | -+ if (truncated) { *truncated= true; } |
1678 | ++ if (truncated) |
1679 | ++ { |
1680 | ++ *truncated= true; |
1681 | ++ } |
1682 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1683 | ER_WARN_DATA_OUT_OF_RANGE, nr, |
1684 | MYSQL_TIMESTAMP_TIME); |
1685 | -@@ -5279,14 +5397,16 @@ |
1686 | +@@ -5279,14 +5698,22 @@ |
1687 | } |
1688 | |
1689 | |
1690 | -int Field_time::store(longlong nr, bool unsigned_val) |
1691 | -+int Field_time::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
1692 | ++int Field_time::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
1693 | { |
1694 | -+ if (truncated) { *truncated= false; } |
1695 | ++ if (truncated) |
1696 | ++ { |
1697 | ++ *truncated= false; |
1698 | ++ } |
1699 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1700 | long tmp; |
1701 | int error= 0; |
1702 | if (nr < (longlong) -TIME_MAX_VALUE && !unsigned_val) |
1703 | { |
1704 | tmp= -TIME_MAX_VALUE; |
1705 | -+ if (truncated) { *truncated= true; } |
1706 | ++ if (truncated) |
1707 | ++ { |
1708 | ++ *truncated= true; |
1709 | ++ } |
1710 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1711 | ER_WARN_DATA_OUT_OF_RANGE, nr, |
1712 | MYSQL_TIMESTAMP_TIME, 1); |
1713 | -@@ -5295,6 +5415,7 @@ |
1714 | +@@ -5295,6 +5722,10 @@ |
1715 | else if (nr > (longlong) TIME_MAX_VALUE || (nr < 0 && unsigned_val)) |
1716 | { |
1717 | tmp= TIME_MAX_VALUE; |
1718 | -+ if (truncated) { *truncated= true; } |
1719 | ++ if (truncated) |
1720 | ++ { |
1721 | ++ *truncated= true; |
1722 | ++ } |
1723 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1724 | ER_WARN_DATA_OUT_OF_RANGE, nr, |
1725 | MYSQL_TIMESTAMP_TIME, 1); |
1726 | -@@ -5306,6 +5427,7 @@ |
1727 | +@@ -5306,6 +5737,10 @@ |
1728 | if (tmp % 100 > 59 || tmp/100 % 100 > 59) |
1729 | { |
1730 | tmp=0; |
1731 | -+ if (truncated) { *truncated= true; } |
1732 | ++ if (truncated) |
1733 | ++ { |
1734 | ++ *truncated= true; |
1735 | ++ } |
1736 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1737 | ER_WARN_DATA_OUT_OF_RANGE, nr, |
1738 | MYSQL_TIMESTAMP_TIME, 1); |
1739 | -@@ -5437,8 +5559,9 @@ |
1740 | +@@ -5437,8 +5872,13 @@ |
1741 | ** Can handle 2 byte or 4 byte years! |
1742 | ****************************************************************************/ |
1743 | |
1744 | -int Field_year::store(const char *from, uint len,CHARSET_INFO *cs) |
1745 | -+int Field_year::store_truncated(const char *from, uint len,CHARSET_INFO *cs,bool *truncated) |
1746 | ++int Field_year::store_truncated(const char *from, uint len, CHARSET_INFO *cs, |
1747 | ++ bool *truncated) |
1748 | { |
1749 | -+ if (truncated) { *truncated= false; } |
1750 | ++ if (truncated) |
1751 | ++ { |
1752 | ++ *truncated= false; |
1753 | ++ } |
1754 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1755 | char *end; |
1756 | int error; |
1757 | -@@ -5448,6 +5571,7 @@ |
1758 | +@@ -5448,6 +5888,10 @@ |
1759 | error == MY_ERRNO_ERANGE) |
1760 | { |
1761 | *ptr=0; |
1762 | -+ if (truncated) { *truncated= true; } |
1763 | ++ if (truncated) |
1764 | ++ { |
1765 | ++ *truncated= true; |
1766 | ++ } |
1767 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1768 | return 1; |
1769 | } |
1770 | -@@ -5474,23 +5598,25 @@ |
1771 | +@@ -5474,23 +5918,31 @@ |
1772 | } |
1773 | |
1774 | |
1775 | -int Field_year::store(double nr) |
1776 | -+int Field_year::store_truncated(double nr,bool *truncated) |
1777 | ++int Field_year::store_truncated(double nr, bool *truncated) |
1778 | { |
1779 | if (nr < 0.0 || nr >= 2155.0) |
1780 | { |
1781 | - (void) Field_year::store((longlong) -1, FALSE); |
1782 | -+ (void) Field_year::store_truncated((longlong) -1, FALSE,truncated); |
1783 | ++ (void) Field_year::store_truncated((longlong) -1, FALSE, truncated); |
1784 | return 1; |
1785 | } |
1786 | - return Field_year::store((longlong) nr, FALSE); |
1787 | -+ return Field_year::store_truncated((longlong) nr, FALSE,truncated); |
1788 | ++ return Field_year::store_truncated((longlong) nr, FALSE, truncated); |
1789 | } |
1790 | |
1791 | |
1792 | -int Field_year::store(longlong nr, bool unsigned_val) |
1793 | -+int Field_year::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
1794 | ++int Field_year::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
1795 | { |
1796 | -+ if (truncated) { *truncated= false; } |
1797 | ++ if (truncated) |
1798 | ++ { |
1799 | ++ *truncated= false; |
1800 | ++ } |
1801 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1802 | if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155) |
1803 | { |
1804 | *ptr= 0; |
1805 | -+ if (truncated) { *truncated= true; } |
1806 | ++ if (truncated) |
1807 | ++ { |
1808 | ++ *truncated= true; |
1809 | ++ } |
1810 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
1811 | return 1; |
1812 | } |
1813 | -@@ -5560,8 +5686,9 @@ |
1814 | +@@ -5560,8 +6012,13 @@ |
1815 | ** Stored as a 4 byte unsigned int |
1816 | ****************************************************************************/ |
1817 | |
1818 | -int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) |
1819 | -+int Field_date::store_truncated(const char *from, uint len,CHARSET_INFO *cs,bool *truncated) |
1820 | ++int Field_date::store_truncated(const char *from, uint len, CHARSET_INFO *cs, |
1821 | ++ bool *truncated) |
1822 | { |
1823 | -+ if (truncated) { *truncated= false; } |
1824 | ++ if (truncated) |
1825 | ++ { |
1826 | ++ *truncated= false; |
1827 | ++ } |
1828 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1829 | MYSQL_TIME l_time; |
1830 | uint32 tmp; |
1831 | -@@ -5581,8 +5708,11 @@ |
1832 | +@@ -5581,8 +6038,14 @@ |
1833 | tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day); |
1834 | |
1835 | if (error) |
1836 | + { |
1837 | -+ if (truncated) { *truncated= true; } |
1838 | ++ if (truncated) |
1839 | ++ { |
1840 | ++ *truncated= true; |
1841 | ++ } |
1842 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, |
1843 | from, len, MYSQL_TIMESTAMP_DATE, 1); |
1844 | + } |
1845 | |
1846 | #ifdef WORDS_BIGENDIAN |
1847 | if (table && table->s->db_low_byte_first) |
1848 | -@@ -5596,14 +5726,16 @@ |
1849 | +@@ -5596,14 +6059,22 @@ |
1850 | } |
1851 | |
1852 | |
1853 | -int Field_date::store(double nr) |
1854 | -+int Field_date::store_truncated(double nr,bool *truncated) |
1855 | ++int Field_date::store_truncated(double nr, bool *truncated) |
1856 | { |
1857 | -+ if (truncated) { *truncated= false; } |
1858 | ++ if (truncated) |
1859 | ++ { |
1860 | ++ *truncated= false; |
1861 | ++ } |
1862 | longlong tmp; |
1863 | if (nr >= 19000000000000.0 && nr <= 99991231235959.0) |
1864 | nr=floor(nr/1000000.0); // Timestamp to date |
1865 | if (nr < 0.0 || nr > 99991231.0) |
1866 | { |
1867 | tmp= LL(0); |
1868 | -+ if (truncated) { *truncated= true; } |
1869 | ++ if (truncated) |
1870 | ++ { |
1871 | ++ *truncated= true; |
1872 | ++ } |
1873 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1874 | ER_WARN_DATA_OUT_OF_RANGE, |
1875 | nr, MYSQL_TIMESTAMP_DATE); |
1876 | -@@ -5611,12 +5743,16 @@ |
1877 | +@@ -5611,12 +6082,22 @@ |
1878 | else |
1879 | tmp= (longlong) rint(nr); |
1880 | |
1881 | - return Field_date::store(tmp, TRUE); |
1882 | + bool truncated2= false; |
1883 | -+ int result = Field_date::store_truncated(tmp, TRUE,&truncated2); |
1884 | -+ if (truncated) { *truncated= (*truncated) || truncated2; } |
1885 | ++ int result= Field_date::store_truncated(tmp, TRUE, &truncated2); |
1886 | ++ if (truncated) |
1887 | ++ { |
1888 | ++ *truncated= (*truncated) || truncated2; |
1889 | ++ } |
1890 | + return result; |
1891 | } |
1892 | |
1893 | |
1894 | -int Field_date::store(longlong nr, bool unsigned_val) |
1895 | -+int Field_date::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
1896 | ++int Field_date::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
1897 | { |
1898 | -+ if (truncated) { *truncated= false; } |
1899 | ++ if (truncated) |
1900 | ++ { |
1901 | ++ *truncated= false; |
1902 | ++ } |
1903 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1904 | MYSQL_TIME not_used; |
1905 | int error; |
1906 | -@@ -5639,10 +5775,13 @@ |
1907 | +@@ -5639,10 +6120,16 @@ |
1908 | nr= (longlong) floor(nr/1000000.0); // Timestamp to date |
1909 | |
1910 | if (error) |
1911 | + { |
1912 | -+ if (truncated) { *truncated= true; } |
1913 | ++ if (truncated) |
1914 | ++ { |
1915 | ++ *truncated= true; |
1916 | ++ } |
1917 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1918 | error == 2 ? ER_WARN_DATA_OUT_OF_RANGE : |
1919 | WARN_DATA_TRUNCATED, initial_nr, |
1920 | @@ -1348,23 +1694,30 @@ |
1921 | |
1922 | #ifdef WORDS_BIGENDIAN |
1923 | if (table && table->s->db_low_byte_first) |
1924 | -@@ -5794,8 +5933,9 @@ |
1925 | +@@ -5794,8 +6281,13 @@ |
1926 | store function. |
1927 | */ |
1928 | |
1929 | -int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) |
1930 | -+int Field_newdate::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
1931 | ++int Field_newdate::store_truncated(const char *from, uint len, CHARSET_INFO *cs, |
1932 | ++ bool *truncated) |
1933 | { |
1934 | -+ if (truncated) { *truncated= false; } |
1935 | ++ if (truncated) |
1936 | ++ { |
1937 | ++ *truncated= false; |
1938 | ++ } |
1939 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1940 | long tmp; |
1941 | MYSQL_TIME l_time; |
1942 | -@@ -5821,31 +5961,36 @@ |
1943 | +@@ -5821,31 +6313,45 @@ |
1944 | } |
1945 | |
1946 | if (error) |
1947 | + { |
1948 | -+ if (truncated) { *truncated= true; } |
1949 | ++ if (truncated) |
1950 | ++ { |
1951 | ++ *truncated= true; |
1952 | ++ } |
1953 | set_datetime_warning(error == 3 ? MYSQL_ERROR::WARN_LEVEL_NOTE : |
1954 | MYSQL_ERROR::WARN_LEVEL_WARN, |
1955 | WARN_DATA_TRUNCATED, |
1956 | @@ -1377,29 +1730,35 @@ |
1957 | |
1958 | |
1959 | -int Field_newdate::store(double nr) |
1960 | -+int Field_newdate::store_truncated(double nr,bool *truncated) |
1961 | ++int Field_newdate::store_truncated(double nr, bool *truncated) |
1962 | { |
1963 | if (nr < 0.0 || nr > 99991231235959.0) |
1964 | { |
1965 | int3store(ptr,(int32) 0); |
1966 | -+ if (truncated) { *truncated= true; } |
1967 | ++ if (truncated) |
1968 | ++ { |
1969 | ++ *truncated= true; |
1970 | ++ } |
1971 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
1972 | WARN_DATA_TRUNCATED, nr, MYSQL_TIMESTAMP_DATE); |
1973 | return 1; |
1974 | } |
1975 | - return Field_newdate::store((longlong) rint(nr), FALSE); |
1976 | -+ return Field_newdate::store_truncated((longlong) rint(nr), FALSE,truncated); |
1977 | ++ return Field_newdate::store_truncated((longlong) rint(nr), FALSE, truncated); |
1978 | } |
1979 | |
1980 | |
1981 | -int Field_newdate::store(longlong nr, bool unsigned_val) |
1982 | -+int Field_newdate::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
1983 | ++int Field_newdate::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
1984 | { |
1985 | -+ if (truncated) { *truncated= false; } |
1986 | ++ if (truncated) |
1987 | ++ { |
1988 | ++ *truncated= false; |
1989 | ++ } |
1990 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
1991 | MYSQL_TIME l_time; |
1992 | longlong tmp; |
1993 | -@@ -5869,11 +6014,14 @@ |
1994 | +@@ -5869,11 +6375,17 @@ |
1995 | error= 3; |
1996 | |
1997 | if (error) |
1998 | @@ -1409,28 +1768,38 @@ |
1999 | error == 2 ? |
2000 | ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED, |
2001 | nr,MYSQL_TIMESTAMP_DATE, 1); |
2002 | -+ if (truncated) { *truncated= true; } |
2003 | ++ if (truncated) |
2004 | ++ { |
2005 | ++ *truncated= true; |
2006 | ++ } |
2007 | + } |
2008 | |
2009 | int3store(ptr,tmp); |
2010 | return error; |
2011 | -@@ -6027,8 +6175,9 @@ |
2012 | +@@ -6027,8 +6539,13 @@ |
2013 | ** Stored as a 8 byte unsigned int. Should sometimes be change to a 6 byte int. |
2014 | ****************************************************************************/ |
2015 | |
2016 | -int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs) |
2017 | -+int Field_datetime::store_truncated(const char *from,uint len,CHARSET_INFO *cs,bool *truncated) |
2018 | ++int Field_datetime::store_truncated(const char *from, uint len, |
2019 | ++ CHARSET_INFO *cs, bool *truncated) |
2020 | { |
2021 | -+ if (truncated) { *truncated= false; } |
2022 | ++ if (truncated) |
2023 | ++ { |
2024 | ++ *truncated= false; |
2025 | ++ } |
2026 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2027 | MYSQL_TIME time_tmp; |
2028 | int error; |
2029 | -@@ -6048,9 +6197,12 @@ |
2030 | +@@ -6048,9 +6565,15 @@ |
2031 | error= 1; // Fix if invalid zero date |
2032 | |
2033 | if (error) |
2034 | + { |
2035 | -+ if (truncated) { *truncated= true; } |
2036 | ++ if (truncated) |
2037 | ++ { |
2038 | ++ *truncated= true; |
2039 | ++ } |
2040 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
2041 | ER_WARN_DATA_OUT_OF_RANGE, |
2042 | from, len, MYSQL_TIMESTAMP_DATETIME, 1); |
2043 | @@ -1438,18 +1807,24 @@ |
2044 | |
2045 | #ifdef WORDS_BIGENDIAN |
2046 | if (table && table->s->db_low_byte_first) |
2047 | -@@ -6064,24 +6216,29 @@ |
2048 | +@@ -6064,24 +6587,43 @@ |
2049 | } |
2050 | |
2051 | |
2052 | -int Field_datetime::store(double nr) |
2053 | -+int Field_datetime::store_truncated(double nr,bool *truncated) |
2054 | ++int Field_datetime::store_truncated(double nr, bool *truncated) |
2055 | { |
2056 | -+ if (truncated) { *truncated= false; } |
2057 | ++ if (truncated) |
2058 | ++ { |
2059 | ++ *truncated= false; |
2060 | ++ } |
2061 | int error= 0; |
2062 | if (nr < 0.0 || nr > 99991231235959.0) |
2063 | { |
2064 | -+ if (truncated) { *truncated= true; } |
2065 | ++ if (truncated) |
2066 | ++ { |
2067 | ++ *truncated= true; |
2068 | ++ } |
2069 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
2070 | ER_WARN_DATA_OUT_OF_RANGE, |
2071 | nr, MYSQL_TIMESTAMP_DATETIME); |
2072 | @@ -1457,26 +1832,37 @@ |
2073 | error= 1; |
2074 | } |
2075 | - error|= Field_datetime::store((longlong) rint(nr), FALSE); |
2076 | -+ bool truncated2 = false; |
2077 | -+ error|= Field_datetime::store_truncated((longlong) rint(nr), FALSE,&truncated2); |
2078 | -+ if (truncated) { *truncated= (*truncated) || truncated2; } |
2079 | ++ bool truncated2= false; |
2080 | ++ error|= Field_datetime::store_truncated((longlong) rint(nr), FALSE, |
2081 | ++ &truncated2); |
2082 | ++ if (truncated) |
2083 | ++ { |
2084 | ++ *truncated= (*truncated) || truncated2; |
2085 | ++ } |
2086 | return error; |
2087 | } |
2088 | |
2089 | |
2090 | -int Field_datetime::store(longlong nr, bool unsigned_val) |
2091 | -+int Field_datetime::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
2092 | ++int Field_datetime::store_truncated(longlong nr, bool unsigned_val, |
2093 | ++ bool *truncated) |
2094 | { |
2095 | -+ if (truncated) { *truncated= false; } |
2096 | ++ if (truncated) |
2097 | ++ { |
2098 | ++ *truncated= false; |
2099 | ++ } |
2100 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2101 | MYSQL_TIME not_used; |
2102 | int error; |
2103 | -@@ -6101,10 +6258,13 @@ |
2104 | +@@ -6101,10 +6641,16 @@ |
2105 | } |
2106 | |
2107 | if (error) |
2108 | + { |
2109 | -+ if (truncated) { *truncated= true; } |
2110 | ++ if (truncated) |
2111 | ++ { |
2112 | ++ *truncated= true; |
2113 | ++ } |
2114 | set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
2115 | error == 2 ? ER_WARN_DATA_OUT_OF_RANGE : |
2116 | WARN_DATA_TRUNCATED, initial_nr, |
2117 | @@ -1485,18 +1871,22 @@ |
2118 | |
2119 | #ifdef WORDS_BIGENDIAN |
2120 | if (table && table->s->db_low_byte_first) |
2121 | -@@ -6421,8 +6581,9 @@ |
2122 | +@@ -6421,8 +6967,13 @@ |
2123 | |
2124 | /* Copy a string and fill with space */ |
2125 | |
2126 | -int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) |
2127 | -+int Field_string::store_truncated(const char *from,uint length,CHARSET_INFO *cs,bool *truncated) |
2128 | ++int Field_string::store_truncated(const char *from, uint length, CHARSET_INFO *cs, |
2129 | ++ bool *truncated) |
2130 | { |
2131 | -+ if (truncated) { *truncated= false; } |
2132 | ++ if (truncated) |
2133 | ++ { |
2134 | ++ *truncated= false; |
2135 | ++ } |
2136 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2137 | uint copy_length; |
2138 | const char *well_formed_error_pos; |
2139 | -@@ -6439,6 +6600,10 @@ |
2140 | +@@ -6439,6 +6990,10 @@ |
2141 | &well_formed_error_pos, |
2142 | &cannot_convert_error_pos, |
2143 | &from_end_pos); |
2144 | @@ -1507,30 +1897,30 @@ |
2145 | |
2146 | /* Append spaces if the string was shorter than the field. */ |
2147 | if (copy_length < field_length) |
2148 | -@@ -6462,7 +6627,7 @@ |
2149 | +@@ -6462,7 +7017,7 @@ |
2150 | @param nr number |
2151 | */ |
2152 | |
2153 | -int Field_str::store(double nr) |
2154 | -+int Field_str::store_truncated(double nr,bool *truncated) |
2155 | ++int Field_str::store_truncated(double nr, bool *truncated) |
2156 | { |
2157 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2158 | char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; |
2159 | -@@ -6544,7 +6709,7 @@ |
2160 | +@@ -6544,7 +7099,7 @@ |
2161 | like inserting 500.0 in char(1) |
2162 | */ |
2163 | DBUG_ASSERT(local_char_length < 5 || length <= local_char_length+1); |
2164 | - return store(buff, length, charset()); |
2165 | -+ return store_truncated(buff, length, charset(),truncated); |
2166 | ++ return store_truncated(buff, length, charset(), truncated); |
2167 | } |
2168 | |
2169 | |
2170 | -@@ -6565,23 +6730,31 @@ |
2171 | +@@ -6565,23 +7120,37 @@ |
2172 | } |
2173 | |
2174 | |
2175 | -int Field_string::store(longlong nr, bool unsigned_val) |
2176 | -+int Field_string::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
2177 | ++int Field_string::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
2178 | { |
2179 | char buff[64]; |
2180 | int l; |
2181 | @@ -1538,14 +1928,17 @@ |
2182 | l= (cs->cset->longlong10_to_str)(cs,buff,sizeof(buff), |
2183 | unsigned_val ? 10 : -10, nr); |
2184 | - return Field_string::store(buff,(uint)l,cs); |
2185 | -+ return Field_string::store_truncated(buff,(uint)l,cs,truncated); |
2186 | ++ return Field_string::store_truncated(buff,(uint)l,cs, truncated); |
2187 | } |
2188 | |
2189 | |
2190 | -int Field_longstr::store_decimal(const my_decimal *d) |
2191 | -+int Field_longstr::store_decimal_truncated(const my_decimal *d,bool *truncated) |
2192 | ++int Field_longstr::store_decimal_truncated(const my_decimal *d, bool *truncated) |
2193 | { |
2194 | -+ if (truncated) { *truncated= false; } |
2195 | ++ if (truncated) |
2196 | ++ { |
2197 | ++ *truncated= false; |
2198 | ++ } |
2199 | char buff[DECIMAL_MAX_STR_LENGTH+1]; |
2200 | String str(buff, sizeof(buff), &my_charset_bin); |
2201 | - my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str); |
2202 | @@ -1553,27 +1946,34 @@ |
2203 | + int op_result= my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str); |
2204 | + if (truncated && (E_DEC_OVERFLOW == op_result || E_DEC_TRUNCATED == op_result)) |
2205 | + { |
2206 | -+ if (truncated) { *truncated= true; } |
2207 | ++ *truncated= true; |
2208 | + } |
2209 | + bool truncated2= false; |
2210 | -+ int result= store_truncated(str.ptr(), str.length(), str.charset(),&truncated2); |
2211 | -+ if (truncated) { *truncated = (*truncated) || truncated2; } |
2212 | ++ int result= store_truncated(str.ptr(), str.length(), str.charset(), &truncated2); |
2213 | ++ if (truncated) |
2214 | ++ { |
2215 | ++ *truncated= (*truncated) || truncated2; |
2216 | ++ } |
2217 | + return result; |
2218 | } |
2219 | |
2220 | uint32 Field_longstr::max_data_length() const |
2221 | -@@ -7096,8 +7269,9 @@ |
2222 | +@@ -7096,8 +7665,13 @@ |
2223 | return 2; |
2224 | } |
2225 | |
2226 | -int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) |
2227 | -+int Field_varstring::store_truncated(const char *from,uint length,CHARSET_INFO *cs,bool *truncated) |
2228 | ++int Field_varstring::store_truncated(const char *from, uint length, |
2229 | ++ CHARSET_INFO *cs, bool *truncated) |
2230 | { |
2231 | -+ if (truncated) { *truncated= false; } |
2232 | ++ if (truncated) |
2233 | ++ { |
2234 | ++ *truncated= false; |
2235 | ++ } |
2236 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2237 | uint copy_length; |
2238 | const char *well_formed_error_pos; |
2239 | -@@ -7112,6 +7286,10 @@ |
2240 | +@@ -7112,6 +7686,10 @@ |
2241 | &well_formed_error_pos, |
2242 | &cannot_convert_error_pos, |
2243 | &from_end_pos); |
2244 | @@ -1584,52 +1984,56 @@ |
2245 | |
2246 | if (length_bytes == 1) |
2247 | *ptr= (uchar) copy_length; |
2248 | -@@ -7126,7 +7304,7 @@ |
2249 | +@@ -7126,7 +7704,7 @@ |
2250 | } |
2251 | |
2252 | |
2253 | -int Field_varstring::store(longlong nr, bool unsigned_val) |
2254 | -+int Field_varstring::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
2255 | ++int Field_varstring::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
2256 | { |
2257 | char buff[64]; |
2258 | uint length; |
2259 | -@@ -7136,7 +7314,7 @@ |
2260 | +@@ -7136,7 +7714,7 @@ |
2261 | (unsigned_val ? 10: |
2262 | -10), |
2263 | nr); |
2264 | - return Field_varstring::store(buff, length, field_charset); |
2265 | -+ return Field_varstring::store_truncated(buff, length, field_charset,truncated); |
2266 | ++ return Field_varstring::store_truncated(buff, length, field_charset, truncated); |
2267 | } |
2268 | |
2269 | |
2270 | -@@ -7761,10 +7939,12 @@ |
2271 | +@@ -7761,10 +8339,16 @@ |
2272 | } |
2273 | |
2274 | |
2275 | -int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) |
2276 | -+int Field_blob::store_truncated(const char *from,uint length,CHARSET_INFO *cs,bool *truncated) |
2277 | ++int Field_blob::store_truncated(const char *from, uint length, CHARSET_INFO *cs, |
2278 | ++ bool *truncated) |
2279 | { |
2280 | -+ if (truncated) { *truncated= false; } |
2281 | ++ if (truncated) |
2282 | ++ { |
2283 | ++ *truncated= false; |
2284 | ++ } |
2285 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2286 | uint copy_length, new_length; |
2287 | -+ uint argument_length = field_charset->mbmaxlen * length; |
2288 | ++ uint argument_length= field_charset->mbmaxlen * length; |
2289 | const char *well_formed_error_pos; |
2290 | const char *cannot_convert_error_pos; |
2291 | const char *from_end_pos, *tmp; |
2292 | -@@ -7801,7 +7981,11 @@ |
2293 | +@@ -7801,7 +8385,11 @@ |
2294 | from= tmpstr.ptr(); |
2295 | } |
2296 | |
2297 | - new_length= min(max_data_length(), field_charset->mbmaxlen * length); |
2298 | -+ new_length= min(max_data_length(),argument_length); |
2299 | -+ if (new_length != argument_length) |
2300 | ++ new_length= min(max_data_length(), argument_length); |
2301 | ++ if (new_length != argument_length && truncated) |
2302 | + { |
2303 | -+ if (truncated) { *truncated= true; } |
2304 | ++ *truncated= true; |
2305 | + } |
2306 | if (value.alloc(new_length)) |
2307 | goto oom_error; |
2308 | |
2309 | -@@ -7828,6 +8012,10 @@ |
2310 | +@@ -7828,6 +8416,10 @@ |
2311 | &well_formed_error_pos, |
2312 | &cannot_convert_error_pos, |
2313 | &from_end_pos); |
2314 | @@ -1640,38 +2044,43 @@ |
2315 | |
2316 | Field_blob::store_length(copy_length); |
2317 | tmp= value.ptr(); |
2318 | -@@ -7846,19 +8034,19 @@ |
2319 | +@@ -7846,19 +8438,21 @@ |
2320 | } |
2321 | |
2322 | |
2323 | -int Field_blob::store(double nr) |
2324 | -+int Field_blob::store_truncated(double nr,bool *truncated) |
2325 | ++int Field_blob::store_truncated(double nr, bool *truncated) |
2326 | { |
2327 | CHARSET_INFO *cs=charset(); |
2328 | value.set_real(nr, 2, cs); |
2329 | - return Field_blob::store(value.ptr(),(uint) value.length(), cs); |
2330 | -+ return Field_blob::store_truncated(value.ptr(),(uint) value.length(), cs,truncated); |
2331 | ++ return Field_blob::store_truncated(value.ptr(), (uint) value.length(), cs, |
2332 | ++ truncated); |
2333 | } |
2334 | |
2335 | |
2336 | -int Field_blob::store(longlong nr, bool unsigned_val) |
2337 | -+int Field_blob::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
2338 | ++int Field_blob::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
2339 | { |
2340 | CHARSET_INFO *cs=charset(); |
2341 | value.set_int(nr, unsigned_val, cs); |
2342 | - return Field_blob::store(value.ptr(), (uint) value.length(), cs); |
2343 | -+ return Field_blob::store_truncated(value.ptr(), (uint) value.length(), cs,truncated); |
2344 | ++ return Field_blob::store_truncated(value.ptr(), (uint) value.length(), cs, |
2345 | ++ truncated); |
2346 | } |
2347 | |
2348 | |
2349 | -@@ -8404,32 +8592,36 @@ |
2350 | +@@ -8404,32 +8996,49 @@ |
2351 | } |
2352 | |
2353 | |
2354 | -int Field_geom::store(double nr) |
2355 | -+int Field_geom::store_truncated(double nr,bool *truncated) |
2356 | ++int Field_geom::store_truncated(double nr, bool *truncated) |
2357 | { |
2358 | -+ if (truncated) { *truncated= false; } |
2359 | ++ if (truncated) |
2360 | ++ { |
2361 | ++ *truncated= false; |
2362 | ++ } |
2363 | my_message(ER_CANT_CREATE_GEOMETRY_OBJECT, |
2364 | ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0)); |
2365 | return -1; |
2366 | @@ -1679,9 +2088,12 @@ |
2367 | |
2368 | |
2369 | -int Field_geom::store(longlong nr, bool unsigned_val) |
2370 | -+int Field_geom::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
2371 | ++int Field_geom::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
2372 | { |
2373 | -+ if (truncated) { *truncated= false; } |
2374 | ++ if (truncated) |
2375 | ++ { |
2376 | ++ *truncated= false; |
2377 | ++ } |
2378 | my_message(ER_CANT_CREATE_GEOMETRY_OBJECT, |
2379 | ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0)); |
2380 | return -1; |
2381 | @@ -1689,9 +2101,12 @@ |
2382 | |
2383 | |
2384 | -int Field_geom::store_decimal(const my_decimal *) |
2385 | -+int Field_geom::store_decimal_truncated(const my_decimal *,bool* truncated) |
2386 | ++int Field_geom::store_decimal_truncated(const my_decimal*, bool *truncated) |
2387 | { |
2388 | -+ if (truncated) { *truncated= false; } |
2389 | ++ if (truncated) |
2390 | ++ { |
2391 | ++ *truncated= false; |
2392 | ++ } |
2393 | my_message(ER_CANT_CREATE_GEOMETRY_OBJECT, |
2394 | ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0)); |
2395 | return -1; |
2396 | @@ -1699,36 +2114,53 @@ |
2397 | |
2398 | |
2399 | -int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) |
2400 | -+int Field_geom::store_truncated(const char *from, uint length, CHARSET_INFO *cs,bool *truncated) |
2401 | ++int Field_geom::store_truncated(const char *from, uint length, |
2402 | ++ CHARSET_INFO *cs, bool *truncated) |
2403 | { |
2404 | -+ if (truncated) { *truncated= false; } |
2405 | ++ if (truncated) |
2406 | ++ { |
2407 | ++ *truncated= false; |
2408 | ++ } |
2409 | if (!length) |
2410 | bzero(ptr, Field_blob::pack_length()); |
2411 | else |
2412 | -@@ -8524,8 +8716,9 @@ |
2413 | +@@ -8524,8 +9133,13 @@ |
2414 | (if there isn't a empty value in the enum) |
2415 | */ |
2416 | |
2417 | -int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) |
2418 | -+int Field_enum::store_truncated(const char *from,uint length,CHARSET_INFO *cs,bool *truncated) |
2419 | ++int Field_enum::store_truncated(const char *from, uint length, CHARSET_INFO *cs, |
2420 | ++ bool *truncated) |
2421 | { |
2422 | -+ if (truncated) { *truncated= false; } |
2423 | ++ if (truncated) |
2424 | ++ { |
2425 | ++ *truncated= false; |
2426 | ++ } |
2427 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2428 | int err= 0; |
2429 | uint32 not_used; |
2430 | -@@ -8554,31 +8747,37 @@ |
2431 | +@@ -8553,32 +9167,50 @@ |
2432 | + tmp=(uint) my_strntoul(cs,from,length,10,&end,&err); |
2433 | if (err || end != from+length || tmp > typelib->count) |
2434 | { |
2435 | - tmp=0; |
2436 | -+ if (truncated) { *truncated= true; } |
2437 | - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); |
2438 | +- tmp=0; |
2439 | +- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); |
2440 | ++ tmp=0; |
2441 | ++ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); |
2442 | ++ if (truncated) |
2443 | ++ { |
2444 | ++ *truncated= true; |
2445 | ++ } |
2446 | } |
2447 | if (!table->in_use->count_cuted_fields) |
2448 | err= 0; |
2449 | } |
2450 | else |
2451 | + { |
2452 | -+ if (truncated) { *truncated= true; } |
2453 | ++ if (truncated) |
2454 | ++ { |
2455 | ++ *truncated= true; |
2456 | ++ } |
2457 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); |
2458 | + } |
2459 | } |
2460 | @@ -1738,7 +2170,7 @@ |
2461 | |
2462 | |
2463 | -int Field_enum::store(double nr) |
2464 | -+int Field_enum::store_truncated(double nr,bool *truncated) |
2465 | ++int Field_enum::store_truncated(double nr, bool *truncated) |
2466 | { |
2467 | - return Field_enum::store((longlong) nr, FALSE); |
2468 | + return Field_enum::store_truncated((longlong) nr, FALSE, truncated); |
2469 | @@ -1746,33 +2178,46 @@ |
2470 | |
2471 | |
2472 | -int Field_enum::store(longlong nr, bool unsigned_val) |
2473 | -+int Field_enum::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
2474 | ++int Field_enum::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
2475 | { |
2476 | -+ if (truncated) { *truncated= false; } |
2477 | ++ if (truncated) |
2478 | ++ { |
2479 | ++ *truncated= false; |
2480 | ++ } |
2481 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2482 | int error= 0; |
2483 | if ((ulonglong) nr > typelib->count || nr == 0) |
2484 | { |
2485 | -+ if (truncated) { *truncated= true; } |
2486 | ++ if (truncated) |
2487 | ++ { |
2488 | ++ *truncated= true; |
2489 | ++ } |
2490 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); |
2491 | if (nr != 0 || table->in_use->count_cuted_fields) |
2492 | { |
2493 | -@@ -8742,8 +8941,9 @@ |
2494 | +@@ -8742,8 +9374,13 @@ |
2495 | */ |
2496 | |
2497 | |
2498 | -int Field_set::store(const char *from,uint length,CHARSET_INFO *cs) |
2499 | -+int Field_set::store_truncated(const char *from,uint length,CHARSET_INFO *cs,bool *truncated) |
2500 | ++int Field_set::store_truncated(const char *from, uint length, CHARSET_INFO *cs, |
2501 | ++ bool *truncated) |
2502 | { |
2503 | -+ if (truncated) { *truncated= false; } |
2504 | ++ if (truncated) |
2505 | ++ { |
2506 | ++ *truncated= false; |
2507 | ++ } |
2508 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2509 | bool got_warning= 0; |
2510 | int err= 0; |
2511 | -@@ -8772,18 +8972,23 @@ |
2512 | +@@ -8772,18 +9409,29 @@ |
2513 | tmp > (ulonglong) (((longlong) 1 << typelib->count) - (longlong) 1)) |
2514 | { |
2515 | tmp=0; |
2516 | -+ if (truncated) { *truncated= true; } |
2517 | ++ if (truncated) |
2518 | ++ { |
2519 | ++ *truncated= true; |
2520 | ++ } |
2521 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); |
2522 | } |
2523 | } |
2524 | @@ -1789,92 +2234,115 @@ |
2525 | |
2526 | |
2527 | -int Field_set::store(longlong nr, bool unsigned_val) |
2528 | -+int Field_set::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
2529 | ++int Field_set::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
2530 | { |
2531 | -+ if (truncated) { *truncated= false; } |
2532 | ++ if (truncated) |
2533 | ++ { |
2534 | ++ *truncated= false; |
2535 | ++ } |
2536 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2537 | int error= 0; |
2538 | ulonglong max_nr; |
2539 | -@@ -8796,6 +9001,7 @@ |
2540 | +@@ -8796,6 +9444,10 @@ |
2541 | if ((ulonglong) nr > max_nr) |
2542 | { |
2543 | nr&= max_nr; |
2544 | -+ if (truncated) { *truncated= true; } |
2545 | ++ if (truncated) |
2546 | ++ { |
2547 | ++ *truncated= true; |
2548 | ++ } |
2549 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); |
2550 | error=1; |
2551 | } |
2552 | -@@ -9105,8 +9311,9 @@ |
2553 | +@@ -9105,8 +9757,13 @@ |
2554 | } |
2555 | |
2556 | |
2557 | -int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs) |
2558 | -+int Field_bit::store_truncated(const char *from, uint length, CHARSET_INFO *cs,bool *truncated) |
2559 | ++int Field_bit::store_truncated(const char *from, uint length, CHARSET_INFO *cs, |
2560 | ++ bool *truncated) |
2561 | { |
2562 | -+ if (truncated) { *truncated= false; } |
2563 | ++ if (truncated) |
2564 | ++ { |
2565 | ++ *truncated= false; |
2566 | ++ } |
2567 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2568 | int delta; |
2569 | |
2570 | -@@ -9123,6 +9330,7 @@ |
2571 | +@@ -9123,6 +9780,10 @@ |
2572 | set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1); |
2573 | else |
2574 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
2575 | -+ if (truncated) { *truncated= true; } |
2576 | ++ if (truncated) |
2577 | ++ { |
2578 | ++ *truncated= true; |
2579 | ++ } |
2580 | return 1; |
2581 | } |
2582 | /* delta is >= -1 here */ |
2583 | -@@ -9152,26 +9360,29 @@ |
2584 | +@@ -9152,26 +9813,32 @@ |
2585 | } |
2586 | |
2587 | |
2588 | -int Field_bit::store(double nr) |
2589 | -+int Field_bit::store_truncated(double nr,bool *truncated) |
2590 | ++int Field_bit::store_truncated(double nr, bool *truncated) |
2591 | { |
2592 | - return Field_bit::store((longlong) nr, FALSE); |
2593 | -+ return Field_bit::store_truncated((longlong) nr, FALSE,truncated); |
2594 | ++ return Field_bit::store_truncated((longlong) nr, FALSE, truncated); |
2595 | } |
2596 | |
2597 | |
2598 | -int Field_bit::store(longlong nr, bool unsigned_val) |
2599 | -+int Field_bit::store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
2600 | ++int Field_bit::store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
2601 | { |
2602 | char buf[8]; |
2603 | |
2604 | mi_int8store(buf, nr); |
2605 | - return store(buf, 8, NULL); |
2606 | -+ return store_truncated(buf, 8, NULL,truncated); |
2607 | ++ return store_truncated(buf, 8, NULL, truncated); |
2608 | } |
2609 | |
2610 | |
2611 | -int Field_bit::store_decimal(const my_decimal *val) |
2612 | -+int Field_bit::store_decimal_truncated(const my_decimal *val,bool *truncated) |
2613 | ++int Field_bit::store_decimal_truncated(const my_decimal *val, bool *truncated) |
2614 | { |
2615 | int err= 0; |
2616 | - longlong i= convert_decimal2longlong(val, 1, &err); |
2617 | - return test(err | store(i, TRUE)); |
2618 | -+ longlong i= convert_decimal2longlong_truncated(val, 1, &err,truncated); |
2619 | ++ longlong i= convert_decimal2longlong_truncated(val, 1, &err, truncated); |
2620 | + bool truncated2= false; |
2621 | -+ int result= test(err | store_truncated(i, TRUE,&truncated2)); |
2622 | -+ if (truncated) { *truncated= (*truncated) || truncated2; } |
2623 | ++ int result= test(err | store_truncated(i, TRUE, &truncated2)); |
2624 | ++ if (truncated) |
2625 | ++ { |
2626 | ++ *truncated= (*truncated) || truncated2; |
2627 | ++ } |
2628 | + return result; |
2629 | } |
2630 | |
2631 | |
2632 | -@@ -9561,8 +9772,9 @@ |
2633 | +@@ -9561,8 +10228,13 @@ |
2634 | } |
2635 | |
2636 | |
2637 | -int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs) |
2638 | -+int Field_bit_as_char::store_truncated(const char *from, uint length, CHARSET_INFO *cs,bool *truncated) |
2639 | ++int Field_bit_as_char::store_truncated(const char *from, uint length, |
2640 | ++ CHARSET_INFO *cs, bool *truncated) |
2641 | { |
2642 | -+ if (truncated) { *truncated= false; } |
2643 | ++ if (truncated) |
2644 | ++ { |
2645 | ++ *truncated= false; |
2646 | ++ } |
2647 | ASSERT_COLUMN_MARKED_FOR_WRITE; |
2648 | int delta; |
2649 | uchar bits= (uchar) (field_length & 7); |
2650 | -@@ -9580,6 +9792,7 @@ |
2651 | +@@ -9580,6 +10252,10 @@ |
2652 | set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1); |
2653 | else |
2654 | set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); |
2655 | -+ if (truncated) { *truncated= true; } |
2656 | ++ if (truncated) |
2657 | ++ { |
2658 | ++ *truncated= true; |
2659 | ++ } |
2660 | return 1; |
2661 | } |
2662 | bzero(ptr, delta); |
2663 | @@ -1919,7 +2387,7 @@ |
2664 | |
2665 | static void do_copy_blob(Copy_field *copy) |
2666 | { |
2667 | -+ copy->truncated = false; |
2668 | ++ copy->truncated= false; |
2669 | ulong length=((Field_blob*) copy->from_field)->get_length(); |
2670 | ((Field_blob*) copy->to_field)->store_length(length); |
2671 | memcpy_fixed(copy->to_ptr,copy->from_ptr,sizeof(char*)); |
2672 | @@ -1932,11 +2400,11 @@ |
2673 | copy->tmp.length(), |
2674 | - copy->tmp.charset()); |
2675 | + copy->tmp.charset(), |
2676 | -+ &(copy->truncated)); |
2677 | ++ &(copy->truncated)); |
2678 | } |
2679 | |
2680 | /** Save blob in copy->tmp for GROUP BY. */ |
2681 | -@@ -306,9 +312,9 @@ |
2682 | +@@ -306,9 +312,10 @@ |
2683 | String res(buff,sizeof(buff),copy->tmp.charset()); |
2684 | copy->from_field->val_str(&res); |
2685 | copy->tmp.copy(res); |
2686 | @@ -1945,18 +2413,21 @@ |
2687 | - copy->tmp.charset()); |
2688 | + ((Field_blob *) copy->to_field)->store_truncated(copy->tmp.ptr(), |
2689 | + copy->tmp.length(), |
2690 | -+ copy->tmp.charset(),&(copy->truncated)); |
2691 | ++ copy->tmp.charset(), |
2692 | ++ &(copy->truncated)); |
2693 | } |
2694 | |
2695 | |
2696 | -@@ -317,15 +323,18 @@ |
2697 | +@@ -317,15 +324,20 @@ |
2698 | char buff[MAX_FIELD_WIDTH]; |
2699 | copy->tmp.set_quick(buff,sizeof(buff),copy->tmp.charset()); |
2700 | copy->from_field->val_str(©->tmp); |
2701 | - copy->to_field->store(copy->tmp.c_ptr_quick(),copy->tmp.length(), |
2702 | - copy->tmp.charset()); |
2703 | -+ copy->to_field->store_truncated(copy->tmp.c_ptr_quick(),copy->tmp.length(), |
2704 | -+ copy->tmp.charset(),&(copy->truncated)); |
2705 | ++ copy->to_field->store_truncated(copy->tmp.c_ptr_quick(), |
2706 | ++ copy->tmp.length(), |
2707 | ++ copy->tmp.charset(), |
2708 | ++ &(copy->truncated)); |
2709 | } |
2710 | |
2711 | |
2712 | @@ -1970,14 +2441,16 @@ |
2713 | else |
2714 | do_field_string(copy); |
2715 | } |
2716 | -@@ -341,29 +350,30 @@ |
2717 | +@@ -341,29 +353,33 @@ |
2718 | uint length= my_lengthsp_8bit(&my_charset_bin, copy->tmp.c_ptr_quick(), |
2719 | copy->from_field->field_length); |
2720 | |
2721 | - copy->to_field->store(copy->tmp.c_ptr_quick(), length, |
2722 | - copy->tmp.charset()); |
2723 | -+ copy->to_field->store_truncated(copy->tmp.c_ptr_quick(), length, |
2724 | -+ copy->tmp.charset(),&(copy->truncated)); |
2725 | ++ copy->to_field->store_truncated(copy->tmp.c_ptr_quick(), |
2726 | ++ length, |
2727 | ++ copy->tmp.charset(), |
2728 | ++ &(copy->truncated)); |
2729 | } |
2730 | |
2731 | |
2732 | @@ -2003,27 +2476,28 @@ |
2733 | { |
2734 | my_decimal value; |
2735 | - copy->to_field->store_decimal(copy->from_field->val_decimal(&value)); |
2736 | -+ copy->to_field->store_decimal_truncated(copy->from_field->val_decimal(&value),&(copy->truncated)); |
2737 | ++ copy->to_field->store_decimal_truncated(copy->from_field->val_decimal(&value), |
2738 | ++ &(copy->truncated)); |
2739 | } |
2740 | |
2741 | |
2742 | -@@ -376,13 +386,14 @@ |
2743 | +@@ -376,13 +392,14 @@ |
2744 | { |
2745 | CHARSET_INFO *cs= copy->from_field->charset(); |
2746 | memcpy(copy->to_ptr,copy->from_ptr,copy->to_length); |
2747 | - |
2748 | -+ copy->truncated = false; |
2749 | ++ copy->truncated= false; |
2750 | /* Check if we loosed any important characters */ |
2751 | if (cs->cset->scan(cs, |
2752 | (char*) copy->from_ptr + copy->to_length, |
2753 | (char*) copy->from_ptr + copy->from_length, |
2754 | MY_SEQ_SPACES) < copy->from_length - copy->to_length) |
2755 | { |
2756 | -+ copy->truncated = true; |
2757 | ++ copy->truncated= true; |
2758 | copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
2759 | WARN_DATA_TRUNCATED, 1); |
2760 | } |
2761 | -@@ -396,6 +407,7 @@ |
2762 | +@@ -396,6 +413,7 @@ |
2763 | |
2764 | static void do_cut_string_complex(Copy_field *copy) |
2765 | { // Shorter string field |
2766 | @@ -2031,18 +2505,18 @@ |
2767 | int well_formed_error; |
2768 | CHARSET_INFO *cs= copy->from_field->charset(); |
2769 | const uchar *from_end= copy->from_ptr + copy->from_length; |
2770 | -@@ -405,7 +417,10 @@ |
2771 | +@@ -405,7 +423,10 @@ |
2772 | copy->to_length / cs->mbmaxlen, |
2773 | &well_formed_error); |
2774 | if (copy->to_length < copy_length) |
2775 | + { |
2776 | copy_length= copy->to_length; |
2777 | -+ copy->truncated = true; |
2778 | ++ copy->truncated= true; |
2779 | + } |
2780 | memcpy(copy->to_ptr, copy->from_ptr, copy_length); |
2781 | |
2782 | /* Check if we lost any important characters */ |
2783 | -@@ -414,6 +429,7 @@ |
2784 | +@@ -414,6 +435,7 @@ |
2785 | (char*) from_end, |
2786 | MY_SEQ_SPACES) < (copy->from_length - copy_length)) |
2787 | { |
2788 | @@ -2050,81 +2524,81 @@ |
2789 | copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
2790 | WARN_DATA_TRUNCATED, 1); |
2791 | } |
2792 | -@@ -447,13 +463,17 @@ |
2793 | +@@ -447,13 +469,17 @@ |
2794 | |
2795 | static void do_varstring1(Copy_field *copy) |
2796 | { |
2797 | -+ copy->truncated = false; |
2798 | ++ copy->truncated= false; |
2799 | uint length= (uint) *(uchar*) copy->from_ptr; |
2800 | if (length > copy->to_length- 1) |
2801 | { |
2802 | length=copy->to_length - 1; |
2803 | if (copy->from_field->table->in_use->count_cuted_fields) |
2804 | + { |
2805 | -+ copy->truncated = true; |
2806 | ++ copy->truncated= true; |
2807 | copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
2808 | WARN_DATA_TRUNCATED, 1); |
2809 | + } |
2810 | } |
2811 | *(uchar*) copy->to_ptr= (uchar) length; |
2812 | memcpy(copy->to_ptr+1, copy->from_ptr + 1, length); |
2813 | -@@ -462,6 +482,7 @@ |
2814 | +@@ -462,6 +488,7 @@ |
2815 | |
2816 | static void do_varstring1_mb(Copy_field *copy) |
2817 | { |
2818 | -+ copy->truncated = false; |
2819 | ++ copy->truncated= false; |
2820 | int well_formed_error; |
2821 | CHARSET_INFO *cs= copy->from_field->charset(); |
2822 | uint from_length= (uint) *(uchar*) copy->from_ptr; |
2823 | -@@ -473,8 +494,11 @@ |
2824 | +@@ -473,8 +500,11 @@ |
2825 | if (length < from_length) |
2826 | { |
2827 | if (current_thd->count_cuted_fields) |
2828 | + { |
2829 | -+ copy->truncated = true; |
2830 | ++ copy->truncated= true; |
2831 | copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
2832 | WARN_DATA_TRUNCATED, 1); |
2833 | + } |
2834 | } |
2835 | *copy->to_ptr= (uchar) length; |
2836 | memcpy(copy->to_ptr + 1, from_ptr, length); |
2837 | -@@ -483,13 +507,17 @@ |
2838 | +@@ -483,13 +513,17 @@ |
2839 | |
2840 | static void do_varstring2(Copy_field *copy) |
2841 | { |
2842 | -+ copy->truncated = false; |
2843 | ++ copy->truncated= false; |
2844 | uint length=uint2korr(copy->from_ptr); |
2845 | if (length > copy->to_length- HA_KEY_BLOB_LENGTH) |
2846 | { |
2847 | length=copy->to_length-HA_KEY_BLOB_LENGTH; |
2848 | if (copy->from_field->table->in_use->count_cuted_fields) |
2849 | + { |
2850 | -+ copy->truncated = true; |
2851 | ++ copy->truncated= true; |
2852 | copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
2853 | WARN_DATA_TRUNCATED, 1); |
2854 | + } |
2855 | } |
2856 | int2store(copy->to_ptr,length); |
2857 | memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, copy->from_ptr + HA_KEY_BLOB_LENGTH, |
2858 | -@@ -499,6 +527,7 @@ |
2859 | +@@ -499,6 +533,7 @@ |
2860 | |
2861 | static void do_varstring2_mb(Copy_field *copy) |
2862 | { |
2863 | -+ copy->truncated = false; |
2864 | ++ copy->truncated= false; |
2865 | int well_formed_error; |
2866 | CHARSET_INFO *cs= copy->from_field->charset(); |
2867 | uint char_length= (copy->to_length - HA_KEY_BLOB_LENGTH) / cs->mbmaxlen; |
2868 | -@@ -509,6 +538,7 @@ |
2869 | +@@ -509,6 +544,7 @@ |
2870 | char_length, &well_formed_error); |
2871 | if (length < from_length) |
2872 | { |
2873 | -+ copy->truncated = true; |
2874 | ++ copy->truncated= true; |
2875 | if (current_thd->count_cuted_fields) |
2876 | copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, |
2877 | WARN_DATA_TRUNCATED, 1); |
2878 | --- a/sql/field.h |
2879 | +++ b/sql/field.h |
2880 | -@@ -115,10 +115,26 @@ |
2881 | +@@ -115,10 +115,27 @@ |
2882 | const char *field_name_arg); |
2883 | virtual ~Field() {} |
2884 | /* Store functions returns 1 on overflow and -1 on fatal error */ |
2885 | @@ -2132,40 +2606,41 @@ |
2886 | - virtual int store(double nr)=0; |
2887 | - virtual int store(longlong nr, bool unsigned_val)=0; |
2888 | - virtual int store_decimal(const my_decimal *d)=0; |
2889 | -+ virtual int store(const char *to, uint length,CHARSET_INFO *cs) |
2890 | ++ virtual int store(const char *to, uint length, CHARSET_INFO *cs) |
2891 | + { |
2892 | + return store_truncated(to,length,cs,0); |
2893 | + } |
2894 | -+ virtual int store_truncated(const char *to, uint length,CHARSET_INFO *cs,bool *truncated)=0; |
2895 | ++ virtual int store_truncated(const char *to, uint length, CHARSET_INFO *cs, |
2896 | ++ bool *truncated)=0; |
2897 | + virtual int store(double nr) |
2898 | + { |
2899 | -+ return store_truncated(nr,0); |
2900 | ++ return store_truncated(nr, 0); |
2901 | + } |
2902 | -+ virtual int store_truncated(double nr,bool *truncated)=0; |
2903 | ++ virtual int store_truncated(double nr, bool *truncated)=0; |
2904 | + virtual int store(longlong nr, bool unsigned_val) |
2905 | + { |
2906 | -+ return store_truncated(nr,unsigned_val,0); |
2907 | ++ return store_truncated(nr, unsigned_val, 0); |
2908 | + } |
2909 | + virtual int store_truncated(longlong nr, bool unsigned_val, bool *truncated)=0; |
2910 | + virtual int store_decimal(const my_decimal *d) |
2911 | + { |
2912 | -+ return store_decimal_truncated(d,0); |
2913 | ++ return store_decimal_truncated(d, 0); |
2914 | + } |
2915 | -+ virtual int store_decimal_truncated(const my_decimal *d,bool *truncated)=0; |
2916 | ++ virtual int store_decimal_truncated(const my_decimal *d, bool *truncated)=0; |
2917 | virtual int store_time(MYSQL_TIME *ltime, timestamp_type t_type); |
2918 | int store(const char *to, uint length, CHARSET_INFO *cs, |
2919 | enum_check_fields check_level); |
2920 | -@@ -463,7 +479,18 @@ |
2921 | +@@ -463,7 +480,18 @@ |
2922 | { |
2923 | return (op_result == E_DEC_OVERFLOW); |
2924 | } |
2925 | - int warn_if_overflow(int op_result); |
2926 | + int warn_if_overflow(int op_result) |
2927 | + { |
2928 | -+ return warn_if_overflow_truncated(op_result,0); |
2929 | ++ return warn_if_overflow_truncated(op_result, 0); |
2930 | + } |
2931 | -+ int warn_if_overflow_truncated(int op_result,bool *truncated); |
2932 | -+ inline void if_overflow_truncated(int op_result,bool *truncated) |
2933 | ++ int warn_if_overflow_truncated(int op_result, bool *truncated); |
2934 | ++ inline void if_overflow_truncated(int op_result, bool *truncated) |
2935 | + { |
2936 | + if (truncated) |
2937 | + { |
2938 | @@ -2175,58 +2650,61 @@ |
2939 | void init(TABLE *table_arg) |
2940 | { |
2941 | orig_table= table= table_arg; |
2942 | -@@ -483,7 +510,12 @@ |
2943 | - virtual uint is_equal(Create_field *new_field); |
2944 | +@@ -484,6 +512,12 @@ |
2945 | /* convert decimal to longlong with overflow check */ |
2946 | longlong convert_decimal2longlong(const my_decimal *val, bool unsigned_flag, |
2947 | - int *err); |
2948 | + int *err) |
2949 | + { |
2950 | -+ return convert_decimal2longlong_truncated(val,unsigned_flag,err,0); |
2951 | ++ return convert_decimal2longlong_truncated(val, unsigned_flag, err, 0); |
2952 | + } |
2953 | -+ longlong convert_decimal2longlong_truncated(const my_decimal *val, bool unsigned_flag, |
2954 | -+ int *err,bool *truncated); |
2955 | ++ longlong convert_decimal2longlong_truncated(const my_decimal *val, |
2956 | ++ bool unsigned_flag, int *err, |
2957 | ++ bool *truncated); |
2958 | /* The max. number of characters */ |
2959 | inline uint32 char_length() const |
2960 | { |
2961 | -@@ -636,7 +668,11 @@ |
2962 | +@@ -636,7 +670,11 @@ |
2963 | uint decimals() const { return (uint) dec; } |
2964 | uint size_of() const { return sizeof(*this); } |
2965 | bool eq_def(Field *field); |
2966 | - int store_decimal(const my_decimal *); |
2967 | + int store_decimal(const my_decimal *value) |
2968 | + { |
2969 | -+ return store_decimal_truncated(value,0); |
2970 | ++ return store_decimal_truncated(value, 0); |
2971 | + } |
2972 | -+ int store_decimal_truncated(const my_decimal *,bool *truncated); |
2973 | ++ int store_decimal_truncated(const my_decimal*, bool *truncated); |
2974 | uint row_pack_length() |
2975 | { |
2976 | return pack_length(); |
2977 | -@@ -651,10 +687,21 @@ |
2978 | +@@ -651,10 +689,22 @@ |
2979 | my_decimal *val_decimal(my_decimal *); |
2980 | uint is_equal(Create_field *new_field); |
2981 | int check_int(CHARSET_INFO *cs, const char *str, int length, |
2982 | - const char *int_end, int error); |
2983 | +- bool get_int(CHARSET_INFO *cs, const char *from, uint len, |
2984 | +- longlong *rnd, ulonglong unsigned_max, |
2985 | +- longlong signed_min, longlong signed_max); |
2986 | + const char *int_end, int error) |
2987 | + { |
2988 | -+ return check_int_truncated(cs,str,length,int_end,error,0); |
2989 | ++ return check_int_truncated(cs, str, length, int_end, error, 0); |
2990 | + } |
2991 | + int check_int_truncated(CHARSET_INFO *cs, const char *str, int length, |
2992 | -+ const char *int_end, int error,bool *truncated); |
2993 | - bool get_int(CHARSET_INFO *cs, const char *from, uint len, |
2994 | - longlong *rnd, ulonglong unsigned_max, |
2995 | -- longlong signed_min, longlong signed_max); |
2996 | -+ longlong signed_min, longlong signed_max) |
2997 | ++ const char *int_end, int error, bool *truncated); |
2998 | ++ bool get_int(CHARSET_INFO *cs, const char *from, uint len, longlong *rnd, |
2999 | ++ ulonglong unsigned_max, longlong signed_min, longlong signed_max) |
3000 | + { |
3001 | -+ return get_int_truncated(cs,from,len,rnd,unsigned_max,signed_min,signed_max,0); |
3002 | ++ return get_int_truncated(cs, from,len, rnd, unsigned_max, signed_min, |
3003 | ++ signed_max, 0); |
3004 | + } |
3005 | -+ bool get_int_truncated(CHARSET_INFO *cs, const char *from, uint len, |
3006 | -+ longlong *rnd, ulonglong unsigned_max, |
3007 | -+ longlong signed_min, longlong signed_max,bool *truncated); |
3008 | ++ bool get_int_truncated(CHARSET_INFO *cs, const char *from, uint len, |
3009 | ++ longlong *rnd, ulonglong unsigned_max, |
3010 | ++ longlong signed_min, longlong signed_max, |
3011 | ++ bool *truncated); |
3012 | }; |
3013 | |
3014 | |
3015 | -@@ -668,10 +715,26 @@ |
3016 | +@@ -668,10 +718,27 @@ |
3017 | const char *field_name_arg, CHARSET_INFO *charset); |
3018 | Item_result result_type () const { return STRING_RESULT; } |
3019 | uint decimals() const { return NOT_FIXED_DEC; } |
3020 | @@ -2236,300 +2714,310 @@ |
3021 | - int store(const char *to,uint length,CHARSET_INFO *cs)=0; |
3022 | + int store(double nr) |
3023 | + { |
3024 | -+ return store_truncated(nr,0); |
3025 | ++ return store_truncated(nr, 0); |
3026 | + } |
3027 | -+ int store_truncated(double nr,bool *truncated); |
3028 | ++ int store_truncated(double nr, bool *truncated); |
3029 | + int store(longlong nr, bool unsigned_val) |
3030 | + { |
3031 | -+ return store_truncated(nr,unsigned_val,0); |
3032 | ++ return store_truncated(nr, unsigned_val, 0); |
3033 | + } |
3034 | -+ int store_truncated(longlong nr, bool unsigned_val,bool* truncated)=0; |
3035 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated)=0; |
3036 | + int store_decimal(const my_decimal *value) |
3037 | + { |
3038 | -+ return store_decimal_truncated(value,0); |
3039 | ++ return store_decimal_truncated(value, 0); |
3040 | + } |
3041 | -+ int store_decimal_truncated(const my_decimal *,bool *truncated); |
3042 | -+ int store(const char *to,uint length,CHARSET_INFO *cs) |
3043 | ++ int store_decimal_truncated(const my_decimal*, bool *truncated); |
3044 | ++ int store(const char *to, uint length, CHARSET_INFO *cs) |
3045 | + { |
3046 | -+ return store_truncated(to,length,cs,0); |
3047 | ++ return store_truncated(to, length, cs, 0); |
3048 | + } |
3049 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *cs,bool *truncated)=0; |
3050 | ++ int store_truncated(const char* to, uint length, CHARSET_INFO *cs, |
3051 | ++ bool *truncated)=0; |
3052 | uint size_of() const { return sizeof(*this); } |
3053 | CHARSET_INFO *charset(void) const { return field_charset; } |
3054 | void set_charset(CHARSET_INFO *charset_arg) { field_charset= charset_arg; } |
3055 | -@@ -702,7 +765,11 @@ |
3056 | +@@ -702,7 +769,11 @@ |
3057 | field_name_arg, charset_arg) |
3058 | {} |
3059 | |
3060 | - int store_decimal(const my_decimal *d); |
3061 | + int store_decimal(const my_decimal *d) |
3062 | + { |
3063 | -+ return store_decimal_truncated(d,0); |
3064 | ++ return store_decimal_truncated(d, 0); |
3065 | + } |
3066 | -+ int store_decimal_truncated(const my_decimal *d,bool *truncated); |
3067 | ++ int store_decimal_truncated(const my_decimal *d, bool *truncated); |
3068 | uint32 max_data_length() const; |
3069 | }; |
3070 | |
3071 | -@@ -719,9 +786,17 @@ |
3072 | +@@ -719,9 +790,17 @@ |
3073 | field_name_arg, dec_arg, zero_arg, unsigned_arg), |
3074 | not_fixed(dec_arg >= NOT_FIXED_DEC) |
3075 | {} |
3076 | - int store_decimal(const my_decimal *); |
3077 | + int store_decimal(const my_decimal *value) |
3078 | + { |
3079 | -+ return store_decimal_truncated(value,0); |
3080 | ++ return store_decimal_truncated(value, 0); |
3081 | + } |
3082 | -+ int store_decimal_truncated(const my_decimal *,bool *truncated); |
3083 | ++ int store_decimal_truncated(const my_decimal*, bool *truncated); |
3084 | my_decimal *val_decimal(my_decimal *); |
3085 | - int truncate(double *nr, double max_length); |
3086 | + int truncate(double *nr, double max_length) |
3087 | + { |
3088 | -+ return truncate_truncated(nr,max_length,0); |
3089 | ++ return truncate_truncated(nr, max_length, 0); |
3090 | + } |
3091 | -+ int truncate_truncated(double *nr, double max_length,bool *truncated); |
3092 | ++ int truncate_truncated(double *nr, double max_length, bool *truncated); |
3093 | uint32 max_display_length() { return field_length; } |
3094 | uint size_of() const { return sizeof(*this); } |
3095 | virtual const uchar *unpack(uchar* to, const uchar *from, |
3096 | -@@ -745,9 +820,21 @@ |
3097 | +@@ -745,9 +824,22 @@ |
3098 | enum ha_base_keytype key_type() const |
3099 | { return zerofill ? HA_KEYTYPE_BINARY : HA_KEYTYPE_NUM; } |
3100 | int reset(void); |
3101 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3102 | - int store(double nr); |
3103 | - int store(longlong nr, bool unsigned_val); |
3104 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3105 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3106 | + { |
3107 | -+ return store_truncated(to,length,charset,0); |
3108 | ++ return store_truncated(to, length, charset, 0); |
3109 | + } |
3110 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3111 | ++ int store_truncated(const char* to, uint length, CHARSET_INFO *charset, |
3112 | ++ bool *truncated); |
3113 | + int store(double nr) |
3114 | + { |
3115 | -+ return store_truncated(nr,0); |
3116 | ++ return store_truncated(nr, 0); |
3117 | + } |
3118 | -+ int store_truncated(double nr,bool *truncated); |
3119 | ++ int store_truncated(double nr, bool *truncated); |
3120 | + int store(longlong nr, bool unsigned_val) |
3121 | + { |
3122 | -+ return store_truncated(nr,unsigned_val,0); |
3123 | ++ return store_truncated(nr, unsigned_val, 0); |
3124 | + } |
3125 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3126 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3127 | double val_real(void); |
3128 | longlong val_int(void); |
3129 | String *val_str(String*,String *); |
3130 | -@@ -794,13 +881,33 @@ |
3131 | +@@ -794,13 +886,34 @@ |
3132 | enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } |
3133 | Item_result result_type () const { return DECIMAL_RESULT; } |
3134 | int reset(void); |
3135 | - bool store_value(const my_decimal *decimal_value); |
3136 | + bool store_value(const my_decimal *decimal_value) |
3137 | + { |
3138 | -+ return store_value_truncated(decimal_value,0); |
3139 | ++ return store_value_truncated(decimal_value, 0); |
3140 | + } |
3141 | -+ bool store_value_truncated(const my_decimal *decimal_value,bool *truncated); |
3142 | ++ bool store_value_truncated(const my_decimal *decimal_value, bool *truncated); |
3143 | void set_value_on_overflow(my_decimal *decimal_value, bool sign); |
3144 | - int store(const char *to, uint length, CHARSET_INFO *charset); |
3145 | - int store(double nr); |
3146 | - int store(longlong nr, bool unsigned_val); |
3147 | -+ int store(const char *to, uint length, CHARSET_INFO *charset) |
3148 | -+ { |
3149 | -+ return store_truncated(to,length,charset,0); |
3150 | -+ } |
3151 | -+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,bool *truncated); |
3152 | -+ int store(double nr) |
3153 | -+ { |
3154 | -+ return store_truncated(nr,0); |
3155 | -+ } |
3156 | -+ int store_truncated(double nr,bool *truncated); |
3157 | -+ int store(longlong nr, bool unsigned_val) |
3158 | -+ { |
3159 | -+ return store_truncated(nr,unsigned_val,0); |
3160 | -+ } |
3161 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3162 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3163 | ++ { |
3164 | ++ return store_truncated(to, length, charset, 0); |
3165 | ++ } |
3166 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3167 | ++ bool *truncated); |
3168 | ++ int store(double nr) |
3169 | ++ { |
3170 | ++ return store_truncated(nr, 0); |
3171 | ++ } |
3172 | ++ int store_truncated(double nr, bool *truncated); |
3173 | ++ int store(longlong nr, bool unsigned_val) |
3174 | ++ { |
3175 | ++ return store_truncated(nr, unsigned_val, 0); |
3176 | ++ } |
3177 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3178 | int store_time(MYSQL_TIME *ltime, timestamp_type t_type); |
3179 | - int store_decimal(const my_decimal *); |
3180 | -+ int store_decimal(const my_decimal *value) |
3181 | ++ int store_decimal(const my_decimal *value) |
3182 | + { |
3183 | -+ return store_decimal_truncated(value,0); |
3184 | ++ return store_decimal_truncated(value, 0); |
3185 | + } |
3186 | -+ int store_decimal_truncated(const my_decimal *,bool *truncated); |
3187 | ++ int store_decimal_truncated(const my_decimal*, bool *truncated); |
3188 | double val_real(void); |
3189 | longlong val_int(void); |
3190 | my_decimal *val_decimal(my_decimal *); |
3191 | -@@ -837,9 +944,21 @@ |
3192 | +@@ -837,9 +950,22 @@ |
3193 | enum_field_types type() const { return MYSQL_TYPE_TINY;} |
3194 | enum ha_base_keytype key_type() const |
3195 | { return unsigned_flag ? HA_KEYTYPE_BINARY : HA_KEYTYPE_INT8; } |
3196 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3197 | - int store(double nr); |
3198 | - int store(longlong nr, bool unsigned_val); |
3199 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3200 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3201 | + { |
3202 | -+ return store_truncated(to,length,charset,0); |
3203 | ++ return store_truncated(to, length, charset, 0); |
3204 | + } |
3205 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3206 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3207 | ++ bool *truncated); |
3208 | + int store(double nr) |
3209 | + { |
3210 | -+ return store_truncated(nr,0); |
3211 | ++ return store_truncated(nr, 0); |
3212 | + } |
3213 | -+ int store_truncated(double nr,bool *truncated); |
3214 | ++ int store_truncated(double nr, bool *truncated); |
3215 | + int store(longlong nr, bool unsigned_val) |
3216 | + { |
3217 | -+ return store_truncated(nr,unsigned_val,0); |
3218 | ++ return store_truncated(nr, unsigned_val, 0); |
3219 | + } |
3220 | + int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3221 | int reset(void) { ptr[0]=0; return 0; } |
3222 | double val_real(void); |
3223 | longlong val_int(void); |
3224 | -@@ -886,9 +1005,21 @@ |
3225 | +@@ -886,9 +1012,22 @@ |
3226 | enum_field_types type() const { return MYSQL_TYPE_SHORT;} |
3227 | enum ha_base_keytype key_type() const |
3228 | { return unsigned_flag ? HA_KEYTYPE_USHORT_INT : HA_KEYTYPE_SHORT_INT;} |
3229 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3230 | - int store(double nr); |
3231 | - int store(longlong nr, bool unsigned_val); |
3232 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3233 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3234 | + { |
3235 | -+ return store_truncated(to,length,charset,0); |
3236 | ++ return store_truncated(to, length, charset, 0); |
3237 | + } |
3238 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3239 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3240 | ++ bool *truncated); |
3241 | + int store(double nr) |
3242 | + { |
3243 | -+ return store_truncated(nr,0); |
3244 | ++ return store_truncated(nr, 0); |
3245 | + } |
3246 | -+ int store_truncated(double nr,bool *truncated); |
3247 | ++ int store_truncated(double nr, bool *truncated); |
3248 | + int store(longlong nr, bool unsigned_val) |
3249 | + { |
3250 | -+ return store_truncated(nr,unsigned_val,0); |
3251 | ++ return store_truncated(nr, unsigned_val, 0); |
3252 | + } |
3253 | + int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3254 | int reset(void) { ptr[0]=ptr[1]=0; return 0; } |
3255 | double val_real(void); |
3256 | longlong val_int(void); |
3257 | -@@ -955,9 +1086,21 @@ |
3258 | +@@ -955,9 +1094,22 @@ |
3259 | enum_field_types type() const { return MYSQL_TYPE_INT24;} |
3260 | enum ha_base_keytype key_type() const |
3261 | { return unsigned_flag ? HA_KEYTYPE_UINT24 : HA_KEYTYPE_INT24; } |
3262 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3263 | - int store(double nr); |
3264 | - int store(longlong nr, bool unsigned_val); |
3265 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3266 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3267 | + { |
3268 | -+ return store_truncated(to,length,charset,0); |
3269 | ++ return store_truncated(to, length, charset, 0); |
3270 | + } |
3271 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3272 | ++ int store_truncated(const char* to, uint length, CHARSET_INFO *charset, |
3273 | ++ bool *truncated); |
3274 | + int store(double nr) |
3275 | + { |
3276 | -+ return store_truncated(nr,0); |
3277 | ++ return store_truncated(nr, 0); |
3278 | + } |
3279 | -+ int store_truncated(double nr,bool *truncated); |
3280 | ++ int store_truncated(double nr, bool *truncated); |
3281 | + int store(longlong nr, bool unsigned_val) |
3282 | + { |
3283 | -+ return store_truncated(nr,unsigned_val,0); |
3284 | ++ return store_truncated(nr, unsigned_val, 0); |
3285 | + } |
3286 | + int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3287 | int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; } |
3288 | double val_real(void); |
3289 | longlong val_int(void); |
3290 | -@@ -1002,9 +1145,21 @@ |
3291 | +@@ -1002,9 +1154,22 @@ |
3292 | enum_field_types type() const { return MYSQL_TYPE_LONG;} |
3293 | enum ha_base_keytype key_type() const |
3294 | { return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; } |
3295 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3296 | - int store(double nr); |
3297 | - int store(longlong nr, bool unsigned_val); |
3298 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3299 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3300 | + { |
3301 | -+ return store_truncated(to,length,charset,0); |
3302 | ++ return store_truncated(to, length, charset, 0); |
3303 | + } |
3304 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3305 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3306 | ++ bool *truncated); |
3307 | + int store(double nr) |
3308 | + { |
3309 | -+ return store_truncated(nr,0); |
3310 | ++ return store_truncated(nr, 0); |
3311 | + } |
3312 | -+ int store_truncated(double nr,bool *truncated); |
3313 | ++ int store_truncated(double nr, bool *truncated); |
3314 | + int store(longlong nr, bool unsigned_val) |
3315 | + { |
3316 | -+ return store_truncated(nr,unsigned_val,0); |
3317 | ++ return store_truncated(nr, unsigned_val, 0); |
3318 | + } |
3319 | + int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3320 | int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; } |
3321 | double val_real(void); |
3322 | longlong val_int(void); |
3323 | -@@ -1051,9 +1206,21 @@ |
3324 | +@@ -1051,9 +1216,22 @@ |
3325 | enum_field_types type() const { return MYSQL_TYPE_LONGLONG;} |
3326 | enum ha_base_keytype key_type() const |
3327 | { return unsigned_flag ? HA_KEYTYPE_ULONGLONG : HA_KEYTYPE_LONGLONG; } |
3328 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3329 | - int store(double nr); |
3330 | - int store(longlong nr, bool unsigned_val); |
3331 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3332 | ++ int store(const char* to, uint length, CHARSET_INFO *charset) |
3333 | + { |
3334 | -+ return store_truncated(to,length,charset,0); |
3335 | ++ return store_truncated(to, length, charset, 0); |
3336 | + } |
3337 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3338 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3339 | ++ bool *truncated); |
3340 | + int store(double nr) |
3341 | + { |
3342 | -+ return store_truncated(nr,0); |
3343 | ++ return store_truncated(nr, 0); |
3344 | + } |
3345 | -+ int store_truncated(double nr,bool *truncated); |
3346 | ++ int store_truncated(double nr, bool *truncated); |
3347 | + int store(longlong nr, bool unsigned_val) |
3348 | + { |
3349 | -+ return store_truncated(nr,unsigned_val,0); |
3350 | ++ return store_truncated(nr, unsigned_val, 0); |
3351 | + } |
3352 | + int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3353 | int reset(void) |
3354 | { |
3355 | ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; |
3356 | -@@ -1102,9 +1269,21 @@ |
3357 | +@@ -1102,9 +1280,22 @@ |
3358 | {} |
3359 | enum_field_types type() const { return MYSQL_TYPE_FLOAT;} |
3360 | enum ha_base_keytype key_type() const { return HA_KEYTYPE_FLOAT; } |
3361 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3362 | - int store(double nr); |
3363 | - int store(longlong nr, bool unsigned_val); |
3364 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3365 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3366 | + { |
3367 | -+ return store_truncated(to,length,charset,0); |
3368 | ++ return store_truncated(to, length, charset, 0); |
3369 | + } |
3370 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3371 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3372 | ++ bool *truncated); |
3373 | + int store(double nr) |
3374 | + { |
3375 | -+ return store_truncated(nr,0); |
3376 | ++ return store_truncated(nr, 0); |
3377 | + } |
3378 | -+ int store_truncated(double nr,bool *truncated); |
3379 | ++ int store_truncated(double nr, bool *truncated); |
3380 | + int store(longlong nr, bool unsigned_val) |
3381 | + { |
3382 | -+ return store_truncated(nr,unsigned_val,0); |
3383 | ++ return store_truncated(nr, unsigned_val, 0); |
3384 | + } |
3385 | + int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3386 | int reset(void) { bzero(ptr,sizeof(float)); return 0; } |
3387 | double val_real(void); |
3388 | longlong val_int(void); |
3389 | -@@ -1142,9 +1321,21 @@ |
3390 | +@@ -1142,9 +1333,22 @@ |
3391 | {not_fixed= not_fixed_arg; } |
3392 | enum_field_types type() const { return MYSQL_TYPE_DOUBLE;} |
3393 | enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; } |
3394 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3395 | - int store(double nr); |
3396 | - int store(longlong nr, bool unsigned_val); |
3397 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3398 | -+ { |
3399 | -+ return store_truncated(to,length,charset,0); |
3400 | -+ } |
3401 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3402 | -+ int store(double nr) |
3403 | -+ { |
3404 | -+ return store_truncated(nr,0); |
3405 | -+ } |
3406 | -+ int store_truncated(double nr,bool *truncated); |
3407 | -+ int store(longlong nr, bool unsigned_val) |
3408 | -+ { |
3409 | -+ return store_truncated(nr,unsigned_val,0); |
3410 | -+ } |
3411 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3412 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3413 | ++ { |
3414 | ++ return store_truncated(to, length, charset, 0); |
3415 | ++ } |
3416 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3417 | ++ bool *truncated); |
3418 | ++ int store(double nr) |
3419 | ++ { |
3420 | ++ return store_truncated(nr, 0); |
3421 | ++ } |
3422 | ++ int store_truncated(double nr, bool *truncated); |
3423 | ++ int store(longlong nr, bool unsigned_val) |
3424 | ++ { |
3425 | ++ return store_truncated(nr, unsigned_val, 0); |
3426 | ++ } |
3427 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3428 | int reset(void) { bzero(ptr,sizeof(double)); return 0; } |
3429 | double val_real(void); |
3430 | longlong val_int(void); |
3431 | -@@ -1173,10 +1364,17 @@ |
3432 | +@@ -1173,10 +1377,58 @@ |
3433 | {} |
3434 | enum_field_types type() const { return MYSQL_TYPE_NULL;} |
3435 | int store(const char *to, uint length, CHARSET_INFO *cs) |
3436 | @@ -2538,239 +3026,301 @@ |
3437 | - int store(longlong nr, bool unsigned_val) { null[0]=1; return 0; } |
3438 | - int store_decimal(const my_decimal *d) { null[0]=1; return 0; } |
3439 | + { |
3440 | -+ return store_truncated(to,length,cs,0); |
3441 | -+ } |
3442 | -+ int store_truncated(const char *to, uint length, CHARSET_INFO *cs,bool *truncated) |
3443 | -+ { if (truncated) { *truncated= false; } null[0]=1; return 0; } |
3444 | -+ int store(double nr) { return store_truncated(nr,0); } |
3445 | -+ int store_truncated(double nr,bool *truncated) { if (truncated) { *truncated= false; } null[0]=1; return 0; } |
3446 | -+ int store(longlong nr, bool unsigned_val) { return store_truncated(nr,unsigned_val,0); } |
3447 | -+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated) { if (truncated) { *truncated= false; } null[0]=1; return 0; } |
3448 | -+ int store_decimal(const my_decimal *d) { return store_decimal_truncated(d,0); } |
3449 | -+ int store_decimal_truncated(const my_decimal *d,bool *truncated) { if (truncated) { *truncated= false; } null[0]=1; return 0; } |
3450 | ++ return store_truncated(to, length, cs, 0); |
3451 | ++ } |
3452 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *cs, |
3453 | ++ bool *truncated) |
3454 | ++ { |
3455 | ++ if (truncated) |
3456 | ++ { |
3457 | ++ *truncated= false; |
3458 | ++ } |
3459 | ++ null[0]= 1; |
3460 | ++ return 0; |
3461 | ++ } |
3462 | ++ int store(double nr) |
3463 | ++ { |
3464 | ++ return store_truncated(nr, 0); |
3465 | ++ } |
3466 | ++ int store_truncated(double nr, bool *truncated) |
3467 | ++ { |
3468 | ++ if (truncated) |
3469 | ++ { |
3470 | ++ *truncated= false; |
3471 | ++ } |
3472 | ++ null[0]=1; |
3473 | ++ return 0; |
3474 | ++ } |
3475 | ++ int store(longlong nr, bool unsigned_val) |
3476 | ++ { |
3477 | ++ return store_truncated(nr, unsigned_val, 0); |
3478 | ++ } |
3479 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
3480 | ++ { |
3481 | ++ if (truncated) |
3482 | ++ { |
3483 | ++ *truncated= false; |
3484 | ++ } |
3485 | ++ null[0]= 1; |
3486 | ++ return 0; |
3487 | ++ } |
3488 | ++ int store_decimal(const my_decimal *d) |
3489 | ++ { |
3490 | ++ return store_decimal_truncated(d, 0); |
3491 | ++ } |
3492 | ++ int store_decimal_truncated(const my_decimal *d, bool *truncated) |
3493 | ++ { |
3494 | ++ if (truncated) |
3495 | ++ { |
3496 | ++ *truncated= false; |
3497 | ++ } |
3498 | ++ null[0]= 1; |
3499 | ++ return 0; |
3500 | ++ } |
3501 | int reset(void) { return 0; } |
3502 | double val_real(void) { return 0.0;} |
3503 | longlong val_int(void) { return 0;} |
3504 | -@@ -1203,9 +1401,21 @@ |
3505 | +@@ -1203,9 +1454,22 @@ |
3506 | enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;} |
3507 | enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } |
3508 | enum Item_result cmp_type () const { return INT_RESULT; } |
3509 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3510 | - int store(double nr); |
3511 | - int store(longlong nr, bool unsigned_val); |
3512 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3513 | -+ { |
3514 | -+ return store_truncated(to,length,charset,0); |
3515 | -+ } |
3516 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3517 | -+ int store(double nr) |
3518 | -+ { |
3519 | -+ return store_truncated(nr,0); |
3520 | -+ } |
3521 | -+ int store_truncated(double nr,bool *truncated); |
3522 | -+ int store(longlong nr, bool unsigned_val) |
3523 | -+ { |
3524 | -+ return store_truncated(nr,unsigned_val,0); |
3525 | -+ } |
3526 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3527 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3528 | ++ { |
3529 | ++ return store_truncated(to, length, charset, 0); |
3530 | ++ } |
3531 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3532 | ++ bool *truncated); |
3533 | ++ int store(double nr) |
3534 | ++ { |
3535 | ++ return store_truncated(nr, 0); |
3536 | ++ } |
3537 | ++ int store_truncated(double nr, bool *truncated); |
3538 | ++ int store(longlong nr, bool unsigned_val) |
3539 | ++ { |
3540 | ++ return store_truncated(nr, unsigned_val, 0); |
3541 | ++ } |
3542 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3543 | int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; } |
3544 | double val_real(void); |
3545 | longlong val_int(void); |
3546 | -@@ -1276,9 +1486,21 @@ |
3547 | +@@ -1276,9 +1540,22 @@ |
3548 | unireg_check_arg, field_name_arg, 1, 1) |
3549 | {} |
3550 | enum_field_types type() const { return MYSQL_TYPE_YEAR;} |
3551 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3552 | - int store(double nr); |
3553 | - int store(longlong nr, bool unsigned_val); |
3554 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3555 | -+ { |
3556 | -+ return store_truncated(to,length,charset,0); |
3557 | -+ } |
3558 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3559 | -+ int store(double nr) |
3560 | -+ { |
3561 | -+ return store_truncated(nr,0); |
3562 | -+ } |
3563 | -+ int store_truncated(double nr,bool *truncated); |
3564 | -+ int store(longlong nr, bool unsigned_val) |
3565 | -+ { |
3566 | -+ return store_truncated(nr,unsigned_val,0); |
3567 | -+ } |
3568 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3569 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3570 | ++ { |
3571 | ++ return store_truncated(to, length, charset, 0); |
3572 | ++ } |
3573 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3574 | ++ bool *truncated); |
3575 | ++ int store(double nr) |
3576 | ++ { |
3577 | ++ return store_truncated(nr, 0); |
3578 | ++ } |
3579 | ++ int store_truncated(double nr, bool *truncated); |
3580 | ++ int store(longlong nr, bool unsigned_val) |
3581 | ++ { |
3582 | ++ return store_truncated(nr, unsigned_val, 0); |
3583 | ++ } |
3584 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3585 | double val_real(void); |
3586 | longlong val_int(void); |
3587 | String *val_str(String*,String *); |
3588 | -@@ -1303,9 +1525,21 @@ |
3589 | +@@ -1303,9 +1580,22 @@ |
3590 | enum_field_types type() const { return MYSQL_TYPE_DATE;} |
3591 | enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } |
3592 | enum Item_result cmp_type () const { return INT_RESULT; } |
3593 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3594 | - int store(double nr); |
3595 | - int store(longlong nr, bool unsigned_val); |
3596 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3597 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3598 | + { |
3599 | -+ return store_truncated(to,length,charset,0); |
3600 | ++ return store_truncated(to, length, charset, 0); |
3601 | + } |
3602 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3603 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3604 | ++ bool *truncated); |
3605 | + int store(double nr) |
3606 | + { |
3607 | -+ return store_truncated(nr,0); |
3608 | ++ return store_truncated(nr, 0); |
3609 | + } |
3610 | -+ int store_truncated(double nr,bool *truncated); |
3611 | ++ int store_truncated(double nr, bool *truncated); |
3612 | + int store(longlong nr, bool unsigned_val) |
3613 | + { |
3614 | -+ return store_truncated(nr,unsigned_val,0); |
3615 | ++ return store_truncated(nr, unsigned_val, 0); |
3616 | + } |
3617 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3618 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3619 | int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; } |
3620 | double val_real(void); |
3621 | longlong val_int(void); |
3622 | -@@ -1348,9 +1582,21 @@ |
3623 | +@@ -1348,9 +1638,22 @@ |
3624 | enum_field_types real_type() const { return MYSQL_TYPE_NEWDATE; } |
3625 | enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; } |
3626 | enum Item_result cmp_type () const { return INT_RESULT; } |
3627 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3628 | - int store(double nr); |
3629 | - int store(longlong nr, bool unsigned_val); |
3630 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3631 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3632 | + { |
3633 | -+ return store_truncated(to,length,charset,0); |
3634 | ++ return store_truncated(to, length, charset, 0); |
3635 | + } |
3636 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3637 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3638 | ++ bool *truncated); |
3639 | + int store(double nr) |
3640 | + { |
3641 | -+ return store_truncated(nr,0); |
3642 | ++ return store_truncated(nr, 0); |
3643 | + } |
3644 | -+ int store_truncated(double nr,bool *truncated); |
3645 | ++ int store_truncated(double nr, bool *truncated); |
3646 | + int store(longlong nr, bool unsigned_val) |
3647 | + { |
3648 | -+ return store_truncated(nr,unsigned_val,0); |
3649 | ++ return store_truncated(nr, unsigned_val, 0); |
3650 | + } |
3651 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3652 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3653 | int store_time(MYSQL_TIME *ltime, timestamp_type type); |
3654 | int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; } |
3655 | double val_real(void); |
3656 | -@@ -1384,9 +1630,21 @@ |
3657 | +@@ -1384,9 +1687,22 @@ |
3658 | enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; } |
3659 | enum Item_result cmp_type () const { return INT_RESULT; } |
3660 | int store_time(MYSQL_TIME *ltime, timestamp_type type); |
3661 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3662 | - int store(double nr); |
3663 | - int store(longlong nr, bool unsigned_val); |
3664 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3665 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3666 | + { |
3667 | -+ return store_truncated(to,length,charset,0); |
3668 | ++ return store_truncated(to, length, charset, 0); |
3669 | + } |
3670 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3671 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3672 | ++ bool *truncated); |
3673 | + int store(double nr) |
3674 | + { |
3675 | -+ return store_truncated(nr,0); |
3676 | ++ return store_truncated(nr, 0); |
3677 | + } |
3678 | -+ int store_truncated(double nr,bool *truncated); |
3679 | ++ int store_truncated(double nr, bool *truncated); |
3680 | + int store(longlong nr, bool unsigned_val) |
3681 | + { |
3682 | -+ return store_truncated(nr,unsigned_val,0); |
3683 | ++ return store_truncated(nr, unsigned_val, 0); |
3684 | + } |
3685 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3686 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3687 | int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; } |
3688 | double val_real(void); |
3689 | longlong val_int(void); |
3690 | -@@ -1421,9 +1679,21 @@ |
3691 | +@@ -1421,9 +1737,22 @@ |
3692 | #endif |
3693 | enum Item_result cmp_type () const { return INT_RESULT; } |
3694 | uint decimals() const { return DATETIME_DEC; } |
3695 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3696 | - int store(double nr); |
3697 | - int store(longlong nr, bool unsigned_val); |
3698 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3699 | -+ { |
3700 | -+ return store_truncated(to,length,charset,0); |
3701 | -+ } |
3702 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3703 | -+ int store(double nr) |
3704 | -+ { |
3705 | -+ return store_truncated(nr,0); |
3706 | -+ } |
3707 | -+ int store_truncated(double nr, bool *truncated); |
3708 | -+ int store(longlong nr, bool unsigned_val) |
3709 | -+ { |
3710 | -+ return store_truncated(nr,unsigned_val,0); |
3711 | -+ } |
3712 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3713 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3714 | ++ { |
3715 | ++ return store_truncated(to, length, charset, 0); |
3716 | ++ } |
3717 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3718 | ++ bool *truncated); |
3719 | ++ int store(double nr) |
3720 | ++ { |
3721 | ++ return store_truncated(nr, 0); |
3722 | ++ } |
3723 | ++ int store_truncated(double nr, bool *truncated); |
3724 | ++ int store(longlong nr, bool unsigned_val) |
3725 | ++ { |
3726 | ++ return store_truncated(nr, unsigned_val, 0); |
3727 | ++ } |
3728 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3729 | int store_time(MYSQL_TIME *ltime, timestamp_type type); |
3730 | int reset(void) |
3731 | { |
3732 | -@@ -1489,9 +1759,18 @@ |
3733 | +@@ -1489,9 +1818,25 @@ |
3734 | (has_charset() ? ' ' : 0)); |
3735 | return 0; |
3736 | } |
3737 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3738 | - int store(longlong nr, bool unsigned_val); |
3739 | - int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */ |
3740 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3741 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3742 | + { |
3743 | -+ return store_truncated(to,length,charset,0); |
3744 | ++ return store_truncated(to, length, charset, 0); |
3745 | + } |
3746 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3747 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3748 | ++ bool *truncated); |
3749 | + int store(longlong nr, bool unsigned_val) |
3750 | + { |
3751 | -+ return store_truncated(nr,unsigned_val,0); |
3752 | -+ } |
3753 | -+ int store_truncated(longlong nr, bool unsigned_val, bool*truncated); |
3754 | -+ int store(double nr) { return store_truncated(nr,0); } /* QQ: To be deleted */ |
3755 | -+ int store_truncated(double nr,bool *truncated) { return Field_str::store_truncated(nr,truncated); } /* QQ: To be deleted */ |
3756 | ++ return store_truncated(nr, unsigned_val, 0); |
3757 | ++ } |
3758 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3759 | ++ int store(double nr) /* QQ: To be deleted */ |
3760 | ++ { |
3761 | ++ return store_truncated(nr, 0); |
3762 | ++ } |
3763 | ++ int store_truncated(double nr, bool *truncated)/* QQ: To be deleted */ |
3764 | ++ { |
3765 | ++ return Field_str::store_truncated(nr, truncated); |
3766 | ++ } |
3767 | double val_real(void); |
3768 | longlong val_int(void); |
3769 | String *val_str(String*,String *); |
3770 | -@@ -1574,9 +1853,18 @@ |
3771 | +@@ -1574,9 +1919,25 @@ |
3772 | return (uint32) field_length + (field_charset == &my_charset_bin ? |
3773 | length_bytes : 0); |
3774 | } |
3775 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3776 | - int store(longlong nr, bool unsigned_val); |
3777 | - int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */ |
3778 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3779 | -+ { |
3780 | -+ return store_truncated(to,length,charset,0); |
3781 | -+ } |
3782 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3783 | -+ int store(longlong nr, bool unsigned_val) |
3784 | -+ { |
3785 | -+ return store_truncated(nr,unsigned_val,0); |
3786 | -+ } |
3787 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3788 | -+ int store(double nr) { return store_truncated(nr,0); } /* QQ: To be deleted */ |
3789 | -+ int store_truncated(double nr,bool *truncated) { return Field_str::store_truncated(nr,truncated); } /* QQ: To be deleted */ |
3790 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3791 | ++ { |
3792 | ++ return store_truncated(to, length, charset, 0); |
3793 | ++ } |
3794 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3795 | ++ bool *truncated); |
3796 | ++ int store(longlong nr, bool unsigned_val) |
3797 | ++ { |
3798 | ++ return store_truncated(nr, unsigned_val, 0); |
3799 | ++ } |
3800 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3801 | ++ int store(double nr) /* QQ: To be deleted */ |
3802 | ++ { |
3803 | ++ return store_truncated(nr, 0); |
3804 | ++ } |
3805 | ++ int store_truncated(double nr, bool *truncated)/* QQ: To be deleted */ |
3806 | ++ { |
3807 | ++ return Field_str::store_truncated(nr, truncated); |
3808 | ++ } |
3809 | double val_real(void); |
3810 | longlong val_int(void); |
3811 | String *val_str(String*,String *); |
3812 | -@@ -1668,9 +1956,21 @@ |
3813 | +@@ -1668,9 +2029,22 @@ |
3814 | enum_field_types type() const { return MYSQL_TYPE_BLOB;} |
3815 | enum ha_base_keytype key_type() const |
3816 | { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; } |
3817 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3818 | - int store(double nr); |
3819 | - int store(longlong nr, bool unsigned_val); |
3820 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3821 | -+ { |
3822 | -+ return store_truncated(to,length,charset,0); |
3823 | -+ } |
3824 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool*truncated); |
3825 | -+ int store(double nr) |
3826 | -+ { |
3827 | -+ return store_truncated(nr,0); |
3828 | -+ } |
3829 | -+ int store_truncated(double nr,bool *truncated); |
3830 | -+ int store(longlong nr, bool unsigned_val) |
3831 | -+ { |
3832 | -+ return store_truncated(nr,unsigned_val,0); |
3833 | -+ } |
3834 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3835 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3836 | ++ { |
3837 | ++ return store_truncated(to, length, charset, 0); |
3838 | ++ } |
3839 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3840 | ++ bool *truncated); |
3841 | ++ int store(double nr) |
3842 | ++ { |
3843 | ++ return store_truncated(nr, 0); |
3844 | ++ } |
3845 | ++ int store_truncated(double nr, bool *truncated); |
3846 | ++ int store(longlong nr, bool unsigned_val) |
3847 | ++ { |
3848 | ++ return store_truncated(nr, unsigned_val, 0); |
3849 | ++ } |
3850 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3851 | double val_real(void); |
3852 | longlong val_int(void); |
3853 | String *val_str(String*,String *); |
3854 | -@@ -1824,10 +2124,26 @@ |
3855 | +@@ -1824,10 +2198,27 @@ |
3856 | enum ha_base_keytype key_type() const { return HA_KEYTYPE_VARBINARY2; } |
3857 | enum_field_types type() const { return MYSQL_TYPE_GEOMETRY; } |
3858 | void sql_type(String &str) const; |
3859 | @@ -2780,75 +3330,84 @@ |
3860 | - int store_decimal(const my_decimal *); |
3861 | + int store(const char *to, uint length, CHARSET_INFO *charset) |
3862 | + { |
3863 | -+ return store_truncated(to,length,charset,0); |
3864 | ++ return store_truncated(to, length, charset, 0); |
3865 | + } |
3866 | -+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,bool *truncated); |
3867 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3868 | ++ bool* truncated); |
3869 | + int store(double nr) |
3870 | + { |
3871 | -+ return store_truncated(nr,0); |
3872 | ++ return store_truncated(nr, 0); |
3873 | + } |
3874 | -+ int store_truncated(double nr,bool *truncated); |
3875 | ++ int store_truncated(double nr, bool *truncated); |
3876 | + int store(longlong nr, bool unsigned_val) |
3877 | + { |
3878 | -+ return store_truncated(nr,unsigned_val,0); |
3879 | ++ return store_truncated(nr, unsigned_val, 0); |
3880 | + } |
3881 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3882 | -+ int store_decimal(const my_decimal * value) |
3883 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3884 | ++ int store_decimal(const my_decimal *value) |
3885 | + { |
3886 | -+ return store_decimal_truncated(value,0); |
3887 | ++ return store_decimal_truncated(value, 0); |
3888 | + } |
3889 | -+ int store_decimal_truncated(const my_decimal *,bool *truncated); |
3890 | ++ int store_decimal_truncated(const my_decimal*, bool *truncated); |
3891 | uint size_of() const { return sizeof(*this); } |
3892 | int reset(void) { return !maybe_null() || Field_blob::reset(); } |
3893 | geometry_type get_geometry_type() { return geom_type; }; |
3894 | -@@ -1857,9 +2173,21 @@ |
3895 | +@@ -1857,9 +2247,22 @@ |
3896 | enum Item_result cmp_type () const { return INT_RESULT; } |
3897 | enum Item_result cast_to_int_type () const { return INT_RESULT; } |
3898 | enum ha_base_keytype key_type() const; |
3899 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3900 | - int store(double nr); |
3901 | - int store(longlong nr, bool unsigned_val); |
3902 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3903 | ++ int store(const char *to, uint length,CHARSET_INFO *charset) |
3904 | + { |
3905 | -+ return store_truncated(to,length,charset,0); |
3906 | ++ return store_truncated(to, length, charset, 0); |
3907 | + } |
3908 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3909 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3910 | ++ bool *truncated); |
3911 | + int store(double nr) |
3912 | + { |
3913 | -+ return store_truncated(nr,0); |
3914 | ++ return store_truncated(nr, 0); |
3915 | + } |
3916 | -+ int store_truncated(double nr,bool *truncated); |
3917 | ++ int store_truncated(double nr, bool *truncated); |
3918 | + int store(longlong nr, bool unsigned_val) |
3919 | + { |
3920 | -+ return store_truncated(nr,unsigned_val,0); |
3921 | ++ return store_truncated(nr, unsigned_val, 0); |
3922 | + } |
3923 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3924 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3925 | double val_real(void); |
3926 | longlong val_int(void); |
3927 | String *val_str(String*,String *); |
3928 | -@@ -1899,9 +2227,18 @@ |
3929 | +@@ -1899,9 +2302,25 @@ |
3930 | { |
3931 | flags=(flags & ~ENUM_FLAG) | SET_FLAG; |
3932 | } |
3933 | - int store(const char *to,uint length,CHARSET_INFO *charset); |
3934 | - int store(double nr) { return Field_set::store((longlong) nr, FALSE); } |
3935 | - int store(longlong nr, bool unsigned_val); |
3936 | -+ int store(const char *to,uint length,CHARSET_INFO *charset) |
3937 | -+ { |
3938 | -+ return store_truncated(to,length,charset,0); |
3939 | -+ } |
3940 | -+ int store_truncated(const char *to,uint length,CHARSET_INFO *charset,bool *truncated); |
3941 | -+ int store(double nr) { return store_truncated(nr,0); } |
3942 | -+ int store_truncated(double nr,bool *truncated) { return Field_set::store_truncated((longlong) nr, FALSE,truncated); } |
3943 | -+ int store(longlong nr, bool unsigned_val) |
3944 | -+ { |
3945 | -+ return store_truncated(nr,unsigned_val,0); |
3946 | -+ } |
3947 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3948 | ++ int store(const char *to, uint length, CHARSET_INFO *charset) |
3949 | ++ { |
3950 | ++ return store_truncated(to, length, charset, 0); |
3951 | ++ } |
3952 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3953 | ++ bool *truncated); |
3954 | ++ int store(double nr) |
3955 | ++ { |
3956 | ++ return store_truncated(nr, 0); |
3957 | ++ } |
3958 | ++ int store_truncated(double nr, bool *truncated) |
3959 | ++ { |
3960 | ++ return Field_set::store_truncated((longlong) nr, FALSE, truncated); |
3961 | ++ } |
3962 | ++ int store(longlong nr, bool unsigned_val) |
3963 | ++ { |
3964 | ++ return store_truncated(nr, unsigned_val, 0); |
3965 | ++ } |
3966 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3967 | |
3968 | virtual bool zero_pack() const { return 1; } |
3969 | String *val_str(String*,String *); |
3970 | -@@ -1947,10 +2284,26 @@ |
3971 | +@@ -1947,10 +2366,27 @@ |
3972 | clr_rec_bits(bit_ptr, bit_ofs, bit_len); |
3973 | return 0; |
3974 | } |
3975 | @@ -2858,28 +3417,29 @@ |
3976 | - int store_decimal(const my_decimal *); |
3977 | + int store(const char *to, uint length, CHARSET_INFO *charset) |
3978 | + { |
3979 | -+ return store_truncated(to,length,charset,0); |
3980 | ++ return store_truncated(to, length, charset, 0); |
3981 | + } |
3982 | -+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,bool *truncated); |
3983 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
3984 | ++ bool *truncated); |
3985 | + int store(double nr) |
3986 | + { |
3987 | -+ return store_truncated(nr,0); |
3988 | ++ return store_truncated(nr, 0); |
3989 | + } |
3990 | -+ int store_truncated(double nr,bool *truncated); |
3991 | ++ int store_truncated(double nr, bool *truncated); |
3992 | + int store(longlong nr, bool unsigned_val) |
3993 | + { |
3994 | -+ return store_truncated(nr,unsigned_val,0); |
3995 | ++ return store_truncated(nr, unsigned_val, 0); |
3996 | + } |
3997 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated); |
3998 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated); |
3999 | + int store_decimal(const my_decimal *value) |
4000 | + { |
4001 | -+ return store_decimal_truncated(value,0); |
4002 | ++ return store_decimal_truncated(value, 0); |
4003 | + } |
4004 | -+ int store_decimal_truncated(const my_decimal *, bool *truncated); |
4005 | ++ int store_decimal_truncated(const my_decimal*, bool *truncated); |
4006 | double val_real(void); |
4007 | longlong val_int(void); |
4008 | String *val_str(String*, String *); |
4009 | -@@ -2033,10 +2386,17 @@ |
4010 | +@@ -2033,10 +2469,28 @@ |
4011 | enum utype unireg_check_arg, const char *field_name_arg); |
4012 | enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } |
4013 | uint size_of() const { return sizeof(*this); } |
4014 | @@ -2887,20 +3447,31 @@ |
4015 | - int store(double nr) { return Field_bit::store(nr); } |
4016 | + int store(const char *to, uint length, CHARSET_INFO *charset) |
4017 | + { |
4018 | -+ return store_truncated(to,length,charset,0); |
4019 | -+ } |
4020 | -+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,bool *truncated); |
4021 | -+ int store(double nr) { return store_truncated(nr,0); } |
4022 | -+ int store_truncated(double nr,bool *truncated) { return Field_bit::store_truncated(nr,truncated); } |
4023 | ++ return store_truncated(to, length, charset, 0); |
4024 | ++ } |
4025 | ++ int store_truncated(const char *to, uint length, CHARSET_INFO *charset, |
4026 | ++ bool *truncated); |
4027 | ++ int store(double nr) |
4028 | ++ { |
4029 | ++ return store_truncated(nr, 0); |
4030 | ++ } |
4031 | ++ int store_truncated(double nr, bool *truncated) |
4032 | ++ { |
4033 | ++ return Field_bit::store_truncated(nr, truncated); |
4034 | ++ } |
4035 | int store(longlong nr, bool unsigned_val) |
4036 | - { return Field_bit::store(nr, unsigned_val); } |
4037 | -+ { return store_truncated(nr, unsigned_val,0); } |
4038 | -+ int store_truncated(longlong nr, bool unsigned_val,bool *truncated) |
4039 | -+ { return Field_bit::store_truncated(nr, unsigned_val,truncated); } |
4040 | ++ { |
4041 | ++ return store_truncated(nr, unsigned_val, 0); |
4042 | ++ } |
4043 | ++ int store_truncated(longlong nr, bool unsigned_val, bool *truncated) |
4044 | ++ { |
4045 | ++ return Field_bit::store_truncated(nr, unsigned_val, truncated); |
4046 | ++ } |
4047 | void sql_type(String &str) const; |
4048 | }; |
4049 | |
4050 | -@@ -2137,6 +2497,7 @@ |
4051 | +@@ -2137,6 +2591,7 @@ |
4052 | uint from_length,to_length; |
4053 | Field *from_field,*to_field; |
4054 | String tmp; // For items |
4055 | @@ -2938,7 +3509,7 @@ |
4056 | static const char *slave_exec_mode_str= "STRICT"; |
4057 | ulong slave_type_conversions_options; |
4058 | const char *slave_type_conversions_default= ""; |
4059 | -+my_bool opt_slave_type_conversions_error_on_truncate=0; |
4060 | ++my_bool opt_slave_type_conversions_error_on_truncate= 0; |
4061 | ulong thread_cache_size=0, thread_pool_size= 0; |
4062 | ulong binlog_cache_size=0; |
4063 | ulonglong max_binlog_cache_size=0; |
4064 | @@ -2950,13 +3521,16 @@ |
4065 | OPT_GENERAL_LOG_FILE, |
4066 | OPT_SLOW_QUERY_LOG_FILE, |
4067 | OPT_USERSTAT_RUNNING, |
4068 | -@@ -6901,6 +6903,10 @@ |
4069 | +@@ -6901,6 +6903,13 @@ |
4070 | (uchar**) &slave_type_conversions_default, |
4071 | (uchar**) &slave_type_conversions_default, |
4072 | 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
4073 | -+ {"slave-type-conversions-error-on-truncate", OPT_SLAVE_TYPE_CONVERSIONS_ERROR_ON_TRUNCATE, |
4074 | -+ "Report error if replicated value truncated on slave in slave_type_conversions=ALL_LOSSY mode", |
4075 | -+ (uchar**) &opt_slave_type_conversions_error_on_truncate, (uchar**) &opt_slave_type_conversions_error_on_truncate, |
4076 | ++ {"slave-type-conversions-error-on-truncate", |
4077 | ++ OPT_SLAVE_TYPE_CONVERSIONS_ERROR_ON_TRUNCATE, |
4078 | ++ "Report error if replicated value truncated on slave in" |
4079 | ++ " slave_type_conversions=ALL_LOSSY mode", |
4080 | ++ (uchar**) &opt_slave_type_conversions_error_on_truncate, |
4081 | ++ (uchar**) &opt_slave_type_conversions_error_on_truncate, |
4082 | + 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, |
4083 | #endif |
4084 | {"slow-query-log", OPT_SLOW_LOG, |
4085 | @@ -2997,7 +3571,7 @@ |
4086 | (*copy.do_copy)(©); |
4087 | + if(opt_slave_type_conversions_error_on_truncate && copy.truncated) |
4088 | + { |
4089 | -+ Field* field = *field_ptr; |
4090 | ++ Field *field= *field_ptr; |
4091 | + const char *db_name= table->s->db.str; |
4092 | + const char *tbl_name= table->s->table_name.str; |
4093 | + char source_buf[MAX_FIELD_WIDTH]; |
4094 | @@ -3010,7 +3584,7 @@ |
4095 | + ER(ER_SLAVE_CONVERSION_WITHOUT_TRUNCATE_FAILED), |
4096 | + column_index, db_name, tbl_name, |
4097 | + source_type.c_ptr_safe(), target_type.c_ptr_safe()); |
4098 | -+ error = ER_SLAVE_CONVERSION_WITHOUT_TRUNCATE_FAILED; |
4099 | ++ error= ER_SLAVE_CONVERSION_WITHOUT_TRUNCATE_FAILED; |
4100 | + DBUG_RETURN(error); |
4101 | + } |
4102 | #ifndef DBUG_OFF |
4103 | @@ -3029,12 +3603,14 @@ |
4104 | A table definition from the master. |
4105 | --- a/sql/set_var.cc |
4106 | +++ b/sql/set_var.cc |
4107 | -@@ -1074,6 +1074,8 @@ |
4108 | +@@ -1074,6 +1074,10 @@ |
4109 | #endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */ |
4110 | static sys_var_have_variable sys_have_response_time_distribution(&vars, "have_response_time_distribution", |
4111 | + &have_response_time_distribution); |
4112 | -+static sys_var_bool_ptr sys_slave_type_conversions_error_on_truncate(&vars, "slave_type_conversions_error_on_truncate", |
4113 | -+ &opt_slave_type_conversions_error_on_truncate); |
4114 | ++static sys_var_bool_ptr |
4115 | ++sys_slave_type_conversions_error_on_truncate(&vars, |
4116 | ++ "slave_type_conversions_error_on_truncate", |
4117 | ++ &opt_slave_type_conversions_error_on_truncate); |
4118 | /* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */ |
4119 | static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries", |
4120 | &opt_slow_log, QUERY_LOG_SLOW); |
LGTM, thank you.