| 1362 | */ |
| 1363 | |
| 1364 | Trigger *Table_triggers_list::find_trigger(const LEX_CSTRING *name, |
| 1365 | bool remove_from_list) |
| 1366 | { |
| 1367 | Trigger *trigger = nullptr; |
| 1368 | |
| 1369 | for (uint i= 0; i < (uint)TRG_EVENT_MAX; i++) |
| 1370 | { |
| 1371 | for (uint j= 0; j < (uint)TRG_ACTION_MAX; j++) |
| 1372 | { |
| 1373 | Trigger **parent; |
| 1374 | |
| 1375 | for (parent= &triggers[i][j]; |
| 1376 | (trigger= *parent); |
| 1377 | parent= &trigger->next[i]) |
| 1378 | { |
| 1379 | if (trigger->name.streq(*name)) |
| 1380 | { |
| 1381 | if (remove_from_list) |
| 1382 | { |
| 1383 | *parent= trigger->next[i]; |
| 1384 | count--; |
| 1385 | /* |
| 1386 | in case only one event left or was assigned to this trigger |
| 1387 | return it, else continue iterations to remove the trigger |
| 1388 | from all events entries. |
| 1389 | */ |
| 1390 | if (trigger->events != (1 << i)) |
| 1391 | { |
| 1392 | /* |
| 1393 | Turn off event bits in the mask as the trigger is removed |
| 1394 | from the array for corresponding trigger event action. |
| 1395 | Eventually, we come to the last event this trigger is |
| 1396 | associated to. The associated trigger be returned from |
| 1397 | the method and finally deleted. |
| 1398 | */ |
| 1399 | trigger->events &= ~(1 << i); |
| 1400 | continue; |
| 1401 | } |
| 1402 | } |
| 1403 | return trigger; |
| 1404 | } |
| 1405 | } |
| 1406 | } |
| 1407 | } |
| 1408 | /* |
| 1409 | We come to this point if either remove_from_list == true and |
| 1410 | the trigger is associated with multiple events, or there is no a trigger |
| 1411 | with requested name. |
| 1412 | */ |
| 1413 | return trigger; |
| 1414 | } |
| 1415 | |
| 1416 | |
| 1417 | /** |
no test coverage detected