Skip to content

Commit

Permalink
sql, pgwire: Add SEVERITY_NONLOCALIZED error field
Browse files Browse the repository at this point in the history
Release note (sql change): We now send the Severity_Nonlocalized field
in the pgwire Notice Response.
  • Loading branch information
e-mbrown committed Jun 9, 2022
1 parent e9456ba commit ea6ded2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
3 changes: 3 additions & 0 deletions pkg/sql/pgwire/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,9 @@ func writeErrFields(
msgBuilder.putErrFieldMsg(pgwirebase.ServerErrFieldSeverity)
msgBuilder.writeTerminatedString(pgErr.Severity)

msgBuilder.putErrFieldMsg(pgwirebase.ServerErrFieldSeverityNonLocalized)
msgBuilder.writeTerminatedString(pgErr.Severity)

msgBuilder.putErrFieldMsg(pgwirebase.ServerErrFieldSQLState)
msgBuilder.writeTerminatedString(pgErr.Code)

Expand Down
19 changes: 10 additions & 9 deletions pkg/sql/pgwire/pgwirebase/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ type ServerErrFieldType byte

// http://www.postgresql.org/docs/current/static/protocol-error-fields.html
const (
ServerErrFieldSeverity ServerErrFieldType = 'S'
ServerErrFieldSQLState ServerErrFieldType = 'C'
ServerErrFieldMsgPrimary ServerErrFieldType = 'M'
ServerErrFieldDetail ServerErrFieldType = 'D'
ServerErrFieldHint ServerErrFieldType = 'H'
ServerErrFieldSrcFile ServerErrFieldType = 'F'
ServerErrFieldSrcLine ServerErrFieldType = 'L'
ServerErrFieldSrcFunction ServerErrFieldType = 'R'
ServerErrFieldConstraintName ServerErrFieldType = 'n'
ServerErrFieldSeverity ServerErrFieldType = 'S'
ServerErrFieldSeverityNonLocalized ServerErrFieldType = 'V'
ServerErrFieldSQLState ServerErrFieldType = 'C'
ServerErrFieldMsgPrimary ServerErrFieldType = 'M'
ServerErrFieldDetail ServerErrFieldType = 'D'
ServerErrFieldHint ServerErrFieldType = 'H'
ServerErrFieldSrcFile ServerErrFieldType = 'F'
ServerErrFieldSrcLine ServerErrFieldType = 'L'
ServerErrFieldSrcFunction ServerErrFieldType = 'R'
ServerErrFieldConstraintName ServerErrFieldType = 'n'
)

// PrepareType represents a subtype for prepare messages.
Expand Down
8 changes: 6 additions & 2 deletions pkg/sql/pgwire/pgwirebase/servererrfieldtype_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/sql/pgwire/testdata/pgtest/notice
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Query {"String": "DROP INDEX t_x_idx"}
until crdb_only
CommandComplete
----
{"Severity":"NOTICE","SeverityUnlocalized":"","Code":"00000","Message":"the data for dropped indexes is reclaimed asynchronously","Detail":"","Hint":"The reclamation delay can be customized in the zone configuration for the table.","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"drop_index.go","Line":572,"Routine":"dropIndexByName","UnknownFields":null}
{"Severity":"NOTICE","SeverityUnlocalized":"NOTICE","Code":"00000","Message":"the data for dropped indexes is reclaimed asynchronously","Detail":"","Hint":"The reclamation delay can be customized in the zone configuration for the table.","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"drop_index.go","Line":572,"Routine":"dropIndexByName","UnknownFields":null}
{"Type":"CommandComplete","CommandTag":"DROP INDEX"}

until noncrdb_only
Expand Down

0 comments on commit ea6ded2

Please sign in to comment.