On 03/06/2016 01:26 PM, Joe Conway wrote: > On 03/06/2016 01:24 PM, Tom Lane wrote: >> * It's randomly unlike every single other place we've addressed the >> same problem. Everywhere else in src/common does it like this:
[...snip...] >> and I think that's what this needs to do too, especially in view of the >> fact that there are only two places that would have to be fixed anyway. > > Ok, will fix. Something like the attached what you had in mind? Thanks, Joe -- Crunchy Data - http://crunchydata.com PostgreSQL Support for Secure Enterprises Consulting, Training, & Open Source Development
diff --git a/src/common/controldata_utils.c b/src/common/controldata_utils.c index b6d0a12..65f2cb9 100644 *** a/src/common/controldata_utils.c --- b/src/common/controldata_utils.c *************** *** 28,46 **** #include "common/controldata_utils.h" #include "port/pg_crc32c.h" - #ifndef FRONTEND - /* NOTE: caller must provide gettext call around the format string */ - #define log_error(...) \ - elog(ERROR, __VA_ARGS__) - #else - #define log_error(...) \ - do { \ - char *buf = psprintf(__VA_ARGS__); \ - fprintf(stderr, "%s: %s\n", progname, buf); \ - exit(2); \ - } while (0) - #endif - /* * get_controlfile(char *DataDir, const char *progname) * --- 28,33 ---- *************** get_controlfile(char *DataDir, const cha *** 59,70 **** snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir); if ((fd = open(ControlFilePath, O_RDONLY | PG_BINARY, 0)) == -1) ! log_error(_("could not open file \"%s\" for reading: %s"), ! ControlFilePath, strerror(errno)); if (read(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData)) ! log_error(_("could not read file \"%s\": %s"), ! ControlFilePath, strerror(errno)); close(fd); --- 46,76 ---- snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir); if ((fd = open(ControlFilePath, O_RDONLY | PG_BINARY, 0)) == -1) ! #ifndef FRONTEND ! ereport(ERROR, ! (errcode_for_file_access(), ! errmsg("could not open file \"%s\" for reading: %m", ! ControlFilePath))); ! #else ! { ! fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"), ! progname, ControlFilePath, strerror(errno)); ! exit(2); ! } ! #endif if (read(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData)) ! #ifndef FRONTEND ! ereport(ERROR, ! (errcode_for_file_access(), ! errmsg("could not read file \"%s\": %m", ControlFilePath))); ! #else ! { ! fprintf(stderr, _("%s: could not read file \"%s\": %s\n"), ! progname, ControlFilePath, strerror(errno)); ! exit(2); ! } ! #endif close(fd);
signature.asc
Description: OpenPGP digital signature