More tablespace.c comment improvements.

This commit is contained in:
Bruce Momjian 2010-01-07 04:10:39 +00:00
parent 85fcbd8655
commit c282b36dd2

View File

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