MCPcopy Index your code
hub / github.com/bytebase/bytebase / CreateColumn

Method CreateColumn

backend/store/model/database.go:975–992  ·  view source on GitHub ↗

CreateColumn creates a new column in the table. Returns an error if the column already exists.

(columnProto *storepb.ColumnMetadata, columnCatalog *storepb.ColumnCatalog)

Source from the content-addressed store, hash-verified

973// CreateColumn creates a new column in the table.
974// Returns an error if the column already exists.
975func (t *TableMetadata) CreateColumn(columnProto *storepb.ColumnMetadata, columnCatalog *storepb.ColumnCatalog) error {
976 // Check if column already exists
977 if t.GetColumn(columnProto.Name) != nil {
978 return errors.Errorf("column %q already exists in table %q", columnProto.Name, t.proto.Name)
979 }
980
981 // Add to proto's column list
982 t.proto.Columns = append(t.proto.Columns, columnProto)
983
984 // Create ColumnMetadata wrapper and add to internal map
985 columnID := normalizeNameByCaseSensitivity(columnProto.Name, t.isDetailCaseSensitive)
986 t.internalColumn[columnID] = &ColumnMetadata{
987 proto: columnProto,
988 config: columnCatalog,
989 }
990
991 return nil
992}
993
994// DropColumn drops a column from the table.
995// Returns an error if the column does not exist.

Callers 4

tidbCopyTableFunction · 0.80
tidbCreateColumnHelperFunction · 0.80

Calls 3

GetColumnMethod · 0.95
ErrorfMethod · 0.80