28
28
#include <drizzled/error.h>
29
29
#include <drizzled/tztime.h>
30
30
#include <drizzled/data_home.h>
31
#include <drizzled/item/blob.h>
31
32
#include <drizzled/item/cmpfunc.h>
32
#include <drizzled/virtual_column_info.h>
33
#include <drizzled/item/return_int.h>
34
#include <drizzled/item/empty_string.h>
35
#include <drizzled/item/return_date_time.h>
33
36
#include <drizzled/sql_base.h>
34
37
#include <drizzled/db.h>
35
38
#include <drizzled/field/timestamp.h>
36
#include <drizzled/field/fdecimal.h>
39
#include <drizzled/field/decimal.h>
40
#include <drizzled/lock.h>
41
#include <drizzled/item/return_date_time.h>
42
#include <drizzled/item/empty_string.h>
43
#include "drizzled/plugin_registry.h"
54
int show_var_cmp(const void *var1, const void *var2);
40
56
inline const char *
41
57
str_or_nil(const char *str)
46
62
/* Match the values of enum ha_choice */
47
63
static const char *ha_choice_values[] = {"", "0", "1"};
49
static void store_key_options(Session *session, String *packet, Table *table,
65
static void store_key_options(String *packet, Table *table, KEY *key_info);
67
static vector<InfoSchemaTable *> all_schema_tables;
69
Table *create_schema_table(Session *session, TableList *table_list);
70
int make_old_format(Session *session, InfoSchemaTable *schema_table);
72
void add_infoschema_table(InfoSchemaTable *schema_table)
74
if (schema_table->create_table == NULL)
75
schema_table->create_table= create_schema_table;
76
if (schema_table->old_format == NULL)
77
schema_table->old_format= make_old_format;
78
if (schema_table->idx_field1 == 0)
79
schema_table->idx_field1= -1;
80
if (schema_table->idx_field2)
81
schema_table->idx_field2= -1;
83
all_schema_tables.push_back(schema_table);
86
void remove_infoschema_table(InfoSchemaTable *table)
88
all_schema_tables.erase(remove_if(all_schema_tables.begin(),
89
all_schema_tables.end(),
90
bind2nd(equal_to<InfoSchemaTable *>(),
92
all_schema_tables.end());
54
96
int wild_case_compare(const CHARSET_INFO * const cs, const char *str,const char *wildstr)
101
143
** List all table types supported
102
144
***************************************************************************/
104
static bool show_plugins(Session *session, plugin_ref plugin,
146
class ShowPlugins : public unary_function<st_plugin_int *, bool>
107
Table *table= (Table*) arg;
108
struct st_mysql_plugin *plug= plugin_decl(plugin);
109
struct st_plugin_dl *plugin_dl= plugin_dlib(plugin);
110
const CHARSET_INFO * const cs= system_charset_info;
112
restore_record(table, s->default_values);
114
table->field[0]->store(plugin_name(plugin)->str,
115
plugin_name(plugin)->length, cs);
119
table->field[1]->store(plug->version, strlen(plug->version), cs);
120
table->field[1]->set_notnull();
123
table->field[1]->set_null();
125
switch (plugin_state(plugin)) {
126
/* case PLUGIN_IS_FREED: does not happen */
127
case PLUGIN_IS_DELETED:
128
table->field[2]->store(STRING_WITH_LEN("DELETED"), cs);
130
case PLUGIN_IS_UNINITIALIZED:
131
table->field[2]->store(STRING_WITH_LEN("INACTIVE"), cs);
133
case PLUGIN_IS_READY:
134
table->field[2]->store(STRING_WITH_LEN("ACTIVE"), cs);
140
table->field[3]->store(plugin_type_names[plug->type].str,
141
plugin_type_names[plug->type].length,
146
table->field[4]->store(plugin_dl->dl.str, plugin_dl->dl.length, cs);
147
table->field[4]->set_notnull();
151
table->field[4]->set_null();
156
table->field[5]->store(plug->author, strlen(plug->author), cs);
151
ShowPlugins(Session *session_arg, Table *table_arg)
152
: session(session_arg), table(table_arg) {}
154
result_type operator() (argument_type plugin)
156
struct drizzled_plugin_manifest *plug= plugin_decl(plugin);
157
const CHARSET_INFO * const cs= system_charset_info;
159
table->restoreRecordAsDefault();
161
table->field[0]->store(plugin_name(plugin)->str,
162
plugin_name(plugin)->length, cs);
166
table->field[1]->store(plug->version, strlen(plug->version), cs);
167
table->field[1]->set_notnull();
170
table->field[1]->set_null();
172
if (plugin->isInited)
173
table->field[2]->store(STRING_WITH_LEN("ACTIVE"), cs);
175
table->field[2]->store(STRING_WITH_LEN("INACTIVE"), cs);
179
table->field[3]->store(plug->author, strlen(plug->author), cs);
180
table->field[3]->set_notnull();
183
table->field[3]->set_null();
187
table->field[4]->store(plug->descr, strlen(plug->descr), cs);
188
table->field[4]->set_notnull();
191
table->field[4]->set_null();
193
switch (plug->license) {
194
case PLUGIN_LICENSE_GPL:
195
table->field[5]->store(PLUGIN_LICENSE_GPL_STRING,
196
strlen(PLUGIN_LICENSE_GPL_STRING), cs);
198
case PLUGIN_LICENSE_BSD:
199
table->field[5]->store(PLUGIN_LICENSE_BSD_STRING,
200
strlen(PLUGIN_LICENSE_BSD_STRING), cs);
202
case PLUGIN_LICENSE_LGPL:
203
table->field[5]->store(PLUGIN_LICENSE_LGPL_STRING,
204
strlen(PLUGIN_LICENSE_LGPL_STRING), cs);
207
table->field[5]->store(PLUGIN_LICENSE_PROPRIETARY_STRING,
208
strlen(PLUGIN_LICENSE_PROPRIETARY_STRING), cs);
157
211
table->field[5]->set_notnull();
160
table->field[5]->set_null();
164
table->field[6]->store(plug->descr, strlen(plug->descr), cs);
165
table->field[6]->set_notnull();
168
table->field[6]->set_null();
170
switch (plug->license) {
171
case PLUGIN_LICENSE_GPL:
172
table->field[7]->store(PLUGIN_LICENSE_GPL_STRING,
173
strlen(PLUGIN_LICENSE_GPL_STRING), cs);
175
case PLUGIN_LICENSE_BSD:
176
table->field[7]->store(PLUGIN_LICENSE_BSD_STRING,
177
strlen(PLUGIN_LICENSE_BSD_STRING), cs);
180
table->field[7]->store(PLUGIN_LICENSE_PROPRIETARY_STRING,
181
strlen(PLUGIN_LICENSE_PROPRIETARY_STRING), cs);
184
table->field[7]->set_notnull();
186
return schema_table_store_record(session, table);
213
return schema_table_store_record(session, table);
190
218
int fill_plugins(Session *session, TableList *tables, COND *)
192
220
Table *table= tables->table;
194
if (plugin_foreach_with_mask(session, show_plugins, DRIZZLE_ANY_PLUGIN,
195
~PLUGIN_IS_FREED, table))
222
PluginRegistry ®istry= PluginRegistry::getPluginRegistry();
223
vector<st_plugin_int *> plugins= registry.get_list(true);
224
vector<st_plugin_int *>::iterator iter=
225
find_if(plugins.begin(), plugins.end(), ShowPlugins(session, table));
226
if (iter != plugins.end())
289
// Return only .frm files which aren't temp files.
290
if (my_strcasecmp(system_charset_info, ext=fn_rext(file->name),reg_ext) ||
319
// Return only .frm files which aren't temp files.
320
if (my_strcasecmp(system_charset_info, ext=fn_rext(file->name),".dfe") ||
291
321
is_prefix(file->name, TMP_FILE_PREFIX))
294
324
file_name_len= filename_to_tablename(file->name, uname, sizeof(uname));
297
if (lower_case_table_names)
299
if (wild_case_compare(files_charset_info, uname, wild))
302
else if (wild_compare(uname, wild, 0))
327
if (lower_case_table_names)
329
if (wild_case_compare(files_charset_info, uname, wild))
332
else if (wild_compare(uname, wild, 0))
307
337
session->make_lex_string(file_name, uname, file_name_len, true)) ||
308
338
files->push_back(file_name))
380
411
String buffer(buff, sizeof(buff), system_charset_info);
381
412
Protocol *protocol=session->protocol;
383
if (store_db_create_info(session, dbname, &buffer, create_info))
414
if (store_db_create_info(dbname, &buffer, create_info))
386
417
This assumes that the only reason for which store_db_create_info()
387
418
can fail is incorrect database name (which is the case now).
389
420
my_error(ER_BAD_DB_ERROR, MYF(0), dbname);
393
424
List<Item> field_list;
394
425
field_list.push_back(new Item_empty_string("Database",NAME_CHAR_LEN));
395
426
field_list.push_back(new Item_empty_string("Create Database",1024));
397
if (protocol->send_fields(&field_list,
398
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
428
if (protocol->sendFields(&field_list,
429
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
401
protocol->prepare_for_resend();
432
protocol->prepareForResend();
402
433
protocol->store(dbname, strlen(dbname), system_charset_info);
403
434
protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
405
436
if (protocol->write())
429
460
Field **ptr,*field;
430
461
for (ptr=table->field ; (field= *ptr); ptr++)
432
if (!wild || !wild[0] ||
463
if (!wild || !wild[0] ||
433
464
!wild_case_compare(system_charset_info, field->field_name,wild))
435
466
field_list.push_back(new Item_field(field));
438
restore_record(table, s->default_values); // Get empty record
469
table->restoreRecordAsDefault(); // Get empty record
439
470
table->use_all_columns();
440
if (session->protocol->send_fields(&field_list, Protocol::SEND_DEFAULTS))
448
Go through all character combinations and ensure that sql_lex.cc can
449
parse it as an identifier.
454
name_length length of name
457
# Pointer to conflicting character
458
0 No conflicting character
461
static const char *require_quotes(const char *name, uint32_t name_length)
464
bool pure_digit= true;
465
const char *end= name + name_length;
467
for (; name < end ; name++)
469
unsigned char chr= (unsigned char) *name;
470
length= my_mbcharlen(system_charset_info, chr);
471
if (length == 1 && !system_charset_info->ident_map[chr])
473
if (length == 1 && (chr < '0' || chr > '9'))
483
Quote the given identifier if needed and append it to the target string.
484
If the given identifier is empty, it will be quoted.
488
session thread handler
490
name the identifier to be appended
491
name_length length of the appending identifier
495
append_identifier(Session *session, String *packet, const char *name, uint32_t length)
497
const char *name_end;
499
int q= get_quote_char_for_identifier(session, name, length);
503
packet->append(name, length, packet->charset());
508
The identifier must be quoted as it includes a quote character or
512
packet->reserve(length*2 + 2);
513
quote_char= (char) q;
514
packet->append("e_char, 1, system_charset_info);
516
for (name_end= name+length ; name < name_end ; name+= length)
518
unsigned char chr= (unsigned char) *name;
519
length= my_mbcharlen(system_charset_info, chr);
521
my_mbcharlen can return 0 on a wrong multibyte
522
sequence. It is possible when upgrading from 4.0,
523
and identifier contains some accented characters.
524
The manual says it does not work. So we'll just
525
change length to 1 not to hang in the endless loop.
529
if (length == 1 && chr == (unsigned char) quote_char)
530
packet->append("e_char, 1, system_charset_info);
531
packet->append(name, length, system_charset_info);
533
packet->append("e_char, 1, system_charset_info);
471
if (session->protocol->sendFields(&field_list, Protocol::SEND_DEFAULTS))
730
654
type.set_charset(system_charset_info);
732
if (field->vcol_info)
734
packet->append(STRING_WITH_LEN("VIRTUAL "));
737
656
field->sql_type(type);
738
657
packet->append(type.ptr(), type.length(), system_charset_info);
740
if (field->vcol_info)
742
packet->append(STRING_WITH_LEN(" AS ("));
743
packet->append(field->vcol_info->expr_str.str,
744
field->vcol_info->expr_str.length,
745
system_charset_info);
746
packet->append(STRING_WITH_LEN(")"));
747
if (field->is_stored)
748
packet->append(STRING_WITH_LEN(" STORED"));
751
659
if (field->has_charset())
753
661
if (field->charset() != share->table_charset)
755
packet->append(STRING_WITH_LEN(" CHARACTER SET "));
756
packet->append(field->charset()->csname);
663
packet->append(STRING_WITH_LEN(" CHARACTER SET "));
664
packet->append(field->charset()->csname);
759
For string types dump collation name only if
760
collation is not primary for the given charset
668
For string types dump collation name only if
669
collation is not primary for the given charset
762
671
if (!(field->charset()->state & MY_CS_PRIMARY))
764
packet->append(STRING_WITH_LEN(" COLLATE "));
765
packet->append(field->charset()->name);
673
packet->append(STRING_WITH_LEN(" COLLATE "));
674
packet->append(field->charset()->name);
1041
941
buffer->append(STRING_WITH_LEN("CREATE DATABASE "));
1043
943
if (create_options & HA_LEX_CREATE_IF_NOT_EXISTS)
1044
buffer->append(STRING_WITH_LEN("/*!32312 IF NOT EXISTS*/ "));
1046
append_identifier(session, buffer, dbname, strlen(dbname));
1048
if (create.default_table_charset)
1050
buffer->append(STRING_WITH_LEN(" /*!40100"));
1051
buffer->append(STRING_WITH_LEN(" DEFAULT CHARACTER SET "));
1052
buffer->append(create.default_table_charset->csname);
1053
if (!(create.default_table_charset->state & MY_CS_PRIMARY))
1055
buffer->append(STRING_WITH_LEN(" COLLATE "));
1056
buffer->append(create.default_table_charset->name);
1058
buffer->append(STRING_WITH_LEN(" */"));
944
buffer->append(STRING_WITH_LEN("IF NOT EXISTS "));
946
buffer->append_identifier(dbname, strlen(dbname));
1064
static void store_key_options(Session *,
1065
String *packet, Table *table,
951
static void store_key_options(String *packet, Table *table, KEY *key_info)
1068
953
char *end, buff[32];
1117
1002
template class I_List<thread_info>;
1120
void mysqld_list_processes(Session *session,const char *user, bool verbose)
1005
void mysqld_list_processes(Session *session,const char *user, bool)
1123
1008
List<Item> field_list;
1124
1009
I_List<thread_info> thread_infos;
1125
ulong max_query_length= (verbose ? session->variables.max_allowed_packet :
1126
PROCESS_LIST_WIDTH);
1127
1010
Protocol *protocol= session->protocol;
1129
1012
field_list.push_back(new Item_int("Id", 0, MY_INT32_NUM_DECIMAL_DIGITS));
1130
1013
field_list.push_back(new Item_empty_string("User",16));
1131
1014
field_list.push_back(new Item_empty_string("Host",LIST_PROCESS_HOST_LEN));
1132
1015
field_list.push_back(field=new Item_empty_string("db",NAME_CHAR_LEN));
1133
field->maybe_null=1;
1016
field->maybe_null= true;
1134
1017
field_list.push_back(new Item_empty_string("Command",16));
1135
1018
field_list.push_back(new Item_return_int("Time",7, DRIZZLE_TYPE_LONG));
1136
1019
field_list.push_back(field=new Item_empty_string("State",30));
1137
field->maybe_null=1;
1138
field_list.push_back(field=new Item_empty_string("Info",max_query_length));
1139
field->maybe_null=1;
1140
if (protocol->send_fields(&field_list,
1141
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1020
field->maybe_null= true;
1021
field_list.push_back(field=new Item_empty_string("Info", PROCESS_LIST_WIDTH));
1022
field->maybe_null= true;
1023
if (protocol->sendFields(&field_list,
1024
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1144
1027
pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
1145
1028
if (!session->killed)
1147
I_List_iterator<Session> it(threads);
1031
for( vector<Session*>::iterator it= session_list.begin(); it != session_list.end(); ++it )
1151
Security_context *tmp_sctx= tmp->security_ctx;
1034
Security_context *tmp_sctx= &tmp->security_ctx;
1152
1035
struct st_my_thread_var *mysys_var;
1153
if ((tmp->vio_ok() || tmp->system_thread) && (!user || (tmp_sctx->user && !strcmp(tmp_sctx->user, user))))
1036
if (tmp->protocol->isConnected() && (!user || (tmp_sctx->user.c_str() && !strcmp(tmp_sctx->user.c_str(), user))))
1155
1038
thread_info *session_info= new thread_info;
1157
1040
session_info->thread_id=tmp->thread_id;
1158
session_info->user= session->strdup(tmp_sctx->user ? tmp_sctx->user :
1159
(tmp->system_thread ?
1160
"system user" : "unauthenticated user"));
1161
session_info->host= session->strdup(tmp_sctx->ip);
1041
session_info->user= session->strdup(tmp_sctx->user.c_str() ? tmp_sctx->user.c_str() : "unauthenticated user");
1042
session_info->host= session->strdup(tmp_sctx->ip.c_str());
1162
1043
if ((session_info->db=tmp->db)) // Safe test
1163
1044
session_info->db=session->strdup(session_info->db);
1164
1045
session_info->command=(int) tmp->command;
1165
1046
if ((mysys_var= tmp->mysys_var))
1166
1047
pthread_mutex_lock(&mysys_var->mutex);
1167
session_info->proc_info= (char*) (tmp->killed == Session::KILL_CONNECTION? "Killed" : 0);
1168
session_info->state_info= (char*) (tmp->net.reading_or_writing ?
1169
(tmp->net.reading_or_writing == 2 ?
1171
session_info->command == COM_SLEEP ? NULL :
1172
"Reading from net") :
1049
if (tmp->killed == Session::KILL_CONNECTION)
1050
session_info->proc_info= (char*) "Killed";
1052
session_info->proc_info= command_name[session_info->command].str;
1054
session_info->state_info= (char*) (tmp->protocol->isWriting() ?
1056
tmp->protocol->isReading() ?
1057
(session_info->command == COM_SLEEP ?
1058
NULL : "Reading from net") :
1173
1059
tmp->get_proc_info() ? tmp->get_proc_info() :
1174
1060
tmp->mysys_var &&
1175
1061
tmp->mysys_var->current_cond ?
1196
1074
pthread_mutex_unlock(&LOCK_thread_count);
1198
1076
thread_info *session_info;
1199
time_t now= my_time(0);
1077
time_t now= time(NULL);
1200
1078
while ((session_info=thread_infos.get()))
1202
protocol->prepare_for_resend();
1080
protocol->prepareForResend();
1203
1081
protocol->store((uint64_t) session_info->thread_id);
1204
1082
protocol->store(session_info->user, system_charset_info);
1205
1083
protocol->store(session_info->host, system_charset_info);
1206
1084
protocol->store(session_info->db, system_charset_info);
1207
if (session_info->proc_info)
1208
protocol->store(session_info->proc_info, system_charset_info);
1210
protocol->store(command_name[session_info->command].str, system_charset_info);
1085
protocol->store(session_info->proc_info, system_charset_info);
1211
1087
if (session_info->start_time)
1212
1088
protocol->store((uint32_t) (now - session_info->start_time));
1214
protocol->store_null();
1215
1092
protocol->store(session_info->state_info, system_charset_info);
1216
1093
protocol->store(session_info->query, system_charset_info);
1217
1095
if (protocol->write())
1218
1096
break; /* purecov: inspected */
1235
1117
if (!session->killed)
1237
I_List_iterator<Session> it(threads);
1121
for( vector<Session*>::iterator it= session_list.begin(); it != session_list.end(); ++it )
1242
Security_context *tmp_sctx= tmp->security_ctx;
1124
Security_context *tmp_sctx= &tmp->security_ctx;
1243
1125
struct st_my_thread_var *mysys_var;
1244
1126
const char *val;
1246
if ((!tmp->vio_ok() && !tmp->system_thread))
1128
if (! tmp->protocol->isConnected())
1249
restore_record(table, s->default_values);
1131
table->restoreRecordAsDefault();
1251
1133
table->field[0]->store((int64_t) tmp->thread_id, true);
1253
val= tmp_sctx->user ? tmp_sctx->user :
1254
(tmp->system_thread ? "system user" : "unauthenticated user");
1135
val= tmp_sctx->user.c_str() ? tmp_sctx->user.c_str() : "unauthenticated user";
1255
1136
table->field[1]->store(val, strlen(val), cs);
1257
table->field[2]->store(tmp_sctx->ip, strlen(tmp_sctx->ip), cs);
1138
table->field[2]->store(tmp_sctx->ip.c_str(), strlen(tmp_sctx->ip.c_str()), cs);
1317
1197
Status functions
1318
1198
*****************************************************************************/
1320
static DYNAMIC_ARRAY all_status_vars;
1200
static vector<SHOW_VAR *> all_status_vars;
1321
1201
static bool status_vars_inited= 0;
1322
static int show_var_cmp(const void *var1, const void *var2)
1202
int show_var_cmp(const void *var1, const void *var2)
1324
1204
return strcmp(((SHOW_VAR*)var1)->name, ((SHOW_VAR*)var2)->name);
1328
deletes all the SHOW_UNDEF elements from the array and calls
1329
delete_dynamic() if it's completely empty.
1331
static void shrink_var_array(DYNAMIC_ARRAY *array)
1207
class show_var_cmp_functor
1334
SHOW_VAR *all= dynamic_element(array, 0, SHOW_VAR *);
1210
show_var_cmp_functor() { }
1211
inline bool operator()(const SHOW_VAR *var1, const SHOW_VAR *var2) const
1213
int val= strcmp(var1->name, var2->name);
1336
for (a= b= 0; b < array->elements; b++)
1337
if (all[b].type != SHOW_UNDEF)
1218
class show_var_remove_if
1221
show_var_remove_if() { }
1222
inline bool operator()(const SHOW_VAR *curr) const
1341
memset(all+a, 0, sizeof(SHOW_VAR)); // writing NULL-element to the end
1224
return (curr->type == SHOW_UNDEF);
1344
else // array is completely empty - delete it
1345
delete_dynamic(array);
1349
1229
Adds an array of SHOW_VAR entries to the output of SHOW STATUS
1361
1241
As a special optimization, if add_status_vars() is called before
1362
1242
init_status_vars(), it assumes "startup mode" - neither concurrent access
1363
1243
to the array nor SHOW STATUS are possible (thus it skips locks and qsort)
1365
The last entry of the all_status_vars[] should always be {0,0,SHOW_UNDEF}
1367
1245
int add_status_vars(SHOW_VAR *list)
1370
1248
if (status_vars_inited)
1371
1249
pthread_mutex_lock(&LOCK_status);
1372
if (!all_status_vars.buffer && // array is not allocated yet - do it now
1373
my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 200, 20))
1378
1250
while (list->name)
1379
res|= insert_dynamic(&all_status_vars, (unsigned char*)list++);
1380
res|= insert_dynamic(&all_status_vars, (unsigned char*)list); // appending NULL-element
1381
all_status_vars.elements--; // but next insert_dynamic should overwite it
1251
all_status_vars.insert(all_status_vars.begin(), list++);
1382
1252
if (status_vars_inited)
1383
sort_dynamic(&all_status_vars, show_var_cmp);
1253
sort(all_status_vars.begin(), all_status_vars.end(),
1254
show_var_cmp_functor());
1385
1255
if (status_vars_inited)
1386
1256
pthread_mutex_unlock(&LOCK_status);
1499
1376
const char *prefix, Table *table,
1500
1377
bool ucase_names)
1502
MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, long);
1379
MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, int64_t);
1503
1380
char * const buff= (char *) &buff_data;
1504
1381
char *prefix_end;
1505
1382
/* the variable name should not be longer than 64 characters */
1506
1383
char name_buffer[64];
1508
LEX_STRING null_lex_str;
1509
1385
SHOW_VAR tmp, *var;
1511
null_lex_str.str= 0; // For sys_var->value_ptr()
1512
null_lex_str.length= 0;
1387
prefix_end= strncpy(name_buffer, prefix, sizeof(name_buffer)-1);
1388
prefix_end+= strlen(prefix);
1514
prefix_end=my_stpncpy(name_buffer, prefix, sizeof(name_buffer)-1);
1516
1391
*prefix_end++= '_';
1517
1392
len=name_buffer + sizeof(name_buffer) - prefix_end;
1519
1394
for (; variables->name; variables++)
1521
my_stpncpy(prefix_end, variables->name, len);
1396
strncpy(prefix_end, variables->name, len);
1522
1397
name_buffer[sizeof(name_buffer)-1]=0; /* Safety */
1523
1398
if (ucase_names)
1524
1399
make_upper(name_buffer);
1579
1452
case SHOW_LONGLONG:
1580
1453
end= int64_t10_to_str(*(int64_t*) value, buff, 10);
1457
stringstream ss (stringstream::in);
1458
ss << *(size_t*) value;
1460
string str= ss.str();
1461
strncpy(buff, str.c_str(), str.length());
1462
end= buff+ str.length();
1582
1465
case SHOW_HA_ROWS:
1583
1466
end= int64_t10_to_str((int64_t) *(ha_rows*) value, buff, 10);
1585
1468
case SHOW_BOOL:
1586
end= my_stpcpy(buff, *(bool*) value ? "ON" : "OFF");
1469
end+= sprintf(buff,"%s", *(bool*) value ? "ON" : "OFF");
1588
1471
case SHOW_MY_BOOL:
1589
end= my_stpcpy(buff, *(bool*) value ? "ON" : "OFF");
1472
end+= sprintf(buff,"%s", *(bool*) value ? "ON" : "OFF");
1475
case SHOW_INT_NOFLUSH: // the difference lies in refresh_status()
1592
1476
end= int10_to_str((long) *(uint32_t*) value, buff, 10);
1594
1478
case SHOW_HAVE:
1596
SHOW_COMP_OPTION tmp= *(SHOW_COMP_OPTION*) value;
1597
pos= show_comp_option_name[(int) tmp];
1480
SHOW_COMP_OPTION tmp_option= *(SHOW_COMP_OPTION *)value;
1481
pos= show_comp_option_name[(int) tmp_option];
1598
1482
end= strchr(pos, '\0');
2093
struct st_add_schema_table
1975
struct st_add_schema_table
2095
1977
List<LEX_STRING> *files;
2096
1978
const char *wild;
2100
static bool add_schema_table(Session *session, plugin_ref plugin,
1982
class AddSchemaTable : public unary_function<InfoSchemaTable *, bool>
2103
LEX_STRING *file_name= 0;
2104
st_add_schema_table *data= (st_add_schema_table *)p_data;
2105
List<LEX_STRING> *file_list= data->files;
2106
const char *wild= data->wild;
2107
ST_SCHEMA_TABLE *schema_table= plugin_data(plugin, ST_SCHEMA_TABLE *);
2109
if (schema_table->hidden)
1985
st_add_schema_table *data;
1987
AddSchemaTable(Session *session_arg, st_add_schema_table *data_arg)
1988
: session(session_arg), data(data_arg) {}
1989
result_type operator() (argument_type schema_table)
2113
if (lower_case_table_names)
1991
LEX_STRING *file_name= 0;
1992
List<LEX_STRING> *file_list= data->files;
1993
const char *wild= data->wild;
1995
if (schema_table->hidden)
2115
if (wild_case_compare(files_charset_info,
2116
schema_table->table_name,
1999
if (lower_case_table_names)
2001
if (wild_case_compare(files_charset_info,
2002
schema_table->table_name,
2006
else if (wild_compare(schema_table->table_name, wild, 0))
2120
else if (wild_compare(schema_table->table_name, wild, 0))
2010
if ((file_name= session->make_lex_string(file_name, schema_table->table_name,
2011
strlen(schema_table->table_name),
2013
!file_list->push_back(file_name))
2124
if ((file_name= session->make_lex_string(file_name, schema_table->table_name,
2125
strlen(schema_table->table_name),
2127
!file_list->push_back(file_name))
2133
2020
int schema_tables_add(Session *session, List<LEX_STRING> *files, const char *wild)
2135
2022
LEX_STRING *file_name= 0;
2136
ST_SCHEMA_TABLE *tmp_schema_table= schema_tables;
2023
InfoSchemaTable *tmp_schema_table= schema_tables;
2137
2024
st_add_schema_table add_data;
2139
2026
for (; tmp_schema_table->table_name; tmp_schema_table++)
2298
2186
get_all_tables() returns 1 on failure and 0 on success thus
2299
2187
return only these and not the result code of ::process_table()
2301
We should use show_table_list->alias instead of
2189
We should use show_table_list->alias instead of
2302
2190
show_table_list->table_name because table_name
2303
2191
could be changed during opening of I_S tables. It's safe
2304
to use alias because alias contains original table name
2305
in this case(this part of code is used only for
2192
to use alias because alias contains original table name
2193
in this case(this part of code is used only for
2306
2194
'show columns' & 'show statistics' commands).
2308
2196
table_name= session->make_lex_string(&tmp_lex_string1, show_table_list->alias,
2309
2197
strlen(show_table_list->alias), false);
2310
2198
db_name= session->make_lex_string(&tmp_lex_string, show_table_list->db,
2311
2199
show_table_list->db_length, false);
2314
2202
error= test(schema_table->process_table(session, show_table_list,
2315
2203
table, res, db_name,
2657
2542
DRIZZLE_LOCK_IGNORE_FLUSH);
2658
2543
lex->sql_command= save_sql_command;
2660
XXX: show_table_list has a flag i_is_requested,
2661
and when it's set, open_normal_and_derived_tables()
2662
can return an error without setting an error message
2663
in Session, which is a hack. This is why we have to
2664
check for res, then for session->is_error() only then
2665
for session->main_da.sql_errno().
2545
XXX: show_table_list has a flag i_is_requested,
2546
and when it's set, open_normal_and_derived_tables()
2547
can return an error without setting an error message
2548
in Session, which is a hack. This is why we have to
2549
check for res, then for session->is_error() only then
2550
for session->main_da.sql_errno().
2667
2552
if (res && session->is_error() &&
2668
2553
session->main_da.sql_errno() == ER_NO_SUCH_TABLE)
2835
2720
table->field[i]->set_notnull();
2837
tmp_buff= (char *) ha_resolve_storage_engine_name(tmp_db_type);
2838
table->field[4]->store(tmp_buff, strlen(tmp_buff), cs);
2722
string engine_name= ha_resolve_storage_engine_name(tmp_db_type);
2723
table->field[4]->store(engine_name.c_str(), engine_name.size(), cs);
2839
2724
table->field[5]->store((int64_t) 0, true);
2841
2726
ptr=option_buff;
2842
2727
if (share->min_rows)
2844
ptr=my_stpcpy(ptr," min_rows=");
2845
ptr=int64_t10_to_str(share->min_rows,ptr,10);
2729
ptr= strcpy(ptr," min_rows=")+10;
2730
ptr= int64_t10_to_str(share->min_rows,ptr,10);
2847
2732
if (share->max_rows)
2849
ptr=my_stpcpy(ptr," max_rows=");
2850
ptr=int64_t10_to_str(share->max_rows,ptr,10);
2734
ptr= strcpy(ptr," max_rows=")+10;
2735
ptr= int64_t10_to_str(share->max_rows,ptr,10);
2852
2737
if (share->avg_row_length)
2854
ptr=my_stpcpy(ptr," avg_row_length=");
2855
ptr=int64_t10_to_str(share->avg_row_length,ptr,10);
2739
ptr= strcpy(ptr," avg_row_length=")+16;
2740
ptr= int64_t10_to_str(share->avg_row_length,ptr,10);
2857
2742
if (share->db_create_options & HA_OPTION_PACK_KEYS)
2858
ptr=my_stpcpy(ptr," pack_keys=1");
2743
ptr= strcpy(ptr," pack_keys=1")+12;
2859
2744
if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
2860
ptr=my_stpcpy(ptr," pack_keys=0");
2745
ptr= strcpy(ptr," pack_keys=0")+12;
2861
2746
/* We use CHECKSUM, instead of TABLE_CHECKSUM, for backward compability */
2862
2747
if (share->db_create_options & HA_OPTION_CHECKSUM)
2863
ptr=my_stpcpy(ptr," checksum=1");
2748
ptr= strcpy(ptr," checksum=1")+11;
2864
2749
if (share->page_checksum != HA_CHOICE_UNDEF)
2865
ptr= strxmov(ptr, " page_checksum=",
2866
ha_choice_values[(uint) share->page_checksum], NULL);
2750
ptr+= sprintf(ptr, " page_checksum=%s",
2751
ha_choice_values[(uint32_t) share->page_checksum]);
2867
2752
if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
2868
ptr=my_stpcpy(ptr," delay_key_write=1");
2753
ptr= strcpy(ptr," delay_key_write=1")+18;
2869
2754
if (share->row_type != ROW_TYPE_DEFAULT)
2870
ptr=strxmov(ptr, " row_format=",
2871
ha_row_type[(uint) share->row_type],
2755
ptr+= sprintf(ptr, " row_format=%s", ha_row_type[(uint32_t)share->row_type]);
2873
2756
if (share->block_size)
2875
ptr= my_stpcpy(ptr, " block_size=");
2758
ptr= strcpy(ptr, " block_size=")+12;
2876
2759
ptr= int64_t10_to_str(share->block_size, ptr, 10);
2879
if (share->transactional != HA_CHOICE_UNDEF)
2881
ptr= strxmov(ptr, " TRANSACTIONAL=",
2882
(share->transactional == HA_CHOICE_YES ? "1" : "0"),
2885
if (share->transactional != HA_CHOICE_UNDEF)
2886
ptr= strxmov(ptr, " transactional=",
2887
ha_choice_values[(uint) share->transactional], NULL);
2888
2762
table->field[19]->store(option_buff+1,
2889
(ptr == option_buff ? 0 :
2890
(uint) (ptr-option_buff)-1), cs);
2763
(ptr == option_buff ? 0 :
2764
(uint32_t) (ptr-option_buff)-1), cs);
2892
2766
tmp_buff= (share->table_charset ?
2893
2767
share->table_charset->name : "default");
2952
2826
if (file->stats.create_time)
2954
2828
session->variables.time_zone->gmt_sec_to_TIME(&time,
2955
(my_time_t) file->stats.create_time);
2829
(time_t) file->stats.create_time);
2956
2830
table->field[14]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2957
2831
table->field[14]->set_notnull();
2959
2833
if (file->stats.update_time)
2961
2835
session->variables.time_zone->gmt_sec_to_TIME(&time,
2962
(my_time_t) file->stats.update_time);
2836
(time_t) file->stats.update_time);
2963
2837
table->field[15]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2964
2838
table->field[15]->set_notnull();
2966
2840
if (file->stats.check_time)
2968
2842
session->variables.time_zone->gmt_sec_to_TIME(&time,
2969
(my_time_t) file->stats.check_time);
2843
(time_t) file->stats.check_time);
2970
2844
table->field[16]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2971
2845
table->field[16]->set_notnull();
3296
3168
CHARSET_INFO **cl;
3297
3169
const CHARSET_INFO *tmp_cs= cs[0];
3298
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
3170
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
3299
3171
!(tmp_cs->state & MY_CS_PRIMARY))
3301
3173
for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
3303
3175
const CHARSET_INFO *tmp_cl= cl[0];
3304
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
3176
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
3305
3177
!my_charset_same(tmp_cs,tmp_cl))
3307
restore_record(table, s->default_values);
3179
table->restoreRecordAsDefault();
3308
3180
table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
3309
3181
table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
3310
3182
if (schema_table_store_record(session, table))
3393
3265
uint32_t flags= key_part->field ? key_part->field->flags : 0;
3394
3266
const char *pos=(char*) ((flags & NOT_NULL_FLAG) ? "" : "YES");
3395
3267
table->field[12]->store(pos, strlen(pos), cs);
3396
if (!show_table->s->keys_in_use.is_set(i))
3268
if (!show_table->s->keys_in_use.test(i))
3397
3269
table->field[14]->store(STRING_WITH_LEN("disabled"), cs);
3399
3271
table->field[14]->store("", 0, cs);
3400
3272
table->field[14]->set_notnull();
3401
assert(test(key_info->flags & HA_USES_COMMENT) ==
3273
assert(test(key_info->flags & HA_USES_COMMENT) ==
3402
3274
(key_info->comment.length > 0));
3403
3275
if (key_info->flags & HA_USES_COMMENT)
3404
table->field[15]->store(key_info->comment.str,
3276
table->field[15]->store(key_info->comment.str,
3405
3277
key_info->comment.length, cs);
3406
3278
if (schema_table_store_record(session, table))
3725
3597
List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
3726
3598
while ((f_key_info= it++))
3728
restore_record(table, s->default_values);
3600
table->restoreRecordAsDefault();
3729
3601
table->field[1]->store(db_name->str, db_name->length, cs);
3730
3602
table->field[9]->store(table_name->str, table_name->length, cs);
3731
3603
table->field[2]->store(f_key_info->forein_id->str,
3732
3604
f_key_info->forein_id->length, cs);
3733
table->field[4]->store(f_key_info->referenced_db->str,
3605
table->field[4]->store(f_key_info->referenced_db->str,
3734
3606
f_key_info->referenced_db->length, cs);
3735
table->field[10]->store(f_key_info->referenced_table->str,
3607
table->field[10]->store(f_key_info->referenced_table->str,
3736
3608
f_key_info->referenced_table->length, cs);
3737
3609
if (f_key_info->referenced_key_name)
3739
table->field[5]->store(f_key_info->referenced_key_name->str,
3611
table->field[5]->store(f_key_info->referenced_key_name->str,
3740
3612
f_key_info->referenced_key_name->length, cs);
3741
3613
table->field[5]->set_notnull();
3744
3616
table->field[5]->set_null();
3745
3617
table->field[6]->store(STRING_WITH_LEN("NONE"), cs);
3746
table->field[7]->store(f_key_info->update_method->str,
3618
table->field[7]->store(f_key_info->update_method->str,
3747
3619
f_key_info->update_method->length, cs);
3748
table->field[8]->store(f_key_info->delete_method->str,
3620
table->field[8]->store(f_key_info->delete_method->str,
3749
3621
f_key_info->delete_method->length, cs);
3750
3622
if (schema_table_store_record(session, table))
3923
3769
item->maybe_null= (fields_info->field_flags & MY_I_S_MAYBE_NULL);
3926
TMP_TABLE_PARAM *tmp_table_param =
3927
(TMP_TABLE_PARAM*) (session->alloc(sizeof(TMP_TABLE_PARAM)));
3772
Tmp_Table_Param *tmp_table_param =
3773
(Tmp_Table_Param*) (session->alloc(sizeof(Tmp_Table_Param)));
3928
3774
tmp_table_param->init();
3929
3775
tmp_table_param->table_charset= cs;
3930
3776
tmp_table_param->field_count= field_count;
3931
3777
tmp_table_param->schema_table= 1;
3932
SELECT_LEX *select_lex= session->lex->current_select;
3778
Select_Lex *select_lex= session->lex->current_select;
3933
3779
if (!(table= create_tmp_table(session, tmp_table_param,
3934
field_list, (order_st*) 0, 0, 0,
3780
field_list, (order_st*) 0, 0, 0,
3935
3781
(select_lex->options | session->options |
3936
3782
TMP_TABLE_ALL_COLUMNS),
3937
3783
HA_POS_ERROR, table_list->alias)))
4143
3989
session->derived_tables= table;
4144
3990
table_list->select_lex->options |= OPTION_SCHEMA_TABLE;
4146
if (table_list->schema_table_reformed) // show command
4148
SELECT_LEX *sel= lex->current_select;
4150
Field_translator *transl, *org_transl;
4152
if (table_list->field_translation)
4154
Field_translator *end= table_list->field_translation_end;
4155
for (transl= table_list->field_translation; transl < end; transl++)
4157
if (!transl->item->fixed &&
4158
transl->item->fix_fields(session, &transl->item))
4163
List_iterator_fast<Item> it(sel->item_list);
4165
(Field_translator*)(session->alloc(sel->item_list.elements *
4166
sizeof(Field_translator)))))
4170
for (org_transl= transl; (item= it++); transl++)
4173
transl->name= item->name;
4174
if (!item->fixed && item->fix_fields(session, &transl->item))
4179
table_list->field_translation= org_transl;
4180
table_list->field_translation_end= transl;
4333
4142
{"ROW_FORMAT", 10, DRIZZLE_TYPE_VARCHAR, 0, 1, "Row_format", OPEN_FULL_TABLE},
4334
4143
{"TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4335
4144
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Rows", OPEN_FULL_TABLE},
4336
{"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4145
{"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4337
4146
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Avg_row_length", OPEN_FULL_TABLE},
4338
{"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4147
{"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4339
4148
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_length", OPEN_FULL_TABLE},
4340
4149
{"MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4341
4150
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Max_data_length", OPEN_FULL_TABLE},
4342
{"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4151
{"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4343
4152
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Index_length", OPEN_FULL_TABLE},
4344
4153
{"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4345
4154
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free", OPEN_FULL_TABLE},
4346
{"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG, 0,
4155
{"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG, 0,
4347
4156
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Auto_increment", OPEN_FULL_TABLE},
4348
4157
{"CREATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Create_time", OPEN_FULL_TABLE},
4349
4158
{"UPDATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Update_time", OPEN_FULL_TABLE},
4543
4352
ST_FIELD_INFO plugin_fields_info[]=
4545
{"PLUGIN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name",
4354
{"PLUGIN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name",
4546
4355
SKIP_OPEN_TABLE},
4547
4356
{"PLUGIN_VERSION", 20, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4548
4357
{"PLUGIN_STATUS", 10, DRIZZLE_TYPE_VARCHAR, 0, 0, "Status", SKIP_OPEN_TABLE},
4549
{"PLUGIN_TYPE", 80, DRIZZLE_TYPE_VARCHAR, 0, 0, "Type", SKIP_OPEN_TABLE},
4550
{"PLUGIN_LIBRARY", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Library",
4552
4358
{"PLUGIN_AUTHOR", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4553
4359
{"PLUGIN_DESCRIPTION", 65535, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4554
4360
{"PLUGIN_LICENSE", 80, DRIZZLE_TYPE_VARCHAR, 0, 1, "License", SKIP_OPEN_TABLE},
4588
ST_SCHEMA_TABLE schema_tables[]=
4394
InfoSchemaTable schema_tables[]=
4590
{"CHARACTER_SETS", charsets_fields_info, create_schema_table,
4396
{"CHARACTER_SETS", charsets_fields_info, create_schema_table,
4591
4397
fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0},
4592
{"COLLATIONS", collation_fields_info, create_schema_table,
4398
{"COLLATIONS", collation_fields_info, create_schema_table,
4593
4399
fill_schema_collation, make_old_format, 0, -1, -1, 0, 0},
4594
4400
{"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
4595
4401
create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, 0},
4596
{"COLUMNS", columns_fields_info, create_schema_table,
4402
{"COLUMNS", columns_fields_info, create_schema_table,
4597
4403
get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0,
4598
4404
OPTIMIZE_I_S_TABLE},
4599
4405
{"GLOBAL_STATUS", variables_fields_info, create_schema_table,
4618
4424
fill_status, make_old_format, 0, -1, -1, 0, 0},
4619
4425
{"SESSION_VARIABLES", variables_fields_info, create_schema_table,
4620
4426
fill_variables, make_old_format, 0, -1, -1, 0, 0},
4621
{"STATISTICS", stat_fields_info, create_schema_table,
4427
{"STATISTICS", stat_fields_info, create_schema_table,
4622
4428
get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0,
4623
4429
OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE},
4624
{"STATUS", variables_fields_info, create_schema_table, fill_status,
4430
{"STATUS", variables_fields_info, create_schema_table, fill_status,
4625
4431
make_old_format, 0, -1, -1, 1, 0},
4626
{"TABLES", tables_fields_info, create_schema_table,
4432
{"TABLES", tables_fields_info, create_schema_table,
4627
4433
get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0,
4628
4434
OPTIMIZE_I_S_TABLE},
4629
4435
{"TABLE_CONSTRAINTS", table_constraints_fields_info, create_schema_table,
4635
4441
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
4639
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
4640
template class List_iterator_fast<char>;
4641
template class List<char>;
4644
int initialize_schema_table(st_plugin_int *plugin)
4646
ST_SCHEMA_TABLE *schema_table;
4648
if (!(schema_table= (ST_SCHEMA_TABLE *)my_malloc(sizeof(ST_SCHEMA_TABLE),
4649
MYF(MY_WME | MY_ZEROFILL))))
4651
/* Historical Requirement */
4652
plugin->data= schema_table; // shortcut for the future
4653
if (plugin->plugin->init)
4655
schema_table->create_table= create_schema_table;
4656
schema_table->old_format= make_old_format;
4657
schema_table->idx_field1= -1,
4658
schema_table->idx_field2= -1;
4660
/* Make the name available to the init() function. */
4661
schema_table->table_name= plugin->name.str;
4663
if (plugin->plugin->init(schema_table))
4665
sql_print_error(_("Plugin '%s' init function returned error."),
4670
/* Make sure the plugin name is not set inside the init() function. */
4671
schema_table->table_name= plugin->name.str;
4680
int finalize_schema_table(st_plugin_int *plugin)
4682
ST_SCHEMA_TABLE *schema_table= (ST_SCHEMA_TABLE *)plugin->data;
4684
if (schema_table && plugin->plugin->deinit)