~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/server_includes.h

  • Committer: Monty Taylor
  • Date: 2008-11-13 22:41:09 UTC
  • mto: (589.1.3 devel) (584.1.7 devel)
  • mto: This revision was merged to the branch mainline in revision 585.
  • Revision ID: monty@inaugust.com-20081113224109-4rkzdtn5f2ppzf9q
Check gnu ld status rather than gcc status (you never know)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#ifndef DRIZZLED_SERVER_INCLUDES_H
31
31
#define DRIZZLED_SERVER_INCLUDES_H
32
32
 
33
 
/* Cross-platform portability code and standard includes */
34
 
#include <drizzled/global.h>
35
 
/* Contains system-wide constants and #defines */
36
 
#include <drizzled/definitions.h>
37
 
/* System-wide common data structures */
38
 
#include <drizzled/structs.h>
39
 
/* Defines for the storage engine handler -- i.e. HA_XXX defines */
40
 
/* Needed by field.h */
41
 
#include <drizzled/base.h>
42
 
 
43
 
/* Lots of system-wide struct definitions like IO_CACHE,
44
 
   prototypes for all my_* functions */
45
 
#include <mysys/my_sys.h>
46
 
/* Custom C string functions */
47
 
#include <mystrings/m_string.h>
48
 
 
49
 
/* The <strong>INTERNAL</strong> plugin API - not the external, or public, server plugin API */
50
 
#include <drizzled/sql_plugin.h>
 
33
/* Some forward declarations just for the server */
 
34
 
 
35
class Comp_creator;
 
36
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
 
37
 
 
38
/**
 
39
 * Contains all headers, definitions, and declarations common to
 
40
 * the server and the plugin infrastructure, and not the client
 
41
 */
 
42
#include <drizzled/common_includes.h>
51
43
/* Range optimization API/library */
52
44
#include <drizzled/opt_range.h>
53
45
/* Simple error injection (crash) module */
54
46
#include <drizzled/error_injection.h>
 
47
/* API for connecting, logging in to a drizzled server */
 
48
#include <drizzled/connect.h>
55
49
/* Routines for dropping, repairing, checking schema tables */
56
50
#include <drizzled/sql_table.h>
57
 
#include <drizzled/log.h>
58
 
 
59
 
#include <string>
60
 
#include <bitset>
61
 
 
62
 
 
63
 
extern const CHARSET_INFO *system_charset_info, *files_charset_info ;
64
 
extern const CHARSET_INFO *national_charset_info, *table_alias_charset;
65
 
 
66
 
typedef class st_select_lex SELECT_LEX;
67
 
typedef struct st_mysql_lock DRIZZLE_LOCK;
68
 
typedef struct st_ha_create_information HA_CREATE_INFO;
69
51
 
70
52
/* information schema */
71
53
static const std::string INFORMATION_SCHEMA_NAME("information_schema");
74
56
#define is_schema_db(X) \
75
57
  !my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X))
76
58
 
 
59
/* sql_base.cc */
 
60
#define TMP_TABLE_KEY_EXTRA 8
 
61
void set_item_name(Item *item,char *pos,uint32_t length);
 
62
bool add_field_to_list(Session *session, LEX_STRING *field_name, enum enum_field_types type,
 
63
                       char *length, char *decimal,
 
64
                       uint32_t type_modifier,
 
65
                       enum column_format_type column_format,
 
66
                       Item *default_value, Item *on_update_value,
 
67
                       LEX_STRING *comment,
 
68
                       char *change, List<String> *interval_list,
 
69
                       const CHARSET_INFO * const cs,
 
70
                       virtual_column_info *vcol_info);
 
71
Create_field * new_create_field(Session *session, char *field_name, enum_field_types type,
 
72
                                char *length, char *decimals,
 
73
                                uint32_t type_modifier, 
 
74
                                Item *default_value, Item *on_update_value,
 
75
                                LEX_STRING *comment, char *change, 
 
76
                                List<String> *interval_list, CHARSET_INFO *cs,
 
77
                                virtual_column_info *vcol_info);
 
78
void store_position_for_column(const char *name);
 
79
bool add_to_list(Session *session, SQL_LIST &list,Item *group,bool asc);
 
80
bool push_new_name_resolution_context(Session *session,
 
81
                                      TableList *left_op,
 
82
                                      TableList *right_op);
 
83
void add_join_on(TableList *b,Item *expr);
 
84
void add_join_natural(TableList *a,TableList *b,List<String> *using_fields,
 
85
                      SELECT_LEX *lex);
 
86
bool add_proc_to_list(Session *session, Item *item);
 
87
void unlink_open_table(Session *session, Table *find, bool unlock);
 
88
void drop_open_table(Session *session, Table *table, const char *db_name,
 
89
                     const char *table_name);
 
90
void update_non_unique_table_error(TableList *update,
 
91
                                   const char *operation,
 
92
                                   TableList *duplicate);
 
93
 
 
94
SQL_SELECT *make_select(Table *head, table_map const_tables,
 
95
                        table_map read_tables, COND *conds,
 
96
                        bool allow_null_cond,  int *error);
 
97
extern Item **not_found_item;
 
98
 
 
99
/*
 
100
  A set of constants used for checking non aggregated fields and sum
 
101
  functions mixture in the ONLY_FULL_GROUP_BY_MODE.
 
102
*/
 
103
#define NON_AGG_FIELD_USED  1
 
104
#define SUM_FUNC_USED       2
 
105
 
 
106
/*
 
107
  This enumeration type is used only by the function find_item_in_list
 
108
  to return the info on how an item has been resolved against a list
 
109
  of possibly aliased items.
 
110
  The item can be resolved: 
 
111
   - against an alias name of the list's element (RESOLVED_AGAINST_ALIAS)
 
112
   - against non-aliased field name of the list  (RESOLVED_WITH_NO_ALIAS)
 
113
   - against an aliased field name of the list   (RESOLVED_BEHIND_ALIAS)
 
114
   - ignoring the alias name in cases when SQL requires to ignore aliases
 
115
     (e.g. when the resolved field reference contains a table name or
 
116
     when the resolved item is an expression)   (RESOLVED_IGNORING_ALIAS)    
 
117
*/
 
118
enum enum_resolution_type {
 
119
  NOT_RESOLVED=0,
 
120
  RESOLVED_IGNORING_ALIAS,
 
121
  RESOLVED_BEHIND_ALIAS,
 
122
  RESOLVED_WITH_NO_ALIAS,
 
123
  RESOLVED_AGAINST_ALIAS
 
124
};
 
125
Item ** find_item_in_list(Item *item, List<Item> &items, uint32_t *counter,
 
126
                          find_item_error_report_type report_error,
 
127
                          enum_resolution_type *resolution);
 
128
bool get_key_map_from_key_list(key_map *map, Table *table,
 
129
                               List<String> *index_list);
 
130
bool insert_fields(Session *session, Name_resolution_context *context,
 
131
                   const char *db_name, const char *table_name,
 
132
                   List_iterator<Item> *it, bool any_privileges);
 
133
bool setup_tables(Session *session, Name_resolution_context *context,
 
134
                  List<TableList> *from_clause, TableList *tables,
 
135
                  TableList **leaves, bool select_insert);
 
136
bool setup_tables_and_check_access(Session *session, 
 
137
                                   Name_resolution_context *context,
 
138
                                   List<TableList> *from_clause, 
 
139
                                   TableList *tables, 
 
140
                                   TableList **leaves, 
 
141
                                   bool select_insert);
 
142
int setup_wild(Session *session, TableList *tables, List<Item> &fields,
 
143
               List<Item> *sum_func_list, uint32_t wild_num);
 
144
bool setup_fields(Session *session, Item** ref_pointer_array,
 
145
                  List<Item> &item, enum_mark_columns mark_used_columns,
 
146
                  List<Item> *sum_func_list, bool allow_sum_func);
 
147
inline bool setup_fields_with_no_wrap(Session *session, Item **ref_pointer_array,
 
148
                                      List<Item> &item,
 
149
                                      enum_mark_columns mark_used_columns,
 
150
                                      List<Item> *sum_func_list,
 
151
                                      bool allow_sum_func)
 
152
{
 
153
  bool res;
 
154
  res= setup_fields(session, ref_pointer_array, item, mark_used_columns, sum_func_list,
 
155
                    allow_sum_func);
 
156
  return res;
 
157
}
 
158
int setup_conds(Session *session, TableList *tables, TableList *leaves,
 
159
                COND **conds);
 
160
int setup_ftfuncs(SELECT_LEX* select);
 
161
int init_ftfuncs(Session *session, SELECT_LEX* select, bool no_order);
 
162
void wait_for_condition(Session *session, pthread_mutex_t *mutex,
 
163
                        pthread_cond_t *cond);
 
164
int open_tables(Session *session, TableList **tables, uint32_t *counter, uint32_t flags);
 
165
/* open_and_lock_tables with optional derived handling */
 
166
int open_and_lock_tables_derived(Session *session, TableList *tables, bool derived);
 
167
/* simple open_and_lock_tables without derived handling */
 
168
inline int simple_open_n_lock_tables(Session *session, TableList *tables)
 
169
{
 
170
  return open_and_lock_tables_derived(session, tables, false);
 
171
}
 
172
/* open_and_lock_tables with derived handling */
 
173
inline int open_and_lock_tables(Session *session, TableList *tables)
 
174
{
 
175
  return open_and_lock_tables_derived(session, tables, true);
 
176
}
 
177
/* simple open_and_lock_tables without derived handling for single table */
 
178
Table *open_n_lock_single_table(Session *session, TableList *table_l,
 
179
                                thr_lock_type lock_type);
 
180
bool open_normal_and_derived_tables(Session *session, TableList *tables, uint32_t flags);
 
181
int lock_tables(Session *session, TableList *tables, uint32_t counter, bool *need_reopen);
 
182
int decide_logging_format(Session *session);
 
183
Table *open_temporary_table(Session *session, const char *path, const char *db,
 
184
                            const char *table_name, bool link_in_list,
 
185
                            open_table_mode open_mode);
 
186
bool rm_temporary_table(handlerton *base, char *path, bool frm_only);
 
187
void free_io_cache(Table *entry);
 
188
void intern_close_table(Table *entry);
 
189
bool close_thread_table(Session *session, Table **table_ptr);
 
190
void close_temporary_tables(Session *session);
 
191
void close_tables_for_reopen(Session *session, TableList **tables);
 
192
TableList *find_table_in_list(TableList *table,
 
193
                               TableList *TableList::*link,
 
194
                               const char *db_name,
 
195
                               const char *table_name);
 
196
TableList *unique_table(Session *session, TableList *table, TableList *table_list,
 
197
                         bool check_alias);
 
198
Table *find_temporary_table(Session *session, const char *db, const char *table_name);
 
199
Table *find_temporary_table(Session *session, TableList *table_list);
 
200
int drop_temporary_table(Session *session, TableList *table_list);
 
201
void close_temporary_table(Session *session, Table *table, bool free_share,
 
202
                           bool delete_table);
 
203
void close_temporary(Table *table, bool free_share, bool delete_table);
 
204
bool rename_temporary_table(Session* session, Table *table, const char *new_db,
 
205
                            const char *table_name);
 
206
void remove_db_from_cache(const char *db);
 
207
void flush_tables();
 
208
bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
 
209
char *make_default_log_name(char *buff,const char* log_ext);
 
210
 
 
211
/* bits for last argument to remove_table_from_cache() */
 
212
#define RTFC_NO_FLAG                0x0000
 
213
#define RTFC_OWNED_BY_Session_FLAG      0x0001
 
214
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
 
215
#define RTFC_CHECK_KILLED_FLAG      0x0004
 
216
bool remove_table_from_cache(Session *session, const char *db, const char *table,
 
217
                             uint32_t flags);
 
218
 
 
219
#define NORMAL_PART_NAME 0
 
220
#define TEMP_PART_NAME 1
 
221
#define RENAMED_PART_NAME 2
 
222
 
 
223
void mem_alloc_error(size_t size);
 
224
 
 
225
#define WFRM_WRITE_SHADOW 1
 
226
#define WFRM_INSTALL_SHADOW 2
 
227
#define WFRM_PACK_FRM 4
 
228
#define WFRM_KEEP_SHARE 8
 
229
 
 
230
bool close_cached_tables(Session *session, TableList *tables, bool have_lock,
 
231
                         bool wait_for_refresh, bool wait_for_placeholders);
 
232
bool close_cached_connection_tables(Session *session, bool wait_for_refresh,
 
233
                                    LEX_STRING *connect_string,
 
234
                                    bool have_lock= false);
 
235
void copy_field_from_tmp_record(Field *field,int offset);
 
236
bool fill_record(Session * session, List<Item> &fields, List<Item> &values, bool ignore_errors);
 
237
bool fill_record(Session *session, Field **field, List<Item> &values, bool ignore_errors);
 
238
OPEN_TableList *list_open_tables(Session *session, const char *db, const char *wild);
 
239
 
 
240
inline TableList *find_table_in_global_list(TableList *table,
 
241
                                             const char *db_name,
 
242
                                             const char *table_name)
 
243
{
 
244
  return find_table_in_list(table, &TableList::next_global,
 
245
                            db_name, table_name);
 
246
}
 
247
 
 
248
inline TableList *find_table_in_local_list(TableList *table,
 
249
                                            const char *db_name,
 
250
                                            const char *table_name)
 
251
{
 
252
  return find_table_in_list(table, &TableList::next_local,
 
253
                            db_name, table_name);
 
254
}
 
255
 
 
256
 
 
257
/* sql_calc.cc */
 
258
bool eval_const_cond(COND *cond);
 
259
 
 
260
/* sql_load.cc */
 
261
int mysql_load(Session *session, sql_exchange *ex, TableList *table_list,
 
262
                List<Item> &fields_vars, List<Item> &set_fields,
 
263
                List<Item> &set_values_list,
 
264
                enum enum_duplicates handle_duplicates, bool ignore,
 
265
                bool local_file);
 
266
int write_record(Session *session, Table *table, COPY_INFO *info);
 
267
 
 
268
 
77
269
/* sql_test.cc */
78
270
void print_where(COND *cond,const char *info, enum_query_type query_type);
79
271
void print_cached_tables(void);
 
272
void TEST_filesort(SORT_FIELD *sortorder,uint32_t s_length);
80
273
void print_plan(JOIN* join,uint32_t idx, double record_count, double read_time,
81
274
                double current_read_time, const char *info);
82
275
void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array);
83
276
void dump_TableList_graph(SELECT_LEX *select_lex, TableList* tl);
84
277
void mysql_print_status();
85
278
 
 
279
/* key.cc */
 
280
int find_ref_key(KEY *key, uint32_t key_count, unsigned char *record, Field *field,
 
281
                 uint32_t *key_length, uint32_t *keypart);
 
282
void key_copy(unsigned char *to_key, unsigned char *from_record, KEY *key_info, uint32_t key_length);
 
283
void key_restore(unsigned char *to_record, unsigned char *from_key, KEY *key_info,
 
284
                 uint16_t key_length);
 
285
void key_zero_nulls(unsigned char *tuple, KEY *key_info);
 
286
bool key_cmp_if_same(Table *form,const unsigned char *key,uint32_t index,uint32_t key_length);
 
287
void key_unpack(String *to,Table *form,uint32_t index);
 
288
bool is_key_used(Table *table, uint32_t idx, const MY_BITMAP *fields);
 
289
int key_cmp(KEY_PART_INFO *key_part, const unsigned char *key, uint32_t key_length);
 
290
extern "C" int key_rec_cmp(void *key_info, unsigned char *a, unsigned char *b);
86
291
 
87
292
bool init_errmessage(void);
88
293
File open_binlog(IO_CACHE *log, const char *log_file_name,
117
322
 
118
323
bool is_keyword(const char *name, uint32_t len);
119
324
 
 
325
#define MY_DB_OPT_FILE "db.opt"
 
326
bool my_database_names_init(void);
 
327
void my_database_names_free(void);
 
328
bool check_db_dir_existence(const char *db_name);
 
329
bool load_db_opt(Session *session, const char *path, HA_CREATE_INFO *create);
 
330
bool load_db_opt_by_name(Session *session, const char *db_name,
 
331
                         HA_CREATE_INFO *db_create_info);
 
332
const CHARSET_INFO *get_default_db_collation(Session *session, const char *db_name);
 
333
bool my_dbopt_init(void);
 
334
void my_dbopt_cleanup(void);
 
335
extern int creating_database; // How many database locks are made
 
336
extern int creating_table;    // How many mysql_create_table() are running
 
337
 
120
338
/*
121
339
  External variables
122
340
*/
123
341
 
124
342
extern time_t server_start_time, flush_status_time;
125
343
extern char *opt_drizzle_tmpdir;
126
 
 
 
344
            
127
345
#define drizzle_tmpdir (my_tmpdir(&drizzle_tmpdir_list))
128
346
extern MY_TMPDIR drizzle_tmpdir_list;
129
347
extern const LEX_STRING command_name[];
132
350
extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
133
351
extern const char * const TRG_EXT;
134
352
extern const char * const TRN_EXT;
 
353
extern Eq_creator eq_creator;
 
354
extern Ne_creator ne_creator;
 
355
extern Gt_creator gt_creator;
 
356
extern Lt_creator lt_creator;
 
357
extern Ge_creator ge_creator;
 
358
extern Le_creator le_creator;
135
359
extern char language[FN_REFLEN];
136
360
extern char glob_hostname[FN_REFLEN], drizzle_home[FN_REFLEN];
137
361
extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
141
365
extern uint64_t keybuff_size;
142
366
extern uint64_t session_startup_options;
143
367
extern ulong thread_id;
144
 
extern uint64_t binlog_cache_use;
145
 
extern uint64_t binlog_cache_disk_use;
146
 
extern uint64_t aborted_threads;
147
 
extern uint64_t aborted_connects;
148
 
extern uint64_t slave_open_temp_tables;
149
 
extern uint64_t slow_launch_threads;
150
 
extern uint64_t slow_launch_time;
151
 
extern uint64_t table_cache_size;
152
 
extern uint64_t table_def_size;
153
 
extern uint64_t max_connections;
154
 
extern uint64_t max_connect_errors;
155
 
extern uint64_t connect_timeout;
 
368
extern ulong binlog_cache_use, binlog_cache_disk_use;
 
369
extern ulong aborted_threads,aborted_connects;
 
370
extern ulong slave_open_temp_tables;
 
371
extern ulong slow_launch_threads, slow_launch_time;
 
372
extern ulong table_cache_size, table_def_size;
 
373
extern ulong max_connections,max_connect_errors, connect_timeout;
156
374
extern bool slave_allow_batching;
157
 
extern uint64_t slave_net_timeout;
158
 
extern uint64_t slave_trans_retries;
 
375
extern ulong slave_net_timeout, slave_trans_retries;
159
376
extern uint32_t max_user_connections;
160
 
extern ulong what_to_log;
161
 
extern uint64_t binlog_cache_size;
162
 
extern uint64_t max_binlog_cache_size;
163
 
extern uint64_t open_files_limit;
164
 
extern uint64_t max_binlog_size;
165
 
extern uint64_t max_relay_log_size;
166
 
extern uint64_t opt_binlog_rows_event_max_size;
167
 
extern uint64_t thread_pool_size;
168
 
extern uint32_t back_log;
169
 
extern pid_t current_pid;
170
 
extern uint64_t expire_logs_days;
171
 
extern uint64_t sync_binlog_period;
172
 
extern uint64_t tc_log_max_pages_used;
173
 
extern uint64_t tc_log_page_size;
174
 
extern uint64_t opt_tc_log_size;
175
 
extern uint64_t tc_log_page_waits;
 
377
extern ulong what_to_log,flush_time;
 
378
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
 
379
extern ulong max_binlog_size, max_relay_log_size;
 
380
extern ulong opt_binlog_rows_event_max_size;
 
381
extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
 
382
extern ulong back_log;
 
383
extern ulong current_pid;
 
384
extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
 
385
extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
 
386
extern ulong tc_log_page_waits;
176
387
extern bool relay_log_purge;
177
388
extern bool opt_innodb_safe_binlog, opt_innodb;
178
389
extern uint32_t test_flags,select_errors,ha_open_options;
183
394
extern bool opt_using_transactions;
184
395
extern bool using_update_log, server_id_supplied;
185
396
extern bool opt_update_log, opt_bin_log, opt_error_log;
186
 
extern bool opt_log;
 
397
extern bool opt_log; 
187
398
extern bool opt_slow_log;
188
399
extern ulong log_output_options;
189
400
extern bool opt_log_queries_not_using_indexes;
208
419
extern char *opt_logname, *opt_slow_logname;
209
420
extern const char *log_output_str;
210
421
 
211
 
extern DRIZZLE_BIN_LOG drizzle_bin_log;
 
422
extern DRIZZLE_BIN_LOG mysql_bin_log;
 
423
extern LOGGER logger;
212
424
extern TableList general_log, slow_log;
213
425
extern FILE *stderror_file;
 
426
extern pthread_key_t THR_MALLOC;
214
427
extern pthread_mutex_t LOCK_drizzle_create_db,LOCK_open, LOCK_lock_db,
215
428
       LOCK_thread_count,LOCK_user_locks, LOCK_status,
216
429
       LOCK_error_log, LOCK_uuid_generator,
219
432
       LOCK_global_system_variables, LOCK_user_conn,
220
433
       LOCK_bytes_sent, LOCK_bytes_received, LOCK_connection_count;
221
434
extern pthread_mutex_t LOCK_server_started;
222
 
extern pthread_rwlock_t LOCK_sys_init_connect;
223
 
extern pthread_rwlock_t LOCK_sys_init_slave;
224
 
extern pthread_rwlock_t LOCK_system_variables_hash;
 
435
extern rw_lock_t LOCK_sys_init_connect, LOCK_sys_init_slave;
 
436
extern rw_lock_t LOCK_system_variables_hash;
225
437
extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
226
438
extern pthread_cond_t COND_global_read_lock;
227
439
extern pthread_attr_t connection_attrib;
228
440
extern I_List<Session> threads;
 
441
extern I_List<NAMED_LIST> key_caches;
229
442
extern MY_BITMAP temp_pool;
230
443
extern String my_empty_string;
231
444
extern const String my_null_string;
237
450
extern const char *opt_date_time_formats[];
238
451
extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
239
452
 
 
453
extern HASH open_cache, lock_db_cache;
240
454
extern Table *unused_tables;
241
455
extern const char* any_db;
242
456
extern struct my_option my_long_options[];
243
457
extern const LEX_STRING view_type;
244
458
extern TYPELIB thread_handling_typelib;
245
459
extern uint8_t uc_update_queries[SQLCOM_END+1];
246
 
extern std::bitset<5> sql_command_flags[];
 
460
extern uint32_t sql_command_flags[];
247
461
extern TYPELIB log_output_typelib;
248
462
 
249
463
/* optional things, have_* variables */
303
517
void unlock_table_names(Session *session, TableList *table_list,
304
518
                        TableList *last_table);
305
519
bool lock_table_names_exclusively(Session *session, TableList *table_list);
306
 
bool is_table_name_exclusively_locked_by_this_thread(Session *session,
 
520
bool is_table_name_exclusively_locked_by_this_thread(Session *session, 
307
521
                                                     TableList *table_list);
308
522
bool is_table_name_exclusively_locked_by_this_thread(Session *session, unsigned char *key,
309
523
                                                     int key_length);
315
529
void unireg_end(void) __attribute__((noreturn));
316
530
bool mysql_create_frm(Session *session, const char *file_name,
317
531
                      const char *db, const char *table,
318
 
                      HA_CREATE_INFO *create_info,
319
 
                      List<Create_field> &create_field,
320
 
                      uint32_t key_count,KEY *key_info,handler *db_type);
 
532
                      HA_CREATE_INFO *create_info,
 
533
                      List<Create_field> &create_field,
 
534
                      uint32_t key_count,KEY *key_info,handler *db_type);
321
535
int rea_create_table(Session *session, const char *path,
322
536
                     const char *db, const char *table_name,
323
537
                     HA_CREATE_INFO *create_info,
324
 
                     List<Create_field> &create_field,
 
538
                     List<Create_field> &create_field,
325
539
                     uint32_t key_count,KEY *key_info,
326
540
                     handler *file);
327
541
int format_number(uint32_t inputflag,uint32_t max_length,char * pos,uint32_t length,
374
588
                                               DATE_TIME_FORMAT *format);
375
589
const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
376
590
                                                             enum enum_drizzle_timestamp_type type);
 
591
extern bool make_date_time(DATE_TIME_FORMAT *format, DRIZZLE_TIME *l_time,
 
592
                                             enum enum_drizzle_timestamp_type type, String *str);
377
593
void make_datetime(const DATE_TIME_FORMAT *format, const DRIZZLE_TIME *l_time,
378
594
                   String *str);
379
595
void make_date(const DATE_TIME_FORMAT *format, const DRIZZLE_TIME *l_time,
389
605
void init_read_record(READ_RECORD *info, Session *session, Table *reg_form,
390
606
                      SQL_SELECT *select,
391
607
                      int use_record_cache, bool print_errors);
392
 
void init_read_record_idx(READ_RECORD *info, Session *session, Table *table,
 
608
void init_read_record_idx(READ_RECORD *info, Session *session, Table *table, 
393
609
                          bool print_error, uint32_t idx);
394
610
void end_read_record(READ_RECORD *info);
395
611
ha_rows filesort(Session *session, Table *form,struct st_sort_field *sortorder,
415
631
int create_frm(Session *session, const char *name, const char *db, const char *table,
416
632
               uint32_t reclength, unsigned char *fileinfo,
417
633
               HA_CREATE_INFO *create_info, uint32_t keys, KEY *key_info);
418
 
int rename_table_proto_file(const char *from, const char* to);
419
 
int delete_table_proto_file(char *file_name);
420
634
int rename_file_ext(const char * from,const char * to,const char * ext);
421
635
bool check_db_name(LEX_STRING *db);
422
636
bool check_column_name(const char *name);
446
660
/* log.cc */
447
661
bool flush_error_log(void);
448
662
 
 
663
/* sql_list.cc */
 
664
void free_list(I_List <i_string_pair> *list);
 
665
void free_list(I_List <i_string> *list);
 
666
 
 
667
/* Some inline functions for more speed */
 
668
 
 
669
inline bool add_item_to_list(Session *session, Item *item)
 
670
{
 
671
  return session->lex->current_select->add_item_to_list(session, item);
 
672
}
 
673
 
 
674
inline bool add_value_to_list(Session *session, Item *value)
 
675
{
 
676
  return session->lex->value_list.push_back(value);
 
677
}
 
678
 
 
679
inline bool add_order_to_list(Session *session, Item *item, bool asc)
 
680
{
 
681
  return session->lex->current_select->add_order_to_list(session, item, asc);
 
682
}
 
683
 
 
684
inline bool add_group_to_list(Session *session, Item *item, bool asc)
 
685
{
 
686
  return session->lex->current_select->add_group_to_list(session, item, asc);
 
687
}
 
688
 
 
689
inline void mark_as_null_row(Table *table)
 
690
{
 
691
  table->null_row=1;
 
692
  table->status|=STATUS_NULL_ROW;
 
693
  memset(table->null_flags, 255, table->s->null_bytes);
 
694
}
449
695
 
450
696
inline ulong sql_rnd()
451
697
{
454
700
  return tmp;
455
701
}
456
702
 
457
 
 
 
703
Comp_creator *comp_eq_creator(bool invert);
 
704
Comp_creator *comp_ge_creator(bool invert);
 
705
Comp_creator *comp_gt_creator(bool invert);
 
706
Comp_creator *comp_le_creator(bool invert);
 
707
Comp_creator *comp_lt_creator(bool invert);
 
708
Comp_creator *comp_ne_creator(bool invert);
 
709
 
 
710
Item * all_any_subquery_creator(Item *left_expr,
 
711
                                chooser_compare_func_creator cmp,
 
712
                                bool all,
 
713
                                SELECT_LEX *select_lex);
 
714
 
 
715
/**
 
716
  clean/setup table fields and map.
 
717
 
 
718
  @param table        Table structure pointer (which should be setup)
 
719
  @param table_list   TableList structure pointer (owner of Table)
 
720
  @param tablenr     table number
 
721
*/
 
722
inline void setup_table_map(Table *table, TableList *table_list, uint32_t tablenr)
 
723
{
 
724
  table->used_fields= 0;
 
725
  table->const_table= 0;
 
726
  table->null_row= 0;
 
727
  table->status= STATUS_NO_RECORD;
 
728
  table->maybe_null= table_list->outer_join;
 
729
  TableList *embedding= table_list->embedding;
 
730
  while (!table->maybe_null && embedding)
 
731
  {
 
732
    table->maybe_null= embedding->outer_join;
 
733
    embedding= embedding->embedding;
 
734
  }
 
735
  table->tablenr= tablenr;
 
736
  table->map= (table_map) 1 << tablenr;
 
737
  table->force_index= table_list->force_index;
 
738
  table->covering_keys= table->s->keys_for_keyread;
 
739
  table->merge_keys.clear_all();
 
740
}
 
741
 
 
742
#include <drizzled/item_create.h>         /* Factory API for creating Item_* instances */
458
743
 
459
744
/**
460
745
  convert a hex digit into number.