~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/server_includes.h

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
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
/* 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 */
19
15
 
20
16
/**
21
17
  @file
23
19
  @details
24
20
  Mostly this file is used in the server. But a little part of it is used in
25
21
  mysqlbinlog too (definition of SELECT_DISTINCT and others).
 
22
  The consequence is that 90% of the file is wrapped in \#ifndef DRIZZLE_CLIENT,
 
23
  except the part which must be in the server and in the client.
26
24
 
27
25
  @TODO Name this file better. "priv" could mean private, privileged, privileges.
 
26
 
 
27
  @TODO Get rid of the DRIZZLE_CLIENT and DRIZZLE_SERVER conditionals
28
28
*/
29
29
 
30
30
#ifndef DRIZZLE_SERVER_SERVER_INCLUDES_H
64
64
/* sql_repl.cc */
65
65
void write_bin_log(THD *thd, bool clear_error,
66
66
                   char const *query, ulong query_length);
67
 
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, uint16_t flags);
 
67
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags);
68
68
void mysql_client_binlog_statement(THD *thd);
69
69
 
70
70
/* sql_rename.cc */
74
74
                      bool skip_error);
75
75
 
76
76
/* sql_parse.cc */
77
 
void mysql_parse(THD *thd, const char *inBuf, uint32_t length,
 
77
void mysql_parse(THD *thd, const char *inBuf, uint length,
78
78
                 const char ** semicolon);
79
79
 
80
 
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint32_t length);
 
80
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
81
81
 
82
82
 
83
83
bool is_update_query(enum enum_sql_command command);
84
84
 
85
 
bool alloc_query(THD *thd, const char *packet, uint32_t packet_length);
 
85
bool alloc_query(THD *thd, const char *packet, uint packet_length);
86
86
 
87
87
void mysql_reset_thd_for_next_command(THD *thd);
88
88
 
97
97
bool do_command(THD *thd);
98
98
 
99
99
bool dispatch_command(enum enum_server_command command, THD *thd,
100
 
                      char* packet, uint32_t packet_length);
 
100
                      char* packet, uint packet_length);
101
101
 
102
102
void log_slow_statement(THD *thd);
103
103
 
108
108
 
109
109
bool check_simple_select();
110
110
 
 
111
/* @TODO <UNUSED> */
111
112
void mysql_init_select(LEX *lex);
112
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);
 
118
bool check_dup(const char *db, const char *name, TableList *tables);
 
119
bool check_table_access(THD *thd, ulong want_access, TableList *tables,
 
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);
 
133
/* </UNUSED> */
113
134
 
114
135
/* sql_base.cc */
115
136
void table_cache_free(void);
117
138
bool table_def_init(void);
118
139
void table_def_free(void);
119
140
void assign_new_table_id(TABLE_SHARE *share);
120
 
uint32_t cached_open_tables(void);
121
 
uint32_t cached_table_definitions(void);
 
141
uint cached_open_tables(void);
 
142
uint cached_table_definitions(void);
122
143
 
123
144
/* drizzled.cc */
124
145
void kill_mysql(void);
125
 
void close_connection(THD *thd, uint32_t errcode, bool lock);
 
146
void close_connection(THD *thd, uint errcode, bool lock);
126
147
 
127
148
/* sql_select.cc */
128
149
Table *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
130
151
/* handler.cc */
131
152
bool mysql_xa_recover(THD *thd);
132
153
 
133
 
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
 
154
SORT_FIELD * make_unireg_sortorder(order_st *order, uint *length,
134
155
                                  SORT_FIELD *sortorder);
135
156
int setup_order(THD *thd, Item **ref_pointer_array, TableList *tables,
136
157
                List<Item> &fields, List <Item> &all_fields, order_st *order);
143
164
bool handle_select(THD *thd, LEX *lex, select_result *result,
144
165
                   ulong setup_tables_done_option);
145
166
bool mysql_select(THD *thd, Item ***rref_pointer_array,
146
 
                  TableList *tables, uint32_t wild_num,  List<Item> &list,
147
 
                  COND *conds, uint32_t og_num, order_st *order, order_st *group,
 
167
                  TableList *tables, uint wild_num,  List<Item> &list,
 
168
                  COND *conds, uint og_num, order_st *order, order_st *group,
148
169
                  Item *having, order_st *proc_param, uint64_t select_type, 
149
170
                  select_result *result, SELECT_LEX_UNIT *unit, 
150
171
                  SELECT_LEX *select_lex);
166
187
                        bool group, bool modify_item,
167
188
                        bool table_cant_handle_bit_fields,
168
189
                        bool make_copy_field,
169
 
                        uint32_t convert_blob_length);
 
190
                        uint convert_blob_length);
170
191
void sp_prepare_create_field(THD *thd, Create_field *sql_field);
171
192
int prepare_create_field(Create_field *sql_field, 
172
 
                         uint32_t *blob_columns, 
 
193
                         uint *blob_columns, 
173
194
                         int *timestamps, int *timestamps_with_niladic,
174
195
                         int64_t table_flags);
175
196
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
176
197
                        HA_CREATE_INFO *create_info,
177
198
                        Alter_info *alter_info,
178
 
                        bool tmp_table, uint32_t select_field_count);
 
199
                        bool tmp_table, uint select_field_count);
179
200
bool mysql_create_table_no_lock(THD *thd, const char *db,
180
201
                                const char *table_name,
181
202
                                HA_CREATE_INFO *create_info,
182
203
                                Alter_info *alter_info,
183
 
                                bool tmp_table, uint32_t select_field_count);
 
204
                                bool tmp_table, uint select_field_count);
184
205
 
185
206
bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
186
207
                       HA_CREATE_INFO *create_info,
187
208
                       TableList *table_list,
188
209
                       Alter_info *alter_info,
189
 
                       uint32_t order_num, order_st *order, bool ignore);
 
210
                       uint order_num, order_st *order, bool ignore);
190
211
bool mysql_recreate_table(THD *thd, TableList *table_list);
191
212
bool mysql_create_like_table(THD *thd, TableList *table,
192
213
                             TableList *src_table,
193
214
                             HA_CREATE_INFO *create_info);
194
215
bool mysql_rename_table(handlerton *base, const char *old_db,
195
216
                        const char * old_name, const char *new_db,
196
 
                        const char * new_name, uint32_t flags);
 
217
                        const char * new_name, uint flags);
197
218
bool mysql_prepare_update(THD *thd, TableList *table_list,
198
 
                          Item **conds, uint32_t order_num, order_st *order);
 
219
                          Item **conds, uint order_num, order_st *order);
199
220
int mysql_update(THD *thd,TableList *tables,List<Item> &fields,
200
221
                 List<Item> &values,COND *conds,
201
 
                 uint32_t order_num, order_st *order, ha_rows limit,
 
222
                 uint order_num, order_st *order, ha_rows limit,
202
223
                 enum enum_duplicates handle_duplicates, bool ignore);
203
224
bool mysql_multi_update(THD *thd, TableList *table_list,
204
225
                        List<Item> *fields, List<Item> *values,
223
244
                  SQL_LIST *order, ha_rows rows, uint64_t options,
224
245
                  bool reset_auto_increment);
225
246
bool mysql_truncate(THD *thd, TableList *table_list, bool dont_send_ok);
226
 
uint32_t create_table_def_key(THD *thd, char *key, TableList *table_list,
 
247
uint create_table_def_key(THD *thd, char *key, TableList *table_list,
227
248
                          bool tmp_table);
228
249
TABLE_SHARE *get_table_share(THD *thd, TableList *table_list, char *key,
229
 
                             uint32_t key_length, uint32_t db_flags, int *error);
 
250
                             uint key_length, uint db_flags, int *error);
230
251
void release_table_share(TABLE_SHARE *share, enum release_type type);
231
252
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
232
253
Table *open_ltable(THD *thd, TableList *table_list, thr_lock_type update,
233
 
                   uint32_t lock_flags);
234
 
Table *open_table(THD *thd, TableList *table_list, bool *refresh, uint32_t flags);
 
254
                   uint lock_flags);
 
255
Table *open_table(THD *thd, TableList *table_list, bool *refresh, uint flags);
235
256
bool name_lock_locked_table(THD *thd, TableList *tables);
236
257
bool reopen_name_locked_table(THD* thd, TableList* table_list, bool link_in);
237
258
Table *table_cache_insert_placeholder(THD *thd, const char *key,
238
 
                                      uint32_t key_length);
 
259
                                      uint key_length);
239
260
bool lock_table_name_if_not_cached(THD *thd, const char *db,
240
261
                                   const char *table_name, Table **table);
241
262
Table *find_locked_table(THD *thd, const char *db,const char *table_name);
248
269
                                      const char *table_name);
249
270
void close_handle_and_leave_table_as_lock(Table *table);
250
271
bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
251
 
                  uint32_t db_stat, uint32_t prgflag,
252
 
                  uint32_t ha_open_flags, Table *outparam,
 
272
                  uint db_stat, uint prgflag,
 
273
                  uint ha_open_flags, Table *outparam,
253
274
                  TableList *table_desc, MEM_ROOT *mem_root);
254
275
bool wait_for_tables(THD *thd);
255
276
bool table_is_used(Table *table, bool wait_for_name_lock);
270
291
                     bool check_privileges, bool register_tree_change);
271
292
Field *
272
293
find_field_in_table_ref(THD *thd, TableList *table_list,
273
 
                        const char *name, uint32_t length,
 
294
                        const char *name, uint length,
274
295
                        const char *item_name, const char *db_name,
275
296
                        const char *table_name, Item **ref,
276
297
                        bool check_privileges, bool allow_rowid,
277
 
                        uint32_t *cached_field_index_ptr,
 
298
                        uint *cached_field_index_ptr,
278
299
                        bool register_tree_change, TableList **actual_table);
279
300
Field *
280
 
find_field_in_table(THD *thd, Table *table, const char *name, uint32_t length,
281
 
                    bool allow_rowid, uint32_t *cached_field_index_ptr);
 
301
find_field_in_table(THD *thd, Table *table, const char *name, uint length,
 
302
                    bool allow_rowid, uint *cached_field_index_ptr);
282
303
Field *
283
304
find_field_in_table_sef(Table *table, const char *name);
284
305
 
323
344
 
324
345
/* sql_base.cc */
325
346
#define TMP_TABLE_KEY_EXTRA 8
326
 
void set_item_name(Item *item,char *pos,uint32_t length);
 
347
void set_item_name(Item *item,char *pos,uint length);
327
348
bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types type,
328
349
                       char *length, char *decimal,
329
 
                       uint32_t type_modifier,
 
350
                       uint type_modifier,
330
351
                       enum column_format_type column_format,
331
352
                       Item *default_value, Item *on_update_value,
332
353
                       LEX_STRING *comment,
334
355
                       const CHARSET_INFO * const cs);
335
356
Create_field * new_create_field(THD *thd, char *field_name, enum_field_types type,
336
357
                                char *length, char *decimals,
337
 
                                uint32_t type_modifier, 
 
358
                                uint type_modifier, 
338
359
                                Item *default_value, Item *on_update_value,
339
360
                                LEX_STRING *comment, char *change, 
340
361
                                List<String> *interval_list, CHARSET_INFO *cs);
385
406
  RESOLVED_WITH_NO_ALIAS,
386
407
  RESOLVED_AGAINST_ALIAS
387
408
};
388
 
Item ** find_item_in_list(Item *item, List<Item> &items, uint32_t *counter,
 
409
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,
389
410
                          find_item_error_report_type report_error,
390
411
                          enum_resolution_type *resolution);
391
412
bool get_key_map_from_key_list(key_map *map, Table *table,
403
424
                                   TableList **leaves, 
404
425
                                   bool select_insert);
405
426
int setup_wild(THD *thd, TableList *tables, List<Item> &fields,
406
 
               List<Item> *sum_func_list, uint32_t wild_num);
 
427
               List<Item> *sum_func_list, uint wild_num);
407
428
bool setup_fields(THD *thd, Item** ref_pointer_array,
408
429
                  List<Item> &item, enum_mark_columns mark_used_columns,
409
430
                  List<Item> *sum_func_list, bool allow_sum_func);
424
445
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
425
446
void wait_for_condition(THD *thd, pthread_mutex_t *mutex,
426
447
                        pthread_cond_t *cond);
427
 
int open_tables(THD *thd, TableList **tables, uint32_t *counter, uint32_t flags);
 
448
int open_tables(THD *thd, TableList **tables, uint *counter, uint flags);
428
449
/* open_and_lock_tables with optional derived handling */
429
450
int open_and_lock_tables_derived(THD *thd, TableList *tables, bool derived);
430
451
/* simple open_and_lock_tables without derived handling */
440
461
/* simple open_and_lock_tables without derived handling for single table */
441
462
Table *open_n_lock_single_table(THD *thd, TableList *table_l,
442
463
                                thr_lock_type lock_type);
443
 
bool open_normal_and_derived_tables(THD *thd, TableList *tables, uint32_t flags);
444
 
int lock_tables(THD *thd, TableList *tables, uint32_t counter, bool *need_reopen);
 
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);
445
466
int decide_logging_format(THD *thd, TableList *tables);
446
467
Table *open_temporary_table(THD *thd, const char *path, const char *db,
447
468
                            const char *table_name, bool link_in_list,
477
498
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
478
499
#define RTFC_CHECK_KILLED_FLAG      0x0004
479
500
bool remove_table_from_cache(THD *thd, const char *db, const char *table,
480
 
                             uint32_t flags);
 
501
                             uint flags);
481
502
 
482
503
#define NORMAL_PART_NAME 0
483
504
#define TEMP_PART_NAME 1
532
553
/* sql_test.cc */
533
554
void print_where(COND *cond,const char *info, enum_query_type query_type);
534
555
void print_cached_tables(void);
535
 
void TEST_filesort(SORT_FIELD *sortorder,uint32_t s_length);
536
 
void print_plan(JOIN* join,uint32_t idx, double record_count, double read_time,
 
556
void TEST_filesort(SORT_FIELD *sortorder,uint s_length);
 
557
void print_plan(JOIN* join,uint idx, double record_count, double read_time,
537
558
                double current_read_time, const char *info);
538
559
void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array);
539
560
void dump_TableList_graph(SELECT_LEX *select_lex, TableList* tl);
540
561
void mysql_print_status();
541
562
 
542
563
/* key.cc */
543
 
int find_ref_key(KEY *key, uint32_t key_count, unsigned char *record, Field *field,
544
 
                 uint32_t *key_length, uint32_t *keypart);
545
 
void key_copy(unsigned char *to_key, unsigned char *from_record, KEY *key_info, uint32_t key_length);
546
 
void key_restore(unsigned char *to_record, unsigned char *from_key, KEY *key_info,
 
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,
547
568
                 uint16_t key_length);
548
 
void key_zero_nulls(unsigned char *tuple, KEY *key_info);
549
 
bool key_cmp_if_same(Table *form,const unsigned char *key,uint32_t index,uint32_t key_length);
550
 
void key_unpack(String *to,Table *form,uint32_t index);
551
 
bool is_key_used(Table *table, uint32_t idx, const MY_BITMAP *fields);
552
 
int key_cmp(KEY_PART_INFO *key_part, const unsigned char *key, uint32_t key_length);
553
 
extern "C" int key_rec_cmp(void *key_info, unsigned char *a, unsigned char *b);
 
569
void key_zero_nulls(uchar *tuple, KEY *key_info);
 
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);
 
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);
554
575
 
555
576
bool init_errmessage(void);
556
577
File open_binlog(IO_CACHE *log, const char *log_file_name,
568
589
 
569
590
/* item_func.cc */
570
591
extern bool check_reserved_words(LEX_STRING *name);
571
 
extern enum_field_types agg_field_type(Item **items, uint32_t nitems);
 
592
extern enum_field_types agg_field_type(Item **items, uint nitems);
572
593
 
573
594
/* strfunc.cc */
574
 
uint64_t find_set(TYPELIB *lib, const char *x, uint32_t length, const CHARSET_INFO * const cs,
575
 
                   char **err_pos, uint32_t *err_len, bool *set_warning);
576
 
uint32_t find_type(const TYPELIB *lib, const char *find, uint32_t length,
 
595
uint64_t find_set(TYPELIB *lib, const char *x, uint length, const CHARSET_INFO * const cs,
 
596
                   char **err_pos, uint *err_len, bool *set_warning);
 
597
uint find_type(const TYPELIB *lib, const char *find, uint length,
577
598
               bool part_match);
578
 
uint32_t find_type2(const TYPELIB *lib, const char *find, uint32_t length,
 
599
uint find_type2(const TYPELIB *lib, const char *find, uint length,
579
600
                const CHARSET_INFO *cs);
580
601
void unhex_type2(TYPELIB *lib);
581
 
uint32_t check_word(TYPELIB *lib, const char *val, const char *end,
 
602
uint check_word(TYPELIB *lib, const char *val, const char *end,
582
603
                const char **end_of_word);
583
604
int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
584
605
                         const CHARSET_INFO * const cs);
585
606
 
586
607
 
587
 
bool is_keyword(const char *name, uint32_t len);
 
608
bool is_keyword(const char *name, uint len);
588
609
 
589
610
#define MY_DB_OPT_FILE "db.opt"
590
611
bool my_database_names_init(void);
637
658
extern ulong max_connections,max_connect_errors, connect_timeout;
638
659
extern bool slave_allow_batching;
639
660
extern ulong slave_net_timeout, slave_trans_retries;
640
 
extern uint32_t max_user_connections;
 
661
extern uint max_user_connections;
641
662
extern ulong what_to_log,flush_time;
642
663
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
643
664
extern ulong max_binlog_size, max_relay_log_size;
650
671
extern ulong tc_log_page_waits;
651
672
extern bool relay_log_purge;
652
673
extern bool opt_innodb_safe_binlog, opt_innodb;
653
 
extern uint32_t test_flags,select_errors,ha_open_options;
654
 
extern uint32_t protocol_version, mysqld_port, dropping_tables;
655
 
extern uint32_t delay_key_write_options;
 
674
extern uint test_flags,select_errors,ha_open_options;
 
675
extern uint protocol_version, mysqld_port, dropping_tables;
 
676
extern uint delay_key_write_options;
656
677
extern bool opt_endinfo, using_udf_functions;
657
678
extern bool locked_in_memory;
658
679
extern bool opt_using_transactions;
664
685
extern bool opt_log_queries_not_using_indexes;
665
686
extern bool opt_character_set_client_handshake;
666
687
extern bool volatile abort_loop, shutdown_in_progress;
667
 
extern uint32_t volatile thread_count, thread_running, global_read_lock;
668
 
extern uint32_t connection_count;
 
688
extern uint volatile thread_count, thread_running, global_read_lock;
 
689
extern uint connection_count;
669
690
extern bool opt_sql_bin_update;
670
691
extern bool opt_safe_user_create;
671
692
extern bool opt_no_mix_types;
681
702
extern bool opt_log_slow_slave_statements;
682
703
extern bool opt_noacl;
683
704
extern bool opt_old_style_user_limits;
684
 
extern uint32_t opt_crash_binlog_innodb;
 
705
extern uint opt_crash_binlog_innodb;
685
706
extern char *default_tz_name;
686
707
extern char *opt_logname, *opt_slow_logname;
687
708
extern const char *log_output_str;
725
746
extern scheduler_functions thread_scheduler;
726
747
extern TYPELIB thread_handling_typelib;
727
748
extern uint8_t uc_update_queries[SQLCOM_END+1];
728
 
extern uint32_t sql_command_flags[];
 
749
extern uint sql_command_flags[];
729
750
extern TYPELIB log_output_typelib;
730
751
 
731
752
/* optional things, have_* variables */
740
761
 
741
762
extern pthread_t signal_thread;
742
763
 
743
 
DRIZZLE_LOCK *mysql_lock_tables(THD *thd, Table **table, uint32_t count,
744
 
                              uint32_t flags, bool *need_reopen);
 
764
DRIZZLE_LOCK *mysql_lock_tables(THD *thd, Table **table, uint count,
 
765
                              uint flags, bool *need_reopen);
745
766
/* mysql_lock_tables() and open_table() flags bits */
746
767
#define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_LOCK      0x0001
747
768
#define DRIZZLE_LOCK_IGNORE_FLUSH                 0x0002
752
773
 
753
774
void mysql_unlock_tables(THD *thd, DRIZZLE_LOCK *sql_lock);
754
775
void mysql_unlock_read_tables(THD *thd, DRIZZLE_LOCK *sql_lock);
755
 
void mysql_unlock_some_tables(THD *thd, Table **table,uint32_t count);
 
776
void mysql_unlock_some_tables(THD *thd, Table **table,uint count);
756
777
void mysql_lock_remove(THD *thd, DRIZZLE_LOCK *locked,Table *table,
757
778
                       bool always_unlock);
758
779
void mysql_lock_abort(THD *thd, Table *table, bool upgrade_lock);
787
808
bool lock_table_names_exclusively(THD *thd, TableList *table_list);
788
809
bool is_table_name_exclusively_locked_by_this_thread(THD *thd, 
789
810
                                                     TableList *table_list);
790
 
bool is_table_name_exclusively_locked_by_this_thread(THD *thd, unsigned char *key,
 
811
bool is_table_name_exclusively_locked_by_this_thread(THD *thd, uchar *key,
791
812
                                                     int key_length);
792
813
 
793
814
 
799
820
                      const char *db, const char *table,
800
821
                      HA_CREATE_INFO *create_info,
801
822
                      List<Create_field> &create_field,
802
 
                      uint32_t key_count,KEY *key_info,handler *db_type);
 
823
                      uint key_count,KEY *key_info,handler *db_type);
803
824
int rea_create_table(THD *thd, const char *path,
804
825
                     const char *db, const char *table_name,
805
826
                     HA_CREATE_INFO *create_info,
806
827
                     List<Create_field> &create_field,
807
 
                     uint32_t key_count,KEY *key_info,
 
828
                     uint key_count,KEY *key_info,
808
829
                     handler *file);
809
 
int format_number(uint32_t inputflag,uint32_t max_length,char * pos,uint32_t length,
 
830
int format_number(uint inputflag,uint max_length,char * pos,uint length,
810
831
                  char * *errpos);
811
832
 
812
833
/* table.cc */
813
834
TABLE_SHARE *alloc_table_share(TableList *table_list, char *key,
814
 
                               uint32_t key_length);
 
835
                               uint key_length);
815
836
void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
816
 
                          uint32_t key_length,
 
837
                          uint key_length,
817
838
                          const char *table_name, const char *path);
818
839
void free_table_share(TABLE_SHARE *share);
819
 
int open_table_def(THD *thd, TABLE_SHARE *share, uint32_t db_flags);
 
840
int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags);
820
841
void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg);
821
842
int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
822
 
                          uint32_t db_stat, uint32_t prgflag, uint32_t ha_open_flags,
 
843
                          uint db_stat, uint prgflag, uint ha_open_flags,
823
844
                          Table *outparam, open_table_mode open_mode);
824
 
int readfrm(const char *name, unsigned char **data, size_t *length);
825
 
int writefrm(const char* name, const unsigned char* data, size_t len);
 
845
int readfrm(const char *name, uchar **data, size_t *length);
 
846
int writefrm(const char* name, const uchar* data, size_t len);
826
847
int closefrm(Table *table, bool free_share);
827
 
int read_string(File file, unsigned char* *to, size_t length);
 
848
int read_string(File file, uchar* *to, size_t length);
828
849
void free_blobs(Table *table);
829
850
int set_zone(int nr,int min_zone,int max_zone);
830
851
ulong convert_period_to_month(ulong period);
831
852
ulong convert_month_to_period(ulong month);
832
 
void get_date_from_daynr(long daynr,uint32_t *year, uint32_t *month,
833
 
                         uint32_t *day);
 
853
void get_date_from_daynr(long daynr,uint *year, uint *month,
 
854
                         uint *day);
834
855
my_time_t TIME_to_timestamp(THD *thd, const DRIZZLE_TIME *t, bool *not_exist);
835
 
bool str_to_time_with_warn(const char *str,uint32_t length,DRIZZLE_TIME *l_time);
836
 
enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str, uint32_t length,
837
 
                                         DRIZZLE_TIME *l_time, uint32_t flags);
 
856
bool str_to_time_with_warn(const char *str,uint length,DRIZZLE_TIME *l_time);
 
857
timestamp_type str_to_datetime_with_warn(const char *str, uint length,
 
858
                                         DRIZZLE_TIME *l_time, uint flags);
838
859
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
839
860
void calc_time_from_sec(DRIZZLE_TIME *to, long seconds, long microseconds);
840
861
 
841
862
void make_truncated_value_warning(THD *thd, DRIZZLE_ERROR::enum_warning_level level,
842
863
                                  const char *str_val,
843
 
                                  uint32_t str_length, enum enum_drizzle_timestamp_type time_type,
 
864
                                  uint str_length, timestamp_type time_type,
844
865
                                  const char *field_name);
845
866
 
846
867
bool date_add_interval(DRIZZLE_TIME *ltime, interval_type int_type, INTERVAL interval);
849
870
 
850
871
extern LEX_STRING interval_type_to_name[];
851
872
 
852
 
extern DATE_TIME_FORMAT *date_time_format_make(enum enum_drizzle_timestamp_type format_type,
 
873
extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type,
853
874
                                               const char *format_str,
854
 
                                               uint32_t format_length);
 
875
                                               uint format_length);
855
876
extern DATE_TIME_FORMAT *date_time_format_copy(THD *thd,
856
877
                                               DATE_TIME_FORMAT *format);
857
878
const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
858
 
                                                             enum enum_drizzle_timestamp_type type);
 
879
                                     timestamp_type type);
859
880
extern bool make_date_time(DATE_TIME_FORMAT *format, DRIZZLE_TIME *l_time,
860
 
                                             enum enum_drizzle_timestamp_type type, String *str);
 
881
                           timestamp_type type, String *str);
861
882
void make_datetime(const DATE_TIME_FORMAT *format, const DRIZZLE_TIME *l_time,
862
883
                   String *str);
863
884
void make_date(const DATE_TIME_FORMAT *format, const DRIZZLE_TIME *l_time,
869
890
                             Item *warn_item, bool *is_null);
870
891
 
871
892
int test_if_number(char *str,int *res,bool allow_wildcards);
872
 
void change_byte(unsigned char *,uint,char,char);
 
893
void change_byte(uchar *,uint,char,char);
873
894
void init_read_record(READ_RECORD *info, THD *thd, Table *reg_form,
874
895
                      SQL_SELECT *select,
875
896
                      int use_record_cache, bool print_errors);
876
897
void init_read_record_idx(READ_RECORD *info, THD *thd, Table *table, 
877
 
                          bool print_error, uint32_t idx);
 
898
                          bool print_error, uint idx);
878
899
void end_read_record(READ_RECORD *info);
879
900
ha_rows filesort(THD *thd, Table *form,struct st_sort_field *sortorder,
880
 
                 uint32_t s_length, SQL_SELECT *select,
 
901
                 uint s_length, SQL_SELECT *select,
881
902
                 ha_rows max_rows, bool sort_positions,
882
903
                 ha_rows *examined_rows);
883
904
void filesort_free_buffers(Table *table, bool full);
884
 
void change_double_for_sort(double nr,unsigned char *to);
 
905
void change_double_for_sort(double nr,uchar *to);
885
906
double my_double_round(double value, int64_t dec, bool dec_unsigned,
886
907
                       bool truncate);
887
908
int get_quick_record(SQL_SELECT *select);
888
909
 
889
910
int calc_weekday(long daynr,bool sunday_first_day_of_week);
890
 
uint32_t calc_week(DRIZZLE_TIME *l_time, uint32_t week_behaviour, uint32_t *year);
891
 
void find_date(char *pos,uint32_t *vek,uint32_t flag);
 
911
uint calc_week(DRIZZLE_TIME *l_time, uint week_behaviour, uint *year);
 
912
void find_date(char *pos,uint *vek,uint flag);
892
913
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
893
914
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings);
894
 
ulong get_form_pos(File file, unsigned char *head, TYPELIB *save_names);
895
 
ulong make_new_entry(File file,unsigned char *fileinfo,TYPELIB *formnames,
 
915
ulong get_form_pos(File file, uchar *head, TYPELIB *save_names);
 
916
ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames,
896
917
                     const char *newname);
897
918
ulong next_io_size(ulong pos);
898
 
void append_unescaped(String *res, const char *pos, uint32_t length);
 
919
void append_unescaped(String *res, const char *pos, uint length);
899
920
int create_frm(THD *thd, const char *name, const char *db, const char *table,
900
 
               uint32_t reclength, unsigned char *fileinfo,
901
 
               HA_CREATE_INFO *create_info, uint32_t keys, KEY *key_info);
 
921
               uint reclength, uchar *fileinfo,
 
922
               HA_CREATE_INFO *create_info, uint keys, KEY *key_info);
902
923
int rename_file_ext(const char * from,const char * to,const char * ext);
903
924
bool check_db_name(LEX_STRING *db);
904
925
bool check_column_name(const char *name);
905
 
bool check_table_name(const char *name, uint32_t length);
 
926
bool check_table_name(const char *name, uint length);
906
927
char *get_field(MEM_ROOT *mem, Field *field);
907
928
bool get_field(MEM_ROOT *mem, Field *field, class String *res);
908
929
char *fn_rext(char *name);
909
930
 
910
931
/* Conversion functions */
911
 
uint32_t build_table_filename(char *buff, size_t bufflen, const char *db,
912
 
                          const char *table, const char *ext, uint32_t flags);
 
932
uint build_table_filename(char *buff, size_t bufflen, const char *db,
 
933
                          const char *table, const char *ext, uint flags);
913
934
 
914
935
#define MYSQL50_TABLE_NAME_PREFIX         "#mysql50#"
915
936
#define MYSQL50_TABLE_NAME_PREFIX_LENGTH  9
961
982
  memset(table->null_flags, 255, table->s->null_bytes);
962
983
}
963
984
 
964
 
inline void table_case_convert(char * name, uint32_t length)
 
985
inline void table_case_convert(char * name, uint length)
965
986
{
966
987
  if (lower_case_table_names)
967
988
    files_charset_info->cset->casedn(files_charset_info,
999
1020
  @param table_list   TableList structure pointer (owner of Table)
1000
1021
  @param tablenr     table number
1001
1022
*/
1002
 
inline void setup_table_map(Table *table, TableList *table_list, uint32_t tablenr)
 
1023
inline void setup_table_map(Table *table, TableList *table_list, uint tablenr)
1003
1024
{
1004
1025
  table->used_fields= 0;
1005
1026
  table->const_table= 0;
1035
1056
  return -1;
1036
1057
}
1037
1058
 
 
1059
/**
 
1060
  return true if the table was created explicitly.
 
1061
*/
 
1062
inline bool is_user_table(Table * table)
 
1063
{
 
1064
  const char *name= table->s->table_name.str;
 
1065
  return strncmp(name, tmp_file_prefix, tmp_file_prefix_length);
 
1066
}
 
1067
 
 
1068
 
 
1069
#ifndef HAVE_LOG2
 
1070
/*
 
1071
  This will be slightly slower and perhaps a tiny bit less accurate than
 
1072
  doing it the IEEE754 way but log2() should be available on C99 systems.
 
1073
*/
 
1074
static inline double log2(double x)
 
1075
{
 
1076
  return (log(x) / M_LN2);
 
1077
}
 
1078
#endif
 
1079
 
 
1080
 
1038
1081
/*
1039
1082
  Some functions that are different in the embedded library and the normal
1040
1083
  server
1042
1085
 
1043
1086
extern "C" void unireg_abort(int exit_code) __attribute__((noreturn));
1044
1087
void kill_delayed_threads(void);
1045
 
bool check_stack_overrun(THD *thd, long margin, unsigned char *dummy);
 
1088
bool check_stack_overrun(THD *thd, long margin, uchar *dummy);
 
1089
 
 
1090
/** 
 
1091
 * Used by handlers to store things in schema tables 
 
1092
 *
 
1093
 * @TODO These should be placed in an information_schema.h header
 
1094
 * file once the new information schema design is finalized.
 
1095
 */
 
1096
#define IS_FILES_FILE_ID              0
 
1097
#define IS_FILES_FILE_NAME            1
 
1098
#define IS_FILES_FILE_TYPE            2
 
1099
#define IS_FILES_TABLESPACE_NAME      3
 
1100
#define IS_FILES_TABLE_CATALOG        4
 
1101
#define IS_FILES_TABLE_SCHEMA         5
 
1102
#define IS_FILES_TABLE_NAME           6
 
1103
#define IS_FILES_LOGFILE_GROUP_NAME   7
 
1104
#define IS_FILES_LOGFILE_GROUP_NUMBER 8
 
1105
#define IS_FILES_ENGINE               9
 
1106
#define IS_FILES_FULLTEXT_KEYS       10
 
1107
#define IS_FILES_DELETED_ROWS        11
 
1108
#define IS_FILES_UPDATE_COUNT        12
 
1109
#define IS_FILES_FREE_EXTENTS        13
 
1110
#define IS_FILES_TOTAL_EXTENTS       14
 
1111
#define IS_FILES_EXTENT_SIZE         15
 
1112
#define IS_FILES_INITIAL_SIZE        16
 
1113
#define IS_FILES_MAXIMUM_SIZE        17
 
1114
#define IS_FILES_AUTOEXTEND_SIZE     18
 
1115
#define IS_FILES_CREATION_TIME       19
 
1116
#define IS_FILES_LAST_UPDATE_TIME    20
 
1117
#define IS_FILES_LAST_ACCESS_TIME    21
 
1118
#define IS_FILES_RECOVER_TIME        22
 
1119
#define IS_FILES_TRANSACTION_COUNTER 23
 
1120
#define IS_FILES_VERSION             24
 
1121
#define IS_FILES_ROW_FORMAT          25
 
1122
#define IS_FILES_TABLE_ROWS          26
 
1123
#define IS_FILES_AVG_ROW_LENGTH      27
 
1124
#define IS_FILES_DATA_LENGTH         28
 
1125
#define IS_FILES_MAX_DATA_LENGTH     29
 
1126
#define IS_FILES_INDEX_LENGTH        30
 
1127
#define IS_FILES_DATA_FREE           31
 
1128
#define IS_FILES_CREATE_TIME         32
 
1129
#define IS_FILES_UPDATE_TIME         33
 
1130
#define IS_FILES_CHECK_TIME          34
 
1131
#define IS_FILES_CHECKSUM            35
 
1132
#define IS_FILES_STATUS              36
 
1133
#define IS_FILES_EXTRA               37
1046
1134
 
1047
1135
#endif /* DRIZZLE_SERVER_SERVER_INCLUDES_H */