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 #include <vector>
00024 
00025 namespace drizzled {
00026 namespace optimizer {
00027 
00031 class KeyField
00032 {
00033 public:
00034 
00035   KeyField()
00036     :
00037       field(NULL),
00038       val(NULL),
00039       level(0),
00040       optimize(0),
00041       eq_func(false),
00042       null_rejecting(false),
00043       cond_guard(NULL)
00044   {}
00045 
00046   KeyField(Field *in_field,
00047            Item *in_val,
00048            uint32_t in_level,
00049            uint32_t in_optimize,
00050            bool in_eq_func,
00051            bool in_null_rejecting,
00052            bool *in_cond_guard)
00053     :
00054       field(in_field),
00055       val(in_val),
00056       level(in_level),
00057       optimize(in_optimize),
00058       eq_func(in_eq_func),
00059       null_rejecting(in_null_rejecting),
00060       cond_guard(in_cond_guard)
00061   {}
00062 
00063   Field *getField()
00064   {
00065     return field;
00066   }
00067 
00068   void setField(Field *in_field)
00069   {
00070     field= in_field;
00071   }
00072 
00073   Item *getValue()
00074   {
00075     return val;
00076   }
00077 
00078   void setValue(Item *in_val)
00079   {
00080     val= in_val;
00081   }
00082 
00083   uint32_t getLevel() const
00084   {
00085     return level;
00086   }
00087 
00088   void setLevel(uint32_t in_level)
00089   {
00090     level= in_level;
00091   }
00092 
00093   uint32_t getOptimizeFlags() const
00094   {
00095     return optimize;
00096   }
00097 
00098   void setOptimizeFlags(uint32_t in_opt)
00099   {
00100     optimize= in_opt;
00101   }
00102 
00103   bool isEqualityCondition() const
00104   {
00105     return eq_func;
00106   }
00107 
00108   void setEqualityConditionUsed(bool in_val)
00109   {
00110     eq_func= in_val;
00111   }
00112 
00113   bool rejectNullValues() const
00114   {
00115     return null_rejecting;
00116   }
00117 
00118   void setRejectNullValues(bool in_val)
00119   {
00120     null_rejecting= in_val;
00121   }
00122 
00123   bool *getConditionalGuard()
00124   {
00125     return cond_guard;
00126   }
00127 
00128   void setConditionalGuard(bool *in_cond_guard)
00129   {
00130     cond_guard= in_cond_guard;
00131   }
00132 
00133 private:
00134 
00135   Field *field;
00136   Item *val; 
00137   uint32_t level;
00138   uint32_t optimize; 
00139   bool eq_func;
00144   bool null_rejecting;
00145   bool *cond_guard; 
00147 };
00148 
00149 void add_key_fields(Join *join, 
00150                     KeyField **key_fields,
00151                     uint32_t *and_level,
00152                     COND *cond,
00153                     table_map usable_tables,
00154                     std::vector<SargableParam> &sargables);
00155 
00156 void add_key_part(DYNAMIC_ARRAY *keyuse_array, KeyField *key_field);
00157 
00192 void add_key_fields_for_nj(Join *join,
00193                            TableList *nested_join_table,
00194                            KeyField **end,
00195                            uint32_t *and_level,
00196                            std::vector<SargableParam> &sargables);
00197 
00221 KeyField *merge_key_fields(KeyField *start,
00222                             KeyField *new_fields,
00223                             KeyField *end, 
00224                             uint32_t and_level);
00225 
00245 void add_key_field(KeyField **key_fields,
00246                    uint32_t and_level,
00247                    Item_func *cond,
00248                    Field *field,
00249                    bool eq_func,
00250                    Item **value,
00251                    uint32_t num_values,
00252                    table_map usable_tables,
00253                    std::vector<SargableParam> &sargables);
00254 
00276 void add_key_equal_fields(KeyField **key_fields,
00277                           uint32_t and_level,
00278                           Item_func *cond,
00279                           Item_field *field_item,
00280                           bool eq_func,
00281                           Item **val,
00282                           uint32_t num_values,
00283                           table_map usable_tables,
00284                           std::vector<SargableParam> &sargables);
00285 
00286 } /* end namespace optimizer */
00287 
00288 } /* end namespace drizzled */
00289