Drizzled Public API Documentation

table_definition_cache.cc
00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2010 Brian Aker
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #include <config.h>
00022 
00023 #include <plugin/table_cache_dictionary/dictionary.h>
00024 
00025 using namespace drizzled;
00026 using namespace std;
00027 
00028 table_cache_dictionary::TableDefinitionCache::TableDefinitionCache() :
00029   plugin::TableFunction("DATA_DICTIONARY", "TABLE_DEFINITION_CACHE")
00030 {
00031   add_field("TABLE_SCHEMA");
00032   add_field("TABLE_NAME");
00033   add_field("VERSION", plugin::TableFunction::NUMBER, 0, false);
00034   add_field("TABLE_COUNT", plugin::TableFunction::NUMBER, 0, false);
00035   add_field("IS_NAME_LOCKED", plugin::TableFunction::BOOLEAN, 0, false);
00036 }
00037 
00038 table_cache_dictionary::TableDefinitionCache::Generator::Generator(drizzled::Field **arg) :
00039   drizzled::plugin::TableFunction::Generator(arg)
00040 {
00041 }
00042 
00043 table_cache_dictionary::TableDefinitionCache::Generator::~Generator()
00044 {
00045 }
00046 
00047 bool table_cache_dictionary::TableDefinitionCache::Generator::populate()
00048 {
00049   drizzled::TableShare::shared_ptr share;
00050 
00051   while ((share= table_definition_cache_generator))
00052   {
00058     /* TABLE_SCHEMA 1 */
00059     string arg;
00060     push(share->getSchemaName(arg));
00061 
00062     /* TABLE_NAME  2 */
00063     push(share->getTableName(arg));
00064 
00065     /* VERSION 3 */
00066     push(static_cast<int64_t>(share->getVersion()));
00067 
00068     /* TABLE_COUNT 4 */
00069     push(static_cast<uint64_t>(share->getTableCount()));
00070 
00071     /* IS_NAME_LOCKED */
00072     push(false);
00073 
00074     return true;
00075   }
00076 
00077   return false;
00078 }