Skip to content

Commit

Permalink
MDEV-17830 Server crashes in Item_null_result::field_type upon SELECT…
Browse files Browse the repository at this point in the history
… with CHARSET(date) and ROLLUP
  • Loading branch information
abarkov committed Apr 17, 2019
1 parent 409dddf commit 0bb924e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mysql-test/r/olap.result
Original file line number Diff line number Diff line change
Expand Up @@ -786,5 +786,19 @@ t COUNT(*)
12:12:13 1
DROP TABLE t1;
#
# MDEV-17830 Server crashes in Item_null_result::field_type upon SELECT with CHARSET(date) and ROLLUP
#
# Note, returning "latin1" in the first row vs "binary" in the second row is wrong here.
# Both lines should return equal values.
# The point in this test is to make sure it does not crash.
# Bad result will be fixed in a later version.
CREATE TABLE t (d DATE) ENGINE=MyISAM;
INSERT INTO t VALUES ('2018-12-12');
SELECT CHARSET(d) AS f FROM t GROUP BY d WITH ROLLUP;
f
latin1
binary
DROP TABLE t;
#
# End of 10.1 tests
#
15 changes: 15 additions & 0 deletions mysql-test/t/olap.test
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,21 @@ SELECT t, COUNT(*) FROM t1 GROUP BY t WITH ROLLUP HAVING t > '00:00:00';
DROP TABLE t1;


--echo #
--echo # MDEV-17830 Server crashes in Item_null_result::field_type upon SELECT with CHARSET(date) and ROLLUP
--echo #

--echo # Note, returning "latin1" in the first row vs "binary" in the second row is wrong here.
--echo # Both lines should return equal values.
--echo # The point in this test is to make sure it does not crash.
--echo # Bad result will be fixed in a later version.

CREATE TABLE t (d DATE) ENGINE=MyISAM;
INSERT INTO t VALUES ('2018-12-12');
SELECT CHARSET(d) AS f FROM t GROUP BY d WITH ROLLUP;
DROP TABLE t;


--echo #
--echo # End of 10.1 tests
--echo #
10 changes: 10 additions & 0 deletions sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -2618,6 +2618,10 @@ class Item_null_result :public Item_null
{
return result_field->type();
}
CHARSET_INFO *charset_for_protocol(void) const
{
return collation.collation;
}
#else
const Type_handler *type_handler() const
{
Expand Down Expand Up @@ -3942,6 +3946,12 @@ class Item_ref :public Item_ident
void save_org_in_field(Field *field, fast_field_copier optimizer_data);
fast_field_copier setup_fast_field_copier(Field *field)
{ return (*ref)->setup_fast_field_copier(field); }
#if MARIADB_VERSION_ID < 100300
CHARSET_INFO *charset_for_protocol(void) const
{
return (*ref)->charset_for_protocol();
}
#endif
enum Item_result result_type () const { return (*ref)->result_type(); }
enum_field_types field_type() const { return (*ref)->field_type(); }
Field *get_tmp_table_field()
Expand Down

0 comments on commit 0bb924e

Please sign in to comment.