~posulliv/drizzle/memcached_applier

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 *
 *  Copyright (C) 2008 Sun Microsystems
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef DRIZZLED_HANDLER_STRUCTS_H
#define DRIZZLED_HANDLER_STRUCTS_H

#include <stdint.h>
#include <time.h>

#include <drizzled/base.h>
#include <drizzled/structs.h>
#include <drizzled/definitions.h>
#include <drizzled/lex_string.h>

class Ha_trx_info;
struct StorageEngine;
struct st_key;
typedef struct st_key KEY;
struct st_key_cache;
typedef struct st_key_cache KEY_CACHE;

struct Session_TRANS
{
  Session_TRANS() {};

  /* true is not all entries in the engines[] support 2pc */
  bool        no_2pc;
  /* storage engines that registered in this transaction */
  Ha_trx_info *ha_list;
  /*
    The purpose of this flag is to keep track of non-transactional
    tables that were modified in scope of:
    - transaction, when the variable is a member of
    Session::transaction.all
    - top-level statement or sub-statement, when the variable is a
    member of Session::transaction.stmt
    This member has the following life cycle:
    * stmt.modified_non_trans_table is used to keep track of
    modified non-transactional tables of top-level statements. At
    the end of the previous statement and at the beginning of the session,
    it is reset to false.  If such functions
    as mysql_insert, mysql_update, mysql_delete etc modify a
    non-transactional table, they set this flag to true.  At the
    end of the statement, the value of stmt.modified_non_trans_table
    is merged with all.modified_non_trans_table and gets reset.
    * all.modified_non_trans_table is reset at the end of transaction

    * Since we do not have a dedicated context for execution of a
    sub-statement, to keep track of non-transactional changes in a
    sub-statement, we re-use stmt.modified_non_trans_table.
    At entrance into a sub-statement, a copy of the value of
    stmt.modified_non_trans_table (containing the changes of the
    outer statement) is saved on stack. Then
    stmt.modified_non_trans_table is reset to false and the
    substatement is executed. Then the new value is merged with the
    saved value.
  */
  bool modified_non_trans_table;

  void reset() { no_2pc= false; modified_non_trans_table= false; }
};

typedef struct st_ha_create_information
{
  const CHARSET_INFO *table_charset, *default_table_charset;
  LEX_STRING connect_string;
  LEX_STRING comment;
  const char *data_file_name, *index_file_name;
  const char *alias;
  uint64_t max_rows,min_rows;
  uint64_t auto_increment_value;
  uint32_t table_options;
  uint32_t avg_row_length;
  uint32_t used_fields;
  uint32_t key_block_size;
  uint32_t block_size;
  enum row_type row_type;
  StorageEngine *db_type;
  uint32_t null_bits;                       /* NULL bits at start of record */
  uint32_t options;                         /* OR of HA_CREATE_ options */
  uint32_t extra_size;                      /* length of extra data segment */
  bool table_existed;			/* 1 in create if table existed */
  bool varchar;                         /* 1 if table has a VARCHAR */
  enum ha_choice page_checksum;         /* If we have page_checksums */
} HA_CREATE_INFO;

typedef struct st_ha_alter_information
{
  KEY  *key_info_buffer;
  uint32_t key_count;
  uint32_t index_drop_count;
  uint32_t *index_drop_buffer;
  uint32_t index_add_count;
  uint32_t *index_add_buffer;
  void *data;
} HA_ALTER_INFO;


typedef struct st_key_create_information
{
  enum ha_key_alg algorithm;
  uint32_t block_size;
  LEX_STRING parser_name;
  LEX_STRING comment;
} KEY_CREATE_INFO;


typedef struct st_ha_check_opt
{
  st_ha_check_opt() {}                        /* Remove gcc warning */
  uint32_t flags;       /* myisam layer flags (e.g. for myisamchk) */
  /* Just rebuild based on the defintion of the table */
  bool use_frm;
  /* new key cache when changing key cache */
  KEY_CACHE *key_cache;
  void init();
} HA_CHECK_OPT;


typedef struct st_range_seq_if
{
  /*
    Initialize the traversal of range sequence

    SYNOPSIS
    init()
    init_params  The seq_init_param parameter
    n_ranges     The number of ranges obtained
    flags        A combination of HA_MRR_SINGLE_POINT, HA_MRR_FIXED_KEY

    RETURN
    An opaque value to be used as RANGE_SEQ_IF::next() parameter
  */
  range_seq_t (*init)(void *init_params, uint32_t n_ranges, uint32_t flags);


  /*
    Get the next range in the range sequence

    SYNOPSIS
    next()
    seq    The value returned by RANGE_SEQ_IF::init()
    range  OUT Information about the next range

    RETURN
    0 - Ok, the range structure filled with info about the next range
    1 - No more ranges
  */
  uint32_t (*next) (range_seq_t seq, KEY_MULTI_RANGE *range);
} RANGE_SEQ_IF;

/*
  This is a buffer area that the handler can use to store rows.
  'end_of_used_area' should be kept updated after calls to
  read-functions so that other parts of the code can use the
  remaining area (until next read calls is issued).
*/

typedef struct st_handler_buffer
{
  unsigned char *buffer;         /* Buffer one can start using */
  unsigned char *buffer_end;     /* End of buffer */
  unsigned char *end_of_used_area;     /* End of area that was used by handler */
} HANDLER_BUFFER;

#endif /* DRIZZLED_HANDLER_STRUCTS_H */