Commit e1246775 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.4 into 10.5

parents 258c34f1 9c6135e8
......@@ -1037,7 +1037,7 @@ sub get_tags_from_file($$) {
}
# Check for a sourced include file.
if ($line =~ /^(--)?[[:space:]]*source[[:space:]]+([^;[:space:]]+)/)
if ($line =~ /^[[:space:]]*(--)?[[:space:]]*source[[:space:]]+([^;[:space:]]+)/)
{
my $include= $2;
# The rules below must match open_file() function of mysqltest.cc
......
#
# MDEV-14429 sql_safe_updates in my.cnf not work
#
select @@sql_safe_updates;
@@sql_safe_updates
1
#
# MDEV-18304 sql_safe_updates does not work with OR clauses
#
create table t1 (a int, b int, primary key (a), key (b));
update t1 set b=2 where a=1 or b=2;
ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
explain update t1 set b=2 where a=1 or b=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where
delete from t1 where a=1 or b=2;
ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
explain delete from t1 where a=1 or b=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where
insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8);
update t1 set b=2 where a=1 or b=2;
delete from t1 where a=1 or b=2;
drop table t1;
#
# End of 10.3 tests
#
#
# MDEV-14429 sql_safe_updates in my.cnf not work
#
--echo #
--echo # MDEV-14429 sql_safe_updates in my.cnf not work
--echo #
select @@sql_safe_updates;
--echo #
--echo # MDEV-18304 sql_safe_updates does not work with OR clauses
--echo #
create table t1 (a int, b int, primary key (a), key (b));
--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
update t1 set b=2 where a=1 or b=2;
explain update t1 set b=2 where a=1 or b=2;
--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
delete from t1 where a=1 or b=2;
explain delete from t1 where a=1 or b=2;
insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8);
update t1 set b=2 where a=1 or b=2;
delete from t1 where a=1 or b=2;
drop table t1;
--echo #
--echo # End of 10.3 tests
--echo #
......@@ -451,4 +451,13 @@ ALTER TABLE t ADD d INT;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
DROP TABLE t;
#
# MDEV-28060 Online DDL fails while checking for instant
# alter condition
#
CREATE TABLE t1(f1 CHAR(10) NOT NULL)ROW_FORMAT=REDUNDANT,ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN(f2 INT NOT NULL, f3 INT NOT NULL,
f4 INT NOT NULL, f5 INT NOT NULL),
CHANGE COLUMN f1 f1 CHAR(10) DEFAULT NULL;
DROP TABLE t1;
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
......@@ -28,6 +28,8 @@ connection con2;
commit;
disconnect con2;
connection default;
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
SET GLOBAL innodb_max_purge_lag_wait=0;
set global innodb_fast_shutdown=0;
# restart
drop table t1, t2;
......@@ -467,4 +467,13 @@ ALTER TABLE t ADD d INT;
--disable_info
DROP TABLE t;
--echo #
--echo # MDEV-28060 Online DDL fails while checking for instant
--echo # alter condition
--echo #
CREATE TABLE t1(f1 CHAR(10) NOT NULL)ROW_FORMAT=REDUNDANT,ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN(f2 INT NOT NULL, f3 INT NOT NULL,
f4 INT NOT NULL, f5 INT NOT NULL),
CHANGE COLUMN f1 f1 CHAR(10) DEFAULT NULL;
DROP TABLE t1;
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
......@@ -46,6 +46,8 @@ connection default;
let $trx_before= `SHOW ENGINE INNODB STATUS`;
let $trx_before= `select substr('$trx_before',9)+2`;
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
SET GLOBAL innodb_max_purge_lag_wait=0;
set global innodb_fast_shutdown=0;
--source include/restart_mysqld.inc
--replace_regex /.*Trx id counter ([0-9]+).*/\1/
......
/*
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
Copyright (c) 2010, 2021, MariaDB
Copyright (c) 2010, 2022, MariaDB
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
......@@ -406,7 +406,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
DBUG_RETURN(TRUE);
const_cond= (!conds || conds->const_item());
safe_update= MY_TEST(thd->variables.option_bits & OPTION_SAFE_UPDATES);
safe_update= (thd->variables.option_bits & OPTION_SAFE_UPDATES) &&
!thd->lex->describe;
if (safe_update && const_cond)
{
my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,
......@@ -531,7 +532,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
}
/* If running in safe sql mode, don't allow updates without keys */
if (table->opt_range_keys.is_clear_all())
if (!select || !select->quick)
{
thd->set_status_no_index_used();
if (safe_update && !using_limit)
......
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2011, 2021, MariaDB
Copyright (c) 2011, 2022, MariaDB
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
......@@ -370,7 +370,8 @@ int mysql_update(THD *thd,
ha_rows *found_return, ha_rows *updated_return)
{
bool using_limit= limit != HA_POS_ERROR;
bool safe_update= thd->variables.option_bits & OPTION_SAFE_UPDATES;
bool safe_update= (thd->variables.option_bits & OPTION_SAFE_UPDATES)
&& !thd->lex->describe;
bool used_key_is_modified= FALSE, transactional_table;
bool will_batch= FALSE;
bool can_compare_record;
......@@ -597,7 +598,7 @@ int mysql_update(THD *thd,
}
/* If running in safe sql mode, don't allow updates without keys */
if (table->opt_range_keys.is_clear_all())
if (!select || !select->quick)
{
thd->set_status_no_index_used();
if (safe_update && !using_limit)
......
......@@ -1758,8 +1758,13 @@ instant_alter_column_possible(
Field** af = altered_table->field;
Field** const end = altered_table->field
+ altered_table->s->fields;
List_iterator_fast<Create_field> cf_it(
ha_alter_info->alter_info->create_list);
for (unsigned c = 0; af < end; af++) {
if (!(*af)->stored_in_db()) {
const Create_field* cf = cf_it++;
if (!cf->field || !(*af)->stored_in_db()) {
/* Ignore virtual or newly created
column */
continue;
}
......
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