~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.h

  • Committer: Monty Taylor
  • Date: 2008-10-14 21:20:42 UTC
  • mto: (511.1.4 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081014212042-tef3njx3368b6lwt
Override copy ctr and op= because we have pointer members.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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, Inc.
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
 
 
21
 
 
22
 
#ifndef DRIZZLED_SQL_BASE_H
23
 
#define DRIZZLED_SQL_BASE_H
24
 
 
25
 
#include <drizzled/table.h>
26
 
#include <drizzled/table_list.h>
27
 
#include <drizzled/table/concurrent.h>
28
 
 
29
 
#include <drizzled/visibility.h>
30
 
 
31
 
namespace drizzled
32
 
{
33
 
class TableShare;
34
 
class Name_resolution_context;
35
 
 
36
 
void table_cache_free(void);
37
 
bool table_cache_init(void);
38
 
uint32_t cached_open_tables(void);
39
 
uint32_t cached_table_definitions(void);
40
 
 
41
 
table::Cache &get_open_cache();
42
 
 
43
 
DRIZZLED_API void kill_drizzle(void);
44
 
 
45
 
/* sql_base.cc */
46
 
void set_item_name(Item *item,char *pos,uint32_t length);
47
 
bool add_field_to_list(Session *session, LEX_STRING *field_name, enum enum_field_types type,
48
 
                       char *length, char *decimal,
49
 
                       uint32_t type_modifier,
50
 
                       enum column_format_type column_format,
51
 
                       Item *default_value, Item *on_update_value,
52
 
                       LEX_STRING *comment,
53
 
                       char *change, List<String> *interval_list,
54
 
                       const CHARSET_INFO * const cs);
55
 
CreateField * new_create_field(Session *session, char *field_name, enum_field_types type,
56
 
                               char *length, char *decimals,
57
 
                               uint32_t type_modifier,
58
 
                               Item *default_value, Item *on_update_value,
59
 
                               LEX_STRING *comment, char *change,
60
 
                               List<String> *interval_list, CHARSET_INFO *cs);
61
 
bool push_new_name_resolution_context(Session *session,
62
 
                                      TableList *left_op,
63
 
                                      TableList *right_op);
64
 
void add_join_on(TableList *b,Item *expr);
65
 
void add_join_natural(TableList *a,TableList *b,List<String> *using_fields,
66
 
                      Select_Lex *lex);
67
 
extern Item **not_found_item;
68
 
 
69
 
/**
70
 
  A set of constants used for checking non aggregated fields and sum
71
 
  functions mixture in the ONLY_FULL_GROUP_BY_MODE.
72
 
*/
73
 
enum enum_group_by_mode_type
74
 
{
75
 
  NON_AGG_FIELD_USED= 0,
76
 
  SUM_FUNC_USED
77
 
};
78
 
 
79
 
/**
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.
83
 
  The item can be resolved:
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
89
 
     when the resolved item is an expression)   (RESOLVED_IGNORING_ALIAS)
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(Session *session,
99
 
                          Item *item, List<Item> &items, uint32_t *counter,
100
 
                          find_item_error_report_type report_error,
101
 
                          enum_resolution_type *resolution);
102
 
bool insert_fields(Session *session, Name_resolution_context *context,
103
 
                   const char *db_name, const char *table_name,
104
 
                   List<Item>::iterator *it, bool any_privileges);
105
 
bool setup_tables(Session *session, Name_resolution_context *context,
106
 
                  List<TableList> *from_clause, TableList *tables,
107
 
                  TableList **leaves, bool select_insert);
108
 
bool setup_tables_and_check_access(Session *session,
109
 
                                   Name_resolution_context *context,
110
 
                                   List<TableList> *from_clause,
111
 
                                   TableList *tables,
112
 
                                   TableList **leaves,
113
 
                                   bool select_insert);
114
 
int setup_wild(Session *session, List<Item> &fields,
115
 
               List<Item> *sum_func_list,
116
 
               uint32_t wild_num);
117
 
bool setup_fields(Session *session, Item** ref_pointer_array,
118
 
                  List<Item> &item, enum_mark_columns mark_used_columns,
119
 
                  List<Item> *sum_func_list, bool allow_sum_func);
120
 
inline bool setup_fields_with_no_wrap(Session *session, Item **ref_pointer_array,
121
 
                                      List<Item> &item,
122
 
                                      enum_mark_columns mark_used_columns,
123
 
                                      List<Item> *sum_func_list,
124
 
                                      bool allow_sum_func)
125
 
{
126
 
  bool res;
127
 
  res= setup_fields(session, ref_pointer_array, item, mark_used_columns, sum_func_list,
128
 
                    allow_sum_func);
129
 
  return res;
130
 
}
131
 
int setup_conds(Session *session, TableList *leaves, COND **conds);
132
 
/* open_and_lock_tables with optional derived handling */
133
 
TableList *find_table_in_list(TableList *table,
134
 
                               TableList *TableList::*link,
135
 
                               const char *db_name,
136
 
                               const char *table_name);
137
 
TableList *unique_table(TableList *table, TableList *table_list,
138
 
                        bool check_alias= false);
139
 
 
140
 
/* bits for last argument to table::Cache::singleton().removeTable() */
141
 
#define RTFC_NO_FLAG                0x0000
142
 
#define RTFC_OWNED_BY_Session_FLAG      0x0001
143
 
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
144
 
#define RTFC_CHECK_KILLED_FLAG      0x0004
145
 
 
146
 
void mem_alloc_error(size_t size);
147
 
 
148
 
bool fill_record(Session* session, List<Item> &fields, List<Item> &values, bool ignore_errors= false);
149
 
bool fill_record(Session *session, Field **field, List<Item> &values, bool ignore_errors= false);
150
 
inline TableList *find_table_in_global_list(TableList *table,
151
 
                                             const char *db_name,
152
 
                                             const char *table_name)
153
 
{
154
 
  return find_table_in_list(table, &TableList::next_global,
155
 
                            db_name, table_name);
156
 
}
157
 
 
158
 
bool drizzle_rm_tmp_tables();
159
 
 
160
 
} /* namespace drizzled */
161
 
 
162
 
#endif /* DRIZZLED_SQL_BASE_H */