Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][mysql][兼容性]:不支持在单个语句中添加列并使其成为外键 #1951

Open
lyukun opened this issue May 7, 2024 · 0 comments

Comments

@lyukun
Copy link

lyukun commented May 7, 2024

【版本信息】
建议贴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);

mysql5/8中正常可执行
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants