~drizzle-trunk/drizzle/development

1 by brian
clean slate
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 */
15
16
/**
17
  @file
18
19
  @details
20
  Mostly this file is used in the server. But a little part of it is used in
21
  mysqlbinlog too (definition of SELECT_DISTINCT and others).
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
22
  The consequence is that 90% of the file is wrapped in \#ifndef DRIZZLE_CLIENT,
1 by brian
clean slate
23
  except the part which must be in the server and in the client.
243.1.11 by Jay Pipes
* Added include guards in a couple places, and removed unecessary
24
25
  @TODO Name this file better. "priv" could mean private, privileged, privileges.
26
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
27
  @TODO Get rid of the DRIZZLE_CLIENT and DRIZZLE_SERVER conditionals
1 by brian
clean slate
28
*/
29
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
30
#ifndef DRIZZLE_SERVER_SERVER_INCLUDES_H
31
#define DRIZZLE_SERVER_SERVER_INCLUDES_H
1 by brian
clean slate
32
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
33
/* Some forward declarations just for the server */
34
243.1.4 by Jay Pipes
removed view_store_options() function - wasn't used anywhere.
35
class Comp_creator;
36
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
37
38
/**
39
 * Contains all headers, definitions, and declarations common to 
40
 * the server and the plugin infrastructure, and not the client 
41
 */
42
#include <drizzled/common_includes.h>       
243.1.16 by Jay Pipes
minor cleanup and final removal of all client and server prepared statement declarations and definitions
43
/* Range optimization API/library */
44
#include <drizzled/opt_range.h>
45
/* Simple error injection (crash) module */
46
#include <drizzled/error_injection.h>
47
/* API for connecting, logging in to a drizzled server */
48
#include <drizzled/connect.h>
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
49
/* Routines for dropping, repairing, checking schema tables */
50
#include <drizzled/sql_table.h>
51
52
/* sql_db.cc */
1 by brian
clean slate
53
int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
54
bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
55
bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
56
bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name,
57
                     bool force_switch);
58
bool mysql_opt_change_db(THD *thd,
59
                         const LEX_STRING *new_db_name,
60
                         LEX_STRING *saved_db_name,
61
                         bool force_switch,
62
                         bool *cur_db_changed);
63
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
64
/* sql_repl.cc */
65
void write_bin_log(THD *thd, bool clear_error,
66
                   char const *query, ulong query_length);
67
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags);
68
void mysql_client_binlog_statement(THD *thd);
69
70
/* sql_rename.cc */
327.2.4 by Brian Aker
Refactoring table.h
71
bool mysql_rename_tables(THD *thd, TableList *table_list, bool silent);
72
bool do_rename(THD *thd, TableList *ren_table, char *new_db,
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
73
                      char *new_table_name, char *new_table_alias,
74
                      bool skip_error);
75
76
/* sql_parse.cc */
1 by brian
clean slate
77
void mysql_parse(THD *thd, const char *inBuf, uint length,
78
                 const char ** semicolon);
79
80
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
81
82
1 by brian
clean slate
83
bool is_update_query(enum enum_sql_command command);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
84
1 by brian
clean slate
85
bool alloc_query(THD *thd, const char *packet, uint packet_length);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
86
1 by brian
clean slate
87
void mysql_reset_thd_for_next_command(THD *thd);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
88
1 by brian
clean slate
89
void create_select_for_variable(const char *var_name);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
90
1 by brian
clean slate
91
void mysql_init_multi_delete(LEX *lex);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
92
1 by brian
clean slate
93
bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
94
1 by brian
clean slate
95
void init_update_queries(void);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
96
1 by brian
clean slate
97
bool do_command(THD *thd);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
98
1 by brian
clean slate
99
bool dispatch_command(enum enum_server_command command, THD *thd,
100
		      char* packet, uint packet_length);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
101
1 by brian
clean slate
102
void log_slow_statement(THD *thd);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
103
1 by brian
clean slate
104
bool append_file_to_dir(THD *thd, const char **filename_ptr, 
105
                        const char *table_name);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
106
327.2.4 by Brian Aker
Refactoring table.h
107
bool reload_cache(THD *thd, ulong options, TableList *tables, bool *write_to_binlog);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
108
109
bool check_simple_select();
110
111
/* @TODO <UNUSED> */
112
void mysql_init_select(LEX *lex);
113
bool mysql_new_select(LEX *lex, bool move_down);
114
void init_max_user_conn(void);
115
void free_max_user_conn(void);
116
pthread_handler_t handle_bootstrap(void *arg);
117
int mysql_execute_command(THD *thd);
327.2.4 by Brian Aker
Refactoring table.h
118
bool check_dup(const char *db, const char *name, TableList *tables);
119
bool check_table_access(THD *thd, ulong want_access, TableList *tables,
1 by brian
clean slate
120
                        bool no_errors,
121
                        bool any_combination_of_privileges_will_do,
122
                        uint number);
123
/*
124
  General routine to change field->ptr of a NULL-terminated array of Field
125
  objects. Useful when needed to call val_int, val_str or similar and the
126
  field data is not in table->record[0] but in some other structure.
127
  set_key_field_ptr changes all fields of an index using a key_info object.
128
  All methods presume that there is at least one field to change.
129
*/
130
void set_field_ptr(Field **ptr, const uchar *new_buf, const uchar *old_buf);
131
void set_key_field_ptr(KEY *key_info, const uchar *new_buf,
132
                       const uchar *old_buf);
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
133
/* </UNUSED> */
134
135
/* sql_base.cc */
136
void table_cache_free(void);
137
bool table_cache_init(void);
138
bool table_def_init(void);
139
void table_def_free(void);
140
void assign_new_table_id(TABLE_SHARE *share);
141
uint cached_open_tables(void);
142
uint cached_table_definitions(void);
143
144
/* drizzled.cc */
145
void kill_mysql(void);
146
void close_connection(THD *thd, uint errcode, bool lock);
147
148
/* sql_select.cc */
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
149
Table *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
1 by brian
clean slate
150
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
151
/* handler.cc */
1 by brian
clean slate
152
bool mysql_xa_recover(THD *thd);
153
327.2.3 by Brian Aker
Refactoring of class Table
154
SORT_FIELD * make_unireg_sortorder(order_st *order, uint *length,
1 by brian
clean slate
155
                                  SORT_FIELD *sortorder);
327.2.4 by Brian Aker
Refactoring table.h
156
int setup_order(THD *thd, Item **ref_pointer_array, TableList *tables,
327.2.3 by Brian Aker
Refactoring of class Table
157
		List<Item> &fields, List <Item> &all_fields, order_st *order);
327.2.4 by Brian Aker
Refactoring table.h
158
int setup_group(THD *thd, Item **ref_pointer_array, TableList *tables,
327.2.3 by Brian Aker
Refactoring of class Table
159
		List<Item> &fields, List<Item> &all_fields, order_st *order,
1 by brian
clean slate
160
		bool *hidden_group_fields);
161
bool fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
162
                   Item **ref_pointer_array);
163
164
bool handle_select(THD *thd, LEX *lex, select_result *result,
165
                   ulong setup_tables_done_option);
166
bool mysql_select(THD *thd, Item ***rref_pointer_array,
327.2.4 by Brian Aker
Refactoring table.h
167
                  TableList *tables, uint wild_num,  List<Item> &list,
327.2.3 by Brian Aker
Refactoring of class Table
168
                  COND *conds, uint og_num, order_st *order, order_st *group,
169
                  Item *having, order_st *proc_param, uint64_t select_type, 
1 by brian
clean slate
170
                  select_result *result, SELECT_LEX_UNIT *unit, 
171
                  SELECT_LEX *select_lex);
172
void free_underlaid_joins(THD *thd, SELECT_LEX *select);
173
bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit,
174
                         select_result *result);
175
int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type,
176
			 select_result *result);
177
bool mysql_union(THD *thd, LEX *lex, select_result *result,
178
                 SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
179
bool mysql_handle_derived(LEX *lex, bool (*processor)(THD *thd,
180
                                                      LEX *lex,
327.2.4 by Brian Aker
Refactoring table.h
181
                                                      TableList *table));
182
bool mysql_derived_prepare(THD *thd, LEX *lex, TableList *t);
183
bool mysql_derived_filling(THD *thd, LEX *lex, TableList *t);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
184
Field *create_tmp_field(THD *thd, Table *table,Item *item, Item::Type type,
1 by brian
clean slate
185
			Item ***copy_func, Field **from_field,
186
                        Field **def_field,
187
			bool group, bool modify_item,
188
			bool table_cant_handle_bit_fields,
189
                        bool make_copy_field,
190
                        uint convert_blob_length);
191
void sp_prepare_create_field(THD *thd, Create_field *sql_field);
192
int prepare_create_field(Create_field *sql_field, 
193
			 uint *blob_columns, 
194
			 int *timestamps, int *timestamps_with_niladic,
152 by Brian Aker
longlong replacement
195
			 int64_t table_flags);
1 by brian
clean slate
196
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
197
                        HA_CREATE_INFO *create_info,
198
                        Alter_info *alter_info,
199
                        bool tmp_table, uint select_field_count);
200
bool mysql_create_table_no_lock(THD *thd, const char *db,
201
                                const char *table_name,
202
                                HA_CREATE_INFO *create_info,
203
                                Alter_info *alter_info,
204
                                bool tmp_table, uint select_field_count);
205
206
bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
207
                       HA_CREATE_INFO *create_info,
327.2.4 by Brian Aker
Refactoring table.h
208
                       TableList *table_list,
1 by brian
clean slate
209
                       Alter_info *alter_info,
327.2.3 by Brian Aker
Refactoring of class Table
210
                       uint order_num, order_st *order, bool ignore);
327.2.4 by Brian Aker
Refactoring table.h
211
bool mysql_recreate_table(THD *thd, TableList *table_list);
212
bool mysql_create_like_table(THD *thd, TableList *table,
213
                             TableList *src_table,
1 by brian
clean slate
214
                             HA_CREATE_INFO *create_info);
215
bool mysql_rename_table(handlerton *base, const char *old_db,
216
                        const char * old_name, const char *new_db,
217
                        const char * new_name, uint flags);
327.2.4 by Brian Aker
Refactoring table.h
218
bool mysql_prepare_update(THD *thd, TableList *table_list,
327.2.3 by Brian Aker
Refactoring of class Table
219
                          Item **conds, uint order_num, order_st *order);
327.2.4 by Brian Aker
Refactoring table.h
220
int mysql_update(THD *thd,TableList *tables,List<Item> &fields,
1 by brian
clean slate
221
		 List<Item> &values,COND *conds,
327.2.3 by Brian Aker
Refactoring of class Table
222
		 uint order_num, order_st *order, ha_rows limit,
1 by brian
clean slate
223
		 enum enum_duplicates handle_duplicates, bool ignore);
327.2.4 by Brian Aker
Refactoring table.h
224
bool mysql_multi_update(THD *thd, TableList *table_list,
1 by brian
clean slate
225
                        List<Item> *fields, List<Item> *values,
151 by Brian Aker
Ulonglong to uint64_t
226
                        COND *conds, uint64_t options,
1 by brian
clean slate
227
                        enum enum_duplicates handle_duplicates, bool ignore,
228
                        SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
327.2.4 by Brian Aker
Refactoring table.h
229
bool mysql_prepare_insert(THD *thd, TableList *table_list, Table *table,
1 by brian
clean slate
230
                          List<Item> &fields, List_item *values,
231
                          List<Item> &update_fields,
232
                          List<Item> &update_values, enum_duplicates duplic,
233
                          COND **where, bool select_insert,
234
                          bool check_fields, bool abort_on_warning);
327.2.4 by Brian Aker
Refactoring table.h
235
bool mysql_insert(THD *thd,TableList *table,List<Item> &fields,
1 by brian
clean slate
236
                  List<List_item> &values, List<Item> &update_fields,
237
                  List<Item> &update_values, enum_duplicates flag,
238
                  bool ignore);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
239
int check_that_all_fields_are_given_values(THD *thd, Table *entry,
327.2.4 by Brian Aker
Refactoring table.h
240
                                           TableList *table_list);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
241
void prepare_triggers_for_insert_stmt(Table *table);
327.2.4 by Brian Aker
Refactoring table.h
242
int mysql_prepare_delete(THD *thd, TableList *table_list, Item **conds);
243
bool mysql_delete(THD *thd, TableList *table_list, COND *conds,
151 by Brian Aker
Ulonglong to uint64_t
244
                  SQL_LIST *order, ha_rows rows, uint64_t options,
1 by brian
clean slate
245
                  bool reset_auto_increment);
327.2.4 by Brian Aker
Refactoring table.h
246
bool mysql_truncate(THD *thd, TableList *table_list, bool dont_send_ok);
247
uint create_table_def_key(THD *thd, char *key, TableList *table_list,
1 by brian
clean slate
248
                          bool tmp_table);
327.2.4 by Brian Aker
Refactoring table.h
249
TABLE_SHARE *get_table_share(THD *thd, TableList *table_list, char *key,
1 by brian
clean slate
250
                             uint key_length, uint db_flags, int *error);
251
void release_table_share(TABLE_SHARE *share, enum release_type type);
252
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
327.2.4 by Brian Aker
Refactoring table.h
253
Table *open_ltable(THD *thd, TableList *table_list, thr_lock_type update,
1 by brian
clean slate
254
                   uint lock_flags);
356 by Brian Aker
Class cleanups... duplicates are in definitions and unireg :(
255
Table *open_table(THD *thd, TableList *table_list, bool *refresh, uint flags);
327.2.4 by Brian Aker
Refactoring table.h
256
bool name_lock_locked_table(THD *thd, TableList *tables);
257
bool reopen_name_locked_table(THD* thd, TableList* table_list, bool link_in);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
258
Table *table_cache_insert_placeholder(THD *thd, const char *key,
1 by brian
clean slate
259
                                      uint key_length);
260
bool lock_table_name_if_not_cached(THD *thd, const char *db,
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
261
                                   const char *table_name, Table **table);
262
Table *find_locked_table(THD *thd, const char *db,const char *table_name);
263
void detach_merge_children(Table *table, bool clear_refs);
327.2.4 by Brian Aker
Refactoring table.h
264
bool fix_merge_after_open(TableList *old_child_list, TableList **old_last,
265
                          TableList *new_child_list, TableList **new_last);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
266
bool reopen_table(Table *table);
1 by brian
clean slate
267
bool reopen_tables(THD *thd,bool get_locks,bool in_refresh);
268
void close_data_files_and_morph_locks(THD *thd, const char *db,
269
                                      const char *table_name);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
270
void close_handle_and_leave_table_as_lock(Table *table);
1 by brian
clean slate
271
bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
272
                  uint db_stat, uint prgflag,
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
273
                  uint ha_open_flags, Table *outparam,
327.2.4 by Brian Aker
Refactoring table.h
274
                  TableList *table_desc, MEM_ROOT *mem_root);
1 by brian
clean slate
275
bool wait_for_tables(THD *thd);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
276
bool table_is_used(Table *table, bool wait_for_name_lock);
277
Table *drop_locked_tables(THD *thd,const char *db, const char *table_name);
1 by brian
clean slate
278
void abort_locked_tables(THD *thd,const char *db, const char *table_name);
279
void execute_init_command(THD *thd, sys_var_str *init_command_var,
280
			  rw_lock_t *var_mutex);
281
extern Field *not_found_field;
282
extern Field *view_ref_found;
283
284
enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
285
				  IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
286
                                  IGNORE_EXCEPT_NON_UNIQUE};
287
Field *
288
find_field_in_tables(THD *thd, Item_ident *item,
327.2.4 by Brian Aker
Refactoring table.h
289
                     TableList *first_table, TableList *last_table,
1 by brian
clean slate
290
                     Item **ref, find_item_error_report_type report_error,
291
                     bool check_privileges, bool register_tree_change);
292
Field *
327.2.4 by Brian Aker
Refactoring table.h
293
find_field_in_table_ref(THD *thd, TableList *table_list,
1 by brian
clean slate
294
                        const char *name, uint length,
295
                        const char *item_name, const char *db_name,
296
                        const char *table_name, Item **ref,
297
                        bool check_privileges, bool allow_rowid,
298
                        uint *cached_field_index_ptr,
327.2.4 by Brian Aker
Refactoring table.h
299
                        bool register_tree_change, TableList **actual_table);
1 by brian
clean slate
300
Field *
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
301
find_field_in_table(THD *thd, Table *table, const char *name, uint length,
1 by brian
clean slate
302
                    bool allow_rowid, uint *cached_field_index_ptr);
303
Field *
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
304
find_field_in_table_sef(Table *table, const char *name);
1 by brian
clean slate
305
306
/* sql_do.cc */
307
bool mysql_do(THD *thd, List<Item> &values);
308
309
/* sql_analyse.h */
310
bool append_escaped(String *to_str, String *from_str);
311
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
312
#include <drizzled/show.h>
1 by brian
clean slate
313
314
/* information schema */
315
extern LEX_STRING INFORMATION_SCHEMA_NAME;
316
/* log tables */
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
317
extern LEX_STRING DRIZZLE_SCHEMA_NAME;
1 by brian
clean slate
318
extern LEX_STRING GENERAL_LOG_NAME;
319
extern LEX_STRING SLOW_LOG_NAME;
320
321
extern const LEX_STRING partition_keywords[];
322
ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name);
323
ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
324
int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
325
                         enum enum_schema_tables schema_table_idx);
326
int make_schema_select(THD *thd,  SELECT_LEX *sel,
327
                       enum enum_schema_tables schema_table_idx);
327.2.4 by Brian Aker
Refactoring table.h
328
int mysql_schema_table(THD *thd, LEX *lex, TableList *table_list);
1 by brian
clean slate
329
bool get_schema_tables_result(JOIN *join,
330
                              enum enum_schema_table_state executed_place);
331
enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
332
333
#define is_schema_db(X) \
334
  !my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X))
335
336
/* sql_handler.cc */
327.2.4 by Brian Aker
Refactoring table.h
337
bool mysql_ha_open(THD *thd, TableList *tables, bool reopen);
338
bool mysql_ha_close(THD *thd, TableList *tables);
339
bool mysql_ha_read(THD *, TableList *,enum enum_ha_read_modes,char *,
1 by brian
clean slate
340
                   List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
341
void mysql_ha_flush(THD *thd);
327.2.4 by Brian Aker
Refactoring table.h
342
void mysql_ha_rm_tables(THD *thd, TableList *tables, bool is_locked);
1 by brian
clean slate
343
void mysql_ha_cleanup(THD *thd);
344
345
/* sql_base.cc */
346
#define TMP_TABLE_KEY_EXTRA 8
347
void set_item_name(Item *item,char *pos,uint length);
348
bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types type,
349
		       char *length, char *decimal,
350
		       uint type_modifier,
351
                       enum column_format_type column_format,
352
		       Item *default_value, Item *on_update_value,
353
		       LEX_STRING *comment,
354
		       char *change, List<String> *interval_list,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
355
		       const CHARSET_INFO * const cs);
1 by brian
clean slate
356
Create_field * new_create_field(THD *thd, char *field_name, enum_field_types type,
357
				char *length, char *decimals,
358
				uint type_modifier, 
359
				Item *default_value, Item *on_update_value,
360
				LEX_STRING *comment, char *change, 
361
				List<String> *interval_list, CHARSET_INFO *cs);
362
void store_position_for_column(const char *name);
363
bool add_to_list(THD *thd, SQL_LIST &list,Item *group,bool asc);
364
bool push_new_name_resolution_context(THD *thd,
327.2.4 by Brian Aker
Refactoring table.h
365
                                      TableList *left_op,
366
                                      TableList *right_op);
367
void add_join_on(TableList *b,Item *expr);
368
void add_join_natural(TableList *a,TableList *b,List<String> *using_fields,
1 by brian
clean slate
369
                      SELECT_LEX *lex);
370
bool add_proc_to_list(THD *thd, Item *item);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
371
void unlink_open_table(THD *thd, Table *find, bool unlock);
372
void drop_open_table(THD *thd, Table *table, const char *db_name,
1 by brian
clean slate
373
                     const char *table_name);
327.2.4 by Brian Aker
Refactoring table.h
374
void update_non_unique_table_error(TableList *update,
1 by brian
clean slate
375
                                   const char *operation,
327.2.4 by Brian Aker
Refactoring table.h
376
                                   TableList *duplicate);
1 by brian
clean slate
377
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
378
SQL_SELECT *make_select(Table *head, table_map const_tables,
1 by brian
clean slate
379
			table_map read_tables, COND *conds,
380
                        bool allow_null_cond,  int *error);
381
extern Item **not_found_item;
382
383
/*
384
  A set of constants used for checking non aggregated fields and sum
385
  functions mixture in the ONLY_FULL_GROUP_BY_MODE.
386
*/
387
#define NON_AGG_FIELD_USED  1
388
#define SUM_FUNC_USED       2
389
390
/*
391
  This enumeration type is used only by the function find_item_in_list
392
  to return the info on how an item has been resolved against a list
393
  of possibly aliased items.
394
  The item can be resolved: 
395
   - against an alias name of the list's element (RESOLVED_AGAINST_ALIAS)
396
   - against non-aliased field name of the list  (RESOLVED_WITH_NO_ALIAS)
397
   - against an aliased field name of the list   (RESOLVED_BEHIND_ALIAS)
398
   - ignoring the alias name in cases when SQL requires to ignore aliases
399
     (e.g. when the resolved field reference contains a table name or
400
     when the resolved item is an expression)   (RESOLVED_IGNORING_ALIAS)    
401
*/
402
enum enum_resolution_type {
403
  NOT_RESOLVED=0,
404
  RESOLVED_IGNORING_ALIAS,
405
  RESOLVED_BEHIND_ALIAS,
406
  RESOLVED_WITH_NO_ALIAS,
407
  RESOLVED_AGAINST_ALIAS
408
};
409
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,
410
                          find_item_error_report_type report_error,
411
                          enum_resolution_type *resolution);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
412
bool get_key_map_from_key_list(key_map *map, Table *table,
1 by brian
clean slate
413
                               List<String> *index_list);
414
bool insert_fields(THD *thd, Name_resolution_context *context,
415
		   const char *db_name, const char *table_name,
416
                   List_iterator<Item> *it, bool any_privileges);
417
bool setup_tables(THD *thd, Name_resolution_context *context,
327.2.4 by Brian Aker
Refactoring table.h
418
                  List<TableList> *from_clause, TableList *tables,
419
                  TableList **leaves, bool select_insert);
1 by brian
clean slate
420
bool setup_tables_and_check_access(THD *thd, 
421
                                   Name_resolution_context *context,
327.2.4 by Brian Aker
Refactoring table.h
422
                                   List<TableList> *from_clause, 
423
                                   TableList *tables, 
424
                                   TableList **leaves, 
1 by brian
clean slate
425
                                   bool select_insert);
327.2.4 by Brian Aker
Refactoring table.h
426
int setup_wild(THD *thd, TableList *tables, List<Item> &fields,
1 by brian
clean slate
427
	       List<Item> *sum_func_list, uint wild_num);
428
bool setup_fields(THD *thd, Item** ref_pointer_array,
429
                  List<Item> &item, enum_mark_columns mark_used_columns,
430
                  List<Item> *sum_func_list, bool allow_sum_func);
431
inline bool setup_fields_with_no_wrap(THD *thd, Item **ref_pointer_array,
432
                                      List<Item> &item,
433
                                      enum_mark_columns mark_used_columns,
434
                                      List<Item> *sum_func_list,
435
                                      bool allow_sum_func)
436
{
437
  bool res;
438
  res= setup_fields(thd, ref_pointer_array, item, mark_used_columns, sum_func_list,
439
                    allow_sum_func);
440
  return res;
441
}
327.2.4 by Brian Aker
Refactoring table.h
442
int setup_conds(THD *thd, TableList *tables, TableList *leaves,
1 by brian
clean slate
443
		COND **conds);
444
int setup_ftfuncs(SELECT_LEX* select);
445
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
446
void wait_for_condition(THD *thd, pthread_mutex_t *mutex,
447
                        pthread_cond_t *cond);
327.2.4 by Brian Aker
Refactoring table.h
448
int open_tables(THD *thd, TableList **tables, uint *counter, uint flags);
1 by brian
clean slate
449
/* open_and_lock_tables with optional derived handling */
327.2.4 by Brian Aker
Refactoring table.h
450
int open_and_lock_tables_derived(THD *thd, TableList *tables, bool derived);
1 by brian
clean slate
451
/* simple open_and_lock_tables without derived handling */
327.2.4 by Brian Aker
Refactoring table.h
452
inline int simple_open_n_lock_tables(THD *thd, TableList *tables)
1 by brian
clean slate
453
{
51.1.34 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
454
  return open_and_lock_tables_derived(thd, tables, false);
1 by brian
clean slate
455
}
456
/* open_and_lock_tables with derived handling */
327.2.4 by Brian Aker
Refactoring table.h
457
inline int open_and_lock_tables(THD *thd, TableList *tables)
1 by brian
clean slate
458
{
51.1.34 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
459
  return open_and_lock_tables_derived(thd, tables, true);
1 by brian
clean slate
460
}
461
/* simple open_and_lock_tables without derived handling for single table */
327.2.4 by Brian Aker
Refactoring table.h
462
Table *open_n_lock_single_table(THD *thd, TableList *table_l,
1 by brian
clean slate
463
                                thr_lock_type lock_type);
327.2.4 by Brian Aker
Refactoring table.h
464
bool open_normal_and_derived_tables(THD *thd, TableList *tables, uint flags);
465
int lock_tables(THD *thd, TableList *tables, uint counter, bool *need_reopen);
466
int decide_logging_format(THD *thd, TableList *tables);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
467
Table *open_temporary_table(THD *thd, const char *path, const char *db,
1 by brian
clean slate
468
                            const char *table_name, bool link_in_list,
469
                            open_table_mode open_mode);
470
bool rm_temporary_table(handlerton *base, char *path, bool frm_only);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
471
void free_io_cache(Table *entry);
472
void intern_close_table(Table *entry);
473
bool close_thread_table(THD *thd, Table **table_ptr);
1 by brian
clean slate
474
void close_temporary_tables(THD *thd);
327.2.4 by Brian Aker
Refactoring table.h
475
void close_tables_for_reopen(THD *thd, TableList **tables);
476
TableList *find_table_in_list(TableList *table,
477
                               TableList *TableList::*link,
1 by brian
clean slate
478
                               const char *db_name,
479
                               const char *table_name);
327.2.4 by Brian Aker
Refactoring table.h
480
TableList *unique_table(THD *thd, TableList *table, TableList *table_list,
1 by brian
clean slate
481
                         bool check_alias);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
482
Table *find_temporary_table(THD *thd, const char *db, const char *table_name);
327.2.4 by Brian Aker
Refactoring table.h
483
Table *find_temporary_table(THD *thd, TableList *table_list);
484
int drop_temporary_table(THD *thd, TableList *table_list);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
485
void close_temporary_table(THD *thd, Table *table, bool free_share,
1 by brian
clean slate
486
                           bool delete_table);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
487
void close_temporary(Table *table, bool free_share, bool delete_table);
488
bool rename_temporary_table(THD* thd, Table *table, const char *new_db,
1 by brian
clean slate
489
			    const char *table_name);
490
void remove_db_from_cache(const char *db);
491
void flush_tables();
492
bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
493
char *make_default_log_name(char *buff,const char* log_ext);
494
495
/* bits for last argument to remove_table_from_cache() */
496
#define RTFC_NO_FLAG                0x0000
497
#define RTFC_OWNED_BY_THD_FLAG      0x0001
498
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
499
#define RTFC_CHECK_KILLED_FLAG      0x0004
500
bool remove_table_from_cache(THD *thd, const char *db, const char *table,
501
                             uint flags);
502
503
#define NORMAL_PART_NAME 0
504
#define TEMP_PART_NAME 1
505
#define RENAMED_PART_NAME 2
506
507
void mem_alloc_error(size_t size);
508
509
#define WFRM_WRITE_SHADOW 1
510
#define WFRM_INSTALL_SHADOW 2
511
#define WFRM_PACK_FRM 4
512
#define WFRM_KEEP_SHARE 8
513
327.2.4 by Brian Aker
Refactoring table.h
514
bool close_cached_tables(THD *thd, TableList *tables, bool have_lock,
1 by brian
clean slate
515
                         bool wait_for_refresh, bool wait_for_placeholders);
516
bool close_cached_connection_tables(THD *thd, bool wait_for_refresh,
517
                                    LEX_STRING *connect_string,
51.1.34 by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE
518
                                    bool have_lock= false);
1 by brian
clean slate
519
void copy_field_from_tmp_record(Field *field,int offset);
520
bool fill_record(THD * thd, List<Item> &fields, List<Item> &values, bool ignore_errors);
521
bool fill_record(THD *thd, Field **field, List<Item> &values, bool ignore_errors);
327.2.4 by Brian Aker
Refactoring table.h
522
OPEN_TableList *list_open_tables(THD *thd, const char *db, const char *wild);
1 by brian
clean slate
523
327.2.4 by Brian Aker
Refactoring table.h
524
inline TableList *find_table_in_global_list(TableList *table,
1 by brian
clean slate
525
                                             const char *db_name,
526
                                             const char *table_name)
527
{
327.2.4 by Brian Aker
Refactoring table.h
528
  return find_table_in_list(table, &TableList::next_global,
1 by brian
clean slate
529
                            db_name, table_name);
530
}
531
327.2.4 by Brian Aker
Refactoring table.h
532
inline TableList *find_table_in_local_list(TableList *table,
1 by brian
clean slate
533
                                            const char *db_name,
534
                                            const char *table_name)
535
{
327.2.4 by Brian Aker
Refactoring table.h
536
  return find_table_in_list(table, &TableList::next_local,
1 by brian
clean slate
537
                            db_name, table_name);
538
}
539
540
541
/* sql_calc.cc */
542
bool eval_const_cond(COND *cond);
543
544
/* sql_load.cc */
327.2.4 by Brian Aker
Refactoring table.h
545
int mysql_load(THD *thd, sql_exchange *ex, TableList *table_list,
1 by brian
clean slate
546
	        List<Item> &fields_vars, List<Item> &set_fields,
547
                List<Item> &set_values_list,
548
                enum enum_duplicates handle_duplicates, bool ignore,
549
                bool local_file);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
550
int write_record(THD *thd, Table *table, COPY_INFO *info);
1 by brian
clean slate
551
552
553
/* sql_test.cc */
554
void print_where(COND *cond,const char *info, enum_query_type query_type);
555
void print_cached_tables(void);
556
void TEST_filesort(SORT_FIELD *sortorder,uint s_length);
557
void print_plan(JOIN* join,uint idx, double record_count, double read_time,
558
                double current_read_time, const char *info);
559
void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array);
327.2.4 by Brian Aker
Refactoring table.h
560
void dump_TableList_graph(SELECT_LEX *select_lex, TableList* tl);
1 by brian
clean slate
561
void mysql_print_status();
562
563
/* key.cc */
564
int find_ref_key(KEY *key, uint key_count, uchar *record, Field *field,
565
                 uint *key_length, uint *keypart);
566
void key_copy(uchar *to_key, uchar *from_record, KEY *key_info, uint key_length);
567
void key_restore(uchar *to_record, uchar *from_key, KEY *key_info,
287.3.8 by Monty Taylor
Oy. Replaced max and min macros with std::max and std::min so that we get
568
                 uint16_t key_length);
1 by brian
clean slate
569
void key_zero_nulls(uchar *tuple, KEY *key_info);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
570
bool key_cmp_if_same(Table *form,const uchar *key,uint index,uint key_length);
571
void key_unpack(String *to,Table *form,uint index);
572
bool is_key_used(Table *table, uint idx, const MY_BITMAP *fields);
1 by brian
clean slate
573
int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length);
574
extern "C" int key_rec_cmp(void *key_info, uchar *a, uchar *b);
575
576
bool init_errmessage(void);
577
File open_binlog(IO_CACHE *log, const char *log_file_name,
578
                 const char **errmsg);
579
580
/* mysqld.cc */
581
extern void MYSQLerror(const char*);
582
void refresh_status(THD *thd);
198 by Brian Aker
More my_bool... man am I getting tired of writing this.
583
bool mysql_rm_tmp_tables(void);
1 by brian
clean slate
584
void handle_connection_in_main_thread(THD *thd);
585
void create_thread_to_handle_connection(THD *thd);
586
void unlink_thd(THD *thd);
587
bool one_thread_per_connection_end(THD *thd, bool put_in_cache);
588
void flush_thread_cache();
589
590
/* item_func.cc */
591
extern bool check_reserved_words(LEX_STRING *name);
592
extern enum_field_types agg_field_type(Item **items, uint nitems);
593
594
/* strfunc.cc */
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
595
uint64_t find_set(TYPELIB *lib, const char *x, uint length, const CHARSET_INFO * const cs,
1 by brian
clean slate
596
		   char **err_pos, uint *err_len, bool *set_warning);
597
uint find_type(const TYPELIB *lib, const char *find, uint length,
598
               bool part_match);
599
uint find_type2(const TYPELIB *lib, const char *find, uint length,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
600
                const CHARSET_INFO *cs);
1 by brian
clean slate
601
void unhex_type2(TYPELIB *lib);
602
uint check_word(TYPELIB *lib, const char *val, const char *end,
603
		const char **end_of_word);
604
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.
605
                         const CHARSET_INFO * const cs);
1 by brian
clean slate
606
607
608
bool is_keyword(const char *name, uint len);
609
610
#define MY_DB_OPT_FILE "db.opt"
611
bool my_database_names_init(void);
612
void my_database_names_free(void);
613
bool check_db_dir_existence(const char *db_name);
614
bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create);
615
bool load_db_opt_by_name(THD *thd, const char *db_name,
616
                         HA_CREATE_INFO *db_create_info);
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
617
const CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name);
1 by brian
clean slate
618
bool my_dbopt_init(void);
619
void my_dbopt_cleanup(void);
620
extern int creating_database; // How many database locks are made
621
extern int creating_table;    // How many mysql_create_table() are running
622
623
/*
624
  External variables
625
*/
626
627
extern time_t server_start_time, flush_status_time;
137 by Brian Aker
Removed dead FT bits. Small refactoring in sql_plugin.cc
628
extern char *opt_mysql_tmpdir, mysql_charsets_dir[];
629
            
1 by brian
clean slate
630
#define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
631
extern MY_TMPDIR mysql_tmpdir_list;
632
extern const LEX_STRING command_name[];
633
extern const char *first_keyword, *my_localhost, *delayed_user, *binary_keyword;
634
extern const char *myisam_recover_options_str;
635
extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
636
extern const char * const TRG_EXT;
637
extern const char * const TRN_EXT;
638
extern Eq_creator eq_creator;
639
extern Ne_creator ne_creator;
640
extern Gt_creator gt_creator;
641
extern Lt_creator lt_creator;
642
extern Ge_creator ge_creator;
643
extern Le_creator le_creator;
644
extern char language[FN_REFLEN];
645
extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
646
extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
647
extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
648
extern const double log_10[309];
151 by Brian Aker
Ulonglong to uint64_t
649
extern uint64_t log_10_int[20];
650
extern uint64_t keybuff_size;
651
extern uint64_t thd_startup_options;
1 by brian
clean slate
652
extern ulong thread_id;
653
extern ulong binlog_cache_use, binlog_cache_disk_use;
654
extern ulong aborted_threads,aborted_connects;
655
extern ulong slave_open_temp_tables;
656
extern ulong slow_launch_threads, slow_launch_time;
657
extern ulong table_cache_size, table_def_size;
658
extern ulong max_connections,max_connect_errors, connect_timeout;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
659
extern bool slave_allow_batching;
1 by brian
clean slate
660
extern ulong slave_net_timeout, slave_trans_retries;
661
extern uint max_user_connections;
662
extern ulong what_to_log,flush_time;
663
extern ulong query_buff_size;
664
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
665
extern ulong max_binlog_size, max_relay_log_size;
666
extern ulong opt_binlog_rows_event_max_size;
667
extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
668
extern ulong back_log;
669
extern ulong current_pid;
670
extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
671
extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
672
extern ulong tc_log_page_waits;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
673
extern bool relay_log_purge;
198 by Brian Aker
More my_bool... man am I getting tired of writing this.
674
extern bool opt_innodb_safe_binlog, opt_innodb;
1 by brian
clean slate
675
extern uint test_flags,select_errors,ha_open_options;
676
extern uint protocol_version, mysqld_port, dropping_tables;
677
extern uint delay_key_write_options;
678
extern bool opt_endinfo, using_udf_functions;
150 by Brian Aker
More bool removal. More cow bell!
679
extern bool locked_in_memory;
1 by brian
clean slate
680
extern bool opt_using_transactions;
30 by Brian Aker
Large file and ftruncate() support
681
extern bool using_update_log, server_id_supplied;
1 by brian
clean slate
682
extern bool opt_update_log, opt_bin_log, opt_error_log;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
683
extern bool opt_log; 
684
extern bool opt_slow_log;
1 by brian
clean slate
685
extern ulong log_output_options;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
686
extern bool opt_log_queries_not_using_indexes;
150 by Brian Aker
More bool removal. More cow bell!
687
extern bool opt_character_set_client_handshake;
1 by brian
clean slate
688
extern bool volatile abort_loop, shutdown_in_progress;
689
extern uint volatile thread_count, thread_running, global_read_lock;
690
extern uint connection_count;
150 by Brian Aker
More bool removal. More cow bell!
691
extern bool opt_sql_bin_update;
692
extern bool opt_safe_user_create;
198 by Brian Aker
More my_bool... man am I getting tired of writing this.
693
extern bool opt_no_mix_types;
694
extern bool opt_safe_show_db, opt_myisam_use_mmap;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
695
extern bool opt_local_infile;
696
extern bool opt_slave_compressed_protocol;
150 by Brian Aker
More bool removal. More cow bell!
697
extern bool use_temp_pool;
1 by brian
clean slate
698
extern ulong slave_exec_mode_options;
147 by Brian Aker
More my_bool conversion. This time the set_var class.
699
extern bool opt_readonly;
700
extern bool opt_sync_frm;
701
extern bool opt_secure_auth;
1 by brian
clean slate
702
extern char* opt_secure_file_priv;
150 by Brian Aker
More bool removal. More cow bell!
703
extern bool opt_log_slow_admin_statements;
704
extern bool opt_log_slow_slave_statements;
705
extern bool opt_noacl;
706
extern bool opt_old_style_user_limits;
1 by brian
clean slate
707
extern uint opt_crash_binlog_innodb;
708
extern char *default_tz_name;
709
extern char *opt_logname, *opt_slow_logname;
710
extern const char *log_output_str;
711
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
712
extern DRIZZLE_BIN_LOG mysql_bin_log;
1 by brian
clean slate
713
extern LOGGER logger;
327.2.4 by Brian Aker
Refactoring table.h
714
extern TableList general_log, slow_log;
1 by brian
clean slate
715
extern FILE *stderror_file;
716
extern pthread_key(MEM_ROOT**,THR_MALLOC);
12 by Brian Aker
More dead code removal.
717
extern pthread_mutex_t LOCK_mysql_create_db,LOCK_open, LOCK_lock_db,
327.2.2 by Brian Aker
Removed dead/not used code.
718
       LOCK_thread_count,LOCK_user_locks, LOCK_status,
1 by brian
clean slate
719
       LOCK_error_log, LOCK_uuid_generator,
12 by Brian Aker
More dead code removal.
720
       LOCK_crypt, LOCK_timezone,
160 by Brian Aker
Removed sql_manager. Ever heard of just setting up the OS to sync when you
721
       LOCK_slave_list, LOCK_active_mi, LOCK_global_read_lock,
1 by brian
clean slate
722
       LOCK_global_system_variables, LOCK_user_conn,
723
       LOCK_bytes_sent, LOCK_bytes_received, LOCK_connection_count;
724
extern pthread_mutex_t LOCK_server_started;
725
extern rw_lock_t LOCK_sys_init_connect, LOCK_sys_init_slave;
726
extern rw_lock_t LOCK_system_variables_hash;
727
extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
728
extern pthread_cond_t COND_global_read_lock;
729
extern pthread_attr_t connection_attrib;
730
extern I_List<THD> threads;
731
extern I_List<NAMED_LIST> key_caches;
732
extern MY_BITMAP temp_pool;
733
extern String my_empty_string;
734
extern const String my_null_string;
735
extern SHOW_VAR status_vars[];
736
extern struct system_variables max_system_variables;
737
extern struct system_status_var global_status_var;
738
extern struct rand_struct sql_rand;
739
740
extern const char *opt_date_time_formats[];
741
extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
742
743
extern String null_string;
744
extern HASH open_cache, lock_db_cache;
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
745
extern Table *unused_tables;
1 by brian
clean slate
746
extern const char* any_db;
747
extern struct my_option my_long_options[];
748
extern const LEX_STRING view_type;
749
extern scheduler_functions thread_scheduler;
750
extern TYPELIB thread_handling_typelib;
206 by Brian Aker
Removed final uint dead types.
751
extern uint8_t uc_update_queries[SQLCOM_END+1];
1 by brian
clean slate
752
extern uint sql_command_flags[];
753
extern TYPELIB log_output_typelib;
754
755
/* optional things, have_* variables */
756
extern SHOW_COMP_OPTION have_community_features;
757
758
extern handlerton *myisam_hton;
759
extern handlerton *heap_hton;
760
177.3.1 by mark
remove ifdef HAVE_DLOPEN, make configure require dlopen()
761
extern SHOW_COMP_OPTION have_symlink;
1 by brian
clean slate
762
extern SHOW_COMP_OPTION have_compress;
763
764
765
extern pthread_t signal_thread;
766
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
767
DRIZZLE_LOCK *mysql_lock_tables(THD *thd, Table **table, uint count,
1 by brian
clean slate
768
                              uint flags, bool *need_reopen);
769
/* mysql_lock_tables() and open_table() flags bits */
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
770
#define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_LOCK      0x0001
771
#define DRIZZLE_LOCK_IGNORE_FLUSH                 0x0002
772
#define DRIZZLE_LOCK_NOTIFY_IF_NEED_REOPEN        0x0004
773
#define DRIZZLE_OPEN_TEMPORARY_ONLY               0x0008
774
#define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_ONLY      0x0010
775
#define DRIZZLE_LOCK_PERF_SCHEMA                  0x0020
1 by brian
clean slate
776
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
777
void mysql_unlock_tables(THD *thd, DRIZZLE_LOCK *sql_lock);
778
void mysql_unlock_read_tables(THD *thd, DRIZZLE_LOCK *sql_lock);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
779
void mysql_unlock_some_tables(THD *thd, Table **table,uint count);
780
void mysql_lock_remove(THD *thd, DRIZZLE_LOCK *locked,Table *table,
1 by brian
clean slate
781
                       bool always_unlock);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
782
void mysql_lock_abort(THD *thd, Table *table, bool upgrade_lock);
783
void mysql_lock_downgrade_write(THD *thd, Table *table,
1 by brian
clean slate
784
                                thr_lock_type new_lock_type);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
785
bool mysql_lock_abort_for_thread(THD *thd, Table *table);
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
786
DRIZZLE_LOCK *mysql_lock_merge(DRIZZLE_LOCK *a,DRIZZLE_LOCK *b);
327.2.4 by Brian Aker
Refactoring table.h
787
TableList *mysql_lock_have_duplicate(THD *thd, TableList *needle,
788
                                      TableList *haystack);
1 by brian
clean slate
789
bool lock_global_read_lock(THD *thd);
790
void unlock_global_read_lock(THD *thd);
791
bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
792
                              bool is_not_commit);
793
void start_waiting_global_read_lock(THD *thd);
794
bool make_global_read_lock_block_commit(THD *thd);
795
bool set_protect_against_global_read_lock(void);
796
void unset_protect_against_global_read_lock(void);
797
void broadcast_refresh(void);
327.2.4 by Brian Aker
Refactoring table.h
798
int try_transactional_lock(THD *thd, TableList *table_list);
799
int check_transactional_lock(THD *thd, TableList *table_list);
800
int set_handler_table_locks(THD *thd, TableList *table_list,
1 by brian
clean slate
801
                            bool transactional);
802
803
/* Lock based on name */
327.2.4 by Brian Aker
Refactoring table.h
804
int lock_and_wait_for_table_name(THD *thd, TableList *table_list);
805
int lock_table_name(THD *thd, TableList *table_list, bool check_in_use);
806
void unlock_table_name(THD *thd, TableList *table_list);
807
bool wait_for_locked_table_names(THD *thd, TableList *table_list);
808
bool lock_table_names(THD *thd, TableList *table_list);
809
void unlock_table_names(THD *thd, TableList *table_list,
810
			TableList *last_table);
811
bool lock_table_names_exclusively(THD *thd, TableList *table_list);
1 by brian
clean slate
812
bool is_table_name_exclusively_locked_by_this_thread(THD *thd, 
327.2.4 by Brian Aker
Refactoring table.h
813
                                                     TableList *table_list);
1 by brian
clean slate
814
bool is_table_name_exclusively_locked_by_this_thread(THD *thd, uchar *key,
815
                                                     int key_length);
816
817
818
/* old unireg functions */
819
820
void unireg_init(ulong options);
821
void unireg_end(void) __attribute__((noreturn));
822
bool mysql_create_frm(THD *thd, const char *file_name,
823
                      const char *db, const char *table,
824
		      HA_CREATE_INFO *create_info,
825
		      List<Create_field> &create_field,
826
		      uint key_count,KEY *key_info,handler *db_type);
827
int rea_create_table(THD *thd, const char *path,
828
                     const char *db, const char *table_name,
829
                     HA_CREATE_INFO *create_info,
830
  		     List<Create_field> &create_field,
831
                     uint key_count,KEY *key_info,
832
                     handler *file);
833
int format_number(uint inputflag,uint max_length,char * pos,uint length,
834
		  char * *errpos);
835
836
/* table.cc */
327.2.4 by Brian Aker
Refactoring table.h
837
TABLE_SHARE *alloc_table_share(TableList *table_list, char *key,
1 by brian
clean slate
838
                               uint key_length);
839
void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
840
                          uint key_length,
841
                          const char *table_name, const char *path);
842
void free_table_share(TABLE_SHARE *share);
843
int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags);
844
void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg);
845
int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
846
                          uint db_stat, uint prgflag, uint ha_open_flags,
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
847
                          Table *outparam, open_table_mode open_mode);
1 by brian
clean slate
848
int readfrm(const char *name, uchar **data, size_t *length);
849
int writefrm(const char* name, const uchar* data, size_t len);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
850
int closefrm(Table *table, bool free_share);
1 by brian
clean slate
851
int read_string(File file, uchar* *to, size_t length);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
852
void free_blobs(Table *table);
1 by brian
clean slate
853
int set_zone(int nr,int min_zone,int max_zone);
854
ulong convert_period_to_month(ulong period);
855
ulong convert_month_to_period(ulong month);
856
void get_date_from_daynr(long daynr,uint *year, uint *month,
857
			 uint *day);
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
858
my_time_t TIME_to_timestamp(THD *thd, const DRIZZLE_TIME *t, bool *not_exist);
859
bool str_to_time_with_warn(const char *str,uint length,DRIZZLE_TIME *l_time);
1 by brian
clean slate
860
timestamp_type str_to_datetime_with_warn(const char *str, uint length,
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
861
                                         DRIZZLE_TIME *l_time, uint flags);
862
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
863
void calc_time_from_sec(DRIZZLE_TIME *to, long seconds, long microseconds);
1 by brian
clean slate
864
261.4.1 by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR.
865
void make_truncated_value_warning(THD *thd, DRIZZLE_ERROR::enum_warning_level level,
1 by brian
clean slate
866
                                  const char *str_val,
867
				  uint str_length, timestamp_type time_type,
868
                                  const char *field_name);
869
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
870
bool date_add_interval(DRIZZLE_TIME *ltime, interval_type int_type, INTERVAL interval);
871
bool calc_time_diff(DRIZZLE_TIME *l_time1, DRIZZLE_TIME *l_time2, int l_sign,
152 by Brian Aker
longlong replacement
872
                    int64_t *seconds_out, long *microseconds_out);
1 by brian
clean slate
873
874
extern LEX_STRING interval_type_to_name[];
875
876
extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type,
877
					       const char *format_str,
878
					       uint format_length);
879
extern DATE_TIME_FORMAT *date_time_format_copy(THD *thd,
880
					       DATE_TIME_FORMAT *format);
881
const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
882
				     timestamp_type type);
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
883
extern bool make_date_time(DATE_TIME_FORMAT *format, DRIZZLE_TIME *l_time,
1 by brian
clean slate
884
			   timestamp_type type, String *str);
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
885
void make_datetime(const DATE_TIME_FORMAT *format, const DRIZZLE_TIME *l_time,
1 by brian
clean slate
886
                   String *str);
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
887
void make_date(const DATE_TIME_FORMAT *format, const DRIZZLE_TIME *l_time,
888
               String *str);
889
void make_time(const DATE_TIME_FORMAT *format, const DRIZZLE_TIME *l_time,
890
               String *str);
891
int my_time_compare(DRIZZLE_TIME *a, DRIZZLE_TIME *b);
151 by Brian Aker
Ulonglong to uint64_t
892
uint64_t get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
1 by brian
clean slate
893
                             Item *warn_item, bool *is_null);
894
895
int test_if_number(char *str,int *res,bool allow_wildcards);
896
void change_byte(uchar *,uint,char,char);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
897
void init_read_record(READ_RECORD *info, THD *thd, Table *reg_form,
1 by brian
clean slate
898
		      SQL_SELECT *select,
899
		      int use_record_cache, bool print_errors);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
900
void init_read_record_idx(READ_RECORD *info, THD *thd, Table *table, 
1 by brian
clean slate
901
                          bool print_error, uint idx);
902
void end_read_record(READ_RECORD *info);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
903
ha_rows filesort(THD *thd, Table *form,struct st_sort_field *sortorder,
1 by brian
clean slate
904
		 uint s_length, SQL_SELECT *select,
905
		 ha_rows max_rows, bool sort_positions,
906
                 ha_rows *examined_rows);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
907
void filesort_free_buffers(Table *table, bool full);
1 by brian
clean slate
908
void change_double_for_sort(double nr,uchar *to);
152 by Brian Aker
longlong replacement
909
double my_double_round(double value, int64_t dec, bool dec_unsigned,
1 by brian
clean slate
910
                       bool truncate);
911
int get_quick_record(SQL_SELECT *select);
912
913
int calc_weekday(long daynr,bool sunday_first_day_of_week);
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
914
uint calc_week(DRIZZLE_TIME *l_time, uint week_behaviour, uint *year);
1 by brian
clean slate
915
void find_date(char *pos,uint *vek,uint flag);
916
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
917
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings);
918
ulong get_form_pos(File file, uchar *head, TYPELIB *save_names);
919
ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames,
920
		     const char *newname);
921
ulong next_io_size(ulong pos);
922
void append_unescaped(String *res, const char *pos, uint length);
923
int create_frm(THD *thd, const char *name, const char *db, const char *table,
924
               uint reclength, uchar *fileinfo,
925
	       HA_CREATE_INFO *create_info, uint keys, KEY *key_info);
926
int rename_file_ext(const char * from,const char * to,const char * ext);
927
bool check_db_name(LEX_STRING *db);
928
bool check_column_name(const char *name);
929
bool check_table_name(const char *name, uint length);
930
char *get_field(MEM_ROOT *mem, Field *field);
931
bool get_field(MEM_ROOT *mem, Field *field, class String *res);
932
char *fn_rext(char *name);
933
934
/* Conversion functions */
935
uint build_table_filename(char *buff, size_t bufflen, const char *db,
936
                          const char *table, const char *ext, uint flags);
937
938
#define MYSQL50_TABLE_NAME_PREFIX         "#mysql50#"
939
#define MYSQL50_TABLE_NAME_PREFIX_LENGTH  9
940
941
/* Flags for conversion functions. */
942
#define FN_FROM_IS_TMP  (1 << 0)
943
#define FN_TO_IS_TMP    (1 << 1)
944
#define FN_IS_TMP       (FN_FROM_IS_TMP | FN_TO_IS_TMP)
945
#define NO_FRM_RENAME   (1 << 2)
946
947
/* item_func.cc */
948
Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
949
		     LEX_STRING component);
950
int get_var_with_binlog(THD *thd, enum_sql_command sql_command,
951
                        LEX_STRING &name, user_var_entry **out_entry);
952
/* log.cc */
953
bool flush_error_log(void);
954
955
/* sql_list.cc */
956
void free_list(I_List <i_string_pair> *list);
957
void free_list(I_List <i_string> *list);
958
959
/* Some inline functions for more speed */
960
961
inline bool add_item_to_list(THD *thd, Item *item)
962
{
963
  return thd->lex->current_select->add_item_to_list(thd, item);
964
}
965
966
inline bool add_value_to_list(THD *thd, Item *value)
967
{
968
  return thd->lex->value_list.push_back(value);
969
}
970
971
inline bool add_order_to_list(THD *thd, Item *item, bool asc)
972
{
973
  return thd->lex->current_select->add_order_to_list(thd, item, asc);
974
}
975
976
inline bool add_group_to_list(THD *thd, Item *item, bool asc)
977
{
978
  return thd->lex->current_select->add_group_to_list(thd, item, asc);
979
}
980
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
981
inline void mark_as_null_row(Table *table)
1 by brian
clean slate
982
{
983
  table->null_row=1;
984
  table->status|=STATUS_NULL_ROW;
212.6.3 by Mats Kindahl
Removing deprecated functions from code and replacing them with C99 equivalents:
985
  memset(table->null_flags, 255, table->s->null_bytes);
1 by brian
clean slate
986
}
987
988
inline void table_case_convert(char * name, uint length)
989
{
990
  if (lower_case_table_names)
991
    files_charset_info->cset->casedn(files_charset_info,
992
                                     name, length, name, length);
993
}
994
995
inline const char *table_case_name(HA_CREATE_INFO *info, const char *name)
996
{
997
  return ((lower_case_table_names == 2 && info->alias) ? info->alias : name);
998
}
999
251 by Brian Aker
Cleanup around rand.
1000
inline ulong sql_rnd()
1 by brian
clean slate
1001
{
251 by Brian Aker
Cleanup around rand.
1002
  ulong tmp= (ulong) (rand() * 0xffffffff); /* make all bits random */
1003
1 by brian
clean slate
1004
  return tmp;
1005
}
1006
1007
Comp_creator *comp_eq_creator(bool invert);
1008
Comp_creator *comp_ge_creator(bool invert);
1009
Comp_creator *comp_gt_creator(bool invert);
1010
Comp_creator *comp_le_creator(bool invert);
1011
Comp_creator *comp_lt_creator(bool invert);
1012
Comp_creator *comp_ne_creator(bool invert);
1013
1014
Item * all_any_subquery_creator(Item *left_expr,
1015
				chooser_compare_func_creator cmp,
1016
				bool all,
1017
				SELECT_LEX *select_lex);
1018
243.1.8 by Jay Pipes
More cleanup and revert broken base.h
1019
/**
1020
  clean/setup table fields and map.
1021
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
1022
  @param table        Table structure pointer (which should be setup)
327.2.4 by Brian Aker
Refactoring table.h
1023
  @param table_list   TableList structure pointer (owner of Table)
243.1.8 by Jay Pipes
More cleanup and revert broken base.h
1024
  @param tablenr     table number
1025
*/
327.2.4 by Brian Aker
Refactoring table.h
1026
inline void setup_table_map(Table *table, TableList *table_list, uint tablenr)
243.1.8 by Jay Pipes
More cleanup and revert broken base.h
1027
{
1028
  table->used_fields= 0;
1029
  table->const_table= 0;
1030
  table->null_row= 0;
1031
  table->status= STATUS_NO_RECORD;
1032
  table->maybe_null= table_list->outer_join;
327.2.4 by Brian Aker
Refactoring table.h
1033
  TableList *embedding= table_list->embedding;
243.1.8 by Jay Pipes
More cleanup and revert broken base.h
1034
  while (!table->maybe_null && embedding)
1035
  {
1036
    table->maybe_null= embedding->outer_join;
1037
    embedding= embedding->embedding;
1038
  }
1039
  table->tablenr= tablenr;
1040
  table->map= (table_map) 1 << tablenr;
1041
  table->force_index= table_list->force_index;
1042
  table->covering_keys= table->s->keys_for_keyread;
1043
  table->merge_keys.clear_all();
1044
}
1045
1046
#include <drizzled/item_create.h>         /* Factory API for creating Item_* instances */
1 by brian
clean slate
1047
1048
/**
1049
  convert a hex digit into number.
1050
*/
1051
1052
inline int hexchar_to_int(char c)
1053
{
1054
  if (c <= '9' && c >= '0')
1055
    return c-'0';
1056
  c|=32;
1057
  if (c <= 'f' && c >= 'a')
1058
    return c-'a'+10;
1059
  return -1;
1060
}
1061
1062
/**
1063
  return true if the table was created explicitly.
1064
*/
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
1065
inline bool is_user_table(Table * table)
1 by brian
clean slate
1066
{
1067
  const char *name= table->s->table_name.str;
1068
  return strncmp(name, tmp_file_prefix, tmp_file_prefix_length);
1069
}
1070
1071
1072
#ifndef HAVE_LOG2
1073
/*
1074
  This will be slightly slower and perhaps a tiny bit less accurate than
1075
  doing it the IEEE754 way but log2() should be available on C99 systems.
1076
*/
1077
static inline double log2(double x)
1078
{
1079
  return (log(x) / M_LN2);
1080
}
1081
#endif
1082
1083
1084
/*
1085
  Some functions that are different in the embedded library and the normal
1086
  server
1087
*/
1088
1089
extern "C" void unireg_abort(int exit_code) __attribute__((noreturn));
1090
void kill_delayed_threads(void);
1091
bool check_stack_overrun(THD *thd, long margin, uchar *dummy);
1092
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
1093
/** 
1094
 * Used by handlers to store things in schema tables 
1095
 *
1096
 * @TODO These should be placed in an information_schema.h header
1097
 * file once the new information schema design is finalized.
1098
 */
1 by brian
clean slate
1099
#define IS_FILES_FILE_ID              0
1100
#define IS_FILES_FILE_NAME            1
1101
#define IS_FILES_FILE_TYPE            2
1102
#define IS_FILES_TABLESPACE_NAME      3
1103
#define IS_FILES_TABLE_CATALOG        4
1104
#define IS_FILES_TABLE_SCHEMA         5
1105
#define IS_FILES_TABLE_NAME           6
1106
#define IS_FILES_LOGFILE_GROUP_NAME   7
1107
#define IS_FILES_LOGFILE_GROUP_NUMBER 8
1108
#define IS_FILES_ENGINE               9
1109
#define IS_FILES_FULLTEXT_KEYS       10
1110
#define IS_FILES_DELETED_ROWS        11
1111
#define IS_FILES_UPDATE_COUNT        12
1112
#define IS_FILES_FREE_EXTENTS        13
1113
#define IS_FILES_TOTAL_EXTENTS       14
1114
#define IS_FILES_EXTENT_SIZE         15
1115
#define IS_FILES_INITIAL_SIZE        16
1116
#define IS_FILES_MAXIMUM_SIZE        17
1117
#define IS_FILES_AUTOEXTEND_SIZE     18
1118
#define IS_FILES_CREATION_TIME       19
1119
#define IS_FILES_LAST_UPDATE_TIME    20
1120
#define IS_FILES_LAST_ACCESS_TIME    21
1121
#define IS_FILES_RECOVER_TIME        22
1122
#define IS_FILES_TRANSACTION_COUNTER 23
1123
#define IS_FILES_VERSION             24
1124
#define IS_FILES_ROW_FORMAT          25
1125
#define IS_FILES_TABLE_ROWS          26
1126
#define IS_FILES_AVG_ROW_LENGTH      27
1127
#define IS_FILES_DATA_LENGTH         28
1128
#define IS_FILES_MAX_DATA_LENGTH     29
1129
#define IS_FILES_INDEX_LENGTH        30
1130
#define IS_FILES_DATA_FREE           31
1131
#define IS_FILES_CREATE_TIME         32
1132
#define IS_FILES_UPDATE_TIME         33
1133
#define IS_FILES_CHECK_TIME          34
1134
#define IS_FILES_CHECKSUM            35
1135
#define IS_FILES_STATUS              36
1136
#define IS_FILES_EXTRA               37
1137
243.1.17 by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.)
1138
#endif /* DRIZZLE_SERVER_SERVER_INCLUDES_H */