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"
31
#include "collation.h"
35
using namespace drizzled;
39
* Vectors of columns for the collation I_S table.
41
static vector<const plugin::ColumnInfo *> *columns= NULL;
44
* Methods for the collation I_S table.
46
static plugin::InfoSchemaMethods *methods= NULL;
49
* collation I_S table.
51
static plugin::InfoSchemaTable *coll_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 *> *CollationIS::createColumns()
62
columns= new vector<const plugin::ColumnInfo *>;
66
clearColumns(*columns);
70
* Create each column for the COLLATION table.
72
columns->push_back(new plugin::ColumnInfo("COLLATION_NAME",
80
columns->push_back(new plugin::ColumnInfo("CHARACTER_SET_NAME",
88
columns->push_back(new plugin::ColumnInfo("DESCRIPTION",
96
columns->push_back(new plugin::ColumnInfo("ID",
97
MY_INT32_NUM_DECIMAL_DIGITS,
98
DRIZZLE_TYPE_LONGLONG,
104
columns->push_back(new plugin::ColumnInfo("IS_DEFAULT",
106
DRIZZLE_TYPE_VARCHAR,
112
columns->push_back(new plugin::ColumnInfo("IS_COMPILED",
114
DRIZZLE_TYPE_VARCHAR,
120
columns->push_back(new plugin::ColumnInfo("SORTLEN",
122
DRIZZLE_TYPE_LONGLONG,
132
* Initialize the I_S table.
134
* @return a pointer to an I_S table
136
plugin::InfoSchemaTable *CollationIS::getTable()
138
columns= createColumns();
142
methods= new CollationISMethods();
145
if (coll_table == NULL)
147
coll_table= new(nothrow) plugin::InfoSchemaTable("COLLATIONS",
149
-1, -1, false, false, 0,
157
* Delete memory allocated for the table, columns and methods.
159
void CollationIS::cleanup()
161
clearColumns(*columns);
167
int CollationISMethods::fillTable(Session *session, TableList *tables)
170
const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
171
Table *table= tables->table;
172
const CHARSET_INFO * const scs= system_charset_info;
173
for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
176
const CHARSET_INFO *tmp_cs= cs[0];
177
if (! tmp_cs || ! (tmp_cs->state & MY_CS_AVAILABLE) ||
178
(tmp_cs->state & MY_CS_HIDDEN) ||
179
!(tmp_cs->state & MY_CS_PRIMARY))
181
for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
183
const CHARSET_INFO *tmp_cl= cl[0];
184
if (! tmp_cl || ! (tmp_cl->state & MY_CS_AVAILABLE) ||
185
!my_charset_same(tmp_cs, tmp_cl))
187
if (! (wild && wild[0] &&
188
wild_case_compare(scs, tmp_cl->name,wild)))
190
const char *tmp_buff;
191
table->restoreRecordAsDefault();
192
table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
193
table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
194
table->field[2]->store((int64_t) tmp_cl->number, true);
195
tmp_buff= (tmp_cl->state & MY_CS_PRIMARY) ? "Yes" : "";
196
table->field[3]->store(tmp_buff, strlen(tmp_buff), scs);
197
tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : "";
198
table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
199
table->field[5]->store((int64_t) tmp_cl->strxfrm_multiply, true);
200
if (schema_table_store_record(session, table))