(ctx context.Context, query string, args ...*plugin.Parameter)
| 348 | } |
| 349 | |
| 350 | func (me *mysqlExplainer) Explain(ctx context.Context, query string, args ...*plugin.Parameter) (*vetEngineOutput, error) { |
| 351 | eQuery := "EXPLAIN FORMAT=JSON " + query |
| 352 | eArgs := make([]any, len(args)) |
| 353 | for i, a := range args { |
| 354 | eArgs[i] = mysqlDefaultValue(a.Column) |
| 355 | } |
| 356 | row := me.QueryRowContext(ctx, eQuery, eArgs...) |
| 357 | var result json.RawMessage |
| 358 | if err := row.Scan(&result); err != nil { |
| 359 | return nil, err |
| 360 | } |
| 361 | if debug.Debug.DumpExplain { |
| 362 | fmt.Println(eQuery, "with args", eArgs) |
| 363 | fmt.Println(string(result)) |
| 364 | } |
| 365 | var explain vet.MySQLExplain |
| 366 | if err := pjson.Unmarshal(result, &explain); err != nil { |
| 367 | return nil, err |
| 368 | } |
| 369 | if explain.QueryBlock.Message != "" { |
| 370 | return nil, fmt.Errorf("mysql explain: %s", explain.QueryBlock.Message) |
| 371 | } |
| 372 | return &vetEngineOutput{MySQL: &vet.MySQL{Explain: &explain}}, nil |
| 373 | } |
| 374 | |
| 375 | type rule struct { |
| 376 | Program *cel.Program |
nothing calls this directly
no test coverage detected