summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2017-12-15 20:37:36 +0300
committerGitHub <noreply@github.com>2017-12-15 20:37:36 +0300
commit9b55cc73f12bce36a77600a3f1883ad8991cdc24 (patch)
treed717e0b6ad719bb3ced3c52de4d7113f8ee69576
parent4624e565f314ed19eefa8532ccd26796b6791bf8 (diff)
downloadmariadb-git-9b55cc73f12bce36a77600a3f1883ad8991cdc24.tar.gz
SQL, IB: unversioned fields with ALTER TABLE [fixes #401]
-rw-r--r--mysql-test/suite/versioning/r/alter.result5
-rw-r--r--mysql-test/suite/versioning/t/alter.test6
-rw-r--r--sql/handler.h2
-rw-r--r--sql/sql_alter.h3
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/sql_yacc.yy2
-rw-r--r--storage/innobase/handler/handler0alter.cc1
7 files changed, 20 insertions, 1 deletions
diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result
index eba447040d2..5566966793a 100644
--- a/mysql-test/suite/versioning/r/alter.result
+++ b/mysql-test/suite/versioning/r/alter.result
@@ -512,5 +512,10 @@ alter table t add system versioning;
ERROR HY000: Table `t` is already system-versioned table
alter table t add system versioning, drop system versioning;
ERROR HY000: Table `t` is already system-versioned table
+set @@versioning_alter_history=keep;
+create or replace table t(x int, y int) with system versioning engine=innodb;
+alter table t modify y int without system versioning;
+insert into t values(1, 1);
+update t set y=2;
drop database test;
create database test;
diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test
index a75fc926a1d..b5154c2d86c 100644
--- a/mysql-test/suite/versioning/t/alter.test
+++ b/mysql-test/suite/versioning/t/alter.test
@@ -349,5 +349,11 @@ alter table t add system versioning;
--error ER_VERS_ALREADY_VERSIONED
alter table t add system versioning, drop system versioning;
+set @@versioning_alter_history=keep;
+create or replace table t(x int, y int) with system versioning engine=innodb;
+alter table t modify y int without system versioning;
+insert into t values(1, 1);
+update t set y=2;
+
drop database test;
create database test;
diff --git a/sql/handler.h b/sql/handler.h
index 44e18e17a1e..c29a10c393f 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -2168,6 +2168,8 @@ public:
static const HA_ALTER_FLAGS ALTER_DROP_HISTORICAL = 1ULL << 41;
+ static const HA_ALTER_FLAGS ALTER_COLUMN_UNVERSIONED = 1ULL << 42;
+
/**
Create options (like MAX_ROWS) for the new version of table.
diff --git a/sql/sql_alter.h b/sql/sql_alter.h
index 75435c7f275..5dc41ebf413 100644
--- a/sql/sql_alter.h
+++ b/sql/sql_alter.h
@@ -95,7 +95,8 @@ public:
// Set for ADD [COLUMN] FIRST | AFTER
ALTER_COLUMN_ORDER = 1L << 25,
ALTER_ADD_CHECK_CONSTRAINT = 1L << 27,
- ALTER_DROP_CHECK_CONSTRAINT = 1L << 28
+ ALTER_DROP_CHECK_CONSTRAINT = 1L << 28,
+ ALTER_COLUMN_UNVERSIONED = 1L << 29,
};
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 7333a6f1196..a6686eec2a4 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -6562,6 +6562,8 @@ static bool fill_alter_inplace_info(THD *thd,
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_DROP_CHECK_CONSTRAINT;
if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_DROP)
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_DROP_HISTORICAL;
+ if (alter_info->flags & Alter_info::ALTER_COLUMN_UNVERSIONED)
+ ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_UNVERSIONED;
/*
If we altering table with old VARCHAR fields we will be automatically
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 2c3150b1a38..1b9b72a5898 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -7112,11 +7112,13 @@ serial_attribute:
with_or_without_system:
WITH_SYSTEM_SYM
{
+ Lex->alter_info.flags|= Alter_info::ALTER_COLUMN_UNVERSIONED;
Lex->create_info.vers_info.versioned_fields= true;
$$= Column_definition::WITH_VERSIONING;
}
| WITHOUT SYSTEM
{
+ Lex->alter_info.flags|= Alter_info::ALTER_COLUMN_UNVERSIONED;
Lex->create_info.vers_info.unversioned_fields= true;
$$= Column_definition::WITHOUT_VERSIONING;
}
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index c2a471b556d..0b322663141 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -87,6 +87,7 @@ static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_ALTER_REBUILD
/*
| Alter_inplace_info::ALTER_STORED_COLUMN_TYPE
*/
+ | Alter_inplace_info::ALTER_COLUMN_UNVERSIONED
;
/** Operations that require changes to data */