From ac2b92c4760c7aa111d3f115f9af40fc657e18ed Mon Sep 17 00:00:00 2001 From: Vicentiu Ciorbaru Date: Tue, 28 Apr 2015 15:09:04 +0300 Subject: [PATCH 1/4] MDEV-7912 multitable delete with wrongly set sort_buffer_size crashes in merge_buffers Fixed overflow error that caused fewer bites to be allocated than necessary on Windows 64 bit. This is due to ulong being 32 bit on 64 bit Windows and 64 bit on 64 bit Linux. --- mysql-test/r/uniques_crash-7912.result | 18 ++++++++++++++++++ mysql-test/t/uniques_crash-7912.test | 18 ++++++++++++++++++ sql/uniques.cc | 15 +++++++++------ 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 mysql-test/r/uniques_crash-7912.result create mode 100644 mysql-test/t/uniques_crash-7912.test diff --git a/mysql-test/r/uniques_crash-7912.result b/mysql-test/r/uniques_crash-7912.result new file mode 100644 index 0000000000000..31029da5c8616 --- /dev/null +++ b/mysql-test/r/uniques_crash-7912.result @@ -0,0 +1,18 @@ +set sql_mode=""; +drop table if exists t1,t2; +Warnings: +Note 1051 Unknown table 't1' +Note 1051 Unknown table 't2' +create table `t1` (`a` datetime not null) engine=InnoDB; +create table `t2` (`a` int not null) engine=innodb; +replace into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +insert into t2 values(0); +set session sort_buffer_size = 1024*1024*1024*1024; +SET session debug_dbug= '+d,make_merge_buff_alloc_fail'; +delete d2 from t2 as d1, t1 as d2 where d1.a <=> d2.a; +ERROR HY000: Out of memory (Needed 2 bytes) +SET SESSION debug_dbug=DEFAULT; +drop table t2; +drop table t1; diff --git a/mysql-test/t/uniques_crash-7912.test b/mysql-test/t/uniques_crash-7912.test new file mode 100644 index 0000000000000..010855f7fb4ff --- /dev/null +++ b/mysql-test/t/uniques_crash-7912.test @@ -0,0 +1,18 @@ +# MDEV-7912 +# multitable delete with wrongly set sort_buffer_size crashes in merge_buffers +--source include/have_innodb.inc +set sql_mode=""; +drop table if exists t1,t2; +create table `t1` (`a` datetime not null) engine=InnoDB; +create table `t2` (`a` int not null) engine=innodb; + +replace into t1 values (),(); +insert into t2 values(0); +set session sort_buffer_size = 1024*1024*1024*1024; +SET session debug_dbug= '+d,make_merge_buff_alloc_fail'; +--error 5 #EE_OUTOFMEMORY +delete d2 from t2 as d1, t1 as d2 where d1.a <=> d2.a; +SET SESSION debug_dbug=DEFAULT; + +drop table t2; +drop table t1; \ No newline at end of file diff --git a/sql/uniques.cc b/sql/uniques.cc index 72411be5cd686..455fe20571737 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -97,7 +97,7 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg, max_elements= (ulong) (max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+size)); (void) open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, - MYF(MY_WME)); + MYF(MY_WME)); } @@ -607,8 +607,10 @@ bool Unique::walk(TABLE *table, tree_walk_action action, void *walk_action_arg) return 1; if (flush_io_cache(&file) || reinit_io_cache(&file, READ_CACHE, 0L, 0, 0)) return 1; - ulong buff_sz= (max_in_memory_size / full_size + 1) * full_size; - if (!(merge_buffer= (uchar *) my_malloc((ulong) buff_sz, MYF(0)))) + size_t buff_sz= (max_in_memory_size / full_size + 1) * full_size; + DBUG_EXECUTE_IF("make_merge_buff_alloc_fail", + DBUG_SET("+d,simulate_out_of_memory");); + if (!(merge_buffer = (uchar *)my_malloc(buff_sz, MYF(MY_WME)))) return 1; if (buff_sz < (ulong) (full_size * (file_ptrs.elements + 1))) res= merge(table, merge_buffer, buff_sz >= full_size * MERGEBUFF2) ; @@ -737,9 +739,10 @@ bool Unique::get(TABLE *table) /* Not enough memory; Save the result to file && free memory used by tree */ if (flush()) return 1; - - ulong buff_sz= (max_in_memory_size / full_size + 1) * full_size; - if (!(sort_buffer= (uchar*) my_malloc(buff_sz, MYF(0)))) + DBUG_EXECUTE_IF("make_merge_buff_alloc_fail", + DBUG_SET("+d,simulate_out_of_memory");); + size_t buff_sz= (max_in_memory_size / full_size + 1) * full_size; + if (!(sort_buffer= (uchar*) my_malloc(buff_sz, MYF(MY_WME)))) return 1; if (merge(table, sort_buffer, FALSE)) From 4c174fcb4aa0ad7173e0e19fb9c7f26e95903187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 28 Apr 2015 15:28:29 +0300 Subject: [PATCH 2/4] MDEV-8020: innodb.innodb-mdev-7055 produces valgrind warnings in buildbot Fixed by reverting incorrect fix of MDEC-7055 (reopened) and removing the test case (because it now crashes). --- .../suite/innodb/r/innodb-mdev-7055.result | 1 - .../suite/innodb/t/innodb-mdev-7055.test | 23 ------------------- storage/innobase/rem/rem0rec.c | 6 ++--- storage/xtradb/rem/rem0rec.c | 4 +--- 4 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 mysql-test/suite/innodb/r/innodb-mdev-7055.result delete mode 100644 mysql-test/suite/innodb/t/innodb-mdev-7055.test diff --git a/mysql-test/suite/innodb/r/innodb-mdev-7055.result b/mysql-test/suite/innodb/r/innodb-mdev-7055.result deleted file mode 100644 index d00491fd7e5bb..0000000000000 --- a/mysql-test/suite/innodb/r/innodb-mdev-7055.result +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/mysql-test/suite/innodb/t/innodb-mdev-7055.test b/mysql-test/suite/innodb/t/innodb-mdev-7055.test deleted file mode 100644 index 8f4d647e35d82..0000000000000 --- a/mysql-test/suite/innodb/t/innodb-mdev-7055.test +++ /dev/null @@ -1,23 +0,0 @@ --- source include/have_innodb.inc - -# MDEV-7055: MySQL#74664 - InnoDB: Failing assertion: len <= col->len -# || col->mtype == 5 || (col->len == 0 && col->mtype == 1) in -# file rem0rec.cc line 845 ---disable_query_log ---disable_warnings ---disable_result_log -set @old_character_set=@@character_set_connection; -set character_set_connection=ucs2; -create TABLE t1 engine=innodb select if(0=0,'Y','N'); -insert INTO t1 values(date_format('2001-01-01','%W')); -select * from t1; -drop table t1; -set @@character_set_connection=@old_character_set; ---enable_result_log ---enable_warnings ---enable_query_log - -#produce something ---echo 1 - - diff --git a/storage/innobase/rem/rem0rec.c b/storage/innobase/rem/rem0rec.c index 95f249bc70e99..f7252594c29f8 100644 --- a/storage/innobase/rem/rem0rec.c +++ b/storage/innobase/rem/rem0rec.c @@ -830,8 +830,7 @@ rec_get_converted_size_comp_prefix_low( } ut_ad(len <= col->len || col->mtype == DATA_BLOB - || col->mtype == DATA_VARMYSQL - || (col->len == 0 && col->mtype == DATA_VARCHAR)); + || (col->len == 0 && col->mtype == DATA_VARCHAR)); fixed_len = field->fixed_len; if (temp && fixed_len @@ -1258,8 +1257,7 @@ rec_convert_dtuple_to_rec_comp( *lens-- = (byte) len; } else { ut_ad(len <= dtype_get_len(type) - || dtype_get_mtype(type) == DATA_BLOB - || dtype_get_mtype(type) == DATA_VARMYSQL); + || dtype_get_mtype(type) == DATA_BLOB); if (len < 128 || (dtype_get_len(type) < 256 && dtype_get_mtype(type) != DATA_BLOB)) { diff --git a/storage/xtradb/rem/rem0rec.c b/storage/xtradb/rem/rem0rec.c index 95f249bc70e99..69d9e49e69356 100644 --- a/storage/xtradb/rem/rem0rec.c +++ b/storage/xtradb/rem/rem0rec.c @@ -830,7 +830,6 @@ rec_get_converted_size_comp_prefix_low( } ut_ad(len <= col->len || col->mtype == DATA_BLOB - || col->mtype == DATA_VARMYSQL || (col->len == 0 && col->mtype == DATA_VARCHAR)); fixed_len = field->fixed_len; @@ -1258,8 +1257,7 @@ rec_convert_dtuple_to_rec_comp( *lens-- = (byte) len; } else { ut_ad(len <= dtype_get_len(type) - || dtype_get_mtype(type) == DATA_BLOB - || dtype_get_mtype(type) == DATA_VARMYSQL); + || dtype_get_mtype(type) == DATA_BLOB); if (len < 128 || (dtype_get_len(type) < 256 && dtype_get_mtype(type) != DATA_BLOB)) { From a5fa434d0cec39b0db9f67ae2d6a824e2e53e39d Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 28 Apr 2015 15:31:49 +0500 Subject: [PATCH 3/4] MDEV-7779 View definition changes upon creation. Fixed by using POINT instead of ST_POINT in the item. Later need to fix that with proper ST_POINT implementation --- mysql-test/r/gis.result | 12 ++++++++++-- mysql-test/t/gis.test | 11 ++++++++++- sql/item_geofunc.h | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 700b5de44f56b..c2de65ee999cb 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -1,4 +1,5 @@ DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; +DROP VIEW IF EXISTS v1; CREATE TABLE gis_point (fid INTEGER NOT NULL PRIMARY KEY, g POINT); CREATE TABLE gis_line (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING); CREATE TABLE gis_polygon (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON); @@ -489,7 +490,7 @@ explain extended select issimple(MultiPoint(Point(3, 6), Point(4, 10))), issimpl id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select st_issimple(st_multipoint(st_point(3,6),st_point(4,10))) AS `issimple(MultiPoint(Point(3, 6), Point(4, 10)))`,st_issimple(st_point(3,6)) AS `issimple(Point(3, 6))` +Note 1003 select st_issimple(st_multipoint(point(3,6),point(4,10))) AS `issimple(MultiPoint(Point(3, 6), Point(4, 10)))`,st_issimple(point(3,6)) AS `issimple(Point(3, 6))` create table t1 (a geometry not null); insert into t1 values (GeomFromText('Point(1 2)')); insert into t1 values ('Garbage'); @@ -1610,4 +1611,11 @@ drop table t1; SELECT st_astext(ST_Buffer(ST_PolygonFromText('POLYGON((3 5, 2 4, 2 5, 3 5))'), -100)); st_astext(ST_Buffer(ST_PolygonFromText('POLYGON((3 5, 2 4, 2 5, 3 5))'), -100)) GEOMETRYCOLLECTION EMPTY -End of 5.5 tests +CREATE VIEW v1 AS SELECT POINT(1,1) AS p; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select point(1,1) AS `p` latin1 latin1_swedish_ci +SELECT ASTEXT(p) FROM v1; +ASTEXT(p) +POINT(1 1) +DROP VIEW v1; diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index bce1fa2c226b8..6e41660d598e0 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -7,6 +7,7 @@ --disable_warnings DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; +DROP VIEW IF EXISTS v1; --enable_warnings CREATE TABLE gis_point (fid INTEGER NOT NULL PRIMARY KEY, g POINT); @@ -1470,4 +1471,12 @@ drop table t1; # SELECT st_astext(ST_Buffer(ST_PolygonFromText('POLYGON((3 5, 2 4, 2 5, 3 5))'), -100)); ---echo End of 5.5 tests +# +# MDEV-7779 View definition changes upon creation +# +CREATE VIEW v1 AS SELECT POINT(1,1) AS p; +SHOW CREATE VIEW v1; +SELECT ASTEXT(p) FROM v1; +DROP VIEW v1; + +# --echo End of 5.5 tests diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index 2d715dc87650e..a2a61758617c8 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -116,7 +116,7 @@ class Item_func_point: public Item_geometry_func public: Item_func_point(Item *a, Item *b): Item_geometry_func(a, b) {} Item_func_point(Item *a, Item *b, Item *srid): Item_geometry_func(a, b, srid) {} - const char *func_name() const { return "st_point"; } + const char *func_name() const { return "point"; } String *val_str(String *); Field::geometry_type get_geometry_type() const; }; From a4477d297728c18cbd25f10d71ea946356e54bfd Mon Sep 17 00:00:00 2001 From: Vicentiu Ciorbaru Date: Wed, 29 Apr 2015 14:14:45 +0300 Subject: [PATCH 4/4] Fix failing test cases for MDEV-7912 patch --- mysql-test/r/uniques_crash-7912.result | 9 +-------- mysql-test/t/uniques_crash-7912.test | 18 +++++++++++++----- sql/uniques.cc | 4 ---- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/uniques_crash-7912.result b/mysql-test/r/uniques_crash-7912.result index 31029da5c8616..bf3aab684ae80 100644 --- a/mysql-test/r/uniques_crash-7912.result +++ b/mysql-test/r/uniques_crash-7912.result @@ -1,18 +1,11 @@ +call mtr.add_suppression("Out of memory"); set sql_mode=""; drop table if exists t1,t2; -Warnings: -Note 1051 Unknown table 't1' -Note 1051 Unknown table 't2' create table `t1` (`a` datetime not null) engine=InnoDB; create table `t2` (`a` int not null) engine=innodb; replace into t1 values (),(); -Warnings: -Warning 1364 Field 'a' doesn't have a default value insert into t2 values(0); set session sort_buffer_size = 1024*1024*1024*1024; -SET session debug_dbug= '+d,make_merge_buff_alloc_fail'; delete d2 from t2 as d1, t1 as d2 where d1.a <=> d2.a; -ERROR HY000: Out of memory (Needed 2 bytes) -SET SESSION debug_dbug=DEFAULT; drop table t2; drop table t1; diff --git a/mysql-test/t/uniques_crash-7912.test b/mysql-test/t/uniques_crash-7912.test index 010855f7fb4ff..8dc82f8f54041 100644 --- a/mysql-test/t/uniques_crash-7912.test +++ b/mysql-test/t/uniques_crash-7912.test @@ -1,18 +1,26 @@ +# # MDEV-7912 +# # multitable delete with wrongly set sort_buffer_size crashes in merge_buffers + --source include/have_innodb.inc +--source include/have_debug.inc +--source include/windows.inc + +call mtr.add_suppression("Out of memory"); + set sql_mode=""; +--disable_warnings drop table if exists t1,t2; create table `t1` (`a` datetime not null) engine=InnoDB; create table `t2` (`a` int not null) engine=innodb; - replace into t1 values (),(); insert into t2 values(0); set session sort_buffer_size = 1024*1024*1024*1024; -SET session debug_dbug= '+d,make_merge_buff_alloc_fail'; ---error 5 #EE_OUTOFMEMORY +#Either fail with EE_OUTOFMEMORY, or succeed +--error 0 , 5 delete d2 from t2 as d1, t1 as d2 where d1.a <=> d2.a; -SET SESSION debug_dbug=DEFAULT; +--enable_warnings drop table t2; -drop table t1; \ No newline at end of file +drop table t1; diff --git a/sql/uniques.cc b/sql/uniques.cc index 455fe20571737..fe3e329cda663 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -608,8 +608,6 @@ bool Unique::walk(TABLE *table, tree_walk_action action, void *walk_action_arg) if (flush_io_cache(&file) || reinit_io_cache(&file, READ_CACHE, 0L, 0, 0)) return 1; size_t buff_sz= (max_in_memory_size / full_size + 1) * full_size; - DBUG_EXECUTE_IF("make_merge_buff_alloc_fail", - DBUG_SET("+d,simulate_out_of_memory");); if (!(merge_buffer = (uchar *)my_malloc(buff_sz, MYF(MY_WME)))) return 1; if (buff_sz < (ulong) (full_size * (file_ptrs.elements + 1))) @@ -739,8 +737,6 @@ bool Unique::get(TABLE *table) /* Not enough memory; Save the result to file && free memory used by tree */ if (flush()) return 1; - DBUG_EXECUTE_IF("make_merge_buff_alloc_fail", - DBUG_SET("+d,simulate_out_of_memory");); size_t buff_sz= (max_in_memory_size / full_size + 1) * full_size; if (!(sort_buffer= (uchar*) my_malloc(buff_sz, MYF(MY_WME)))) return 1;