| 726 | |
| 727 | |
| 728 | Sql_condition* THD::raise_condition(uint sql_errno, |
| 729 | const char* sqlstate, |
| 730 | Sql_condition::enum_warning_level level, |
| 731 | const char* msg) |
| 732 | { |
| 733 | Diagnostics_area *da= get_stmt_da(); |
| 734 | Sql_condition *cond= NULL; |
| 735 | DBUG_ENTER("THD::raise_condition"); |
| 736 | |
| 737 | if (!(variables.option_bits & OPTION_SQL_NOTES) && |
| 738 | (level == Sql_condition::WARN_LEVEL_NOTE)) |
| 739 | DBUG_RETURN(NULL); |
| 740 | |
| 741 | da->opt_clear_warning_info(query_id); |
| 742 | |
| 743 | /* |
| 744 | TODO: replace by DBUG_ASSERT(sql_errno != 0) once all bugs similar to |
| 745 | Bug#36768 are fixed: a SQL condition must have a real (!=0) error number |
| 746 | so that it can be caught by handlers. |
| 747 | */ |
| 748 | if (sql_errno == 0) |
| 749 | sql_errno= ER_UNKNOWN_ERROR; |
| 750 | if (msg == NULL) |
| 751 | msg= ER(sql_errno); |
| 752 | if (sqlstate == NULL) |
| 753 | sqlstate= mysql_errno_to_sqlstate(sql_errno); |
| 754 | |
| 755 | if ((level == Sql_condition::WARN_LEVEL_WARN) && |
| 756 | really_abort_on_warning()) |
| 757 | { |
| 758 | /* |
| 759 | FIXME: |
| 760 | push_warning and strict SQL_MODE case. |
| 761 | */ |
| 762 | level= Sql_condition::WARN_LEVEL_ERROR; |
| 763 | killed= THD::KILL_BAD_DATA; |
| 764 | } |
| 765 | |
| 766 | switch (level) |
| 767 | { |
| 768 | case Sql_condition::WARN_LEVEL_NOTE: |
| 769 | case Sql_condition::WARN_LEVEL_WARN: |
| 770 | got_warning= 1; |
| 771 | break; |
| 772 | case Sql_condition::WARN_LEVEL_ERROR: |
| 773 | break; |
| 774 | default: |
| 775 | DBUG_ASSERT(FALSE); |
| 776 | } |
| 777 | |
| 778 | if (handle_condition(sql_errno, sqlstate, level, msg, &cond)) |
| 779 | DBUG_RETURN(cond); |
| 780 | |
| 781 | if (level == Sql_condition::WARN_LEVEL_ERROR) |
| 782 | { |
| 783 | is_slave_error= 1; // needed to catch query errors during replication |
| 784 | |
| 785 | /* |
no test coverage detected