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

Method assign_defaults

sql/sql_error.cc:238–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236
237
238void Sql_state_errno_level::assign_defaults(THD *thd,
239 const Sql_state_errno *from)
240{
241 DBUG_ASSERT(from);
242 int sqlerrno= from->get_sql_errno();
243 /*
244 SIGNAL is restricted in sql_yacc.yy to only signal SQLSTATE conditions.
245 */
246 DBUG_ASSERT(from->has_sql_state());
247 set_sqlstate(from);
248 /* SQLSTATE class "00": illegal, rejected in the parser. */
249 DBUG_ASSERT(m_sqlstate[0] != '0' || get_sqlstate()[1] != '0');
250
251 if (Sql_state::is_warning()) /* SQLSTATE class "01": warning. */
252 {
253 m_level= Sql_condition::WARN_LEVEL_WARN;
254 m_sql_errno= sqlerrno ? sqlerrno : ER_SIGNAL_WARN;
255 }
256 else if (Sql_state::is_not_found()) /* SQLSTATE class "02": not found. */
257 {
258 m_level= Sql_condition::WARN_LEVEL_ERROR;
259 if (sqlerrno)
260 m_sql_errno= sqlerrno;
261 else
262 {
263 if ((thd->in_sub_stmt & (SUB_STMT_TRIGGER | SUB_STMT_BEFORE_TRIGGER)) ==
264 (SUB_STMT_TRIGGER | SUB_STMT_BEFORE_TRIGGER) &&
265 strcmp(get_sqlstate(), "02TRG") == 0)
266 m_sql_errno= ER_SIGNAL_SKIP_ROW_FROM_TRIGGER;
267 else
268 m_sql_errno= ER_SIGNAL_NOT_FOUND;
269 }
270 }
271 else /* other SQLSTATE classes : error. */
272 {
273 m_level= Sql_condition::WARN_LEVEL_ERROR;
274 m_sql_errno= sqlerrno ? sqlerrno : ER_SIGNAL_EXCEPTION;
275 }
276}
277
278
279void Sql_condition::assign_defaults(THD *thd, const Sql_state_errno *from)

Callers 1

raise_conditionMethod · 0.80

Calls 2

get_sql_errnoMethod · 0.80
has_sql_stateMethod · 0.80

Tested by

no test coverage detected