| 2502 | */ |
| 2503 | |
| 2504 | void THD::cleanup_after_query() |
| 2505 | { |
| 2506 | DBUG_ENTER("THD::cleanup_after_query"); |
| 2507 | |
| 2508 | thd_progress_end(this); |
| 2509 | |
| 2510 | if (!spcont && !in_sub_stmt) |
| 2511 | { |
| 2512 | /* |
| 2513 | We're at the end of the top level statement |
| 2514 | (not just in the end of a stored routine individual statement). |
| 2515 | */ |
| 2516 | statement_rcontext_reinit(); |
| 2517 | } |
| 2518 | |
| 2519 | /* |
| 2520 | Reset RAND_USED so that detection of calls to rand() will save random |
| 2521 | seeds if needed by the slave. |
| 2522 | |
| 2523 | Do not reset RAND_USED if inside a stored function or trigger because |
| 2524 | only the call to these operations is logged. Thus only the calling |
| 2525 | statement needs to detect rand() calls made by its substatements. These |
| 2526 | substatements must not set RAND_USED to 0 because it would remove the |
| 2527 | detection of rand() by the calling statement. |
| 2528 | */ |
| 2529 | if (!in_sub_stmt) /* stored functions and triggers are a special case */ |
| 2530 | { |
| 2531 | /* Forget those values, for next binlogger: */ |
| 2532 | stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0; |
| 2533 | auto_inc_intervals_in_cur_stmt_for_binlog.empty(); |
| 2534 | used&= ~THD::RAND_USED; |
| 2535 | #ifndef EMBEDDED_LIBRARY |
| 2536 | /* |
| 2537 | Clean possible unused INSERT_ID events by current statement. |
| 2538 | is_update_query() is needed to ignore SET statements: |
| 2539 | Statements that don't update anything directly and don't |
| 2540 | used stored functions. This is mostly necessary to ignore |
| 2541 | statements in binlog between SET INSERT_ID and DML statement |
| 2542 | which is intended to consume its event (there can be other |
| 2543 | SET statements between them). |
| 2544 | */ |
| 2545 | if ((rgi_slave || rli_fake) && is_update_query(lex->sql_command)) |
| 2546 | auto_inc_intervals_forced.empty(); |
| 2547 | #endif |
| 2548 | } |
| 2549 | /* |
| 2550 | Forget the binlog stmt filter for the next query. |
| 2551 | There are some code paths that: |
| 2552 | - do not call THD::decide_logging_format() |
| 2553 | - do call THD::binlog_query(), |
| 2554 | making this reset necessary. |
| 2555 | */ |
| 2556 | reset_binlog_local_stmt_filter(); |
| 2557 | if (first_successful_insert_id_in_cur_stmt > 0) |
| 2558 | { |
| 2559 | /* set what LAST_INSERT_ID() will return */ |
| 2560 | first_successful_insert_id_in_prev_stmt= |
| 2561 | first_successful_insert_id_in_cur_stmt; |
no test coverage detected