Commit b4477ae7 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch '10.3' into 10.4

parents 8a7776a8 a36fc80a
......@@ -121,7 +121,6 @@ static struct my_option my_long_options[]=
&opt_not_used, &opt_not_used, 0 , GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#define PASSWORD_OPT 12
{"password", 'p',
"Password to use when connecting to server. If password is not given,"
" it's solicited on the tty.", &opt_password,&opt_password,
......@@ -153,7 +152,6 @@ static struct my_option my_long_options[]=
{"upgrade-system-tables", 's', "Only upgrade the system tables in the mysql database. Tables in other databases are not checked or touched.",
&opt_systables_only, &opt_systables_only, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
#define USER_OPT (array_elements(my_long_options) - 6)
{"user", 'u', "User for login.", &opt_user,
&opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Display more output about the process; Using it twice will print connection argument; Using it 3 times will print out all CHECK, RENAME and ALTER TABLE during the check phase.",
......@@ -260,11 +258,11 @@ static void print_error(const char *error_msg, DYNAMIC_STRING *output)
*/
static void add_one_option_cmd_line(DYNAMIC_STRING *ds,
const struct my_option *opt,
const char* arg)
const char *name,
const char *arg)
{
dynstr_append(ds, "--");
dynstr_append(ds, opt->name);
dynstr_append(ds, name);
if (arg)
{
dynstr_append(ds, "=");
......@@ -274,10 +272,10 @@ static void add_one_option_cmd_line(DYNAMIC_STRING *ds,
}
static void add_one_option_cnf_file(DYNAMIC_STRING *ds,
const struct my_option *opt,
const char* arg)
const char *name,
const char *arg)
{
dynstr_append(ds, opt->name);
dynstr_append(ds, name);
if (arg)
{
dynstr_append(ds, "=");
......@@ -320,7 +318,7 @@ get_one_option(int optid, const struct my_option *opt,
if (argument)
{
/* Add password to ds_args before overwriting the arg with x's */
add_one_option_cnf_file(&ds_args, opt, argument);
add_one_option_cnf_file(&ds_args, opt->name, argument);
while (*argument)
*argument++= 'x'; /* Destroy argument */
tty_password= 0;
......@@ -378,7 +376,7 @@ get_one_option(int optid, const struct my_option *opt,
case OPT_MYSQL_PROTOCOL: /* --protocol */
case OPT_PLUGIN_DIR: /* --plugin-dir */
case OPT_DEFAULT_AUTH: /* --default-auth */
add_one_option_cmd_line(&conn_args, opt, argument);
add_one_option_cmd_line(&conn_args, opt->name, argument);
break;
}
......@@ -389,7 +387,7 @@ get_one_option(int optid, const struct my_option *opt,
it can be passed on to "mysql" and "mysqlcheck"
Save it in the ds_args string
*/
add_one_option_cnf_file(&ds_args, opt, argument);
add_one_option_cnf_file(&ds_args, opt->name, argument);
}
return 0;
}
......@@ -1349,12 +1347,10 @@ int main(int argc, char **argv)
{
opt_password= get_tty_password(NullS);
/* add password to defaults file */
add_one_option_cnf_file(&ds_args, &my_long_options[PASSWORD_OPT], opt_password);
DBUG_ASSERT(strcmp(my_long_options[PASSWORD_OPT].name, "password") == 0);
add_one_option_cnf_file(&ds_args, "password", opt_password);
}
/* add user to defaults file */
add_one_option_cnf_file(&ds_args, &my_long_options[USER_OPT], opt_user);
DBUG_ASSERT(strcmp(my_long_options[USER_OPT].name, "user") == 0);
add_one_option_cnf_file(&ds_args, "user", opt_user);
cnf_file_path= strmov(defaults_file, "--defaults-file=");
{
......
......@@ -2185,6 +2185,39 @@ select * from t1;
a
7
drop table t1,t2;
#
# MDEV-25766: Unused CTE lead to a crash in
# find_field_in_tables/find_order_in_list
#
create table t1 (f1 INTEGER);
create view v1 as
select
subq_0.c4 as c2,
subq_0.c4 as c4
from
(select
ref_0.f1 as c4
from
t1 as ref_0
where (select 1)
) as subq_0
order by c2, c4 desc;
WITH
unused_with AS (select
subq_0.c4 as c6
from
(select
11 as c4
from
v1 as ref_0
) as subq_0,
v1 as ref_2
)
select 1 ;
1
1
drop view v1;
drop table t1;
# End of 10.2 tests
#
# MDEV-21673: several references to CTE that uses
......
......@@ -1625,6 +1625,42 @@ select * from t1;
drop table t1,t2;
--echo #
--echo # MDEV-25766: Unused CTE lead to a crash in
--echo # find_field_in_tables/find_order_in_list
--echo #
create table t1 (f1 INTEGER);
create view v1 as
select
subq_0.c4 as c2,
subq_0.c4 as c4
from
(select
ref_0.f1 as c4
from
t1 as ref_0
where (select 1)
) as subq_0
order by c2, c4 desc;
WITH
unused_with AS (select
subq_0.c4 as c6
from
(select
11 as c4
from
v1 as ref_0
) as subq_0,
v1 as ref_2
)
select 1 ;
drop view v1;
drop table t1;
--echo # End of 10.2 tests
--echo #
......
......@@ -1358,6 +1358,8 @@ INSERT IGNORE INTO t2 VALUES (8,0,0),(5,0,0);
CREATE TABLE t3 (f4 int,KEY (f4)) ;
INSERT IGNORE INTO t3 VALUES (0),(0);
set @@optimizer_switch='semijoin=off';
# NOTE: the following should have 'SUBQUERY', not 'DEPENDENT SUBQUERY'
# for line with id=2, see MDEV-27794.
EXPLAIN
SELECT * FROM t1 WHERE
(SELECT f2 FROM t2
......@@ -1367,7 +1369,7 @@ FROM t3 AS SQ1_t1 JOIN t3 AS SQ1_t3 ON SQ1_t3.f4
GROUP BY SQ1_t1.f4));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary
3 SUBQUERY SQ1_t3 index f4 f4 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
SELECT * FROM t1 WHERE
......
......@@ -1039,6 +1039,8 @@ INSERT IGNORE INTO t3 VALUES (0),(0);
set @@optimizer_switch='semijoin=off';
--echo # NOTE: the following should have 'SUBQUERY', not 'DEPENDENT SUBQUERY'
--echo # for line with id=2, see MDEV-27794.
EXPLAIN
SELECT * FROM t1 WHERE
(SELECT f2 FROM t2
......
This diff is collapsed.
This diff is collapsed.
#
# MDEV-25636: Bug report: abortion in sql/sql_parse.cc:6294
#
CREATE TABLE t1 (i1 int)engine=innodb;
INSERT INTO `t1` VALUES (62),(66);
CREATE TABLE t2 (i1 int) engine=innodb;
SELECT 1 FROM t1
WHERE t1.i1 =( SELECT t1.i1 FROM t2
UNION SELECT i1 FROM (t1 AS dt1 natural JOIN t2)
window w1 as (partition by t1.i1));
1
drop table t1,t2;
# Another testcase
CREATE TABLE t1 (i3 int NOT NULL, i1 int , i2 int , i4 int , PRIMARY key(i2));
INSERT INTO t1 VALUES (6,72,98,98),(46,1,6952,0);
SELECT i1 FROM t1
WHERE t1.i3 =
(SELECT ref_4.i2 FROM t1 AS ref_4
WHERE t1.i2 > (SELECT i3 FROM t1 ORDER BY i3 LIMIT 1 OFFSET 4)
UNION
SELECT ref_6.i2
FROM (t1 AS ref_5 JOIN t1 AS ref_6 ON ((ref_6.i1 > ref_6.i2) OR (ref_5.i4 < ref_5.i4)))
WHERE (t1.i2 >= t1.i2));
i1
drop table t1;
#
# MDEV-25761: Assertion `aggr != __null' failed in sub_select_postjoin_aggr
#
CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY) engine=innodb;
INSERT INTO t1 VALUES (0),(4),(31);
CREATE TABLE t2 (i int) engine=innodb;
DELETE FROM t1 WHERE t1.a =
(SELECT t1.a FROM t2 UNION SELECT DISTINCT 52 FROM t2 r WHERE t1.a = t1.a);
DROP TABLE t1,t2;
--source include/have_innodb.inc
--echo #
--echo # MDEV-25636: Bug report: abortion in sql/sql_parse.cc:6294
--echo #
CREATE TABLE t1 (i1 int)engine=innodb;
INSERT INTO `t1` VALUES (62),(66);
CREATE TABLE t2 (i1 int) engine=innodb;
SELECT 1 FROM t1
WHERE t1.i1 =( SELECT t1.i1 FROM t2
UNION SELECT i1 FROM (t1 AS dt1 natural JOIN t2)
window w1 as (partition by t1.i1));
drop table t1,t2;
--echo # Another testcase
CREATE TABLE t1 (i3 int NOT NULL, i1 int , i2 int , i4 int , PRIMARY key(i2));
INSERT INTO t1 VALUES (6,72,98,98),(46,1,6952,0);
SELECT i1 FROM t1
WHERE t1.i3 =
(SELECT ref_4.i2 FROM t1 AS ref_4
WHERE t1.i2 > (SELECT i3 FROM t1 ORDER BY i3 LIMIT 1 OFFSET 4)
UNION
SELECT ref_6.i2
FROM (t1 AS ref_5 JOIN t1 AS ref_6 ON ((ref_6.i1 > ref_6.i2) OR (ref_5.i4 < ref_5.i4)))
WHERE (t1.i2 >= t1.i2));
drop table t1;
--echo #
--echo # MDEV-25761: Assertion `aggr != __null' failed in sub_select_postjoin_aggr
--echo #
CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY) engine=innodb;
INSERT INTO t1 VALUES (0),(4),(31);
CREATE TABLE t2 (i int) engine=innodb;
DELETE FROM t1 WHERE t1.a =
(SELECT t1.a FROM t2 UNION SELECT DISTINCT 52 FROM t2 r WHERE t1.a = t1.a);
DROP TABLE t1,t2;
......@@ -4198,6 +4198,38 @@ drop procedure sp7;
drop view v1,v2;
drop table t1;
#
# MDEV-17785: Window functions not working in ONLY_FULL_GROUP_BY mode
#
CREATE TABLE t1(a VARCHAR(10), b int);
INSERT INTO t1 VALUES
('Maths', 60),('Maths', 60),
('Maths', 70),('Maths', 55),
('Biology', 60), ('Biology', 70);
SET @save_sql_mode= @@sql_mode;
SET sql_mode = 'ONLY_FULL_GROUP_BY';
SELECT
RANK() OVER (PARTITION BY a ORDER BY b) AS rank,
a, b FROM t1 ORDER BY a, b DESC;
rank a b
2 Biology 70
1 Biology 60
4 Maths 70
2 Maths 60
2 Maths 60
1 Maths 55
SET sql_mode= @save_sql_mode;
DROP TABLE t1;
CREATE TABLE t1(i int,j int);
INSERT INTO t1 VALUES (1,1), (1,5),(1,4), (2,2),(2,5), (3,3),(4,4);
INSERT INTO t1 VALUES (1,1), (1,5),(1,4), (2,2),(2,5), (3,3),(4,4);
SELECT i, LAST_VALUE(COUNT(i)) OVER (PARTITION BY i ORDER BY j) FROM t1 GROUP BY i;
i LAST_VALUE(COUNT(i)) OVER (PARTITION BY i ORDER BY j)
1 6
2 4
3 2
4 2
DROP TABLE t1;
#
# End of 10.2 tests
#
#
......
......@@ -2703,6 +2703,33 @@ drop procedure sp7;
drop view v1,v2;
drop table t1;
--echo #
--echo # MDEV-17785: Window functions not working in ONLY_FULL_GROUP_BY mode
--echo #
CREATE TABLE t1(a VARCHAR(10), b int);
INSERT INTO t1 VALUES
('Maths', 60),('Maths', 60),
('Maths', 70),('Maths', 55),
('Biology', 60), ('Biology', 70);
SET @save_sql_mode= @@sql_mode;
SET sql_mode = 'ONLY_FULL_GROUP_BY';
SELECT
RANK() OVER (PARTITION BY a ORDER BY b) AS rank,
a, b FROM t1 ORDER BY a, b DESC;
SET sql_mode= @save_sql_mode;
DROP TABLE t1;
CREATE TABLE t1(i int,j int);
INSERT INTO t1 VALUES (1,1), (1,5),(1,4), (2,2),(2,5), (3,3),(4,4);
INSERT INTO t1 VALUES (1,1), (1,5),(1,4), (2,2),(2,5), (3,3),(4,4);
SELECT i, LAST_VALUE(COUNT(i)) OVER (PARTITION BY i ORDER BY j) FROM t1 GROUP BY i;
DROP TABLE t1;
--echo #
--echo # End of 10.2 tests
--echo #
......
......@@ -1747,7 +1747,7 @@ sub collect_mysqld_features_from_running_server ()
}
mtr_add_arg($args, "--silent"); # Tab separated output
mtr_add_arg($args, "-e '%s'", "use mysql; SHOW VARIABLES");
mtr_add_arg($args, "-e \"use mysql; SHOW VARIABLES\"");
my $cmd= "$mysql " . join(' ', @$args);
mtr_verbose("cmd: $cmd");
......
......@@ -4204,6 +4204,38 @@ drop procedure sp7;
drop view v1,v2;
drop table t1;
#
# MDEV-17785: Window functions not working in ONLY_FULL_GROUP_BY mode
#
CREATE TABLE t1(a VARCHAR(10), b int);
INSERT INTO t1 VALUES
('Maths', 60),('Maths', 60),
('Maths', 70),('Maths', 55),
('Biology', 60), ('Biology', 70);
SET @save_sql_mode= @@sql_mode;
SET sql_mode = 'ONLY_FULL_GROUP_BY';
SELECT
RANK() OVER (PARTITION BY a ORDER BY b) AS rank,
a, b FROM t1 ORDER BY a, b DESC;
rank a b
2 Biology 70
1 Biology 60
4 Maths 70
2 Maths 60
2 Maths 60
1 Maths 55
SET sql_mode= @save_sql_mode;
DROP TABLE t1;
CREATE TABLE t1(i int,j int);
INSERT INTO t1 VALUES (1,1), (1,5),(1,4), (2,2),(2,5), (3,3),(4,4);
INSERT INTO t1 VALUES (1,1), (1,5),(1,4), (2,2),(2,5), (3,3),(4,4);
SELECT i, LAST_VALUE(COUNT(i)) OVER (PARTITION BY i ORDER BY j) FROM t1 GROUP BY i;
i LAST_VALUE(COUNT(i)) OVER (PARTITION BY i ORDER BY j)
1 6
2 4
3 2
4 2
DROP TABLE t1;
#
# End of 10.2 tests
#
#
......
......@@ -28,6 +28,8 @@
# showed
#
# MDEV-27721 rpl.rpl_relay_max_extension test is not FreeBSD-compatible
--source include/linux.inc
--source include/have_innodb.inc
--source include/have_binlog_format_row.inc
--let $rpl_topology=1->2
......
#!/bin/bash -ue
#!/usr/bin/env bash
set -ue
# Copyright (C) 2017-2021 MariaDB
# Copyright (C) 2013 Percona Inc
#
......
#!/bin/bash -ue
#!/usr/bin/env bash
set -ue
# Copyright (C) 2009-2015 Codership Oy
# Copyright (C) 2017-2021 MariaDB
#
......
#!/bin/bash -ue
#!/usr/bin/env bash
set -ue
# Copyright (C) 2017-2021 MariaDB
# Copyright (C) 2010-2014 Codership Oy
......@@ -740,7 +742,7 @@ EOF
elif [ "$OS" = 'Linux' ]; then
tmpfile=$(mktemp "--tmpdir=$tmpdir")
else
tmpfile=$(TMPDIR="$tmpdir"; mktemp '-d')
tmpfile=$(TMPDIR="$tmpdir"; mktemp)
fi
wsrep_log_info "Extracting binlog files:"
......
......@@ -109,6 +109,8 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
return true;
}
window_func()->mark_as_window_func_sum_expr();
/*
TODO: why the last parameter is 'ref' in this call? What if window_func
decides to substitute itself for something else and does *ref=.... ?
......
......@@ -321,7 +321,7 @@ void end_read_record(READ_RECORD *info)
free_cache(info);
if (info->table)
{
if (info->table->is_created())
if (info->table->db_stat) // if opened
(void) info->table->file->extra(HA_EXTRA_NO_CACHE);
if (info->read_record_func != rr_quick) // otherwise quick_range does it
(void) info->table->file->ha_index_or_rnd_end();
......
......@@ -6475,9 +6475,10 @@ find_field_in_tables(THD *thd, Item_ident *item,
sl=sl->outer_select())
{
Item *subs= sl->master_unit()->item;
if (subs->type() == Item::SUBSELECT_ITEM &&
((Item_subselect*)subs)->substype() == Item_subselect::IN_SUBS &&
((Item_in_subselect*)subs)->test_strategy(SUBS_SEMI_JOIN))
if (!subs ||
(subs->type() == Item::SUBSELECT_ITEM &&
((Item_subselect*)subs)->substype() == Item_subselect::IN_SUBS &&
((Item_in_subselect*)subs)->test_strategy(SUBS_SEMI_JOIN)))
{
continue;
}
......
......@@ -4264,7 +4264,21 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
}
if (empty_union_result)
subquery_predicate->no_rows_in_result();
if (!is_correlated_unit)
if (is_correlated_unit)
{
/*
Some parts of UNION are not correlated. This means we will need to
re-execute the whole UNION every time. Mark all parts of the UNION
as correlated so that they are prepared to be executed multiple
times (if we don't do that, some part of the UNION may free its
execution data at the end of first execution and crash on the second
execution)
*/
for (SELECT_LEX *sl= un->first_select(); sl; sl= sl->next_select())
sl->uncacheable |= UNCACHEABLE_DEPENDENT;
}
else
un->uncacheable&= ~UNCACHEABLE_DEPENDENT;
subquery_predicate->is_correlated= is_correlated_unit;
}
......
......@@ -11693,9 +11693,6 @@ window_func:
simple_window_func
|
sum_expr
{
((Item_sum *) $1)->mark_as_window_func_sum_expr();
}
|
function_call_generic
{
......@@ -11708,8 +11705,6 @@ window_func:
thd->parse_error();
MYSQL_YYABORT;
}
((Item_sum *) $1)->mark_as_window_func_sum_expr();
}
;
......
......@@ -11791,9 +11791,6 @@ window_func:
simple_window_func
|
sum_expr
{
((Item_sum *) $1)->mark_as_window_func_sum_expr();
}
|
function_call_generic
{
......@@ -11806,8 +11803,6 @@ window_func:
thd->parse_error();
MYSQL_YYABORT;
}
((Item_sum *) $1)->mark_as_window_func_sum_expr();
}
;
......
......@@ -718,9 +718,10 @@ int maria_create(const char *name, enum data_file_type datafile_type,
share.base.extra_options|= MA_EXTRA_OPTIONS_INSERT_ORDER;
}
share.state.state.key_file_length= MY_ALIGN(info_length, maria_block_size);
DBUG_PRINT("info", ("info_length: %u", info_length));
/* There are only 16 bits for the total header length. */
if (info_length > 65535)
if (share.state.state.key_file_length > 65535)
{
my_printf_error(HA_WRONG_CREATE_OPTION,
"Aria table '%s' has too many columns and/or "
......@@ -777,8 +778,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
maria_set_all_keys_active(share.state.key_map, keys);
share.base.keystart = share.state.state.key_file_length=
MY_ALIGN(info_length, maria_block_size);
share.base.keystart = share.state.state.key_file_length;
share.base.max_key_block_length= maria_block_size;
share.base.max_key_length=ALIGN_SIZE(max_key_length+4);
share.base.records=ci->max_rows;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment