Drizzled Public API Documentation

key_field.h

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2009 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 #pragma once
00021 
00022 #include <drizzled/sql_select.h>
00023 
00024 #include <vector>
00025 
00026 namespace drizzled
00027 {
00028 namespace optimizer
00029 {
00030 
00034 class KeyField
00035 {
00036 public:
00037 
00038   KeyField()
00039     :
00040       field(NULL),
00041       val(NULL),
00042       level(0),
00043       optimize(0),
00044       eq_func(false),
00045       null_rejecting(false),
00046       cond_guard(NULL)
00047   {}
00048 
00049   KeyField(Field *in_field,
00050            Item *in_val,
00051            uint32_t in_level,
00052            uint32_t in_optimize,
00053            bool in_eq_func,
00054            bool in_null_rejecting,
00055            bool *in_cond_guard)
00056     :
00057       field(in_field),
00058       val(in_val),
00059       level(in_level),
00060       optimize(in_optimize),
00061       eq_func(in_eq_func),
00062       null_rejecting(in_null_rejecting),
00063       cond_guard(in_cond_guard)
00064   {}
00065 
00066   Field *getField()
00067   {
00068     return field;
00069   }
00070 
00071   void setField(Field *in_field)
00072   {
00073     field= in_field;
00074   }
00075 
00076   Item *getValue()
00077   {
00078     return val;
00079   }
00080 
00081   void setValue(Item *in_val)
00082   {
00083     val= in_val;
00084   }
00085 
00086   uint32_t getLevel()
00087   {
00088     return level;
00089   }
00090 
00091   void setLevel(uint32_t in_level)
00092   {
00093     level= in_level;
00094   }
00095 
00096   uint32_t getOptimizeFlags()
00097   {
00098     return optimize;
00099   }
00100 
00101   void setOptimizeFlags(uint32_t in_opt)
00102   {
00103     optimize= in_opt;
00104   }
00105 
00106   bool isEqualityCondition() const
00107   {
00108     return eq_func;
00109   }
00110 
00111   void setEqualityConditionUsed(bool in_val)
00112   {
00113     eq_func= in_val;
00114   }
00115 
00116   bool rejectNullValues() const
00117   {
00118     return null_rejecting;
00119   }
00120 
00121   void setRejectNullValues(bool in_val)
00122   {
00123     null_rejecting= in_val;
00124   }
00125 
00126   bool *getConditionalGuard()
00127   {
00128     return cond_guard;
00129   }
00130 
00131   void setConditionalGuard(bool *in_cond_guard)
00132   {
00133     cond_guard= in_cond_guard;
00134   }
00135 
00136 private:
00137 
00138   Field *field;
00139   Item *val; 
00140   uint32_t level;
00141   uint32_t optimize; 
00142   bool eq_func;
00147   bool null_rejecting;
00148   bool *cond_guard; 
00150 };
00151 
00152 void add_key_fields(Join *join, 
00153                     KeyField **key_fields,
00154                     uint32_t *and_level,
00155                     COND *cond,
00156                     table_map usable_tables,
00157                     std::vector<SargableParam> &sargables);
00158 
00159 void add_key_part(DYNAMIC_ARRAY *keyuse_array, KeyField *key_field);
00160 
00195 void add_key_fields_for_nj(Join *join,
00196                            TableList *nested_join_table,
00197                            KeyField **end,
00198                            uint32_t *and_level,
00199                            std::vector<SargableParam> &sargables);
00200 
00224 KeyField *merge_key_fields(KeyField *start,
00225                             KeyField *new_fields,
00226                             KeyField *end, 
00227                             uint32_t and_level);
00228 
00248 void add_key_field(KeyField **key_fields,
00249                    uint32_t and_level,
00250                    Item_func *cond,
00251                    Field *field,
00252                    bool eq_func,
00253                    Item **value,
00254                    uint32_t num_values,
00255                    table_map usable_tables,
00256                    std::vector<SargableParam> &sargables);
00257 
00279 void add_key_equal_fields(KeyField **key_fields,
00280                           uint32_t and_level,
00281                           Item_func *cond,
00282                           Item_field *field_item,
00283                           bool eq_func,
00284                           Item **val,
00285                           uint32_t num_values,
00286                           table_map usable_tables,
00287                           std::vector<SargableParam> &sargables);
00288 
00289 } /* end namespace optimizer */
00290 
00291 } /* end namespace drizzled */
00292