79
void mysql_parse(THD *thd, const char *inBuf, uint length,
79
void mysql_parse(THD *thd, const char *inBuf, uint32_t length,
80
80
const char ** semicolon);
82
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
82
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint32_t length);
85
85
bool is_update_query(enum enum_sql_command command);
87
bool alloc_query(THD *thd, const char *packet, uint packet_length);
87
bool alloc_query(THD *thd, const char *packet, uint32_t packet_length);
89
89
void mysql_reset_thd_for_next_command(THD *thd);
140
140
bool table_def_init(void);
141
141
void table_def_free(void);
142
142
void assign_new_table_id(TABLE_SHARE *share);
143
uint cached_open_tables(void);
144
uint cached_table_definitions(void);
143
uint32_t cached_open_tables(void);
144
uint32_t cached_table_definitions(void);
146
146
/* drizzled.cc */
147
147
void kill_mysql(void);
148
void close_connection(THD *thd, uint errcode, bool lock);
148
void close_connection(THD *thd, uint32_t errcode, bool lock);
150
150
/* sql_select.cc */
151
151
Table *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
154
154
bool mysql_xa_recover(THD *thd);
156
SORT_FIELD * make_unireg_sortorder(order_st *order, uint *length,
156
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
157
157
SORT_FIELD *sortorder);
158
158
int setup_order(THD *thd, Item **ref_pointer_array, TableList *tables,
159
159
List<Item> &fields, List <Item> &all_fields, order_st *order);
166
166
bool handle_select(THD *thd, LEX *lex, select_result *result,
167
167
ulong setup_tables_done_option);
168
168
bool mysql_select(THD *thd, Item ***rref_pointer_array,
169
TableList *tables, uint wild_num, List<Item> &list,
170
COND *conds, uint og_num, order_st *order, order_st *group,
169
TableList *tables, uint32_t wild_num, List<Item> &list,
170
COND *conds, uint32_t og_num, order_st *order, order_st *group,
171
171
Item *having, order_st *proc_param, uint64_t select_type,
172
172
select_result *result, SELECT_LEX_UNIT *unit,
173
173
SELECT_LEX *select_lex);
189
189
bool group, bool modify_item,
190
190
bool table_cant_handle_bit_fields,
191
191
bool make_copy_field,
192
uint convert_blob_length);
192
uint32_t convert_blob_length);
193
193
void sp_prepare_create_field(THD *thd, Create_field *sql_field);
194
194
int prepare_create_field(Create_field *sql_field,
195
uint32_t *blob_columns,
196
196
int *timestamps, int *timestamps_with_niladic,
197
197
int64_t table_flags);
198
198
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
199
199
HA_CREATE_INFO *create_info,
200
200
Alter_info *alter_info,
201
bool tmp_table, uint select_field_count);
201
bool tmp_table, uint32_t select_field_count);
202
202
bool mysql_create_table_no_lock(THD *thd, const char *db,
203
203
const char *table_name,
204
204
HA_CREATE_INFO *create_info,
205
205
Alter_info *alter_info,
206
bool tmp_table, uint select_field_count);
206
bool tmp_table, uint32_t select_field_count);
208
208
bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
209
209
HA_CREATE_INFO *create_info,
210
210
TableList *table_list,
211
211
Alter_info *alter_info,
212
uint order_num, order_st *order, bool ignore);
212
uint32_t order_num, order_st *order, bool ignore);
213
213
bool mysql_recreate_table(THD *thd, TableList *table_list);
214
214
bool mysql_create_like_table(THD *thd, TableList *table,
215
215
TableList *src_table,
216
216
HA_CREATE_INFO *create_info);
217
217
bool mysql_rename_table(handlerton *base, const char *old_db,
218
218
const char * old_name, const char *new_db,
219
const char * new_name, uint flags);
219
const char * new_name, uint32_t flags);
220
220
bool mysql_prepare_update(THD *thd, TableList *table_list,
221
Item **conds, uint order_num, order_st *order);
221
Item **conds, uint32_t order_num, order_st *order);
222
222
int mysql_update(THD *thd,TableList *tables,List<Item> &fields,
223
223
List<Item> &values,COND *conds,
224
uint order_num, order_st *order, ha_rows limit,
224
uint32_t order_num, order_st *order, ha_rows limit,
225
225
enum enum_duplicates handle_duplicates, bool ignore);
226
226
bool mysql_multi_update(THD *thd, TableList *table_list,
227
227
List<Item> *fields, List<Item> *values,
246
246
SQL_LIST *order, ha_rows rows, uint64_t options,
247
247
bool reset_auto_increment);
248
248
bool mysql_truncate(THD *thd, TableList *table_list, bool dont_send_ok);
249
uint create_table_def_key(THD *thd, char *key, TableList *table_list,
249
uint32_t create_table_def_key(THD *thd, char *key, TableList *table_list,
251
251
TABLE_SHARE *get_table_share(THD *thd, TableList *table_list, char *key,
252
uint key_length, uint db_flags, int *error);
252
uint32_t key_length, uint32_t db_flags, int *error);
253
253
void release_table_share(TABLE_SHARE *share, enum release_type type);
254
254
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
255
255
Table *open_ltable(THD *thd, TableList *table_list, thr_lock_type update,
257
Table *open_table(THD *thd, TableList *table_list, bool *refresh, uint flags);
256
uint32_t lock_flags);
257
Table *open_table(THD *thd, TableList *table_list, bool *refresh, uint32_t flags);
258
258
bool name_lock_locked_table(THD *thd, TableList *tables);
259
259
bool reopen_name_locked_table(THD* thd, TableList* table_list, bool link_in);
260
260
Table *table_cache_insert_placeholder(THD *thd, const char *key,
261
uint32_t key_length);
262
262
bool lock_table_name_if_not_cached(THD *thd, const char *db,
263
263
const char *table_name, Table **table);
264
264
Table *find_locked_table(THD *thd, const char *db,const char *table_name);
271
271
const char *table_name);
272
272
void close_handle_and_leave_table_as_lock(Table *table);
273
273
bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
274
uint db_stat, uint prgflag,
275
uint ha_open_flags, Table *outparam,
274
uint32_t db_stat, uint32_t prgflag,
275
uint32_t ha_open_flags, Table *outparam,
276
276
TableList *table_desc, MEM_ROOT *mem_root);
277
277
bool wait_for_tables(THD *thd);
278
278
bool table_is_used(Table *table, bool wait_for_name_lock);
293
293
bool check_privileges, bool register_tree_change);
295
295
find_field_in_table_ref(THD *thd, TableList *table_list,
296
const char *name, uint length,
296
const char *name, uint32_t length,
297
297
const char *item_name, const char *db_name,
298
298
const char *table_name, Item **ref,
299
299
bool check_privileges, bool allow_rowid,
300
uint *cached_field_index_ptr,
300
uint32_t *cached_field_index_ptr,
301
301
bool register_tree_change, TableList **actual_table);
303
find_field_in_table(THD *thd, Table *table, const char *name, uint length,
304
bool allow_rowid, uint *cached_field_index_ptr);
303
find_field_in_table(THD *thd, Table *table, const char *name, uint32_t length,
304
bool allow_rowid, uint32_t *cached_field_index_ptr);
306
306
find_field_in_table_sef(Table *table, const char *name);
347
347
/* sql_base.cc */
348
348
#define TMP_TABLE_KEY_EXTRA 8
349
void set_item_name(Item *item,char *pos,uint length);
349
void set_item_name(Item *item,char *pos,uint32_t length);
350
350
bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types type,
351
351
char *length, char *decimal,
352
uint32_t type_modifier,
353
353
enum column_format_type column_format,
354
354
Item *default_value, Item *on_update_value,
355
355
LEX_STRING *comment,
357
357
const CHARSET_INFO * const cs);
358
358
Create_field * new_create_field(THD *thd, char *field_name, enum_field_types type,
359
359
char *length, char *decimals,
360
uint32_t type_modifier,
361
361
Item *default_value, Item *on_update_value,
362
362
LEX_STRING *comment, char *change,
363
363
List<String> *interval_list, CHARSET_INFO *cs);
408
408
RESOLVED_WITH_NO_ALIAS,
409
409
RESOLVED_AGAINST_ALIAS
411
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,
411
Item ** find_item_in_list(Item *item, List<Item> &items, uint32_t *counter,
412
412
find_item_error_report_type report_error,
413
413
enum_resolution_type *resolution);
414
414
bool get_key_map_from_key_list(key_map *map, Table *table,
426
426
TableList **leaves,
427
427
bool select_insert);
428
428
int setup_wild(THD *thd, TableList *tables, List<Item> &fields,
429
List<Item> *sum_func_list, uint wild_num);
429
List<Item> *sum_func_list, uint32_t wild_num);
430
430
bool setup_fields(THD *thd, Item** ref_pointer_array,
431
431
List<Item> &item, enum_mark_columns mark_used_columns,
432
432
List<Item> *sum_func_list, bool allow_sum_func);
447
447
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
448
448
void wait_for_condition(THD *thd, pthread_mutex_t *mutex,
449
449
pthread_cond_t *cond);
450
int open_tables(THD *thd, TableList **tables, uint *counter, uint flags);
450
int open_tables(THD *thd, TableList **tables, uint32_t *counter, uint32_t flags);
451
451
/* open_and_lock_tables with optional derived handling */
452
452
int open_and_lock_tables_derived(THD *thd, TableList *tables, bool derived);
453
453
/* simple open_and_lock_tables without derived handling */
463
463
/* simple open_and_lock_tables without derived handling for single table */
464
464
Table *open_n_lock_single_table(THD *thd, TableList *table_l,
465
465
thr_lock_type lock_type);
466
bool open_normal_and_derived_tables(THD *thd, TableList *tables, uint flags);
467
int lock_tables(THD *thd, TableList *tables, uint counter, bool *need_reopen);
466
bool open_normal_and_derived_tables(THD *thd, TableList *tables, uint32_t flags);
467
int lock_tables(THD *thd, TableList *tables, uint32_t counter, bool *need_reopen);
468
468
int decide_logging_format(THD *thd, TableList *tables);
469
469
Table *open_temporary_table(THD *thd, const char *path, const char *db,
470
470
const char *table_name, bool link_in_list,
555
555
/* sql_test.cc */
556
556
void print_where(COND *cond,const char *info, enum_query_type query_type);
557
557
void print_cached_tables(void);
558
void TEST_filesort(SORT_FIELD *sortorder,uint s_length);
559
void print_plan(JOIN* join,uint idx, double record_count, double read_time,
558
void TEST_filesort(SORT_FIELD *sortorder,uint32_t s_length);
559
void print_plan(JOIN* join,uint32_t idx, double record_count, double read_time,
560
560
double current_read_time, const char *info);
561
561
void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array);
562
562
void dump_TableList_graph(SELECT_LEX *select_lex, TableList* tl);
563
563
void mysql_print_status();
566
int find_ref_key(KEY *key, uint key_count, unsigned char *record, Field *field,
567
uint *key_length, uint *keypart);
568
void key_copy(unsigned char *to_key, unsigned char *from_record, KEY *key_info, uint key_length);
566
int find_ref_key(KEY *key, uint32_t key_count, unsigned char *record, Field *field,
567
uint32_t *key_length, uint32_t *keypart);
568
void key_copy(unsigned char *to_key, unsigned char *from_record, KEY *key_info, uint32_t key_length);
569
569
void key_restore(unsigned char *to_record, unsigned char *from_key, KEY *key_info,
570
570
uint16_t key_length);
571
571
void key_zero_nulls(unsigned char *tuple, KEY *key_info);
572
bool key_cmp_if_same(Table *form,const unsigned char *key,uint index,uint key_length);
573
void key_unpack(String *to,Table *form,uint index);
574
bool is_key_used(Table *table, uint idx, const MY_BITMAP *fields);
575
int key_cmp(KEY_PART_INFO *key_part, const unsigned char *key, uint key_length);
572
bool key_cmp_if_same(Table *form,const unsigned char *key,uint32_t index,uint32_t key_length);
573
void key_unpack(String *to,Table *form,uint32_t index);
574
bool is_key_used(Table *table, uint32_t idx, const MY_BITMAP *fields);
575
int key_cmp(KEY_PART_INFO *key_part, const unsigned char *key, uint32_t key_length);
576
576
extern "C" int key_rec_cmp(void *key_info, unsigned char *a, unsigned char *b);
578
578
bool init_errmessage(void);
592
592
/* item_func.cc */
593
593
extern bool check_reserved_words(LEX_STRING *name);
594
extern enum_field_types agg_field_type(Item **items, uint nitems);
594
extern enum_field_types agg_field_type(Item **items, uint32_t nitems);
597
uint64_t find_set(TYPELIB *lib, const char *x, uint length, const CHARSET_INFO * const cs,
598
char **err_pos, uint *err_len, bool *set_warning);
599
uint find_type(const TYPELIB *lib, const char *find, uint length,
597
uint64_t find_set(TYPELIB *lib, const char *x, uint32_t length, const CHARSET_INFO * const cs,
598
char **err_pos, uint32_t *err_len, bool *set_warning);
599
uint32_t find_type(const TYPELIB *lib, const char *find, uint32_t length,
600
600
bool part_match);
601
uint find_type2(const TYPELIB *lib, const char *find, uint length,
601
uint32_t find_type2(const TYPELIB *lib, const char *find, uint32_t length,
602
602
const CHARSET_INFO *cs);
603
603
void unhex_type2(TYPELIB *lib);
604
uint check_word(TYPELIB *lib, const char *val, const char *end,
604
uint32_t check_word(TYPELIB *lib, const char *val, const char *end,
605
605
const char **end_of_word);
606
606
int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
607
607
const CHARSET_INFO * const cs);
610
bool is_keyword(const char *name, uint len);
610
bool is_keyword(const char *name, uint32_t len);
612
612
#define MY_DB_OPT_FILE "db.opt"
613
613
bool my_database_names_init(void);
660
660
extern ulong max_connections,max_connect_errors, connect_timeout;
661
661
extern bool slave_allow_batching;
662
662
extern ulong slave_net_timeout, slave_trans_retries;
663
extern uint max_user_connections;
663
extern uint32_t max_user_connections;
664
664
extern ulong what_to_log,flush_time;
665
665
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
666
666
extern ulong max_binlog_size, max_relay_log_size;
673
673
extern ulong tc_log_page_waits;
674
674
extern bool relay_log_purge;
675
675
extern bool opt_innodb_safe_binlog, opt_innodb;
676
extern uint test_flags,select_errors,ha_open_options;
677
extern uint protocol_version, mysqld_port, dropping_tables;
678
extern uint delay_key_write_options;
676
extern uint32_t test_flags,select_errors,ha_open_options;
677
extern uint32_t protocol_version, mysqld_port, dropping_tables;
678
extern uint32_t delay_key_write_options;
679
679
extern bool opt_endinfo, using_udf_functions;
680
680
extern bool locked_in_memory;
681
681
extern bool opt_using_transactions;
687
687
extern bool opt_log_queries_not_using_indexes;
688
688
extern bool opt_character_set_client_handshake;
689
689
extern bool volatile abort_loop, shutdown_in_progress;
690
extern uint volatile thread_count, thread_running, global_read_lock;
691
extern uint connection_count;
690
extern uint32_t volatile thread_count, thread_running, global_read_lock;
691
extern uint32_t connection_count;
692
692
extern bool opt_sql_bin_update;
693
693
extern bool opt_safe_user_create;
694
694
extern bool opt_no_mix_types;
764
764
extern pthread_t signal_thread;
766
DRIZZLE_LOCK *mysql_lock_tables(THD *thd, Table **table, uint count,
767
uint flags, bool *need_reopen);
766
DRIZZLE_LOCK *mysql_lock_tables(THD *thd, Table **table, uint32_t count,
767
uint32_t flags, bool *need_reopen);
768
768
/* mysql_lock_tables() and open_table() flags bits */
769
769
#define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_LOCK 0x0001
770
770
#define DRIZZLE_LOCK_IGNORE_FLUSH 0x0002
776
776
void mysql_unlock_tables(THD *thd, DRIZZLE_LOCK *sql_lock);
777
777
void mysql_unlock_read_tables(THD *thd, DRIZZLE_LOCK *sql_lock);
778
void mysql_unlock_some_tables(THD *thd, Table **table,uint count);
778
void mysql_unlock_some_tables(THD *thd, Table **table,uint32_t count);
779
779
void mysql_lock_remove(THD *thd, DRIZZLE_LOCK *locked,Table *table,
780
780
bool always_unlock);
781
781
void mysql_lock_abort(THD *thd, Table *table, bool upgrade_lock);
822
822
const char *db, const char *table,
823
823
HA_CREATE_INFO *create_info,
824
824
List<Create_field> &create_field,
825
uint key_count,KEY *key_info,handler *db_type);
825
uint32_t key_count,KEY *key_info,handler *db_type);
826
826
int rea_create_table(THD *thd, const char *path,
827
827
const char *db, const char *table_name,
828
828
HA_CREATE_INFO *create_info,
829
829
List<Create_field> &create_field,
830
uint key_count,KEY *key_info,
830
uint32_t key_count,KEY *key_info,
832
int format_number(uint inputflag,uint max_length,char * pos,uint length,
832
int format_number(uint32_t inputflag,uint32_t max_length,char * pos,uint32_t length,
836
836
TABLE_SHARE *alloc_table_share(TableList *table_list, char *key,
837
uint32_t key_length);
838
838
void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
840
840
const char *table_name, const char *path);
841
841
void free_table_share(TABLE_SHARE *share);
842
int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags);
842
int open_table_def(THD *thd, TABLE_SHARE *share, uint32_t db_flags);
843
843
void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg);
844
844
int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
845
uint db_stat, uint prgflag, uint ha_open_flags,
845
uint32_t db_stat, uint32_t prgflag, uint32_t ha_open_flags,
846
846
Table *outparam, open_table_mode open_mode);
847
847
int readfrm(const char *name, unsigned char **data, size_t *length);
848
848
int writefrm(const char* name, const unsigned char* data, size_t len);
852
852
int set_zone(int nr,int min_zone,int max_zone);
853
853
ulong convert_period_to_month(ulong period);
854
854
ulong convert_month_to_period(ulong month);
855
void get_date_from_daynr(long daynr,uint *year, uint *month,
855
void get_date_from_daynr(long daynr,uint32_t *year, uint32_t *month,
857
857
my_time_t TIME_to_timestamp(THD *thd, const DRIZZLE_TIME *t, bool *not_exist);
858
bool str_to_time_with_warn(const char *str,uint length,DRIZZLE_TIME *l_time);
859
enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str, uint length,
860
DRIZZLE_TIME *l_time, uint flags);
858
bool str_to_time_with_warn(const char *str,uint32_t length,DRIZZLE_TIME *l_time);
859
enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str, uint32_t length,
860
DRIZZLE_TIME *l_time, uint32_t flags);
861
861
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
862
862
void calc_time_from_sec(DRIZZLE_TIME *to, long seconds, long microseconds);
864
864
void make_truncated_value_warning(THD *thd, DRIZZLE_ERROR::enum_warning_level level,
865
865
const char *str_val,
866
uint str_length, enum enum_drizzle_timestamp_type time_type,
866
uint32_t str_length, enum enum_drizzle_timestamp_type time_type,
867
867
const char *field_name);
869
869
bool date_add_interval(DRIZZLE_TIME *ltime, interval_type int_type, INTERVAL interval);
897
897
SQL_SELECT *select,
898
898
int use_record_cache, bool print_errors);
899
899
void init_read_record_idx(READ_RECORD *info, THD *thd, Table *table,
900
bool print_error, uint idx);
900
bool print_error, uint32_t idx);
901
901
void end_read_record(READ_RECORD *info);
902
902
ha_rows filesort(THD *thd, Table *form,struct st_sort_field *sortorder,
903
uint s_length, SQL_SELECT *select,
903
uint32_t s_length, SQL_SELECT *select,
904
904
ha_rows max_rows, bool sort_positions,
905
905
ha_rows *examined_rows);
906
906
void filesort_free_buffers(Table *table, bool full);
910
910
int get_quick_record(SQL_SELECT *select);
912
912
int calc_weekday(long daynr,bool sunday_first_day_of_week);
913
uint calc_week(DRIZZLE_TIME *l_time, uint week_behaviour, uint *year);
914
void find_date(char *pos,uint *vek,uint flag);
913
uint32_t calc_week(DRIZZLE_TIME *l_time, uint32_t week_behaviour, uint32_t *year);
914
void find_date(char *pos,uint32_t *vek,uint32_t flag);
915
915
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
916
916
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings);
917
917
ulong get_form_pos(File file, unsigned char *head, TYPELIB *save_names);
918
918
ulong make_new_entry(File file,unsigned char *fileinfo,TYPELIB *formnames,
919
919
const char *newname);
920
920
ulong next_io_size(ulong pos);
921
void append_unescaped(String *res, const char *pos, uint length);
921
void append_unescaped(String *res, const char *pos, uint32_t length);
922
922
int create_frm(THD *thd, const char *name, const char *db, const char *table,
923
uint reclength, unsigned char *fileinfo,
924
HA_CREATE_INFO *create_info, uint keys, KEY *key_info);
923
uint32_t reclength, unsigned char *fileinfo,
924
HA_CREATE_INFO *create_info, uint32_t keys, KEY *key_info);
925
925
int rename_file_ext(const char * from,const char * to,const char * ext);
926
926
bool check_db_name(LEX_STRING *db);
927
927
bool check_column_name(const char *name);
928
bool check_table_name(const char *name, uint length);
928
bool check_table_name(const char *name, uint32_t length);
929
929
char *get_field(MEM_ROOT *mem, Field *field);
930
930
bool get_field(MEM_ROOT *mem, Field *field, class String *res);
931
931
char *fn_rext(char *name);
933
933
/* Conversion functions */
934
uint build_table_filename(char *buff, size_t bufflen, const char *db,
935
const char *table, const char *ext, uint flags);
934
uint32_t build_table_filename(char *buff, size_t bufflen, const char *db,
935
const char *table, const char *ext, uint32_t flags);
937
937
#define MYSQL50_TABLE_NAME_PREFIX "#mysql50#"
938
938
#define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9