~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/common_includes.h

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

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