// buildTrace builds a trace plan. Inside this method, it first optimize the
// underlying query and then constructs a schema, which will be used to constructs
// rows result.
buildTrace builds a trace plan. Inside this method, it first optimize the
underlying query and then constructs a schema, which will be used to constructs
rows result.
// buildTrace builds a trace plan . Inside this method it first optimize the // underlying query and then constructs a schema which will be used to constructs // rows result .
func (b *PlanBuilder) buildTrace(trace *ast.TraceStmt) (Plan, error) {
	p := &Trace{StmtNode: trace.Stmt, Format: trace.Format}
	switch trace.Format {
	case TraceFormatRow:
		schema := newColumnsWithNames(3)
		schema.Append(buildColumnWithName("", "operation", mysql.TypeString, mysql.MaxBlobWidth))
		schema.Append(buildColumnWithName("", "startTS", mysql.TypeString, mysql.MaxBlobWidth))
		schema.Append(buildColumnWithName("", "duration", mysql.TypeString, mysql.MaxBlobWidth))
		p.SetSchema(schema.col2Schema())
		p.names = schema.names
	case TraceFormatJSON:
		schema := newColumnsWithNames(1)
		schema.Append(buildColumnWithName("", "operation", mysql.TypeString, mysql.MaxBlobWidth))
		p.SetSchema(schema.col2Schema())
		p.names = schema.names
	case TraceFormatLog:
		schema := newColumnsWithNames(4)
		schema.Append(buildColumnWithName("", "time", mysql.TypeTimestamp, mysql.MaxBlobWidth))
		schema.Append(buildColumnWithName("", "event", mysql.TypeString, mysql.MaxBlobWidth))
		schema.Append(buildColumnWithName("", "tags", mysql.TypeString, mysql.MaxBlobWidth))
		schema.Append(buildColumnWithName("", "spanName", mysql.TypeString, mysql.MaxBlobWidth))
		p.SetSchema(schema.col2Schema())
		p.names = schema.names
	default:
		return nil, errors.New("trace format should be one of 'row', 'log' or 'json'")
	}
	return p, nil
}
func ( b * PlanBuilder ) buildTrace ( trace * ast . TraceStmt ) ( Plan , error ) { p := & Trace { StmtNode : trace . Stmt , Format : trace . Format } switch trace . Format { case TraceFormatRow : schema := newColumnsWithNames ( 3 ) schema . Append ( buildColumnWithName ( " " , " " , mysql . TypeString , mysql . MaxBlobWidth ) ) schema . Append ( buildColumnWithName ( " " , " " , mysql . TypeString , mysql . MaxBlobWidth ) ) schema . Append ( buildColumnWithName ( " " , " " , mysql . TypeString , mysql . MaxBlobWidth ) ) p . SetSchema ( schema . col2Schema ( ) ) p . names = schema . names case TraceFormatJSON : schema := newColumnsWithNames ( 1 ) schema . Append ( buildColumnWithName ( " " , " " , mysql . TypeString , mysql . MaxBlobWidth ) ) p . SetSchema ( schema . col2Schema ( ) ) p . names = schema . names case TraceFormatLog : schema := newColumnsWithNames ( 4 ) schema . Append ( buildColumnWithName ( " " , " " , mysql . TypeTimestamp , mysql . MaxBlobWidth ) ) schema . Append ( buildColumnWithName ( " " , " " , mysql . TypeString , mysql . MaxBlobWidth ) ) schema . Append ( buildColumnWithName ( " " , " " , mysql . TypeString , mysql . MaxBlobWidth ) ) schema . Append ( buildColumnWithName ( " " , " " , mysql . TypeString , mysql . MaxBlobWidth ) ) p . SetSchema ( schema . col2Schema ( ) ) p . names = schema . names default : return nil , errors . New ( " " ) } return p , nil }
buildTrace builds a trace plan.
buildTrace builds a trace plan .