Commit 23a5b2eb authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-6103 - Adding/removing non-materialized virtual column triggers

            table recreation

Relaxed InnoDB/XtraDB checks to allow online add/drop of
non-materialized virtual columns.
parent b6b5b748
......@@ -160,3 +160,15 @@ select * from t1;
show create table t1;
drop table t1;
--echo #
--echo # MDEV-6103 - Adding/removing non-materialized virtual column triggers
--echo # table recreation
--echo #
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(1),(1),(1),(1),(1),(1),(1),(1),(1),(1);
enable_info;
ALTER TABLE t1 ADD COLUMN b INT AS (a + 1) VIRTUAL;
ALTER TABLE t1 DROP COLUMN b;
disable_info;
CHECK TABLE t1;
DROP TABLE t1;
......@@ -240,3 +240,19 @@ t1 CREATE TABLE `t1` (
`c` int(11) AS (week(b,1)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
#
# MDEV-6103 - Adding/removing non-materialized virtual column triggers
# table recreation
#
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(1),(1),(1),(1),(1),(1),(1),(1),(1),(1);
ALTER TABLE t1 ADD COLUMN b INT AS (a + 1) VIRTUAL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE t1 DROP COLUMN b;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
......@@ -240,3 +240,19 @@ t1 CREATE TABLE `t1` (
`c` int(11) AS (week(b,1)) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
#
# MDEV-6103 - Adding/removing non-materialized virtual column triggers
# table recreation
#
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(1),(1),(1),(1),(1),(1),(1),(1),(1),(1);
ALTER TABLE t1 ADD COLUMN b INT AS (a + 1) VIRTUAL;
affected rows: 10
info: Records: 10 Duplicates: 0 Warnings: 0
ALTER TABLE t1 DROP COLUMN b;
affected rows: 10
info: Records: 10 Duplicates: 0 Warnings: 0
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
......@@ -351,10 +351,14 @@ ha_innobase::check_if_supported_inplace_alter(
Don't do online ALTER if mtype/unsigned_flag are wrong.
*/
for (ulint i = 0; i < table->s->fields; i++) {
for (ulint i = 0, icol= 0; i < table->s->fields; i++) {
const Field* field = table->field[i];
const dict_col_t* col = dict_table_get_nth_col(prebuilt->table, i);
const dict_col_t* col = dict_table_get_nth_col(prebuilt->table, icol);
ulint unsigned_flag;
if (!field->stored_in_db)
continue;
icol++;
if (col->mtype != get_innobase_type_from_mysql_type(&unsigned_flag, field)) {
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
......
......@@ -351,10 +351,14 @@ ha_innobase::check_if_supported_inplace_alter(
Don't do online ALTER if mtype/unsigned_flag are wrong.
*/
for (ulint i = 0; i < table->s->fields; i++) {
for (ulint i = 0, icol= 0; i < table->s->fields; i++) {
const Field* field = table->field[i];
const dict_col_t* col = dict_table_get_nth_col(prebuilt->table, i);
const dict_col_t* col = dict_table_get_nth_col(prebuilt->table, icol);
ulint unsigned_flag;
if (!field->stored_in_db)
continue;
icol++;
if (col->mtype != get_innobase_type_from_mysql_type(&unsigned_flag, field)) {
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
......
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