1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Definitions required for TableFunction plugin
|
|
5 |
*
|
|
6 |
* Copyright (C) 2010 Sun Microsystems
|
|
7 |
* Copyright (C) 2010 Monty Taylor
|
|
8 |
*
|
|
9 |
* This program is free software; you can redistribute it and/or modify
|
|
10 |
* it under the terms of the GNU General Public License as published by
|
|
11 |
* the Free Software Foundation; version 2 of the License.
|
|
12 |
*
|
|
13 |
* This program is distributed in the hope that it will be useful,
|
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 |
* GNU General Public License for more details.
|
|
17 |
*
|
|
18 |
* You should have received a copy of the GNU General Public License
|
|
19 |
* along with this program; if not, write to the Free Software
|
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21 |
*/
|
|
22 |
||
23 |
#ifndef DRIZZLED_PLUGIN_TABLE_FUNCTION_H
|
|
24 |
#define DRIZZLED_PLUGIN_TABLE_FUNCTION_H
|
|
25 |
||
1273.13.49
by Brian Aker
Does not work (compile issue in plugin). |
26 |
#include <drizzled/definitions.h> |
27 |
#include "drizzled/plugin.h" |
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
28 |
#include "drizzled/plugin/plugin.h" |
1660.1.1
by Brian Aker
Merge in move identifier work. |
29 |
#include "drizzled/identifier.h" |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
30 |
#include "drizzled/message/table.pb.h" |
31 |
#include "drizzled/charset.h" |
|
32 |
#include "drizzled/field.h" |
|
33 |
||
34 |
#include <string> |
|
35 |
#include <set> |
|
1273.23.4
by Monty Taylor
Added include so that transform works on Sun Studio. |
36 |
#include <algorithm> |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
37 |
|
1273.14.5
by Monty Taylor
Merged trunk. |
38 |
namespace drizzled |
39 |
{
|
|
40 |
||
1273.13.38
by Brian Aker
Add in new show work. |
41 |
extern int wild_case_compare(const CHARSET_INFO * const cs, |
42 |
const char *str,const char *wildstr); |
|
43 |
||
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
44 |
namespace plugin |
45 |
{
|
|
46 |
||
1340.1.5
by Brian Aker
Update, we now have all of the ANSI INFORMATION_SCHEMA listed. |
47 |
// Not thread safe, but plugins are just loaded in a single thread right
|
48 |
// now.
|
|
49 |
static const char *local_string_append(const char *arg1, const char *arg2) |
|
50 |
{
|
|
51 |
static char buffer[1024]; |
|
52 |
char *buffer_ptr= buffer; |
|
53 |
strcpy(buffer_ptr, arg1); |
|
54 |
buffer_ptr+= strlen(arg1); |
|
55 |
buffer_ptr[0]= '-'; |
|
56 |
buffer_ptr++; |
|
57 |
strcpy(buffer_ptr, arg2); |
|
58 |
||
59 |
return buffer; |
|
60 |
}
|
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
61 |
|
62 |
class TableFunction : public Plugin |
|
63 |
{
|
|
64 |
TableFunction(); |
|
65 |
TableFunction(const TableFunction &); |
|
66 |
TableFunction& operator=(const TableFunction &); |
|
67 |
||
1273.14.5
by Monty Taylor
Merged trunk. |
68 |
message::Table proto; |
69 |
TableIdentifier identifier; |
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
70 |
std::string local_path; |
1340.1.5
by Brian Aker
Update, we now have all of the ANSI INFORMATION_SCHEMA listed. |
71 |
std::string original_table_label; |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
72 |
|
73 |
void setName(); // init name |
|
74 |
||
75 |
void init(); |
|
76 |
||
77 |
public: |
|
78 |
TableFunction(const char *schema_arg, const char *table_arg) : |
|
1340.1.5
by Brian Aker
Update, we now have all of the ANSI INFORMATION_SCHEMA listed. |
79 |
Plugin(local_string_append(schema_arg, table_arg) , "TableFunction"), |
80 |
identifier(schema_arg, table_arg), |
|
81 |
original_table_label(table_arg) |
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
82 |
{
|
83 |
init(); |
|
84 |
}
|
|
85 |
||
86 |
virtual ~TableFunction() {} |
|
87 |
||
88 |
static bool addPlugin(TableFunction *function); |
|
89 |
static void removePlugin(TableFunction *) |
|
90 |
{ } |
|
91 |
static TableFunction *getFunction(const std::string &arg); |
|
92 |
static void getNames(const std::string &arg, |
|
93 |
std::set<std::string> &set_of_names); |
|
94 |
||
95 |
enum ColumnType { |
|
96 |
BOOLEAN, |
|
97 |
NUMBER, |
|
1337.1.2
by Stewart Smith
make DATA_DICTIONARY.COLUMNS.COLUMN_DEFAULT be a VARBINARY column that can be null. Add a test for binary default values as well as non-binary default values. |
98 |
STRING, |
99 |
VARBINARY
|
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
100 |
};
|
101 |
||
102 |
class Generator |
|
103 |
{
|
|
104 |
Field **columns; |
|
105 |
Field **columns_iterator; |
|
1436
by Brian Aker
Move toward not having to call current_session (first pass). |
106 |
Session *session; |
107 |
||
108 |
protected: |
|
109 |
||
110 |
drizzled::Session &getSession() |
|
111 |
{
|
|
112 |
return *session; |
|
113 |
}
|
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
114 |
|
115 |
public: |
|
116 |
const CHARSET_INFO *scs; |
|
117 |
||
118 |
Generator(Field **arg); |
|
119 |
virtual ~Generator() |
|
120 |
{ } |
|
121 |
||
122 |
/*
|
|
123 |
Return type is bool meaning "are there more rows".
|
|
124 |
*/
|
|
1273.13.44
by Brian Aker
Updates/bug fix for columns. Assert now for checking that we filled in all |
125 |
bool sub_populate(uint32_t field_size); |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
126 |
|
127 |
virtual bool populate() |
|
128 |
{
|
|
129 |
return false; |
|
130 |
}
|
|
131 |
||
1300.1.3
by Monty Taylor
Fixed osx build without templates. |
132 |
void push(uint64_t arg); |
133 |
void push(int64_t arg); |
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
134 |
void push(const char *arg, uint32_t length= 0); |
1302.2.1
by Monty Taylor
Fixed the OSX build issues. |
135 |
void push(const std::string& arg); |
1300.1.3
by Monty Taylor
Fixed osx build without templates. |
136 |
void push(bool arg); |
1273.13.45
by Brian Aker
Update for test split. |
137 |
void push(); |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
138 |
|
1273.13.38
by Brian Aker
Add in new show work. |
139 |
bool isWild(const std::string &predicate); |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
140 |
};
|
141 |
||
1273.14.5
by Monty Taylor
Merged trunk. |
142 |
void define(message::Table &arg) |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
143 |
{
|
144 |
arg.CopyFrom(proto); |
|
145 |
}
|
|
146 |
||
1340.1.5
by Brian Aker
Update, we now have all of the ANSI INFORMATION_SCHEMA listed. |
147 |
const std::string &getTableLabel() |
148 |
{
|
|
149 |
return original_table_label; |
|
150 |
}
|
|
151 |
||
152 |
const std::string &getIdentifierTableName() |
|
153 |
{
|
|
1669.3.3
by Brian Aker
Remove the need for tolower in retrieval of table functions. |
154 |
return identifier.getTableName(); |
1340.1.5
by Brian Aker
Update, we now have all of the ANSI INFORMATION_SCHEMA listed. |
155 |
}
|
156 |
||
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
157 |
const std::string &getSchemaHome() |
158 |
{
|
|
1669.3.3
by Brian Aker
Remove the need for tolower in retrieval of table functions. |
159 |
return identifier.getSchemaName(); |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
160 |
}
|
161 |
||
162 |
const std::string &getPath() |
|
163 |
{
|
|
1669.3.3
by Brian Aker
Remove the need for tolower in retrieval of table functions. |
164 |
return identifier.getPath(); |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
165 |
}
|
166 |
||
167 |
virtual Generator *generator(Field **arg); |
|
168 |
||
169 |
void add_field(const char *label, |
|
1273.14.5
by Monty Taylor
Merged trunk. |
170 |
message::Table::Field::FieldType type, |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
171 |
uint32_t length= 0); |
172 |
||
173 |
void add_field(const char *label, |
|
1567.1.1
by Brian Aker
This fixes bug 586009, increases the size of the log files so that the UNION |
174 |
uint32_t field_length= MAXIMUM_IDENTIFIER_LENGTH); |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
175 |
|
176 |
void add_field(const char *label, |
|
177 |
TableFunction::ColumnType type, |
|
1273.13.45
by Brian Aker
Update for test split. |
178 |
bool is_default_null= true); |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
179 |
|
180 |
void add_field(const char *label, |
|
181 |
TableFunction::ColumnType type, |
|
182 |
uint32_t field_length, |
|
183 |
bool is_default_null= false); |
|
184 |
};
|
|
185 |
||
186 |
} /* namespace plugin */ |
|
187 |
} /* namespace drizzled */ |
|
188 |
||
189 |
#endif /* DRIZZLED_PLUGIN_TABLE_FUNCTION_H */ |