~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/show.cc

  • Committer: Lee Bieber
  • Date: 2011-02-11 20:30:05 UTC
  • mfrom: (2157.1.3 build)
  • Revision ID: kalebral@gmail.com-20110211203005-757o1y2yf78dxzqr
Merge Stewart - 716848: drizzleimport displays wrong program_name
Merge Stewart - update README file
Merge Andrew and Joe - Exposes the InnoDB SYS_REPLICATION_LOG to data_dictionary so that it is fast and fixes many issues we have been having

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
 
22
22
/* Function with list databases, tables or fields */
23
 
#include <config.h>
24
 
 
 
23
#include "config.h"
 
24
#include <drizzled/sql_select.h>
 
25
#include <drizzled/show.h>
 
26
#include <drizzled/gettext.h>
 
27
#include <drizzled/util/convert.h>
 
28
#include <drizzled/error.h>
 
29
#include <drizzled/tztime.h>
25
30
#include <drizzled/data_home.h>
26
 
#include <drizzled/error.h>
27
 
#include <drizzled/internal/my_sys.h>
28
 
#include <drizzled/plugin/storage_engine.h>
29
 
#include <drizzled/session.h>
30
 
#include <drizzled/show.h>
31
 
#include <drizzled/sql_select.h>
 
31
#include <drizzled/item/blob.h>
 
32
#include <drizzled/item/cmpfunc.h>
 
33
#include <drizzled/item/return_int.h>
 
34
#include <drizzled/item/empty_string.h>
 
35
#include <drizzled/item/return_date_time.h>
 
36
#include <drizzled/sql_base.h>
 
37
#include <drizzled/db.h>
 
38
#include <drizzled/field/epoch.h>
 
39
#include <drizzled/field/decimal.h>
 
40
#include <drizzled/lock.h>
 
41
#include <drizzled/item/return_date_time.h>
 
42
#include <drizzled/item/empty_string.h>
 
43
#include "drizzled/session/cache.h"
 
44
#include <drizzled/message/schema.pb.h>
 
45
#include <drizzled/plugin/client.h>
 
46
#include <drizzled/cached_directory.h>
 
47
#include "drizzled/sql_table.h"
 
48
#include "drizzled/global_charset_info.h"
 
49
#include "drizzled/pthread_globals.h"
 
50
#include "drizzled/internal/m_string.h"
 
51
#include "drizzled/internal/my_sys.h"
 
52
#include "drizzled/message/statement_transform.h"
32
53
 
33
 
#include <drizzled/statement/show.h>
34
 
#include <drizzled/statement/show_errors.h>
35
 
#include <drizzled/statement/show_warnings.h>
 
54
#include "drizzled/statement/show.h"
 
55
#include "drizzled/statement/show_errors.h"
 
56
#include "drizzled/statement/show_warnings.h"
36
57
 
37
58
 
38
59
#include <sys/stat.h>
54
75
  return str ? str : "<nil>";
55
76
}
56
77
 
57
 
int wild_case_compare(const charset_info_st * const cs, const char *str, const char *wildstr)
 
78
int wild_case_compare(const CHARSET_INFO * const cs, const char *str, const char *wildstr)
58
79
{
59
80
  register int flag;
60
81
 
64
85
    {
65
86
      if (*wildstr == internal::wild_prefix && wildstr[1])
66
87
        wildstr++;
67
 
 
68
88
      if (my_toupper(cs, *wildstr++) != my_toupper(cs, *str++))
69
89
        return (1);
70
90
    }
71
 
 
72
91
    if (! *wildstr )
73
92
      return (*str != 0);
74
 
 
75
93
    if (*wildstr++ == internal::wild_one)
76
94
    {
77
95
      if (! *str++)
81
99
    {                                           /* Found '*' */
82
100
      if (! *wildstr)
83
101
        return (0);             /* '*' as last char: OK */
84
 
 
85
102
      flag=(*wildstr != internal::wild_many && *wildstr != internal::wild_one);
86
103
      do
87
104
      {
90
107
          char cmp;
91
108
          if ((cmp= *wildstr) == internal::wild_prefix && wildstr[1])
92
109
            cmp= wildstr[1];
93
 
 
94
110
          cmp= my_toupper(cs, cmp);
95
 
 
96
111
          while (*str && my_toupper(cs, *str) != cmp)
97
112
            str++;
98
 
 
99
113
          if (! *str)
100
114
            return (1);
101
115
        }
102
 
 
103
116
        if (wild_case_compare(cs, str, wildstr) == 0)
104
117
          return (0);
105
 
 
106
118
      } while (*str++);
107
 
 
108
119
      return (1);
109
120
    }
110
121
  }
163
174
      return false;
164
175
  }
165
176
 
166
 
  Item_field *my_field= new Item_field(&session->getLex()->current_select->context, NULL, NULL, "SCHEMA_NAME");
 
177
  Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
167
178
  my_field->is_autogenerated_name= false;
168
179
  my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
169
180
 
193
204
    session->getLex()->select_lex.db= const_cast<char *>(ident);
194
205
    if (not plugin::StorageEngine::doesSchemaExist(identifier))
195
206
    {
196
 
      my_error(ER_BAD_DB_ERROR, identifier);
 
207
      my_error(ER_BAD_DB_ERROR, MYF(0), ident);
197
208
    }
198
209
    select->setShowPredicate(ident, "");
199
210
  }
219
230
  if (prepare_new_schema_table(session, session->getLex(), "SHOW_TABLES"))
220
231
    return false;
221
232
 
222
 
  Item_field *my_field= new Item_field(&session->getLex()->current_select->context, NULL, NULL, "TABLE_NAME");
 
233
  Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
223
234
  my_field->is_autogenerated_name= false;
224
235
  my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
225
236
 
242
253
  if (prepare_new_schema_table(session, session->getLex(), "SHOW_TEMPORARY_TABLES"))
243
254
    return false;
244
255
 
245
 
  if (session->add_item_to_list( new Item_field(&session->getLex()->current_select->context, NULL, NULL, "*")))
 
256
  if (session->add_item_to_list( new Item_field(&session->lex->current_select->context, NULL, NULL, "*")))
246
257
    return false;
247
258
 
248
 
  (session->getLex()->current_select->with_wild)++;
 
259
  (session->lex->current_select->with_wild)++;
249
260
 
250
261
  return true;
251
262
}
266
277
    identifier::Schema identifier(ident);
267
278
    if (not plugin::StorageEngine::doesSchemaExist(identifier))
268
279
    {
269
 
      my_error(ER_BAD_DB_ERROR, identifier);
 
280
      my_error(ER_BAD_DB_ERROR, MYF(0), ident);
270
281
    }
271
282
 
272
283
    select->setShowPredicate(ident, "");
284
295
  if (prepare_new_schema_table(session, session->getLex(), "SHOW_TABLE_STATUS"))
285
296
    return false;
286
297
 
287
 
  if (session->add_item_to_list( new Item_field(&session->getLex()->current_select->
 
298
  if (session->add_item_to_list( new Item_field(&session->lex->current_select->
288
299
                                                  context,
289
300
                                                  NULL, NULL, "*")))
290
301
    return false;
291
302
 
292
 
  (session->getLex()->current_select->with_wild)++;
 
303
  (session->lex->current_select->with_wild)++;
293
304
 
294
305
  return true;
295
306
}
341
352
  if (prepare_new_schema_table(session, session->getLex(), "SHOW_COLUMNS"))
342
353
    return false;
343
354
 
344
 
  if (session->add_item_to_list( new Item_field(&session->getLex()->current_select->context, NULL, NULL, "*")))
 
355
  if (session->add_item_to_list( new Item_field(&session->lex->current_select->context, NULL, NULL, "*")))
345
356
    return false;
346
357
 
347
 
  (session->getLex()->current_select->with_wild)++;
 
358
  (session->lex->current_select->with_wild)++;
348
359
 
349
360
  return true;
350
361
}
407
418
  if (prepare_new_schema_table(session, session->getLex(), "SHOW_INDEXES"))
408
419
    return false;
409
420
 
410
 
  if (session->add_item_to_list( new Item_field(&session->getLex()->current_select->context, NULL, NULL, "*")))
 
421
  if (session->add_item_to_list( new Item_field(&session->lex->current_select->context, NULL, NULL, "*")))
411
422
    return false;
412
423
 
413
 
  (session->getLex()->current_select->with_wild)++;
 
424
  (session->lex->current_select->with_wild)++;
414
425
 
415
426
  return true;
416
427
}
434
445
  std::string key("Variable_name");
435
446
  std::string value("Value");
436
447
 
437
 
  Item_field *my_field= new Item_field(&session->getLex()->current_select->context, NULL, NULL, "VARIABLE_NAME");
 
448
  Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
438
449
  my_field->is_autogenerated_name= false;
439
450
  my_field->set_name(key.c_str(), key.length(), system_charset_info);
440
451
 
441
452
  if (session->add_item_to_list(my_field))
442
453
    return false;
443
454
 
444
 
  my_field= new Item_field(&session->getLex()->current_select->context, NULL, NULL, "VARIABLE_VALUE");
 
455
  my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
445
456
  my_field->is_autogenerated_name= false;
446
457
  my_field->set_name(value.c_str(), value.length(), system_charset_info);
447
458
 
481
492
  std::string key("Table");
482
493
  std::string value("Create Table");
483
494
 
484
 
  Item_field *my_field= new Item_field(&session->getLex()->current_select->context, NULL, NULL, "TABLE_NAME");
 
495
  Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
485
496
  my_field->is_autogenerated_name= false;
486
497
  my_field->set_name(key.c_str(), key.length(), system_charset_info);
487
498
 
488
499
  if (session->add_item_to_list(my_field))
489
500
    return false;
490
501
 
491
 
  my_field= new Item_field(&session->getLex()->current_select->context, NULL, NULL, "TABLE_SQL_DEFINITION");
 
502
  my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_SQL_DEFINITION");
492
503
  my_field->is_autogenerated_name= false;
493
504
  my_field->set_name(value.c_str(), value.length(), system_charset_info);
494
505
 
506
517
  if (prepare_new_schema_table(session, session->getLex(), "PROCESSLIST"))
507
518
    return false;
508
519
 
509
 
  if (session->add_item_to_list( new Item_field(&session->getLex()->current_select->context, NULL, NULL, "*")))
 
520
  if (session->add_item_to_list( new Item_field(&session->lex->current_select->context, NULL, NULL, "*")))
510
521
    return false;
511
522
 
512
 
  (session->getLex()->current_select->with_wild)++;
 
523
  (session->lex->current_select->with_wild)++;
513
524
 
514
525
  return true;
515
526
}
533
544
  std::string key("Variable_name");
534
545
  std::string value("Value");
535
546
 
536
 
  Item_field *my_field= new Item_field(&session->getLex()->current_select->context, NULL, NULL, "VARIABLE_NAME");
 
547
  Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
537
548
  my_field->is_autogenerated_name= false;
538
549
  my_field->set_name(key.c_str(), key.length(), system_charset_info);
539
550
 
540
551
  if (session->add_item_to_list(my_field))
541
552
    return false;
542
553
 
543
 
  my_field= new Item_field(&session->getLex()->current_select->context, NULL, NULL, "VARIABLE_VALUE");
 
554
  my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
544
555
  my_field->is_autogenerated_name= false;
545
556
  my_field->set_name(value.c_str(), value.length(), system_charset_info);
546
557
 
577
588
  std::string key("Database");
578
589
  std::string value("Create Database");
579
590
 
580
 
  Item_field *my_field= new Item_field(&session->getLex()->current_select->context, NULL, NULL, "SCHEMA_NAME");
 
591
  Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
581
592
  my_field->is_autogenerated_name= false;
582
593
  my_field->set_name(key.c_str(), key.length(), system_charset_info);
583
594
 
584
595
  if (session->add_item_to_list(my_field))
585
596
    return false;
586
597
 
587
 
  my_field= new Item_field(&session->getLex()->current_select->context, NULL, NULL, "SCHEMA_SQL_DEFINITION");
 
598
  my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_SQL_DEFINITION");
588
599
  my_field->is_autogenerated_name= false;
589
600
  my_field->set_name(value.c_str(), value.length(), system_charset_info);
590
601
 
632
643
    return false;
633
644
  }
634
645
 
635
 
  if (session->add_item_to_list( new Item_field(&session->getLex()->current_select->
 
646
  if (session->add_item_to_list( new Item_field(&session->lex->current_select->
636
647
                                                  context,
637
648
                                                  NULL, NULL, "*")))
638
649
  {
639
650
    return false;
640
651
  }
641
652
 
642
 
  (session->getLex()->current_select->with_wild)++;
 
653
  (session->lex->current_select->with_wild)++;
643
654
 
644
655
  return true;
645
656
}