~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.h

  • Committer: Stewart Smith
  • Date: 2009-06-16 06:55:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1094.
  • Revision ID: stewart@flamingspork.com-20090616065511-ps3ewfxj7918lwy3
rollback.test for MyISAM temp only.
- rename to myisam_rollback to reflect what it's testing
- just use create temporary table

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef DRIZZLED_SQL_BASE_H
21
21
#define DRIZZLED_SQL_BASE_H
22
22
 
 
23
#include <stdint.h>
23
24
#include <drizzled/table.h>
24
 
#include <drizzled/table/concurrent.h>
25
25
 
26
 
namespace drizzled
27
 
{
28
26
class TableShare;
29
 
class Name_resolution_context;
30
27
 
31
28
void table_cache_free(void);
32
29
bool table_cache_init(void);
 
30
bool table_def_init(void);
 
31
void table_def_free(void);
 
32
void assign_new_table_id(TableShare *share);
33
33
uint32_t cached_open_tables(void);
34
34
uint32_t cached_table_definitions(void);
35
35
 
36
 
table::Cache &get_open_cache();
37
 
 
38
36
void kill_drizzle(void);
39
37
 
40
38
/* sql_base.cc */
41
39
void set_item_name(Item *item,char *pos,uint32_t length);
42
40
bool add_field_to_list(Session *session, LEX_STRING *field_name, enum enum_field_types type,
43
 
                       char *length, char *decimal,
44
 
                       uint32_t type_modifier,
45
 
                       enum column_format_type column_format,
46
 
                       Item *default_value, Item *on_update_value,
47
 
                       LEX_STRING *comment,
48
 
                       char *change, List<String> *interval_list,
49
 
                       const CHARSET_INFO * const cs);
 
41
                       char *length, char *decimal,
 
42
                       uint32_t type_modifier,
 
43
           enum column_format_type column_format,
 
44
                       Item *default_value, Item *on_update_value,
 
45
                       LEX_STRING *comment,
 
46
                       char *change, List<String> *interval_list,
 
47
                       const CHARSET_INFO * const cs);
50
48
CreateField * 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);
 
49
                                char *length, char *decimals,
 
50
                                uint32_t type_modifier,
 
51
                                Item *default_value, Item *on_update_value,
 
52
                                LEX_STRING *comment, char *change,
 
53
                                List<String> *interval_list, CHARSET_INFO *cs);
56
54
void store_position_for_column(const char *name);
 
55
bool add_to_list(Session *session, SQL_LIST &list,Item *group,bool asc);
57
56
bool push_new_name_resolution_context(Session *session,
58
57
                                      TableList *left_op,
59
58
                                      TableList *right_op);
60
59
void add_join_on(TableList *b,Item *expr);
61
60
void add_join_natural(TableList *a,TableList *b,List<String> *using_fields,
62
61
                      Select_Lex *lex);
 
62
void unlink_open_table(Session *session, Table *find);
 
63
void drop_open_table(Session *session, Table *table, const char *db_name,
 
64
                     const char *table_name);
 
65
 
 
66
SQL_SELECT *make_select(Table *head, table_map const_tables,
 
67
                        table_map read_tables, COND *conds,
 
68
                        bool allow_null_cond,  int *error);
63
69
extern Item **not_found_item;
64
70
 
65
71
/**
66
72
  A set of constants used for checking non aggregated fields and sum
67
73
  functions mixture in the ONLY_FULL_GROUP_BY_MODE.
68
74
*/
69
 
enum enum_group_by_mode_type
70
 
{
71
 
  NON_AGG_FIELD_USED= 0,
72
 
  SUM_FUNC_USED
73
 
};
 
75
#define NON_AGG_FIELD_USED  1
 
76
#define SUM_FUNC_USED       2
74
77
 
75
78
/**
76
79
  This enumeration type is used only by the function find_item_in_list
91
94
  RESOLVED_WITH_NO_ALIAS,
92
95
  RESOLVED_AGAINST_ALIAS
93
96
};
94
 
Item ** find_item_in_list(Session *session,
95
 
                          Item *item, List<Item> &items, uint32_t *counter,
 
97
Item ** find_item_in_list(Item *item, List<Item> &items, uint32_t *counter,
96
98
                          find_item_error_report_type report_error,
97
99
                          enum_resolution_type *resolution);
 
100
bool get_key_map_from_key_list(key_map *map, Table *table,
 
101
                               List<String> *index_list);
98
102
bool insert_fields(Session *session, Name_resolution_context *context,
99
 
                   const char *db_name, const char *table_name,
 
103
                   const char *db_name, const char *table_name,
100
104
                   List_iterator<Item> *it, bool any_privileges);
101
105
bool setup_tables(Session *session, Name_resolution_context *context,
102
106
                  List<TableList> *from_clause, TableList *tables,
125
129
  return res;
126
130
}
127
131
int setup_conds(Session *session, TableList *leaves, COND **conds);
 
132
int setup_ftfuncs(Select_Lex* select);
 
133
int init_ftfuncs(Session *session, Select_Lex* select, bool no_order);
 
134
void wait_for_condition(Session *session, pthread_mutex_t *mutex,
 
135
                        pthread_cond_t *cond);
 
136
int open_tables_from_list(Session *session, TableList **tables, uint32_t *counter, uint32_t flags);
128
137
/* open_and_lock_tables with optional derived handling */
 
138
int open_and_lock_tables_derived(Session *session, TableList *tables, bool derived);
 
139
bool open_normal_and_derived_tables(Session *session, TableList *tables, uint32_t flags);
 
140
int lock_tables(Session *session, TableList *tables, uint32_t counter, bool *need_reopen);
 
141
int decide_logging_format(Session *session);
 
142
Table *open_temporary_table(Session *session, const char *path, const char *db,
 
143
                            const char *table_name, bool link_in_list,
 
144
                            open_table_mode open_mode);
 
145
bool rm_temporary_table(StorageEngine *base, char *path);
 
146
void free_io_cache(Table *entry);
 
147
void intern_close_table(Table *entry);
 
148
void close_temporary_tables(Session *session);
 
149
void close_tables_for_reopen(Session *session, TableList **tables);
129
150
TableList *find_table_in_list(TableList *table,
130
151
                               TableList *TableList::*link,
131
152
                               const char *db_name,
132
153
                               const char *table_name);
133
 
TableList *unique_table(TableList *table, TableList *table_list,
134
 
                        bool check_alias= false);
 
154
TableList *unique_table(Session *session, TableList *table, TableList *table_list,
 
155
                         bool check_alias);
 
156
Table *find_temporary_table(Session *session, const char *db, const char *table_name);
 
157
Table *find_temporary_table(Session *session, TableList *table_list);
 
158
int drop_temporary_table(Session *session, TableList *table_list);
 
159
void close_temporary_table(Session *session, Table *table, bool free_share,
 
160
                           bool delete_table);
 
161
void close_temporary(Table *table, bool free_share, bool delete_table);
 
162
bool rename_temporary_table(Table *table, const char *new_db, const char *table_name);
 
163
void remove_db_from_cache(const char *db);
 
164
bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
135
165
 
136
 
/* bits for last argument to table::Cache::singleton().removeTable() */
 
166
/* bits for last argument to remove_table_from_cache() */
137
167
#define RTFC_NO_FLAG                0x0000
138
168
#define RTFC_OWNED_BY_Session_FLAG      0x0001
139
169
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
140
170
#define RTFC_CHECK_KILLED_FLAG      0x0004
 
171
bool remove_table_from_cache(Session *session, const char *db, const char *table,
 
172
                             uint32_t flags);
 
173
 
 
174
#define NORMAL_PART_NAME 0
 
175
#define TEMP_PART_NAME 1
 
176
#define RENAMED_PART_NAME 2
141
177
 
142
178
void mem_alloc_error(size_t size);
143
179
 
144
 
bool fill_record(Session* session, List<Item> &fields, List<Item> &values, bool ignore_errors= false);
145
 
bool fill_record(Session *session, Field **field, List<Item> &values, bool ignore_errors= false);
 
180
#define WFRM_WRITE_SHADOW 1
 
181
#define WFRM_INSTALL_SHADOW 2
 
182
#define WFRM_PACK_FRM 4
 
183
#define WFRM_KEEP_SHARE 8
 
184
 
 
185
bool close_cached_tables(Session *session, TableList *tables,
 
186
                         bool wait_for_refresh, bool wait_for_placeholders);
 
187
void copy_field_from_tmp_record(Field *field,int offset);
 
188
bool fill_record(Session * session, List<Item> &fields, List<Item> &values, bool ignore_errors);
 
189
bool fill_record(Session *session, Field **field, List<Item> &values, bool ignore_errors);
 
190
OPEN_TableList *list_open_tables(const char *db, const char *wild);
 
191
 
146
192
inline TableList *find_table_in_global_list(TableList *table,
147
193
                                             const char *db_name,
148
194
                                             const char *table_name)
151
197
                            db_name, table_name);
152
198
}
153
199
 
154
 
} /* namespace drizzled */
155
 
 
 
200
inline TableList *find_table_in_local_list(TableList *table,
 
201
                                            const char *db_name,
 
202
                                            const char *table_name)
 
203
{
 
204
  return find_table_in_list(table, &TableList::next_local,
 
205
                            db_name, table_name);
 
206
}
156
207
#endif /* DRIZZLED_SQL_BASE_H */