~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/explain_plan.cc

  • Committer: Mark Atwood
  • Date: 2011-10-21 14:25:19 UTC
  • mfrom: (2440.2.28 rf)
  • Revision ID: me@mark.atwood.name-20111021142519-bqnyqrkthibv70rc
Tags: 2011.10.28
mergeĀ lp:~olafvdspek/drizzle/refactor6

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
   */
93
93
  if (message)
94
94
  {
95
 
    item_list.push_back(new Item_int((int32_t)
96
 
                        join->select_lex->select_number));
97
 
    item_list.push_back(new Item_string(select_type_str[join->select_lex->type].c_str(),
98
 
                                        select_type_str[join->select_lex->type].length(),
99
 
                                        cs));
 
95
    item_list.push_back(new Item_int((int32_t)join->select_lex->select_number));
 
96
    item_list.push_back(new Item_string(select_type_str[join->select_lex->type], cs));
100
97
    for (uint32_t i= 0; i < 7; i++)
101
98
      item_list.push_back(item_null);
102
99
 
103
100
    if (join->session->lex().describe & DESCRIBE_EXTENDED)
104
101
      item_list.push_back(item_null);
105
102
 
106
 
    item_list.push_back(new Item_string(message,strlen(message),cs));
 
103
    item_list.push_back(new Item_string(str_ref(message), cs));
107
104
    if (result->send_data(item_list))
108
105
      join->error= 1;
109
106
  }
121
118
    /* id */
122
119
    item_list.push_back(new Item_null);
123
120
    /* select_type */
124
 
    item_list.push_back(new Item_string(select_type_str[join->select_lex->type].c_str(),
125
 
                                        select_type_str[join->select_lex->type].length(),
126
 
                                        cs));
 
121
    item_list.push_back(new Item_string(select_type_str[join->select_lex->type], cs));
127
122
    /* table */
128
123
    {
129
124
      Select_Lex *sl= join->unit->first_select();
148
143
      item_list.push_back(new Item_string(table_name_buffer, len, cs));
149
144
    }
150
145
    /* type */
151
 
    item_list.push_back(new Item_string(access_method_str[AM_ALL].c_str(),
152
 
                                        access_method_str[AM_ALL].length(),
153
 
                                        cs));
 
146
    item_list.push_back(new Item_string(access_method_str[AM_ALL], cs));
154
147
    /* possible_keys */
155
148
    item_list.push_back(item_null);
156
149
    /* key*/
166
159
    item_list.push_back(item_null);
167
160
    /* extra */
168
161
    if (join->unit->global_parameters->order_list.first)
169
 
      item_list.push_back(new Item_string("Using filesort",
170
 
                                          14, 
171
 
                                          cs));
 
162
      item_list.push_back(new Item_string(str_ref("Using filesort"), cs));
172
163
    else
173
 
      item_list.push_back(new Item_string("", 0, cs));
 
164
      item_list.push_back(new Item_string(str_ref(""), cs));
174
165
 
175
166
    if (result->send_data(item_list))
176
167
      join->error= 1;
192
183
      quick_type= -1;
193
184
      item_list.clear();
194
185
      /* id */
195
 
      item_list.push_back(new Item_uint((uint32_t)
196
 
            join->select_lex->select_number));
 
186
      item_list.push_back(new Item_uint((uint32_t)join->select_lex->select_number));
197
187
      /* select_type */
198
 
      item_list.push_back(new Item_string(select_type_str[join->select_lex->type].c_str(),
199
 
                                          select_type_str[join->select_lex->type].length(),
200
 
                                          cs));
 
188
      item_list.push_back(new Item_string(select_type_str[join->select_lex->type], cs));
201
189
      if (tab->type == AM_ALL && tab->select && tab->select->quick)
202
190
      {
203
191
        quick_type= tab->select->quick->get_type();
221
209
      else
222
210
      {
223
211
        TableList *real_table= table->pos_in_table_list;
224
 
        item_list.push_back(new Item_string(real_table->alias,
225
 
                                            strlen(real_table->alias),
226
 
                                            cs));
 
212
        item_list.push_back(new Item_string(str_ref(real_table->alias), cs));
227
213
      }
228
214
      /* "type" column */
229
 
      item_list.push_back(new Item_string(access_method_str[tab->type].c_str(),
230
 
                                          access_method_str[tab->type].length(),
231
 
                                          cs));
 
215
      item_list.push_back(new Item_string(access_method_str[tab->type], cs));
232
216
      /* Build "possible_keys" value and add it to item_list */
233
217
      if (tab->keys.any())
234
218
      {
244
228
        }
245
229
      }
246
230
      if (tmp1.length())
247
 
        item_list.push_back(new Item_string(tmp1.c_str(),tmp1.length(),cs));
 
231
        item_list.push_back(new Item_string(tmp1, cs));
248
232
      else
249
233
        item_list.push_back(item_null);
250
234
 
252
236
      if (tab->ref.key_parts)
253
237
      {
254
238
        KeyInfo *key_info= table->key_info+ tab->ref.key;
255
 
        item_list.push_back(new Item_string(key_info->name,
256
 
                                            strlen(key_info->name),
257
 
                                            system_charset_info));
258
 
        uint32_t length= internal::int64_t2str(tab->ref.key_length, keylen_str_buf, 10) -
259
 
                                     keylen_str_buf;
260
 
        item_list.push_back(new Item_string(keylen_str_buf, 
261
 
                                            length,
262
 
                                            system_charset_info));
 
239
        item_list.push_back(new Item_string(str_ref(key_info->name), system_charset_info));
 
240
        uint32_t length= internal::int64_t2str(tab->ref.key_length, keylen_str_buf, 10) - keylen_str_buf;
 
241
        item_list.push_back(new Item_string(keylen_str_buf, length, system_charset_info));
263
242
        for (StoredKey **ref= tab->ref.key_copy; *ref; ref++)
264
243
        {
265
244
          if (tmp2.length())
267
246
          tmp2.append((*ref)->name(),
268
247
                      strlen((*ref)->name()));
269
248
        }
270
 
        item_list.push_back(new Item_string(tmp2.c_str(),tmp2.length(),cs));
 
249
        item_list.push_back(new Item_string(tmp2, cs));
271
250
      }
272
251
      else if (tab->type == AM_NEXT)
273
252
      {
274
253
        KeyInfo *key_info=table->key_info+ tab->index;
275
 
        item_list.push_back(new Item_string(key_info->name,
276
 
              strlen(key_info->name),cs));
277
 
        uint32_t length= internal::int64_t2str(key_info->key_length, keylen_str_buf, 10) -
278
 
                                     keylen_str_buf;
279
 
        item_list.push_back(new Item_string(keylen_str_buf,
280
 
                                            length,
281
 
                                            system_charset_info));
 
254
        item_list.push_back(new Item_string(str_ref(key_info->name),cs));
 
255
        uint32_t length= internal::int64_t2str(key_info->key_length, keylen_str_buf, 10) - keylen_str_buf;
 
256
        item_list.push_back(new Item_string(keylen_str_buf, length, system_charset_info));
282
257
        item_list.push_back(item_null);
283
258
      }
284
259
      else if (tab->select && tab->select->quick)
285
260
      {
286
261
        tab->select->quick->add_keys_and_lengths(&tmp2, &tmp3);
287
 
        item_list.push_back(new Item_string(tmp2.c_str(),tmp2.length(),cs));
288
 
        item_list.push_back(new Item_string(tmp3.c_str(),tmp3.length(),cs));
 
262
        item_list.push_back(new Item_string(tmp2, cs));
 
263
        item_list.push_back(new Item_string(tmp3, cs));
289
264
        item_list.push_back(item_null);
290
265
      }
291
266
      else
336
311
        key_read= 1;
337
312
 
338
313
      if (tab->info)
339
 
        item_list.push_back(new Item_string(tab->info,strlen(tab->info),cs));
 
314
        item_list.push_back(new Item_string(str_ref(tab->info),cs));
340
315
      else if (tab->packed_info & TAB_INFO_HAVE_VALUE)
341
316
      {
342
317
        if (tab->packed_info & TAB_INFO_USING_INDEX)
347
322
          extra.append("; Full scan on NULL key");
348
323
        if (extra.length())
349
324
          extra.erase(0, 2);        /* Skip initial "; "*/
350
 
        item_list.push_back(new Item_string(extra.c_str(), extra.length(), cs));
 
325
        item_list.push_back(new Item_string(extra, cs));
351
326
      }
352
327
      else
353
328
      {
431
406
 
432
407
        if (extra.length())
433
408
          extra.erase(0, 2);
434
 
        item_list.push_back(new Item_string(extra.c_str(), extra.length(), cs));
 
409
        item_list.push_back(new Item_string(extra, cs));
435
410
      }
436
411
      // For next iteration
437
412
      used_tables|=table->map;