21
21
/* The old structures from unireg */
23
#ifndef DRIZZLED_STRUCTS_H
24
#define DRIZZLED_STRUCTS_H
26
#include <drizzled/base.h>
27
#include <mysys/definitions.h>
28
#include <drizzled/lex_string.h>
26
typedef struct st_date_time_format {
27
unsigned char positions[8];
28
char time_separator; /* Separator between hour and minute */
29
uint32_t flag; /* For future */
32
typedef struct st_io_cache IO_CACHE;
34
34
typedef struct st_keyfile_info { /* used with ha_info() */
35
35
unsigned char ref[MAX_REFLENGTH]; /* Pointer to current row */
100
100
struct st_join_table;
102
typedef struct st_reginfo { /* Extra info about reg */
102
struct RegInfo { /* Extra info about reg */
103
103
struct st_join_table *join_tab; /* Used by SELECT() */
104
104
enum thr_lock_type lock_type; /* How database is used */
105
105
bool not_exists_optimize;
106
106
bool impossible_range;
108
: join_tab(NULL), lock_type(TL_UNLOCK),
109
not_exists_optimize(false), impossible_range(false) {}
113
lock_type= TL_UNLOCK;
114
not_exists_optimize= false;
115
impossible_range= false;
110
119
struct st_read_record; /* For referense later */
111
120
class SQL_SELECT;
114
123
struct st_join_table;
137
ulong year,month,day,hour;
138
150
uint64_t minute,second,second_part;
143
typedef struct st_known_date_time_format {
144
const char *format_name;
145
const char *date_format;
146
const char *datetime_format;
147
const char *time_format;
148
} KNOWN_DATE_TIME_FORMAT;
150
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
152
154
extern const char *show_comp_option_name[];
154
typedef int *(*update_var)(THD *, struct st_mysql_show_var *);
156
typedef struct st_lex_user {
157
LEX_STRING user, host, password;
161
This structure specifies the maximum amount of resources which
162
can be consumed by each account. Zero value of a member means
165
typedef struct user_resources {
166
/* Maximum number of queries/statements per hour. */
169
Maximum number of updating statements per hour (which statements are
170
updating is defined by sql_command_flags array).
173
/* Maximum number of connections established per hour. */
174
uint32_t conn_per_hour;
175
/* Maximum number of concurrent connections. */
178
Values of this enum and specified_limits member are used by the
179
parser to store which user limits were specified in GRANT statement.
181
enum {QUERIES_PER_HOUR= 1, UPDATES_PER_HOUR= 2, CONNECTIONS_PER_HOUR= 4,
182
USER_CONNECTIONS= 8};
183
uint32_t specified_limits;
188
This structure is used for counting resources consumed and for checking
189
them against specified user limits.
191
typedef struct user_conn {
193
Pointer to user+host key (pair separated by '\0') defining the entity
194
for which resources are counted (By default it is user account thus
195
priv_user/priv_host pair is used. If --old-style-user-limits option
196
is enabled, resources are counted for each user+host separately).
199
/* Pointer to host part of the key. */
202
The moment of time when per hour counters were reset last time
203
(i.e. start of "hour" for conn_per_hour, updates, questions counters).
205
uint64_t reset_utime;
206
/* Total length of the key. */
208
/* Current amount of concurrent connections for this account. */
209
uint32_t connections;
211
Current number of connections per hour, number of updating statements
212
per hour and total number of statements per hour for this account.
214
uint32_t conn_per_hour, updates, questions;
215
/* Maximum amount of resources which account is allowed to consume. */
216
USER_RESOURCES user_resources;
156
typedef int *(*update_var)(Session *, struct st_mysql_show_var *);
219
158
/* Bits in form->update */
220
159
#define REG_MAKE_DUPP 1 /* Make a copy of record when read */
238
177
#define STATUS_NULL_ROW 32 /* table->null_row is set */
239
178
#define STATUS_DELETED 64
242
Such interval is "discrete": it is the set of
243
{ auto_inc_interval_min + k * increment,
244
0 <= k <= (auto_inc_interval_values-1) }
245
Where "increment" is maintained separately by the user of this class (and is
246
currently only thd->variables.auto_increment_increment).
247
It mustn't derive from Sql_alloc, because SET INSERT_ID needs to
248
allocate memory which must stay allocated for use by the next statement.
250
class Discrete_interval {
252
uint64_t interval_min;
253
uint64_t interval_values;
254
uint64_t interval_max; // excluded bound. Redundant.
256
Discrete_interval *next; // used when linked into Discrete_intervals_list
257
void replace(uint64_t start, uint64_t val, uint64_t incr)
260
interval_values= val;
261
interval_max= (val == UINT64_MAX) ? val : start + val * incr;
263
Discrete_interval(uint64_t start, uint64_t val, uint64_t incr) :
264
next(NULL) { replace(start, val, incr); };
265
Discrete_interval() : next(NULL) { replace(0, 0, 0); };
266
uint64_t minimum() const { return interval_min; };
267
uint64_t values() const { return interval_values; };
268
uint64_t maximum() const { return interval_max; };
270
If appending [3,5] to [1,2], we merge both in [1,5] (they should have the
271
same increment for that, user of the class has to ensure that). That is
272
just a space optimization. Returns 0 if merge succeeded.
274
bool merge_if_contiguous(uint64_t start, uint64_t val, uint64_t incr)
276
if (interval_max == start)
278
if (val == UINT64_MAX)
280
interval_values= interval_max= val;
284
interval_values+= val;
285
interval_max= start + val * incr;
293
/* List of Discrete_interval objects */
294
class Discrete_intervals_list {
296
Discrete_interval *head;
297
Discrete_interval *tail;
299
When many intervals are provided at the beginning of the execution of a
300
statement (in a replication slave or SET INSERT_ID), "current" points to
301
the interval being consumed by the thread now (so "current" goes from
302
"head" to "tail" then to NULL).
304
Discrete_interval *current;
305
uint32_t elements; // number of elements
307
/* helper function for copy construct and assignment operator */
308
void copy_(const Discrete_intervals_list& from)
310
for (Discrete_interval *i= from.head; i; i= i->next)
312
Discrete_interval j= *i;
317
Discrete_intervals_list() : head(NULL), current(NULL), elements(0) {};
318
Discrete_intervals_list(const Discrete_intervals_list& from)
322
void operator=(const Discrete_intervals_list& from)
334
for (Discrete_interval *i= head; i;)
336
Discrete_interval *next= i->next;
343
const Discrete_interval* get_next()
345
Discrete_interval *tmp= current;
347
current= current->next;
350
~Discrete_intervals_list() { empty(); };
351
bool append(uint64_t start, uint64_t val, uint64_t incr);
352
bool append(Discrete_interval *interval);
353
uint64_t minimum() const { return (head ? head->minimum() : 0); };
354
uint64_t maximum() const { return (head ? tail->maximum() : 0); };
355
uint32_t nb_elements() const { return elements; }
180
#endif /* DRIZZLED_STRUCTS_H */