~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/show_dictionary/show_schemas.cc

  • Committer: lbieber at stabletransit
  • Date: 2010-10-19 14:03:27 UTC
  • mfrom: (1861.1.2 build)
  • Revision ID: lbieber@drizzle-build-n02.wc1.dfw1.stabletransit.com-20101019140327-2jvt5j2wi4pzhm1z
Merge Brian - Small collection of cleanups/refactor'ing around locks
Merge Monty - fix a few things in the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
using namespace drizzled;
26
26
 
27
27
ShowSchemas::ShowSchemas() :
28
 
  show_dictionary::Show("SHOW_SCHEMAS")
 
28
  plugin::TableFunction("DATA_DICTIONARY", "SHOW_SCHEMAS")
29
29
{
30
30
  add_field("SCHEMA_NAME");
31
31
}
32
32
 
33
33
ShowSchemas::Generator::Generator(Field **arg) :
34
 
  show_dictionary::Show::Generator(arg),
35
 
  schema_generator(getSession())
36
 
{
37
 
}
 
34
  plugin::TableFunction::Generator(arg),
 
35
  is_schema_primed(false)
 
36
{
 
37
}
 
38
 
 
39
/**
 
40
  @note return true if a match occurs.
 
41
*/
 
42
bool ShowSchemas::Generator::checkSchema()
 
43
{
 
44
  if (isWild((*schema_iterator).getSchemaName()))
 
45
    return true;
 
46
 
 
47
  return false;
 
48
}
 
49
 
 
50
bool ShowSchemas::Generator::nextSchemaCore()
 
51
{
 
52
  if (is_schema_primed)
 
53
  {
 
54
    schema_iterator++;
 
55
  }
 
56
  else
 
57
  {
 
58
    plugin::StorageEngine::getIdentifiers(getSession(), schema_names);
 
59
    schema_iterator= schema_names.begin();
 
60
    is_schema_primed= true;
 
61
  }
 
62
 
 
63
  if (schema_iterator == schema_names.end())
 
64
    return false;
 
65
 
 
66
  if (checkSchema())
 
67
      return false;
 
68
 
 
69
  return true;
 
70
}
 
71
  
 
72
bool ShowSchemas::Generator::nextSchema()
 
73
{
 
74
  while (not nextSchemaCore())
 
75
  {
 
76
    if (schema_iterator == schema_names.end())
 
77
      return false;
 
78
  }
 
79
 
 
80
  return true;
 
81
}
 
82
 
38
83
 
39
84
bool ShowSchemas::Generator::populate()
40
85
{
41
 
  drizzled::message::schema::shared_ptr schema_ptr;
42
 
 
43
 
  if (not isShowQuery())
44
 
    return false;
45
 
 
46
 
  while ((schema_ptr= schema_generator))
 
86
  if (nextSchema())
47
87
  {
48
 
    if (isWild(schema_ptr->name()))
49
 
      continue;
50
 
 
51
 
    /* Schema */
52
 
    push(schema_ptr->name());
53
 
 
 
88
    fill();
54
89
    return true;
55
90
  }
56
91
 
57
92
  return false;
58
93
}
 
94
 
 
95
/**
 
96
  A lack of a parsed schema file means we are using defaults.
 
97
*/
 
98
void ShowSchemas::Generator::fill()
 
99
{
 
100
  /* Schema */
 
101
  push((*schema_iterator).getSchemaName());
 
102
}