File tree Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -5762,5 +5762,20 @@ DROP TABLE t1;
5762
5762
# End of ctype_utf8_ilseq.inc
5763
5763
#
5764
5764
#
5765
+ # MDEV-8067 correct fix for MySQL Bug # 19699237: UNINITIALIZED VARIABLE IN ITEM_FIELD::STR_RESULT
5766
+ #
5767
+ CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8);
5768
+ CREATE TABLE t2 (a VARCHAR(10) CHARACTER SET latin1);
5769
+ INSERT INTO t1 VALUES ('aaa');
5770
+ INSERT INTO t2 VALUES ('aaa');
5771
+ SELECT (SELECT CONCAT(a),1 FROM t1) <=> (SELECT CONCAT(a),1 FROM t2);
5772
+ (SELECT CONCAT(a),1 FROM t1) <=> (SELECT CONCAT(a),1 FROM t2)
5773
+ 1
5774
+ INSERT INTO t1 VALUES ('aaa');
5775
+ INSERT INTO t2 VALUES ('aaa');
5776
+ SELECT (SELECT CONCAT(a),1 FROM t1) <=> (SELECT CONCAT(a),1 FROM t2);
5777
+ ERROR 21000: Subquery returns more than 1 row
5778
+ DROP TABLE t1, t2;
5779
+ #
5765
5780
# End of 5.5 tests
5766
5781
#
Original file line number Diff line number Diff line change @@ -1616,6 +1616,22 @@ SET NAMES utf8 COLLATE utf8_general_ci;
1616
1616
--let ENGINE=HEAP
1617
1617
--source include/ctype_utf8_ilseq.inc
1618
1618
1619
+ --echo #
1620
+ --echo # MDEV-8067 correct fix for MySQL Bug # 19699237: UNINITIALIZED VARIABLE IN ITEM_FIELD::STR_RESULT
1621
+ --echo #
1622
+ CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8);
1623
+ CREATE TABLE t2 (a VARCHAR(10) CHARACTER SET latin1);
1624
+ INSERT INTO t1 VALUES ('aaa');
1625
+ INSERT INTO t2 VALUES ('aaa');
1626
+ SELECT (SELECT CONCAT(a),1 FROM t1) <=> (SELECT CONCAT(a),1 FROM t2);
1627
+ INSERT INTO t1 VALUES ('aaa');
1628
+ INSERT INTO t2 VALUES ('aaa');
1629
+ # Running the below query crashed with two rows
1630
+ --error ER_SUBQUERY_NO_1_ROW
1631
+ SELECT (SELECT CONCAT(a),1 FROM t1) <=> (SELECT CONCAT(a),1 FROM t2);
1632
+ DROP TABLE t1, t2;
1633
+
1634
+
1619
1635
--echo #
1620
1636
--echo # End of 5.5 tests
1621
1637
--echo #
Original file line number Diff line number Diff line change @@ -1135,6 +1135,36 @@ Item *Item::safe_charset_converter(CHARSET_INFO *tocs)
1135
1135
}
1136
1136
1137
1137
1138
+ /* *
1139
+ Some pieces of the code do not support changing of
1140
+ Item_cache to other Item types.
1141
+
1142
+ Example:
1143
+ Item_singlerow_subselect has "Item_cache **row".
1144
+ Creating of Item_func_conv_charset followed by THD::change_item_tree()
1145
+ should not change row[i] from Item_cache directly to Item_func_conv_charset, because Item_singlerow_subselect
1146
+ because Item_singlerow_subselect later calls Item_cache-specific methods,
1147
+ e.g. row[i]->store() and row[i]->cache_value().
1148
+
1149
+ Let's wrap Item_func_conv_charset to a new Item_cache,
1150
+ so the Item_cache-specific methods can still be used for
1151
+ Item_singlerow_subselect::row[i] safely.
1152
+
1153
+ TODO: we should eventually check all other use cases of change_item_tree().
1154
+ Perhaps some more potentially dangerous substitution examples exist.
1155
+ */
1156
+ Item *Item_cache::safe_charset_converter (CHARSET_INFO *tocs)
1157
+ {
1158
+ Item_func_conv_charset *conv= new Item_func_conv_charset (example, tocs, 1 );
1159
+ Item_cache *cache;
1160
+ if (!conv || !conv->safe || !(cache= new Item_cache_str (conv)))
1161
+ return NULL ; // Safe conversion is not possible, or OEM
1162
+ cache->setup (conv);
1163
+ cache->fixed = false ; // Make Item::fix_fields() happy
1164
+ return cache;
1165
+ }
1166
+
1167
+
1138
1168
/* *
1139
1169
@details
1140
1170
Created mostly for mysql_prepare_table(). Important
Original file line number Diff line number Diff line change @@ -4161,6 +4161,7 @@ class Item_cache: public Item_basic_constant
4161
4161
return TRUE ;
4162
4162
return (this ->*processor)(arg);
4163
4163
}
4164
+ virtual Item *safe_charset_converter (CHARSET_INFO *tocs);
4164
4165
};
4165
4166
4166
4167
You can’t perform that action at this time.
0 commit comments