@@ -937,19 +937,20 @@ func (b *Builder) buildAlterNotNull(inScope *scope, ddl *ast.DDL, table *plan.Re
937937 spec := ddl .NotNullSpec
938938 for _ , c := range table .Schema () {
939939 if strings .EqualFold (c .Name , spec .Column .String ()) {
940+ colCopy := * c
940941 switch strings .ToLower (spec .Action ) {
941942 case ast .SetStr :
942943 // Set NOT NULL constraint
943- c .Nullable = false
944+ colCopy .Nullable = false
944945 case ast .DropStr :
945946 // Drop NOT NULL constraint
946- c .Nullable = true
947+ colCopy .Nullable = true
947948 default :
948949 err := sql .ErrUnsupportedFeature .New (ast .String (ddl ))
949950 b .handleErr (err )
950951 }
951952
952- modifyColumn := plan .NewModifyColumnResolved (table , c .Name , * c , nil )
953+ modifyColumn := plan .NewModifyColumnResolved (table , c .Name , colCopy , nil )
953954 outScope .node = b .modifySchemaTarget (inScope , modifyColumn , table .Schema ())
954955 return
955956 }
@@ -964,13 +965,14 @@ func (b *Builder) buildAlterChangeColumnType(inScope *scope, ddl *ast.DDL, table
964965 spec := ddl .ColumnTypeSpec
965966 for _ , c := range table .Schema () {
966967 if strings .EqualFold (c .Name , spec .Column .String ()) {
968+ colCopy := * c
967969 typ , err := types .ColumnTypeToType (& spec .Type )
968970 if err != nil {
969971 b .handleErr (err )
970972 return
971973 }
972- c .Type = typ
973- modifyColumn := plan .NewModifyColumnResolved (table , c .Name , * c , nil )
974+ colCopy .Type = typ
975+ modifyColumn := plan .NewModifyColumnResolved (table , c .Name , colCopy , nil )
974976 outScope .node = b .modifySchemaTarget (inScope , modifyColumn , table .Schema ())
975977 return
976978 }
0 commit comments