summaryrefslogtreecommitdiff
path: root/src/backend/backup
diff options
context:
space:
mode:
authorMichael Paquier2024-07-04 00:48:40 +0000
committerMichael Paquier2024-07-04 00:48:40 +0000
commitb81a71aa05f294705e1b1d4fe24548f175f9bfe9 (patch)
tree8d1c94fdfd570891b7b2e5b7f079eaf252e018b8 /src/backend/backup
parent6897f0ec024582a570868939d3f34a6853374723 (diff)
Assign error codes where missing for user-facing failures
All the errors triggered in the code paths patched here would cause the backend to issue an internal_error errcode, which is a state that should be used only for "can't happen" situations. However, these code paths are reachable by the regression tests, and could be seen by users in valid cases. Some regression tests expect internal errcodes as they manipulate the backend state to cause corruption (like checksums), or use elog() because it is more convenient (like injection points), these have no need to change. This reduces the number of internal failures triggered in a check-world by more than half, while providing correct errcodes for these valid cases. Reviewed-by: Robert Haas Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/backup')
-rw-r--r--src/backend/backup/basebackup.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/backup/basebackup.c b/src/backend/backup/basebackup.c
index 9a2bf59e84e..01b35e26bda 100644
--- a/src/backend/backup/basebackup.c
+++ b/src/backend/backup/basebackup.c
@@ -2045,12 +2045,14 @@ _tarWriteHeader(bbsink *sink, const char *filename, const char *linktarget,
break;
case TAR_NAME_TOO_LONG:
ereport(ERROR,
- (errmsg("file name too long for tar format: \"%s\"",
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("file name too long for tar format: \"%s\"",
filename)));
break;
case TAR_SYMLINK_TOO_LONG:
ereport(ERROR,
- (errmsg("symbolic link target too long for tar format: "
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("symbolic link target too long for tar format: "
"file name \"%s\", target \"%s\"",
filename, linktarget)));
break;