Skip to content

Commit 42da53a

Browse files
committed
Removing AlterDefaultSet case and letting the general SchemaTarget case handle it
1 parent b1bb38e commit 42da53a

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

sql/analyzer/resolve_column_defaults.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -163,43 +163,6 @@ func resolveColumnDefaults(ctx *sql.Context, _ *Analyzer, n sql.Node, _ *plan.Sc
163163
node.Source = newSource
164164
}
165165
return node, identity, err
166-
case *plan.AlterDefaultSet:
167-
table := getResolvedTable(node)
168-
sch := table.Schema()
169-
index := sch.IndexOfColName(node.ColumnName)
170-
if index == -1 {
171-
return nil, transform.SameTree, sql.ErrColumnNotFound.New(node.ColumnName)
172-
}
173-
col := sch[index]
174-
175-
eWrapper := expression.WrapExpression(node.Default)
176-
newExpr, sameColumnDefault, err := resolveColumnDefault(ctx, col, eWrapper)
177-
if err != nil {
178-
return node, transform.SameTree, err
179-
}
180-
181-
newNode, err := node.WithDefault(newExpr)
182-
if err != nil {
183-
return node, transform.SameTree, err
184-
}
185-
186-
// After resolving the new column default value, ensure all column defaults in the target schema are resolved
187-
newNode, sameTargetSchema, err := transform.OneNodeExpressions(newNode, func(e sql.Expression) (sql.Expression, transform.TreeIdentity, error) {
188-
eWrapper, ok := e.(*expression.Wrapper)
189-
if !ok {
190-
return e, transform.SameTree, nil
191-
}
192-
193-
col, err := lookupColumnForTargetSchema(ctx, node, colIndex)
194-
if err != nil {
195-
return nil, transform.SameTree, err
196-
}
197-
colIndex++
198-
199-
return resolveColumnDefault(ctx, col, eWrapper)
200-
})
201-
202-
return newNode, sameColumnDefault && sameTargetSchema, err
203166
case sql.SchemaTarget:
204167
return transform.OneNodeExpressions(n, func(e sql.Expression) (sql.Expression, transform.TreeIdentity, error) {
205168
eWrapper, ok := e.(*expression.Wrapper)

0 commit comments

Comments
 (0)