[MDEV-22603] ALTER TABLE gives false reason for refusing to instantly drop primary key Created: 2020-05-17 Updated: 2023-04-26 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table, Storage Engine - InnoDB |
| Affects Version/s: | 10.4, 10.5 |
| Fix Version/s: | 10.4, 10.5 |
| Type: | Bug | Priority: | Trivial |
| Reporter: | Elena Stepanova | Assignee: | Thirunarayanan Balathandayuthapani |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Apparently in the first case it means to say that the primary key has to be on the same column, but it doesn't say that. |
| Comments |
| Comment by Thirunarayanan Balathandayuthapani [ 2020-05-17 ] |
|
Inplace operation supports only when DROP PRIMARY KEY is only allowed in combination with ADD PRIMARY KEY. I think it is not a bug. |
| Comment by Elena Stepanova [ 2020-05-17 ] |
|
My only complaint is about the error message . Sorry, I've realized it might be unclear, I said it in the bug summary but not in the description. |
| Comment by Marko Mäkelä [ 2020-05-18 ] |
|
elenst, in The native ALTER TABLE algorithm in InnoDB does support redefining or adding a primary key (even while the table is concurrently being modified), but it does not support dropping a primary key without a replacement. What would you like the error message to say? |
| Comment by Elena Stepanova [ 2020-05-18 ] |
|
Repeating what was explained on Slack, my confusion and the reason why I made this note was that the first error message attempts to be specific, but incorrectly so. It says "Reason: Dropping a primary key is not allowed without also adding a new primary key". It can mean only one thing, that if the operation also adds a new primary key, it is supported. So, I add the new primary key in the second ALTER, but then it claims it isn't supported anyway. I don't insist on fixing it though. It was just a side note from something else that I was checking at the time. |
| Comment by Marko Mäkelä [ 2020-05-18 ] |
|
I am afraid that this cannot be fixed without changing the handler API. ha_innobase::check_if_supported_inplace_alter() does not know what ALGORITHM or LOCK has been requested, and hence it cannot specify a less specific error message. Also, redundant ADD and DROP pairs (of indexes or columns, possibly also constraints) are being optimized away on the SQL layer before the function in the storage engine is called. |
| Comment by Jivan Pal [ 2023-04-26 ] |
|
I have also just run into this misleading error message on MariaDB 10.4, understanding it to mean that adding a new primary key would permit the use of ALGORITHM=INSTANT. Given that the handler API cannot be changed, is it possible to change the entire error message ...
... to something else? If so, I'd suggest this:
|