154
typedef struct st_known_date_time_format {
155
const char *format_name;
156
const char *date_format;
157
const char *datetime_format;
158
const char *time_format;
159
} KNOWN_DATE_TIME_FORMAT;
162
145
extern const char *show_comp_option_name[];
164
147
typedef int *(*update_var)(Session *, struct st_mysql_show_var *);
166
typedef struct st_lex_user {
167
LEX_STRING user, host, password;
171
This structure specifies the maximum amount of resources which
172
can be consumed by each account. Zero value of a member means
175
typedef struct user_resources {
176
/* Maximum number of queries/statements per hour. */
179
Maximum number of updating statements per hour (which statements are
180
updating is defined by sql_command_flags array).
183
/* Maximum number of connections established per hour. */
184
uint32_t conn_per_hour;
185
/* Maximum number of concurrent connections. */
188
Values of this enum and specified_limits member are used by the
189
parser to store which user limits were specified in GRANT statement.
191
enum {QUERIES_PER_HOUR= 1, UPDATES_PER_HOUR= 2, CONNECTIONS_PER_HOUR= 4,
192
USER_CONNECTIONS= 8};
193
uint32_t specified_limits;
198
This structure is used for counting resources consumed and for checking
199
them against specified user limits.
201
typedef struct user_conn {
203
Pointer to user+host key (pair separated by '\0') defining the entity
204
for which resources are counted (By default it is user account thus
205
priv_user/priv_host pair is used. If --old-style-user-limits option
206
is enabled, resources are counted for each user+host separately).
209
/* Pointer to host part of the key. */
212
The moment of time when per hour counters were reset last time
213
(i.e. start of "hour" for conn_per_hour, updates, questions counters).
215
uint64_t reset_utime;
216
/* Total length of the key. */
218
/* Current amount of concurrent connections for this account. */
219
uint32_t connections;
221
Current number of connections per hour, number of updating statements
222
per hour and total number of statements per hour for this account.
224
uint32_t conn_per_hour, updates, questions;
225
/* Maximum amount of resources which account is allowed to consume. */
226
USER_RESOURCES user_resources;
229
149
/* Bits in form->update */
230
150
#define REG_MAKE_DUPP 1 /* Make a copy of record when read */
231
151
#define REG_NEW_RECORD 2 /* Write a new record if not found */
248
168
#define STATUS_NULL_ROW 32 /* table->null_row is set */
249
169
#define STATUS_DELETED 64
252
Such interval is "discrete": it is the set of
253
{ auto_inc_interval_min + k * increment,
254
0 <= k <= (auto_inc_interval_values-1) }
255
Where "increment" is maintained separately by the user of this class (and is
256
currently only session->variables.auto_increment_increment).
257
It mustn't derive from Sql_alloc, because SET INSERT_ID needs to
258
allocate memory which must stay allocated for use by the next statement.
260
class Discrete_interval {
262
uint64_t interval_min;
263
uint64_t interval_values;
264
uint64_t interval_max; // excluded bound. Redundant.
266
Discrete_interval *next; // used when linked into Discrete_intervals_list
267
void replace(uint64_t start, uint64_t val, uint64_t incr)
270
interval_values= val;
271
interval_max= (val == UINT64_MAX) ? val : start + val * incr;
273
Discrete_interval(uint64_t start, uint64_t val, uint64_t incr) :
274
interval_min(start), interval_values(val),
275
interval_max((val == UINT64_MAX) ? val : start + val * incr),
278
Discrete_interval() :
279
interval_min(0), interval_values(0),
280
interval_max(0), next(NULL)
282
uint64_t minimum() const { return interval_min; };
283
uint64_t values() const { return interval_values; };
284
uint64_t maximum() const { return interval_max; };
286
If appending [3,5] to [1,2], we merge both in [1,5] (they should have the
287
same increment for that, user of the class has to ensure that). That is
288
just a space optimization. Returns 0 if merge succeeded.
290
bool merge_if_contiguous(uint64_t start, uint64_t val, uint64_t incr)
292
if (interval_max == start)
294
if (val == UINT64_MAX)
296
interval_values= interval_max= val;
300
interval_values+= val;
301
interval_max= start + val * incr;
309
/* List of Discrete_interval objects */
310
class Discrete_intervals_list {
312
Discrete_interval *head;
313
Discrete_interval *tail;
315
When many intervals are provided at the beginning of the execution of a
316
statement (in a replication slave or SET INSERT_ID), "current" points to
317
the interval being consumed by the thread now (so "current" goes from
318
"head" to "tail" then to NULL).
320
Discrete_interval *current;
321
uint32_t elements; // number of elements
323
/* helper function for copy construct and assignment operator */
324
void copy_(const Discrete_intervals_list& from)
326
for (Discrete_interval *i= from.head; i; i= i->next)
328
Discrete_interval j= *i;
333
Discrete_intervals_list() :
334
head(NULL), tail(NULL),
335
current(NULL), elements(0) {};
336
Discrete_intervals_list(const Discrete_intervals_list& from) :
337
head(NULL), tail(NULL),
338
current(NULL), elements(0)
342
Discrete_intervals_list& operator=(const Discrete_intervals_list& from)
355
for (Discrete_interval *i= head; i;)
357
Discrete_interval *next= i->next;
364
const Discrete_interval* get_next()
366
Discrete_interval *tmp= current;
368
current= current->next;
371
~Discrete_intervals_list() { empty(); };
372
bool append(uint64_t start, uint64_t val, uint64_t incr);
373
bool append(Discrete_interval *interval);
374
uint64_t minimum() const { return (head ? head->minimum() : 0); };
375
uint64_t maximum() const { return (head ? tail->maximum() : 0); };
376
uint32_t nb_elements() const { return elements; }
379
171
#endif /* DRIZZLED_STRUCTS_H */