Drizzled Public API Documentation

index_hint.h
Go to the documentation of this file.
00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008-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; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00027 #pragma once
00028 
00029 namespace drizzled
00030 {
00031 
00032 /*
00033   String names used to print a statement with index hints.
00034   Keep in sync with index_hint_type.
00035 */
00036 extern const char * index_hint_type_name[];
00037 typedef unsigned char index_clause_map;
00038 
00039 enum index_hint_type
00040 {
00041   INDEX_HINT_IGNORE,
00042   INDEX_HINT_USE,
00043   INDEX_HINT_FORCE
00044 };
00045 
00046 /*
00047   Bits in index_clause_map : one for each possible FOR clause in
00048   USE/FORCE/IGNORE INDEX index hint specification
00049 */
00050 #define INDEX_HINT_MASK_JOIN  (1)
00051 #define INDEX_HINT_MASK_GROUP (1 << 1)
00052 #define INDEX_HINT_MASK_ORDER (1 << 2)
00053 
00054 #define INDEX_HINT_MASK_ALL (INDEX_HINT_MASK_JOIN | INDEX_HINT_MASK_GROUP | \
00055                              INDEX_HINT_MASK_ORDER)
00056 
00057 /* Single element of an USE/FORCE/IGNORE INDEX list specified as a SQL hint  */
00058 class Index_hint : public memory::SqlAlloc
00059 {
00060 public:
00061   /* The type of the hint : USE/FORCE/IGNORE */
00062   enum index_hint_type type;
00063   /* Where the hit applies to. A bitmask of INDEX_HINT_MASK_<place> values */
00064   index_clause_map clause;
00065   /*
00066     The index name. Empty (str=NULL) name represents an empty list
00067     USE INDEX () clause
00068   */
00069   LEX_STRING key_name;
00070 
00071   Index_hint (enum index_hint_type type_arg, index_clause_map clause_arg,
00072               char *str, uint32_t length) :
00073     type(type_arg), clause(clause_arg)
00074   {
00075     key_name.str= str;
00076     key_name.length= length;
00077   }
00078 
00079   void print(Session *session, String *str);
00080 };
00081 
00082 } /* namespace drizzled */
00083