~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/collation_dictionary/collations.cc

  • Committer: Brian Aker
  • Date: 2010-02-14 02:02:48 UTC
  • mfrom: (1273.13.64 fix_is)
  • Revision ID: brian@gaz-20100214020248-bhovaejhz9fmer3q
MergeĀ inĀ data_dictionary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2010 Sun Microsystems
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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
 
19
 */
 
20
 
 
21
#include "config.h"
 
22
#include "plugin/collation_dictionary/dictionary.h"
 
23
 
 
24
using namespace std;
 
25
using namespace drizzled;
 
26
 
 
27
 
 
28
CollationsTool::CollationsTool() :
 
29
  plugin::TableFunction("DATA_DICTIONARY", "COLLATIONS")
 
30
{
 
31
  add_field("CHARACTER_SET_NAME");
 
32
  add_field("COLLATION_NAME");
 
33
  add_field("DESCRIPTION");
 
34
  add_field("ID", plugin::TableFunction::NUMBER);
 
35
  add_field("IS_DEFAULT", plugin::TableFunction::BOOLEAN);
 
36
  add_field("IS_COMPILED", plugin::TableFunction::BOOLEAN);
 
37
  add_field("SORTLEN", plugin::TableFunction::NUMBER);
 
38
}
 
39
 
 
40
CollationsTool::Generator::Generator(Field **arg) :
 
41
  plugin::TableFunction::Generator(arg)
 
42
{
 
43
  cs= all_charsets;
 
44
  cl= all_charsets;
 
45
}
 
46
 
 
47
bool CollationsTool::Generator::populate()
 
48
{
 
49
  for (; cs < all_charsets+255 ; cs++)
 
50
  {
 
51
    const CHARSET_INFO *tmp_cs= cs[0];
 
52
 
 
53
    if (! tmp_cs || ! (tmp_cs->state & MY_CS_AVAILABLE) ||
 
54
        (tmp_cs->state & MY_CS_HIDDEN) ||
 
55
        !(tmp_cs->state & MY_CS_PRIMARY))
 
56
      continue;
 
57
 
 
58
    for (; cl < all_charsets+255 ;cl ++)
 
59
    {
 
60
      const CHARSET_INFO *tmp_cl= cl[0];
 
61
 
 
62
      if (! tmp_cl || ! (tmp_cl->state & MY_CS_AVAILABLE) ||
 
63
          !my_charset_same(tmp_cs, tmp_cl))
 
64
        continue;
 
65
 
 
66
      {
 
67
        /* CHARACTER_SET_NAME */
 
68
        push(tmp_cs->name);
 
69
 
 
70
        /* "COLLATION_NAME" */
 
71
        push(tmp_cl->name);
 
72
 
 
73
        /* "DESCRIPTION" */
 
74
        push(tmp_cl->csname);
 
75
 
 
76
        /* COLLATION_ID */
 
77
        push((int64_t) tmp_cl->number);
 
78
         
 
79
        /* IS_DEFAULT */
 
80
        push((bool)(tmp_cl->state & MY_CS_PRIMARY));
 
81
 
 
82
        /* IS_COMPILED */
 
83
        push((bool)(tmp_cl->state & MY_CS_COMPILED));
 
84
 
 
85
        /* SORTLEN */
 
86
        push((int64_t) tmp_cl->strxfrm_multiply);
 
87
 
 
88
        cl++;
 
89
 
 
90
        return true;
 
91
      }
 
92
      cs++;
 
93
    }
 
94
 
 
95
    cl= all_charsets;
 
96
  }
 
97
 
 
98
  return false;
 
99
}