From c4d080cc9e68902fcced19335a9175de11e33bff Mon Sep 17 00:00:00 2001 From: crazycs Date: Wed, 12 Feb 2020 11:13:48 +0800 Subject: [PATCH] executor: fix admin show ddl jobs end time bug when job is not finished Signed-off-by: crazycs --- executor/executor.go | 6 +++++- executor/executor_test.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/executor/executor.go b/executor/executor.go index 617e294fcad93..0fcee0117a9f0 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -485,7 +485,11 @@ func (e *ShowDDLJobsExec) appendJobToChunk(req *chunk.Chunk, job *model.Job) { req.AppendInt64(6, job.TableID) req.AppendInt64(7, job.RowCount) req.AppendString(8, model.TSConvert2Time(job.StartTS).String()) - req.AppendString(9, model.TSConvert2Time(finishTS).String()) + if finishTS > 0 { + req.AppendString(9, model.TSConvert2Time(finishTS).String()) + } else { + req.AppendString(9, "") + } req.AppendString(10, job.State.String()) } diff --git a/executor/executor_test.go b/executor/executor_test.go index 8ec6bd912e33a..4040bc9b9c89f 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -478,6 +478,7 @@ func (s *testSuiteP2) TestAdminShowDDLJobs(c *C) { re = tk.MustQuery("admin show ddl jobs 1 where job_type='create table'") row = re.Rows()[0] c.Assert(row[1], Equals, "test_admin_show_ddl_jobs") + c.Assert(row[9], Equals, "") } func (s *testSuiteP2) TestAdminChecksumOfPartitionedTable(c *C) {