| 105 | } |
| 106 | |
| 107 | static my_bool |
| 108 | emb_advanced_command(MYSQL *mysql, enum enum_server_command command, |
| 109 | const uchar *header, ulong header_length, |
| 110 | const uchar *arg, ulong arg_length, my_bool skip_check, |
| 111 | MYSQL_STMT *stmt) |
| 112 | { |
| 113 | my_bool result= 1; |
| 114 | THD *thd=(THD *) mysql->thd, *old_current_thd= current_thd; |
| 115 | NET *net= &mysql->net; |
| 116 | my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE; |
| 117 | |
| 118 | if (thd && thd->killed != NOT_KILLED) |
| 119 | { |
| 120 | if (thd->killed < KILL_CONNECTION) |
| 121 | thd->killed= NOT_KILLED; |
| 122 | else |
| 123 | { |
| 124 | free_embedded_thd(mysql); |
| 125 | if (old_current_thd == thd) |
| 126 | old_current_thd= 0; |
| 127 | thd= 0; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | if (!thd) |
| 132 | { |
| 133 | /* Do "reconnect" if possible */ |
| 134 | if (mysql_reconnect(mysql) || stmt_skip) |
| 135 | return 1; |
| 136 | thd= (THD *) mysql->thd; |
| 137 | } |
| 138 | |
| 139 | thd->clear_data_list(); |
| 140 | /* Check that we are calling the client functions in right order */ |
| 141 | if (mysql->status != MYSQL_STATUS_READY) |
| 142 | { |
| 143 | set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); |
| 144 | result= 1; |
| 145 | goto end; |
| 146 | } |
| 147 | |
| 148 | /* Clear result variables */ |
| 149 | thd->clear_error(1); |
| 150 | mysql->affected_rows= ~(my_ulonglong) 0; |
| 151 | mysql->field_count= 0; |
| 152 | net_clear_error(net); |
| 153 | thd->current_stmt= stmt; |
| 154 | |
| 155 | thd->thread_stack= (char*) &thd; |
| 156 | thd->store_globals(); // Fix if more than one connect |
| 157 | /* |
| 158 | We have to call free_old_query before we start to fill mysql->fields |
| 159 | for new query. In the case of embedded server we collect field data |
| 160 | during query execution (not during data retrieval as it is in remote |
| 161 | client). So we have to call free_old_query here |
| 162 | */ |
| 163 | free_old_query(mysql); |
| 164 |
no test coverage detected