summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/main/func_sformat.result13
-rw-r--r--mysql-test/main/func_sformat.test15
-rw-r--r--sql/item_strfunc.cc10
3 files changed, 33 insertions, 5 deletions
diff --git a/mysql-test/main/func_sformat.result b/mysql-test/main/func_sformat.result
index d6b30ac6f36..b3a494d48a7 100644
--- a/mysql-test/main/func_sformat.result
+++ b/mysql-test/main/func_sformat.result
@@ -437,6 +437,7 @@ t1 CREATE TABLE `t1` (
`x` varchar(8) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+set names latin1;
#
# ps parameters
#
@@ -455,3 +456,15 @@ Warning 4183 SFORMAT error: invalid type specifier
select sformat('{}', cast(1.1 as float));
sformat('{}', cast(1.1 as float))
1.1
+#
+# MDEV-26646 SFORMAT Does not allow @variable use
+#
+set names utf8;
+set @a=3.14;
+select sformat('{:f}', @a);
+sformat('{:f}', @a)
+3.140000
+set names latin1;
+#
+# End of 10.7 tests
+#
diff --git a/mysql-test/main/func_sformat.test b/mysql-test/main/func_sformat.test
index 36b755acae5..7c850fc2644 100644
--- a/mysql-test/main/func_sformat.test
+++ b/mysql-test/main/func_sformat.test
@@ -199,7 +199,7 @@ select hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442'));
create table t1 as select sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442') as x;
show create table t1;
drop table t1;
-
+set names latin1;
echo #;
echo # ps parameters;
@@ -213,3 +213,16 @@ echo # MDEV-26691 SFORMAT: Pass down FLOAT as FLOAT, without upcast to DOUBLE;
echo #;
select sformat('{}', cast(1.1 as float));
+
+echo #;
+echo # MDEV-26646 SFORMAT Does not allow @variable use;
+echo #;
+
+set names utf8;
+set @a=3.14;
+select sformat('{:f}', @a);
+set names latin1;
+
+echo #;
+echo # End of 10.7 tests;
+echo #;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index a9decdbdf04..1a210f79ce5 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1336,12 +1336,14 @@ bool Item_func_sformat::fix_length_and_dec()
if (c.collation->mbminlen > 1)
c.collation= &my_charset_utf8mb4_bin;
- if (Type_std_attributes::agg_item_set_converter(c, func_name_cstring(), args,
- arg_count, flags, 1))
- return TRUE;
-
for (uint i=0 ; i < arg_count ; i++)
+ {
char_length+= args[i]->max_char_length();
+ if (args[i]->result_type() == STRING_RESULT &&
+ Type_std_attributes::agg_item_set_converter(c, func_name_cstring(),
+ args+i, 1, flags, 1))
+ return TRUE;
+ }
fix_char_length_ulonglong(char_length);
return FALSE;