3737 *
3838 *
3939 * 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 $
4141 *
4242 *-------------------------------------------------------------------------
4343 */
@@ -89,7 +89,7 @@ static void write_version_file(const char *path);
8989 * Each database using a table space is isolated into its own name space
9090 * by a subdirectory named for the database OID. On first creation of an
9191 * object in the tablespace, create the subdirectory. If the subdirectory
92- * already exists, just fall through quietly.
92+ * already exists, fall through quietly.
9393 *
9494 * isRedo indicates that we are creating an object during WAL replay.
9595 * In this case we will cope with the possibility of the tablespace
@@ -137,29 +137,32 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
137137 */
138138 if (stat (dir , & st ) == 0 && S_ISDIR (st .st_mode ))
139139 {
140- /* need not do anything */
140+ /* Directory was created. */
141141 }
142142 else
143143 {
144- /* OK, go for it */
144+ /* Directory creation failed? */
145145 if (mkdir (dir , S_IRWXU ) < 0 )
146146 {
147147 char * parentdir ;
148148
149+ /* Failure other than not exists? */
149150 if (errno != ENOENT || !isRedo )
150151 ereport (ERROR ,
151152 (errcode_for_file_access (),
152153 errmsg ("could not create directory \"%s\": %m" ,
153154 dir )));
154- /* Try to make parent directory too */
155+ /* Parent directory must be missing */
155156 parentdir = pstrdup (dir );
156157 get_parent_directory (parentdir );
158+ /* Can't create parent either? */
157159 if (mkdir (parentdir , S_IRWXU ) < 0 )
158160 ereport (ERROR ,
159161 (errcode_for_file_access (),
160162 errmsg ("could not create directory \"%s\": %m" ,
161163 parentdir )));
162164 pfree (parentdir );
165+ /* Create database directory */
163166 if (mkdir (dir , S_IRWXU ) < 0 )
164167 ereport (ERROR ,
165168 (errcode_for_file_access (),
@@ -179,7 +182,7 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
179182 }
180183 else
181184 {
182- /* be paranoid */
185+ /* Is it not a directory? */
183186 if (!S_ISDIR (st .st_mode ))
184187 ereport (ERROR ,
185188 (errcode (ERRCODE_WRONG_OBJECT_TYPE ),
0 commit comments