~drizzle-trunk/drizzle/development

575.4.7 by Monty Taylor
More header cleanup.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
#ifndef DRIZZLED_SQL_BASE_H
21
#define DRIZZLED_SQL_BASE_H
22
23
#include <stdint.h>
798.2.22 by Brian Aker
Removing include structures to old replication
24
#include <drizzled/table.h>
575.4.7 by Monty Taylor
More header cleanup.
25
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
26
class TableShare;
575.4.7 by Monty Taylor
More header cleanup.
27
28
void table_cache_free(void);
29
bool table_cache_init(void);
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
30
void assign_new_table_id(TableShare *share);
575.4.7 by Monty Taylor
More header cleanup.
31
uint32_t cached_open_tables(void);
32
uint32_t cached_table_definitions(void);
33
34
void kill_drizzle(void);
35
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
36
/* sql_base.cc */
37
void set_item_name(Item *item,char *pos,uint32_t length);
38
bool add_field_to_list(Session *session, LEX_STRING *field_name, enum enum_field_types type,
39
		       char *length, char *decimal,
40
		       uint32_t type_modifier,
1019.1.4 by Brian Aker
Once again... removed vcol code.
41
           enum column_format_type column_format,
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
42
		       Item *default_value, Item *on_update_value,
43
		       LEX_STRING *comment,
44
		       char *change, List<String> *interval_list,
998.1.2 by Brian Aker
First pass on removing virt columns
45
		       const CHARSET_INFO * const cs);
1052.2.3 by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards.
46
CreateField * new_create_field(Session *session, char *field_name, enum_field_types type,
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
47
				char *length, char *decimals,
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
48
				uint32_t type_modifier,
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
49
				Item *default_value, Item *on_update_value,
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
50
				LEX_STRING *comment, char *change,
1019.1.4 by Brian Aker
Once again... removed vcol code.
51
				List<String> *interval_list, CHARSET_INFO *cs);
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
52
void store_position_for_column(const char *name);
53
bool add_to_list(Session *session, SQL_LIST &list,Item *group,bool asc);
54
bool push_new_name_resolution_context(Session *session,
55
                                      TableList *left_op,
56
                                      TableList *right_op);
57
void add_join_on(TableList *b,Item *expr);
58
void add_join_natural(TableList *a,TableList *b,List<String> *using_fields,
846 by Brian Aker
Removing on typedeffed class.
59
                      Select_Lex *lex);
1054.1.8 by Brian Aker
Remove lock_tables list from session.
60
void unlink_open_table(Session *session, Table *find);
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
61
void drop_open_table(Session *session, Table *table, const char *db_name,
62
                     const char *table_name);
63
64
SQL_SELECT *make_select(Table *head, table_map const_tables,
65
			table_map read_tables, COND *conds,
66
                        bool allow_null_cond,  int *error);
67
extern Item **not_found_item;
68
1055.2.13 by Jay Pipes
Documentation and style fixes in Session class. Doxygen should finally pick up the Statement and Session classes now. Removes the silly Query_arena class, as it's not needed anymore.
69
/**
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
70
  A set of constants used for checking non aggregated fields and sum
71
  functions mixture in the ONLY_FULL_GROUP_BY_MODE.
72
*/
1089.6.3 by Padraig O'Sullivan
Replaced an instance where a uint8_t type was being used to hold a
73
enum enum_group_by_mode_type
74
{
75
  NON_AGG_FIELD_USED= 0,
76
  SUM_FUNC_USED
77
};
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
78
1055.2.13 by Jay Pipes
Documentation and style fixes in Session class. Doxygen should finally pick up the Statement and Session classes now. Removes the silly Query_arena class, as it's not needed anymore.
79
/**
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
80
  This enumeration type is used only by the function find_item_in_list
81
  to return the info on how an item has been resolved against a list
82
  of possibly aliased items.
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
83
  The item can be resolved:
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
84
   - against an alias name of the list's element (RESOLVED_AGAINST_ALIAS)
85
   - against non-aliased field name of the list  (RESOLVED_WITH_NO_ALIAS)
86
   - against an aliased field name of the list   (RESOLVED_BEHIND_ALIAS)
87
   - ignoring the alias name in cases when SQL requires to ignore aliases
88
     (e.g. when the resolved field reference contains a table name or
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
89
     when the resolved item is an expression)   (RESOLVED_IGNORING_ALIAS)
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
90
*/
91
enum enum_resolution_type {
92
  NOT_RESOLVED=0,
93
  RESOLVED_IGNORING_ALIAS,
94
  RESOLVED_BEHIND_ALIAS,
95
  RESOLVED_WITH_NO_ALIAS,
96
  RESOLVED_AGAINST_ALIAS
97
};
98
Item ** find_item_in_list(Item *item, List<Item> &items, uint32_t *counter,
99
                          find_item_error_report_type report_error,
100
                          enum_resolution_type *resolution);
101
bool get_key_map_from_key_list(key_map *map, Table *table,
102
                               List<String> *index_list);
103
bool insert_fields(Session *session, Name_resolution_context *context,
104
		   const char *db_name, const char *table_name,
105
                   List_iterator<Item> *it, bool any_privileges);
106
bool setup_tables(Session *session, Name_resolution_context *context,
107
                  List<TableList> *from_clause, TableList *tables,
108
                  TableList **leaves, bool select_insert);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
109
bool setup_tables_and_check_access(Session *session,
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
110
                                   Name_resolution_context *context,
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
111
                                   List<TableList> *from_clause,
112
                                   TableList *tables,
113
                                   TableList **leaves,
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
114
                                   bool select_insert);
1034.1.7 by Brian Aker
Remove dead bits to the end of functions.
115
int setup_wild(Session *session, List<Item> &fields,
116
               List<Item> *sum_func_list,
117
               uint32_t wild_num);
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
118
bool setup_fields(Session *session, Item** ref_pointer_array,
119
                  List<Item> &item, enum_mark_columns mark_used_columns,
120
                  List<Item> *sum_func_list, bool allow_sum_func);
121
inline bool setup_fields_with_no_wrap(Session *session, Item **ref_pointer_array,
122
                                      List<Item> &item,
123
                                      enum_mark_columns mark_used_columns,
124
                                      List<Item> *sum_func_list,
125
                                      bool allow_sum_func)
126
{
127
  bool res;
128
  res= setup_fields(session, ref_pointer_array, item, mark_used_columns, sum_func_list,
129
                    allow_sum_func);
130
  return res;
131
}
1034.1.7 by Brian Aker
Remove dead bits to the end of functions.
132
int setup_conds(Session *session, TableList *leaves, COND **conds);
846 by Brian Aker
Removing on typedeffed class.
133
int setup_ftfuncs(Select_Lex* select);
134
int init_ftfuncs(Session *session, Select_Lex* select, bool no_order);
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
135
void wait_for_condition(Session *session, pthread_mutex_t *mutex,
136
                        pthread_cond_t *cond);
1054.1.9 by Brian Aker
This is a large number of refactors against the Session class for its
137
int open_tables_from_list(Session *session, TableList **tables, uint32_t *counter, uint32_t flags);
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
138
/* open_and_lock_tables with optional derived handling */
139
int open_and_lock_tables_derived(Session *session, TableList *tables, bool derived);
140
bool open_normal_and_derived_tables(Session *session, TableList *tables, uint32_t flags);
141
int lock_tables(Session *session, TableList *tables, uint32_t counter, bool *need_reopen);
142
int decide_logging_format(Session *session);
143
Table *open_temporary_table(Session *session, const char *path, const char *db,
144
                            const char *table_name, bool link_in_list,
145
                            open_table_mode open_mode);
960.2.24 by Monty Taylor
Changed handlerton to StorageEngine.
146
bool rm_temporary_table(StorageEngine *base, char *path);
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
147
void free_io_cache(Table *entry);
148
void intern_close_table(Table *entry);
149
void close_temporary_tables(Session *session);
150
void close_tables_for_reopen(Session *session, TableList **tables);
151
TableList *find_table_in_list(TableList *table,
152
                               TableList *TableList::*link,
153
                               const char *db_name,
154
                               const char *table_name);
155
TableList *unique_table(Session *session, TableList *table, TableList *table_list,
156
                         bool check_alias);
157
Table *find_temporary_table(Session *session, const char *db, const char *table_name);
158
Table *find_temporary_table(Session *session, TableList *table_list);
159
int drop_temporary_table(Session *session, TableList *table_list);
160
void close_temporary_table(Session *session, Table *table, bool free_share,
161
                           bool delete_table);
162
void close_temporary(Table *table, bool free_share, bool delete_table);
1019 by Brian Aker
Remove the need for TMP_TABLE_KEY_EXTRA (we don't replicate temp tables).
163
bool rename_temporary_table(Table *table, const char *new_db, const char *table_name);
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
164
void remove_db_from_cache(const char *db);
165
bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
166
167
/* bits for last argument to remove_table_from_cache() */
168
#define RTFC_NO_FLAG                0x0000
169
#define RTFC_OWNED_BY_Session_FLAG      0x0001
170
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
171
#define RTFC_CHECK_KILLED_FLAG      0x0004
172
bool remove_table_from_cache(Session *session, const char *db, const char *table,
173
                             uint32_t flags);
174
175
#define NORMAL_PART_NAME 0
176
#define TEMP_PART_NAME 1
177
#define RENAMED_PART_NAME 2
178
179
void mem_alloc_error(size_t size);
180
181
#define WFRM_WRITE_SHADOW 1
182
#define WFRM_INSTALL_SHADOW 2
183
#define WFRM_PACK_FRM 4
184
#define WFRM_KEEP_SHARE 8
185
1046.1.12 by Brian Aker
Simplify close_cached_tables() (it now always locks).
186
bool close_cached_tables(Session *session, TableList *tables,
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
187
                         bool wait_for_refresh, bool wait_for_placeholders);
188
void copy_field_from_tmp_record(Field *field,int offset);
189
bool fill_record(Session * session, List<Item> &fields, List<Item> &values, bool ignore_errors);
190
bool fill_record(Session *session, Field **field, List<Item> &values, bool ignore_errors);
1093.6.2 by Brian Aker
Small optimization to make table listing simpler
191
bool list_open_tables(const char *db, const char *wild, bool(*func)(Table *table, open_table_list_st& open_list), Table *display);
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
192
193
inline TableList *find_table_in_global_list(TableList *table,
194
                                             const char *db_name,
195
                                             const char *table_name)
196
{
197
  return find_table_in_list(table, &TableList::next_global,
198
                            db_name, table_name);
199
}
200
201
inline TableList *find_table_in_local_list(TableList *table,
202
                                            const char *db_name,
203
                                            const char *table_name)
204
{
205
  return find_table_in_list(table, &TableList::next_local,
206
                            db_name, table_name);
207
}
575.4.7 by Monty Taylor
More header cleanup.
208
#endif /* DRIZZLED_SQL_BASE_H */