[MDEV-28831] Improve and unify error messages on ALTER TABLE ... RENAME to unknown db Created: 2022-06-14  Updated: 2022-10-14  Resolved: 2022-10-14

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Partitioning, Storage Engine - Aria, Storage Engine - InnoDB, Storage Engine - MyISAM, Storage Engine - RocksDB
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Oleksandr Byelkin
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-19849 InnoDB should and can be more specifi... Confirmed

 Description   

CREATE TABLE t (c INT) ENGINE=InnoDB;
ALTER TABLE t RENAME a.t;

On MySQL 8.0 will give:

8.0.29-opt>ALTER TABLE t RENAME a.t;
ERROR 1049 (42000): Unknown database 'a'

This will be the same output, no matter what the engine or options (like partitioning) are.

On MariaDB 10.10 we see a variety of outputs:

CREATE TABLE t (c INT) ENGINE=InnoDB;
ALTER TABLE t RENAME a.t;

Leads to:

10.10.0 081a284712bb661349e2e3802077b12211cede3e (Optimized)

10.10.0-opt>ALTER TABLE t RENAME a.t;
ERROR 1025 (HY000): Error on rename of './test/t' to './a/t' (errno: 168 "Unknown (generic) error from engine")

And for MyISAM/Aria:

CREATE TABLE t (c INT) ENGINE=MyISAM;
ALTER TABLE t RENAME a.t;

Leads to:

10.10.0 081a284712bb661349e2e3802077b12211cede3e (Optimized)

10.10.0-opt>ALTER TABLE t RENAME a.t;
ERROR 7 (HY000): Error on rename of './test/t.MYI' to './a/t.MYI' (Errcode: 20 "Not a directory")

And

CREATE TABLE t (c INT) ENGINE=InnoDB;
ALTER TABLE t PARTITION BY LIST (c) (PARTITION p VALUES IN (1,2));
ALTER TABLE t RENAME a.t;

Leads to a similar message as the InnoDB testcase above, but we also see in the error log:

10.10.0 081a284712bb661349e2e3802077b12211cede3e (Optimized)

2022-06-14 13:57:04 4 [ERROR] InnoDB: Cannot rename file './test/t#P#p.ibd' to './a/t#P#p.ibd'

And for MEMORY and Spider (which both seem to correctly report the right error);

# INSTALL PLUGIN spider SONAME 'ha_spider.so';  # For Spider 
CREATE TABLE t (c INT) ENGINE=MEMORY;  # or ENGINE=Spider for Spider
ALTER TABLE t RENAME a.t;

We see:

10.10.0 081a284712bb661349e2e3802077b12211cede3e (Optimized)

10.10.0-opt>ALTER TABLE t RENAME a.t;
ERROR 1049 (42000): Unknown database 'a'

For RocksDB:

INSTALL SONAME 'ha_rocksdb.so';
CREATE TABLE t (c INT) ENGINE=rocksdb;
ALTER TABLE t RENAME a.t;

Leads to:

10.10.0 081a284712bb661349e2e3802077b12211cede3e (Optimized)

10.10.0-opt>ALTER TABLE t RENAME a.t;
ERROR 1025 (HY000): Error on rename of './test/t' to './a/t' (errno: -1 "Internal error < 0 (Not system error)")

Bug fix: change all various engine messages to a uniform:

ERROR 1049 (42000): Unknown database 'a'



 Comments   
Comment by Marko Mäkelä [ 2022-06-14 ]

I think that this needs to be handled in the SQL layer, possibly with some adjustments in some storage engines. As far as I remember, ALTER TABLE…RENAME will always invoke handler::rename_table().

It might be worth mentioning that DELETE TABLE or RENAME TABLE will not invoke handler::open() before the operation, while any ALTER TABLE always will.

Comment by Roel Van de Paar [ 2022-10-14 ]

Marked as duplicate of MDEV-19849

Generated at Thu Feb 08 10:03:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.