Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc1275cf

Browse files
committed
pg_upgrade: throw an error for non-existent tablespace directories
Non-existent tablespace directory references can occur if usertablespaces are created inside data directories and the data directoryis renamed in preparation for running pg_upgrade, and the symbolic linksare not updated.Backpatch to 9.3.
1 parent52e7574 commitc1275cf

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎contrib/pg_upgrade/tablespace.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include"pg_upgrade.h"
1313

14+
#include<sys/types.h>
15+
1416
staticvoidget_tablespace_paths(void);
1517
staticvoidset_tablespace_directory_suffix(ClusterInfo*cluster);
1618

@@ -65,9 +67,39 @@ get_tablespace_paths(void)
6567
i_spclocation=PQfnumber(res,"spclocation");
6668

6769
for (tblnum=0;tblnum<os_info.num_old_tablespaces;tblnum++)
70+
{
71+
structstatstatBuf;
72+
6873
os_info.old_tablespaces[tblnum]=pg_strdup(
6974
PQgetvalue(res,tblnum,i_spclocation));
7075

76+
/*
77+
* Check that the tablespace path exists and is a directory.
78+
* Effectively, this is checking only for tables/indexes in
79+
* non-existent tablespace directories. Databases located in
80+
* non-existent tablespaces already throw a backend error.
81+
* Non-existent tablespace directories can occur when a data
82+
* directory that contains user tablespaces is moved as part
83+
* of pg_upgrade preparation and the symbolic links are not
84+
* updated.
85+
*/
86+
if (stat(os_info.old_tablespaces[tblnum],&statBuf)!=0)
87+
{
88+
if (errno==ENOENT)
89+
report_status(PG_FATAL,
90+
"tablespace directory \"%s\" does not exist\n",
91+
os_info.old_tablespaces[tblnum]);
92+
else
93+
report_status(PG_FATAL,
94+
"cannot stat() tablespace directory \"%s\": %s\n",
95+
os_info.old_tablespaces[tblnum],getErrorText(errno));
96+
}
97+
if (!S_ISDIR(statBuf.st_mode))
98+
report_status(PG_FATAL,
99+
"tablespace path \"%s\" is not a directory\n",
100+
os_info.old_tablespaces[tblnum]);
101+
}
102+
71103
PQclear(res);
72104

73105
PQfinish(conn);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp