Helper function to get the error code of the query to be binlogged. */
| 2256 | Helper function to get the error code of the query to be binlogged. |
| 2257 | */ |
| 2258 | int query_error_code(THD *thd, bool not_killed) |
| 2259 | { |
| 2260 | int error; |
| 2261 | |
| 2262 | if (not_killed || (thd->killed == THD::KILL_BAD_DATA)) |
| 2263 | { |
| 2264 | error= thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0; |
| 2265 | |
| 2266 | /* thd->get_stmt_da()->sql_errno() might be ER_SERVER_SHUTDOWN or |
| 2267 | ER_QUERY_INTERRUPTED, So here we need to make sure that error |
| 2268 | is not set to these errors when specified not_killed by the |
| 2269 | caller. |
| 2270 | */ |
| 2271 | if (error == ER_SERVER_SHUTDOWN || error == ER_QUERY_INTERRUPTED) |
| 2272 | error= 0; |
| 2273 | } |
| 2274 | else |
| 2275 | { |
| 2276 | /* killed status for DELAYED INSERT thread should never be used */ |
| 2277 | DBUG_ASSERT(!(thd->system_thread & SYSTEM_THREAD_DELAYED_INSERT)); |
| 2278 | error= thd->killed_errno(); |
| 2279 | } |
| 2280 | |
| 2281 | return error; |
| 2282 | } |
| 2283 | |
| 2284 | |
| 2285 | /** |
no outgoing calls
no test coverage detected