If the condition you mention, that Falcon can always rely on datadir to
exist, is correct, then this looks OK to push.
Btw, is there any practical difference between #ifndef STORAGE_ENGINE
and #ifndef FALCONDB in this case?
/Lars-Erik
On Mon, 2008-08-18 at 22:17 +0200, Vladislav Vaintroub wrote:
> #At file:///C:/bzr/mysql-6.0-falcon-team/
>
> 2788 Vladislav Vaintroub 2008-08-18
> Bug#38843 Falcon does not start if datadir is located on home directory on
> Solaris
>
> Problem
> Falcon tries to create all directories recursively before creating a file
> While trying to create a directory structure, IO::createPath runs onto Solaris
> bug.
> mkdir returns ENOSYS instead of EEXIST on an existing path, if if it happens to
> be NFS
> automounted root dir.
>
> Fix:
> 1) IO::createPath - Workaround the bug by handling ENOSYS like EEXIST.
> We do not expect any other OS to return ENOSYS(not supported) for mkdir().
>
>
> 2) As Falcon can always rely on datadir to exist, enclose all current
> occurences of IO::createPath() into #ifndef FALCONDB. It is possibly
> needed for Netfrastructure, so the change is safe.
> modified:
> storage/falcon/BackLog.cpp
> storage/falcon/IO.cpp
> storage/falcon/RepositoryVolume.cpp
> storage/falcon/StorageDatabase.cpp
> storage/falcon/TableSpace.cpp
>
> per-file messages:
> storage/falcon/BackLog.cpp
> Falcon should not create any directoies
> storage/falcon/IO.cpp
> Workaround a Solaris bug : ENOSYS is not what we think is of it.
> In case of mkdir() ENOSYS means "EEXIST on automounted NFS root directory".
> storage/falcon/RepositoryVolume.cpp
> Falcon should not create any directories
> storage/falcon/StorageDatabase.cpp
> Falcon should not create any directories
> storage/falcon/TableSpace.cpp
> Falcon should not create any directories.
> === modified file 'storage/falcon/BackLog.cpp'
> --- a/storage/falcon/BackLog.cpp 2008-07-17 13:52:17 +0000
> +++ b/storage/falcon/BackLog.cpp 2008-08-18 20:17:15 +0000
> @@ -37,7 +37,9 @@ BackLog::BackLog(Database *db, const cha
> {
> database = db;
> dbb = new Dbb(database->dbb, 0);
> +#ifndef FALCONDB
> dbb->createPath(fileName);
> +#endif
> dbb->create(fileName, dbb->pageSize, 0, HdrTableSpace, 0, NULL);
> dbb->noLog = true;
> dbb->tableSpaceId = -1;
>
> === modified file 'storage/falcon/IO.cpp'
> --- a/storage/falcon/IO.cpp 2008-08-14 16:34:43 +0000
> +++ b/storage/falcon/IO.cpp 2008-08-18 20:17:15 +0000
> @@ -411,13 +411,17 @@ void IO::declareFatalError()
> fatalError = true;
> }
>
> +
> +#ifndef ENOSYS
> +#define ENOSYS EEXIST
> +#endif
> +
> +// Make sure parent directories for file exist
> 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 = fname.getString(); *p;)
> {
> char c = *p++;
> @@ -427,9 +431,14 @@ void IO::createPath(const char *fileName
> *q = 0;
>
> if (q > directory && q [-1] != ':')
> - if (MKDIR (directory) && errno != EEXIST)
> + {
> + if (MKDIR (directory) && errno != EEXIST && errno != ENOSYS)
> + // ENOSYS is a Solaris speficic workaround, mkdir returns it
> + // on existing automounted NFS directories, instead
> + // of EEXIST.
> throw SQLError (IO_ERROR,
> "can't create directory \"%s\"\n", directory);
> + }
> }
> *q++ = c;
> }
>
> === modified file 'storage/falcon/RepositoryVolume.cpp'
> --- a/storage/falcon/RepositoryVolume.cpp 2008-07-24 08:45:03 +0000
> +++ b/storage/falcon/RepositoryVolume.cpp 2008-08-18 20:17:15 +0000
> @@ -232,7 +232,9 @@ void RepositoryVolume::makeWritable()
>
> void RepositoryVolume::create()
> {
> +#ifndef FALCONDB
> IO::createPath (fileName);
> +#endif
> dbb->create(fileName, dbb->pageSize, 0, HdrRepositoryFile, 0, NULL);
> Sync syncDDL(&database->syncSysDDL, "RepositoryVolume::create");
> Transaction *transaction = database->getSystemTransaction();
>
> === modified file 'storage/falcon/StorageDatabase.cpp'
> --- a/storage/falcon/StorageDatabase.cpp 2008-08-18 05:45:29 +0000
> +++ b/storage/falcon/StorageDatabase.cpp 2008-08-18 20:17:15 +0000
> @@ -156,7 +156,9 @@ Connection* StorageDatabase::createDatab
> try
> {
> masterConnection = getConnection();
> +#ifndef FALCONDB
> IO::createPath(filename);
> +#endif
> masterConnection->createDatabase(name, filename, ACCOUNT, PASSWORD, threads);
> Statement *statement = masterConnection->createStatement();
>
>
> === modified file 'storage/falcon/TableSpace.cpp'
> --- a/storage/falcon/TableSpace.cpp 2008-07-17 13:52:17 +0000
> +++ b/storage/falcon/TableSpace.cpp 2008-08-18 20:17:15 +0000
> @@ -123,7 +123,9 @@ void TableSpace::open()
>
> void TableSpace::create()
> {
> +#ifndef FALCONDB
> dbb->createPath(filename);
> +#endif
> dbb->create(filename, dbb->pageSize, 0, HdrTableSpace, 0, NULL);
> active = true;
> dbb->flush();
>
>