Skip to content

Commit

Permalink
Merge pull request cockroachdb#91510 from maryliag/backport22.1-91214
Browse files Browse the repository at this point in the history
release-22.1: server, ui: update prettify parameter
  • Loading branch information
maryliag authored Nov 9, 2022
2 parents 36052be + 14707d6 commit cf70396
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions pkg/server/combined_statement_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catconstants"
"github.com/cockroachdb/cockroach/pkg/sql/parser"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"github.com/cockroachdb/cockroach/pkg/sql/sqlstats"
Expand Down Expand Up @@ -538,20 +539,14 @@ func getTotalStatementDetails(
}
statistics.Stats.SensitiveInfo.MostRecentPlanDescription = *plan

args = []interface{}{}
args = append(args, aggregatedMetadata.Query)
query = fmt.Sprintf(
`SELECT prettify_statement($1, %d, %d, %d)`,
tree.ConsoleLineWidth, tree.PrettyAlignAndDeindent, tree.UpperCase)
row, err = ie.QueryRowEx(ctx, "combined-stmts-details-format-query", nil,
sessiondata.InternalExecutorOverride{
User: security.NodeUserName(),
}, query, args...)

queryTree, err := parser.ParseOne(aggregatedMetadata.Query)
if err != nil {
return statement, serverError(ctx, err)
}
aggregatedMetadata.FormattedQuery = string(tree.MustBeDString(row[0]))
cfg := tree.DefaultPrettyCfg()
cfg.Align = tree.PrettyAlignOnly
cfg.LineWidth = tree.ConsoleLineWidth
aggregatedMetadata.FormattedQuery = cfg.Pretty(queryTree.AST)

statement = serverpb.StatementDetailsResponse_CollectedStatementSummary{
Metadata: aggregatedMetadata,
Expand Down

0 comments on commit cf70396

Please sign in to comment.