1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Sun Microsystems, Inc.
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
22
#include "plugin/collation_dictionary/dictionary.h"
25
using namespace drizzled;
28
CollationsTool::CollationsTool() :
29
CharacterSetsTool("COLLATIONS")
31
add_field("CHARACTER_SET_NAME");
32
add_field("COLLATION_NAME");
33
add_field("DESCRIPTION");
34
add_field("ID", plugin::TableFunction::NUMBER, 0, false);
35
add_field("IS_DEFAULT", plugin::TableFunction::BOOLEAN, 0, false);
36
add_field("IS_COMPILED", plugin::TableFunction::BOOLEAN, 0, false);
37
add_field("SORTLEN", plugin::TableFunction::NUMBER, 0, false);
40
CollationsTool::Generator::Generator(Field **arg) :
41
CharacterSetsTool::Generator(arg),
42
is_collation_primed(false)
47
bool CollationsTool::Generator::end()
49
return collation_iter == all_charsets+255;
53
bool CollationsTool::Generator::check()
55
const CHARSET_INFO *tmp_cs= character_set();
56
const CHARSET_INFO *tmp_cl= collation();
59
not (tmp_cl->state & MY_CS_AVAILABLE) ||
60
not my_charset_same(tmp_cs, tmp_cl))
66
bool CollationsTool::Generator::nextCollationCore()
74
if (not isCharacterSetPrimed())
77
collation_iter= all_charsets;
91
bool CollationsTool::Generator::next()
93
while (not nextCollationCore())
96
if (isPrimed() && not end())
99
if (not nextCharacterSet())
108
bool CollationsTool::Generator::populate()
118
void CollationsTool::Generator::fill()
120
const CHARSET_INFO *tmp_cs= character_set();
121
const CHARSET_INFO *tmp_cl= collation_iter[0];
126
assert(tmp_cs->name);
127
/* CHARACTER_SET_NAME */
130
/* "COLLATION_NAME" */
131
assert(tmp_cl->name);
135
push(tmp_cl->csname);
138
push(static_cast<int64_t>(tmp_cl->number));
141
push((bool)(tmp_cl->state & MY_CS_PRIMARY));
144
push((bool)(tmp_cl->state & MY_CS_COMPILED));
147
push(static_cast<int64_t>(tmp_cl->strxfrm_multiply));