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.
27
#include "drizzled/session.h"
28
#include "drizzled/show.h"
29
#include "drizzled/global_charset_info.h"
30
#include "drizzled/charset.h"
33
#include "helper_methods.h"
34
#include "collation.h"
38
using namespace drizzled;
42
* Vectors of columns for the collation I_S table.
44
static vector<const plugin::ColumnInfo *> *columns= NULL;
47
* Methods for the collation I_S table.
49
static plugin::InfoSchemaMethods *methods= NULL;
52
* collation I_S table.
54
static plugin::InfoSchemaTable *coll_table= NULL;
57
* Populate the vectors of columns for the I_S table.
59
* @return a pointer to a std::vector of Columns.
61
vector<const plugin::ColumnInfo *> *CollationIS::createColumns()
65
columns= new vector<const plugin::ColumnInfo *>;
69
clearColumns(*columns);
73
* Create each column for the COLLATION table.
75
columns->push_back(new plugin::ColumnInfo("COLLATION_NAME",
82
columns->push_back(new plugin::ColumnInfo("CHARACTER_SET_NAME",
87
"Default collation"));
89
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,
103
columns->push_back(new plugin::ColumnInfo("IS_DEFAULT",
105
DRIZZLE_TYPE_VARCHAR,
110
columns->push_back(new plugin::ColumnInfo("IS_COMPILED",
112
DRIZZLE_TYPE_VARCHAR,
117
columns->push_back(new plugin::ColumnInfo("SORTLEN",
119
DRIZZLE_TYPE_LONGLONG,
128
* Initialize the I_S table.
130
* @return a pointer to an I_S table
132
plugin::InfoSchemaTable *CollationIS::getTable()
134
columns= createColumns();
138
methods= new CollationISMethods();
141
if (coll_table == NULL)
143
coll_table= new(nothrow) plugin::InfoSchemaTable("COLLATIONS",
145
-1, -1, false, false, 0,
153
* Delete memory allocated for the table, columns and methods.
155
void CollationIS::cleanup()
157
clearColumns(*columns);
163
int CollationISMethods::fillTable(Session *session,
165
plugin::InfoSchemaTable *schema_table)
168
const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
169
const CHARSET_INFO * const scs= system_charset_info;
170
for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
173
const CHARSET_INFO *tmp_cs= cs[0];
174
if (! tmp_cs || ! (tmp_cs->state & MY_CS_AVAILABLE) ||
175
(tmp_cs->state & MY_CS_HIDDEN) ||
176
!(tmp_cs->state & MY_CS_PRIMARY))
178
for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
180
const CHARSET_INFO *tmp_cl= cl[0];
181
if (! tmp_cl || ! (tmp_cl->state & MY_CS_AVAILABLE) ||
182
!my_charset_same(tmp_cs, tmp_cl))
184
if (! (wild && wild[0] &&
185
wild_case_compare(scs, tmp_cl->name,wild)))
187
const char *tmp_buff;
188
table->restoreRecordAsDefault();
189
/* set the appropriate bits in the write bitset */
190
table->setWriteSet(0);
191
table->setWriteSet(1);
192
table->setWriteSet(2);
193
table->setWriteSet(3);
194
table->setWriteSet(4);
195
table->setWriteSet(5);
196
table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
197
table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
198
table->field[2]->store((int64_t) tmp_cl->number, true);
199
tmp_buff= (tmp_cl->state & MY_CS_PRIMARY) ? "Yes" : "";
200
table->field[3]->store(tmp_buff, strlen(tmp_buff), scs);
201
tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : "";
202
table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
203
table->field[5]->store((int64_t) tmp_cl->strxfrm_multiply, true);
204
schema_table->addRow(table->record[0], table->s->reclength);