~drizzle-pbxt/drizzle/drizzle-pbxt-2

« back to all changes in this revision

Viewing changes to drizzled/server_includes.h

  • Committer: Paul McCullagh
  • Date: 2009-11-10 14:18:39 UTC
  • mfrom: (1038.1.7 drizzle-pbxt-pre-merge)
  • Revision ID: paul.mccullagh@primebase.org-20091110141839-2j3k43b17ag6f605
Merged Drizzle trunk and PBXT 1.0.09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
1
/*
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
4
 *  Copyright (C) 2008 Sun Microsystems
18
18
 */
19
19
 
20
20
/**
21
 
  @file
22
 
 
23
 
  @details
24
 
  Mostly this file is used in the server. But a little part of it is used in
25
 
  definition of SELECT_DISTINCT and others.
26
 
 
27
 
  @TODO Name this file better. "priv" could mean private, privileged, privileges.
28
 
*/
 
21
 * @file
 
22
 *
 
23
 * Various server-wide declarations and variables.
 
24
 */
29
25
 
30
26
#ifndef DRIZZLED_SERVER_INCLUDES_H
31
27
#define DRIZZLED_SERVER_INCLUDES_H
41
37
/* Custom C string functions */
42
38
#include <mystrings/m_string.h>
43
39
 
44
 
/* The <strong>INTERNAL</strong> plugin API - not the external, or public, server plugin API */
45
 
#include <drizzled/sql_plugin.h>
46
40
/* Range optimization API/library */
47
41
#include <drizzled/opt_range.h>
48
 
/* Simple error injection (crash) module */
49
 
#include <drizzled/error_injection.h>
50
42
/* Routines for dropping, repairing, checking schema tables */
51
43
#include <drizzled/sql_table.h>
52
44
 
57
49
#include <sstream>
58
50
#include <bitset>
59
51
 
60
 
 
61
 
extern const CHARSET_INFO *system_charset_info, *files_charset_info ;
62
 
extern const CHARSET_INFO *national_charset_info, *table_alias_charset;
63
 
 
64
 
typedef struct drizzled_lock_st DRIZZLE_LOCK;
65
52
typedef struct st_ha_create_information HA_CREATE_INFO;
66
53
 
67
54
/* information schema */
68
55
static const std::string INFORMATION_SCHEMA_NAME("information_schema");
69
56
 
70
 
 
71
 
 
72
 
/* mysqld.cc */
 
57
/* drizzled.cc */
73
58
void refresh_status(Session *session);
74
 
bool drizzle_rm_tmp_tables(void);
75
59
void unlink_session(Session *session);
76
60
 
77
61
/* item_func.cc */
85
69
               bool part_match);
86
70
uint32_t find_type2(const TYPELIB *lib, const char *find, uint32_t length,
87
71
                const CHARSET_INFO *cs);
88
 
void unhex_type2(TYPELIB *lib);
89
 
uint32_t check_word(TYPELIB *lib, const char *val, const char *end,
90
 
                const char **end_of_word);
91
 
int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
92
 
                         const CHARSET_INFO * const cs);
93
 
 
94
72
 
95
73
/*
96
74
  External variables
97
75
*/
98
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
 
99
81
extern char *drizzle_tmpdir;
100
82
extern const LEX_STRING command_name[];
101
 
extern const char *first_keyword, *my_localhost, *delayed_user, *binary_keyword;
102
 
extern const char *myisam_recover_options_str;
103
 
extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
104
 
extern const char * const TRG_EXT;
105
 
extern const char * const TRN_EXT;
 
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;
106
88
extern char language[FN_REFLEN];
107
 
extern char glob_hostname[FN_REFLEN], drizzle_home[FN_REFLEN];
108
 
extern char pidfile_name[FN_REFLEN], system_time_zone[30];
 
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];
109
93
extern char *opt_tc_log_file;
110
94
extern const double log_10[309];
111
95
extern uint64_t log_10_int[20];
112
 
extern uint64_t keybuff_size;
113
96
extern uint64_t session_startup_options;
114
 
extern uint32_t thread_id;
 
97
extern uint32_t global_thread_id;
115
98
extern uint64_t aborted_threads;
116
99
extern uint64_t aborted_connects;
117
 
extern uint64_t slow_launch_threads;
118
100
extern uint64_t table_cache_size;
119
101
extern uint64_t table_def_size;
120
102
extern uint64_t max_connect_errors;
121
 
extern uint32_t connect_timeout;
122
103
extern uint32_t back_log;
123
104
extern pid_t current_pid;
124
 
extern uint64_t expire_logs_days;
125
 
extern uint64_t tc_log_max_pages_used;
126
 
extern uint64_t tc_log_page_size;
127
 
extern uint64_t opt_tc_log_size;
128
 
extern uint64_t tc_log_page_waits;
129
 
extern bool opt_innodb;
130
 
extern uint32_t test_flags,select_errors,ha_open_options;
131
 
extern uint32_t protocol_version, drizzled_port, dropping_tables;
132
 
extern uint32_t delay_key_write_options;
133
 
extern bool opt_endinfo, using_udf_functions;
 
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;
134
112
extern bool locked_in_memory;
135
 
extern bool using_update_log, server_id_supplied;
136
 
extern bool opt_log;
137
 
extern ulong log_output_options;
138
 
extern bool opt_character_set_client_handshake;
139
 
extern bool volatile abort_loop, shutdown_in_progress;
140
 
extern uint32_t volatile thread_running, global_read_lock;
141
 
extern bool opt_safe_user_create;
142
 
extern bool opt_no_mix_types;
143
 
extern bool opt_safe_show_db, opt_myisam_use_mmap;
 
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;
144
117
extern bool opt_readonly;
145
118
extern char* opt_secure_file_priv;
146
 
extern bool opt_noacl;
147
 
extern bool opt_old_style_user_limits;
148
119
extern char *default_tz_name;
149
 
extern char *opt_logname;
150
120
 
151
 
extern TableList general_log, slow_log;
152
121
extern FILE *stderror_file;
153
 
extern pthread_mutex_t LOCK_create_db,LOCK_open, LOCK_lock_db,
154
 
       LOCK_thread_count,LOCK_user_locks, LOCK_status,
155
 
       LOCK_global_read_lock,
156
 
       LOCK_global_system_variables;
 
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;
157
128
 
158
129
extern pthread_rwlock_t LOCK_system_variables_hash;
159
 
extern pthread_cond_t COND_refresh, COND_thread_count;
 
130
extern pthread_cond_t COND_refresh;
 
131
extern pthread_cond_t COND_thread_count;
160
132
extern pthread_cond_t COND_global_read_lock;
161
133
extern pthread_attr_t connection_attrib;
162
 
extern std::vector<Session*> session_list;
 
134
extern std::vector<Session *> session_list;
163
135
extern String my_empty_string;
164
136
extern const String my_null_string;
165
 
extern SHOW_VAR status_vars[];
166
137
extern struct system_variables max_system_variables;
167
138
extern struct system_status_var global_status_var;
168
 
extern struct rand_struct sql_rand;
169
139
 
170
140
extern Table *unused_tables;
171
141
extern const char* any_db;
172
142
extern struct my_option my_long_options[];
173
 
extern uint8_t uc_update_queries[SQLCOM_END+1];
174
143
extern std::bitset<5> sql_command_flags[];
175
 
extern TYPELIB log_output_typelib;
176
144
 
177
 
extern StorageEngine *myisam_engine;
178
 
extern StorageEngine *heap_engine;
 
145
extern drizzled::plugin::StorageEngine *myisam_engine;
 
146
extern drizzled::plugin::StorageEngine *heap_engine;
179
147
 
180
148
extern SHOW_COMP_OPTION have_symlink;
181
149
 
182
150
extern pthread_t signal_thread;
183
151
 
184
 
 
185
152
/* table.cc */
186
153
TableShare *alloc_table_share(TableList *table_list, char *key,
187
154
                               uint32_t key_length);
190
157
int open_table_from_share(Session *session, TableShare *share, const char *alias,
191
158
                          uint32_t db_stat, uint32_t prgflag, uint32_t ha_open_flags,
192
159
                          Table *outparam, open_table_mode open_mode);
193
 
int read_string(File file, unsigned char* *to, size_t length);
194
160
void free_blobs(Table *table);
195
161
int set_zone(int nr,int min_zone,int max_zone);
196
162
uint32_t convert_period_to_month(uint32_t period);
201
167
enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str, uint32_t length,
202
168
                                         DRIZZLE_TIME *l_time, uint32_t flags);
203
169
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
204
 
void calc_time_from_sec(DRIZZLE_TIME *to, long seconds, long microseconds);
205
170
 
206
171
void make_truncated_value_warning(Session *session, DRIZZLE_ERROR::enum_warning_level level,
207
172
                                  const char *str_val,
208
173
                                  uint32_t str_length, enum enum_drizzle_timestamp_type time_type,
209
174
                                  const char *field_name);
210
175
 
211
 
bool date_add_interval(DRIZZLE_TIME *ltime, interval_type int_type, INTERVAL interval);
212
176
bool calc_time_diff(DRIZZLE_TIME *l_time1, DRIZZLE_TIME *l_time2, int l_sign,
213
177
                    int64_t *seconds_out, long *microseconds_out);
214
178
 
215
 
extern LEX_STRING interval_type_to_name[];
216
 
 
217
179
void make_datetime(const DRIZZLE_TIME *l_time, String *str);
218
180
void make_date(const DRIZZLE_TIME *l_time, String *str);
219
 
void make_time(const DRIZZLE_TIME *l_time, String *str);
220
 
int my_time_compare(DRIZZLE_TIME *a, DRIZZLE_TIME *b);
221
181
uint64_t get_datetime_value(Session *session, Item ***item_arg, Item **cache_arg,
222
182
                             Item *warn_item, bool *is_null);
223
183
 
245
205
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
246
206
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings);
247
207
ulong get_form_pos(File file, unsigned char *head, TYPELIB *save_names);
248
 
off_t make_new_entry(File file,unsigned char *fileinfo,TYPELIB *formnames,
249
 
                     const char *newname);
250
208
ulong next_io_size(ulong pos);
251
209
void append_unescaped(String *res, const char *pos, uint32_t length);
252
 
int rename_table_proto_file(const char *from, const char* to);
253
 
int delete_table_proto_file(const char *file_name);
 
210
 
 
211
 
254
212
int rename_file_ext(const char * from,const char * to,const char * ext);
255
213
bool check_db_name(LEX_STRING *db);
256
214
bool check_column_name(const char *name);
257
215
bool check_table_name(const char *name, uint32_t length);
258
 
char *get_field(MEM_ROOT *mem, Field *field);
259
 
bool get_field(MEM_ROOT *mem, Field *field, class String *res);
260
216
char *fn_rext(char *name);
261
217
 
262
218
/* Conversion functions */
263
 
uint32_t build_table_filename(char *buff, size_t bufflen, const char *db,
264
 
                          const char *table, const char *ext, uint32_t flags);
 
219
size_t build_table_filename(char *buff, size_t bufflen, const char *db, 
 
220
                            const char *table_name, bool is_tmp);
265
221
 
266
222
/* Flags for conversion functions. */
267
223
#define FN_FROM_IS_TMP  (1 << 0)
269
225
#define FN_IS_TMP       (FN_FROM_IS_TMP | FN_TO_IS_TMP)
270
226
#define NO_FRM_RENAME   (1 << 2)
271
227
 
272
 
 
273
 
inline ulong sql_rnd()
 
228
inline uint32_t sql_rnd()
274
229
{
275
 
  ulong tmp= (ulong) (rand() * 0xffffffff); /* make all bits random */
276
 
 
277
 
  return tmp;
 
230
  return (uint32_t) (rand() * 0xffffffff); /* make all bits random */
278
231
}
279
232
 
280
 
 
281
 
 
282
233
/**
283
234
  convert a hex digit into number.
284
235
*/
285
 
 
286
236
inline int hexchar_to_int(char c)
287
237
{
288
238
  if (c <= '9' && c >= '0')
293
243
  return -1;
294
244
}
295
245
 
296
 
 
297
 
#endif /* DRIZZLE_SERVER_SERVER_INCLUDES_H */
 
246
#endif /* DRIZZLED_SERVER_INCLUDES_H */