~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/show.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:
97
97
      if (*wildstr == wild_prefix && wildstr[1])
98
98
        wildstr++;
99
99
      if (my_toupper(cs, *wildstr++) != my_toupper(cs, *str++))
100
 
        return(1);
 
100
        return (1);
101
101
    }
102
102
    if (! *wildstr )
103
103
      return (*str != 0);
108
108
    }
109
109
    else
110
110
    {                                           /* Found '*' */
111
 
      if (!*wildstr)
112
 
        return(0);              /* '*' as last char: OK */
 
111
      if (! *wildstr)
 
112
        return (0);             /* '*' as last char: OK */
113
113
      flag=(*wildstr != wild_many && *wildstr != wild_one);
114
114
      do
115
115
      {
116
 
        if (flag)
117
 
        {
118
 
          char cmp;
119
 
          if ((cmp= *wildstr) == wild_prefix && wildstr[1])
120
 
            cmp=wildstr[1];
121
 
          cmp=my_toupper(cs, cmp);
122
 
          while (*str && my_toupper(cs, *str) != cmp)
123
 
            str++;
124
 
    if (!*str)
 
116
        if (flag)
 
117
        {
 
118
          char cmp;
 
119
          if ((cmp= *wildstr) == wild_prefix && wildstr[1])
 
120
            cmp= wildstr[1];
 
121
          cmp= my_toupper(cs, cmp);
 
122
          while (*str && my_toupper(cs, *str) != cmp)
 
123
            str++;
 
124
          if (! *str)
 
125
            return (1);
 
126
        }
 
127
        if (wild_case_compare(cs, str, wildstr) == 0)
 
128
          return (0);
 
129
      } while (*str++);
125
130
      return (1);
126
 
        }
127
 
  if (wild_case_compare(cs, str,wildstr) == 0)
128
 
      return (0);
129
 
      } while (*str++);
130
 
      return(1);
131
131
    }
132
132
  }
133
133
  return (*str != '\0');
2955
2955
  return(0);
2956
2956
}
2957
2957
 
2958
 
 
2959
 
 
2960
 
int CharSetISMethods::fillTable(Session *session, TableList *tables, COND *)
2961
 
{
2962
 
  CHARSET_INFO **cs;
2963
 
  const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
2964
 
  Table *table= tables->table;
2965
 
  const CHARSET_INFO * const scs= system_charset_info;
2966
 
 
2967
 
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++)
2968
 
  {
2969
 
    const CHARSET_INFO * const tmp_cs= cs[0];
2970
 
    if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) &&
2971
 
        (tmp_cs->state & MY_CS_AVAILABLE) &&
2972
 
        !(tmp_cs->state & MY_CS_HIDDEN) &&
2973
 
        !(wild && wild[0] &&
2974
 
          wild_case_compare(scs, tmp_cs->csname,wild)))
2975
 
    {
2976
 
      const char *comment;
2977
 
      table->restoreRecordAsDefault();
2978
 
      table->field[0]->store(tmp_cs->csname, strlen(tmp_cs->csname), scs);
2979
 
      table->field[1]->store(tmp_cs->name, strlen(tmp_cs->name), scs);
2980
 
      comment= tmp_cs->comment ? tmp_cs->comment : "";
2981
 
      table->field[2]->store(comment, strlen(comment), scs);
2982
 
      table->field[3]->store((int64_t) tmp_cs->mbmaxlen, true);
2983
 
      if (schema_table_store_record(session, table))
2984
 
        return 1;
2985
 
    }
2986
 
  }
2987
 
  return 0;
2988
 
}
2989
 
 
2990
 
 
2991
2958
int CollationISMethods::fillTable(Session *session, TableList *tables, COND *)
2992
2959
{
2993
2960
  CHARSET_INFO **cs;
3799
3766
}
3800
3767
 
3801
3768
 
3802
 
int CharSetISMethods::oldFormat(Session *session, InfoSchemaTable *schema_table)
3803
 
  const
3804
 
{
3805
 
  int fields_arr[]= {0, 2, 1, 3, -1};
3806
 
  int *field_num= fields_arr;
3807
 
  const InfoSchemaTable::Columns columns= schema_table->getColumns();
3808
 
  const ColumnInfo *column;
3809
 
  Name_resolution_context *context= &session->lex->select_lex.context;
3810
 
 
3811
 
  for (; *field_num >= 0; field_num++)
3812
 
  {
3813
 
    column= columns[*field_num];
3814
 
    Item_field *field= new Item_field(context,
3815
 
                                      NULL, NULL, column->getName().c_str());
3816
 
    if (field)
3817
 
    {
3818
 
      field->set_name(column->getOldName().c_str(),
3819
 
                      column->getOldName().length(),
3820
 
                      system_charset_info);
3821
 
      if (session->add_item_to_list(field))
3822
 
        return 1;
3823
 
    }
3824
 
  }
3825
 
  return 0;
3826
 
}
3827
 
 
3828
 
 
3829
3769
/*
3830
3770
  Create information_schema table
3831
3771
 
4092
4032
};
4093
4033
 
4094
4034
 
4095
 
ColumnInfo charsets_fields_info[]=
4096
 
{
4097
 
  ColumnInfo("CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Charset",
4098
 
   SKIP_OPEN_TABLE),
4099
 
  ColumnInfo("DEFAULT_COLLATE_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Default collation",
4100
 
   SKIP_OPEN_TABLE),
4101
 
  ColumnInfo("DESCRIPTION", 60, DRIZZLE_TYPE_VARCHAR, 0, 0, "Description",
4102
 
   SKIP_OPEN_TABLE),
4103
 
  ColumnInfo("MAXLEN", 3, DRIZZLE_TYPE_LONGLONG, 0, 0, "Maxlen", SKIP_OPEN_TABLE),
4104
 
  ColumnInfo()
4105
 
};
4106
 
 
4107
 
 
4108
4035
ColumnInfo collation_fields_info[]=
4109
4036
{
4110
4037
  ColumnInfo("COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Collation", SKIP_OPEN_TABLE),
4259
4186
  ColumnInfo()
4260
4187
};
4261
4188
 
4262
 
static CharSetISMethods char_set_methods;
4263
4189
static CollationISMethods collations_methods;
4264
4190
static CollCharISMethods coll_char_methods;
4265
4191
static ColumnsISMethods columns_methods;
4275
4201
static TabConstraintsISMethods tab_constraints_methods;
4276
4202
static TabNamesISMethods tab_names_methods;
4277
4203
 
4278
 
static InfoSchemaTable char_set_table("CHARACTER_SETS",
4279
 
                                      charsets_fields_info,
4280
 
                                      -1, -1, false, false, 0,
4281
 
                                      &char_set_methods);
4282
4204
static InfoSchemaTable collations_table("COLLATIONS",
4283
4205
                                        collation_fields_info,
4284
4206
                                        -1, -1, false, false, 0,
4361
4283
 
4362
4284
InfoSchemaTable schema_tables[]=
4363
4285
{
4364
 
  char_set_table,
4365
4286
  collations_table,
4366
4287
  coll_char_set_table,
4367
4288
  columns_table,