~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/schema.cc

  • Committer: Brian Aker
  • Date: 2010-12-16 02:16:37 UTC
  • mto: This revision was merged to the branch mainline in revision 1999.
  • Revision ID: brian@tangent.org-20101216021637-owmmneuy57ddhcn3
uuid type code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
  return boost::iequals(arg, db);
99
99
}
100
100
 
101
 
bool SchemaIdentifier::compare(SchemaIdentifier::const_reference arg) const
102
 
{
103
 
  return boost::iequals(arg.getSchemaName(), db);
104
 
}
105
 
 
106
101
bool SchemaIdentifier::isValid() const
107
102
{
108
 
  bool error= false;
109
 
 
110
 
  do
111
 
  {
112
 
    if (db.empty())
113
 
    {
114
 
      error= true;
115
 
      break;
116
 
    }
117
 
 
118
 
    if (db.size() > NAME_LEN)
119
 
    {
120
 
      error= true;
121
 
      break;
122
 
    }
123
 
 
124
 
    if (db.at(db.length() -1) == ' ')
125
 
    {
126
 
      error= true;
127
 
      break;
128
 
    }
129
 
 
130
 
    if (db.at(0) == '.')
131
 
    {
132
 
      error= true;
133
 
      break;
134
 
    }
135
 
 
136
 
    {
137
 
      const CHARSET_INFO * const cs= &my_charset_utf8mb4_general_ci;
138
 
 
139
 
      int well_formed_error;
140
 
      uint32_t res= cs->cset->well_formed_len(cs, db.c_str(), db.c_str() + db.length(),
141
 
                                              NAME_CHAR_LEN, &well_formed_error);
142
 
      if (well_formed_error or db.length() != res)
143
 
      {
144
 
        error= true;
145
 
        break;
146
 
      }
147
 
    }
148
 
  } while (0);
149
 
 
150
 
  if (error)
151
 
  {
152
 
    std::string name;
153
 
 
154
 
    getSQLPath(name);
155
 
    my_error(ER_WRONG_DB_NAME, MYF(0), name.c_str());
156
 
 
 
103
  if (db.empty())
 
104
    return false;
 
105
 
 
106
  if (db.size() > NAME_LEN)
 
107
    return false;
 
108
 
 
109
  if (db.at(db.length() -1) == ' ')
 
110
    return false;
 
111
 
 
112
  const CHARSET_INFO * const cs= &my_charset_utf8mb4_general_ci;
 
113
 
 
114
  int well_formed_error;
 
115
  uint32_t res= cs->cset->well_formed_len(cs, db.c_str(), db.c_str() + db.length(),
 
116
                                          NAME_CHAR_LEN, &well_formed_error);
 
117
 
 
118
  if (well_formed_error)
 
119
  {
 
120
    my_error(ER_INVALID_CHARACTER_STRING, MYF(0), "identifier", db.c_str());
157
121
    return false;
158
122
  }
159
123
 
 
124
  if (db.length() != res)
 
125
    return false;
 
126
 
160
127
  return true;
161
128
}
162
129