~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.h

  • Committer: Monty Taylor
  • Date: 2009-03-24 17:33:03 UTC
  • mto: (960.5.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 964.
  • Revision ID: mordred@inaugust.com-20090324173303-va856e49yqgvmrde
Moved handlerton to plugin/storage_engine.h.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <stdint.h>
24
24
#include <drizzled/table.h>
25
25
 
26
 
class TableShare;
27
 
class Name_resolution_context;
 
26
class TABLE_SHARE;
28
27
 
29
28
void table_cache_free(void);
30
29
bool table_cache_init(void);
31
 
void assign_new_table_id(TableShare *share);
 
30
bool table_def_init(void);
 
31
void table_def_free(void);
 
32
void assign_new_table_id(TABLE_SHARE *share);
32
33
uint32_t cached_open_tables(void);
33
34
uint32_t cached_table_definitions(void);
34
35
 
35
36
void kill_drizzle(void);
36
37
 
37
38
/* sql_base.cc */
 
39
#define TMP_TABLE_KEY_EXTRA 8
38
40
void set_item_name(Item *item,char *pos,uint32_t length);
39
41
bool add_field_to_list(Session *session, LEX_STRING *field_name, enum enum_field_types type,
40
 
                       char *length, char *decimal,
41
 
                       uint32_t type_modifier,
 
42
                       char *length, char *decimal,
 
43
                       uint32_t type_modifier,
42
44
                       enum column_format_type column_format,
43
 
                       Item *default_value, Item *on_update_value,
44
 
                       LEX_STRING *comment,
45
 
                       char *change, List<String> *interval_list,
46
 
                       const CHARSET_INFO * const cs);
47
 
CreateField * new_create_field(Session *session, char *field_name, enum_field_types type,
48
 
                               char *length, char *decimals,
49
 
                               uint32_t type_modifier,
50
 
                               Item *default_value, Item *on_update_value,
51
 
                               LEX_STRING *comment, char *change,
52
 
                               List<String> *interval_list, CHARSET_INFO *cs);
 
45
                       Item *default_value, Item *on_update_value,
 
46
                       LEX_STRING *comment,
 
47
                       char *change, List<String> *interval_list,
 
48
                       const CHARSET_INFO * const cs,
 
49
                       virtual_column_info *vcol_info);
 
50
Create_field * new_create_field(Session *session, char *field_name, enum_field_types type,
 
51
                                char *length, char *decimals,
 
52
                                uint32_t type_modifier,
 
53
                                Item *default_value, Item *on_update_value,
 
54
                                LEX_STRING *comment, char *change,
 
55
                                List<String> *interval_list, CHARSET_INFO *cs,
 
56
                                virtual_column_info *vcol_info);
53
57
void store_position_for_column(const char *name);
 
58
bool add_to_list(Session *session, SQL_LIST &list,Item *group,bool asc);
54
59
bool push_new_name_resolution_context(Session *session,
55
60
                                      TableList *left_op,
56
61
                                      TableList *right_op);
57
62
void add_join_on(TableList *b,Item *expr);
58
63
void add_join_natural(TableList *a,TableList *b,List<String> *using_fields,
59
64
                      Select_Lex *lex);
 
65
void unlink_open_table(Session *session, Table *find, bool unlock);
 
66
void drop_open_table(Session *session, Table *table, const char *db_name,
 
67
                     const char *table_name);
 
68
void update_non_unique_table_error(TableList *update,
 
69
                                   const char *operation,
 
70
                                   TableList *duplicate);
 
71
 
 
72
SQL_SELECT *make_select(Table *head, table_map const_tables,
 
73
                        table_map read_tables, COND *conds,
 
74
                        bool allow_null_cond,  int *error);
60
75
extern Item **not_found_item;
61
76
 
62
 
/**
 
77
/*
63
78
  A set of constants used for checking non aggregated fields and sum
64
79
  functions mixture in the ONLY_FULL_GROUP_BY_MODE.
65
80
*/
66
 
enum enum_group_by_mode_type
67
 
{
68
 
  NON_AGG_FIELD_USED= 0,
69
 
  SUM_FUNC_USED
70
 
};
 
81
#define NON_AGG_FIELD_USED  1
 
82
#define SUM_FUNC_USED       2
71
83
 
72
 
/**
 
84
/*
73
85
  This enumeration type is used only by the function find_item_in_list
74
86
  to return the info on how an item has been resolved against a list
75
87
  of possibly aliased items.
91
103
Item ** find_item_in_list(Item *item, List<Item> &items, uint32_t *counter,
92
104
                          find_item_error_report_type report_error,
93
105
                          enum_resolution_type *resolution);
 
106
bool get_key_map_from_key_list(key_map *map, Table *table,
 
107
                               List<String> *index_list);
94
108
bool insert_fields(Session *session, Name_resolution_context *context,
95
 
                   const char *db_name, const char *table_name,
 
109
                   const char *db_name, const char *table_name,
96
110
                   List_iterator<Item> *it, bool any_privileges);
97
111
bool setup_tables(Session *session, Name_resolution_context *context,
98
112
                  List<TableList> *from_clause, TableList *tables,
103
117
                                   TableList *tables,
104
118
                                   TableList **leaves,
105
119
                                   bool select_insert);
106
 
int setup_wild(Session *session, List<Item> &fields,
107
 
               List<Item> *sum_func_list,
108
 
               uint32_t wild_num);
 
120
int setup_wild(Session *session, TableList *tables, List<Item> &fields,
 
121
               List<Item> *sum_func_list, uint32_t wild_num);
109
122
bool setup_fields(Session *session, Item** ref_pointer_array,
110
123
                  List<Item> &item, enum_mark_columns mark_used_columns,
111
124
                  List<Item> *sum_func_list, bool allow_sum_func);
120
133
                    allow_sum_func);
121
134
  return res;
122
135
}
123
 
int setup_conds(Session *session, TableList *leaves, COND **conds);
 
136
int setup_conds(Session *session, TableList *tables, TableList *leaves,
 
137
                COND **conds);
 
138
int setup_ftfuncs(Select_Lex* select);
 
139
int init_ftfuncs(Session *session, Select_Lex* select, bool no_order);
 
140
void wait_for_condition(Session *session, pthread_mutex_t *mutex,
 
141
                        pthread_cond_t *cond);
 
142
int open_tables(Session *session, TableList **tables, uint32_t *counter, uint32_t flags);
124
143
/* open_and_lock_tables with optional derived handling */
 
144
int open_and_lock_tables_derived(Session *session, TableList *tables, bool derived);
 
145
/* simple open_and_lock_tables without derived handling */
 
146
inline int simple_open_n_lock_tables(Session *session, TableList *tables)
 
147
{
 
148
  return open_and_lock_tables_derived(session, tables, false);
 
149
}
 
150
/* open_and_lock_tables with derived handling */
 
151
inline int open_and_lock_tables(Session *session, TableList *tables)
 
152
{
 
153
  return open_and_lock_tables_derived(session, tables, true);
 
154
}
 
155
/* simple open_and_lock_tables without derived handling for single table */
 
156
Table *open_n_lock_single_table(Session *session, TableList *table_l,
 
157
                                thr_lock_type lock_type);
 
158
bool open_normal_and_derived_tables(Session *session, TableList *tables, uint32_t flags);
 
159
int lock_tables(Session *session, TableList *tables, uint32_t counter, bool *need_reopen);
 
160
int decide_logging_format(Session *session);
 
161
Table *open_temporary_table(Session *session, const char *path, const char *db,
 
162
                            const char *table_name, bool link_in_list,
 
163
                            open_table_mode open_mode);
 
164
bool rm_temporary_table(handlerton *base, char *path);
 
165
void free_io_cache(Table *entry);
 
166
void intern_close_table(Table *entry);
 
167
bool close_thread_table(Session *session, Table **table_ptr);
 
168
void close_temporary_tables(Session *session);
 
169
void close_tables_for_reopen(Session *session, TableList **tables);
125
170
TableList *find_table_in_list(TableList *table,
126
171
                               TableList *TableList::*link,
127
172
                               const char *db_name,
128
173
                               const char *table_name);
129
 
TableList *unique_table(TableList *table, TableList *table_list,
130
 
                        bool check_alias= false);
 
174
TableList *unique_table(Session *session, TableList *table, TableList *table_list,
 
175
                         bool check_alias);
 
176
Table *find_temporary_table(Session *session, const char *db, const char *table_name);
 
177
Table *find_temporary_table(Session *session, TableList *table_list);
 
178
int drop_temporary_table(Session *session, TableList *table_list);
 
179
void close_temporary_table(Session *session, Table *table, bool free_share,
 
180
                           bool delete_table);
 
181
void close_temporary(Table *table, bool free_share, bool delete_table);
 
182
bool rename_temporary_table(Session* session, Table *table, const char *new_db,
 
183
                            const char *table_name);
131
184
void remove_db_from_cache(const char *db);
 
185
void flush_tables();
 
186
bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
132
187
 
133
188
/* bits for last argument to remove_table_from_cache() */
134
189
#define RTFC_NO_FLAG                0x0000
138
193
bool remove_table_from_cache(Session *session, const char *db, const char *table,
139
194
                             uint32_t flags);
140
195
 
 
196
#define NORMAL_PART_NAME 0
 
197
#define TEMP_PART_NAME 1
 
198
#define RENAMED_PART_NAME 2
 
199
 
141
200
void mem_alloc_error(size_t size);
142
201
 
143
 
bool fill_record(Session* session, List<Item> &fields, List<Item> &values, bool ignore_errors= false);
144
 
bool fill_record(Session *session, Field **field, List<Item> &values, bool ignore_errors= false);
145
 
bool list_open_tables(const char *db,
146
 
                      const char *wild,
147
 
                      bool(*func)(Table *table,
148
 
                                  open_table_list_st& open_list,
149
 
                                  drizzled::plugin::InfoSchemaTable *schema_table),
150
 
                      Table *display,
151
 
                      drizzled::plugin::InfoSchemaTable *schema_table);
 
202
#define WFRM_WRITE_SHADOW 1
 
203
#define WFRM_INSTALL_SHADOW 2
 
204
#define WFRM_PACK_FRM 4
 
205
#define WFRM_KEEP_SHARE 8
 
206
 
 
207
bool close_cached_tables(Session *session, TableList *tables, bool have_lock,
 
208
                         bool wait_for_refresh, bool wait_for_placeholders);
 
209
bool close_cached_connection_tables(Session *session, bool wait_for_refresh,
 
210
                                    LEX_STRING *connect_string,
 
211
                                    bool have_lock= false);
 
212
void copy_field_from_tmp_record(Field *field,int offset);
 
213
bool fill_record(Session * session, List<Item> &fields, List<Item> &values, bool ignore_errors);
 
214
bool fill_record(Session *session, Field **field, List<Item> &values, bool ignore_errors);
 
215
OPEN_TableList *list_open_tables(const char *db, const char *wild);
152
216
 
153
217
inline TableList *find_table_in_global_list(TableList *table,
154
218
                                             const char *db_name,
157
221
  return find_table_in_list(table, &TableList::next_global,
158
222
                            db_name, table_name);
159
223
}
 
224
 
 
225
inline TableList *find_table_in_local_list(TableList *table,
 
226
                                            const char *db_name,
 
227
                                            const char *table_name)
 
228
{
 
229
  return find_table_in_list(table, &TableList::next_local,
 
230
                            db_name, table_name);
 
231
}
 
232
 
 
233
 
 
234
 
 
235
 
160
236
#endif /* DRIZZLED_SQL_BASE_H */