Drizzled Public API Documentation

sql_base.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 
00021 
00022 #pragma once
00023 
00024 #include <drizzled/table.h>
00025 #include <drizzled/table_list.h>
00026 #include <drizzled/table/concurrent.h>
00027 
00028 #include <drizzled/visibility.h>
00029 
00030 namespace drizzled
00031 {
00032 class TableShare;
00033 class Name_resolution_context;
00034 
00035 void table_cache_free(void);
00036 bool table_cache_init(void);
00037 uint32_t cached_open_tables(void);
00038 uint32_t cached_table_definitions(void);
00039 
00040 table::Cache &get_open_cache();
00041 
00042 DRIZZLED_API void kill_drizzle(void);
00043 
00044 /* sql_base.cc */
00045 void set_item_name(Item *item,char *pos,uint32_t length);
00046 bool add_field_to_list(Session *session, LEX_STRING *field_name, enum enum_field_types type,
00047                        char *length, char *decimal,
00048                        uint32_t type_modifier,
00049                        enum column_format_type column_format,
00050                        Item *default_value, Item *on_update_value,
00051                        LEX_STRING *comment,
00052                        char *change, List<String> *interval_list,
00053                        const CHARSET_INFO * const cs);
00054 CreateField * new_create_field(Session *session, char *field_name, enum_field_types type,
00055                                char *length, char *decimals,
00056                                uint32_t type_modifier,
00057                                Item *default_value, Item *on_update_value,
00058                                LEX_STRING *comment, char *change,
00059                                List<String> *interval_list, CHARSET_INFO *cs);
00060 bool push_new_name_resolution_context(Session *session,
00061                                       TableList *left_op,
00062                                       TableList *right_op);
00063 void add_join_on(TableList *b,Item *expr);
00064 void add_join_natural(TableList *a,TableList *b,List<String> *using_fields,
00065                       Select_Lex *lex);
00066 extern Item **not_found_item;
00067 
00072 enum enum_group_by_mode_type
00073 {
00074   NON_AGG_FIELD_USED= 0,
00075   SUM_FUNC_USED
00076 };
00077 
00090 enum enum_resolution_type {
00091   NOT_RESOLVED=0,
00092   RESOLVED_IGNORING_ALIAS,
00093   RESOLVED_BEHIND_ALIAS,
00094   RESOLVED_WITH_NO_ALIAS,
00095   RESOLVED_AGAINST_ALIAS
00096 };
00097 Item ** find_item_in_list(Session *session,
00098                           Item *item, List<Item> &items, uint32_t *counter,
00099                           find_item_error_report_type report_error,
00100                           enum_resolution_type *resolution);
00101 bool insert_fields(Session *session, Name_resolution_context *context,
00102                    const char *db_name, const char *table_name,
00103                    List<Item>::iterator *it, bool any_privileges);
00104 bool setup_tables(Session *session, Name_resolution_context *context,
00105                   List<TableList> *from_clause, TableList *tables,
00106                   TableList **leaves, bool select_insert);
00107 bool setup_tables_and_check_access(Session *session,
00108                                    Name_resolution_context *context,
00109                                    List<TableList> *from_clause,
00110                                    TableList *tables,
00111                                    TableList **leaves,
00112                                    bool select_insert);
00113 int setup_wild(Session *session, List<Item> &fields,
00114                List<Item> *sum_func_list,
00115                uint32_t wild_num);
00116 bool setup_fields(Session *session, Item** ref_pointer_array,
00117                   List<Item> &item, enum_mark_columns mark_used_columns,
00118                   List<Item> *sum_func_list, bool allow_sum_func);
00119 inline bool setup_fields_with_no_wrap(Session *session, Item **ref_pointer_array,
00120                                       List<Item> &item,
00121                                       enum_mark_columns mark_used_columns,
00122                                       List<Item> *sum_func_list,
00123                                       bool allow_sum_func)
00124 {
00125   bool res;
00126   res= setup_fields(session, ref_pointer_array, item, mark_used_columns, sum_func_list,
00127                     allow_sum_func);
00128   return res;
00129 }
00130 int setup_conds(Session *session, TableList *leaves, COND **conds);
00131 /* open_and_lock_tables with optional derived handling */
00132 TableList *find_table_in_list(TableList *table,
00133                                TableList *TableList::*link,
00134                                const char *db_name,
00135                                const char *table_name);
00136 TableList *unique_table(TableList *table, TableList *table_list,
00137                         bool check_alias= false);
00138 
00139 /* bits for last argument to table::Cache::singleton().removeTable() */
00140 #define RTFC_NO_FLAG                0x0000
00141 #define RTFC_OWNED_BY_Session_FLAG      0x0001
00142 #define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
00143 #define RTFC_CHECK_KILLED_FLAG      0x0004
00144 
00145 void mem_alloc_error(size_t size);
00146 
00147 bool fill_record(Session* session, List<Item> &fields, List<Item> &values, bool ignore_errors= false);
00148 bool fill_record(Session *session, Field **field, List<Item> &values, bool ignore_errors= false);
00149 inline TableList *find_table_in_global_list(TableList *table,
00150                                              const char *db_name,
00151                                              const char *table_name)
00152 {
00153   return find_table_in_list(table, &TableList::next_global,
00154                             db_name, table_name);
00155 }
00156 
00157 bool drizzle_rm_tmp_tables();
00158 
00159 } /* namespace drizzled */
00160