Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00063 #include <config.h>
00064
00065 #include "data_dictionary_schema.h"
00066 #include "transaction_log_index.h"
00067
00068 #include <fcntl.h>
00069 #include <sys/stat.h>
00070
00071 using namespace std;
00072 using namespace drizzled;
00073
00074 extern TransactionLog *transaction_log;
00075 extern TransactionLogIndex *transaction_log_index;
00076
00077
00078
00079
00080
00081
00082
00083 TransactionLogTool::TransactionLogTool() :
00084 plugin::TableFunction("DATA_DICTIONARY", "TRANSACTION_LOG")
00085 {
00086 add_field("FILE_NAME");
00087 add_field("FILE_LENGTH", plugin::TableFunction::NUMBER);
00088 add_field("NUM_LOG_ENTRIES", plugin::TableFunction::NUMBER);
00089 add_field("NUM_TRANSACTIONS", plugin::TableFunction::NUMBER);
00090 add_field("MIN_TRANSACTION_ID", plugin::TableFunction::NUMBER);
00091 add_field("MAX_TRANSACTION_ID", plugin::TableFunction::NUMBER);
00092 add_field("MIN_END_TIMESTAMP", plugin::TableFunction::NUMBER);
00093 add_field("MAX_END_TIMESTAMP", plugin::TableFunction::NUMBER);
00094 add_field("INDEX_SIZE_IN_BYTES", plugin::TableFunction::NUMBER);
00095 }
00096
00097 TransactionLogTool::Generator::Generator(Field **arg) :
00098 plugin::TableFunction::Generator(arg)
00099 {
00100 is_done= false;
00101 }
00102
00103 bool TransactionLogTool::Generator::populate()
00104 {
00105 if (is_done)
00106 {
00107 return false;
00108 }
00109
00110 const string &filename= transaction_log->getLogFilename();
00111 push(filename.c_str());
00112
00113
00114 struct stat file_stat;
00115 (void) stat(filename.c_str(), &file_stat);
00116 push(file_stat.st_size);
00117
00118 push(transaction_log_index->getNumLogEntries());
00119 push(transaction_log_index->getNumTransactionEntries());
00120 push(transaction_log_index->getMinTransactionId());
00121 push(transaction_log_index->getMaxTransactionId());
00122 push(transaction_log_index->getMinEndTimestamp());
00123 push(transaction_log_index->getMaxEndTimestamp());
00124 push(static_cast<uint64_t>(transaction_log_index->getSizeInBytes()));
00125
00126 is_done= true;
00127 return true;
00128 }
00129
00130
00131
00132
00133
00134
00135
00136 TransactionLogEntriesTool::TransactionLogEntriesTool() :
00137 plugin::TableFunction("DATA_DICTIONARY", "TRANSACTION_LOG_ENTRIES")
00138 {
00139 add_field("ENTRY_OFFSET", plugin::TableFunction::NUMBER);
00140 add_field("ENTRY_TYPE");
00141 add_field("ENTRY_LENGTH", plugin::TableFunction::NUMBER);
00142 }
00143
00144 TransactionLogEntriesTool::Generator::Generator(Field **arg) :
00145 plugin::TableFunction::Generator(arg)
00146 {
00147 it= transaction_log_index->getEntries().begin();
00148 end= transaction_log_index->getEntries().end();
00149 }
00150
00151 bool TransactionLogEntriesTool::Generator::populate()
00152 {
00153 if (it == end)
00154 {
00155 return false;
00156 }
00157
00158 TransactionLogEntry &entry= *it;
00159
00160 push(entry.getOffset());
00161 push(entry.getTypeAsString());
00162 push(static_cast<uint64_t>(entry.getLengthInBytes()));
00163
00164 it++;
00165
00166 return true;
00167 }
00168
00169
00170
00171
00172
00173
00174
00175 TransactionLogTransactionsTool::TransactionLogTransactionsTool() :
00176 plugin::TableFunction("DATA_DICTIONARY", "TRANSACTION_LOG_TRANSACTIONS")
00177 {
00178 add_field("ENTRY_OFFSET", plugin::TableFunction::NUMBER);
00179 add_field("TRANSACTION_ID", plugin::TableFunction::NUMBER);
00180 add_field("SERVER_ID", plugin::TableFunction::NUMBER);
00181 add_field("START_TIMESTAMP", plugin::TableFunction::NUMBER);
00182 add_field("END_TIMESTAMP", plugin::TableFunction::NUMBER);
00183 add_field("NUM_STATEMENTS", plugin::TableFunction::NUMBER);
00184 add_field("CHECKSUM", plugin::TableFunction::NUMBER);
00185 }
00186
00187 TransactionLogTransactionsTool::Generator::Generator(Field **arg) :
00188 plugin::TableFunction::Generator(arg)
00189 {
00190 it= transaction_log_index->getTransactionEntries().begin();
00191 end= transaction_log_index->getTransactionEntries().end();
00192 }
00193
00194 bool TransactionLogTransactionsTool::Generator::populate()
00195 {
00196 if (it == end)
00197 {
00198 return false;
00199 }
00200
00201 TransactionLogTransactionEntry &entry= *it;
00202
00203 push(entry.getOffset());
00204 push(entry.getTransactionId());
00205 push(static_cast<uint64_t>(entry.getServerId()));
00206 push(entry.getStartTimestamp());
00207 push(entry.getEndTimestamp());
00208 push(static_cast<uint64_t>(entry.getNumStatements()));
00209 push(static_cast<uint64_t>(entry.getChecksum()));
00210
00211 it++;
00212
00213 return true;
00214 }