~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/server_includes.h

  • Committer: Brian Aker
  • Date: 2008-08-16 22:34:15 UTC
  • mto: This revision was merged to the branch mainline in revision 346.
  • Revision ID: brian@tangent.org-20080816223415-n24esdpfcqi4pwpy
Refactor around classes. TABLE_LIST has been factored out of table.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
/* </UNUSED> */
134
134
 
135
135
/* sql_update.cc */
136
 
bool compare_record(TABLE *table);
 
136
bool compare_record(Table *table);
137
137
 
138
138
/* sql_base.cc */
139
139
void table_cache_free(void);
149
149
void close_connection(THD *thd, uint errcode, bool lock);
150
150
 
151
151
/* sql_select.cc */
152
 
TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
 
152
Table *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
153
153
 
154
154
/* handler.cc */
155
155
bool mysql_xa_recover(THD *thd);
184
184
                                                      TABLE_LIST *table));
185
185
bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t);
186
186
bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t);
187
 
Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
 
187
Field *create_tmp_field(THD *thd, Table *table,Item *item, Item::Type type,
188
188
                        Item ***copy_func, Field **from_field,
189
189
                        Field **def_field,
190
190
                        bool group, bool modify_item,
229
229
                        COND *conds, uint64_t options,
230
230
                        enum enum_duplicates handle_duplicates, bool ignore,
231
231
                        SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
232
 
bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
 
232
bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, Table *table,
233
233
                          List<Item> &fields, List_item *values,
234
234
                          List<Item> &update_fields,
235
235
                          List<Item> &update_values, enum_duplicates duplic,
239
239
                  List<List_item> &values, List<Item> &update_fields,
240
240
                  List<Item> &update_values, enum_duplicates flag,
241
241
                  bool ignore);
242
 
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
 
242
int check_that_all_fields_are_given_values(THD *thd, Table *entry,
243
243
                                           TABLE_LIST *table_list);
244
 
void prepare_triggers_for_insert_stmt(TABLE *table);
 
244
void prepare_triggers_for_insert_stmt(Table *table);
245
245
int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
246
246
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
247
247
                  SQL_LIST *order, ha_rows rows, uint64_t options,
253
253
                             uint key_length, uint db_flags, int *error);
254
254
void release_table_share(TABLE_SHARE *share, enum release_type type);
255
255
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
256
 
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
 
256
Table *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
257
257
                   uint lock_flags);
258
 
TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT* mem,
 
258
Table *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT* mem,
259
259
                  bool *refresh, uint flags);
260
260
bool name_lock_locked_table(THD *thd, TABLE_LIST *tables);
261
261
bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list, bool link_in);
262
 
TABLE *table_cache_insert_placeholder(THD *thd, const char *key,
 
262
Table *table_cache_insert_placeholder(THD *thd, const char *key,
263
263
                                      uint key_length);
264
264
bool lock_table_name_if_not_cached(THD *thd, const char *db,
265
 
                                   const char *table_name, TABLE **table);
266
 
TABLE *find_locked_table(THD *thd, const char *db,const char *table_name);
267
 
void detach_merge_children(TABLE *table, bool clear_refs);
 
265
                                   const char *table_name, Table **table);
 
266
Table *find_locked_table(THD *thd, const char *db,const char *table_name);
 
267
void detach_merge_children(Table *table, bool clear_refs);
268
268
bool fix_merge_after_open(TABLE_LIST *old_child_list, TABLE_LIST **old_last,
269
269
                          TABLE_LIST *new_child_list, TABLE_LIST **new_last);
270
 
bool reopen_table(TABLE *table);
 
270
bool reopen_table(Table *table);
271
271
bool reopen_tables(THD *thd,bool get_locks,bool in_refresh);
272
272
void close_data_files_and_morph_locks(THD *thd, const char *db,
273
273
                                      const char *table_name);
274
 
void close_handle_and_leave_table_as_lock(TABLE *table);
 
274
void close_handle_and_leave_table_as_lock(Table *table);
275
275
bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
276
276
                  uint db_stat, uint prgflag,
277
 
                  uint ha_open_flags, TABLE *outparam,
 
277
                  uint ha_open_flags, Table *outparam,
278
278
                  TABLE_LIST *table_desc, MEM_ROOT *mem_root);
279
279
bool wait_for_tables(THD *thd);
280
 
bool table_is_used(TABLE *table, bool wait_for_name_lock);
281
 
TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name);
 
280
bool table_is_used(Table *table, bool wait_for_name_lock);
 
281
Table *drop_locked_tables(THD *thd,const char *db, const char *table_name);
282
282
void abort_locked_tables(THD *thd,const char *db, const char *table_name);
283
283
void execute_init_command(THD *thd, sys_var_str *init_command_var,
284
284
                          rw_lock_t *var_mutex);
302
302
                        uint *cached_field_index_ptr,
303
303
                        bool register_tree_change, TABLE_LIST **actual_table);
304
304
Field *
305
 
find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
 
305
find_field_in_table(THD *thd, Table *table, const char *name, uint length,
306
306
                    bool allow_rowid, uint *cached_field_index_ptr);
307
307
Field *
308
 
find_field_in_table_sef(TABLE *table, const char *name);
 
308
find_field_in_table_sef(Table *table, const char *name);
309
309
 
310
310
/* sql_do.cc */
311
311
bool mysql_do(THD *thd, List<Item> &values);
372
372
void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List<String> *using_fields,
373
373
                      SELECT_LEX *lex);
374
374
bool add_proc_to_list(THD *thd, Item *item);
375
 
void unlink_open_table(THD *thd, TABLE *find, bool unlock);
376
 
void drop_open_table(THD *thd, TABLE *table, const char *db_name,
 
375
void unlink_open_table(THD *thd, Table *find, bool unlock);
 
376
void drop_open_table(THD *thd, Table *table, const char *db_name,
377
377
                     const char *table_name);
378
378
void update_non_unique_table_error(TABLE_LIST *update,
379
379
                                   const char *operation,
380
380
                                   TABLE_LIST *duplicate);
381
381
 
382
 
SQL_SELECT *make_select(TABLE *head, table_map const_tables,
 
382
SQL_SELECT *make_select(Table *head, table_map const_tables,
383
383
                        table_map read_tables, COND *conds,
384
384
                        bool allow_null_cond,  int *error);
385
385
extern Item **not_found_item;
413
413
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,
414
414
                          find_item_error_report_type report_error,
415
415
                          enum_resolution_type *resolution);
416
 
bool get_key_map_from_key_list(key_map *map, TABLE *table,
 
416
bool get_key_map_from_key_list(key_map *map, Table *table,
417
417
                               List<String> *index_list);
418
418
bool insert_fields(THD *thd, Name_resolution_context *context,
419
419
                   const char *db_name, const char *table_name,
463
463
  return open_and_lock_tables_derived(thd, tables, true);
464
464
}
465
465
/* simple open_and_lock_tables without derived handling for single table */
466
 
TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l,
 
466
Table *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l,
467
467
                                thr_lock_type lock_type);
468
468
bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags);
469
469
int lock_tables(THD *thd, TABLE_LIST *tables, uint counter, bool *need_reopen);
470
470
int decide_logging_format(THD *thd, TABLE_LIST *tables);
471
 
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
 
471
Table *open_temporary_table(THD *thd, const char *path, const char *db,
472
472
                            const char *table_name, bool link_in_list,
473
473
                            open_table_mode open_mode);
474
474
bool rm_temporary_table(handlerton *base, char *path, bool frm_only);
475
 
void free_io_cache(TABLE *entry);
476
 
void intern_close_table(TABLE *entry);
477
 
bool close_thread_table(THD *thd, TABLE **table_ptr);
 
475
void free_io_cache(Table *entry);
 
476
void intern_close_table(Table *entry);
 
477
bool close_thread_table(THD *thd, Table **table_ptr);
478
478
void close_temporary_tables(THD *thd);
479
479
void close_tables_for_reopen(THD *thd, TABLE_LIST **tables);
480
480
TABLE_LIST *find_table_in_list(TABLE_LIST *table,
483
483
                               const char *table_name);
484
484
TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
485
485
                         bool check_alias);
486
 
TABLE *find_temporary_table(THD *thd, const char *db, const char *table_name);
487
 
TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list);
 
486
Table *find_temporary_table(THD *thd, const char *db, const char *table_name);
 
487
Table *find_temporary_table(THD *thd, TABLE_LIST *table_list);
488
488
int drop_temporary_table(THD *thd, TABLE_LIST *table_list);
489
 
void close_temporary_table(THD *thd, TABLE *table, bool free_share,
 
489
void close_temporary_table(THD *thd, Table *table, bool free_share,
490
490
                           bool delete_table);
491
 
void close_temporary(TABLE *table, bool free_share, bool delete_table);
492
 
bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db,
 
491
void close_temporary(Table *table, bool free_share, bool delete_table);
 
492
bool rename_temporary_table(THD* thd, Table *table, const char *new_db,
493
493
                            const char *table_name);
494
494
void remove_db_from_cache(const char *db);
495
495
void flush_tables();
551
551
                List<Item> &set_values_list,
552
552
                enum enum_duplicates handle_duplicates, bool ignore,
553
553
                bool local_file);
554
 
int write_record(THD *thd, TABLE *table, COPY_INFO *info);
 
554
int write_record(THD *thd, Table *table, COPY_INFO *info);
555
555
 
556
556
 
557
557
/* sql_test.cc */
571
571
void key_restore(uchar *to_record, uchar *from_key, KEY *key_info,
572
572
                 uint16_t key_length);
573
573
void key_zero_nulls(uchar *tuple, KEY *key_info);
574
 
bool key_cmp_if_same(TABLE *form,const uchar *key,uint index,uint key_length);
575
 
void key_unpack(String *to,TABLE *form,uint index);
576
 
bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields);
 
574
bool key_cmp_if_same(Table *form,const uchar *key,uint index,uint key_length);
 
575
void key_unpack(String *to,Table *form,uint index);
 
576
bool is_key_used(Table *table, uint idx, const MY_BITMAP *fields);
577
577
int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length);
578
578
extern "C" int key_rec_cmp(void *key_info, uchar *a, uchar *b);
579
579
 
746
746
 
747
747
extern String null_string;
748
748
extern HASH open_cache, lock_db_cache;
749
 
extern TABLE *unused_tables;
 
749
extern Table *unused_tables;
750
750
extern const char* any_db;
751
751
extern struct my_option my_long_options[];
752
752
extern const LEX_STRING view_type;
768
768
 
769
769
extern pthread_t signal_thread;
770
770
 
771
 
DRIZZLE_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count,
 
771
DRIZZLE_LOCK *mysql_lock_tables(THD *thd, Table **table, uint count,
772
772
                              uint flags, bool *need_reopen);
773
773
/* mysql_lock_tables() and open_table() flags bits */
774
774
#define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_LOCK      0x0001
780
780
 
781
781
void mysql_unlock_tables(THD *thd, DRIZZLE_LOCK *sql_lock);
782
782
void mysql_unlock_read_tables(THD *thd, DRIZZLE_LOCK *sql_lock);
783
 
void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count);
784
 
void mysql_lock_remove(THD *thd, DRIZZLE_LOCK *locked,TABLE *table,
 
783
void mysql_unlock_some_tables(THD *thd, Table **table,uint count);
 
784
void mysql_lock_remove(THD *thd, DRIZZLE_LOCK *locked,Table *table,
785
785
                       bool always_unlock);
786
 
void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock);
787
 
void mysql_lock_downgrade_write(THD *thd, TABLE *table,
 
786
void mysql_lock_abort(THD *thd, Table *table, bool upgrade_lock);
 
787
void mysql_lock_downgrade_write(THD *thd, Table *table,
788
788
                                thr_lock_type new_lock_type);
789
 
bool mysql_lock_abort_for_thread(THD *thd, TABLE *table);
 
789
bool mysql_lock_abort_for_thread(THD *thd, Table *table);
790
790
DRIZZLE_LOCK *mysql_lock_merge(DRIZZLE_LOCK *a,DRIZZLE_LOCK *b);
791
791
TABLE_LIST *mysql_lock_have_duplicate(THD *thd, TABLE_LIST *needle,
792
792
                                      TABLE_LIST *haystack);
848
848
void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg);
849
849
int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
850
850
                          uint db_stat, uint prgflag, uint ha_open_flags,
851
 
                          TABLE *outparam, open_table_mode open_mode);
 
851
                          Table *outparam, open_table_mode open_mode);
852
852
int readfrm(const char *name, uchar **data, size_t *length);
853
853
int writefrm(const char* name, const uchar* data, size_t len);
854
 
int closefrm(TABLE *table, bool free_share);
 
854
int closefrm(Table *table, bool free_share);
855
855
int read_string(File file, uchar* *to, size_t length);
856
 
void free_blobs(TABLE *table);
 
856
void free_blobs(Table *table);
857
857
int set_zone(int nr,int min_zone,int max_zone);
858
858
ulong convert_period_to_month(ulong period);
859
859
ulong convert_month_to_period(ulong month);
898
898
 
899
899
int test_if_number(char *str,int *res,bool allow_wildcards);
900
900
void change_byte(uchar *,uint,char,char);
901
 
void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
 
901
void init_read_record(READ_RECORD *info, THD *thd, Table *reg_form,
902
902
                      SQL_SELECT *select,
903
903
                      int use_record_cache, bool print_errors);
904
 
void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table, 
 
904
void init_read_record_idx(READ_RECORD *info, THD *thd, Table *table, 
905
905
                          bool print_error, uint idx);
906
906
void end_read_record(READ_RECORD *info);
907
 
ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder,
 
907
ha_rows filesort(THD *thd, Table *form,struct st_sort_field *sortorder,
908
908
                 uint s_length, SQL_SELECT *select,
909
909
                 ha_rows max_rows, bool sort_positions,
910
910
                 ha_rows *examined_rows);
911
 
void filesort_free_buffers(TABLE *table, bool full);
 
911
void filesort_free_buffers(Table *table, bool full);
912
912
void change_double_for_sort(double nr,uchar *to);
913
913
double my_double_round(double value, int64_t dec, bool dec_unsigned,
914
914
                       bool truncate);
982
982
  return thd->lex->current_select->add_group_to_list(thd, item, asc);
983
983
}
984
984
 
985
 
inline void mark_as_null_row(TABLE *table)
 
985
inline void mark_as_null_row(Table *table)
986
986
{
987
987
  table->null_row=1;
988
988
  table->status|=STATUS_NULL_ROW;
1023
1023
/**
1024
1024
  clean/setup table fields and map.
1025
1025
 
1026
 
  @param table        TABLE structure pointer (which should be setup)
1027
 
  @param table_list   TABLE_LIST structure pointer (owner of TABLE)
 
1026
  @param table        Table structure pointer (which should be setup)
 
1027
  @param table_list   TABLE_LIST structure pointer (owner of Table)
1028
1028
  @param tablenr     table number
1029
1029
*/
1030
 
inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr)
 
1030
inline void setup_table_map(Table *table, TABLE_LIST *table_list, uint tablenr)
1031
1031
{
1032
1032
  table->used_fields= 0;
1033
1033
  table->const_table= 0;
1066
1066
/**
1067
1067
  return true if the table was created explicitly.
1068
1068
*/
1069
 
inline bool is_user_table(TABLE * table)
 
1069
inline bool is_user_table(Table * table)
1070
1070
{
1071
1071
  const char *name= table->s->table_name.str;
1072
1072
  return strncmp(name, tmp_file_prefix, tmp_file_prefix_length);