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

Method raise_condition

sql/sql_class.cc:1124–1228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1122}
1123
1124Sql_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:

Callers 2

my_message_sqlFunction · 0.45
push_warningFunction · 0.45

Calls 12

mysql_errno_to_sqlstateFunction · 0.85
mysql_audit_generalFunction · 0.85
get_sql_errnoMethod · 0.80
get_levelMethod · 0.80
get_message_textMethod · 0.80
copy_opt_attributesMethod · 0.80
wsrep_must_replayFunction · 0.70
get_sqlstateMethod · 0.45
is_errorMethod · 0.45
set_error_statusMethod · 0.45
push_warningMethod · 0.45

Tested by

no test coverage detected