MDEV-33814 Wrong error message "Can't create table" on "ALTER TABLE"#4712
MDEV-33814 Wrong error message "Can't create table" on "ALTER TABLE"#4712a18792721831 wants to merge 1 commit intoMariaDB:10.6from
Conversation
952a605 to
6de3de8
Compare
|
few more tests still to re-record/update. |
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
The commit message is somewhat misleading: HA_CREATE_TMP_ALTER is not how you distinguish between ANY ALTER TABLE and CREATE TABLE: It's how you distinguish between ALTER TABLE that creates a table before it does something more with the new table and generic CREATE TABLE.
I'd rephrase a bit. Instead of:
Fix: Check HA_CREATE_TMP_ALTER flag in create_info->options to
distinguish ALTER TABLE from CREATE TABLE
I'd say:
Fix Check HA_CREATE_TMP_ALTER flag in create_info->options to
distinguish between top level CREATE TABLE and CREATE TABLE executed internally by ALTER TABLE.
| @@ -41,12 +41,12 @@ ALTER TABLE t2 MODIFY COLUMN msg VARCHAR(100) CHARACTER SET utf8mb4,ALGORITHM=IN | |||
| ERROR HY000: Cannot change column 'msg': used in a foreign key constraint 'test/fk_t1' | |||
There was a problem hiding this comment.
there's more tests to re-record. Please check the buldbot: it must be clean
6de3de8 to
b3e87bf
Compare
Thank you for the review and the correction on the commit message! I've updated the commit message as you suggested, and also re-recorded all the affected test result files that were failing in the buildbot. The updated commit now includes changes to 22 files in total. Please let me know if there's anything else that needs to be addressed. |
When ALTER TABLE fails (e.g., due to foreign key constraint errors), the error message incorrectly says "Can't create table" instead of "Can't alter table". This is because ha_create_table() is shared by both top level CREATE TABLE and CREATE TABLE executed internally by ALTER TABLE. Fix: Check HA_CREATE_TMP_ALTER flag in create_info->options to distinguish between top level CREATE TABLE and CREATE TABLE executed internally by ALTER TABLE, and use my_printf_error() to report "Can't alter table" with the same error code (1005) for backward compatibility.
b3e87bf to
6217f0d
Compare
| my_error(ER_CANT_CREATE_TABLE, MYF(0), db, table_name, error); | ||
| { | ||
| if (create_info->options & HA_CREATE_TMP_ALTER) | ||
| my_printf_error(ER_CANT_CREATE_TABLE, |
There was a problem hiding this comment.
Just a thought, should we add ER_CANT_ALTER_TABLE HY000 in sql/share/errmsg-utf8.txt with the same error number HY000 as ER_CANT_CREATE_TABLE so translations can be added? Then this becomes a similar looking to the else clause.
When ALTER TABLE fails (e.g., due to foreign key constraint errors),
the error message incorrectly says "Can't create table" instead of
"Can't alter table". This is because ha_create_table() is shared by
both CREATE TABLE and ALTER TABLE (copy method).
Fix: Check HA_CREATE_TMP_ALTER flag in create_info->options to
distinguish ALTER TABLE from CREATE TABLE, and use my_printf_error()
to report "Can't alter table" with the same error code (1005) for
backward compatibility.
All modified test cases pass: