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

sql: properly wrap some errors #66452

Merged
merged 1 commit into from
Jun 15, 2021
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/alter_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ func (p *planner) updateFKBackReferenceName(
} else {
lookup, err := p.Descriptors().GetMutableTableVersionByID(ctx, ref.ReferencedTableID, p.txn)
if err != nil {
return errors.Errorf("error resolving referenced table ID %d: %v", ref.ReferencedTableID, err)
return errors.Wrapf(err, "error resolving referenced table ID %d", ref.ReferencedTableID)
}
referencedTableDesc = lookup
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ func runSchemaChangesInTxn(
} else {
lookup, err := planner.Descriptors().GetMutableTableVersionByID(ctx, fk.ReferencedTableID, planner.Txn())
if err != nil {
return errors.Errorf("error resolving referenced table ID %d: %v", fk.ReferencedTableID, err)
return errors.Wrapf(err, "error resolving referenced table ID %d", fk.ReferencedTableID)
}
referencedTableDesc = lookup
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/conn_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func (s *Server) GetUnscrubbedStmtStats(
s.sqlStats.IterateStatementStats(ctx, &sqlstats.IteratorOptions{}, stmtStatsVisitor)

if err != nil {
return nil, errors.Errorf("failed to fetch statement stats: %s", err)
return nil, errors.Wrap(err, "failed to fetch statement stats")
}

return stmtStats, nil
Expand All @@ -459,7 +459,7 @@ func (s *Server) GetUnscrubbedTxnStats(
s.sqlStats.IterateTransactionStats(ctx, &sqlstats.IteratorOptions{}, txnStatsVisitor)

if err != nil {
return nil, errors.Errorf("failed to fetch statement stats: %s", err)
return nil, errors.Wrap(err, "failed to fetch statement stats")
}

return txnStats, nil
Expand Down Expand Up @@ -509,7 +509,7 @@ func (s *Server) getScrubbedStmtStats(
statsProvider.IterateStatementStats(ctx, &sqlstats.IteratorOptions{}, stmtStatsVisitor)

if err != nil {
return nil, errors.Errorf("failed to fetch scrubbed statement stats: %s", err)
return nil, errors.Wrap(err, "failed to fetch scrubbed statement stats")
}

return scrubbedStats, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/drop_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func (p *planner) removeFKForBackReference(
} else {
lookup, err := p.Descriptors().GetMutableTableVersionByID(ctx, ref.OriginTableID, p.txn)
if err != nil {
return errors.Errorf("error resolving origin table ID %d: %v", ref.OriginTableID, err)
return errors.Wrapf(err, "error resolving origin table ID %d", ref.OriginTableID)
}
originTableDesc = lookup
}
Expand Down Expand Up @@ -607,7 +607,7 @@ func (p *planner) removeFKBackReference(
} else {
lookup, err := p.Descriptors().GetMutableTableVersionByID(ctx, ref.ReferencedTableID, p.txn)
if err != nil {
return errors.Errorf("error resolving referenced table ID %d: %v", ref.ReferencedTableID, err)
return errors.Wrapf(err, "error resolving referenced table ID %d", ref.ReferencedTableID)
}
referencedTableDesc = lookup
}
Expand Down Expand Up @@ -663,7 +663,7 @@ func (p *planner) removeInterleaveBackReference(
} else {
lookup, err := p.Descriptors().GetMutableTableVersionByID(ctx, ancestor.TableID, p.txn)
if err != nil {
return errors.Errorf("error resolving referenced table ID %d: %v", ancestor.TableID, err)
return errors.Wrapf(err, "error resolving referenced table ID %d", ancestor.TableID)
}
t = lookup
}
Expand Down