~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/info_schema/info_schema_methods.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-06-27 16:33:55 UTC
  • mfrom: (1067.3.1 full-i-s-plugin)
  • mto: This revision was merged to the branch mainline in revision 1079.
  • Revision ID: osullivan.padraig@gmail.com-20090627163355-iyclbhr9901qlmjh
Extracted the CHARACTER_SET table into the I_S plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
using namespace std;
33
33
 
 
34
int CharSetISMethods::fillTable(Session *session, TableList *tables, COND *)
 
35
{
 
36
  CHARSET_INFO **cs;
 
37
  const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
 
38
  Table *table= tables->table;
 
39
  const CHARSET_INFO * const scs= system_charset_info;
 
40
 
 
41
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++)
 
42
  {
 
43
    const CHARSET_INFO * const tmp_cs= cs[0];
 
44
    if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) &&
 
45
        (tmp_cs->state & MY_CS_AVAILABLE) &&
 
46
        !(tmp_cs->state & MY_CS_HIDDEN) &&
 
47
        !(wild && wild[0] &&
 
48
          wild_case_compare(scs, tmp_cs->csname,wild)))
 
49
    {
 
50
      const char *comment;
 
51
      table->restoreRecordAsDefault();
 
52
      table->field[0]->store(tmp_cs->csname, strlen(tmp_cs->csname), scs);
 
53
      table->field[1]->store(tmp_cs->name, strlen(tmp_cs->name), scs);
 
54
      comment= tmp_cs->comment ? tmp_cs->comment : "";
 
55
      table->field[2]->store(comment, strlen(comment), scs);
 
56
      table->field[3]->store((int64_t) tmp_cs->mbmaxlen, true);
 
57
      if (schema_table_store_record(session, table))
 
58
        return 1;
 
59
    }
 
60
  }
 
61
  return 0;
 
62
}
 
63
 
 
64
int CharSetISMethods::oldFormat(Session *session, InfoSchemaTable *schema_table)
 
65
  const
 
66
{
 
67
  int fields_arr[]= {0, 2, 1, 3, -1};
 
68
  int *field_num= fields_arr;
 
69
  const ColumnInfo *column;
 
70
  Name_resolution_context *context= &session->lex->select_lex.context;
 
71
 
 
72
  for (; *field_num >= 0; field_num++)
 
73
  {
 
74
    column= schema_table->getSpecificColumn(*field_num);
 
75
    Item_field *field= new Item_field(context,
 
76
                                      NULL, NULL, column->getName());
 
77
    if (field)
 
78
    {
 
79
      field->set_name(column->getOldName(),
 
80
                      strlen(column->getOldName()),
 
81
                      system_charset_info);
 
82
      if (session->add_item_to_list(field))
 
83
        return 1;
 
84
    }
 
85
  }
 
86
  return 0;
 
87
}
 
88
 
34
89
int ProcessListISMethods::fillTable(Session* session, TableList* tables, COND*)
35
90
{
36
91
  Table *table= tables->table;