summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-04-17 20:21:11 +0400
committerAlexander Barkov <bar@mariadb.com>2019-04-17 20:21:11 +0400
commit0bb924e18c338fa2dc901041aad09998b399efc1 (patch)
tree1d085472927f26a89d656a87d0ff3982958fa2de
parent409dddf6958736d65ee77aa9b469f8b807da3bb1 (diff)
downloadmariadb-git-0bb924e18c338fa2dc901041aad09998b399efc1.tar.gz
MDEV-17830 Server crashes in Item_null_result::field_type upon SELECT with CHARSET(date) and ROLLUP
-rw-r--r--mysql-test/r/olap.result14
-rw-r--r--mysql-test/t/olap.test15
-rw-r--r--sql/item.h10
3 files changed, 39 insertions, 0 deletions
diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result
index 24140583d13..84c54c0c3c7 100644
--- a/mysql-test/r/olap.result
+++ b/mysql-test/r/olap.result
@@ -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
#
diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test
index 4a61cebdc0d..bb7806969d3 100644
--- a/mysql-test/t/olap.test
+++ b/mysql-test/t/olap.test
@@ -425,5 +425,20 @@ 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 #
diff --git a/sql/item.h b/sql/item.h
index 75ebcdb624c..4b93d3f9164 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2618,6 +2618,10 @@ public:
{
return result_field->type();
}
+ CHARSET_INFO *charset_for_protocol(void) const
+ {
+ return collation.collation;
+ }
#else
const Type_handler *type_handler() const
{
@@ -3942,6 +3946,12 @@ public:
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()