~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/server_includes.h

Reverted 1103

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 */
 
19
 
 
20
/**
 
21
 * @file
 
22
 *
 
23
 * Various server-wide declarations and variables.
 
24
 */
 
25
 
 
26
#ifndef DRIZZLED_SERVER_INCLUDES_H
 
27
#define DRIZZLED_SERVER_INCLUDES_H
 
28
 
 
29
/* Cross-platform portability code and standard includes */
 
30
#include <drizzled/global.h>
 
31
/* Contains system-wide constants and #defines */
 
32
#include <drizzled/definitions.h>
 
33
 
 
34
/* Lots of system-wide struct definitions like IO_CACHE,
 
35
   prototypes for all my_* functions */
 
36
#include <mysys/my_sys.h>
 
37
/* Custom C string functions */
 
38
#include <mystrings/m_string.h>
 
39
 
 
40
/* The <strong>INTERNAL</strong> plugin API - not the external, or public, server plugin API */
 
41
#include <drizzled/sql_plugin.h>
 
42
/* Range optimization API/library */
 
43
#include <drizzled/opt_range.h>
 
44
/* Simple error injection (crash) module */
 
45
#include <drizzled/error_injection.h>
 
46
/* Routines for dropping, repairing, checking schema tables */
 
47
#include <drizzled/sql_table.h>
 
48
 
 
49
/* Routines for printing error messages */
 
50
#include <drizzled/errmsg_print.h>
 
51
 
 
52
#include <string>
 
53
#include <sstream>
 
54
#include <bitset>
 
55
 
 
56
typedef struct st_ha_create_information HA_CREATE_INFO;
 
57
 
 
58
/* information schema */
 
59
static const std::string INFORMATION_SCHEMA_NAME("information_schema");
 
60
 
 
61
/* mysqld.cc */
 
62
class ListenHandler;
 
63
void refresh_status(Session *session);
 
64
bool drizzle_rm_tmp_tables(ListenHandler &listen_handler);
 
65
void unlink_session(Session *session);
 
66
 
 
67
/* item_func.cc */
 
68
extern bool check_reserved_words(LEX_STRING *name);
 
69
extern enum_field_types agg_field_type(Item **items, uint32_t nitems);
 
70
 
 
71
/* strfunc.cc */
 
72
uint64_t find_set(TYPELIB *lib, const char *x, uint32_t length, const CHARSET_INFO * const cs,
 
73
                   char **err_pos, uint32_t *err_len, bool *set_warning);
 
74
uint32_t find_type(const TYPELIB *lib, const char *find, uint32_t length,
 
75
               bool part_match);
 
76
uint32_t find_type2(const TYPELIB *lib, const char *find, uint32_t length,
 
77
                const CHARSET_INFO *cs);
 
78
void unhex_type2(TYPELIB *lib);
 
79
uint32_t check_word(TYPELIB *lib, const char *val, const char *end,
 
80
                const char **end_of_word);
 
81
int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
 
82
                         const CHARSET_INFO * const cs);
 
83
 
 
84
/*
 
85
  External variables
 
86
*/
 
87
 
 
88
extern const CHARSET_INFO *system_charset_info;
 
89
extern const CHARSET_INFO *files_charset_info;
 
90
extern const CHARSET_INFO *table_alias_charset;
 
91
 
 
92
extern char *drizzle_tmpdir;
 
93
extern const LEX_STRING command_name[];
 
94
extern const char *first_keyword;
 
95
extern const char *binary_keyword;
 
96
extern const char *in_left_expr_name;
 
97
extern const char *in_additional_cond;
 
98
extern const char *in_having_cond;
 
99
extern char language[FN_REFLEN];
 
100
extern char glob_hostname[FN_REFLEN];
 
101
extern char drizzle_home[FN_REFLEN];
 
102
extern char pidfile_name[FN_REFLEN];
 
103
extern char system_time_zone[30];
 
104
extern char *opt_tc_log_file;
 
105
extern const double log_10[309];
 
106
extern uint64_t log_10_int[20];
 
107
extern uint64_t session_startup_options;
 
108
extern uint32_t thread_id;
 
109
extern uint64_t aborted_threads;
 
110
extern uint64_t aborted_connects;
 
111
extern uint64_t table_cache_size;
 
112
extern uint64_t table_def_size;
 
113
extern uint64_t max_connect_errors;
 
114
extern uint32_t connect_timeout;
 
115
extern uint32_t back_log;
 
116
extern pid_t current_pid;
 
117
extern std::bitset<12> test_flags;
 
118
extern uint32_t ha_open_options;
 
119
extern uint32_t drizzled_tcp_port;
 
120
extern uint32_t dropping_tables;
 
121
extern uint32_t delay_key_write_options;
 
122
extern bool opt_endinfo;
 
123
extern bool locked_in_memory;
 
124
extern bool volatile abort_loop;
 
125
extern bool volatile shutdown_in_progress;
 
126
extern uint32_t volatile thread_running;
 
127
extern uint32_t volatile global_read_lock;
 
128
extern bool opt_readonly;
 
129
extern char* opt_secure_file_priv;
 
130
extern char *default_tz_name;
 
131
 
 
132
extern FILE *stderror_file;
 
133
extern pthread_mutex_t LOCK_create_db;
 
134
extern pthread_mutex_t LOCK_open;
 
135
extern pthread_mutex_t LOCK_thread_count;
 
136
extern pthread_mutex_t LOCK_status;
 
137
extern pthread_mutex_t LOCK_global_read_lock;
 
138
extern pthread_mutex_t LOCK_global_system_variables;
 
139
 
 
140
extern pthread_rwlock_t LOCK_system_variables_hash;
 
141
extern pthread_cond_t COND_refresh;
 
142
extern pthread_cond_t COND_thread_count;
 
143
extern pthread_cond_t COND_global_read_lock;
 
144
extern pthread_attr_t connection_attrib;
 
145
extern std::vector<Session *> session_list;
 
146
extern String my_empty_string;
 
147
extern const String my_null_string;
 
148
extern SHOW_VAR status_vars[];
 
149
extern struct system_variables max_system_variables;
 
150
extern struct system_status_var global_status_var;
 
151
 
 
152
extern Table *unused_tables;
 
153
extern const char* any_db;
 
154
extern struct my_option my_long_options[];
 
155
extern std::bitset<5> sql_command_flags[];
 
156
 
 
157
extern StorageEngine *myisam_engine;
 
158
extern StorageEngine *heap_engine;
 
159
 
 
160
extern SHOW_COMP_OPTION have_symlink;
 
161
 
 
162
extern pthread_t signal_thread;
 
163
 
 
164
/* table.cc */
 
165
TableShare *alloc_table_share(TableList *table_list, char *key,
 
166
                               uint32_t key_length);
 
167
int open_table_def(Session *session, TableShare *share);
 
168
void open_table_error(TableShare *share, int error, int db_errno, int errarg);
 
169
int open_table_from_share(Session *session, TableShare *share, const char *alias,
 
170
                          uint32_t db_stat, uint32_t prgflag, uint32_t ha_open_flags,
 
171
                          Table *outparam, open_table_mode open_mode);
 
172
void free_blobs(Table *table);
 
173
int set_zone(int nr,int min_zone,int max_zone);
 
174
uint32_t convert_period_to_month(uint32_t period);
 
175
uint32_t convert_month_to_period(uint32_t month);
 
176
void get_date_from_daynr(long daynr,uint32_t *year, uint32_t *month,
 
177
                         uint32_t *day);
 
178
bool str_to_time_with_warn(const char *str,uint32_t length,DRIZZLE_TIME *l_time);
 
179
enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str, uint32_t length,
 
180
                                         DRIZZLE_TIME *l_time, uint32_t flags);
 
181
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
 
182
void calc_time_from_sec(DRIZZLE_TIME *to, long seconds, long microseconds);
 
183
 
 
184
void make_truncated_value_warning(Session *session, DRIZZLE_ERROR::enum_warning_level level,
 
185
                                  const char *str_val,
 
186
                                  uint32_t str_length, enum enum_drizzle_timestamp_type time_type,
 
187
                                  const char *field_name);
 
188
 
 
189
bool calc_time_diff(DRIZZLE_TIME *l_time1, DRIZZLE_TIME *l_time2, int l_sign,
 
190
                    int64_t *seconds_out, long *microseconds_out);
 
191
 
 
192
extern LEX_STRING interval_type_to_name[];
 
193
 
 
194
void make_datetime(const DRIZZLE_TIME *l_time, String *str);
 
195
void make_date(const DRIZZLE_TIME *l_time, String *str);
 
196
void make_time(const DRIZZLE_TIME *l_time, String *str);
 
197
int my_time_compare(DRIZZLE_TIME *a, DRIZZLE_TIME *b);
 
198
uint64_t get_datetime_value(Session *session, Item ***item_arg, Item **cache_arg,
 
199
                             Item *warn_item, bool *is_null);
 
200
 
 
201
int test_if_number(char *str,int *res,bool allow_wildcards);
 
202
void change_byte(unsigned char *,uint,char,char);
 
203
void init_read_record(READ_RECORD *info, Session *session, Table *reg_form,
 
204
                      SQL_SELECT *select,
 
205
                      int use_record_cache, bool print_errors);
 
206
void init_read_record_idx(READ_RECORD *info, Session *session, Table *table,
 
207
                          bool print_error, uint32_t idx);
 
208
void end_read_record(READ_RECORD *info);
 
209
ha_rows filesort(Session *session, Table *form,struct st_sort_field *sortorder,
 
210
                 uint32_t s_length, SQL_SELECT *select,
 
211
                 ha_rows max_rows, bool sort_positions,
 
212
                 ha_rows *examined_rows);
 
213
void filesort_free_buffers(Table *table, bool full);
 
214
void change_double_for_sort(double nr,unsigned char *to);
 
215
double my_double_round(double value, int64_t dec, bool dec_unsigned,
 
216
                       bool truncate);
 
217
int get_quick_record(SQL_SELECT *select);
 
218
 
 
219
int calc_weekday(long daynr,bool sunday_first_day_of_week);
 
220
uint32_t calc_week(DRIZZLE_TIME *l_time, uint32_t week_behaviour, uint32_t *year);
 
221
void find_date(char *pos,uint32_t *vek,uint32_t flag);
 
222
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
 
223
TYPELIB *typelib(MEM_ROOT *mem_root, std::vector<String*> &strings);
 
224
ulong get_form_pos(File file, unsigned char *head, TYPELIB *save_names);
 
225
ulong next_io_size(ulong pos);
 
226
void append_unescaped(String *res, const char *pos, uint32_t length);
 
227
int rename_table_proto_file(const char *from, const char* to);
 
228
int delete_table_proto_file(const char *file_name);
 
229
int rename_file_ext(const char * from,const char * to,const char * ext);
 
230
bool check_db_name(LEX_STRING *db);
 
231
bool check_column_name(const char *name);
 
232
bool check_table_name(const char *name, uint32_t length);
 
233
char *fn_rext(char *name);
 
234
 
 
235
/* Conversion functions */
 
236
size_t build_table_filename(char *buff, size_t bufflen, const char *db, 
 
237
                            const char *table_name, bool is_tmp);
 
238
 
 
239
/* Flags for conversion functions. */
 
240
#define FN_FROM_IS_TMP  (1 << 0)
 
241
#define FN_TO_IS_TMP    (1 << 1)
 
242
#define FN_IS_TMP       (FN_FROM_IS_TMP | FN_TO_IS_TMP)
 
243
#define NO_FRM_RENAME   (1 << 2)
 
244
 
 
245
inline uint32_t sql_rnd()
 
246
{
 
247
  return (uint32_t) (rand() * 0xffffffff); /* make all bits random */
 
248
}
 
249
 
 
250
/**
 
251
  convert a hex digit into number.
 
252
*/
 
253
inline int hexchar_to_int(char c)
 
254
{
 
255
  if (c <= '9' && c >= '0')
 
256
    return c-'0';
 
257
  c|=32;
 
258
  if (c <= 'f' && c >= 'a')
 
259
    return c-'a'+10;
 
260
  return -1;
 
261
}
 
262
 
 
263
#endif /* DRIZZLED_SERVER_INCLUDES_H */