Drizzled Public API Documentation

natural_join_column.cc

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 #include <config.h>
00021 #include <drizzled/natural_join_column.h>
00022 #include <drizzled/table_list.h>
00023 #include <drizzled/session.h>
00024 #include <drizzled/sql_lex.h>
00025 
00026 namespace drizzled {
00027 
00028 Natural_join_column::Natural_join_column(Field *field_param,
00029                                          TableList *tab)
00030 {
00031   assert(tab->table == field_param->getTable());
00032   table_field= field_param;
00033   table_ref= tab;
00034   is_common= false;
00035 }
00036 
00037 
00038 const char *Natural_join_column::name()
00039 {
00040   return table_field->field_name;
00041 }
00042 
00043 
00044 Item *Natural_join_column::create_item(Session *session)
00045 {
00046   return new Item_field(session, &session->lex().current_select->context, table_field);
00047 }
00048 
00049 
00050 Field *Natural_join_column::field()
00051 {
00052   return table_field;
00053 }
00054 
00055 
00056 const char *Natural_join_column::table_name()
00057 {
00058   assert(table_ref);
00059   return table_ref->alias;
00060 }
00061 
00062 
00063 const char *Natural_join_column::db_name()
00064 {
00065   /*
00066     Test that TableList::db is the same as TableShare::db to
00067     ensure consistency. 
00068   */
00069   assert(!strcmp(table_ref->getSchemaName(), table_ref->table->getShare()->getSchemaName()));
00070 
00071   return table_ref->getSchemaName();
00072 }
00073 
00074 } /* namespace drizzled */