37
37
*
38
38
*
39
39
* IDENTIFICATION
40
- * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.68 2010/01/06 23:23:51 momjian Exp $
40
+ * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.69 2010/01/07 04:05:39 momjian Exp $
41
41
*
42
42
*-------------------------------------------------------------------------
43
43
*/
@@ -89,7 +89,7 @@ static void write_version_file(const char *path);
89
89
* Each database using a table space is isolated into its own name space
90
90
* by a subdirectory named for the database OID. On first creation of an
91
91
* object in the tablespace, create the subdirectory. If the subdirectory
92
- * already exists, just fall through quietly.
92
+ * already exists, fall through quietly.
93
93
*
94
94
* isRedo indicates that we are creating an object during WAL replay.
95
95
* In this case we will cope with the possibility of the tablespace
@@ -137,29 +137,32 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
137
137
*/
138
138
if (stat (dir , & st ) == 0 && S_ISDIR (st .st_mode ))
139
139
{
140
- /* need not do anything */
140
+ /* Directory was created. */
141
141
}
142
142
else
143
143
{
144
- /* OK, go for it */
144
+ /* Directory creation failed? */
145
145
if (mkdir (dir , S_IRWXU ) < 0 )
146
146
{
147
147
char * parentdir ;
148
148
149
+ /* Failure other than not exists? */
149
150
if (errno != ENOENT || !isRedo )
150
151
ereport (ERROR ,
151
152
(errcode_for_file_access (),
152
153
errmsg ("could not create directory \"%s\": %m" ,
153
154
dir )));
154
- /* Try to make parent directory too */
155
+ /* Parent directory must be missing */
155
156
parentdir = pstrdup (dir );
156
157
get_parent_directory (parentdir );
158
+ /* Can't create parent either? */
157
159
if (mkdir (parentdir , S_IRWXU ) < 0 )
158
160
ereport (ERROR ,
159
161
(errcode_for_file_access (),
160
162
errmsg ("could not create directory \"%s\": %m" ,
161
163
parentdir )));
162
164
pfree (parentdir );
165
+ /* Create database directory */
163
166
if (mkdir (dir , S_IRWXU ) < 0 )
164
167
ereport (ERROR ,
165
168
(errcode_for_file_access (),
@@ -179,7 +182,7 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
179
182
}
180
183
else
181
184
{
182
- /* be paranoid */
185
+ /* Is it not a directory? */
183
186
if (!S_ISDIR (st .st_mode ))
184
187
ereport (ERROR ,
185
188
(errcode (ERRCODE_WRONG_OBJECT_TYPE ),
0 commit comments