Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9cb4a28

Browse files
committed
Improve error message for cp or rm failur during create/drop database,
per recent discussions.
1 parent2b56a96 commit9cb4a28

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.121 2003/08/04 02:39:58 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.122 2003/09/10 20:24:09 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -354,19 +354,40 @@ createdb(const CreatedbStmt *stmt)
354354
nominal_loc,alt_loc)));
355355
}
356356

357-
/* Copy the template database to the new location */
357+
/*
358+
* Copy the template database to the new location
359+
*
360+
* XXX use of cp really makes this code pretty grotty, particularly
361+
* with respect to lack of ability to report errors well. Someday
362+
* rewrite to do it for ourselves.
363+
*/
358364
#ifndefWIN32
359365
snprintf(buf,sizeof(buf),"cp -r '%s' '%s'",src_loc,target_dir);
360366
if (system(buf)!=0)
361-
#else
367+
{
368+
if (remove_dbdirs(nominal_loc,alt_loc))
369+
ereport(ERROR,
370+
(errmsg("could not initialize database directory"),
371+
errdetail("Failing system command was: %s",buf),
372+
errhint("Look in the postmaster's stderr log for more information.")));
373+
else
374+
ereport(ERROR,
375+
(errmsg("could not initialize database directory; delete failed as well"),
376+
errdetail("Failing system command was: %s",buf),
377+
errhint("Look in the postmaster's stderr log for more information.")));
378+
}
379+
#else/* WIN32 */
362380
if (copydir(src_loc,target_dir)!=0)
363-
#endif
364381
{
382+
/* copydir should already have given details of its troubles */
365383
if (remove_dbdirs(nominal_loc,alt_loc))
366-
elog(ERROR,"could not initialize database directory");
384+
ereport(ERROR,
385+
(errmsg("could not initialize database directory")));
367386
else
368-
elog(ERROR,"could not initialize database directory; delete failed as well");
387+
ereport(ERROR,
388+
(errmsg("could not initialize database directory; delete failed as well")));
369389
}
390+
#endif/* WIN32 */
370391

371392
/*
372393
* Now OK to grab exclusive lock on pg_database.
@@ -935,9 +956,10 @@ remove_dbdirs(const char *nominal_loc, const char *alt_loc)
935956
if (system(buf)!=0)
936957
{
937958
ereport(WARNING,
938-
(errcode_for_file_access(),
939-
errmsg("could not remove database directory \"%s\": %m",
940-
target_dir)));
959+
(errmsg("could not remove database directory \"%s\"",
960+
target_dir),
961+
errdetail("Failing system command was: %s",buf),
962+
errhint("Look in the postmaster's stderr log for more information.")));
941963
success= false;
942964
}
943965

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp