~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/structs.h

Removed/replaced DBUG symbols

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; 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
 
 */
 
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
 
20
16
 
21
17
/* The old structures from unireg */
22
18
 
23
 
#include <mysys/iocache.h>
24
 
 
25
 
class Table;
 
19
struct st_table;
26
20
class Field;
27
21
 
28
22
typedef struct st_date_time_format {
29
 
  unsigned char positions[8];
 
23
  uchar positions[8];
30
24
  char  time_separator;                 /* Separator between hour and minute */
31
 
  uint32_t flag;                                /* For future */
 
25
  uint flag;                            /* For future */
32
26
  LEX_STRING format;
33
27
} DATE_TIME_FORMAT;
34
28
 
35
29
 
36
30
typedef struct st_keyfile_info {        /* used with ha_info() */
37
 
  unsigned char ref[MAX_REFLENGTH];             /* Pointer to current row */
38
 
  unsigned char dupp_ref[MAX_REFLENGTH];        /* Pointer to dupp row */
39
 
  uint32_t ref_length;                  /* Length of ref (1-8) */
40
 
  uint32_t block_size;                  /* index block size */
 
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 */
41
35
  File filenr;                          /* (uniq) filenr for table */
42
36
  ha_rows records;                      /* Records i datafilen */
43
37
  ha_rows deleted;                      /* Deleted records */
44
 
  uint64_t data_file_length;            /* Length off data file */
45
 
  uint64_t max_data_file_length;        /* Length off data file */
46
 
  uint64_t index_file_length;
47
 
  uint64_t max_index_file_length;
48
 
  uint64_t delete_length;               /* Free bytes */
49
 
  uint64_t auto_increment_value;
 
38
  ulonglong data_file_length;           /* Length off data file */
 
39
  ulonglong max_data_file_length;       /* Length off data file */
 
40
  ulonglong index_file_length;
 
41
  ulonglong max_index_file_length;
 
42
  ulonglong delete_length;              /* Free bytes */
 
43
  ulonglong auto_increment_value;
50
44
  int errkey,sortkey;                   /* Last errorkey and sorted by */
51
45
  time_t create_time;                   /* When table was created */
52
46
  time_t check_time;
53
47
  time_t update_time;
54
 
  uint64_t mean_rec_length;             /* physical reclength */
 
48
  ulong mean_rec_length;                /* physical reclength */
55
49
} KEYFILE_INFO;
56
50
 
57
51
 
60
54
  uint  offset;                         /* offset in record (from 0) */
61
55
  uint  null_offset;                    /* Offset to null_bit in record */
62
56
  /* Length of key part in bytes, excluding NULL flag and length bytes */
63
 
  uint16_t length;
 
57
  uint16 length;
64
58
  /*
65
59
    Number of bytes required to store the keypart value. This may be
66
60
    different from the "length" field as it also counts
69
63
       actual value is stored from offset+1].
70
64
     - possible HA_KEY_BLOB_LENGTH bytes needed to store actual value length.
71
65
  */
72
 
  uint16_t store_length;
73
 
  uint16_t key_type;
74
 
  uint16_t fieldnr;                     /* Fieldnum in UNIREG (1,2,3,...) */
75
 
  uint16_t key_part_flag;                       /* 0 or HA_REVERSE_SORT */
76
 
  uint8_t type;
77
 
  uint8_t null_bit;                     /* Position to null_bit */
 
66
  uint16 store_length;
 
67
  uint16 key_type;
 
68
  uint16 fieldnr;                       /* Fieldnum in UNIREG (1,2,3,...) */
 
69
  uint16 key_part_flag;                 /* 0 or HA_REVERSE_SORT */
 
70
  uint8 type;
 
71
  uint8 null_bit;                       /* Position to null_bit */
78
72
} KEY_PART_INFO ;
79
73
 
80
74
 
82
76
  uint  key_length;                     /* Tot length of key */
83
77
  ulong flags;                          /* dupp key and pack flags */
84
78
  uint  key_parts;                      /* How many key_parts */
85
 
  uint32_t  extra_length;
 
79
  uint  extra_length;
86
80
  uint  usable_key_parts;               /* Should normally be = key_parts */
87
 
  uint32_t  block_size;
 
81
  uint  block_size;
88
82
  enum  ha_key_alg algorithm;
89
83
  KEY_PART_INFO *key_part;
90
84
  char  *name;                          /* Name of key */
94
88
    For temporary heap tables this member is NULL.
95
89
  */
96
90
  ulong *rec_per_key;
97
 
  Table *table;
 
91
  struct st_table *table;
98
92
  LEX_STRING comment;
99
93
} KEY;
100
94
 
111
105
 
112
106
struct st_read_record;                          /* For referense later */
113
107
class SQL_SELECT;
114
 
class Session;
 
108
class THD;
115
109
class handler;
116
110
struct st_join_table;
117
111
 
118
112
typedef struct st_read_record {                 /* Parameter to read_record */
119
 
  Table *table;                 /* Head-form */
 
113
  struct st_table *table;                       /* Head-form */
120
114
  handler *file;
121
 
  Table **forms;                        /* head and ref forms */
 
115
  struct st_table **forms;                      /* head and ref forms */
122
116
  int (*read_record)(struct st_read_record *);
123
 
  Session *session;
 
117
  THD *thd;
124
118
  SQL_SELECT *select;
125
 
  uint32_t cache_records;
126
 
  uint32_t ref_length,struct_length,reclength,rec_cache_size,error_offset;
127
 
  uint32_t index;
128
 
  unsigned char *ref_pos;                               /* pointer to form->refpos */
129
 
  unsigned char *record;
130
 
  unsigned char *rec_buf;                /* to read field values  after filesort */
131
 
  unsigned char *cache,*cache_pos,*cache_end,*read_positions;
 
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;
132
126
  IO_CACHE *io_cache;
133
127
  bool print_error, ignore_not_found_rows;
134
128
  struct st_join_table *do_insideout_scan;
135
129
} READ_RECORD;
136
130
 
137
131
 
 
132
/*
 
133
  Originally MySQL used MYSQL_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_mysql_timestamp_type timestamp_type;
 
139
 
 
140
 
138
141
typedef struct {
139
 
  uint32_t year;
140
 
  uint32_t month;
141
 
  uint32_t day;
142
 
  uint32_t hour;
143
 
  uint64_t minute,second,second_part;
 
142
  ulong year,month,day,hour;
 
143
  ulonglong minute,second,second_part;
144
144
  bool neg;
145
145
} INTERVAL;
146
146
 
156
156
 
157
157
extern const char *show_comp_option_name[];
158
158
 
159
 
typedef int *(*update_var)(Session *, struct st_mysql_show_var *);
 
159
typedef int *(*update_var)(THD *, struct st_mysql_show_var *);
160
160
 
161
161
typedef struct  st_lex_user {
162
162
  LEX_STRING user, host, password;
169
169
*/
170
170
typedef struct user_resources {
171
171
  /* Maximum number of queries/statements per hour. */
172
 
  uint32_t questions;
 
172
  uint questions;
173
173
  /*
174
174
     Maximum number of updating statements per hour (which statements are
175
175
     updating is defined by sql_command_flags array).
176
176
  */
177
 
  uint32_t updates;
 
177
  uint updates;
178
178
  /* Maximum number of connections established per hour. */
179
 
  uint32_t conn_per_hour;
 
179
  uint conn_per_hour;
180
180
  /* Maximum number of concurrent connections. */
181
 
  uint32_t user_conn;
 
181
  uint user_conn;
182
182
  /*
183
183
     Values of this enum and specified_limits member are used by the
184
184
     parser to store which user limits were specified in GRANT statement.
185
185
  */
186
186
  enum {QUERIES_PER_HOUR= 1, UPDATES_PER_HOUR= 2, CONNECTIONS_PER_HOUR= 4,
187
187
        USER_CONNECTIONS= 8};
188
 
  uint32_t specified_limits;
 
188
  uint specified_limits;
189
189
} USER_RESOURCES;
190
190
 
191
191
 
207
207
     The moment of time when per hour counters were reset last time
208
208
     (i.e. start of "hour" for conn_per_hour, updates, questions counters).
209
209
  */
210
 
  uint64_t reset_utime;
 
210
  ulonglong reset_utime;
211
211
  /* Total length of the key. */
212
 
  uint32_t len;
 
212
  uint len;
213
213
  /* Current amount of concurrent connections for this account. */
214
 
  uint32_t connections;
 
214
  uint connections;
215
215
  /*
216
216
     Current number of connections per hour, number of updating statements
217
217
     per hour and total number of statements per hour for this account.
218
218
  */
219
 
  uint32_t conn_per_hour, updates, questions;
 
219
  uint conn_per_hour, updates, questions;
220
220
  /* Maximum amount of resources which account is allowed to consume. */
221
221
  USER_RESOURCES user_resources;
222
222
} USER_CONN;
248
248
  { auto_inc_interval_min + k * increment,
249
249
    0 <= k <= (auto_inc_interval_values-1) }
250
250
  Where "increment" is maintained separately by the user of this class (and is
251
 
  currently only session->variables.auto_increment_increment).
 
251
  currently only thd->variables.auto_increment_increment).
252
252
  It mustn't derive from Sql_alloc, because SET INSERT_ID needs to
253
253
  allocate memory which must stay allocated for use by the next statement.
254
254
*/
255
255
class Discrete_interval {
256
256
private:
257
 
  uint64_t interval_min;
258
 
  uint64_t interval_values;
259
 
  uint64_t  interval_max;    // excluded bound. Redundant.
 
257
  ulonglong interval_min;
 
258
  ulonglong interval_values;
 
259
  ulonglong  interval_max;    // excluded bound. Redundant.
260
260
public:
261
261
  Discrete_interval *next;    // used when linked into Discrete_intervals_list
262
 
  void replace(uint64_t start, uint64_t val, uint64_t incr)
 
262
  void replace(ulonglong start, ulonglong val, ulonglong incr)
263
263
  {
264
264
    interval_min=    start;
265
265
    interval_values= val;
266
 
    interval_max=    (val == UINT64_MAX) ? val : start + val * incr;
 
266
    interval_max=    (val == ULONGLONG_MAX) ? val : start + val * incr;
267
267
  }
268
 
  Discrete_interval(uint64_t start, uint64_t val, uint64_t incr) :
269
 
    interval_min(start), interval_values(val),
270
 
    interval_max((val == UINT64_MAX) ? val : start + val * incr),
271
 
    next(NULL)
272
 
  {};
273
 
  Discrete_interval() :
274
 
    interval_min(0), interval_values(0),
275
 
    interval_max(0), next(NULL)
276
 
  {};
277
 
  uint64_t minimum() const { return interval_min;    };
278
 
  uint64_t values()  const { return interval_values; };
279
 
  uint64_t maximum() const { return interval_max;    };
 
268
  Discrete_interval(ulonglong start, ulonglong val, ulonglong incr) :
 
269
    next(NULL) { replace(start, val, incr); };
 
270
  Discrete_interval() : next(NULL) { replace(0, 0, 0); };
 
271
  ulonglong minimum() const { return interval_min;    };
 
272
  ulonglong values()  const { return interval_values; };
 
273
  ulonglong maximum() const { return interval_max;    };
280
274
  /*
281
275
    If appending [3,5] to [1,2], we merge both in [1,5] (they should have the
282
276
    same increment for that, user of the class has to ensure that). That is
283
277
    just a space optimization. Returns 0 if merge succeeded.
284
278
  */
285
 
  bool merge_if_contiguous(uint64_t start, uint64_t val, uint64_t incr)
 
279
  bool merge_if_contiguous(ulonglong start, ulonglong val, ulonglong incr)
286
280
  {
287
281
    if (interval_max == start)
288
282
    {
289
 
      if (val == UINT64_MAX)
 
283
      if (val == ULONGLONG_MAX)
290
284
      {
291
285
        interval_values=   interval_max= val;
292
286
      }
313
307
    "head" to "tail" then to NULL).
314
308
  */
315
309
  Discrete_interval        *current;
316
 
  uint32_t                  elements; // number of elements
 
310
  uint                  elements; // number of elements
317
311
 
318
312
  /* helper function for copy construct and assignment operator */
319
313
  void copy_(const Discrete_intervals_list& from)
325
319
    }
326
320
  }
327
321
public:
328
 
  Discrete_intervals_list() :
329
 
    head(NULL), tail(NULL),
330
 
    current(NULL), elements(0) {};
331
 
  Discrete_intervals_list(const Discrete_intervals_list& from) :
332
 
    head(NULL), tail(NULL),
333
 
    current(NULL), elements(0)
 
322
  Discrete_intervals_list() : head(NULL), current(NULL), elements(0) {};
 
323
  Discrete_intervals_list(const Discrete_intervals_list& from)
334
324
  {
335
325
    copy_(from);
336
326
  }
337
 
  Discrete_intervals_list& operator=(const Discrete_intervals_list& from)
 
327
  void operator=(const Discrete_intervals_list& from)
338
328
  {
339
329
    empty();
340
330
    copy_(from);
341
 
    return *this;
342
331
  }
343
332
  void empty_no_free()
344
333
  {
364
353
    return tmp;
365
354
  }
366
355
  ~Discrete_intervals_list() { empty(); };
367
 
  bool append(uint64_t start, uint64_t val, uint64_t incr);
 
356
  bool append(ulonglong start, ulonglong val, ulonglong incr);
368
357
  bool append(Discrete_interval *interval);
369
 
  uint64_t minimum()     const { return (head ? head->minimum() : 0); };
370
 
  uint64_t maximum()     const { return (head ? tail->maximum() : 0); };
371
 
  uint32_t      nb_elements() const { return elements; }
 
358
  ulonglong minimum()     const { return (head ? head->minimum() : 0); };
 
359
  ulonglong maximum()     const { return (head ? tail->maximum() : 0); };
 
360
  uint      nb_elements() const { return elements; }
372
361
};