Skip to content

Commit

Permalink
sql: fix wrong representation of SHOW JOBS
Browse files Browse the repository at this point in the history
`WHEN COMPLETE` was wrongly being put in the end of the string
representation of `SHOW JOBS WHEN COMPLETE SELECT...` stmt.

Fixes: #40534.

Release note: None
  • Loading branch information
Spas Bojanov committed Sep 9, 2019
1 parent 01c7cf5 commit df9963b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/sql/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ func TestParse(t *testing.T) {
{`EXPLAIN PAUSE JOBS SELECT a`},
{`SHOW JOBS SELECT a`},
{`EXPLAIN SHOW JOBS SELECT a`},
{`SHOW JOBS WHEN COMPLETE SELECT a`},
{`EXPLAIN SHOW JOBS WHEN COMPLETE SELECT a`},

{`EXPLAIN SELECT 1`},
{`EXPLAIN EXPLAIN SELECT 1`},
Expand Down Expand Up @@ -1765,6 +1767,8 @@ func TestParse2(t *testing.T) {
{`EXPLAIN PAUSE JOB a`, `EXPLAIN PAUSE JOBS VALUES (a)`},
{`SHOW JOB a`, `SHOW JOBS VALUES (a)`},
{`EXPLAIN SHOW JOB a`, `EXPLAIN SHOW JOBS VALUES (a)`},
{`SHOW JOB WHEN COMPLETE a`, `SHOW JOBS WHEN COMPLETE VALUES (a)`},
{`EXPLAIN SHOW JOB WHEN COMPLETE a`, `EXPLAIN SHOW JOBS WHEN COMPLETE VALUES (a)`},
{`CANCEL QUERY a`, `CANCEL QUERIES VALUES (a)`},
{`CANCEL QUERY IF EXISTS a`, `CANCEL QUERIES IF EXISTS VALUES (a)`},
{`CANCEL SESSION a`, `CANCEL SESSIONS VALUES (a)`},
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/sem/tree/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ func (node *ShowJobs) Format(ctx *FmtCtx) {
ctx.WriteString("AUTOMATIC ")
}
ctx.WriteString("JOBS")
if node.Block {
ctx.WriteString(" WHEN COMPLETE")
}
if node.Jobs != nil {
ctx.WriteString(" ")
ctx.FormatNode(node.Jobs)
}
if node.Block {
ctx.WriteString(" WHEN COMPLETE")
}
}

// ShowSessions represents a SHOW SESSIONS statement
Expand Down

0 comments on commit df9963b

Please sign in to comment.