1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
* table names I_S table methods.
26
#include "drizzled/server_includes.h"
27
#include "drizzled/session.h"
28
#include "drizzled/show.h"
29
#include "drizzled/tztime.h"
31
#include "helper_methods.h"
32
#include "table_names.h"
36
using namespace drizzled;
40
* Vectors of columns for the table names I_S table.
42
static vector<const plugin::ColumnInfo *> *columns= NULL;
45
* Methods for the table names I_S table.
47
static plugin::InfoSchemaMethods *methods= NULL;
50
* table names I_S table.
52
static plugin::InfoSchemaTable *tn_table= NULL;
55
* Populate the vectors of columns for the I_S table.
57
* @return a pointer to a std::vector of Columns.
59
vector<const plugin::ColumnInfo *> *TableNamesIS::createColumns()
63
columns= new vector<const plugin::ColumnInfo *>;
67
clearColumns(*columns);
70
columns->push_back(new plugin::ColumnInfo("TABLE_CATALOG",
78
columns->push_back(new plugin::ColumnInfo("TABLE_SCHEMA",
86
columns->push_back(new plugin::ColumnInfo("TABLE_NAME",
94
columns->push_back(new plugin::ColumnInfo("TABLE_TYPE",
105
* Initialize the I_S table.
107
* @return a pointer to an I_S table
109
plugin::InfoSchemaTable *TableNamesIS::getTable()
111
columns= createColumns();
115
methods= new TabNamesISMethods();
118
if (tn_table == NULL)
120
tn_table= new plugin::InfoSchemaTable("TABLE_NAMES",
130
* Delete memory allocated for the table, columns and methods.
132
void TableNamesIS::cleanup()
134
clearColumns(*columns);
140
int TabNamesISMethods::oldFormat(Session *session, drizzled::plugin::InfoSchemaTable *schema_table)
144
String buffer(tmp,sizeof(tmp), session->charset());
145
LEX *lex= session->lex;
146
Name_resolution_context *context= &lex->select_lex.context;
147
const drizzled::plugin::InfoSchemaTable::Columns tab_columns= schema_table->getColumns();
149
const drizzled::plugin::ColumnInfo *column= tab_columns[2];
151
buffer.append(column->getOldName().c_str());
152
buffer.append(lex->select_lex.db);
153
if (lex->wild && lex->wild->ptr())
155
buffer.append(STRING_WITH_LEN(" ("));
156
buffer.append(lex->wild->ptr());
159
Item_field *field= new Item_field(context,
160
NULL, NULL, column->getName().c_str());
161
if (session->add_item_to_list(field))
165
field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
166
if (session->lex->verbose)
168
field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
169
column= tab_columns[3];
170
field= new Item_field(context, NULL, NULL, column->getName().c_str());
171
if (session->add_item_to_list(field))
175
field->set_name(column->getOldName().c_str(),
176
column->getOldName().length(),
177
system_charset_info);