Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
772a5f1e
Commit
772a5f1e
authored
13 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Improve pg_upgrade error reporting if the bin or data directories do not
exist or are not directories.
parent
4a6a5c86
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/pg_upgrade/exec.c
+26
-24
26 additions, 24 deletions
contrib/pg_upgrade/exec.c
with
26 additions
and
24 deletions
contrib/pg_upgrade/exec.c
+
26
−
24
View file @
772a5f1e
...
@@ -71,7 +71,8 @@ is_server_running(const char *datadir)
...
@@ -71,7 +71,8 @@ is_server_running(const char *datadir)
if
((
fd
=
open
(
path
,
O_RDONLY
,
0
))
<
0
)
if
((
fd
=
open
(
path
,
O_RDONLY
,
0
))
<
0
)
{
{
if
(
errno
!=
ENOENT
)
if
(
errno
!=
ENOENT
)
pg_log
(
PG_FATAL
,
"could not open file
\"
%s
\"
for reading
\n
"
,
/* issue a warning but continue so we can throw a clearer error later */
pg_log
(
PG_WARNING
,
"could not open file
\"
%s
\"
for reading
\n
"
,
path
);
path
);
return
false
;
return
false
;
...
@@ -94,6 +95,8 @@ void
...
@@ -94,6 +95,8 @@ void
verify_directories
(
void
)
verify_directories
(
void
)
{
{
prep_status
(
"Checking current, bin, and data directories"
);
if
(
access
(
"."
,
R_OK
|
W_OK
if
(
access
(
"."
,
R_OK
|
W_OK
#ifndef WIN32
#ifndef WIN32
/*
/*
...
@@ -107,20 +110,10 @@ verify_directories(void)
...
@@ -107,20 +110,10 @@ verify_directories(void)
pg_log
(
PG_FATAL
,
pg_log
(
PG_FATAL
,
"You must have read and write access in the current directory.
\n
"
);
"You must have read and write access in the current directory.
\n
"
);
prep_status
(
"Checking old data directory (%s)"
,
old_cluster
.
pgdata
);
check_data_dir
(
old_cluster
.
pgdata
);
check_ok
();
prep_status
(
"Checking old bin directory (%s)"
,
old_cluster
.
bindir
);
check_bin_dir
(
&
old_cluster
);
check_bin_dir
(
&
old_cluster
);
check_ok
();
check_data_dir
(
old_cluster
.
pgdata
);
prep_status
(
"Checking new data directory (%s)"
,
new_cluster
.
pgdata
);
check_data_dir
(
new_cluster
.
pgdata
);
check_ok
();
prep_status
(
"Checking new bin directory (%s)"
,
new_cluster
.
bindir
);
check_bin_dir
(
&
new_cluster
);
check_bin_dir
(
&
new_cluster
);
check_data_dir
(
new_cluster
.
pgdata
);
check_ok
();
check_ok
();
}
}
...
@@ -139,25 +132,25 @@ check_data_dir(const char *pg_data)
...
@@ -139,25 +132,25 @@ check_data_dir(const char *pg_data)
{
{
char
subDirName
[
MAXPGPATH
];
char
subDirName
[
MAXPGPATH
];
int
subdirnum
;
int
subdirnum
;
const
char
*
requiredSubdirs
[]
=
{
"base"
,
"global"
,
"pg_clog"
,
/* start check with top-most directory */
const
char
*
requiredSubdirs
[]
=
{
""
,
"base"
,
"global"
,
"pg_clog"
,
"pg_multixact"
,
"pg_subtrans"
,
"pg_tblspc"
,
"pg_twophase"
,
"pg_multixact"
,
"pg_subtrans"
,
"pg_tblspc"
,
"pg_twophase"
,
"pg_xlog"
};
"pg_xlog"
};
for
(
subdirnum
=
0
;
for
(
subdirnum
=
0
;
subdirnum
<
sizeof
(
requiredSubdirs
)
/
sizeof
(
requiredSubdirs
[
0
]);
subdirnum
<
sizeof
(
requiredSubdirs
)
/
sizeof
(
requiredSubdirs
[
0
]);
++
subdirnum
)
++
subdirnum
)
{
{
struct
stat
statBuf
;
struct
stat
statBuf
;
snprintf
(
subDirName
,
sizeof
(
subDirName
),
"%s/%s"
,
pg_data
,
snprintf
(
subDirName
,
sizeof
(
subDirName
),
"%s/%s"
,
pg_data
,
requiredSubdirs
[
subdirnum
]);
requiredSubdirs
[
subdirnum
]);
if
(
stat
(
subDirName
,
&
statBuf
)
!=
0
)
if
(
stat
(
subDirName
,
&
statBuf
)
!=
0
)
report_status
(
PG_FATAL
,
"check for %s failed: %s
\n
"
,
report_status
(
PG_FATAL
,
"check for %s failed: %s
\n
"
,
requiredSubdirs
[
sub
d
ir
num
]
,
getErrorText
(
errno
));
sub
D
ir
Name
,
getErrorText
(
errno
));
else
if
(
!
S_ISDIR
(
statBuf
.
st_mode
))
else
if
(
!
S_ISDIR
(
statBuf
.
st_mode
))
report_status
(
PG_FATAL
,
"%s is not a directory
\n
"
,
report_status
(
PG_FATAL
,
"%s is not a directory
\n
"
,
requiredSubdirs
[
sub
d
ir
num
]
);
sub
D
ir
Name
);
}
}
}
}
...
@@ -173,6 +166,16 @@ check_data_dir(const char *pg_data)
...
@@ -173,6 +166,16 @@ check_data_dir(const char *pg_data)
static
void
static
void
check_bin_dir
(
ClusterInfo
*
cluster
)
check_bin_dir
(
ClusterInfo
*
cluster
)
{
{
struct
stat
statBuf
;
/* check bindir */
if
(
stat
(
cluster
->
bindir
,
&
statBuf
)
!=
0
)
report_status
(
PG_FATAL
,
"check for %s failed: %s
\n
"
,
cluster
->
bindir
,
getErrorText
(
errno
));
else
if
(
!
S_ISDIR
(
statBuf
.
st_mode
))
report_status
(
PG_FATAL
,
"%s is not a directory
\n
"
,
cluster
->
bindir
);
validate_exec
(
cluster
->
bindir
,
"postgres"
);
validate_exec
(
cluster
->
bindir
,
"postgres"
);
validate_exec
(
cluster
->
bindir
,
"pg_ctl"
);
validate_exec
(
cluster
->
bindir
,
"pg_ctl"
);
validate_exec
(
cluster
->
bindir
,
"pg_resetxlog"
);
validate_exec
(
cluster
->
bindir
,
"pg_resetxlog"
);
...
@@ -211,11 +214,10 @@ validate_exec(const char *dir, const char *cmdName)
...
@@ -211,11 +214,10 @@ validate_exec(const char *dir, const char *cmdName)
*/
*/
if
(
stat
(
path
,
&
buf
)
<
0
)
if
(
stat
(
path
,
&
buf
)
<
0
)
pg_log
(
PG_FATAL
,
"check for %s failed - %s
\n
"
,
pg_log
(
PG_FATAL
,
"check for %s failed - %s
\n
"
,
cmdName
,
getErrorText
(
errno
));
path
,
getErrorText
(
errno
));
else
if
(
!
S_ISREG
(
buf
.
st_mode
))
if
(
!
S_ISREG
(
buf
.
st_mode
))
pg_log
(
PG_FATAL
,
"check for %s failed - not an executable file
\n
"
,
pg_log
(
PG_FATAL
,
"check for %s failed - not an executable file
\n
"
,
cmdName
);
path
);
/*
/*
* Ensure that the file is both executable and readable (required for
* Ensure that the file is both executable and readable (required for
...
@@ -227,7 +229,7 @@ validate_exec(const char *dir, const char *cmdName)
...
@@ -227,7 +229,7 @@ validate_exec(const char *dir, const char *cmdName)
if
((
buf
.
st_mode
&
S_IRUSR
)
==
0
)
if
((
buf
.
st_mode
&
S_IRUSR
)
==
0
)
#endif
#endif
pg_log
(
PG_FATAL
,
"check for %s failed - cannot read file (permission denied)
\n
"
,
pg_log
(
PG_FATAL
,
"check for %s failed - cannot read file (permission denied)
\n
"
,
cmdName
);
path
);
#ifndef WIN32
#ifndef WIN32
if
(
access
(
path
,
X_OK
)
!=
0
)
if
(
access
(
path
,
X_OK
)
!=
0
)
...
@@ -235,5 +237,5 @@ validate_exec(const char *dir, const char *cmdName)
...
@@ -235,5 +237,5 @@ validate_exec(const char *dir, const char *cmdName)
if
((
buf
.
st_mode
&
S_IXUSR
)
==
0
)
if
((
buf
.
st_mode
&
S_IXUSR
)
==
0
)
#endif
#endif
pg_log
(
PG_FATAL
,
"check for %s failed - cannot execute (permission denied)
\n
"
,
pg_log
(
PG_FATAL
,
"check for %s failed - cannot execute (permission denied)
\n
"
,
cmdName
);
path
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment