1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
#ifndef DRIZZLED_SQL_BASE_H
21
#define DRIZZLED_SQL_BASE_H
23
#include <drizzled/table.h>
24
#include <drizzled/table/concurrent.h>
29
class Name_resolution_context;
31
void table_cache_free(void);
32
bool table_cache_init(void);
33
uint32_t cached_open_tables(void);
34
uint32_t cached_table_definitions(void);
36
table::Cache &get_open_cache();
38
void kill_drizzle(void);
41
void set_item_name(Item *item,char *pos,uint32_t length);
42
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,
48
char *change, List<String> *interval_list,
49
const CHARSET_INFO * const cs);
50
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);
56
void store_position_for_column(const char *name);
57
bool push_new_name_resolution_context(Session *session,
60
void add_join_on(TableList *b,Item *expr);
61
void add_join_natural(TableList *a,TableList *b,List<String> *using_fields,
63
extern Item **not_found_item;
66
A set of constants used for checking non aggregated fields and sum
67
functions mixture in the ONLY_FULL_GROUP_BY_MODE.
69
enum enum_group_by_mode_type
71
NON_AGG_FIELD_USED= 0,
76
This enumeration type is used only by the function find_item_in_list
77
to return the info on how an item has been resolved against a list
78
of possibly aliased items.
79
The item can be resolved:
80
- against an alias name of the list's element (RESOLVED_AGAINST_ALIAS)
81
- against non-aliased field name of the list (RESOLVED_WITH_NO_ALIAS)
82
- against an aliased field name of the list (RESOLVED_BEHIND_ALIAS)
83
- ignoring the alias name in cases when SQL requires to ignore aliases
84
(e.g. when the resolved field reference contains a table name or
85
when the resolved item is an expression) (RESOLVED_IGNORING_ALIAS)
87
enum enum_resolution_type {
89
RESOLVED_IGNORING_ALIAS,
90
RESOLVED_BEHIND_ALIAS,
91
RESOLVED_WITH_NO_ALIAS,
92
RESOLVED_AGAINST_ALIAS
94
Item ** find_item_in_list(Session *session,
95
Item *item, List<Item> &items, uint32_t *counter,
96
find_item_error_report_type report_error,
97
enum_resolution_type *resolution);
98
bool insert_fields(Session *session, Name_resolution_context *context,
99
const char *db_name, const char *table_name,
100
List_iterator<Item> *it, bool any_privileges);
101
bool setup_tables(Session *session, Name_resolution_context *context,
102
List<TableList> *from_clause, TableList *tables,
103
TableList **leaves, bool select_insert);
104
bool setup_tables_and_check_access(Session *session,
105
Name_resolution_context *context,
106
List<TableList> *from_clause,
110
int setup_wild(Session *session, List<Item> &fields,
111
List<Item> *sum_func_list,
113
bool setup_fields(Session *session, Item** ref_pointer_array,
114
List<Item> &item, enum_mark_columns mark_used_columns,
115
List<Item> *sum_func_list, bool allow_sum_func);
116
inline bool setup_fields_with_no_wrap(Session *session, Item **ref_pointer_array,
118
enum_mark_columns mark_used_columns,
119
List<Item> *sum_func_list,
123
res= setup_fields(session, ref_pointer_array, item, mark_used_columns, sum_func_list,
127
int setup_conds(Session *session, TableList *leaves, COND **conds);
128
/* open_and_lock_tables with optional derived handling */
129
TableList *find_table_in_list(TableList *table,
130
TableList *TableList::*link,
132
const char *table_name);
133
TableList *unique_table(TableList *table, TableList *table_list,
134
bool check_alias= false);
136
/* bits for last argument to table::Cache::singleton().removeTable() */
137
#define RTFC_NO_FLAG 0x0000
138
#define RTFC_OWNED_BY_Session_FLAG 0x0001
139
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
140
#define RTFC_CHECK_KILLED_FLAG 0x0004
142
void mem_alloc_error(size_t size);
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);
146
inline TableList *find_table_in_global_list(TableList *table,
148
const char *table_name)
150
return find_table_in_list(table, &TableList::next_global,
151
db_name, table_name);
154
} /* namespace drizzled */
156
#endif /* DRIZZLED_SQL_BASE_H */