Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d6e98eb

Browse files
committed
Improve some error message strings and errcodes
This makes a bit less work for translators, by unifying error strings a bit more with what the rest of the code does, this time for three error strings in autoprewarm and one in base backup code. After some code review of slot.c, some file-access errcodes are reported but lead to an incorrect internal error, while corrupted data makes the most sense, similarly to the previous work done in e41d0a1. Also, after calling rmtree(), a WARNING gets reported, which is a duplicate of what the internal call report, so make the code more consistent with all other code paths calling this function. Author: Michael Paquier Discussion: https://postgr.es/m/20180902200747.GC1343@paquier.xyz
1 parent 17b7c30 commit d6e98eb

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

contrib/pg_prewarm/autoprewarm.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
641641
errno = save_errno;
642642
ereport(ERROR,
643643
(errcode_for_file_access(),
644-
errmsg("could not write to file \"%s\" : %m",
644+
errmsg("could not write to file \"%s\": %m",
645645
transient_dump_file_path)));
646646
}
647647

@@ -664,7 +664,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
664664
errno = save_errno;
665665
ereport(ERROR,
666666
(errcode_for_file_access(),
667-
errmsg("could not write to file \"%s\" : %m",
667+
errmsg("could not write to file \"%s\": %m",
668668
transient_dump_file_path)));
669669
}
670670
}
@@ -684,7 +684,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
684684
errno = save_errno;
685685
ereport(ERROR,
686686
(errcode_for_file_access(),
687-
errmsg("could not close file \"%s\" : %m",
687+
errmsg("could not close file \"%s\": %m",
688688
transient_dump_file_path)));
689689
}
690690

src/backend/replication/basebackup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ perform_base_backup(basebackup_options *opt)
333333
if (lstat(XLOG_CONTROL_FILE, &statbuf) != 0)
334334
ereport(ERROR,
335335
(errcode_for_file_access(),
336-
errmsg("could not stat control file \"%s\": %m",
336+
errmsg("could not stat file \"%s\": %m",
337337
XLOG_CONTROL_FILE)));
338338
sendFile(XLOG_CONTROL_FILE, XLOG_CONTROL_FILE, &statbuf, false);
339339
}

src/backend/replication/slot.c

+8-9
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,7 @@ ReplicationSlotDropPtr(ReplicationSlot *slot)
628628
*/
629629
if (!rmtree(tmppath, true))
630630
ereport(WARNING,
631-
(errcode_for_file_access(),
632-
errmsg("could not remove directory \"%s\"", tmppath)));
631+
(errmsg("could not remove directory \"%s\"", tmppath)));
633632

634633
/*
635634
* We release this at the very end, so that nobody starts trying to create
@@ -1132,8 +1131,8 @@ StartupReplicationSlots(void)
11321131
if (!rmtree(path, true))
11331132
{
11341133
ereport(WARNING,
1135-
(errcode_for_file_access(),
1136-
errmsg("could not remove directory \"%s\"", path)));
1134+
(errmsg("could not remove directory \"%s\"",
1135+
path)));
11371136
continue;
11381137
}
11391138
fsync_fname("pg_replslot", true);
@@ -1432,21 +1431,21 @@ RestoreSlotFromDisk(const char *name)
14321431
/* verify magic */
14331432
if (cp.magic != SLOT_MAGIC)
14341433
ereport(PANIC,
1435-
(errcode_for_file_access(),
1434+
(errcode(ERRCODE_DATA_CORRUPTED),
14361435
errmsg("replication slot file \"%s\" has wrong magic number: %u instead of %u",
14371436
path, cp.magic, SLOT_MAGIC)));
14381437

14391438
/* verify version */
14401439
if (cp.version != SLOT_VERSION)
14411440
ereport(PANIC,
1442-
(errcode_for_file_access(),
1441+
(errcode(ERRCODE_DATA_CORRUPTED),
14431442
errmsg("replication slot file \"%s\" has unsupported version %u",
14441443
path, cp.version)));
14451444

14461445
/* boundary check on length */
14471446
if (cp.length != ReplicationSlotOnDiskV2Size)
14481447
ereport(PANIC,
1449-
(errcode_for_file_access(),
1448+
(errcode(ERRCODE_DATA_CORRUPTED),
14501449
errmsg("replication slot file \"%s\" has corrupted length %u",
14511450
path, cp.length)));
14521451

@@ -1496,8 +1495,8 @@ RestoreSlotFromDisk(const char *name)
14961495
if (!rmtree(slotdir, true))
14971496
{
14981497
ereport(WARNING,
1499-
(errcode_for_file_access(),
1500-
errmsg("could not remove directory \"%s\"", slotdir)));
1498+
(errmsg("could not remove directory \"%s\"",
1499+
slotdir)));
15011500
}
15021501
fsync_fname("pg_replslot", true);
15031502
return;

0 commit comments

Comments
 (0)