| 3009 | */ |
| 3010 | |
| 3011 | TABLE *Delayed_insert::get_local_table(THD* client_thd) |
| 3012 | { |
| 3013 | my_ptrdiff_t adjust_ptrs; |
| 3014 | Field **field,**org_field, *found_next_number_field; |
| 3015 | TABLE *copy; |
| 3016 | TABLE_SHARE *share; |
| 3017 | uchar *bitmap; |
| 3018 | char *copy_tmp; |
| 3019 | uint bitmaps_used; |
| 3020 | Field **default_fields, **virtual_fields; |
| 3021 | uchar *record; |
| 3022 | DBUG_ENTER("Delayed_insert::get_local_table"); |
| 3023 | |
| 3024 | /* First request insert thread to get a lock */ |
| 3025 | status=1; |
| 3026 | tables_in_use++; |
| 3027 | if (!thd.lock) // Table is not locked |
| 3028 | { |
| 3029 | THD_STAGE_INFO(client_thd, stage_waiting_for_handler_lock); |
| 3030 | mysql_cond_signal(&cond); // Tell handler to lock table |
| 3031 | while (!thd.killed && !thd.lock && ! client_thd->killed) |
| 3032 | { |
| 3033 | mysql_cond_wait(&cond_client, &mutex); |
| 3034 | } |
| 3035 | THD_STAGE_INFO(client_thd, stage_got_handler_lock); |
| 3036 | if (client_thd->killed) |
| 3037 | goto error2; |
| 3038 | if (thd.killed) |
| 3039 | { |
| 3040 | /* |
| 3041 | Check how the insert thread was killed. If it was killed |
| 3042 | by FLUSH TABLES which calls kill_delayed_threads_for_table(), |
| 3043 | then is_error is not set. |
| 3044 | In this case, return without setting an error, |
| 3045 | which means that the insert will be converted to a normal insert. |
| 3046 | */ |
| 3047 | if (thd.is_error()) |
| 3048 | { |
| 3049 | /* |
| 3050 | Copy the error message. Note that we don't treat fatal |
| 3051 | errors in the delayed thread as fatal errors in the |
| 3052 | main thread. If delayed thread was killed, we don't |
| 3053 | want to send "Server shutdown in progress" in the |
| 3054 | INSERT THREAD. |
| 3055 | |
| 3056 | The thread could be killed with an error message if |
| 3057 | di->handle_inserts() or di->open_and_lock_table() fails. |
| 3058 | */ |
| 3059 | my_message(thd.get_stmt_da()->sql_errno(), |
| 3060 | thd.get_stmt_da()->message(), MYF(0)); |
| 3061 | } |
| 3062 | goto error2; |
| 3063 | } |
| 3064 | } |
| 3065 | share= table->s; |
| 3066 | |
| 3067 | /* |
| 3068 | Allocate memory for the TABLE object, the field pointers array, |
no test coverage detected