~drizzle-trunk/drizzle/development

1097.2.1 by clint at fewbar
refactoring INTERVAL into C++ class
1
/*
390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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
 */
1 by brian
clean slate
19
20
/**
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
21
 * @file
22
 *
23
 * Various server-wide declarations and variables.
24
 */
1 by brian
clean slate
25
575.4.7 by Monty Taylor
More header cleanup.
26
#ifndef DRIZZLED_SERVER_INCLUDES_H
27
#define DRIZZLED_SERVER_INCLUDES_H
1 by brian
clean slate
28
670.2.2 by Monty Taylor
Got rid of the rest of common_includes. Now on to server_includes.
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
243.1.16 by Jay Pipes
minor cleanup and final removal of all client and server prepared statement declarations and definitions
40
/* Range optimization API/library */
41
#include <drizzled/opt_range.h>
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
42
/* Routines for dropping, repairing, checking schema tables */
43
#include <drizzled/sql_table.h>
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
44
722.4.1 by Mark Atwood
integrate errmsg plugin into sql_print_* functions
45
/* Routines for printing error messages */
46
#include <drizzled/errmsg_print.h>
47
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
48
#include <string>
670.3.1 by Toru Maesaka
Replaced MySQL's my_stpncpy() with libc and c++ calls
49
#include <sstream>
602.2.1 by Yoshinori Sano
The global variable sql_command_flags uses std::bitset.
50
#include <bitset>
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
51
52
typedef struct st_ha_create_information HA_CREATE_INFO;
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
53
1 by brian
clean slate
54
/* information schema */
575.4.7 by Monty Taylor
More header cleanup.
55
static const std::string INFORMATION_SCHEMA_NAME("information_schema");
1 by brian
clean slate
56
971.3.65 by Eric Day
Namespace cleanup for Protocol and Listen.
57
/* drizzled.cc */
520.1.22 by Brian Aker
Second pass of thd cleanup
58
void refresh_status(Session *session);
938 by Brian Aker
Merge of Monty/Eric/Padraig
59
void unlink_session(Session *session);
1 by brian
clean slate
60
61
/* item_func.cc */
62
extern bool check_reserved_words(LEX_STRING *name);
482 by Brian Aker
Remove uint.
63
extern enum_field_types agg_field_type(Item **items, uint32_t nitems);
1 by brian
clean slate
64
65
/* strfunc.cc */
482 by Brian Aker
Remove uint.
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,
1 by brian
clean slate
69
               bool part_match);
482 by Brian Aker
Remove uint.
70
uint32_t find_type2(const TYPELIB *lib, const char *find, uint32_t length,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
71
                const CHARSET_INFO *cs);
1 by brian
clean slate
72
void unhex_type2(TYPELIB *lib);
482 by Brian Aker
Remove uint.
73
uint32_t check_word(TYPELIB *lib, const char *val, const char *end,
1 by brian
clean slate
74
		const char **end_of_word);
75
int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
76
                         const CHARSET_INFO * const cs);
1 by brian
clean slate
77
78
/*
79
  External variables
80
*/
81
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
82
extern const CHARSET_INFO *system_charset_info;
1095.1.1 by Monty Taylor
Merged Jay from lp:~jaypipes/drizzle/for-brian
83
extern const CHARSET_INFO *files_charset_info;
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
84
extern const CHARSET_INFO *table_alias_charset;
85
680 by Brian Aker
Remove locks around temp tables for searching tmp directory path.
86
extern char *drizzle_tmpdir;
1 by brian
clean slate
87
extern const LEX_STRING command_name[];
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
88
extern const char *first_keyword;
89
extern const char *binary_keyword;
90
extern const char *in_left_expr_name;
91
extern const char *in_additional_cond;
92
extern const char *in_having_cond;
1 by brian
clean slate
93
extern char language[FN_REFLEN];
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
94
extern char glob_hostname[FN_REFLEN];
95
extern char drizzle_home[FN_REFLEN];
96
extern char pidfile_name[FN_REFLEN];
97
extern char system_time_zone[30];
722.4.1 by Mark Atwood
integrate errmsg plugin into sql_print_* functions
98
extern char *opt_tc_log_file;
1 by brian
clean slate
99
extern const double log_10[309];
151 by Brian Aker
Ulonglong to uint64_t
100
extern uint64_t log_10_int[20];
520.1.22 by Brian Aker
Second pass of thd cleanup
101
extern uint64_t session_startup_options;
971.3.66 by Eric Day
Fixed thread_id bug from session refactoring work.
102
extern uint32_t global_thread_id;
625 by Brian Aker
ulong/64 bit straighten out.
103
extern uint64_t aborted_threads;
104
extern uint64_t aborted_connects;
622.1.1 by Brian Aker
32bit fixes around vars
105
extern uint64_t table_cache_size;
106
extern uint64_t table_def_size;
107
extern uint64_t max_connect_errors;
626 by Brian Aker
More of the same (ulong/64)
108
extern uint32_t back_log;
606 by Brian Aker
Remove dead lex structure and clean up use of pid_t
109
extern pid_t current_pid;
1089.6.2 by Padraig O'Sullivan
Modified the size of the test_flags bitset to be 12 bits instead of 32. No
110
extern std::bitset<12> test_flags;
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
111
extern uint32_t ha_open_options;
112
extern uint32_t drizzled_tcp_port;
971.6.7 by Eric Day
Reworked listen interface to not require binding of TCP ports.
113
extern char *drizzled_bind_host;
114
extern uint32_t drizzled_bind_timeout;
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
115
extern uint32_t dropping_tables;
116
extern bool opt_endinfo;
150 by Brian Aker
More bool removal. More cow bell!
117
extern bool locked_in_memory;
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
118
extern bool volatile abort_loop;
119
extern bool volatile shutdown_in_progress;
120
extern uint32_t volatile thread_running;
121
extern uint32_t volatile global_read_lock;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
122
extern bool opt_readonly;
1 by brian
clean slate
123
extern char* opt_secure_file_priv;
124
extern char *default_tz_name;
125
126
extern FILE *stderror_file;
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
127
extern pthread_mutex_t LOCK_create_db;
128
extern pthread_mutex_t LOCK_open;
129
extern pthread_mutex_t LOCK_thread_count;
130
extern pthread_mutex_t LOCK_status;
131
extern pthread_mutex_t LOCK_global_read_lock;
132
extern pthread_mutex_t LOCK_global_system_variables;
908.3.1 by Stewart Smith
remove some unused extern variables in server_includes.h
133
658 by Brian Aker
Part removal of my_pthread.h
134
extern pthread_rwlock_t LOCK_system_variables_hash;
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
135
extern pthread_cond_t COND_refresh;
136
extern pthread_cond_t COND_thread_count;
1 by brian
clean slate
137
extern pthread_cond_t COND_global_read_lock;
138
extern pthread_attr_t connection_attrib;
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
139
extern std::vector<Session *> session_list;
1 by brian
clean slate
140
extern String my_empty_string;
141
extern const String my_null_string;
142
extern SHOW_VAR status_vars[];
143
extern struct system_variables max_system_variables;
144
extern struct system_status_var global_status_var;
145
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
146
extern Table *unused_tables;
1 by brian
clean slate
147
extern const char* any_db;
148
extern struct my_option my_long_options[];
590.2.18 by Monty Taylor
Changed the bitset<32> to a bitset<5>. Made the int constants into bitset constants.
149
extern std::bitset<5> sql_command_flags[];
1 by brian
clean slate
150
1130.1.4 by Monty Taylor
Moved StorageEngine into plugin namespace.
151
extern drizzled::plugin::StorageEngine *myisam_engine;
152
extern drizzled::plugin::StorageEngine *heap_engine;
1 by brian
clean slate
153
177.3.1 by mark
remove ifdef HAVE_DLOPEN, make configure require dlopen()
154
extern SHOW_COMP_OPTION have_symlink;
1 by brian
clean slate
155
156
extern pthread_t signal_thread;
157
158
/* table.cc */
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
159
TableShare *alloc_table_share(TableList *table_list, char *key,
482 by Brian Aker
Remove uint.
160
                               uint32_t key_length);
1000.1.5 by Brian Aker
More refactoring back to TableShare object.
161
int open_table_def(Session *session, TableShare *share);
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
162
void open_table_error(TableShare *share, int error, int db_errno, int errarg);
163
int open_table_from_share(Session *session, TableShare *share, const char *alias,
482 by Brian Aker
Remove uint.
164
                          uint32_t db_stat, uint32_t prgflag, uint32_t ha_open_flags,
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
165
                          Table *outparam, open_table_mode open_mode);
166
void free_blobs(Table *table);
1 by brian
clean slate
167
int set_zone(int nr,int min_zone,int max_zone);
520.1.6 by Brian Aker
Fixed ulong in time calculation.
168
uint32_t convert_period_to_month(uint32_t period);
169
uint32_t convert_month_to_period(uint32_t month);
482 by Brian Aker
Remove uint.
170
void get_date_from_daynr(long daynr,uint32_t *year, uint32_t *month,
171
			 uint32_t *day);
172
bool str_to_time_with_warn(const char *str,uint32_t length,DRIZZLE_TIME *l_time);
173
enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str, uint32_t length,
174
                                         DRIZZLE_TIME *l_time, uint32_t flags);
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
175
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
176
void calc_time_from_sec(DRIZZLE_TIME *to, long seconds, long microseconds);
1 by brian
clean slate
177
520.1.22 by Brian Aker
Second pass of thd cleanup
178
void make_truncated_value_warning(Session *session, DRIZZLE_ERROR::enum_warning_level level,
1 by brian
clean slate
179
                                  const char *str_val,
482 by Brian Aker
Remove uint.
180
				  uint32_t str_length, enum enum_drizzle_timestamp_type time_type,
1 by brian
clean slate
181
                                  const char *field_name);
182
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
183
bool calc_time_diff(DRIZZLE_TIME *l_time1, DRIZZLE_TIME *l_time2, int l_sign,
152 by Brian Aker
longlong replacement
184
                    int64_t *seconds_out, long *microseconds_out);
1 by brian
clean slate
185
186
extern LEX_STRING interval_type_to_name[];
187
907.1.2 by Jay Pipes
Merging in old r902 temporal changes
188
void make_datetime(const DRIZZLE_TIME *l_time, String *str);
189
void make_date(const DRIZZLE_TIME *l_time, String *str);
190
void make_time(const DRIZZLE_TIME *l_time, String *str);
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
191
int my_time_compare(DRIZZLE_TIME *a, DRIZZLE_TIME *b);
520.1.22 by Brian Aker
Second pass of thd cleanup
192
uint64_t get_datetime_value(Session *session, Item ***item_arg, Item **cache_arg,
1 by brian
clean slate
193
                             Item *warn_item, bool *is_null);
194
195
int test_if_number(char *str,int *res,bool allow_wildcards);
481 by Brian Aker
Remove all of uchar.
196
void change_byte(unsigned char *,uint,char,char);
520.1.22 by Brian Aker
Second pass of thd cleanup
197
void init_read_record(READ_RECORD *info, Session *session, Table *reg_form,
1 by brian
clean slate
198
		      SQL_SELECT *select,
199
		      int use_record_cache, bool print_errors);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
200
void init_read_record_idx(READ_RECORD *info, Session *session, Table *table,
482 by Brian Aker
Remove uint.
201
                          bool print_error, uint32_t idx);
1 by brian
clean slate
202
void end_read_record(READ_RECORD *info);
520.1.22 by Brian Aker
Second pass of thd cleanup
203
ha_rows filesort(Session *session, Table *form,struct st_sort_field *sortorder,
482 by Brian Aker
Remove uint.
204
		 uint32_t s_length, SQL_SELECT *select,
1 by brian
clean slate
205
		 ha_rows max_rows, bool sort_positions,
206
                 ha_rows *examined_rows);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
207
void filesort_free_buffers(Table *table, bool full);
481 by Brian Aker
Remove all of uchar.
208
void change_double_for_sort(double nr,unsigned char *to);
152 by Brian Aker
longlong replacement
209
double my_double_round(double value, int64_t dec, bool dec_unsigned,
1 by brian
clean slate
210
                       bool truncate);
211
int get_quick_record(SQL_SELECT *select);
212
213
int calc_weekday(long daynr,bool sunday_first_day_of_week);
482 by Brian Aker
Remove uint.
214
uint32_t calc_week(DRIZZLE_TIME *l_time, uint32_t week_behaviour, uint32_t *year);
215
void find_date(char *pos,uint32_t *vek,uint32_t flag);
1 by brian
clean slate
216
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
1101.3.1 by Nathan Williams
Reverted CreateField::interval_list to a List<String>. Fixes memory leaks I introduced by converting it to a vector in branch listed below.
217
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings);
481 by Brian Aker
Remove all of uchar.
218
ulong get_form_pos(File file, unsigned char *head, TYPELIB *save_names);
1 by brian
clean slate
219
ulong next_io_size(ulong pos);
482 by Brian Aker
Remove uint.
220
void append_unescaped(String *res, const char *pos, uint32_t length);
584.2.7 by Stewart Smith
rename and delete tabledefinition protobuf file
221
int rename_table_proto_file(const char *from, const char* to);
813.5.3 by Stewart Smith
fix bug on failing to create table in rea_create_table.
222
int delete_table_proto_file(const char *file_name);
1 by brian
clean slate
223
int rename_file_ext(const char * from,const char * to,const char * ext);
224
bool check_db_name(LEX_STRING *db);
225
bool check_column_name(const char *name);
482 by Brian Aker
Remove uint.
226
bool check_table_name(const char *name, uint32_t length);
1 by brian
clean slate
227
char *fn_rext(char *name);
228
229
/* Conversion functions */
1039.1.6 by Brian Aker
Refactor for build_table_filename()
230
size_t build_table_filename(char *buff, size_t bufflen, const char *db, 
231
                            const char *table_name, bool is_tmp);
1 by brian
clean slate
232
233
/* Flags for conversion functions. */
234
#define FN_FROM_IS_TMP  (1 << 0)
235
#define FN_TO_IS_TMP    (1 << 1)
236
#define FN_IS_TMP       (FN_FROM_IS_TMP | FN_TO_IS_TMP)
237
#define NO_FRM_RENAME   (1 << 2)
238
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
239
inline uint32_t sql_rnd()
1 by brian
clean slate
240
{
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
241
  return (uint32_t) (rand() * 0xffffffff); /* make all bits random */
1 by brian
clean slate
242
}
243
244
/**
245
  convert a hex digit into number.
246
*/
247
inline int hexchar_to_int(char c)
248
{
249
  if (c <= '9' && c >= '0')
250
    return c-'0';
251
  c|=32;
252
  if (c <= 'f' && c >= 'a')
253
    return c-'a'+10;
254
  return -1;
255
}
256
1089.9.1 by Jay Pipes
Removes a bunch of dead code and unused variables in drizzled.cc and server_includes.h
257
#endif /* DRIZZLED_SERVER_INCLUDES_H */