Commit 428f03c0 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-8839 COLUMN_GET() produces warnings with no data

parent e5418942
...@@ -346,5 +346,24 @@ t1 CREATE TABLE `t1` ( ...@@ -346,5 +346,24 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-8839 COLUMN_GET() produces warnings with no data
#
SET @aaa= COLUMN_CREATE('price', _binary 0xF0F1F2F3F4F5F6F7);
SELECT COLUMN_GET(@aaa, 'price' AS DECIMAL) aaa;
aaa
0
Warnings:
Warning 1918 Encountered illegal value '\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7' when converting to DECIMAL
SELECT COLUMN_GET(@aaa, 'price' AS INT) aaa;
aaa
0
Warnings:
Warning 1918 Encountered illegal value '\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7' when converting to INT
SELECT COLUMN_GET(@aaa, 'price' AS DOUBLE) aaa;
aaa
0
Warnings:
Warning 1918 Encountered illegal value '\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7' when converting to DOUBLE
#
# End of 10.1 tests # End of 10.1 tests
# #
...@@ -302,6 +302,15 @@ CREATE TABLE t1 (a DATETIME, b TIMESTAMP AS (TIMESTAMP(a)),c TIMESTAMP); ...@@ -302,6 +302,15 @@ CREATE TABLE t1 (a DATETIME, b TIMESTAMP AS (TIMESTAMP(a)),c TIMESTAMP);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-8839 COLUMN_GET() produces warnings with no data
--echo #
SET @aaa= COLUMN_CREATE('price', _binary 0xF0F1F2F3F4F5F6F7);
SELECT COLUMN_GET(@aaa, 'price' AS DECIMAL) aaa;
SELECT COLUMN_GET(@aaa, 'price' AS INT) aaa;
SELECT COLUMN_GET(@aaa, 'price' AS DOUBLE) aaa;
--echo # --echo #
--echo # End of 10.1 tests --echo # End of 10.1 tests
--echo # --echo #
...@@ -4963,13 +4963,12 @@ longlong Item_dyncol_get::val_int() ...@@ -4963,13 +4963,12 @@ longlong Item_dyncol_get::val_int()
if (end != org_end || error > 0) if (end != org_end || error > 0)
{ {
THD *thd= current_thd; THD *thd= current_thd;
char buff[80];
strmake(buff, val.x.string.value.str, MY_MIN(sizeof(buff)-1,
val.x.string.value.length));
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_BAD_DATA, ER_BAD_DATA,
ER_THD(thd, ER_BAD_DATA), ER_THD(thd, ER_BAD_DATA),
buff, ErrConvString(val.x.string.value.str,
val.x.string.value.length,
val.x.string.charset).ptr(),
unsigned_flag ? "UNSIGNED INT" : "INT"); unsigned_flag ? "UNSIGNED INT" : "INT");
} }
unsigned_flag= error >= 0; unsigned_flag= error >= 0;
...@@ -5028,13 +5027,13 @@ double Item_dyncol_get::val_real() ...@@ -5028,13 +5027,13 @@ double Item_dyncol_get::val_real()
error) error)
{ {
THD *thd= current_thd; THD *thd= current_thd;
char buff[80];
strmake(buff, val.x.string.value.str, MY_MIN(sizeof(buff)-1,
val.x.string.value.length));
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_BAD_DATA, ER_BAD_DATA,
ER_THD(thd, ER_BAD_DATA), ER_THD(thd, ER_BAD_DATA),
buff, "DOUBLE"); ErrConvString(val.x.string.value.str,
val.x.string.value.length,
val.x.string.charset).ptr(),
"DOUBLE");
} }
return res; return res;
} }
...@@ -5085,9 +5084,6 @@ my_decimal *Item_dyncol_get::val_decimal(my_decimal *decimal_value) ...@@ -5085,9 +5084,6 @@ my_decimal *Item_dyncol_get::val_decimal(my_decimal *decimal_value)
int rc; int rc;
rc= str2my_decimal(0, val.x.string.value.str, val.x.string.value.length, rc= str2my_decimal(0, val.x.string.value.str, val.x.string.value.length,
val.x.string.charset, decimal_value, &end); val.x.string.charset, decimal_value, &end);
char buff[80];
strmake(buff, val.x.string.value.str, MY_MIN(sizeof(buff)-1,
val.x.string.value.length));
if (rc != E_DEC_OK || if (rc != E_DEC_OK ||
end != val.x.string.value.str + val.x.string.value.length) end != val.x.string.value.str + val.x.string.value.length)
{ {
...@@ -5095,7 +5091,10 @@ my_decimal *Item_dyncol_get::val_decimal(my_decimal *decimal_value) ...@@ -5095,7 +5091,10 @@ my_decimal *Item_dyncol_get::val_decimal(my_decimal *decimal_value)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_BAD_DATA, ER_BAD_DATA,
ER_THD(thd, ER_BAD_DATA), ER_THD(thd, ER_BAD_DATA),
buff, "DECIMAL"); ErrConvString(val.x.string.value.str,
val.x.string.value.length,
val.x.string.charset).ptr(),
"DECIMAL");
} }
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment