~drizzle-trunk/drizzle/development

243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
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
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
25
 * #ifdef DRIZZLE_SERVER blocks which made it very difficult to determine
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
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>                   
373.1.8 by Monty Taylor
Removed DYNAMIC_STRING.
38
/* Lots of system-wide struct definitions like IO_CACHE, prototypes for all my_* functions */
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
39
#include <mysys/my_sys.h>                       
40
/* Convenience functions for working with times */
383.1.17 by Brian Aker
Cleanup of time code (moved into mysys)
41
#include <mysys/my_time.h>
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
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>
373.1.5 by Monty Taylor
Removed templated Dynamic_array class - we don't need it.
58
/* Array of pointers to Elem that uses memory from MEM_ROOT */
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
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
#ifdef HAVE_DTRACE
84
#define _DTRACE_VERSION 1
85
#endif
86
#include "probes.h"
87
88
/**
89
  Query type constants.
90
91
  QT_ORDINARY -- ordinary SQL query.
92
  QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
93
  character set introducers).
94
95
  @TODO
96
97
  Move this out of here once Stew's done with UDF breakout.  The following headers need it:
98
99
    sql_lex.h --> included by sql_class.h
100
    item.h
101
    table.h
102
    item_func.h
103
    item_subselect.h
104
    item_timefunc.h
105
    item_sum.h
106
    item_cmpfunc.h
107
    item_strfunc.h
108
*/
109
enum enum_query_type
110
{
111
  QT_ORDINARY,
112
  QT_IS
113
};
114
115
/** 
116
 * @TODO convert all these three maps to Bitmap classes 
117
 *
118
 * @TODO Move these to a more appropriate header file (maps.h?).  The following files use them:
119
 *
120
 *    item_sum.h
121
 *    item_compfunc.h
122
 *    item.h
123
 *    table.h
124
 *    item_subselect.h
125
 *    sql_bitmap.h
126
 *    unireg.h (going bye bye?)
127
 *    sql_udf.h
128
 *    item_row.h
129
 *    handler.cc
130
 *    sql_insert.cc
131
 *    opt_range.h
132
 *    opt_sum.cc
133
 *    item_strfunc.h
134
 *    sql_delete.cc
135
 *    sql_select.h
136
 *
137
 *    Since most of these include table.h, I think that would appropriate...
138
 */
139
typedef uint64_t table_map;          /* Used for table bits in join */
140
#if MAX_INDEXES <= 64
141
typedef Bitmap<64>  key_map;          /* Used for finding keys */
142
#else
143
typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
144
#endif
145
typedef uint32_t nesting_map;  /* Used for flags of nesting constructs */
146
147
/*
148
  Used to identify NESTED_JOIN structures within a join (applicable only to
149
  structures that have not been simplified away and embed more the one
150
  element)
151
*/
152
typedef uint64_t nested_join_map; /* Needed by sql_select.h and table.h */
153
154
/* useful constants */#
155
extern const key_map key_map_empty;
156
extern key_map key_map_full;          /* Should be threaded as const */
157
extern const char *primary_key_name;
158
159
/**
160
 * @TODO Move the following into a drizzled.h header?
161
 *
162
 * I feel that global variables and functions referencing them directly
163
 * and that are used only in the server should be separated out into 
164
 * a drizzled.h header file -- JRP
165
 */
166
typedef uint64_t query_id_t;
167
extern query_id_t global_query_id;
168
169
/* increment query_id and return it.  */
170
inline query_id_t next_query_id() { return global_query_id++; }
171
264.1.6 by Monty Taylor
Merged from Jay.
172
extern const CHARSET_INFO *system_charset_info, *files_charset_info ;
173
extern const CHARSET_INFO *national_charset_info, *table_alias_charset;
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
174
175
/**
176
 * @TODO Move to a separate header?
177
 *
178
 * It's needed by item.h and field.h, which are both inter-dependent
179
 * and contain forward declarations of many structs/classes in the
180
 * other header file.
181
 *
182
 * What is needed is a separate header file that is included
183
 * by *both* item.h and field.h to resolve inter-dependencies
184
 *
185
 * But, probably want to hold off on this until Stew finished the UDF cleanup
186
 */
187
enum Derivation
188
{
189
  DERIVATION_IGNORABLE= 5,
190
  DERIVATION_COERCIBLE= 4,
191
  DERIVATION_SYSCONST= 3,
192
  DERIVATION_IMPLICIT= 2,
193
  DERIVATION_NONE= 1,
194
  DERIVATION_EXPLICIT= 0
195
};
196
197
/**
198
 * Opening modes for open_temporary_table and open_table_from_share
199
 *
200
 * @TODO Put this into an appropriate header. It is only needed in:
201
 *
202
 *    table.cc
203
 *    sql_base.cc
204
 */
205
enum open_table_mode
206
{
207
  OTM_OPEN= 0,
208
  OTM_CREATE= 1,
209
  OTM_ALTER= 2
210
};
211
212
enum enum_parsing_place
213
{
214
  NO_MATTER
215
  , IN_HAVING
216
  , SELECT_LIST
217
  , IN_WHERE
218
  , IN_ON
219
};
220
221
enum enum_mysql_completiontype {
222
  ROLLBACK_RELEASE= -2
223
  , ROLLBACK= 1
224
  , ROLLBACK_AND_CHAIN= 7
225
  , COMMIT_RELEASE= -1
226
  , COMMIT= 0
227
  , COMMIT_AND_CHAIN= 6
228
};
229
230
enum enum_check_fields
231
{
232
  CHECK_FIELD_IGNORE
233
  , CHECK_FIELD_WARN
234
  , CHECK_FIELD_ERROR_FOR_NULL
235
};
236
237
enum enum_var_type
238
{
239
  OPT_DEFAULT= 0
240
  , OPT_SESSION
241
  , OPT_GLOBAL
242
};
243
244
/* Forward declarations */
245
327.2.4 by Brian Aker
Refactoring table.h
246
class TableList;
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
247
class String;
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
248
class Table;
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
249
class THD;
250
class user_var_entry;
251
class Security_context;
252
253
extern pthread_key(THD*, THR_THD);
254
inline THD *_current_thd(void)
255
{
256
  return (THD *)pthread_getspecific(THR_THD);
257
}
258
#define current_thd _current_thd()
259
322.2.5 by Mats Kindahl
Replaced use of thd_proc_info() macro with calls to
260
extern "C" void set_thd_proc_info(THD *thd, const char *info);
261
extern "C" const char *get_thd_proc_info(THD *thd);
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
262
263
/*
264
  External variables
265
*/
266
extern ulong server_id;
267
268
/* Custom C++-style String class API */
269
#include <drizzled/sql_string.h>
270
/* Custom singly-linked list lite struct and full-blown type-safe, templatized class */
271
#include <drizzled/sql_list.h>
272
#include "my_decimal.h"
273
#include "handler.h"
347 by Monty Taylor
Fixed a few build oopses for out-of-tree builds.
274
#include <drizzled/table_list.h>
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
275
#include "sql_error.h"
276
/* Drizzle server data type class definitions */
277
#include <drizzled/field.h>
278
#include "protocol.h"
279
#include "sql_udf.h"
280
#include "item.h"
281
282
extern my_decimal decimal_zero;
283
284
/** @TODO Find a good header to put this guy... */
285
void close_thread_tables(THD *thd);
286
287
#include <drizzled/sql_parse.h>
288
289
#include "sql_class.h"
290
#include "slave.h" // for tables_ok(), rpl_filter
291
#include "tztime.h"
292
293
void sql_perror(const char *message);
294
295
bool fn_format_relative_to_data_home(char * to, const char *name,
296
				     const char *dir, const char *extension);
297
298
/**
299
 * @TODO
300
 *
301
 * This is much better than the previous situation of a crap-ton
302
 * of conditional defines all over mysql_priv.h, but this still
303
 * is hackish.  Put these things into a separate header?  Or fix
304
 * InnoDB?  Or does the InnoDB plugin already fix this stuff?
305
 */
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
306
#if defined DRIZZLE_SERVER || defined INNODB_COMPATIBILITY_HOOKS
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
307
bool check_global_access(THD *thd, ulong want_access);
308
int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
309
extern struct system_variables global_system_variables;
310
extern uint mysql_data_home_len;
311
extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
312
            mysql_real_data_home[], mysql_unpacked_real_data_home[];
264.1.6 by Monty Taylor
Merged from Jay.
313
extern const CHARSET_INFO *character_set_filesystem;
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
314
extern char reg_ext[FN_EXTLEN];
315
extern uint reg_ext_length;
316
extern ulong specialflag;
317
extern uint lower_case_table_names;
264.1.6 by Monty Taylor
Merged from Jay.
318
uint strconvert(const CHARSET_INFO *from_cs, const char *from,
319
                const CHARSET_INFO *to_cs, char *to, uint to_length,
320
                uint *errors);
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
321
uint filename_to_tablename(const char *from, char *to, uint to_length);
322
uint tablename_to_filename(const char *from, char *to, uint to_length);
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
323
#endif /* DRIZZLE_SERVER || INNODB_COMPATIBILITY_HOOKS */
243.1.15 by Jay Pipes
Added new non-server, non-client common includes header, new show.h and connect.h headers
324
325
#endif /* DRIZZLE_SERVER_COMMON_INCLUDES_H */