Skip to content

Commit

Permalink
Fix panic for WHERE filter over SHOW VARIABLES (#1892)
Browse files Browse the repository at this point in the history
  • Loading branch information
jycor authored Jul 25, 2023
1 parent cefa093 commit 9b2674c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions enginetest/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -4996,6 +4996,20 @@ Select * from (
{"version_comment", "Dolt"}, {"version_compile_machine", ""}, {"version_compile_os", ""}, {"version_compile_zlib", ""}, {"wait_timeout", 28800}, {"windowing_use_high_precision", 1},
},
},
{
Query: `SHOW VARIABLES WHERE "1" and variable_name = 'autocommit'`,
Expected: []sql.Row{
{"autocommit", 1},
},
},
{
Query: `SHOW VARIABLES WHERE "0" and variable_name = 'autocommit'`,
Expected: []sql.Row{},
},
{
Query: `SHOW VARIABLES WHERE "abc" and variable_name = 'autocommit'`,
Expected: []sql.Row{},
},
{
Query: `SHOW GLOBAL VARIABLES LIKE '%mode'`,
Expected: []sql.Row{
Expand Down
7 changes: 6 additions & 1 deletion sql/rowexec/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,12 @@ func (b *BaseBuilder) buildShowVariables(ctx *sql.Context, n *plan.ShowVariables
if err != nil {
return nil, err
}
if !res.(bool) {
res, _, err = types.Boolean.Convert(res)
if err != nil {
ctx.Warn(1292, err.Error())
continue
}
if res.(int8) == 0 {
continue
}
}
Expand Down

0 comments on commit 9b2674c

Please sign in to comment.