/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 *
 *  Copyright (C) 2008 Sun Microsystems
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef DRIZZLED_NATURAL_JOIN_COLUMN_H
#define DRIZZLED_NATURAL_JOIN_COLUMN_H

#include "drizzled/memory/sql_alloc.h"

namespace drizzled
{

class Field;
class TableList;
class Item;

/*
  Column reference of a NATURAL/USING join. Since column references in
  joins can be both from views and stored tables, may point to either a
  Field (for tables).
*/

class Natural_join_column: public memory::SqlAlloc
{
public:
  Field            *table_field; /* Column reference of table or temp view. */
  TableList *table_ref; /* Original base table/view reference. */
  /*
    True if a common join column of two NATURAL/USING join operands. Notice
    that when we have a hierarchy of nested NATURAL/USING joins, a column can
    be common at some level of nesting but it may not be common at higher
    levels of nesting. Thus this flag may change depending on at which level
    we are looking at some column.
  */
  bool is_common;
public:
  Natural_join_column(Field *field_param, TableList *tab);
  const char *name();
  Item *create_item(Session *session);
  Field *field();
  const char *table_name();
  const char *db_name();
};

} /* namespace drizzled */

#endif /* DRIZZLED_NATURAL_JOIN_COLUMN_H */
