[Commits] 5cfb043: MDEV-16174 Assertion `0' failed in Type_handler_string_result::make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*)
by holyfoot@askmonty.org 09 Nov '18
by holyfoot@askmonty.org 09 Nov '18
09 Nov '18
revision-id: 5cfb043d2919439fccfa350edd9a3fdb4aaf229b (mariadb-10.2.18-71-g5cfb043)
parent(s): f5bcf788e76c2cb5da5ddecdb6ff9b2f766b1a49
committer: Alexey Botchkov
timestamp: 2018-11-09 22:55:34 +0400
message:
MDEV-16174 Assertion `0' failed in Type_handler_string_result::make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*)
maybe_null should be always set to TRUE in
Item_func_json_array_append::fix_length_and_dec()
---
mysql-test/r/func_json.result | 14 ++++++++++++++
mysql-test/t/func_json.test | 13 +++++++++++++
sql/item_jsonfunc.cc | 1 +
3 files changed, 28 insertions(+)
diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result
index c828b26..90458bc 100644
--- a/mysql-test/r/func_json.result
+++ b/mysql-test/r/func_json.result
@@ -810,3 +810,17 @@ SET @`json` := NULL, @`value` := NULL;
SELECT JSON_MERGE('[1]', '[]');
JSON_MERGE('[1]', '[]')
[1]
+#
+# MDEV-16174 Assertion `0' failed in Type_handler_string_result::
+# make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*)
+#
+SET sql_mode='';
+CREATE TABLE t1 (fld varchar(16) NOT NULL);
+CREATE TABLE t2 SELECT JSON_ARRAY_INSERT(fld, '$.[0]', '0') FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `JSON_ARRAY_INSERT(fld, '$.[0]', '0')` varchar(25) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1, t2;
+SET sql_mode=default;
diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test
index 1dc1641..d266641 100644
--- a/mysql-test/t/func_json.test
+++ b/mysql-test/t/func_json.test
@@ -468,3 +468,16 @@ SET @`json` := NULL, @`value` := NULL;
--echo #
SELECT JSON_MERGE('[1]', '[]');
+
+--echo #
+--echo # MDEV-16174 Assertion `0' failed in Type_handler_string_result::
+--echo # make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*)
+--echo #
+
+SET sql_mode='';
+CREATE TABLE t1 (fld varchar(16) NOT NULL);
+CREATE TABLE t2 SELECT JSON_ARRAY_INSERT(fld, '$.[0]', '0') FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+SET sql_mode=default;
+
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index 6072605..27bc97f 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -1562,6 +1562,7 @@ bool Item_func_json_array_append::fix_length_and_dec()
}
fix_char_length_ulonglong(char_length);
+ maybe_null= 1;
return FALSE;
}
1
0
[Commits] 54ce7155476: MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free or Invalid write in JOIN::make_aggr_tables_info
by varunraiko1803@gmail.com 09 Nov '18
by varunraiko1803@gmail.com 09 Nov '18
09 Nov '18
revision-id: 54ce715547686bba1970b37ef590cbe05c4e950d (mariadb-10.2.18-71-g54ce7155476)
parent(s): f5bcf788e76c2cb5da5ddecdb6ff9b2f766b1a49
author: Varun Gupta
committer: Varun Gupta
timestamp: 2018-11-09 19:53:40 +0530
message:
MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free or Invalid write in JOIN::make_aggr_tables_info
During the optimize state of a query, we come know that the result set
would atmost contain one row, then for such a query we don't need
to compute GROUP BY, ORDER BY and DISTINCT.
---
mysql-test/r/distinct.result | 20 ++++++++++++++
mysql-test/r/group_by.result | 10 +++++++
mysql-test/r/win.result | 62 ++++++++++++++++++++++++++++++++++++++++++++
mysql-test/t/distinct.test | 18 +++++++++++++
mysql-test/t/group_by.test | 12 +++++++++
mysql-test/t/win.test | 56 +++++++++++++++++++++++++++++++++++++++
sql/sql_select.cc | 12 +++++++++
7 files changed, 190 insertions(+)
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result
index e1bbf5adb79..850ce9a1965 100644
--- a/mysql-test/r/distinct.result
+++ b/mysql-test/r/distinct.result
@@ -1049,4 +1049,24 @@ b1+'0' b2+'0' b3+'0' b4+'0' b5+'0' b6 +'0'
1 0 0 1 0 1
0 1 0 0 1 0
DROP TABLE t1;
+#
+# MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free
+# or Invalid write in JOIN::make_aggr_tables_info
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY);
+INSERT INTO t1 VALUES (1),(2);
+explain
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) )
+UNION
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index; Using temporary
+2 UNION t1 index NULL PRIMARY 4 NULL 2 Using index; Using temporary
+NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) )
+UNION
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) );
+1
+1
+drop table t1;
End of 5.5 tests
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 9fee03877c5..9da6fa5ae8f 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -2832,3 +2832,13 @@ select distinct 1 from t1 group by a,b with rollup limit 1;
1
1
drop table t1;
+CREATE TABLE t1 ( pk int, i1 int, v1 varchar(1));
+explain
+SELECT 1 FROM t1
+GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
+SELECT 1 FROM t1
+GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ;
+1
+drop table t1;
diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index 790b264fc09..c539ac4f252 100644
--- a/mysql-test/r/win.result
+++ b/mysql-test/r/win.result
@@ -3361,3 +3361,65 @@ Esben Tuning 31 68.7500
Kaolin Tuning 88 68.7500
Tatiana Tuning 83 68.7500
drop table t1;
+#
+# MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free
+# or Invalid write in JOIN::make_aggr_tables_info
+#
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) order by 1+2;
+BIT_OR(100) OVER ()
+100
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT * FROM (
+SELECT
+ROW_NUMBER() OVER(), i, sum(i)
+FROM t1
+WHERE 1=0
+limit 0
+) AS sq;
+ROW_NUMBER() OVER() i sum(i)
+SELECT * FROM (
+SELECT
+ROW_NUMBER() OVER(), i, sum(i)
+FROM t1
+WHERE 1=0
+GROUP BY i
+) AS sq;
+ROW_NUMBER() OVER() i sum(i)
+drop table t1;
+create table t1 (a int);
+explain
+select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup;
+1 row_number() over (order by 1)
+drop table t1;
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP
+HAVING @A := 'qwerty';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP
+HAVING @A := 'qwerty';
+BIT_OR(100) OVER ()
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100)
+HAVING @A := 'qwerty';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100)
+HAVING @A := 'qwerty';
+BIT_OR(100) OVER ()
+create table t1 (a int);
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM t1
+GROUP BY LEFT('2018-08-24', 100) having 1=1 limit 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit
+drop table t1;
diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test
index c11f8b501bc..d41340c29fd 100644
--- a/mysql-test/t/distinct.test
+++ b/mysql-test/t/distinct.test
@@ -798,4 +798,22 @@ CREATE TABLE t1 (b1 BIT, b2 BIT, b3 BIT, b4 BIT , b5 BIT, b6 BIT);
INSERT INTO t1 VALUES (1,0,0,1,0,1),(0,1,0,0,1,0);
SELECT DISTINCT b1+'0', b2+'0', b3+'0', b4+'0', b5+'0', b6 +'0' FROM t1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free
+--echo # or Invalid write in JOIN::make_aggr_tables_info
+--echo #
+
+CREATE TABLE t1 (pk INT PRIMARY KEY);
+INSERT INTO t1 VALUES (1),(2);
+explain
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) )
+UNION
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) );
+
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) )
+UNION
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) );
+drop table t1;
+
--echo End of 5.5 tests
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 275939df5c5..61be676bb11 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1948,3 +1948,15 @@ insert into t1 values(-126,7),(1,1),(0,0),(-1,1),(351,65534);
select distinct 1 from t1 group by a,b with rollup limit 1;
drop table t1;
+#
+# MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free
+# or Invalid write in JOIN::make_aggr_tables_info
+#
+
+CREATE TABLE t1 ( pk int, i1 int, v1 varchar(1));
+explain
+SELECT 1 FROM t1
+GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ;
+SELECT 1 FROM t1
+GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ;
+drop table t1;
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index e9c8ee05773..7dda2b6215f 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -2119,3 +2119,59 @@ SELECT name, test, score,
FROM t1
ORDER BY test, name;
drop table t1;
+
+--echo #
+--echo # MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free
+--echo # or Invalid write in JOIN::make_aggr_tables_info
+--echo #
+
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) order by 1+2;
+
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+
+SELECT * FROM (
+ SELECT
+ ROW_NUMBER() OVER(), i, sum(i)
+ FROM t1
+ WHERE 1=0
+ limit 0
+) AS sq;
+
+SELECT * FROM (
+ SELECT
+ ROW_NUMBER() OVER(), i, sum(i)
+ FROM t1
+ WHERE 1=0
+ GROUP BY i
+) AS sq;
+drop table t1;
+
+create table t1 (a int);
+explain
+select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup;
+select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup;
+drop table t1;
+
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP
+HAVING @A := 'qwerty';
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP
+HAVING @A := 'qwerty';
+
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100)
+HAVING @A := 'qwerty';
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100)
+HAVING @A := 'qwerty';
+
+create table t1 (a int);
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM t1
+GROUP BY LEFT('2018-08-24', 100) having 1=1 limit 0;
+drop table t1;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 0cdecf1bf2e..db3ed8a1aa9 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2245,6 +2245,18 @@ JOIN::optimize_inner()
if (!tables_list || !table_count)
{
choose_tableless_subquery_plan();
+
+ /* The output has atmost one row */
+ if (group_list)
+ {
+ group_list= NULL;
+ group_optimized_away= 1;
+ rollup.state= ROLLUP::STATE_NONE;
+ }
+ order= NULL;
+ simple_order= TRUE;
+ select_distinct= FALSE;
+
if (select_lex->have_window_funcs())
{
if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB))))
1
0
[Commits] e60cbbbda31: MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free or Invalid write in JOIN::make_aggr_tables_info
by varunraiko1803@gmail.com 09 Nov '18
by varunraiko1803@gmail.com 09 Nov '18
09 Nov '18
revision-id: e60cbbbda31d7a10e87c16313171b2036a4519c4 (mariadb-10.2.18-52-ge60cbbbda31)
parent(s): f8268f3cce4577c28ab62e53293556d05a74fb1a
author: Varun Gupta
committer: Varun Gupta
timestamp: 2018-11-01 14:27:24 +0530
message:
MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free or Invalid write in JOIN::make_aggr_tables_info
During the optimize state of a query, we come know that the result set
would atmost contain one row, then for such a query we don't need
to compute GROUP BY, ORDER BY and DISTINCT.
---
mysql-test/r/distinct.result | 20 ++++++++++++++
mysql-test/r/group_by.result | 10 +++++++
mysql-test/r/win.result | 62 ++++++++++++++++++++++++++++++++++++++++++++
mysql-test/t/distinct.test | 18 +++++++++++++
mysql-test/t/group_by.test | 12 +++++++++
mysql-test/t/win.test | 56 +++++++++++++++++++++++++++++++++++++++
sql/sql_select.cc | 12 +++++++++
7 files changed, 190 insertions(+)
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result
index e1bbf5adb79..850ce9a1965 100644
--- a/mysql-test/r/distinct.result
+++ b/mysql-test/r/distinct.result
@@ -1049,4 +1049,24 @@ b1+'0' b2+'0' b3+'0' b4+'0' b5+'0' b6 +'0'
1 0 0 1 0 1
0 1 0 0 1 0
DROP TABLE t1;
+#
+# MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free
+# or Invalid write in JOIN::make_aggr_tables_info
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY);
+INSERT INTO t1 VALUES (1),(2);
+explain
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) )
+UNION
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index; Using temporary
+2 UNION t1 index NULL PRIMARY 4 NULL 2 Using index; Using temporary
+NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) )
+UNION
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) );
+1
+1
+drop table t1;
End of 5.5 tests
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 9fee03877c5..9da6fa5ae8f 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -2832,3 +2832,13 @@ select distinct 1 from t1 group by a,b with rollup limit 1;
1
1
drop table t1;
+CREATE TABLE t1 ( pk int, i1 int, v1 varchar(1));
+explain
+SELECT 1 FROM t1
+GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
+SELECT 1 FROM t1
+GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ;
+1
+drop table t1;
diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index b73fe346303..dc4ff0aaa1e 100644
--- a/mysql-test/r/win.result
+++ b/mysql-test/r/win.result
@@ -3363,3 +3363,65 @@ Kaolin Tuning 88 68.7500
Tatiana SQL 87 65.2500
Tatiana Tuning 83 68.7500
drop table t1;
+#
+# MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free
+# or Invalid write in JOIN::make_aggr_tables_info
+#
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) order by 1+2;
+BIT_OR(100) OVER ()
+100
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT * FROM (
+SELECT
+ROW_NUMBER() OVER(), i, sum(i)
+FROM t1
+WHERE 1=0
+limit 0
+) AS sq;
+ROW_NUMBER() OVER() i sum(i)
+SELECT * FROM (
+SELECT
+ROW_NUMBER() OVER(), i, sum(i)
+FROM t1
+WHERE 1=0
+GROUP BY i
+) AS sq;
+ROW_NUMBER() OVER() i sum(i)
+drop table t1;
+create table t1 (a int);
+explain
+select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup;
+1 row_number() over (order by 1)
+drop table t1;
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP
+HAVING @A := 'qwerty';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP
+HAVING @A := 'qwerty';
+BIT_OR(100) OVER ()
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100)
+HAVING @A := 'qwerty';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100)
+HAVING @A := 'qwerty';
+BIT_OR(100) OVER ()
+create table t1 (a int);
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM t1
+GROUP BY LEFT('2018-08-24', 100) having 1=1 limit 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit
+drop table t1;
diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test
index c11f8b501bc..d41340c29fd 100644
--- a/mysql-test/t/distinct.test
+++ b/mysql-test/t/distinct.test
@@ -798,4 +798,22 @@ CREATE TABLE t1 (b1 BIT, b2 BIT, b3 BIT, b4 BIT , b5 BIT, b6 BIT);
INSERT INTO t1 VALUES (1,0,0,1,0,1),(0,1,0,0,1,0);
SELECT DISTINCT b1+'0', b2+'0', b3+'0', b4+'0', b5+'0', b6 +'0' FROM t1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free
+--echo # or Invalid write in JOIN::make_aggr_tables_info
+--echo #
+
+CREATE TABLE t1 (pk INT PRIMARY KEY);
+INSERT INTO t1 VALUES (1),(2);
+explain
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) )
+UNION
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) );
+
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) )
+UNION
+( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) );
+drop table t1;
+
--echo End of 5.5 tests
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 275939df5c5..61be676bb11 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1948,3 +1948,15 @@ insert into t1 values(-126,7),(1,1),(0,0),(-1,1),(351,65534);
select distinct 1 from t1 group by a,b with rollup limit 1;
drop table t1;
+#
+# MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free
+# or Invalid write in JOIN::make_aggr_tables_info
+#
+
+CREATE TABLE t1 ( pk int, i1 int, v1 varchar(1));
+explain
+SELECT 1 FROM t1
+GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ;
+SELECT 1 FROM t1
+GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ;
+drop table t1;
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index e24c6533dcd..f70403ca6a9 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -2117,3 +2117,59 @@ SELECT name, test, score,
AVG(score) OVER (PARTITION BY test) AS average_by_test
FROM t1;
drop table t1;
+
+--echo #
+--echo # MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free
+--echo # or Invalid write in JOIN::make_aggr_tables_info
+--echo #
+
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) order by 1+2;
+
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+
+SELECT * FROM (
+ SELECT
+ ROW_NUMBER() OVER(), i, sum(i)
+ FROM t1
+ WHERE 1=0
+ limit 0
+) AS sq;
+
+SELECT * FROM (
+ SELECT
+ ROW_NUMBER() OVER(), i, sum(i)
+ FROM t1
+ WHERE 1=0
+ GROUP BY i
+) AS sq;
+drop table t1;
+
+create table t1 (a int);
+explain
+select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup;
+select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup;
+drop table t1;
+
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP
+HAVING @A := 'qwerty';
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP
+HAVING @A := 'qwerty';
+
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100)
+HAVING @A := 'qwerty';
+SELECT DISTINCT BIT_OR(100) OVER () FROM dual
+GROUP BY LEFT('2018-08-24', 100)
+HAVING @A := 'qwerty';
+
+create table t1 (a int);
+explain
+SELECT DISTINCT BIT_OR(100) OVER () FROM t1
+GROUP BY LEFT('2018-08-24', 100) having 1=1 limit 0;
+drop table t1;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 1fa80da85a6..a721aed6ce3 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2245,6 +2245,18 @@ JOIN::optimize_inner()
if (!tables_list || !table_count)
{
choose_tableless_subquery_plan();
+
+ /* The output has atmost one row */
+ if (group_list)
+ {
+ group_list= 0;
+ group_optimized_away= 1;
+ rollup.state= ROLLUP::STATE_NONE;
+ }
+ order=0;
+ simple_order=1;
+ select_distinct=0;
+
if (select_lex->have_window_funcs())
{
if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB))))
2
1
[Commits] 6915cb7: MDEV-17574 SIGSEGV or Assertion `producing_item != __null' in
by IgorBabaev 09 Nov '18
by IgorBabaev 09 Nov '18
09 Nov '18
revision-id: 6915cb7abe3ba6c237549e6a0803aba41787548e (mariadb-10.2.18-68-g6915cb7)
parent(s): 4142589207649e3317adc8c0d371897b7cb53733
author: Igor Babaev
committer: Igor Babaev
timestamp: 2018-11-08 22:54:03 -0800
message:
MDEV-17574 SIGSEGV or Assertion `producing_item != __null' in
Item_direct_view_ref::derived_field_transformer_for_where
upon updating a view
The condition pushed into a materialized derived / view mast be adjusted
for the new context: its column references must be substituted for
references to the columns of the underlying tables if the condition
is pushed into WHERE. The substitution is performed by the 'transform'
method. If the materialized derived is used in a mergeable view then
the references to the columns of the view are represented by
Item_direct_view_ref objects. The transform method first processes
the item wrapped in such an object and only after this it transforms
the object itself.
The transformation procedure of an Item_direct_view_ref object has
to know whether the item it wraps has been substituted. If so the
procedure does not have to do anything. In the code before this patch
it was not possible for the transformation procedure used by an
Item_direct_view_ref object to find out whether a substitution for
the wrapped item had happened.
---
mysql-test/r/derived_cond_pushdown.result | 93 +++++++++++++++++++++++++++++++
mysql-test/t/derived_cond_pushdown.test | 27 +++++++++
sql/item.cc | 32 ++++++++++-
sql/item.h | 1 +
4 files changed, 150 insertions(+), 3 deletions(-)
diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result
index f5bc72e..14c8e4d 100644
--- a/mysql-test/r/derived_cond_pushdown.result
+++ b/mysql-test/r/derived_cond_pushdown.result
@@ -10387,4 +10387,97 @@ f
3
DROP VIEW v1;
DROP TABLE t1;
+#
+# MDEV-17574: pushdown into derived from mergeable view
+# used in multi-table UPDATE
+# pushdown into materialized derived from mergeable view
+# used in SELECT
+#
+CREATE TABLE t1 (f1 text, f2 int);
+INSERT INTO t1 VALUES ('x',1), ('y',2);
+CREATE VIEW v1 AS SELECT f2 FROM ( SELECT f2 FROM t1 ) AS t;
+UPDATE v1, t1 SET t1.f1 = 'z' WHERE v1.f2 < 2 AND t1.f2 = v1.f2;
+EXPLAIN FORMAT=JSON UPDATE v1, t1 SET t1.f1 = 'z' WHERE v1.f2 < 2 AND t1.f2 = v1.f2;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t.f2 < 2",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t1.f2 < 2"
+ }
+ }
+ }
+ },
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t1.f2 = t.f2"
+ }
+ }
+}
+SELECT * FROM t1;
+f1 f2
+z 1
+y 2
+CREATE VIEW v2 AS SELECT f2 FROM ( SELECT DISTINCT f2 FROM t1 ) AS t;
+SELECT * FROM v2, t1 WHERE v2.f2 < 2 AND t1.f2 = v2.f2;
+f2 f1 f2
+1 z 1
+EXPLAIN FORMAT=JSON SELECT * FROM v2, t1 WHERE v2.f2 < 2 AND t1.f2 = v2.f2;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t.f2 < 2",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t1.f2 < 2"
+ }
+ }
+ }
+ }
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100
+ },
+ "buffer_type": "flat",
+ "buffer_size": "256Kb",
+ "join_type": "BNL",
+ "attached_condition": "t1.f2 = t.f2"
+ }
+ }
+}
+DROP VIEW v1,v2;
+DROP TABLE t1;
# End of 10.2 tests
diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test
index 46aa898..25cb29e 100644
--- a/mysql-test/t/derived_cond_pushdown.test
+++ b/mysql-test/t/derived_cond_pushdown.test
@@ -2075,4 +2075,31 @@ SELECT * FROM t1;
DROP VIEW v1;
DROP TABLE t1;
+--echo #
+--echo # MDEV-17574: pushdown into derived from mergeable view
+--echo # used in multi-table UPDATE
+--echo # pushdown into materialized derived from mergeable view
+--echo # used in SELECT
+--echo #
+
+CREATE TABLE t1 (f1 text, f2 int);
+INSERT INTO t1 VALUES ('x',1), ('y',2);
+
+CREATE VIEW v1 AS SELECT f2 FROM ( SELECT f2 FROM t1 ) AS t;
+let $q1 =
+UPDATE v1, t1 SET t1.f1 = 'z' WHERE v1.f2 < 2 AND t1.f2 = v1.f2;
+eval $q1;
+eval EXPLAIN FORMAT=JSON $q1;
+
+SELECT * FROM t1;
+
+CREATE VIEW v2 AS SELECT f2 FROM ( SELECT DISTINCT f2 FROM t1 ) AS t;
+let $q2 =
+SELECT * FROM v2, t1 WHERE v2.f2 < 2 AND t1.f2 = v2.f2;
+eval $q2;
+eval EXPLAIN FORMAT=JSON $q2;
+
+DROP VIEW v1,v2;
+DROP TABLE t1;
+
--echo # End of 10.2 tests
diff --git a/sql/item.cc b/sql/item.cc
index 2adec33..9ac1ed3 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -7143,13 +7143,21 @@ Item *Item_field::derived_field_transformer_for_having(THD *thd, uchar *arg)
return this;
if (!item_equal && used_tables() != tab_map)
return this;
- return get_field_item_for_having(thd, this, sel);
+ Item *item= get_field_item_for_having(thd, this, sel);
+ if (item)
+ item->marker|= SUBSTITUTION_FL;
+ return item;
}
Item *Item_direct_view_ref::derived_field_transformer_for_having(THD *thd,
uchar *arg)
{
+ if ((*ref)->marker & SUBSTITUTION_FL)
+ {
+ this->marker|= SUBSTITUTION_FL;
+ return this;
+ }
st_select_lex *sel= (st_select_lex *)arg;
table_map tab_map= sel->master_unit()->derived->table->map;
if ((item_equal && !(item_equal->used_tables() & tab_map)) ||
@@ -7200,13 +7208,20 @@ Item *Item_field::derived_field_transformer_for_where(THD *thd, uchar *arg)
st_select_lex *sel= (st_select_lex *)arg;
Item *producing_item= find_producing_item(this, sel);
if (producing_item)
- return producing_item->build_clone(thd, thd->mem_root);
+ {
+ Item *producing_clone= producing_item->build_clone(thd, thd->mem_root);
+ if (producing_clone)
+ producing_clone->marker|= SUBSTITUTION_FL;
+ return producing_clone;
+ }
return this;
}
Item *Item_direct_view_ref::derived_field_transformer_for_where(THD *thd,
uchar *arg)
{
+ if ((*ref)->marker & SUBSTITUTION_FL)
+ return (*ref);
if (item_equal)
{
st_select_lex *sel= (st_select_lex *)arg;
@@ -7258,7 +7273,13 @@ Item *Item_field::derived_grouping_field_transformer_for_where(THD *thd,
st_select_lex *sel= (st_select_lex *)arg;
Grouping_tmp_field *gr_field= find_matching_grouping_field(this, sel);
if (gr_field)
- return gr_field->producing_item->build_clone(thd, thd->mem_root);
+ {
+ Item *producing_clone=
+ gr_field->producing_item->build_clone(thd, thd->mem_root);
+ if (producing_clone)
+ producing_clone->marker|= SUBSTITUTION_FL;
+ return producing_clone;
+ }
return this;
}
@@ -7267,6 +7288,11 @@ Item *
Item_direct_view_ref::derived_grouping_field_transformer_for_where(THD *thd,
uchar *arg)
{
+ if ((*ref)->marker & SUBSTITUTION_FL)
+ {
+ this->marker|= SUBSTITUTION_FL;
+ return this;
+ }
if (!item_equal)
return this;
st_select_lex *sel= (st_select_lex *)arg;
diff --git a/sql/item.h b/sql/item.h
index 8d02d98..3a64ea1 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -147,6 +147,7 @@ bool mark_unsupported_function(const char *w1, const char *w2,
#define NO_EXTRACTION_FL (1 << 6)
#define FULL_EXTRACTION_FL (1 << 7)
+#define SUBSTITUTION_FL (1 << 8)
#define EXTRACTION_MASK (NO_EXTRACTION_FL | FULL_EXTRACTION_FL)
class DTCollation {
1
0
09 Nov '18
revision-id: 781f1a765b322d3d2a26c56e13d542403702a771 (mariadb-10.3.10-63-g781f1a765b3)
parent(s): 3074beaad6bf259c6427d77783ea821d0b16b424
author: Jan Lindström
committer: Jan Lindström
timestamp: 2018-11-09 08:41:05 +0200
message:
MDEV-17379: galera_new_cluster throws error in 10.3.10
Use exit instead of return.
---
scripts/galera_new_cluster.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/galera_new_cluster.sh b/scripts/galera_new_cluster.sh
index 5a8ca6958a7..e0763ed516a 100755
--- a/scripts/galera_new_cluster.sh
+++ b/scripts/galera_new_cluster.sh
@@ -28,4 +28,4 @@ extcode=$?
systemctl set-environment _WSREP_NEW_CLUSTER=''
-return $extcode
+exit $extcode
1
0
[Commits] 8dffa7eaf67: Merge remote-tracking branch 'origin/10.4' into bb-10.4-galera4
by jan 08 Nov '18
by jan 08 Nov '18
08 Nov '18
revision-id: 8dffa7eaf67cec01b91f521cf49447a34936ab92 (mariadb-10.3.6-186-g8dffa7eaf67)
parent(s): 6f6b74089cf7324205d4c774d30d35e6e650d003 c761b43451d54eeeecdf3c102906fcce88d4e9d9
author: Jan Lindström
committer: Jan Lindström
timestamp: 2018-11-08 13:57:59 +0200
message:
Merge remote-tracking branch 'origin/10.4' into bb-10.4-galera4
.gitignore | 1 +
CMakeLists.txt | 2 +-
README.md | 10 +-
client/CMakeLists.txt | 1 +
client/mysql.cc | 6 +-
client/mysqltest.cc | 2 +-
cmake/cpack_rpm.cmake | 3 +
cmake/libutils.cmake | 12 +-
cmake/os/Windows.cmake | 5 +-
cmake/plugin.cmake | 3 +-
cmake/ssl.cmake | 4 +-
cmake/zlib.cmake | 18 +-
configure.cmake | 11 +-
debian/autobake-deb.sh | 2 +-
debian/rules | 1 +
extra/mariabackup/backup_copy.cc | 4 +-
extra/mariabackup/backup_mysql.cc | 63 +-
extra/mariabackup/crc/crc-intel-pclmul.c | 2 +-
extra/mariabackup/innobackupex.cc | 4 +-
extra/mariabackup/xtrabackup.cc | 4 +-
extra/my_print_defaults.c | 29 +-
include/big_endian.h | 2 +-
include/byte_order_generic.h | 2 +-
include/byte_order_generic_x86.h | 2 +-
include/byte_order_generic_x86_64.h | 2 +-
include/little_endian.h | 2 +-
include/my_bit.h | 10 +-
include/my_cpu.h | 2 +-
include/my_global.h | 1 -
include/my_sys.h | 1 +
include/my_time.h | 7 +-
include/mysql/plugin_auth.h | 46 +-
include/mysql/plugin_auth.h.pp | 4 +
include/mysql/plugin_password_validation.h | 4 +-
include/mysql/plugin_password_validation.h.pp | 4 +-
include/mysql/service_kill_statement.h | 4 +-
include/wsrep.h | 14 +-
libmysqld/CMakeLists.txt | 2 +-
man/my_print_defaults.1 | 7 +-
mysql-test/dgcov.pl | 2 +-
mysql-test/include/diff_tables.inc | 2 +-
mysql-test/include/have_32bit.inc | 9 +
mysql-test/include/have_64bit.inc | 9 +
mysql-test/include/mtr_warnings.sql | 2 +-
mysql-test/lib/My/Config.pm | 6 +-
mysql-test/lib/v1/mysql-test-run.pl | 2 +-
mysql-test/main/alter_table.result | 53 +
mysql-test/main/alter_table.test | 50 +
mysql-test/main/alter_user.result | 35 +-
mysql-test/main/alter_user.test | 8 +-
.../main/auto_increment_ranges_innodb.result | 14 +
mysql-test/main/auto_increment_ranges_innodb.test | 13 +
mysql-test/main/brackets.result | 24 +
mysql-test/main/brackets.test | 18 +
mysql-test/main/cast.result | 2 +-
mysql-test/main/connect.result | 16 +-
mysql-test/main/connect.test | 19 +-
mysql-test/main/create_drop_user.result | 24 +-
mysql-test/main/create_drop_user.test | 8 +-
mysql-test/main/create_or_replace.result | 8 +-
mysql-test/main/create_or_replace.test | 8 +-
mysql-test/main/create_user.result | 24 +-
mysql-test/main/cte_recursive.result | 159 +
mysql-test/main/cte_recursive.test | 55 +
mysql-test/main/ctype_latin1.result | 9 +
mysql-test/main/ctype_latin1.test | 12 +
mysql-test/main/ctype_uca.result | 21 +
mysql-test/main/ctype_uca.test | 18 +
mysql-test/main/date_formats.result | 2 +-
mysql-test/main/derived_cond_pushdown.result | 15817 ++++++++++---------
mysql-test/main/derived_cond_pushdown.test | 3552 ++---
mysql-test/main/dyncol.result | 4 +-
mysql-test/main/failed_auth_3909.result | 8 +-
mysql-test/main/failed_auth_3909.test | 8 +-
mysql-test/main/failed_auth_unixsocket.result | 11 +-
mysql-test/main/failed_auth_unixsocket.test | 20 +-
mysql-test/main/flush.result | 1 -
mysql-test/main/flush.test | 1 -
mysql-test/main/func_concat.result | 20 +
mysql-test/main/func_concat.test | 22 +
mysql-test/main/func_in.result | 2 +-
mysql-test/main/func_sapdb.result | 2 +-
mysql-test/main/func_time.result | 38 +-
mysql-test/main/grant.result | 6 +-
mysql-test/main/grant2.result | 89 +-
mysql-test/main/grant2.test | 62 +-
mysql-test/main/grant4.result | 16 +-
mysql-test/main/grant5.result | 81 +
mysql-test/main/grant5.test | 60 +
mysql-test/main/index_merge_myisam.result | 50 +
mysql-test/main/index_merge_myisam.test | 35 +
mysql-test/main/init_file_set_password-7656.result | 6 +-
mysql-test/main/init_file_set_password-7656.test | 2 +-
mysql-test/main/join_nested_jcl6.result | 2 +-
mysql-test/main/join_outer.result | 68 +
mysql-test/main/join_outer.test | 60 +
mysql-test/main/join_outer_jcl6.result | 68 +
mysql-test/main/lock.result | 4 +-
mysql-test/main/lock.test | 4 +-
mysql-test/main/lock_multi.result | 12 +-
mysql-test/main/lock_multi.test | 14 +-
mysql-test/main/lowercase_fs_off.result | 68 +
mysql-test/main/lowercase_fs_off.test | 15 +
mysql-test/main/multi_update.result | 4 +-
mysql-test/main/mysqld--help.result | 5 +
mysql-test/main/mysqldump.test | 2 +-
mysql-test/main/mysqldump_restore.result | 20 -
.../main/no_password_column-mdev-11170.result | 2 +-
mysql-test/main/null.result | 16 +-
mysql-test/main/order_by_zerolength-4285.result | 20 +
mysql-test/main/order_by_zerolength-4285.test | 14 +
mysql-test/main/parser.result | 21 +
mysql-test/main/parser.test | 17 +
mysql-test/main/partition_explicit_prune.result | 19 +
mysql-test/main/partition_explicit_prune.test | 19 +
mysql-test/main/partition_pruning.result | 33 +
mysql-test/main/partition_pruning.test | 31 +
mysql-test/main/plugin.result | 45 +
mysql-test/main/plugin.test | 40 +
mysql-test/main/plugin_auth_qa.result | 32 +-
mysql-test/main/plugin_auth_qa_1.result | 42 +-
mysql-test/main/plugin_auth_qa_1.test | 2 +-
mysql-test/main/plugin_auth_qa_2.result | 22 +-
mysql-test/main/range.result | 8 +-
mysql-test/main/range_mrr_icp.result | 8 +-
mysql-test/main/select.result | 32 +-
mysql-test/main/select_jcl6.result | 32 +-
mysql-test/main/select_pkeycache.result | 32 +-
mysql-test/main/set_password.result | 8 +-
mysql-test/main/show_create_user.result | 4 +-
mysql-test/main/show_create_user.test | 2 +-
.../main/show_grants_with_plugin-7985.result | 4 +-
mysql-test/main/sp-security.result | 16 +-
mysql-test/main/sp-security.test | 15 +-
mysql-test/main/sp_notembedded.result | 2 +-
mysql-test/main/sp_notembedded.test | 2 +-
mysql-test/main/sql_safe_updates.opt | 1 +
mysql-test/main/sql_safe_updates.result | 3 +
mysql-test/main/sql_safe_updates.test | 4 +
mysql-test/main/str_to_datetime_457.result | 4 +-
mysql-test/main/type_date.result | 6 +-
mysql-test/main/type_datetime.result | 61 +-
mysql-test/main/type_datetime.test | 24 +-
mysql-test/main/type_newdecimal.result | 44 +-
mysql-test/main/type_newdecimal.test | 45 +-
mysql-test/main/type_temporal_innodb.result | 36 +-
mysql-test/main/type_time.result | 74 +
mysql-test/main/type_time.test | 42 +
mysql-test/main/type_timestamp.result | 2 +-
mysql-test/main/type_year.result | 18 +-
mysql-test/main/type_year.test | 18 +-
mysql-test/main/win.result | 401 +-
mysql-test/main/win.test | 45 +-
mysql-test/main/win_big.result | 12 -
mysql-test/main/win_first_last_value.result | 20 +-
mysql-test/main/win_percent_cume.result | 72 +-
mysql-test/main/win_percent_cume.test | 6 +-
mysql-test/main/win_percentile.result | 60 +-
mysql-test/main/win_percentile.test | 7 +
mysql-test/main/win_rank.result | 81 +-
mysql-test/main/win_rank.test | 17 +-
mysql-test/main/win_std.test | 4 +
mysql-test/mysql-test-run.pl | 2 +-
mysql-test/suite.pm | 6 +-
.../r/binlog_flush_binlogs_delete_domain.result | 12 +
.../t/binlog_flush_binlogs_delete_domain.test | 19 +
.../suite/binlog_encryption/rpl_corruption.result | 4 -
.../suite/binlog_encryption/rpl_loadfile.result | 4 -
.../rpl_mixed_binlog_max_cache_size.result | 28 -
.../binlog_encryption/rpl_special_charset.result | 4 -
.../rpl_stm_relay_ign_space.result | 4 -
.../rpl_switch_stm_row_mixed.result | 2 +-
mysql-test/suite/binlog_encryption/rpl_sync.result | 8 -
.../encryption/r/innodb-encryption-alter.result | 37 +
.../encryption/t/innodb-encryption-alter.test | 24 +
mysql-test/suite/funcs_1/r/innodb_func_view.result | 48 +-
.../suite/funcs_1/r/is_user_privileges.result | 66 +-
mysql-test/suite/funcs_1/r/memory_func_view.result | 48 +-
mysql-test/suite/funcs_1/r/myisam_func_view.result | 48 +-
mysql-test/suite/gcol/r/gcol_bug20746926.result | 8 +-
.../suite/gcol/r/innodb_virtual_index.result | 32 +
mysql-test/suite/gcol/t/innodb_virtual_index.test | 31 +
mysql-test/suite/heap/heap_btree.result | 4 +
mysql-test/suite/heap/heap_btree.test | 9 +
mysql-test/suite/innodb/include/alter_nocopy.inc | 33 -
.../suite/innodb/include/alter_nocopy_fail.inc | 51 -
mysql-test/suite/innodb/include/alter_not_null.inc | 94 -
.../innodb/include/innodb_binlog.combinations | 3 +
mysql-test/suite/innodb/include/innodb_binlog.inc | 3 +
.../suite/innodb/r/alter_algorithm,INPLACE.rdiff | 63 +-
.../suite/innodb/r/alter_algorithm,INSTANT.rdiff | 63 +-
.../suite/innodb/r/alter_algorithm,NOCOPY.rdiff | 63 +-
mysql-test/suite/innodb/r/alter_algorithm.result | 54 +-
.../suite/innodb/r/alter_inplace_perfschema.result | 20 +
mysql-test/suite/innodb/r/alter_instant,COPY.rdiff | 61 -
.../suite/innodb/r/alter_instant,INPLACE.rdiff | 11 -
.../suite/innodb/r/alter_instant,INSTANT.rdiff | 11 -
mysql-test/suite/innodb/r/alter_instant.result | 50 -
.../innodb/r/auto_increment_dup,skip-log-bin.rdiff | 51 +
.../suite/innodb/r/auto_increment_dup.result | 22 +-
mysql-test/suite/innodb/r/foreign_key.result | 59 +-
.../suite/innodb/r/innodb-alter-debug.result | 18 +-
mysql-test/suite/innodb/r/innodb-alter.result | 140 +-
mysql-test/suite/innodb/r/innodb_mysql.result | 2 +-
.../suite/innodb/r/table_flags,32k,debug.rdiff | 132 +
...ags,32k.rdiff => table_flags,32k,release.rdiff} | 0
.../suite/innodb/r/table_flags,64k,debug.rdiff | 132 +
...ags,64k.rdiff => table_flags,64k,release.rdiff} | 0
mysql-test/suite/innodb/r/table_flags,debug.rdiff | 122 +
mysql-test/suite/innodb/t/alter_algorithm.test | 127 +-
.../suite/innodb/t/alter_inplace_perfschema.opt | 2 +
.../suite/innodb/t/alter_inplace_perfschema.test | 40 +
mysql-test/suite/innodb/t/alter_instant.test | 45 -
mysql-test/suite/innodb/t/alter_not_null.test | 94 +-
mysql-test/suite/innodb/t/auto_increment_dup.test | 40 +-
mysql-test/suite/innodb/t/foreign_key.test | 94 +-
mysql-test/suite/innodb/t/innodb-alter-debug.test | 25 +-
mysql-test/suite/innodb/t/innodb-alter.test | 101 +-
mysql-test/suite/innodb/t/table_flags.test | 5 +-
.../innodb_gis/r/rtree_concurrent_srch.result | 4 +-
.../suite/innodb_gis/t/rtree_concurrent_srch.test | 2 +-
mysql-test/suite/maria/fulltext2.result | 86 +
mysql-test/suite/maria/fulltext2.test | 77 +
mysql-test/suite/plugins/r/auth_ed25519.result | 25 +-
.../suite/plugins/r/simple_password_check.result | 5 +-
mysql-test/suite/plugins/t/auth_ed25519.test | 9 +
.../suite/plugins/t/simple_password_check.test | 6 +-
.../rpl/include/rpl_lower_case_table_names.test | 141 +
mysql-test/suite/rpl/include/rpl_mixed_dml.inc | 1 -
mysql-test/suite/rpl/r/rpl_15919.result | 19 +
mysql-test/suite/rpl/r/rpl_auto_increment.result | 16 -
.../rpl/r/rpl_auto_increment_update_failure.result | 112 -
mysql-test/suite/rpl/r/rpl_binlog_index.result | 4 -
mysql-test/suite/rpl/r/rpl_checksum_cache.result | 24 -
.../suite/rpl/r/rpl_conditional_comments.result | 12 -
mysql-test/suite/rpl/r/rpl_corruption.result | 4 -
mysql-test/suite/rpl/r/rpl_create_drop_user.result | 44 +-
mysql-test/suite/rpl/r/rpl_current_user.result | 78 -
mysql-test/suite/rpl/r/rpl_do_grant.result | 1 +
mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result | 15 +-
mysql-test/suite/rpl/r/rpl_insert_ignore.result | 8 -
.../rpl/r/rpl_lcase_tblnames_rewrite_db.result | 38 +
mysql-test/suite/rpl/r/rpl_loaddata.result | 4 -
mysql-test/suite/rpl/r/rpl_loadfile.result | 4 -
.../suite/rpl/r/rpl_lost_events_on_rotate.result | 4 -
.../rpl/r/rpl_mixed_binlog_max_cache_size.result | 28 -
.../rpl/r/rpl_mixed_implicit_commit_binlog.result | 4 -
.../rpl/r/rpl_nondeterministic_functions.result | 4 -
mysql-test/suite/rpl/r/rpl_not_null_innodb.result | 16 -
mysql-test/suite/rpl/r/rpl_not_null_myisam.result | 16 -
mysql-test/suite/rpl/r/rpl_old_master.result | 3 +
mysql-test/suite/rpl/r/rpl_reset_slave_fail.result | 4 -
.../suite/rpl/r/rpl_row_basic_2myisam.result | 32 -
.../suite/rpl/r/rpl_row_basic_3innodb.result | 32 -
mysql-test/suite/rpl/r/rpl_row_find_row.result | 4 -
mysql-test/suite/rpl/r/rpl_row_img_blobs.result | 2016 ---
mysql-test/suite/rpl/r/rpl_row_img_eng_min.result | 1152 --
.../suite/rpl/r/rpl_row_img_eng_noblob.result | 1152 --
.../rpl/r/rpl_row_implicit_commit_binlog.result | 4 -
.../suite/rpl/r/rpl_row_lcase_tblnames.result | 60 +
.../suite/rpl/r/rpl_row_loaddata_concurrent.result | 4 -
mysql-test/suite/rpl/r/rpl_row_merge_engine.result | 16 -
.../suite/rpl/r/rpl_row_rec_comp_innodb.result | 12 -
.../suite/rpl/r/rpl_row_rec_comp_myisam.result | 16 -
mysql-test/suite/rpl/r/rpl_row_tbl_metadata.result | 44 -
mysql-test/suite/rpl/r/rpl_row_utf16.result | 4 -
mysql-test/suite/rpl/r/rpl_set_null_innodb.result | 16 -
mysql-test/suite/rpl/r/rpl_set_null_myisam.result | 16 -
mysql-test/suite/rpl/r/rpl_slave_load_in.result | 8 -
mysql-test/suite/rpl/r/rpl_special_charset.result | 4 -
.../rpl/r/rpl_stm_binlog_max_cache_size.result | 28 -
.../rpl/r/rpl_stm_implicit_commit_binlog.result | 4 -
.../suite/rpl/r/rpl_stm_lcase_tblnames.result | 57 +
.../suite/rpl/r/rpl_stm_loaddata_concurrent.result | 4 -
.../suite/rpl/r/rpl_stm_mixing_engines.result | 4 -
.../suite/rpl/r/rpl_stm_relay_ign_space.result | 4 -
.../suite/rpl/r/rpl_stm_user_variables.result | 4 -
mysql-test/suite/rpl/r/rpl_stop_slave.result | 8 -
.../suite/rpl/r/rpl_switch_stm_row_mixed.result | 2 +-
mysql-test/suite/rpl/r/rpl_sync.result | 8 -
.../suite/rpl/r/rpl_temp_table_mix_row.result | 4 -
mysql-test/suite/rpl/r/rpl_test_framework.result | 126 -
mysql-test/suite/rpl/r/rpl_trigger.result | 8 -
mysql-test/suite/rpl/r/rpl_truncate_2myisam.result | 16 -
mysql-test/suite/rpl/r/rpl_truncate_3innodb.result | 16 -
mysql-test/suite/rpl/r/rpl_typeconv_innodb.result | 4 -
.../suite/rpl/r/rpl_unsafe_statements.result | 24 -
mysql-test/suite/rpl/r/rpl_variables.result | 20 -
mysql-test/suite/rpl/r/rpl_variables_stm.result | 20 -
mysql-test/suite/rpl/t/rpl_15919-slave.opt | 1 +
mysql-test/suite/rpl/t/rpl_15919.test | 18 +
mysql-test/suite/rpl/t/rpl_create_drop_user.test | 18 +-
mysql-test/suite/rpl/t/rpl_do_grant.test | 1 +
.../rpl/t/rpl_lcase_tblnames_rewrite_db-slave.opt | 1 +
.../suite/rpl/t/rpl_lcase_tblnames_rewrite_db.test | 60 +
mysql-test/suite/rpl/t/rpl_old_master.test | 8 +
.../suite/rpl/t/rpl_row_lcase_tblnames-slave.opt | 1 +
mysql-test/suite/rpl/t/rpl_row_lcase_tblnames.test | 12 +
.../suite/rpl/t/rpl_stm_lcase_tblnames-slave.opt | 1 +
mysql-test/suite/rpl/t/rpl_stm_lcase_tblnames.test | 12 +
mysql-test/suite/sql_sequence/create.result | 9 +
mysql-test/suite/sql_sequence/create.test | 11 +
.../sys_vars/r/delayed_insert_limit_func.result | 4 +-
.../r/innodb_ft_result_cache_limit_32.result | 7 +
.../r/innodb_ft_result_cache_limit_64.result | 5 +
.../innodb_ft_result_cache_limit_basic,32bit.rdiff | 13 +
.../r/innodb_ft_result_cache_limit_basic.result | 7 +-
.../r/sql_low_priority_updates_func.result | 4 +-
.../suite/sys_vars/r/sysvars_innodb,32bit.rdiff | 118 +-
mysql-test/suite/sys_vars/r/sysvars_innodb.result | 2 +-
.../sys_vars/r/sysvars_server_notembedded.result | 2 +-
.../suite/sys_vars/r/thread_pool_size_high.result | 1 +
.../sys_vars/t/delayed_insert_limit_func.test | 20 +-
.../t/innodb_ft_result_cache_limit_32.test | 9 +
.../t/innodb_ft_result_cache_limit_64.test | 9 +
.../t/innodb_ft_result_cache_limit_basic.test | 5 +-
.../sys_vars/t/sql_low_priority_updates_func.test | 4 +-
.../suite/sys_vars/t/thread_pool_size_high.test | 1 +
mysql-test/suite/vcol/r/races.result | 16 +
mysql-test/suite/vcol/r/wrong_arena.result | 28 +-
mysql-test/suite/vcol/t/races.test | 22 +
mysql-test/suite/versioning/innodb.combinations | 5 +
mysql-test/suite/versioning/innodb.inc | 1 +
mysql-test/suite/versioning/r/alter.result | 2 +-
mysql-test/suite/versioning/r/online.result | 131 +-
mysql-test/suite/versioning/r/partition.result | 8 +-
.../trx_id_versioning_attribute_persistence.result | 86 -
mysql-test/suite/versioning/t/online.test | 145 +-
.../t/trx_id_versioning_attribute_persistence.test | 87 -
mysys/CMakeLists.txt | 1 +
mysys/mf_iocache.c | 20 +-
mysys/mf_iocache2.c | 4 +-
mysys/my_alloc.c | 11 +
mysys/my_pread.c | 26 +-
mysys/ptr_cmp.c | 7 +
plugin/auth_ed25519/ed25519-t.c | 2 +-
plugin/auth_ed25519/server_ed25519.c | 47 +-
plugin/auth_examples/dialog_examples.c | 6 +-
plugin/auth_examples/qa_auth_interface.c | 3 +-
plugin/auth_examples/qa_auth_server.c | 3 +-
plugin/auth_examples/test_plugin.c | 6 +-
.../auth_gssapi/mysql-test/auth_gssapi/basic.test | 1 +
plugin/auth_gssapi/sspi_server.cc | 9 +-
plugin/auth_pam/auth_pam_common.c | 3 +-
plugin/auth_socket/auth_socket.c | 3 +-
.../cracklib_password_check.c | 3 +-
.../simple_password_check/simple_password_check.c | 4 +-
plugin/user_variables/user_variables.cc | 2 +-
scripts/mysql_system_tables_fix.sql | 11 +-
sql-common/my_time.c | 16 +-
sql/CMakeLists.txt | 4 +-
sql/compat56.cc | 3 +
sql/events.cc | 20 +-
sql/field.cc | 17 +-
sql/field.h | 8 +-
sql/field_conv.cc | 2 +-
sql/ha_partition.cc | 9 +-
sql/ha_partition.h | 5 +-
sql/handler.cc | 2 +-
sql/handler.h | 51 +-
sql/item.cc | 59 +-
sql/item.h | 43 +-
sql/item_cmpfunc.cc | 15 +-
sql/item_func.cc | 35 -
sql/item_func.h | 47 +-
sql/item_subselect.cc | 3 +-
sql/item_sum.cc | 24 +-
sql/item_sum.h | 6 +-
sql/item_timefunc.cc | 6 +-
sql/item_timefunc.h | 2 +-
sql/lock.cc | 16 -
sql/lock.h | 1 -
sql/log_event.cc | 49 +-
sql/my_decimal.h | 2 -
sql/mysql_install_db.cc | 88 +-
sql/mysqld.cc | 12 +
sql/opt_range.cc | 6 +
sql/procedure.h | 2 +-
sql/rpl_gtid.cc | 6 +-
sql/share/errmsg-utf8.txt | 2 +-
sql/slave.cc | 13 +
sql/sql_acl.cc | 1436 +-
sql/sql_admin.cc | 9 +
sql/sql_alter.cc | 7 +-
sql/sql_alter.h | 2 +-
sql/sql_base.cc | 6 +-
sql/sql_class.cc | 8 +
sql/sql_const.h | 2 +-
sql/sql_cte.cc | 2 +-
sql/sql_delete.cc | 2 +-
sql/sql_error.h | 55 +-
sql/sql_get_diagnostics.cc | 2 +-
sql/sql_get_diagnostics.h | 2 +-
sql/sql_insert.cc | 3 +-
sql/sql_lex.cc | 9 +-
sql/sql_lex.h | 6 +-
sql/sql_parse.cc | 10 +-
sql/sql_partition.cc | 2 +-
sql/sql_partition_admin.cc | 4 +-
sql/sql_plugin.cc | 73 +-
sql/sql_prepare.cc | 2 +-
sql/sql_select.cc | 201 +-
sql/sql_select.h | 8 +-
sql/sql_table.cc | 18 +-
sql/sql_time.cc | 83 +-
sql/sql_trigger.cc | 18 +-
sql/sql_type.cc | 210 +-
sql/sql_type.h | 321 +-
sql/sql_type_int.h | 50 +-
sql/sql_update.cc | 2 +-
sql/sql_view.cc | 12 +-
sql/sql_window.cc | 17 +-
sql/sql_window.h | 4 +-
sql/sql_yacc.yy | 61 +-
sql/sql_yacc_ora.yy | 38 +-
sql/structs.h | 7 +-
sql/sys_vars.cc | 2 +-
sql/table.cc | 20 +-
sql/table.h | 4 +-
sql/wsrep_mysqld.cc | 5 +-
storage/connect/CMakeLists.txt | 9 +
storage/connect/connect.cc | 2 +-
storage/connect/global.h | 4 +-
storage/connect/ha_connect.cc | 104 +-
storage/connect/ha_connect.h | 6 +-
storage/connect/mysql-test/connect/disabled.def | 23 +-
.../connect/mysql-test/connect/r/mysql_exec.result | 6 +
.../mysql-test/connect/r/odbc_postgresql.result | 18 +-
storage/connect/odbconn.cpp | 10 +-
storage/connect/tabext.cpp | 6 +
storage/connect/tabjdbc.cpp | 9 +-
storage/connect/tabmysql.cpp | 11 +-
storage/connect/tabodbc.cpp | 13 +-
storage/heap/hp_create.c | 22 +-
storage/innobase/btr/btr0btr.cc | 6 +-
storage/innobase/btr/btr0cur.cc | 2 +-
storage/innobase/btr/btr0sea.cc | 2 +-
storage/innobase/buf/buf0buf.cc | 57 +-
storage/innobase/buf/buf0dblwr.cc | 2 +-
storage/innobase/buf/buf0flu.cc | 4 +-
storage/innobase/buf/buf0lru.cc | 3 +-
storage/innobase/buf/buf0rea.cc | 10 +-
storage/innobase/dict/dict0crea.cc | 15 +
storage/innobase/dict/dict0dict.cc | 8 +-
storage/innobase/dict/dict0mem.cc | 4 +-
storage/innobase/fil/fil0fil.cc | 27 +-
storage/innobase/fsp/fsp0fsp.cc | 32 +-
storage/innobase/fts/fts0fts.cc | 2 +-
storage/innobase/fts/fts0que.cc | 2 +-
storage/innobase/gis/gis0sea.cc | 5 +-
storage/innobase/handler/ha_innodb.cc | 54 +-
storage/innobase/handler/ha_innodb.h | 10 +-
storage/innobase/handler/handler0alter.cc | 92 +-
storage/innobase/ibuf/ibuf0ibuf.cc | 28 +-
storage/innobase/include/btr0btr.h | 8 +-
storage/innobase/include/btr0btr.ic | 4 +-
storage/innobase/include/btr0cur.h | 2 +-
storage/innobase/include/btr0sea.h | 2 +-
storage/innobase/include/buf0buf.h | 114 +-
storage/innobase/include/buf0buf.ic | 26 +-
storage/innobase/include/buf0rea.h | 8 +-
storage/innobase/include/fil0fil.h | 62 +-
storage/innobase/include/fsp0fsp.h | 40 +-
storage/innobase/include/fsp0fsp.ic | 2 +-
storage/innobase/include/fts0fts.h | 2 +-
storage/innobase/include/fts0types.h | 4 +-
storage/innobase/include/ha_prototypes.h | 3 +
storage/innobase/include/ibuf0ibuf.h | 12 +-
storage/innobase/include/ibuf0ibuf.ic | 2 +-
storage/innobase/include/mtr0mtr.h | 28 +-
storage/innobase/include/page0page.h | 2 +-
storage/innobase/include/trx0rec.h | 3 +-
storage/innobase/include/trx0sys.h | 4 +-
storage/innobase/include/trx0undo.h | 4 +-
storage/innobase/include/trx0undo.ic | 4 +-
storage/innobase/include/univ.i | 2 +-
storage/innobase/log/log0recv.cc | 5 +-
storage/innobase/mtr/mtr0mtr.cc | 27 +-
storage/innobase/page/page0page.cc | 2 +-
storage/innobase/que/que0que.cc | 3 +-
storage/innobase/row/row0import.cc | 5 +-
storage/innobase/row/row0ins.cc | 63 +-
storage/innobase/row/row0merge.cc | 20 +-
storage/innobase/row/row0mysql.cc | 196 +-
storage/innobase/row/row0row.cc | 4 +-
storage/innobase/row/row0upd.cc | 2 +
storage/innobase/srv/srv0start.cc | 8 +-
storage/innobase/trx/trx0purge.cc | 2 +-
storage/innobase/trx/trx0rec.cc | 3 +-
storage/innobase/trx/trx0trx.cc | 7 +-
storage/maria/ma_check.c | 5 +-
storage/maria/ma_ft_boolean_search.c | 2 +-
storage/maria/ma_write.c | 15 +-
storage/mroonga/ha_mroonga.cpp | 9 +-
storage/mroonga/ha_mroonga.hpp | 2 +-
.../mroonga/lib/mrn_multiple_column_key_codec.cpp | 4 +-
.../mysql-test/storage_engine/disabled.def | 1 +
storage/perfschema/unittest/pfs-t.cc | 5 +-
storage/rocksdb/event_listener.cc | 2 +-
storage/rocksdb/event_listener.h | 2 +-
storage/rocksdb/ha_rocksdb.cc | 12 +-
storage/rocksdb/ha_rocksdb.h | 2 +-
storage/rocksdb/ha_rocksdb_proto.h | 2 +-
storage/rocksdb/logger.h | 2 +-
.../mysql-test/rocksdb/r/rocksdb_range2.result | 17 +
storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 1 +
.../mysql-test/rocksdb/t/rocksdb_range2.test | 12 +
storage/rocksdb/properties_collector.cc | 2 +-
storage/rocksdb/properties_collector.h | 2 +-
storage/rocksdb/rdb_buff.h | 2 +-
storage/rocksdb/rdb_cf_manager.cc | 2 +-
storage/rocksdb/rdb_cf_manager.h | 2 +-
storage/rocksdb/rdb_cf_options.cc | 2 +-
storage/rocksdb/rdb_cf_options.h | 2 +-
storage/rocksdb/rdb_compact_filter.h | 2 +-
storage/rocksdb/rdb_comparator.h | 2 +-
storage/rocksdb/rdb_datadic.cc | 2 +-
storage/rocksdb/rdb_datadic.h | 2 +-
storage/rocksdb/rdb_i_s.cc | 2 +-
storage/rocksdb/rdb_i_s.h | 2 +-
storage/rocksdb/rdb_index_merge.cc | 2 +-
storage/rocksdb/rdb_index_merge.h | 2 +-
storage/rocksdb/rdb_io_watchdog.cc | 2 +-
storage/rocksdb/rdb_io_watchdog.h | 2 +-
storage/rocksdb/rdb_mutex_wrapper.cc | 2 +-
storage/rocksdb/rdb_mutex_wrapper.h | 2 +-
storage/rocksdb/rdb_perf_context.cc | 2 +-
storage/rocksdb/rdb_perf_context.h | 2 +-
storage/rocksdb/rdb_sst_info.cc | 2 +-
storage/rocksdb/rdb_sst_info.h | 2 +-
storage/rocksdb/rdb_threads.cc | 2 +-
storage/rocksdb/rdb_threads.h | 2 +-
storage/rocksdb/rdb_utils.cc | 2 +-
storage/rocksdb/rdb_utils.h | 2 +-
.../rocksdb/unittest/test_properties_collector.cc | 2 +-
.../mysql-test/spider/r/show_system_tables.result | 20 +-
.../mysql-test/spider/t/show_system_tables.test | 7 +-
.../mysql-test/rpl/r/rpl_not_null_tokudb.result | 16 -
.../rpl/r/rpl_parallel_tokudb_delete_pk.result | 8 -
...pl_parallel_tokudb_update_pk_uc0_lookup0.result | 8 -
.../rpl/r/rpl_parallel_tokudb_write_pk.result | 4 -
.../mysql-test/rpl/r/rpl_row_basic_3tokudb.result | 32 -
.../rpl/r/rpl_row_rec_comp_tokudb.result | 12 -
.../mysql-test/rpl/r/rpl_set_null_tokudb.result | 16 -
.../mysql-test/rpl/r/rpl_tokudb_mixed_dml.result | 15 +-
.../mysql-test/rpl/r/rpl_truncate_3tokudb.result | 16 -
.../mysql-test/rpl/r/rpl_typeconv_tokudb.result | 4 -
.../mysql-test/rpl/r/rpl_xa_interleave.result | 4 -
.../mysql-test/rpl/r/tokudb_innodb_xa_crash.result | 8 -
.../tokudb/r/change_column_bin_descriptor.result | 4 -
.../tokudb/r/change_column_bin_rename.result | 64 -
.../tokudb/r/change_column_blob_data.result | 72 -
.../tokudb/r/change_column_char_descriptor.result | 4 -
.../tokudb/r/change_column_char_rename.result | 64 -
.../mysql-test/tokudb/r/change_column_int.result | 120 -
.../tokudb/r/change_column_int_descriptor.result | 4 -
.../tokudb/r/change_column_int_rename.result | 40 -
.../tokudb/r/change_column_text_data.result | 72 -
.../r/change_column_varbin_descriptor.result | 4 -
.../r/change_column_varchar_descriptor.result | 4 -
.../mysql-test/tokudb/r/type_datetime.result | 8 +-
.../tokudb_alter_table/r/hcad_all_add.result | 1736 --
.../tokudb_alter_table/r/hcad_all_add2.result | 1736 --
.../tokudb_alter_table/r/hcad_all_add3.result | 1736 --
.../tokudb_alter_table/r/hcad_all_blob_add.result | 1736 --
.../tokudb_alter_table/r/hcad_all_blob_drop.result | 160 -
.../tokudb_alter_table/r/hcad_all_drop.result | 1232 --
.../tokudb_alter_table/r/hcad_all_fixed_add.result | 1736 --
.../r/hcad_all_fixed_drop.result | 160 -
.../tokudb_alter_table/r/hcad_all_var_add.result | 1736 --
.../tokudb_alter_table/r/hcad_all_var_drop.result | 160 -
.../tokudb_alter_table/r/hcad_clustering.result | 32 -
.../tokudb_alter_table/r/hcad_clustering2.result | 32 -
.../r/hcad_diff_num_offset_bytes.result | 84 -
.../tokudb_alter_table/r/hcad_fixedblob_add.result | 1736 --
.../r/hcad_fixedblob_add2.result | 1736 --
.../r/hcad_fixedblob_drop.result | 560 -
.../tokudb_alter_table/r/hcad_fixedvar_add.result | 1736 --
.../tokudb_alter_table/r/hcad_fixedvar_add2.result | 1736 --
.../tokudb_alter_table/r/hcad_fixedvar_drop.result | 560 -
.../tokudb_alter_table/r/hcad_null_bits.result | 68 -
.../mysql-test/tokudb_alter_table/r/hcad_pk.result | 32 -
.../tokudb_alter_table/r/hcad_pk2.result | 32 -
.../tokudb_alter_table/r/hcad_varblob_add.result | 1736 --
.../tokudb_alter_table/r/hcad_varblob_add2.result | 1736 --
.../tokudb_alter_table/r/hcad_varblob_drop.result | 560 -
.../tokudb_alter_table/r/other_alter2.result | 72 -
.../tokudb_bugs/r/alter_part_tokudb_bug_155.result | 4 -
.../tokudb/mysql-test/tokudb_bugs/r/db743.result | 4 -
.../mysql-test/tokudb_bugs/r/mdev5932.result | 4 -
strings/ctype-simple.c | 4 +-
strings/ctype-uca.c | 116 +-
strings/ctype-uca.ic | 39 +
strings/ctype-utf8.c | 46 +-
strings/decimal.c | 35 +-
support-files/mysql.server.sh | 31 +-
unittest/sql/mf_iocache-t.cc | 88 +-
vio/viossl.c | 10 +-
zlib/CMakeLists.txt | 156 +-
zlib/ChangeLog | 666 +-
zlib/FAQ | 267 +-
zlib/INDEX | 41 +-
zlib/README | 94 +-
zlib/README.MySQL | 16 -
zlib/adler32.c | 113 +-
zlib/algorithm.txt | 209 -
zlib/amiga/Makefile.pup | 69 +
zlib/amiga/Makefile.sas | 68 +
zlib/compress.c | 45 +-
zlib/crc32.c | 149 +-
zlib/crc32.h | 2 +-
zlib/deflate.c | 1269 +-
zlib/deflate.h | 78 +-
zlib/gzclose.c | 25 +
zlib/gzguts.h | 218 +
zlib/gzio.c | 1031 --
zlib/gzlib.c | 637 +
zlib/gzread.c | 654 +
zlib/gzwrite.c | 665 +
zlib/infback.c | 107 +-
zlib/inffast.c | 159 +-
zlib/inffast.h | 4 +-
zlib/inffixed.h | 6 +-
zlib/inflate.c | 507 +-
zlib/inflate.h | 38 +-
zlib/inftrees.c | 109 +-
zlib/inftrees.h | 27 +-
zlib/make_vms.com | 867 +
zlib/msdos/Makefile.bor | 115 +
zlib/msdos/Makefile.dj2 | 104 +
zlib/msdos/Makefile.emx | 69 +
zlib/msdos/Makefile.msc | 112 +
zlib/msdos/Makefile.tc | 100 +
zlib/nintendods/README | 5 +
zlib/old/Makefile.emx | 69 +
zlib/old/Makefile.riscos | 151 +
zlib/old/README | 3 +
zlib/old/descrip.mms | 48 +
zlib/old/os2/Makefile.os2 | 136 +
zlib/old/os2/zlib.def | 51 +
zlib/old/visual-basic.txt | 160 +
zlib/os400/README400 | 48 +
zlib/os400/bndsrc | 119 +
zlib/os400/make.sh | 366 +
zlib/os400/zlib.inc | 527 +
zlib/qnx/package.qpg | 141 +
zlib/test/example.c | 602 +
zlib/test/infcover.c | 671 +
zlib/test/minigzip.c | 651 +
zlib/treebuild.xml | 116 +
zlib/trees.c | 246 +-
zlib/trees.h | 4 +-
zlib/uncompr.c | 100 +-
zlib/watcom/watcom_f.mak | 43 +
zlib/watcom/watcom_l.mak | 43 +
zlib/win32/DLL_FAQ.txt | 397 +
zlib/win32/Makefile.bor | 110 +
zlib/win32/Makefile.gcc | 182 +
zlib/win32/Makefile.msc | 163 +
zlib/win32/README-WIN32.txt | 103 +
zlib/win32/VisualC.txt | 3 +
zlib/win32/zlib.def | 94 +
zlib/win32/zlib1.rc | 40 +
zlib/zconf.h.cmakein | 536 +
zlib/{zconf.h => zconf.h.in} | 324 +-
zlib/zlib.3 | 122 +-
zlib/zlib.h | 1639 +-
zlib/zlib.pc.cmakein | 13 +
zlib/zlib.pc.in | 13 +
zlib/zlib2ansi | 152 +
zlib/zutil.c | 101 +-
zlib/zutil.h | 192 +-
672 files changed, 31897 insertions(+), 47669 deletions(-)
diff --cc include/wsrep.h
index abe3bcc7b8c,f7a9b6b0231..ce085ababb4
--- a/include/wsrep.h
+++ b/include/wsrep.h
@@@ -25,18 -25,15 +25,18 @@@
#define WSREP_MYSQL_DB (char *)"mysql"
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \
if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \
- goto error;
+ goto wsrep_error_label;
#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_) \
- if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, \
- table_list_, alter_info_)) \
+ if (WSREP_ON && WSREP(thd) && wsrep_thd_is_local(thd) && \
+ wsrep_to_isolation_begin(thd, db_, table_, \
+ table_list_, alter_info_)) \
- goto error;
+ goto wsrep_error_label;
-#define WSREP_TO_ISOLATION_END \
- if (WSREP_ON && (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER))) \
+#define WSREP_TO_ISOLATION_END \
+ if (WSREP_ON && WSREP(thd) && \
+ (wsrep_thd_is_local_toi(thd) || \
+ wsrep_thd_is_in_rsu(thd))) \
wsrep_to_isolation_end(thd);
/*
@@@ -45,38 -42,31 +45,38 @@@
*/
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \
if (WSREP(thd) && !thd->lex->no_write_to_binlog \
- && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error;
+ && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto wsrep_error_label;
+#define WSREP_SYNC_WAIT(thd_, before_) \
+ { if (WSREP_CLIENT(thd_) && \
+ wsrep_sync_wait(thd_, before_)) goto error; }
+
+
#define WSREP_DEBUG(...) \
if (wsrep_debug) WSREP_LOG(sql_print_information, ##__VA_ARGS__)
#define WSREP_INFO(...) WSREP_LOG(sql_print_information, ##__VA_ARGS__)
#define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__)
#define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__)
- #define WSREP_SYNC_WAIT(thd_, before_) \
- { if (WSREP_CLIENT(thd_) && \
- wsrep_sync_wait(thd_, before_)) goto error; }
+ #define WSREP_SYNC_WAIT(thd_, before_) \
+ { if (WSREP_CLIENT(thd_) && \
+ wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; }
-#else
+#else /* !WITH_WSREP */
+
+/* These macros are needed to compile MariaDB without WSREP support
+ * (e.g. embedded) */
+
#define IF_WSREP(A,B) B
-#define DBUG_ASSERT_IF_WSREP(A)
+//#define DBUG_ASSERT_IF_WSREP(A)
#define WSREP_DEBUG(...)
-#define WSREP_INFO(...)
-#define WSREP_WARN(...)
+//#define WSREP_INFO(...)
+//#define WSREP_WARN(...)
#define WSREP_ERROR(...)
- #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_)
+ #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) do { } while(0)
-#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_)
-#define WSREP_TO_ISOLATION_END
+//#define WSREP_TO_ISOLATION_END
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)
#define WSREP_SYNC_WAIT(thd_, before_)
-
#endif /* WITH_WSREP */
#endif /* WSREP_INCLUDED */
diff --cc sql/sql_base.cc
index 61976aabe2e,fc8a20404a3..acb56e4ed61
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@@ -4307,14 -4293,13 +4307,17 @@@ restart
thd->lex->sql_command == SQLCOM_LOAD ||
thd->lex->sql_command == SQLCOM_DELETE)))
{
- WSREP_TO_ISOLATION_BEGIN(NULL, NULL, (*start));
+ wsrep_before_rollback(thd, true);
+ wsrep_after_rollback(thd, true);
+ wsrep_after_statement(thd);
+ WSREP_TO_ISOLATION_BEGIN(NULL, NULL, (*start));
}
+#endif /* WITH_WSREP */
error:
+ #ifdef WITH_WSREP
+ wsrep_error_label:
+ #endif
THD_STAGE_INFO(thd, stage_after_opening_tables);
thd_proc_info(thd, 0);
diff --cc sql/sql_parse.cc
index ea24b2e74a3,1f9cd305847..cde1af33d82
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@@ -109,13 -109,11 +109,14 @@@
#include "../storage/maria/ha_maria.h"
#endif
+ #include "wsrep.h"
#include "wsrep_mysqld.h"
+#ifdef WITH_WSREP
+#include "mysql/service_wsrep.h"
#include "wsrep_thd.h"
+#include "wsrep_trans_observer.h" /* wsrep transaction hooks */
-static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
+static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
Parser_state *parser_state,
bool is_com_multi,
bool is_next_command);
diff --cc sql/wsrep_mysqld.cc
index 1d909fdce75,bc52bff0de9..507293186b5
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@@ -2953,13 -2730,15 +2953,14 @@@ bool wsrep_create_like_table(THD* thd,
}
return(false);
-
- error:
+ #ifdef WITH_WSREP
+ wsrep_error_label:
thd->wsrep_TOI_pre_query= NULL;
return (true);
+ #endif
}
-
-static int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len)
+int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len)
{
LEX *lex= thd->lex;
String stmt_query;
1
0
revision-id: 6f6b74089cf7324205d4c774d30d35e6e650d003 (mariadb-10.3.6-185-g6f6b74089cf)
parent(s): 4f5d633547688f071df517483f791457bf87873a
author: Jan Lindström
committer: Jan Lindström
timestamp: 2018-11-08 12:37:24 +0200
message:
Remove extra WITH_WSREP.
---
storage/innobase/trx/trx0trx.cc | 3 ---
1 file changed, 3 deletions(-)
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 388cd3c8174..600a6eb6229 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -55,9 +55,6 @@ Created 3/26/1996 Heikki Tuuri
#include <set>
#include <new>
-#ifdef WITH_WSREP
-#include "mysql/service_wsrep.h"
-#endif /* WITH_WSREP */
/** The bit pattern corresponding to TRX_ID_MAX */
const byte trx_id_max_bytes[8] = {
1
0
[Commits] 0187bb03884: MDEV_-17589: Stack-buffer-overflow with indexed varchar (utf8) field
by varunraiko1803@gmail.com 08 Nov '18
by varunraiko1803@gmail.com 08 Nov '18
08 Nov '18
revision-id: 0187bb03884a34ca8de96e47f4cb1f3d860e6db9 (mariadb-10.2.16-224-g0187bb03884)
parent(s): 8a346f31b913daa011085afec2b2d38450c73e00
author: Varun Gupta
committer: Varun Gupta
timestamp: 2018-11-05 19:32:26 +0530
message:
MDEV_-17589: Stack-buffer-overflow with indexed varchar (utf8) field
Create a new constant MAX_DATA_LENGTH_FOR_KEY.
Replace the value of MAX_KEY_LENGTH to also include the LENGTH and NULL BYTES.
---
mysql-test/r/func_group_innodb.result | 23 +++++++++++++++++++++++
mysql-test/r/innodb_ext_key.result | 4 ++--
mysql-test/r/partition_datatype.result | 2 +-
mysql-test/r/partition_utf8.result | 2 +-
mysql-test/t/func_group_innodb.test | 18 ++++++++++++++++++
mysql-test/t/partition_datatype.test | 2 +-
mysql-test/t/partition_utf8.test | 2 +-
sql/handler.h | 10 +++++++---
sql/sql_const.h | 2 +-
9 files changed, 55 insertions(+), 10 deletions(-)
diff --git a/mysql-test/r/func_group_innodb.result b/mysql-test/r/func_group_innodb.result
index 52d5922df95..c2bfe9bf81c 100644
--- a/mysql-test/r/func_group_innodb.result
+++ b/mysql-test/r/func_group_innodb.result
@@ -246,4 +246,27 @@ EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL b 263 NULL 3 Using index for group-by
DROP TABLE t1;
+#
+# MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) field
+#
+CREATE TABLE t1 (v1 varchar(1020), v2 varchar(2), v3 varchar(2), KEY k1 (v3,v2,v1)) ENGINE=InnoDB CHARACTER SET=utf8;
+INSERT INTO t1 VALUES ('king', 'qu','qu'), ('bad','go','go');
+explain
+SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu';
+MIN(t1.v1)
+king
+drop table t1;
+CREATE TABLE t1 (v1 varchar(1024) CHARACTER SET utf8, KEY v1 (v1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES ('king'), ('bad');
+explain
+SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x;
+MIN(x.v1)
+NULL
+drop table t1;
End of 5.5 tests
diff --git a/mysql-test/r/innodb_ext_key.result b/mysql-test/r/innodb_ext_key.result
index c55e8d138f8..c76c8613c57 100644
--- a/mysql-test/r/innodb_ext_key.result
+++ b/mysql-test/r/innodb_ext_key.result
@@ -1168,8 +1168,8 @@ EXPLAIN
"access_type": "range",
"possible_keys": ["f2"],
"key": "f2",
- "key_length": "3070",
- "used_key_parts": ["f2", "pk1"],
+ "key_length": "3074",
+ "used_key_parts": ["f2", "pk1", "pk2"],
"rows": 1,
"filtered": 100,
"index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'",
diff --git a/mysql-test/r/partition_datatype.result b/mysql-test/r/partition_datatype.result
index 2e518c194f0..66d003c97cb 100644
--- a/mysql-test/r/partition_datatype.result
+++ b/mysql-test/r/partition_datatype.result
@@ -314,7 +314,7 @@ bbbb
drop table t1;
set sql_mode='';
create table t1 (a varchar(3070)) partition by key (a);
-ERROR HY000: The total length of the partitioning fields is too large
+drop table t1;
create table t1 (a varchar(65532) not null) partition by key (a);
ERROR HY000: The total length of the partitioning fields is too large
create table t1 (a varchar(65533)) partition by key (a);
diff --git a/mysql-test/r/partition_utf8.result b/mysql-test/r/partition_utf8.result
index 7718e651423..5c0d4d86e8e 100644
--- a/mysql-test/r/partition_utf8.result
+++ b/mysql-test/r/partition_utf8.result
@@ -24,7 +24,7 @@ drop table t1;
create table t1 (a varchar(1500), b varchar(1570))
partition by list columns(a,b)
( partition p0 values in (('a','b')));
-ERROR HY000: The total length of the partitioning fields is too large
+drop table t1;
create table t1 (a varchar(1023) character set utf8 collate utf8_spanish2_ci)
partition by range columns(a)
( partition p0 values less than ('CZ'),
diff --git a/mysql-test/t/func_group_innodb.test b/mysql-test/t/func_group_innodb.test
index c62d3d08496..0d24f37363b 100644
--- a/mysql-test/t/func_group_innodb.test
+++ b/mysql-test/t/func_group_innodb.test
@@ -192,4 +192,22 @@ EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
DROP TABLE t1;
+--echo #
+--echo # MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) field
+--echo #
+
+CREATE TABLE t1 (v1 varchar(1020), v2 varchar(2), v3 varchar(2), KEY k1 (v3,v2,v1)) ENGINE=InnoDB CHARACTER SET=utf8;
+INSERT INTO t1 VALUES ('king', 'qu','qu'), ('bad','go','go');
+explain
+SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu';
+SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu';
+drop table t1;
+
+CREATE TABLE t1 (v1 varchar(1024) CHARACTER SET utf8, KEY v1 (v1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES ('king'), ('bad');
+explain
+SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x;
+SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x;
+drop table t1;
+
--echo End of 5.5 tests
diff --git a/mysql-test/t/partition_datatype.test b/mysql-test/t/partition_datatype.test
index 9ab3bd4d5fa..96f7da96e3d 100644
--- a/mysql-test/t/partition_datatype.test
+++ b/mysql-test/t/partition_datatype.test
@@ -216,8 +216,8 @@ select * from t1 where a like 'aaa%';
select * from t1 where a = 'bbbb';
drop table t1;
set sql_mode='';
--- error ER_PARTITION_FIELDS_TOO_LONG
create table t1 (a varchar(3070)) partition by key (a);
+drop table t1;
-- error ER_PARTITION_FIELDS_TOO_LONG
create table t1 (a varchar(65532) not null) partition by key (a);
-- error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
diff --git a/mysql-test/t/partition_utf8.test b/mysql-test/t/partition_utf8.test
index d3ad7ba671e..b806abe0a98 100644
--- a/mysql-test/t/partition_utf8.test
+++ b/mysql-test/t/partition_utf8.test
@@ -15,10 +15,10 @@ drop table t1;
#
# BUG#48164, too long partition fields causes crash
#
---error ER_PARTITION_FIELDS_TOO_LONG
create table t1 (a varchar(1500), b varchar(1570))
partition by list columns(a,b)
( partition p0 values in (('a','b')));
+drop table t1;
create table t1 (a varchar(1023) character set utf8 collate utf8_spanish2_ci)
partition by range columns(a)
diff --git a/sql/handler.h b/sql/handler.h
index ed2ef822c88..75f72bdfb53 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -378,6 +378,10 @@ enum enum_alter_inplace_result {
#define HA_KEY_NULL_LENGTH 1
#define HA_KEY_BLOB_LENGTH 2
+#define MAX_KEY_LENGTH (MAX_DATA_LENGTH_FOR_KEY \
+ +(MAX_REF_PARTS \
+ *(HA_KEY_NULL_LENGTH + HA_KEY_BLOB_LENGTH)))
+
#define HA_LEX_CREATE_TMP_TABLE 1U
#define HA_CREATE_TMP_ALTER 8U
@@ -3421,14 +3425,14 @@ class handler :public Sql_alloc
uint max_key_parts() const
{ return MY_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
uint max_key_length() const
- { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
+ { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_length()); }
uint max_key_part_length() const
- { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
+ { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_part_length()); }
virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
virtual uint max_supported_keys() const { return 0; }
virtual uint max_supported_key_parts() const { return MAX_REF_PARTS; }
- virtual uint max_supported_key_length() const { return MAX_KEY_LENGTH; }
+ virtual uint max_supported_key_length() const { return MAX_DATA_LENGTH_FOR_KEY; }
virtual uint max_supported_key_part_length() const { return 255; }
virtual uint min_record_length(uint options) const { return 1; }
diff --git a/sql/sql_const.h b/sql/sql_const.h
index 7395ae3c08a..0be63a2a5ad 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -33,7 +33,7 @@
#define MAX_SYS_VAR_LENGTH 32
#define MAX_KEY MAX_INDEXES /* Max used keys */
#define MAX_REF_PARTS 32 /* Max parts used as ref */
-#define MAX_KEY_LENGTH 3072 /* max possible key */
+#define MAX_DATA_LENGTH_FOR_KEY 3072
#if SIZEOF_OFF_T > 4
#define MAX_REFLENGTH 8 /* Max length for record ref */
#else
2
1
[Commits] ac0baa4: MDEV-17635 Server hangs after the query with recursive CTE
by IgorBabaev 07 Nov '18
by IgorBabaev 07 Nov '18
07 Nov '18
revision-id: ac0baa4346b79750a0d066ee632dd8d455137f14 (mariadb-10.2.18-63-gac0baa4)
parent(s): 54b8856b87629e9fec075e3a71179eefc7fa02ac
author: Igor Babaev
committer: Igor Babaev
timestamp: 2018-11-07 12:07:32 -0800
message:
MDEV-17635 Server hangs after the query with recursive CTE
This bug in the code of the function With_element::check_unrestricted_recursive()
could force a recursive CTE to be executed in a non-standard compliant mode
in which recursive UNION ALL could lead to an infinite execution. This
problem could occur only in the case when this CTE was used by another
recursive CTE at least twice.
---
mysql-test/r/cte_recursive.result | 159 ++++++++++++++++++++++++++++++++++++++
mysql-test/t/cte_recursive.test | 55 +++++++++++++
sql/sql_cte.cc | 2 +-
3 files changed, 215 insertions(+), 1 deletion(-)
diff --git a/mysql-test/r/cte_recursive.result b/mysql-test/r/cte_recursive.result
index de23d54..7853026 100644
--- a/mysql-test/r/cte_recursive.result
+++ b/mysql-test/r/cte_recursive.result
@@ -3441,3 +3441,162 @@ expired_date purchase_date quantity p_id purchase_processed unresolved
2014-11-08 NULL 0 2 5 1
2014-11-08 2014-11-03 1 2 4 0
DROP TABLE purchases, expired;
+#
+# MDEV-17635: Two recursive CTEs, the second using the first
+#
+WITH RECURSIVE
+x AS (SELECT 0 as k UNION ALL SELECT k + 1 FROM x WHERE k < 1),
+z AS
+( SELECT k1 AS cx, k2 AS cy, k1, k2
+FROM (SELECT k AS k1 FROM x) x1 JOIN (SELECT k AS k2 FROM x) y1
+UNION
+SELECT 1,1,1,1 FROM z)
+SELECT * FROM z;
+cx cy k1 k2
+0 0 0 0
+1 0 1 0
+0 1 0 1
+1 1 1 1
+# https://wiki.postgresql.org/wiki/Mandelbrot_set:
+WITH RECURSIVE x(i) AS (
+SELECT CAST(0 AS DECIMAL(13, 10))
+UNION ALL
+SELECT i + 1
+FROM x
+WHERE i < 101
+),
+Z(Ix, Iy, Cx, Cy, X, Y, I) AS (
+SELECT Ix, Iy, X, Y, X, Y, 0
+FROM (SELECT CAST(-2.2 + 0.031 * i AS DECIMAL(13, 10)) AS X,
+i AS Ix FROM x) AS xgen
+CROSS JOIN (
+SELECT CAST(-1.5 + 0.031 * i AS DECIMAL(13, 10)) AS Y,
+i AS iY FROM x
+) AS ygen
+UNION ALL
+SELECT Ix, Iy, Cx, Cy,
+CAST(X * X - Y * Y + Cx AS DECIMAL(13, 10)) AS X,
+CAST(Y * X * 2 + Cy AS DECIMAL(13, 10)), I + 1
+FROM Z
+WHERE X * X + Y * Y < 16.0
+AND I < 27
+),
+Zt (Ix, Iy, I) AS (
+SELECT Ix, Iy, MAX(I) AS I
+FROM Z
+GROUP BY Iy, Ix
+ORDER BY Iy, Ix
+)
+SELECT GROUP_CONCAT(
+SUBSTRING(
+' .,,,-----++++%%%%@@@@#### ',
+GREATEST(I, 1),
+1
+) ORDER BY Ix SEPARATOR ''
+ ) AS 'Mandelbrot Set'
+ FROM Zt
+GROUP BY Iy
+ORDER BY Iy;
+Mandelbrot Set
+ ....................................................................................
+ .......................................................................................
+ .........................................................................................
+ ...........................................................................................
+ ....................................................,,,,,,,,,.................................
+ ................................................,,,,,,,,,,,,,,,,,,.............................
+ ..............................................,,,,,,,,,,,,,,,,,,,,,,,,..........................
+ ............................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,........................
+ ..........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......................
+ .........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,....................
+ ........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................
+ .......................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.................
+ .......................................,,,,,,,,,,,,,,,,,,,,,,,,--,,,,,,,,,,,,,,,,,,,,................
+......................................,,,,,,,,,,,,,,,,,,,,,,,,,,-+--,,,,,,,,,,,,,,,,,,,...............
+....................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----,,,,,,,,,,,,,,,,,,,..............
+...................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,--- -----,,,,,,,,,,,,,,,,,.............
+.................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---++--++,,,,,,,,,,,,,,,,,,............
+................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----%++---,,,,,,,,,,,,,,,,,............
+..............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+%----,,,,,,,,,,,,,,,,,,...........
+.............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----- %%+----,,,,,,,,,,,,,,,,,,..........
+...........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---%-+% ----,,,,,,,,,,,,,,,,,,,.........
+..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+ +## %+%---,,,,,,,,,,,,,,,,,,.........
+........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----# # +---,,,,,,,,,,,,,,,,,,........
+.......................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------% %-----,,,,,,,,,,,,,,,,,........
+.....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------+ ------,,,,,,,,,,,,,,,,,.......
+....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----------+@ +-----------,,,,,,,,,,,,.......
+..................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----@-------++ ++-----------,,,,,,,,,,,,......
+.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--+@% ---+ +@%%@ %%+@+@%------+-,,,,,,,,,,,......
+................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---- # ++% % @-----++--,,,,,,,,,,,.....
+..............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----+ % %%++ %+%@-,,,,,,,,,,,.....
+.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+# #% ++-,,,,,,,,,,,,....
+............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------+ @---,,,,,,,,,,,,....
+..........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------++% ---,,,,,,,,,,,,....
+.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------+ + %+---,,,,,,,,,,,,,...
+........,,,,,,,,,,,,,,,,,,,,,--------------------@ +----,,,,,,,,,,,,...
+.......,,,,,,,,,,,,,,,,,,,,,,- +-----------------+ ----,,,,,,,,,,,,...
+.......,,,,,,,,,,,,,,,,,,,,,--++------+---------+% +++--,,,,,,,,,,,,..
+......,,,,,,,,,,,,,,,,,,,,,,--%+-----++--------- #+-,,,,,,,,,,,,..
+.....,,,,,,,,,,,,,,,,,,,,,,----#%++--+@ -+-----+% --,,,,,,,,,,,,..
+.....,,,,,,,,,,,,,,,,,,,,,,-----+## ++@ + +----% +--,,,,,,,,,,,,,..
+....,,,,,,,,,,,,,,,,,,,,,,------+@ @ @@++++# +--,,,,,,,,,,,,,..
+....,,,,,,,,,,,,,,,,,,,,,-------% #++% -,,,,,,,,,,,,,..
+...,,,,,,,,,,,,,,,,,,,,,------++%# %%@ %-,,,,,,,,,,,,,,.
+...,,,,,,,,,,,,,,,,,,,--------+ % +--,,,,,,,,,,,,,,.
+...,,,,,,,,,,,,,,,,,,-----+--++@ # --,,,,,,,,,,,,,,.
+..,,,,,,,,,,,,,,,,,-------%+++% @--,,,,,,,,,,,,,,,.
+..,,,,,,,,,,,-------------+ @#@ ---,,,,,,,,,,,,,,,.
+..,,,,,,,,,---@--------@-+% +---,,,,,,,,,,,,,,,.
+..,,,,,------- +-++++-+%%% +----,,,,,,,,,,,,,,,.
+..,,,,,,------%--------++% +----,,,,,,,,,,,,,,,.
+..,,,,,,,,,,--+----------++# ---,,,,,,,,,,,,,,,.
+..,,,,,,,,,,,,------------+@@@% +--,,,,,,,,,,,,,,,.
+..,,,,,,,,,,,,,,,,,------- +++% %--,,,,,,,,,,,,,,,.
+...,,,,,,,,,,,,,,,,,,---------+@ @ --,,,,,,,,,,,,,,.
+...,,,,,,,,,,,,,,,,,,,,------- # %@ +--,,,,,,,,,,,,,,.
+...,,,,,,,,,,,,,,,,,,,,,-------++@ %+ %-,,,,,,,,,,,,,,.
+....,,,,,,,,,,,,,,,,,,,,,------- %++% %-,,,,,,,,,,,,,..
+....,,,,,,,,,,,,,,,,,,,,,,------+# %# #@ ++++ +--,,,,,,,,,,,,,..
+.....,,,,,,,,,,,,,,,,,,,,,,-----+ %%++% +@+----+ +--,,,,,,,,,,,,,..
+.....,,,,,,,,,,,,,,,,,,,,,,,---%+++--+#+--------% #--,,,,,,,,,,,,..
+......,,,,,,,,,,,,,,,,,,,,,,--++-----%%--------- @#--,,,,,,,,,,,,..
+.......,,,,,,,,,,,,,,,,,,,,,---------------------+@ +-++,,,,,,,,,,,,...
+........,,,,,,,,,,,,,,,,,,,,,--------------------+ ----,,,,,,,,,,,,...
+.........,,,,,,,,,,,,,,,,,,,,----,,,------------- #+----,,,,,,,,,,,,...
+..........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------+ + +---,,,,,,,,,,,,,...
+...........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------+%# #---,,,,,,,,,,,,....
+............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------+# @ @---,,,,,,,,,,,,....
+.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+# + @--,,,,,,,,,,,,....
+..............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+% %+@ %+-+ +++%-,,,,,,,,,,,.....
+................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----% %@++ # % -----++-,,,,,,,,,,,,.....
+.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-- ++ ---+ + +%@ %++++++------%-,,,,,,,,,,,......
+...................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---- -------++ +------------,,,,,,,,,,,,......
+....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----------+% +--------,,,,,,,,,,,,,,,.......
+......................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------+# -----,,,,,,,,,,,,,,,,,,.......
+.......................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------+ #----,,,,,,,,,,,,,,,,,,........
+.........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----+% %#---,,,,,,,,,,,,,,,,,,,........
+..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+%+%@ %+%%--,,,,,,,,,,,,,,,,,,.........
+............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+-+% %----,,,,,,,,,,,,,,,,,,..........
+.............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+%@+---,,,,,,,,,,,,,,,,,,,..........
+...............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+%----,,,,,,,,,,,,,,,,,,...........
+................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----%+ +--,,,,,,,,,,,,,,,,,............
+..................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---++----,,,,,,,,,,,,,,,,,.............
+...................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,---@-----,,,,,,,,,,,,,,,,,.............
+.....................................,,,,,,,,,,,,,,,,,,,,,,,,,,,-----,,,,,,,,,,,,,,,,,,,..............
+ .....................................,,,,,,,,,,,,,,,,,,,,,,,,,,--%,,,,,,,,,,,,,,,,,,,,...............
+ .......................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.................
+ ........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,..................
+ ........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................
+ .........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,....................
+ ..........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......................
+ ............................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,........................
+ .............................................,,,,,,,,,,,,,,,,,,,,,,,,..........................
+ ................................................,,,,,,,,,,,,,,,,,.............................
+ .....................................................,,,,....................................
+ ...........................................................................................
+ .........................................................................................
+ ......................................................................................
+ ....................................................................................
+ .................................................................................
+ ..............................................................................
+ ...........................................................................
+ ........................................................................
diff --git a/mysql-test/t/cte_recursive.test b/mysql-test/t/cte_recursive.test
index acaf95b..3c5bc62 100644
--- a/mysql-test/t/cte_recursive.test
+++ b/mysql-test/t/cte_recursive.test
@@ -2440,3 +2440,58 @@ WITH RECURSIVE expired_map AS (
SELECT * FROM expired_map;
DROP TABLE purchases, expired;
+
+--echo #
+--echo # MDEV-17635: Two recursive CTEs, the second using the first
+--echo #
+
+WITH RECURSIVE
+x AS (SELECT 0 as k UNION ALL SELECT k + 1 FROM x WHERE k < 1),
+z AS
+ ( SELECT k1 AS cx, k2 AS cy, k1, k2
+ FROM (SELECT k AS k1 FROM x) x1 JOIN (SELECT k AS k2 FROM x) y1
+ UNION
+ SELECT 1,1,1,1 FROM z)
+SELECT * FROM z;
+
+--echo # https://wiki.postgresql.org/wiki/Mandelbrot_set:
+
+WITH RECURSIVE x(i) AS (
+ SELECT CAST(0 AS DECIMAL(13, 10))
+ UNION ALL
+ SELECT i + 1
+ FROM x
+ WHERE i < 101
+),
+Z(Ix, Iy, Cx, Cy, X, Y, I) AS (
+ SELECT Ix, Iy, X, Y, X, Y, 0
+ FROM (SELECT CAST(-2.2 + 0.031 * i AS DECIMAL(13, 10)) AS X,
+ i AS Ix FROM x) AS xgen
+ CROSS JOIN (
+ SELECT CAST(-1.5 + 0.031 * i AS DECIMAL(13, 10)) AS Y,
+ i AS iY FROM x
+ ) AS ygen
+ UNION ALL
+ SELECT Ix, Iy, Cx, Cy,
+ CAST(X * X - Y * Y + Cx AS DECIMAL(13, 10)) AS X,
+ CAST(Y * X * 2 + Cy AS DECIMAL(13, 10)), I + 1
+ FROM Z
+ WHERE X * X + Y * Y < 16.0
+ AND I < 27
+),
+Zt (Ix, Iy, I) AS (
+ SELECT Ix, Iy, MAX(I) AS I
+ FROM Z
+ GROUP BY Iy, Ix
+ ORDER BY Iy, Ix
+)
+SELECT GROUP_CONCAT(
+ SUBSTRING(
+ ' .,,,-----++++%%%%@@@@#### ',
+ GREATEST(I, 1),
+ 1
+ ) ORDER BY Ix SEPARATOR ''
+ ) AS 'Mandelbrot Set'
+ FROM Zt
+GROUP BY Iy
+ORDER BY Iy;
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index 5a590bf..5d4c2b2 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -1263,7 +1263,7 @@ bool With_element::check_unrestricted_recursive(st_select_lex *sel,
With_element *with_elem= unit->with_element;
if (encountered & with_elem->get_elem_map())
unrestricted|= with_elem->mutually_recursive;
- else
+ else if (with_elem ==this)
encountered|= with_elem->get_elem_map();
}
}
1
0
[Commits] 031efde365c: MDEV-16217: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed in Field_num::get_date
by Oleksandr Byelkin 07 Nov '18
by Oleksandr Byelkin 07 Nov '18
07 Nov '18
revision-id: 031efde365c674dbdbaada95aa6d42a4274db438 (mariadb-10.2.18-65-g031efde365c)
parent(s): 89f948c766721a26e110bc9da0ca5ebc20f65112
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2018-11-07 14:29:47 +0100
message:
MDEV-16217: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed in Field_num::get_date
- clean up DEFAULT() to work only with default value and correctly print
itself.
- fix of DBUG_ASSERT about fields read/write
- fix of field marking for write based really on the thd->mark_used_columns flag
---
mysql-test/r/func_default.result | 10 ++++++-
mysql-test/r/func_time.result | 57 ++++++++++++++++++++++++++++++++++++++++
mysql-test/t/func_default.test | 5 ++++
mysql-test/t/func_time.test | 32 ++++++++++++++++++++++
sql/field.cc | 17 ++++++++++--
sql/field.h | 1 +
sql/item.cc | 25 ++++++++++++++++--
sql/item.h | 5 ++++
sql/sql_base.cc | 2 +-
9 files changed, 148 insertions(+), 6 deletions(-)
diff --git a/mysql-test/r/func_default.result b/mysql-test/r/func_default.result
index 535be10da86..9699f0795e3 100644
--- a/mysql-test/r/func_default.result
+++ b/mysql-test/r/func_default.result
@@ -8,13 +8,21 @@ explain extended select default(str), default(strnull), default(intg), default(r
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select default('') AS `default(str)`,default('') AS `default(strnull)`,default(0) AS `default(intg)`,default(0) AS `default(rel)` from dual
+Note 1003 select default(`test`.`t1`.`str`) AS `default(str)`,default(`test`.`t1`.`strnull`) AS `default(strnull)`,default(`test`.`t1`.`intg`) AS `default(intg)`,default(`test`.`t1`.`rel`) AS `default(rel)` from dual
select * from t1 where str <> default(str);
str strnull intg rel
0 0
explain select * from t1 where str <> default(str);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1
+create view v1 as select default(str), default(strnull), default(intg), default(rel) from t1;
+select * from v1;
+default(str) default(strnull) default(intg) default(rel)
+def NULL 10 3.14
+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 default(`t1`.`str`) AS `default(str)`,default(`t1`.`strnull`) AS `default(strnull)`,default(`t1`.`intg`) AS `default(intg)`,default(`t1`.`rel`) AS `default(rel)` from `t1` latin1 latin1_swedish_ci
+drop view v1;
drop table t1;
CREATE TABLE t1 (id int(11), s varchar(20));
INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three');
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 5ca9cf5228f..16acf3fcbea 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -3423,3 +3423,60 @@ DROP TABLE t1,t2;
#
# End of 10.1 tests
#
+#
+# MDEV-16217: Assertion `!table || (!table->read_set ||
+# bitmap_is_set(table->read_set, field_index))'
+# failed in Field_num::get_date
+#
+CREATE TABLE t1 (pk int default 0, a1 date);
+INSERT INTO t1 VALUES (1,'1900-01-01'),(2,NULL),(3,NULL),(4,NULL);
+CREATE VIEW v1 AS
+SELECT t1.pk AS pk, t1.a1 AS a1 FROM t1;
+SELECT a1 BETWEEN (('2018-08-24')) AND (DEFAULT(pk)) FROM v1;
+a1 BETWEEN (('2018-08-24')) AND (DEFAULT(pk))
+0
+NULL
+NULL
+NULL
+SELECT a1 BETWEEN (('2018-08-24')) AND (~ DEFAULT(pk)) FROM v1;
+a1 BETWEEN (('2018-08-24')) AND (~ DEFAULT(pk))
+0
+NULL
+NULL
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '18446744073709551615'
+CREATE TABLE t2 (pk int default 1, a1 date);
+INSERT INTO t2 VALUES (4,NULL);
+CREATE view v2 as SELECT default(t1.pk), default(t2.pk), t1.pk from t1,t2;
+select * from v2;
+default(t1.pk) default(t2.pk) pk
+0 1 1
+0 1 2
+0 1 3
+0 1 4
+show create view v2;
+View Create View character_set_client collation_connection
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select default(`t1`.`pk`) AS `default(t1.pk)`,default(`t2`.`pk`) AS `default(t2.pk)`,`t1`.`pk` AS `pk` from (`t1` join `t2`) latin1 latin1_swedish_ci
+CREATE view v3 as SELECT default(pk) from t2;
+select * from v3;
+default(pk)
+1
+explain extended select * from v3;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
+Warnings:
+Note 1003 select default(`test`.`t2`.`pk`) AS `default(pk)` from dual
+explain extended select default(pk) from t2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
+Warnings:
+Note 1003 select default(`test`.`t2`.`pk`) AS `default(pk)` from dual
+show create view v3;
+View Create View character_set_client collation_connection
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select default(`t2`.`pk`) AS `default(pk)` from `t2` latin1 latin1_swedish_ci
+DROP VIEW v1,v2,v3;
+DROP TABLE t1,t2;
+#
+# End of 10.2 tests
+#
diff --git a/mysql-test/t/func_default.test b/mysql-test/t/func_default.test
index fbd73990297..332bfca021f 100644
--- a/mysql-test/t/func_default.test
+++ b/mysql-test/t/func_default.test
@@ -11,6 +11,11 @@ explain extended select default(str), default(strnull), default(intg), default(r
select * from t1 where str <> default(str);
explain select * from t1 where str <> default(str);
+create view v1 as select default(str), default(strnull), default(intg), default(rel) from t1;
+select * from v1;
+show create view v1;
+drop view v1;
+
#TODO: uncomment when bug will be fixed
#create table t2 select default(str), default(strnull), default(intg), default(rel) from t1;
#show create table from t1;
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 73f91bb90a0..d391e5f5059 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1910,3 +1910,35 @@ DROP TABLE t1,t2;
--echo #
--echo # End of 10.1 tests
--echo #
+
+--echo #
+--echo # MDEV-16217: Assertion `!table || (!table->read_set ||
+--echo # bitmap_is_set(table->read_set, field_index))'
+--echo # failed in Field_num::get_date
+--echo #
+CREATE TABLE t1 (pk int default 0, a1 date);
+INSERT INTO t1 VALUES (1,'1900-01-01'),(2,NULL),(3,NULL),(4,NULL);
+
+CREATE VIEW v1 AS
+SELECT t1.pk AS pk, t1.a1 AS a1 FROM t1;
+
+SELECT a1 BETWEEN (('2018-08-24')) AND (DEFAULT(pk)) FROM v1;
+SELECT a1 BETWEEN (('2018-08-24')) AND (~ DEFAULT(pk)) FROM v1;
+
+CREATE TABLE t2 (pk int default 1, a1 date);
+INSERT INTO t2 VALUES (4,NULL);
+CREATE view v2 as SELECT default(t1.pk), default(t2.pk), t1.pk from t1,t2;
+select * from v2;
+show create view v2;
+CREATE view v3 as SELECT default(pk) from t2;
+select * from v3;
+explain extended select * from v3;
+explain extended select default(pk) from t2;
+show create view v3;
+
+DROP VIEW v1,v2,v3;
+DROP TABLE t1,t2;
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/sql/field.cc b/sql/field.cc
index caa84dc9932..6cd8940a893 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -70,8 +70,21 @@ const char field_separator=',';
#define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
((ulong) ((1LL << MY_MIN(arg, 4) * 8) - 1))
-#define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
-#define ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED DBUG_ASSERT(is_stat_field || !table || (!table->write_set || bitmap_is_set(table->write_set, field_index) || (table->vcol_set && bitmap_is_set(table->vcol_set, field_index))))
+// Column marked for read or the field set to read out or record[0] or [1]
+#define ASSERT_COLUMN_MARKED_FOR_READ \
+ DBUG_ASSERT(!table || \
+ (!table->read_set || \
+ bitmap_is_set(table->read_set, field_index) || \
+ (!(ptr >= table->record[0] && \
+ ptr < table->record[0] + table->s->reclength))))
+
+#define ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED \
+ DBUG_ASSERT(is_stat_field || !table || \
+ (!table->write_set || \
+ bitmap_is_set(table->write_set, field_index) || \
+ (!(ptr >= table->record[0] && \
+ ptr < table->record[0] + table->s->reclength))) || \
+ (table->vcol_set && bitmap_is_set(table->vcol_set, field_index)))
#define FLAGSTR(S,F) ((S) & (F) ? #F " " : "")
diff --git a/sql/field.h b/sql/field.h
index 22c276478b6..55c3ed4c4bd 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -630,6 +630,7 @@ class Virtual_column_info: public Sql_alloc
bool utf8; /* Already in utf8 */
Item *expr;
LEX_STRING name; /* Name of constraint */
+ /* see VCOL_* (VCOL_FIELD_REF, ...) */
uint flags;
Virtual_column_info()
diff --git a/sql/item.cc b/sql/item.cc
index 2adec33491b..6828a74f9ff 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -8792,8 +8792,19 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
fixed= 1;
return FALSE;
}
+
+ /*
+ DEFAULT() do not need table field so should not ask handler to bring
+ field value (mark column for read)
+ */
+ enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
+ thd->mark_used_columns= MARK_COLUMNS_NONE;
if (!arg->fixed && arg->fix_fields(thd, &arg))
+ {
+ thd->mark_used_columns= save_mark_used_columns;
goto error;
+ }
+ thd->mark_used_columns= save_mark_used_columns;
real_arg= arg->real_item();
@@ -8813,15 +8824,19 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
goto error;
memcpy((void *)def_field, (void *)field_arg->field,
field_arg->field->size_of());
- IF_DBUG(def_field->is_stat_field=1,); // a hack to fool ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED
+ // If non-constant default value expression
if (def_field->default_value && def_field->default_value->flags)
{
uchar *newptr= (uchar*) thd->alloc(1+def_field->pack_length());
if (!newptr)
goto error;
+ /*
+ Even if DEFAULT() do not read tables fields, the default value
+ expression can do it.
+ */
fix_session_vcol_expr_for_read(thd, def_field, def_field->default_value);
if (thd->mark_used_columns != MARK_COLUMNS_NONE)
- def_field->default_value->expr->walk(&Item::register_field_in_read_map, 1, 0);
+ def_field->default_value->expr->update_used_tables();
def_field->move_field(newptr+1, def_field->maybe_null() ? newptr : 0, 1);
}
else
@@ -8845,6 +8860,12 @@ void Item_default_value::print(String *str, enum_query_type query_type)
return;
}
str->append(STRING_WITH_LEN("default("));
+ /*
+ We take DEFAULT from a field so do not need it value in case of const
+ tables but its name so we set QT_NO_DATA_EXPANSION (as we print for
+ table definition, also we do not need table and database name)
+ */
+ query_type= (enum_query_type) (query_type | QT_NO_DATA_EXPANSION);
arg->print(str, query_type);
str->append(')');
}
diff --git a/sql/item.h b/sql/item.h
index 8d02d981d38..5866f328f38 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -5229,6 +5229,11 @@ class Item_default_value : public Item_field
return false;
}
table_map used_tables() const;
+ virtual void update_used_tables()
+ {
+ if (field && field->default_value)
+ field->default_value->expr->walk(&Item::register_field_in_read_map, 1, 0);
+ }
Field *get_tmp_table_field() { return 0; }
Item *get_tmp_table_item(THD *thd) { return this; }
Item_field *field_for_view_update() { return 0; }
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index c282db42fdd..0deb5ec1362 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -5737,7 +5737,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
TABLE *table= field_to_set->table;
if (thd->mark_used_columns == MARK_COLUMNS_READ)
bitmap_set_bit(table->read_set, field_to_set->field_index);
- else
+ else if (thd->mark_used_columns == MARK_COLUMNS_WRITE)
bitmap_set_bit(table->write_set, field_to_set->field_index);
}
}
1
0