8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
25
25
26
26
#include "access/heapam.h"
27
27
#include "catalog/catname.h"
28
+ #include "catalog/catalog.h"
28
29
#include "catalog/pg_database.h"
29
30
#include "catalog/pg_shadow.h"
30
31
#include "commands/comment.h"
@@ -76,6 +77,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
76
77
if (IsTransactionBlock ())
77
78
elog (ERROR , "CREATE DATABASE: may not be called in a transaction block" );
78
79
80
+ #ifdef OLD_FILE_NAMING
79
81
/* Generate directory name for the new database */
80
82
if (dbpath == NULL || strcmp (dbpath , dbname ) == 0 )
81
83
strcpy (locbuf , dbname );
@@ -89,6 +91,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
89
91
"The database path '%s' is invalid. "
90
92
"This may be due to a character that is not allowed or because the chosen "
91
93
"path isn't permitted for databases" , dbpath );
94
+ #endif
92
95
93
96
/*
94
97
* Insert a new tuple into pg_database
@@ -111,6 +114,10 @@ createdb(const char *dbname, const char *dbpath, int encoding)
111
114
*/
112
115
heap_insert (pg_database_rel , tuple );
113
116
117
+ #ifndef OLD_FILE_NAMING
118
+ loc = GetDatabasePath (tuple -> t_data -> t_oid );
119
+ #endif
120
+
114
121
/*
115
122
* Update indexes (there aren't any currently)
116
123
*/
@@ -140,8 +147,19 @@ createdb(const char *dbname, const char *dbpath, int encoding)
140
147
if (mkdir (loc , S_IRWXU ) != 0 )
141
148
elog (ERROR , "CREATE DATABASE: unable to create database directory '%s': %s" , loc , strerror (errno ));
142
149
150
+ #ifdef OLD_FILE_NAMING
143
151
snprintf (buf , sizeof (buf ), "cp %s%cbase%ctemplate1%c* '%s'" ,
144
152
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
+
145
163
ret = system (buf );
146
164
/* Some versions of SunOS seem to return ECHILD after a system() call */
147
165
#if defined(sun )
@@ -204,12 +222,16 @@ dropdb(const char *dbname)
204
222
if (GetUserId () != db_owner && !use_super )
205
223
elog (ERROR , "DROP DATABASE: Permission denied" );
206
224
225
+ #ifdef OLD_FILE_NAMING
207
226
path = ExpandDatabasePath (dbpath );
208
227
if (path == NULL )
209
228
elog (ERROR ,
210
229
"The database path '%s' is invalid. "
211
230
"This may be due to a character that is not allowed or because the chosen "
212
231
"path isn't permitted for databases" , path );
232
+ #else
233
+ path = GetDatabasePath (db_id );
234
+ #endif
213
235
214
236
/*
215
237
* Obtain exclusive lock on pg_database. We need this to ensure that
0 commit comments