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 * 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 00021 #pragma once 00022 00023 #include <drizzled/lex_string.h> 00024 #include <drizzled/memory/sql_alloc.h> 00025 #include <drizzled/util/test.h> 00026 00027 namespace drizzled { 00028 00029 /* Structure for db & table in sql_yacc */ 00030 class Table_ident : public memory::SqlAlloc 00031 { 00032 public: 00033 lex_string_t db; 00034 str_ref table; 00035 Select_Lex_Unit *sel; 00036 00037 Table_ident(lex_string_t db_arg, str_ref table_arg) 00038 : db(db_arg), table(table_arg), sel(NULL) 00039 { 00040 } 00041 00042 explicit Table_ident(lex_string_t table_arg) 00043 : table(table_arg), sel(NULL) 00044 { 00045 db.assign(static_cast<const char*>(NULL), 0); 00046 } 00047 00048 /* 00049 This constructor is used only for the case when we create a derived 00050 table. A derived table has no name and doesn't belong to any database. 00051 Later, if there was an alias specified for the table, it will be set 00052 by add_table_to_list. 00053 */ 00054 explicit Table_ident(Select_Lex_Unit *s) : 00055 table("*"), sel(s) 00056 { 00057 /* We must have a table name here as this is used with add_table_to_list */ 00058 db.assign("", 0); // a subject to casedn_str 00059 } 00060 bool is_derived_table() const { return test(sel); } 00061 }; 00062 00063 } /* namespace drizzled */ 00064