Skip to content

fix(pg-protocol): expose severity field V as severityNonLocalized - #3833

Open
princejain756 wants to merge 1 commit into
brianc:masterfrom
princejain756:fix-protocol-severity-nonlocalized
Open

princejain756 wants to merge 1 commit into
brianc:masterfrom
princejain756:fix-protocol-severity-nonlocalized

Conversation

@princejain756

Copy link
Copy Markdown

PostgreSQL sends severity twice in ErrorResponse/NoticeResponse: S localized per lc_messages, and V never localized (9.6+). parseErrorMessage already reads V into the field map but drops it, so on a localized server nothing on the error carries a comparable severity - a Russian FATAL arrives as ВАЖНО.

// server with lc_messages = 'ru_RU.UTF-8' sending S='ВАЖНО', V='FATAL'
err.severity // "ВАЖНО"
err.severityNonLocalized // "FATAL" (new)

DatabaseError and NoticeMessage now expose V as severityNonLocalized, absent for pre-9.6 servers. severity keeps its current value so nothing changes for users comparing it today. The name follows libpq's PG_DIAG_SEVERITY_NONLOCALIZED; happy to rename if you prefer something else.

Fixes #3827

The V field holds the never-localized severity, while S is translated
per lc_messages. The parser already read V into the field map but kept
only S, so on a localized server nothing on the error object carried a
severity a client could compare (a Russian FATAL arrives as "ВАЖНО").
Errors and notices now expose it beside severity.

Fixes brianc#3827
@princejain756

Copy link
Copy Markdown
Author

Thanks for the review, @charmander!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DatabaseError.severity is the server's translated severity; the untranslated V field is parsed and dropped

2 participants