Commit 4c2c5ec9 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-14434 Wrong result for CHARSET(CONCAT(?,const))

parent 0d1e805a
...@@ -4992,3 +4992,40 @@ ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NE ...@@ -4992,3 +4992,40 @@ ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NE
EXECUTE IMMEDIATE 'CALL p1(?)' USING IGNORE; EXECUTE IMMEDIATE 'CALL p1(?)' USING IGNORE;
ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
DROP PROCEDURE p1; DROP PROCEDURE p1;
#
# MDEV-14434 Wrong result for CHARSET(CONCAT(?,const))
#
SET NAMES utf8;
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(5,_latin1'a'))";
CHARSET(CONCAT(5,_latin1'a'))
latin1
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING 5;
CHARSET(CONCAT(?,_latin1'a'))
latin1
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING 5.5;
CHARSET(CONCAT(?,_latin1'a'))
latin1
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING 5.5e0;
CHARSET(CONCAT(?,_latin1'a'))
latin1
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING TIME'10:20:30';
CHARSET(CONCAT(?,_latin1'a'))
latin1
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING TIMESTAMP'2001-01-01 10:20:30';
CHARSET(CONCAT(?,_latin1'a'))
latin1
EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING 5;
COERCIBILITY(?)
5
EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING 5.5;
COERCIBILITY(?)
5
EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING 5.5e0;
COERCIBILITY(?)
5
EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING TIME'10:20:30';
COERCIBILITY(?)
5
EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING TIMESTAMP'2001-01-01 10:20:30';
COERCIBILITY(?)
5
...@@ -4476,3 +4476,22 @@ EXECUTE IMMEDIATE 'CALL p1(?)' USING DEFAULT; ...@@ -4476,3 +4476,22 @@ EXECUTE IMMEDIATE 'CALL p1(?)' USING DEFAULT;
--error ER_SP_NOT_VAR_ARG --error ER_SP_NOT_VAR_ARG
EXECUTE IMMEDIATE 'CALL p1(?)' USING IGNORE; EXECUTE IMMEDIATE 'CALL p1(?)' USING IGNORE;
DROP PROCEDURE p1; DROP PROCEDURE p1;
--echo #
--echo # MDEV-14434 Wrong result for CHARSET(CONCAT(?,const))
--echo #
SET NAMES utf8;
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(5,_latin1'a'))";
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING 5;
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING 5.5;
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING 5.5e0;
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING TIME'10:20:30';
EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING TIMESTAMP'2001-01-01 10:20:30';
EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING 5;
EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING 5.5;
EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING 5.5e0;
EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING TIME'10:20:30';
EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING TIMESTAMP'2001-01-01 10:20:30';
...@@ -3409,6 +3409,7 @@ void Item_param::set_int(longlong i, uint32 max_length_arg) ...@@ -3409,6 +3409,7 @@ void Item_param::set_int(longlong i, uint32 max_length_arg)
DBUG_ENTER("Item_param::set_int"); DBUG_ENTER("Item_param::set_int");
value.integer= (longlong) i; value.integer= (longlong) i;
state= INT_VALUE; state= INT_VALUE;
collation.set_numeric();
max_length= max_length_arg; max_length= max_length_arg;
decimals= 0; decimals= 0;
maybe_null= 0; maybe_null= 0;
...@@ -3421,6 +3422,7 @@ void Item_param::set_double(double d) ...@@ -3421,6 +3422,7 @@ void Item_param::set_double(double d)
DBUG_ENTER("Item_param::set_double"); DBUG_ENTER("Item_param::set_double");
value.real= d; value.real= d;
state= REAL_VALUE; state= REAL_VALUE;
collation.set_numeric();
max_length= DBL_DIG + 8; max_length= DBL_DIG + 8;
decimals= NOT_FIXED_DEC; decimals= NOT_FIXED_DEC;
maybe_null= 0; maybe_null= 0;
...@@ -3450,6 +3452,7 @@ void Item_param::set_decimal(const char *str, ulong length) ...@@ -3450,6 +3452,7 @@ void Item_param::set_decimal(const char *str, ulong length)
str2my_decimal(E_DEC_FATAL_ERROR, str, &decimal_value, &end); str2my_decimal(E_DEC_FATAL_ERROR, str, &decimal_value, &end);
state= DECIMAL_VALUE; state= DECIMAL_VALUE;
decimals= decimal_value.frac; decimals= decimal_value.frac;
collation.set_numeric();
max_length= max_length=
my_decimal_precision_to_length_no_truncation(decimal_value.precision(), my_decimal_precision_to_length_no_truncation(decimal_value.precision(),
decimals, unsigned_flag); decimals, unsigned_flag);
...@@ -3465,6 +3468,7 @@ void Item_param::set_decimal(const my_decimal *dv, bool unsigned_arg) ...@@ -3465,6 +3468,7 @@ void Item_param::set_decimal(const my_decimal *dv, bool unsigned_arg)
my_decimal2decimal(dv, &decimal_value); my_decimal2decimal(dv, &decimal_value);
decimals= (uint8) decimal_value.frac; decimals= (uint8) decimal_value.frac;
collation.set_numeric();
unsigned_flag= unsigned_arg; unsigned_flag= unsigned_arg;
max_length= my_decimal_precision_to_length(decimal_value.intg + decimals, max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
decimals, unsigned_flag); decimals, unsigned_flag);
...@@ -3475,6 +3479,7 @@ void Item_param::set_decimal(const my_decimal *dv, bool unsigned_arg) ...@@ -3475,6 +3479,7 @@ void Item_param::set_decimal(const my_decimal *dv, bool unsigned_arg)
void Item_param::fix_temporal(uint32 max_length_arg, uint decimals_arg) void Item_param::fix_temporal(uint32 max_length_arg, uint decimals_arg)
{ {
state= TIME_VALUE; state= TIME_VALUE;
collation.set_numeric();
max_length= max_length_arg; max_length= max_length_arg;
decimals= decimals_arg; decimals= decimals_arg;
fix_type(Item::DATE_ITEM); fix_type(Item::DATE_ITEM);
......
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