aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablespace.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-03-22 19:51:44 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-03-22 19:51:44 +0000
commita4127b713de3a655a0136bf53adceebf7b83d319 (patch)
treee145d2801b883735c1f4929230e57dfe4456530b /src/backend/commands/tablespace.c
parent832b6d00e9b7608ce21aff68abda50c400c5c7d6 (diff)
downloadpostgresql-a4127b713de3a655a0136bf53adceebf7b83d319.tar.gz
postgresql-a4127b713de3a655a0136bf53adceebf7b83d319.zip
Allow DROP TABLESPACE to succeed (with a warning) if the pg_tblspc symlink
doesn't exist. This allows DROP to be used to clean out the pg_tablespace catalog entry in a situation where a previous DROP attempt failed before committing but after having removed the directories and symlink. Per report from William Garrison. Even though his test case depends on an unrelated bug in PreventTransactionChain, it's certainly possible for this situation to arise due to other problems, eg a system crash at just the right time.
Diffstat (limited to 'src/backend/commands/tablespace.c')
-rw-r--r--src/backend/commands/tablespace.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 8e3bfbda863..16a9f52bd5f 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.44 2007/03/13 00:33:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.45 2007/03/22 19:51:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -523,12 +523,25 @@ remove_tablespace_directories(Oid tablespaceoid, bool redo)
* fresh subdirectories in parallel. It is possible that new files are
* being created within subdirectories, though, so the rmdir call could
* fail. Worst consequence is a less friendly error message.
+ *
+ * If redo is true then ENOENT is a likely outcome here, and we allow it
+ * to pass without comment. In normal operation we still allow it, but
+ * with a warning. This is because even though ProcessUtility disallows
+ * DROP TABLESPACE in a transaction block, it's possible that a previous
+ * DROP failed and rolled back after removing the tablespace directories
+ * and symlink. We want to allow a new DROP attempt to succeed at
+ * removing the catalog entries, so we should not give a hard error here.
*/
dirdesc = AllocateDir(location);
if (dirdesc == NULL)
{
- if (redo && errno == ENOENT)
+ if (errno == ENOENT)
{
+ if (!redo)
+ ereport(WARNING,
+ (errcode_for_file_access(),
+ errmsg("could not open directory \"%s\": %m",
+ location)));
pfree(location);
return true;
}