|
24 | 24 | #include "probes_mysql.h"
|
25 | 25 | #include "sql_parse.h" // mysql_execute_command
|
26 | 26 |
|
27 |
| -/**************************************************************************** |
28 |
| - Declarations. |
29 |
| -****************************************************************************/ |
30 |
| - |
31 |
| -/** |
32 |
| - Materialized_cursor -- an insensitive materialized server-side |
33 |
| - cursor. The result set of this cursor is saved in a temporary |
34 |
| - table at open. The cursor itself is simply an interface for the |
35 |
| - handler of the temporary table. |
36 |
| -*/ |
37 |
| - |
38 |
| -class Materialized_cursor: public Server_side_cursor |
39 |
| -{ |
40 |
| - MEM_ROOT main_mem_root; |
41 |
| - /* A fake unit to supply to select_send when fetching */ |
42 |
| - SELECT_LEX_UNIT fake_unit; |
43 |
| - TABLE *table; |
44 |
| - List<Item> item_list; |
45 |
| - ulong fetch_limit; |
46 |
| - ulong fetch_count; |
47 |
| - bool is_rnd_inited; |
48 |
| -public: |
49 |
| - Materialized_cursor(select_result *result, TABLE *table); |
50 |
| - |
51 |
| - int send_result_set_metadata(THD *thd, List<Item> &send_result_set_metadata); |
52 |
| - bool is_open() const override { return table != 0; } |
53 |
| - int open(JOIN *join __attribute__((unused))) override; |
54 |
| - void fetch(ulong num_rows) override; |
55 |
| - void close() override; |
56 |
| - bool export_structure(THD *thd, Row_definition_list *defs) override |
57 |
| - { |
58 |
| - return table->export_structure(thd, defs); |
59 |
| - } |
60 |
| - ~Materialized_cursor() override; |
61 |
| - |
62 |
| - void on_table_fill_finished(); |
63 |
| -}; |
64 |
| - |
65 |
| - |
66 |
| -/** |
67 |
| - Select_materialize -- a mediator between a cursor query and the |
68 |
| - protocol. In case we were not able to open a non-materialzed |
69 |
| - cursor, it creates an internal temporary HEAP table, and insert |
70 |
| - all rows into it. When the table reaches max_heap_table_size, |
71 |
| - it's converted to a MyISAM table. Later this table is used to |
72 |
| - create a Materialized_cursor. |
73 |
| -*/ |
74 |
| - |
75 |
| -class Select_materialize: public select_unit |
76 |
| -{ |
77 |
| - select_result *result; /**< the result object of the caller (PS or SP) */ |
78 |
| -public: |
79 |
| - Materialized_cursor *materialized_cursor; |
80 |
| - Select_materialize(THD *thd_arg, select_result *result_arg): |
81 |
| - select_unit(thd_arg), result(result_arg), materialized_cursor(0) {} |
82 |
| - bool send_result_set_metadata(List<Item> &list, uint flags) override; |
83 |
| - bool send_eof() override { return false; } |
84 |
| - bool view_structure_only() const override |
85 |
| - { |
86 |
| - return result->view_structure_only(); |
87 |
| - } |
88 |
| -}; |
89 |
| - |
90 |
| - |
91 |
| -/**************************************************************************/ |
92 |
| - |
93 | 27 | /**
|
94 | 28 | Attempt to open a materialized cursor.
|
95 | 29 |
|
|
0 commit comments