

Public Member Functions | |
| Materialized_cursor (select_result *result, TABLE *table) | |
| virtual bool | is_open () const |
| virtual int | open (JOIN *join __attribute__((unused))) |
| virtual void | fetch (ulong num_rows) |
| virtual void | close () |
| virtual | ~Materialized_cursor () |
Private Attributes | |
| MEM_ROOT | main_mem_root |
| SELECT_LEX_UNIT | fake_unit |
| TABLE * | table |
| List< Item > | item_list |
| ulong | fetch_limit |
| ulong | fetch_count |
Definition at line 80 of file sql_cursor.cc.
| Materialized_cursor::Materialized_cursor | ( | select_result * | result, | |
| TABLE * | table | |||
| ) |
Definition at line 536 of file sql_cursor.cc.
References fake_unit, st_table::in_use, and table.
00538 :Server_side_cursor(&table_arg->mem_root, result_arg), 00539 table(table_arg), 00540 fetch_limit(0), 00541 fetch_count(0) 00542 { 00543 fake_unit.init_query(); 00544 fake_unit.thd= table->in_use; 00545 }
| Materialized_cursor::~Materialized_cursor | ( | ) | [virtual] |
| void Materialized_cursor::close | ( | ) | [virtual] |
Implements Server_side_cursor.
Definition at line 634 of file sql_cursor.cc.
References clear_alloc_root, st_table::file, free_items(), free_tmp_table(), handler::ha_rnd_end(), st_table::in_use, main_mem_root, st_table::mem_root, and table.
Referenced by fetch(), and ~Materialized_cursor().
00635 { 00636 /* Free item_list items */ 00637 free_items(); 00638 (void) table->file->ha_rnd_end(); 00639 /* 00640 We need to grab table->mem_root to prevent free_tmp_table from freeing: 00641 the cursor object was allocated in this memory. 00642 */ 00643 main_mem_root= table->mem_root; 00644 mem_root= &main_mem_root; 00645 clear_alloc_root(&table->mem_root); 00646 free_tmp_table(table->in_use, table); 00647 table= 0; 00648 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void Materialized_cursor::fetch | ( | ulong | num_rows | ) | [virtual] |
Implements Server_side_cursor.
Definition at line 600 of file sql_cursor.cc.
References close(), fetch_count, fetch_limit, st_table::file, HA_ERR_END_OF_FILE, st_table::in_use, item_list, MYF, handler::print_error(), st_table::record, Server_side_cursor::result, handler::rnd_next(), SERVER_STATUS_CURSOR_EXISTS, SERVER_STATUS_LAST_ROW_SENT, and table.
00601 { 00602 THD *thd= table->in_use; 00603 00604 int res= 0; 00605 result->begin_dataset(); 00606 for (fetch_limit+= num_rows; fetch_count < fetch_limit; fetch_count++) 00607 { 00608 if ((res= table->file->rnd_next(table->record[0]))) 00609 break; 00610 /* Send data only if the read was successful. */ 00611 result->send_data(item_list); 00612 } 00613 00614 switch (res) { 00615 case 0: 00616 thd->server_status|= SERVER_STATUS_CURSOR_EXISTS; 00617 result->send_eof(); 00618 thd->server_status&= ~SERVER_STATUS_CURSOR_EXISTS; 00619 break; 00620 case HA_ERR_END_OF_FILE: 00621 thd->server_status|= SERVER_STATUS_LAST_ROW_SENT; 00622 result->send_eof(); 00623 thd->server_status&= ~SERVER_STATUS_LAST_ROW_SENT; 00624 close(); 00625 break; 00626 default: 00627 table->file->print_error(res, MYF(0)); 00628 close(); 00629 break; 00630 } 00631 }
Here is the call graph for this function:

| virtual bool Materialized_cursor::is_open | ( | ) | const [inline, virtual] |
Implements Server_side_cursor.
Definition at line 92 of file sql_cursor.cc.
References table.
Referenced by ~Materialized_cursor().
00092 { return table != 0; }
Here is the caller graph for this function:

| int Materialized_cursor::open | ( | JOIN *join | __attribute__((unused)) | ) | [virtual] |
Definition at line 548 of file sql_cursor.cc.
References fake_unit, st_table::file, st_table::fill_item_list(), handler::ha_rnd_init(), item_list, Server_side_cursor::result, Protocol::SEND_NUM_ROWS, SERVER_STATUS_CURSOR_EXISTS, table, and TRUE.
Referenced by mysql_open_cursor().
00549 { 00550 THD *thd= fake_unit.thd; 00551 int rc; 00552 Query_arena backup_arena; 00553 00554 thd->set_n_backup_active_arena(this, &backup_arena); 00555 /* Create a list of fields and start sequential scan */ 00556 rc= (table->fill_item_list(&item_list) || 00557 result->prepare(item_list, &fake_unit) || 00558 table->file->ha_rnd_init(TRUE)); 00559 thd->restore_active_arena(this, &backup_arena); 00560 if (rc == 0) 00561 { 00562 /* 00563 Now send the result set metadata to the client. We need to 00564 do it here, as in Select_materialize::send_fields the items 00565 for column types are not yet created (send_fields requires 00566 a list of items). The new types may differ from the original 00567 ones sent at prepare if some of them were altered by MySQL 00568 HEAP tables mechanism -- used when create_tmp_field_from_item 00569 may alter the original column type. 00570 00571 We can't simply supply SEND_EOF flag to send_fields, because 00572 send_fields doesn't flush the network buffer. 00573 */ 00574 rc= result->send_fields(item_list, Protocol::SEND_NUM_ROWS); 00575 thd->server_status|= SERVER_STATUS_CURSOR_EXISTS; 00576 result->send_eof(); 00577 thd->server_status&= ~SERVER_STATUS_CURSOR_EXISTS; 00578 } 00579 return rc; 00580 }
Here is the call graph for this function:

Here is the caller graph for this function:

SELECT_LEX_UNIT Materialized_cursor::fake_unit [private] |
ulong Materialized_cursor::fetch_count [private] |
ulong Materialized_cursor::fetch_limit [private] |
List<Item> Materialized_cursor::item_list [private] |
MEM_ROOT Materialized_cursor::main_mem_root [private] |
TABLE* Materialized_cursor::table [private] |
Definition at line 85 of file sql_cursor.cc.
Referenced by close(), fetch(), is_open(), Materialized_cursor(), and open().
1.4.7

