Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions enginetest/queries/alter_table_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ var AlterTableScripts = []ScriptTest{
},
},
},
{
Name: "issue 8917: exec error nested in block doesn't panic",
SetUpScript: []string{
"CREATE TABLE b(b int primary key)",
"CREATE TABLE a(a int primary key, b int, CONSTRAINT `fk` FOREIGN KEY (b) REFERENCES b (b))",
},
Assertions: []ScriptTestAssertion{
{
Query: "alter table a add column c varchar(100), modify column b varchar(100)",
ExpectedErr: sql.ErrForeignKeyTypeChange,
},
},
},
{
Name: "variety of alter column statements in a single statement",
SetUpScript: []string{
Expand Down
4 changes: 4 additions & 0 deletions sql/rowexec/other.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ func (b *BaseBuilder) buildBlock(ctx *sql.Context, n *plan.Block, row sql.Row) (
}

handleError := func(err error) error {
if n.Pref == nil {
// alter table blocks do not have a proc reference
return err
}
scope := n.Pref.InnermostScope
for i := len(scope.Handlers) - 1; i >= 0; i-- {
if !scope.Handlers[i].Cond.Matches(err) {
Expand Down
Loading