Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-8960

Can't refer the same column twice in one ALTER TABLE

    XMLWordPrintable

    Details

      Description

      I have a simple table with the following structure:

      CREATE TABLE `test` (
        `a` int(11) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8

      When I'm trying to run following statement:

      ALTER TABLE `test` ADD COLUMN `consultant_id` integer NOT NULL,
      ALTER COLUMN `consultant_id` DROP DEFAULT;

      I've got an error:

      ERROR 1054 (42S22): Unknown column 'consultant_id' in 'test'

      However when I'm splitting these changes into two separate ALTER TABLE, it works:

      MariaDB> ALTER TABLE `test` ADD COLUMN `consultant_id` integer NOT NULL;
      Query OK, 0 rows affected (0.01 sec)
      Records: 0  Duplicates: 0  Warnings: 0
      MariaDB> ALTER TABLE `test` ALTER COLUMN `consultant_id` DROP DEFAULT;
      Query OK, 0 rows affected (0.00 sec)
      Records: 0  Duplicates: 0  Warnings: 0

        Attachments

          Activity

            People

            Assignee:
            jplindst Jan Lindström
            Reporter:
            dmalinovsky Denis Malinovskiy
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: