Skip to content

Commit

Permalink
sql: don't panic on unexpected null in kvfetcher
Browse files Browse the repository at this point in the history
Closes #35083

Release note: None
  • Loading branch information
asubiotto committed Feb 28, 2019
1 parent e880fe6 commit 4ffe666
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/sql/sqlbase/rowfetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/internal/client"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/scrub"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/storage/engine"
Expand Down Expand Up @@ -1238,16 +1239,15 @@ func (rf *RowFetcher) finalizeRow() error {
indexColValues = append(indexColValues, "?")
}
}
if rf.isCheck {
return scrub.WrapError(scrub.UnexpectedNullValueError, errors.Errorf(
"Non-nullable column \"%s:%s\" with no value! Index scanned was %q with the index key columns (%s) and the values (%s)",
table.desc.Name, table.cols[i].Name, table.index.Name,
strings.Join(table.index.ColumnNames, ","), strings.Join(indexColValues, ",")))
}
panic(fmt.Sprintf(
err := pgerror.NewAssertionErrorf(
"Non-nullable column \"%s:%s\" with no value! Index scanned was %q with the index key columns (%s) and the values (%s)",
table.desc.Name, table.cols[i].Name, table.index.Name,
strings.Join(table.index.ColumnNames, ","), strings.Join(indexColValues, ",")))
strings.Join(table.index.ColumnNames, ","), strings.Join(indexColValues, ","))

if rf.isCheck {
return scrub.WrapError(scrub.UnexpectedNullValueError, err)
}
return err
}
table.row[i] = EncDatum{
Datum: tree.DNull,
Expand Down

0 comments on commit 4ffe666

Please sign in to comment.