Skip to content

Commit

Permalink
Merge branch '10.6' into 10.9
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Aug 7, 2023
2 parents 998edc3 + 4bc9d50 commit 2146541
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mysql-test/suite/vcol/r/innodb_virtual_fk.result
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,24 @@ drop table if exists t2, t1;
Warnings:
Note 1051 Unknown table 'test.t2'
#
# MDEV-31853 Assertion failure in Column_definition::check_vcol_for_key upon adding FK
#
create table t (a int, b int, c int generated always as (a), key(b), key(c));
alter table t add foreign key (a) references t (b) on update set null, algorithm=nocopy;
ERROR 0A000: ALGORITHM=NOCOPY is not supported. Reason: Adding foreign keys needs foreign_key_checks=OFF. Try ALGORITHM=COPY
alter table t add foreign key (a) references t (b);
show create table t;
Table Create Table
t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL,
KEY `b` (`b`),
KEY `c` (`c`),
KEY `a` (`a`),
CONSTRAINT `t_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t;
#
# End of 10.5 tests
#
9 changes: 9 additions & 0 deletions mysql-test/suite/vcol/r/vcol_sql_mode_upgrade.result
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ t1 CREATE TABLE `t1` (
`a` char(5) DEFAULT NULL,
`v` varchar(5) GENERATED ALWAYS AS (`a`) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SELECT * FROM t1;
a v
1 1
Expand All @@ -86,6 +89,9 @@ a v
1 1
2 2
3 3
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
#
# Fixing a Maria-10.2.26 table with a stored VARCHAR column
Expand Down Expand Up @@ -201,6 +207,9 @@ a v
1 1
2 2
3 3
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
#
# Fixing a Maria-10.2.26 table with a virtual VARCHAR column
Expand Down
10 changes: 10 additions & 0 deletions mysql-test/suite/vcol/t/innodb_virtual_fk.test
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreig

drop table if exists t2, t1;

--echo #
--echo # MDEV-31853 Assertion failure in Column_definition::check_vcol_for_key upon adding FK
--echo #
create table t (a int, b int, c int generated always as (a), key(b), key(c));
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t add foreign key (a) references t (b) on update set null, algorithm=nocopy;
alter table t add foreign key (a) references t (b);
show create table t;
drop table t;

--echo #
--echo # End of 10.5 tests
--echo #
7 changes: 7 additions & 0 deletions sql/sql_alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ Alter_info::algorithm(const THD *thd) const

uint Alter_info::check_vcol_field(Item_field *item) const
{
/*
vcol->flags are modified in-place, so we'll need to reset them
if ALTER fails for any reason
*/
if (item->field && !item->field->table->needs_reopen())
item->field->table->mark_table_for_reopen();

if (!item->field &&
((item->db_name.length && !db.streq(item->db_name)) ||
(item->table_name.length && !table_name.streq(item->table_name))))
Expand Down
11 changes: 11 additions & 0 deletions storage/mroonga/ha_mroonga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4963,6 +4963,17 @@ int ha_mroonga::wrapper_close()
MRN_DBUG_ENTER_METHOD();
MRN_SET_WRAP_SHARE_KEY(share, table->s);
MRN_SET_WRAP_TABLE_KEY(this, table);
#ifdef MRN_HANDLER_HAVE_CHECK_IF_SUPPORTED_INPLACE_ALTER
if (alter_key_info_buffer) {
my_free(alter_key_info_buffer);
alter_key_info_buffer = NULL;
}
#else
if (wrap_alter_key_info) {
my_free(wrap_alter_key_info);
wrap_alter_key_info = NULL;
}
#endif
#ifdef MRN_HANDLER_HAVE_HA_CLOSE
error = wrap_handler->ha_close();
#else
Expand Down

0 comments on commit 2146541

Please sign in to comment.