~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.h

  • Committer: Monty Taylor
  • Date: 2008-11-18 22:12:56 UTC
  • mto: (589.1.3 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081118221256-ap2kmj073pdw7uap
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
 
21
 
#ifndef DRIZZLED_SQL_CLASS_H
22
 
#define DRIZZLED_SQL_CLASS_H
 
21
#ifndef DRIZZLED_SESSION_H
 
22
#define DRIZZLED_SESSION_H
23
23
 
24
24
/* Classes in mysql */
25
25
 
44
44
class Rows_log_event;
45
45
class user_var_entry;
46
46
class Copy_field;
 
47
class Table_ident;
47
48
 
48
 
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
49
 
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
50
 
                            DELAY_KEY_WRITE_ALL };
51
 
enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT,
52
 
                            SLAVE_EXEC_MODE_IDEMPOTENT,
53
 
                            SLAVE_EXEC_MODE_LAST_BIT};
54
 
enum enum_mark_columns
55
 
{ MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
56
 
enum enum_filetype { FILETYPE_CSV, FILETYPE_XML };
57
49
 
58
50
extern char internal_table_name[2];
59
51
extern char empty_c_string[1];
107
99
} COPY_INFO;
108
100
 
109
101
 
110
 
class Key_part_spec :public Sql_alloc {
111
 
public:
112
 
  LEX_STRING field_name;
113
 
  uint32_t length;
114
 
  Key_part_spec(const LEX_STRING &name, uint32_t len)
115
 
    : field_name(name), length(len)
116
 
  {}
117
 
  Key_part_spec(const char *name, const size_t name_len, uint32_t len)
118
 
    : length(len)
119
 
  { field_name.str= (char *)name; field_name.length= name_len; }
120
 
  bool operator==(const Key_part_spec& other) const;
121
 
  /**
122
 
    Construct a copy of this Key_part_spec. field_name is copied
123
 
    by-pointer as it is known to never change. At the same time
124
 
    'length' may be reset in mysql_prepare_create_table, and this
125
 
    is why we supply it with a copy.
126
 
 
127
 
    @return If out of memory, 0 is returned and an error is set in
128
 
    Session.
129
 
  */
130
 
  Key_part_spec *clone(MEM_ROOT *mem_root) const
131
 
  { return new (mem_root) Key_part_spec(*this); }
132
 
};
133
 
 
134
 
 
135
 
class Alter_drop :public Sql_alloc {
136
 
public:
137
 
  enum drop_type {KEY, COLUMN };
138
 
  const char *name;
139
 
  enum drop_type type;
140
 
  Alter_drop(enum drop_type par_type,const char *par_name)
141
 
    :name(par_name), type(par_type) {}
142
 
  /**
143
 
    Used to make a clone of this object for ALTER/CREATE TABLE
144
 
    @sa comment for Key_part_spec::clone
145
 
  */
146
 
  Alter_drop *clone(MEM_ROOT *mem_root) const
147
 
    { return new (mem_root) Alter_drop(*this); }
148
 
};
149
 
 
150
 
 
151
 
class Alter_column :public Sql_alloc {
152
 
public:
153
 
  const char *name;
154
 
  Item *def;
155
 
  Alter_column(const char *par_name,Item *literal)
156
 
    :name(par_name), def(literal) {}
157
 
  /**
158
 
    Used to make a clone of this object for ALTER/CREATE TABLE
159
 
    @sa comment for Key_part_spec::clone
160
 
  */
161
 
  Alter_column *clone(MEM_ROOT *mem_root) const
162
 
    { return new (mem_root) Alter_column(*this); }
163
 
};
164
 
 
165
 
 
166
 
class Key :public Sql_alloc {
167
 
public:
168
 
  enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FOREIGN_KEY};
169
 
  enum Keytype type;
170
 
  KEY_CREATE_INFO key_create_info;
171
 
  List<Key_part_spec> columns;
172
 
  LEX_STRING name;
173
 
  bool generated;
174
 
 
175
 
  Key(enum Keytype type_par, const LEX_STRING &name_arg,
176
 
      KEY_CREATE_INFO *key_info_arg,
177
 
      bool generated_arg, List<Key_part_spec> &cols)
178
 
    :type(type_par), key_create_info(*key_info_arg), columns(cols),
179
 
    name(name_arg), generated(generated_arg)
180
 
  {}
181
 
  Key(enum Keytype type_par, const char *name_arg, size_t name_len_arg,
182
 
      KEY_CREATE_INFO *key_info_arg, bool generated_arg,
183
 
      List<Key_part_spec> &cols)
184
 
    :type(type_par), key_create_info(*key_info_arg), columns(cols),
185
 
    generated(generated_arg)
186
 
  {
187
 
    name.str= (char *)name_arg;
188
 
    name.length= name_len_arg;
189
 
  }
190
 
  Key(const Key &rhs, MEM_ROOT *mem_root);
191
 
  virtual ~Key() {}
192
 
  /* Equality comparison of keys (ignoring name) */
193
 
  friend bool foreign_key_prefix(Key *a, Key *b);
194
 
  /**
195
 
    Used to make a clone of this object for ALTER/CREATE TABLE
196
 
    @sa comment for Key_part_spec::clone
197
 
  */
198
 
  virtual Key *clone(MEM_ROOT *mem_root) const
199
 
    { return new (mem_root) Key(*this, mem_root); }
200
 
};
201
 
 
202
 
class Table_ident;
203
 
 
204
 
class Foreign_key: public Key {
205
 
public:
206
 
  enum fk_match_opt { FK_MATCH_UNDEF, FK_MATCH_FULL,
207
 
                      FK_MATCH_PARTIAL, FK_MATCH_SIMPLE};
208
 
  enum fk_option { FK_OPTION_UNDEF, FK_OPTION_RESTRICT, FK_OPTION_CASCADE,
209
 
                   FK_OPTION_SET_NULL, FK_OPTION_NO_ACTION, FK_OPTION_DEFAULT};
210
 
 
211
 
  Table_ident *ref_table;
212
 
  List<Key_part_spec> ref_columns;
213
 
  uint32_t delete_opt, update_opt, match_opt;
214
 
  Foreign_key(const LEX_STRING &name_arg, List<Key_part_spec> &cols,
215
 
              Table_ident *table,   List<Key_part_spec> &ref_cols,
216
 
              uint32_t delete_opt_arg, uint32_t update_opt_arg, uint32_t match_opt_arg)
217
 
    :Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols),
218
 
    ref_table(table), ref_columns(ref_cols),
219
 
    delete_opt(delete_opt_arg), update_opt(update_opt_arg),
220
 
    match_opt(match_opt_arg)
221
 
  {}
222
 
  Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root);
223
 
  /**
224
 
    Used to make a clone of this object for ALTER/CREATE TABLE
225
 
    @sa comment for Key_part_spec::clone
226
 
  */
227
 
  virtual Key *clone(MEM_ROOT *mem_root) const
228
 
  { return new (mem_root) Foreign_key(*this, mem_root); }
229
 
  /* Used to validate foreign key options */
230
 
  bool validate(List<Create_field> &table_fields);
231
 
};
 
102
 
 
103
 
232
104
 
233
105
typedef struct st_mysql_lock
234
106
{
2449
2321
 
2450
2322
void close_connection(Session *session, uint32_t errcode, bool lock);
2451
2323
 
 
2324
/* Some inline functions for more speed */
 
2325
 
 
2326
inline bool add_item_to_list(Session *session, Item *item)
 
2327
{
 
2328
  return session->lex->current_select->add_item_to_list(session, item);
 
2329
}
 
2330
 
 
2331
inline bool add_value_to_list(Session *session, Item *value)
 
2332
{
 
2333
  return session->lex->value_list.push_back(value);
 
2334
}
 
2335
 
 
2336
inline bool add_order_to_list(Session *session, Item *item, bool asc)
 
2337
{
 
2338
  return session->lex->current_select->add_order_to_list(session, item, asc);
 
2339
}
 
2340
 
 
2341
inline bool add_group_to_list(Session *session, Item *item, bool asc)
 
2342
{
 
2343
  return session->lex->current_select->add_group_to_list(session, item, asc);
 
2344
}
 
2345
 
2452
2346
#endif /* DRIZZLE_SERVER */
2453
2347
 
2454
2348
#endif /* DRIZZLED_SQL_CLASS_H */