From 7afbf338aaf425d41c2e27044b32ea94aecceb42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 4 Feb 2015 09:29:54 +0200 Subject: [PATCH 01/18] MDEV-7513: ib_warn_row_too_big dereferences null thd Analysis: Purge thread does not have thd and no access to handlerton. Fix: If thd does not exists we use sql_print_warning instead of push_warning_printf. --- .../suite/innodb/r/innodb-mdev-7513.result | 204 +++++++++++++++++ .../suite/innodb/t/innodb-mdev-7513.test | 214 ++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 28 ++- 3 files changed, 438 insertions(+), 8 deletions(-) create mode 100644 mysql-test/suite/innodb/r/innodb-mdev-7513.result create mode 100644 mysql-test/suite/innodb/t/innodb-mdev-7513.test diff --git a/mysql-test/suite/innodb/r/innodb-mdev-7513.result b/mysql-test/suite/innodb/r/innodb-mdev-7513.result new file mode 100644 index 00000000000..bb3531e3f90 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-mdev-7513.result @@ -0,0 +1,204 @@ +call mtr.add_suppression("Row size too large (> 8126)*"); +CREATE TABLE t1 ( text1 TEXT, +text2 TEXT, +text3 TEXT, +text4 TEXT, +text5 TEXT, +text6 TEXT, +text7 TEXT, +text8 TEXT, +text9 TEXT, +text10 TEXT, +text11 TEXT, +text12 TEXT, +text13 TEXT, +text14 TEXT, +text15 TEXT, +text16 TEXT, +text17 TEXT, +text18 TEXT, +text19 TEXT, +text20 TEXT, +text21 TEXT, +text22 TEXT, +text23 TEXT, +text24 TEXT, +text25 TEXT, +text26 TEXT, +text27 TEXT, +text28 TEXT, +text29 TEXT, +text30 TEXT, +text31 TEXT, +text32 TEXT, +text33 TEXT, +text34 TEXT, +text35 TEXT, +text36 TEXT, +text37 TEXT, +text38 TEXT, +text39 TEXT, +text40 TEXT, +text41 TEXT, +text42 TEXT, +text43 TEXT, +text44 TEXT, +text45 TEXT, +text46 TEXT, +text47 TEXT, +text48 TEXT, +text49 TEXT, +text50 TEXT, +text51 TEXT, +text52 TEXT, +text53 TEXT, +text54 TEXT, +text55 TEXT, +text56 TEXT, +text57 TEXT, +text58 TEXT, +text59 TEXT, +text60 TEXT, +text61 TEXT, +text62 TEXT, +text63 TEXT, +text64 TEXT, +text65 TEXT, +text66 TEXT, +text67 TEXT, +text68 TEXT, +text69 TEXT, +text70 TEXT, +text71 TEXT, +text72 TEXT, +text73 TEXT, +text74 TEXT, +text75 TEXT, +text76 TEXT, +text77 TEXT, +text78 TEXT, +text79 TEXT, +text80 TEXT, +text81 TEXT, +text82 TEXT, +text83 TEXT, +text84 TEXT, +text85 TEXT, +text86 TEXT, +text87 TEXT, +text88 TEXT, +text89 TEXT, +text90 TEXT, +text91 TEXT, +text92 TEXT, +text93 TEXT, +text94 TEXT, +text95 TEXT, +text96 TEXT, +text97 TEXT, +text98 TEXT, +text99 TEXT, +text100 TEXT, +text101 TEXT, +text102 TEXT, +text103 TEXT, +text104 TEXT, +text105 TEXT, +text106 TEXT, +text107 TEXT, +text108 TEXT, +text109 TEXT, +text110 TEXT, +text111 TEXT, +text112 TEXT, +text113 TEXT, +text114 TEXT, +text115 TEXT, +text116 TEXT, +text117 TEXT, +text118 TEXT, +text119 TEXT, +text120 TEXT, +text121 TEXT, +text122 TEXT, +text123 TEXT, +text124 TEXT, +text125 TEXT, +text126 TEXT, +text127 TEXT, +text128 TEXT, +text129 TEXT, +text130 TEXT, +text131 TEXT, +text132 TEXT, +text133 TEXT, +text134 TEXT, +text135 TEXT, +text136 TEXT, +text137 TEXT, +text138 TEXT, +text139 TEXT, +text140 TEXT, +text141 TEXT, +text142 TEXT, +text143 TEXT, +text144 TEXT, +text145 TEXT, +text146 TEXT, +text147 TEXT, +text148 TEXT, +text149 TEXT, +text150 TEXT, +text151 TEXT, +text152 TEXT, +text153 TEXT, +text154 TEXT, +text155 TEXT, +text156 TEXT, +text157 TEXT, +text158 TEXT, +text159 TEXT, +text160 TEXT, +text161 TEXT, +text162 TEXT, +text163 TEXT, +text164 TEXT, +text165 TEXT, +text166 TEXT, +text167 TEXT, +text168 TEXT, +text169 TEXT, +text170 TEXT, +text171 TEXT, +text172 TEXT, +text173 TEXT, +text174 TEXT, +text175 TEXT, +text176 TEXT, +text177 TEXT, +text178 TEXT, +text179 TEXT, +text180 TEXT, +text181 TEXT, +text182 TEXT, +text183 TEXT, +text184 TEXT, +text185 TEXT, +text186 TEXT, +text187 TEXT, +text188 TEXT, +text189 TEXT, +text190 TEXT, +text191 TEXT, +text192 TEXT, +text193 TEXT, +text194 TEXT, +text195 TEXT, +text196 TEXT, +text197 TEXT +) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef'); +DELETE FROM t1 WHERE text1 = 'abcdef'; +SELECT * from t1; +text1 text2 text3 text4 text5 text6 text7 text8 text9 text10 text11 text12 text13 text14 text15 text16 text17 text18 text19 text20 text21 text22 text23 text24 text25 text26 text27 text28 text29 text30 text31 text32 text33 text34 text35 text36 text37 text38 text39 text40 text41 text42 text43 text44 text45 text46 text47 text48 text49 text50 text51 text52 text53 text54 text55 text56 text57 text58 text59 text60 text61 text62 text63 text64 text65 text66 text67 text68 text69 text70 text71 text72 text73 text74 text75 text76 text77 text78 text79 text80 text81 text82 text83 text84 text85 text86 text87 text88 text89 text90 text91 text92 text93 text94 text95 text96 text97 text98 text99 text100 text101 text102 text103 text104 text105 text106 text107 text108 text109 text110 text111 text112 text113 text114 text115 text116 text117 text118 text119 text120 text121 text122 text123 text124 text125 text126 text127 text128 text129 text130 text131 text132 text133 text134 text135 text136 text137 text138 text139 text140 text141 text142 text143 text144 text145 text146 text147 text148 text149 text150 text151 text152 text153 text154 text155 text156 text157 text158 text159 text160 text161 text162 text163 text164 text165 text166 text167 text168 text169 text170 text171 text172 text173 text174 text175 text176 text177 text178 text179 text180 text181 text182 text183 text184 text185 text186 text187 text188 text189 text190 text191 text192 text193 text194 text195 text196 text197 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-mdev-7513.test b/mysql-test/suite/innodb/t/innodb-mdev-7513.test new file mode 100644 index 00000000000..54948adcbd4 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-mdev-7513.test @@ -0,0 +1,214 @@ +-- source include/have_innodb.inc +-- source include/not_embedded.inc + +call mtr.add_suppression("Row size too large (> 8126)*"); + +CREATE TABLE t1 ( text1 TEXT, +text2 TEXT, +text3 TEXT, +text4 TEXT, +text5 TEXT, +text6 TEXT, +text7 TEXT, +text8 TEXT, +text9 TEXT, +text10 TEXT, +text11 TEXT, +text12 TEXT, +text13 TEXT, +text14 TEXT, +text15 TEXT, +text16 TEXT, +text17 TEXT, +text18 TEXT, +text19 TEXT, +text20 TEXT, +text21 TEXT, +text22 TEXT, +text23 TEXT, +text24 TEXT, +text25 TEXT, +text26 TEXT, +text27 TEXT, +text28 TEXT, +text29 TEXT, +text30 TEXT, +text31 TEXT, +text32 TEXT, +text33 TEXT, +text34 TEXT, +text35 TEXT, +text36 TEXT, +text37 TEXT, +text38 TEXT, +text39 TEXT, +text40 TEXT, +text41 TEXT, +text42 TEXT, +text43 TEXT, +text44 TEXT, +text45 TEXT, +text46 TEXT, +text47 TEXT, +text48 TEXT, +text49 TEXT, +text50 TEXT, +text51 TEXT, +text52 TEXT, +text53 TEXT, +text54 TEXT, +text55 TEXT, +text56 TEXT, +text57 TEXT, +text58 TEXT, +text59 TEXT, +text60 TEXT, +text61 TEXT, +text62 TEXT, +text63 TEXT, +text64 TEXT, +text65 TEXT, +text66 TEXT, +text67 TEXT, +text68 TEXT, +text69 TEXT, +text70 TEXT, +text71 TEXT, +text72 TEXT, +text73 TEXT, +text74 TEXT, +text75 TEXT, +text76 TEXT, +text77 TEXT, +text78 TEXT, +text79 TEXT, +text80 TEXT, +text81 TEXT, +text82 TEXT, +text83 TEXT, +text84 TEXT, +text85 TEXT, +text86 TEXT, +text87 TEXT, +text88 TEXT, +text89 TEXT, +text90 TEXT, +text91 TEXT, +text92 TEXT, +text93 TEXT, +text94 TEXT, +text95 TEXT, +text96 TEXT, +text97 TEXT, +text98 TEXT, +text99 TEXT, +text100 TEXT, +text101 TEXT, +text102 TEXT, +text103 TEXT, +text104 TEXT, +text105 TEXT, +text106 TEXT, +text107 TEXT, +text108 TEXT, +text109 TEXT, +text110 TEXT, +text111 TEXT, +text112 TEXT, +text113 TEXT, +text114 TEXT, +text115 TEXT, +text116 TEXT, +text117 TEXT, +text118 TEXT, +text119 TEXT, +text120 TEXT, +text121 TEXT, +text122 TEXT, +text123 TEXT, +text124 TEXT, +text125 TEXT, +text126 TEXT, +text127 TEXT, +text128 TEXT, +text129 TEXT, +text130 TEXT, +text131 TEXT, +text132 TEXT, +text133 TEXT, +text134 TEXT, +text135 TEXT, +text136 TEXT, +text137 TEXT, +text138 TEXT, +text139 TEXT, +text140 TEXT, +text141 TEXT, +text142 TEXT, +text143 TEXT, +text144 TEXT, +text145 TEXT, +text146 TEXT, +text147 TEXT, +text148 TEXT, +text149 TEXT, +text150 TEXT, +text151 TEXT, +text152 TEXT, +text153 TEXT, +text154 TEXT, +text155 TEXT, +text156 TEXT, +text157 TEXT, +text158 TEXT, +text159 TEXT, +text160 TEXT, +text161 TEXT, +text162 TEXT, +text163 TEXT, +text164 TEXT, +text165 TEXT, +text166 TEXT, +text167 TEXT, +text168 TEXT, +text169 TEXT, +text170 TEXT, +text171 TEXT, +text172 TEXT, +text173 TEXT, +text174 TEXT, +text175 TEXT, +text176 TEXT, +text177 TEXT, +text178 TEXT, +text179 TEXT, +text180 TEXT, +text181 TEXT, +text182 TEXT, +text183 TEXT, +text184 TEXT, +text185 TEXT, +text186 TEXT, +text187 TEXT, +text188 TEXT, +text189 TEXT, +text190 TEXT, +text191 TEXT, +text192 TEXT, +text193 TEXT, +text194 TEXT, +text195 TEXT, +text196 TEXT, +text197 TEXT +) ENGINE = InnoDB; + +INSERT INTO t1 VALUES ('abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef'); + +DELETE FROM t1 WHERE text1 = 'abcdef'; + +--source include/restart_mysqld.inc + +SELECT * from t1; + +DROP TABLE t1; + diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index d58eb0689a2..af455f488a3 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -12273,12 +12273,24 @@ ib_warn_row_too_big(const dict_table_t* table) THD* thd = current_thd; - push_warning_printf( - thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_ERR_TO_BIG_ROW, - "Row size too large (> %lu). Changing some columns to TEXT" - " or BLOB %smay help. In current row format, BLOB prefix of" - " %d bytes is stored inline.", free_space - , prefix ? "or using ROW_FORMAT=DYNAMIC or" - " ROW_FORMAT=COMPRESSED ": "" - , prefix ? DICT_MAX_FIXED_COL_LEN : 0); + if (thd) { + push_warning_printf( + thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_ERR_TO_BIG_ROW, + "Row size too large (> %lu). Changing some columns to TEXT" + " or BLOB %smay help. In current row format, BLOB prefix of" + " %d bytes is stored inline.", free_space + , prefix ? "or using ROW_FORMAT=DYNAMIC or" + " ROW_FORMAT=COMPRESSED ": "" + , prefix ? DICT_MAX_FIXED_COL_LEN : 0); + } else { + /* Note that we can't use push_warning_printf here because + e.g. purge thread has no thd */ + sql_print_warning( + "Row size too large (> %lu). Changing some columns to TEXT" + " or BLOB %smay help. In current row format, BLOB prefix of" + " %d bytes is stored inline.", free_space + , prefix ? "or using ROW_FORMAT=DYNAMIC or" + " ROW_FORMAT=COMPRESSED ": "" + , prefix ? DICT_MAX_FIXED_COL_LEN : 0); + } } From f32091532da365db85d5441ddff212995e15aa9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 4 Feb 2015 10:50:16 +0200 Subject: [PATCH 02/18] 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 Debug assertion maybe too strict. --- mysql-test/suite/innodb/r/innodb-mdev-7055.result | Bin 0 -> 326 bytes mysql-test/suite/innodb/t/innodb-mdev-7055.test | 9 +++++++++ storage/innobase/rem/rem0rec.c | 6 ++++-- storage/xtradb/rem/rem0rec.c | 6 ++++-- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 mysql-test/suite/innodb/r/innodb-mdev-7055.result create 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 new file mode 100644 index 0000000000000000000000000000000000000000..9e02163baade185c32fda0e1c2629d771fd568f8 GIT binary patch literal 326 zcmZ9GPfNo<5XHTAKgC>RQ>l;y^k4`QO%8&z(pE}OVY`{sg=AKCC;IgriwYLzFn`|r z&8yd|7pSXk^-ygZV2oU-$8}R}oAd4K-#sFOeKWyW#?Z>tT2F+Qou_iLF)x%2Xc$4T z&qB=r>F5YcN94N$L>xp7u20f3UFf}D=%t<)%2C9?@U+~nzD*xym@p=tklNmd(Qu;k zG|jG0C8o=ro{Mc~0y#RyyWeh><+nGp+OPo*6IlUtAOx^}m_`D9_F02r2>uf?^%Lz1 a`rt~ literal 0 HcmV?d00001 diff --git a/mysql-test/suite/innodb/t/innodb-mdev-7055.test b/mysql-test/suite/innodb/t/innodb-mdev-7055.test new file mode 100644 index 00000000000..2e19dd74108 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-mdev-7055.test @@ -0,0 +1,9 @@ +-- 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 +DROP DATABASE test;CREATE DATABASE test;USE test; +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; \ No newline at end of file diff --git a/storage/innobase/rem/rem0rec.c b/storage/innobase/rem/rem0rec.c index d938aa696dd..95f249bc70e 100644 --- a/storage/innobase/rem/rem0rec.c +++ b/storage/innobase/rem/rem0rec.c @@ -830,7 +830,8 @@ rec_get_converted_size_comp_prefix_low( } ut_ad(len <= col->len || col->mtype == DATA_BLOB - || (col->len == 0 && col->mtype == DATA_VARCHAR)); + || col->mtype == DATA_VARMYSQL + || (col->len == 0 && col->mtype == DATA_VARCHAR)); fixed_len = field->fixed_len; if (temp && fixed_len @@ -1257,7 +1258,8 @@ 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_BLOB + || dtype_get_mtype(type) == DATA_VARMYSQL); 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 d938aa696dd..95f249bc70e 100644 --- a/storage/xtradb/rem/rem0rec.c +++ b/storage/xtradb/rem/rem0rec.c @@ -830,7 +830,8 @@ rec_get_converted_size_comp_prefix_low( } ut_ad(len <= col->len || col->mtype == DATA_BLOB - || (col->len == 0 && col->mtype == DATA_VARCHAR)); + || col->mtype == DATA_VARMYSQL + || (col->len == 0 && col->mtype == DATA_VARCHAR)); fixed_len = field->fixed_len; if (temp && fixed_len @@ -1257,7 +1258,8 @@ 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_BLOB + || dtype_get_mtype(type) == DATA_VARMYSQL); if (len < 128 || (dtype_get_len(type) < 256 && dtype_get_mtype(type) != DATA_BLOB)) { From 422ffe99b53336b907311dcfa507998ffb6a2df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 4 Feb 2015 11:12:46 +0200 Subject: [PATCH 03/18] InnoDB and XtraDB produce different output on MDEV-7513. --- mysql-test/suite/innodb/r/innodb-mdev-7513,xtradb.rdiff | 3 +++ mysql-test/suite/innodb/r/innodb-mdev-7513.result | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 mysql-test/suite/innodb/r/innodb-mdev-7513,xtradb.rdiff diff --git a/mysql-test/suite/innodb/r/innodb-mdev-7513,xtradb.rdiff b/mysql-test/suite/innodb/r/innodb-mdev-7513,xtradb.rdiff new file mode 100644 index 00000000000..1038ba9c116 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-mdev-7513,xtradb.rdiff @@ -0,0 +1,3 @@ +200,201d199 +< Warnings: +< Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline. diff --git a/mysql-test/suite/innodb/r/innodb-mdev-7513.result b/mysql-test/suite/innodb/r/innodb-mdev-7513.result index bb3531e3f90..904d0ed3fcf 100644 --- a/mysql-test/suite/innodb/r/innodb-mdev-7513.result +++ b/mysql-test/suite/innodb/r/innodb-mdev-7513.result @@ -197,6 +197,8 @@ text195 TEXT, text196 TEXT, text197 TEXT ) ENGINE = InnoDB; +Warnings: +Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline. INSERT INTO t1 VALUES ('abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef'); DELETE FROM t1 WHERE text1 = 'abcdef'; SELECT * from t1; From 8cc97511652603930eef074eaacb0ca088cb34d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 4 Feb 2015 14:40:46 +0200 Subject: [PATCH 04/18] MDEV-7538: Wrong constraint (TINYINT or MEDIUMINT and INT) causes server crash Analysis: If wrong data types used on foreign constraint there was possibility that foreign->id is NULL when incorrect foreign constraint was removed from the dictionary cache. Fix: Add guard foreign->id != NULL before trying to lookup or remove the foreign constraint from dictionary cache. Tested using user database where problem was repeatable. --- storage/innobase/dict/dict0dict.c | 4 ++-- storage/xtradb/dict/dict0dict.c | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index c298f867ae3..9a99a03b70e 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -2530,7 +2530,7 @@ dict_foreign_remove_from_cache( rbt = foreign->referenced_table->referenced_rbt; - if (rbt != NULL) { + if (rbt != NULL && foreign->id != NULL) { const ib_rbt_node_t* node = rbt_lookup(rbt, foreign->id); dict_foreign_t* val = *(dict_foreign_t**) node->value; @@ -2549,7 +2549,7 @@ dict_foreign_remove_from_cache( foreign); rbt = foreign->foreign_table->foreign_rbt; - if (rbt != NULL) { + if (rbt != NULL && foreign->id != NULL) { const ib_rbt_node_t* node = rbt_lookup(rbt, foreign->id); dict_foreign_t* val = *(dict_foreign_t**) node->value; diff --git a/storage/xtradb/dict/dict0dict.c b/storage/xtradb/dict/dict0dict.c index cf246bcdd5f..efb180d6e90 100644 --- a/storage/xtradb/dict/dict0dict.c +++ b/storage/xtradb/dict/dict0dict.c @@ -2650,8 +2650,14 @@ dict_foreign_remove_from_cache( foreign); rbt = foreign->referenced_table->referenced_rbt; - if (rbt != NULL) { - rbt_delete(rbt, foreign->id); + if (rbt != NULL && foreign->id != NULL) { + const ib_rbt_node_t* node + = rbt_lookup(rbt, foreign->id); + dict_foreign_t* val = *(dict_foreign_t**) node->value; + + if (val == foreign) { + rbt_delete(rbt, foreign->id); + } } } @@ -2663,8 +2669,14 @@ dict_foreign_remove_from_cache( foreign); rbt = foreign->foreign_table->foreign_rbt; - if (rbt != NULL) { - rbt_delete(rbt, foreign->id); + if (rbt != NULL && foreign->id != NULL) { + const ib_rbt_node_t* node + = rbt_lookup(rbt, foreign->id); + dict_foreign_t* val = *(dict_foreign_t**) node->value; + + if (val == foreign) { + rbt_delete(rbt, foreign->id); + } } } From 5c6eb5222ec12fe38095b2e69d1b4732b04e3a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 4 Feb 2015 16:50:29 +0200 Subject: [PATCH 05/18] Fix test failure. --- .../suite/innodb/r/innodb-mdev-7055.result | Bin 326 -> 325 bytes mysql-test/suite/innodb/t/innodb-mdev-7055.test | 11 ++++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-mdev-7055.result b/mysql-test/suite/innodb/r/innodb-mdev-7055.result index 9e02163baade185c32fda0e1c2629d771fd568f8..67a30ba783fb80eaff1e64f3ce3a2dcdf438d01b 100644 GIT binary patch delta 58 zcmX@cbd<@kIJHEbP=pZx3ziXM diff --git a/mysql-test/suite/innodb/t/innodb-mdev-7055.test b/mysql-test/suite/innodb/t/innodb-mdev-7055.test index 2e19dd74108..d68be46c35a 100644 --- a/mysql-test/suite/innodb/t/innodb-mdev-7055.test +++ b/mysql-test/suite/innodb/t/innodb-mdev-7055.test @@ -1,9 +1,14 @@ -- 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 -DROP DATABASE test;CREATE DATABASE test;USE test; +# 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 +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; \ No newline at end of file +drop table t1; +--disable_query_log +set @@character_set_connection=@old_character_set; + From b9d616c243972afb7bb5169d5136ed451ab7cd31 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Fri, 6 Feb 2015 15:49:45 +0400 Subject: [PATCH 06/18] MDEV-7435 Windows debug: Run-Time Check Failure #3 - The variable 'unused' is being used without being initialized. Fixed as it's done in 10.0. --- sql-common/client_plugin.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql-common/client_plugin.c b/sql-common/client_plugin.c index d96f9648011..f31ddb22a6a 100644 --- a/sql-common/client_plugin.c +++ b/sql-common/client_plugin.c @@ -28,6 +28,11 @@ There is no reference counting and no unloading either. */ +#if _MSC_VER +/* Silence warnings about variable 'unused' being used. */ +#define FORCE_INIT_OF_VARS 1 +#endif + #include #include "mysql.h" #include From 0d73bc1c25d12b89153ece12a42bf030679a4add Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Sun, 8 Feb 2015 15:47:00 +0300 Subject: [PATCH 07/18] MDEV-7519 debian / ubuntu packaging creation of plugin table (if not exists) Previously IF NOT EXISTS was added in Debian version in revno 3543. Now added the same for Ubuntu. --- debian/dist/Ubuntu/mariadb-server-5.5.postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/dist/Ubuntu/mariadb-server-5.5.postinst b/debian/dist/Ubuntu/mariadb-server-5.5.postinst index 1c7aa37f69f..920868e22e6 100644 --- a/debian/dist/Ubuntu/mariadb-server-5.5.postinst +++ b/debian/dist/Ubuntu/mariadb-server-5.5.postinst @@ -213,7 +213,7 @@ EOF # admin might already have chosen to remove one or more plugins. Newlines are necessary. install_plugins=`/bin/echo -e \ "USE mysql;\n" \ - "CREATE TABLE plugin (name char(64) COLLATE utf8_bin NOT NULL DEFAULT '', " \ + "CREATE TABLE IF NOT EXISTS plugin (name char(64) COLLATE utf8_bin NOT NULL DEFAULT '', " \ " dl char(128) COLLATE utf8_bin NOT NULL DEFAULT '', " \ " PRIMARY KEY (name)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='MySQL plugins';" ` From 919f40e464e4f6d0f6368b1065b43aaebaf7b681 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Sun, 8 Feb 2015 22:38:19 +0400 Subject: [PATCH 08/18] Audit plugin v1.2.0. --- .../suite/plugins/r/server_audit.result | 136 ++++- mysql-test/suite/plugins/t/server_audit.test | 40 +- plugin/server_audit/server_audit.c | 563 +++++++++++++++++- 3 files changed, 703 insertions(+), 36 deletions(-) diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result index 8843fc8b3e9..d91a4f424fe 100644 --- a/mysql-test/suite/plugins/r/server_audit.result +++ b/mysql-test/suite/plugins/r/server_audit.result @@ -85,6 +85,66 @@ create table sa_t1(id int); insert into sa_t1 values (1), (2); drop table sa_t1; drop database sa_db; +create database sa_db; +use sa_db; +CREATE USER u1 IDENTIFIED BY 'pwd-123'; +GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; +SET PASSWORD FOR u1 = PASSWORD('pwd 098'); +CREATE USER u3 IDENTIFIED BY ''; +drop user u1, u2, u3; +set global server_audit_events='query_ddl'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +id +1 +2 +select 2; +2 +2 +(select 2); +2 +2 +/*! select 2*/; +2 +2 +/*comment*/ select 2; +2 +2 +drop table t1; +set global server_audit_events='query_ddl,query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +id +1 +2 +select 2; +2 +2 +drop table t1; +set global server_audit_events='query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +id +1 +2 +select 2; +2 +2 +(select 2); +2 +2 +/*! select 2*/; +2 +2 +/*comment*/ select 2; +2 +2 +drop table t1; +set global server_audit_events=''; +drop database sa_db; set global server_audit_file_path='.'; show status like 'server_audit_current_log'; Variable_name Value @@ -176,19 +236,65 @@ TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proc, TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event, TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0 TIME,HOSTNAME,root,localhost,ID,0,DISCONNECT,sa_db,,0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_file_path=\'.\'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_file_path=\'.\'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'show status like \'server_audit_current_log\'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_file_path=\'\'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_file_path=\'\'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'show status like \'server_audit_current_log\'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_file_path=\' \'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_file_path=\' \'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'show status like \'server_audit_current_log\'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_file_path=\'nonexisting_dir/\'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_file_path=\'nonexisting_dir/\'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'SHOW WARNINGS',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'show status like \'server_audit_current_log\'',0 -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'show variables like \'server_audit%\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'create database sa_db',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'use sa_db',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,db, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,tables_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,columns_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,procs_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proxies_priv, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'CREATE USER u1 IDENTIFIED BY *****',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,tables_priv, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'GRANT ALL ON sa_db TO u2 IDENTIFIED BY *****',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SET PASSWORD FOR u1 = PASSWORD(*****)',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,db, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,tables_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,columns_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,procs_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proxies_priv, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'CREATE USER u3 IDENTIFIED BY *****',0 +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,user, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,db, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,tables_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,columns_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,procs_priv, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proxies_priv, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop user u1, u2, u3',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'create table t1(id int)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop table t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'create table t1(id int)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'insert into t1 values (1), (2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select * from t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select 2',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop table t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'insert into t1 values (1), (2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select * from t1',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select 2',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'(select 2)',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'/*! select 2*/',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'/*comment*/ select 2',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_events=\'\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,READ,mysql,proc, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proc, +TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event, +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\' \'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\' \'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'nonexisting_dir/\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'nonexisting_dir/\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SHOW WARNINGS',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show variables like \'server_audit%\'',0 TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,plugin, -TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'uninstall plugin server_audit',0 +TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'uninstall plugin server_audit',0 diff --git a/mysql-test/suite/plugins/t/server_audit.test b/mysql-test/suite/plugins/t/server_audit.test index f63c8022392..f59a68e3148 100644 --- a/mysql-test/suite/plugins/t/server_audit.test +++ b/mysql-test/suite/plugins/t/server_audit.test @@ -15,6 +15,7 @@ connect (con1,localhost,root,,mysql); connection default; disconnect con1; --sleep 2 +--sleep 2 --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect (con1,localhost,no_such_user,,mysql); @@ -45,6 +46,8 @@ set global server_audit_events=''; create database sa_db; connect (con1,localhost,root,,test); connection con1; +--sleep 2 +--sleep 2 create table t1 (id2 int); insert into t1 values (1), (2); select * from t1; @@ -56,8 +59,43 @@ drop table sa_t1; drop database sa_db; connection default; disconnect con1; - --sleep 2 +--sleep 2 +create database sa_db; +use sa_db; +CREATE USER u1 IDENTIFIED BY 'pwd-123'; +GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; +SET PASSWORD FOR u1 = PASSWORD('pwd 098'); +CREATE USER u3 IDENTIFIED BY ''; +drop user u1, u2, u3; + +set global server_audit_events='query_ddl'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; +set global server_audit_events='query_ddl,query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +drop table t1; +set global server_audit_events='query_dml'; +create table t1(id int); +insert into t1 values (1), (2); +select * from t1; +select 2; +(select 2); +/*! select 2*/; +/*comment*/ select 2; +drop table t1; +set global server_audit_events=''; +drop database sa_db; + set global server_audit_file_path='.'; --replace_regex /\.[\\\/]/HOME_DIR\// show status like 'server_audit_current_log'; diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index 5c19b366347..491a98e44dd 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -14,11 +14,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define PLUGIN_VERSION 0x101 -#define PLUGIN_STR_VERSION "1.1.7" +#define PLUGIN_VERSION 0x102 +#define PLUGIN_STR_VERSION "1.2.0" #include - #include #include #include @@ -142,6 +141,10 @@ static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)), #define flogger_mutex_lock(A) pthread_mutex_lock(&(A)->m_mutex) #define flogger_mutex_unlock(A) pthread_mutex_unlock(&(A)->m_mutex) +static char **int_mysql_data_home; +static char *default_home= (char *)"."; +#define mysql_data_home (*int_mysql_data_home) + #include "../../mysys/file_logger.c" #endif /*!MARIADB_ONLY*/ @@ -165,6 +168,7 @@ static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)), extern char server_version[]; static const char *serv_ver= NULL; static int started_mysql= 0; +static int started_mariadb= 0; static int maria_above_5= 0; static char *incl_users, *excl_users, *file_path, *syslog_info; @@ -222,11 +226,15 @@ static MYSQL_SYSVAR_STR(excl_users, excl_users, PLUGIN_VAR_RQCMDARG, NULL, update_excl_users, NULL); /* bits in the event filter. */ #define EVENT_CONNECT 1 -#define EVENT_QUERY 2 +#define EVENT_QUERY_ALL 2 +#define EVENT_QUERY 26 #define EVENT_TABLE 4 +#define EVENT_QUERY_DDL 8 +#define EVENT_QUERY_DML 16 + static const char *event_names[]= { - "CONNECT", "QUERY", "TABLE", + "CONNECT", "QUERY", "TABLE", "QUERY_DDL", "QUERY_DML", NULL }; static TYPELIB events_typelib= @@ -234,7 +242,7 @@ static TYPELIB events_typelib= array_elements(event_names) - 1, "", event_names, NULL }; static MYSQL_SYSVAR_SET(events, events, PLUGIN_VAR_RQCMDARG, - "Specifies the set of events to monitor. Can be CONNECT, QUERY, TABLE.", + "Specifies the set of events to monitor. Can be CONNECT, QUERY, TABLE, QUERY_DDL, QUERY_DML.", NULL, NULL, 0, &events_typelib); #define OUTPUT_SYSLOG 0 #define OUTPUT_FILE 1 @@ -526,6 +534,103 @@ static int user_hash_fill(HASH *h, char *users, } +enum sa_keywords +{ + SQLCOM_NOTHING=0, + SQLCOM_DDL, + SQLCOM_DML, + SQLCOM_GRANT, + SQLCOM_CREATE_USER, + SQLCOM_CHANGE_MASTER, + SQLCOM_CREATE_SERVER, + SQLCOM_SET_OPTION, + SQLCOM_ALTER_SERVER, + SQLCOM_TRUNCATE, + SQLCOM_QUERY_ADMIN, + SQLCOM_DCL, +}; + +struct sa_keyword +{ + int length; + const char *wd; + struct sa_keyword *next; + enum sa_keywords type; +}; + + +struct sa_keyword xml_word= {3, "XML", 0, SQLCOM_NOTHING}; +struct sa_keyword user_word= {4, "USER", 0, SQLCOM_NOTHING}; +struct sa_keyword data_word= {4, "DATA", 0, SQLCOM_NOTHING}; +struct sa_keyword server_word= {6, "SERVER", 0, SQLCOM_NOTHING}; +struct sa_keyword master_word= {6, "MASTER", 0, SQLCOM_NOTHING}; +struct sa_keyword password_word= {8, "PASSWORD", 0, SQLCOM_NOTHING}; +struct sa_keyword function_word= {8, "FUNCTION", 0, SQLCOM_NOTHING}; +struct sa_keyword statement_word= {9, "STATEMENT", 0, SQLCOM_NOTHING}; +struct sa_keyword procedure_word= {9, "PROCEDURE", 0, SQLCOM_NOTHING}; + + +struct sa_keyword keywords_to_skip[]= +{ + {3, "SET", &statement_word, SQLCOM_QUERY_ADMIN}, + {0, NULL, 0, SQLCOM_DDL} +}; + + +struct sa_keyword not_ddl_keywords[]= +{ + {4, "DROP", &function_word, SQLCOM_QUERY_ADMIN}, + {4, "DROP", &procedure_word, SQLCOM_QUERY_ADMIN}, + {4, "DROP", &user_word, SQLCOM_DCL}, + {6, "CREATE", &user_word, SQLCOM_DCL}, + {6, "CREATE", &function_word, SQLCOM_QUERY_ADMIN}, + {6, "CREATE", &procedure_word, SQLCOM_QUERY_ADMIN}, + {6, "RENAME", &user_word, SQLCOM_DCL}, + {0, NULL, 0, SQLCOM_DDL} +}; + + +struct sa_keyword ddl_keywords[]= +{ + {4, "DROP", 0, SQLCOM_DDL}, + {5, "ALTER", 0, SQLCOM_DDL}, + {6, "CREATE", 0, SQLCOM_DDL}, + {6, "RENAME", 0, SQLCOM_DDL}, + {8, "TRUNCATE", 0, SQLCOM_DDL}, + {0, NULL, 0, SQLCOM_DDL} +}; + + +struct sa_keyword dml_keywords[]= +{ + {2, "DO", 0, SQLCOM_DML}, + {4, "CALL", 0, SQLCOM_DML}, + {4, "LOAD", &data_word, SQLCOM_DML}, + {4, "LOAD", &xml_word, SQLCOM_DML}, + {6, "DELETE", 0, SQLCOM_DML}, + {6, "INSERT", 0, SQLCOM_DML}, + {6, "SELECT", 0, SQLCOM_DML}, + {6, "UPDATE", 0, SQLCOM_DML}, + {7, "HANDLER", 0, SQLCOM_DML}, + {7, "REPLACE", 0, SQLCOM_DML}, + {0, NULL, 0, SQLCOM_DML} +}; + + +struct sa_keyword passwd_keywords[]= +{ + {3, "SET", &password_word, SQLCOM_SET_OPTION}, + {5, "ALTER", &server_word, SQLCOM_ALTER_SERVER}, + {5, "GRANT", 0, SQLCOM_GRANT}, + {6, "CREATE", &user_word, SQLCOM_CREATE_USER}, + {6, "CREATE", &server_word, SQLCOM_CREATE_SERVER}, + {6, "CHANGE", &master_word, SQLCOM_CHANGE_MASTER}, + {0, NULL, 0, SQLCOM_NOTHING} +}; + +#define MAX_KEYWORD 9 + + static void error_header() { struct tm tm_time; @@ -563,6 +668,7 @@ struct connection_info int log_always; }; + static HASH connection_hash; @@ -773,6 +879,21 @@ static struct connection_info * #define SAFE_STRLEN(s) (s ? strlen(s) : 0) +static int is_space(char c) +{ + return c == ' ' || c == '\r' || c == '\n' || c == '\t'; +} + + +#define SKIP_SPACES(str) \ +do { \ + while (is_space(*str)) \ + ++str; \ +} while(0) + + + + static struct connection_info * add_connection_initdb(const struct mysql_event_general *event) { @@ -980,6 +1101,98 @@ static size_t escape_string(const char *str, unsigned int len, } +static size_t escape_string_hide_passwords(const char *str, unsigned int len, + char *result, size_t result_len, + const char *word1, size_t word1_len, + const char *word2, size_t word2_len, + int next_text_string) +{ + const char *res_start= result; + const char *res_end= result + result_len - 2; + size_t d_len; + char b_char; + + while (len) + { + if (len > word1_len + 1 && strncasecmp(str, word1, word1_len) == 0) + { + const char *next_s= str + word1_len; + size_t c; + + if (next_text_string) + { + while (*next_s && *next_s != '\'' && *next_s != '"') + ++next_s; + } + else + { + if (word2) + { + SKIP_SPACES(next_s); + if (len < (next_s - str) + word2_len + 1 || + strncasecmp(next_s, word2, word2_len) != 0) + goto no_password; + next_s+= word2_len; + } + + while (*next_s && *next_s != '\'' && *next_s != '"') + ++next_s; + } + + d_len= next_s - str; + if (result + d_len + 5 > res_end) + break; + + for (c=0; c= res_end) + break; + if (*str == '\'') + { + *(result++)= '\\'; + *(result++)= '\''; + } + else if (*str == '\\') + { + *(result++)= '\\'; + *(result++)= '\\'; + } + else if (is_space(*str)) + *(result++)= ' '; + else + *(result++)= *str; + str++; + len--; + } + *result= 0; + return result - res_start; +} + + + static int do_log_user(const char *name) { size_t len; @@ -998,6 +1211,96 @@ static int do_log_user(const char *name) } +static int get_next_word(const char *query, char *word) +{ + int len= 0; + char c; + while ((c= query[len])) + { + if (c >= 'a' && c <= 'z') + word[len]= 'A' + (c-'a'); + else if (c >= 'A' && c <= 'Z') + word[len]= c; + else + break; + + if (len++ == MAX_KEYWORD) + return 0; + } + word[len]= 0; + return len; +} + + +static int filter_query_type(const char *query, struct sa_keyword *kwd) +{ + int qwe_in_list; + char fword[MAX_KEYWORD + 1], nword[MAX_KEYWORD + 1]; + int len, nlen= 0; + const struct sa_keyword *l_keywords; + + while (*query && (is_space(*query) || *query == '(' || *query == '/')) + { + /* comment handling */ + if (*query == '/' && query[1] == '*') + { + if (query[2] == '!') + { + query+= 3; + while (*query >= '0' && *query <= '9') + query++; + continue; + } + query+= 2; + while (*query) + { + if (*query=='*' && query[1] == '/') + { + query+= 2; + break; + } + query++; + } + continue; + } + query++; + } + + qwe_in_list= 0; + if (!(len= get_next_word(query, fword))) + goto not_in_list; + query+= len+1; + + l_keywords= kwd; + while (l_keywords->length) + { + if (l_keywords->length == len && strncmp(l_keywords->wd, fword, len) == 0) + { + if (l_keywords->next) + { + if (nlen == 0) + { + while (*query && is_space(*query)) + query++; + nlen= get_next_word(query, nword); + } + if (l_keywords->next->length != nlen || + strncmp(l_keywords->next->wd, nword, nlen) != 0) + goto do_loop; + } + + qwe_in_list= l_keywords->type; + break; + }; +do_loop: + l_keywords++; + } + +not_in_list: + return qwe_in_list; +} + + static int log_statement_ex(const struct connection_info *cn, time_t ev_time, unsigned long thd_id, const char *query, unsigned int query_len, @@ -1034,10 +1337,77 @@ static int log_statement_ex(const struct connection_info *cn, /* Can happen after the error in mysqld_prepare_stmt() */ query= cn->query; query_len= cn->query_length; + if (query == 0 || query_len == 0) + return 0; } - esc_q_len= escape_string(query, query_len, - uh_buffer, sizeof(uh_buffer)); + if (query && !(events & EVENT_QUERY_ALL) && + (events & EVENT_QUERY)) + { + const char *orig_query= query; + + if (filter_query_type(query, keywords_to_skip)) + { + char fword[MAX_KEYWORD + 1]; + int len; + do + { + len= get_next_word(query, fword); + query+= len ? len : 1; + if (len == 3 && strncmp(fword, "FOR", 3) == 0) + break; + } while (*query); + + if (*query == 0) + return 0; + } + + if (events & EVENT_QUERY_DDL) + { + if (!filter_query_type(query, not_ddl_keywords) && + filter_query_type(query, ddl_keywords)) + goto do_log_query; + } + if (events & EVENT_QUERY_DML) + { + if (filter_query_type(query, dml_keywords)) + goto do_log_query; + } + + return 0; +do_log_query: + query= orig_query; + } + + switch (filter_query_type(query, passwd_keywords)) + { + case SQLCOM_GRANT: + case SQLCOM_CREATE_USER: + esc_q_len= escape_string_hide_passwords(query, query_len, + uh_buffer, sizeof(uh_buffer), + "IDENTIFIED", 10, "BY", 2, 0); + break; + case SQLCOM_CHANGE_MASTER: + esc_q_len= escape_string_hide_passwords(query, query_len, + uh_buffer, sizeof(uh_buffer), + "MASTER_PASSWORD", 15, "=", 1, 0); + break; + case SQLCOM_CREATE_SERVER: + case SQLCOM_ALTER_SERVER: + esc_q_len= escape_string_hide_passwords(query, query_len, + uh_buffer, sizeof(uh_buffer), + "PASSWORD", 8, NULL, 0, 0); + break; + case SQLCOM_SET_OPTION: + esc_q_len= escape_string_hide_passwords(query, query_len, + uh_buffer, sizeof(uh_buffer), + "=", 1, NULL, 0, 1); + break; + default: + esc_q_len= escape_string(query, query_len, + uh_buffer, sizeof(uh_buffer)); + break; + } csize+= my_snprintf(message+csize, sizeof(message) - 1 - csize, ",\'%.*s\',%d", esc_q_len, uh_buffer, error_code); message[csize]= '\n'; @@ -1386,6 +1756,105 @@ exit_func: } +#ifdef DBUG_OFF + #ifdef __x86_64__ +static const int cmd_off= 4200; +static const int db_off= 120; +static const int db_len_off= 128; + #else +static const int cmd_off= 2668; +static const int db_off= 60; +static const int db_len_off= 64; + #endif /*x86_64*/ +#else + #ifdef __x86_64__ +static const int cmd_off= 4432; +static const int db_off= 120; +static const int db_len_off= 128; + #else +static const int cmd_off= 2808; +static const int db_off= 64; +static const int db_len_off= 68; + #endif /*x86_64*/ +#endif /*DBUG_OFF*/ + +struct mysql_event_general_v8 +{ + unsigned int event_class; + unsigned int event_subclass; + int general_error_code; + unsigned long general_thread_id; + const char *general_user; + unsigned int general_user_length; + const char *general_command; + unsigned int general_command_length; + const char *general_query; + unsigned int general_query_length; + struct charset_info_st *general_charset; + unsigned long long general_time; + unsigned long long general_rows; +}; + +static void auditing_v8(MYSQL_THD thd, struct mysql_event_general_v8 *ev_v8) +{ + struct mysql_event_general event; + + if (ev_v8->event_class != MYSQL_AUDIT_GENERAL_CLASS) + return; + + event.event_subclass= ev_v8->event_subclass; + event.general_error_code= ev_v8->general_error_code; + event.general_thread_id= ev_v8->general_thread_id; + event.general_user= ev_v8->general_user; + event.general_user_length= ev_v8->general_user_length; + event.general_command= ev_v8->general_command; + event.general_command_length= ev_v8->general_command_length; + event.general_query= ev_v8->general_query; + event.general_query_length= ev_v8->general_query_length; + event.general_charset= ev_v8->general_charset; + event.general_time= ev_v8->general_time; + event.general_rows= ev_v8->general_rows; + event.database= 0; + event.database_length= 0; + + if (event.general_query_length > 0) + { + event.event_subclass= MYSQL_AUDIT_GENERAL_STATUS; + event.general_command= "Query"; + event.general_command_length= 5; +#ifdef __linux__ + event.database= *(char **) (((char *) thd) + db_off); + event.database_length= *(size_t *) (((char *) thd) + db_len_off); +#endif /*__linux*/ + } +#ifdef __linux__ + else if (*((int *) (((char *)thd) + cmd_off)) == 2) + { + event.event_subclass= MYSQL_AUDIT_GENERAL_LOG; + event.general_command= "Init DB"; + event.general_command_length= 7; + event.general_query= *(char **) (((char *) thd) + db_off); + event.general_query_length= *(size_t *) (((char *) thd) + db_len_off); + } +#endif /*__linux*/ + auditing(thd, ev_v8->event_class, &event); +} + + +static void auditing_v13(MYSQL_THD thd, unsigned int *ev_v0) +{ + struct mysql_event_general event= *(const struct mysql_event_general *) (ev_v0+1); + + if (event.general_query_length > 0) + { + event.event_subclass= MYSQL_AUDIT_GENERAL_STATUS; + event.general_command= "Query"; + event.general_command_length= 5; + } + auditing(thd, ev_v0[0], &event); +} + + /* As it's just too difficult to #include "sql_class.h", let's just copy the necessary part of the system_variables @@ -1461,15 +1930,19 @@ typedef struct loc_system_variables ulong query_cache_type; } LOC_SV; + static int server_audit_init(void *p __attribute__((unused))) { const void *my_hash_init_ptr; -#ifdef _WIN32 - serv_ver= (const char *) GetProcAddress(0, "server_version"); -#else - serv_ver= server_version; -#endif /*_WIN32*/ + if (!serv_ver) + { +#ifdef _WIN32 + serv_ver= (const char *) GetProcAddress(0, "server_version"); +#else + serv_ver= server_version; +#endif /*_WIN32*/ + } my_hash_init_ptr= dlsym(RTLD_DEFAULT, "_my_hash_init"); if (!my_hash_init_ptr) { @@ -1477,8 +1950,14 @@ static int server_audit_init(void *p __attribute__((unused))) my_hash_init_ptr= dlsym(RTLD_DEFAULT, "my_hash_init2"); } + if(!(int_mysql_data_home= dlsym(RTLD_DEFAULT, "mysql_data_home"))) + { + if(!(int_mysql_data_home= dlsym(RTLD_DEFAULT, "?mysql_data_home@@3PADA"))) + int_mysql_data_home= &default_home; + } + if (!serv_ver || !my_hash_init_ptr) - return 0; + return 1; if (!started_mysql) { @@ -1489,7 +1968,6 @@ static int server_audit_init(void *p __attribute__((unused))) } } - if (gethostname(servhost, sizeof(servhost))) strcpy(servhost, "unknown"); @@ -1608,8 +2086,8 @@ mysql_declare_plugin(server_audit) MYSQL_AUDIT_PLUGIN, &mysql_descriptor, "SERVER_AUDIT", - " Alexey Botchkov (MariaDB)", - "Audit the server activity.", + " Alexey Botchkov (MariaDB Corporation)", + "Audit the server activity", PLUGIN_LICENSE_GPL, server_audit_init_mysql, server_audit_deinit, @@ -1636,8 +2114,8 @@ maria_declare_plugin(server_audit) MYSQL_AUDIT_PLUGIN, &maria_descriptor, "SERVER_AUDIT", - "Alexey Botchkov (MariaDB)", - "Audit the server activity.", + "Alexey Botchkov (MariaDB Corporation)", + "Audit the server activity", PLUGIN_LICENSE_GPL, server_audit_init, server_audit_deinit, @@ -1645,7 +2123,7 @@ maria_declare_plugin(server_audit) audit_status, vars, PLUGIN_STR_VERSION, - MariaDB_PLUGIN_MATURITY_BETA + MariaDB_PLUGIN_MATURITY_GAMMA } maria_declare_plugin_end; @@ -1915,3 +2393,48 @@ static void update_syslog_ident(MYSQL_THD thd __attribute__((unused)), } +#ifdef _WIN32 +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + if (fdwReason != DLL_PROCESS_ATTACH) + return 1; + + serv_ver= (const char *) GetProcAddress(0, "server_version"); +#else +void __attribute__ ((constructor)) audit_plugin_so_init(void) +{ + serv_ver= server_version; +#endif /*_WIN32*/ + + if (!serv_ver) + goto exit; + + started_mariadb= strstr(serv_ver, "MariaDB") != 0; + + if (!started_mariadb) + { + if (serv_ver[0] == '5' && serv_ver[2] == '5') + { + int sc= serv_ver[4] - '0'; + if (serv_ver[5] >= '0' && serv_ver[5] <= '9') + sc= sc * 10 + serv_ver[5] - '0'; + if (sc <= 10) + { + mysql_descriptor.interface_version= 0x0200; + mysql_descriptor.event_notify= (void *) auditing_v8; + } + else if (sc < 14) + { + mysql_descriptor.interface_version= 0x0200; + mysql_descriptor.event_notify= (void *) auditing_v13; + } + } + } +exit: +#ifdef _WIN32 + return 1; +#else + return; +#endif +} + From 44a9e3f7b4c908dc4ccc36a5ae48a281cd6dba88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 9 Feb 2015 16:14:27 +0200 Subject: [PATCH 09/18] MDEV-7139: Sporadic failure in innodb.innodb_corrupt_bit on P8 The testcase fails randomly due to ibuf merge happening in the background. Fix not to do any merges with ibuf_debug enabled. --- mysql-test/suite/innodb/t/innodb_corrupt_bit.test | 10 +++------- storage/innobase/ibuf/ibuf0ibuf.c | 8 ++++++++ storage/xtradb/ibuf/ibuf0ibuf.c | 6 ++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test index 753f2e29ef2..88da919bfaa 100644 --- a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test +++ b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test @@ -3,11 +3,6 @@ # -- source include/have_innodb.inc -if (`select plugin_auth_version <= "5.5.40-MariaDB-36.1" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in XtraDB as of 5.5.40-MariaDB-36.1 or earlier -} - # Issues with innodb_change_buffering_debug on Windows, so the test scenario # cannot be created on windows --source include/not_windows.inc @@ -16,6 +11,7 @@ if (`select plugin_auth_version <= "5.5.40-MariaDB-36.1" from information_schema --source include/have_debug.inc -- disable_query_log +call mtr.add_suppression("Flagged corruption of idx.*in CHECK TABLE"); # This test setup is extracted from bug56680.test: # The flag innodb_change_buffering_debug is only available in debug builds. # It instructs InnoDB to try to evict pages from the buffer pool when @@ -28,10 +24,10 @@ SET GLOBAL innodb_change_buffering_debug = 1; SET UNIQUE_CHECKS=0; CREATE DATABASE pad; -let $i=345; +let $i=338; while ($i) { - --eval CREATE TABLE pad.t$i (a INT PRIMARY KEY) ENGINE=InnoDB; +--eval CREATE TABLE pad.t$i(a INT PRIMARY KEY)ENGINE=InnoDB; dec $i; } diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c index d22fc8b9962..eee5402daa7 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.c +++ b/storage/innobase/ibuf/ibuf0ibuf.c @@ -2731,6 +2731,14 @@ ibuf_contract_for_n_pages( ulint n_bytes; ulint n_pag2; +#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG + if (ibuf_debug) { + return(0); + } +#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ + + + while (sum_pages < n_pages) { n_bytes = ibuf_contract_ext(&n_pag2, sync); diff --git a/storage/xtradb/ibuf/ibuf0ibuf.c b/storage/xtradb/ibuf/ibuf0ibuf.c index e04b6ac3ba6..7811b6ba19e 100644 --- a/storage/xtradb/ibuf/ibuf0ibuf.c +++ b/storage/xtradb/ibuf/ibuf0ibuf.c @@ -2775,6 +2775,12 @@ ibuf_contract_for_n_pages( ulint n_bytes; ulint n_pag2; +#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG + if (ibuf_debug) { + return(0); + } +#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ + while (sum_pages < n_pages) { n_bytes = ibuf_contract_ext(&n_pag2, sync); From ada07435b42a6a3e739a386864ef8ab7f2a8838d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 10 Feb 2015 08:08:59 +0200 Subject: [PATCH 10/18] Fix test failure on innodb-mdev-7055. --- .../suite/innodb/r/innodb-mdev-7055.result | Bin 325 -> 97 bytes mysql-test/suite/innodb/t/innodb-mdev-7055.test | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/innodb-mdev-7055.result b/mysql-test/suite/innodb/r/innodb-mdev-7055.result index 67a30ba783fb80eaff1e64f3ce3a2dcdf438d01b..167ace92f32d0b00180de93f361049ae4d42a65f 100644 GIT binary patch delta 10 RcmX@glsNIQ&tyeLQ2-aA1Csy% literal 325 zcmZ{fK}*Cy428Y!{EA#;y0SuB(1WE|MGu0kmxX0dWp*ZA2ilBeQvLhJf`=7^91>pM zmzRtJT^d90-yJ(I$bCj>yY6i6eIi0HF;QbwhyT=e_PK71XLN$Fdw6_(2B`q)6bai% zl)@1*j>>{K6lGg(?7?pA)~*{9DI*KKYnyDQsPq)%8+py4>5f z+V+kq(kb8lcB`tsy;(guaUeXCS3m$IfKTH*5!gSMEjR&AUr_09OSCH(I87QtL!GBI R2Xk?60;dlUcN}rq`38wYXCwds diff --git a/mysql-test/suite/innodb/t/innodb-mdev-7055.test b/mysql-test/suite/innodb/t/innodb-mdev-7055.test index d68be46c35a..8fd6f86d927 100644 --- a/mysql-test/suite/innodb/t/innodb-mdev-7055.test +++ b/mysql-test/suite/innodb/t/innodb-mdev-7055.test @@ -3,12 +3,13 @@ # 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 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; ---disable_query_log set @@character_set_connection=@old_character_set; +--enable_query_log From 552f1b350587a2db6c8d8c6596983da1b1d87e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 10 Feb 2015 14:17:23 +0200 Subject: [PATCH 11/18] Fix test failures on innodb-mdev-7055 and innodb-mdev-7513. --- mysql-test/suite/innodb/r/innodb-mdev-7055.result | Bin 97 -> 2 bytes .../suite/innodb/r/innodb-mdev-7513,xtradb.rdiff | 3 --- mysql-test/suite/innodb/r/innodb-mdev-7513.result | 2 -- mysql-test/suite/innodb/t/innodb-mdev-7055.test | 8 ++++++++ mysql-test/suite/innodb/t/innodb-mdev-7513.test | 6 ++++++ 5 files changed, 14 insertions(+), 5 deletions(-) delete mode 100644 mysql-test/suite/innodb/r/innodb-mdev-7513,xtradb.rdiff diff --git a/mysql-test/suite/innodb/r/innodb-mdev-7055.result b/mysql-test/suite/innodb/r/innodb-mdev-7055.result index 167ace92f32d0b00180de93f361049ae4d42a65f..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 100644 GIT binary patch literal 2 JcmXry0ssJR06YKy literal 97 zcmWGfEXvEwOE0$K3Wu;b4UNo9Ib9M<5*12{O7oHvOHxx5((;QGlJj#)bMq9`Gt)E- iYz=hOBh_`({nRzp6%tDnit@`947t!`xFWe2?70Bnvm03e diff --git a/mysql-test/suite/innodb/r/innodb-mdev-7513,xtradb.rdiff b/mysql-test/suite/innodb/r/innodb-mdev-7513,xtradb.rdiff deleted file mode 100644 index 1038ba9c116..00000000000 --- a/mysql-test/suite/innodb/r/innodb-mdev-7513,xtradb.rdiff +++ /dev/null @@ -1,3 +0,0 @@ -200,201d199 -< Warnings: -< Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline. diff --git a/mysql-test/suite/innodb/r/innodb-mdev-7513.result b/mysql-test/suite/innodb/r/innodb-mdev-7513.result index 904d0ed3fcf..bb3531e3f90 100644 --- a/mysql-test/suite/innodb/r/innodb-mdev-7513.result +++ b/mysql-test/suite/innodb/r/innodb-mdev-7513.result @@ -197,8 +197,6 @@ text195 TEXT, text196 TEXT, text197 TEXT ) ENGINE = InnoDB; -Warnings: -Warning 139 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline. INSERT INTO t1 VALUES ('abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef'); DELETE FROM t1 WHERE text1 = 'abcdef'; SELECT * from t1; diff --git a/mysql-test/suite/innodb/t/innodb-mdev-7055.test b/mysql-test/suite/innodb/t/innodb-mdev-7055.test index 8fd6f86d927..8f4d647e35d 100644 --- a/mysql-test/suite/innodb/t/innodb-mdev-7055.test +++ b/mysql-test/suite/innodb/t/innodb-mdev-7055.test @@ -4,6 +4,8 @@ # || 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'); @@ -11,5 +13,11 @@ 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/mysql-test/suite/innodb/t/innodb-mdev-7513.test b/mysql-test/suite/innodb/t/innodb-mdev-7513.test index 54948adcbd4..b929ea14781 100644 --- a/mysql-test/suite/innodb/t/innodb-mdev-7513.test +++ b/mysql-test/suite/innodb/t/innodb-mdev-7513.test @@ -1,8 +1,11 @@ -- source include/have_innodb.inc -- source include/not_embedded.inc +# MDEV-7513: ib_warn_row_too_big dereferences null thd + call mtr.add_suppression("Row size too large (> 8126)*"); +--disable_warnings CREATE TABLE t1 ( text1 TEXT, text2 TEXT, text3 TEXT, @@ -203,12 +206,15 @@ text197 TEXT ) ENGINE = InnoDB; INSERT INTO t1 VALUES ('abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef', 'abcdef'); +--enable_warnings DELETE FROM t1 WHERE text1 = 'abcdef'; --source include/restart_mysqld.inc +--disable_warnings SELECT * from t1; +--enable_warnings DROP TABLE t1; From cfb7d5d78a8aa6a683cd7a2f745d98ecfaca0100 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 10 Feb 2015 16:16:31 +0400 Subject: [PATCH 12/18] MDEV-7516 Assertion `!cur_p->event' failed in Gcalc_scan_iterator::arrange_event(int, int). When the distance in ST_BUFFER is too far negative the coordinates can run out of the operational area. We should just return an empty geometry in this case. --- mysql-test/r/gis.result | 3 +++ mysql-test/t/gis.test | 5 +++++ sql/item_geofunc.cc | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index ba69416b0ef..700b5de44f5 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -1607,4 +1607,7 @@ create table t1 (pt point); insert into t1 values(Geomfromtext('POLYGON((1 1, 2 2, 2 1, 1 1))')); ERROR 22007: Incorrect POINT value: 'POLYGON' for column 'pt' at row 1 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 diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 4d421e15d58..bce1fa2c226 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -1465,4 +1465,9 @@ create table t1 (pt point); insert into t1 values(Geomfromtext('POLYGON((1 1, 2 2, 2 1, 1 1))')); drop table t1; +# +# MDEV-7516 Assertion `!cur_p->event' failed in Gcalc_scan_iterator::arrange_event(int, int) +# +SELECT st_astext(ST_Buffer(ST_PolygonFromText('POLYGON((3 5, 2 4, 2 5, 3 5))'), -100)); + --echo End of 5.5 tests diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index a38e9d416a7..5e1c0add54b 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -1286,6 +1286,13 @@ String *Item_func_buffer::val_str(String *str_value) if (dist > 0.0) mbr.buffer(dist); + else + { + /* This happens when dist is too far negative. */ + if (mbr.xmax + dist < mbr.xmin || mbr.ymax + dist < mbr.ymin) + goto return_empty_result; + } + collector.set_extent(mbr.xmin, mbr.xmax, mbr.ymin, mbr.ymax); /* If the distance given is 0, the Buffer function is in fact NOOP, @@ -1313,6 +1320,7 @@ String *Item_func_buffer::val_str(String *str_value) goto mem_error; +return_empty_result: str_value->set_charset(&my_charset_bin); if (str_value->reserve(SRID_SIZE, 512)) goto mem_error; From c233d6e120e20ea39dc7b9eac4cef264befc3cd0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Feb 2015 01:26:50 +0100 Subject: [PATCH 13/18] MDEV-7260: Crash in get_best_combination when executing multi-table UPDATE with nested views Do not use merge_for_insert for commands which use SELECT because optimizer can't work with such tables. Fixes which makes multi-delete working with normally merged views. --- mysql-test/r/view.result | 13 +++++++++++++ mysql-test/t/view.test | 22 ++++++++++++++++++++++ sql/sql_base.cc | 3 +++ sql/sql_delete.cc | 5 +++-- sql/sql_derived.cc | 3 +++ sql/table.h | 18 ++++++++++++++++++ 6 files changed, 62 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index cb40fbbcbca..b3977648d41 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -5398,6 +5398,19 @@ DROP VIEW v1; DROP TABLE t1, t2; create view v1 as select 1; drop view v1; +# +# MDEV-7260: Crash in get_best_combination when executing multi-table +# UPDATE with nested views +# +CREATE TABLE `t1` (`id` bigint(20)); +INSERT INTO `t1` VALUES (1),(2); +CREATE TABLE `t2` (`id` bigint(20)); +CREATE TABLE `t3` (`id` bigint(20), `flag` tinyint(4)); +create view v1 as select id from t1; +create view v2 as select t2.* from (t2 left join v1 using (id)); +update t3 left join v2 using (id) set flag=flag+1; +drop view v2, v1; +drop table t1, t2, t3; # ----------------------------------------------------------------- # -- End of 5.5 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 8056836fe9a..b96799215fe 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -5345,6 +5345,28 @@ create view v1 as select 1; drop view v1; +--echo # +--echo # MDEV-7260: Crash in get_best_combination when executing multi-table +--echo # UPDATE with nested views +--echo # + +CREATE TABLE `t1` (`id` bigint(20)); + +INSERT INTO `t1` VALUES (1),(2); + +CREATE TABLE `t2` (`id` bigint(20)); + +CREATE TABLE `t3` (`id` bigint(20), `flag` tinyint(4)); + +create view v1 as select id from t1; + +create view v2 as select t2.* from (t2 left join v1 using (id)); + +update t3 left join v2 using (id) set flag=flag+1; + +drop view v2, v1; +drop table t1, t2, t3; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.5 tests. --echo # ----------------------------------------------------------------- diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 90a12eb366d..3c36c2b514a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2028,6 +2028,9 @@ unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, bool check_alias) { TABLE_LIST *dup; + + table= table->find_table_for_update(); + if (table->table && table->table->file->ht->db_type == DB_TYPE_MRG_MYISAM) { TABLE_LIST *child; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 97d3d10c21c..055b4858598 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -657,9 +657,10 @@ multi_delete::initialize_tables(JOIN *join) delete_while_scanning= 1; for (walk= delete_tables; walk; walk= walk->next_local) { - tables_to_delete_from|= walk->table->map; + TABLE_LIST *tbl= walk->correspondent_table->find_table_for_update(); + tables_to_delete_from|= tbl->table->map; if (delete_while_scanning && - unique_table(thd, walk, join->tables_list, false)) + unique_table(thd, tbl, join->tables_list, false)) { /* If the table we are going to delete from appears diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 004cccb41a9..56748fa110d 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -507,6 +507,9 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived) DBUG_RETURN(FALSE); if (derived->is_materialized_derived()) DBUG_RETURN(mysql_derived_prepare(thd, lex, derived)); + if ((thd->lex->sql_command == SQLCOM_UPDATE_MULTI || + thd->lex->sql_command == SQLCOM_DELETE_MULTI)) + DBUG_RETURN(FALSE); if (!derived->is_multitable()) { if (!derived->single_table_updatable()) diff --git a/sql/table.h b/sql/table.h index 8e8c2811b71..7a1e380f14c 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1984,6 +1984,24 @@ struct TABLE_LIST TABLE_LIST *find_underlying_table(TABLE *table); TABLE_LIST *first_leaf_for_name_resolution(); TABLE_LIST *last_leaf_for_name_resolution(); + /** + @brief + Find the bottom in the chain of embedded table VIEWs. + + @detail + This is used for single-table UPDATE/DELETE when they are modifying a + single-table VIEW. + */ + TABLE_LIST *find_table_for_update() + { + TABLE_LIST *tbl= this; + while(!tbl->is_multitable() && tbl->single_table_updatable() && + tbl->merge_underlying_list) + { + tbl= tbl->merge_underlying_list; + } + return tbl; + } TABLE *get_real_join_table(); bool is_leaf_for_name_resolution(); inline TABLE_LIST *top_table() From f007f82881b4294fa00236780309522863259546 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 9 Feb 2015 20:53:28 +0100 Subject: [PATCH 14/18] MDEV-7351 5.5 build fails on Ubuntu Utopic in buildbot include oqgraph into deb packages conditionally, just like we do with tokudb --- debian/dist/Debian/mariadb-server-5.5.files.in | 2 +- debian/dist/Ubuntu/mariadb-server-5.5.files.in | 2 +- storage/oqgraph/CMakeLists.txt | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/debian/dist/Debian/mariadb-server-5.5.files.in b/debian/dist/Debian/mariadb-server-5.5.files.in index 5682adbdce0..c1ea58740e4 100644 --- a/debian/dist/Debian/mariadb-server-5.5.files.in +++ b/debian/dist/Debian/mariadb-server-5.5.files.in @@ -1,5 +1,4 @@ usr/lib/mysql/plugin/ha_innodb.so -usr/lib/mysql/plugin/ha_oqgraph.so usr/lib/mysql/plugin/sphinx.so usr/lib/mysql/plugin/auth_socket.so usr/lib/mysql/plugin/auth_pam.so @@ -73,3 +72,4 @@ usr/share/mysql/mysql_system_tables.sql usr/share/mysql/mysql_performance_tables.sql usr/share/mysql/mysql_test_data_timezone.sql @TOKUDB_DEB_FILES@ +@OQGRAPH_DEB_FILES@ diff --git a/debian/dist/Ubuntu/mariadb-server-5.5.files.in b/debian/dist/Ubuntu/mariadb-server-5.5.files.in index 06a6643d650..7f75ccc2303 100644 --- a/debian/dist/Ubuntu/mariadb-server-5.5.files.in +++ b/debian/dist/Ubuntu/mariadb-server-5.5.files.in @@ -1,5 +1,4 @@ usr/lib/mysql/plugin/ha_innodb.so -usr/lib/mysql/plugin/ha_oqgraph.so usr/lib/mysql/plugin/sphinx.so usr/lib/mysql/plugin/auth_socket.so usr/lib/mysql/plugin/auth_pam.so @@ -75,3 +74,4 @@ usr/share/mysql/mysql_system_tables.sql usr/share/mysql/mysql_performance_tables.sql usr/share/mysql/mysql_test_data_timezone.sql @TOKUDB_DEB_FILES@ +@OQGRAPH_DEB_FILES@ diff --git a/storage/oqgraph/CMakeLists.txt b/storage/oqgraph/CMakeLists.txt index 7b110b7de5a..0a3cabcd03c 100644 --- a/storage/oqgraph/CMakeLists.txt +++ b/storage/oqgraph/CMakeLists.txt @@ -52,4 +52,5 @@ IF(BOOST_OK) MYSQL_ADD_PLUGIN(oqgraph ha_oqgraph.cc graphcore.cc STORAGE_ENGINE MODULE_ONLY) + SET(OQGRAPH_DEB_FILES "usr/lib/mysql/plugin/ha_oqgraph.so\n" PARENT_SCOPE) ENDIF(BOOST_OK) From a34fd50ce1c4385a7e63522d3d248fc3d417449b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 9 Feb 2015 20:53:36 +0100 Subject: [PATCH 15/18] MDEV-7478 log-basename unpredictable behavior in standalone mode * fix /etc/init.d/mysql to use log-basename for pid-filename * fix mysqld_safe not to force logging-to-file when log-basename is specified --- scripts/mysqld_safe.sh | 14 ++++++++++++-- support-files/mysql.server.sh | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 3428fff6a59..303e7a29a6d 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -28,6 +28,7 @@ syslog_tag= user='@MYSQLD_USER@' pid_file= err_log= +err_log_base= syslog_tag_mysqld=mysqld syslog_tag_mysqld_safe=mysqld_safe @@ -208,7 +209,7 @@ parse_arguments() { --user=*) user="$val"; SET_USER=1 ;; --log-basename=*|--hostname=*|--loose-log-basename=*) pid_file="$val.pid"; - err_log="$val.err"; + err_log_base="$val"; ;; # these might have been set in a [mysqld_safe] section of my.cnf @@ -577,7 +578,16 @@ then * ) err_log="$DATADIR/$err_log" ;; esac else - err_log=$DATADIR/`@HOSTNAME@`.err + if [ -n "$err_log_base" ] + then + err_log=$err_log_base.err + case "$err_log" in + /* ) ;; + * ) err_log="$DATADIR/$err_log" ;; + esac + else + err_log=$DATADIR/`@HOSTNAME@`.err + fi fi append_arg_to_args "--log-error=$err_log" diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index a19f09fc91f..e23b8373ec4 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -146,6 +146,9 @@ parse_server_arguments() { --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` datadir_set=1 ;; + --log-basename=*|--hostname=*|--loose-log-basename=*) + mysqld_pid_file_path=`echo "$arg.pid" | sed -e 's/^[^=]*=//'` + ;; --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; esac From 75884242abd855429fa17c5aa4ef8e7a76fd22fb Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 10 Feb 2015 10:19:42 +0100 Subject: [PATCH 16/18] restore a cross-compiling bit that was lost in a merge --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bb269abe76..20191c0f154 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -350,6 +350,11 @@ MYSQL_CHECK_READLINE() CHECK_JEMALLOC() +IF(CMAKE_CROSSCOMPILING) + SET(IMPORT_EXECUTABLES "IMPORTFILE-NOTFOUND" CACHE FILEPATH "Path to import_executables.cmake from a native build") + INCLUDE(${IMPORT_EXECUTABLES}) +ENDIF() + # # Setup maintainer mode options by the end. Platform checks are # not run with the warning options as to not perturb fragile checks From d996dc29970b01d4e1fe5f82ff240e643dd53185 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 11 Feb 2015 15:02:15 +0100 Subject: [PATCH 17/18] MDEV-7290 please update MSI installer to include HeidiSQL 9.1 --- win/packaging/heidisql.cmake | 2 +- win/packaging/heidisql.wxi.in | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake index e429907cb2e..f9334f09570 100644 --- a/win/packaging/heidisql.cmake +++ b/win/packaging/heidisql.cmake @@ -1,4 +1,4 @@ -SET(HEIDISQL_BASE_NAME "HeidiSQL_8.3_Portable") +SET(HEIDISQL_BASE_NAME "HeidiSQL_9.1_Portable") SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip") SET(HEIDISQL_URL "http://www.heidisql.com/downloads/releases/${HEIDISQL_ZIP}") SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME}) diff --git a/win/packaging/heidisql.wxi.in b/win/packaging/heidisql.wxi.in index 1e6e3d552a8..6b1176921bc 100644 --- a/win/packaging/heidisql.wxi.in +++ b/win/packaging/heidisql.wxi.in @@ -23,9 +23,10 @@ uninstallation. We use RemoveFile to force delete in any case. --> + + - @@ -34,6 +35,26 @@ + + + + + + + + + + + + + + + + + + + + HEIDISQLINSTALLED @@ -46,6 +67,11 @@ + + + + + From 13927f878e02c33d118cac43b14bd06d2382eb26 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 11 Feb 2015 18:32:40 +0100 Subject: [PATCH 18/18] percona-server-5.5.41-37.0 --- CMakeLists.txt | 8 +++++++ dict/dict0dict.c | 42 +++++++++++++++++++++++++++------- handler/ha_innodb.cc | 54 ++++++++++++++++++++++++++++++++++++++++++-- include/btr0cur.ic | 4 ++-- include/dict0dict.h | 8 +++++++ include/dict0dict.ic | 12 ++++++++++ include/univ.i | 6 ++++- log/log0log.c | 2 +- log/log0online.c | 2 +- log/log0recv.c | 3 ++- row/row0mysql.c | 9 +++++--- 11 files changed, 131 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 194a9cb2be2..a8952614966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,6 +276,14 @@ SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c ut/ut0byte.c ut/ut0dbg.c ut/ut0list.c ut/ut0mem.c ut/ut0rbt.c ut/ut0rnd.c ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c ut/ut0bh.c) +# These files have unused result errors, so we skip Werror +CHECK_C_COMPILER_FLAG("-Werror" HAVE_WERROR) +IF(HAVE_WERROR) + INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake) + ADD_COMPILE_FLAGS(page/page0zip.c COMPILE_FLAGS "-Wno-error") + ADD_COMPILE_FLAGS(ut/ut0ut.c COMPILE_FLAGS "-Wno-error") +ENDIF() + IF(WITH_INNODB) # Legacy option SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) diff --git a/dict/dict0dict.c b/dict/dict0dict.c index 67fb427ecf8..546cead76d2 100644 --- a/dict/dict0dict.c +++ b/dict/dict0dict.c @@ -42,6 +42,12 @@ UNIV_INTERN dict_index_t* dict_ind_compact; UNIV_INTERN uint ibuf_debug; #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ +/********************************************************************** +Issue a warning that the row is too big. */ +void +ib_warn_row_too_big(const dict_table_t* table); + + #ifndef UNIV_HOTBACKUP #include "buf0buf.h" #include "data0type.h" @@ -1892,11 +1898,18 @@ dict_index_add_to_cache( new_index->n_fields = new_index->n_def; - if (strict && dict_index_too_big_for_tree(table, new_index)) { + if (dict_index_too_big_for_tree(table, new_index)) { + + if (strict) { too_big: - dict_mem_index_free(new_index); - dict_mem_index_free(index); - return(DB_TOO_BIG_RECORD); + dict_mem_index_free(new_index); + dict_mem_index_free(index); + return(DB_TOO_BIG_RECORD); + } else { + + ib_warn_row_too_big(table); + + } } if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) { @@ -2650,8 +2663,15 @@ dict_foreign_remove_from_cache( foreign); rbt = foreign->referenced_table->referenced_rbt; + if (rbt != NULL) { - rbt_delete(rbt, foreign->id); + const ib_rbt_node_t* node + = rbt_lookup(rbt, foreign->id); + dict_foreign_t* val = *(dict_foreign_t**) node->value; + + if (val == foreign) { + rbt_delete(rbt, foreign->id); + } } } @@ -2664,7 +2684,13 @@ dict_foreign_remove_from_cache( rbt = foreign->foreign_table->foreign_rbt; if (rbt != NULL) { - rbt_delete(rbt, foreign->id); + const ib_rbt_node_t* node + = rbt_lookup(rbt, foreign->id); + dict_foreign_t* val = *(dict_foreign_t**) node->value; + + if (val == foreign) { + rbt_delete(rbt, foreign->id); + } } } @@ -6031,11 +6057,11 @@ dict_set_corrupted( dict_index_copy_types(tuple, sys_index, 2); - btr_cur_search_to_nth_level(sys_index, 0, tuple, PAGE_CUR_GE, + btr_cur_search_to_nth_level(sys_index, 0, tuple, PAGE_CUR_LE, BTR_MODIFY_LEAF, &cursor, 0, __FILE__, __LINE__, &mtr); - if (cursor.up_match == dtuple_get_n_fields(tuple)) { + if (cursor.low_match == dtuple_get_n_fields(tuple)) { /* UPDATE SYS_INDEXES SET TYPE=index->type WHERE TABLE_ID=index->table->id AND INDEX_ID=index->id */ ulint len; diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc index ce3f12ff01c..c9a89b69375 100644 --- a/handler/ha_innodb.cc +++ b/handler/ha_innodb.cc @@ -2681,7 +2681,7 @@ innobase_init( innobase_hton->start_consistent_snapshot=innobase_start_trx_and_assign_read_view; innobase_hton->flush_logs=innobase_flush_logs; innobase_hton->show_status=innobase_show_status; - innobase_hton->flags=HTON_NO_FLAGS; + innobase_hton->flags=HTON_SUPPORTS_FOREIGN_KEYS; innobase_hton->release_temporary_latches=innobase_release_temporary_latches; innobase_hton->alter_table_flags = innobase_alter_table_flags; innobase_hton->flush_changed_page_bitmaps @@ -10238,6 +10238,7 @@ ha_innobase::start_stmt( thr_lock_type lock_type) { trx_t* trx; + DBUG_ENTER("ha_innobase::start_stmt"); update_thd(thd); @@ -10260,6 +10261,28 @@ ha_innobase::start_stmt( prebuilt->hint_need_to_fetch_extra_cols = 0; reset_template(prebuilt); + if (dict_table_is_temporary(prebuilt->table) + && prebuilt->mysql_has_locked + && prebuilt->select_lock_type == LOCK_NONE) { + ulint error; + + switch (thd_sql_command(thd)) { + case SQLCOM_INSERT: + case SQLCOM_UPDATE: + case SQLCOM_DELETE: + init_table_handle_for_HANDLER(); + prebuilt->select_lock_type = LOCK_X; + error = row_lock_table_for_mysql(prebuilt, NULL, 1); + + if (error != DB_SUCCESS) { + error = convert_error_code_to_mysql( + (int) error, 0, thd); + DBUG_RETURN((int) error); + } + break; + } + } + if (!prebuilt->mysql_has_locked) { /* This handle is for a temporary table created inside this same LOCK TABLES; since MySQL does NOT call external_lock @@ -10292,7 +10315,7 @@ ha_innobase::start_stmt( innobase_register_trx(ht, thd, trx); - return(0); + DBUG_RETURN(0); } /******************************************************************//** @@ -13711,3 +13734,30 @@ innobase_convert_to_filename_charset( return(strconvert(cs_from, from, cs_to, to, len, &errors)); } + + +/********************************************************************** +Issue a warning that the row is too big. */ +extern "C" +void +ib_warn_row_too_big(const dict_table_t* table) +{ + /* If prefix is true then a 768-byte prefix is stored + locally for BLOB fields. Refer to dict_table_get_format() */ + const bool prefix = ((table->flags & DICT_TF_FORMAT_MASK) + >> DICT_TF_FORMAT_SHIFT) < UNIV_FORMAT_B; + + const ulint free_space = page_get_free_space_of_empty( + table->flags & DICT_TF_COMPACT) / 2; + + THD* thd = current_thd; + + push_warning_printf( + thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_ERR_TO_BIG_ROW, + "Row size too large (> %lu). Changing some columns to TEXT" + " or BLOB %smay help. In current row format, BLOB prefix of" + " %d bytes is stored inline.", free_space + , prefix ? "or using ROW_FORMAT=DYNAMIC or" + " ROW_FORMAT=COMPRESSED ": "" + , prefix ? DICT_MAX_FIXED_COL_LEN : 0); +} diff --git a/include/btr0cur.ic b/include/btr0cur.ic index 5fc4651ca13..5d122101fab 100644 --- a/include/btr0cur.ic +++ b/include/btr0cur.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -28,7 +28,7 @@ Created 10/16/1994 Heikki Tuuri #ifdef UNIV_DEBUG # define LIMIT_OPTIMISTIC_INSERT_DEBUG(NREC, CODE)\ -if (btr_cur_limit_optimistic_insert_debug\ +if (btr_cur_limit_optimistic_insert_debug > 1\ && (NREC) >= (ulint)btr_cur_limit_optimistic_insert_debug) {\ CODE;\ } diff --git a/include/dict0dict.h b/include/dict0dict.h index 8908d7608ad..121f9241cbc 100644 --- a/include/dict0dict.h +++ b/include/dict0dict.h @@ -1391,6 +1391,14 @@ dict_table_init_referenced_rbt( /*===========================*/ dict_table_t* table); /*!< in: the table object whose table->referenced_rbt will be initialized */ +/********************************************************************//** +Check if it is a temporary table. +@return true if temporary table flag is set. */ +UNIV_INLINE +ibool +dict_table_is_temporary( +/*====================*/ + const dict_table_t* table); /*!< in: table to check */ #ifndef UNIV_NONINL #include "dict0dict.ic" diff --git a/include/dict0dict.ic b/include/dict0dict.ic index 00ae3d0a718..6836928ff49 100644 --- a/include/dict0dict.ic +++ b/include/dict0dict.ic @@ -1017,3 +1017,15 @@ dict_table_init_referenced_rbt( ut_a(table->referenced_rbt != NULL); return(table->referenced_rbt); } + +/********************************************************************//** +Check if it is a temporary table. +@return true if temporary table flag is set. */ +UNIV_INLINE +ibool +dict_table_is_temporary( +/*====================*/ + const dict_table_t* table) /*!< in: table to check */ +{ + return(table->flags & (DICT_TF2_TEMPORARY << DICT_TF2_SHIFT)); +} diff --git a/include/univ.i b/include/univ.i index d38773d5b59..56241492038 100644 --- a/include/univ.i +++ b/include/univ.i @@ -64,7 +64,7 @@ component, i.e. we show M.N.P as M.N */ (INNODB_VERSION_MAJOR << 8 | INNODB_VERSION_MINOR) #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 36.1 +#define PERCONA_INNODB_VERSION 37.0 #endif #define INNODB_VERSION_STR MYSQL_SERVER_VERSION @@ -122,6 +122,10 @@ if we are compiling on Windows. */ # include # endif +# ifdef HAVE_MALLOC_H +# include +# endif + /* We only try to do explicit inlining of functions with gcc and Sun Studio */ diff --git a/log/log0log.c b/log/log0log.c index ab0def5739c..b4b48a065f9 100644 --- a/log/log0log.c +++ b/log/log0log.c @@ -252,7 +252,7 @@ log_buffer_extend( { ulint move_start; ulint move_end; - byte tmp_buf[OS_FILE_LOG_BLOCK_SIZE]; + byte* tmp_buf = alloca(OS_FILE_LOG_BLOCK_SIZE); mutex_enter(&(log_sys->mutex)); diff --git a/log/log0online.c b/log/log0online.c index 58f86d1581a..acb3bd58714 100644 --- a/log/log0online.c +++ b/log/log0online.c @@ -1817,7 +1817,7 @@ log_online_purge_changed_page_bitmaps( return TRUE; } - if (srv_track_changed_pages && lsn >= log_bmp_sys->end_lsn) { + if (srv_track_changed_pages && lsn > log_bmp_sys->end_lsn) { /* If we have to delete the current output file, close it first. */ os_file_close(log_bmp_sys->out.file); diff --git a/log/log0recv.c b/log/log0recv.c index 4d83a37fad1..55d951d8ff6 100644 --- a/log/log0recv.c +++ b/log/log0recv.c @@ -2989,7 +2989,8 @@ recv_recovery_from_checkpoint_start_func( #endif /* UNIV_LOG_ARCHIVE */ byte* buf; byte* log_hdr_buf; - byte log_hdr_buf_base[LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE]; + byte* log_hdr_buf_base = alloca(LOG_FILE_HDR_SIZE + + OS_FILE_LOG_BLOCK_SIZE); ulint err; log_hdr_buf = ut_align(log_hdr_buf_base, OS_FILE_LOG_BLOCK_SIZE); diff --git a/row/row0mysql.c b/row/row0mysql.c index 7029a007fbb..2e89ab64504 100644 --- a/row/row0mysql.c +++ b/row/row0mysql.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2014, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -3226,6 +3226,9 @@ row_drop_table_for_mysql( ulint namelen; ibool locked_dictionary = FALSE; pars_info_t* info = NULL; + DBUG_ENTER("row_drop_table_for_mysql"); + + DBUG_PRINT("row_drop_table_for_mysql", ("table: %s", name)); ut_a(name != NULL); @@ -3236,7 +3239,7 @@ row_drop_table_for_mysql( "InnoDB: Shut down mysqld and edit my.cnf so that newraw" " is replaced with raw.\n", stderr); - return(DB_ERROR); + DBUG_RETURN(DB_ERROR); } trx->op_info = "dropping table"; @@ -3643,7 +3646,7 @@ funct_exit: srv_wake_master_thread(); - return((int) err); + DBUG_RETURN((int) err); } /*********************************************************************//**