~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/structs.h

  • Committer: Stewart Smith
  • Date: 2009-03-11 06:37:19 UTC
  • mto: (910.4.19 sparc) (937.2.1 sparc)
  • mto: This revision was merged to the branch mainline in revision 931.
  • Revision ID: stewart@flamingspork.com-20090311063719-v9iqjd00ts6260vv
batch up more INSERTs into transactions to help tests run quicker.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
23
23
#ifndef DRIZZLED_STRUCTS_H
24
24
#define DRIZZLED_STRUCTS_H
25
25
 
26
 
#include "drizzled/base.h"
27
 
#include "drizzled/definitions.h"
28
 
#include "drizzled/lex_string.h"
29
 
#include "drizzled/thr_lock.h"
30
 
 
31
 
namespace drizzled
32
 
{
33
 
 
34
 
namespace internal
35
 
{
36
 
typedef struct st_io_cache IO_CACHE;
37
 
}
 
26
#include <drizzled/base.h>
 
27
#include <mysys/definitions.h>
 
28
#include <drizzled/lex_string.h>
38
29
 
39
30
class Table;
40
31
class Field;
41
 
 
42
 
class KeyPartInfo 
43
 
{       /* Info about a key part */
44
 
public:
 
32
typedef struct st_io_cache IO_CACHE;
 
33
 
 
34
typedef struct st_keyfile_info {        /* used with ha_info() */
 
35
  unsigned char ref[MAX_REFLENGTH];             /* Pointer to current row */
 
36
  unsigned char dupp_ref[MAX_REFLENGTH];        /* Pointer to dupp row */
 
37
  uint32_t ref_length;                  /* Length of ref (1-8) */
 
38
  uint32_t block_size;                  /* index block size */
 
39
  File filenr;                          /* (uniq) filenr for table */
 
40
  ha_rows records;                      /* Records i datafilen */
 
41
  ha_rows deleted;                      /* Deleted records */
 
42
  uint64_t data_file_length;            /* Length off data file */
 
43
  uint64_t max_data_file_length;        /* Length off data file */
 
44
  uint64_t index_file_length;
 
45
  uint64_t max_index_file_length;
 
46
  uint64_t delete_length;               /* Free bytes */
 
47
  uint64_t auto_increment_value;
 
48
  int errkey,sortkey;                   /* Last errorkey and sorted by */
 
49
  time_t create_time;                   /* When table was created */
 
50
  time_t check_time;
 
51
  time_t update_time;
 
52
  uint64_t mean_rec_length;             /* physical reclength */
 
53
} KEYFILE_INFO;
 
54
 
 
55
 
 
56
typedef struct st_key_part_info {       /* Info about a key part */
45
57
  Field *field;
46
 
  unsigned int  offset;                         /* offset in record (from 0) */
47
 
  unsigned int  null_offset;                    /* Offset to null_bit in record */
 
58
  uint  offset;                         /* offset in record (from 0) */
 
59
  uint  null_offset;                    /* Offset to null_bit in record */
48
60
  /* Length of key part in bytes, excluding NULL flag and length bytes */
49
61
  uint16_t length;
50
62
  /*
57
69
  */
58
70
  uint16_t store_length;
59
71
  uint16_t key_type;
60
 
private:
61
 
public:
62
 
  uint16_t getKeyType() const
63
 
  {
64
 
    return key_type;
65
 
  }
66
72
  uint16_t fieldnr;                     /* Fieldnum in UNIREG (1,2,3,...) */
67
73
  uint16_t key_part_flag;                       /* 0 or HA_REVERSE_SORT */
68
74
  uint8_t type;
69
75
  uint8_t null_bit;                     /* Position to null_bit */
70
 
};
71
 
 
72
 
 
73
 
class KeyInfo 
74
 
{
75
 
public:
76
 
  unsigned int  key_length;             /* Tot length of key */
77
 
  enum  ha_key_alg algorithm;
78
 
  unsigned long flags;                  /* dupp key and pack flags */
79
 
  unsigned int key_parts;               /* How many key_parts */
 
76
} KEY_PART_INFO ;
 
77
 
 
78
 
 
79
typedef struct st_key {
 
80
  uint  key_length;                     /* Tot length of key */
 
81
  ulong flags;                          /* dupp key and pack flags */
 
82
  uint  key_parts;                      /* How many key_parts */
80
83
  uint32_t  extra_length;
81
 
  unsigned int usable_key_parts;        /* Should normally be = key_parts */
 
84
  uint  usable_key_parts;               /* Should normally be = key_parts */
82
85
  uint32_t  block_size;
83
 
  KeyPartInfo *key_part;
 
86
  enum  ha_key_alg algorithm;
 
87
  KEY_PART_INFO *key_part;
84
88
  char  *name;                          /* Name of key */
85
89
  /*
86
90
    Array of AVG(#records with the same field value) for 1st ... Nth key part.
90
94
  ulong *rec_per_key;
91
95
  Table *table;
92
96
  LEX_STRING comment;
93
 
};
94
 
 
95
 
 
96
 
class JoinTable;
97
 
 
98
 
class RegInfo 
99
 
{
100
 
public:         /* Extra info about reg */
101
 
  JoinTable *join_tab;  /* Used by SELECT() */
 
97
} KEY;
 
98
 
 
99
 
 
100
struct st_join_table;
 
101
 
 
102
typedef struct st_reginfo {             /* Extra info about reg */
 
103
  struct st_join_table *join_tab;       /* Used by SELECT() */
102
104
  enum thr_lock_type lock_type;         /* How database is used */
103
105
  bool not_exists_optimize;
104
106
  bool impossible_range;
105
 
  RegInfo()
106
 
    : join_tab(NULL), lock_type(TL_UNLOCK),
107
 
      not_exists_optimize(false), impossible_range(false) {}
108
 
  void reset()
109
 
  {
110
 
    join_tab= NULL;
111
 
    lock_type= TL_UNLOCK;
112
 
    not_exists_optimize= false;
113
 
    impossible_range= false;
114
 
  }
115
 
};
116
 
 
 
107
} REGINFO;
 
108
 
 
109
 
 
110
struct st_read_record;                          /* For referense later */
 
111
class SQL_SELECT;
117
112
class Session;
118
 
class Cursor;
119
 
namespace optimizer { class SqlSelect; }
120
 
 
121
 
typedef int *(*update_var)(Session *, struct drizzle_show_var *);
122
 
 
123
 
} /* namespace drizzled */
 
113
class handler;
 
114
struct st_join_table;
 
115
 
 
116
typedef struct st_read_record {                 /* Parameter to read_record */
 
117
  Table *table;                 /* Head-form */
 
118
  handler *file;
 
119
  Table **forms;                        /* head and ref forms */
 
120
  int (*read_record)(struct st_read_record *);
 
121
  Session *session;
 
122
  SQL_SELECT *select;
 
123
  uint32_t cache_records;
 
124
  uint32_t ref_length,struct_length,reclength,rec_cache_size,error_offset;
 
125
  uint32_t index;
 
126
  unsigned char *ref_pos;                               /* pointer to form->refpos */
 
127
  unsigned char *record;
 
128
  unsigned char *rec_buf;                /* to read field values  after filesort */
 
129
  unsigned char *cache,*cache_pos,*cache_end,*read_positions;
 
130
  IO_CACHE *io_cache;
 
131
  bool print_error, ignore_not_found_rows;
 
132
  struct st_join_table *do_insideout_scan;
 
133
} READ_RECORD;
 
134
 
 
135
 
 
136
typedef struct {
 
137
  uint32_t year;
 
138
  uint32_t month;
 
139
  uint32_t day;
 
140
  uint32_t hour;
 
141
  uint64_t minute,second,second_part;
 
142
  bool neg;
 
143
} INTERVAL;
 
144
 
 
145
extern const char *show_comp_option_name[];
 
146
 
 
147
typedef int *(*update_var)(Session *, struct st_mysql_show_var *);
 
148
 
 
149
typedef struct  st_lex_user {
 
150
  LEX_STRING user, host, password;
 
151
} LEX_USER;
 
152
 
 
153
/*
 
154
  This structure is used for counting resources consumed and for checking
 
155
  them against specified user limits.
 
156
*/
 
157
typedef struct  user_conn {
 
158
  /*
 
159
     Pointer to user+host key (pair separated by '\0') defining the entity
 
160
     for which resources are counted (By default it is user account thus
 
161
     priv_user/priv_host pair is used. If --old-style-user-limits option
 
162
     is enabled, resources are counted for each user+host separately).
 
163
  */
 
164
  char *user;
 
165
  /* Pointer to host part of the key. */
 
166
  char *host;
 
167
  /**
 
168
     The moment of time when per hour counters were reset last time
 
169
     (i.e. start of "hour" for conn_per_hour, updates, questions counters).
 
170
  */
 
171
  uint64_t reset_utime;
 
172
  /* Total length of the key. */
 
173
  uint32_t len;
 
174
  /* Current amount of concurrent connections for this account. */
 
175
  uint32_t connections;
 
176
  /*
 
177
     Current number of connections per hour, number of updating statements
 
178
     per hour and total number of statements per hour for this account.
 
179
  */
 
180
  uint32_t conn_per_hour, updates, questions;
 
181
} USER_CONN;
 
182
 
 
183
        /* Bits in form->update */
 
184
#define REG_MAKE_DUPP           1       /* Make a copy of record when read */
 
185
#define REG_NEW_RECORD          2       /* Write a new record if not found */
 
186
#define REG_UPDATE              4       /* Uppdate record */
 
187
#define REG_DELETE              8       /* Delete found record */
 
188
#define REG_PROG                16      /* User is updating database */
 
189
#define REG_CLEAR_AFTER_WRITE   32
 
190
#define REG_MAY_BE_UPDATED      64
 
191
#define REG_AUTO_UPDATE         64      /* Used in D-forms for scroll-tables */
 
192
#define REG_OVERWRITE           128
 
193
#define REG_SKIP_DUP            256
124
194
 
125
195
        /* Bits in form->status */
126
196
#define STATUS_NO_RECORD        (1+2)   /* Record isn't usably */