Skip to content

Commit

Permalink
sql/delegate: pick up new 21.2 columns in SHOW JOBS
Browse files Browse the repository at this point in the history
New columns were added to `crdb_internal.jobs` to expose retry and
exponential backoff state. This commit exposes them in `SHOW JOBS`.

No need for a version gate because the virtual table is local and will
just populate the columns with NULL in the mixed version state.

Fixes #70765.

Release note (sql change): `SHOW JOBS` will now include the newly added
columns from `crdb_internal.jobs` (`last_run`, `next_run`, `num_runs`,
and `execution_errors`). The columns capture state related to retries,
failures, and exponential backoff.
  • Loading branch information
ajwerner committed Sep 27, 2021
1 parent fdac0cb commit 33948df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pkg/sql/delegate/show_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ SHOW JOBS SELECT id FROM system.jobs WHERE created_by_type='%s' and created_by_i
sqltelemetry.IncrementShowCounter(sqltelemetry.Jobs)

const (
selectClause = `SELECT job_id, job_type, description, statement, user_name, status,
running_status, created, started, finished, modified,
fraction_completed, error, coordinator_id, trace_id
FROM crdb_internal.jobs`
selectClause = `
SELECT job_id, job_type, description, statement, user_name, status,
running_status, created, started, finished, modified,
fraction_completed, error, coordinator_id, trace_id, last_run,
next_run, num_runs, execution_errors
FROM crdb_internal.jobs`
)
var typePredicate, whereClause, orderbyClause string
if n.Jobs == nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/logictest/testdata/logic_test/show_source
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ SELECT * FROM [SHOW COMPACT TRACE FOR SESSION] LIMIT 0
----
age message tag operation

query ITTTTTTTTTTRTII colnames
query ITTTTTTTTTTRTIITTIT colnames
SELECT * FROM [SHOW JOBS] LIMIT 0
----
job_id job_type description statement user_name status running_status created started finished modified fraction_completed error coordinator_id trace_id
job_id job_type description statement user_name status running_status created started finished modified fraction_completed error coordinator_id trace_id last_run next_run num_runs execution_errors

query TT colnames
SELECT * FROM [SHOW SYNTAX 'select 1; select 2']
Expand Down

0 comments on commit 33948df

Please sign in to comment.