*** pgsql/src/backend/commands/tablespace.c 2010/01/07 04:05:39 1.69 --- pgsql/src/backend/commands/tablespace.c 2010/01/07 04:10:39 1.70 *************** *** 37,43 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.68 2010/01/06 23:23:51 momjian Exp $ * *------------------------------------------------------------------------- */ --- 37,43 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.69 2010/01/07 04:05:39 momjian Exp $ * *------------------------------------------------------------------------- */ *************** static void write_version_file(const cha *** 99,107 **** * symlink would normally be. This isn't an exact replay of course, but * it's the best we can do given the available information. * ! * If tablespaces are not supported, you might think this could be a no-op, ! * but you'd be wrong: we still need it in case we have to re-create a ! * database subdirectory (of $PGDATA/base) during WAL replay. */ void TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo) --- 99,106 ---- * symlink would normally be. This isn't an exact replay of course, but * it's the best we can do given the available information. * ! * If tablespaces are not supported, we still need it in case we have to ! * re-create a database subdirectory (of $PGDATA/base) during WAL replay. */ void TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo) *************** TablespaceCreateDbspace(Oid spcNode, Oid *** 123,128 **** --- 122,128 ---- if (stat(dir, &st) < 0) { + /* Directory does not exist? */ if (errno == ENOENT) { /* *************** TablespaceCreateDbspace(Oid spcNode, Oid *** 137,143 **** */ if (stat(dir, &st) == 0 && S_ISDIR(st.st_mode)) { ! /* Directory was created. */ } else { --- 137,143 ---- */ if (stat(dir, &st) == 0 && S_ISDIR(st.st_mode)) { ! /* Directory was created */ } else { *************** TablespaceCreateDbspace(Oid spcNode, Oid *** 152,157 **** --- 152,158 ---- (errcode_for_file_access(), errmsg("could not create directory \"%s\": %m", dir))); + /* Parent directory must be missing */ parentdir = pstrdup(dir); get_parent_directory(parentdir); *************** TablespaceCreateDbspace(Oid spcNode, Oid *** 162,167 **** --- 163,169 ---- errmsg("could not create directory \"%s\": %m", parentdir))); pfree(parentdir); + /* Create database directory */ if (mkdir(dir, S_IRWXU) < 0) ereport(ERROR, *************** CreateTableSpace(CreateTableSpaceStmt *s *** 252,258 **** * '//.' (XXX but do we ever form the whole path * explicitly? This may be overly conservative.) */ ! if (strlen(location) >= (MAXPGPATH - 1 - OIDCHARS - 1 - OIDCHARS - 1 - OIDCHARS)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), errmsg("tablespace location \"%s\" is too long", --- 254,260 ---- * '//.' (XXX but do we ever form the whole path * explicitly? This may be overly conservative.) */ ! if (strlen(location) >= MAXPGPATH - 1 - OIDCHARS - 1 - OIDCHARS - 1 - OIDCHARS) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), errmsg("tablespace location \"%s\" is too long",