1 #ifndef SQL_RECORDS_H 2 #define SQL_RECORDS_H 3 /* Copyright (c) 2008, 2018, 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, version 2.0, 7 as published by the Free Software Foundation. 8 9 This program is also distributed with certain software (including 10 but not limited to OpenSSL) that is licensed under separate terms, 11 as designated in a particular file or component or in included license 12 documentation. The authors of MySQL hereby grant you an additional 13 permission to link the program and your derivative works with the 14 separately licensed software that they have included with MySQL. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License, version 2.0, for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with this program; if not, write to the Free Software Foundation, 23 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 24 25 #include <my_global.h> /* for uint typedefs */ 26 #include "my_base.h" 27 28 class QEP_TAB; 29 class handler; 30 struct TABLE; 31 class THD; 32 33 /** 34 A context for reading through a single table using a chosen access method: 35 index read, scan, etc, use of cache, etc. 36 37 Use by: 38 @code 39 READ_RECORD read_record; 40 if (init_read_record(&read_record, ...)) 41 return TRUE; 42 while (read_record.read_record()) 43 { 44 ... 45 } 46 end_read_record(); 47 @endcode 48 */ 49 50 class QUICK_SELECT_I; 51 52 struct READ_RECORD 53 { 54 typedef int (*Read_func)(READ_RECORD*); 55 typedef void (*Unlock_row_func)(QEP_TAB *); 56 typedef int (*Setup_func)(QEP_TAB*); 57 58 TABLE *table; /* Head-form */ 59 TABLE **forms; /* head and ref forms */ 60 Unlock_row_func unlock_row; 61 Read_func read_record; 62 THD *thd; 63 QUICK_SELECT_I *quick; 64 uint cache_records; 65 uint ref_length,struct_length,reclength,rec_cache_size,error_offset; 66 67 /** 68 Counting records when reading result from filesort(). 69 Used when filesort leaves the result in the filesort buffer. 70 */ 71 ha_rows unpack_counter; 72 73 uchar *ref_pos; /* pointer to form->refpos */ 74 uchar *record; 75 uchar *rec_buf; /* to read field values after filesort */ 76 uchar *cache,*cache_pos,*cache_end,*read_positions; 77 struct st_io_cache *io_cache; 78 bool print_error, ignore_not_found_rows; 79 80 public: READ_RECORDREAD_RECORD81 READ_RECORD() { memset(this, 0, sizeof(*this)); } 82 }; 83 84 bool init_read_record(READ_RECORD *info, THD *thd, 85 TABLE *table, QEP_TAB *qep_tab, 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 void end_read_record(READ_RECORD *info); 91 92 void rr_unlock_row(QEP_TAB *tab); 93 int rr_sequential(READ_RECORD *info); 94 95 #endif /* SQL_RECORDS_H */ 96