From 7f53057ae713083f35b8c30ba01eede61f33adf3 Mon Sep 17 00:00:00 2001 From: chan Date: Fri, 26 Jun 2026 16:38:53 +0900 Subject: [PATCH 1/2] fix(pgsql): classify backend error severity from non-localized field fill_error_info() classified the severity of a backend error from PG_DIAG_SEVERITY, which the backend localizes via lc_messages. With a non-English backend (e.g. lc_messages=Korean) the value is not "ERROR"/"FATAL"/..., so identify_error_severity() returns ERRSEVERITY_UNKNOWN_SEVERITY, is_error_present() returns false, and the assert(is_error_present()) in PgSQL_Connection.cpp aborts the whole process on every erroring query. Classify from PG_DIAG_SEVERITY_NONLOCALIZED (as already done for the wire 'V' field), falling back to PG_DIAG_SEVERITY for servers older than 9.6. The localized PG_DIAG_SEVERITY is still forwarded to the client unchanged in the 'S' field. --- lib/PgSQL_Error_Helper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/PgSQL_Error_Helper.cpp b/lib/PgSQL_Error_Helper.cpp index 7b172ebf3c..2ac01ae50a 100644 --- a/lib/PgSQL_Error_Helper.cpp +++ b/lib/PgSQL_Error_Helper.cpp @@ -447,7 +447,8 @@ void PgSQL_Error_Helper::fill_error_info(PgSQL_ErrorInfo& err_info, const PGresu } const char* sqlstate = PQresultErrorField(result, PG_DIAG_SQLSTATE); const char* message = PQresultErrorField(result, PG_DIAG_MESSAGE_PRIMARY); - const char* severity = PQresultErrorField(result, PG_DIAG_SEVERITY); + const char* severity = PQresultErrorField(result, PG_DIAG_SEVERITY_NONLOCALIZED); + if (severity == nullptr) severity = PQresultErrorField(result, PG_DIAG_SEVERITY); fill_error_info(err_info, sqlstate ? sqlstate : "00000", message ? message : "", severity ? severity : ""); fill_extended_error_info(err_info, result, ext_fields); } From 9b101695a6727401953f6f2f3e30e8da73cb2de4 Mon Sep 17 00:00:00 2001 From: chan Date: Mon, 29 Jun 2026 12:40:59 +0900 Subject: [PATCH 2/2] fix(pgsql): apply non-localized severity fallback to extended error text fill_extended_error_info() read the severity for ext_info->text from PG_DIAG_SEVERITY_NONLOCALIZED only, while fill_error_info() falls back to the localized PG_DIAG_SEVERITY when the non-localized field is absent (PostgreSQL < 9.6). Apply the same fallback here so both severity paths stay consistent and ext_info->text is classified correctly on pre-9.6 backends. --- lib/PgSQL_Error_Helper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/PgSQL_Error_Helper.cpp b/lib/PgSQL_Error_Helper.cpp index 2ac01ae50a..de748129b0 100644 --- a/lib/PgSQL_Error_Helper.cpp +++ b/lib/PgSQL_Error_Helper.cpp @@ -367,6 +367,7 @@ void PgSQL_Error_Helper::fill_extended_error_info(PgSQL_ErrorInfo& err_info, con if (ext_fields & PGSQL_ERROR_FIELD_TEXT) { val = PQresultErrorField(result, PG_DIAG_SEVERITY_NONLOCALIZED); + if (val == nullptr) val = PQresultErrorField(result, PG_DIAG_SEVERITY); err_info.ext_info->text = identify_error_severity(val ? val : ""); }