From 8590ff9bd900a250073be9d5148c7b97f05d1394 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Wed, 6 Jul 2022 15:23:35 -0400 Subject: [PATCH] pgwire: use better error for invalid Describe message Release note: None --- pkg/sql/conn_executor_prepare.go | 6 ++++-- pkg/sql/pgwire/testdata/pgtest/portals | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/sql/conn_executor_prepare.go b/pkg/sql/conn_executor_prepare.go index 9ad93f4f8ad1..488f04596f84 100644 --- a/pkg/sql/conn_executor_prepare.go +++ b/pkg/sql/conn_executor_prepare.go @@ -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 } diff --git a/pkg/sql/pgwire/testdata/pgtest/portals b/pkg/sql/pgwire/testdata/pgtest/portals index 200fa2a950ab..21509f383ce5 100644 --- a/pkg/sql/pgwire/testdata/pgtest/portals +++ b/pkg/sql/pgwire/testdata/pgtest/portals @@ -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"}