Skip to content

Commit 33cb8ff

Browse files
committed
Warn about tablespace creation in PGDATA
Also add warning to pg_upgrade Report by Josh Berkus
1 parent 290713e commit 33cb8ff

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/backend/commands/tablespace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
288288
errmsg("tablespace location \"%s\" is too long",
289289
location)));
290290

291+
/* Warn if the tablespace is in the data directory. */
292+
if (path_is_prefix_of_path(DataDir, location))
293+
ereport(WARNING,
294+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
295+
errmsg("tablespace location should not be inside the data directory")));
296+
291297
/*
292298
* Disallow creation of tablespaces named "pg_xxx"; we reserve this
293299
* namespace for system purposes.

src/bin/pg_upgrade/check.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,10 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
508508
canonicalize_path(old_tablespace_dir);
509509
if (path_is_prefix_of_path(old_cluster_pgdata, old_tablespace_dir))
510510
{
511+
/* reproduce warning from CREATE TABLESPACE that is in the log */
512+
pg_log(PG_WARNING,
513+
"\nWARNING: user-defined tablespace locations should not be inside the data directory, e.g. %s\n", old_tablespace_dir);
514+
511515
/* Unlink file in case it is left over from a previous run. */
512516
unlink(*deletion_script_file_name);
513517
pg_free(*deletion_script_file_name);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy