[MDEV-23533] Key column 'a' doesn't exist in table on ALTER after creating UNIQUE INDEX Created: 2020-08-21  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.5.5, 10.2, 10.3, 10.4
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Minor
Reporter: Roel Van de Paar Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: not-10.1


 Description   

USE test;
CREATE TABLE IF NOT EXISTS t (a INT, b INT);
CREATE UNIQUE INDEX i USING BTREE ON t(b, a);
ALTER TABLE t DROP a;

Leads to:

10.5.6 1c587481966abc7a9ad5309d0a91ca920f7a5657 (Optimized)

10.5.6>USE test;
Database changed
10.5.6>CREATE TABLE IF NOT EXISTS t (a INT, b INT);
Query OK, 0 rows affected (0.011 sec)
10.5.6>CREATE UNIQUE INDEX i USING BTREE ON t(b, a);
Query OK, 0 rows affected (0.008 sec)
Records: 0  Duplicates: 0  Warnings: 0
10.5.6>ALTER TABLE t DROP a;
ERROR 1072 (42000): Key column 'a' doesn't exist in table

Same result for InnoDB, MyISAM, Aria. Same result on debug build.

Same on these versions/revisions:
10.2.34 unknown_build_rev
10.3.25 bafc5c1321a7dff5f2da292111bf98fed9d1658d
10.4.15 eae968f62d285de97ed607c87bc131cd863d5d03

10.1.47 (Optimized)

10.1.47>ALTER TABLE t DROP a;
Query OK, 0 rows affected (0.04 sec)               
Records: 0  Duplicates: 0  Warnings: 0



 Comments   
Comment by Elena Stepanova [ 2020-08-22 ]

It's not related to BTREE, and unfortunately it's not a bug ("unfortunately" because the error message confuses a lot of people).

The behavior is a result of a bug fix, it's documented here (the box "starting from 10.2.8"), and a longer discussion is, for example, in comments to MDEV-13613 .

Comment by Roel Van de Paar [ 2020-08-22 ]

Hmm I see. Perhaps we can make the error message clearer?

Comment by Sergei Petrunia [ 2022-08-09 ]

This is close to Runtime than optimizer. Re-assigning accordingly.

Generated at Thu Feb 08 09:23:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.