Skip to content

Commit

Permalink
SQL, IB: unversioned fields with ALTER TABLE [fixes #401]
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgs committed Dec 15, 2017
1 parent 4624e56 commit 9b55cc7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions mysql-test/suite/versioning/r/alter.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 6 additions & 0 deletions mysql-test/suite/versioning/t/alter.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 2 additions & 0 deletions sql/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,8 @@ class Alter_inplace_info

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.
Expand Down
3 changes: 2 additions & 1 deletion sql/sql_alter.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class Alter_info
// 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 };
Expand Down
2 changes: 2 additions & 0 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 9b55cc7

Please sign in to comment.