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

Subscribers

People subscribed via source and target branches