From c5c0035f882e5ac8268c350e0f7ebc595fb0faaa Mon Sep 17 00:00:00 2001 From: Marius Posta Date: Wed, 3 Feb 2021 11:28:46 -0500 Subject: [PATCH] sql: remove deprecated ForeachColumn-methods from TableDescriptor Previously, these methods would be called on a table descriptor interface to apply a function on *descpb.ColumnDescriptor for some subset of columns. This patch removes these calls, along with the method definitions, in favour of new methods which use the catalog.Column interface type instead. Fixes #59805. Release note: None --- pkg/sql/catalog/descriptor.go | 4 +- pkg/sql/catalog/schemaexpr/computed_column.go | 18 +- pkg/sql/catalog/tabledesc/structured.go | 29 --- pkg/sql/crdb_internal.go | 11 +- pkg/sql/indexbackfiller_test.go | 9 +- pkg/sql/information_schema.go | 201 +++++++++--------- pkg/sql/pg_catalog.go | 29 +-- pkg/sql/pg_extension.go | 19 +- pkg/sql/row/fetcher.go | 21 +- pkg/sql/rowenc/testutils.go | 16 +- 10 files changed, 165 insertions(+), 192 deletions(-) diff --git a/pkg/sql/catalog/descriptor.go b/pkg/sql/catalog/descriptor.go index d4bde2439b02..764cf6830a80 100644 --- a/pkg/sql/catalog/descriptor.go +++ b/pkg/sql/catalog/descriptor.go @@ -211,9 +211,7 @@ type TableDescriptor interface { FindColumnWithID(id descpb.ColumnID) (Column, error) FindColumnWithName(name tree.Name) (Column, error) - GetPublicColumns() []descpb.ColumnDescriptor // deprecated - ForeachPublicColumn(f func(col *descpb.ColumnDescriptor) error) error // deprecated - ForeachNonDropColumn(f func(col *descpb.ColumnDescriptor) error) error // deprecated + GetPublicColumns() []descpb.ColumnDescriptor // deprecated NamesForColumnIDs(ids descpb.ColumnIDs) ([]string, error) FindColumnByName(name tree.Name) (*descpb.ColumnDescriptor, bool, error) // deprecated FindActiveColumnByID(id descpb.ColumnID) (*descpb.ColumnDescriptor, error) // deprecated diff --git a/pkg/sql/catalog/schemaexpr/computed_column.go b/pkg/sql/catalog/schemaexpr/computed_column.go index 1081e5513e48..19a2c388e366 100644 --- a/pkg/sql/catalog/schemaexpr/computed_column.go +++ b/pkg/sql/catalog/schemaexpr/computed_column.go @@ -137,33 +137,33 @@ func (v *ComputedColumnValidator) Validate( // computed columns being added reference the given column. // TODO(mgartner): Add unit tests for ValidateNoDependents. func (v *ComputedColumnValidator) ValidateNoDependents(col *descpb.ColumnDescriptor) error { - checkComputed := func(c *descpb.ColumnDescriptor) error { + for _, c := range v.desc.NonDropColumnsNew() { if !c.IsComputed() { - return nil + continue } - expr, err := parser.ParseExpr(*c.ComputeExpr) + expr, err := parser.ParseExpr(c.GetComputeExpr()) if err != nil { // At this point, we should be able to parse the computed expression. return errors.WithAssertionFailure(err) } - return iterColDescriptors(v.desc, expr, func(colVar *descpb.ColumnDescriptor) error { + err = iterColDescriptors(v.desc, expr, func(colVar *descpb.ColumnDescriptor) error { if colVar.ID == col.ID { return pgerror.Newf( pgcode.InvalidColumnReference, "column %q is referenced by computed column %q", col.Name, - c.Name, + c.GetName(), ) } return nil }) + if err != nil { + return err + } } - - return v.desc.ForeachNonDropColumn(func(col *descpb.ColumnDescriptor) error { - return checkComputed(col) - }) + return nil } // MakeComputedExprs returns a slice of the computed expressions for the diff --git a/pkg/sql/catalog/tabledesc/structured.go b/pkg/sql/catalog/tabledesc/structured.go index 9ebd3e807e07..515ac4797b77 100644 --- a/pkg/sql/catalog/tabledesc/structured.go +++ b/pkg/sql/catalog/tabledesc/structured.go @@ -364,35 +364,6 @@ func (desc *wrapper) AllActiveAndInactiveForeignKeys() []*descpb.ForeignKeyConst return fks } -// ForeachPublicColumn runs a function on all public columns. -func (desc *wrapper) ForeachPublicColumn(f func(column *descpb.ColumnDescriptor) error) error { - for i := range desc.Columns { - if err := f(&desc.Columns[i]); err != nil { - return err - } - } - return nil -} - -// ForeachNonDropColumn runs a function on all public columns and columns -// currently being added. -func (desc *wrapper) ForeachNonDropColumn(f func(column *descpb.ColumnDescriptor) error) error { - if err := desc.ForeachPublicColumn(f); err != nil { - return err - } - - for i := range desc.Mutations { - mut := &desc.Mutations[i] - mutCol := mut.GetColumn() - if mut.Direction == descpb.DescriptorMutation_ADD && mutCol != nil { - if err := f(mutCol); err != nil { - return err - } - } - } - return nil -} - // ForeachDependedOnBy runs a function on all indexes, including those being // added in the mutations. func (desc *wrapper) ForeachDependedOnBy( diff --git a/pkg/sql/crdb_internal.go b/pkg/sql/crdb_internal.go index ae67e778e67b..54f68ceb5d98 100644 --- a/pkg/sql/crdb_internal.go +++ b/pkg/sql/crdb_internal.go @@ -2346,12 +2346,13 @@ CREATE TABLE crdb_internal.backward_dependencies ( } // Record sequence dependencies. - return table.ForeachPublicColumn(func(col *descpb.ColumnDescriptor) error { - for _, sequenceID := range col.UsesSequenceIds { + for _, col := range table.PublicColumnsNew() { + for i := 0; i < col.NumUsesSequences(); i++ { + sequenceID := col.GetUsesSequenceID(i) if err := addRow( tableID, tableName, tree.DNull, - tree.NewDInt(tree.DInt(col.ID)), + tree.NewDInt(tree.DInt(col.GetID())), tree.NewDInt(tree.DInt(sequenceID)), sequenceDep, tree.DNull, @@ -2361,8 +2362,8 @@ CREATE TABLE crdb_internal.backward_dependencies ( return err } } - return nil - }) + } + return nil }) }, } diff --git a/pkg/sql/indexbackfiller_test.go b/pkg/sql/indexbackfiller_test.go index 9724265d95f0..ac48a34bc79a 100644 --- a/pkg/sql/indexbackfiller_test.go +++ b/pkg/sql/indexbackfiller_test.go @@ -361,12 +361,11 @@ INSERT INTO foo VALUES (1), (10), (100); colIdxMap := table.ColumnIdxMap() var valsNeeded util.FastIntSet if idx.Primary() { - _ = table.ForeachPublicColumn(func(column *descpb.ColumnDescriptor) error { - if !column.Virtual { - valsNeeded.Add(colIdxMap.GetDefault(column.ID)) + for _, column := range table.PublicColumnsNew() { + if !column.IsVirtual() { + valsNeeded.Add(colIdxMap.GetDefault(column.GetID())) } - return nil - }) + } } else { _ = idx.ForEachColumnID(func(id descpb.ColumnID) error { valsNeeded.Add(colIdxMap.GetDefault(id)) diff --git a/pkg/sql/information_schema.go b/pkg/sql/information_schema.go index c599719d022e..6ce5f7741b1f 100755 --- a/pkg/sql/information_schema.go +++ b/pkg/sql/information_schema.go @@ -331,29 +331,30 @@ https://www.postgresql.org/docs/9.5/infoschema-check-constraints.html`, // NULL column constraints in information_schema.check_constraints. // Cockroach doesn't track these constraints as check constraints, // but we can pull them off of the table's column descriptors. - colNum := 0 - return table.ForeachPublicColumn(func(column *descpb.ColumnDescriptor) error { - colNum++ + for _, column := range table.PublicColumnsNew() { // Only visible, non-nullable columns are included. - if column.Hidden || column.Nullable { - return nil + if column.IsHidden() || column.IsNullable() { + continue } // Generate a unique name for each NOT NULL constraint. Postgres // uses the format ___not_null. // We might as well do the same. conNameStr := tree.NewDString(fmt.Sprintf( - "%s_%s_%d_not_null", h.NamespaceOid(db.GetID(), scName), tableOid(table.GetID()), colNum, + "%s_%s_%d_not_null", h.NamespaceOid(db.GetID(), scName), tableOid(table.GetID()), column.Ordinal()+1, )) chkExprStr := tree.NewDString(fmt.Sprintf( - "%s IS NOT NULL", column.Name, + "%s IS NOT NULL", column.GetName(), )) - return addRow( + if err := addRow( dbNameStr, // constraint_catalog scNameStr, // constraint_schema conNameStr, // constraint_name chkExprStr, // check_clause - ) - }) + ); err != nil { + return err + } + } + return nil }) }, } @@ -428,26 +429,26 @@ https://www.postgresql.org/docs/9.5/infoschema-columns.html`, ) error { dbNameStr := tree.NewDString(db.GetName()) scNameStr := tree.NewDString(scName) - return table.ForeachPublicColumn(func(column *descpb.ColumnDescriptor) error { + for _, column := range table.PublicColumnsNew() { collationCatalog := tree.DNull collationSchema := tree.DNull collationName := tree.DNull - if locale := column.Type.Locale(); locale != "" { + if locale := column.GetType().Locale(); locale != "" { collationCatalog = dbNameStr collationSchema = pgCatalogNameDString collationName = tree.NewDString(locale) } colDefault := tree.DNull - if column.DefaultExpr != nil { - colExpr, err := schemaexpr.FormatExprForDisplay(ctx, table, *column.DefaultExpr, &p.semaCtx, tree.FmtParsable) + if column.HasDefault() { + colExpr, err := schemaexpr.FormatExprForDisplay(ctx, table, column.GetDefaultExpr(), &p.semaCtx, tree.FmtParsable) if err != nil { return err } colDefault = tree.NewDString(colExpr) } colComputed := emptyString - if column.ComputeExpr != nil { - colExpr, err := schemaexpr.FormatExprForDisplay(ctx, table, *column.ComputeExpr, &p.semaCtx, tree.FmtSimple) + if column.IsComputed() { + colExpr, err := schemaexpr.FormatExprForDisplay(ctx, table, column.GetComputeExpr(), &p.semaCtx, tree.FmtSimple) if err != nil { return err } @@ -456,62 +457,66 @@ https://www.postgresql.org/docs/9.5/infoschema-columns.html`, // Match the comment belonging to current column from map,using table id and column id tableID := tree.DInt(table.GetID()) - columnID := tree.DInt(column.ID) + columnID := tree.DInt(column.GetID()) description := commentMap[tableID][columnID] - return addRow( - dbNameStr, // table_catalog - scNameStr, // table_schema - tree.NewDString(table.GetName()), // table_name - tree.NewDString(column.Name), // column_name - tree.NewDString(description), // column_comment + err := addRow( + dbNameStr, // table_catalog + scNameStr, // table_schema + tree.NewDString(table.GetName()), // table_name + tree.NewDString(column.GetName()), // column_name + tree.NewDString(description), // column_comment tree.NewDInt(tree.DInt(column.GetPGAttributeNum())), // ordinal_position - colDefault, // column_default - yesOrNoDatum(column.Nullable), // is_nullable - tree.NewDString(column.Type.InformationSchemaName()), // data_type - characterMaximumLength(column.Type), // character_maximum_length - characterOctetLength(column.Type), // character_octet_length - numericPrecision(column.Type), // numeric_precision - numericPrecisionRadix(column.Type), // numeric_precision_radix - numericScale(column.Type), // numeric_scale - datetimePrecision(column.Type), // datetime_precision - tree.DNull, // interval_type - tree.DNull, // interval_precision - tree.DNull, // character_set_catalog - tree.DNull, // character_set_schema - tree.DNull, // character_set_name - collationCatalog, // collation_catalog - collationSchema, // collation_schema - collationName, // collation_name - tree.DNull, // domain_catalog - tree.DNull, // domain_schema - tree.DNull, // domain_name - dbNameStr, // udt_catalog - pgCatalogNameDString, // udt_schema - tree.NewDString(column.Type.PGName()), // udt_name - tree.DNull, // scope_catalog - tree.DNull, // scope_schema - tree.DNull, // scope_name - tree.DNull, // maximum_cardinality - tree.DNull, // dtd_identifier - tree.DNull, // is_self_referencing - tree.DNull, // is_identity - tree.DNull, // identity_generation - tree.DNull, // identity_start - tree.DNull, // identity_increment - tree.DNull, // identity_maximum - tree.DNull, // identity_minimum - tree.DNull, // identity_cycle - yesOrNoDatum(column.IsComputed()), // is_generated - colComputed, // generation_expression + colDefault, // column_default + yesOrNoDatum(column.IsNullable()), // is_nullable + tree.NewDString(column.GetType().InformationSchemaName()), // data_type + characterMaximumLength(column.GetType()), // character_maximum_length + characterOctetLength(column.GetType()), // character_octet_length + numericPrecision(column.GetType()), // numeric_precision + numericPrecisionRadix(column.GetType()), // numeric_precision_radix + numericScale(column.GetType()), // numeric_scale + datetimePrecision(column.GetType()), // datetime_precision + tree.DNull, // interval_type + tree.DNull, // interval_precision + tree.DNull, // character_set_catalog + tree.DNull, // character_set_schema + tree.DNull, // character_set_name + collationCatalog, // collation_catalog + collationSchema, // collation_schema + collationName, // collation_name + tree.DNull, // domain_catalog + tree.DNull, // domain_schema + tree.DNull, // domain_name + dbNameStr, // udt_catalog + pgCatalogNameDString, // udt_schema + tree.NewDString(column.GetType().PGName()), // udt_name + tree.DNull, // scope_catalog + tree.DNull, // scope_schema + tree.DNull, // scope_name + tree.DNull, // maximum_cardinality + tree.DNull, // dtd_identifier + tree.DNull, // is_self_referencing + tree.DNull, // is_identity + tree.DNull, // identity_generation + tree.DNull, // identity_start + tree.DNull, // identity_increment + tree.DNull, // identity_maximum + tree.DNull, // identity_minimum + tree.DNull, // identity_cycle + yesOrNoDatum(column.IsComputed()), // is_generated + colComputed, // generation_expression yesOrNoDatum(table.IsTable() && !table.IsVirtualTable() && !column.IsComputed(), ), // is_updatable - yesOrNoDatum(column.Hidden), // is_hidden - tree.NewDString(column.Type.SQLString()), // crdb_sql_type + yesOrNoDatum(column.IsHidden()), // is_hidden + tree.NewDString(column.GetType().SQLString()), // crdb_sql_type ) - }) + if err != nil { + return err + } + } + return nil }) }, } @@ -527,20 +532,23 @@ https://www.postgresql.org/docs/current/infoschema-column-udt-usage.html`, dbNameStr := tree.NewDString(db.GetName()) scNameStr := tree.NewDString(scName) tbNameStr := tree.NewDString(table.GetName()) - return table.ForeachPublicColumn(func(col *descpb.ColumnDescriptor) error { - if !col.Type.UserDefined() { - return nil + for _, col := range table.PublicColumnsNew() { + if !col.GetType().UserDefined() { + continue } - return addRow( - tree.NewDString(col.Type.TypeMeta.Name.Catalog), // UDT_CATALOG - tree.NewDString(col.Type.TypeMeta.Name.Schema), // UDT_SCHEMA - tree.NewDString(col.Type.TypeMeta.Name.Name), // UDT_NAME - dbNameStr, // TABLE_CATALOG - scNameStr, // TABLE_SCHEMA - tbNameStr, // TABLE_NAME - tree.NewDString(col.Name), // COLUMN_NAME - ) - }) + if err := addRow( + tree.NewDString(col.GetType().TypeMeta.Name.Catalog), // UDT_CATALOG + tree.NewDString(col.GetType().TypeMeta.Name.Schema), // UDT_SCHEMA + tree.NewDString(col.GetType().TypeMeta.Name.Name), // UDT_NAME + dbNameStr, // TABLE_CATALOG + scNameStr, // TABLE_SCHEMA + tbNameStr, // TABLE_NAME + tree.NewDString(col.GetName()), // COLUMN_NAME + ); err != nil { + return err + } + } + return nil }, ) }, @@ -1448,30 +1456,29 @@ CREATE TABLE information_schema.table_constraints ( // NULL column constraints in information_schema.check_constraints. // Cockroach doesn't track these constraints as check constraints, // but we can pull them off of the table's column descriptors. - colNum := 0 - return table.ForeachPublicColumn(func(col *descpb.ColumnDescriptor) error { - colNum++ + for _, col := range table.PublicColumnsNew() { + if col.IsNullable() { + continue + } // NOT NULL column constraints are implemented as a CHECK in postgres. conNameStr := tree.NewDString(fmt.Sprintf( - "%s_%s_%d_not_null", h.NamespaceOid(db.GetID(), scName), tableOid(table.GetID()), colNum, + "%s_%s_%d_not_null", h.NamespaceOid(db.GetID(), scName), tableOid(table.GetID()), col.Ordinal()+1, )) - if !col.Nullable { - if err := addRow( - dbNameStr, // constraint_catalog - scNameStr, // constraint_schema - conNameStr, // constraint_name - dbNameStr, // table_catalog - scNameStr, // table_schema - tbNameStr, // table_name - tree.NewDString("CHECK"), // constraint_type - yesOrNoDatum(false), // is_deferrable - yesOrNoDatum(false), // initially_deferred - ); err != nil { - return err - } + if err := addRow( + dbNameStr, // constraint_catalog + scNameStr, // constraint_schema + conNameStr, // constraint_name + dbNameStr, // table_catalog + scNameStr, // table_schema + tbNameStr, // table_name + tree.NewDString("CHECK"), // constraint_type + yesOrNoDatum(false), // is_deferrable + yesOrNoDatum(false), // initially_deferred + ); err != nil { + return err } - return nil - }) + } + return nil }) }, } diff --git a/pkg/sql/pg_catalog.go b/pkg/sql/pg_catalog.go index 349ec9aa9f14..b30337701697 100644 --- a/pkg/sql/pg_catalog.go +++ b/pkg/sql/pg_catalog.go @@ -366,26 +366,27 @@ https://www.postgresql.org/docs/9.5/catalog-pg-attrdef.html`, table catalog.TableDescriptor, lookup simpleSchemaResolver, addRow func(...tree.Datum) error) error { - colNum := 0 - return table.ForeachPublicColumn(func(column *descpb.ColumnDescriptor) error { - colNum++ - if column.DefaultExpr == nil { + for _, column := range table.PublicColumnsNew() { + if !column.HasDefault() { // pg_attrdef only expects rows for columns with default values. - return nil + continue } - displayExpr, err := schemaexpr.FormatExprForDisplay(ctx, table, *column.DefaultExpr, &p.semaCtx, tree.FmtPGCatalog) + displayExpr, err := schemaexpr.FormatExprForDisplay(ctx, table, column.GetDefaultExpr(), &p.semaCtx, tree.FmtPGCatalog) if err != nil { return err } defSrc := tree.NewDString(displayExpr) - return addRow( - h.ColumnOid(table.GetID(), column.ID), // oid + if err := addRow( + h.ColumnOid(table.GetID(), column.GetID()), // oid tableOid(table.GetID()), // adrelid tree.NewDInt(tree.DInt(column.GetPGAttributeNum())), // adnum defSrc, // adbin defSrc, // adsrc - ) - }) + ); err != nil { + return err + } + } + return nil }) var pgCatalogAttributeTable = makeAllRelationsVirtualTableWithDescriptorIDIndex( @@ -436,11 +437,11 @@ https://www.postgresql.org/docs/12/catalog-pg-attribute.html`, } // Columns for table. - if err := table.ForeachPublicColumn(func(column *descpb.ColumnDescriptor) error { + for _, column := range table.PublicColumnsNew() { tableID := tableOid(table.GetID()) - return addColumn(column, tableID, column.GetPGAttributeNum()) - }); err != nil { - return err + if err := addColumn(column.ColumnDesc(), tableID, column.GetPGAttributeNum()); err != nil { + return err + } } // Columns for each index. diff --git a/pkg/sql/pg_extension.go b/pkg/sql/pg_extension.go index 1eebb9e83de6..975cce2b5b82 100644 --- a/pkg/sql/pg_extension.go +++ b/pkg/sql/pg_extension.go @@ -55,11 +55,11 @@ func postgisColumnsTablePopulator( if p.CheckAnyPrivilege(ctx, table) != nil { return nil } - return table.ForeachPublicColumn(func(colDesc *descpb.ColumnDescriptor) error { - if colDesc.Type.Family() != matchingFamily { - return nil + for _, col := range table.PublicColumnsNew() { + if col.GetType().Family() != matchingFamily { + continue } - m, err := colDesc.Type.GeoMetadata() + m, err := col.GetType().GeoMetadata() if err != nil { return err } @@ -85,16 +85,19 @@ func postgisColumnsTablePopulator( shapeName = geopb.ShapeType_Geometry.String() } - return addRow( + if err := addRow( tree.NewDString(db.GetName()), tree.NewDString(scName), tree.NewDString(table.GetName()), - tree.NewDString(colDesc.Name), + tree.NewDString(col.GetName()), datumNDims, tree.NewDInt(tree.DInt(m.SRID)), tree.NewDString(strings.ToUpper(shapeName)), - ) - }) + ); err != nil { + return err + } + } + return nil }, ) } diff --git a/pkg/sql/row/fetcher.go b/pkg/sql/row/fetcher.go index 59b1e0053fec..877c836ce2e6 100644 --- a/pkg/sql/row/fetcher.go +++ b/pkg/sql/row/fetcher.go @@ -1415,11 +1415,10 @@ func (rf *Fetcher) NextRowWithErrors(ctx context.Context) (rowenc.EncDatumRow, e func (rf *Fetcher) checkPrimaryIndexDatumEncodings(ctx context.Context) error { table := rf.rowReadyTable scratch := make([]byte, 1024) - colIDToColumn := make(map[descpb.ColumnID]*descpb.ColumnDescriptor) - _ = table.desc.ForeachPublicColumn(func(col *descpb.ColumnDescriptor) error { - colIDToColumn[col.ID] = col - return nil - }) + colIDToColumn := make(map[descpb.ColumnID]catalog.Column) + for _, col := range table.desc.PublicColumnsNew() { + colIDToColumn[col.GetID()] = col + } indexes := make([]descpb.IndexDescriptor, len(table.desc.PublicNonPrimaryIndexes())) for i, idx := range table.desc.PublicNonPrimaryIndexes() { @@ -1454,20 +1453,20 @@ func (rf *Fetcher) checkPrimaryIndexDatumEncodings(ctx context.Context) error { return errors.AssertionFailedf("column mapping not found for column %d", colID) } - if lastColID > col.ID { - return errors.AssertionFailedf("cannot write column id %d after %d", col.ID, lastColID) + if lastColID > col.GetID() { + return errors.AssertionFailedf("cannot write column id %d after %d", col.GetID(), lastColID) } - colIDDiff := col.ID - lastColID - lastColID = col.ID + colIDDiff := col.GetID() - lastColID + lastColID = col.GetID() if result, err := rowenc.EncodeTableValue([]byte(nil), colIDDiff, rowVal.Datum, scratch); err != nil { return errors.NewAssertionErrorWithWrappedErrf(err, "could not re-encode column %s, value was %#v", - col.Name, rowVal.Datum) + col.GetName(), rowVal.Datum) } else if !rowVal.BytesEqual(result) { return scrub.WrapError(scrub.IndexValueDecodingError, errors.Errorf( "value failed to round-trip encode. Column=%s colIDDiff=%d Key=%s expected %#v, got: %#v", - col.Name, colIDDiff, rf.kv.Key, rowVal.EncodedString(), result)) + col.GetName(), colIDDiff, rf.kv.Key, rowVal.EncodedString(), result)) } } return nil diff --git a/pkg/sql/rowenc/testutils.go b/pkg/sql/rowenc/testutils.go index 4b2a721b2666..364c8a13a780 100644 --- a/pkg/sql/rowenc/testutils.go +++ b/pkg/sql/rowenc/testutils.go @@ -1019,18 +1019,12 @@ func TestingMakePrimaryIndexKey( } // Check that the value type matches. colID := index.GetColumnID(i) - var done bool - if err := desc.ForeachPublicColumn(func(c *descpb.ColumnDescriptor) error { - if !done && c.ID == colID { - colTyp := datums[i].ResolvedType() - if t := colTyp.Family(); t != c.Type.Family() { - return errors.Errorf("column %d of type %s, got value of type %s", i, c.Type.Family(), t) - } - done = true + col, _ := desc.FindColumnWithID(colID) + if col != nil && col.Public() { + colTyp := datums[i].ResolvedType() + if t := colTyp.Family(); t != col.GetType().Family() { + return nil, errors.Errorf("column %d of type %s, got value of type %s", i, col.GetType().Family(), t) } - return nil - }); err != nil { - return nil, err } } // Create the ColumnID to index in datums slice map needed by