/
run_control.go
71 lines (61 loc) · 1.75 KB
/
run_control.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2017 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package ast
// ControlJobs represents a PAUSE/RESUME/CANCEL JOBS statement.
type ControlJobs struct {
Jobs *Select
Command JobCommand
}
// JobCommand determines which type of action to effect on the selected job(s).
type JobCommand int
// JobCommand values
const (
PauseJob JobCommand = iota
CancelJob
ResumeJob
)
// JobCommandToStatement translates a job command integer to a statement prefix.
var JobCommandToStatement = map[JobCommand]string{
PauseJob: "PAUSE",
CancelJob: "CANCEL",
ResumeJob: "RESUME",
}
// Format implements the NodeFormatter interface.
func (n *ControlJobs) Format(ctx *FmtCtx) {
ctx.WriteString(JobCommandToStatement[n.Command])
ctx.WriteString(" JOBS ")
ctx.FormatNode(n.Jobs)
}
// CancelQueries represents a CANCEL QUERIES statement.
type CancelQueries struct {
Queries *Select
IfExists bool
}
// Format implements the NodeFormatter interface.
func (node *CancelQueries) Format(ctx *FmtCtx) {
ctx.WriteString("CANCEL QUERIES ")
if node.IfExists {
ctx.WriteString("IF EXISTS ")
}
ctx.FormatNode(node.Queries)
}
// CancelSessions represents a CANCEL SESSIONS statement.
type CancelSessions struct {
Sessions *Select
IfExists bool
}
// Format implements the NodeFormatter interface.
func (node *CancelSessions) Format(ctx *FmtCtx) {
ctx.WriteString("CANCEL SESSIONS ")
if node.IfExists {
ctx.WriteString("IF EXISTS ")
}
ctx.FormatNode(node.Sessions)
}