88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.60 2000/09/06 14:15:16 petere Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.61 2000/10/16 14:52:03 vadim Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
2525
2626#include "access/heapam.h"
2727#include "catalog/catname.h"
28+ #include "catalog/catalog.h"
2829#include "catalog/pg_database.h"
2930#include "catalog/pg_shadow.h"
3031#include "commands/comment.h"
@@ -76,6 +77,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
7677 if (IsTransactionBlock ())
7778 elog (ERROR , "CREATE DATABASE: may not be called in a transaction block" );
7879
80+ #ifdef OLD_FILE_NAMING
7981 /* Generate directory name for the new database */
8082 if (dbpath == NULL || strcmp (dbpath , dbname ) == 0 )
8183 strcpy (locbuf , dbname );
@@ -89,6 +91,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
8991 "The database path '%s' is invalid. "
9092 "This may be due to a character that is not allowed or because the chosen "
9193 "path isn't permitted for databases" , dbpath );
94+ #endif
9295
9396 /*
9497 * Insert a new tuple into pg_database
@@ -111,6 +114,10 @@ createdb(const char *dbname, const char *dbpath, int encoding)
111114 */
112115 heap_insert (pg_database_rel , tuple );
113116
117+ #ifndef OLD_FILE_NAMING
118+ loc = GetDatabasePath (tuple -> t_data -> t_oid );
119+ #endif
120+
114121 /*
115122 * Update indexes (there aren't any currently)
116123 */
@@ -140,8 +147,19 @@ createdb(const char *dbname, const char *dbpath, int encoding)
140147 if (mkdir (loc , S_IRWXU ) != 0 )
141148 elog (ERROR , "CREATE DATABASE: unable to create database directory '%s': %s" , loc , strerror (errno ));
142149
150+ #ifdef OLD_FILE_NAMING
143151 snprintf (buf , sizeof (buf ), "cp %s%cbase%ctemplate1%c* '%s'" ,
144152 DataDir , SEP_CHAR , SEP_CHAR , SEP_CHAR , loc );
153+ #else
154+ {
155+ char * tmpl = GetDatabasePath (TemplateDbOid );
156+
157+ snprintf (buf , sizeof (buf ), "cp %s%c* '%s'" ,
158+ tmpl , SEP_CHAR , loc );
159+ pfree (tmpl );
160+ }
161+ #endif
162+
145163 ret = system (buf );
146164 /* Some versions of SunOS seem to return ECHILD after a system() call */
147165#if defined(sun )
@@ -204,12 +222,16 @@ dropdb(const char *dbname)
204222 if (GetUserId () != db_owner && !use_super )
205223 elog (ERROR , "DROP DATABASE: Permission denied" );
206224
225+ #ifdef OLD_FILE_NAMING
207226 path = ExpandDatabasePath (dbpath );
208227 if (path == NULL )
209228 elog (ERROR ,
210229 "The database path '%s' is invalid. "
211230 "This may be due to a character that is not allowed or because the chosen "
212231 "path isn't permitted for databases" , path );
232+ #else
233+ path = GetDatabasePath (db_id );
234+ #endif
213235
214236 /*
215237 * Obtain exclusive lock on pg_database. We need this to ensure that
0 commit comments