Skip to content

Commit

Permalink
Merge pull request #119990 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-23.1.17-rc-119986

release-23.1.17-rc: sql: enhance error messages on validation of rows in virtual tables (#119990)

Co-Authored-By: Yahor Yuzefovich <yahor@cockroachlabs.com>
  • Loading branch information
yuzefovich and yuzefovich committed Mar 7, 2024
2 parents 52968ea + e85748b commit c2c2a20
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/sql/virtual_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/iterutil"
"github.com/cockroachdb/cockroach/pkg/util/stop"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/redact"
)

const virtualSchemaNotImplementedMessage = "virtual schema table not implemented: %s.%s"
Expand Down Expand Up @@ -597,15 +598,18 @@ func (e *virtualDefEntry) validateRow(datums tree.Datums, columns colinfo.Result
}
for i := range columns {
col := &columns[i]
// Names of virtual tables and columns in them don't contain any PII, so
// we can always mark them safe for redaction.
colName := redact.SafeString(col.Name)
datum := datums[i]
if datum == tree.DNull {
if !e.desc.PublicColumns()[i].IsNullable() {
return errors.AssertionFailedf("column %s.%s not nullable, but found NULL value",
e.desc.GetName(), col.Name)
redact.SafeString(e.desc.GetName()), colName)
}
} else if !datum.ResolvedType().Equivalent(col.Typ) {
return errors.AssertionFailedf("datum column %q expected to be type %s; found type %s",
col.Name, col.Typ, datum.ResolvedType())
colName, col.Typ.SQLStringForError(), datum.ResolvedType().SQLStringForError())
}
}
return nil
Expand Down

0 comments on commit c2c2a20

Please sign in to comment.