From 2c723aa91f073c88859da703745dad4bcd91f67c Mon Sep 17 00:00:00 2001 From: "tomas@whalegate.ndb.mysql.com" <> Date: Mon, 16 Apr 2007 11:43:14 +0200 Subject: [PATCH] Bug #27712 Single user mode. Creating logfile group and tablespace is allowed --- mysql-test/r/ndb_single_user.result | 30 +++++++++++++++ mysql-test/t/ndb_single_user.test | 30 +++++++++++++++ .../kernel/signaldata/CreateFilegroup.hpp | 6 ++- .../kernel/signaldata/DropFilegroup.hpp | 6 ++- .../ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 38 ++++++++++++++++++- 5 files changed, 104 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/ndb_single_user.result b/mysql-test/r/ndb_single_user.result index 732acc6f000..81eca46b413 100644 --- a/mysql-test/r/ndb_single_user.result +++ b/mysql-test/r/ndb_single_user.result @@ -2,7 +2,37 @@ use test; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; create table t1 (a int key, b int unique, c int) engine ndb; ERROR HY000: Can't create table 'test.t1' (errno: 299) +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +ERROR HY000: Failed to create LOGFILE GROUP +show warnings; +Level Code Message +Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB +Error 1516 Failed to create LOGFILE GROUP create table t1 (a int key, b int unique, c int) engine ndb; +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; +ERROR HY000: Failed to create TABLESPACE +show warnings; +Level Code Message +Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB +Error 1516 Failed to create TABLESPACE +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0); create table t2 as select * from t1; select * from t1 where a = 1; diff --git a/mysql-test/t/ndb_single_user.test b/mysql-test/t/ndb_single_user.test index f2f47becb0c..bff1b843a08 100644 --- a/mysql-test/t/ndb_single_user.test +++ b/mysql-test/t/ndb_single_user.test @@ -20,13 +20,43 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; --exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" --single-user >> $NDB_TOOLS_OUTPUT # verify that we are indeed in single user mode +# and test that some operations give correct errors --connection server2 --error 1005 create table t1 (a int key, b int unique, c int) engine ndb; +# Bug #27712 Single user mode. Creating logfile group and tablespace is allowed +# - before bug fix these would succeed +--error 1516 +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +show warnings; # test some sql on first mysqld --connection server1 create table t1 (a int key, b int unique, c int) engine ndb; +# Check that we can create logfile group +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +--connection server2 +--error 1516 +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; +show warnings; +--connection server1 +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0); create table t2 as select * from t1; # read with pk diff --git a/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp b/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp index b1261431a4e..fa92af1de8c 100644 --- a/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp @@ -66,7 +66,8 @@ struct CreateFilegroupRef { InvalidExtentSize = 764, InvalidUndoBufferSize = 779, NoSuchLogfileGroup = 767, - InvalidFilegroupVersion = 768 + InvalidFilegroupVersion = 768, + SingleUser = 299 }; Uint32 senderData; @@ -159,7 +160,8 @@ struct CreateFileRef { FilenameAlreadyExists = 760, OutOfFileRecords = 751, InvalidFileType = 750, - NotSupportedWhenDiskless = 775 + NotSupportedWhenDiskless = 775, + SingleUser = 299 }; Uint32 senderData; diff --git a/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp b/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp index 0125e523653..a243380246e 100644 --- a/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp +++ b/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp @@ -66,7 +66,8 @@ struct DropFilegroupRef { NotMaster = 702, NoSuchFilegroup = 767, FilegroupInUse = 768, - InvalidSchemaObjectVersion = 774 + InvalidSchemaObjectVersion = 774, + SingleUser = 299 }; Uint32 senderData; @@ -152,7 +153,8 @@ struct DropFileRef { NotMaster = 702, NoSuchFile = 766, DropUndoFileNotSupported = 769, - InvalidSchemaObjectVersion = 774 + InvalidSchemaObjectVersion = 774, + SingleUser = 299 }; Uint32 senderData; diff --git a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index 46c7c71d886..1e3063371a5 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -14084,6 +14084,15 @@ Dbdict::execCREATE_FILE_REQ(Signal* signal){ break; } + if (checkSingleUserMode(senderRef)) + { + ref->errorCode = CreateFileRef::SingleUser; + ref->status = 0; + ref->errorKey = 0; + ref->errorLine = __LINE__; + break; + } + Ptr trans_ptr; if (! c_Trans.seize(trans_ptr)){ ref->errorCode = CreateFileRef::Busy; @@ -14189,6 +14198,15 @@ Dbdict::execCREATE_FILEGROUP_REQ(Signal* signal){ break; } + if (checkSingleUserMode(senderRef)) + { + ref->errorCode = CreateFilegroupRef::SingleUser; + ref->status = 0; + ref->errorKey = 0; + ref->errorLine = __LINE__; + break; + } + Ptr trans_ptr; if (! c_Trans.seize(trans_ptr)){ ref->errorCode = CreateFilegroupRef::Busy; @@ -14291,6 +14309,14 @@ Dbdict::execDROP_FILE_REQ(Signal* signal) break; } + if (checkSingleUserMode(senderRef)) + { + ref->errorCode = DropFileRef::SingleUser; + ref->errorKey = 0; + ref->errorLine = __LINE__; + break; + } + Ptr file_ptr; if (!c_file_hash.find(file_ptr, objId)) { @@ -14309,7 +14335,7 @@ Dbdict::execDROP_FILE_REQ(Signal* signal) Ptr trans_ptr; if (! c_Trans.seize(trans_ptr)) { - ref->errorCode = CreateFileRef::Busy; + ref->errorCode = DropFileRef::Busy; ref->errorLine = __LINE__; break; } @@ -14392,6 +14418,14 @@ Dbdict::execDROP_FILEGROUP_REQ(Signal* signal) break; } + if (checkSingleUserMode(senderRef)) + { + ref->errorCode = DropFilegroupRef::SingleUser; + ref->errorKey = 0; + ref->errorLine = __LINE__; + break; + } + Ptr filegroup_ptr; if (!c_filegroup_hash.find(filegroup_ptr, objId)) { @@ -14410,7 +14444,7 @@ Dbdict::execDROP_FILEGROUP_REQ(Signal* signal) Ptr trans_ptr; if (! c_Trans.seize(trans_ptr)) { - ref->errorCode = CreateFilegroupRef::Busy; + ref->errorCode = DropFilegroupRef::Busy; ref->errorLine = __LINE__; break; }