~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to library/sql-parser/source/structs.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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; either version 2 of the License, or
 
6
   (at your option) any later version.
 
7
 
 
8
   This program is distributed in the hope that it will be useful,
 
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
   GNU General Public License for more details.
 
12
 
 
13
   You should have received a copy of the GNU General Public License
 
14
   along with this program; if not, write to the Free Software
 
15
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
16
 
 
17
 
 
18
/* The old structures from unireg */
 
19
 
 
20
#ifndef __STRUCTS_H__
 
21
#define __STRUCTS_H__
 
22
 
 
23
namespace mysql_parser
 
24
{
 
25
 
 
26
struct st_table;
 
27
class Field;
 
28
 
 
29
typedef struct st_lex_string
 
30
{
 
31
  char *str;
 
32
  uint length;
 
33
} LEX_STRING;
 
34
 
 
35
typedef struct st_lex_string_with_init :public st_lex_string
 
36
{
 
37
  st_lex_string_with_init(const char *str_arg, uint length_arg)
 
38
  {
 
39
    str= (char*) str_arg;
 
40
    length= length_arg;
 
41
  }
 
42
} LEX_STRING_WITH_INIT;
 
43
 
 
44
 
 
45
typedef struct st_date_time_format {
 
46
  uchar positions[8];
 
47
  char  time_separator;                 /* Separator between hour and minute */
 
48
  uint flag;                            /* For future */
 
49
  LEX_STRING format;
 
50
} DATE_TIME_FORMAT;
 
51
 
 
52
#if 0
 
53
typedef struct st_keyfile_info {        /* used with ha_info() */
 
54
  byte ref[MAX_REFLENGTH];              /* Pointer to current row */
 
55
  byte dupp_ref[MAX_REFLENGTH];         /* Pointer to dupp row */
 
56
  uint ref_length;                      /* Length of ref (1-8) */
 
57
  uint block_size;                      /* index block size */
 
58
  File filenr;                          /* (uniq) filenr for table */
 
59
  ha_rows records;                      /* Records i datafilen */
 
60
  ha_rows deleted;                      /* Deleted records */
 
61
  ulonglong data_file_length;           /* Length off data file */
 
62
  ulonglong max_data_file_length;       /* Length off data file */
 
63
  ulonglong index_file_length;
 
64
  ulonglong max_index_file_length;
 
65
  ulonglong delete_length;              /* Free bytes */
 
66
  ulonglong auto_increment_value;
 
67
  int errkey,sortkey;                   /* Last errorkey and sorted by */
 
68
  time_t create_time;                   /* When table was created */
 
69
  time_t check_time;
 
70
  time_t update_time;
 
71
  ulong mean_rec_length;                /* physical reclength */
 
72
} KEYFILE_INFO;
 
73
#endif
 
74
 
 
75
typedef struct st_key_part_info {       /* Info about a key part */
 
76
  Field *field;
 
77
  uint  offset;                         /* offset in record (from 0) */
 
78
  uint  null_offset;                    /* Offset to null_bit in record */
 
79
  uint16 length;                        /* Length of key_part */
 
80
  uint16 store_length;
 
81
  uint16 key_type;
 
82
  uint16 fieldnr;                       /* Fieldnum in UNIREG */
 
83
  uint16 key_part_flag;                 /* 0 or HA_REVERSE_SORT */
 
84
  uint8 type;
 
85
  uint8 null_bit;                       /* Position to null_bit */
 
86
} KEY_PART_INFO ;
 
87
 
 
88
 
 
89
typedef struct st_key {
 
90
  uint  key_length;                     /* Tot length of key */
 
91
  uint  flags;                          /* dupp key and pack flags */
 
92
  uint  key_parts;                      /* How many key_parts */
 
93
  uint  extra_length;
 
94
  uint  usable_key_parts;               /* Should normally be = key_parts */
 
95
 // enum  ha_key_alg algorithm;
 
96
  /*
 
97
    Note that parser is used when the table is opened for use, and
 
98
    parser_name is used when the table is being created.
 
99
  */
 
100
  union
 
101
  {
 
102
    struct st_plugin_int *parser;       /* Fulltext [pre]parser */
 
103
    LEX_STRING *parser_name;            /* Fulltext [pre]parser name */
 
104
  };
 
105
  KEY_PART_INFO *key_part;
 
106
  char  *name;                          /* Name of key */
 
107
  /*
 
108
    Array of AVG(#records with the same field value) for 1st ... Nth key part.
 
109
    0 means 'not known'.
 
110
    For temporary heap tables this member is NULL.
 
111
  */
 
112
  ulong *rec_per_key;
 
113
  union {
 
114
    int  bdb_return_if_eq;
 
115
  } handler;
 
116
  struct st_table *table;
 
117
} KEY;
 
118
 
 
119
 
 
120
struct st_join_table;
 
121
 
 
122
typedef struct st_reginfo {             /* Extra info about reg */
 
123
  struct st_join_table *join_tab;       /* Used by SELECT() */
 
124
  //enum thr_lock_type lock_type;               /* How database is used */
 
125
  bool not_exists_optimize;
 
126
  bool impossible_range;
 
127
} REGINFO;
 
128
 
 
129
 
 
130
struct st_read_record;                          /* For referense later */
 
131
//class SQL_SELECT;
 
132
//class THD;
 
133
class handler;
 
134
 
 
135
typedef struct st_read_record {                 /* Parameter to read_record */
 
136
  struct st_table *table;                       /* Head-form */
 
137
  handler *file;
 
138
  struct st_table **forms;                      /* head and ref forms */
 
139
  int (*read_record)(struct st_read_record *);
 
140
  //THD *thd;
 
141
  //SQL_SELECT *select;
 
142
  uint cache_records;
 
143
  uint ref_length,struct_length,reclength,rec_cache_size,error_offset;
 
144
  uint index;
 
145
  byte *ref_pos;                                /* pointer to form->refpos */
 
146
  byte *record;
 
147
  byte *rec_buf;                /* to read field values  after filesort */
 
148
  byte  *cache,*cache_pos,*cache_end,*read_positions;
 
149
  //IO_CACHE *io_cache;
 
150
  bool print_error, ignore_not_found_rows;
 
151
} READ_RECORD;
 
152
 
 
153
 
 
154
/*
 
155
  Originally MySQL used TIME structure inside server only, but since
 
156
  4.1 it's exported to user in the new client API. Define aliases for
 
157
  new names to keep existing code simple.
 
158
*/
 
159
 
 
160
typedef struct st_mysql_time TIME;
 
161
//typedef enum enum_mysql_timestamp_type timestamp_type;
 
162
 
 
163
 
 
164
typedef struct {
 
165
  ulong year,month,day,hour;
 
166
  ulonglong minute,second,second_part;
 
167
  bool neg;
 
168
} INTERVAL;
 
169
 
 
170
 
 
171
typedef struct st_known_date_time_format {
 
172
  const char *format_name;
 
173
  const char *date_format;
 
174
  const char *datetime_format;
 
175
  const char *time_format;
 
176
} KNOWN_DATE_TIME_FORMAT;
 
177
 
 
178
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
 
179
 
 
180
extern const char *show_comp_option_name[];
 
181
 
 
182
//typedef int *(*update_var)(THD *, struct st_mysql_show_var *);
 
183
 
 
184
typedef struct  st_lex_user {
 
185
  LEX_STRING user, host, password;
 
186
} LEX_USER;
 
187
 
 
188
/*
 
189
  This structure specifies the maximum amount of resources which
 
190
  can be consumed by each account. Zero value of a member means
 
191
  there is no limit.
 
192
*/
 
193
typedef struct user_resources {
 
194
  /* Maximum number of queries/statements per hour. */
 
195
  uint questions;
 
196
  /*
 
197
     Maximum number of updating statements per hour (which statements are
 
198
     updating is defined by uc_update_queries array).
 
199
  */
 
200
  uint updates;
 
201
  /* Maximum number of connections established per hour. */
 
202
  uint conn_per_hour;
 
203
  /* Maximum number of concurrent connections. */
 
204
  uint user_conn;
 
205
  /*
 
206
     Values of this enum and specified_limits member are used by the
 
207
     parser to store which user limits were specified in GRANT statement.
 
208
  */
 
209
  enum {QUERIES_PER_HOUR= 1, UPDATES_PER_HOUR= 2, CONNECTIONS_PER_HOUR= 4,
 
210
        USER_CONNECTIONS= 8};
 
211
  uint specified_limits;
 
212
} USER_RESOURCES;
 
213
 
 
214
 
 
215
/*
 
216
  This structure is used for counting resources consumed and for checking
 
217
  them against specified user limits.
 
218
*/
 
219
typedef struct  user_conn {
 
220
  /*
 
221
     Pointer to user+host key (pair separated by '\0') defining the entity
 
222
     for which resources are counted (By default it is user account thus
 
223
     priv_user/priv_host pair is used. If --old-style-user-limits option
 
224
     is enabled, resources are counted for each user+host separately).
 
225
  */
 
226
  char *user;
 
227
  /* Pointer to host part of the key. */
 
228
  char *host;
 
229
  /* Total length of the key. */
 
230
  uint len;
 
231
  /* Current amount of concurrent connections for this account. */
 
232
  uint connections;
 
233
  /*
 
234
     Current number of connections per hour, number of updating statements
 
235
     per hour and total number of statements per hour for this account.
 
236
  */
 
237
  uint conn_per_hour, updates, questions;
 
238
  /* Maximum amount of resources which account is allowed to consume. */
 
239
  USER_RESOURCES user_resources;
 
240
  /*
 
241
     The moment of time when per hour counters were reset last time
 
242
     (i.e. start of "hour" for conn_per_hour, updates, questions counters).
 
243
  */
 
244
  time_t intime;
 
245
} USER_CONN;
 
246
 
 
247
        /* Bits in form->update */
 
248
#define REG_MAKE_DUPP           1       /* Make a copy of record when read */
 
249
#define REG_NEW_RECORD          2       /* Write a new record if not found */
 
250
#define REG_UPDATE              4       /* Uppdate record */
 
251
#define REG_DELETE              8       /* Delete found record */
 
252
#define REG_PROG                16      /* User is updating database */
 
253
#define REG_CLEAR_AFTER_WRITE   32
 
254
#define REG_MAY_BE_UPDATED      64
 
255
#define REG_AUTO_UPDATE         64      /* Used in D-forms for scroll-tables */
 
256
#define REG_OVERWRITE           128
 
257
#define REG_SKIP_DUP            256
 
258
 
 
259
        /* Bits in form->status */
 
260
#define STATUS_NO_RECORD        (1+2)   /* Record isn't usably */
 
261
#define STATUS_GARBAGE          1
 
262
#define STATUS_NOT_FOUND        2       /* No record in database when needed */
 
263
#define STATUS_NO_PARENT        4       /* Parent record wasn't found */
 
264
#define STATUS_NOT_READ         8       /* Record isn't read */
 
265
#define STATUS_UPDATED          16      /* Record is updated by formula */
 
266
#define STATUS_NULL_ROW         32      /* table->null_row is set */
 
267
#define STATUS_DELETED          64
 
268
 
 
269
 
 
270
} // namespace mysql_parser
 
271
 
 
272
#endif // __STRUCTS_H__
 
273