~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/show_dictionary/show_schemas.cc

edit

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
22
 
#include <plugin/show_dictionary/dictionary.h>
 
21
#include "config.h"
 
22
#include "plugin/show_dictionary/dictionary.h"
23
23
 
24
24
using namespace std;
25
25
using namespace drizzled;
32
32
 
33
33
ShowSchemas::Generator::Generator(Field **arg) :
34
34
  show_dictionary::Show::Generator(arg),
35
 
  schema_generator(getSession())
36
 
{
37
 
}
38
 
 
39
 
bool ShowSchemas::Generator::populate()
40
 
{
41
 
  drizzled::message::schema::shared_ptr schema_ptr;
42
 
 
 
35
  is_schema_primed(false)
 
36
{
43
37
  if (not isShowQuery())
 
38
   return;
 
39
}
 
40
 
 
41
/**
 
42
  @note return true if a match occurs.
 
43
*/
 
44
bool ShowSchemas::Generator::checkSchema()
 
45
{
 
46
  if (isWild((*schema_iterator).getSchemaName()))
 
47
    return true;
 
48
 
 
49
  return false;
 
50
}
 
51
 
 
52
bool ShowSchemas::Generator::nextSchemaCore()
 
53
{
 
54
  if (is_schema_primed)
 
55
  {
 
56
    schema_iterator++;
 
57
  }
 
58
  else
 
59
  {
 
60
    plugin::StorageEngine::getIdentifiers(getSession(), schema_names);
 
61
    schema_iterator= schema_names.begin();
 
62
    is_schema_primed= true;
 
63
  }
 
64
 
 
65
  if (schema_iterator == schema_names.end())
44
66
    return false;
45
67
 
46
 
  while ((schema_ptr= schema_generator))
47
 
  {
48
 
    if (isWild(schema_ptr->name()))
49
 
      continue;
50
 
 
51
 
    /* Schema */
52
 
    push(schema_ptr->name());
53
 
 
 
68
  if (checkSchema())
 
69
      return false;
 
70
 
 
71
  return true;
 
72
}
 
73
  
 
74
bool ShowSchemas::Generator::nextSchema()
 
75
{
 
76
  while (not nextSchemaCore())
 
77
  {
 
78
    if (schema_iterator == schema_names.end())
 
79
      return false;
 
80
  }
 
81
 
 
82
  return true;
 
83
}
 
84
 
 
85
 
 
86
bool ShowSchemas::Generator::populate()
 
87
{
 
88
  if (nextSchema())
 
89
  {
 
90
    fill();
54
91
    return true;
55
92
  }
56
93
 
57
94
  return false;
58
95
}
 
96
 
 
97
/**
 
98
  A lack of a parsed schema file means we are using defaults.
 
99
*/
 
100
void ShowSchemas::Generator::fill()
 
101
{
 
102
  /* Schema */
 
103
  push((*schema_iterator).getSchemaName());
 
104
}