~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/table_list.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
using namespace std;
29
29
 
30
 
namespace drizzled
31
 
{
32
 
 
33
 
class Item;
34
 
class Item_field;
35
 
 
36
 
bool TableList::set_insert_values(memory::Root *)
 
30
namespace drizzled {
 
31
 
 
32
void TableList::set_insert_values()
37
33
{
38
34
  if (table)
39
35
  {
40
36
    table->insert_values.resize(table->getShare()->rec_buff_length);
41
37
  }
42
 
 
43
 
  return false;
44
38
}
45
39
 
46
 
bool TableList::is_leaf_for_name_resolution()
 
40
bool TableList::is_leaf_for_name_resolution() const
47
41
{
48
 
  return (is_natural_join || is_join_columns_complete || !nested_join);
 
42
  return is_natural_join || is_join_columns_complete || not nested_join;
49
43
}
50
44
 
51
45
TableList *TableList::find_underlying_table(Table *table_to_find)
160
154
    key_map index_join[INDEX_HINT_FORCE + 1];
161
155
    key_map index_order[INDEX_HINT_FORCE + 1];
162
156
    key_map index_group[INDEX_HINT_FORCE + 1];
163
 
    Index_hint *hint;
164
 
    int type;
165
157
    bool have_empty_use_join= false, have_empty_use_order= false,
166
158
         have_empty_use_group= false;
167
159
    List_iterator <Index_hint> iter(index_hints->begin());
168
160
 
169
161
    /* initialize temporary variables used to collect hints of each kind */
170
 
    for (type= INDEX_HINT_IGNORE; type <= INDEX_HINT_FORCE; type++)
 
162
    for (int type= INDEX_HINT_IGNORE; type <= INDEX_HINT_FORCE; type++)
171
163
    {
172
164
      index_join[type].reset();
173
165
      index_order[type].reset();
175
167
    }
176
168
 
177
169
    /* iterate over the hints list */
178
 
    while ((hint= iter++))
 
170
    while (Index_hint* hint= iter++)
179
171
    {
180
 
      uint32_t pos= 0;
181
 
 
182
172
      /* process empty USE INDEX () */
183
 
      if (hint->type == INDEX_HINT_USE && !hint->key_name.str)
 
173
      if (hint->type == INDEX_HINT_USE && !hint->key_name)
184
174
      {
185
175
        if (hint->clause & INDEX_HINT_MASK_JOIN)
186
176
        {
204
194
        Check if an index with the given name exists and get his offset in
205
195
        the keys bitmask for the table
206
196
      */
207
 
      if (not tbl->getShare()->doesKeyNameExist(hint->key_name.str, hint->key_name.length, pos))
 
197
      uint32_t pos= tbl->getShare()->doesKeyNameExist(hint->key_name);
 
198
      if (pos == UINT32_MAX)
208
199
      {
209
 
        my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), hint->key_name.str, alias);
 
200
        my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), hint->key_name, alias);
210
201
        return 1;
211
202
      }
212
203
      /* add to the appropriate clause mask */
226
217
         index_order[INDEX_HINT_USE].any() || have_empty_use_order ||
227
218
         index_group[INDEX_HINT_USE].any() || have_empty_use_group))
228
219
    {
229
 
      my_error(ER_WRONG_USAGE, MYF(0), index_hint_type_name[INDEX_HINT_USE],
230
 
               index_hint_type_name[INDEX_HINT_FORCE]);
 
220
      my_error(ER_WRONG_USAGE, MYF(0), index_hint_type_name[INDEX_HINT_USE], index_hint_type_name[INDEX_HINT_FORCE]);
231
221
      return 1;
232
222
    }
233
223
 
283
273
    else
284
274
    {
285
275
      // A normal table
286
 
      {
287
 
        str->append_identifier(db, db_length);
288
 
        str->append('.');
289
 
      }
290
 
      str->append_identifier(table_name, table_name_length);
 
276
      str->append_identifier(str_ref(schema));
 
277
      str->append('.');
 
278
      str->append_identifier(str_ref(table_name));
291
279
      cmp_name= table_name;
292
280
    }
293
 
    if (my_strcasecmp(table_alias_charset, cmp_name, alias))
 
281
    if (table_alias_charset->strcasecmp(cmp_name, alias) && alias && alias[0])
294
282
    {
295
 
 
296
 
      if (alias && alias[0])
297
 
      {
298
 
        str->append(' ');
299
 
 
300
 
        string t_alias(alias);
301
 
        transform(t_alias.begin(), t_alias.end(),
302
 
                  t_alias.begin(), ::tolower);
303
 
 
304
 
        str->append_identifier(t_alias.c_str(), t_alias.length());
305
 
      }
306
 
 
 
283
      str->append(' ');
 
284
      str->append_identifier(boost::to_lower_copy(string(alias)));
307
285
    }
308
286
 
309
287
    if (index_hints)
310
288
    {
311
289
      List<Index_hint>::iterator it(index_hints->begin());
312
 
      Index_hint *hint;
313
 
 
314
 
      while ((hint= it++))
 
290
      while (Index_hint* hint= it++)
315
291
      {
316
 
        str->append (STRING_WITH_LEN(" "));
317
 
        hint->print (session, str);
 
292
        str->append(STRING_WITH_LEN(" "));
 
293
        hint->print(*str);
318
294
      }
319
295
    }
320
296
  }