00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022 #include <plugin/collation_dictionary/dictionary.h>
00023
00024 using namespace std;
00025 using namespace drizzled;
00026
00027
00028 CollationsTool::CollationsTool() :
00029 CharacterSetsTool("COLLATIONS")
00030 {
00031 add_field("CHARACTER_SET_NAME");
00032 add_field("COLLATION_NAME");
00033 add_field("DESCRIPTION");
00034 add_field("ID", plugin::TableFunction::NUMBER, 0, false);
00035 add_field("IS_DEFAULT", plugin::TableFunction::BOOLEAN, 0, false);
00036 add_field("IS_COMPILED", plugin::TableFunction::BOOLEAN, 0, false);
00037 add_field("SORTLEN", plugin::TableFunction::NUMBER, 0, false);
00038 }
00039
00040 CollationsTool::Generator::Generator(Field **arg) :
00041 CharacterSetsTool::Generator(arg),
00042 is_collation_primed(false)
00043 {
00044 }
00045
00046
00047 bool CollationsTool::Generator::end()
00048 {
00049 return collation_iter == all_charsets+255;
00050 }
00051
00052
00053 bool CollationsTool::Generator::check()
00054 {
00055 const CHARSET_INFO *tmp_cs= character_set();
00056 const CHARSET_INFO *tmp_cl= collation();
00057
00058 if (not tmp_cl ||
00059 not (tmp_cl->state & MY_CS_AVAILABLE) ||
00060 not my_charset_same(tmp_cs, tmp_cl))
00061 return true;
00062
00063 return false;
00064 }
00065
00066 bool CollationsTool::Generator::nextCollationCore()
00067 {
00068 if (isPrimed())
00069 {
00070 collation_iter++;
00071 }
00072 else
00073 {
00074 if (not isCharacterSetPrimed())
00075 return false;
00076
00077 collation_iter= all_charsets;
00078 prime();
00079 }
00080
00081 if (end())
00082 return false;
00083
00084 if (check())
00085 return false;
00086
00087 return true;
00088 }
00089
00090
00091 bool CollationsTool::Generator::next()
00092 {
00093 while (not nextCollationCore())
00094 {
00095
00096 if (isPrimed() && not end())
00097 continue;
00098
00099 if (not nextCharacterSet())
00100 return false;
00101
00102 prime(false);
00103 }
00104
00105 return true;
00106 }
00107
00108 bool CollationsTool::Generator::populate()
00109 {
00110 if (not next())
00111 return false;
00112
00113 fill();
00114
00115 return true;
00116 }
00117
00118 void CollationsTool::Generator::fill()
00119 {
00120 const CHARSET_INFO *tmp_cs= character_set();
00121 const CHARSET_INFO *tmp_cl= collation_iter[0];
00122
00123 assert(tmp_cs);
00124 assert(tmp_cl);
00125
00126 assert(tmp_cs->name);
00127
00128 push(tmp_cs->name);
00129
00130
00131 assert(tmp_cl->name);
00132 push(tmp_cl->name);
00133
00134
00135 push(tmp_cl->csname);
00136
00137
00138 push(static_cast<int64_t>(tmp_cl->number));
00139
00140
00141 push((bool)(tmp_cl->state & MY_CS_PRIMARY));
00142
00143
00144 push((bool)(tmp_cl->state & MY_CS_COMPILED));
00145
00146
00147 push(static_cast<int64_t>(tmp_cl->strxfrm_multiply));
00148 }