[Feature][mysql][兼容性]:不支持在单个语句中添加列并使其成为外键
lyukun opened this issue · comments
【版本信息】
建议贴bin/observer -V的结果,如果这次测试也涉及obproxy的版本变化,也建议贴上obproxy -V的结果
observer (OceanBase_CE 4.2.0.0)
REVISION: 1-0949c8defaa02cb7794e497969d5fcda748935f5
BUILD_BRANCH: master
BUILD_TIME: Jul 10 2023 13:02:23
BUILD_FLAGS: RelWithDebInfo|Sanity
BUILD_INFO:
Copyright (c) 2011-present OceanBase Inc.
【场景描述/复现步骤】
测试sql如下,报错为ErrorCode = 5031, SQLState = HY000, Details = Column not found,
不是not support
CREATE TABLE schema_authorwithevenlongername
(
id
integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
name
varchar(255) NOT NULL,
height
integer UNSIGNED NULL CHECK (height
>= 0)
);
CREATE TABLE schema_bookwithlongname
(
id
integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
author_foreign_key_with_really_long_field_name_id
integer NOT NULL
);
ALTER TABLE
schema_bookwithlongname
ADD
COLUMN author_other_really_long_named_i_mean_so_long_fk_id
integer NOT NULL,
ADD
CONSTRAINT schema_bookwithlongn_author_other_really__6c36f4d2_fk_schema_au
FOREIGN KEY (
author_other_really_long_named_i_mean_so_long_fk_id
) REFERENCES schema_authorwithevenlongername
(id
);
ALTER 语句拆分后执行正常,拆分后为:
ALTER TABLE schema_bookwithlongname
ADD COLUMN author_other_really_long_named_i_mean_so_long_fk_id
integer NOT NULL;
ALTER TABLE schema_bookwithlongname
ADD CONSTRAINT schema_bookwithlongn_author_other_really__6c36f4d2_fk_schema_au
FOREIGN KEY (
author_other_really_long_named_i_mean_so_long_fk_id
) REFERENCES schema_authorwithevenlongername
(id
);