Merge 10.3 into 10.4

This commit is contained in:
Marko Mäkelä 2020-07-15 10:17:15 +03:00
commit 9936cfd531
39 changed files with 467 additions and 141 deletions

View File

@ -125,7 +125,7 @@ ENDIF()
IF(UNIX) IF(UNIX)
SET(WITH_EXTRA_CHARSETS all CACHE STRING "") SET(WITH_EXTRA_CHARSETS all CACHE STRING "")
SET(PLUGIN_AUTH_PAM YES) SET(PLUGIN_AUTH_PAM YES CACHE BOOL "")
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
IF(NOT IGNORE_AIO_CHECK) IF(NOT IGNORE_AIO_CHECK)

View File

@ -1043,10 +1043,14 @@ inline_mysql_socket_accept
#else #else
socket_accept.fd= accept(socket_listen.fd, addr, &addr_length); socket_accept.fd= accept(socket_listen.fd, addr, &addr_length);
#ifdef FD_CLOEXEC #ifdef FD_CLOEXEC
flags= fcntl(socket_accept.fd, F_GETFD); if (socket_accept.fd != INVALID_SOCKET)
if (flags != -1) { {
flags |= FD_CLOEXEC; flags= fcntl(socket_accept.fd, F_GETFD);
fcntl(socket_accept.fd, F_SETFD, flags); if (flags != -1)
{
flags |= FD_CLOEXEC;
fcntl(socket_accept.fd, F_SETFD, flags);
}
} }
#endif #endif
#endif #endif
@ -1065,10 +1069,14 @@ inline_mysql_socket_accept
#else #else
socket_accept.fd= accept(socket_listen.fd, addr, &addr_length); socket_accept.fd= accept(socket_listen.fd, addr, &addr_length);
#ifdef FD_CLOEXEC #ifdef FD_CLOEXEC
flags= fcntl(socket_accept.fd, F_GETFD); if (socket_accept.fd != INVALID_SOCKET)
if (flags != -1) { {
flags |= FD_CLOEXEC; flags= fcntl(socket_accept.fd, F_GETFD);
fcntl(socket_accept.fd, F_SETFD, flags); if (flags != -1)
{
flags |= FD_CLOEXEC;
fcntl(socket_accept.fd, F_SETFD, flags);
}
} }
#endif #endif
#endif #endif

View File

@ -52,3 +52,20 @@ body
DROP FUNCTION IF EXISTS f1; DROP FUNCTION IF EXISTS f1;
Warnings: Warnings:
Note 1305 FUNCTION test.f1 does not exist Note 1305 FUNCTION test.f1 does not exist
#
# 10.1 Test
#
# MDEV-22654: Assertion `!is_set() || (m_status == DA_OK_BULK &&
# is_bulk_op())' failed in Diagnostics_area::set_ok_status on FUNCTION replace
#
SET GLOBAL log_bin_trust_function_creators=0;
CREATE FUNCTION f(c INT) RETURNS NUMERIC NO SQL RETURN 0;
CREATE OR REPLACE FUNCTION f(c INT) RETURNS INT RETURN 0;
ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
CREATE OR REPLACE FUNCTION sp1_thisisaveryverylongnamelongnameverylongname_thisisaveryverylongname234872934(a INT) RETURNS INT RETURN 0;
ERROR 42000: Identifier name 'sp1_thisisaveryverylongnamelongnameverylongname_thisisaveryverylongname234872934' is too long
DROP FUNCTION IF EXISTS f;
Warnings:
Note 1305 FUNCTION test.f does not exist
SET GLOBAL log_bin_trust_function_creators=1;
# End of 10.1 Test

View File

@ -1,3 +1,5 @@
source include/have_log_bin.inc;
SET timestamp=UNIX_TIMESTAMP('2014-09-30 08:00:00'); SET timestamp=UNIX_TIMESTAMP('2014-09-30 08:00:00');
CREATE FUNCTION f1(str char(20)) CREATE FUNCTION f1(str char(20))
@ -39,3 +41,25 @@ DROP FUNCTION IF EXISTS f1;
SELECT body FROM mysql.proc WHERE name like 'f1'; SELECT body FROM mysql.proc WHERE name like 'f1';
DROP FUNCTION IF EXISTS f1; DROP FUNCTION IF EXISTS f1;
--echo #
--echo # 10.1 Test
--echo #
--echo # MDEV-22654: Assertion `!is_set() || (m_status == DA_OK_BULK &&
--echo # is_bulk_op())' failed in Diagnostics_area::set_ok_status on FUNCTION replace
--echo #
SET GLOBAL log_bin_trust_function_creators=0;
CREATE FUNCTION f(c INT) RETURNS NUMERIC NO SQL RETURN 0;
--error ER_BINLOG_UNSAFE_ROUTINE
CREATE OR REPLACE FUNCTION f(c INT) RETURNS INT RETURN 0;
--error ER_TOO_LONG_IDENT
CREATE OR REPLACE FUNCTION sp1_thisisaveryverylongnamelongnameverylongname_thisisaveryverylongname234872934(a INT) RETURNS INT RETURN 0;
DROP FUNCTION IF EXISTS f;
SET GLOBAL log_bin_trust_function_creators=1;
--echo # End of 10.1 Test

View File

@ -35,10 +35,10 @@ SET @@session.session_track_system_variables= @save_session_track_system_variabl
# #
set @save_optimizer_switch=@@optimizer_switch; set @save_optimizer_switch=@@optimizer_switch;
SET @@session.session_track_system_variables='optimizer_switch'; SET @@session.session_track_system_variables='optimizer_switch';
set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off'; set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off';
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES -- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- optimizer_switch -- optimizer_switch
-- index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on -- index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
Warnings: Warnings:
Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release

View File

@ -36,7 +36,7 @@ set @save_optimizer_switch=@@optimizer_switch;
SET @@session.session_track_system_variables='optimizer_switch'; SET @@session.session_track_system_variables='optimizer_switch';
--enable_session_track_info --enable_session_track_info
set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off'; set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off';
--disable_session_track_info --disable_session_track_info
set @@optimizer_switch=@save_optimizer_switch; set @@optimizer_switch=@save_optimizer_switch;

View File

@ -3377,6 +3377,61 @@ SET @@sort_buffer_size= @save_sort_buffer_size;
SET @@max_sort_length= @save_max_sort_length; SET @@max_sort_length= @save_max_sort_length;
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-22390: Assertion `m_next_rec_ptr >= m_rawmem' failed in Filesort_buffer::spaceleft |
# SIGSEGV in __memmove_avx_unaligned_erms from my_b_write (on optimized)
#
SET @save_max_sort_length= @@max_sort_length;
SET @save_sort_buffer_size= @@sort_buffer_size;
SET @save_max_length_for_sort_data= @@max_length_for_sort_data;
SET max_sort_length=8;
SET sort_buffer_size=1024;
SET max_length_for_sort_data=7000;
CREATE TABLE t1(a VARCHAR(64), b VARCHAR(2048))DEFAULT CHARSET=utf8;
INSERT INTO t1 SELECT seq,seq from seq_1_to_100;
ANALYZE FORMAT=JSON SELECT * FROM t1 ORDER BY a LIMIT 5;
ANALYZE
{
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"read_sorted_file": {
"r_rows": 5,
"filesort": {
"sort_key": "t1.a",
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"r_limit": 5,
"r_used_priority_queue": false,
"r_output_rows": 35,
"r_sort_passes": 1,
"r_buffer_size": "REPLACED",
"table": {
"table_name": "t1",
"access_type": "ALL",
"r_loops": 1,
"rows": 100,
"r_rows": 100,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100
}
}
}
}
}
SELECT * FROM t1 ORDER BY a LIMIT 5;
a b
1 1
10 10
100 100
11 11
12 12
SET max_sort_length= @save_max_sort_length;
SET sort_buffer_size= @save_sort_buffer_size;
SET max_length_for_sort_data= @save_max_length_for_sort_data;
DROP TABLE t1;
#
# MDEV-13994: Bad join results with orderby_uses_equalities=on # MDEV-13994: Bad join results with orderby_uses_equalities=on
# #
CREATE TABLE books ( CREATE TABLE books (

View File

@ -2179,6 +2179,28 @@ SET @@sort_buffer_size= @save_sort_buffer_size;
SET @@max_sort_length= @save_max_sort_length; SET @@max_sort_length= @save_max_sort_length;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-22390: Assertion `m_next_rec_ptr >= m_rawmem' failed in Filesort_buffer::spaceleft |
--echo # SIGSEGV in __memmove_avx_unaligned_erms from my_b_write (on optimized)
--echo #
SET @save_max_sort_length= @@max_sort_length;
SET @save_sort_buffer_size= @@sort_buffer_size;
SET @save_max_length_for_sort_data= @@max_length_for_sort_data;
SET max_sort_length=8;
SET sort_buffer_size=1024;
# needed to make sure we use addon fields
SET max_length_for_sort_data=7000;
CREATE TABLE t1(a VARCHAR(64), b VARCHAR(2048))DEFAULT CHARSET=utf8;
INSERT INTO t1 SELECT seq,seq from seq_1_to_100;
--source include/analyze-format.inc
ANALYZE FORMAT=JSON SELECT * FROM t1 ORDER BY a LIMIT 5;
SELECT * FROM t1 ORDER BY a LIMIT 5;
SET max_sort_length= @save_max_sort_length;
SET sort_buffer_size= @save_sort_buffer_size;
SET max_length_for_sort_data= @save_max_length_for_sort_data;
DROP TABLE t1;
--echo # --echo #
--echo # MDEV-13994: Bad join results with orderby_uses_equalities=on --echo # MDEV-13994: Bad join results with orderby_uses_equalities=on
--echo # --echo #

View File

@ -932,11 +932,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(30); INSERT INTO t1 VALUES (10),(20),(30);
SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a); SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a);
a ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION
1
SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a ORDER BY a); SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a ORDER BY a);
a ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION
1
DROP TABLE t1; DROP TABLE t1;
# UNION with a parenthesed term # UNION with a parenthesed term
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
@ -999,14 +997,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(30); INSERT INTO t1 VALUES (10),(20),(30);
SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a); SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a);
a ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION
1
SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a ORDER BY a); SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a ORDER BY a);
a ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION
1
SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a ORDER BY a) LIMIT 1; SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a ORDER BY a) LIMIT 1;
a ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION
1
DROP TABLE t1; DROP TABLE t1;
# Derived table with ROLLUP # Derived table with ROLLUP
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);

View File

@ -1084,7 +1084,9 @@ CREATE TABLE t1 AS SELECT 1 LIMIT 1 UNION SELECT 2;
--echo # For now, we're testing the parser. --echo # For now, we're testing the parser.
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(30); INSERT INTO t1 VALUES (10),(20),(30);
--error ER_AGGREGATE_ORDER_FOR_UNION
SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a); SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a);
--error ER_AGGREGATE_ORDER_FOR_UNION
SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a ORDER BY a); SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a ORDER BY a);
DROP TABLE t1; DROP TABLE t1;
@ -1125,8 +1127,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(30); INSERT INTO t1 VALUES (10),(20),(30);
--error ER_AGGREGATE_ORDER_FOR_UNION
SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a); SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a);
--error ER_AGGREGATE_ORDER_FOR_UNION
SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a ORDER BY a); SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a ORDER BY a);
--error ER_AGGREGATE_ORDER_FOR_UNION
SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a ORDER BY a) LIMIT 1; SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a ORDER BY a) LIMIT 1;
DROP TABLE t1; DROP TABLE t1;

View File

@ -2874,3 +2874,16 @@ SELECT @msg;
DROP FUNCTION f1; DROP FUNCTION f1;
DROP FUNCTION f2; DROP FUNCTION f2;
DROP TABLE t1; DROP TABLE t1;
#
# 10.2 Test
#
# MDEV-MDEV-22058: Assertion `!is_set() || (m_status == DA_OK_BULK &&
# is_bulk_op())' failed in Diagnostics_area::set_ok_status
#
SET @old_optimizer_switch = @@SESSION.OPTIMIZER_SWITCH;
SET @cmd:="SET @@SESSION.SQL_MODE=(SELECT 'a')";
SET @@SESSION.OPTIMIZER_SWITCH="in_to_exists=OFF,materialization=OFF";
ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'
PREPARE stmt FROM @cmd;
set @@SESSION.OPTIMIZER_SWITCH=@old_optimizer_switch;
# End of 10.2 Test

View File

@ -3846,3 +3846,22 @@ SELECT @msg;
DROP FUNCTION f1; DROP FUNCTION f1;
DROP FUNCTION f2; DROP FUNCTION f2;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # 10.2 Test
--echo #
--echo # MDEV-MDEV-22058: Assertion `!is_set() || (m_status == DA_OK_BULK &&
--echo # is_bulk_op())' failed in Diagnostics_area::set_ok_status
--echo #
SET @old_optimizer_switch = @@SESSION.OPTIMIZER_SWITCH;
SET @cmd:="SET @@SESSION.SQL_MODE=(SELECT 'a')";
--error ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES
SET @@SESSION.OPTIMIZER_SWITCH="in_to_exists=OFF,materialization=OFF";
PREPARE stmt FROM @cmd;
set @@SESSION.OPTIMIZER_SWITCH=@old_optimizer_switch;
--echo # End of 10.2 Test

View File

@ -440,8 +440,8 @@ drop table t1,t3;
# MDEV-159 Assertion about not marked for read failed in # MDEV-159 Assertion about not marked for read failed in
# String* Field_varstring::val_str(String*, String*) # String* Field_varstring::val_str(String*, String*)
# #
SET optimizer_switch = REPLACE( @@optimizer_switch, '=on', '=off' ); SET optimizer_switch = REPLACE(REPLACE(@@optimizer_switch, '=on', '=off'), 'in_to_exists=off', 'in_to_exists=on');
SET optimizer_switch='in_to_exists=on,exists_to_in=on'; SET optimizer_switch='exists_to_in=on';
CREATE TABLE t1 ( a VARCHAR(1) ); CREATE TABLE t1 ( a VARCHAR(1) );
INSERT INTO t1 VALUES ('k'),('m'); INSERT INTO t1 VALUES ('k'),('m');
CREATE TABLE t2 ( b INT, CREATE TABLE t2 ( b INT,
@ -596,8 +596,8 @@ Warnings:
Note 1276 Field or reference 'test.alias.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.alias.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.alias.b' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.alias.b' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`alias`.`a` AS `a`,`test`.`alias`.`b` AS `b` from `test`.`t1` `alias` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`alias`.`b` and `test`.`alias`.`b` > `test`.`alias`.`a` Note 1003 select `test`.`alias`.`a` AS `a`,`test`.`alias`.`b` AS `b` from `test`.`t1` `alias` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`alias`.`b` and `test`.`alias`.`b` > `test`.`alias`.`a`
SET optimizer_switch = REPLACE( @@optimizer_switch, '=on', '=off' ); SET optimizer_switch = REPLACE(REPLACE(@@optimizer_switch, '=on', '=off'), 'materialization=off', 'materialization=on');
SET optimizer_switch = 'exists_to_in=on,materialization=on,semijoin=off'; SET optimizer_switch = 'exists_to_in=on,semijoin=off';
SELECT * FROM t1 AS alias SELECT * FROM t1 AS alias
WHERE EXISTS ( SELECT * FROM t1 WHERE a > alias.a AND a = alias.b ); WHERE EXISTS ( SELECT * FROM t1 WHERE a > alias.a AND a = alias.b );
a b a b

View File

@ -330,8 +330,8 @@ drop table t1,t3;
--echo # String* Field_varstring::val_str(String*, String*) --echo # String* Field_varstring::val_str(String*, String*)
--echo # --echo #
SET optimizer_switch = REPLACE( @@optimizer_switch, '=on', '=off' ); SET optimizer_switch = REPLACE(REPLACE(@@optimizer_switch, '=on', '=off'), 'in_to_exists=off', 'in_to_exists=on');
SET optimizer_switch='in_to_exists=on,exists_to_in=on'; SET optimizer_switch='exists_to_in=on';
CREATE TABLE t1 ( a VARCHAR(1) ); CREATE TABLE t1 ( a VARCHAR(1) );
INSERT INTO t1 VALUES ('k'),('m'); INSERT INTO t1 VALUES ('k'),('m');
@ -466,8 +466,8 @@ explain extended
SELECT * FROM t1 AS alias SELECT * FROM t1 AS alias
WHERE EXISTS ( SELECT * FROM t1 WHERE a > alias.a AND a = alias.b ); WHERE EXISTS ( SELECT * FROM t1 WHERE a > alias.a AND a = alias.b );
SET optimizer_switch = REPLACE( @@optimizer_switch, '=on', '=off' ); SET optimizer_switch = REPLACE(REPLACE(@@optimizer_switch, '=on', '=off'), 'materialization=off', 'materialization=on');
SET optimizer_switch = 'exists_to_in=on,materialization=on,semijoin=off'; SET optimizer_switch = 'exists_to_in=on,semijoin=off';
SELECT * FROM t1 AS alias SELECT * FROM t1 AS alias
WHERE EXISTS ( SELECT * FROM t1 WHERE a > alias.a AND a = alias.b ); WHERE EXISTS ( SELECT * FROM t1 WHERE a > alias.a AND a = alias.b );
explain extended explain extended

View File

@ -1794,8 +1794,7 @@ union
select 4 select 4
order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
; ;
foo ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION
1
prepare stmt1 from 'select 1 as foo prepare stmt1 from 'select 1 as foo
union union
select 2 select 2
@ -1805,12 +1804,7 @@ union
select 4 select 4
order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
'; ';
execute stmt1; ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION
foo
1
execute stmt1;
foo
1
select 1 as foo select 1 as foo
union union
select 2 select 2
@ -1820,8 +1814,7 @@ union
(select 4) (select 4)
order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
; ;
foo ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION
1
prepare stmt1 from 'select 1 as foo prepare stmt1 from 'select 1 as foo
union union
select 2 select 2
@ -1831,13 +1824,7 @@ union
(select 4) (select 4)
order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
'; ';
execute stmt1; ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION
foo
1
execute stmt1;
foo
1
deallocate prepare stmt1;
End of 5.1 tests End of 5.1 tests
# #
# mdev-5091: Asseirtion failure for UNION with ORDER BY # mdev-5091: Asseirtion failure for UNION with ORDER BY
@ -2336,6 +2323,14 @@ Warnings:
Note 1003 /* select#1 */ select 1 AS `1`,2 AS `2` union all /* select#2 */ select 1 AS `i`,count(0) AS `COUNT(*)` from `test`.`t2` where 0 group by 1 having 1 Note 1003 /* select#1 */ select 1 AS `1`,2 AS `2` union all /* select#2 */ select 1 AS `i`,count(0) AS `COUNT(*)` from `test`.`t2` where 0 group by 1 having 1
DROP TABLE t1,t2; DROP TABLE t1,t2;
# #
# MDEV-10120: Wrong result of UNION .. ORDER BY GROUP_CONCAT()
#
CREATE TABLE t1 (a INT);
INSERT t1 VALUES (1),(2),(3);
(SELECT 1 AS a) UNION (SELECT a FROM t1 GROUP BY a) ORDER BY GROUP_CONCAT(a);
ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION
DROP TABLE t1;
#
# Start of 10.3 tests # Start of 10.3 tests
# #
# #

View File

@ -1210,11 +1210,11 @@ select 4
order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
; ;
--error ER_AGGREGATE_ORDER_FOR_UNION
eval $my_stmt; eval $my_stmt;
--error ER_AGGREGATE_ORDER_FOR_UNION
eval prepare stmt1 from '$my_stmt'; eval prepare stmt1 from '$my_stmt';
execute stmt1;
execute stmt1;
let $my_stmt= let $my_stmt=
select 1 as foo select 1 as foo
@ -1227,13 +1227,11 @@ union
order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1)
; ;
--error ER_AGGREGATE_ORDER_FOR_UNION
eval $my_stmt; eval $my_stmt;
--error ER_AGGREGATE_ORDER_FOR_UNION
eval prepare stmt1 from '$my_stmt'; eval prepare stmt1 from '$my_stmt';
execute stmt1;
execute stmt1;
deallocate prepare stmt1;
--echo End of 5.1 tests --echo End of 5.1 tests
@ -1663,6 +1661,17 @@ eval EXPLAIN EXTENDED $q;
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo #
--echo # MDEV-10120: Wrong result of UNION .. ORDER BY GROUP_CONCAT()
--echo #
CREATE TABLE t1 (a INT);
INSERT t1 VALUES (1),(2),(3);
--error ER_AGGREGATE_ORDER_FOR_UNION
(SELECT 1 AS a) UNION (SELECT a FROM t1 GROUP BY a) ORDER BY GROUP_CONCAT(a);
DROP TABLE t1;
--echo # --echo #
--echo # Start of 10.3 tests --echo # Start of 10.3 tests

View File

@ -3798,6 +3798,51 @@ SELECT FIRST_VALUE(MAX(a) OVER (PARTITION BY a)) OVER (ORDER BY a) AS x FROM t1
ERROR HY000: Window functions can not be used as arguments to group functions. ERROR HY000: Window functions can not be used as arguments to group functions.
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-12059: Assertion `precision > 0' failed with a window function or window aggregate function
#
CREATE TABLE t1 (d DECIMAL(1,0) UNSIGNED);
INSERT INTO t1 VALUES (1),(2);
SELECT MIN(d) OVER () FROM t1;
MIN(d) OVER ()
1
1
DROP TABLE t1;
#
# MDEV-22463: Element_type &Bounds_checked_array<Item *>::operator[](size_t) [Element_type = Item *]:
# Assertion `n < m_size' failed
#
CREATE TABLE t1 (a INT, b INT, c INT, d INT, e INT, f INT, g int, h INT, i INT);
INSERT INTO t1 SELECT seq,seq,seq,seq, seq,seq,seq,seq,seq FROM seq_1_to_5;
SELECT ROW_NUMBER() OVER w2 FROM t1 WINDOW w2 AS (PARTITION BY -1,0,1,2,3,4,5,6);
ROW_NUMBER() OVER w2
1
2
3
4
5
SELECT a FROM t1 ORDER BY ROW_NUMBER() OVER (PARTITION BY -1,1,0,2,3,4,5,6,7,8);
a
1
2
3
4
5
SELECT a,b FROM t1 WINDOW w2 AS (PARTITION BY -1,1,0,2,3,4);
a b
1 1
2 2
3 3
4 4
5 5
SELECT ROW_NUMBER() OVER w2 FROM t1 WINDOW w2 AS (PARTITION BY -1,0,1,2,3,4,5,6);
ROW_NUMBER() OVER w2
1
2
3
4
5
DROP TABLE t1;
#
# End of 10.2 tests # End of 10.2 tests
# #
# #

View File

@ -1,6 +1,7 @@
# #
# Window Functions Tests # Window Functions Tests
# #
--source include/have_sequence.inc
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2;
@ -2472,6 +2473,30 @@ SELECT NTILE(MAX(a) OVER (PARTITION BY a)) OVER (PARTITION BY a ORDER BY b) FROM
SELECT FIRST_VALUE(MAX(a) OVER (PARTITION BY a)) OVER (ORDER BY a) AS x FROM t1 GROUP BY a; SELECT FIRST_VALUE(MAX(a) OVER (PARTITION BY a)) OVER (ORDER BY a) AS x FROM t1 GROUP BY a;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-12059: Assertion `precision > 0' failed with a window function or window aggregate function
--echo #
CREATE TABLE t1 (d DECIMAL(1,0) UNSIGNED);
INSERT INTO t1 VALUES (1),(2);
SELECT MIN(d) OVER () FROM t1;
DROP TABLE t1;
--echo #
--echo # MDEV-22463: Element_type &Bounds_checked_array<Item *>::operator[](size_t) [Element_type = Item *]:
--echo # Assertion `n < m_size' failed
--echo #
CREATE TABLE t1 (a INT, b INT, c INT, d INT, e INT, f INT, g int, h INT, i INT);
INSERT INTO t1 SELECT seq,seq,seq,seq, seq,seq,seq,seq,seq FROM seq_1_to_5;
SELECT ROW_NUMBER() OVER w2 FROM t1 WINDOW w2 AS (PARTITION BY -1,0,1,2,3,4,5,6);
--sorted_result
SELECT a FROM t1 ORDER BY ROW_NUMBER() OVER (PARTITION BY -1,1,0,2,3,4,5,6,7,8);
SELECT a,b FROM t1 WINDOW w2 AS (PARTITION BY -1,1,0,2,3,4);
SELECT ROW_NUMBER() OVER w2 FROM t1 WINDOW w2 AS (PARTITION BY -1,0,1,2,3,4,5,6);
DROP TABLE t1;
--echo # --echo #
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #

View File

@ -17,3 +17,7 @@ SELECT * FROM t;
i i
1 1
DROP TABLE t; DROP TABLE t;
# shutdown server
# remove datadir
# xtrabackup move back
# restart

View File

@ -8,6 +8,10 @@
let INNODB_PAGE_SIZE=`select @@innodb_page_size`; let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
let MYSQLD_DATADIR=`select @@datadir`; let MYSQLD_DATADIR=`select @@datadir`;
let $targetdir_old=$MYSQLTEST_VARDIR/tmp/backup_1;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir_old;
--enable_result_log
--source include/shutdown_mysqld.inc --source include/shutdown_mysqld.inc
perl; perl;
@ -56,3 +60,7 @@ exec $XTRABACKUP --prepare --target-dir=$targetdir;
SELECT * FROM t; SELECT * FROM t;
DROP TABLE t; DROP TABLE t;
rmdir $targetdir; rmdir $targetdir;
let $targetdir= $targetdir_old;
exec $XTRABACKUP --prepare --target-dir=$targetdir;
--source include/restart_and_restore.inc
rmdir $targetdir_old;

View File

@ -17,38 +17,38 @@ OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,i
select * from information_schema.session_variables where variable_name='optimizer_switch'; select * from information_schema.session_variables where variable_name='optimizer_switch';
VARIABLE_NAME VARIABLE_VALUE VARIABLE_NAME VARIABLE_VALUE
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
set global optimizer_switch=10; set global optimizer_switch=4101;
set session optimizer_switch=5; set session optimizer_switch=2058;
select @@global.optimizer_switch; select @@global.optimizer_switch;
@@global.optimizer_switch @@global.optimizer_switch
index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off
select @@session.optimizer_switch; select @@session.optimizer_switch;
@@session.optimizer_switch @@session.optimizer_switch
index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off
set global optimizer_switch="index_merge_sort_union=on"; set global optimizer_switch="index_merge_sort_union=on";
set session optimizer_switch="index_merge=off"; set session optimizer_switch="index_merge=off";
select @@global.optimizer_switch; select @@global.optimizer_switch;
@@global.optimizer_switch @@global.optimizer_switch
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off
select @@session.optimizer_switch; select @@session.optimizer_switch;
@@session.optimizer_switch @@session.optimizer_switch
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off
show global variables like 'optimizer_switch'; show global variables like 'optimizer_switch';
Variable_name Value Variable_name Value
optimizer_switch index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off optimizer_switch index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off
show session variables like 'optimizer_switch'; show session variables like 'optimizer_switch';
Variable_name Value Variable_name Value
optimizer_switch index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off optimizer_switch index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off
select * from information_schema.global_variables where variable_name='optimizer_switch'; select * from information_schema.global_variables where variable_name='optimizer_switch';
VARIABLE_NAME VARIABLE_VALUE VARIABLE_NAME VARIABLE_VALUE
OPTIMIZER_SWITCH index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off OPTIMIZER_SWITCH index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off
select * from information_schema.session_variables where variable_name='optimizer_switch'; select * from information_schema.session_variables where variable_name='optimizer_switch';
VARIABLE_NAME VARIABLE_VALUE VARIABLE_NAME VARIABLE_VALUE
OPTIMIZER_SWITCH index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off OPTIMIZER_SWITCH index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off
set session optimizer_switch="default"; set session optimizer_switch="default";
select @@session.optimizer_switch; select @@session.optimizer_switch;
@@session.optimizer_switch @@session.optimizer_switch
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off,condition_pushdown_for_subquery=off,rowid_filter=off,condition_pushdown_from_having=off
set optimizer_switch = replace(@@optimizer_switch, '=off', '=on'); set optimizer_switch = replace(@@optimizer_switch, '=off', '=on');
Warnings: Warnings:
Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release

View File

@ -19,8 +19,8 @@ select * from information_schema.session_variables where variable_name='optimize
# #
# show that it's writable # show that it's writable
# #
set global optimizer_switch=10; set global optimizer_switch=4101;
set session optimizer_switch=5; set session optimizer_switch=2058;
select @@global.optimizer_switch; select @@global.optimizer_switch;
select @@session.optimizer_switch; select @@session.optimizer_switch;
set global optimizer_switch="index_merge_sort_union=on"; set global optimizer_switch="index_merge_sort_union=on";

View File

@ -1,5 +1,5 @@
# Copyright (c) 2006, 2017, Oracle and/or its affiliates. # Copyright (c) 2006, 2017, Oracle and/or its affiliates.
# Copyright (c) 2011, 2017, MariaDB Corporation # Copyright (c) 2011, 2020, MariaDB Corporation
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -281,6 +281,36 @@ ELSE()
SET(WSREP_SOURCE SET(WSREP_SOURCE
wsrep_sst_common wsrep_sst_common
) )
SET (wsrep_sst_rsync_wan ${CMAKE_CURRENT_BINARY_DIR}/wsrep_sst_rsync_wan)
ADD_CUSTOM_COMMAND(
OUTPUT ${wsrep_sst_rsync_wan}
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink
wsrep_sst_rsync
wsrep_sst_rsync_wan
)
ADD_CUSTOM_TARGET(symlink_wsrep_sst_rsync
ALL
DEPENDS ${wsrep_sst_rsync_wan}
)
INSTALL(
FILES ${wsrep_sst_rsync_wan}
DESTINATION ${INSTALL_BINDIR}
COMPONENT Server
)
FOREACH(file ${WSREP_SOURCE})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh
${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY)
IF(NOT ${file}_COMPONENT)
SET(${file}_COMPONENT Server)
ENDIF()
INSTALL(FILES
${CMAKE_CURRENT_BINARY_DIR}/${file}
DESTINATION ${INSTALL_BINDIR}
COMPONENT ${${file}_COMPONENT}
)
ENDFOREACH()
ENDIF() ENDIF()
IF (NOT WITHOUT_SERVER) IF (NOT WITHOUT_SERVER)
SET(SERVER_SCRIPTS SET(SERVER_SCRIPTS
@ -332,36 +362,6 @@ ELSE()
COMPONENT ${${file}_COMPONENT} COMPONENT ${${file}_COMPONENT}
) )
ENDFOREACH() ENDFOREACH()
SET (wsrep_sst_rsync_wan ${CMAKE_CURRENT_BINARY_DIR}/wsrep_sst_rsync_wan)
ADD_CUSTOM_COMMAND(
OUTPUT ${wsrep_sst_rsync_wan}
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink
wsrep_sst_rsync
wsrep_sst_rsync_wan
)
ADD_CUSTOM_TARGET(symlink_wsrep_sst_rsync
ALL
DEPENDS ${wsrep_sst_rsync_wan}
)
INSTALL(
FILES ${wsrep_sst_rsync_wan}
DESTINATION ${INSTALL_BINDIR}
COMPONENT Server
)
FOREACH(file ${WSREP_SOURCE})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh
${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY)
IF(NOT ${file}_COMPONENT)
SET(${file}_COMPONENT Server)
ENDIF()
INSTALL(FILES
${CMAKE_CURRENT_BINARY_DIR}/${file}
DESTINATION ${INSTALL_BINDIR}
COMPONENT ${${file}_COMPONENT}
)
ENDFOREACH()
ENDIF() ENDIF()
# Install libgcc as mylibgcc.a # Install libgcc as mylibgcc.a

View File

@ -57,7 +57,7 @@ const char field_separator=',';
#define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \ #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
((ulong) ((1LL << MY_MIN(arg, 4) * 8) - 1)) ((ulong) ((1LL << MY_MIN(arg, 4) * 8) - 1))
// Column marked for read or the field set to read out or record[0] or [1] // Column marked for read or the field set to read out of record[0]
inline bool Field::marked_for_read() const inline bool Field::marked_for_read() const
{ {
return !table || return !table ||
@ -68,7 +68,7 @@ inline bool Field::marked_for_read() const
} }
/* /*
The name of this function is a bit missleading as in 10.4 we don't The name of this function is a bit misleading as in 10.4 we don't
have to test anymore if the field is computed. Instead we mark have to test anymore if the field is computed. Instead we mark
changed fields with DBUG_FIX_WRITE_SET() in table.cc changed fields with DBUG_FIX_WRITE_SET() in table.cc
*/ */

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. /* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
Copyright (c) 2009, 2015, MariaDB Copyright (c) 2009, 2020, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -236,7 +236,8 @@ SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort,
while (memory_available >= min_sort_memory) while (memory_available >= min_sort_memory)
{ {
ulonglong keys= memory_available / (param.rec_length + sizeof(char*)); ulonglong keys= memory_available / (param.rec_length + sizeof(char*));
param.max_keys_per_buffer= (uint) MY_MIN(num_rows, keys); param.max_keys_per_buffer= (uint) MY_MAX(MERGEBUFF2,
MY_MIN(num_rows, keys));
if (sort->alloc_sort_buffer(param.max_keys_per_buffer, param.rec_length)) if (sort->alloc_sort_buffer(param.max_keys_per_buffer, param.rec_length))
break; break;
size_t old_memory_available= memory_available; size_t old_memory_available= memory_available;

View File

@ -1,4 +1,5 @@
/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2012, 2020, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -106,7 +107,6 @@ uchar **Filesort_buffer::alloc_sort_buffer(uint num_records,
DBUG_SET("+d,simulate_out_of_memory");); DBUG_SET("+d,simulate_out_of_memory"););
buff_size= ((size_t)num_records) * (record_length + sizeof(uchar*)); buff_size= ((size_t)num_records) * (record_length + sizeof(uchar*));
set_if_bigger(buff_size, record_length * MERGEBUFF2);
if (!m_idx_array.is_null()) if (!m_idx_array.is_null())
{ {

View File

@ -1,5 +1,5 @@
/* /*
Copyright (c) 2016,2017 MariaDB Copyright (c) 2016, 2020, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -724,9 +724,8 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
{ {
DBUG_PRINT("info", ("Subquery can't be converted to merged semi-join")); DBUG_PRINT("info", ("Subquery can't be converted to merged semi-join"));
/* Test if the user has set a legal combination of optimizer switches. */ /* Test if the user has set a legal combination of optimizer switches. */
if (!optimizer_flag(thd, OPTIMIZER_SWITCH_IN_TO_EXISTS) && DBUG_ASSERT(optimizer_flag(thd, OPTIMIZER_SWITCH_IN_TO_EXISTS |
!optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION)) OPTIMIZER_SWITCH_MATERIALIZATION));
my_error(ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES, MYF(0));
/* /*
Transform each subquery predicate according to its overloaded Transform each subquery predicate according to its overloaded
transformer. transformer.

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2002, 2018, Oracle and/or its affiliates. Copyright (c) 2002, 2018, Oracle and/or its affiliates.
Copyright (c) 2009, 2018, MariaDB Copyright (c) 2009, 2020, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1234,20 +1234,20 @@ Sp_handler::sp_create_routine(THD *thd, const sp_head *sp) const
switch (type()) { switch (type()) {
case TYPE_ENUM_PACKAGE: case TYPE_ENUM_PACKAGE:
// Drop together with its PACKAGE BODY mysql.proc record // Drop together with its PACKAGE BODY mysql.proc record
ret= sp_handler_package_spec.sp_find_and_drop_routine(thd, table, sp); if (sp_handler_package_spec.sp_find_and_drop_routine(thd, table, sp))
goto done;
break; break;
case TYPE_ENUM_PACKAGE_BODY: case TYPE_ENUM_PACKAGE_BODY:
case TYPE_ENUM_FUNCTION: case TYPE_ENUM_FUNCTION:
case TYPE_ENUM_PROCEDURE: case TYPE_ENUM_PROCEDURE:
ret= sp_drop_routine_internal(thd, sp, table); if (sp_drop_routine_internal(thd, sp, table))
goto done;
break; break;
case TYPE_ENUM_TRIGGER: case TYPE_ENUM_TRIGGER:
case TYPE_ENUM_PROXY: case TYPE_ENUM_PROXY:
DBUG_ASSERT(0); DBUG_ASSERT(0);
ret= SP_OK; ret= SP_OK;
} }
if (ret != SP_OK)
goto done;
} }
else if (lex->create_info.if_not_exists()) else if (lex->create_info.if_not_exists())
{ {

View File

@ -2409,6 +2409,7 @@ void st_select_lex::init_query()
n_sum_items= 0; n_sum_items= 0;
n_child_sum_items= 0; n_child_sum_items= 0;
hidden_bit_fields= 0; hidden_bit_fields= 0;
fields_in_window_functions= 0;
subquery_in_having= explicit_limit= 0; subquery_in_having= explicit_limit= 0;
is_item_list_lookup= 0; is_item_list_lookup= 0;
changed_elements= 0; changed_elements= 0;
@ -2970,7 +2971,8 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
select_n_having_items + select_n_having_items +
select_n_where_fields + select_n_where_fields +
order_group_num + order_group_num +
hidden_bit_fields) * 5; hidden_bit_fields +
fields_in_window_functions) * 5;
if (!ref_pointer_array.is_null()) if (!ref_pointer_array.is_null())
{ {
/* /*

View File

@ -1171,6 +1171,14 @@ public:
converted to a GROUP BY involving BIT fields. converted to a GROUP BY involving BIT fields.
*/ */
uint hidden_bit_fields; uint hidden_bit_fields;
/*
Number of fields used in the definition of all the windows functions.
This includes:
1) Fields in the arguments
2) Fields in the PARTITION BY clause
3) Fields in the ORDER BY clause
*/
uint fields_in_window_functions;
enum_parsing_place parsing_place; /* where we are parsing expression */ enum_parsing_place parsing_place; /* where we are parsing expression */
enum_parsing_place save_parsing_place; enum_parsing_place save_parsing_place;
enum_parsing_place context_analysis_place; /* where we are in prepare */ enum_parsing_place context_analysis_place; /* where we are in prepare */
@ -1504,10 +1512,7 @@ public:
SQL_I_List<ORDER> win_order_list, SQL_I_List<ORDER> win_order_list,
Window_frame *win_frame); Window_frame *win_frame);
List<Item_window_func> window_funcs; List<Item_window_func> window_funcs;
bool add_window_func(Item_window_func *win_func) bool add_window_func(Item_window_func *win_func);
{
return window_funcs.push_back(win_func);
}
bool have_window_funcs() const { return (window_funcs.elements !=0); } bool have_window_funcs() const { return (window_funcs.elements !=0); }
ORDER *find_common_window_func_partition_fields(THD *thd); ORDER *find_common_window_func_partition_fields(THD *thd);

View File

@ -8732,6 +8732,11 @@ bool st_select_lex::add_window_def(THD *thd,
win_frame); win_frame);
group_list= thd->lex->save_group_list; group_list= thd->lex->save_group_list;
order_list= thd->lex->save_order_list; order_list= thd->lex->save_order_list;
if (parsing_place != SELECT_LIST)
{
fields_in_window_functions+= win_part_list_ptr->elements +
win_order_list_ptr->elements;
}
return (win_def == NULL || window_specs.push_back(win_def)); return (win_def == NULL || window_specs.push_back(win_def));
} }
@ -8753,6 +8758,11 @@ bool st_select_lex::add_window_spec(THD *thd,
win_frame); win_frame);
group_list= thd->lex->save_group_list; group_list= thd->lex->save_group_list;
order_list= thd->lex->save_order_list; order_list= thd->lex->save_order_list;
if (parsing_place != SELECT_LIST)
{
fields_in_window_functions+= win_part_list_ptr->elements +
win_order_list_ptr->elements;
}
thd->lex->win_spec= win_spec; thd->lex->win_spec= win_spec;
return (win_spec == NULL || window_specs.push_back(win_spec)); return (win_spec == NULL || window_specs.push_back(win_spec));
} }

View File

@ -24274,10 +24274,13 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
List<Item> &fields, List<Item> &all_fields, ORDER *order, List<Item> &fields, List<Item> &all_fields, ORDER *order,
bool from_window_spec) bool from_window_spec)
{ {
SELECT_LEX *select = thd->lex->current_select;
enum_parsing_place context_analysis_place= enum_parsing_place context_analysis_place=
thd->lex->current_select->context_analysis_place; thd->lex->current_select->context_analysis_place;
thd->where="order clause"; thd->where="order clause";
for (; order; order=order->next) const bool for_union= select->master_unit()->is_unit_op() &&
select == select->master_unit()->fake_select_lex;
for (uint number = 1; order; order=order->next, number++)
{ {
if (find_order_in_list(thd, ref_pointer_array, tables, order, fields, if (find_order_in_list(thd, ref_pointer_array, tables, order, fields,
all_fields, false, true, from_window_spec)) all_fields, false, true, from_window_spec))
@ -24288,8 +24291,22 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0));
return 1; return 1;
} }
if (from_window_spec && (*order->item)->with_sum_func() &&
(*order->item)->type() != Item::SUM_FUNC_ITEM) if (!(*order->item)->with_sum_func())
continue;
/*
UNION queries cannot be used with an aggregate function in
an ORDER BY clause
*/
if (for_union)
{
my_error(ER_AGGREGATE_ORDER_FOR_UNION, MYF(0), number);
return 1;
}
if (from_window_spec && (*order->item)->type() != Item::SUM_FUNC_ITEM)
(*order->item)->split_sum_func(thd, ref_pointer_array, (*order->item)->split_sum_func(thd, ref_pointer_array,
all_fields, SPLIT_SUM_SELECT); all_fields, SPLIT_SUM_SELECT);
} }

View File

@ -3159,6 +3159,14 @@ Window_funcs_computation::save_explain_plan(MEM_ROOT *mem_root,
return xpl; return xpl;
} }
bool st_select_lex::add_window_func(Item_window_func *win_func)
{
if (parsing_place != SELECT_LIST)
fields_in_window_functions+= win_func->window_func()->argument_count();
return window_funcs.push_back(win_func);
}
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Unneeded comments (will be removed when we develop a replacement for // Unneeded comments (will be removed when we develop a replacement for
// the feature that was attempted here // the feature that was attempted here

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2002, 2015, Oracle and/or its affiliates. /* Copyright (c) 2002, 2015, Oracle and/or its affiliates.
Copyright (c) 2012, 2018, MariaDB Corporation. Copyright (c) 2012, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -2612,12 +2612,23 @@ static bool fix_optimizer_switch(sys_var *self, THD *thd,
"engine_condition_pushdown=on"); "engine_condition_pushdown=on");
return false; return false;
} }
static bool check_legal_optimizer_switch(sys_var *self, THD *thd,
set_var *var)
{
if (var->save_result.ulonglong_value & (OPTIMIZER_SWITCH_MATERIALIZATION |
OPTIMIZER_SWITCH_IN_TO_EXISTS))
{
return false;
}
my_error(ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES, MYF(0));
return true;
}
static Sys_var_flagset Sys_optimizer_switch( static Sys_var_flagset Sys_optimizer_switch(
"optimizer_switch", "optimizer_switch",
"Fine-tune the optimizer behavior", "Fine-tune the optimizer behavior",
SESSION_VAR(optimizer_switch), CMD_LINE(REQUIRED_ARG), SESSION_VAR(optimizer_switch), CMD_LINE(REQUIRED_ARG),
optimizer_switch_names, DEFAULT(OPTIMIZER_SWITCH_DEFAULT), optimizer_switch_names, DEFAULT(OPTIMIZER_SWITCH_DEFAULT),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_legal_optimizer_switch),
ON_UPDATE(fix_optimizer_switch)); ON_UPDATE(fix_optimizer_switch));
static Sys_var_flagset Sys_optimizer_trace( static Sys_var_flagset Sys_optimizer_trace(

View File

@ -116,6 +116,24 @@ BOOL exclude_service(mysqld_service_properties *props)
} }
static void get_datadir_from_ini(const char *ini, char *service_name, char *datadir, size_t sz)
{
*datadir= 0;
const char *sections[]= {service_name, "mysqld", "server", "mariadb",
"mariadbd"};
for (int i= 0; i < sizeof(sections) / sizeof(sections[0]); i++)
{
if (sections[i])
{
GetPrivateProfileStringA(sections[i], "datadir", NULL, datadir,
(DWORD) sz, ini);
if (*datadir)
return;
}
}
}
/* /*
Retrieve some properties from windows mysqld service binary path. Retrieve some properties from windows mysqld service binary path.
We're interested in ini file location and datadir, and also in version of We're interested in ini file location and datadir, and also in version of
@ -135,6 +153,7 @@ int get_mysql_service_properties(const wchar_t *bin_path,
wchar_t **args= NULL; wchar_t **args= NULL;
int retval= 1; int retval= 1;
BOOL have_inifile; BOOL have_inifile;
char service_name[MAX_PATH];
props->datadir[0]= 0; props->datadir[0]= 0;
props->inifile[0]= 0; props->inifile[0]= 0;
@ -163,6 +182,9 @@ int get_mysql_service_properties(const wchar_t *bin_path,
goto end; goto end;
} }
/* Last parameter is the service name*/
wcstombs(service_name, args[numargs-1], MAX_PATH);
if(have_inifile && wcsncmp(args[1], L"--defaults-file=", 16) != 0) if(have_inifile && wcsncmp(args[1], L"--defaults-file=", 16) != 0)
goto end; goto end;
@ -194,8 +216,8 @@ int get_mysql_service_properties(const wchar_t *bin_path,
normalize_path(props->inifile, MAX_PATH); normalize_path(props->inifile, MAX_PATH);
if (GetFileAttributes(props->inifile) != INVALID_FILE_ATTRIBUTES) if (GetFileAttributes(props->inifile) != INVALID_FILE_ATTRIBUTES)
{ {
GetPrivateProfileString("mysqld", "datadir", NULL, props->datadir, MAX_PATH, get_datadir_from_ini(props->inifile, service_name, props->datadir,
props->inifile); sizeof(props->datadir));
} }
else else
{ {
@ -244,8 +266,8 @@ int get_mysql_service_properties(const wchar_t *bin_path,
if (GetFileAttributes(props->inifile) != INVALID_FILE_ATTRIBUTES) if (GetFileAttributes(props->inifile) != INVALID_FILE_ATTRIBUTES)
{ {
/* Ini file found, get datadir from there */ /* Ini file found, get datadir from there */
GetPrivateProfileString("mysqld", "datadir", NULL, props->datadir, get_datadir_from_ini(props->inifile, service_name, props->datadir,
MAX_PATH, props->inifile); sizeof(props->datadir));
} }
else else
{ {

View File

@ -1622,8 +1622,6 @@ buf_chunk_init(
return(NULL); return(NULL);
} }
MEM_MAKE_ADDRESSABLE(chunk->mem, chunk->mem_size());
#ifdef HAVE_LIBNUMA #ifdef HAVE_LIBNUMA
if (srv_numa_interleave) { if (srv_numa_interleave) {
struct bitmask *numa_mems_allowed = numa_get_mems_allowed(); struct bitmask *numa_mems_allowed = numa_get_mems_allowed();

View File

@ -2487,7 +2487,7 @@ i_s_metrics_fill(
time_diff = 0; time_diff = 0;
} }
/* Unless MONITOR__NO_AVERAGE is marked, we will need /* Unless MONITOR_NO_AVERAGE is set, we must
to calculate the average value. If this is a monitor set to calculate the average value. If this is a monitor set
owner marked by MONITOR_SET_OWNER, divide owner marked by MONITOR_SET_OWNER, divide
the value by another counter (number of calls) designated the value by another counter (number of calls) designated
@ -2495,8 +2495,9 @@ i_s_metrics_fill(
Otherwise average the counter value by the time between the Otherwise average the counter value by the time between the
time that the counter is enabled and time it is disabled time that the counter is enabled and time it is disabled
or time it is sampled. */ or time it is sampled. */
if (!(monitor_info->monitor_type & MONITOR_NO_AVERAGE) if ((monitor_info->monitor_type
&& (monitor_info->monitor_type & MONITOR_SET_OWNER) & (MONITOR_NO_AVERAGE | MONITOR_SET_OWNER))
== MONITOR_SET_OWNER
&& monitor_info->monitor_related_id) { && monitor_info->monitor_related_id) {
mon_type_t value_start mon_type_t value_start
= MONITOR_VALUE_SINCE_START( = MONITOR_VALUE_SINCE_START(
@ -2512,18 +2513,18 @@ i_s_metrics_fill(
fields[METRIC_AVG_VALUE_START]->set_null(); fields[METRIC_AVG_VALUE_START]->set_null();
} }
if (MONITOR_VALUE(monitor_info->monitor_related_id)) { if (mon_type_t related_value =
OK(fields[METRIC_AVG_VALUE_RESET]->store( MONITOR_VALUE(monitor_info->monitor_related_id)) {
MONITOR_VALUE(count) OK(fields[METRIC_AVG_VALUE_RESET]
/ MONITOR_VALUE( ->store(MONITOR_VALUE(count)
monitor_info->monitor_related_id), / related_value, false));
FALSE)); fields[METRIC_AVG_VALUE_RESET]->set_notnull();
} else { } else {
fields[METRIC_AVG_VALUE_RESET]->set_null(); fields[METRIC_AVG_VALUE_RESET]->set_null();
} }
} else if (!(monitor_info->monitor_type & MONITOR_NO_AVERAGE) } else if (!(monitor_info->monitor_type
&& !(monitor_info->monitor_type & (MONITOR_NO_AVERAGE
& MONITOR_DISPLAY_CURRENT)) { | MONITOR_DISPLAY_CURRENT))) {
if (time_diff != 0) { if (time_diff != 0) {
OK(fields[METRIC_AVG_VALUE_START]->store( OK(fields[METRIC_AVG_VALUE_START]->store(
(double) MONITOR_VALUE_SINCE_START( (double) MONITOR_VALUE_SINCE_START(
@ -3305,6 +3306,8 @@ no_fts:
conv_str.f_len = sizeof word; conv_str.f_len = sizeof word;
conv_str.f_str = word; conv_str.f_str = word;
rw_lock_s_lock(&cache->lock);
for (ulint i = 0; i < ib_vector_size(cache->indexes); i++) { for (ulint i = 0; i < ib_vector_size(cache->indexes); i++) {
fts_index_cache_t* index_cache; fts_index_cache_t* index_cache;
@ -3315,6 +3318,7 @@ no_fts:
index_cache, thd, &conv_str, tables)); index_cache, thd, &conv_str, tables));
} }
rw_lock_s_unlock(&cache->lock);
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, FALSE, FALSE);
rw_lock_s_unlock(&dict_sys.latch); rw_lock_s_unlock(&dict_sys.latch);

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation. Copyright (c) 2017, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -668,13 +668,18 @@ row_quiesce_set_state(
" FTS auxiliary tables will not be flushed."); " FTS auxiliary tables will not be flushed.");
} }
dict_index_t* clust_index = dict_table_get_first_index(table);
row_mysql_lock_data_dictionary(trx); row_mysql_lock_data_dictionary(trx);
for (dict_index_t* index = dict_table_get_first_index(table);
for (dict_index_t* index = dict_table_get_next_index(clust_index);
index != NULL; index != NULL;
index = dict_table_get_next_index(index)) { index = dict_table_get_next_index(index)) {
rw_lock_x_lock(&index->lock); rw_lock_x_lock(&index->lock);
} }
rw_lock_x_lock(&clust_index->lock);
switch (state) { switch (state) {
case QUIESCE_START: case QUIESCE_START:
break; break;