Skip to content

Commit e124677

Browse files
committed
Merge 10.4 into 10.5
2 parents 258c34f + 9c6135e commit e124677

File tree

10 files changed

+83
-11
lines changed

10 files changed

+83
-11
lines changed

mysql-test/lib/mtr_cases.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ sub get_tags_from_file($$) {
10371037
}
10381038

10391039
# Check for a sourced include file.
1040-
if ($line =~ /^(--)?[[:space:]]*source[[:space:]]+([^;[:space:]]+)/)
1040+
if ($line =~ /^[[:space:]]*(--)?[[:space:]]*source[[:space:]]+([^;[:space:]]+)/)
10411041
{
10421042
my $include= $2;
10431043
# The rules below must match open_file() function of mysqltest.cc
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
#
2+
# MDEV-14429 sql_safe_updates in my.cnf not work
3+
#
14
select @@sql_safe_updates;
25
@@sql_safe_updates
36
1
7+
#
8+
# MDEV-18304 sql_safe_updates does not work with OR clauses
9+
#
10+
create table t1 (a int, b int, primary key (a), key (b));
11+
update t1 set b=2 where a=1 or b=2;
12+
ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
13+
explain update t1 set b=2 where a=1 or b=2;
14+
id select_type table type possible_keys key key_len ref rows Extra
15+
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where
16+
delete from t1 where a=1 or b=2;
17+
ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
18+
explain delete from t1 where a=1 or b=2;
19+
id select_type table type possible_keys key key_len ref rows Extra
20+
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where
21+
insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8);
22+
update t1 set b=2 where a=1 or b=2;
23+
delete from t1 where a=1 or b=2;
24+
drop table t1;
25+
#
26+
# End of 10.3 tests
27+
#

mysql-test/main/sql_safe_updates.test

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
#
2-
# MDEV-14429 sql_safe_updates in my.cnf not work
3-
#
1+
--echo #
2+
--echo # MDEV-14429 sql_safe_updates in my.cnf not work
3+
--echo #
44
select @@sql_safe_updates;
5+
6+
--echo #
7+
--echo # MDEV-18304 sql_safe_updates does not work with OR clauses
8+
--echo #
9+
create table t1 (a int, b int, primary key (a), key (b));
10+
--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
11+
update t1 set b=2 where a=1 or b=2;
12+
explain update t1 set b=2 where a=1 or b=2;
13+
--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
14+
delete from t1 where a=1 or b=2;
15+
explain delete from t1 where a=1 or b=2;
16+
insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8);
17+
update t1 set b=2 where a=1 or b=2;
18+
delete from t1 where a=1 or b=2;
19+
drop table t1;
20+
21+
--echo #
22+
--echo # End of 10.3 tests
23+
--echo #

mysql-test/suite/innodb/r/instant_alter_bugs.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,13 @@ ALTER TABLE t ADD d INT;
451451
affected rows: 0
452452
info: Records: 0 Duplicates: 0 Warnings: 0
453453
DROP TABLE t;
454+
#
455+
# MDEV-28060 Online DDL fails while checking for instant
456+
# alter condition
457+
#
458+
CREATE TABLE t1(f1 CHAR(10) NOT NULL)ROW_FORMAT=REDUNDANT,ENGINE=InnoDB;
459+
ALTER TABLE t1 ADD COLUMN(f2 INT NOT NULL, f3 INT NOT NULL,
460+
f4 INT NOT NULL, f5 INT NOT NULL),
461+
CHANGE COLUMN f1 f1 CHAR(10) DEFAULT NULL;
462+
DROP TABLE t1;
454463
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;

mysql-test/suite/innodb/r/undo_truncate.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ connection con2;
2828
commit;
2929
disconnect con2;
3030
connection default;
31+
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
32+
SET GLOBAL innodb_max_purge_lag_wait=0;
3133
set global innodb_fast_shutdown=0;
3234
# restart
3335
drop table t1, t2;

mysql-test/suite/innodb/t/instant_alter_bugs.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,4 +467,13 @@ ALTER TABLE t ADD d INT;
467467
--disable_info
468468
DROP TABLE t;
469469

470+
--echo #
471+
--echo # MDEV-28060 Online DDL fails while checking for instant
472+
--echo # alter condition
473+
--echo #
474+
CREATE TABLE t1(f1 CHAR(10) NOT NULL)ROW_FORMAT=REDUNDANT,ENGINE=InnoDB;
475+
ALTER TABLE t1 ADD COLUMN(f2 INT NOT NULL, f3 INT NOT NULL,
476+
f4 INT NOT NULL, f5 INT NOT NULL),
477+
CHANGE COLUMN f1 f1 CHAR(10) DEFAULT NULL;
478+
DROP TABLE t1;
470479
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;

mysql-test/suite/innodb/t/undo_truncate.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ connection default;
4646
let $trx_before= `SHOW ENGINE INNODB STATUS`;
4747
let $trx_before= `select substr('$trx_before',9)+2`;
4848

49+
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
50+
SET GLOBAL innodb_max_purge_lag_wait=0;
4951
set global innodb_fast_shutdown=0;
5052
--source include/restart_mysqld.inc
5153
--replace_regex /.*Trx id counter ([0-9]+).*/\1/

sql/sql_delete.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
3-
Copyright (c) 2010, 2021, MariaDB
3+
Copyright (c) 2010, 2022, MariaDB
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -406,7 +406,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
406406
DBUG_RETURN(TRUE);
407407

408408
const_cond= (!conds || conds->const_item());
409-
safe_update= MY_TEST(thd->variables.option_bits & OPTION_SAFE_UPDATES);
409+
safe_update= (thd->variables.option_bits & OPTION_SAFE_UPDATES) &&
410+
!thd->lex->describe;
410411
if (safe_update && const_cond)
411412
{
412413
my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,
@@ -531,7 +532,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
531532
}
532533

533534
/* If running in safe sql mode, don't allow updates without keys */
534-
if (table->opt_range_keys.is_clear_all())
535+
if (!select || !select->quick)
535536
{
536537
thd->set_status_no_index_used();
537538
if (safe_update && !using_limit)

sql/sql_update.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
2-
Copyright (c) 2011, 2021, MariaDB
2+
Copyright (c) 2011, 2022, MariaDB
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -370,7 +370,8 @@ int mysql_update(THD *thd,
370370
ha_rows *found_return, ha_rows *updated_return)
371371
{
372372
bool using_limit= limit != HA_POS_ERROR;
373-
bool safe_update= thd->variables.option_bits & OPTION_SAFE_UPDATES;
373+
bool safe_update= (thd->variables.option_bits & OPTION_SAFE_UPDATES)
374+
&& !thd->lex->describe;
374375
bool used_key_is_modified= FALSE, transactional_table;
375376
bool will_batch= FALSE;
376377
bool can_compare_record;
@@ -597,7 +598,7 @@ int mysql_update(THD *thd,
597598
}
598599

599600
/* If running in safe sql mode, don't allow updates without keys */
600-
if (table->opt_range_keys.is_clear_all())
601+
if (!select || !select->quick)
601602
{
602603
thd->set_status_no_index_used();
603604
if (safe_update && !using_limit)

storage/innobase/handler/handler0alter.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,8 +1758,13 @@ instant_alter_column_possible(
17581758
Field** af = altered_table->field;
17591759
Field** const end = altered_table->field
17601760
+ altered_table->s->fields;
1761+
List_iterator_fast<Create_field> cf_it(
1762+
ha_alter_info->alter_info->create_list);
17611763
for (unsigned c = 0; af < end; af++) {
1762-
if (!(*af)->stored_in_db()) {
1764+
const Create_field* cf = cf_it++;
1765+
if (!cf->field || !(*af)->stored_in_db()) {
1766+
/* Ignore virtual or newly created
1767+
column */
17631768
continue;
17641769
}
17651770

0 commit comments

Comments
 (0)