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
* Open tables I_S table methods.
26
#include "drizzled/server_includes.h"
27
#include "drizzled/session.h"
28
#include "drizzled/show.h"
30
#include "helper_methods.h"
31
#include "open_tables.h"
35
using namespace drizzled;
39
* Vectors of columns for the open tables I_S table.
41
static vector<const plugin::ColumnInfo *> *columns= NULL;
44
* Methods for the open tables I_S table.
46
static plugin::InfoSchemaMethods *methods= NULL;
49
* open tables I_S table.
51
static plugin::InfoSchemaTable *open_tabs_table= NULL;
54
* Populate the vectors of columns for the I_S table.
56
* @return a pointer to a std::vector of Columns.
58
vector<const plugin::ColumnInfo *> *OpenTablesIS::createColumns()
62
columns= new vector<const plugin::ColumnInfo *>;
66
clearColumns(*columns);
69
columns->push_back(new plugin::ColumnInfo("Database",
77
columns->push_back(new plugin::ColumnInfo("Table",
85
columns->push_back(new plugin::ColumnInfo("In_use",
87
DRIZZLE_TYPE_LONGLONG,
93
columns->push_back(new plugin::ColumnInfo("Name_locked",
95
DRIZZLE_TYPE_LONGLONG,
105
* Initialize the I_S table.
107
* @return a pointer to an I_S table
109
plugin::InfoSchemaTable *OpenTablesIS::getTable()
111
columns= createColumns();
115
methods= new OpenTablesISMethods();
118
if (open_tabs_table == NULL)
120
open_tabs_table= new plugin::InfoSchemaTable("OPEN_TABLES",
122
-1, -1, true, false, 0,
126
return open_tabs_table;
130
* Delete memory allocated for the table, columns and methods.
132
void OpenTablesIS::cleanup()
134
clearColumns(*columns);
135
delete open_tabs_table;
140
inline bool open_list_store(Table *table, open_table_list_st& open_list);
141
inline bool open_list_store(Table *table, open_table_list_st& open_list)
143
table->restoreRecordAsDefault();
144
table->field[0]->store(open_list.db.c_str(), open_list.db.length(), system_charset_info);
145
table->field[1]->store(open_list.table.c_str(), open_list.table.length(), system_charset_info);
146
table->field[2]->store((int64_t) open_list.in_use, true);
147
table->field[3]->store((int64_t) open_list.locked, true);
148
if (schema_table_store_record(table->in_use, table))
154
int OpenTablesISMethods::fillTable(Session *session, TableList *tables)
156
const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
158
if ((list_open_tables(session->lex->select_lex.db, wild, open_list_store, tables->table) == true) && session->is_fatal_error)