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.
27
#include "drizzled/session.h"
28
#include "drizzled/show.h"
29
#include "drizzled/global_charset_info.h"
32
#include "helper_methods.h"
33
#include "open_tables.h"
37
using namespace drizzled;
41
* Vectors of columns for the open tables I_S table.
43
static vector<const plugin::ColumnInfo *> *columns= NULL;
46
* Methods for the open tables I_S table.
48
static plugin::InfoSchemaMethods *methods= NULL;
51
* open tables I_S table.
53
static plugin::InfoSchemaTable *open_tabs_table= NULL;
56
* Populate the vectors of columns for the I_S table.
58
* @return a pointer to a std::vector of Columns.
60
vector<const plugin::ColumnInfo *> *OpenTablesIS::createColumns()
64
columns= new vector<const plugin::ColumnInfo *>;
68
clearColumns(*columns);
71
columns->push_back(new plugin::ColumnInfo("Database",
78
columns->push_back(new plugin::ColumnInfo("Table",
85
columns->push_back(new plugin::ColumnInfo("In_use",
87
DRIZZLE_TYPE_LONGLONG,
92
columns->push_back(new plugin::ColumnInfo("Name_locked",
94
DRIZZLE_TYPE_LONGLONG,
103
* Initialize the I_S table.
105
* @return a pointer to an I_S table
107
plugin::InfoSchemaTable *OpenTablesIS::getTable()
109
columns= createColumns();
113
methods= new OpenTablesISMethods();
116
if (open_tabs_table == NULL)
118
open_tabs_table= new plugin::InfoSchemaTable("OPEN_TABLES",
120
-1, -1, true, false, 0,
124
return open_tabs_table;
128
* Delete memory allocated for the table, columns and methods.
130
void OpenTablesIS::cleanup()
132
clearColumns(*columns);
133
delete open_tabs_table;
138
inline bool open_list_store(Table *table,
139
open_table_list_st& open_list,
140
plugin::InfoSchemaTable *schema_table);
141
inline bool open_list_store(Table *table,
142
open_table_list_st& open_list,
143
plugin::InfoSchemaTable *schema_table)
145
table->restoreRecordAsDefault();
146
table->setWriteSet(0);
147
table->setWriteSet(1);
148
table->setWriteSet(2);
149
table->setWriteSet(3);
150
table->field[0]->store(open_list.db.c_str(), open_list.db.length(), system_charset_info);
151
table->field[1]->store(open_list.table.c_str(), open_list.table.length(), system_charset_info);
152
table->field[2]->store((int64_t) open_list.in_use, true);
153
table->field[3]->store((int64_t) open_list.locked, true);
154
schema_table->addRow(table->record[0], table->s->reclength);
159
int OpenTablesISMethods::fillTable(Session *session,
161
plugin::InfoSchemaTable *schema_table)
163
const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
165
if ((list_open_tables(session->lex->select_lex.db, wild, open_list_store, table, schema_table) == true) && session->is_fatal_error)