Skip to content

Commit 253658d

Browse files
authored
Merge pull request #13 from openark/unique-key-generated-column
Generated column as part of UNIQUE (or PRIMARY) KEY
2 parents ff82140 + b7b3bfb commit 253658d

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

go/logic/inspect.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ func (this *Inspector) inspectOriginalAndGhostTables() (err error) {
188188
}
189189

190190
for _, column := range this.migrationContext.UniqueKey.Columns.Columns() {
191+
if this.migrationContext.GhostTableVirtualColumns.GetColumn(column.Name) != nil {
192+
// this is a virtual column
193+
continue
194+
}
191195
if this.migrationContext.MappedSharedColumns.HasTimezoneConversion(column.Name) {
192196
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)
193197
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
drop table if exists gh_ost_test;
2+
create table gh_ost_test (
3+
id int auto_increment,
4+
`idb` varchar(36) CHARACTER SET utf8mb4 GENERATED ALWAYS AS (json_unquote(json_extract(`jsonobj`,_utf8mb4'$._id'))) STORED NOT NULL,
5+
`jsonobj` json NOT NULL,
6+
PRIMARY KEY (`id`,`idb`)
7+
) auto_increment=1;
8+
9+
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":2}');
10+
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":3}');
11+
12+
drop event if exists gh_ost_test;
13+
delimiter ;;
14+
create event gh_ost_test
15+
on schedule every 1 second
16+
starts current_timestamp
17+
ends current_timestamp + interval 60 second
18+
on completion not preserve
19+
enable
20+
do
21+
begin
22+
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":5}');
23+
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":7}');
24+
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":11}');
25+
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":13}');
26+
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":17}');
27+
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":19}');
28+
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":23}');
29+
insert into gh_ost_test (id, jsonobj) values (null, '{"_id":27}');
30+
end ;;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(5.5|5.6)

0 commit comments

Comments
 (0)