From bff5bb372657fb362bd62815104164aae7610b43 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Wed, 6 Jul 2022 19:23:35 +0000 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 | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/pkg/sql/conn_executor_prepare.go b/pkg/sql/conn_executor_prepare.go index 2da1e78528cd..f6bb0e0c5104 100644 --- a/pkg/sql/conn_executor_prepare.go +++ b/pkg/sql/conn_executor_prepare.go @@ -599,8 +599,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 8f641e91fe46..55c0595da6df 100644 --- a/pkg/sql/pgwire/testdata/pgtest/portals +++ b/pkg/sql/pgwire/testdata/pgtest/portals @@ -1460,3 +1460,29 @@ ReadyForQuery {"Type":"DataRow","Values":[{"text":"2"}]} {"Type":"CommandComplete","CommandTag":"FETCH 2"} {"Type":"ReadyForQuery","TxStatus":"T"} + +send +Query {"String": "ROLLBACK"} +---- + +until +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"}