~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 01:56:51 UTC
  • mto: (1273.16.5 fix_is)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: brian@gaz-20100214015651-ror9j0xu7dccz0ct
Two fixes for "make dist"

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
 
28
28
CollationsTool::CollationsTool() :
29
 
  CharacterSetsTool("COLLATIONS")
 
29
  plugin::TableFunction("DATA_DICTIONARY", "COLLATIONS")
30
30
{
31
31
  add_field("CHARACTER_SET_NAME");
32
32
  add_field("COLLATION_NAME");
33
33
  add_field("DESCRIPTION");
34
 
  add_field("ID", plugin::TableFunction::NUMBER, 0, false);
 
34
  add_field("ID", plugin::TableFunction::NUMBER);
35
35
  add_field("IS_DEFAULT", plugin::TableFunction::BOOLEAN);
36
36
  add_field("IS_COMPILED", plugin::TableFunction::BOOLEAN);
37
 
  add_field("SORTLEN", plugin::TableFunction::NUMBER, 0, false);
 
37
  add_field("SORTLEN", plugin::TableFunction::NUMBER);
38
38
}
39
39
 
40
40
CollationsTool::Generator::Generator(Field **arg) :
41
 
  CharacterSetsTool::Generator(arg),
42
 
  is_collation_primed(false)
43
 
{
44
 
}
45
 
 
46
 
 
47
 
bool CollationsTool::Generator::end()
48
 
{
49
 
  return collation_iter == all_charsets+255;
50
 
}
51
 
 
52
 
 
53
 
bool CollationsTool::Generator::check()
54
 
{
55
 
  const CHARSET_INFO *tmp_cs= character_set();
56
 
  const CHARSET_INFO *tmp_cl= collation();
57
 
 
58
 
  if (not tmp_cl || 
59
 
      not (tmp_cl->state & MY_CS_AVAILABLE) ||
60
 
      not my_charset_same(tmp_cs, tmp_cl))
61
 
    return true;
 
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
  }
62
97
 
63
98
  return false;
64
99
}
65
 
 
66
 
bool CollationsTool::Generator::nextCollationCore()
67
 
{
68
 
  if (isPrimed())
69
 
  {
70
 
    collation_iter++;
71
 
  }
72
 
  else
73
 
  {
74
 
    if (not isCharacterSetPrimed())
75
 
     return false;
76
 
 
77
 
    collation_iter= all_charsets;
78
 
    prime();
79
 
  }
80
 
 
81
 
  if (end())
82
 
    return false;
83
 
 
84
 
  if (check())
85
 
      return false;
86
 
 
87
 
  return true;
88
 
}
89
 
 
90
 
 
91
 
bool CollationsTool::Generator::next()
92
 
{
93
 
  while (not nextCollationCore())
94
 
  {
95
 
 
96
 
    if (isPrimed() && not end())
97
 
      continue;
98
 
 
99
 
    if (not nextCharacterSet())
100
 
      return false;
101
 
 
102
 
    prime(false);
103
 
  }
104
 
 
105
 
  return true;
106
 
}
107
 
 
108
 
bool CollationsTool::Generator::populate()
109
 
{
110
 
  if (not next())
111
 
    return false;
112
 
 
113
 
  fill();
114
 
 
115
 
  return true;
116
 
}
117
 
 
118
 
void CollationsTool::Generator::fill()
119
 
{
120
 
  const CHARSET_INFO *tmp_cs= character_set();
121
 
  const CHARSET_INFO *tmp_cl= collation_iter[0];
122
 
 
123
 
  assert(tmp_cs);
124
 
  assert(tmp_cl);
125
 
 
126
 
  assert(tmp_cs->name);
127
 
  /* CHARACTER_SET_NAME */
128
 
  push(tmp_cs->name);
129
 
 
130
 
  /* "COLLATION_NAME" */
131
 
  assert(tmp_cl->name);
132
 
  push(tmp_cl->name);
133
 
 
134
 
  /* "DESCRIPTION" */
135
 
  push(tmp_cl->csname);
136
 
 
137
 
  /* COLLATION_ID */
138
 
  push(static_cast<int64_t>(tmp_cl->number));
139
 
 
140
 
  /* IS_DEFAULT */
141
 
  push((bool)(tmp_cl->state & MY_CS_PRIMARY));
142
 
 
143
 
  /* IS_COMPILED */
144
 
  push((bool)(tmp_cl->state & MY_CS_COMPILED));
145
 
 
146
 
  /* SORTLEN */
147
 
  push(static_cast<int64_t>(tmp_cl->strxfrm_multiply));
148
 
}