MCPcopy Create free account
hub / github.com/MariaDB/server / show_routine_code

Method show_routine_code

sql/sp_head.cc:3450–3510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3448*/
3449
3450int
3451sp_head::show_routine_code(THD *thd)
3452{
3453 Protocol *protocol= thd->protocol;
3454 char buff[2048];
3455 String buffer(buff, sizeof(buff), system_charset_info);
3456 List<Item> field_list;
3457 sp_instr *i;
3458 bool full_access;
3459 int res= 0;
3460 uint ip;
3461 DBUG_ENTER("sp_head::show_routine_code");
3462 DBUG_PRINT("info", ("procedure: %s", m_name.str));
3463
3464 if (check_show_routine_access(thd, this, &full_access) || !full_access)
3465 DBUG_RETURN(1);
3466
3467 field_list.push_back(new (thd->mem_root) Item_uint(thd, "Pos", 9),
3468 thd->mem_root);
3469 // 1024 is for not to confuse old clients
3470 field_list.push_back(new (thd->mem_root)
3471 Item_empty_string(thd, "Instruction",
3472 MY_MAX(buffer.length(), 1024)),
3473 thd->mem_root);
3474 if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS |
3475 Protocol::SEND_EOF))
3476 DBUG_RETURN(1);
3477
3478 for (ip= 0; (i = get_instr(ip)) ; ip++)
3479 {
3480 /*
3481 Consistency check. If these are different something went wrong
3482 during optimization.
3483 */
3484 if (ip != i->m_ip)
3485 {
3486 const char *format= "Instruction at position %u has m_ip=%u";
3487 char tmp[sizeof(format) + 2*SP_INSTR_UINT_MAXLEN + 1];
3488
3489 my_snprintf(tmp, sizeof(tmp), format, ip, i->m_ip);
3490 /*
3491 Since this is for debugging purposes only, we don't bother to
3492 introduce a special error code for it.
3493 */
3494 push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, tmp);
3495 }
3496 protocol->prepare_for_resend();
3497 protocol->store_long(ip);
3498
3499 buffer.set("", 0, system_charset_info);
3500 i->print(&buffer);
3501 protocol->store(buffer.ptr(), buffer.length(), system_charset_info);
3502 if ((res= protocol->write()))
3503 break;
3504 }
3505
3506 if (!res)
3507 my_eof(thd);

Callers 1

executeMethod · 0.80

Calls 14

my_snprintfFunction · 0.85
push_warningFunction · 0.85
my_eofFunction · 0.85
push_backMethod · 0.45
lengthMethod · 0.45
prepare_for_resendMethod · 0.45
store_longMethod · 0.45
setMethod · 0.45
printMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected