Skip to content

Commit 054a9d3

Browse files
committed
sql: add 'compact' auto_trace option
This allows a user of auto_trace to specify \set auto_trace=on,compact if they want the per-statement trace output to use the compact format supported by SHOW TRACE FOR SESSION. Epic: none Release Note (cli change): The SQL shell now supports the compact output mode when auto_trace is enabled.
1 parent 8453f7b commit 054a9d3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/cli/clisqlshell/sql.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2169,17 +2169,21 @@ func (c *cliState) doRunStatements(nextState cliStateEnum) cliStateEnum {
21692169
// shell.
21702170
} else {
21712171
traceType := ""
2172+
compact := ""
21722173
if strings.Contains(c.iCtx.autoTrace, "kv") {
21732174
traceType = "kv"
21742175
}
2176+
if strings.Contains(c.iCtx.autoTrace, "compact") {
2177+
compact = "COMPACT"
2178+
}
21752179
if err := c.runWithInterruptableCtx(func(ctx context.Context) error {
21762180
defer c.maybeFlushOutput()
21772181
return c.sqlExecCtx.RunQueryAndFormatResults(ctx,
21782182
c.conn,
21792183
c.iCtx.queryOutput, // query output
21802184
c.iCtx.stdout, // timings
21812185
c.iCtx.stderr, // errors
2182-
clisqlclient.MakeQuery(fmt.Sprintf("SHOW %s TRACE FOR SESSION", traceType)))
2186+
clisqlclient.MakeQuery(fmt.Sprintf("SHOW %s %s TRACE FOR SESSION", compact, traceType)))
21832187
}); err != nil {
21842188
clierror.OutputError(c.iCtx.stderr, err, true /*showSeverity*/, false /*verbose*/)
21852189
if c.exitErr == nil {

pkg/sql/conn_executor_exec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4101,6 +4101,8 @@ func (ex *connExecutor) enableTracing(modes []string) error {
41014101
traceKV = true
41024102
case "cluster":
41034103
recordingType = tracingpb.RecordingVerbose
4104+
case "compact":
4105+
// compact modifies the output format.
41044106
default:
41054107
return pgerror.Newf(pgcode.Syntax,
41064108
"set tracing: unknown mode %q", s)

0 commit comments

Comments
 (0)