68 errmsg(
"could not open file \"%s\" for reading: %m",
71 if ((fd = open(ControlFilePath, O_RDONLY |
PG_BINARY, 0)) == -1)
73 pg_log_fatal(
"could not open file \"%s\" for reading: %m",
86 errmsg(
"could not read file \"%s\": %m", ControlFilePath)));
89 pg_log_fatal(
"could not read file \"%s\": %m", ControlFilePath);
97 errmsg(
"could not read file \"%s\": read %d of %zu",
101 pg_log_fatal(
"could not read file \"%s\": read %d of %zu",
112 errmsg(
"could not close file \"%s\": %m",
117 pg_log_fatal(
"could not close file \"%s\": %m", ControlFilePath);
125 (
char *) ControlFile,
129 *crc_ok_p =
EQ_CRC32C(crc, ControlFile->crc);
132 if (ControlFile->pg_control_version % 65536 == 0 &&
133 ControlFile->pg_control_version / 65536 != 0)
138 "The byte ordering used to store the pg_control file might not match the one\n" 139 "used by this program. In that case the results below would be incorrect, and\n" 140 "the PostgreSQL installation would be incompatible with this data directory.");
167 "pg_control is too large for atomic disk writes");
169 "sizeof(ControlFileData) exceeds PG_CONTROL_FILE_SIZE");
174 (
char *) ControlFile,
197 errmsg(
"could not open file \"%s\": %m",
200 if ((fd = open(ControlFilePath, O_WRONLY |
PG_BINARY,
203 pg_log_fatal(
"could not open file \"%s\": %m", ControlFilePath);
221 errmsg(
"could not write file \"%s\": %m",
224 pg_log_fatal(
"could not write file \"%s\": %m", ControlFilePath);
239 errmsg(
"could not fsync file \"%s\": %m",
245 pg_log_fatal(
"could not fsync file \"%s\": %m", ControlFilePath);
256 errmsg(
"could not close file \"%s\": %m",
259 pg_log_fatal(
"could not close file \"%s\": %m", ControlFilePath);
int errcode(int sqlerrcode)
#define PG_CONTROL_MAX_SAFE_SIZE
static int fd(const char *x, int i)
#define StaticAssertStmt(condition, errmessage)
void update_controlfile(const char *DataDir, ControlFileData *ControlFile, bool do_sync)
int OpenTransientFile(const char *fileName, int fileFlags)
int errcode_for_file_access(void)
static void pgstat_report_wait_end(void)
#define EQ_CRC32C(c1, c2)
#define ereport(elevel, rest)
#define AssertArg(condition)
#define ERRCODE_DATA_CORRUPTED
int CloseTransientFile(int fd)
static ControlFileData * ControlFile
#define XLOG_CONTROL_FILE
ControlFileData * get_controlfile(const char *DataDir, bool *crc_ok_p)
static void pgstat_report_wait_start(uint32 wait_event_info)
#define PG_CONTROL_FILE_SIZE
int BasicOpenFile(const char *fileName, int fileFlags)
int errmsg(const char *fmt,...)
#define pg_log_warning(...)
#define COMP_CRC32C(crc, data, len)
#define offsetof(type, field)
#define pg_log_fatal(...)