Generated column as part of UNIQUE (or PRIMARY) KEY (#919)
* v1.1.0 * WIP: copying AUTO_INCREMENT value to ghost table Initial commit: towards setting up a test suite Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> * greping for 'expect_table_structure' content * Adding simple test for 'expect_table_structure' scenario * adding tests for AUTO_INCREMENT value after row deletes. Should initially fail * clear event beforehand * parsing AUTO_INCREMENT from alter query, reading AUTO_INCREMENT from original table, applying AUTO_INCREMENT value onto ghost table if applicable and user has not specified AUTO_INCREMENT in alter statement * support GetUint64 Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> * minor update to test Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> * adding test for user defined AUTO_INCREMENT statement * Generated column as part of UNIQUE (or PRIMARY) KEY Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> * skip analysis of generated column data type in unique key Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
This commit is contained in:
parent
57a81ceff5
commit
36c669dd75
@ -190,6 +190,10 @@ func (this *Inspector) inspectOriginalAndGhostTables() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, column := range this.migrationContext.UniqueKey.Columns.Columns() {
|
for _, column := range this.migrationContext.UniqueKey.Columns.Columns() {
|
||||||
|
if this.migrationContext.GhostTableVirtualColumns.GetColumn(column.Name) != nil {
|
||||||
|
// this is a virtual column
|
||||||
|
continue
|
||||||
|
}
|
||||||
if this.migrationContext.MappedSharedColumns.HasTimezoneConversion(column.Name) {
|
if this.migrationContext.MappedSharedColumns.HasTimezoneConversion(column.Name) {
|
||||||
return fmt.Errorf("No support at this time for converting a column from DATETIME to TIMESTAMP that is also part of the chosen unique key. Column: %s, key: %s", column.Name, this.migrationContext.UniqueKey.Name)
|
return fmt.Errorf("No support at this time for converting a column from DATETIME to TIMESTAMP that is also part of the chosen unique key. Column: %s, key: %s", column.Name, this.migrationContext.UniqueKey.Name)
|
||||||
}
|
}
|
||||||
|
30
localtests/generated-columns57-unique/create.sql
Normal file
30
localtests/generated-columns57-unique/create.sql
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
drop table if exists gh_ost_test;
|
||||||
|
create table gh_ost_test (
|
||||||
|
id int auto_increment,
|
||||||
|
`idb` varchar(36) CHARACTER SET utf8mb4 GENERATED ALWAYS AS (json_unquote(json_extract(`jsonobj`,_utf8mb4'$._id'))) STORED NOT NULL,
|
||||||
|
`jsonobj` json NOT NULL,
|
||||||
|
PRIMARY KEY (`id`,`idb`)
|
||||||
|
) auto_increment=1;
|
||||||
|
|
||||||
|
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":2}');
|
||||||
|
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":3}');
|
||||||
|
|
||||||
|
drop event if exists gh_ost_test;
|
||||||
|
delimiter ;;
|
||||||
|
create event gh_ost_test
|
||||||
|
on schedule every 1 second
|
||||||
|
starts current_timestamp
|
||||||
|
ends current_timestamp + interval 60 second
|
||||||
|
on completion not preserve
|
||||||
|
enable
|
||||||
|
do
|
||||||
|
begin
|
||||||
|
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":5}');
|
||||||
|
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":7}');
|
||||||
|
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":11}');
|
||||||
|
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":13}');
|
||||||
|
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":17}');
|
||||||
|
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":19}');
|
||||||
|
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":23}');
|
||||||
|
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":27}');
|
||||||
|
end ;;
|
1
localtests/generated-columns57-unique/ignore_versions
Normal file
1
localtests/generated-columns57-unique/ignore_versions
Normal file
@ -0,0 +1 @@
|
|||||||
|
(5.5|5.6)
|
Loading…
Reference in New Issue
Block a user