| 287 | */ |
| 288 | |
| 289 | void Materialized_cursor::fetch(ulong num_rows) |
| 290 | { |
| 291 | THD *thd= table->in_use; |
| 292 | |
| 293 | int res= 0; |
| 294 | result->begin_dataset(); |
| 295 | for (fetch_limit+= num_rows; fetch_count < fetch_limit; fetch_count++) |
| 296 | { |
| 297 | if ((res= table->file->ha_rnd_next(table->record[0]))) |
| 298 | break; |
| 299 | /* Send data only if the read was successful. */ |
| 300 | /* |
| 301 | If network write failed (i.e. due to a closed socked), |
| 302 | the error has already been set. Just return. |
| 303 | */ |
| 304 | if (result->send_data(item_list) > 0) |
| 305 | return; |
| 306 | } |
| 307 | |
| 308 | switch (res) { |
| 309 | case 0: |
| 310 | thd->server_status|= SERVER_STATUS_CURSOR_EXISTS; |
| 311 | result->send_eof(); |
| 312 | break; |
| 313 | case HA_ERR_END_OF_FILE: |
| 314 | thd->server_status|= SERVER_STATUS_LAST_ROW_SENT; |
| 315 | result->send_eof(); |
| 316 | close(); |
| 317 | break; |
| 318 | default: |
| 319 | table->file->print_error(res, MYF(0)); |
| 320 | close(); |
| 321 | break; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | |
| 326 | void Materialized_cursor::close() |
no test coverage detected