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

Commit7b077af

Browse files
committed
Make get_controlfile() error logging consistent with src/common
As originally committed, get_controlfile() used a non-standard approachto error logging. Make it consistent with the majority of error loggingdone in src/common.Applies to master only.
1 parentb63bea5 commit7b077af

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

‎src/common/controldata_utils.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,6 @@
2828
#include"common/controldata_utils.h"
2929
#include"port/pg_crc32c.h"
3030

31-
#ifndefFRONTEND
32-
/* NOTE: caller must provide gettext call around the format string */
33-
#definelog_error(...)\
34-
elog(ERROR, __VA_ARGS__)
35-
#else
36-
#definelog_error(...)\
37-
do { \
38-
char *buf = psprintf(__VA_ARGS__); \
39-
fprintf(stderr, "%s: %s\n", progname, buf); \
40-
exit(2); \
41-
} while (0)
42-
#endif
43-
4431
/*
4532
* get_controlfile(char *DataDir, const char *progname)
4633
*
@@ -59,12 +46,31 @@ get_controlfile(char *DataDir, const char *progname)
5946
snprintf(ControlFilePath,MAXPGPATH,"%s/global/pg_control",DataDir);
6047

6148
if ((fd=open(ControlFilePath,O_RDONLY |PG_BINARY,0))==-1)
62-
log_error(_("could not open file \"%s\" for reading: %s"),
63-
ControlFilePath,strerror(errno));
49+
#ifndefFRONTEND
50+
ereport(ERROR,
51+
(errcode_for_file_access(),
52+
errmsg("could not open file \"%s\" for reading: %m",
53+
ControlFilePath)));
54+
#else
55+
{
56+
fprintf(stderr,_("%s: could not open file \"%s\" for reading: %s\n"),
57+
progname,ControlFilePath,strerror(errno));
58+
exit(EXIT_FAILURE);
59+
}
60+
#endif
6461

6562
if (read(fd,ControlFile,sizeof(ControlFileData))!=sizeof(ControlFileData))
66-
log_error(_("could not read file \"%s\": %s"),
67-
ControlFilePath,strerror(errno));
63+
#ifndefFRONTEND
64+
ereport(ERROR,
65+
(errcode_for_file_access(),
66+
errmsg("could not read file \"%s\": %m",ControlFilePath)));
67+
#else
68+
{
69+
fprintf(stderr,_("%s: could not read file \"%s\": %s\n"),
70+
progname,ControlFilePath,strerror(errno));
71+
exit(EXIT_FAILURE);
72+
}
73+
#endif
6874

6975
close(fd);
7076

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp