1063.4.5
by Padraig O'Sullivan
Fixed a stupid mistake I made in the innodb handler. Also reverted back to |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
520.4.14
by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf. |
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
5 |
*
|
|
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; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
1
by brian
clean slate |
19 |
|
20 |
||
21 |
/* Function with list databases, tables or fields */
|
|
1241.9.36
by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h. |
22 |
#include "config.h" |
243.1.17
by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.) |
23 |
#include <drizzled/sql_select.h> |
575.4.7
by Monty Taylor
More header cleanup. |
24 |
#include <drizzled/show.h> |
538
by Monty Taylor
Moved gettext.h into drizzled in anticipation of the new client lib. |
25 |
#include <drizzled/gettext.h> |
492.1.8
by Monty Taylor
Replaced some int10_to_str with to_string. |
26 |
#include <drizzled/util/convert.h> |
550
by Monty Taylor
Moved error.h into just the files that need it. |
27 |
#include <drizzled/error.h> |
520.4.14
by Monty Taylor
Removed korr.h and tztime.h from common_includes. Also removed the HAVE_DTRACE block and stuck it in autoconf. |
28 |
#include <drizzled/tztime.h> |
520.6.7
by Monty Taylor
Moved a bunch of crap out of common_includes. |
29 |
#include <drizzled/data_home.h> |
642.1.63
by Lee
more header file cleanup |
30 |
#include <drizzled/item/blob.h> |
584.4.7
by Monty Taylor
Removed a big bank of includes from item.h. |
31 |
#include <drizzled/item/cmpfunc.h> |
642.1.17
by Lee
header file clean up |
32 |
#include <drizzled/item/return_int.h> |
642.1.23
by Lee
more header file cleanup |
33 |
#include <drizzled/item/empty_string.h> |
642.1.18
by Lee
header file clean up |
34 |
#include <drizzled/item/return_date_time.h> |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
35 |
#include <drizzled/sql_base.h> |
36 |
#include <drizzled/db.h> |
|
584.5.1
by Monty Taylor
Removed field includes from field.h. |
37 |
#include <drizzled/field/timestamp.h> |
670.1.1
by Monty Taylor
Renamed fdecimal.* to decimal.*. Let's see how many things we can break! |
38 |
#include <drizzled/field/decimal.h> |
670.2.4
by Monty Taylor
Removed more stuff from the headers. |
39 |
#include <drizzled/lock.h> |
675
by Brian Aker
Cleanup around item includes. |
40 |
#include <drizzled/item/return_date_time.h> |
41 |
#include <drizzled/item/empty_string.h> |
|
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
42 |
#include "drizzled/plugin/registry.h" |
1241.9.17
by Monty Taylor
Removed more bits from server_includes. |
43 |
#include "drizzled/session_list.h" |
1130.1.7
by Monty Taylor
Renamed plugin::InfoSchema to plugin::InfoSchemaTable as per Jay. |
44 |
#include <drizzled/plugin/info_schema_table.h> |
1089.10.1
by Stewart Smith
fix SHOW CREATE DATABASE for default collation. Move database metadata reading code around to be a bit more sane. |
45 |
#include <drizzled/message/schema.pb.h> |
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
46 |
#include <drizzled/plugin/client.h> |
1241.9.44
by Monty Taylor
Made magic with cached_directory. |
47 |
#include <drizzled/cached_directory.h> |
1241.9.23
by Monty Taylor
Removed sql_table.h from server_includes.h. |
48 |
#include "drizzled/sql_table.h" |
1241.9.28
by Monty Taylor
Removed global_charset_info.h from server_includes.h |
49 |
#include "drizzled/global_charset_info.h" |
1241.9.31
by Monty Taylor
Moved global pthread variables into their own header. |
50 |
#include "drizzled/pthread_globals.h" |
1241.9.64
by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal. |
51 |
#include "drizzled/internal/m_string.h" |
52 |
#include "drizzled/internal/my_sys.h" |
|
1241.9.28
by Monty Taylor
Removed global_charset_info.h from server_includes.h |
53 |
|
1108.4.2
by David Shrewsbury
Replace my_dir in find_files() with CachedDirectory. Renamed find_files() to find_dirs() to more accurately reflect what it is doing after removing dead code inside it. |
54 |
#include <sys/stat.h> |
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
55 |
|
56 |
#include <string> |
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
57 |
#include <iostream> |
58 |
#include <sstream> |
|
901.1.1
by Padraig
Initial work to replace an instance of DYNAMIC_ARRAY in show.cc with STL |
59 |
#include <vector> |
60 |
#include <algorithm> |
|
629.4.1
by Monty Taylor
First step in support size_t sys_var stuff. |
61 |
|
62 |
using namespace std; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
63 |
|
64 |
namespace drizzled |
|
65 |
{
|
|
1
by brian
clean slate |
66 |
|
322.2.2
by Mats Kindahl
Hiding THD::proc_info field and providing a setter and getter. |
67 |
inline const char * |
68 |
str_or_nil(const char *str) |
|
69 |
{
|
|
70 |
return str ? str : "<nil>"; |
|
71 |
}
|
|
1
by brian
clean slate |
72 |
|
1014.3.4
by Brian Aker
Remove dead session calls. |
73 |
static void store_key_options(String *packet, Table *table, KEY *key_info); |
1
by brian
clean slate |
74 |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
75 |
int wild_case_compare(const CHARSET_INFO * const cs, const char *str,const char *wildstr) |
1
by brian
clean slate |
76 |
{
|
77 |
register int flag; |
|
78 |
while (*wildstr) |
|
79 |
{
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
80 |
while (*wildstr && *wildstr != internal::wild_many && *wildstr != internal::wild_one) |
1
by brian
clean slate |
81 |
{
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
82 |
if (*wildstr == internal::wild_prefix && wildstr[1]) |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
83 |
wildstr++; |
84 |
if (my_toupper(cs, *wildstr++) != my_toupper(cs, *str++)) |
|
1067.3.1
by Padraig O'Sullivan
Extracted the CHARACTER_SET I_S table into the I_S plugin. |
85 |
return (1); |
1
by brian
clean slate |
86 |
}
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
87 |
if (! *wildstr ) |
88 |
return (*str != 0); |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
89 |
if (*wildstr++ == internal::wild_one) |
1
by brian
clean slate |
90 |
{
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
91 |
if (! *str++) |
92 |
return (1); /* One char; skip */ |
|
1
by brian
clean slate |
93 |
}
|
94 |
else
|
|
95 |
{ /* Found '*' */ |
|
1067.3.1
by Padraig O'Sullivan
Extracted the CHARACTER_SET I_S table into the I_S plugin. |
96 |
if (! *wildstr) |
97 |
return (0); /* '*' as last char: OK */ |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
98 |
flag=(*wildstr != internal::wild_many && *wildstr != internal::wild_one); |
1
by brian
clean slate |
99 |
do
|
100 |
{
|
|
1067.3.1
by Padraig O'Sullivan
Extracted the CHARACTER_SET I_S table into the I_S plugin. |
101 |
if (flag) |
102 |
{
|
|
103 |
char cmp; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
104 |
if ((cmp= *wildstr) == internal::wild_prefix && wildstr[1]) |
1067.3.1
by Padraig O'Sullivan
Extracted the CHARACTER_SET I_S table into the I_S plugin. |
105 |
cmp= wildstr[1]; |
106 |
cmp= my_toupper(cs, cmp); |
|
107 |
while (*str && my_toupper(cs, *str) != cmp) |
|
108 |
str++; |
|
109 |
if (! *str) |
|
110 |
return (1); |
|
111 |
}
|
|
112 |
if (wild_case_compare(cs, str, wildstr) == 0) |
|
113 |
return (0); |
|
114 |
} while (*str++); |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
115 |
return (1); |
1
by brian
clean slate |
116 |
}
|
117 |
}
|
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
118 |
return (*str != '\0'); |
1
by brian
clean slate |
119 |
}
|
120 |
||
121 |
||
1071.1.1
by Nathan Williams
Refactored find_files function: style cleanup, removing dead variables, doxygenized-header, and removed unneeded LEX_STRING creation. |
122 |
/**
|
123 |
* @brief
|
|
1108.4.4
by David Shrewsbury
Minor style change. Renamed find_databases() to find_schemas() for consistency. Changed return type from int to bool. |
124 |
* Find subdirectories (schemas) in a given directory (datadir).
|
1071.1.1
by Nathan Williams
Refactored find_files function: style cleanup, removing dead variables, doxygenized-header, and removed unneeded LEX_STRING creation. |
125 |
*
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
126 |
* @param[in] session Thread Cursor
|
1108.4.2
by David Shrewsbury
Replace my_dir in find_files() with CachedDirectory. Renamed find_files() to find_dirs() to more accurately reflect what it is doing after removing dead code inside it. |
127 |
* @param[out] files Put found entries in this list
|
1071.1.1
by Nathan Williams
Refactored find_files function: style cleanup, removing dead variables, doxygenized-header, and removed unneeded LEX_STRING creation. |
128 |
* @param[in] path Path to database
|
1108.4.2
by David Shrewsbury
Replace my_dir in find_files() with CachedDirectory. Renamed find_files() to find_dirs() to more accurately reflect what it is doing after removing dead code inside it. |
129 |
* @param[in] wild Filter for found entries
|
1071.1.1
by Nathan Williams
Refactored find_files function: style cleanup, removing dead variables, doxygenized-header, and removed unneeded LEX_STRING creation. |
130 |
*
|
1108.4.4
by David Shrewsbury
Minor style change. Renamed find_databases() to find_schemas() for consistency. Changed return type from int to bool. |
131 |
* @retval false Success
|
132 |
* @retval true Error
|
|
1071.1.1
by Nathan Williams
Refactored find_files function: style cleanup, removing dead variables, doxygenized-header, and removed unneeded LEX_STRING creation. |
133 |
*/
|
1108.4.4
by David Shrewsbury
Minor style change. Renamed find_databases() to find_schemas() for consistency. Changed return type from int to bool. |
134 |
static bool find_schemas(Session *session, vector<LEX_STRING*> &files, |
135 |
const char *path, const char *wild) |
|
1
by brian
clean slate |
136 |
{
|
1071.1.1
by Nathan Williams
Refactored find_files function: style cleanup, removing dead variables, doxygenized-header, and removed unneeded LEX_STRING creation. |
137 |
if (wild && (wild[0] == '\0')) |
138 |
wild= 0; |
|
139 |
||
1108.4.2
by David Shrewsbury
Replace my_dir in find_files() with CachedDirectory. Renamed find_files() to find_dirs() to more accurately reflect what it is doing after removing dead code inside it. |
140 |
CachedDirectory directory(path); |
141 |
||
142 |
if (directory.fail()) |
|
1
by brian
clean slate |
143 |
{
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
144 |
errno= directory.getError(); |
145 |
my_error(ER_CANT_READ_DIR, MYF(0), path, errno); |
|
1183.1.15
by Brian Aker
I_S now provides its own tables via the SE interface |
146 |
|
147 |
return true; |
|
1
by brian
clean slate |
148 |
}
|
149 |
||
1108.4.2
by David Shrewsbury
Replace my_dir in find_files() with CachedDirectory. Renamed find_files() to find_dirs() to more accurately reflect what it is doing after removing dead code inside it. |
150 |
CachedDirectory::Entries entries= directory.getEntries(); |
151 |
CachedDirectory::Entries::iterator entry_iter= entries.begin(); |
|
152 |
||
153 |
while (entry_iter != entries.end()) |
|
1
by brian
clean slate |
154 |
{
|
1071.1.1
by Nathan Williams
Refactored find_files function: style cleanup, removing dead variables, doxygenized-header, and removed unneeded LEX_STRING creation. |
155 |
uint32_t file_name_len; |
1
by brian
clean slate |
156 |
char uname[NAME_LEN + 1]; /* Unencoded name */ |
1108.4.2
by David Shrewsbury
Replace my_dir in find_files() with CachedDirectory. Renamed find_files() to find_dirs() to more accurately reflect what it is doing after removing dead code inside it. |
157 |
struct stat entry_stat; |
158 |
CachedDirectory::Entry *entry= *entry_iter; |
|
159 |
||
160 |
if ((entry->filename == ".") || (entry->filename == "..")) |
|
161 |
{
|
|
162 |
++entry_iter; |
|
163 |
continue; |
|
164 |
}
|
|
165 |
||
166 |
if (stat(entry->filename.c_str(), &entry_stat)) |
|
167 |
{
|
|
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
168 |
errno= errno; |
169 |
my_error(ER_CANT_GET_STAT, MYF(0), entry->filename.c_str(), errno); |
|
1108.4.4
by David Shrewsbury
Minor style change. Renamed find_databases() to find_schemas() for consistency. Changed return type from int to bool. |
170 |
return(true); |
1108.4.2
by David Shrewsbury
Replace my_dir in find_files() with CachedDirectory. Renamed find_files() to find_dirs() to more accurately reflect what it is doing after removing dead code inside it. |
171 |
}
|
172 |
||
1108.4.4
by David Shrewsbury
Minor style change. Renamed find_databases() to find_schemas() for consistency. Changed return type from int to bool. |
173 |
if (! S_ISDIR(entry_stat.st_mode)) |
1108.4.2
by David Shrewsbury
Replace my_dir in find_files() with CachedDirectory. Renamed find_files() to find_dirs() to more accurately reflect what it is doing after removing dead code inside it. |
174 |
{
|
175 |
++entry_iter; |
|
176 |
continue; |
|
177 |
}
|
|
178 |
||
179 |
file_name_len= filename_to_tablename(entry->filename.c_str(), uname, |
|
180 |
sizeof(uname)); |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
181 |
if (wild && internal::wild_compare(uname, wild, 0)) |
1108.4.2
by David Shrewsbury
Replace my_dir in find_files() with CachedDirectory. Renamed find_files() to find_dirs() to more accurately reflect what it is doing after removing dead code inside it. |
182 |
{
|
183 |
++entry_iter; |
|
184 |
continue; |
|
1
by brian
clean slate |
185 |
}
|
1071.1.1
by Nathan Williams
Refactored find_files function: style cleanup, removing dead variables, doxygenized-header, and removed unneeded LEX_STRING creation. |
186 |
|
187 |
LEX_STRING *file_name= 0; |
|
188 |
file_name= session->make_lex_string(file_name, uname, file_name_len, true); |
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
189 |
if (file_name == NULL) |
1108.4.4
by David Shrewsbury
Minor style change. Renamed find_databases() to find_schemas() for consistency. Changed return type from int to bool. |
190 |
return(true); |
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
191 |
|
1071.1.3
by Nathan Williams
Removed st_add_schema_table struct and moved data members into the AddSchemaTable class/functor. That was the only place it was used. |
192 |
files.push_back(file_name); |
1108.4.2
by David Shrewsbury
Replace my_dir in find_files() with CachedDirectory. Renamed find_files() to find_dirs() to more accurately reflect what it is doing after removing dead code inside it. |
193 |
++entry_iter; |
1
by brian
clean slate |
194 |
}
|
1071.1.1
by Nathan Williams
Refactored find_files function: style cleanup, removing dead variables, doxygenized-header, and removed unneeded LEX_STRING creation. |
195 |
|
1183.1.5
by Brian Aker
Reworked getTableNames() interface. Way simpler, less mallocs.... |
196 |
return false; |
1
by brian
clean slate |
197 |
}
|
198 |
||
199 |
||
1222.2.3
by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO. |
200 |
bool drizzled_show_create(Session *session, TableList *table_list, bool is_if_not_exists) |
1
by brian
clean slate |
201 |
{
|
202 |
char buff[2048]; |
|
203 |
String buffer(buff, sizeof(buff), system_charset_info); |
|
204 |
||
205 |
/* Only one table for now, but VIEW can involve several tables */
|
|
1109.1.3
by Brian Aker
Move names around a bit (to align similar methods) |
206 |
if (session->openTables(table_list)) |
1
by brian
clean slate |
207 |
{
|
737
by Brian Aker
Updates for dead code removal (and forced assert() in delete). |
208 |
if (session->is_error()) |
1014.3.4
by Brian Aker
Remove dead session calls. |
209 |
return true; |
1
by brian
clean slate |
210 |
|
211 |
/*
|
|
212 |
Clear all messages with 'error' level status and
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
213 |
issue a warning with 'warning' level status in
|
1
by brian
clean slate |
214 |
case of invalid view and last error is ER_VIEW_INVALID
|
215 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
216 |
drizzle_reset_errors(session, true); |
217 |
session->clear_error(); |
|
1
by brian
clean slate |
218 |
}
|
219 |
||
220 |
buffer.length(0); |
|
221 |
||
1222.1.3
by Brian Aker
Remove used flag for engine. |
222 |
if (store_create_info(table_list, &buffer, is_if_not_exists)) |
1014.3.4
by Brian Aker
Remove dead session calls. |
223 |
return true; |
1
by brian
clean slate |
224 |
|
225 |
List<Item> field_list; |
|
226 |
{
|
|
227 |
field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN)); |
|
228 |
// 1024 is for not to confuse old clients
|
|
229 |
field_list.push_back(new Item_empty_string("Create Table", |
|
1067.4.7
by Nathan Williams
The remaining files using cmax have been converted to std::max. |
230 |
max(buffer.length(),(uint32_t)1024))); |
1
by brian
clean slate |
231 |
}
|
232 |
||
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
233 |
if (session->client->sendFields(&field_list)) |
1014.3.4
by Brian Aker
Remove dead session calls. |
234 |
return true; |
1
by brian
clean slate |
235 |
{
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
236 |
session->client->store(table_list->table->alias); |
1
by brian
clean slate |
237 |
}
|
238 |
||
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
239 |
session->client->store(buffer.ptr(), buffer.length()); |
1
by brian
clean slate |
240 |
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
241 |
if (session->client->flush()) |
1014.3.4
by Brian Aker
Remove dead session calls. |
242 |
return true; |
1
by brian
clean slate |
243 |
|
836
by Brian Aker
Fixed session call from function to method. |
244 |
session->my_eof(); |
1014.3.4
by Brian Aker
Remove dead session calls. |
245 |
return false; |
1
by brian
clean slate |
246 |
}
|
247 |
||
1089.10.1
by Stewart Smith
fix SHOW CREATE DATABASE for default collation. Move database metadata reading code around to be a bit more sane. |
248 |
/**
|
249 |
Get a CREATE statement for a given database.
|
|
250 |
||
251 |
The database is identified by its name, passed as @c dbname parameter.
|
|
252 |
The name should be encoded using the system character set (UTF8 currently).
|
|
253 |
||
254 |
Resulting statement is stored in the string pointed by @c buffer. The string
|
|
255 |
is emptied first and its character set is set to the system character set.
|
|
256 |
||
1222.2.3
by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO. |
257 |
If is_if_not_exists is set, then
|
1089.10.1
by Stewart Smith
fix SHOW CREATE DATABASE for default collation. Move database metadata reading code around to be a bit more sane. |
258 |
the resulting CREATE statement contains "IF NOT EXISTS" clause. Other flags
|
259 |
in @c create_options are ignored.
|
|
260 |
||
261 |
@param session The current thread instance.
|
|
262 |
@param dbname The name of the database.
|
|
263 |
@param buffer A String instance where the statement is stored.
|
|
264 |
@param create_info If not NULL, the options member influences the resulting
|
|
265 |
CRATE statement.
|
|
266 |
||
267 |
@returns true if errors are detected, false otherwise.
|
|
268 |
*/
|
|
269 |
||
270 |
static bool store_db_create_info(const char *dbname, String *buffer, bool if_not_exists) |
|
271 |
{
|
|
1118.2.1
by Stewart Smith
fix drizzled::message::Table usage so that in kernel .cc files we are 'using namespace drizzled' |
272 |
message::Schema schema; |
1089.10.1
by Stewart Smith
fix SHOW CREATE DATABASE for default collation. Move database metadata reading code around to be a bit more sane. |
273 |
|
274 |
if (!my_strcasecmp(system_charset_info, dbname, |
|
275 |
INFORMATION_SCHEMA_NAME.c_str())) |
|
276 |
{
|
|
277 |
dbname= INFORMATION_SCHEMA_NAME.c_str(); |
|
278 |
}
|
|
279 |
else
|
|
280 |
{
|
|
281 |
int r= get_database_metadata(dbname, &schema); |
|
282 |
if(r < 0) |
|
283 |
return true; |
|
284 |
}
|
|
285 |
||
286 |
buffer->length(0); |
|
287 |
buffer->free(); |
|
288 |
buffer->set_charset(system_charset_info); |
|
289 |
buffer->append(STRING_WITH_LEN("CREATE DATABASE ")); |
|
290 |
||
291 |
if (if_not_exists) |
|
292 |
buffer->append(STRING_WITH_LEN("IF NOT EXISTS ")); |
|
293 |
||
294 |
buffer->append_identifier(dbname, strlen(dbname)); |
|
295 |
||
296 |
if (schema.has_collation() && strcmp(schema.collation().c_str(), |
|
297 |
default_charset_info->name)) |
|
298 |
{
|
|
299 |
buffer->append(" COLLATE = "); |
|
300 |
buffer->append(schema.collation().c_str()); |
|
301 |
}
|
|
302 |
||
303 |
return false; |
|
304 |
}
|
|
305 |
||
1273
by Brian Aker
Revert db patch. |
306 |
bool mysqld_show_create_db(Session *session, char *dbname, bool if_not_exists) |
1
by brian
clean slate |
307 |
{
|
308 |
char buff[2048]; |
|
309 |
String buffer(buff, sizeof(buff), system_charset_info); |
|
310 |
||
1273
by Brian Aker
Revert db patch. |
311 |
if (store_db_create_info(dbname, &buffer, if_not_exists)) |
1
by brian
clean slate |
312 |
{
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
313 |
/*
|
1
by brian
clean slate |
314 |
This assumes that the only reason for which store_db_create_info()
|
315 |
can fail is incorrect database name (which is the case now).
|
|
316 |
*/
|
|
1273
by Brian Aker
Revert db patch. |
317 |
my_error(ER_BAD_DB_ERROR, MYF(0), dbname); |
1014.3.4
by Brian Aker
Remove dead session calls. |
318 |
return true; |
1
by brian
clean slate |
319 |
}
|
320 |
||
321 |
List<Item> field_list; |
|
322 |
field_list.push_back(new Item_empty_string("Database",NAME_CHAR_LEN)); |
|
323 |
field_list.push_back(new Item_empty_string("Create Database",1024)); |
|
324 |
||
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
325 |
if (session->client->sendFields(&field_list)) |
1014.3.4
by Brian Aker
Remove dead session calls. |
326 |
return true; |
1
by brian
clean slate |
327 |
|
1273
by Brian Aker
Revert db patch. |
328 |
session->client->store(dbname, strlen(dbname)); |
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
329 |
session->client->store(buffer.ptr(), buffer.length()); |
1
by brian
clean slate |
330 |
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
331 |
if (session->client->flush()) |
1014.3.4
by Brian Aker
Remove dead session calls. |
332 |
return true; |
836
by Brian Aker
Fixed session call from function to method. |
333 |
session->my_eof(); |
1014.3.4
by Brian Aker
Remove dead session calls. |
334 |
return false; |
1
by brian
clean slate |
335 |
}
|
336 |
||
337 |
/*
|
|
338 |
Get the quote character for displaying an identifier.
|
|
339 |
||
340 |
SYNOPSIS
|
|
341 |
get_quote_char_for_identifier()
|
|
342 |
||
343 |
IMPLEMENTATION
|
|
344 |
Force quoting in the following cases:
|
|
345 |
- name is empty (for one, it is possible when we use this function for
|
|
346 |
quoting user and host names for DEFINER clause);
|
|
347 |
- name is a keyword;
|
|
348 |
- name includes a special character;
|
|
349 |
Otherwise identifier is quoted only if the option OPTION_QUOTE_SHOW_CREATE
|
|
350 |
is set.
|
|
351 |
||
352 |
RETURN
|
|
353 |
EOF No quote character is needed
|
|
354 |
# Quote character
|
|
355 |
*/
|
|
356 |
||
1014.3.4
by Brian Aker
Remove dead session calls. |
357 |
int get_quote_char_for_identifier() |
1
by brian
clean slate |
358 |
{
|
352.2.1
by Harrison Fisk
Fix for bugs 259843 and 256482 |
359 |
return '`'; |
1
by brian
clean slate |
360 |
}
|
361 |
||
362 |
||
363 |
#define LIST_PROCESS_HOST_LEN 64
|
|
364 |
||
1014.3.4
by Brian Aker
Remove dead session calls. |
365 |
static bool get_field_default_value(Field *timestamp_field, |
1
by brian
clean slate |
366 |
Field *field, String *def_value, |
367 |
bool quoted) |
|
368 |
{
|
|
369 |
bool has_default; |
|
370 |
bool has_now_default; |
|
371 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
372 |
/*
|
1
by brian
clean slate |
373 |
We are using CURRENT_TIMESTAMP instead of NOW because it is
|
374 |
more standard
|
|
375 |
*/
|
|
376 |
has_now_default= (timestamp_field == field && |
|
377 |
field->unireg_check != Field::TIMESTAMP_UN_FIELD); |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
378 |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
379 |
has_default= (field->type() != DRIZZLE_TYPE_BLOB && |
1
by brian
clean slate |
380 |
!(field->flags & NO_DEFAULT_VALUE_FLAG) && |
884.2.1
by Toru Maesaka
Fixed the bug of SHOW CREATE TABLE not outputting DEFAULT values. Killed some tabular indents on the way too |
381 |
field->unireg_check != Field::NEXT_NUMBER); |
1
by brian
clean slate |
382 |
|
383 |
def_value->length(0); |
|
384 |
if (has_default) |
|
385 |
{
|
|
386 |
if (has_now_default) |
|
387 |
def_value->append(STRING_WITH_LEN("CURRENT_TIMESTAMP")); |
|
388 |
else if (!field->is_null()) |
|
389 |
{ // Not null by default |
|
390 |
char tmp[MAX_FIELD_WIDTH]; |
|
391 |
String type(tmp, sizeof(tmp), field->charset()); |
|
392 |
field->val_str(&type); |
|
393 |
if (type.length()) |
|
394 |
{
|
|
395 |
String def_val; |
|
482
by Brian Aker
Remove uint. |
396 |
uint32_t dummy_errors; |
1
by brian
clean slate |
397 |
/* convert to system_charset_info == utf8 */
|
398 |
def_val.copy(type.ptr(), type.length(), field->charset(), |
|
399 |
system_charset_info, &dummy_errors); |
|
400 |
if (quoted) |
|
401 |
append_unescaped(def_value, def_val.ptr(), def_val.length()); |
|
402 |
else
|
|
403 |
def_value->append(def_val.ptr(), def_val.length()); |
|
404 |
}
|
|
405 |
else if (quoted) |
|
406 |
def_value->append(STRING_WITH_LEN("''")); |
|
407 |
}
|
|
408 |
else if (field->maybe_null() && quoted) |
|
409 |
def_value->append(STRING_WITH_LEN("NULL")); // Null as default |
|
410 |
else
|
|
1014.3.4
by Brian Aker
Remove dead session calls. |
411 |
return false; |
1
by brian
clean slate |
412 |
}
|
413 |
return has_default; |
|
414 |
}
|
|
415 |
||
416 |
/*
|
|
417 |
Build a CREATE TABLE statement for a table.
|
|
418 |
||
419 |
SYNOPSIS
|
|
420 |
store_create_info()
|
|
421 |
table_list A list containing one table to write statement
|
|
422 |
for.
|
|
423 |
packet Pointer to a string where statement will be
|
|
424 |
written.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
425 |
|
1
by brian
clean slate |
426 |
NOTE
|
427 |
Currently always return 0, but might return error code in the
|
|
428 |
future.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
429 |
|
1
by brian
clean slate |
430 |
RETURN
|
431 |
0 OK
|
|
432 |
*/
|
|
433 |
||
1222.1.3
by Brian Aker
Remove used flag for engine. |
434 |
int store_create_info(TableList *table_list, String *packet, bool is_if_not_exists) |
1
by brian
clean slate |
435 |
{
|
436 |
List<Item> field_list; |
|
492.1.8
by Monty Taylor
Replaced some int10_to_str with to_string. |
437 |
char tmp[MAX_FIELD_WIDTH], *for_str, def_value_buf[MAX_FIELD_WIDTH]; |
1
by brian
clean slate |
438 |
const char *alias; |
670.3.3
by Toru Maesaka
Added namespacing for std to .cc files that needed it |
439 |
string buff; |
1
by brian
clean slate |
440 |
String type(tmp, sizeof(tmp), system_charset_info); |
441 |
String def_value(def_value_buf, sizeof(def_value_buf), system_charset_info); |
|
442 |
Field **ptr,*field; |
|
482
by Brian Aker
Remove uint. |
443 |
uint32_t primary_key; |
1
by brian
clean slate |
444 |
KEY *key_info; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
445 |
Table *table= table_list->table; |
1208.3.2
by brian
Update for Cursor renaming. |
446 |
Cursor *cursor= table->cursor; |
1000.1.3
by Brian Aker
Renamed TABLE_SHARE to TableShare |
447 |
TableShare *share= table->s; |
1
by brian
clean slate |
448 |
HA_CREATE_INFO create_info; |
163
by Brian Aker
Merge Monty's code. |
449 |
bool show_table_options= false; |
1005.2.3
by Monty Taylor
Further reversion of P. |
450 |
my_bitmap_map *old_map; |
1
by brian
clean slate |
451 |
|
997.5.1
by chris
Replace macros around unireg.h, store_record,restore_record,cmp_record,empty_record |
452 |
table->restoreRecordAsDefault(); // Get empty record |
1
by brian
clean slate |
453 |
|
454 |
if (share->tmp_table) |
|
455 |
packet->append(STRING_WITH_LEN("CREATE TEMPORARY TABLE ")); |
|
456 |
else
|
|
457 |
packet->append(STRING_WITH_LEN("CREATE TABLE ")); |
|
1222.2.3
by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO. |
458 |
if (is_if_not_exists) |
1
by brian
clean slate |
459 |
packet->append(STRING_WITH_LEN("IF NOT EXISTS ")); |
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
460 |
alias= share->table_name.str; |
1039.1.5
by Brian Aker
Remove lower case filename bits (aka we just lock into the most compatible |
461 |
|
794
by Brian Aker
Refactor append_identifier and remove dead OPTION_QUOTE_SHOW_CREATE option |
462 |
packet->append_identifier(alias, strlen(alias)); |
1
by brian
clean slate |
463 |
packet->append(STRING_WITH_LEN(" (\n")); |
464 |
/*
|
|
465 |
We need this to get default values from the table
|
|
466 |
We have to restore the read_set if we are called from insert in case
|
|
467 |
of row based replication.
|
|
468 |
*/
|
|
1005.2.3
by Monty Taylor
Further reversion of P. |
469 |
old_map= table->use_all_columns(table->read_set); |
1
by brian
clean slate |
470 |
|
471 |
for (ptr=table->field ; (field= *ptr); ptr++) |
|
472 |
{
|
|
482
by Brian Aker
Remove uint. |
473 |
uint32_t flags = field->flags; |
1
by brian
clean slate |
474 |
|
475 |
if (ptr != table->field) |
|
476 |
packet->append(STRING_WITH_LEN(",\n")); |
|
477 |
||
478 |
packet->append(STRING_WITH_LEN(" ")); |
|
794
by Brian Aker
Refactor append_identifier and remove dead OPTION_QUOTE_SHOW_CREATE option |
479 |
packet->append_identifier(field->field_name, strlen(field->field_name)); |
1
by brian
clean slate |
480 |
packet->append(' '); |
481 |
// check for surprises from the previous call to Field::sql_type()
|
|
482 |
if (type.ptr() != tmp) |
|
483 |
type.set(tmp, sizeof(tmp), system_charset_info); |
|
484 |
else
|
|
485 |
type.set_charset(system_charset_info); |
|
486 |
||
487 |
field->sql_type(type); |
|
488 |
packet->append(type.ptr(), type.length(), system_charset_info); |
|
489 |
||
490 |
if (field->has_charset()) |
|
491 |
{
|
|
492 |
if (field->charset() != share->table_charset) |
|
493 |
{
|
|
884.2.1
by Toru Maesaka
Fixed the bug of SHOW CREATE TABLE not outputting DEFAULT values. Killed some tabular indents on the way too |
494 |
packet->append(STRING_WITH_LEN(" CHARACTER SET ")); |
495 |
packet->append(field->charset()->csname); |
|
1
by brian
clean slate |
496 |
}
|
884.2.1
by Toru Maesaka
Fixed the bug of SHOW CREATE TABLE not outputting DEFAULT values. Killed some tabular indents on the way too |
497 |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
498 |
/*
|
884.2.1
by Toru Maesaka
Fixed the bug of SHOW CREATE TABLE not outputting DEFAULT values. Killed some tabular indents on the way too |
499 |
For string types dump collation name only if
|
500 |
collation is not primary for the given charset
|
|
1
by brian
clean slate |
501 |
*/
|
502 |
if (!(field->charset()->state & MY_CS_PRIMARY)) |
|
503 |
{
|
|
884.2.1
by Toru Maesaka
Fixed the bug of SHOW CREATE TABLE not outputting DEFAULT values. Killed some tabular indents on the way too |
504 |
packet->append(STRING_WITH_LEN(" COLLATE ")); |
505 |
packet->append(field->charset()->name); |
|
1
by brian
clean slate |
506 |
}
|
507 |
}
|
|
508 |
||
509 |
if (flags & NOT_NULL_FLAG) |
|
510 |
packet->append(STRING_WITH_LEN(" NOT NULL")); |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
511 |
else if (field->type() == DRIZZLE_TYPE_TIMESTAMP) |
1
by brian
clean slate |
512 |
{
|
513 |
/*
|
|
514 |
TIMESTAMP field require explicit NULL flag, because unlike
|
|
515 |
all other fields they are treated as NOT NULL by default.
|
|
516 |
*/
|
|
517 |
packet->append(STRING_WITH_LEN(" NULL")); |
|
518 |
}
|
|
519 |
{
|
|
520 |
/*
|
|
521 |
Add field flags about FIELD FORMAT (FIXED or DYNAMIC)
|
|
522 |
and about STORAGE (DISK or MEMORY).
|
|
523 |
*/
|
|
524 |
enum column_format_type column_format= (enum column_format_type) |
|
525 |
((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK); |
|
526 |
if (column_format) |
|
527 |
{
|
|
528 |
packet->append(STRING_WITH_LEN(" /*!")); |
|
529 |
packet->append(STRING_WITH_LEN(" COLUMN_FORMAT")); |
|
530 |
if (column_format == COLUMN_FORMAT_TYPE_FIXED) |
|
531 |
packet->append(STRING_WITH_LEN(" FIXED */")); |
|
532 |
else
|
|
533 |
packet->append(STRING_WITH_LEN(" DYNAMIC */")); |
|
534 |
}
|
|
535 |
}
|
|
1014.3.4
by Brian Aker
Remove dead session calls. |
536 |
if (get_field_default_value(table->timestamp_field, field, &def_value, 1)) |
1
by brian
clean slate |
537 |
{
|
538 |
packet->append(STRING_WITH_LEN(" DEFAULT ")); |
|
539 |
packet->append(def_value.ptr(), def_value.length(), system_charset_info); |
|
540 |
}
|
|
541 |
||
542 |
if (table->timestamp_field == field && field->unireg_check != Field::TIMESTAMP_DN_FIELD) |
|
543 |
packet->append(STRING_WITH_LEN(" ON UPDATE CURRENT_TIMESTAMP")); |
|
544 |
||
545 |
if (field->unireg_check == Field::NEXT_NUMBER) |
|
546 |
packet->append(STRING_WITH_LEN(" AUTO_INCREMENT")); |
|
547 |
||
548 |
if (field->comment.length) |
|
549 |
{
|
|
550 |
packet->append(STRING_WITH_LEN(" COMMENT ")); |
|
551 |
append_unescaped(packet, field->comment.str, field->comment.length); |
|
552 |
}
|
|
553 |
}
|
|
554 |
||
555 |
key_info= table->key_info; |
|
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
556 |
memset(&create_info, 0, sizeof(create_info)); |
1
by brian
clean slate |
557 |
/* Allow update_create_info to update row type */
|
558 |
create_info.row_type= share->row_type; |
|
1208.3.2
by brian
Update for Cursor renaming. |
559 |
cursor->update_create_info(&create_info); |
1
by brian
clean slate |
560 |
primary_key= share->primary_key; |
561 |
||
482
by Brian Aker
Remove uint. |
562 |
for (uint32_t i=0 ; i < share->keys ; i++,key_info++) |
1
by brian
clean slate |
563 |
{
|
564 |
KEY_PART_INFO *key_part= key_info->key_part; |
|
565 |
bool found_primary=0; |
|
566 |
packet->append(STRING_WITH_LEN(",\n ")); |
|
567 |
||
590.1.1
by Stewart Smith
begin moving from global const char* primary_key_name to methods is_primary_key() and is_primary_key_name() |
568 |
if (i == primary_key && is_primary_key(key_info)) |
1
by brian
clean slate |
569 |
{
|
570 |
found_primary=1; |
|
571 |
/*
|
|
572 |
No space at end, because a space will be added after where the
|
|
573 |
identifier would go, but that is not added for primary key.
|
|
574 |
*/
|
|
575 |
packet->append(STRING_WITH_LEN("PRIMARY KEY")); |
|
576 |
}
|
|
577 |
else if (key_info->flags & HA_NOSAME) |
|
578 |
packet->append(STRING_WITH_LEN("UNIQUE KEY ")); |
|
579 |
else
|
|
580 |
packet->append(STRING_WITH_LEN("KEY ")); |
|
581 |
||
582 |
if (!found_primary) |
|
794
by Brian Aker
Refactor append_identifier and remove dead OPTION_QUOTE_SHOW_CREATE option |
583 |
packet->append_identifier(key_info->name, strlen(key_info->name)); |
1
by brian
clean slate |
584 |
|
585 |
packet->append(STRING_WITH_LEN(" (")); |
|
586 |
||
482
by Brian Aker
Remove uint. |
587 |
for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++) |
1
by brian
clean slate |
588 |
{
|
589 |
if (j) |
|
590 |
packet->append(','); |
|
591 |
||
592 |
if (key_part->field) |
|
794
by Brian Aker
Refactor append_identifier and remove dead OPTION_QUOTE_SHOW_CREATE option |
593 |
packet->append_identifier(key_part->field->field_name, |
884.2.1
by Toru Maesaka
Fixed the bug of SHOW CREATE TABLE not outputting DEFAULT values. Killed some tabular indents on the way too |
594 |
strlen(key_part->field->field_name)); |
1
by brian
clean slate |
595 |
if (key_part->field && |
596 |
(key_part->length != |
|
597 |
table->field[key_part->fieldnr-1]->key_length())) |
|
598 |
{
|
|
1008.3.8
by Stewart Smith
remove more evil that is operator overloading. |
599 |
buff.assign("("); |
1008.3.7
by Stewart Smith
remove evil that is operator overloading. |
600 |
buff.append(to_string((int32_t) key_part->length / |
601 |
key_part->field->charset()->mbmaxlen)); |
|
602 |
buff.append(")"); |
|
492.1.8
by Monty Taylor
Replaced some int10_to_str with to_string. |
603 |
packet->append(buff.c_str(), buff.length()); |
1
by brian
clean slate |
604 |
}
|
605 |
}
|
|
606 |
packet->append(')'); |
|
1014.3.4
by Brian Aker
Remove dead session calls. |
607 |
store_key_options(packet, table, key_info); |
1
by brian
clean slate |
608 |
}
|
609 |
||
610 |
/*
|
|
611 |
Get possible foreign key definitions stored in InnoDB and append them
|
|
612 |
to the CREATE TABLE statement
|
|
613 |
*/
|
|
614 |
||
1208.3.2
by brian
Update for Cursor renaming. |
615 |
if ((for_str= cursor->get_foreign_key_create_info())) |
1
by brian
clean slate |
616 |
{
|
617 |
packet->append(for_str, strlen(for_str)); |
|
1208.3.2
by brian
Update for Cursor renaming. |
618 |
cursor->free_foreign_key_create_info(for_str); |
1
by brian
clean slate |
619 |
}
|
620 |
||
621 |
packet->append(STRING_WITH_LEN("\n)")); |
|
622 |
{
|
|
163
by Brian Aker
Merge Monty's code. |
623 |
show_table_options= true; |
1
by brian
clean slate |
624 |
/*
|
625 |
Get possible table space definitions and append them
|
|
626 |
to the CREATE TABLE statement
|
|
627 |
*/
|
|
628 |
||
1222.1.3
by Brian Aker
Remove used flag for engine. |
629 |
/*
|
630 |
We should always store engine since we will now be
|
|
631 |
making sure engines accept options (aka... no
|
|
632 |
dangling arguments for engines.
|
|
1
by brian
clean slate |
633 |
*/
|
1222.1.3
by Brian Aker
Remove used flag for engine. |
634 |
packet->append(STRING_WITH_LEN(" ENGINE=")); |
635 |
packet->append(cursor->engine->getName().c_str()); |
|
1
by brian
clean slate |
636 |
|
637 |
if (share->db_create_options & HA_OPTION_PACK_KEYS) |
|
638 |
packet->append(STRING_WITH_LEN(" PACK_KEYS=1")); |
|
639 |
if (share->db_create_options & HA_OPTION_NO_PACK_KEYS) |
|
640 |
packet->append(STRING_WITH_LEN(" PACK_KEYS=0")); |
|
641 |
if (create_info.row_type != ROW_TYPE_DEFAULT) |
|
642 |
{
|
|
643 |
packet->append(STRING_WITH_LEN(" ROW_FORMAT=")); |
|
895
by Brian Aker
Completion (?) of uint conversion. |
644 |
packet->append(ha_row_type[(uint32_t) create_info.row_type]); |
1
by brian
clean slate |
645 |
}
|
1188.2.1
by Stewart Smith
move key_block_size out of table_share and into the table proto. init it in parser |
646 |
if (table->s->hasKeyBlockSize()) |
1
by brian
clean slate |
647 |
{
|
648 |
packet->append(STRING_WITH_LEN(" KEY_BLOCK_SIZE=")); |
|
1188.2.1
by Stewart Smith
move key_block_size out of table_share and into the table proto. init it in parser |
649 |
buff= to_string(table->s->getKeyBlockSize()); |
492.1.8
by Monty Taylor
Replaced some int10_to_str with to_string. |
650 |
packet->append(buff.c_str(), buff.length()); |
1
by brian
clean slate |
651 |
}
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
652 |
if (share->block_size) |
653 |
{
|
|
654 |
packet->append(STRING_WITH_LEN(" BLOCK_SIZE=")); |
|
492.1.8
by Monty Taylor
Replaced some int10_to_str with to_string. |
655 |
buff= to_string(share->block_size); |
656 |
packet->append(buff.c_str(), buff.length()); |
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
657 |
}
|
1208.3.2
by brian
Update for Cursor renaming. |
658 |
table->cursor->append_create_info(packet); |
1116.1.1
by Brian Aker
Fix for Stewart's patch (includes hack to solve MAX rows problem). |
659 |
if (share->hasComment() && share->getCommentLength()) |
1
by brian
clean slate |
660 |
{
|
661 |
packet->append(STRING_WITH_LEN(" COMMENT=")); |
|
1116.1.1
by Brian Aker
Fix for Stewart's patch (includes hack to solve MAX rows problem). |
662 |
append_unescaped(packet, share->getComment(), |
663 |
share->getCommentLength()); |
|
1
by brian
clean slate |
664 |
}
|
665 |
}
|
|
1005.2.3
by Monty Taylor
Further reversion of P. |
666 |
table->restore_column_map(old_map); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
667 |
return(0); |
1
by brian
clean slate |
668 |
}
|
669 |
||
1014.3.4
by Brian Aker
Remove dead session calls. |
670 |
static void store_key_options(String *packet, Table *table, KEY *key_info) |
1
by brian
clean slate |
671 |
{
|
672 |
char *end, buff[32]; |
|
673 |
||
674 |
if (key_info->algorithm == HA_KEY_ALG_BTREE) |
|
675 |
packet->append(STRING_WITH_LEN(" USING BTREE")); |
|
676 |
||
677 |
if (key_info->algorithm == HA_KEY_ALG_HASH) |
|
678 |
packet->append(STRING_WITH_LEN(" USING HASH")); |
|
679 |
||
680 |
if ((key_info->flags & HA_USES_BLOCK_SIZE) && |
|
1188.2.1
by Stewart Smith
move key_block_size out of table_share and into the table proto. init it in parser |
681 |
table->s->getKeyBlockSize() != key_info->block_size) |
1
by brian
clean slate |
682 |
{
|
683 |
packet->append(STRING_WITH_LEN(" KEY_BLOCK_SIZE=")); |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
684 |
end= internal::int64_t10_to_str(key_info->block_size, buff, 10); |
895
by Brian Aker
Completion (?) of uint conversion. |
685 |
packet->append(buff, (uint32_t) (end - buff)); |
1
by brian
clean slate |
686 |
}
|
687 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
688 |
assert(test(key_info->flags & HA_USES_COMMENT) == |
1
by brian
clean slate |
689 |
(key_info->comment.length > 0)); |
690 |
if (key_info->flags & HA_USES_COMMENT) |
|
691 |
{
|
|
692 |
packet->append(STRING_WITH_LEN(" COMMENT ")); |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
693 |
append_unescaped(packet, key_info->comment.str, |
1
by brian
clean slate |
694 |
key_info->comment.length); |
695 |
}
|
|
696 |
}
|
|
697 |
||
698 |
||
699 |
/****************************************************************************
|
|
700 |
Return info about all processes
|
|
701 |
returns for each thread: thread id, user, host, db, command, info
|
|
702 |
****************************************************************************/
|
|
703 |
||
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
704 |
class thread_info |
705 |
{
|
|
706 |
thread_info(); |
|
1
by brian
clean slate |
707 |
public: |
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
708 |
uint64_t thread_id; |
1
by brian
clean slate |
709 |
time_t start_time; |
482
by Brian Aker
Remove uint. |
710 |
uint32_t command; |
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
711 |
string user, host, db, proc_info, state_info, query; |
1245.2.7
by Monty Taylor
Merged up with trunk. |
712 |
thread_info(uint64_t thread_id_arg, |
713 |
time_t start_time_arg, |
|
714 |
uint32_t command_arg, |
|
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
715 |
const string &user_arg, |
716 |
const string &host_arg, |
|
717 |
const string &db_arg, |
|
718 |
const string &proc_info_arg, |
|
719 |
const string &state_info_arg, |
|
720 |
const string &query_arg) |
|
721 |
: thread_id(thread_id_arg), start_time(start_time_arg), command(command_arg), |
|
722 |
user(user_arg), host(host_arg), db(db_arg), proc_info(proc_info_arg), |
|
723 |
state_info(state_info_arg), query(query_arg) |
|
724 |
{}
|
|
1
by brian
clean slate |
725 |
};
|
726 |
||
961.1.3
by Brian Aker
Remove additional lock for proceslist. |
727 |
void mysqld_list_processes(Session *session,const char *user, bool) |
1
by brian
clean slate |
728 |
{
|
729 |
Item *field; |
|
730 |
List<Item> field_list; |
|
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
731 |
vector<thread_info> thread_infos; |
1
by brian
clean slate |
732 |
|
733 |
field_list.push_back(new Item_int("Id", 0, MY_INT32_NUM_DECIMAL_DIGITS)); |
|
734 |
field_list.push_back(new Item_empty_string("User",16)); |
|
735 |
field_list.push_back(new Item_empty_string("Host",LIST_PROCESS_HOST_LEN)); |
|
736 |
field_list.push_back(field=new Item_empty_string("db",NAME_CHAR_LEN)); |
|
961.1.3
by Brian Aker
Remove additional lock for proceslist. |
737 |
field->maybe_null= true; |
1
by brian
clean slate |
738 |
field_list.push_back(new Item_empty_string("Command",16)); |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
739 |
field_list.push_back(new Item_return_int("Time",7, DRIZZLE_TYPE_LONG)); |
1
by brian
clean slate |
740 |
field_list.push_back(field=new Item_empty_string("State",30)); |
961.1.3
by Brian Aker
Remove additional lock for proceslist. |
741 |
field->maybe_null= true; |
742 |
field_list.push_back(field=new Item_empty_string("Info", PROCESS_LIST_WIDTH)); |
|
743 |
field->maybe_null= true; |
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
744 |
if (session->client->sendFields(&field_list)) |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
745 |
return; |
1
by brian
clean slate |
746 |
|
398.1.6
by Monty Taylor
Removed __alpha__ references. |
747 |
pthread_mutex_lock(&LOCK_thread_count); // For unlink from list |
520.1.22
by Brian Aker
Second pass of thd cleanup |
748 |
if (!session->killed) |
1
by brian
clean slate |
749 |
{
|
520.1.21
by Brian Aker
THD -> Session rename |
750 |
Session *tmp; |
1241.9.17
by Monty Taylor
Removed more bits from server_includes. |
751 |
for(vector<Session*>::iterator it= getSessionList().begin(); it != getSessionList().end(); ++it) |
1
by brian
clean slate |
752 |
{
|
1014.7.1
by Nathan Williams
Replaced global I_List<Session> with std::vector<Session*> |
753 |
tmp= *it; |
694
by Brian Aker
Refactor out char* strdup for string class in user. |
754 |
Security_context *tmp_sctx= &tmp->security_ctx; |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
755 |
internal::st_my_thread_var *mysys_var; |
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
756 |
if (tmp->client->isConnected() && (!user || (tmp_sctx->user.c_str() && !strcmp(tmp_sctx->user.c_str(), user)))) |
1
by brian
clean slate |
757 |
{
|
758 |
||
759 |
if ((mysys_var= tmp->mysys_var)) |
|
760 |
pthread_mutex_lock(&mysys_var->mutex); |
|
971.3.18
by Eric Day
Finished store() cleanup. |
761 |
|
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
762 |
const string tmp_proc_info((tmp->killed == Session::KILL_CONNECTION) ? "Killed" : command_name[tmp->command].str); |
971.3.18
by Eric Day
Finished store() cleanup. |
763 |
|
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
764 |
const string tmp_state_info(tmp->client->isWriting() |
765 |
? "Writing to net" |
|
766 |
: tmp->client->isReading() |
|
767 |
? (tmp->command == COM_SLEEP |
|
768 |
? "" |
|
769 |
: "Reading from net") |
|
770 |
: tmp->get_proc_info() |
|
771 |
? tmp->get_proc_info() |
|
772 |
: (tmp->mysys_var && tmp->mysys_var->current_cond) |
|
773 |
? "Waiting on cond" |
|
774 |
: ""); |
|
1
by brian
clean slate |
775 |
if (mysys_var) |
776 |
pthread_mutex_unlock(&mysys_var->mutex); |
|
777 |
||
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
778 |
const string tmp_query((tmp->process_list_info[0]) ? tmp->process_list_info : ""); |
779 |
thread_infos.push_back(thread_info(tmp->thread_id, |
|
780 |
tmp->start_time, |
|
781 |
tmp->command, |
|
782 |
tmp_sctx->user.empty() |
|
783 |
? string("unauthenticated user") |
|
784 |
: tmp_sctx->user, |
|
785 |
tmp_sctx->ip, |
|
786 |
tmp->db, |
|
787 |
tmp_proc_info, |
|
788 |
tmp_state_info, |
|
789 |
tmp_query)); |
|
1
by brian
clean slate |
790 |
}
|
791 |
}
|
|
792 |
}
|
|
398.1.6
by Monty Taylor
Removed __alpha__ references. |
793 |
pthread_mutex_unlock(&LOCK_thread_count); |
685.3.4
by Toru Maesaka
Fixed the issues pointed out by Jay's code review |
794 |
time_t now= time(NULL); |
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
795 |
for(vector<thread_info>::iterator iter= thread_infos.begin(); |
796 |
iter != thread_infos.end(); |
|
797 |
++iter) |
|
1
by brian
clean slate |
798 |
{
|
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
799 |
session->client->store((uint64_t) (*iter).thread_id); |
800 |
session->client->store((*iter).user); |
|
801 |
session->client->store((*iter).host); |
|
802 |
session->client->store((*iter).db); |
|
803 |
session->client->store((*iter).proc_info); |
|
971.3.18
by Eric Day
Finished store() cleanup. |
804 |
|
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
805 |
if ((*iter).start_time) |
806 |
session->client->store((uint32_t) (now - (*iter).start_time)); |
|
1
by brian
clean slate |
807 |
else
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
808 |
session->client->store(); |
809 |
||
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
810 |
session->client->store((*iter).state_info); |
811 |
session->client->store((*iter).query); |
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
812 |
|
813 |
if (session->client->flush()) |
|
971.6.11
by Eric Day
Removed purecov messages. |
814 |
break; |
1
by brian
clean slate |
815 |
}
|
836
by Brian Aker
Fixed session call from function to method. |
816 |
session->my_eof(); |
1245.2.1
by Monty Taylor
Removed final use if I_List<> in the server. |
817 |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
818 |
return; |
1
by brian
clean slate |
819 |
}
|
820 |
||
821 |
/*****************************************************************************
|
|
822 |
Status functions
|
|
823 |
*****************************************************************************/
|
|
824 |
||
901.1.3
by Padraig
More work on removing DYNAMIC_ARRAY from show.cc |
825 |
static vector<SHOW_VAR *> all_status_vars; |
1
by brian
clean slate |
826 |
static bool status_vars_inited= 0; |
1165.1.122
by Stewart Smith
make show_var_cmp() static in drizzled/show.cc |
827 |
static int show_var_cmp(const void *var1, const void *var2) |
1
by brian
clean slate |
828 |
{
|
829 |
return strcmp(((SHOW_VAR*)var1)->name, ((SHOW_VAR*)var2)->name); |
|
830 |
}
|
|
831 |
||
901.1.13
by Padraig
Renaming the function object for the std::sort() algorithm. |
832 |
class show_var_cmp_functor |
901.1.9
by Padraig
Modified function object to be used as comparison parameter for sort() |
833 |
{
|
834 |
public: |
|
901.1.13
by Padraig
Renaming the function object for the std::sort() algorithm. |
835 |
show_var_cmp_functor() { } |
901.1.22
by Padraig
Small modifications based on Jay's merge review comments. Should be all good |
836 |
inline bool operator()(const SHOW_VAR *var1, const SHOW_VAR *var2) const |
901.1.9
by Padraig
Modified function object to be used as comparison parameter for sort() |
837 |
{
|
901.1.22
by Padraig
Small modifications based on Jay's merge review comments. Should be all good |
838 |
int val= strcmp(var1->name, var2->name); |
839 |
return (val < 0); |
|
901.1.9
by Padraig
Modified function object to be used as comparison parameter for sort() |
840 |
}
|
841 |
};
|
|
842 |
||
901.1.14
by Padraig
Changing name of functor show_var_if to show_var_remove_if. |
843 |
class show_var_remove_if |
901.1.4
by Padraig
Added function object to be used for removing elements from the vector. This |
844 |
{
|
845 |
public: |
|
901.1.14
by Padraig
Changing name of functor show_var_if to show_var_remove_if. |
846 |
show_var_remove_if() { } |
901.1.22
by Padraig
Small modifications based on Jay's merge review comments. Should be all good |
847 |
inline bool operator()(const SHOW_VAR *curr) const |
901.1.4
by Padraig
Added function object to be used for removing elements from the vector. This |
848 |
{
|
901.1.8
by Padraig
Removed function which has become unused and also added some more comments. |
849 |
return (curr->type == SHOW_UNDEF); |
901.1.4
by Padraig
Added function object to be used for removing elements from the vector. This |
850 |
}
|
851 |
};
|
|
852 |
||
1088.1.1
by Padraig O'Sullivan
Extracted the 3 STATUS tables into the I_S plugin. |
853 |
SHOW_VAR *getFrontOfStatusVars() |
854 |
{
|
|
855 |
return all_status_vars.front(); |
|
856 |
}
|
|
857 |
||
1
by brian
clean slate |
858 |
/*
|
859 |
Adds an array of SHOW_VAR entries to the output of SHOW STATUS
|
|
860 |
||
861 |
SYNOPSIS
|
|
862 |
add_status_vars(SHOW_VAR *list)
|
|
863 |
list - an array of SHOW_VAR entries to add to all_status_vars
|
|
864 |
the last entry must be {0,0,SHOW_UNDEF}
|
|
865 |
||
866 |
NOTE
|
|
867 |
The handling of all_status_vars[] is completely internal, it's allocated
|
|
868 |
automatically when something is added to it, and deleted completely when
|
|
869 |
the last entry is removed.
|
|
870 |
||
871 |
As a special optimization, if add_status_vars() is called before
|
|
872 |
init_status_vars(), it assumes "startup mode" - neither concurrent access
|
|
873 |
to the array nor SHOW STATUS are possible (thus it skips locks and qsort)
|
|
874 |
*/
|
|
875 |
int add_status_vars(SHOW_VAR *list) |
|
876 |
{
|
|
877 |
int res= 0; |
|
878 |
if (status_vars_inited) |
|
879 |
pthread_mutex_lock(&LOCK_status); |
|
880 |
while (list->name) |
|
901.1.22
by Padraig
Small modifications based on Jay's merge review comments. Should be all good |
881 |
all_status_vars.insert(all_status_vars.begin(), list++); |
1
by brian
clean slate |
882 |
if (status_vars_inited) |
901.1.1
by Padraig
Initial work to replace an instance of DYNAMIC_ARRAY in show.cc with STL |
883 |
sort(all_status_vars.begin(), all_status_vars.end(), |
901.1.17
by Padraig
cleaning up comments a little bit. |
884 |
show_var_cmp_functor()); |
1
by brian
clean slate |
885 |
if (status_vars_inited) |
886 |
pthread_mutex_unlock(&LOCK_status); |
|
887 |
return res; |
|
888 |
}
|
|
889 |
||
890 |
/*
|
|
891 |
Make all_status_vars[] usable for SHOW STATUS
|
|
892 |
||
893 |
NOTE
|
|
894 |
See add_status_vars(). Before init_status_vars() call, add_status_vars()
|
|
895 |
works in a special fast "startup" mode. Thus init_status_vars()
|
|
896 |
should be called as late as possible but before enabling multi-threading.
|
|
897 |
*/
|
|
898 |
void init_status_vars() |
|
899 |
{
|
|
901.1.3
by Padraig
More work on removing DYNAMIC_ARRAY from show.cc |
900 |
status_vars_inited= 1; |
901.1.1
by Padraig
Initial work to replace an instance of DYNAMIC_ARRAY in show.cc with STL |
901 |
sort(all_status_vars.begin(), all_status_vars.end(), |
901.1.17
by Padraig
cleaning up comments a little bit. |
902 |
show_var_cmp_functor()); |
1
by brian
clean slate |
903 |
}
|
904 |
||
905 |
void reset_status_vars() |
|
906 |
{
|
|
901.1.3
by Padraig
More work on removing DYNAMIC_ARRAY from show.cc |
907 |
vector<SHOW_VAR *>::iterator p= all_status_vars.begin(); |
901.1.1
by Padraig
Initial work to replace an instance of DYNAMIC_ARRAY in show.cc with STL |
908 |
while (p != all_status_vars.end()) |
1
by brian
clean slate |
909 |
{
|
910 |
/* Note that SHOW_LONG_NOFLUSH variables are not reset */
|
|
901.1.3
by Padraig
More work on removing DYNAMIC_ARRAY from show.cc |
911 |
if ((*p)->type == SHOW_LONG) |
912 |
(*p)->value= 0; |
|
901.1.1
by Padraig
Initial work to replace an instance of DYNAMIC_ARRAY in show.cc with STL |
913 |
++p; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
914 |
}
|
1
by brian
clean slate |
915 |
}
|
916 |
||
917 |
/*
|
|
918 |
catch-all cleanup function, cleans up everything no matter what
|
|
919 |
||
920 |
DESCRIPTION
|
|
921 |
This function is not strictly required if all add_to_status/
|
|
922 |
remove_status_vars are properly paired, but it's a safety measure that
|
|
901.1.17
by Padraig
cleaning up comments a little bit. |
923 |
deletes everything from the all_status_vars vector even if some
|
1
by brian
clean slate |
924 |
remove_status_vars were forgotten
|
925 |
*/
|
|
901.1.3
by Padraig
More work on removing DYNAMIC_ARRAY from show.cc |
926 |
void free_status_vars() |
927 |
{
|
|
901.1.12
by Padraig
Modifying free_status_vars() for std::vector. |
928 |
all_status_vars.clear(); |
901.1.3
by Padraig
More work on removing DYNAMIC_ARRAY from show.cc |
929 |
}
|
1
by brian
clean slate |
930 |
|
931 |
/*
|
|
932 |
Removes an array of SHOW_VAR entries from the output of SHOW STATUS
|
|
933 |
||
934 |
SYNOPSIS
|
|
935 |
remove_status_vars(SHOW_VAR *list)
|
|
936 |
list - an array of SHOW_VAR entries to remove to all_status_vars
|
|
937 |
the last entry must be {0,0,SHOW_UNDEF}
|
|
938 |
||
939 |
NOTE
|
|
940 |
there's lots of room for optimizing this, especially in non-sorted mode,
|
|
941 |
but nobody cares - it may be called only in case of failed plugin
|
|
942 |
initialization in the mysqld startup.
|
|
943 |
*/
|
|
944 |
||
945 |
void remove_status_vars(SHOW_VAR *list) |
|
946 |
{
|
|
947 |
if (status_vars_inited) |
|
948 |
{
|
|
949 |
pthread_mutex_lock(&LOCK_status); |
|
901.1.1
by Padraig
Initial work to replace an instance of DYNAMIC_ARRAY in show.cc with STL |
950 |
SHOW_VAR *all= all_status_vars.front(); |
951 |
int a= 0, b= all_status_vars.size(), c= (a+b)/2; |
|
1
by brian
clean slate |
952 |
|
953 |
for (; list->name; list++) |
|
954 |
{
|
|
955 |
int res= 0; |
|
901.1.1
by Padraig
Initial work to replace an instance of DYNAMIC_ARRAY in show.cc with STL |
956 |
for (a= 0, b= all_status_vars.size(); b-a > 1; c= (a+b)/2) |
1
by brian
clean slate |
957 |
{
|
958 |
res= show_var_cmp(list, all+c); |
|
959 |
if (res < 0) |
|
960 |
b= c; |
|
961 |
else if (res > 0) |
|
962 |
a= c; |
|
963 |
else
|
|
964 |
break; |
|
965 |
}
|
|
966 |
if (res == 0) |
|
967 |
all[c].type= SHOW_UNDEF; |
|
968 |
}
|
|
901.1.8
by Padraig
Removed function which has become unused and also added some more comments. |
969 |
/* removes all the SHOW_UNDEF elements from the vector */
|
901.1.18
by Padraig
Adding std:: prefix to remove_if since that caused compilation errors on |
970 |
all_status_vars.erase(std::remove_if(all_status_vars.begin(), |
901.1.14
by Padraig
Changing name of functor show_var_if to show_var_remove_if. |
971 |
all_status_vars.end(),show_var_remove_if()), |
901.1.4
by Padraig
Added function object to be used for removing elements from the vector. This |
972 |
all_status_vars.end()); |
1
by brian
clean slate |
973 |
pthread_mutex_unlock(&LOCK_status); |
974 |
}
|
|
975 |
else
|
|
976 |
{
|
|
901.1.1
by Padraig
Initial work to replace an instance of DYNAMIC_ARRAY in show.cc with STL |
977 |
SHOW_VAR *all= all_status_vars.front(); |
482
by Brian Aker
Remove uint. |
978 |
uint32_t i; |
1
by brian
clean slate |
979 |
for (; list->name; list++) |
980 |
{
|
|
901.1.1
by Padraig
Initial work to replace an instance of DYNAMIC_ARRAY in show.cc with STL |
981 |
for (i= 0; i < all_status_vars.size(); i++) |
1
by brian
clean slate |
982 |
{
|
983 |
if (show_var_cmp(list, all+i)) |
|
984 |
continue; |
|
985 |
all[i].type= SHOW_UNDEF; |
|
986 |
break; |
|
987 |
}
|
|
988 |
}
|
|
901.1.8
by Padraig
Removed function which has become unused and also added some more comments. |
989 |
/* removes all the SHOW_UNDEF elements from the vector */
|
901.1.18
by Padraig
Adding std:: prefix to remove_if since that caused compilation errors on |
990 |
all_status_vars.erase(std::remove_if(all_status_vars.begin(), |
901.1.14
by Padraig
Changing name of functor show_var_if to show_var_remove_if. |
991 |
all_status_vars.end(),show_var_remove_if()), |
901.1.4
by Padraig
Added function object to be used for removing elements from the vector. This |
992 |
all_status_vars.end()); |
1
by brian
clean slate |
993 |
}
|
994 |
}
|
|
995 |
||
996 |
/* collect status for all running threads */
|
|
997 |
||
998 |
void calc_sum_of_all_status(STATUS_VAR *to) |
|
999 |
{
|
|
1000 |
/* Ensure that thread id not killed during loop */
|
|
398.1.6
by Monty Taylor
Removed __alpha__ references. |
1001 |
pthread_mutex_lock(&LOCK_thread_count); // For unlink from list |
1
by brian
clean slate |
1002 |
|
1003 |
/* Get global values as base */
|
|
1004 |
*to= global_status_var; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1005 |
|
1
by brian
clean slate |
1006 |
/* Add to this status from existing threads */
|
1241.9.17
by Monty Taylor
Removed more bits from server_includes. |
1007 |
for(vector<Session*>::iterator it= getSessionList().begin(); it != getSessionList().end(); ++it ) |
1014.7.1
by Nathan Williams
Replaced global I_List<Session> with std::vector<Session*> |
1008 |
{
|
1009 |
add_to_status(to, &((*it)->status_var)); |
|
1010 |
}
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1011 |
|
398.1.6
by Monty Taylor
Removed __alpha__ references. |
1012 |
pthread_mutex_unlock(&LOCK_thread_count); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
1013 |
return; |
1
by brian
clean slate |
1014 |
}
|
1015 |
||
1016 |
||
1085.1.2
by Monty Taylor
Fixed -Wmissing-declarations |
1017 |
static int make_table_list(Session *session, Select_Lex *sel, |
1018 |
LEX_STRING *db_name, LEX_STRING *table_name) |
|
1
by brian
clean slate |
1019 |
{
|
1020 |
Table_ident *table_ident; |
|
971.3.59
by Eric Day
Removed client_capabilities from session and pushed functionality into protocol plugin. |
1021 |
table_ident= new Table_ident(*db_name, *table_name); |
1
by brian
clean slate |
1022 |
sel->init_query(); |
971.3.70
by Eric Day
Fixed style issues found by Jay. |
1023 |
if (! sel->add_table_to_list(session, table_ident, 0, 0, TL_READ)) |
1
by brian
clean slate |
1024 |
return 1; |
1025 |
return 0; |
|
1026 |
}
|
|
1027 |
||
1028 |
||
1029 |
/**
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1030 |
@brief Get lookup value from the part of 'WHERE' condition
|
1
by brian
clean slate |
1031 |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1032 |
@details This function gets lookup value from
|
1033 |
the part of 'WHERE' condition if it's possible and
|
|
1
by brian
clean slate |
1034 |
fill appropriate lookup_field_vals struct field
|
1035 |
with this value.
|
|
1036 |
||
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
1037 |
@param[in] session thread Cursor
|
1
by brian
clean slate |
1038 |
@param[in] item_func part of WHERE condition
|
1039 |
@param[in] table I_S table
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1040 |
@param[in, out] lookup_field_vals Struct which holds lookup values
|
1
by brian
clean slate |
1041 |
|
1042 |
@return
|
|
1043 |
0 success
|
|
1044 |
1 error, there can be no matching records for the condition
|
|
1045 |
*/
|
|
1046 |
||
1085.1.2
by Monty Taylor
Fixed -Wmissing-declarations |
1047 |
static bool get_lookup_value(Session *session, Item_func *item_func, |
1048 |
TableList *table, |
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1049 |
LOOKUP_FIELD_VALUES *lookup_field_vals, |
1050 |
plugin::InfoSchemaTable *schema_table) |
|
1
by brian
clean slate |
1051 |
{
|
1063.4.10
by Padraig O'Sullivan
Changing name of FieldInfo class to ColumnInfo based on some feedback from |
1052 |
const char *field_name1= schema_table->getFirstColumnIndex() >= 0 ? |
1076.2.1
by Padraig O'Sullivan
Converted the const char * members of ColumnInfo to be std::string instead. |
1053 |
schema_table->getColumnName(schema_table->getFirstColumnIndex()).c_str() : ""; |
1063.4.10
by Padraig O'Sullivan
Changing name of FieldInfo class to ColumnInfo based on some feedback from |
1054 |
const char *field_name2= schema_table->getSecondColumnIndex() >= 0 ? |
1076.2.1
by Padraig O'Sullivan
Converted the const char * members of ColumnInfo to be std::string instead. |
1055 |
schema_table->getColumnName(schema_table->getSecondColumnIndex()).c_str() : ""; |
1
by brian
clean slate |
1056 |
|
1057 |
if (item_func->functype() == Item_func::EQ_FUNC || |
|
1058 |
item_func->functype() == Item_func::EQUAL_FUNC) |
|
1059 |
{
|
|
1060 |
int idx_field, idx_val; |
|
1061 |
char tmp[MAX_FIELD_WIDTH]; |
|
1062 |
String *tmp_str, str_buff(tmp, sizeof(tmp), system_charset_info); |
|
1063 |
Item_field *item_field; |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1064 |
const CHARSET_INFO * const cs= system_charset_info; |
1
by brian
clean slate |
1065 |
|
1066 |
if (item_func->arguments()[0]->type() == Item::FIELD_ITEM && |
|
1067 |
item_func->arguments()[1]->const_item()) |
|
1068 |
{
|
|
1069 |
idx_field= 0; |
|
1070 |
idx_val= 1; |
|
1071 |
}
|
|
1072 |
else if (item_func->arguments()[1]->type() == Item::FIELD_ITEM && |
|
1073 |
item_func->arguments()[0]->const_item()) |
|
1074 |
{
|
|
1075 |
idx_field= 1; |
|
1076 |
idx_val= 0; |
|
1077 |
}
|
|
1078 |
else
|
|
1079 |
return 0; |
|
1080 |
||
1081 |
item_field= (Item_field*) item_func->arguments()[idx_field]; |
|
1082 |
if (table->table != item_field->field->table) |
|
1083 |
return 0; |
|
1084 |
tmp_str= item_func->arguments()[idx_val]->val_str(&str_buff); |
|
1085 |
||
1086 |
/* impossible value */
|
|
1087 |
if (!tmp_str) |
|
1088 |
return 1; |
|
1089 |
||
1090 |
/* Lookup value is database name */
|
|
481
by Brian Aker
Remove all of uchar. |
1091 |
if (!cs->coll->strnncollsp(cs, (unsigned char *) field_name1, strlen(field_name1), |
1092 |
(unsigned char *) item_field->field_name, |
|
1
by brian
clean slate |
1093 |
strlen(item_field->field_name), 0)) |
1094 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1095 |
session->make_lex_string(&lookup_field_vals->db_value, tmp_str->ptr(), |
163
by Brian Aker
Merge Monty's code. |
1096 |
tmp_str->length(), false); |
1
by brian
clean slate |
1097 |
}
|
1098 |
/* Lookup value is table name */
|
|
481
by Brian Aker
Remove all of uchar. |
1099 |
else if (!cs->coll->strnncollsp(cs, (unsigned char *) field_name2, |
1
by brian
clean slate |
1100 |
strlen(field_name2), |
481
by Brian Aker
Remove all of uchar. |
1101 |
(unsigned char *) item_field->field_name, |
1
by brian
clean slate |
1102 |
strlen(item_field->field_name), 0)) |
1103 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1104 |
session->make_lex_string(&lookup_field_vals->table_value, tmp_str->ptr(), |
163
by Brian Aker
Merge Monty's code. |
1105 |
tmp_str->length(), false); |
1
by brian
clean slate |
1106 |
}
|
1107 |
}
|
|
1108 |
return 0; |
|
1109 |
}
|
|
1110 |
||
1111 |
||
1112 |
/**
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1113 |
@brief Calculates lookup values from 'WHERE' condition
|
1
by brian
clean slate |
1114 |
|
1115 |
@details This function calculates lookup value(database name, table name)
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1116 |
from 'WHERE' condition if it's possible and
|
1
by brian
clean slate |
1117 |
fill lookup_field_vals struct fields with these values.
|
1118 |
||
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
1119 |
@param[in] session thread Cursor
|
1
by brian
clean slate |
1120 |
@param[in] cond WHERE condition
|
1121 |
@param[in] table I_S table
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1122 |
@param[in, out] lookup_field_vals Struct which holds lookup values
|
1
by brian
clean slate |
1123 |
|
1124 |
@return
|
|
1125 |
0 success
|
|
1126 |
1 error, there can be no matching records for the condition
|
|
1127 |
*/
|
|
1128 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1129 |
bool calc_lookup_values_from_cond(Session *session, COND *cond, TableList *table, |
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1130 |
LOOKUP_FIELD_VALUES *lookup_field_vals, |
1131 |
plugin::InfoSchemaTable *schema_table) |
|
1
by brian
clean slate |
1132 |
{
|
1133 |
if (!cond) |
|
1134 |
return 0; |
|
1135 |
||
1136 |
if (cond->type() == Item::COND_ITEM) |
|
1137 |
{
|
|
1138 |
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC) |
|
1139 |
{
|
|
1140 |
List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); |
|
1141 |
Item *item; |
|
1142 |
while ((item= li++)) |
|
1143 |
{
|
|
1144 |
if (item->type() == Item::FUNC_ITEM) |
|
1145 |
{
|
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1146 |
if (get_lookup_value(session, (Item_func*)item, table, lookup_field_vals, schema_table)) |
1
by brian
clean slate |
1147 |
return 1; |
1148 |
}
|
|
1149 |
else
|
|
1150 |
{
|
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1151 |
if (calc_lookup_values_from_cond(session, item, table, lookup_field_vals, schema_table)) |
1
by brian
clean slate |
1152 |
return 1; |
1153 |
}
|
|
1154 |
}
|
|
1155 |
}
|
|
1156 |
return 0; |
|
1157 |
}
|
|
1158 |
else if (cond->type() == Item::FUNC_ITEM && |
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1159 |
get_lookup_value(session, (Item_func*) cond, table, lookup_field_vals, schema_table)) |
1
by brian
clean slate |
1160 |
return 1; |
1161 |
return 0; |
|
1162 |
}
|
|
1163 |
||
1164 |
||
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1165 |
static bool uses_only_table_name_fields(Item *item, Table *table, plugin::InfoSchemaTable *schema_table) |
1
by brian
clean slate |
1166 |
{
|
1167 |
if (item->type() == Item::FUNC_ITEM) |
|
1168 |
{
|
|
1169 |
Item_func *item_func= (Item_func*)item; |
|
482
by Brian Aker
Remove uint. |
1170 |
for (uint32_t i=0; i<item_func->argument_count(); i++) |
1
by brian
clean slate |
1171 |
{
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1172 |
if (! uses_only_table_name_fields(item_func->arguments()[i], table, schema_table)) |
1
by brian
clean slate |
1173 |
return 0; |
1174 |
}
|
|
1175 |
}
|
|
1176 |
else if (item->type() == Item::FIELD_ITEM) |
|
1177 |
{
|
|
1178 |
Item_field *item_field= (Item_field*)item; |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1179 |
const CHARSET_INFO * const cs= system_charset_info; |
1063.4.10
by Padraig O'Sullivan
Changing name of FieldInfo class to ColumnInfo based on some feedback from |
1180 |
const char *field_name1= schema_table->getFirstColumnIndex() >= 0 ? |
1076.2.1
by Padraig O'Sullivan
Converted the const char * members of ColumnInfo to be std::string instead. |
1181 |
schema_table->getColumnName(schema_table->getFirstColumnIndex()).c_str() : ""; |
1063.4.10
by Padraig O'Sullivan
Changing name of FieldInfo class to ColumnInfo based on some feedback from |
1182 |
const char *field_name2= schema_table->getSecondColumnIndex() >= 0 ? |
1076.2.1
by Padraig O'Sullivan
Converted the const char * members of ColumnInfo to be std::string instead. |
1183 |
schema_table->getColumnName(schema_table->getSecondColumnIndex()).c_str() : ""; |
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1184 |
if (table != item_field->field->table || |
481
by Brian Aker
Remove all of uchar. |
1185 |
(cs->coll->strnncollsp(cs, (unsigned char *) field_name1, strlen(field_name1), |
1186 |
(unsigned char *) item_field->field_name, |
|
1
by brian
clean slate |
1187 |
strlen(item_field->field_name), 0) && |
481
by Brian Aker
Remove all of uchar. |
1188 |
cs->coll->strnncollsp(cs, (unsigned char *) field_name2, strlen(field_name2), |
1189 |
(unsigned char *) item_field->field_name, |
|
1
by brian
clean slate |
1190 |
strlen(item_field->field_name), 0))) |
1191 |
return 0; |
|
1192 |
}
|
|
1193 |
else if (item->type() == Item::REF_ITEM) |
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1194 |
return uses_only_table_name_fields(item->real_item(), table, schema_table); |
1
by brian
clean slate |
1195 |
|
1196 |
if (item->type() == Item::SUBSELECT_ITEM && !item->const_item()) |
|
1197 |
return 0; |
|
1198 |
||
1199 |
return 1; |
|
1200 |
}
|
|
1201 |
||
1202 |
||
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1203 |
static COND * make_cond_for_info_schema(COND *cond, Table *table, plugin::InfoSchemaTable *schema_table) |
1
by brian
clean slate |
1204 |
{
|
1205 |
if (!cond) |
|
1206 |
return (COND*) 0; |
|
1207 |
if (cond->type() == Item::COND_ITEM) |
|
1208 |
{
|
|
1209 |
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC) |
|
1210 |
{
|
|
1211 |
/* Create new top level AND item */
|
|
1212 |
Item_cond_and *new_cond=new Item_cond_and; |
|
1213 |
if (!new_cond) |
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1214 |
return (COND*) 0; |
1
by brian
clean slate |
1215 |
List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); |
1216 |
Item *item; |
|
1217 |
while ((item=li++)) |
|
1218 |
{
|
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1219 |
Item *fix= make_cond_for_info_schema(item, table, schema_table); |
1220 |
if (fix) |
|
1221 |
new_cond->argument_list()->push_back(fix); |
|
1
by brian
clean slate |
1222 |
}
|
1223 |
switch (new_cond->argument_list()->elements) { |
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1224 |
case 0: |
1225 |
return (COND*) 0; |
|
1226 |
case 1: |
|
1227 |
return new_cond->argument_list()->head(); |
|
1228 |
default: |
|
1229 |
new_cond->quick_fix_field(); |
|
1230 |
return new_cond; |
|
1
by brian
clean slate |
1231 |
}
|
1232 |
}
|
|
1233 |
else
|
|
1234 |
{ // Or list |
|
1235 |
Item_cond_or *new_cond=new Item_cond_or; |
|
1236 |
if (!new_cond) |
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1237 |
return (COND*) 0; |
1
by brian
clean slate |
1238 |
List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); |
1239 |
Item *item; |
|
1240 |
while ((item=li++)) |
|
1241 |
{
|
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1242 |
Item *fix=make_cond_for_info_schema(item, table, schema_table); |
1243 |
if (!fix) |
|
1244 |
return (COND*) 0; |
|
1245 |
new_cond->argument_list()->push_back(fix); |
|
1
by brian
clean slate |
1246 |
}
|
1247 |
new_cond->quick_fix_field(); |
|
1248 |
new_cond->top_level_item(); |
|
1249 |
return new_cond; |
|
1250 |
}
|
|
1251 |
}
|
|
1252 |
||
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1253 |
if (! uses_only_table_name_fields(cond, table, schema_table)) |
1
by brian
clean slate |
1254 |
return (COND*) 0; |
1255 |
return cond; |
|
1256 |
}
|
|
1257 |
||
1258 |
||
1259 |
/**
|
|
1260 |
@brief Calculate lookup values(database name, table name)
|
|
1261 |
||
1262 |
@details This function calculates lookup values(database name, table name)
|
|
1263 |
from 'WHERE' condition or wild values (for 'SHOW' commands only)
|
|
1264 |
from LEX struct and fill lookup_field_vals struct field
|
|
1265 |
with these values.
|
|
1266 |
||
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
1267 |
@param[in] session thread Cursor
|
1
by brian
clean slate |
1268 |
@param[in] cond WHERE condition
|
1269 |
@param[in] tables I_S table
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1270 |
@param[in, out] lookup_field_values Struct which holds lookup values
|
1
by brian
clean slate |
1271 |
|
1272 |
@return
|
|
1273 |
0 success
|
|
1274 |
1 error, there can be no matching records for the condition
|
|
1275 |
*/
|
|
1276 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1277 |
bool get_lookup_field_values(Session *session, COND *cond, TableList *tables, |
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1278 |
LOOKUP_FIELD_VALUES *lookup_field_values, |
1279 |
plugin::InfoSchemaTable *schema_table) |
|
1
by brian
clean slate |
1280 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1281 |
LEX *lex= session->lex; |
461
by Monty Taylor
Removed NullS. bu-bye. |
1282 |
const char *wild= lex->wild ? lex->wild->ptr() : NULL; |
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
1283 |
memset(lookup_field_values, 0, sizeof(LOOKUP_FIELD_VALUES)); |
1
by brian
clean slate |
1284 |
switch (lex->sql_command) { |
1285 |
case SQLCOM_SHOW_DATABASES: |
|
1286 |
if (wild) |
|
1287 |
{
|
|
1288 |
lookup_field_values->db_value.str= (char*) wild; |
|
1289 |
lookup_field_values->db_value.length= strlen(wild); |
|
1290 |
lookup_field_values->wild_db_value= 1; |
|
1291 |
}
|
|
1292 |
return 0; |
|
1293 |
case SQLCOM_SHOW_TABLES: |
|
1294 |
case SQLCOM_SHOW_TABLE_STATUS: |
|
1295 |
lookup_field_values->db_value.str= lex->select_lex.db; |
|
1296 |
lookup_field_values->db_value.length=strlen(lex->select_lex.db); |
|
1297 |
if (wild) |
|
1298 |
{
|
|
1299 |
lookup_field_values->table_value.str= (char*)wild; |
|
1300 |
lookup_field_values->table_value.length= strlen(wild); |
|
1301 |
lookup_field_values->wild_table_value= 1; |
|
1302 |
}
|
|
1303 |
return 0; |
|
1304 |
default: |
|
1305 |
/*
|
|
1306 |
The "default" is for queries over I_S.
|
|
1307 |
All previous cases handle SHOW commands.
|
|
1308 |
*/
|
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1309 |
return calc_lookup_values_from_cond(session, cond, tables, lookup_field_values, schema_table); |
1
by brian
clean slate |
1310 |
}
|
1311 |
}
|
|
1312 |
||
1313 |
||
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1314 |
/**
|
1108.4.6
by David Shrewsbury
Fix to make sure make_db_list gets the directory entries in sorted order, with I_S first. |
1315 |
* Function used for sorting with std::sort within make_db_list.
|
1316 |
*
|
|
1317 |
* @returns true if a < b, false otherwise
|
|
1318 |
*/
|
|
1319 |
||
1320 |
static bool lex_string_sort(const LEX_STRING *a, const LEX_STRING *b) |
|
1321 |
{
|
|
1322 |
return (strcmp(a->str, b->str) < 0); |
|
1323 |
}
|
|
1324 |
||
1325 |
||
1326 |
/**
|
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1327 |
* @brief
|
1328 |
* Create db names list. Information schema name always is first in list
|
|
1329 |
*
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
1330 |
* @param[in] session Thread Cursor
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1331 |
* @param[out] files List of db names
|
1332 |
* @param[in] wild Wild string
|
|
1333 |
* @param[in] idx_field_vals idx_field_vals->db_name contains db name or
|
|
1334 |
* wild string
|
|
1335 |
* @param[out] with_i_schema Returns 1 if we added 'IS' name to list
|
|
1336 |
* otherwise returns 0
|
|
1337 |
*
|
|
1338 |
* @retval 0 Success
|
|
1339 |
* @retval 1 Error
|
|
1340 |
*/
|
|
1071.1.3
by Nathan Williams
Removed st_add_schema_table struct and moved data members into the AddSchemaTable class/functor. That was the only place it was used. |
1341 |
int make_db_list(Session *session, vector<LEX_STRING*> &files, |
1
by brian
clean slate |
1342 |
LOOKUP_FIELD_VALUES *lookup_field_vals, |
1343 |
bool *with_i_schema) |
|
1344 |
{
|
|
1345 |
LEX_STRING *i_s_name_copy= 0; |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1346 |
i_s_name_copy= session->make_lex_string(i_s_name_copy, |
575.4.7
by Monty Taylor
More header cleanup. |
1347 |
INFORMATION_SCHEMA_NAME.c_str(), |
1348 |
INFORMATION_SCHEMA_NAME.length(), true); |
|
1
by brian
clean slate |
1349 |
*with_i_schema= 0; |
1350 |
if (lookup_field_vals->wild_db_value) |
|
1351 |
{
|
|
1352 |
/*
|
|
1353 |
This part of code is only for SHOW DATABASES command.
|
|
1354 |
idx_field_vals->db_value can be 0 when we don't use
|
|
1355 |
LIKE clause (see also get_index_field_values() function)
|
|
1356 |
*/
|
|
1357 |
if (!lookup_field_vals->db_value.str || |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1358 |
!wild_case_compare(system_charset_info, |
575.4.7
by Monty Taylor
More header cleanup. |
1359 |
INFORMATION_SCHEMA_NAME.c_str(), |
1
by brian
clean slate |
1360 |
lookup_field_vals->db_value.str)) |
1361 |
{
|
|
1362 |
*with_i_schema= 1; |
|
1071.1.3
by Nathan Williams
Removed st_add_schema_table struct and moved data members into the AddSchemaTable class/functor. That was the only place it was used. |
1363 |
files.push_back(i_s_name_copy); |
1
by brian
clean slate |
1364 |
}
|
1108.4.6
by David Shrewsbury
Fix to make sure make_db_list gets the directory entries in sorted order, with I_S first. |
1365 |
|
1366 |
if (find_schemas(session, files, drizzle_data_home, |
|
1367 |
lookup_field_vals->db_value.str) == true) |
|
1368 |
{
|
|
1093.1.47
by Jay Pipes
Merge David's my_dir_removal |
1369 |
return 1; |
1108.4.6
by David Shrewsbury
Fix to make sure make_db_list gets the directory entries in sorted order, with I_S first. |
1370 |
}
|
1371 |
||
1372 |
sort(files.begin()+1, files.end(), lex_string_sort); |
|
1093.1.47
by Jay Pipes
Merge David's my_dir_removal |
1373 |
return 0; |
1
by brian
clean slate |
1374 |
}
|
1375 |
||
1376 |
||
1377 |
/*
|
|
1378 |
If we have db lookup vaule we just add it to list and
|
|
1379 |
exit from the function
|
|
1380 |
*/
|
|
1381 |
if (lookup_field_vals->db_value.str) |
|
1382 |
{
|
|
575.4.7
by Monty Taylor
More header cleanup. |
1383 |
if (!my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.c_str(), |
1
by brian
clean slate |
1384 |
lookup_field_vals->db_value.str)) |
1385 |
{
|
|
1386 |
*with_i_schema= 1; |
|
1071.1.3
by Nathan Williams
Removed st_add_schema_table struct and moved data members into the AddSchemaTable class/functor. That was the only place it was used. |
1387 |
files.push_back(i_s_name_copy); |
1
by brian
clean slate |
1388 |
return 0; |
1389 |
}
|
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1390 |
|
1071.1.3
by Nathan Williams
Removed st_add_schema_table struct and moved data members into the AddSchemaTable class/functor. That was the only place it was used. |
1391 |
files.push_back(&lookup_field_vals->db_value); |
1
by brian
clean slate |
1392 |
return 0; |
1393 |
}
|
|
1394 |
||
1395 |
/*
|
|
1396 |
Create list of existing databases. It is used in case
|
|
1397 |
of select from information schema table
|
|
1398 |
*/
|
|
1071.1.3
by Nathan Williams
Removed st_add_schema_table struct and moved data members into the AddSchemaTable class/functor. That was the only place it was used. |
1399 |
files.push_back(i_s_name_copy); |
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1400 |
|
1
by brian
clean slate |
1401 |
*with_i_schema= 1; |
1108.4.6
by David Shrewsbury
Fix to make sure make_db_list gets the directory entries in sorted order, with I_S first. |
1402 |
|
1403 |
if (find_schemas(session, files, drizzle_data_home, NULL) == true) |
|
1404 |
{
|
|
1093.1.47
by Jay Pipes
Merge David's my_dir_removal |
1405 |
return 1; |
1108.4.6
by David Shrewsbury
Fix to make sure make_db_list gets the directory entries in sorted order, with I_S first. |
1406 |
}
|
1407 |
||
1408 |
sort(files.begin()+1, files.end(), lex_string_sort); |
|
1093.1.47
by Jay Pipes
Merge David's my_dir_removal |
1409 |
return 0; |
1
by brian
clean slate |
1410 |
}
|
1411 |
||
1412 |
||
1413 |
/**
|
|
1414 |
@brief Create table names list
|
|
1415 |
||
1416 |
@details The function creates the list of table names in
|
|
1417 |
database
|
|
1418 |
||
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
1419 |
@param[in] session thread Cursor
|
1
by brian
clean slate |
1420 |
@param[in] table_names List of table names in database
|
1421 |
@param[in] lex pointer to LEX struct
|
|
1422 |
@param[in] lookup_field_vals pointer to LOOKUP_FIELD_VALUE struct
|
|
163
by Brian Aker
Merge Monty's code. |
1423 |
@param[in] with_i_schema true means that we add I_S tables to list
|
1
by brian
clean slate |
1424 |
@param[in] db_name database name
|
1425 |
||
1426 |
@return Operation status
|
|
1427 |
@retval 0 ok
|
|
1428 |
@retval 1 fatal error
|
|
1208.3.2
by brian
Update for Cursor renaming. |
1429 |
@retval 2 Not fatal error; Safe to ignore this cursor list
|
1
by brian
clean slate |
1430 |
*/
|
1431 |
||
1432 |
static int |
|
1183.1.5
by Brian Aker
Reworked getTableNames() interface. Way simpler, less mallocs.... |
1433 |
make_table_name_list(Session *session, vector<LEX_STRING*> &table_names, |
1
by brian
clean slate |
1434 |
LOOKUP_FIELD_VALUES *lookup_field_vals, |
1435 |
bool with_i_schema, LEX_STRING *db_name) |
|
1436 |
{
|
|
1437 |
char path[FN_REFLEN]; |
|
1183.1.5
by Brian Aker
Reworked getTableNames() interface. Way simpler, less mallocs.... |
1438 |
set<string> set_of_names; |
1160.1.1
by Brian Aker
Refactor SE createTable back to engine class. |
1439 |
|
1039.1.6
by Brian Aker
Refactor for build_table_filename() |
1440 |
build_table_filename(path, sizeof(path), db_name->str, "", false); |
1183.1.15
by Brian Aker
I_S now provides its own tables via the SE interface |
1441 |
|
1
by brian
clean slate |
1442 |
if (!lookup_field_vals->wild_table_value && |
1443 |
lookup_field_vals->table_value.str) |
|
1444 |
{
|
|
1445 |
if (with_i_schema) |
|
1446 |
{
|
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
1447 |
if (plugin::InfoSchemaTable::getTable(lookup_field_vals->table_value.str)) |
1
by brian
clean slate |
1448 |
{
|
1071.1.3
by Nathan Williams
Removed st_add_schema_table struct and moved data members into the AddSchemaTable class/functor. That was the only place it was used. |
1449 |
table_names.push_back(&lookup_field_vals->table_value); |
1
by brian
clean slate |
1450 |
}
|
1451 |
}
|
|
1452 |
else
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1453 |
{
|
1071.1.3
by Nathan Williams
Removed st_add_schema_table struct and moved data members into the AddSchemaTable class/functor. That was the only place it was used. |
1454 |
table_names.push_back(&lookup_field_vals->table_value); |
1
by brian
clean slate |
1455 |
}
|
1456 |
return 0; |
|
1457 |
}
|
|
1458 |
||
1095.3.20
by Stewart Smith
start using an iterator like object for traversing tables in a database (SHOW TABLES) |
1459 |
string db(db_name->str); |
1183.1.5
by Brian Aker
Reworked getTableNames() interface. Way simpler, less mallocs.... |
1460 |
plugin::StorageEngine::getTableNames(db, set_of_names); |
1461 |
||
1462 |
/*
|
|
1463 |
New I_S engine will make this go away, so ignore lack of foreach() usage.
|
|
1464 |
||
1465 |
Notice how bad this design is... sure we created a set... but then we
|
|
1466 |
are just pushing to another set. --
|
|
1467 |
Also... callback design won't work, so we need to rewrite this to
|
|
1468 |
feed (which means new I_S). For the moment we will not optimize this.
|
|
1469 |
||
1470 |
*/
|
|
1471 |
for (set<string>::iterator it= set_of_names.begin(); it != set_of_names.end(); it++) |
|
1095.3.20
by Stewart Smith
start using an iterator like object for traversing tables in a database (SHOW TABLES) |
1472 |
{
|
1183.1.5
by Brian Aker
Reworked getTableNames() interface. Way simpler, less mallocs.... |
1473 |
LEX_STRING *file_name= NULL; |
1474 |
||
1475 |
file_name= session->make_lex_string(file_name, (*it).c_str(), |
|
1476 |
(*it).length(), true); |
|
1477 |
const char* wild= lookup_field_vals->table_value.str; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1478 |
if (wild && internal::wild_compare((*it).c_str(), wild, 0)) |
1183.1.5
by Brian Aker
Reworked getTableNames() interface. Way simpler, less mallocs.... |
1479 |
continue; |
1183.1.15
by Brian Aker
I_S now provides its own tables via the SE interface |
1480 |
|
1183.1.5
by Brian Aker
Reworked getTableNames() interface. Way simpler, less mallocs.... |
1481 |
table_names.push_back(file_name); |
1
by brian
clean slate |
1482 |
}
|
1095.3.20
by Stewart Smith
start using an iterator like object for traversing tables in a database (SHOW TABLES) |
1483 |
|
1
by brian
clean slate |
1484 |
return 0; |
1485 |
}
|
|
1486 |
||
1487 |
||
1488 |
/**
|
|
1489 |
@brief Fill I_S table for SHOW COLUMNS|INDEX commands
|
|
1490 |
||
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
1491 |
@param[in] session thread Cursor
|
327.2.4
by Brian Aker
Refactoring table.h |
1492 |
@param[in] tables TableList for I_S table
|
1
by brian
clean slate |
1493 |
@param[in] schema_table pointer to I_S structure
|
1494 |
@param[in] open_tables_state_backup pointer to Open_tables_state object
|
|
1495 |
which is used to save|restore original
|
|
1496 |
status of variables related to
|
|
1497 |
open tables state
|
|
1498 |
||
1499 |
@return Operation status
|
|
1500 |
@retval 0 success
|
|
1501 |
@retval 1 error
|
|
1502 |
*/
|
|
1503 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1504 |
static int |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1505 |
fill_schema_show_cols_or_idxs(Session *session, TableList *tables, |
1130.1.7
by Monty Taylor
Renamed plugin::InfoSchema to plugin::InfoSchemaTable as per Jay. |
1506 |
plugin::InfoSchemaTable *schema_table, |
1
by brian
clean slate |
1507 |
Open_tables_state *open_tables_state_backup) |
1508 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1509 |
LEX *lex= session->lex; |
1
by brian
clean slate |
1510 |
bool res; |
1511 |
LEX_STRING tmp_lex_string, tmp_lex_string1, *db_name, *table_name; |
|
1512 |
enum_sql_command save_sql_command= lex->sql_command; |
|
327.2.4
by Brian Aker
Refactoring table.h |
1513 |
TableList *show_table_list= (TableList*) tables->schema_select_lex-> |
1
by brian
clean slate |
1514 |
table_list.first; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
1515 |
Table *table= tables->table; |
1
by brian
clean slate |
1516 |
int error= 1; |
1517 |
||
1518 |
lex->all_selects_list= tables->schema_select_lex; |
|
1519 |
/*
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1520 |
Restore session->temporary_tables to be able to process
|
1
by brian
clean slate |
1521 |
temporary tables(only for 'show index' & 'show columns').
|
1522 |
This should be changed when processing of temporary tables for
|
|
1523 |
I_S tables will be done.
|
|
1524 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1525 |
session->temporary_tables= open_tables_state_backup->temporary_tables; |
1
by brian
clean slate |
1526 |
/*
|
1527 |
Let us set fake sql_command so views won't try to merge
|
|
1528 |
themselves into main statement. If we don't do this,
|
|
1529 |
SELECT * from information_schema.xxxx will cause problems.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1530 |
SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()'
|
1
by brian
clean slate |
1531 |
*/
|
1532 |
lex->sql_command= SQLCOM_SHOW_FIELDS; |
|
1109.1.3
by Brian Aker
Move names around a bit (to align similar methods) |
1533 |
res= session->openTables(show_table_list, DRIZZLE_LOCK_IGNORE_FLUSH); |
1
by brian
clean slate |
1534 |
lex->sql_command= save_sql_command; |
1535 |
/*
|
|
1536 |
get_all_tables() returns 1 on failure and 0 on success thus
|
|
1537 |
return only these and not the result code of ::process_table()
|
|
1538 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1539 |
We should use show_table_list->alias instead of
|
1
by brian
clean slate |
1540 |
show_table_list->table_name because table_name
|
1541 |
could be changed during opening of I_S tables. It's safe
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1542 |
to use alias because alias contains original table name
|
1543 |
in this case(this part of code is used only for
|
|
1
by brian
clean slate |
1544 |
'show columns' & 'show statistics' commands).
|
1545 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1546 |
table_name= session->make_lex_string(&tmp_lex_string1, show_table_list->alias, |
163
by Brian Aker
Merge Monty's code. |
1547 |
strlen(show_table_list->alias), false); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1548 |
db_name= session->make_lex_string(&tmp_lex_string, show_table_list->db, |
163
by Brian Aker
Merge Monty's code. |
1549 |
show_table_list->db_length, false); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1550 |
|
1
by brian
clean slate |
1551 |
|
1089.1.3
by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix |
1552 |
table->setWriteSet(); |
1063.4.3
by Padraig O'Sullivan
Removed the function pointers in the InfoSchemaTable class. Added a new |
1553 |
error= test(schema_table->processTable(session, show_table_list, |
1554 |
table, res, db_name, |
|
1555 |
table_name)); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1556 |
session->temporary_tables= 0; |
1046.1.14
by Brian Aker
More redactoring of all lock issue code that is session bound, to be a |
1557 |
session->close_tables_for_reopen(&show_table_list); |
1558 |
||
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
1559 |
return(error); |
1
by brian
clean slate |
1560 |
}
|
1561 |
||
1562 |
||
1563 |
/**
|
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
1564 |
@brief Fill I_S table for SHOW Table NAMES commands
|
1
by brian
clean slate |
1565 |
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
1566 |
@param[in] session thread Cursor
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
1567 |
@param[in] table Table struct for I_S table
|
1
by brian
clean slate |
1568 |
@param[in] db_name database name
|
1569 |
@param[in] table_name table name
|
|
163
by Brian Aker
Merge Monty's code. |
1570 |
@param[in] with_i_schema I_S table if true
|
1
by brian
clean slate |
1571 |
|
1572 |
@return Operation status
|
|
1573 |
@retval 0 success
|
|
1574 |
@retval 1 error
|
|
1575 |
*/
|
|
1576 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1577 |
static int fill_schema_table_names(Session *session, Table *table, |
1
by brian
clean slate |
1578 |
LEX_STRING *db_name, LEX_STRING *table_name, |
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1579 |
bool with_i_schema, |
1580 |
plugin::InfoSchemaTable *schema_table) |
|
1
by brian
clean slate |
1581 |
{
|
1582 |
if (with_i_schema) |
|
1583 |
{
|
|
1584 |
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), |
|
1585 |
system_charset_info); |
|
1586 |
}
|
|
1587 |
else
|
|
1588 |
{
|
|
1589 |
char path[FN_REFLEN]; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1590 |
(void) build_table_filename(path, sizeof(path), db_name->str, |
1039.1.6
by Brian Aker
Refactor for build_table_filename() |
1591 |
table_name->str, false); |
590.1.7
by Stewart Smith
remove mysql_frm_type |
1592 |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
1593 |
table->field[3]->store(STRING_WITH_LEN("BASE Table"), |
1594 |
system_charset_info); |
|
1595 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1596 |
if (session->is_error() && session->main_da.sql_errno() == ER_NO_SUCH_TABLE) |
1
by brian
clean slate |
1597 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1598 |
session->clear_error(); |
1
by brian
clean slate |
1599 |
return 0; |
1600 |
}
|
|
1601 |
}
|
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1602 |
schema_table->addRow(table->record[0], table->s->reclength); |
1
by brian
clean slate |
1603 |
return 0; |
1604 |
}
|
|
1605 |
||
1259.5.2
by Stewart Smith
remove mention of getting information from FRM files for INFORMATION_SCHEMA. The comment was now pretty much all lies anyway |
1606 |
int plugin::InfoSchemaMethods::fillTable(Session *session, |
1225.1.19
by Padraig O'Sullivan
Modified the fillTable method to not take a TableList parameter anymore. Instead we now take a Table |
1607 |
Table *table, |
1608 |
plugin::InfoSchemaTable *schema_table) |
|
1
by brian
clean slate |
1609 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1610 |
LEX *lex= session->lex; |
846
by Brian Aker
Removing on typedeffed class. |
1611 |
Select_Lex *old_all_select_lex= lex->all_selects_list; |
1
by brian
clean slate |
1612 |
enum_sql_command save_sql_command= lex->sql_command; |
1225.1.19
by Padraig O'Sullivan
Modified the fillTable method to not take a TableList parameter anymore. Instead we now take a Table |
1613 |
Select_Lex *lsel= table->pos_in_table_list->schema_select_lex; |
846
by Brian Aker
Removing on typedeffed class. |
1614 |
Select_Lex sel; |
1
by brian
clean slate |
1615 |
LOOKUP_FIELD_VALUES lookup_field_vals; |
1616 |
bool with_i_schema; |
|
1071.1.4
by Nathan Williams
Merged trunk, resolved conflicts. |
1617 |
vector<LEX_STRING*> db_names, table_names; |
1183.1.31
by Padraig O'Sullivan
Changed the fillTable method to not take a COND parameter anymore. |
1618 |
/* the WHERE clause */
|
1619 |
COND *cond= table->reginfo.join_tab->select_cond; |
|
1
by brian
clean slate |
1620 |
COND *partial_cond= 0; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1621 |
uint32_t derived_tables= lex->derived_tables; |
1
by brian
clean slate |
1622 |
int error= 1; |
1623 |
Open_tables_state open_tables_state_backup; |
|
1624 |
Query_tables_list query_tables_list_backup; |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1625 |
bool old_value= session->no_warnings_for_error; |
1
by brian
clean slate |
1626 |
|
1627 |
/*
|
|
1628 |
We should not introduce deadlocks even if we already have some
|
|
1629 |
tables open and locked, since we won't lock tables which we will
|
|
1630 |
open and will ignore possible name-locks for these tables.
|
|
1631 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1632 |
session->reset_n_backup_open_tables_state(&open_tables_state_backup); |
1
by brian
clean slate |
1633 |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1634 |
/*
|
1
by brian
clean slate |
1635 |
this branch processes SHOW FIELDS, SHOW INDEXES commands.
|
1636 |
see sql_parse.cc, prepare_schema_table() function where
|
|
1637 |
this values are initialized
|
|
1638 |
*/
|
|
1639 |
if (lsel && lsel->table_list.first) |
|
1640 |
{
|
|
1225.1.19
by Padraig O'Sullivan
Modified the fillTable method to not take a TableList parameter anymore. Instead we now take a Table |
1641 |
error= fill_schema_show_cols_or_idxs(session, table->pos_in_table_list, schema_table, |
1
by brian
clean slate |
1642 |
&open_tables_state_backup); |
1643 |
goto err; |
|
1644 |
}
|
|
1645 |
||
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1646 |
if (get_lookup_field_values(session, |
1647 |
cond, |
|
1648 |
table->pos_in_table_list, |
|
1649 |
&lookup_field_vals, |
|
1650 |
schema_table)) |
|
1
by brian
clean slate |
1651 |
{
|
1652 |
error= 0; |
|
1653 |
goto err; |
|
1654 |
}
|
|
1655 |
||
1656 |
if (!lookup_field_vals.wild_db_value && !lookup_field_vals.wild_table_value) |
|
1657 |
{
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1658 |
/*
|
1
by brian
clean slate |
1659 |
if lookup value is empty string then
|
1660 |
it's impossible table name or db name
|
|
1661 |
*/
|
|
140
by Brian Aker
Remove dead class, clean up warning. |
1662 |
if ((lookup_field_vals.db_value.str && !lookup_field_vals.db_value.str[0]) || |
1663 |
(lookup_field_vals.table_value.str && !lookup_field_vals.table_value.str[0])) |
|
1
by brian
clean slate |
1664 |
{
|
1665 |
error= 0; |
|
1666 |
goto err; |
|
1667 |
}
|
|
1668 |
}
|
|
1669 |
||
1670 |
if (lookup_field_vals.db_value.length && |
|
1671 |
!lookup_field_vals.wild_db_value) |
|
1225.1.19
by Padraig O'Sullivan
Modified the fillTable method to not take a TableList parameter anymore. Instead we now take a Table |
1672 |
table->pos_in_table_list->has_db_lookup_value= true; |
1071.1.4
by Nathan Williams
Merged trunk, resolved conflicts. |
1673 |
|
1
by brian
clean slate |
1674 |
if (lookup_field_vals.table_value.length && |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1675 |
!lookup_field_vals.wild_table_value) |
1225.1.19
by Padraig O'Sullivan
Modified the fillTable method to not take a TableList parameter anymore. Instead we now take a Table |
1676 |
table->pos_in_table_list->has_table_lookup_value= true; |
1
by brian
clean slate |
1677 |
|
1225.1.19
by Padraig O'Sullivan
Modified the fillTable method to not take a TableList parameter anymore. Instead we now take a Table |
1678 |
if (table->pos_in_table_list->has_db_lookup_value && |
1679 |
table->pos_in_table_list->has_table_lookup_value) |
|
1
by brian
clean slate |
1680 |
partial_cond= 0; |
1681 |
else
|
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1682 |
partial_cond= make_cond_for_info_schema(cond, table, schema_table); |
1
by brian
clean slate |
1683 |
|
1684 |
if (lex->describe) |
|
1685 |
{
|
|
1686 |
/* EXPLAIN SELECT */
|
|
1687 |
error= 0; |
|
1688 |
goto err; |
|
1689 |
}
|
|
1690 |
||
1089.1.3
by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix |
1691 |
table->setWriteSet(); |
1071.1.3
by Nathan Williams
Removed st_add_schema_table struct and moved data members into the AddSchemaTable class/functor. That was the only place it was used. |
1692 |
if (make_db_list(session, db_names, &lookup_field_vals, &with_i_schema)) |
1
by brian
clean slate |
1693 |
goto err; |
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1694 |
|
1071.1.4
by Nathan Williams
Merged trunk, resolved conflicts. |
1695 |
for (vector<LEX_STRING*>::iterator db_name= db_names.begin(); db_name != db_names.end(); ++db_name ) |
1
by brian
clean slate |
1696 |
{
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1697 |
session->no_warnings_for_error= 1; |
1698 |
table_names.clear(); |
|
1183.1.5
by Brian Aker
Reworked getTableNames() interface. Way simpler, less mallocs.... |
1699 |
int res= make_table_name_list(session, table_names, |
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1700 |
&lookup_field_vals, |
1701 |
with_i_schema, *db_name); |
|
1702 |
||
1703 |
if (res == 2) /* Not fatal error, continue */ |
|
1704 |
continue; |
|
1705 |
||
1706 |
if (res) |
|
1707 |
goto err; |
|
1708 |
||
1071.1.4
by Nathan Williams
Merged trunk, resolved conflicts. |
1709 |
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1710 |
for (vector<LEX_STRING*>::iterator table_name= table_names.begin(); table_name != table_names.end(); ++table_name) |
1
by brian
clean slate |
1711 |
{
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1712 |
table->restoreRecordAsDefault(); |
1713 |
table->field[schema_table->getFirstColumnIndex()]-> |
|
1714 |
store((*db_name)->str, (*db_name)->length, system_charset_info); |
|
1715 |
table->field[schema_table->getSecondColumnIndex()]-> |
|
1716 |
store((*table_name)->str, (*table_name)->length, system_charset_info); |
|
1
by brian
clean slate |
1717 |
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1718 |
if (!partial_cond || partial_cond->val_int()) |
1
by brian
clean slate |
1719 |
{
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1720 |
/* SHOW Table NAMES command */
|
1071.1.4
by Nathan Williams
Merged trunk, resolved conflicts. |
1721 |
if (schema_table->getTableName().compare("TABLE_NAMES") == 0) |
1
by brian
clean slate |
1722 |
{
|
1225.1.12
by Padraig O'Sullivan
Removed fill_schema_table_from_frm method. |
1723 |
if (fill_schema_table_names(session, |
1225.1.19
by Padraig O'Sullivan
Modified the fillTable method to not take a TableList parameter anymore. Instead we now take a Table |
1724 |
table, |
1225.1.12
by Padraig O'Sullivan
Removed fill_schema_table_from_frm method. |
1725 |
*db_name, |
1726 |
*table_name, |
|
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1727 |
with_i_schema, |
1728 |
schema_table)) |
|
1
by brian
clean slate |
1729 |
continue; |
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1730 |
}
|
1731 |
else
|
|
1732 |
{
|
|
1733 |
LEX_STRING tmp_lex_string, orig_db_name; |
|
1734 |
/*
|
|
1735 |
Set the parent lex of 'sel' because it is needed by
|
|
1736 |
sel.init_query() which is called inside make_table_list.
|
|
1737 |
*/
|
|
1738 |
session->no_warnings_for_error= 1; |
|
1739 |
sel.parent_lex= lex; |
|
1740 |
/* db_name can be changed in make_table_list() func */
|
|
1225.1.12
by Padraig O'Sullivan
Removed fill_schema_table_from_frm method. |
1741 |
if (! session->make_lex_string(&orig_db_name, |
1742 |
(*db_name)->str, |
|
1743 |
(*db_name)->length, |
|
1744 |
false)) |
|
1745 |
{
|
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1746 |
goto err; |
1225.1.12
by Padraig O'Sullivan
Removed fill_schema_table_from_frm method. |
1747 |
}
|
1071.1.4
by Nathan Williams
Merged trunk, resolved conflicts. |
1748 |
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1749 |
if (make_table_list(session, &sel, *db_name, *table_name)) |
1750 |
goto err; |
|
1071.1.4
by Nathan Williams
Merged trunk, resolved conflicts. |
1751 |
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1752 |
TableList *show_table_list= (TableList*) sel.table_list.first; |
1753 |
lex->all_selects_list= &sel; |
|
1754 |
lex->derived_tables= 0; |
|
1755 |
lex->sql_command= SQLCOM_SHOW_FIELDS; |
|
1756 |
show_table_list->i_s_requested_object= |
|
1757 |
schema_table->getRequestedObject(); |
|
1109.1.3
by Brian Aker
Move names around a bit (to align similar methods) |
1758 |
res= session->openTables(show_table_list, DRIZZLE_LOCK_IGNORE_FLUSH); |
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1759 |
lex->sql_command= save_sql_command; |
1760 |
/*
|
|
1761 |
XXX-> show_table_list has a flag i_is_requested,
|
|
1109.1.3
by Brian Aker
Move names around a bit (to align similar methods) |
1762 |
and when it's set, openTables()
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1763 |
can return an error without setting an error message
|
1764 |
in Session, which is a hack. This is why we have to
|
|
1765 |
check for res, then for session->is_error() only then
|
|
1766 |
for session->main_da.sql_errno().
|
|
1767 |
*/
|
|
1768 |
if (res && session->is_error() && |
|
1769 |
session->main_da.sql_errno() == ER_NO_SUCH_TABLE) |
|
1770 |
{
|
|
1771 |
/*
|
|
1772 |
Hide error for not existing table.
|
|
1773 |
This error can occur for example when we use
|
|
1774 |
where condition with db name and table name and this
|
|
1775 |
table does not exist.
|
|
1776 |
*/
|
|
1777 |
res= 0; |
|
1778 |
session->clear_error(); |
|
1779 |
}
|
|
1
by brian
clean slate |
1780 |
else
|
1781 |
{
|
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1782 |
/*
|
1783 |
We should use show_table_list->alias instead of
|
|
1784 |
show_table_list->table_name because table_name
|
|
1785 |
could be changed during opening of I_S tables. It's safe
|
|
1786 |
to use alias because alias contains original table name
|
|
1787 |
in this case.
|
|
1788 |
*/
|
|
1789 |
session->make_lex_string(&tmp_lex_string, show_table_list->alias, |
|
1790 |
strlen(show_table_list->alias), false); |
|
1791 |
res= schema_table->processTable(session, show_table_list, table, |
|
1792 |
res, &orig_db_name, |
|
1793 |
&tmp_lex_string); |
|
1794 |
session->close_tables_for_reopen(&show_table_list); |
|
1
by brian
clean slate |
1795 |
}
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1796 |
assert(!lex->query_tables_own_last); |
1797 |
if (res) |
|
1798 |
goto err; |
|
1
by brian
clean slate |
1799 |
}
|
1800 |
}
|
|
1801 |
}
|
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1802 |
/*
|
1803 |
If we have information schema its always the first table and only
|
|
1804 |
the first table. Reset for other tables.
|
|
1805 |
*/
|
|
1806 |
with_i_schema= 0; |
|
1
by brian
clean slate |
1807 |
}
|
1808 |
||
1809 |
error= 0; |
|
1071.1.2
by Nathan Williams
Converted st_add_schema_table::files from List<LEX_STRING> to std::vector<LEX_STRING*>. |
1810 |
|
1
by brian
clean slate |
1811 |
err: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1812 |
session->restore_backup_open_tables_state(&open_tables_state_backup); |
1
by brian
clean slate |
1813 |
lex->derived_tables= derived_tables; |
1814 |
lex->all_selects_list= old_all_select_lex; |
|
1815 |
lex->sql_command= save_sql_command; |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1816 |
session->no_warnings_for_error= old_value; |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
1817 |
return(error); |
1
by brian
clean slate |
1818 |
}
|
1819 |
||
1820 |
||
1821 |
/**
|
|
1822 |
@brief Store field characteristics into appropriate I_S table columns
|
|
1823 |
||
1824 |
@param[in] table I_S table
|
|
1825 |
@param[in] field processed field
|
|
1826 |
@param[in] cs I_S table charset
|
|
1827 |
@param[in] offset offset from beginning of table
|
|
1828 |
to DATE_TYPE column in I_S table
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1829 |
|
1
by brian
clean slate |
1830 |
@return void
|
1831 |
*/
|
|
1832 |
||
1085.1.2
by Monty Taylor
Fixed -Wmissing-declarations |
1833 |
static void store_column_type(Table *table, Field *field, |
1834 |
const CHARSET_INFO * const cs, |
|
1835 |
uint32_t offset) |
|
1
by brian
clean slate |
1836 |
{
|
1837 |
bool is_blob; |
|
1838 |
int decimals, field_length; |
|
1839 |
const char *tmp_buff; |
|
1840 |
char column_type_buff[MAX_FIELD_WIDTH]; |
|
1841 |
String column_type(column_type_buff, sizeof(column_type_buff), cs); |
|
1842 |
||
1843 |
field->sql_type(column_type); |
|
1844 |
/* DTD_IDENTIFIER column */
|
|
1845 |
table->field[offset + 7]->store(column_type.ptr(), column_type.length(), cs); |
|
1846 |
table->field[offset + 7]->set_notnull(); |
|
1847 |
tmp_buff= strchr(column_type.ptr(), '('); |
|
1848 |
/* DATA_TYPE column */
|
|
1849 |
table->field[offset]->store(column_type.ptr(), |
|
1850 |
(tmp_buff ? tmp_buff - column_type.ptr() : |
|
1851 |
column_type.length()), cs); |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1852 |
is_blob= (field->type() == DRIZZLE_TYPE_BLOB); |
1
by brian
clean slate |
1853 |
if (field->has_charset() || is_blob || |
238
by Brian Aker
Pass through sql_show to remove type to be removed. |
1854 |
field->real_type() == DRIZZLE_TYPE_VARCHAR) // For varbinary type |
1
by brian
clean slate |
1855 |
{
|
205
by Brian Aker
uint32 -> uin32_t |
1856 |
uint32_t octet_max_length= field->max_display_length(); |
1857 |
if (is_blob && octet_max_length != (uint32_t) 4294967295U) |
|
1
by brian
clean slate |
1858 |
octet_max_length /= field->charset()->mbmaxlen; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1859 |
int64_t char_max_len= is_blob ? |
152
by Brian Aker
longlong replacement |
1860 |
(int64_t) octet_max_length / field->charset()->mbminlen : |
1861 |
(int64_t) octet_max_length / field->charset()->mbmaxlen; |
|
1
by brian
clean slate |
1862 |
/* CHARACTER_MAXIMUM_LENGTH column*/
|
163
by Brian Aker
Merge Monty's code. |
1863 |
table->field[offset + 1]->store(char_max_len, true); |
1
by brian
clean slate |
1864 |
table->field[offset + 1]->set_notnull(); |
1865 |
/* CHARACTER_OCTET_LENGTH column */
|
|
163
by Brian Aker
Merge Monty's code. |
1866 |
table->field[offset + 2]->store((int64_t) octet_max_length, true); |
1
by brian
clean slate |
1867 |
table->field[offset + 2]->set_notnull(); |
1868 |
}
|
|
1869 |
||
1870 |
/*
|
|
1871 |
Calculate field_length and decimals.
|
|
1872 |
They are set to -1 if they should not be set (we should return NULL)
|
|
1873 |
*/
|
|
1874 |
||
1875 |
decimals= field->decimals(); |
|
1876 |
switch (field->type()) { |
|
1211.1.1
by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update |
1877 |
case DRIZZLE_TYPE_DECIMAL: |
1878 |
field_length= ((Field_decimal*) field)->precision; |
|
1
by brian
clean slate |
1879 |
break; |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1880 |
case DRIZZLE_TYPE_LONG: |
1881 |
case DRIZZLE_TYPE_LONGLONG: |
|
1
by brian
clean slate |
1882 |
field_length= field->max_display_length() - 1; |
1883 |
break; |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1884 |
case DRIZZLE_TYPE_DOUBLE: |
1
by brian
clean slate |
1885 |
field_length= field->field_length; |
1886 |
if (decimals == NOT_FIXED_DEC) |
|
1887 |
decimals= -1; // return NULL |
|
1888 |
break; |
|
1889 |
default: |
|
1890 |
field_length= decimals= -1; |
|
1891 |
break; |
|
1892 |
}
|
|
1893 |
||
1894 |
/* NUMERIC_PRECISION column */
|
|
1895 |
if (field_length >= 0) |
|
1896 |
{
|
|
163
by Brian Aker
Merge Monty's code. |
1897 |
table->field[offset + 3]->store((int64_t) field_length, true); |
1
by brian
clean slate |
1898 |
table->field[offset + 3]->set_notnull(); |
1899 |
}
|
|
1900 |
/* NUMERIC_SCALE column */
|
|
1901 |
if (decimals >= 0) |
|
1902 |
{
|
|
163
by Brian Aker
Merge Monty's code. |
1903 |
table->field[offset + 4]->store((int64_t) decimals, true); |
1
by brian
clean slate |
1904 |
table->field[offset + 4]->set_notnull(); |
1905 |
}
|
|
1906 |
if (field->has_charset()) |
|
1907 |
{
|
|
1908 |
/* CHARACTER_SET_NAME column*/
|
|
1909 |
tmp_buff= field->charset()->csname; |
|
1910 |
table->field[offset + 5]->store(tmp_buff, strlen(tmp_buff), cs); |
|
1911 |
table->field[offset + 5]->set_notnull(); |
|
1912 |
/* COLLATION_NAME column */
|
|
1913 |
tmp_buff= field->charset()->name; |
|
1914 |
table->field[offset + 6]->store(tmp_buff, strlen(tmp_buff), cs); |
|
1915 |
table->field[offset + 6]->set_notnull(); |
|
1916 |
}
|
|
1917 |
}
|
|
1918 |
||
1919 |
||
1225.1.2
by Padraig O'Sullivan
Resolved issue with segmentation fault on some queries on some I_S tables. Needed to change the |
1920 |
int plugin::InfoSchemaMethods::processTable( |
1921 |
plugin::InfoSchemaTable *store_table, |
|
1922 |
Session *session, |
|
1923 |
TableList *tables, |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
1924 |
Table *table, bool res, |
1
by brian
clean slate |
1925 |
LEX_STRING *db_name, |
1225.1.2
by Padraig O'Sullivan
Resolved issue with segmentation fault on some queries on some I_S tables. Needed to change the |
1926 |
LEX_STRING *table_name) |
1
by brian
clean slate |
1927 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1928 |
LEX *lex= session->lex; |
461
by Monty Taylor
Removed NullS. bu-bye. |
1929 |
const char *wild= lex->wild ? lex->wild->ptr() : NULL; |
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1930 |
const CHARSET_INFO * const cs= system_charset_info; |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
1931 |
Table *show_table; |
1000.1.3
by Brian Aker
Renamed TABLE_SHARE to TableShare |
1932 |
TableShare *show_table_share; |
1
by brian
clean slate |
1933 |
Field **ptr, *field, *timestamp_field; |
1934 |
int count; |
|
1935 |
||
1936 |
if (res) |
|
1937 |
{
|
|
1938 |
if (lex->sql_command != SQLCOM_SHOW_FIELDS) |
|
1939 |
{
|
|
1940 |
/*
|
|
1941 |
I.e. we are in SELECT FROM INFORMATION_SCHEMA.COLUMS
|
|
1942 |
rather than in SHOW COLUMNS
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1943 |
*/
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1944 |
if (session->is_error()) |
1945 |
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, |
|
1946 |
session->main_da.sql_errno(), session->main_da.message()); |
|
1947 |
session->clear_error(); |
|
1
by brian
clean slate |
1948 |
res= 0; |
1949 |
}
|
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
1950 |
return(res); |
1
by brian
clean slate |
1951 |
}
|
1952 |
||
1953 |
show_table= tables->table; |
|
1954 |
show_table_share= show_table->s; |
|
1955 |
count= 0; |
|
1956 |
||
1225.1.20
by Padraig O'Sullivan
Removed all remnants of schema_table from the TableList class. This cleans up a bunch of code. |
1957 |
ptr= show_table_share->field; |
1958 |
timestamp_field= show_table_share->timestamp_field; |
|
1089.1.3
by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix |
1959 |
|
1960 |
/* For the moment we just set everything to read */
|
|
1961 |
if (!show_table->read_set) |
|
1962 |
{
|
|
1103.6.3
by Padraig O'Sullivan
Fixing up more calls to the old bitmap API. |
1963 |
show_table->def_read_set.setAll(); |
1089.1.3
by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix |
1964 |
show_table->read_set= &show_table->def_read_set; |
1965 |
}
|
|
1966 |
show_table->use_all_columns(); // Required for default |
|
1
by brian
clean slate |
1967 |
|
1968 |
for (; (field= *ptr) ; ptr++) |
|
1969 |
{
|
|
481
by Brian Aker
Remove all of uchar. |
1970 |
unsigned char *pos; |
1
by brian
clean slate |
1971 |
char tmp[MAX_FIELD_WIDTH]; |
1972 |
String type(tmp,sizeof(tmp), system_charset_info); |
|
1973 |
char *end; |
|
1974 |
||
1975 |
/* to satisfy 'field->val_str' ASSERTs */
|
|
1976 |
field->table= show_table; |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1977 |
show_table->in_use= session; |
1
by brian
clean slate |
1978 |
|
1979 |
if (wild && wild[0] && |
|
1980 |
wild_case_compare(system_charset_info, field->field_name,wild)) |
|
1981 |
continue; |
|
1982 |
||
1983 |
count++; |
|
1984 |
/* Get default row, with all NULL fields set to NULL */
|
|
997.5.1
by chris
Replace macros around unireg.h, store_record,restore_record,cmp_record,empty_record |
1985 |
table->restoreRecordAsDefault(); |
1
by brian
clean slate |
1986 |
|
1987 |
table->field[1]->store(db_name->str, db_name->length, cs); |
|
1988 |
table->field[2]->store(table_name->str, table_name->length, cs); |
|
1989 |
table->field[3]->store(field->field_name, strlen(field->field_name), |
|
1990 |
cs); |
|
163
by Brian Aker
Merge Monty's code. |
1991 |
table->field[4]->store((int64_t) count, true); |
1
by brian
clean slate |
1992 |
|
1014.3.4
by Brian Aker
Remove dead session calls. |
1993 |
if (get_field_default_value(timestamp_field, field, &type, 0)) |
1
by brian
clean slate |
1994 |
{
|
1995 |
table->field[5]->store(type.ptr(), type.length(), cs); |
|
1996 |
table->field[5]->set_notnull(); |
|
1997 |
}
|
|
481
by Brian Aker
Remove all of uchar. |
1998 |
pos=(unsigned char*) ((field->flags & NOT_NULL_FLAG) ? "NO" : "YES"); |
1
by brian
clean slate |
1999 |
table->field[6]->store((const char*) pos, |
2000 |
strlen((const char*) pos), cs); |
|
2001 |
store_column_type(table, field, cs, 7); |
|
2002 |
||
481
by Brian Aker
Remove all of uchar. |
2003 |
pos=(unsigned char*) ((field->flags & PRI_KEY_FLAG) ? "PRI" : |
1
by brian
clean slate |
2004 |
(field->flags & UNIQUE_KEY_FLAG) ? "UNI" : |
2005 |
(field->flags & MULTIPLE_KEY_FLAG) ? "MUL":""); |
|
2006 |
table->field[15]->store((const char*) pos, |
|
2007 |
strlen((const char*) pos), cs); |
|
2008 |
||
2009 |
end= tmp; |
|
2010 |
if (field->unireg_check == Field::NEXT_NUMBER) |
|
2011 |
table->field[16]->store(STRING_WITH_LEN("auto_increment"), cs); |
|
2012 |
if (timestamp_field == field && |
|
2013 |
field->unireg_check != Field::TIMESTAMP_DN_FIELD) |
|
2014 |
table->field[16]->store(STRING_WITH_LEN("on update CURRENT_TIMESTAMP"), |
|
2015 |
cs); |
|
2016 |
table->field[18]->store(field->comment.str, field->comment.length, cs); |
|
2017 |
{
|
|
2018 |
enum column_format_type column_format= (enum column_format_type) |
|
2019 |
((field->flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK); |
|
481
by Brian Aker
Remove all of uchar. |
2020 |
pos=(unsigned char*)"Default"; |
1
by brian
clean slate |
2021 |
table->field[19]->store((const char*) pos, |
2022 |
strlen((const char*) pos), cs); |
|
481
by Brian Aker
Remove all of uchar. |
2023 |
pos=(unsigned char*)(column_format == COLUMN_FORMAT_TYPE_DEFAULT ? "Default" : |
1
by brian
clean slate |
2024 |
column_format == COLUMN_FORMAT_TYPE_FIXED ? "Fixed" : |
2025 |
"Dynamic"); |
|
2026 |
table->field[20]->store((const char*) pos, |
|
2027 |
strlen((const char*) pos), cs); |
|
2028 |
}
|
|
1225.1.2
by Padraig O'Sullivan
Resolved issue with segmentation fault on some queries on some I_S tables. Needed to change the |
2029 |
store_table->addRow(table->record[0], table->s->reclength); |
1
by brian
clean slate |
2030 |
}
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
2031 |
return(0); |
1
by brian
clean slate |
2032 |
}
|
2033 |
||
2034 |
||
2035 |
/*
|
|
2036 |
For old SHOW compatibility. It is used when
|
|
2037 |
old SHOW doesn't have generated column names
|
|
2038 |
Make list of fields for SHOW
|
|
2039 |
||
2040 |
SYNOPSIS
|
|
1130.1.1
by Monty Taylor
Merged in plugin-slot-reorg patches. |
2041 |
plugin::InfoSchemaMethods::oldFormat()
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
2042 |
session thread Cursor
|
1
by brian
clean slate |
2043 |
schema_table pointer to 'schema_tables' element
|
2044 |
||
2045 |
RETURN
|
|
2046 |
1 error
|
|
2047 |
0 success
|
|
2048 |
*/
|
|
2049 |
||
1130.1.7
by Monty Taylor
Renamed plugin::InfoSchema to plugin::InfoSchemaTable as per Jay. |
2050 |
int plugin::InfoSchemaMethods::oldFormat(Session *session, plugin::InfoSchemaTable *schema_table) |
1063.4.3
by Padraig O'Sullivan
Removed the function pointers in the InfoSchemaTable class. Added a new |
2051 |
const
|
1
by brian
clean slate |
2052 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
2053 |
Name_resolution_context *context= &session->lex->select_lex.context; |
1130.1.7
by Monty Taylor
Renamed plugin::InfoSchema to plugin::InfoSchemaTable as per Jay. |
2054 |
const plugin::InfoSchemaTable::Columns columns= schema_table->getColumns(); |
2055 |
plugin::InfoSchemaTable::Columns::const_iterator iter= columns.begin(); |
|
1067.2.9
by Padraig O'Sullivan
Removed the getSpecificColumn(), beginColumnInfo(), endColumnInfo() methods |
2056 |
|
2057 |
while (iter != columns.end()) |
|
1
by brian
clean slate |
2058 |
{
|
1130.1.1
by Monty Taylor
Merged in plugin-slot-reorg patches. |
2059 |
const plugin::ColumnInfo *column= *iter; |
1076.2.1
by Padraig O'Sullivan
Converted the const char * members of ColumnInfo to be std::string instead. |
2060 |
if (column->getOldName().length() != 0) |
1
by brian
clean slate |
2061 |
{
|
2062 |
Item_field *field= new Item_field(context, |
|
1076.2.1
by Padraig O'Sullivan
Converted the const char * members of ColumnInfo to be std::string instead. |
2063 |
NULL, NULL, |
2064 |
column->getName().c_str()); |
|
1
by brian
clean slate |
2065 |
if (field) |
2066 |
{
|
|
1076.2.1
by Padraig O'Sullivan
Converted the const char * members of ColumnInfo to be std::string instead. |
2067 |
field->set_name(column->getOldName().c_str(), |
2068 |
column->getOldName().length(), |
|
1
by brian
clean slate |
2069 |
system_charset_info); |
838
by Brian Aker
More class adoption/method |
2070 |
if (session->add_item_to_list(field)) |
1
by brian
clean slate |
2071 |
return 1; |
2072 |
}
|
|
2073 |
}
|
|
1067.2.9
by Padraig O'Sullivan
Removed the getSpecificColumn(), beginColumnInfo(), endColumnInfo() methods |
2074 |
++iter; |
1
by brian
clean slate |
2075 |
}
|
2076 |
return 0; |
|
2077 |
}
|
|
2078 |
||
2079 |
||
2080 |
/*
|
|
2081 |
Generate select from information_schema table
|
|
2082 |
||
2083 |
SYNOPSIS
|
|
2084 |
make_schema_select()
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
2085 |
session thread Cursor
|
846
by Brian Aker
Removing on typedeffed class. |
2086 |
sel pointer to Select_Lex
|
1079.2.9
by Padraig O'Sullivan
Removed the dependency on knowing the position of an I_S table in the |
2087 |
schema_table_name name of 'schema_tables' element
|
1
by brian
clean slate |
2088 |
|
2089 |
RETURN
|
|
1034.1.4
by Brian Aker
Fixed TableList to correctly construct (and removed memset() calls in |
2090 |
true on error
|
1
by brian
clean slate |
2091 |
*/
|
2092 |
||
1034.1.4
by Brian Aker
Fixed TableList to correctly construct (and removed memset() calls in |
2093 |
bool make_schema_select(Session *session, Select_Lex *sel, |
1079.2.9
by Padraig O'Sullivan
Removed the dependency on knowing the position of an I_S table in the |
2094 |
const string& schema_table_name) |
1
by brian
clean slate |
2095 |
{
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
2096 |
plugin::InfoSchemaTable *schema_table= plugin::InfoSchemaTable::getTable(schema_table_name.c_str()); |
1
by brian
clean slate |
2097 |
LEX_STRING db, table; |
2098 |
/*
|
|
2099 |
We have to make non const db_name & table_name
|
|
2100 |
because of lower_case_table_names
|
|
2101 |
*/
|
|
575.4.7
by Monty Taylor
More header cleanup. |
2102 |
session->make_lex_string(&db, INFORMATION_SCHEMA_NAME.c_str(), |
2103 |
INFORMATION_SCHEMA_NAME.length(), 0); |
|
1076.2.2
by Padraig O'Sullivan
Converted the const char * members of InfoSchemaTable to be std::string |
2104 |
session->make_lex_string(&table, schema_table->getTableName().c_str(), |
2105 |
schema_table->getTableName().length(), 0); |
|
1063.4.3
by Padraig O'Sullivan
Removed the function pointers in the InfoSchemaTable class. Added a new |
2106 |
if (schema_table->oldFormat(session, schema_table) || /* Handle old syntax */ |
1093.1.57
by Jay Pipes
Merge and resolved conflicts for Monty's plugins/slots reorganization |
2107 |
! sel->add_table_to_list(session, new Table_ident(db, table), 0, 0, TL_READ)) |
1
by brian
clean slate |
2108 |
{
|
1034.1.4
by Brian Aker
Fixed TableList to correctly construct (and removed memset() calls in |
2109 |
return true; |
1
by brian
clean slate |
2110 |
}
|
1034.1.4
by Brian Aker
Fixed TableList to correctly construct (and removed memset() calls in |
2111 |
return false; |
1
by brian
clean slate |
2112 |
}
|
2113 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
2114 |
} /* namespace drizzled */ |