3737 *
3838 *
3939 * IDENTIFICATION
40- * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.69 2010/01/07 04:05 :39 momjian Exp $
40+ * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.70 2010/01/07 04:10 :39 momjian Exp $
4141 *
4242 *-------------------------------------------------------------------------
4343 */
@@ -99,9 +99,8 @@ static void write_version_file(const char *path);
9999 * symlink would normally be. This isn't an exact replay of course, but
100100 * it's the best we can do given the available information.
101101 *
102- * If tablespaces are not supported, you might think this could be a no-op,
103- * but you'd be wrong: we still need it in case we have to re-create a
104- * database subdirectory (of $PGDATA/base) during WAL replay.
102+ * If tablespaces are not supported, we still need it in case we have to
103+ * re-create a database subdirectory (of $PGDATA/base) during WAL replay.
105104 */
106105void
107106TablespaceCreateDbspace (Oid spcNode ,Oid dbNode ,bool isRedo )
@@ -123,6 +122,7 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
123122
124123if (stat (dir ,& st )< 0 )
125124{
125+ /* Directory does not exist? */
126126if (errno == ENOENT )
127127{
128128/*
@@ -137,7 +137,7 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
137137 */
138138if (stat (dir ,& st )== 0 && S_ISDIR (st .st_mode ))
139139{
140- /* Directory was created. */
140+ /* Directory was created */
141141}
142142else
143143{
@@ -152,6 +152,7 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
152152(errcode_for_file_access (),
153153errmsg ("could not create directory \"%s\": %m" ,
154154dir )));
155+
155156/* Parent directory must be missing */
156157parentdir = pstrdup (dir );
157158get_parent_directory (parentdir );
@@ -162,6 +163,7 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
162163errmsg ("could not create directory \"%s\": %m" ,
163164parentdir )));
164165pfree (parentdir );
166+
165167/* Create database directory */
166168if (mkdir (dir ,S_IRWXU )< 0 )
167169ereport (ERROR ,
@@ -252,7 +254,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
252254 * '/<dboid>/<relid>.<nnn>' (XXX but do we ever form the whole path
253255 * explicitly?This may be overly conservative.)
254256 */
255- if (strlen (location ) >=( MAXPGPATH - 1 - OIDCHARS - 1 - OIDCHARS - 1 - OIDCHARS ) )
257+ if (strlen (location ) >=MAXPGPATH - 1 - OIDCHARS - 1 - OIDCHARS - 1 - OIDCHARS )
256258ereport (ERROR ,
257259(errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
258260errmsg ("tablespace location \"%s\" is too long" ,