> > > Some of them are, yes. However, they are also worded with the same > format as some of the legit cases. So they don't add any extra > workload on the translation side as far as I recall, and I've been > fond of the errdetail part to get a consistent style across the board. > I'll double-check the whole a bit later, attached is the rest of them. > > Corey, any comments about these? >
The wordings are fine, and I'm sorry I didn't word them as complete sentences from the get-go. Attached is a follow-on to Michael's most recent uncommitted patch, changing the errors that I see as "impossible" to elogs. However, I agree that they don't add significant workload to the translations, and most input functions need to avoid any hard error returns lest they be called in a soft-error context.
From 9e7c703eb0ed04dde25a2a6e189f21e916e581bc Mon Sep 17 00:00:00 2001 From: Corey Huinker <[email protected]> Date: Fri, 5 Dec 2025 00:24:02 -0500 Subject: [PATCH v1 2/2] Change impossible conditions to elogs. --- src/backend/utils/adt/pg_dependencies.c | 14 ++++++-------- src/backend/utils/adt/pg_ndistinct.c | 7 +++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/backend/utils/adt/pg_dependencies.c b/src/backend/utils/adt/pg_dependencies.c index 1552e03d1c1..7375e8498c5 100644 --- a/src/backend/utils/adt/pg_dependencies.c +++ b/src/backend/utils/adt/pg_dependencies.c @@ -326,10 +326,9 @@ dependencies_array_end(void *state) * This can only happen if a case was missed in * dependencies_array_start(). */ - errsave(parse->escontext, - errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed pg_dependencies: \"%s\"", parse->str), - errdetail("Array has been found at an unexpected location.")); + elog(ERROR, + "pg_dependencies array end encountered in unexpected parse state: %d.", + (int) parse->state); break; } return JSON_SEM_ACTION_FAILED; @@ -443,10 +442,9 @@ dependencies_array_element_start(void *state, bool isnull) break; default: - errsave(parse->escontext, - errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed pg_dependencies: \"%s\"", parse->str), - errdetail("Unexpected array element has been found.")); + elog(ERROR, + "pg_dependencies array element encountered in unexpected parse state: %d.", + (int) parse->state); break; } diff --git a/src/backend/utils/adt/pg_ndistinct.c b/src/backend/utils/adt/pg_ndistinct.c index 9bf1546c803..718d161ec41 100644 --- a/src/backend/utils/adt/pg_ndistinct.c +++ b/src/backend/utils/adt/pg_ndistinct.c @@ -286,10 +286,9 @@ ndistinct_array_end(void *state) * This can only happen if a case was missed in * ndistinct_array_start(). */ - errsave(parse->escontext, - errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed pg_ndistinct: \"%s\"", parse->str), - errdetail("Array has been found at an unexpected location.")); + elog(ERROR, + "pg_ndistinct array element encountered in unexpected parse state: %d.", + (int) parse->state); break; } -- 2.52.0
