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/slot/info_schema.h"
23
#include "drizzled/plugin/info_schema.h"
24
#include "drizzled/gettext.h"
25
#include "drizzled/session.h"
26
#include "drizzled/lex_string.h"
30
using namespace drizzled;
34
void slot::InfoSchema::add(plugin::InfoSchema *schema_table)
36
if (schema_table->getFirstColumnIndex() == 0)
37
schema_table->setFirstColumnIndex(-1);
38
if (schema_table->getSecondColumnIndex() == 0)
39
schema_table->setSecondColumnIndex(-1);
41
all_schema_tables.push_back(schema_table);
44
void slot::InfoSchema::remove(plugin::InfoSchema *table)
46
all_schema_tables.erase(remove_if(all_schema_tables.begin(),
47
all_schema_tables.end(),
48
bind2nd(equal_to<plugin::InfoSchema *>(),
50
all_schema_tables.end());
61
class AddSchemaTable : public unary_function<plugin::InfoSchema *, bool>
65
vector<LEX_STRING*> &files;
68
AddSchemaTable(Session *session_arg, vector<LEX_STRING*> &files_arg, const char *wild_arg)
69
: session(session_arg), wild(wild_arg), files(files_arg)
72
result_type operator() (argument_type schema_table)
74
if (schema_table->isHidden())
79
const string &schema_table_name= schema_table->getTableName();
81
if (wild && wild_case_compare(files_charset_info, schema_table_name.c_str(), wild))
86
LEX_STRING *file_name= 0;
87
file_name= session->make_lex_string(file_name, schema_table_name.c_str(),
88
schema_table_name.length(), true);
89
if (file_name == NULL)
94
files.push_back(file_name);
99
class FindSchemaTableByName : public unary_function<plugin::InfoSchema *, bool>
101
const char *table_name;
103
FindSchemaTableByName(const char *table_name_arg)
104
: table_name(table_name_arg) {}
105
result_type operator() (argument_type schema_table)
107
return ! my_strcasecmp(system_charset_info,
108
schema_table->getTableName().c_str(),
117
plugin::InfoSchema * slot::InfoSchema::getTable(const char *table_name)
119
vector<plugin::InfoSchema *>::iterator iter=
120
find_if(all_schema_tables.begin(),
121
all_schema_tables.end(),
122
slot::i_s_priv::FindSchemaTableByName(table_name));
124
if (iter != all_schema_tables.end())
134
int slot::InfoSchema::addTableToList(Session *session,
135
vector<LEX_STRING*> &files,
139
vector<plugin::InfoSchema *>::iterator iter=
140
find_if(all_schema_tables.begin(),
141
all_schema_tables.end(),
142
slot::i_s_priv::AddSchemaTable(session, files, wild));
144
if (iter != all_schema_tables.end())