Skip to content

Commit

Permalink
pgwire: use better error for invalid Describe message
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
rafiss committed Jul 12, 2022
1 parent eb641a5 commit 8590ff9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/sql/conn_executor_prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,10 @@ func (ex *connExecutor) execDescribe(
res.SetPortalOutput(ctx, portal.Stmt.Columns, portal.OutFormats)
}
default:
return retErr(errors.AssertionFailedf(
"unknown describe type: %s", errors.Safe(descCmd.Type)))
return retErr(pgerror.Newf(
pgcode.ProtocolViolation,
"invalid DESCRIBE message subtype %d", errors.Safe(byte(descCmd.Type)),
))
}
return nil, nil
}
16 changes: 16 additions & 0 deletions pkg/sql/pgwire/testdata/pgtest/portals
Original file line number Diff line number Diff line change
Expand Up @@ -998,3 +998,19 @@ ReadyForQuery
----
{"Type":"CommandComplete","CommandTag":"ROLLBACK"}
{"Type":"ReadyForQuery","TxStatus":"I"}

send
Parse {"Query": "SELECT * FROM generate_series(1, 4)"}
Describe
Bind
Execute
Sync
----

until keepErrMessage
ErrorResponse
ReadyForQuery
----
{"Type":"ParseComplete"}
{"Type":"ErrorResponse","Code":"08P01","Message":"invalid DESCRIBE message subtype 0"}
{"Type":"ReadyForQuery","TxStatus":"I"}

0 comments on commit 8590ff9

Please sign in to comment.