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.