Skip to content

Commit 36c669d

Browse files
authored
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 <[email protected]> * 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 <[email protected]> * minor update to test Signed-off-by: Shlomi Noach <[email protected]> * adding test for user defined AUTO_INCREMENT statement * Generated column as part of UNIQUE (or PRIMARY) KEY Signed-off-by: Shlomi Noach <[email protected]> * skip analysis of generated column data type in unique key Signed-off-by: Shlomi Noach <[email protected]>
1 parent 57a81ce commit 36c669d

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
@@ -190,6 +190,10 @@ func (this *Inspector) inspectOriginalAndGhostTables() (err error) {
190190
}
191191

192192
for _, column := range this.migrationContext.UniqueKey.Columns.Columns() {
193+
if this.migrationContext.GhostTableVirtualColumns.GetColumn(column.Name) != nil {
194+
// this is a virtual column
195+
continue
196+
}
193197
if this.migrationContext.MappedSharedColumns.HasTimezoneConversion(column.Name) {
194198
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)
195199
}
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)