~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handler_structs.h

  • Committer: Brian Aker
  • Date: 2008-11-07 23:16:58 UTC
  • mfrom: (575.1.14 devel)
  • Revision ID: brian@tangent.org-20081107231658-fboahr524d1or2ya
Merge from Monty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 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_HANDLER_STRUCTS_H
 
21
#define DRIZZLED_HANDLER_STRUCTS_H
 
22
 
 
23
#include CSTDINT_H
 
24
#include <time.h>
 
25
 
 
26
#include <drizzled/base.h>
 
27
#include <drizzled/structs.h>
 
28
#include <drizzled/definitions.h>
 
29
#include <drizzled/lex_string.h>
 
30
 
 
31
class Ha_trx_info;
 
32
struct handlerton;
 
33
struct st_key;
 
34
typedef struct st_key KEY;
 
35
struct st_key_cache;
 
36
typedef struct st_key_cache KEY_CACHE;
 
37
 
 
38
struct Session_TRANS
 
39
{
 
40
  /* true is not all entries in the ht[] support 2pc */
 
41
  bool        no_2pc;
 
42
  /* storage engines that registered in this transaction */
 
43
  Ha_trx_info *ha_list;
 
44
  /*
 
45
    The purpose of this flag is to keep track of non-transactional
 
46
    tables that were modified in scope of:
 
47
    - transaction, when the variable is a member of
 
48
    Session::transaction.all
 
49
    - top-level statement or sub-statement, when the variable is a
 
50
    member of Session::transaction.stmt
 
51
    This member has the following life cycle:
 
52
    * stmt.modified_non_trans_table is used to keep track of
 
53
    modified non-transactional tables of top-level statements. At
 
54
    the end of the previous statement and at the beginning of the session,
 
55
    it is reset to false.  If such functions
 
56
    as mysql_insert, mysql_update, mysql_delete etc modify a
 
57
    non-transactional table, they set this flag to true.  At the
 
58
    end of the statement, the value of stmt.modified_non_trans_table
 
59
    is merged with all.modified_non_trans_table and gets reset.
 
60
    * all.modified_non_trans_table is reset at the end of transaction
 
61
 
 
62
    * Since we do not have a dedicated context for execution of a
 
63
    sub-statement, to keep track of non-transactional changes in a
 
64
    sub-statement, we re-use stmt.modified_non_trans_table.
 
65
    At entrance into a sub-statement, a copy of the value of
 
66
    stmt.modified_non_trans_table (containing the changes of the
 
67
    outer statement) is saved on stack. Then
 
68
    stmt.modified_non_trans_table is reset to false and the
 
69
    substatement is executed. Then the new value is merged with the
 
70
    saved value.
 
71
  */
 
72
  bool modified_non_trans_table;
 
73
 
 
74
  void reset() { no_2pc= false; modified_non_trans_table= false; }
 
75
};
 
76
 
 
77
typedef struct {
 
78
  uint64_t data_file_length;
 
79
  uint64_t max_data_file_length;
 
80
  uint64_t index_file_length;
 
81
  uint64_t delete_length;
 
82
  ha_rows records;
 
83
  uint32_t mean_rec_length;
 
84
  time_t create_time;
 
85
  time_t check_time;
 
86
  time_t update_time;
 
87
  uint64_t check_sum;
 
88
} PARTITION_INFO;
 
89
 
 
90
typedef struct st_ha_create_information
 
91
{
 
92
  const CHARSET_INFO *table_charset, *default_table_charset;
 
93
  LEX_STRING connect_string;
 
94
  LEX_STRING comment;
 
95
  const char *data_file_name, *index_file_name;
 
96
  const char *alias;
 
97
  uint64_t max_rows,min_rows;
 
98
  uint64_t auto_increment_value;
 
99
  uint32_t table_options;
 
100
  uint32_t avg_row_length;
 
101
  uint32_t used_fields;
 
102
  uint32_t key_block_size;
 
103
  uint32_t block_size;
 
104
  handlerton *db_type;
 
105
  enum row_type row_type;
 
106
  uint32_t null_bits;                       /* NULL bits at start of record */
 
107
  uint32_t options;                         /* OR of HA_CREATE_ options */
 
108
  uint32_t extra_size;                      /* length of extra data segment */
 
109
  bool table_existed;                   /* 1 in create if table existed */
 
110
  bool frm_only;                        /* 1 if no ha_create_table() */
 
111
  bool varchar;                         /* 1 if table has a VARCHAR */
 
112
  enum ha_choice page_checksum;         /* If we have page_checksums */
 
113
} HA_CREATE_INFO;
 
114
 
 
115
typedef struct st_ha_alter_information
 
116
{
 
117
  KEY  *key_info_buffer;
 
118
  uint32_t key_count;
 
119
  uint32_t index_drop_count;
 
120
  uint32_t *index_drop_buffer;
 
121
  uint32_t index_add_count;
 
122
  uint32_t *index_add_buffer;
 
123
  void *data;
 
124
} HA_ALTER_INFO;
 
125
 
 
126
 
 
127
typedef struct st_key_create_information
 
128
{
 
129
  enum ha_key_alg algorithm;
 
130
  uint32_t block_size;
 
131
  LEX_STRING parser_name;
 
132
  LEX_STRING comment;
 
133
} KEY_CREATE_INFO;
 
134
 
 
135
 
 
136
typedef struct st_ha_check_opt
 
137
{
 
138
  st_ha_check_opt() {}                        /* Remove gcc warning */
 
139
  uint32_t sort_buffer_size;
 
140
  uint32_t flags;       /* isam layer flags (e.g. for myisamchk) */
 
141
  /* sql layer flags - for something myisamchk cannot do */
 
142
  uint32_t sql_flags;
 
143
  /* new key cache when changing key cache */
 
144
  KEY_CACHE *key_cache;
 
145
  void init();
 
146
} HA_CHECK_OPT;
 
147
 
 
148
 
 
149
typedef struct st_range_seq_if
 
150
{
 
151
  /*
 
152
    Initialize the traversal of range sequence
 
153
 
 
154
    SYNOPSIS
 
155
    init()
 
156
    init_params  The seq_init_param parameter
 
157
    n_ranges     The number of ranges obtained
 
158
    flags        A combination of HA_MRR_SINGLE_POINT, HA_MRR_FIXED_KEY
 
159
 
 
160
    RETURN
 
161
    An opaque value to be used as RANGE_SEQ_IF::next() parameter
 
162
  */
 
163
  range_seq_t (*init)(void *init_params, uint32_t n_ranges, uint32_t flags);
 
164
 
 
165
 
 
166
  /*
 
167
    Get the next range in the range sequence
 
168
 
 
169
    SYNOPSIS
 
170
    next()
 
171
    seq    The value returned by RANGE_SEQ_IF::init()
 
172
    range  OUT Information about the next range
 
173
 
 
174
    RETURN
 
175
    0 - Ok, the range structure filled with info about the next range
 
176
    1 - No more ranges
 
177
  */
 
178
  uint32_t (*next) (range_seq_t seq, KEY_MULTI_RANGE *range);
 
179
} RANGE_SEQ_IF;
 
180
 
 
181
/*
 
182
  This is a buffer area that the handler can use to store rows.
 
183
  'end_of_used_area' should be kept updated after calls to
 
184
  read-functions so that other parts of the code can use the
 
185
  remaining area (until next read calls is issued).
 
186
*/
 
187
 
 
188
typedef struct st_handler_buffer
 
189
{
 
190
  unsigned char *buffer;         /* Buffer one can start using */
 
191
  unsigned char *buffer_end;     /* End of buffer */
 
192
  unsigned char *end_of_used_area;     /* End of area that was used by handler */
 
193
} HANDLER_BUFFER;
 
194
 
 
195
#endif /* DRIZZLED_HANDLER_STRUCTS_H */