Skip to content

Commit 5e051bf

Browse files
author
Alexander Barkov
committed
MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
The patch b96c196 added a new call for safe_charset_converter() without a corresponding fix_fields(). In case of a sub-query the created Item remained in non-fixed state. The problem did not show up with literal derived expressions, only subselects were affected. This patch adds a corresponding fix_fields() to the previously added safe_charset_converter().
1 parent ef82fd8 commit 5e051bf

File tree

7 files changed

+67
-1
lines changed

7 files changed

+67
-1
lines changed

mysql-test/r/subselect.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7105,3 +7105,14 @@ group by round((select 1 from t1 limit 1));
71057105
round((select 1 from t1 limit 1))
71067106
1
71077107
drop table t1;
7108+
#
7109+
# MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
7110+
#
7111+
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
7112+
INSERT INTO t1 VALUES ('foo','bar');
7113+
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
7114+
f1 f2
7115+
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
7116+
f1 f2
7117+
foo bar
7118+
DROP TABLE t1;

mysql-test/r/subselect_no_mat.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7102,6 +7102,17 @@ group by round((select 1 from t1 limit 1));
71027102
round((select 1 from t1 limit 1))
71037103
1
71047104
drop table t1;
7105+
#
7106+
# MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
7107+
#
7108+
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
7109+
INSERT INTO t1 VALUES ('foo','bar');
7110+
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
7111+
f1 f2
7112+
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
7113+
f1 f2
7114+
foo bar
7115+
DROP TABLE t1;
71057116
set optimizer_switch=default;
71067117
select @@optimizer_switch like '%materialization=on%';
71077118
@@optimizer_switch like '%materialization=on%'

mysql-test/r/subselect_no_opts.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7100,4 +7100,15 @@ group by round((select 1 from t1 limit 1));
71007100
round((select 1 from t1 limit 1))
71017101
1
71027102
drop table t1;
7103+
#
7104+
# MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
7105+
#
7106+
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
7107+
INSERT INTO t1 VALUES ('foo','bar');
7108+
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
7109+
f1 f2
7110+
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
7111+
f1 f2
7112+
foo bar
7113+
DROP TABLE t1;
71037114
set @optimizer_switch_for_subselect_test=null;

mysql-test/r/subselect_no_scache.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7111,6 +7111,17 @@ group by round((select 1 from t1 limit 1));
71117111
round((select 1 from t1 limit 1))
71127112
1
71137113
drop table t1;
7114+
#
7115+
# MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
7116+
#
7117+
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
7118+
INSERT INTO t1 VALUES ('foo','bar');
7119+
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
7120+
f1 f2
7121+
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
7122+
f1 f2
7123+
foo bar
7124+
DROP TABLE t1;
71147125
set optimizer_switch=default;
71157126
select @@optimizer_switch like '%subquery_cache=on%';
71167127
@@optimizer_switch like '%subquery_cache=on%'

mysql-test/r/subselect_no_semijoin.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7100,5 +7100,16 @@ group by round((select 1 from t1 limit 1));
71007100
round((select 1 from t1 limit 1))
71017101
1
71027102
drop table t1;
7103+
#
7104+
# MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
7105+
#
7106+
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
7107+
INSERT INTO t1 VALUES ('foo','bar');
7108+
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
7109+
f1 f2
7110+
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
7111+
f1 f2
7112+
foo bar
7113+
DROP TABLE t1;
71037114
set @optimizer_switch_for_subselect_test=null;
71047115
set @join_cache_level_for_subselect_test=NULL;

mysql-test/t/subselect.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5988,3 +5988,13 @@ from t1
59885988
group by round((select 1 from t1 limit 1));
59895989

59905990
drop table t1;
5991+
5992+
--echo #
5993+
--echo # MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
5994+
--echo #
5995+
5996+
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
5997+
INSERT INTO t1 VALUES ('foo','bar');
5998+
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
5999+
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
6000+
DROP TABLE t1;

sql/item.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,8 @@ Item *Item_cache::safe_charset_converter(CHARSET_INFO *tocs)
11641164
if (conv == example)
11651165
return this;
11661166
Item_cache *cache;
1167-
if (!conv || !(cache= new Item_cache_str(conv)))
1167+
if (!conv || conv->fix_fields(current_thd, (Item **) NULL) ||
1168+
!(cache= new Item_cache_str(conv)))
11681169
return NULL; // Safe conversion is not possible, or OEM
11691170
cache->setup(conv);
11701171
cache->fixed= false; // Make Item::fix_fields() happy

0 commit comments

Comments
 (0)