From faededefcd70b93bb3b28cc83187e81055967a09 Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 6 Jul 2021 08:56:06 +0300 Subject: [PATCH] GENERATED colunm as part of PK: handling UPDATE scenario Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> --- go/mysql/utils.go | 2 +- localtests/generated-columns57-unique/create.sql | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go/mysql/utils.go b/go/mysql/utils.go index e429dc3..277a4da 100644 --- a/go/mysql/utils.go +++ b/go/mysql/utils.go @@ -188,7 +188,7 @@ func GetTableColumns(db *gosql.DB, databaseName, tableName string) (*sql.ColumnL err := sqlutils.QueryRowsMap(db, query, func(rowMap sqlutils.RowMap) error { columnName := rowMap.GetString("Field") columnNames = append(columnNames, columnName) - if strings.Contains(rowMap.GetString("Extra"), " GENERATED") { + if strings.Contains(rowMap.GetString("Extra"), "GENERATED") || strings.Contains(rowMap.GetString("Extra"), "VIRTUAL") { log.Debugf("%s is a generated column", columnName) virtualColumnNames = append(virtualColumnNames, columnName) } diff --git a/localtests/generated-columns57-unique/create.sql b/localtests/generated-columns57-unique/create.sql index 7a63dd9..c62747d 100644 --- a/localtests/generated-columns57-unique/create.sql +++ b/localtests/generated-columns57-unique/create.sql @@ -27,4 +27,6 @@ begin 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}'); + + update gh_ost_test set jsonobj=JSON_OBJECT('_id', 27, 'name', 'carrot') where id>0 and idb=27; end ;;