#At file:///C:/bzr/mysql-6.0-falcon-team/
2779 Vladislav Vaintroub 2008-08-14
Bug #38770: falcon disregards datadir option and always creates files in current
directory.
This is fixed in this patch. For all file operations that accept name as parameter
(create, open, delete, stat), relative paths are translated to absolute using
mysql_real_data_home as base directory.
Also, falcon_serial_log_dir default value is now mysql_real_data_home.
modified:
mysql-test/suite/falcon/r/falcon_options.result
mysql-test/suite/falcon/r/falcon_options2.result
mysql-test/suite/falcon/t/falcon_options.test
mysql-test/suite/falcon/t/falcon_options2.test
storage/falcon/IO.cpp
storage/falcon/IOx.h
storage/falcon/StorageHandler.cpp
storage/falcon/StorageHandler.h
storage/falcon/ha_falcon.cpp
per-file messages:
mysql-test/suite/falcon/r/falcon_options.result
remove falcon_serial_log_dir from output
(the path is not constant and varies from one machine to another)
mysql-test/suite/falcon/r/falcon_options2.result
remove falcon_serial_log_dir from output
(the path is not constant and varies from one machine to another)
mysql-test/suite/falcon/t/falcon_options.test
remove falcon_serial_log_dir from output
(the path is not constant and varies from one machine to another)
remove real_sleep (seems to be workaround for _something_)
mysql-test/suite/falcon/t/falcon_options2.test
remove falcon_serial_log_dir from output
(the path is not constant and varies from one machine to another)
storage/falcon/IO.cpp
Normalize path (taking base directory into account), when doing open/create/delete
storage/falcon/IOx.h
new function setBaseDirectory
storage/falcon/StorageHandler.cpp
new function setDataDirectory()
storage/falcon/StorageHandler.h
new function setDataDirectory()
storage/falcon/ha_falcon.cpp
Set data directory for falcon tablespaces and log files
=== modified file 'mysql-test/suite/falcon/r/falcon_options.result'
--- a/mysql-test/suite/falcon/r/falcon_options.result 2008-07-17 13:52:17 +0000
+++ b/mysql-test/suite/falcon/r/falcon_options.result 2008-08-14 11:24:18 +0000
@@ -1,4 +1,4 @@
-SHOW VARIABLES LIKE 'falcon_%';
+SHOW VARIABLES where variable_name LIKE 'falcon_%' and variable_name <>'falcon_serial_log_dir';
Variable_name Value
falcon_checkpoint_schedule 7 * * * * *
falcon_checksums ON
@@ -21,7 +21,6 @@ falcon_record_scavenge_threshold 67
falcon_scavenge_schedule 15,45 * * * * *
falcon_serial_log_block_size 0
falcon_serial_log_buffers 20
-falcon_serial_log_dir
falcon_serial_log_file_size 10485760
falcon_serial_log_priority 1
falcon_support_xa OFF
@@ -33,9 +32,6 @@ SELECT @@GLOBAL.falcon_debug_server;
0
SET GLOBAL falcon_debug_server = TRUE;
ERROR HY000: Variable 'falcon_debug_server' is a read only variable
-SELECT @@GLOBAL.falcon_serial_log_dir;
-@@GLOBAL.falcon_serial_log_dir
-NULL
SET GLOBAL falcon_serial_log_dir = '/foo';
ERROR HY000: Variable 'falcon_serial_log_dir' is a read only variable
SELECT @@GLOBAL.falcon_page_cache_size;
@@ -80,7 +76,7 @@ SELECT @@GLOBAL.falcon_record_chill_thre
@@GLOBAL.falcon_record_chill_threshold
1073741824
SELECT * FROM INFORMATION_SCHEMA.global_variables
-WHERE variable_name LIKE 'falcon%';
+WHERE variable_name LIKE 'falcon%' and variable_name <> 'falcon_serial_log_dir';
VARIABLE_NAME VARIABLE_VALUE
FALCON_CHECKPOINT_SCHEDULE 7 * * * * *
FALCON_CHECKSUMS ON
@@ -103,7 +99,6 @@ FALCON_RECORD_SCAVENGE_THRESHOLD 67
FALCON_SCAVENGE_SCHEDULE 15,45 * * * * *
FALCON_SERIAL_LOG_BLOCK_SIZE 0
FALCON_SERIAL_LOG_BUFFERS 20
-FALCON_SERIAL_LOG_DIR
FALCON_SERIAL_LOG_FILE_SIZE 10485760
FALCON_SERIAL_LOG_PRIORITY 1
FALCON_SUPPORT_XA OFF
=== modified file 'mysql-test/suite/falcon/r/falcon_options2.result'
--- a/mysql-test/suite/falcon/r/falcon_options2.result 2008-07-17 13:52:17 +0000
+++ b/mysql-test/suite/falcon/r/falcon_options2.result 2008-08-14 11:24:18 +0000
@@ -1,5 +1,5 @@
SELECT * FROM INFORMATION_SCHEMA.global_variables
-WHERE variable_name LiKE 'falcon_%';
+WHERE variable_name LiKE 'falcon_%' AND variable_name <> 'falcon_serial_log_dir';
VARIABLE_NAME VARIABLE_VALUE
FALCON_CHECKPOINT_SCHEDULE 7 * * * * *
FALCON_CHECKSUMS ON
@@ -22,7 +22,6 @@ FALCON_RECORD_SCAVENGE_THRESHOLD 67
FALCON_SCAVENGE_SCHEDULE 15,45 * * * * *
FALCON_SERIAL_LOG_BLOCK_SIZE 0
FALCON_SERIAL_LOG_BUFFERS 20
-FALCON_SERIAL_LOG_DIR
FALCON_SERIAL_LOG_FILE_SIZE 10485760
FALCON_SERIAL_LOG_PRIORITY 1
FALCON_SUPPORT_XA OFF
@@ -89,9 +88,6 @@ SELECT @@falcon_serial_log_block_size;
SELECT @@falcon_serial_log_buffers;
@@falcon_serial_log_buffers
20
-SELECT @@falcon_serial_log_dir;
-@@falcon_serial_log_dir
-NULL
SELECT @@falcon_serial_log_priority;
@@falcon_serial_log_priority
1
=== modified file 'mysql-test/suite/falcon/t/falcon_options.test'
--- a/mysql-test/suite/falcon/t/falcon_options.test 2008-07-03 11:24:12 +0000
+++ b/mysql-test/suite/falcon/t/falcon_options.test 2008-08-14 11:24:18 +0000
@@ -1,8 +1,6 @@
--source include/have_falcon.inc
-SHOW VARIABLES LIKE 'falcon_%';
-
---real_sleep 1
+SHOW VARIABLES where variable_name LIKE 'falcon_%' and variable_name <>'falcon_serial_log_dir';
# Test that these server variables are READ ONLY.
@@ -10,7 +8,6 @@ SELECT @@GLOBAL.falcon_debug_server;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL falcon_debug_server = TRUE;
-SELECT @@GLOBAL.falcon_serial_log_dir;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL falcon_serial_log_dir = '/foo';
@@ -49,7 +46,7 @@ SELECT @@GLOBAL.falcon_record_chill_thre
# Test INFORMATION_SCHEMA access to variables.
--sorted_result
SELECT * FROM INFORMATION_SCHEMA.global_variables
- WHERE variable_name LIKE 'falcon%';
+ WHERE variable_name LIKE 'falcon%' and variable_name <> 'falcon_serial_log_dir';
# Final cleanup.
SET GLOBAL falcon_debug_mask = @previous_falcon_debug_mask;
=== modified file 'mysql-test/suite/falcon/t/falcon_options2.test'
--- a/mysql-test/suite/falcon/t/falcon_options2.test 2008-07-17 13:52:17 +0000
+++ b/mysql-test/suite/falcon/t/falcon_options2.test 2008-08-14 11:24:18 +0000
@@ -4,7 +4,7 @@
--sorted_result
SELECT * FROM INFORMATION_SCHEMA.global_variables
- WHERE variable_name LiKE 'falcon_%';
+ WHERE variable_name LiKE 'falcon_%' AND variable_name <> 'falcon_serial_log_dir';
SELECT @@falcon_checkpoint_schedule;
SELECT @@falcon_consistent_read;
@@ -26,7 +26,6 @@ SELECT @@falcon_record_scavenge_threshol
SELECT @@falcon_scavenge_schedule;
SELECT @@falcon_serial_log_block_size;
SELECT @@falcon_serial_log_buffers;
-SELECT @@falcon_serial_log_dir;
SELECT @@falcon_serial_log_priority;
SELECT @@falcon_use_deferred_index_hash;
SELECT @@falcon_use_sectorcache;
=== modified file 'storage/falcon/IO.cpp'
--- a/storage/falcon/IO.cpp 2008-07-24 08:45:03 +0000
+++ b/storage/falcon/IO.cpp 2008-08-14 11:24:18 +0000
@@ -113,6 +113,7 @@ static int simulateDiskFull = SIMULATE_D
#endif
static FILE *traceFile;
+static JString baseDir;
#ifdef _DEBUG
#undef THIS_FILE
@@ -142,9 +143,35 @@ IO::~IO()
closeFile();
}
+static bool isAbsolutePath(const char *name)
+{
+#ifdef _WIN32
+ size_t len = strlen(name);
+ if(len < 2)
+ return false;
+ return (name[0]=='\\' || name[1]==':');
+#else
+ return (name[0]=='/');
+#endif
+}
+
+void IO::setBaseDirectory(const char *directory)
+{
+ baseDir = directory;
+ if (baseDir[baseDir.length()-1] != SEPARATOR)
+ baseDir += SEPARATOR;
+}
+
+static JString getPath(const char *filename)
+{
+ if(!baseDir || isAbsolutePath(filename))
+ return JString(filename);
+ return baseDir + filename;
+}
+
bool IO::openFile(const char * name, bool readOnly)
{
- fileName = name;
+ fileName = getPath(name);
for (int attempt = 0; attempt < 3; ++attempt)
{
@@ -189,7 +216,7 @@ bool IO::createFile(const char *name)
{
Log::debug("IO::createFile: creating file \"%s\"\n", name);
- fileName = name;
+ fileName = getPath(name);
for (int attempt = 0; attempt < 3; ++attempt)
{
@@ -380,10 +407,11 @@ void IO::declareFatalError()
void IO::createPath(const char *fileName)
{
// First, better make sure directories exists
+ JString fname = getPath(fileName);
char directory [256], *q = directory;
- for (const char *p = fileName; *p;)
+ for (const char *p = fname.getString(); *p;)
{
char c = *p++;
@@ -393,7 +421,8 @@ void IO::createPath(const char *fileName
if (q > directory && q [-1] != ':')
if (MKDIR (directory) && errno != EEXIST)
- throw SQLError (IO_ERROR, "can't create directory \"%s\"\n", directory);
+ throw SQLError (IO_ERROR,
+ "can't create directory \"%s\"\n", directory);
}
*q++ = c;
}
@@ -408,7 +437,10 @@ const char* IO::baseName(const char *pat
void IO::expandFileName(const char *fileName, int length, char *buffer, const char **baseFileName)
{
char expandedName[PATH_MAX+1];
- const char *path;
+ char *path;
+ JString fname = getPath(fileName);
+ fileName = fname.getString();
+
#ifdef _WIN32
char *base;
@@ -465,7 +497,8 @@ bool IO::doesFileExist(const char *fileN
int IO::fileStat(const char *fileName, struct stat *fileStats, int *errnum)
{
struct stat stats;
- int retCode = stat(fileName, &stats);
+ JString path = getPath(fileName);
+ int retCode = stat(path.getString(), &stats);
if (fileStats)
*fileStats = stats;
@@ -621,7 +654,8 @@ void IO::sync(void)
void IO::deleteFile(const char* fileName)
{
- unlink(fileName);
+ JString path = getPath(fileName);
+ unlink(path.getString());
}
void IO::tracePage(Bdb* bdb)
@@ -753,4 +787,3 @@ uint16 IO::computeChecksum(Page *page, s
return (uint16) sum;
}
-
=== modified file 'storage/falcon/IOx.h'
--- a/storage/falcon/IOx.h 2008-07-18 08:15:54 +0000
+++ b/storage/falcon/IOx.h 2008-08-14 11:24:18 +0000
@@ -64,6 +64,7 @@ public:
void writePages(int32 pageNumber, int length, const UCHAR* data, int type);
void readPage (Bdb *page);
bool createFile (const char *name);
+ static void setBaseDirectory(const char *path);
bool openFile (const char *name, bool readOnly);
void longSeek(int64 offset);
void read(int64 offset, int length, UCHAR* buffer);
=== modified file 'storage/falcon/StorageHandler.cpp'
--- a/storage/falcon/StorageHandler.cpp 2008-08-07 21:11:55 +0000
+++ b/storage/falcon/StorageHandler.cpp 2008-08-14 11:24:18 +0000
@@ -37,6 +37,7 @@
#include "Dbb.h"
#include "Database.h"
#include "TableSpaceManager.h"
+#include "IOx.h"
#define DICTIONARY_ACCOUNT "mysql"
#define DICTIONARY_PW "mysql"
@@ -112,6 +113,10 @@ StorageHandler* getFalconStorageHandler(
return storageHandler;
}
+void StorageHandler::setDataDirectory(const char *directory)
+{
+ IO::setBaseDirectory(directory);
+}
StorageHandler::StorageHandler(int lockSize)
{
=== modified file 'storage/falcon/StorageHandler.h'
--- a/storage/falcon/StorageHandler.h 2008-07-29 10:45:39 +0000
+++ b/storage/falcon/StorageHandler.h 2008-08-14 11:24:18 +0000
@@ -141,6 +141,7 @@ public:
Connection *dictionaryConnection;
int mySqlLockSize;
bool initialized;
+ static void setDataDirectory(const char *directory);
};
#endif
=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp 2008-08-12 14:10:28 +0000
+++ b/storage/falcon/ha_falcon.cpp 2008-08-14 11:24:18 +0000
@@ -162,9 +162,11 @@ int StorageInterface::falcon_init(void *
falcon_hton = (handlerton *)p;
my_bool error = false;
+ StorageHandler::setDataDirectory(mysql_real_data_home);
+
if (!storageHandler)
storageHandler = getFalconStorageHandler(sizeof(THR_LOCK));
-
+
falcon_hton->state = SHOW_OPTION_YES;
falcon_hton->db_type = DB_TYPE_FALCON;
falcon_hton->savepoint_offset = sizeof(void*);
@@ -177,6 +179,8 @@ int StorageInterface::falcon_init(void *
falcon_hton->create = falcon_create_handler;
falcon_hton->drop_database = StorageInterface::dropDatabase;
falcon_hton->panic = StorageInterface::panic;
+
+
#if 0
falcon_hton->alter_table_flags = StorageInterface::alter_table_flags;
#endif
@@ -3525,7 +3529,7 @@ void StorageInterface::unmapFields(void)
static MYSQL_SYSVAR_STR(serial_log_dir, falcon_serial_log_dir,
PLUGIN_VAR_RQCMDARG| PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC,
"Falcon serial log file directory.",
- NULL, NULL, NULL);
+ NULL, NULL, mysql_real_data_home);
static MYSQL_SYSVAR_STR(checkpoint_schedule, falcon_checkpoint_schedule,
PLUGIN_VAR_RQCMDARG| PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC,