00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #pragma once
00022
00023 #include <drizzled/lock.h>
00024 #include <drizzled/query_id.h>
00025
00026 namespace drizzled
00027 {
00028
00029 class CachedDirectory;
00030
00037 class Open_tables_state
00038 {
00039 public:
00044 Table *open_tables;
00045
00053 private:
00054 Table *temporary_tables;
00055
00056 public:
00057
00058 Table *getTemporaryTables()
00059 {
00060 return temporary_tables;
00061 }
00062
00072 void mark_temp_tables_as_free_for_reuse();
00073
00074 protected:
00075 void close_temporary_tables();
00076
00077 public:
00078 void close_temporary_table(Table *table);
00079
00080 private:
00081
00082
00083 void nukeTable(Table *table);
00084
00085 public:
00086
00087 Table *find_temporary_table(const identifier::Table &identifier);
00088
00089 void dumpTemporaryTableNames(const char *id);
00090 int drop_temporary_table(const drizzled::identifier::Table &identifier);
00091 bool rm_temporary_table(plugin::StorageEngine *base, const identifier::Table &identifier);
00092 bool rm_temporary_table(const drizzled::identifier::Table &identifier, bool best_effort= false);
00093 Table *open_temporary_table(const drizzled::identifier::Table &identifier,
00094 bool link_in_list= true);
00095
00096 virtual query_id_t getQueryId() const= 0;
00097
00098 private:
00099 Table *derived_tables;
00100 public:
00101
00102
00103 Table *getDerivedTables()
00104 {
00105 return derived_tables;
00106 }
00107
00108 void setDerivedTables(Table *arg)
00109 {
00110 derived_tables= arg;
00111 }
00112
00113 void clearDerivedTables()
00114 {
00115 if (derived_tables)
00116 derived_tables= NULL;
00117 }
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 DrizzleLock *lock;
00133
00134
00135
00136
00137
00138
00139 DrizzleLock *extra_lock;
00140
00141 uint64_t version;
00142 uint32_t current_tablenr;
00143
00144
00145
00146
00147
00148 Open_tables_state() :
00149 open_tables(0),
00150 temporary_tables(0),
00151 derived_tables(0),
00152 lock(0),
00153 extra_lock(0),
00154 version(0),
00155 current_tablenr(0)
00156 { }
00157 virtual ~Open_tables_state() {}
00158
00159 void doGetTableNames(CachedDirectory &directory,
00160 const identifier::Schema &schema_identifier,
00161 std::set<std::string>& set_of_names);
00162 void doGetTableNames(const identifier::Schema &schema_identifier,
00163 std::set<std::string>& set_of_names);
00164
00165 void doGetTableIdentifiers(CachedDirectory &directory,
00166 const identifier::Schema &schema_identifier,
00167 identifier::Table::vector &set_of_identifiers);
00168 void doGetTableIdentifiers(const identifier::Schema &schema_identifier,
00169 identifier::Table::vector &set_of_identifiers);
00170
00171 int doGetTableDefinition(const drizzled::identifier::Table &identifier,
00172 message::Table &table_proto);
00173 bool doDoesTableExist(const drizzled::identifier::Table &identifier);
00174
00175
00176 Open_tables_state(uint64_t version_arg);
00177 };
00178
00179 }
00180