Hi all, While looking at the source code for more consistency work with error messages, I have bumped into a couple of messages which could be simplified, as those include in the name of the file manipulated basically the same information as the context added.
I have finished with the attached. Note that for most of the messages, I think that the context can be useful, like for example the stats temporary file which could be user-defined, so those are left out. There are also other cases, say the reorder buffer spill file, where we may not know the path worked on, so the messages are kept consistent as per HEAD. That's a bit less work to do for translators, particularly with pg_stat_statements. Thoughts? -- Michael
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index cc9efab243..33f9a79f54 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -642,19 +642,19 @@ pgss_shmem_startup(void) read_error: ereport(LOG, (errcode_for_file_access(), - errmsg("could not read pg_stat_statement file \"%s\": %m", + errmsg("could not read file \"%s\": %m", PGSS_DUMP_FILE))); goto fail; data_error: ereport(LOG, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("ignoring invalid data in pg_stat_statement file \"%s\"", + errmsg("ignoring invalid data in file \"%s\"", PGSS_DUMP_FILE))); goto fail; write_error: ereport(LOG, (errcode_for_file_access(), - errmsg("could not write pg_stat_statement file \"%s\": %m", + errmsg("could not write file \"%s\": %m", PGSS_TEXT_FILE))); fail: if (buffer) @@ -761,7 +761,7 @@ pgss_shmem_shutdown(int code, Datum arg) error: ereport(LOG, (errcode_for_file_access(), - errmsg("could not write pg_stat_statement file \"%s\": %m", + errmsg("could not write file \"%s\": %m", PGSS_DUMP_FILE ".tmp"))); if (qbuffer) free(qbuffer); @@ -1871,7 +1871,7 @@ qtext_store(const char *query, int query_len, error: ereport(LOG, (errcode_for_file_access(), - errmsg("could not write pg_stat_statement file \"%s\": %m", + errmsg("could not write file \"%s\": %m", PGSS_TEXT_FILE))); if (fd >= 0) @@ -1913,7 +1913,7 @@ qtext_load_file(Size *buffer_size) if (errno != ENOENT) ereport(LOG, (errcode_for_file_access(), - errmsg("could not read pg_stat_statement file \"%s\": %m", + errmsg("could not read file \"%s\": %m", PGSS_TEXT_FILE))); return NULL; } @@ -1923,7 +1923,7 @@ qtext_load_file(Size *buffer_size) { ereport(LOG, (errcode_for_file_access(), - errmsg("could not stat pg_stat_statement file \"%s\": %m", + errmsg("could not stat file \"%s\": %m", PGSS_TEXT_FILE))); CloseTransientFile(fd); return NULL; @@ -1939,7 +1939,7 @@ qtext_load_file(Size *buffer_size) ereport(LOG, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"), - errdetail("Could not allocate enough memory to read pg_stat_statement file \"%s\".", + errdetail("Could not allocate enough memory to read file \"%s\".", PGSS_TEXT_FILE))); CloseTransientFile(fd); return NULL; @@ -1958,7 +1958,7 @@ qtext_load_file(Size *buffer_size) if (errno) ereport(LOG, (errcode_for_file_access(), - errmsg("could not read pg_stat_statement file \"%s\": %m", + errmsg("could not read file \"%s\": %m", PGSS_TEXT_FILE))); free(buf); CloseTransientFile(fd); @@ -2088,7 +2088,7 @@ gc_qtexts(void) { ereport(LOG, (errcode_for_file_access(), - errmsg("could not write pg_stat_statement file \"%s\": %m", + errmsg("could not write file \"%s\": %m", PGSS_TEXT_FILE))); goto gc_fail; } @@ -2118,7 +2118,7 @@ gc_qtexts(void) { ereport(LOG, (errcode_for_file_access(), - errmsg("could not write pg_stat_statement file \"%s\": %m", + errmsg("could not write file \"%s\": %m", PGSS_TEXT_FILE))); hash_seq_term(&hash_seq); goto gc_fail; @@ -2136,14 +2136,14 @@ gc_qtexts(void) if (ftruncate(fileno(qfile), extent) != 0) ereport(LOG, (errcode_for_file_access(), - errmsg("could not truncate pg_stat_statement file \"%s\": %m", + errmsg("could not truncate file \"%s\": %m", PGSS_TEXT_FILE))); if (FreeFile(qfile)) { ereport(LOG, (errcode_for_file_access(), - errmsg("could not write pg_stat_statement file \"%s\": %m", + errmsg("could not write file \"%s\": %m", PGSS_TEXT_FILE))); qfile = NULL; goto gc_fail; @@ -2203,7 +2203,7 @@ gc_fail: if (qfile == NULL) ereport(LOG, (errcode_for_file_access(), - errmsg("could not write new pg_stat_statement file \"%s\": %m", + errmsg("could not recreate file \"%s\": %m", PGSS_TEXT_FILE))); else FreeFile(qfile); @@ -2255,7 +2255,7 @@ entry_reset(void) { ereport(LOG, (errcode_for_file_access(), - errmsg("could not create pg_stat_statement file \"%s\": %m", + errmsg("could not create file \"%s\": %m", PGSS_TEXT_FILE))); goto done; } @@ -2264,7 +2264,7 @@ entry_reset(void) if (ftruncate(fileno(qfile), 0) != 0) ereport(LOG, (errcode_for_file_access(), - errmsg("could not truncate pg_stat_statement file \"%s\": %m", + errmsg("could not truncate file \"%s\": %m", PGSS_TEXT_FILE))); FreeFile(qfile); diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index bebe6405de..237a444bcd 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -3569,7 +3569,7 @@ XLogFileOpen(XLogSegNo segno) if (fd < 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not open write-ahead log file \"%s\": %m", path))); + errmsg("could not open file \"%s\": %m", path))); return fd; } @@ -3758,7 +3758,7 @@ XLogFileClose(void) if (close(openLogFile)) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not close log file %s: %m", + errmsg("could not close file \"%s\": %m", XLogFileNameP(ThisTimeLineID, openLogSegNo)))); openLogFile = -1; } @@ -4092,7 +4092,7 @@ RemoveXlogFile(const char *segname, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr) { ereport(LOG, (errcode_for_file_access(), - errmsg("could not rename old write-ahead log file \"%s\": %m", + errmsg("could not rename file \"%s\": %m", path))); return; } @@ -4502,7 +4502,7 @@ WriteControlFile(void) if (fd < 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not create control file \"%s\": %m", + errmsg("could not create file \"%s\": %m", XLOG_CONTROL_FILE))); errno = 0; @@ -4514,7 +4514,8 @@ WriteControlFile(void) errno = ENOSPC; ereport(PANIC, (errcode_for_file_access(), - errmsg("could not write to control file: %m"))); + errmsg("could not write to file \"%s\": %m", + XLOG_CONTROL_FILE))); } pgstat_report_wait_end(); @@ -4522,13 +4523,15 @@ WriteControlFile(void) if (pg_fsync(fd) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fsync control file: %m"))); + errmsg("could not fsync file \"%s\": %m", + XLOG_CONTROL_FILE))); pgstat_report_wait_end(); if (close(fd)) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not close control file: %m"))); + errmsg("could not close file \"%s\": %m", + XLOG_CONTROL_FILE))); } static void @@ -4758,8 +4761,7 @@ UpdateControlFile(void) if (fd < 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not open control file \"%s\": %m", - XLOG_CONTROL_FILE))); + errmsg("could not open file \"%s\": %m", XLOG_CONTROL_FILE))); errno = 0; pgstat_report_wait_start(WAIT_EVENT_CONTROL_FILE_WRITE_UPDATE); @@ -4770,7 +4772,8 @@ UpdateControlFile(void) errno = ENOSPC; ereport(PANIC, (errcode_for_file_access(), - errmsg("could not write to control file: %m"))); + errmsg("could not write to file \"%s\": %m", + XLOG_CONTROL_FILE))); } pgstat_report_wait_end(); @@ -4778,13 +4781,15 @@ UpdateControlFile(void) if (pg_fsync(fd) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fsync control file: %m"))); + errmsg("could not fsync file \"%s\": %m", + XLOG_CONTROL_FILE))); pgstat_report_wait_end(); if (close(fd)) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not close control file: %m"))); + errmsg("could not close file \"%s\": %m", + XLOG_CONTROL_FILE))); } /* @@ -5684,7 +5689,7 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog) if (close(fd)) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not close log file %s: %m", + errmsg("could not close file \"%s\": %m", XLogFileNameP(ThisTimeLineID, startLogSegNo)))); } @@ -10232,7 +10237,7 @@ assign_xlog_sync_method(int new_sync_method, void *extra) if (pg_fsync(openLogFile) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fsync log segment %s: %m", + errmsg("could not fsync file \"%s\": %m", XLogFileNameP(ThisTimeLineID, openLogSegNo)))); pgstat_report_wait_end(); if (get_sync_bit(sync_method) != get_sync_bit(new_sync_method)) @@ -10258,7 +10263,7 @@ issue_xlog_fsync(int fd, XLogSegNo segno) if (pg_fsync_no_writethrough(fd) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fsync log file %s: %m", + errmsg("could not fsync file \"%s\": %m", XLogFileNameP(ThisTimeLineID, segno)))); break; #ifdef HAVE_FSYNC_WRITETHROUGH @@ -10266,7 +10271,7 @@ issue_xlog_fsync(int fd, XLogSegNo segno) if (pg_fsync_writethrough(fd) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fsync write-through log file %s: %m", + errmsg("could not fsync write-through file \"%s\": %m", XLogFileNameP(ThisTimeLineID, segno)))); break; #endif @@ -10275,7 +10280,7 @@ issue_xlog_fsync(int fd, XLogSegNo segno) if (pg_fdatasync(fd) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fdatasync log file %s: %m", + errmsg("could not fdatasync file \"%s\": %m", XLogFileNameP(ThisTimeLineID, segno)))); break; #endif diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c index ef85c9af4c..a242e0be88 100644 --- a/src/bin/pg_basebackup/pg_recvlogical.c +++ b/src/bin/pg_basebackup/pg_recvlogical.c @@ -197,7 +197,7 @@ OutputFsync(TimestampTz now) if (fsync(outfd) != 0) { fprintf(stderr, - _("%s: could not fsync log file \"%s\": %s\n"), + _("%s: could not fsync file \"%s\": %s\n"), progname, outfile, strerror(errno)); return false; }
signature.asc
Description: PGP signature