MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:August 13 2008 7:41pm
Subject:bzr commit into mysql-6.0-falcon branch (vvaintroub:2778) Bug#38770
View as plain text  
#At file:///C:/bzr/mysql-6.0-falcon-team/

 2778 Vladislav Vaintroub	2008-08-13
      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:
  storage/falcon/IO.cpp
  storage/falcon/IOx.h
  storage/falcon/StorageHandler.cpp
  storage/falcon/StorageHandler.h
  storage/falcon/ha_falcon.cpp

per-file messages:
  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 setDataDir
  storage/falcon/StorageHandler.h
    new function setDataDir()
  storage/falcon/ha_falcon.cpp
    Set data directory for falcon tablespaces and log files
=== 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-13 19:40:46 +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-13 19:40:46 +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-13 19:40:46 +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-13 19:40:46 +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-13 19:40:46 +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,

Thread
bzr commit into mysql-6.0-falcon branch (vvaintroub:2778) Bug#38770Vladislav Vaintroub13 Aug
  • Re: bzr commit into mysql-6.0-falcon branch (vvaintroub:2778) Bug#38770Lars-Erik Bjørk14 Aug