Auxiliary method used by @c binlog_query() to raise warnings. The type of warning and the type of unsafeness is stored in THD::binlog_unsafe_warning_flags. */
| 9593 | THD::binlog_unsafe_warning_flags. |
| 9594 | */ |
| 9595 | void THD::issue_unsafe_warnings() |
| 9596 | { |
| 9597 | char buf[MYSQL_ERRMSG_SIZE * 2]; |
| 9598 | DBUG_ENTER("issue_unsafe_warnings"); |
| 9599 | /* |
| 9600 | Ensure that binlog_unsafe_warning_flags is big enough to hold all |
| 9601 | bits. This is actually a constant expression. |
| 9602 | */ |
| 9603 | DBUG_ASSERT(LEX::BINLOG_STMT_UNSAFE_COUNT <= |
| 9604 | sizeof(binlog_unsafe_warning_flags) * CHAR_BIT); |
| 9605 | |
| 9606 | uint32 unsafe_type_flags= binlog_unsafe_warning_flags; |
| 9607 | |
| 9608 | if ((unsafe_type_flags & (1U << LEX::BINLOG_STMT_UNSAFE_LIMIT)) != 0) |
| 9609 | { |
| 9610 | if ((lex->sql_command == SQLCOM_DELETE || lex->sql_command == SQLCOM_UPDATE) && |
| 9611 | lex->select_lex.select_limit) |
| 9612 | { |
| 9613 | ORDER *order= (ORDER *) ((lex->select_lex.order_list.elements) ? |
| 9614 | lex->select_lex.order_list.first : NULL); |
| 9615 | if ((lex->select_lex.select_limit && |
| 9616 | lex->select_lex.select_limit->fixed && |
| 9617 | lex->select_lex.select_limit->val_int() == 0) || |
| 9618 | is_order_deterministic(lex->query_tables, |
| 9619 | lex->select_lex.where, order)) |
| 9620 | { |
| 9621 | unsafe_type_flags&= ~(1U << LEX::BINLOG_STMT_UNSAFE_LIMIT); |
| 9622 | } |
| 9623 | } |
| 9624 | if ((lex->sql_command == SQLCOM_INSERT_SELECT || |
| 9625 | lex->sql_command == SQLCOM_REPLACE_SELECT) && |
| 9626 | order_deterministic) |
| 9627 | { |
| 9628 | unsafe_type_flags&= ~(1U << LEX::BINLOG_STMT_UNSAFE_LIMIT); |
| 9629 | } |
| 9630 | |
| 9631 | } |
| 9632 | |
| 9633 | /* |
| 9634 | For each unsafe_type, check if the statement is unsafe in this way |
| 9635 | and issue a warning. |
| 9636 | */ |
| 9637 | for (int unsafe_type=0; |
| 9638 | unsafe_type < LEX::BINLOG_STMT_UNSAFE_COUNT; |
| 9639 | unsafe_type++) |
| 9640 | { |
| 9641 | if ((unsafe_type_flags & (1 << unsafe_type)) != 0) |
| 9642 | { |
| 9643 | push_warning_printf(this, Sql_condition::WARN_LEVEL_NOTE, |
| 9644 | ER_BINLOG_UNSAFE_STATEMENT, |
| 9645 | ER(ER_BINLOG_UNSAFE_STATEMENT), |
| 9646 | ER(LEX::binlog_stmt_unsafe_errcode[unsafe_type])); |
| 9647 | if (log_warnings && ((opt_log_warnings_suppress & (ULL(1) << log_warnings_suppress_1592)) == 0)) |
| 9648 | { |
| 9649 | if (unsafe_type == LEX::BINLOG_STMT_UNSAFE_LIMIT) |
| 9650 | do_unsafe_limit_checkout( buf, unsafe_type, query()); |
| 9651 | else //cases other than LIMIT unsafety |
| 9652 | print_unsafe_warning_to_log(unsafe_type, buf, query()); |
nothing calls this directly
no test coverage detected