~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/records.h

  • Committer: Brian Aker
  • Date: 2009-12-06 01:55:53 UTC
  • mfrom: (1238.1.5 push)
  • Revision ID: brian@gaz-20091206015553-cva833q4gvwj11ob
Bundle for staging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2009 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
#ifndef DRIZZLED_RECORDS_H
 
21
#define DRIZZLED_RECORDS_H
 
22
 
 
23
/**
 
24
  Initialize READ_RECORD structure to perform full index scan (in forward
 
25
  direction) using read_record.read_record() interface.
 
26
 
 
27
    This function has been added at late stage and is used only by
 
28
    UPDATE/DELETE. Other statements perform index scans using
 
29
    join_read_first/next functions.
 
30
 
 
31
  @param info         READ_RECORD structure to initialize.
 
32
  @param session          Thread handle
 
33
  @param table        Table to be accessed
 
34
  @param print_error  If true, call table->print_error() if an error
 
35
                      occurs (except for end-of-records error)
 
36
  @param idx          index to scan
 
37
*/
 
38
void init_read_record_idx(READ_RECORD *info, 
 
39
                          Session *session, 
 
40
                          Table *table,
 
41
                          bool print_error, 
 
42
                          uint32_t idx);
 
43
 
 
44
/*
 
45
  init_read_record is used to scan by using a number of different methods.
 
46
  Which method to use is set-up in this call so that later calls to
 
47
  the info->read_record will call the appropriate method using a function
 
48
  pointer.
 
49
 
 
50
  There are five methods that relate completely to the sort function
 
51
  filesort. The result of a filesort is retrieved using read_record
 
52
  calls. The other two methods are used for normal table access.
 
53
 
 
54
  The filesort will produce references to the records sorted, these
 
55
  references can be stored in memory or in a temporary cursor.
 
56
 
 
57
  The temporary cursor is normally used when the references doesn't fit into
 
58
  a properly sized memory buffer. For most small queries the references
 
59
  are stored in the memory buffer.
 
60
 
 
61
  The temporary cursor is also used when performing an update where a key is
 
62
  modified.
 
63
 
 
64
  Methods used when ref's are in memory (using rr_from_pointers):
 
65
    rr_unpack_from_buffer:
 
66
    ----------------------
 
67
      This method is used when table->sort.addon_field is allocated.
 
68
      This is allocated for most SELECT queries not involving any BLOB's.
 
69
      In this case the records are fetched from a memory buffer.
 
70
    rr_from_pointers:
 
71
    -----------------
 
72
      Used when the above is not true, UPDATE, DELETE and so forth and
 
73
      SELECT's involving BLOB's. It is also used when the addon_field
 
74
      buffer is not allocated due to that its size was bigger than the
 
75
      session variable max_length_for_sort_data.
 
76
      In this case the record data is fetched from the handler using the
 
77
      saved reference using the rnd_pos handler call.
 
78
 
 
79
  Methods used when ref's are in a temporary cursor (using rr_from_tempfile)
 
80
    rr_unpack_from_tempfile:
 
81
    ------------------------
 
82
      Same as rr_unpack_from_buffer except that references are fetched from
 
83
      temporary cursor. Should obviously not really happen other than in
 
84
      strange configurations.
 
85
 
 
86
    rr_from_tempfile:
 
87
    -----------------
 
88
      Same as rr_from_pointers except that references are fetched from
 
89
      temporary cursor instead of from
 
90
    rr_from_cache:
 
91
    --------------
 
92
      This is a special variant of rr_from_tempfile that can be used for
 
93
      handlers that is not using the HA_FAST_KEY_READ table flag. Instead
 
94
      of reading the references one by one from the temporary cursor it reads
 
95
      a set of them, sorts them and reads all of them into a buffer which
 
96
      is then used for a number of subsequent calls to rr_from_cache.
 
97
      It is only used for SELECT queries and a number of other conditions
 
98
      on table size.
 
99
 
 
100
  All other accesses use either index access methods (rr_quick) or a full
 
101
  table scan (rr_sequential).
 
102
  rr_quick:
 
103
  ---------
 
104
    rr_quick uses one of the QUICK_SELECT classes in optimizer/range.cc to
 
105
    perform an index scan. There are loads of functionality hidden
 
106
    in these quick classes. It handles all index scans of various kinds.
 
107
  rr_sequential:
 
108
  --------------
 
109
    This is the most basic access method of a table using rnd_init,
 
110
    rnd_next and rnd_end. No indexes are used.
 
111
*/
 
112
void init_read_record(READ_RECORD *info, 
 
113
                      Session *session, 
 
114
                      Table *reg_form,
 
115
                      drizzled::optimizer::SQL_SELECT *select,
 
116
                      int use_record_cache, 
 
117
                      bool print_errors);
 
118
 
 
119
void end_read_record(READ_RECORD *info);
 
120
 
 
121
#endif /* DRIZZLED_RECORDS_H */