~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/server_includes.h

Added the testsuite location finding code to support in-plugin-dir test suites.

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