1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Brian Aker
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
#include "plugin/table_cache_dictionary/dictionary.h"
24
#include "drizzled/pthread_globals.h"
26
using namespace drizzled;
29
table_cache_dictionary::TableDefinitionCache::TableDefinitionCache() :
30
plugin::TableFunction("DATA_DICTIONARY", "TABLE_DEFINITION_CACHE")
32
add_field("TABLE_SCHEMA");
33
add_field("TABLE_NAME");
34
add_field("VERSION", plugin::TableFunction::NUMBER);
35
add_field("TABLE_COUNT", plugin::TableFunction::NUMBER);
36
add_field("IS_NAME_LOCKED", plugin::TableFunction::BOOLEAN);
39
table_cache_dictionary::TableDefinitionCache::Generator::Generator(drizzled::Field **arg) :
40
drizzled::plugin::TableFunction::Generator(arg),
43
pthread_mutex_lock(&LOCK_open); /* Optionally lock for remove tables from open_cahe if not in use */
46
table_cache_dictionary::TableDefinitionCache::Generator::~Generator()
48
pthread_mutex_unlock(&LOCK_open); /* Optionally lock for remove tables from open_cahe if not in use */
51
bool table_cache_dictionary::TableDefinitionCache::Generator::nextCore()
55
table_share_iterator++;
60
table_share_iterator= TableShare::getCache().begin();
63
if (table_share_iterator == TableShare::getCache().end())
66
share= (*table_share_iterator).second;
71
bool table_cache_dictionary::TableDefinitionCache::Generator::next()
73
while (not nextCore())
75
if (table_share_iterator != TableShare::getCache().end())
84
bool table_cache_dictionary::TableDefinitionCache::Generator::populate()
94
void table_cache_dictionary::TableDefinitionCache::Generator::fill()
98
--replace_column 3 # 4 # 5 #
102
push(share->getSchemaName());
105
push(share->getTableName());
108
push(static_cast<int64_t>(share->getVersion()));
111
push(static_cast<uint64_t>(share->getTableCount()));
114
push(share->isNameLock());