Commit 7849a27c authored by Dyre Tjeldvoll's avatar Dyre Tjeldvoll

Bug#25514146: DB_NAME IS IGNORED WHEN CREATING TABLE WITH DATA DIRECTORY

Problem: CREATE TABLE using a fully qualified name with INDEX DIR/DATA DIR
option reports an error when the current database is not SET.

check_access() was incorrectly called with NULL as the database
argument in a situation where the database name was not needed for
the particular privilege being checked. This will cause the current
database to be used, or an error to be reported if there is no current
database.

Fix: Call check_access() with any_db as the database argument in this situation.
parent b21a0212
...@@ -213,3 +213,14 @@ t2 CREATE TABLE `t2` ( ...@@ -213,3 +213,14 @@ t2 CREATE TABLE `t2` (
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop tables t1, t2; drop tables t1, t2;
#
# Test for bug #25514146 DB_NAME IS IGNORED WHEN CREATING TABLE
# WITH DATA DIRECTORY
#
# Make sure we have no current database
CREATE DATABASE x;
USE x;
DROP DATABASE x;
CREATE TABLE test.t1(id INT(11)) ENGINE MYISAM
DATA DIRECTORY "MYSQLTEST_VARDIR/tmp";
DROP TABLE test.t1;
...@@ -298,3 +298,19 @@ show create table t1; ...@@ -298,3 +298,19 @@ show create table t1;
create table t2 like t1; create table t2 like t1;
show create table t2; show create table t2;
drop tables t1, t2; drop tables t1, t2;
--echo #
--echo # Test for bug #25514146 DB_NAME IS IGNORED WHEN CREATING TABLE
--echo # WITH DATA DIRECTORY
--echo #
--echo # Make sure we have no current database
CREATE DATABASE x;
USE x;
DROP DATABASE x;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE test.t1(id INT(11)) ENGINE MYISAM
DATA DIRECTORY "$MYSQLTEST_VARDIR/tmp";
DROP TABLE test.t1;
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -2425,7 +2425,7 @@ case SQLCOM_PREPARE: ...@@ -2425,7 +2425,7 @@ case SQLCOM_PREPARE:
if (((lex->create_info.used_fields & HA_CREATE_USED_DATADIR) != 0 || if (((lex->create_info.used_fields & HA_CREATE_USED_DATADIR) != 0 ||
(lex->create_info.used_fields & HA_CREATE_USED_INDEXDIR) != 0) && (lex->create_info.used_fields & HA_CREATE_USED_INDEXDIR) != 0) &&
check_access(thd, FILE_ACL, NULL, NULL, NULL, FALSE, FALSE)) check_access(thd, FILE_ACL, any_db, NULL, NULL, FALSE, FALSE))
{ {
res= 1; res= 1;
my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "FILE"); my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "FILE");
...@@ -2470,7 +2470,7 @@ case SQLCOM_PREPARE: ...@@ -2470,7 +2470,7 @@ case SQLCOM_PREPARE:
{ {
partition_info *part_info= thd->lex->part_info; partition_info *part_info= thd->lex->part_info;
if (part_info != NULL && has_external_data_or_index_dir(*part_info) && if (part_info != NULL && has_external_data_or_index_dir(*part_info) &&
check_access(thd, FILE_ACL, NULL, NULL, NULL, FALSE, FALSE)) check_access(thd, FILE_ACL, any_db, NULL, NULL, FALSE, FALSE))
{ {
res= -1; res= -1;
goto end_with_restore_list; goto end_with_restore_list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment