| 1122 | } |
| 1123 | |
| 1124 | Sql_condition* THD::raise_condition(const Sql_condition *cond) |
| 1125 | { |
| 1126 | uint sql_errno= cond->get_sql_errno(); |
| 1127 | const char *sqlstate= cond->get_sqlstate(); |
| 1128 | Sql_condition::enum_warning_level level= cond->get_level(); |
| 1129 | const char *msg= cond->get_message_text(); |
| 1130 | |
| 1131 | Diagnostics_area *da= get_stmt_da(); |
| 1132 | Sql_condition *raised= NULL; |
| 1133 | DBUG_ENTER("THD::raise_condition"); |
| 1134 | DBUG_ASSERT(level < Sql_condition::WARN_LEVEL_END); |
| 1135 | |
| 1136 | if ((level == Sql_condition::WARN_LEVEL_NOTE) && |
| 1137 | (!(variables.option_bits & OPTION_SQL_NOTES) || |
| 1138 | (variables.note_verbosity == 0))) |
| 1139 | DBUG_RETURN(NULL); |
| 1140 | #ifdef WITH_WSREP |
| 1141 | /* |
| 1142 | Suppress warnings/errors if the wsrep THD is going to replay. The |
| 1143 | deadlock/interrupted errors may be transient and should not be |
| 1144 | reported to the client. |
| 1145 | */ |
| 1146 | if (wsrep_must_replay(this)) |
| 1147 | DBUG_RETURN(NULL); |
| 1148 | #endif /* WITH_WSREP */ |
| 1149 | |
| 1150 | da->opt_clear_warning_info(query_id); |
| 1151 | |
| 1152 | /* |
| 1153 | TODO: replace by DBUG_ASSERT(sql_errno != 0) once all bugs similar to |
| 1154 | Bug#36768 are fixed: a SQL condition must have a real (!=0) error number |
| 1155 | so that it can be caught by handlers. |
| 1156 | */ |
| 1157 | if (sql_errno == 0) |
| 1158 | sql_errno= ER_UNKNOWN_ERROR; |
| 1159 | if (msg == NULL) |
| 1160 | msg= ER_THD(this, sql_errno); |
| 1161 | if (!*sqlstate) |
| 1162 | sqlstate= mysql_errno_to_sqlstate(sql_errno); |
| 1163 | |
| 1164 | if ((level == Sql_condition::WARN_LEVEL_WARN) && really_abort_on_warning()) |
| 1165 | { |
| 1166 | /* FIXME: push_warning and strict SQL_MODE case. */ |
| 1167 | level= Sql_condition::WARN_LEVEL_ERROR; |
| 1168 | } |
| 1169 | |
| 1170 | if (!is_fatal_error && |
| 1171 | handle_condition(sql_errno, sqlstate, &level, msg, &raised)) |
| 1172 | goto ret; |
| 1173 | |
| 1174 | switch (level) { |
| 1175 | case Sql_condition::WARN_LEVEL_WARN: |
| 1176 | mysql_audit_general(this, MYSQL_AUDIT_GENERAL_WARNING, sql_errno, msg); |
| 1177 | /* fall through */ |
| 1178 | case Sql_condition::WARN_LEVEL_NOTE: |
| 1179 | got_warning= 1; |
| 1180 | break; |
| 1181 | case Sql_condition::WARN_LEVEL_ERROR: |
no test coverage detected