-
Type:
Bug
-
Status: Closed (View Workflow)
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 5.5.41, 5.5.46, 5.5, 10.1, 10.0
-
Component/s: Data Definition - Alter Table
-
Labels:
-
Environment:Tested on Windows 2012, CentOS6.7
When creating a table with a constraint which references a table without explicitly naming the database the statement fails with the following error.
ERROR 1046 (3D000) at line ##@ No database selected.
|
The test statement used is as follows:
CREATE TABLE `kg_test1`.`person` |
(
|
`Id` INT(11) NOT NULL AUTO_INCREMENT, |
`Name` VARCHAR(50) NOT NULL, |
PRIMARY KEY (`Id`), |
CONSTRAINT `fk_person_group` FOREIGN KEY (`Id`) REFERENCES `group` (`Id`) |
) ENGINE=INNODB DEFAULT CHARSET=utf8; |
I'm using a local client to connect and run the test statement on MariaDB 5.5.41 - 46, on both Windows 2012 & CentOS 6.7....which all fail with the same error as above.
You can work around this by either adding a database name to the reference, (kg_test1.group) or adding database context (i.e. use <db-name>) when logging in via the client, but it does not have to be the same database the table is being created in.
This is a change in behaviour to MariaDB verisons prior to 5.5.41.