21
21
/* The old structures from unireg */
23
#ifndef DRIZZLED_STRUCTS_H
24
#define DRIZZLED_STRUCTS_H
26
#include "drizzled/base.h"
27
#include "drizzled/definitions.h"
28
#include "drizzled/lex_string.h"
29
#include "drizzled/thr_lock.h"
36
typedef struct st_io_cache IO_CACHE;
23
#include <mysys/iocache.h>
42
struct KeyPartInfo { /* Info about a key part */
28
typedef struct st_date_time_format {
29
unsigned char positions[8];
30
char time_separator; /* Separator between hour and minute */
31
uint32_t flag; /* For future */
36
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 */
41
File filenr; /* (uniq) filenr for table */
42
ha_rows records; /* Records i datafilen */
43
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;
50
int errkey,sortkey; /* Last errorkey and sorted by */
51
time_t create_time; /* When table was created */
54
ulong mean_rec_length; /* physical reclength */
58
typedef struct st_key_part_info { /* Info about a key part */
44
unsigned int offset; /* offset in record (from 0) */
45
unsigned int null_offset; /* Offset to null_bit in record */
60
uint offset; /* offset in record (from 0) */
61
uint null_offset; /* Offset to null_bit in record */
46
62
/* Length of key part in bytes, excluding NULL flag and length bytes */
56
72
uint16_t store_length;
60
uint16_t getKeyType() const
64
74
uint16_t fieldnr; /* Fieldnum in UNIREG (1,2,3,...) */
65
75
uint16_t key_part_flag; /* 0 or HA_REVERSE_SORT */
67
77
uint8_t null_bit; /* Position to null_bit */
72
unsigned int key_length; /* Tot length of key */
73
enum ha_key_alg algorithm;
74
unsigned long flags; /* dupp key and pack flags */
75
unsigned int key_parts; /* How many key_parts */
81
typedef struct st_key {
82
uint key_length; /* Tot length of key */
83
ulong flags; /* dupp key and pack flags */
84
uint key_parts; /* How many key_parts */
76
85
uint32_t extra_length;
77
unsigned int usable_key_parts; /* Should normally be = key_parts */
86
uint usable_key_parts; /* Should normally be = key_parts */
78
87
uint32_t block_size;
79
KeyPartInfo *key_part;
88
enum ha_key_alg algorithm;
89
KEY_PART_INFO *key_part;
80
90
char *name; /* Name of key */
82
92
Array of AVG(#records with the same field value) for 1st ... Nth key part.
86
96
ulong *rec_per_key;
88
98
LEX_STRING comment;
94
struct RegInfo { /* Extra info about reg */
95
JoinTable *join_tab; /* Used by SELECT() */
102
struct st_join_table;
104
typedef struct st_reginfo { /* Extra info about reg */
105
struct st_join_table *join_tab; /* Used by SELECT() */
96
106
enum thr_lock_type lock_type; /* How database is used */
97
107
bool not_exists_optimize;
98
108
bool impossible_range;
100
: join_tab(NULL), lock_type(TL_UNLOCK),
101
not_exists_optimize(false), impossible_range(false) {}
105
lock_type= TL_UNLOCK;
106
not_exists_optimize= false;
107
impossible_range= false;
113
namespace optimizer { class SqlSelect; }
115
typedef int *(*update_var)(Session *, struct drizzle_show_var *);
117
} /* namespace drizzled */
112
struct st_read_record; /* For referense later */
116
struct st_join_table;
118
typedef struct st_read_record { /* Parameter to read_record */
119
Table *table; /* Head-form */
121
Table **forms; /* head and ref forms */
122
int (*read_record)(struct st_read_record *);
125
uint32_t cache_records;
126
uint32_t ref_length,struct_length,reclength,rec_cache_size,error_offset;
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;
133
bool print_error, ignore_not_found_rows;
134
struct st_join_table *do_insideout_scan;
139
ulong year,month,day,hour;
140
uint64_t minute,second,second_part;
145
typedef struct st_known_date_time_format {
146
const char *format_name;
147
const char *date_format;
148
const char *datetime_format;
149
const char *time_format;
150
} KNOWN_DATE_TIME_FORMAT;
152
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
154
extern const char *show_comp_option_name[];
156
typedef int *(*update_var)(THD *, struct st_mysql_show_var *);
158
typedef struct st_lex_user {
159
LEX_STRING user, host, password;
163
This structure specifies the maximum amount of resources which
164
can be consumed by each account. Zero value of a member means
167
typedef struct user_resources {
168
/* Maximum number of queries/statements per hour. */
171
Maximum number of updating statements per hour (which statements are
172
updating is defined by sql_command_flags array).
175
/* Maximum number of connections established per hour. */
176
uint32_t conn_per_hour;
177
/* Maximum number of concurrent connections. */
180
Values of this enum and specified_limits member are used by the
181
parser to store which user limits were specified in GRANT statement.
183
enum {QUERIES_PER_HOUR= 1, UPDATES_PER_HOUR= 2, CONNECTIONS_PER_HOUR= 4,
184
USER_CONNECTIONS= 8};
185
uint32_t specified_limits;
190
This structure is used for counting resources consumed and for checking
191
them against specified user limits.
193
typedef struct user_conn {
195
Pointer to user+host key (pair separated by '\0') defining the entity
196
for which resources are counted (By default it is user account thus
197
priv_user/priv_host pair is used. If --old-style-user-limits option
198
is enabled, resources are counted for each user+host separately).
201
/* Pointer to host part of the key. */
204
The moment of time when per hour counters were reset last time
205
(i.e. start of "hour" for conn_per_hour, updates, questions counters).
207
uint64_t reset_utime;
208
/* Total length of the key. */
210
/* Current amount of concurrent connections for this account. */
211
uint32_t connections;
213
Current number of connections per hour, number of updating statements
214
per hour and total number of statements per hour for this account.
216
uint32_t conn_per_hour, updates, questions;
217
/* Maximum amount of resources which account is allowed to consume. */
218
USER_RESOURCES user_resources;
221
/* Bits in form->update */
222
#define REG_MAKE_DUPP 1 /* Make a copy of record when read */
223
#define REG_NEW_RECORD 2 /* Write a new record if not found */
224
#define REG_UPDATE 4 /* Uppdate record */
225
#define REG_DELETE 8 /* Delete found record */
226
#define REG_PROG 16 /* User is updating database */
227
#define REG_CLEAR_AFTER_WRITE 32
228
#define REG_MAY_BE_UPDATED 64
229
#define REG_AUTO_UPDATE 64 /* Used in D-forms for scroll-tables */
230
#define REG_OVERWRITE 128
231
#define REG_SKIP_DUP 256
119
233
/* Bits in form->status */
120
234
#define STATUS_NO_RECORD (1+2) /* Record isn't usably */
126
240
#define STATUS_NULL_ROW 32 /* table->null_row is set */
127
241
#define STATUS_DELETED 64
129
#endif /* DRIZZLED_STRUCTS_H */
244
Such interval is "discrete": it is the set of
245
{ auto_inc_interval_min + k * increment,
246
0 <= k <= (auto_inc_interval_values-1) }
247
Where "increment" is maintained separately by the user of this class (and is
248
currently only thd->variables.auto_increment_increment).
249
It mustn't derive from Sql_alloc, because SET INSERT_ID needs to
250
allocate memory which must stay allocated for use by the next statement.
252
class Discrete_interval {
254
uint64_t interval_min;
255
uint64_t interval_values;
256
uint64_t interval_max; // excluded bound. Redundant.
258
Discrete_interval *next; // used when linked into Discrete_intervals_list
259
void replace(uint64_t start, uint64_t val, uint64_t incr)
262
interval_values= val;
263
interval_max= (val == UINT64_MAX) ? val : start + val * incr;
265
Discrete_interval(uint64_t start, uint64_t val, uint64_t incr) :
266
next(NULL) { replace(start, val, incr); };
267
Discrete_interval() : next(NULL) { replace(0, 0, 0); };
268
uint64_t minimum() const { return interval_min; };
269
uint64_t values() const { return interval_values; };
270
uint64_t maximum() const { return interval_max; };
272
If appending [3,5] to [1,2], we merge both in [1,5] (they should have the
273
same increment for that, user of the class has to ensure that). That is
274
just a space optimization. Returns 0 if merge succeeded.
276
bool merge_if_contiguous(uint64_t start, uint64_t val, uint64_t incr)
278
if (interval_max == start)
280
if (val == UINT64_MAX)
282
interval_values= interval_max= val;
286
interval_values+= val;
287
interval_max= start + val * incr;
295
/* List of Discrete_interval objects */
296
class Discrete_intervals_list {
298
Discrete_interval *head;
299
Discrete_interval *tail;
301
When many intervals are provided at the beginning of the execution of a
302
statement (in a replication slave or SET INSERT_ID), "current" points to
303
the interval being consumed by the thread now (so "current" goes from
304
"head" to "tail" then to NULL).
306
Discrete_interval *current;
307
uint32_t elements; // number of elements
309
/* helper function for copy construct and assignment operator */
310
void copy_(const Discrete_intervals_list& from)
312
for (Discrete_interval *i= from.head; i; i= i->next)
314
Discrete_interval j= *i;
319
Discrete_intervals_list() : head(NULL), current(NULL), elements(0) {};
320
Discrete_intervals_list(const Discrete_intervals_list& from)
324
void operator=(const Discrete_intervals_list& from)
336
for (Discrete_interval *i= head; i;)
338
Discrete_interval *next= i->next;
345
const Discrete_interval* get_next()
347
Discrete_interval *tmp= current;
349
current= current->next;
352
~Discrete_intervals_list() { empty(); };
353
bool append(uint64_t start, uint64_t val, uint64_t incr);
354
bool append(Discrete_interval *interval);
355
uint64_t minimum() const { return (head ? head->minimum() : 0); };
356
uint64_t maximum() const { return (head ? tail->maximum() : 0); };
357
uint32_t nb_elements() const { return elements; }