1 | #ifndef SQL_RECORDS_H |
2 | #define SQL_RECORDS_H |
3 | /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; version 2 of the License. |
8 | |
9 | This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU General Public License |
15 | along with this program; if not, write to the Free Software |
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
17 | |
18 | #ifdef USE_PRAGMA_INTERFACE |
19 | #pragma interface /* gcc class implementation */ |
20 | #endif |
21 | |
22 | struct st_join_table; |
23 | class handler; |
24 | struct TABLE; |
25 | class THD; |
26 | class SQL_SELECT; |
27 | class Copy_field; |
28 | class SORT_INFO; |
29 | |
30 | struct READ_RECORD; |
31 | |
32 | void end_read_record(READ_RECORD *info); |
33 | |
34 | /** |
35 | A context for reading through a single table using a chosen access method: |
36 | index read, scan, etc, use of cache, etc. |
37 | |
38 | Use by: |
39 | READ_RECORD read_record; |
40 | init_read_record(&read_record, ...); |
41 | while (read_record.read_record()) |
42 | { |
43 | ... |
44 | } |
45 | end_read_record(); |
46 | */ |
47 | |
48 | struct READ_RECORD |
49 | { |
50 | typedef int (*Read_func)(READ_RECORD*); |
51 | typedef void (*Unlock_row_func)(st_join_table *); |
52 | typedef int (*Setup_func)(struct st_join_table*); |
53 | |
54 | TABLE *table; /* Head-form */ |
55 | //handler *file; |
56 | TABLE **forms; /* head and ref forms */ |
57 | Unlock_row_func unlock_row; |
58 | Read_func read_record_func; |
59 | THD *thd; |
60 | SQL_SELECT *select; |
61 | uint cache_records; |
62 | uint ref_length,struct_length,reclength,rec_cache_size,error_offset; |
63 | uint index; |
64 | uchar *ref_pos; /* pointer to form->refpos */ |
65 | uchar *record; |
66 | uchar *rec_buf; /* to read field values after filesort */ |
67 | uchar *cache,*cache_pos,*cache_end,*read_positions; |
68 | struct st_sort_addon_field *addon_field; /* Pointer to the fields info */ |
69 | struct st_io_cache *io_cache; |
70 | bool print_error; |
71 | void (*unpack)(struct st_sort_addon_field *, uchar *, uchar *); |
72 | |
73 | int read_record() { return read_record_func(this); } |
74 | |
75 | /* |
76 | SJ-Materialization runtime may need to read fields from the materialized |
77 | table and unpack them into original table fields: |
78 | */ |
79 | Copy_field *copy_field; |
80 | Copy_field *copy_field_end; |
81 | public: |
82 | READ_RECORD() : table(NULL), cache(NULL) {} |
83 | ~READ_RECORD() { end_read_record(this); } |
84 | }; |
85 | |
86 | bool init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form, |
87 | SQL_SELECT *select, SORT_INFO *sort, |
88 | int use_record_cache, |
89 | bool print_errors, bool disable_rr_cache); |
90 | bool init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table, |
91 | bool print_error, uint idx, bool reverse); |
92 | |
93 | void rr_unlock_row(st_join_table *tab); |
94 | |
95 | #endif /* SQL_RECORDS_H */ |
96 | |