Merge lp:~tsarev/percona-server/18205_07_slave_type_conversions_error_on_truncate.patch into lp:percona-server/rnt-5.1

Proposed by Oleg Tsarev
Status: Merged
Merged at revision: 216
Proposed branch: lp:~tsarev/percona-server/18205_07_slave_type_conversions_error_on_truncate.patch
Merge into: lp:percona-server/rnt-5.1
Prerequisite: lp:~tsarev/percona-server/18205_06_replication_slave_skip_colulmns.patch
Diff against target: 3270 lines (+502/-923)
1 file modified
patches/slave_type_conversions_error_on_truncate.patch (+502/-923)
To merge this branch: bzr merge lp:~tsarev/percona-server/18205_07_slave_type_conversions_error_on_truncate.patch
Reviewer Review Type Date Requested Status
Oleg Tsarev (community) Needs Information
Alexey Kopytov (community) Approve
Laurynas Biveinis Pending
Review via email: mp+93551@code.launchpad.net

This proposal supersedes a proposal from 2012-02-17.

Description of the change

I renamed <name>_truncated methods to <name>, and "truncated" argument now has default value (0). I removed <name> methods, because their usage exactly correlate with new methods.

bzr branch lp:~tsarev/percona-server/18205_07_slave_type_conversions_error_on_truncate.patch-refactoring && cd 18205_07_slave_type_conversions_error_on_truncate.patch-refactoring && ONE=216 && TWO=217 && rm -rf ${ONE} && bzr update -r ${ONE} && make main && mv Percona-Server-5.1.59-rel13.0 ${ONE} && rm ${ONE}/patches && rm -rf ${ONE}/.pc && rm -rf ${TWO} && bzr update -r ${TWO} && make main && mv Percona-Server-5.1.59-rel13.0 ${TWO} && rm ${TWO}/patches && rm -rf ${TWO}/.pc && diff -ruN ${ONE} ${TWO}

http://pastebin.com/KdtVAM37

To post a comment you must log in.
Revision history for this message
Oleg Tsarev (tsarev) wrote : Posted in a previous version of this proposal
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Please replace default arg value 0 with NULL.
Line 19: space after error comma
Lines 2097--2099: indentation.

review: Needs Fixing
Revision history for this message
Oleg Tsarev (tsarev) wrote : Posted in a previous version of this proposal

Fixed

review: Needs Resubmitting
Revision history for this message
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal
Download full text (3.4 KiB)

Don't touch upstream code unless you really have to. Fixing some whitespace in the upstream code is just not worth possible merge conflicts in the future.

That is, remove the following:

> -@@ -6027,8 +6539,13 @@
> +@@ -5908,8 +6407,7 @@
> + char buff[MAX_DATE_STRING_REP_LENGTH];
> + String str(buff, sizeof(buff), &my_charset_latin1);
> + make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str);
> +- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_NOTE,
> +- WARN_DATA_TRUNCATED,
> ++ set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED,
> + str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1);
> + error= 3;
> + }
> +@@ -6027,8 +6525,13 @@
> ** Stored as a 8 byte unsigned int. Should sometimes be change to a 6 byte int.

and this

> -@@ -7096,8 +7665,13 @@
> +@@ -6608,7 +7164,7 @@
> + String tmp(buf, sizeof(buf), cs);
> + tmp.copy((char*) ptr, field_length, cs);
> + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
> +- ER_TRUNCATED_WRONG_VALUE,
> ++ ER_TRUNCATED_WRONG_VALUE,
> + ER(ER_TRUNCATED_WRONG_VALUE),
> + "DOUBLE", tmp.c_ptr());
> + }
> +@@ -6626,7 +7182,7 @@
> +
> + result= my_strntoll(cs, (char*) ptr,field_length,10,&end,&error);
> + if (!table->in_use->no_errors &&
> +- (error || (field_length != (uint32)(end - (char*) ptr) &&
> ++ (error || (field_length != (uint32)(end - (char*) ptr) &&
> + !check_if_only_end_space(cs, end,
> + (char*) ptr + field_length))))
> + {
> +@@ -6634,7 +7190,7 @@
> + String tmp(buf, sizeof(buf), cs);
> + tmp.copy((char*) ptr, field_length, cs);
> + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
> +- ER_TRUNCATED_WRONG_VALUE,
> ++ ER_TRUNCATED_WRONG_VALUE,
> + ER(ER_TRUNCATED_WRONG_VALUE),
> + "INTEGER", tmp.c_ptr());
> + }
> +@@ -6673,7 +7229,7 @@
> + String tmp(buf, sizeof(buf), cs);
> + tmp.copy((char*) ptr, field_length, cs);
> + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
> +- ER_TRUNCATED_WRONG_VALUE,
> ++ ER_TRUNCATED_WRONG_VALUE,
> + ER(ER_TRUNCATED_WRONG_VALUE),
> + "DECIMAL", tmp.c_ptr());
> + }
> +@@ -7095,8 +7651,13 @@
> return 2;

and this

> -@@ -8553,32 +9167,50 @@
> +@@ -8533,7 +9134,7 @@
> +
> + /* Convert character set if necessary */
> + if (String::needs_conversion(length, cs, field_charset, &not_used))
> +- {
> ++ {
> + uint dummy_errors;
> + tmpstr.copy(from, length, cs, field_charset, &dummy_errors);
> + from= tmpstr.ptr();
> +@@ -8552,32 +9153,50 @@
> tmp=(uint) my_strntoul(cs,from,length,10,&end,&err);

and this

> - tmp=0;
> +- tmp=0;
> ++ tmp=0;
> + if (truncated)

and this

> +@@ -9097,15 +9736,20 @@
> + }
> +
> +
> +-uint Field_bit::is_equal(Create_field *new_field)
> ...

Read more...

review: Needs Fixing
Revision history for this message
Oleg Tsarev (tsarev) wrote :

Fixed

review: Needs Resubmitting
Revision history for this message
Alexey Kopytov (akopytov) wrote :

I took a closer look at slave_type_conversions_error_on_truncate.patch. I think it's implemented in a wrong way. But it doesn't make sense to discuss it here, since this MP is only about cosmetic changes. Will be discussed when merging into the main 5.1 branch.

review: Approve
Revision history for this message
Oleg Tsarev (tsarev) wrote :

Better discuss right now here, because I want merge three patches:
 * wl5151.patch
 * slave_type_conversions_error_on_truncate.patch
 * replication_slave_skip_columns.patch
together.
Test related to this three patches intersected and hard to split this tests separated to every patch.

I see two possible solutions:
1) I split tests related to each patch
2) We discuss patch here, I prepare additional proposal with implementation not a wrong way, I merge patches together and propose for merge to 5.1

Way (2) allows to save my time to split tests.
Discussion about correct implementation required anycase, and better discuss as soon, as possible.

review: Needs Information
Revision history for this message
Alexey Kopytov (akopytov) wrote :

What about adding a truncated flag to the base Field class, and setting it in Field_*::store() if truncation occurs? This way we don't have to make invasive changes in all Field_*::store() signatures and implementation.

But even that doesn't seem necessary at a glance. Field_*::store() returns 1 on truncation. But it must be verified that Field_*::store() returns 1 if and only if 'truncated' would be set to TRUE by the current patch. And if there are differences, it must be checked whether it's a bug in the patch, or we do have valid cases when Field_*::store() reports an error, but the patch doesn't want to consider it as truncation for whatever reasons.

Revision history for this message
Alexey Kopytov (akopytov) wrote :

I also see a number of unnecessary changes in the upstream code. Like this:

> @@ -7652,8 +7652,12 @@
> THD* old_thd= table->in_use;
> if (!table->in_use)
> table->in_use= thd;
> -
> error= do_exec_row(rli);
> + if(ER_SLAVE_CONVERSION_WITHOUT_TRUNCATE_FAILED == error)

or this:

> @@ -2777,22 +2929,31 @@
> nr, unsigned_val, &decimal_value)))
> {
> if (check_overflow(err))
> + {
> set_value_on_overflow(&decimal_value, decimal_value.sign());
> + }

There is nothing wrong with existing code according to the guidelines. But even if there was, it's not a good idea to fix it.

Another suspicious change:

> @@ -9242,7 +9246,6 @@
>
> if (error && !thd->is_error())
> {
> - DBUG_ASSERT(0);
> my_error(ER_UNKNOWN_ERROR, MYF(0));
> }

What's that for?

Revision history for this message
Alexey Kopytov (akopytov) wrote :

Another thought is that those 3 patches should be submitted for review separately, no matter what.

Every one of them is big and invasive enough to make reviews non-trivial. A merged patch will be impossible to review.

Dependencies are not a problem. You can just submit 3 dependent MPs.

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-12 03:52:34 +0000
3+++ patches/slave_type_conversions_error_on_truncate.patch 2012-02-17 10:41:17 +0000
4@@ -7,15 +7,14 @@
5 # should be done or reviewed by the maintainer!
6 --- a/sql/field.cc
7 +++ b/sql/field.cc
8-@@ -1123,15 +1123,24 @@
9+@@ -1123,15 +1123,23 @@
10 2 error: garbage at the end of string.
11 */
12
13 -int Field_num::check_int(CHARSET_INFO *cs, const char *str, int length,
14 - const char *int_end, int error)
15-+int Field_num::check_int_truncated(CHARSET_INFO *cs, const char *str,
16-+ int length, const char *int_end, int error,
17-+ bool *truncated)
18++int Field_num::check_int(CHARSET_INFO *cs, const char *str, int length,
19++ const char *int_end, int error, bool *truncated)
20 {
21 + if (truncated)
22 + {
23@@ -34,7 +33,7 @@
24 push_warning_printf(table->in_use, MYSQL_ERROR::WARN_LEVEL_WARN,
25 ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
26 ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
27-@@ -1142,6 +1151,10 @@
28+@@ -1142,6 +1150,10 @@
29 /* Test if we have garbage at the end of the given string. */
30 if (test_if_important_data(cs, int_end, str + length))
31 {
32@@ -45,17 +44,15 @@
33 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
34 return 2;
35 }
36-@@ -1172,10 +1185,15 @@
37- 1 error
38+@@ -1173,9 +1185,14 @@
39 */
40
41--bool Field_num::get_int(CHARSET_INFO *cs, const char *from, uint len,
42+ bool Field_num::get_int(CHARSET_INFO *cs, const char *from, uint len,
43 - longlong *rnd, ulonglong unsigned_max,
44 - longlong signed_min, longlong signed_max)
45-+bool Field_num::get_int_truncated(CHARSET_INFO *cs, const char *from, uint len,
46-+ longlong *rnd, ulonglong unsigned_max,
47-+ longlong signed_min, longlong signed_max,
48-+ bool *truncated)
49++ longlong *rnd, ulonglong unsigned_max,
50++ longlong signed_min, longlong signed_max,
51++ bool *truncated)
52 {
53 + if (truncated)
54 + {
55@@ -64,7 +61,7 @@
56 char *end;
57 int error;
58
59-@@ -1210,6 +1228,10 @@
60+@@ -1210,6 +1227,10 @@
61 return 0;
62
63 out_of_range:
64@@ -75,26 +72,24 @@
65 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
66 return 1;
67 }
68-@@ -1226,8 +1248,9 @@
69+@@ -1226,8 +1247,9 @@
70 0 no error or some other errors except overflow
71 */
72
73 -int Field::warn_if_overflow(int op_result)
74-+int Field::warn_if_overflow_truncated(int op_result, bool *truncated)
75++int Field::warn_if_overflow(int op_result, bool *truncated)
76 {
77-+ if_overflow_truncated(op_result, truncated);
78++ if_overflow(op_result, truncated);
79 if (op_result == E_DEC_OVERFLOW)
80 {
81 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
82-@@ -1609,29 +1632,42 @@
83- @return
84+@@ -1610,28 +1632,37 @@
85 value converted from val
86 */
87--longlong Field::convert_decimal2longlong(const my_decimal *val,
88+ longlong Field::convert_decimal2longlong(const my_decimal *val,
89 - bool unsigned_flag, int *err)
90-+longlong Field::convert_decimal2longlong_truncated(const my_decimal *val,
91-+ bool unsigned_flag, int *err,
92-+ bool *truncated)
93++ bool unsigned_flag, int *err,
94++ bool *truncated)
95 {
96 + if (truncated)
97 + {
98@@ -116,11 +111,9 @@
99 - else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR &
100 - ~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED,
101 - val, TRUE, &i)))
102-+ else if (warn_if_overflow_truncated(my_decimal2int(E_DEC_ERROR &
103-+ ~E_DEC_OVERFLOW &
104-+ ~E_DEC_TRUNCATED,
105-+ val, TRUE, &i),
106-+ truncated))
107++ else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR & ~E_DEC_OVERFLOW &
108++ ~E_DEC_TRUNCATED, val, TRUE, &i),
109++ truncated))
110 {
111 i= ~(longlong) 0;
112 *err= 1;
113@@ -129,30 +122,28 @@
114 - else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR &
115 - ~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED,
116 - val, FALSE, &i)))
117-+ else if (warn_if_overflow_truncated(my_decimal2int(E_DEC_ERROR &
118-+ ~E_DEC_OVERFLOW &
119-+ ~E_DEC_TRUNCATED,
120-+ val, FALSE, &i),
121-+ truncated))
122++ else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR & ~E_DEC_OVERFLOW &
123++ ~E_DEC_TRUNCATED, val, FALSE, &i),
124++ truncated))
125 {
126 i= (val->sign() ? LONGLONG_MIN : LONGLONG_MAX);
127 *err= 1;
128-@@ -1654,12 +1690,19 @@
129+@@ -1654,12 +1685,19 @@
130 !=0 error
131 */
132
133 -int Field_num::store_decimal(const my_decimal *val)
134-+int Field_num::store_decimal_truncated(const my_decimal *val, bool *truncated)
135++int Field_num::store_decimal(const my_decimal *val, bool *truncated)
136 {
137 ASSERT_COLUMN_MARKED_FOR_WRITE;
138 - int err= 0;
139 - longlong i= convert_decimal2longlong(val, unsigned_flag, &err);
140 - return test(err | store(i, unsigned_flag));
141 + int err= 0;
142-+ longlong i= convert_decimal2longlong_truncated(val, unsigned_flag,
143-+ &err, truncated);
144++ longlong i= convert_decimal2longlong(val, unsigned_flag, &err,
145++ truncated);
146 + bool truncated2= false;
147-+ int result= test(err | store_truncated(i, unsigned_flag, &truncated2));
148++ int result= test(err | store(i, unsigned_flag, &truncated2));
149 + if (truncated)
150 + {
151 + *truncated= *truncated || truncated2;
152@@ -161,12 +152,12 @@
153 }
154
155
156-@@ -1726,14 +1769,20 @@
157+@@ -1726,14 +1764,20 @@
158 !=0 error
159 */
160
161 -int Field_str::store_decimal(const my_decimal *d)
162-+int Field_str::store_decimal_truncated(const my_decimal *d, bool *truncated)
163++int Field_str::store_decimal(const my_decimal *d, bool *truncated)
164 {
165 ASSERT_COLUMN_MARKED_FOR_WRITE;
166 double val;
167@@ -175,9 +166,9 @@
168 - ~E_DEC_OVERFLOW, d, &val));
169 - return err | store(val);
170 + int err= my_decimal2double(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, d, &val);
171-+ err= warn_if_overflow_truncated(err, truncated);
172++ err= warn_if_overflow(err, truncated);
173 + bool truncated2= false;
174-+ int result= err | store_truncated(val, &truncated2);
175++ int result= err | store(val, &truncated2);
176 + if (truncated)
177 + {
178 + *truncated= (*truncated) || truncated2;
179@@ -186,13 +177,13 @@
180 }
181
182
183-@@ -1929,8 +1979,13 @@
184+@@ -1929,8 +1973,13 @@
185 }
186
187
188 -int Field_decimal::store(const char *from_arg, uint len, CHARSET_INFO *cs)
189-+int Field_decimal::store_truncated(const char *from_arg, uint len,
190-+ CHARSET_INFO *cs, bool *truncated)
191++int Field_decimal::store(const char *from_arg, uint len, CHARSET_INFO *cs,
192++ bool *truncated)
193 {
194 + if (truncated)
195 + {
196@@ -201,7 +192,7 @@
197 ASSERT_COLUMN_MARKED_FOR_WRITE;
198 char buff[STRING_BUFFER_USUAL_SIZE];
199 String tmp(buff,sizeof(buff), &my_charset_bin);
200-@@ -2003,6 +2058,10 @@
201+@@ -2003,6 +2052,10 @@
202 from++;
203 if (from == end)
204 {
205@@ -212,7 +203,7 @@
206 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
207 is_cuted_fields_incr=1;
208 }
209-@@ -2018,6 +2077,10 @@
210+@@ -2018,6 +2071,10 @@
211 {
212 if (sign_char=='-')
213 {
214@@ -223,7 +214,7 @@
215 Field_decimal::overflow(1);
216 return 1;
217 }
218-@@ -2079,6 +2142,10 @@
219+@@ -2079,6 +2136,10 @@
220 for (;from != end && my_isspace(&my_charset_bin, *from); from++) ;
221 if (from != end) // If still something left, warn
222 {
223@@ -234,7 +225,7 @@
224 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
225 is_cuted_fields_incr=1;
226 }
227-@@ -2163,6 +2230,10 @@
228+@@ -2163,6 +2224,10 @@
229 if (field_length < tmp_uint + (int) (sign_char == '-'))
230 {
231 // too big number, change to max or min number
232@@ -245,7 +236,7 @@
233 Field_decimal::overflow(sign_char == '-');
234 return 1;
235 }
236-@@ -2257,8 +2328,14 @@
237+@@ -2257,8 +2322,14 @@
238 if (tmp_char != '0') // Losing a non zero digit ?
239 {
240 if (!is_cuted_fields_incr)
241@@ -260,7 +251,7 @@
242 return 0;
243 }
244 continue;
245-@@ -2280,6 +2357,10 @@
246+@@ -2280,6 +2351,10 @@
247 This is a note, not a warning, as we don't want to abort
248 when we cut decimals in strict mode
249 */
250@@ -271,12 +262,12 @@
251 set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1);
252 }
253 return 0;
254-@@ -2295,17 +2376,29 @@
255+@@ -2295,17 +2370,29 @@
256 }
257
258
259 -int Field_decimal::store(double nr)
260-+int Field_decimal::store_truncated(double nr, bool *truncated)
261++int Field_decimal::store(double nr, bool *truncated)
262 {
263 + if (truncated)
264 + {
265@@ -302,12 +293,12 @@
266 overflow(nr < 0.0);
267 return 1;
268 }
269-@@ -2340,8 +2433,12 @@
270+@@ -2340,8 +2427,12 @@
271 }
272
273
274 -int Field_decimal::store(longlong nr, bool unsigned_val)
275-+int Field_decimal::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
276++int Field_decimal::store(longlong nr, bool unsigned_val, bool *truncated)
277 {
278 + if (truncated)
279 + {
280@@ -316,7 +307,7 @@
281 ASSERT_COLUMN_MARKED_FOR_WRITE;
282 char buff[22];
283 uint length, int_part;
284-@@ -2350,6 +2447,10 @@
285+@@ -2350,6 +2441,10 @@
286
287 if (nr < 0 && unsigned_flag && !unsigned_val)
288 {
289@@ -327,13 +318,13 @@
290 overflow(1);
291 return 1;
292 }
293-@@ -2620,8 +2721,13 @@
294+@@ -2620,8 +2715,13 @@
295 1 error
296 */
297
298 -bool Field_new_decimal::store_value(const my_decimal *decimal_value)
299-+bool Field_new_decimal::store_value_truncated(const my_decimal *decimal_value,
300-+ bool *truncated)
301++bool Field_new_decimal::store_value(const my_decimal *decimal_value,
302++ bool *truncated)
303 {
304 + if (truncated)
305 + {
306@@ -342,7 +333,7 @@
307 ASSERT_COLUMN_MARKED_FOR_WRITE;
308 int error= 0;
309 DBUG_ENTER("Field_new_decimal::store_value");
310-@@ -2636,6 +2742,10 @@
311+@@ -2636,6 +2736,10 @@
312 if (unsigned_flag && decimal_value->sign())
313 {
314 DBUG_PRINT("info", ("unsigned overflow"));
315@@ -353,29 +344,22 @@
316 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
317 error= 1;
318 decimal_value= &decimal_zero;
319-@@ -2649,8 +2759,11 @@
320- }
321+@@ -2650,7 +2754,8 @@
322 #endif
323
324-- if (warn_if_overflow(my_decimal2binary(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
325+ if (warn_if_overflow(my_decimal2binary(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
326 - decimal_value, ptr, precision, dec)))
327-+ if (warn_if_overflow_truncated(my_decimal2binary(E_DEC_FATAL_ERROR &
328-+ ~E_DEC_OVERFLOW,
329-+ decimal_value, ptr,
330-+ precision, dec),
331-+ truncated))
332++ decimal_value, ptr, precision, dec),
333++ truncated))
334 {
335 my_decimal buff;
336 DBUG_PRINT("info", ("overflow"));
337-@@ -2664,9 +2777,14 @@
338- }
339-
340-
341--int Field_new_decimal::store(const char *from, uint length,
342+@@ -2665,8 +2770,12 @@
343+
344+
345+ int Field_new_decimal::store(const char *from, uint length,
346 - CHARSET_INFO *charset_arg)
347-+int Field_new_decimal::store_truncated(const char *from, uint length,
348-+ CHARSET_INFO *charset_arg,
349-+ bool *truncated)
350++ CHARSET_INFO *charset_arg, bool *truncated)
351 {
352 + if (truncated)
353 + {
354@@ -384,7 +368,7 @@
355 ASSERT_COLUMN_MARKED_FOR_WRITE;
356 int err;
357 my_decimal decimal_value;
358-@@ -2682,6 +2800,10 @@
359+@@ -2682,6 +2791,10 @@
360 String from_as_str;
361 from_as_str.copy(from, length, &my_charset_bin);
362
363@@ -395,7 +379,7 @@
364 push_warning_printf(table->in_use, MYSQL_ERROR::WARN_LEVEL_ERROR,
365 ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
366 ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
367-@@ -2693,9 +2815,17 @@
368+@@ -2693,9 +2806,17 @@
369
370 switch (err) {
371 case E_DEC_TRUNCATED:
372@@ -413,13 +397,13 @@
373 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
374 set_value_on_overflow(&decimal_value, decimal_value.sign());
375 break;
376-@@ -2721,7 +2851,12 @@
377+@@ -2721,7 +2842,12 @@
378 DBUG_PRINT("enter", ("value: %s",
379 dbug_decimal_as_string(dbug_buff, &decimal_value)));
380 #endif
381 - store_value(&decimal_value);
382 + bool truncated2= false;
383-+ store_value_truncated(&decimal_value, &truncated2);
384++ store_value(&decimal_value, &truncated2);
385 + if (truncated)
386 + {
387 + *truncated= (*truncated) || truncated2;
388@@ -427,12 +411,12 @@
389 DBUG_RETURN(err);
390 }
391
392-@@ -2732,8 +2867,12 @@
393+@@ -2732,8 +2858,12 @@
394 will return E_DEC_TRUNCATED always correctly
395 */
396
397 -int Field_new_decimal::store(double nr)
398-+int Field_new_decimal::store_truncated(double nr, bool *truncated)
399++int Field_new_decimal::store(double nr, bool *truncated)
400 {
401 + if (truncated)
402 + {
403@@ -441,11 +425,11 @@
404 ASSERT_COLUMN_MARKED_FOR_WRITE;
405 my_decimal decimal_value;
406 int err;
407-@@ -2745,30 +2884,53 @@
408+@@ -2745,30 +2875,52 @@
409 TODO: fix following when double2my_decimal when double2decimal
410 will return E_DEC_TRUNCATED always correctly
411 */
412-+ if_overflow_truncated(err, truncated);
413++ if_overflow(err, truncated);
414 if (!err)
415 {
416 double nr2;
417@@ -474,7 +458,7 @@
418 }
419 - if (store_value(&decimal_value))
420 + bool truncated2= false;
421-+ if (store_value_truncated(&decimal_value, &truncated2))
422++ if (store_value(&decimal_value, &truncated2))
423 err= 1;
424 else if (err && !table->in_use->got_warning)
425 err= warn_if_overflow(err);
426@@ -487,8 +471,7 @@
427
428
429 -int Field_new_decimal::store(longlong nr, bool unsigned_val)
430-+int Field_new_decimal::store_truncated(longlong nr, bool unsigned_val,
431-+ bool *truncated)
432++int Field_new_decimal::store(longlong nr, bool unsigned_val, bool *truncated)
433 {
434 + if (truncated)
435 + {
436@@ -497,20 +480,20 @@
437 ASSERT_COLUMN_MARKED_FOR_WRITE;
438 my_decimal decimal_value;
439 int err;
440-@@ -2777,22 +2938,31 @@
441+@@ -2777,22 +2929,31 @@
442 nr, unsigned_val, &decimal_value)))
443 {
444 if (check_overflow(err))
445 + {
446 set_value_on_overflow(&decimal_value, decimal_value.sign());
447 + }
448-+ if_overflow_truncated(err, truncated);
449++ if_overflow(err, truncated);
450 /* Only issue a warning if store_value doesn't issue an warning */
451 table->in_use->got_warning= 0;
452 }
453 - if (store_value(&decimal_value))
454 + bool truncated2= false;
455-+ if (store_value_truncated(&decimal_value, &truncated2))
456++ if (store_value(&decimal_value, &truncated2))
457 err= 1;
458 else if (err && !table->in_use->got_warning)
459 err= warn_if_overflow(err);
460@@ -523,36 +506,36 @@
461
462
463 -int Field_new_decimal::store_decimal(const my_decimal *decimal_value)
464-+int Field_new_decimal::store_decimal_truncated(const my_decimal *decimal_value,
465-+ bool *truncated)
466++int Field_new_decimal::store_decimal(const my_decimal *decimal_value,
467++ bool *truncated)
468 {
469 ASSERT_COLUMN_MARKED_FOR_WRITE;
470 - return store_value(decimal_value);
471-+ return store_value_truncated(decimal_value, truncated);
472++ return store_value(decimal_value, truncated);
473 }
474
475
476-@@ -3023,20 +3193,25 @@
477+@@ -3023,20 +3184,25 @@
478 ** tiny int
479 ****************************************************************************/
480
481 -int Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs)
482-+int Field_tiny::store_truncated(const char *from, uint len, CHARSET_INFO *cs,
483-+ bool *truncated)
484++int Field_tiny::store(const char *from, uint len, CHARSET_INFO *cs,
485++ bool *truncated)
486 {
487 ASSERT_COLUMN_MARKED_FOR_WRITE;
488 int error;
489 longlong rnd;
490
491 - error= get_int(cs, from, len, &rnd, 255, -128, 127);
492-+ error= get_int_truncated(cs, from, len, &rnd, 255, -128, 127, truncated);
493++ error= get_int(cs, from, len, &rnd, 255, -128, 127, truncated);
494 ptr[0]= unsigned_flag ? (char) (ulonglong) rnd : (char) rnd;
495 return error;
496 }
497
498
499 -int Field_tiny::store(double nr)
500-+int Field_tiny::store_truncated(double nr, bool *truncated)
501++int Field_tiny::store(double nr, bool *truncated)
502 {
503 + if (truncated)
504 + {
505@@ -561,7 +544,7 @@
506 ASSERT_COLUMN_MARKED_FOR_WRITE;
507 int error= 0;
508 nr=rint(nr);
509-@@ -3045,12 +3220,20 @@
510+@@ -3045,12 +3211,20 @@
511 if (nr < 0.0)
512 {
513 *ptr=0;
514@@ -582,7 +565,7 @@
515 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
516 error= 1;
517 }
518-@@ -3062,12 +3245,20 @@
519+@@ -3062,12 +3236,20 @@
520 if (nr < -128.0)
521 {
522 *ptr= (char) -128;
523@@ -603,12 +586,12 @@
524 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
525 error= 1;
526 }
527-@@ -3078,8 +3269,12 @@
528+@@ -3078,8 +3260,12 @@
529 }
530
531
532 -int Field_tiny::store(longlong nr, bool unsigned_val)
533-+int Field_tiny::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
534++int Field_tiny::store(longlong nr, bool unsigned_val, bool *truncated)
535 {
536 + if (truncated)
537 + {
538@@ -617,7 +600,7 @@
539 ASSERT_COLUMN_MARKED_FOR_WRITE;
540 int error= 0;
541
542-@@ -3088,13 +3283,11 @@
543+@@ -3088,13 +3274,11 @@
544 if (nr < 0 && !unsigned_val)
545 {
546 *ptr= 0;
547@@ -631,7 +614,7 @@
548 error= 1;
549 }
550 else
551-@@ -3107,18 +3300,24 @@
552+@@ -3107,18 +3291,24 @@
553 if (nr < -128)
554 {
555 *ptr= (char) -128;
556@@ -649,22 +632,22 @@
557 }
558 + if (1 == error)
559 + {
560-+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
561 + if (truncated)
562 + {
563 + *truncated= true;
564 + }
565++ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
566 + }
567 return error;
568 }
569
570-@@ -3198,14 +3397,16 @@
571+@@ -3198,14 +3388,16 @@
572 Field type short int (2 byte)
573 ****************************************************************************/
574
575 -int Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
576-+int Field_short::store_truncated(const char *from, uint len, CHARSET_INFO *cs,
577-+ bool *truncated)
578++int Field_short::store(const char *from, uint len, CHARSET_INFO *cs,
579++ bool *truncated)
580 {
581 ASSERT_COLUMN_MARKED_FOR_WRITE;
582 int store_tmp;
583@@ -672,17 +655,17 @@
584 longlong rnd;
585
586 - error= get_int(cs, from, len, &rnd, UINT_MAX16, INT_MIN16, INT_MAX16);
587-+ error= get_int_truncated(cs, from, len, &rnd, UINT_MAX16, INT_MIN16,
588-+ INT_MAX16, truncated);
589++ error= get_int(cs, from, len, &rnd, UINT_MAX16, INT_MIN16, INT_MAX16,
590++ truncated);
591 store_tmp= unsigned_flag ? (int) (ulonglong) rnd : (int) rnd;
592 #ifdef WORDS_BIGENDIAN
593 if (table->s->db_low_byte_first)
594-@@ -3219,8 +3420,12 @@
595+@@ -3219,8 +3411,12 @@
596 }
597
598
599 -int Field_short::store(double nr)
600-+int Field_short::store_truncated(double nr, bool *truncated)
601++int Field_short::store(double nr, bool *truncated)
602 {
603 + if (truncated)
604 + {
605@@ -691,7 +674,7 @@
606 ASSERT_COLUMN_MARKED_FOR_WRITE;
607 int error= 0;
608 int16 res;
609-@@ -3230,12 +3435,20 @@
610+@@ -3230,12 +3426,20 @@
611 if (nr < 0)
612 {
613 res=0;
614@@ -712,7 +695,7 @@
615 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
616 error= 1;
617 }
618-@@ -3247,12 +3460,20 @@
619+@@ -3247,12 +3451,20 @@
620 if (nr < (double) INT_MIN16)
621 {
622 res=INT_MIN16;
623@@ -733,12 +716,12 @@
624 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
625 error= 1;
626 }
627-@@ -3271,8 +3492,12 @@
628+@@ -3271,8 +3483,12 @@
629 }
630
631
632 -int Field_short::store(longlong nr, bool unsigned_val)
633-+int Field_short::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
634++int Field_short::store(longlong nr, bool unsigned_val, bool *truncated)
635 {
636 + if (truncated)
637 + {
638@@ -747,7 +730,7 @@
639 ASSERT_COLUMN_MARKED_FOR_WRITE;
640 int error= 0;
641 int16 res;
642-@@ -3282,13 +3507,11 @@
643+@@ -3282,13 +3498,11 @@
644 if (nr < 0L && !unsigned_val)
645 {
646 res=0;
647@@ -761,7 +744,7 @@
648 error= 1;
649 }
650 else
651-@@ -3302,13 +3525,11 @@
652+@@ -3302,13 +3516,11 @@
653 if (nr < INT_MIN16)
654 {
655 res=INT_MIN16;
656@@ -775,28 +758,28 @@
657 error= 1;
658 }
659 else
660-@@ -3322,6 +3543,14 @@
661+@@ -3322,6 +3534,14 @@
662 else
663 #endif
664 shortstore(ptr,res);
665 + if (1 == error)
666 + {
667-+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
668 + if (truncated)
669 + {
670 + *truncated= true;
671 + }
672++ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
673 + }
674 return error;
675 }
676
677-@@ -3445,22 +3674,27 @@
678+@@ -3445,22 +3665,28 @@
679 Field type medium int (3 byte)
680 ****************************************************************************/
681
682 -int Field_medium::store(const char *from,uint len,CHARSET_INFO *cs)
683-+int Field_medium::store_truncated(const char *from, uint len, CHARSET_INFO *cs,
684-+ bool *truncated)
685++int Field_medium::store(const char *from, uint len, CHARSET_INFO *cs,
686++ bool *truncated)
687 {
688 ASSERT_COLUMN_MARKED_FOR_WRITE;
689 int store_tmp;
690@@ -804,7 +787,8 @@
691 longlong rnd;
692
693 - error= get_int(cs, from, len, &rnd, UINT_MAX24, INT_MIN24, INT_MAX24);
694-+ error= get_int_truncated(cs, from, len, &rnd, UINT_MAX24, INT_MIN24, INT_MAX24, truncated);
695++ error= get_int(cs, from, len, &rnd, UINT_MAX24, INT_MIN24, INT_MAX24,
696++ truncated);
697 store_tmp= unsigned_flag ? (int) (ulonglong) rnd : (int) rnd;
698 int3store(ptr, store_tmp);
699 return error;
700@@ -812,7 +796,7 @@
701
702
703 -int Field_medium::store(double nr)
704-+int Field_medium::store_truncated(double nr, bool *truncated)
705++int Field_medium::store(double nr, bool *truncated)
706 {
707 + if (truncated)
708 + {
709@@ -821,7 +805,7 @@
710 ASSERT_COLUMN_MARKED_FOR_WRITE;
711 int error= 0;
712 nr=rint(nr);
713-@@ -3469,14 +3703,12 @@
714+@@ -3469,14 +3695,12 @@
715 if (nr < 0)
716 {
717 int3store(ptr,0);
718@@ -836,7 +820,7 @@
719 error= 1;
720 }
721 else
722-@@ -3488,25 +3720,35 @@
723+@@ -3488,25 +3712,35 @@
724 {
725 long tmp=(long) INT_MIN24;
726 int3store(ptr,tmp);
727@@ -866,7 +850,7 @@
728
729
730 -int Field_medium::store(longlong nr, bool unsigned_val)
731-+int Field_medium::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
732++int Field_medium::store(longlong nr, bool unsigned_val, bool *truncated)
733 {
734 + if (truncated)
735 + {
736@@ -875,7 +859,7 @@
737 ASSERT_COLUMN_MARKED_FOR_WRITE;
738 int error= 0;
739
740-@@ -3515,14 +3757,12 @@
741+@@ -3515,14 +3749,12 @@
742 if (nr < 0 && !unsigned_val)
743 {
744 int3store(ptr,0);
745@@ -890,7 +874,7 @@
746 error= 1;
747 }
748 else
749-@@ -3537,19 +3777,25 @@
750+@@ -3537,19 +3769,25 @@
751 {
752 long tmp= (long) INT_MIN24;
753 int3store(ptr,tmp);
754@@ -909,22 +893,22 @@
755 }
756 + if (1 == error)
757 + {
758-+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
759 + if (truncated)
760 + {
761 + *truncated= true;
762 + }
763++ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
764 + }
765 return error;
766 }
767
768-@@ -3635,14 +3881,16 @@
769+@@ -3635,14 +3873,16 @@
770 ** long int
771 ****************************************************************************/
772
773 -int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
774-+int Field_long::store_truncated(const char *from, uint len, CHARSET_INFO *cs,
775-+ bool *truncated)
776++int Field_long::store(const char *from, uint len, CHARSET_INFO *cs,
777++ bool *truncated)
778 {
779 ASSERT_COLUMN_MARKED_FOR_WRITE;
780 long store_tmp;
781@@ -932,17 +916,17 @@
782 longlong rnd;
783
784 - error= get_int(cs, from, len, &rnd, UINT_MAX32, INT_MIN32, INT_MAX32);
785-+ error= get_int_truncated(cs, from, len, &rnd, UINT_MAX32, INT_MIN32,
786-+ INT_MAX32, truncated);
787++ error= get_int(cs, from, len, &rnd, UINT_MAX32, INT_MIN32, INT_MAX32,
788++ truncated);
789 store_tmp= unsigned_flag ? (long) (ulonglong) rnd : (long) rnd;
790 #ifdef WORDS_BIGENDIAN
791 if (table->s->db_low_byte_first)
792-@@ -3656,8 +3904,12 @@
793+@@ -3656,8 +3896,12 @@
794 }
795
796
797 -int Field_long::store(double nr)
798-+int Field_long::store_truncated(double nr, bool *truncated)
799++int Field_long::store(double nr, bool *truncated)
800 {
801 + if (truncated)
802 + {
803@@ -951,7 +935,7 @@
804 ASSERT_COLUMN_MARKED_FOR_WRITE;
805 int error= 0;
806 int32 res;
807-@@ -3672,7 +3924,6 @@
808+@@ -3672,7 +3916,6 @@
809 else if (nr > (double) UINT_MAX32)
810 {
811 res= UINT_MAX32;
812@@ -959,7 +943,7 @@
813 error= 1;
814 }
815 else
816-@@ -3693,8 +3944,14 @@
817+@@ -3693,8 +3936,14 @@
818 else
819 res=(int32) (longlong) nr;
820 }
821@@ -975,12 +959,12 @@
822
823 #ifdef WORDS_BIGENDIAN
824 if (table->s->db_low_byte_first)
825-@@ -3708,8 +3965,12 @@
826+@@ -3708,8 +3957,12 @@
827 }
828
829
830 -int Field_long::store(longlong nr, bool unsigned_val)
831-+int Field_long::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
832++int Field_long::store(longlong nr, bool unsigned_val, bool *truncated)
833 {
834 + if (truncated)
835 + {
836@@ -989,7 +973,7 @@
837 ASSERT_COLUMN_MARKED_FOR_WRITE;
838 int error= 0;
839 int32 res;
840-@@ -3746,8 +4007,14 @@
841+@@ -3746,8 +3999,14 @@
842 else
843 res=(int32) nr;
844 }
845@@ -1005,13 +989,13 @@
846
847 #ifdef WORDS_BIGENDIAN
848 if (table->s->db_low_byte_first)
849-@@ -3882,8 +4149,13 @@
850+@@ -3882,8 +4141,13 @@
851 Field type longlong int (8 bytes)
852 ****************************************************************************/
853
854 -int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
855-+int Field_longlong::store_truncated(const char *from, uint len,
856-+ CHARSET_INFO *cs, bool *truncated)
857++int Field_longlong::store(const char *from, uint len, CHARSET_INFO *cs,
858++ bool *truncated)
859 {
860 + if (truncated)
861 + {
862@@ -1020,7 +1004,7 @@
863 ASSERT_COLUMN_MARKED_FOR_WRITE;
864 int error= 0;
865 char *end;
866-@@ -3892,11 +4164,15 @@
867+@@ -3892,11 +4156,15 @@
868 tmp= cs->cset->strntoull10rnd(cs,from,len,unsigned_flag,&end,&error);
869 if (error == MY_ERRNO_ERANGE)
870 {
871@@ -1031,18 +1015,19 @@
872 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
873 error= 1;
874 }
875- else if (table->in_use->count_cuted_fields &&
876+- else if (table->in_use->count_cuted_fields &&
877 - check_int(cs, from, len, end, error))
878-+ check_int_truncated(cs, from, len, end, error, truncated))
879++ else if (table->in_use->count_cuted_fields &&
880++ check_int(cs, from, len, end, error, truncated))
881 error= 1;
882 else
883 error= 0;
884-@@ -3912,8 +4188,12 @@
885+@@ -3912,8 +4180,12 @@
886 }
887
888
889 -int Field_longlong::store(double nr)
890-+int Field_longlong::store_truncated(double nr, bool *truncated)
891++int Field_longlong::store(double nr, bool *truncated)
892 {
893 + if (truncated)
894 + {
895@@ -1051,7 +1036,7 @@
896 ASSERT_COLUMN_MARKED_FOR_WRITE;
897 int error= 0;
898 longlong res;
899-@@ -3950,7 +4230,13 @@
900+@@ -3950,7 +4222,13 @@
901 res=(longlong) nr;
902 }
903 if (error)
904@@ -1065,12 +1050,12 @@
905
906 #ifdef WORDS_BIGENDIAN
907 if (table->s->db_low_byte_first)
908-@@ -3964,8 +4250,12 @@
909+@@ -3964,8 +4242,12 @@
910 }
911
912
913 -int Field_longlong::store(longlong nr, bool unsigned_val)
914-+int Field_longlong::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
915++int Field_longlong::store(longlong nr, bool unsigned_val, bool *truncated)
916 {
917 + if (truncated)
918 + {
919@@ -1079,24 +1064,24 @@
920 ASSERT_COLUMN_MARKED_FOR_WRITE;
921 int error= 0;
922
923-@@ -3979,6 +4269,10 @@
924+@@ -3978,6 +4260,10 @@
925+ if (unsigned_flag != unsigned_val)
926 {
927 nr= unsigned_flag ? (ulonglong) 0 : (ulonglong) LONGLONG_MAX;
928- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
929 + if (truncated)
930 + {
931 + *truncated= true;
932 + }
933+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
934 error= 1;
935 }
936- }
937-@@ -4173,27 +4467,41 @@
938+@@ -4173,27 +4459,41 @@
939 single precision float
940 ****************************************************************************/
941
942 -int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
943-+int Field_float::store_truncated(const char *from, uint len, CHARSET_INFO* cs,
944-+ bool *truncated)
945++int Field_float::store(const char *from, uint len, CHARSET_INFO* cs,
946++ bool *truncated)
947 {
948 + if (truncated)
949 + {
950@@ -1118,7 +1103,7 @@
951 }
952 - Field_float::store(nr);
953 + bool truncated2= false;
954-+ Field_float::store_truncated(nr, &truncated2);
955++ Field_float::store(nr, &truncated2);
956 + if (truncated)
957 + {
958 + *truncated= (*truncated) || truncated2;
959@@ -1128,37 +1113,34 @@
960
961
962 -int Field_float::store(double nr)
963-+int Field_float::store_truncated(double nr, bool *truncated)
964++int Field_float::store(double nr, bool *truncated)
965 {
966 ASSERT_COLUMN_MARKED_FOR_WRITE;
967 - int error= truncate(&nr, FLT_MAX);
968-+ int error= truncate_truncated(&nr, FLT_MAX, truncated);
969++ int error= truncate(&nr, FLT_MAX, truncated);
970 float j= (float)nr;
971
972 #ifdef WORDS_BIGENDIAN
973-@@ -4208,10 +4516,12 @@
974+@@ -4208,10 +4508,10 @@
975 }
976
977
978 -int Field_float::store(longlong nr, bool unsigned_val)
979-+int Field_float::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
980++int Field_float::store(longlong nr, bool unsigned_val, bool *truncated)
981 {
982-- return Field_float::store(unsigned_val ? ulonglong2double((ulonglong) nr) :
983+ return Field_float::store(unsigned_val ? ulonglong2double((ulonglong) nr) :
984 - (double) nr);
985-+ return Field_float::store_truncated(unsigned_val ?
986-+ ulonglong2double((ulonglong) nr) :
987-+ (double) nr,
988-+ truncated);
989++ (double) nr, truncated);
990 }
991
992
993-@@ -4435,27 +4745,41 @@
994+@@ -4435,27 +4735,41 @@
995 double precision floating point numbers
996 ****************************************************************************/
997
998 -int Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
999-+int Field_double::store_truncated(const char *from, uint len, CHARSET_INFO *cs,
1000-+ bool *truncated)
1001++int Field_double::store(const char *from, uint len, CHARSET_INFO *cs,
1002++ bool *truncated)
1003 {
1004 + if (truncated)
1005 + {
1006@@ -1180,7 +1162,7 @@
1007 }
1008 - Field_double::store(nr);
1009 + bool truncated2= false;
1010-+ Field_double::store_truncated(nr, &truncated2);
1011++ Field_double::store(nr, &truncated2);
1012 + if (truncated)
1013 + {
1014 + *truncated= (*truncated) || truncated2;
1015@@ -1190,37 +1172,33 @@
1016
1017
1018 -int Field_double::store(double nr)
1019-+int Field_double::store_truncated(double nr, bool *truncated)
1020++int Field_double::store(double nr, bool *truncated)
1021 {
1022 ASSERT_COLUMN_MARKED_FOR_WRITE;
1023 - int error= truncate(&nr, DBL_MAX);
1024-+ int error= truncate_truncated(&nr, DBL_MAX, truncated);
1025++ int error= truncate(&nr, DBL_MAX, truncated);
1026
1027 #ifdef WORDS_BIGENDIAN
1028 if (table->s->db_low_byte_first)
1029-@@ -4469,10 +4793,12 @@
1030+@@ -4469,10 +4783,10 @@
1031 }
1032
1033
1034 -int Field_double::store(longlong nr, bool unsigned_val)
1035-+int Field_double::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1036++int Field_double::store(longlong nr, bool unsigned_val, bool *truncated)
1037 {
1038-- return Field_double::store(unsigned_val ? ulonglong2double((ulonglong) nr) :
1039+ return Field_double::store(unsigned_val ? ulonglong2double((ulonglong) nr) :
1040 - (double) nr);
1041-+ return Field_double::store_truncated(unsigned_val ?
1042-+ ulonglong2double((ulonglong) nr) :
1043-+ (double) nr,
1044-+ truncated);
1045++ (double) nr, truncated);
1046 }
1047
1048 /*
1049-@@ -4481,8 +4807,13 @@
1050+@@ -4481,8 +4795,12 @@
1051 Also ensure that the argument is within [-max_value; max_value] range.
1052 */
1053
1054 -int Field_real::truncate(double *nr, double max_value)
1055-+int Field_real::truncate_truncated(double *nr, double max_value,
1056-+ bool *truncated)
1057++int Field_real::truncate(double *nr, double max_value, bool *truncated)
1058 {
1059 + if (truncated)
1060 + {
1061@@ -1229,7 +1207,7 @@
1062 int error= 1;
1063 double res= *nr;
1064
1065-@@ -4490,12 +4820,20 @@
1066+@@ -4490,12 +4808,20 @@
1067 {
1068 res= 0;
1069 set_null();
1070@@ -1250,18 +1228,15 @@
1071 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
1072 goto end;
1073 }
1074-@@ -4516,12 +4854,20 @@
1075-
1076+@@ -4517,11 +4843,19 @@
1077 if (res < -max_value)
1078 {
1079-- res= -max_value;
1080-- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
1081-+ res= -max_value;
1082+ res= -max_value;
1083 + if (truncated)
1084 + {
1085 + *truncated= true;
1086 + }
1087-+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
1088+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
1089 }
1090 else if (res > max_value)
1091 {
1092@@ -1273,27 +1248,27 @@
1093 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
1094 }
1095 else
1096-@@ -4533,11 +4879,11 @@
1097+@@ -4533,11 +4867,11 @@
1098 }
1099
1100
1101 -int Field_real::store_decimal(const my_decimal *dm)
1102-+int Field_real::store_decimal_truncated(const my_decimal *dm, bool *truncated)
1103++int Field_real::store_decimal(const my_decimal *dm, bool *truncated)
1104 {
1105 double dbl;
1106 my_decimal2double(E_DEC_FATAL_ERROR, dm, &dbl);
1107 - return store(dbl);
1108-+ return store_truncated(dbl, truncated);
1109++ return store(dbl, truncated);
1110 }
1111
1112 double Field_double::val_real(void)
1113-@@ -4879,8 +5225,13 @@
1114+@@ -4879,8 +5213,13 @@
1115 }
1116
1117
1118 -int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
1119-+int Field_timestamp::store_truncated(const char *from, uint len,
1120-+ CHARSET_INFO *cs, bool *truncated)
1121++int Field_timestamp::store(const char *from, uint len, CHARSET_INFO *cs,
1122++ bool *truncated)
1123 {
1124 + if (truncated)
1125 + {
1126@@ -1302,7 +1277,7 @@
1127 ASSERT_COLUMN_MARKED_FOR_WRITE;
1128 MYSQL_TIME l_time;
1129 my_time_t tmp= 0;
1130-@@ -4899,6 +5250,10 @@
1131+@@ -4899,6 +5238,10 @@
1132 if (error || !have_smth_to_conv)
1133 {
1134 error= 1;
1135@@ -1313,7 +1288,7 @@
1136 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
1137 from, len, MYSQL_TIMESTAMP_DATETIME, 1);
1138 }
1139-@@ -4908,6 +5263,10 @@
1140+@@ -4908,6 +5251,10 @@
1141 {
1142 if (!(tmp= TIME_to_timestamp(thd, &l_time, &in_dst_time_gap)))
1143 {
1144@@ -1324,12 +1299,12 @@
1145 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1146 ER_WARN_DATA_OUT_OF_RANGE,
1147 from, len, MYSQL_TIMESTAMP_DATETIME, !error);
1148-@@ -4926,24 +5285,41 @@
1149+@@ -4926,24 +5273,41 @@
1150 }
1151
1152
1153 -int Field_timestamp::store(double nr)
1154-+int Field_timestamp::store_truncated(double nr, bool *truncated)
1155++int Field_timestamp::store(double nr, bool *truncated)
1156 {
1157 + if (truncated)
1158 + {
1159@@ -1350,7 +1325,7 @@
1160 }
1161 - error|= Field_timestamp::store((longlong) rint(nr), FALSE);
1162 + bool truncated2= false;
1163-+ error|= Field_timestamp::store_truncated((longlong) rint(nr), FALSE, &truncated2);
1164++ error|= Field_timestamp::store((longlong) rint(nr), FALSE, &truncated2);
1165 + if (truncated)
1166 + {
1167 + *truncated= (*truncated) || truncated2;
1168@@ -1360,7 +1335,7 @@
1169
1170
1171 -int Field_timestamp::store(longlong nr, bool unsigned_val)
1172-+int Field_timestamp::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1173++int Field_timestamp::store(longlong nr, bool unsigned_val, bool *truncated)
1174 {
1175 + if (truncated)
1176 + {
1177@@ -1369,7 +1344,7 @@
1178 ASSERT_COLUMN_MARKED_FOR_WRITE;
1179 MYSQL_TIME l_time;
1180 my_time_t timestamp= 0;
1181-@@ -4964,6 +5340,10 @@
1182+@@ -4964,6 +5328,10 @@
1183 {
1184 if (!(timestamp= TIME_to_timestamp(thd, &l_time, &in_dst_time_gap)))
1185 {
1186@@ -1380,7 +1355,7 @@
1187 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1188 ER_WARN_DATA_OUT_OF_RANGE,
1189 nr, MYSQL_TIMESTAMP_DATETIME, 1);
1190-@@ -4977,9 +5357,15 @@
1191+@@ -4977,9 +5345,15 @@
1192 error= 1;
1193 }
1194 } else if (error)
1195@@ -1396,13 +1371,13 @@
1196
1197 store_timestamp(timestamp);
1198 return error;
1199-@@ -5189,8 +5575,13 @@
1200+@@ -5189,8 +5563,13 @@
1201 ** Stored as a 3 byte unsigned int
1202 ****************************************************************************/
1203
1204 -int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
1205-+int Field_time::store_truncated(const char *from, uint len, CHARSET_INFO *cs,
1206-+ bool *truncated)
1207++int Field_time::store(const char *from, uint len, CHARSET_INFO *cs,
1208++ bool *truncated)
1209 {
1210 + if (truncated)
1211 + {
1212@@ -1411,7 +1386,7 @@
1213 MYSQL_TIME ltime;
1214 long tmp;
1215 int error= 0;
1216-@@ -5200,6 +5591,10 @@
1217+@@ -5200,6 +5579,10 @@
1218 {
1219 tmp=0L;
1220 error= 2;
1221@@ -1422,7 +1397,7 @@
1222 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
1223 from, len, MYSQL_TIMESTAMP_TIME, 1);
1224 }
1225-@@ -5207,6 +5602,10 @@
1226+@@ -5207,6 +5590,10 @@
1227 {
1228 if (warning & MYSQL_TIME_WARN_TRUNCATED)
1229 {
1230@@ -1433,7 +1408,7 @@
1231 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1232 WARN_DATA_TRUNCATED,
1233 from, len, MYSQL_TIMESTAMP_TIME, 1);
1234-@@ -5214,6 +5613,10 @@
1235+@@ -5214,6 +5601,10 @@
1236 }
1237 if (warning & MYSQL_TIME_WARN_OUT_OF_RANGE)
1238 {
1239@@ -1444,12 +1419,12 @@
1240 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1241 ER_WARN_DATA_OUT_OF_RANGE,
1242 from, len, MYSQL_TIMESTAMP_TIME, !error);
1243-@@ -5241,14 +5644,22 @@
1244+@@ -5241,14 +5632,22 @@
1245 }
1246
1247
1248 -int Field_time::store(double nr)
1249-+int Field_time::store_truncated(double nr, bool *truncated)
1250++int Field_time::store(double nr, bool *truncated)
1251 {
1252 + if (truncated)
1253 + {
1254@@ -1468,7 +1443,7 @@
1255 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1256 ER_WARN_DATA_OUT_OF_RANGE, nr, MYSQL_TIMESTAMP_TIME);
1257 error= 1;
1258-@@ -5256,6 +5667,10 @@
1259+@@ -5256,6 +5655,10 @@
1260 else if (nr < (double)-TIME_MAX_VALUE)
1261 {
1262 tmp= -TIME_MAX_VALUE;
1263@@ -1479,7 +1454,7 @@
1264 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1265 ER_WARN_DATA_OUT_OF_RANGE, nr, MYSQL_TIMESTAMP_TIME);
1266 error= 1;
1267-@@ -5268,6 +5683,10 @@
1268+@@ -5268,6 +5671,10 @@
1269 if (tmp % 100 > 59 || tmp/100 % 100 > 59)
1270 {
1271 tmp=0;
1272@@ -1490,12 +1465,12 @@
1273 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1274 ER_WARN_DATA_OUT_OF_RANGE, nr,
1275 MYSQL_TIMESTAMP_TIME);
1276-@@ -5279,14 +5698,22 @@
1277+@@ -5279,14 +5686,22 @@
1278 }
1279
1280
1281 -int Field_time::store(longlong nr, bool unsigned_val)
1282-+int Field_time::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1283++int Field_time::store(longlong nr, bool unsigned_val, bool *truncated)
1284 {
1285 + if (truncated)
1286 + {
1287@@ -1514,7 +1489,7 @@
1288 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1289 ER_WARN_DATA_OUT_OF_RANGE, nr,
1290 MYSQL_TIMESTAMP_TIME, 1);
1291-@@ -5295,6 +5722,10 @@
1292+@@ -5295,6 +5710,10 @@
1293 else if (nr > (longlong) TIME_MAX_VALUE || (nr < 0 && unsigned_val))
1294 {
1295 tmp= TIME_MAX_VALUE;
1296@@ -1525,7 +1500,7 @@
1297 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1298 ER_WARN_DATA_OUT_OF_RANGE, nr,
1299 MYSQL_TIMESTAMP_TIME, 1);
1300-@@ -5306,6 +5737,10 @@
1301+@@ -5306,6 +5725,10 @@
1302 if (tmp % 100 > 59 || tmp/100 % 100 > 59)
1303 {
1304 tmp=0;
1305@@ -1536,13 +1511,13 @@
1306 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1307 ER_WARN_DATA_OUT_OF_RANGE, nr,
1308 MYSQL_TIMESTAMP_TIME, 1);
1309-@@ -5437,8 +5872,13 @@
1310+@@ -5437,8 +5860,13 @@
1311 ** Can handle 2 byte or 4 byte years!
1312 ****************************************************************************/
1313
1314 -int Field_year::store(const char *from, uint len,CHARSET_INFO *cs)
1315-+int Field_year::store_truncated(const char *from, uint len, CHARSET_INFO *cs,
1316-+ bool *truncated)
1317++int Field_year::store(const char *from, uint len, CHARSET_INFO *cs,
1318++ bool *truncated)
1319 {
1320 + if (truncated)
1321 + {
1322@@ -1551,7 +1526,7 @@
1323 ASSERT_COLUMN_MARKED_FOR_WRITE;
1324 char *end;
1325 int error;
1326-@@ -5448,6 +5888,10 @@
1327+@@ -5448,6 +5876,10 @@
1328 error == MY_ERRNO_ERANGE)
1329 {
1330 *ptr=0;
1331@@ -1562,26 +1537,26 @@
1332 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
1333 return 1;
1334 }
1335-@@ -5474,23 +5918,31 @@
1336+@@ -5474,23 +5906,31 @@
1337 }
1338
1339
1340 -int Field_year::store(double nr)
1341-+int Field_year::store_truncated(double nr, bool *truncated)
1342++int Field_year::store(double nr, bool *truncated)
1343 {
1344 if (nr < 0.0 || nr >= 2155.0)
1345 {
1346 - (void) Field_year::store((longlong) -1, FALSE);
1347-+ (void) Field_year::store_truncated((longlong) -1, FALSE, truncated);
1348++ (void) Field_year::store((longlong) -1, FALSE, truncated);
1349 return 1;
1350 }
1351 - return Field_year::store((longlong) nr, FALSE);
1352-+ return Field_year::store_truncated((longlong) nr, FALSE, truncated);
1353++ return Field_year::store((longlong) nr, FALSE, truncated);
1354 }
1355
1356
1357 -int Field_year::store(longlong nr, bool unsigned_val)
1358-+int Field_year::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1359++int Field_year::store(longlong nr, bool unsigned_val, bool *truncated)
1360 {
1361 + if (truncated)
1362 + {
1363@@ -1598,13 +1573,13 @@
1364 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
1365 return 1;
1366 }
1367-@@ -5560,8 +6012,13 @@
1368+@@ -5560,8 +6000,13 @@
1369 ** Stored as a 4 byte unsigned int
1370 ****************************************************************************/
1371
1372 -int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
1373-+int Field_date::store_truncated(const char *from, uint len, CHARSET_INFO *cs,
1374-+ bool *truncated)
1375++int Field_date::store(const char *from, uint len, CHARSET_INFO *cs,
1376++ bool *truncated)
1377 {
1378 + if (truncated)
1379 + {
1380@@ -1613,7 +1588,7 @@
1381 ASSERT_COLUMN_MARKED_FOR_WRITE;
1382 MYSQL_TIME l_time;
1383 uint32 tmp;
1384-@@ -5581,8 +6038,14 @@
1385+@@ -5581,8 +6026,14 @@
1386 tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day);
1387
1388 if (error)
1389@@ -1628,12 +1603,12 @@
1390
1391 #ifdef WORDS_BIGENDIAN
1392 if (table && table->s->db_low_byte_first)
1393-@@ -5596,14 +6059,22 @@
1394+@@ -5596,14 +6047,22 @@
1395 }
1396
1397
1398 -int Field_date::store(double nr)
1399-+int Field_date::store_truncated(double nr, bool *truncated)
1400++int Field_date::store(double nr, bool *truncated)
1401 {
1402 + if (truncated)
1403 + {
1404@@ -1652,13 +1627,13 @@
1405 set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
1406 ER_WARN_DATA_OUT_OF_RANGE,
1407 nr, MYSQL_TIMESTAMP_DATE);
1408-@@ -5611,12 +6082,22 @@
1409+@@ -5611,12 +6070,22 @@
1410 else
1411 tmp= (longlong) rint(nr);
1412
1413 - return Field_date::store(tmp, TRUE);
1414 + bool truncated2= false;
1415-+ int result= Field_date::store_truncated(tmp, TRUE, &truncated2);
1416++ int result= Field_date::store(tmp, TRUE, &truncated2);
1417 + if (truncated)
1418 + {
1419 + *truncated= (*truncated) || truncated2;
1420@@ -1668,7 +1643,7 @@
1421
1422
1423 -int Field_date::store(longlong nr, bool unsigned_val)
1424-+int Field_date::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1425++int Field_date::store(longlong nr, bool unsigned_val, bool *truncated)
1426 {
1427 + if (truncated)
1428 + {
1429@@ -1677,7 +1652,7 @@
1430 ASSERT_COLUMN_MARKED_FOR_WRITE;
1431 MYSQL_TIME not_used;
1432 int error;
1433-@@ -5639,10 +6120,16 @@
1434+@@ -5639,10 +6108,16 @@
1435 nr= (longlong) floor(nr/1000000.0); // Timestamp to date
1436
1437 if (error)
1438@@ -1694,13 +1669,13 @@
1439
1440 #ifdef WORDS_BIGENDIAN
1441 if (table && table->s->db_low_byte_first)
1442-@@ -5794,8 +6281,13 @@
1443+@@ -5794,8 +6269,13 @@
1444 store function.
1445 */
1446
1447 -int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
1448-+int Field_newdate::store_truncated(const char *from, uint len, CHARSET_INFO *cs,
1449-+ bool *truncated)
1450++int Field_newdate::store(const char *from, uint len, CHARSET_INFO *cs,
1451++ bool *truncated)
1452 {
1453 + if (truncated)
1454 + {
1455@@ -1709,7 +1684,7 @@
1456 ASSERT_COLUMN_MARKED_FOR_WRITE;
1457 long tmp;
1458 MYSQL_TIME l_time;
1459-@@ -5821,31 +6313,45 @@
1460+@@ -5821,31 +6301,45 @@
1461 }
1462
1463 if (error)
1464@@ -1730,7 +1705,7 @@
1465
1466
1467 -int Field_newdate::store(double nr)
1468-+int Field_newdate::store_truncated(double nr, bool *truncated)
1469++int Field_newdate::store(double nr, bool *truncated)
1470 {
1471 if (nr < 0.0 || nr > 99991231235959.0)
1472 {
1473@@ -1744,12 +1719,12 @@
1474 return 1;
1475 }
1476 - return Field_newdate::store((longlong) rint(nr), FALSE);
1477-+ return Field_newdate::store_truncated((longlong) rint(nr), FALSE, truncated);
1478++ return Field_newdate::store((longlong) rint(nr), FALSE, truncated);
1479 }
1480
1481
1482 -int Field_newdate::store(longlong nr, bool unsigned_val)
1483-+int Field_newdate::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1484++int Field_newdate::store(longlong nr, bool unsigned_val, bool *truncated)
1485 {
1486 + if (truncated)
1487 + {
1488@@ -1758,7 +1733,7 @@
1489 ASSERT_COLUMN_MARKED_FOR_WRITE;
1490 MYSQL_TIME l_time;
1491 longlong tmp;
1492-@@ -5869,11 +6375,17 @@
1493+@@ -5869,11 +6363,17 @@
1494 error= 3;
1495
1496 if (error)
1497@@ -1776,13 +1751,13 @@
1498
1499 int3store(ptr,tmp);
1500 return error;
1501-@@ -6027,8 +6539,13 @@
1502+@@ -6027,8 +6527,13 @@
1503 ** Stored as a 8 byte unsigned int. Should sometimes be change to a 6 byte int.
1504 ****************************************************************************/
1505
1506 -int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
1507-+int Field_datetime::store_truncated(const char *from, uint len,
1508-+ CHARSET_INFO *cs, bool *truncated)
1509++int Field_datetime::store(const char *from, uint len, CHARSET_INFO *cs,
1510++ bool *truncated)
1511 {
1512 + if (truncated)
1513 + {
1514@@ -1791,7 +1766,7 @@
1515 ASSERT_COLUMN_MARKED_FOR_WRITE;
1516 MYSQL_TIME time_tmp;
1517 int error;
1518-@@ -6048,9 +6565,15 @@
1519+@@ -6048,9 +6553,15 @@
1520 error= 1; // Fix if invalid zero date
1521
1522 if (error)
1523@@ -1807,12 +1782,12 @@
1524
1525 #ifdef WORDS_BIGENDIAN
1526 if (table && table->s->db_low_byte_first)
1527-@@ -6064,24 +6587,43 @@
1528+@@ -6064,24 +6575,41 @@
1529 }
1530
1531
1532 -int Field_datetime::store(double nr)
1533-+int Field_datetime::store_truncated(double nr, bool *truncated)
1534++int Field_datetime::store(double nr, bool *truncated)
1535 {
1536 + if (truncated)
1537 + {
1538@@ -1833,8 +1808,7 @@
1539 }
1540 - error|= Field_datetime::store((longlong) rint(nr), FALSE);
1541 + bool truncated2= false;
1542-+ error|= Field_datetime::store_truncated((longlong) rint(nr), FALSE,
1543-+ &truncated2);
1544++ error|= Field_datetime::store((longlong) rint(nr), FALSE, &truncated2);
1545 + if (truncated)
1546 + {
1547 + *truncated= (*truncated) || truncated2;
1548@@ -1844,8 +1818,7 @@
1549
1550
1551 -int Field_datetime::store(longlong nr, bool unsigned_val)
1552-+int Field_datetime::store_truncated(longlong nr, bool unsigned_val,
1553-+ bool *truncated)
1554++int Field_datetime::store(longlong nr, bool unsigned_val, bool *truncated)
1555 {
1556 + if (truncated)
1557 + {
1558@@ -1854,7 +1827,7 @@
1559 ASSERT_COLUMN_MARKED_FOR_WRITE;
1560 MYSQL_TIME not_used;
1561 int error;
1562-@@ -6101,10 +6641,16 @@
1563+@@ -6101,10 +6629,16 @@
1564 }
1565
1566 if (error)
1567@@ -1871,13 +1844,13 @@
1568
1569 #ifdef WORDS_BIGENDIAN
1570 if (table && table->s->db_low_byte_first)
1571-@@ -6421,8 +6967,13 @@
1572+@@ -6421,8 +6955,13 @@
1573
1574 /* Copy a string and fill with space */
1575
1576 -int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
1577-+int Field_string::store_truncated(const char *from, uint length, CHARSET_INFO *cs,
1578-+ bool *truncated)
1579++int Field_string::store(const char *from, uint length, CHARSET_INFO *cs,
1580++ bool *truncated)
1581 {
1582 + if (truncated)
1583 + {
1584@@ -1886,7 +1859,7 @@
1585 ASSERT_COLUMN_MARKED_FOR_WRITE;
1586 uint copy_length;
1587 const char *well_formed_error_pos;
1588-@@ -6439,6 +6990,10 @@
1589+@@ -6439,6 +6978,10 @@
1590 &well_formed_error_pos,
1591 &cannot_convert_error_pos,
1592 &from_end_pos);
1593@@ -1897,30 +1870,30 @@
1594
1595 /* Append spaces if the string was shorter than the field. */
1596 if (copy_length < field_length)
1597-@@ -6462,7 +7017,7 @@
1598+@@ -6462,7 +7005,7 @@
1599 @param nr number
1600 */
1601
1602 -int Field_str::store(double nr)
1603-+int Field_str::store_truncated(double nr, bool *truncated)
1604++int Field_str::store(double nr, bool *truncated)
1605 {
1606 ASSERT_COLUMN_MARKED_FOR_WRITE;
1607 char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
1608-@@ -6544,7 +7099,7 @@
1609+@@ -6544,7 +7087,7 @@
1610 like inserting 500.0 in char(1)
1611 */
1612 DBUG_ASSERT(local_char_length < 5 || length <= local_char_length+1);
1613 - return store(buff, length, charset());
1614-+ return store_truncated(buff, length, charset(), truncated);
1615++ return store(buff, length, charset(), truncated);
1616 }
1617
1618
1619-@@ -6565,23 +7120,37 @@
1620+@@ -6565,23 +7108,38 @@
1621 }
1622
1623
1624 -int Field_string::store(longlong nr, bool unsigned_val)
1625-+int Field_string::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1626++int Field_string::store(longlong nr, bool unsigned_val, bool *truncated)
1627 {
1628 char buff[64];
1629 int l;
1630@@ -1928,12 +1901,12 @@
1631 l= (cs->cset->longlong10_to_str)(cs,buff,sizeof(buff),
1632 unsigned_val ? 10 : -10, nr);
1633 - return Field_string::store(buff,(uint)l,cs);
1634-+ return Field_string::store_truncated(buff,(uint)l,cs, truncated);
1635++ return Field_string::store(buff,(uint)l,cs, truncated);
1636 }
1637
1638
1639 -int Field_longstr::store_decimal(const my_decimal *d)
1640-+int Field_longstr::store_decimal_truncated(const my_decimal *d, bool *truncated)
1641++int Field_longstr::store_decimal(const my_decimal *d, bool *truncated)
1642 {
1643 + if (truncated)
1644 + {
1645@@ -1944,12 +1917,13 @@
1646 - my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str);
1647 - return store(str.ptr(), str.length(), str.charset());
1648 + int op_result= my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str);
1649-+ if (truncated && (E_DEC_OVERFLOW == op_result || E_DEC_TRUNCATED == op_result))
1650++ if (truncated && (E_DEC_OVERFLOW == op_result ||
1651++ E_DEC_TRUNCATED == op_result))
1652 + {
1653 + *truncated= true;
1654 + }
1655 + bool truncated2= false;
1656-+ int result= store_truncated(str.ptr(), str.length(), str.charset(), &truncated2);
1657++ int result= store(str.ptr(), str.length(), str.charset(), &truncated2);
1658 + if (truncated)
1659 + {
1660 + *truncated= (*truncated) || truncated2;
1661@@ -1958,13 +1932,13 @@
1662 }
1663
1664 uint32 Field_longstr::max_data_length() const
1665-@@ -7096,8 +7665,13 @@
1666+@@ -7095,8 +7653,13 @@
1667 return 2;
1668 }
1669
1670 -int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
1671-+int Field_varstring::store_truncated(const char *from, uint length,
1672-+ CHARSET_INFO *cs, bool *truncated)
1673++int Field_varstring::store(const char *from, uint length, CHARSET_INFO *cs,
1674++ bool *truncated)
1675 {
1676 + if (truncated)
1677 + {
1678@@ -1973,7 +1947,7 @@
1679 ASSERT_COLUMN_MARKED_FOR_WRITE;
1680 uint copy_length;
1681 const char *well_formed_error_pos;
1682-@@ -7112,6 +7686,10 @@
1683+@@ -7111,6 +7674,10 @@
1684 &well_formed_error_pos,
1685 &cannot_convert_error_pos,
1686 &from_end_pos);
1687@@ -1984,31 +1958,31 @@
1688
1689 if (length_bytes == 1)
1690 *ptr= (uchar) copy_length;
1691-@@ -7126,7 +7704,7 @@
1692+@@ -7125,7 +7692,7 @@
1693 }
1694
1695
1696 -int Field_varstring::store(longlong nr, bool unsigned_val)
1697-+int Field_varstring::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1698++int Field_varstring::store(longlong nr, bool unsigned_val, bool *truncated)
1699 {
1700 char buff[64];
1701 uint length;
1702-@@ -7136,7 +7714,7 @@
1703+@@ -7135,7 +7702,7 @@
1704 (unsigned_val ? 10:
1705 -10),
1706 nr);
1707 - return Field_varstring::store(buff, length, field_charset);
1708-+ return Field_varstring::store_truncated(buff, length, field_charset, truncated);
1709++ return Field_varstring::store(buff, length, field_charset, truncated);
1710 }
1711
1712
1713-@@ -7761,10 +8339,16 @@
1714+@@ -7760,10 +8327,16 @@
1715 }
1716
1717
1718 -int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
1719-+int Field_blob::store_truncated(const char *from, uint length, CHARSET_INFO *cs,
1720-+ bool *truncated)
1721++int Field_blob::store(const char *from, uint length, CHARSET_INFO *cs,
1722++ bool *truncated)
1723 {
1724 + if (truncated)
1725 + {
1726@@ -2020,7 +1994,7 @@
1727 const char *well_formed_error_pos;
1728 const char *cannot_convert_error_pos;
1729 const char *from_end_pos, *tmp;
1730-@@ -7801,7 +8385,11 @@
1731+@@ -7800,7 +8373,11 @@
1732 from= tmpstr.ptr();
1733 }
1734
1735@@ -2033,7 +2007,7 @@
1736 if (value.alloc(new_length))
1737 goto oom_error;
1738
1739-@@ -7828,6 +8416,10 @@
1740+@@ -7827,6 +8404,10 @@
1741 &well_formed_error_pos,
1742 &cannot_convert_error_pos,
1743 &from_end_pos);
1744@@ -2044,38 +2018,36 @@
1745
1746 Field_blob::store_length(copy_length);
1747 tmp= value.ptr();
1748-@@ -7846,19 +8438,21 @@
1749+@@ -7845,19 +8426,19 @@
1750 }
1751
1752
1753 -int Field_blob::store(double nr)
1754-+int Field_blob::store_truncated(double nr, bool *truncated)
1755++int Field_blob::store(double nr, bool *truncated)
1756 {
1757 CHARSET_INFO *cs=charset();
1758 value.set_real(nr, 2, cs);
1759 - return Field_blob::store(value.ptr(),(uint) value.length(), cs);
1760-+ return Field_blob::store_truncated(value.ptr(), (uint) value.length(), cs,
1761-+ truncated);
1762++ return Field_blob::store(value.ptr(), (uint) value.length(), cs, truncated);
1763 }
1764
1765
1766 -int Field_blob::store(longlong nr, bool unsigned_val)
1767-+int Field_blob::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1768++int Field_blob::store(longlong nr, bool unsigned_val, bool *truncated)
1769 {
1770 CHARSET_INFO *cs=charset();
1771 value.set_int(nr, unsigned_val, cs);
1772 - return Field_blob::store(value.ptr(), (uint) value.length(), cs);
1773-+ return Field_blob::store_truncated(value.ptr(), (uint) value.length(), cs,
1774-+ truncated);
1775++ return Field_blob::store(value.ptr(), (uint) value.length(), cs, truncated);
1776 }
1777
1778
1779-@@ -8404,32 +8996,49 @@
1780+@@ -8403,32 +8984,49 @@
1781 }
1782
1783
1784 -int Field_geom::store(double nr)
1785-+int Field_geom::store_truncated(double nr, bool *truncated)
1786++int Field_geom::store(double nr, bool *truncated)
1787 {
1788 + if (truncated)
1789 + {
1790@@ -2088,7 +2060,7 @@
1791
1792
1793 -int Field_geom::store(longlong nr, bool unsigned_val)
1794-+int Field_geom::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1795++int Field_geom::store(longlong nr, bool unsigned_val, bool *truncated)
1796 {
1797 + if (truncated)
1798 + {
1799@@ -2101,7 +2073,7 @@
1800
1801
1802 -int Field_geom::store_decimal(const my_decimal *)
1803-+int Field_geom::store_decimal_truncated(const my_decimal*, bool *truncated)
1804++int Field_geom::store_decimal(const my_decimal*, bool *truncated)
1805 {
1806 + if (truncated)
1807 + {
1808@@ -2114,8 +2086,8 @@
1809
1810
1811 -int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
1812-+int Field_geom::store_truncated(const char *from, uint length,
1813-+ CHARSET_INFO *cs, bool *truncated)
1814++int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs,
1815++ bool *truncated)
1816 {
1817 + if (truncated)
1818 + {
1819@@ -2124,13 +2096,13 @@
1820 if (!length)
1821 bzero(ptr, Field_blob::pack_length());
1822 else
1823-@@ -8524,8 +9133,13 @@
1824+@@ -8523,8 +9121,13 @@
1825 (if there isn't a empty value in the enum)
1826 */
1827
1828 -int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
1829-+int Field_enum::store_truncated(const char *from, uint length, CHARSET_INFO *cs,
1830-+ bool *truncated)
1831++int Field_enum::store(const char *from, uint length, CHARSET_INFO *cs,
1832++ bool *truncated)
1833 {
1834 + if (truncated)
1835 + {
1836@@ -2139,18 +2111,15 @@
1837 ASSERT_COLUMN_MARKED_FOR_WRITE;
1838 int err= 0;
1839 uint32 not_used;
1840-@@ -8553,32 +9167,50 @@
1841- tmp=(uint) my_strntoul(cs,from,length,10,&end,&err);
1842+@@ -8553,31 +9156,49 @@
1843 if (err || end != from+length || tmp > typelib->count)
1844 {
1845-- tmp=0;
1846-- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
1847-+ tmp=0;
1848-+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
1849+ tmp=0;
1850 + if (truncated)
1851 + {
1852 + *truncated= true;
1853 + }
1854+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
1855 }
1856 if (!table->in_use->count_cuted_fields)
1857 err= 0;
1858@@ -2170,15 +2139,15 @@
1859
1860
1861 -int Field_enum::store(double nr)
1862-+int Field_enum::store_truncated(double nr, bool *truncated)
1863++int Field_enum::store(double nr, bool *truncated)
1864 {
1865 - return Field_enum::store((longlong) nr, FALSE);
1866-+ return Field_enum::store_truncated((longlong) nr, FALSE, truncated);
1867++ return Field_enum::store((longlong) nr, FALSE, truncated);
1868 }
1869
1870
1871 -int Field_enum::store(longlong nr, bool unsigned_val)
1872-+int Field_enum::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1873++int Field_enum::store(longlong nr, bool unsigned_val, bool *truncated)
1874 {
1875 + if (truncated)
1876 + {
1877@@ -2195,13 +2164,13 @@
1878 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
1879 if (nr != 0 || table->in_use->count_cuted_fields)
1880 {
1881-@@ -8742,8 +9374,13 @@
1882+@@ -8741,8 +9362,13 @@
1883 */
1884
1885
1886 -int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
1887-+int Field_set::store_truncated(const char *from, uint length, CHARSET_INFO *cs,
1888-+ bool *truncated)
1889++int Field_set::store(const char *from, uint length, CHARSET_INFO *cs,
1890++ bool *truncated)
1891 {
1892 + if (truncated)
1893 + {
1894@@ -2210,7 +2179,7 @@
1895 ASSERT_COLUMN_MARKED_FOR_WRITE;
1896 bool got_warning= 0;
1897 int err= 0;
1898-@@ -8772,18 +9409,29 @@
1899+@@ -8771,6 +9397,10 @@
1900 tmp > (ulonglong) (((longlong) 1 << typelib->count) - (longlong) 1))
1901 {
1902 tmp=0;
1903@@ -2221,20 +2190,12 @@
1904 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
1905 }
1906 }
1907-- else if (got_warning)
1908-- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
1909-+ else
1910-+ {
1911-+ if (got_warning)
1912-+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
1913-+ }
1914- store_type(tmp);
1915- return err;
1916+@@ -8781,8 +9411,12 @@
1917 }
1918
1919
1920 -int Field_set::store(longlong nr, bool unsigned_val)
1921-+int Field_set::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1922++int Field_set::store(longlong nr, bool unsigned_val, bool *truncated)
1923 {
1924 + if (truncated)
1925 + {
1926@@ -2243,7 +2204,7 @@
1927 ASSERT_COLUMN_MARKED_FOR_WRITE;
1928 int error= 0;
1929 ulonglong max_nr;
1930-@@ -8796,6 +9444,10 @@
1931+@@ -8795,6 +9429,10 @@
1932 if ((ulonglong) nr > max_nr)
1933 {
1934 nr&= max_nr;
1935@@ -2254,13 +2215,13 @@
1936 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
1937 error=1;
1938 }
1939-@@ -9105,8 +9757,13 @@
1940+@@ -9104,8 +9742,13 @@
1941 }
1942
1943
1944 -int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs)
1945-+int Field_bit::store_truncated(const char *from, uint length, CHARSET_INFO *cs,
1946-+ bool *truncated)
1947++int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs,
1948++ bool *truncated)
1949 {
1950 + if (truncated)
1951 + {
1952@@ -2269,7 +2230,7 @@
1953 ASSERT_COLUMN_MARKED_FOR_WRITE;
1954 int delta;
1955
1956-@@ -9123,6 +9780,10 @@
1957+@@ -9122,6 +9765,10 @@
1958 set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
1959 else
1960 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
1961@@ -2280,38 +2241,38 @@
1962 return 1;
1963 }
1964 /* delta is >= -1 here */
1965-@@ -9152,26 +9813,32 @@
1966+@@ -9151,26 +9798,32 @@
1967 }
1968
1969
1970 -int Field_bit::store(double nr)
1971-+int Field_bit::store_truncated(double nr, bool *truncated)
1972++int Field_bit::store(double nr, bool *truncated)
1973 {
1974 - return Field_bit::store((longlong) nr, FALSE);
1975-+ return Field_bit::store_truncated((longlong) nr, FALSE, truncated);
1976++ return Field_bit::store((longlong) nr, FALSE, truncated);
1977 }
1978
1979
1980 -int Field_bit::store(longlong nr, bool unsigned_val)
1981-+int Field_bit::store_truncated(longlong nr, bool unsigned_val, bool *truncated)
1982++int Field_bit::store(longlong nr, bool unsigned_val, bool *truncated)
1983 {
1984 char buf[8];
1985
1986 mi_int8store(buf, nr);
1987 - return store(buf, 8, NULL);
1988-+ return store_truncated(buf, 8, NULL, truncated);
1989++ return store(buf, 8, NULL, truncated);
1990 }
1991
1992
1993 -int Field_bit::store_decimal(const my_decimal *val)
1994-+int Field_bit::store_decimal_truncated(const my_decimal *val, bool *truncated)
1995++int Field_bit::store_decimal(const my_decimal *val, bool *truncated)
1996 {
1997 int err= 0;
1998 - longlong i= convert_decimal2longlong(val, 1, &err);
1999 - return test(err | store(i, TRUE));
2000-+ longlong i= convert_decimal2longlong_truncated(val, 1, &err, truncated);
2001++ longlong i= convert_decimal2longlong(val, 1, &err, truncated);
2002 + bool truncated2= false;
2003-+ int result= test(err | store_truncated(i, TRUE, &truncated2));
2004++ int result= test(err | store(i, TRUE, &truncated2));
2005 + if (truncated)
2006 + {
2007 + *truncated= (*truncated) || truncated2;
2008@@ -2320,13 +2281,13 @@
2009 }
2010
2011
2012-@@ -9561,8 +10228,13 @@
2013+@@ -9560,8 +10213,13 @@
2014 }
2015
2016
2017 -int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs)
2018-+int Field_bit_as_char::store_truncated(const char *from, uint length,
2019-+ CHARSET_INFO *cs, bool *truncated)
2020++int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs,
2021++ bool *truncated)
2022 {
2023 + if (truncated)
2024 + {
2025@@ -2335,7 +2296,7 @@
2026 ASSERT_COLUMN_MARKED_FOR_WRITE;
2027 int delta;
2028 uchar bits= (uchar) (field_length & 7);
2029-@@ -9580,6 +10252,10 @@
2030+@@ -9579,6 +10237,10 @@
2031 set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
2032 else
2033 set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
2034@@ -2391,43 +2352,40 @@
2035 ulong length=((Field_blob*) copy->from_field)->get_length();
2036 ((Field_blob*) copy->to_field)->store_length(length);
2037 memcpy_fixed(copy->to_ptr,copy->from_ptr,sizeof(char*));
2038-@@ -293,9 +298,10 @@
2039+@@ -293,9 +298,9 @@
2040 static void do_conv_blob(Copy_field *copy)
2041 {
2042 copy->from_field->val_str(&copy->tmp);
2043 - ((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
2044-+ ((Field_blob *) copy->to_field)->store_truncated(copy->tmp.ptr(),
2045- copy->tmp.length(),
2046+- copy->tmp.length(),
2047 - copy->tmp.charset());
2048-+ copy->tmp.charset(),
2049-+ &(copy->truncated));
2050++ ((Field_blob *) copy->to_field)->store(copy->tmp.ptr(), copy->tmp.length(),
2051++ copy->tmp.charset(),
2052++ &(copy->truncated));
2053 }
2054
2055 /** Save blob in copy->tmp for GROUP BY. */
2056-@@ -306,9 +312,10 @@
2057+@@ -306,9 +311,9 @@
2058 String res(buff,sizeof(buff),copy->tmp.charset());
2059 copy->from_field->val_str(&res);
2060 copy->tmp.copy(res);
2061 - ((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
2062 - copy->tmp.length(),
2063 - copy->tmp.charset());
2064-+ ((Field_blob *) copy->to_field)->store_truncated(copy->tmp.ptr(),
2065-+ copy->tmp.length(),
2066-+ copy->tmp.charset(),
2067-+ &(copy->truncated));
2068++ ((Field_blob *) copy->to_field)->store(copy->tmp.ptr(), copy->tmp.length(),
2069++ copy->tmp.charset(),
2070++ &(copy->truncated));
2071 }
2072
2073
2074-@@ -317,15 +324,20 @@
2075+@@ -317,15 +322,18 @@
2076 char buff[MAX_FIELD_WIDTH];
2077 copy->tmp.set_quick(buff,sizeof(buff),copy->tmp.charset());
2078 copy->from_field->val_str(&copy->tmp);
2079 - copy->to_field->store(copy->tmp.c_ptr_quick(),copy->tmp.length(),
2080 - copy->tmp.charset());
2081-+ copy->to_field->store_truncated(copy->tmp.c_ptr_quick(),
2082-+ copy->tmp.length(),
2083-+ copy->tmp.charset(),
2084-+ &(copy->truncated));
2085++ copy->to_field->store(copy->tmp.c_ptr_quick(), copy->tmp.length(),
2086++ copy->tmp.charset(), &(copy->truncated));
2087 }
2088
2089
2090@@ -2441,16 +2399,14 @@
2091 else
2092 do_field_string(copy);
2093 }
2094-@@ -341,29 +353,33 @@
2095+@@ -341,29 +349,30 @@
2096 uint length= my_lengthsp_8bit(&my_charset_bin, copy->tmp.c_ptr_quick(),
2097 copy->from_field->field_length);
2098
2099 - copy->to_field->store(copy->tmp.c_ptr_quick(), length,
2100 - copy->tmp.charset());
2101-+ copy->to_field->store_truncated(copy->tmp.c_ptr_quick(),
2102-+ length,
2103-+ copy->tmp.charset(),
2104-+ &(copy->truncated));
2105++ copy->to_field->store(copy->tmp.c_ptr_quick(), length, copy->tmp.charset(),
2106++ &(copy->truncated));
2107 }
2108
2109
2110@@ -2459,8 +2415,7 @@
2111 longlong value= copy->from_field->val_int();
2112 - copy->to_field->store(value,
2113 - test(copy->from_field->flags & UNSIGNED_FLAG));
2114-+ copy->to_field->store_truncated(value,
2115-+ test(copy->from_field->flags & UNSIGNED_FLAG),
2116++ copy->to_field->store(value, test(copy->from_field->flags & UNSIGNED_FLAG),
2117 + &(copy->truncated));
2118 }
2119
2120@@ -2468,7 +2423,7 @@
2121 {
2122 double value=copy->from_field->val_real();
2123 - copy->to_field->store(value);
2124-+ copy->to_field->store_truncated(value,&(copy->truncated));
2125++ copy->to_field->store(value,&(copy->truncated));
2126 }
2127
2128
2129@@ -2476,12 +2431,12 @@
2130 {
2131 my_decimal value;
2132 - copy->to_field->store_decimal(copy->from_field->val_decimal(&value));
2133-+ copy->to_field->store_decimal_truncated(copy->from_field->val_decimal(&value),
2134-+ &(copy->truncated));
2135++ copy->to_field->store_decimal(copy->from_field->val_decimal(&value),
2136++ &(copy->truncated));
2137 }
2138
2139
2140-@@ -376,13 +392,14 @@
2141+@@ -376,13 +385,14 @@
2142 {
2143 CHARSET_INFO *cs= copy->from_field->charset();
2144 memcpy(copy->to_ptr,copy->from_ptr,copy->to_length);
2145@@ -2497,7 +2452,7 @@
2146 copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
2147 WARN_DATA_TRUNCATED, 1);
2148 }
2149-@@ -396,6 +413,7 @@
2150+@@ -396,6 +406,7 @@
2151
2152 static void do_cut_string_complex(Copy_field *copy)
2153 { // Shorter string field
2154@@ -2505,7 +2460,7 @@
2155 int well_formed_error;
2156 CHARSET_INFO *cs= copy->from_field->charset();
2157 const uchar *from_end= copy->from_ptr + copy->from_length;
2158-@@ -405,7 +423,10 @@
2159+@@ -405,7 +416,10 @@
2160 copy->to_length / cs->mbmaxlen,
2161 &well_formed_error);
2162 if (copy->to_length < copy_length)
2163@@ -2516,7 +2471,7 @@
2164 memcpy(copy->to_ptr, copy->from_ptr, copy_length);
2165
2166 /* Check if we lost any important characters */
2167-@@ -414,6 +435,7 @@
2168+@@ -414,6 +428,7 @@
2169 (char*) from_end,
2170 MY_SEQ_SPACES) < (copy->from_length - copy_length))
2171 {
2172@@ -2524,7 +2479,7 @@
2173 copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
2174 WARN_DATA_TRUNCATED, 1);
2175 }
2176-@@ -447,13 +469,17 @@
2177+@@ -447,13 +462,17 @@
2178
2179 static void do_varstring1(Copy_field *copy)
2180 {
2181@@ -2542,7 +2497,7 @@
2182 }
2183 *(uchar*) copy->to_ptr= (uchar) length;
2184 memcpy(copy->to_ptr+1, copy->from_ptr + 1, length);
2185-@@ -462,6 +488,7 @@
2186+@@ -462,6 +481,7 @@
2187
2188 static void do_varstring1_mb(Copy_field *copy)
2189 {
2190@@ -2550,7 +2505,7 @@
2191 int well_formed_error;
2192 CHARSET_INFO *cs= copy->from_field->charset();
2193 uint from_length= (uint) *(uchar*) copy->from_ptr;
2194-@@ -473,8 +500,11 @@
2195+@@ -473,8 +493,11 @@
2196 if (length < from_length)
2197 {
2198 if (current_thd->count_cuted_fields)
2199@@ -2562,7 +2517,7 @@
2200 }
2201 *copy->to_ptr= (uchar) length;
2202 memcpy(copy->to_ptr + 1, from_ptr, length);
2203-@@ -483,13 +513,17 @@
2204+@@ -483,13 +506,17 @@
2205
2206 static void do_varstring2(Copy_field *copy)
2207 {
2208@@ -2580,7 +2535,7 @@
2209 }
2210 int2store(copy->to_ptr,length);
2211 memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, copy->from_ptr + HA_KEY_BLOB_LENGTH,
2212-@@ -499,6 +533,7 @@
2213+@@ -499,6 +526,7 @@
2214
2215 static void do_varstring2_mb(Copy_field *copy)
2216 {
2217@@ -2588,7 +2543,7 @@
2218 int well_formed_error;
2219 CHARSET_INFO *cs= copy->from_field->charset();
2220 uint char_length= (copy->to_length - HA_KEY_BLOB_LENGTH) / cs->mbmaxlen;
2221-@@ -509,6 +544,7 @@
2222+@@ -509,6 +537,7 @@
2223 char_length, &well_formed_error);
2224 if (length < from_length)
2225 {
2226@@ -2598,7 +2553,7 @@
2227 WARN_DATA_TRUNCATED, 1);
2228 --- a/sql/field.h
2229 +++ b/sql/field.h
2230-@@ -115,10 +115,27 @@
2231+@@ -115,10 +115,11 @@
2232 const char *field_name_arg);
2233 virtual ~Field() {}
2234 /* Store functions returns 1 on overflow and -1 on fatal error */
2235@@ -2606,78 +2561,48 @@
2236 - virtual int store(double nr)=0;
2237 - virtual int store(longlong nr, bool unsigned_val)=0;
2238 - virtual int store_decimal(const my_decimal *d)=0;
2239-+ virtual int store(const char *to, uint length, CHARSET_INFO *cs)
2240-+ {
2241-+ return store_truncated(to,length,cs,0);
2242-+ }
2243-+ virtual int store_truncated(const char *to, uint length, CHARSET_INFO *cs,
2244-+ bool *truncated)=0;
2245-+ virtual int store(double nr)
2246-+ {
2247-+ return store_truncated(nr, 0);
2248-+ }
2249-+ virtual int store_truncated(double nr, bool *truncated)=0;
2250-+ virtual int store(longlong nr, bool unsigned_val)
2251-+ {
2252-+ return store_truncated(nr, unsigned_val, 0);
2253-+ }
2254-+ virtual int store_truncated(longlong nr, bool unsigned_val, bool *truncated)=0;
2255-+ virtual int store_decimal(const my_decimal *d)
2256-+ {
2257-+ return store_decimal_truncated(d, 0);
2258-+ }
2259-+ virtual int store_decimal_truncated(const my_decimal *d, bool *truncated)=0;
2260++ virtual int store(const char *to, uint length, CHARSET_INFO *cs,
2261++ bool *truncated= NULL)=0;
2262++ virtual int store(double nr, bool *truncated= NULL)=0;
2263++ virtual int store(longlong nr, bool unsigned_val, bool *truncated= NULL)=0;
2264++ virtual int store_decimal(const my_decimal *d, bool *truncated= NULL)=0;
2265 virtual int store_time(MYSQL_TIME *ltime, timestamp_type t_type);
2266 int store(const char *to, uint length, CHARSET_INFO *cs,
2267 enum_check_fields check_level);
2268-@@ -463,7 +480,18 @@
2269+@@ -463,7 +464,13 @@
2270 {
2271 return (op_result == E_DEC_OVERFLOW);
2272 }
2273 - int warn_if_overflow(int op_result);
2274-+ int warn_if_overflow(int op_result)
2275-+ {
2276-+ return warn_if_overflow_truncated(op_result, 0);
2277-+ }
2278-+ int warn_if_overflow_truncated(int op_result, bool *truncated);
2279-+ inline void if_overflow_truncated(int op_result, bool *truncated)
2280-+ {
2281-+ if (truncated)
2282-+ {
2283-+ *truncated= (op_result == E_DEC_OVERFLOW) || (op_result == E_DEC_TRUNCATED);
2284-+ }
2285++ int warn_if_overflow(int op_result, bool *truncated= NULL);
2286++ inline void if_overflow(int op_result, bool *truncated)
2287++ {
2288++ if (!truncated)
2289++ return;
2290++ *truncated= (op_result == E_DEC_OVERFLOW) || (op_result == E_DEC_TRUNCATED);
2291 + }
2292 void init(TABLE *table_arg)
2293 {
2294 orig_table= table= table_arg;
2295-@@ -484,6 +512,12 @@
2296+@@ -483,7 +490,7 @@
2297+ virtual uint is_equal(Create_field *new_field);
2298 /* convert decimal to longlong with overflow check */
2299 longlong convert_decimal2longlong(const my_decimal *val, bool unsigned_flag,
2300 - int *err);
2301-+ int *err)
2302-+ {
2303-+ return convert_decimal2longlong_truncated(val, unsigned_flag, err, 0);
2304-+ }
2305-+ longlong convert_decimal2longlong_truncated(const my_decimal *val,
2306-+ bool unsigned_flag, int *err,
2307-+ bool *truncated);
2308++ int *err, bool *truncated= NULL);
2309 /* The max. number of characters */
2310 inline uint32 char_length() const
2311 {
2312-@@ -636,7 +670,11 @@
2313+@@ -636,7 +643,7 @@
2314 uint decimals() const { return (uint) dec; }
2315 uint size_of() const { return sizeof(*this); }
2316 bool eq_def(Field *field);
2317 - int store_decimal(const my_decimal *);
2318-+ int store_decimal(const my_decimal *value)
2319-+ {
2320-+ return store_decimal_truncated(value, 0);
2321-+ }
2322-+ int store_decimal_truncated(const my_decimal*, bool *truncated);
2323++ int store_decimal(const my_decimal*, bool *truncated= NULL);
2324 uint row_pack_length()
2325 {
2326 return pack_length();
2327-@@ -651,10 +689,22 @@
2328+@@ -651,10 +658,10 @@
2329 my_decimal *val_decimal(my_decimal *);
2330 uint is_equal(Create_field *new_field);
2331 int check_int(CHARSET_INFO *cs, const char *str, int length,
2332@@ -2685,26 +2610,14 @@
2333 - bool get_int(CHARSET_INFO *cs, const char *from, uint len,
2334 - longlong *rnd, ulonglong unsigned_max,
2335 - longlong signed_min, longlong signed_max);
2336-+ const char *int_end, int error)
2337-+ {
2338-+ return check_int_truncated(cs, str, length, int_end, error, 0);
2339-+ }
2340-+ int check_int_truncated(CHARSET_INFO *cs, const char *str, int length,
2341-+ const char *int_end, int error, bool *truncated);
2342++ const char *int_end, int error, bool *truncated= NULL);
2343 + bool get_int(CHARSET_INFO *cs, const char *from, uint len, longlong *rnd,
2344-+ ulonglong unsigned_max, longlong signed_min, longlong signed_max)
2345-+ {
2346-+ return get_int_truncated(cs, from,len, rnd, unsigned_max, signed_min,
2347-+ signed_max, 0);
2348-+ }
2349-+ bool get_int_truncated(CHARSET_INFO *cs, const char *from, uint len,
2350-+ longlong *rnd, ulonglong unsigned_max,
2351-+ longlong signed_min, longlong signed_max,
2352-+ bool *truncated);
2353++ ulonglong unsigned_max, longlong signed_min, longlong signed_max,
2354++ bool *truncated= NULL);
2355 };
2356
2357
2358-@@ -668,10 +718,27 @@
2359+@@ -668,10 +675,10 @@
2360 const char *field_name_arg, CHARSET_INFO *charset);
2361 Item_result result_type () const { return STRING_RESULT; }
2362 uint decimals() const { return NOT_FIXED_DEC; }
2363@@ -2712,324 +2625,177 @@
2364 - int store(longlong nr, bool unsigned_val)=0;
2365 - int store_decimal(const my_decimal *);
2366 - int store(const char *to,uint length,CHARSET_INFO *cs)=0;
2367-+ int store(double nr)
2368-+ {
2369-+ return store_truncated(nr, 0);
2370-+ }
2371-+ int store_truncated(double nr, bool *truncated);
2372-+ int store(longlong nr, bool unsigned_val)
2373-+ {
2374-+ return store_truncated(nr, unsigned_val, 0);
2375-+ }
2376-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated)=0;
2377-+ int store_decimal(const my_decimal *value)
2378-+ {
2379-+ return store_decimal_truncated(value, 0);
2380-+ }
2381-+ int store_decimal_truncated(const my_decimal*, bool *truncated);
2382-+ int store(const char *to, uint length, CHARSET_INFO *cs)
2383-+ {
2384-+ return store_truncated(to, length, cs, 0);
2385-+ }
2386-+ int store_truncated(const char* to, uint length, CHARSET_INFO *cs,
2387-+ bool *truncated)=0;
2388++ int store(double nr, bool *truncated= NULL);
2389++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL)=0;
2390++ int store_decimal(const my_decimal *value, bool *truncated= NULL);
2391++ int store(const char *to, uint length, CHARSET_INFO *cs, bool *truncated= NULL)=0;
2392 uint size_of() const { return sizeof(*this); }
2393 CHARSET_INFO *charset(void) const { return field_charset; }
2394 void set_charset(CHARSET_INFO *charset_arg) { field_charset= charset_arg; }
2395-@@ -702,7 +769,11 @@
2396+@@ -702,7 +709,7 @@
2397 field_name_arg, charset_arg)
2398 {}
2399
2400 - int store_decimal(const my_decimal *d);
2401-+ int store_decimal(const my_decimal *d)
2402-+ {
2403-+ return store_decimal_truncated(d, 0);
2404-+ }
2405-+ int store_decimal_truncated(const my_decimal *d, bool *truncated);
2406++ int store_decimal(const my_decimal *d, bool *truncated= NULL);
2407 uint32 max_data_length() const;
2408 };
2409
2410-@@ -719,9 +790,17 @@
2411+@@ -719,9 +726,9 @@
2412 field_name_arg, dec_arg, zero_arg, unsigned_arg),
2413 not_fixed(dec_arg >= NOT_FIXED_DEC)
2414 {}
2415 - int store_decimal(const my_decimal *);
2416-+ int store_decimal(const my_decimal *value)
2417-+ {
2418-+ return store_decimal_truncated(value, 0);
2419-+ }
2420-+ int store_decimal_truncated(const my_decimal*, bool *truncated);
2421++ int store_decimal(const my_decimal *value, bool *truncated= NULL);
2422 my_decimal *val_decimal(my_decimal *);
2423 - int truncate(double *nr, double max_length);
2424-+ int truncate(double *nr, double max_length)
2425-+ {
2426-+ return truncate_truncated(nr, max_length, 0);
2427-+ }
2428-+ int truncate_truncated(double *nr, double max_length, bool *truncated);
2429++ int truncate(double *nr, double max_length, bool *truncated= NULL);
2430 uint32 max_display_length() { return field_length; }
2431 uint size_of() const { return sizeof(*this); }
2432 virtual const uchar *unpack(uchar* to, const uchar *from,
2433-@@ -745,9 +824,22 @@
2434+@@ -745,9 +752,10 @@
2435 enum ha_base_keytype key_type() const
2436 { return zerofill ? HA_KEYTYPE_BINARY : HA_KEYTYPE_NUM; }
2437 int reset(void);
2438 - int store(const char *to,uint length,CHARSET_INFO *charset);
2439 - int store(double nr);
2440 - int store(longlong nr, bool unsigned_val);
2441-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2442-+ {
2443-+ return store_truncated(to, length, charset, 0);
2444-+ }
2445-+ int store_truncated(const char* to, uint length, CHARSET_INFO *charset,
2446-+ bool *truncated);
2447-+ int store(double nr)
2448-+ {
2449-+ return store_truncated(nr, 0);
2450-+ }
2451-+ int store_truncated(double nr, bool *truncated);
2452-+ int store(longlong nr, bool unsigned_val)
2453-+ {
2454-+ return store_truncated(nr, unsigned_val, 0);
2455-+ }
2456-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2457++ int store(const char *to, uint length, CHARSET_INFO *charset,
2458++ bool *truncated= NULL);
2459++ int store(double nr, bool *truncated= NULL);
2460++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2461 double val_real(void);
2462 longlong val_int(void);
2463 String *val_str(String*,String *);
2464-@@ -794,13 +886,34 @@
2465+@@ -794,13 +802,14 @@
2466 enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
2467 Item_result result_type () const { return DECIMAL_RESULT; }
2468 int reset(void);
2469 - bool store_value(const my_decimal *decimal_value);
2470-+ bool store_value(const my_decimal *decimal_value)
2471-+ {
2472-+ return store_value_truncated(decimal_value, 0);
2473-+ }
2474-+ bool store_value_truncated(const my_decimal *decimal_value, bool *truncated);
2475++ bool store_value(const my_decimal *decimal_value, bool *truncated= NULL);
2476 void set_value_on_overflow(my_decimal *decimal_value, bool sign);
2477 - int store(const char *to, uint length, CHARSET_INFO *charset);
2478 - int store(double nr);
2479 - int store(longlong nr, bool unsigned_val);
2480-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2481-+ {
2482-+ return store_truncated(to, length, charset, 0);
2483-+ }
2484-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2485-+ bool *truncated);
2486-+ int store(double nr)
2487-+ {
2488-+ return store_truncated(nr, 0);
2489-+ }
2490-+ int store_truncated(double nr, bool *truncated);
2491-+ int store(longlong nr, bool unsigned_val)
2492-+ {
2493-+ return store_truncated(nr, unsigned_val, 0);
2494-+ }
2495-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2496++ int store(const char *to, uint length, CHARSET_INFO *charset,
2497++ bool *truncated= NULL);
2498++ int store(double nr, bool *truncated= NULL);
2499++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2500 int store_time(MYSQL_TIME *ltime, timestamp_type t_type);
2501 - int store_decimal(const my_decimal *);
2502-+ int store_decimal(const my_decimal *value)
2503-+ {
2504-+ return store_decimal_truncated(value, 0);
2505-+ }
2506-+ int store_decimal_truncated(const my_decimal*, bool *truncated);
2507++ int store_decimal(const my_decimal *value, bool *truncated= NULL);
2508 double val_real(void);
2509 longlong val_int(void);
2510 my_decimal *val_decimal(my_decimal *);
2511-@@ -837,9 +950,22 @@
2512+@@ -837,9 +846,10 @@
2513 enum_field_types type() const { return MYSQL_TYPE_TINY;}
2514 enum ha_base_keytype key_type() const
2515 { return unsigned_flag ? HA_KEYTYPE_BINARY : HA_KEYTYPE_INT8; }
2516 - int store(const char *to,uint length,CHARSET_INFO *charset);
2517 - int store(double nr);
2518 - int store(longlong nr, bool unsigned_val);
2519-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2520-+ {
2521-+ return store_truncated(to, length, charset, 0);
2522-+ }
2523-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2524-+ bool *truncated);
2525-+ int store(double nr)
2526-+ {
2527-+ return store_truncated(nr, 0);
2528-+ }
2529-+ int store_truncated(double nr, bool *truncated);
2530-+ int store(longlong nr, bool unsigned_val)
2531-+ {
2532-+ return store_truncated(nr, unsigned_val, 0);
2533-+ }
2534-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2535++ int store(const char *to, uint length, CHARSET_INFO *charset,
2536++ bool *truncated= NULL);
2537++ int store(double nr, bool *truncated= NULL);
2538++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2539 int reset(void) { ptr[0]=0; return 0; }
2540 double val_real(void);
2541 longlong val_int(void);
2542-@@ -886,9 +1012,22 @@
2543+@@ -886,9 +896,10 @@
2544 enum_field_types type() const { return MYSQL_TYPE_SHORT;}
2545 enum ha_base_keytype key_type() const
2546 { return unsigned_flag ? HA_KEYTYPE_USHORT_INT : HA_KEYTYPE_SHORT_INT;}
2547 - int store(const char *to,uint length,CHARSET_INFO *charset);
2548 - int store(double nr);
2549 - int store(longlong nr, bool unsigned_val);
2550-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2551-+ {
2552-+ return store_truncated(to, length, charset, 0);
2553-+ }
2554-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2555-+ bool *truncated);
2556-+ int store(double nr)
2557-+ {
2558-+ return store_truncated(nr, 0);
2559-+ }
2560-+ int store_truncated(double nr, bool *truncated);
2561-+ int store(longlong nr, bool unsigned_val)
2562-+ {
2563-+ return store_truncated(nr, unsigned_val, 0);
2564-+ }
2565-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2566++ int store(const char *to, uint length, CHARSET_INFO *charset,
2567++ bool *truncated= NULL);
2568++ int store(double nr, bool *truncated= NULL);
2569++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2570 int reset(void) { ptr[0]=ptr[1]=0; return 0; }
2571 double val_real(void);
2572 longlong val_int(void);
2573-@@ -955,9 +1094,22 @@
2574+@@ -955,9 +966,10 @@
2575 enum_field_types type() const { return MYSQL_TYPE_INT24;}
2576 enum ha_base_keytype key_type() const
2577 { return unsigned_flag ? HA_KEYTYPE_UINT24 : HA_KEYTYPE_INT24; }
2578 - int store(const char *to,uint length,CHARSET_INFO *charset);
2579 - int store(double nr);
2580 - int store(longlong nr, bool unsigned_val);
2581-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2582-+ {
2583-+ return store_truncated(to, length, charset, 0);
2584-+ }
2585-+ int store_truncated(const char* to, uint length, CHARSET_INFO *charset,
2586-+ bool *truncated);
2587-+ int store(double nr)
2588-+ {
2589-+ return store_truncated(nr, 0);
2590-+ }
2591-+ int store_truncated(double nr, bool *truncated);
2592-+ int store(longlong nr, bool unsigned_val)
2593-+ {
2594-+ return store_truncated(nr, unsigned_val, 0);
2595-+ }
2596-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2597++ int store(const char *to, uint length, CHARSET_INFO *charset,
2598++ bool *truncated= NULL);
2599++ int store(double nr, bool *truncated= NULL);
2600++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2601 int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
2602 double val_real(void);
2603 longlong val_int(void);
2604-@@ -1002,9 +1154,22 @@
2605+@@ -1002,9 +1014,10 @@
2606 enum_field_types type() const { return MYSQL_TYPE_LONG;}
2607 enum ha_base_keytype key_type() const
2608 { return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; }
2609 - int store(const char *to,uint length,CHARSET_INFO *charset);
2610 - int store(double nr);
2611 - int store(longlong nr, bool unsigned_val);
2612-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2613-+ {
2614-+ return store_truncated(to, length, charset, 0);
2615-+ }
2616-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2617-+ bool *truncated);
2618-+ int store(double nr)
2619-+ {
2620-+ return store_truncated(nr, 0);
2621-+ }
2622-+ int store_truncated(double nr, bool *truncated);
2623-+ int store(longlong nr, bool unsigned_val)
2624-+ {
2625-+ return store_truncated(nr, unsigned_val, 0);
2626-+ }
2627-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2628++ int store(const char *to, uint length, CHARSET_INFO *charset,
2629++ bool *truncated= NULL);
2630++ int store(double nr, bool *truncated= NULL);
2631++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2632 int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
2633 double val_real(void);
2634 longlong val_int(void);
2635-@@ -1051,9 +1216,22 @@
2636+@@ -1051,9 +1064,10 @@
2637 enum_field_types type() const { return MYSQL_TYPE_LONGLONG;}
2638 enum ha_base_keytype key_type() const
2639 { return unsigned_flag ? HA_KEYTYPE_ULONGLONG : HA_KEYTYPE_LONGLONG; }
2640 - int store(const char *to,uint length,CHARSET_INFO *charset);
2641 - int store(double nr);
2642 - int store(longlong nr, bool unsigned_val);
2643-+ int store(const char* to, uint length, CHARSET_INFO *charset)
2644-+ {
2645-+ return store_truncated(to, length, charset, 0);
2646-+ }
2647-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2648-+ bool *truncated);
2649-+ int store(double nr)
2650-+ {
2651-+ return store_truncated(nr, 0);
2652-+ }
2653-+ int store_truncated(double nr, bool *truncated);
2654-+ int store(longlong nr, bool unsigned_val)
2655-+ {
2656-+ return store_truncated(nr, unsigned_val, 0);
2657-+ }
2658-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2659++ int store(const char* to, uint length, CHARSET_INFO *charset,
2660++ bool *truncated= NULL);
2661++ int store(double nr, bool *truncated= NULL);
2662++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2663 int reset(void)
2664 {
2665 ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0;
2666-@@ -1102,9 +1280,22 @@
2667+@@ -1102,9 +1116,10 @@
2668 {}
2669 enum_field_types type() const { return MYSQL_TYPE_FLOAT;}
2670 enum ha_base_keytype key_type() const { return HA_KEYTYPE_FLOAT; }
2671 - int store(const char *to,uint length,CHARSET_INFO *charset);
2672 - int store(double nr);
2673 - int store(longlong nr, bool unsigned_val);
2674-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2675-+ {
2676-+ return store_truncated(to, length, charset, 0);
2677-+ }
2678-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2679-+ bool *truncated);
2680-+ int store(double nr)
2681-+ {
2682-+ return store_truncated(nr, 0);
2683-+ }
2684-+ int store_truncated(double nr, bool *truncated);
2685-+ int store(longlong nr, bool unsigned_val)
2686-+ {
2687-+ return store_truncated(nr, unsigned_val, 0);
2688-+ }
2689-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2690++ int store(const char *to, uint length, CHARSET_INFO *charset,
2691++ bool *truncated= NULL);
2692++ int store(double nr, bool *truncated= NULL);
2693++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2694 int reset(void) { bzero(ptr,sizeof(float)); return 0; }
2695 double val_real(void);
2696 longlong val_int(void);
2697-@@ -1142,9 +1333,22 @@
2698+@@ -1142,9 +1157,10 @@
2699 {not_fixed= not_fixed_arg; }
2700 enum_field_types type() const { return MYSQL_TYPE_DOUBLE;}
2701 enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; }
2702 - int store(const char *to,uint length,CHARSET_INFO *charset);
2703 - int store(double nr);
2704 - int store(longlong nr, bool unsigned_val);
2705-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2706-+ {
2707-+ return store_truncated(to, length, charset, 0);
2708-+ }
2709-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2710-+ bool *truncated);
2711-+ int store(double nr)
2712-+ {
2713-+ return store_truncated(nr, 0);
2714-+ }
2715-+ int store_truncated(double nr, bool *truncated);
2716-+ int store(longlong nr, bool unsigned_val)
2717-+ {
2718-+ return store_truncated(nr, unsigned_val, 0);
2719-+ }
2720-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2721++ int store(const char *to, uint length, CHARSET_INFO *charset,
2722++ bool *truncated= NULL);
2723++ int store(double nr, bool *truncated= NULL);
2724++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2725 int reset(void) { bzero(ptr,sizeof(double)); return 0; }
2726 double val_real(void);
2727 longlong val_int(void);
2728-@@ -1173,10 +1377,58 @@
2729+@@ -1172,11 +1188,43 @@
2730+ unireg_check_arg, field_name_arg, cs)
2731 {}
2732 enum_field_types type() const { return MYSQL_TYPE_NULL;}
2733- int store(const char *to, uint length, CHARSET_INFO *cs)
2734+- int store(const char *to, uint length, CHARSET_INFO *cs)
2735 - { null[0]=1; return 0; }
2736 - int store(double nr) { null[0]=1; return 0; }
2737 - int store(longlong nr, bool unsigned_val) { null[0]=1; return 0; }
2738 - int store_decimal(const my_decimal *d) { null[0]=1; return 0; }
2739-+ {
2740-+ return store_truncated(to, length, cs, 0);
2741-+ }
2742-+ int store_truncated(const char *to, uint length, CHARSET_INFO *cs,
2743-+ bool *truncated)
2744++ int store(const char *to, uint length, CHARSET_INFO *cs,
2745++ bool *truncated= NULL)
2746 + {
2747 + if (truncated)
2748 + {
2749@@ -3038,11 +2804,7 @@
2750 + null[0]= 1;
2751 + return 0;
2752 + }
2753-+ int store(double nr)
2754-+ {
2755-+ return store_truncated(nr, 0);
2756-+ }
2757-+ int store_truncated(double nr, bool *truncated)
2758++ int store(double nr, bool *truncated= NULL)
2759 + {
2760 + if (truncated)
2761 + {
2762@@ -3051,11 +2813,7 @@
2763 + null[0]=1;
2764 + return 0;
2765 + }
2766-+ int store(longlong nr, bool unsigned_val)
2767-+ {
2768-+ return store_truncated(nr, unsigned_val, 0);
2769-+ }
2770-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated)
2771++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL)
2772 + {
2773 + if (truncated)
2774 + {
2775@@ -3064,11 +2822,7 @@
2776 + null[0]= 1;
2777 + return 0;
2778 + }
2779-+ int store_decimal(const my_decimal *d)
2780-+ {
2781-+ return store_decimal_truncated(d, 0);
2782-+ }
2783-+ int store_decimal_truncated(const my_decimal *d, bool *truncated)
2784++ int store_decimal(const my_decimal *d, bool *truncated= NULL)
2785 + {
2786 + if (truncated)
2787 + {
2788@@ -3080,247 +2834,139 @@
2789 int reset(void) { return 0; }
2790 double val_real(void) { return 0.0;}
2791 longlong val_int(void) { return 0;}
2792-@@ -1203,9 +1454,22 @@
2793+@@ -1203,9 +1251,10 @@
2794 enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;}
2795 enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
2796 enum Item_result cmp_type () const { return INT_RESULT; }
2797 - int store(const char *to,uint length,CHARSET_INFO *charset);
2798 - int store(double nr);
2799 - int store(longlong nr, bool unsigned_val);
2800-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2801-+ {
2802-+ return store_truncated(to, length, charset, 0);
2803-+ }
2804-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2805-+ bool *truncated);
2806-+ int store(double nr)
2807-+ {
2808-+ return store_truncated(nr, 0);
2809-+ }
2810-+ int store_truncated(double nr, bool *truncated);
2811-+ int store(longlong nr, bool unsigned_val)
2812-+ {
2813-+ return store_truncated(nr, unsigned_val, 0);
2814-+ }
2815-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2816++ int store(const char *to, uint length, CHARSET_INFO *charset,
2817++ bool *truncated= NULL);
2818++ int store(double nr, bool *truncated= NULL);
2819++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2820 int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
2821 double val_real(void);
2822 longlong val_int(void);
2823-@@ -1276,9 +1540,22 @@
2824+@@ -1276,9 +1325,10 @@
2825 unireg_check_arg, field_name_arg, 1, 1)
2826 {}
2827 enum_field_types type() const { return MYSQL_TYPE_YEAR;}
2828 - int store(const char *to,uint length,CHARSET_INFO *charset);
2829 - int store(double nr);
2830 - int store(longlong nr, bool unsigned_val);
2831-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2832-+ {
2833-+ return store_truncated(to, length, charset, 0);
2834-+ }
2835-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2836-+ bool *truncated);
2837-+ int store(double nr)
2838-+ {
2839-+ return store_truncated(nr, 0);
2840-+ }
2841-+ int store_truncated(double nr, bool *truncated);
2842-+ int store(longlong nr, bool unsigned_val)
2843-+ {
2844-+ return store_truncated(nr, unsigned_val, 0);
2845-+ }
2846-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2847++ int store(const char *to, uint length, CHARSET_INFO *charset,
2848++ bool *truncated= NULL);
2849++ int store(double nr, bool *truncated= NULL);
2850++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2851 double val_real(void);
2852 longlong val_int(void);
2853 String *val_str(String*,String *);
2854-@@ -1303,9 +1580,22 @@
2855+@@ -1303,9 +1353,10 @@
2856 enum_field_types type() const { return MYSQL_TYPE_DATE;}
2857 enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
2858 enum Item_result cmp_type () const { return INT_RESULT; }
2859 - int store(const char *to,uint length,CHARSET_INFO *charset);
2860 - int store(double nr);
2861 - int store(longlong nr, bool unsigned_val);
2862-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2863-+ {
2864-+ return store_truncated(to, length, charset, 0);
2865-+ }
2866-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2867-+ bool *truncated);
2868-+ int store(double nr)
2869-+ {
2870-+ return store_truncated(nr, 0);
2871-+ }
2872-+ int store_truncated(double nr, bool *truncated);
2873-+ int store(longlong nr, bool unsigned_val)
2874-+ {
2875-+ return store_truncated(nr, unsigned_val, 0);
2876-+ }
2877-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2878++ int store(const char *to, uint length, CHARSET_INFO *charset,
2879++ bool *truncated= NULL);
2880++ int store(double nr, bool *truncated= NULL);
2881++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2882 int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
2883 double val_real(void);
2884 longlong val_int(void);
2885-@@ -1348,9 +1638,22 @@
2886+@@ -1348,9 +1399,10 @@
2887 enum_field_types real_type() const { return MYSQL_TYPE_NEWDATE; }
2888 enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; }
2889 enum Item_result cmp_type () const { return INT_RESULT; }
2890 - int store(const char *to,uint length,CHARSET_INFO *charset);
2891 - int store(double nr);
2892 - int store(longlong nr, bool unsigned_val);
2893-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2894-+ {
2895-+ return store_truncated(to, length, charset, 0);
2896-+ }
2897-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2898-+ bool *truncated);
2899-+ int store(double nr)
2900-+ {
2901-+ return store_truncated(nr, 0);
2902-+ }
2903-+ int store_truncated(double nr, bool *truncated);
2904-+ int store(longlong nr, bool unsigned_val)
2905-+ {
2906-+ return store_truncated(nr, unsigned_val, 0);
2907-+ }
2908-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2909++ int store(const char *to, uint length, CHARSET_INFO *charset,
2910++ bool *truncated= NULL);
2911++ int store(double nr, bool *truncated= NULL);
2912++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2913 int store_time(MYSQL_TIME *ltime, timestamp_type type);
2914 int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
2915 double val_real(void);
2916-@@ -1384,9 +1687,22 @@
2917+@@ -1384,9 +1436,10 @@
2918 enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
2919 enum Item_result cmp_type () const { return INT_RESULT; }
2920 int store_time(MYSQL_TIME *ltime, timestamp_type type);
2921 - int store(const char *to,uint length,CHARSET_INFO *charset);
2922 - int store(double nr);
2923 - int store(longlong nr, bool unsigned_val);
2924-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2925-+ {
2926-+ return store_truncated(to, length, charset, 0);
2927-+ }
2928-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2929-+ bool *truncated);
2930-+ int store(double nr)
2931-+ {
2932-+ return store_truncated(nr, 0);
2933-+ }
2934-+ int store_truncated(double nr, bool *truncated);
2935-+ int store(longlong nr, bool unsigned_val)
2936-+ {
2937-+ return store_truncated(nr, unsigned_val, 0);
2938-+ }
2939-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2940++ int store(const char *to, uint length, CHARSET_INFO *charset,
2941++ bool *truncated= NULL);
2942++ int store(double nr, bool *truncated= NULL);
2943++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2944 int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
2945 double val_real(void);
2946 longlong val_int(void);
2947-@@ -1421,9 +1737,22 @@
2948+@@ -1421,9 +1474,10 @@
2949 #endif
2950 enum Item_result cmp_type () const { return INT_RESULT; }
2951 uint decimals() const { return DATETIME_DEC; }
2952 - int store(const char *to,uint length,CHARSET_INFO *charset);
2953 - int store(double nr);
2954 - int store(longlong nr, bool unsigned_val);
2955-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2956-+ {
2957-+ return store_truncated(to, length, charset, 0);
2958-+ }
2959-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2960-+ bool *truncated);
2961-+ int store(double nr)
2962-+ {
2963-+ return store_truncated(nr, 0);
2964-+ }
2965-+ int store_truncated(double nr, bool *truncated);
2966-+ int store(longlong nr, bool unsigned_val)
2967-+ {
2968-+ return store_truncated(nr, unsigned_val, 0);
2969-+ }
2970-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2971++ int store(const char *to, uint length, CHARSET_INFO *charset,
2972++ bool *truncated= NULL);
2973++ int store(double nr, bool *truncated= NULL);
2974++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
2975 int store_time(MYSQL_TIME *ltime, timestamp_type type);
2976 int reset(void)
2977 {
2978-@@ -1489,9 +1818,25 @@
2979+@@ -1489,9 +1543,13 @@
2980 (has_charset() ? ' ' : 0));
2981 return 0;
2982 }
2983 - int store(const char *to,uint length,CHARSET_INFO *charset);
2984 - int store(longlong nr, bool unsigned_val);
2985 - int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
2986-+ int store(const char *to, uint length, CHARSET_INFO *charset)
2987-+ {
2988-+ return store_truncated(to, length, charset, 0);
2989-+ }
2990-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
2991-+ bool *truncated);
2992-+ int store(longlong nr, bool unsigned_val)
2993-+ {
2994-+ return store_truncated(nr, unsigned_val, 0);
2995-+ }
2996-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
2997-+ int store(double nr) /* QQ: To be deleted */
2998-+ {
2999-+ return store_truncated(nr, 0);
3000-+ }
3001-+ int store_truncated(double nr, bool *truncated)/* QQ: To be deleted */
3002-+ {
3003-+ return Field_str::store_truncated(nr, truncated);
3004++ int store(const char *to, uint length, CHARSET_INFO *charset,
3005++ bool *truncated= NULL);
3006++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
3007++ int store(double nr, bool *truncated= NULL) /* QQ: To be deleted */
3008++ {
3009++ return Field_str::store(nr, truncated);
3010 + }
3011 double val_real(void);
3012 longlong val_int(void);
3013 String *val_str(String*,String *);
3014-@@ -1574,9 +1919,25 @@
3015+@@ -1574,9 +1632,13 @@
3016 return (uint32) field_length + (field_charset == &my_charset_bin ?
3017 length_bytes : 0);
3018 }
3019 - int store(const char *to,uint length,CHARSET_INFO *charset);
3020 - int store(longlong nr, bool unsigned_val);
3021 - int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
3022-+ int store(const char *to, uint length, CHARSET_INFO *charset)
3023-+ {
3024-+ return store_truncated(to, length, charset, 0);
3025-+ }
3026-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
3027-+ bool *truncated);
3028-+ int store(longlong nr, bool unsigned_val)
3029-+ {
3030-+ return store_truncated(nr, unsigned_val, 0);
3031-+ }
3032-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
3033-+ int store(double nr) /* QQ: To be deleted */
3034-+ {
3035-+ return store_truncated(nr, 0);
3036-+ }
3037-+ int store_truncated(double nr, bool *truncated)/* QQ: To be deleted */
3038-+ {
3039-+ return Field_str::store_truncated(nr, truncated);
3040-+ }
3041++ int store(const char *to, uint length, CHARSET_INFO *charset,
3042++ bool *truncated= NULL);
3043++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
3044++ int store(double nr, bool *truncated= NULL) /* QQ: To be deleted */
3045++ {
3046++ return Field_str::store(nr, truncated);
3047++ }
3048 double val_real(void);
3049 longlong val_int(void);
3050 String *val_str(String*,String *);
3051-@@ -1668,9 +2029,22 @@
3052+@@ -1668,9 +1730,10 @@
3053 enum_field_types type() const { return MYSQL_TYPE_BLOB;}
3054 enum ha_base_keytype key_type() const
3055 { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
3056 - int store(const char *to,uint length,CHARSET_INFO *charset);
3057 - int store(double nr);
3058 - int store(longlong nr, bool unsigned_val);
3059-+ int store(const char *to, uint length, CHARSET_INFO *charset)
3060-+ {
3061-+ return store_truncated(to, length, charset, 0);
3062-+ }
3063-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
3064-+ bool *truncated);
3065-+ int store(double nr)
3066-+ {
3067-+ return store_truncated(nr, 0);
3068-+ }
3069-+ int store_truncated(double nr, bool *truncated);
3070-+ int store(longlong nr, bool unsigned_val)
3071-+ {
3072-+ return store_truncated(nr, unsigned_val, 0);
3073-+ }
3074-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
3075++ int store(const char *to, uint length, CHARSET_INFO *charset,
3076++ bool *truncated= NULL);
3077++ int store(double nr, bool *truncated= NULL);
3078++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
3079 double val_real(void);
3080 longlong val_int(void);
3081 String *val_str(String*,String *);
3082-@@ -1824,10 +2198,27 @@
3083+@@ -1824,10 +1887,11 @@
3084 enum ha_base_keytype key_type() const { return HA_KEYTYPE_VARBINARY2; }
3085 enum_field_types type() const { return MYSQL_TYPE_GEOMETRY; }
3086 void sql_type(String &str) const;
3087@@ -3328,86 +2974,46 @@
3088 - int store(double nr);
3089 - int store(longlong nr, bool unsigned_val);
3090 - int store_decimal(const my_decimal *);
3091-+ int store(const char *to, uint length, CHARSET_INFO *charset)
3092-+ {
3093-+ return store_truncated(to, length, charset, 0);
3094-+ }
3095-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
3096-+ bool* truncated);
3097-+ int store(double nr)
3098-+ {
3099-+ return store_truncated(nr, 0);
3100-+ }
3101-+ int store_truncated(double nr, bool *truncated);
3102-+ int store(longlong nr, bool unsigned_val)
3103-+ {
3104-+ return store_truncated(nr, unsigned_val, 0);
3105-+ }
3106-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
3107-+ int store_decimal(const my_decimal *value)
3108-+ {
3109-+ return store_decimal_truncated(value, 0);
3110-+ }
3111-+ int store_decimal_truncated(const my_decimal*, bool *truncated);
3112++ int store(const char *to, uint length, CHARSET_INFO *charset,
3113++ bool *truncated= NULL);
3114++ int store(double nr, bool *truncated= NULL);
3115++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
3116++ int store_decimal(const my_decimal *value, bool *truncated= NULL);
3117 uint size_of() const { return sizeof(*this); }
3118 int reset(void) { return !maybe_null() || Field_blob::reset(); }
3119 geometry_type get_geometry_type() { return geom_type; };
3120-@@ -1857,9 +2247,22 @@
3121+@@ -1857,9 +1921,10 @@
3122 enum Item_result cmp_type () const { return INT_RESULT; }
3123 enum Item_result cast_to_int_type () const { return INT_RESULT; }
3124 enum ha_base_keytype key_type() const;
3125 - int store(const char *to,uint length,CHARSET_INFO *charset);
3126 - int store(double nr);
3127 - int store(longlong nr, bool unsigned_val);
3128-+ int store(const char *to, uint length,CHARSET_INFO *charset)
3129-+ {
3130-+ return store_truncated(to, length, charset, 0);
3131-+ }
3132-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
3133-+ bool *truncated);
3134-+ int store(double nr)
3135-+ {
3136-+ return store_truncated(nr, 0);
3137-+ }
3138-+ int store_truncated(double nr, bool *truncated);
3139-+ int store(longlong nr, bool unsigned_val)
3140-+ {
3141-+ return store_truncated(nr, unsigned_val, 0);
3142-+ }
3143-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
3144++ int store(const char *to, uint length,CHARSET_INFO *charset,
3145++ bool *truncated= NULL);
3146++ int store(double nr, bool *truncated= NULL);
3147++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
3148 double val_real(void);
3149 longlong val_int(void);
3150 String *val_str(String*,String *);
3151-@@ -1899,9 +2302,25 @@
3152+@@ -1899,9 +1964,13 @@
3153 {
3154 flags=(flags & ~ENUM_FLAG) | SET_FLAG;
3155 }
3156 - int store(const char *to,uint length,CHARSET_INFO *charset);
3157 - int store(double nr) { return Field_set::store((longlong) nr, FALSE); }
3158 - int store(longlong nr, bool unsigned_val);
3159-+ int store(const char *to, uint length, CHARSET_INFO *charset)
3160-+ {
3161-+ return store_truncated(to, length, charset, 0);
3162-+ }
3163-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
3164-+ bool *truncated);
3165-+ int store(double nr)
3166-+ {
3167-+ return store_truncated(nr, 0);
3168-+ }
3169-+ int store_truncated(double nr, bool *truncated)
3170-+ {
3171-+ return Field_set::store_truncated((longlong) nr, FALSE, truncated);
3172-+ }
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(const char *to, uint length, CHARSET_INFO *charset,
3179++ bool *truncated= NULL);
3180++ int store(double nr, bool *truncated= NULL)
3181++ {
3182++ return Field_set::store((longlong) nr, FALSE, truncated);
3183++ }
3184++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
3185
3186 virtual bool zero_pack() const { return 1; }
3187 String *val_str(String*,String *);
3188-@@ -1947,10 +2366,27 @@
3189+@@ -1947,10 +2016,11 @@
3190 clr_rec_bits(bit_ptr, bit_ofs, bit_len);
3191 return 0;
3192 }
3193@@ -3415,63 +3021,36 @@
3194 - int store(double nr);
3195 - int store(longlong nr, bool unsigned_val);
3196 - int store_decimal(const my_decimal *);
3197-+ int store(const char *to, uint length, CHARSET_INFO *charset)
3198-+ {
3199-+ return store_truncated(to, length, charset, 0);
3200-+ }
3201-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
3202-+ bool *truncated);
3203-+ int store(double nr)
3204-+ {
3205-+ return store_truncated(nr, 0);
3206-+ }
3207-+ int store_truncated(double nr, bool *truncated);
3208-+ int store(longlong nr, bool unsigned_val)
3209-+ {
3210-+ return store_truncated(nr, unsigned_val, 0);
3211-+ }
3212-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated);
3213-+ int store_decimal(const my_decimal *value)
3214-+ {
3215-+ return store_decimal_truncated(value, 0);
3216-+ }
3217-+ int store_decimal_truncated(const my_decimal*, bool *truncated);
3218++ int store(const char *to, uint length, CHARSET_INFO *charset,
3219++ bool *truncated= NULL);
3220++ int store(double nr, bool *truncated= NULL);
3221++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL);
3222++ int store_decimal(const my_decimal *value, bool *truncated= NULL);
3223 double val_real(void);
3224 longlong val_int(void);
3225 String *val_str(String*, String *);
3226-@@ -2033,10 +2469,28 @@
3227+@@ -2033,10 +2103,16 @@
3228 enum utype unireg_check_arg, const char *field_name_arg);
3229 enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
3230 uint size_of() const { return sizeof(*this); }
3231 - int store(const char *to, uint length, CHARSET_INFO *charset);
3232 - int store(double nr) { return Field_bit::store(nr); }
3233-+ int store(const char *to, uint length, CHARSET_INFO *charset)
3234-+ {
3235-+ return store_truncated(to, length, charset, 0);
3236-+ }
3237-+ int store_truncated(const char *to, uint length, CHARSET_INFO *charset,
3238-+ bool *truncated);
3239-+ int store(double nr)
3240-+ {
3241-+ return store_truncated(nr, 0);
3242-+ }
3243-+ int store_truncated(double nr, bool *truncated)
3244-+ {
3245-+ return Field_bit::store_truncated(nr, truncated);
3246-+ }
3247- int store(longlong nr, bool unsigned_val)
3248+- int store(longlong nr, bool unsigned_val)
3249 - { return Field_bit::store(nr, unsigned_val); }
3250++ int store(const char *to, uint length, CHARSET_INFO *charset,
3251++ bool *truncated= NULL);
3252++ int store(double nr, bool *truncated= NULL)
3253 + {
3254-+ return store_truncated(nr, unsigned_val, 0);
3255++ return Field_bit::store(nr, truncated);
3256 + }
3257-+ int store_truncated(longlong nr, bool unsigned_val, bool *truncated)
3258++ int store(longlong nr, bool unsigned_val, bool *truncated= NULL)
3259 + {
3260-+ return Field_bit::store_truncated(nr, unsigned_val, truncated);
3261++ return Field_bit::store(nr, unsigned_val, truncated);
3262 + }
3263 void sql_type(String &str) const;
3264 };
3265
3266-@@ -2137,6 +2591,7 @@
3267+@@ -2137,6 +2213,7 @@
3268 uint from_length,to_length;
3269 Field *from_field,*to_field;
3270 String tmp; // For items

Subscribers

People subscribed via source and target branches