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-1335 USA */ 17 18 #ifdef USE_PRAGMA_INTERFACE 19 #pragma interface /* gcc class implementation */ 20 #endif 21 22 #include "table.h" 23 24 struct st_join_table; 25 class handler; 26 class THD; 27 class SQL_SELECT; 28 class Copy_field; 29 class SORT_INFO; 30 31 struct READ_RECORD; 32 33 void end_read_record(READ_RECORD *info); 34 void free_cache(READ_RECORD *info); 35 36 /** 37 A context for reading through a single table using a chosen access method: 38 index read, scan, etc, use of cache, etc. 39 40 Use by: 41 READ_RECORD read_record; 42 init_read_record(&read_record, ...); 43 while (read_record.read_record()) 44 { 45 ... 46 } 47 end_read_record(); 48 */ 49 50 struct READ_RECORD 51 { 52 typedef int (*Read_func)(READ_RECORD*); 53 typedef void (*Unlock_row_func)(st_join_table *); 54 typedef int (*Setup_func)(struct st_join_table*); 55 56 TABLE *table; /* Head-form */ 57 Unlock_row_func unlock_row; 58 Read_func read_record_func; 59 THD *thd; 60 SQL_SELECT *select; 61 uint ref_length, reclength, rec_cache_size, error_offset; 62 uchar *ref_pos; /* pointer to form->refpos */ 63 uchar *rec_buf; /* to read field values after filesort */ 64 uchar *cache,*cache_pos,*cache_end,*read_positions; 65 struct st_sort_addon_field *addon_field; /* Pointer to the fields info */ 66 struct st_io_cache *io_cache; 67 bool print_error; 68 void (*unpack)(struct st_sort_addon_field *, uchar *, uchar *); 69 read_recordREAD_RECORD70 int read_record() { return read_record_func(this); } recordREAD_RECORD71 uchar *record() const { return table->record[0]; } 72 73 /* 74 SJ-Materialization runtime may need to read fields from the materialized 75 table and unpack them into original table fields: 76 */ 77 Copy_field *copy_field; 78 Copy_field *copy_field_end; 79 public: READ_RECORDREAD_RECORD80 READ_RECORD() : table(NULL), cache(NULL) {} ~READ_RECORDREAD_RECORD81 ~READ_RECORD() { end_read_record(this); } 82 }; 83 84 bool init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form, 85 SQL_SELECT *select, SORT_INFO *sort, 86 int use_record_cache, 87 bool print_errors, bool disable_rr_cache); 88 bool init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table, 89 bool print_error, uint idx, bool reverse); 90 91 void rr_unlock_row(st_join_table *tab); 92 93 #endif /* SQL_RECORDS_H */ 94