| 411 | */ |
| 412 | |
| 413 | static |
| 414 | int print_explain_row(select_result_sink *result, |
| 415 | uint8 options, bool is_analyze, |
| 416 | uint select_number, |
| 417 | const char *select_type, |
| 418 | const char *table_name, |
| 419 | const char *partitions, |
| 420 | enum join_type jtype, |
| 421 | String_list *possible_keys, |
| 422 | const char *index, |
| 423 | const char *key_len, |
| 424 | const char *ref, |
| 425 | ha_rows *rows, |
| 426 | double *r_rows, |
| 427 | double r_filtered, |
| 428 | const char *extra) |
| 429 | { |
| 430 | THD *thd= result->thd; |
| 431 | MEM_ROOT *mem_root= thd->mem_root; |
| 432 | Item *item_null= new (mem_root) Item_null(thd); |
| 433 | List<Item> item_list; |
| 434 | Item *item; |
| 435 | |
| 436 | if (!select_type[0]) |
| 437 | return 0; |
| 438 | |
| 439 | item_list.push_back(new (mem_root) Item_int(thd, (int32) select_number), |
| 440 | mem_root); |
| 441 | item_list.push_back(new (mem_root) Item_string_sys(thd, select_type), |
| 442 | mem_root); |
| 443 | item_list.push_back(new (mem_root) Item_string_sys(thd, table_name), |
| 444 | mem_root); |
| 445 | if (options & DESCRIBE_PARTITIONS) |
| 446 | { |
| 447 | if (partitions) |
| 448 | { |
| 449 | item_list.push_back(new (mem_root) Item_string_sys(thd, partitions), |
| 450 | mem_root); |
| 451 | } |
| 452 | else |
| 453 | item_list.push_back(item_null, mem_root); |
| 454 | } |
| 455 | |
| 456 | const char *jtype_str= join_type_str[jtype]; |
| 457 | item_list.push_back(new (mem_root) Item_string_sys(thd, jtype_str), |
| 458 | mem_root); |
| 459 | |
| 460 | /* 'possible_keys' |
| 461 | The buffer must not be deallocated before we call send_data, otherwise |
| 462 | we may end up reading freed memory. |
| 463 | */ |
| 464 | StringBuffer<64> possible_keys_buf; |
| 465 | if (possible_keys && !possible_keys->is_empty()) |
| 466 | { |
| 467 | push_string_list(thd, &item_list, *possible_keys, &possible_keys_buf); |
| 468 | } |
| 469 | else |
| 470 | item_list.push_back(item_null, mem_root); |
no test coverage detected