Drizzled Public API Documentation

index_hint.cc

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 Sun Microsystems, Inc.
00005  *
00006  *  Authors:
00007  *
00008  *  Jay Pipes <jay.pipes@sun.com>
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00023  */
00024 
00030 #include <config.h>
00031 #include <drizzled/sql_string.h>
00032 #include <drizzled/session.h>
00033 #include <drizzled/index_hint.h>
00034 #include <drizzled/sql_table.h>
00035 
00036 namespace drizzled
00037 {
00038 
00039 /*
00040  * Names of the index hints (for error messages). Keep in sync with
00041  * index_hint_type
00042  */
00043 const char *index_hint_type_name[] =
00044 {
00045   "IGNORE INDEX"
00046 , "USE INDEX"
00047 , "FORCE INDEX"
00048 };
00049 
00058 void Index_hint::print(Session *session, String *str)
00059 {
00060   str->append(STRING_WITH_LEN(index_hint_type_name[type]));
00061   str->append(STRING_WITH_LEN(" ("));
00062   if (key_name.length)
00063   {
00064     if (session && is_primary_key_name(key_name.str))
00065       str->append(is_primary_key_name(key_name.str));
00066     else
00067       str->append_identifier(key_name.str, key_name.length);
00068   }
00069   str->append(')');
00070 }
00071 
00072 } /* namespace drizzled */