On solaris, createdb/dropdb fails because of strange behavior of system().
(it returns error with errno ECHILD upon successful completion of commands). This fix ignores an error from system() if errno == ECHILD.
This commit is contained in:
parent
c439756ffd
commit
07d4d36aae
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.53 2000/04/12 17:14:58 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.54 2000/05/25 06:53:43 ishii Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -148,13 +148,21 @@ createdb(const char *dbname, const char *dbpath, int encoding)
|
|||||||
|
|
||||||
snprintf(buf, sizeof(buf), "cp %s%cbase%ctemplate1%c* '%s'",
|
snprintf(buf, sizeof(buf), "cp %s%cbase%ctemplate1%c* '%s'",
|
||||||
DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, loc);
|
DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, loc);
|
||||||
|
#if defined(sun)
|
||||||
|
if (system(buf) != 0 && errno != ECHILD)
|
||||||
|
#else
|
||||||
if (system(buf) != 0)
|
if (system(buf) != 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "rm -rf '%s'", loc);
|
snprintf(buf, sizeof(buf), "rm -rf '%s'", loc);
|
||||||
ret = system(buf);
|
ret = system(buf);
|
||||||
|
#if defined(sun)
|
||||||
|
if (ret == 0 || errno == ECHILD)
|
||||||
|
#else
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
#endif
|
||||||
elog(ERROR, "CREATE DATABASE: could not initialize database directory");
|
elog(ERROR, "CREATE DATABASE: could not initialize database directory");
|
||||||
else
|
else
|
||||||
elog(ERROR, "CREATE DATABASE: Could not initialize database directory. Delete failed as well");
|
elog(ERROR, "CREATE DATABASE: Could not initialize database directory. Delete failed as well");
|
||||||
@ -281,7 +289,11 @@ dropdb(const char *dbname)
|
|||||||
* Remove the database's subdirectory and everything in it.
|
* Remove the database's subdirectory and everything in it.
|
||||||
*/
|
*/
|
||||||
snprintf(buf, sizeof(buf), "rm -rf '%s'", path);
|
snprintf(buf, sizeof(buf), "rm -rf '%s'", path);
|
||||||
|
#if defined(sun)
|
||||||
|
if (system(buf) != 0 && errno != ECHILD)
|
||||||
|
#else
|
||||||
if (system(buf) != 0)
|
if (system(buf) != 0)
|
||||||
|
#endif
|
||||||
elog(NOTICE, "DROP DATABASE: The database directory '%s' could not be removed", path);
|
elog(NOTICE, "DROP DATABASE: The database directory '%s' could not be removed", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user