~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/structs.h

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
 
 
 
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; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
16
20
 
17
21
/* The old structures from unireg */
18
22
 
 
23
#include <mysys/iocache.h>
 
24
#include <mysys/definitions.h>
 
25
 
19
26
class Table;
20
27
class Field;
21
28
 
22
29
typedef struct st_date_time_format {
23
 
  uchar positions[8];
 
30
  unsigned char positions[8];
24
31
  char  time_separator;                 /* Separator between hour and minute */
25
 
  uint flag;                            /* For future */
 
32
  uint32_t flag;                                /* For future */
26
33
  LEX_STRING format;
27
34
} DATE_TIME_FORMAT;
28
35
 
29
36
 
30
37
typedef struct st_keyfile_info {        /* used with ha_info() */
31
 
  uchar ref[MAX_REFLENGTH];             /* Pointer to current row */
32
 
  uchar dupp_ref[MAX_REFLENGTH];        /* Pointer to dupp row */
33
 
  uint ref_length;                      /* Length of ref (1-8) */
34
 
  uint block_size;                      /* index block size */
 
38
  unsigned char ref[MAX_REFLENGTH];             /* Pointer to current row */
 
39
  unsigned char dupp_ref[MAX_REFLENGTH];        /* Pointer to dupp row */
 
40
  uint32_t ref_length;                  /* Length of ref (1-8) */
 
41
  uint32_t block_size;                  /* index block size */
35
42
  File filenr;                          /* (uniq) filenr for table */
36
43
  ha_rows records;                      /* Records i datafilen */
37
44
  ha_rows deleted;                      /* Deleted records */
45
52
  time_t create_time;                   /* When table was created */
46
53
  time_t check_time;
47
54
  time_t update_time;
48
 
  ulong mean_rec_length;                /* physical reclength */
 
55
  uint64_t mean_rec_length;             /* physical reclength */
49
56
} KEYFILE_INFO;
50
57
 
51
58
 
76
83
  uint  key_length;                     /* Tot length of key */
77
84
  ulong flags;                          /* dupp key and pack flags */
78
85
  uint  key_parts;                      /* How many key_parts */
79
 
  uint  extra_length;
 
86
  uint32_t  extra_length;
80
87
  uint  usable_key_parts;               /* Should normally be = key_parts */
81
 
  uint  block_size;
 
88
  uint32_t  block_size;
82
89
  enum  ha_key_alg algorithm;
83
90
  KEY_PART_INFO *key_part;
84
91
  char  *name;                          /* Name of key */
105
112
 
106
113
struct st_read_record;                          /* For referense later */
107
114
class SQL_SELECT;
108
 
class THD;
 
115
class Session;
109
116
class handler;
110
117
struct st_join_table;
111
118
 
114
121
  handler *file;
115
122
  Table **forms;                        /* head and ref forms */
116
123
  int (*read_record)(struct st_read_record *);
117
 
  THD *thd;
 
124
  Session *session;
118
125
  SQL_SELECT *select;
119
 
  uint cache_records;
120
 
  uint ref_length,struct_length,reclength,rec_cache_size,error_offset;
121
 
  uint index;
122
 
  uchar *ref_pos;                               /* pointer to form->refpos */
123
 
  uchar *record;
124
 
  uchar *rec_buf;                /* to read field values  after filesort */
125
 
  uchar *cache,*cache_pos,*cache_end,*read_positions;
 
126
  uint32_t cache_records;
 
127
  uint32_t ref_length,struct_length,reclength,rec_cache_size,error_offset;
 
128
  uint32_t index;
 
129
  unsigned char *ref_pos;                               /* pointer to form->refpos */
 
130
  unsigned char *record;
 
131
  unsigned char *rec_buf;                /* to read field values  after filesort */
 
132
  unsigned char *cache,*cache_pos,*cache_end,*read_positions;
126
133
  IO_CACHE *io_cache;
127
134
  bool print_error, ignore_not_found_rows;
128
135
  struct st_join_table *do_insideout_scan;
129
136
} READ_RECORD;
130
137
 
131
138
 
132
 
/*
133
 
  Originally MySQL used DRIZZLE_TIME structure inside server only, but since
134
 
  4.1 it's exported to user in the new client API. Define aliases for
135
 
  new names to keep existing code simple.
136
 
*/
137
 
 
138
 
typedef enum enum_drizzle_timestamp_type timestamp_type;
139
 
 
140
 
 
141
139
typedef struct {
142
 
  ulong year,month,day,hour;
 
140
  uint32_t year;
 
141
  uint32_t month;
 
142
  uint32_t day;
 
143
  uint32_t hour;
143
144
  uint64_t minute,second,second_part;
144
145
  bool neg;
145
146
} INTERVAL;
156
157
 
157
158
extern const char *show_comp_option_name[];
158
159
 
159
 
typedef int *(*update_var)(THD *, struct st_mysql_show_var *);
 
160
typedef int *(*update_var)(Session *, struct st_mysql_show_var *);
160
161
 
161
162
typedef struct  st_lex_user {
162
163
  LEX_STRING user, host, password;
169
170
*/
170
171
typedef struct user_resources {
171
172
  /* Maximum number of queries/statements per hour. */
172
 
  uint questions;
 
173
  uint32_t questions;
173
174
  /*
174
175
     Maximum number of updating statements per hour (which statements are
175
176
     updating is defined by sql_command_flags array).
176
177
  */
177
 
  uint updates;
 
178
  uint32_t updates;
178
179
  /* Maximum number of connections established per hour. */
179
 
  uint conn_per_hour;
 
180
  uint32_t conn_per_hour;
180
181
  /* Maximum number of concurrent connections. */
181
 
  uint user_conn;
 
182
  uint32_t user_conn;
182
183
  /*
183
184
     Values of this enum and specified_limits member are used by the
184
185
     parser to store which user limits were specified in GRANT statement.
185
186
  */
186
187
  enum {QUERIES_PER_HOUR= 1, UPDATES_PER_HOUR= 2, CONNECTIONS_PER_HOUR= 4,
187
188
        USER_CONNECTIONS= 8};
188
 
  uint specified_limits;
 
189
  uint32_t specified_limits;
189
190
} USER_RESOURCES;
190
191
 
191
192
 
209
210
  */
210
211
  uint64_t reset_utime;
211
212
  /* Total length of the key. */
212
 
  uint len;
 
213
  uint32_t len;
213
214
  /* Current amount of concurrent connections for this account. */
214
 
  uint connections;
 
215
  uint32_t connections;
215
216
  /*
216
217
     Current number of connections per hour, number of updating statements
217
218
     per hour and total number of statements per hour for this account.
218
219
  */
219
 
  uint conn_per_hour, updates, questions;
 
220
  uint32_t conn_per_hour, updates, questions;
220
221
  /* Maximum amount of resources which account is allowed to consume. */
221
222
  USER_RESOURCES user_resources;
222
223
} USER_CONN;
248
249
  { auto_inc_interval_min + k * increment,
249
250
    0 <= k <= (auto_inc_interval_values-1) }
250
251
  Where "increment" is maintained separately by the user of this class (and is
251
 
  currently only thd->variables.auto_increment_increment).
 
252
  currently only session->variables.auto_increment_increment).
252
253
  It mustn't derive from Sql_alloc, because SET INSERT_ID needs to
253
254
  allocate memory which must stay allocated for use by the next statement.
254
255
*/
266
267
    interval_max=    (val == UINT64_MAX) ? val : start + val * incr;
267
268
  }
268
269
  Discrete_interval(uint64_t start, uint64_t val, uint64_t incr) :
269
 
    next(NULL) { replace(start, val, incr); };
270
 
  Discrete_interval() : next(NULL) { replace(0, 0, 0); };
 
270
    interval_min(start), interval_values(val),
 
271
    interval_max((val == UINT64_MAX) ? val : start + val * incr),
 
272
    next(NULL)
 
273
  {};
 
274
  Discrete_interval() :
 
275
    interval_min(0), interval_values(0),
 
276
    interval_max(0), next(NULL)
 
277
  {};
271
278
  uint64_t minimum() const { return interval_min;    };
272
279
  uint64_t values()  const { return interval_values; };
273
280
  uint64_t maximum() const { return interval_max;    };
307
314
    "head" to "tail" then to NULL).
308
315
  */
309
316
  Discrete_interval        *current;
310
 
  uint                  elements; // number of elements
 
317
  uint32_t                  elements; // number of elements
311
318
 
312
319
  /* helper function for copy construct and assignment operator */
313
320
  void copy_(const Discrete_intervals_list& from)
319
326
    }
320
327
  }
321
328
public:
322
 
  Discrete_intervals_list() : head(NULL), current(NULL), elements(0) {};
323
 
  Discrete_intervals_list(const Discrete_intervals_list& from)
 
329
  Discrete_intervals_list() :
 
330
    head(NULL), tail(NULL),
 
331
    current(NULL), elements(0) {};
 
332
  Discrete_intervals_list(const Discrete_intervals_list& from) :
 
333
    head(NULL), tail(NULL),
 
334
    current(NULL), elements(0)
324
335
  {
325
336
    copy_(from);
326
337
  }
327
 
  void operator=(const Discrete_intervals_list& from)
 
338
  Discrete_intervals_list& operator=(const Discrete_intervals_list& from)
328
339
  {
329
340
    empty();
330
341
    copy_(from);
 
342
    return *this;
331
343
  }
332
344
  void empty_no_free()
333
345
  {
357
369
  bool append(Discrete_interval *interval);
358
370
  uint64_t minimum()     const { return (head ? head->minimum() : 0); };
359
371
  uint64_t maximum()     const { return (head ? tail->maximum() : 0); };
360
 
  uint      nb_elements() const { return elements; }
 
372
  uint32_t      nb_elements() const { return elements; }
361
373
};