Skip to content

Commit 9b2674c

Browse files
authored
Fix panic for WHERE filter over SHOW VARIABLES (#1892)
1 parent cefa093 commit 9b2674c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

enginetest/queries/queries.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4996,6 +4996,20 @@ Select * from (
49964996
{"version_comment", "Dolt"}, {"version_compile_machine", ""}, {"version_compile_os", ""}, {"version_compile_zlib", ""}, {"wait_timeout", 28800}, {"windowing_use_high_precision", 1},
49974997
},
49984998
},
4999+
{
5000+
Query: `SHOW VARIABLES WHERE "1" and variable_name = 'autocommit'`,
5001+
Expected: []sql.Row{
5002+
{"autocommit", 1},
5003+
},
5004+
},
5005+
{
5006+
Query: `SHOW VARIABLES WHERE "0" and variable_name = 'autocommit'`,
5007+
Expected: []sql.Row{},
5008+
},
5009+
{
5010+
Query: `SHOW VARIABLES WHERE "abc" and variable_name = 'autocommit'`,
5011+
Expected: []sql.Row{},
5012+
},
49995013
{
50005014
Query: `SHOW GLOBAL VARIABLES LIKE '%mode'`,
50015015
Expected: []sql.Row{

sql/rowexec/show.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,12 @@ func (b *BaseBuilder) buildShowVariables(ctx *sql.Context, n *plan.ShowVariables
529529
if err != nil {
530530
return nil, err
531531
}
532-
if !res.(bool) {
532+
res, _, err = types.Boolean.Convert(res)
533+
if err != nil {
534+
ctx.Warn(1292, err.Error())
535+
continue
536+
}
537+
if res.(int8) == 0 {
533538
continue
534539
}
535540
}

0 commit comments

Comments
 (0)