~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/common_includes.h

Merged from Jay.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000-2003 MySQL 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; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
/**
 
17
 * @file
 
18
 * 
 
19
 * Contains #includes and definitions that apply to ALL server-related
 
20
 * executables, including storage engine plugins.
 
21
 *
 
22
 * @details
 
23
 *
 
24
 * Previously, the mysql_priv.h file contained a number of conditional
 
25
 * #ifdef MYSQL_SERVER blocks which made it very difficult to determine
 
26
 * which headers and definitions were actually necessary for plugins to 
 
27
 * include.  The file, and NOT mysql_priv.h, should now be the main included
 
28
 * header for storage engine plugins, as it contains all definitions and 
 
29
 * declarations needed by the plugin and nothing more.
 
30
 */
 
31
#ifndef DRIZZLE_SERVER_COMMON_INCLUDES_H
 
32
#define DRIZZLE_SERVER_COMMON_INCLUDES_H
 
33
 
 
34
/* Cross-platform portability code and standard includes */
 
35
#include <drizzled/global.h>                    
 
36
/* Server versioning information and defines */
 
37
#include <drizzled/version.h>                   
 
38
/* Lots of system-wide struct definitions like IO_CACHE, DYNAMIC_STRING, prototypes for all my_* functions */
 
39
#include <mysys/my_sys.h>                       
 
40
/* Convenience functions for working with times */
 
41
#include <libdrizzle/my_time.h>
 
42
/* Custom C string functions */
 
43
#include <mystrings/m_string.h>
 
44
/* Custom HASH API */
 
45
#include <mysys/hash.h>
 
46
/* Standard signals API */
 
47
#include <signal.h>
 
48
/* Deadlock-free table-list lock API */
 
49
#include <mysys/thr_lock.h>
 
50
/* Custom error API */
 
51
#include <drizzled/error.h>
 
52
/* Defines for the storage engine handler -- i.e. HA_XXX defines */
 
53
#include <drizzled/base.h>                                      /* Needed by field.h */
 
54
/* Custom queue API */
 
55
#include <mysys/queues.h>
 
56
/* Custom Bitmap API */
 
57
#include <drizzled/sql_bitmap.h>
 
58
/* Custom templatized, type-safe Dynamic_Array API */
 
59
#include "sql_array.h"
 
60
/* The <strong>INTERNAL</strong> plugin API - not the external, or public, server plugin API */
 
61
#include "sql_plugin.h"
 
62
/* The <strong>connection</strong> thread scheduler API */
 
63
#include "scheduler.h"
 
64
/* Network database operations (hostent, netent, servent, etc...*/
 
65
#include <netdb.h>
 
66
/* Definitions that the client and the server have in common */
 
67
#include <libdrizzle/drizzle_com.h>
 
68
/* gettext() convenience wrappers */
 
69
#include <libdrizzle/gettext.h>
 
70
/* Contains system-wide constants and #defines */
 
71
#include <drizzled/definitions.h>
 
72
/* System-wide common data structures */
 
73
#include <drizzled/structs.h>
 
74
/* Custom error definitions */
 
75
#include <drizzled/error.h>
 
76
/* Custom continguous-section memory allocator */
 
77
#include <drizzled/sql_alloc.h>
 
78
/* Virtual I/O wrapper library */
 
79
#include <vio/violite.h>
 
80
/* Definition of the MY_LOCALE struct and some convenience functions */
 
81
#include <drizzled/sql_locale.h>
 
82
/* 
 
83
 * Declarations of Object_creation_ctx and Default_creation_ctx, 
 
84
 * needed by parser.  Object_creation_ctx depends on THD, but THD
 
85
 * is forward-declared in scheduler.h, so we're good to put this
 
86
 * here 
 
87
 */
 
88
#include <drizzled/object_creation_ctx.h>
 
89
 
 
90
#ifdef HAVE_DTRACE
 
91
#define _DTRACE_VERSION 1
 
92
#endif
 
93
#include "probes.h"
 
94
 
 
95
/**
 
96
  Query type constants.
 
97
 
 
98
  QT_ORDINARY -- ordinary SQL query.
 
99
  QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
 
100
  character set introducers).
 
101
 
 
102
  @TODO
 
103
 
 
104
  Move this out of here once Stew's done with UDF breakout.  The following headers need it:
 
105
 
 
106
    sql_lex.h --> included by sql_class.h
 
107
    item.h
 
108
    table.h
 
109
    item_func.h
 
110
    item_subselect.h
 
111
    item_timefunc.h
 
112
    item_sum.h
 
113
    item_cmpfunc.h
 
114
    item_strfunc.h
 
115
*/
 
116
enum enum_query_type
 
117
{
 
118
  QT_ORDINARY,
 
119
  QT_IS
 
120
};
 
121
 
 
122
/** 
 
123
 * @TODO convert all these three maps to Bitmap classes 
 
124
 *
 
125
 * @TODO Move these to a more appropriate header file (maps.h?).  The following files use them:
 
126
 *
 
127
 *    item_sum.h
 
128
 *    item_compfunc.h
 
129
 *    item.h
 
130
 *    table.h
 
131
 *    item_subselect.h
 
132
 *    sql_bitmap.h
 
133
 *    unireg.h (going bye bye?)
 
134
 *    sql_udf.h
 
135
 *    item_row.h
 
136
 *    handler.cc
 
137
 *    sql_insert.cc
 
138
 *    opt_range.h
 
139
 *    opt_sum.cc
 
140
 *    item_strfunc.h
 
141
 *    sql_delete.cc
 
142
 *    sql_select.h
 
143
 *
 
144
 *    Since most of these include table.h, I think that would appropriate...
 
145
 */
 
146
typedef uint64_t table_map;          /* Used for table bits in join */
 
147
#if MAX_INDEXES <= 64
 
148
typedef Bitmap<64>  key_map;          /* Used for finding keys */
 
149
#else
 
150
typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
 
151
#endif
 
152
typedef uint32_t nesting_map;  /* Used for flags of nesting constructs */
 
153
 
 
154
/*
 
155
  Used to identify NESTED_JOIN structures within a join (applicable only to
 
156
  structures that have not been simplified away and embed more the one
 
157
  element)
 
158
*/
 
159
typedef uint64_t nested_join_map; /* Needed by sql_select.h and table.h */
 
160
 
 
161
/* useful constants */#
 
162
extern const key_map key_map_empty;
 
163
extern key_map key_map_full;          /* Should be threaded as const */
 
164
extern const char *primary_key_name;
 
165
 
 
166
/**
 
167
 * @TODO Move the following into a drizzled.h header?
 
168
 *
 
169
 * I feel that global variables and functions referencing them directly
 
170
 * and that are used only in the server should be separated out into 
 
171
 * a drizzled.h header file -- JRP
 
172
 */
 
173
typedef uint64_t query_id_t;
 
174
extern query_id_t global_query_id;
 
175
 
 
176
/* increment query_id and return it.  */
 
177
inline query_id_t next_query_id() { return global_query_id++; }
 
178
 
 
179
extern const CHARSET_INFO *system_charset_info, *files_charset_info ;
 
180
extern const CHARSET_INFO *national_charset_info, *table_alias_charset;
 
181
 
 
182
/**
 
183
 * @TODO Move to a separate header?
 
184
 *
 
185
 * It's needed by item.h and field.h, which are both inter-dependent
 
186
 * and contain forward declarations of many structs/classes in the
 
187
 * other header file.
 
188
 *
 
189
 * What is needed is a separate header file that is included
 
190
 * by *both* item.h and field.h to resolve inter-dependencies
 
191
 *
 
192
 * But, probably want to hold off on this until Stew finished the UDF cleanup
 
193
 */
 
194
enum Derivation
 
195
{
 
196
  DERIVATION_IGNORABLE= 5,
 
197
  DERIVATION_COERCIBLE= 4,
 
198
  DERIVATION_SYSCONST= 3,
 
199
  DERIVATION_IMPLICIT= 2,
 
200
  DERIVATION_NONE= 1,
 
201
  DERIVATION_EXPLICIT= 0
 
202
};
 
203
 
 
204
/**
 
205
 * Opening modes for open_temporary_table and open_table_from_share
 
206
 *
 
207
 * @TODO Put this into an appropriate header. It is only needed in:
 
208
 *
 
209
 *    table.cc
 
210
 *    sql_base.cc
 
211
 */
 
212
enum open_table_mode
 
213
{
 
214
  OTM_OPEN= 0,
 
215
  OTM_CREATE= 1,
 
216
  OTM_ALTER= 2
 
217
};
 
218
 
 
219
enum enum_parsing_place
 
220
{
 
221
  NO_MATTER
 
222
  , IN_HAVING
 
223
  , SELECT_LIST
 
224
  , IN_WHERE
 
225
  , IN_ON
 
226
};
 
227
 
 
228
enum enum_mysql_completiontype {
 
229
  ROLLBACK_RELEASE= -2
 
230
  , ROLLBACK= 1
 
231
  , ROLLBACK_AND_CHAIN= 7
 
232
  , COMMIT_RELEASE= -1
 
233
  , COMMIT= 0
 
234
  , COMMIT_AND_CHAIN= 6
 
235
};
 
236
 
 
237
enum enum_check_fields
 
238
{
 
239
  CHECK_FIELD_IGNORE
 
240
  , CHECK_FIELD_WARN
 
241
  , CHECK_FIELD_ERROR_FOR_NULL
 
242
};
 
243
 
 
244
enum enum_var_type
 
245
{
 
246
  OPT_DEFAULT= 0
 
247
  , OPT_SESSION
 
248
  , OPT_GLOBAL
 
249
};
 
250
 
 
251
/* Forward declarations */
 
252
 
 
253
struct TABLE_LIST;
 
254
class String;
 
255
struct st_table;
 
256
class THD;
 
257
class user_var_entry;
 
258
class Security_context;
 
259
 
 
260
#define thd_proc_info(thd, msg)  set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
 
261
 
 
262
extern pthread_key(THD*, THR_THD);
 
263
inline THD *_current_thd(void)
 
264
{
 
265
  return (THD *)pthread_getspecific(THR_THD);
 
266
}
 
267
#define current_thd _current_thd()
 
268
 
 
269
/** 
 
270
  The meat of thd_proc_info(THD*, char*), a macro that packs the last
 
271
  three calling-info parameters. 
 
272
*/
 
273
extern "C"
 
274
const char *set_thd_proc_info(THD *thd, const char *info, 
 
275
                              const char *calling_func, 
 
276
                              const char *calling_file, 
 
277
                              const unsigned int calling_line);
 
278
 
 
279
/*
 
280
  External variables
 
281
*/
 
282
extern ulong server_id;
 
283
 
 
284
/* Custom C++-style String class API */
 
285
#include <drizzled/sql_string.h>
 
286
/* Custom singly-linked list lite struct and full-blown type-safe, templatized class */
 
287
#include <drizzled/sql_list.h>
 
288
#include "sql_map.h"
 
289
#include "my_decimal.h"
 
290
#include "handler.h"
 
291
#include "table.h"
 
292
#include "sql_error.h"
 
293
/* Drizzle server data type class definitions */
 
294
#include <drizzled/field.h>
 
295
#include "protocol.h"
 
296
#include "sql_udf.h"
 
297
#include "item.h"
 
298
 
 
299
extern my_decimal decimal_zero;
 
300
 
 
301
/** @TODO Find a good header to put this guy... */
 
302
void close_thread_tables(THD *thd);
 
303
 
 
304
#include <drizzled/sql_parse.h>
 
305
 
 
306
#include "sql_class.h"
 
307
#include "slave.h" // for tables_ok(), rpl_filter
 
308
#include "tztime.h"
 
309
 
 
310
void sql_perror(const char *message);
 
311
 
 
312
bool fn_format_relative_to_data_home(char * to, const char *name,
 
313
                                     const char *dir, const char *extension);
 
314
 
 
315
/**
 
316
 * @TODO
 
317
 *
 
318
 * This is much better than the previous situation of a crap-ton
 
319
 * of conditional defines all over mysql_priv.h, but this still
 
320
 * is hackish.  Put these things into a separate header?  Or fix
 
321
 * InnoDB?  Or does the InnoDB plugin already fix this stuff?
 
322
 */
 
323
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
 
324
bool check_global_access(THD *thd, ulong want_access);
 
325
int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
 
326
extern struct system_variables global_system_variables;
 
327
extern uint mysql_data_home_len;
 
328
extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
 
329
            mysql_real_data_home[], mysql_unpacked_real_data_home[];
 
330
extern const CHARSET_INFO *character_set_filesystem;
 
331
extern char reg_ext[FN_EXTLEN];
 
332
extern uint reg_ext_length;
 
333
extern ulong specialflag;
 
334
extern uint lower_case_table_names;
 
335
uint strconvert(const CHARSET_INFO *from_cs, const char *from,
 
336
                const CHARSET_INFO *to_cs, char *to, uint to_length,
 
337
                uint *errors);
 
338
uint filename_to_tablename(const char *from, char *to, uint to_length);
 
339
uint tablename_to_filename(const char *from, char *to, uint to_length);
 
340
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
 
341
 
 
342
#endif /* DRIZZLE_SERVER_COMMON_INCLUDES_H */