Bug #78891 Can't refer the same column twice in one ALTER TABLE: ER_BAD_FIELD_ERROR
Submitted: 20 Oct 2015 20:29 Modified: 21 Oct 2015 6:37
Reporter: Elena Stepanova Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.5, 5.6, 5.7 OS:Any
Assigned to: CPU Architecture:Any

[20 Oct 2015 20:29] Elena Stepanova
Description:
Filing on behalf of our user, initially reported as https://mariadb.atlassian.net/browse/MDEV-8960.

An attempt to create and then modify a column in one ALTER statement results in the error ER_BAD_FIELD_ERROR:

ALTER TABLE `test` ADD COLUMN `consultant_id` integer NOT NULL,
ALTER COLUMN `consultant_id` DROP DEFAULT;
ERROR 1054 (42S22): Unknown column 'consultant_id' in 'test'

Same is true for DROP COLUMN, MODIFY COLUMN, probably other operations as well.

I realize it must be known, either as a bug or a feature, but I failed to find anything in documentation or in the bug system. I would appreciate if you could point at a place where it is described.

How to repeat:
CREATE TABLE `test` (
  `a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `test` ADD COLUMN `consultant_id` integer NOT NULL,
ALTER COLUMN `consultant_id` DROP DEFAULT;
[21 Oct 2015 6:37] Umesh Shastry
Hello Elena,

Thank you for the report and test case.
Observed this behavior in 5.0.96, 5.1.77, 5.5.47, 5.6.28, 5.7.10.
Also, couldn't locate any closest bug report matching this behavior.

Thanks,
Umesh
[9 Nov 2018 18:09] Arnaud Adant
Also affects 8.0.13 despite the new data dictionary.