Skip to content

Commit

Permalink
Merge pull request #88242 from yuzefovich/backport22.1-88182
Browse files Browse the repository at this point in the history
release-22.1: sql: fix relocate commands with NULLs
  • Loading branch information
yuzefovich authored Sep 20, 2022
2 parents de459ce + 1b986a5 commit 32e459b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Binary file modified pkg/sql/logictest/testdata/logic_test/ranges
Binary file not shown.
11 changes: 10 additions & 1 deletion pkg/sql/relocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ func (n *relocateNode) Next(params runParams) (bool, error) {
var relocationTargets []roachpb.ReplicationTarget
var leaseStoreID roachpb.StoreID
if n.subjectReplicas == tree.RelocateLease {
leaseStoreID = roachpb.StoreID(tree.MustBeDInt(data[0]))
if !data[0].ResolvedType().Equivalent(types.Int) {
return false, errors.Errorf(
"expected int in the first EXPERIMENTAL_RELOCATE data column; got %s",
data[0].ResolvedType(),
)
}
leaseStoreID = roachpb.StoreID(*data[0].(*tree.DInt))
if leaseStoreID <= 0 {
return false, errors.Errorf("invalid target leaseholder store ID %d for EXPERIMENTAL_RELOCATE LEASE", leaseStoreID)
}
Expand All @@ -86,6 +92,9 @@ func (n *relocateNode) Next(params runParams) (bool, error) {
// Create an array of the desired replication targets.
relocationTargets = make([]roachpb.ReplicationTarget, len(relocation.Array))
for i, d := range relocation.Array {
if d == tree.DNull {
return false, errors.Errorf("NULL value in relocation array for EXPERIMENTAL_RELOCATE")
}
storeID := roachpb.StoreID(*d.(*tree.DInt))
nodeID, ok := n.run.storeMap[storeID]
if !ok {
Expand Down

0 comments on commit 32e459b

Please sign in to comment.