~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/data_engine/character_sets.cc

Does not work (compile issue in plugin).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2010 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2010 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
22
 
#include <plugin/collation_dictionary/dictionary.h>
 
21
#include "config.h"
 
22
 
 
23
#include "plugin/data_engine/character_sets.h"
23
24
 
24
25
using namespace std;
25
26
using namespace drizzled;
30
31
  add_field("CHARACTER_SET_NAME");
31
32
  add_field("DEFAULT_COLLATE_NAME");
32
33
  add_field("DESCRIPTION");
33
 
  add_field("MAXLEN", plugin::TableFunction::NUMBER, 0, false);
 
34
  add_field("MAXLEN", plugin::TableFunction::NUMBER);
34
35
}
35
36
 
36
37
CharacterSetsTool::Generator::Generator(Field **arg) :
37
 
  plugin::TableFunction::Generator(arg),
38
 
  is_char_primed(false)
39
 
{
40
 
}
41
 
 
42
 
bool CharacterSetsTool::Generator::checkCharacterSet()
43
 
{
44
 
  if (character_set() && (character_set()->state & MY_CS_PRIMARY) &&
45
 
      (character_set()->state & MY_CS_AVAILABLE) && not (character_set()->state & MY_CS_HIDDEN))
46
 
  {
47
 
    return false;
48
 
  }
49
 
 
50
 
  return true;
51
 
}
52
 
 
53
 
bool CharacterSetsTool::Generator::nextCharacterSetCore()
54
 
{
55
 
  if (is_char_primed)
56
 
  {
57
 
    character_set_iter++;
58
 
  }
59
 
  else
60
 
  {
61
 
    character_set_iter= all_charsets;
62
 
    is_char_primed= true;
63
 
  }
64
 
 
65
 
  if (character_set_iter == all_charsets+255)
66
 
    return false;
67
 
 
68
 
  if (checkCharacterSet())
69
 
      return false;
70
 
 
71
 
  return true;
72
 
}
73
 
 
74
 
bool CharacterSetsTool::Generator::nextCharacterSet()
75
 
{
76
 
  while (not nextCharacterSetCore())
77
 
  {
78
 
    if (character_set_iter == all_charsets+255)
79
 
      return false;
80
 
  }
81
 
 
82
 
  return true;
 
38
  plugin::TableFunction::Generator(arg)
 
39
{
 
40
  cs= all_charsets;
83
41
}
84
42
 
85
43
bool CharacterSetsTool::Generator::populate()
86
44
{
87
 
  if (nextCharacterSet())
 
45
  for (; cs < all_charsets+255 ; cs++)
88
46
  {
89
 
    fill();
90
 
    return true;
 
47
    const CHARSET_INFO * const tmp_cs= cs[0];
 
48
 
 
49
    if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) &&
 
50
        (tmp_cs->state & MY_CS_AVAILABLE) &&
 
51
        ! (tmp_cs->state & MY_CS_HIDDEN))
 
52
    {
 
53
      /* CHARACTER_SET_NAME */
 
54
      push(tmp_cs->csname);
 
55
 
 
56
      /* DEFAULT_COLLATE_NAME */
 
57
      push(tmp_cs->name);
 
58
 
 
59
      /* DESCRIPTION */
 
60
      push(tmp_cs->comment);
 
61
 
 
62
      /* MAXLEN */
 
63
      push((int64_t) tmp_cs->mbmaxlen);
 
64
 
 
65
      cs++;
 
66
 
 
67
      return true;
 
68
    }
91
69
  }
92
70
 
93
71
  return false;
94
72
}
95
 
 
96
 
void CharacterSetsTool::Generator::fill()
97
 
{
98
 
  const charset_info_st * const tmp_cs= character_set_iter[0];
99
 
 
100
 
  /* CHARACTER_SET_NAME */
101
 
  push(tmp_cs->csname);
102
 
 
103
 
  /* DEFAULT_COLLATE_NAME */
104
 
  push(tmp_cs->name);
105
 
 
106
 
  /* DESCRIPTION */
107
 
  push(tmp_cs->comment);
108
 
 
109
 
  /* MAXLEN */
110
 
  push(static_cast<int64_t>(tmp_cs->mbmaxlen));
111
 
}