1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

Clean up CREATE DATABASE processing to make it more robust and get rid

of special case for Windows port.  Put a PG_TRY around most of createdb()
to ensure that we remove copied subdirectories on failure, even if the
failure happens while creating the pg_database row.  (I think this explains
Oliver Siegmar's recent report.)  Having done that, there's no need for
the fragile assumption that copydir() mustn't ereport(ERROR), so simplify
its API.  Eliminate the old code that used system("cp ...") to copy
subdirectories, in favor of using copydir() on all platforms.  This not
only should allow much better error reporting, but allows us to fsync
the created files before trusting that the copy has succeeded.
This commit is contained in:
Tom Lane
2005-08-02 19:02:32 +00:00
parent 0001e98d54
commit 558730ac6b
6 changed files with 283 additions and 287 deletions

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/port.h,v 1.79 2005/07/06 21:40:09 momjian Exp $
* $PostgreSQL: pgsql/src/include/port.h,v 1.80 2005/08/02 19:02:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -206,6 +206,8 @@ extern int pgsymlink(const char *oldpath, const char *newpath);
#endif /* defined(WIN32) || defined(__CYGWIN__) */
extern void copydir(char *fromdir, char *todir, bool recurse);
extern bool rmtree(char *path, bool rmtopdir);
#if defined(WIN32) && !defined(__CYGWIN__)
@@ -223,8 +225,6 @@ extern int win32_open(const char *, int,...);
#define pclose(a) _pclose(a)
#endif
extern int copydir(char *fromdir, char *todir);
/* Missing rand functions */
extern long lrand48(void);
extern void srand48(long seed);