1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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
21
#include "drizzled/server_includes.h"
22
#include "drizzled/plugin/info_schema_table.h"
23
#include "drizzled/gettext.h"
24
#include "drizzled/session.h"
25
#include "drizzled/lex_string.h"
34
vector<plugin::InfoSchemaTable *> all_schema_tables;
37
void plugin::InfoSchemaTable::add(plugin::InfoSchemaTable *schema_table)
39
if (schema_table->getFirstColumnIndex() == 0)
40
schema_table->setFirstColumnIndex(-1);
41
if (schema_table->getSecondColumnIndex() == 0)
42
schema_table->setSecondColumnIndex(-1);
44
all_schema_tables.push_back(schema_table);
47
void plugin::InfoSchemaTable::remove(plugin::InfoSchemaTable *table)
49
all_schema_tables.erase(remove_if(all_schema_tables.begin(),
50
all_schema_tables.end(),
51
bind2nd(equal_to<plugin::InfoSchemaTable *>(),
53
all_schema_tables.end());
57
class AddSchemaTable : public unary_function<plugin::InfoSchemaTable *, bool>
61
vector<LEX_STRING*> &files;
64
AddSchemaTable(Session *session_arg, vector<LEX_STRING*> &files_arg, const char *wild_arg)
65
: session(session_arg), wild(wild_arg), files(files_arg)
68
result_type operator() (argument_type schema_table)
70
if (schema_table->isHidden())
75
const string &schema_table_name= schema_table->getTableName();
77
if (wild && wild_case_compare(files_charset_info, schema_table_name.c_str(), wild))
82
LEX_STRING *file_name= 0;
83
file_name= session->make_lex_string(file_name, schema_table_name.c_str(),
84
schema_table_name.length(), true);
85
if (file_name == NULL)
90
files.push_back(file_name);
95
class FindSchemaTableByName : public unary_function<plugin::InfoSchemaTable *, bool>
97
const char *table_name;
99
FindSchemaTableByName(const char *table_name_arg)
100
: table_name(table_name_arg) {}
101
result_type operator() (argument_type schema_table)
103
return ! my_strcasecmp(system_charset_info,
104
schema_table->getTableName().c_str(),
109
plugin::InfoSchemaTable *plugin::InfoSchemaTable::getTable(const char *table_name)
111
vector<plugin::InfoSchemaTable *>::iterator iter=
112
find_if(all_schema_tables.begin(),
113
all_schema_tables.end(),
114
FindSchemaTableByName(table_name));
116
if (iter != all_schema_tables.end())
126
int plugin::InfoSchemaTable::addTableToList(Session *session,
127
vector<LEX_STRING*> &files,
131
vector<plugin::InfoSchemaTable *>::iterator iter=
132
find_if(all_schema_tables.begin(),
133
all_schema_tables.end(),
134
AddSchemaTable(session, files, wild));
136
if (iter != all_schema_tables.end())
144
} /* namespace drizzled */