| 4250 | **************************************************************************/ |
| 4251 | |
| 4252 | static MYSQL_RES * cli_use_result(MYSQL *mysql) |
| 4253 | { |
| 4254 | MYSQL_RES *result; |
| 4255 | DBUG_ENTER("cli_use_result"); |
| 4256 | |
| 4257 | if (!mysql->fields) |
| 4258 | DBUG_RETURN(0); |
| 4259 | if (mysql->status != MYSQL_STATUS_GET_RESULT) |
| 4260 | { |
| 4261 | set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); |
| 4262 | DBUG_RETURN(0); |
| 4263 | } |
| 4264 | if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result)+ |
| 4265 | sizeof(ulong)*mysql->field_count, |
| 4266 | MYF(MY_WME | MY_ZEROFILL)))) |
| 4267 | DBUG_RETURN(0); |
| 4268 | result->lengths=(ulong*) (result+1); |
| 4269 | result->methods= mysql->methods; |
| 4270 | if (!(result->row=(MYSQL_ROW) |
| 4271 | my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME)))) |
| 4272 | { /* Ptrs: to one row */ |
| 4273 | my_free(result); |
| 4274 | DBUG_RETURN(0); |
| 4275 | } |
| 4276 | result->fields= mysql->fields; |
| 4277 | result->field_alloc= mysql->field_alloc; |
| 4278 | result->field_count= mysql->field_count; |
| 4279 | result->current_field=0; |
| 4280 | result->handle= mysql; |
| 4281 | result->current_row= 0; |
| 4282 | mysql->fields=0; /* fields is now in result */ |
| 4283 | clear_alloc_root(&mysql->field_alloc); |
| 4284 | mysql->status=MYSQL_STATUS_USE_RESULT; |
| 4285 | mysql->unbuffered_fetch_owner= &result->unbuffered_fetch_cancelled; |
| 4286 | DBUG_RETURN(result); /* Data is read to be fetched */ |
| 4287 | } |
| 4288 | |
| 4289 | |
| 4290 | /************************************************************************** |
no test coverage detected