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
* Character Set 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"
35
using namespace drizzled;
39
* Vectors of columns for the columns I_S table.
41
static vector<const plugin::ColumnInfo *> *columns= NULL;
44
* Methods for the columns I_S table.
46
static plugin::InfoSchemaMethods *methods= NULL;
51
static plugin::InfoSchemaTable *cols_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 *> *ColumnsIS::createColumns()
62
columns= new vector<const plugin::ColumnInfo *>;
66
clearColumns(*columns);
70
* Create each column for the COLUMNS table.
72
columns->push_back(new plugin::ColumnInfo("TABLE_CATALOG",
80
columns->push_back(new plugin::ColumnInfo("TABLE_SCHEMA",
88
columns->push_back(new plugin::ColumnInfo("TABLE_NAME",
96
columns->push_back(new plugin::ColumnInfo("COLUMN_NAME",
104
columns->push_back(new plugin::ColumnInfo("ORDINAL_POSITION",
105
MY_INT64_NUM_DECIMAL_DIGITS,
106
DRIZZLE_TYPE_LONGLONG,
112
columns->push_back(new plugin::ColumnInfo("COLUMN_DEFAULT",
113
MAX_FIELD_VARCHARLENGTH,
114
DRIZZLE_TYPE_VARCHAR,
120
columns->push_back(new plugin::ColumnInfo("IS_NULLABLE",
122
DRIZZLE_TYPE_VARCHAR,
128
columns->push_back(new plugin::ColumnInfo("DATA_TYPE",
130
DRIZZLE_TYPE_VARCHAR,
136
columns->push_back(new plugin::ColumnInfo("CHARACTER_MAXIMUM_LENGTH",
137
MY_INT64_NUM_DECIMAL_DIGITS,
138
DRIZZLE_TYPE_LONGLONG,
140
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
144
columns->push_back(new plugin::ColumnInfo("CHARACTER_OCTET_LENGTH",
145
MY_INT64_NUM_DECIMAL_DIGITS,
146
DRIZZLE_TYPE_LONGLONG,
148
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
152
columns->push_back(new plugin::ColumnInfo("NUMERIC_PRECISION",
153
MY_INT64_NUM_DECIMAL_DIGITS,
154
DRIZZLE_TYPE_LONGLONG,
156
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
160
columns->push_back(new plugin::ColumnInfo("NUMERIC_SCALE",
161
MY_INT64_NUM_DECIMAL_DIGITS,
162
DRIZZLE_TYPE_LONGLONG,
164
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
168
columns->push_back(new plugin::ColumnInfo("CHARACTER_SET_NAME",
170
DRIZZLE_TYPE_VARCHAR,
176
columns->push_back(new plugin::ColumnInfo("COLLATION_NAME",
178
DRIZZLE_TYPE_VARCHAR,
184
columns->push_back(new plugin::ColumnInfo("COLUMN_TYPE",
186
DRIZZLE_TYPE_VARCHAR,
192
columns->push_back(new plugin::ColumnInfo("COLUMN_KEY",
194
DRIZZLE_TYPE_VARCHAR,
200
columns->push_back(new plugin::ColumnInfo("EXTRA",
202
DRIZZLE_TYPE_VARCHAR,
208
columns->push_back(new plugin::ColumnInfo("PRIVILEGES",
210
DRIZZLE_TYPE_VARCHAR,
216
columns->push_back(new plugin::ColumnInfo("COLUMN_COMMENT",
217
COLUMN_COMMENT_MAXLEN,
218
DRIZZLE_TYPE_VARCHAR,
224
columns->push_back(new plugin::ColumnInfo("STORAGE",
226
DRIZZLE_TYPE_VARCHAR,
232
columns->push_back(new plugin::ColumnInfo("FORMAT",
234
DRIZZLE_TYPE_VARCHAR,
243
* Initialize the I_S table.
245
* @return a pointer to an I_S table
247
plugin::InfoSchemaTable *ColumnsIS::getTable()
249
columns= createColumns();
253
methods= new ColumnsISMethods();
256
if (cols_table == NULL)
258
cols_table= new plugin::InfoSchemaTable("COLUMNS",
269
* Delete memory allocated for the table, columns and methods.
271
void ColumnsIS::cleanup()
273
clearColumns(*columns);
279
int ColumnsISMethods::oldFormat(Session *session, drizzled::plugin::InfoSchemaTable *schema_table)
282
int fields_arr[]= {3, 14, 13, 6, 15, 5, 16, 17, 18, -1};
283
int *field_num= fields_arr;
284
const drizzled::plugin::InfoSchemaTable::Columns tab_columns= schema_table->getColumns();
285
const drizzled::plugin::ColumnInfo *column;
286
Name_resolution_context *context= &session->lex->select_lex.context;
288
for (; *field_num >= 0; field_num++)
290
column= tab_columns[*field_num];
291
if (! session->lex->verbose && (*field_num == 13 ||
297
Item_field *field= new Item_field(context,
298
NULL, NULL, column->getName().c_str());
301
field->set_name(column->getOldName().c_str(),
302
column->getOldName().length(),
303
system_charset_info);
304
if (session->add_item_to_list(field))