Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgwire: improve multiple portal error msgs #40197

Merged
merged 1 commit into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/sql/distsql_running.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ func (r *DistSQLReceiver) Push(
var (
// ErrLimitedResultNotSupported is an error produced by pgwire
// indicating an unsupported feature of row count limits was attempted.
ErrLimitedResultNotSupported = unimplemented.NewWithIssue(4035, "execute row count limits only partially supported")
ErrLimitedResultNotSupported = unimplemented.NewWithIssue(40195, "multiple active portals not supported")
// ErrLimitedResultClosed is a sentinel error produced by pgwire
// indicating the portal should be closed without error.
ErrLimitedResultClosed = errors.New("row count limit closed")
Expand Down
10 changes: 7 additions & 3 deletions pkg/sql/pgwire/command_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ func (r *limitedCommandResult) moreResultsNeeded(ctx context.Context) error {
// the cleanup. We are in effect peeking to see if the
// next message is a delete portal.
if c.Type != pgwirebase.PreparePortal || c.Name != r.portalName {
return errors.WithDetail(sql.ErrLimitedResultNotSupported, "portals must be executed to completion")
return errors.WithDetail(sql.ErrLimitedResultNotSupported,
"cannot close a portal while a different one is open")
}
r.typ = noCompletionMsg
// Rewind to before the delete so the AdvanceOne in
Expand All @@ -417,7 +418,8 @@ func (r *limitedCommandResult) moreResultsNeeded(ctx context.Context) error {
case sql.ExecPortal:
// The happy case: the client wants more rows from the portal.
if c.Name != r.portalName {
return errors.WithDetail(sql.ErrLimitedResultNotSupported, "portals must be executed to completion")
return errors.WithDetail(sql.ErrLimitedResultNotSupported,
"cannot execute a portal while a different one is open")
}
r.limit = c.Limit
// In order to get the correct command tag, we need to reset the seen rows.
Expand All @@ -436,7 +438,9 @@ func (r *limitedCommandResult) moreResultsNeeded(ctx context.Context) error {
}
default:
// We got some other message, but we only support executing to completion.
return errors.WithDetail(sql.ErrLimitedResultNotSupported, "portals must be executed to completion")
return errors.WithSafeDetails(sql.ErrLimitedResultNotSupported,
"cannot perform operation %T while a different portal is open",
errors.Safe(c))
}
prevPos = curPos
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/pgwire/testdata/pgtest/portals_crbugs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ReadyForQuery
{"Type":"BindComplete"}
{"Type":"DataRow","Values":[{"text":"1"}]}
{"Type":"PortalSuspended"}
{"Type":"ErrorResponse","Code":"0A000","Message":"unimplemented: execute row count limits only partially supported"}
{"Type":"ErrorResponse","Code":"0A000","Message":"unimplemented: multiple active portals not supported"}
{"Type":"ReadyForQuery","TxStatus":"E"}
{"Type":"ReadyForQuery","TxStatus":"E"}

Expand Down Expand Up @@ -67,7 +67,7 @@ ReadyForQuery
{"Type":"BindComplete"}
{"Type":"DataRow","Values":[{"text":"1"}]}
{"Type":"PortalSuspended"}
{"Type":"ErrorResponse","Code":"0A000","Message":"unimplemented: execute row count limits only partially supported"}
{"Type":"ErrorResponse","Code":"0A000","Message":"unimplemented: multiple active portals not supported"}
{"Type":"ReadyForQuery","TxStatus":"E"}

send
Expand Down