00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023 #include <plugin/show_dictionary/dictionary.h>
00024 #include <drizzled/identifier.h>
00025
00026 using namespace std;
00027 using namespace drizzled;
00028
00029 ShowTables::ShowTables() :
00030 show_dictionary::Show("SHOW_TABLES")
00031 {
00032 add_field("TABLE_NAME");
00033 }
00034
00035 ShowTables::Generator::Generator(drizzled::Field **arg) :
00036 show_dictionary::Show::Generator(arg),
00037 is_primed(false)
00038 {
00039 if (not isShowQuery())
00040 return;
00041
00042 statement::Show& select= static_cast<statement::Show&>(statement());
00043
00044 if (not select.getShowSchema().empty())
00045 {
00046 schema_name.append(select.getShowSchema());
00047 assert(not schema_name.empty());
00048 }
00049 }
00050
00051 bool ShowTables::Generator::nextCore()
00052 {
00053 if (is_primed)
00054 {
00055 table_iterator++;
00056 }
00057 else
00058 {
00059 if (schema_name.empty())
00060 {
00061 is_primed= true;
00062 return false;
00063 }
00064
00065 identifier::Schema identifier(schema_name);
00066 plugin::StorageEngine::getIdentifiers(getSession(), identifier, set_of_identifiers);
00067 table_iterator= set_of_identifiers.begin();
00068 is_primed= true;
00069 }
00070
00071 if (table_iterator == set_of_identifiers.end())
00072 return false;
00073
00074 if (isWild((*table_iterator).getTableName()))
00075 return false;
00076
00077 return true;
00078 }
00079
00080 bool ShowTables::Generator::next()
00081 {
00082 while (not nextCore())
00083 {
00084 if (table_iterator != set_of_identifiers.end())
00085 continue;
00086
00087 return false;
00088 }
00089
00090 return true;
00091 }
00092
00093 bool ShowTables::Generator::populate()
00094 {
00095 if (not next())
00096 return false;
00097
00098 fill();
00099
00100 return true;
00101 }
00102
00103 void ShowTables::Generator::fill()
00104 {
00105
00106 push((*table_iterator).getTableName());
00107 }