1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
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.
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
1
/* Copyright (C) 2000-2004 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21
17
/* Function with list databases, tables or fields */
22
18
#include <drizzled/server_includes.h>
23
19
#include <drizzled/sql_select.h>
24
#include <drizzled/show.h>
20
#include <drizzled/sql_show.h>
21
#include "repl_failsafe.h"
25
22
#include <mysys/my_dir.h>
26
#include <drizzled/gettext.h>
27
#include <drizzled/util/convert.h>
28
#include <drizzled/error.h>
29
#include <drizzled/tztime.h>
30
#include <drizzled/data_home.h>
31
#include <drizzled/item/blob.h>
32
#include <drizzled/item/cmpfunc.h>
33
#include <drizzled/item/return_int.h>
34
#include <drizzled/item/empty_string.h>
35
#include <drizzled/item/return_date_time.h>
36
#include <drizzled/virtual_column_info.h>
37
#include <drizzled/sql_base.h>
38
#include <drizzled/db.h>
39
#include <drizzled/field/timestamp.h>
40
#include <drizzled/field/decimal.h>
41
#include <drizzled/lock.h>
42
#include <drizzled/item/return_date_time.h>
43
#include <drizzled/item/empty_string.h>
52
str_or_nil(const char *str)
54
return str ? str : "<nil>";
24
#define STR_OR_NIL(S) ((S) ? (S) : "<nil>")
57
26
/* Match the values of enum ha_choice */
58
27
static const char *ha_choice_values[] = {"", "0", "1"};
60
static void store_key_options(Session *session, String *packet, Table *table,
29
static void store_key_options(THD *thd, String *packet, TABLE *table,
181
150
switch (plug->license) {
182
151
case PLUGIN_LICENSE_GPL:
183
table->field[7]->store(PLUGIN_LICENSE_GPL_STRING,
152
table->field[7]->store(PLUGIN_LICENSE_GPL_STRING,
184
153
strlen(PLUGIN_LICENSE_GPL_STRING), cs);
186
155
case PLUGIN_LICENSE_BSD:
187
table->field[7]->store(PLUGIN_LICENSE_BSD_STRING,
156
table->field[7]->store(PLUGIN_LICENSE_BSD_STRING,
188
157
strlen(PLUGIN_LICENSE_BSD_STRING), cs);
191
table->field[7]->store(PLUGIN_LICENSE_PROPRIETARY_STRING,
160
table->field[7]->store(PLUGIN_LICENSE_PROPRIETARY_STRING,
192
161
strlen(PLUGIN_LICENSE_PROPRIETARY_STRING), cs);
195
164
table->field[7]->set_notnull();
197
return schema_table_store_record(session, table);
166
return schema_table_store_record(thd, table);
201
int fill_plugins(Session *session, TableList *tables, COND *)
170
int fill_plugins(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
203
Table *table= tables->table;
172
TABLE *table= tables->table;
205
if (plugin_foreach_with_mask(session, show_plugins, DRIZZLE_ANY_PLUGIN,
174
if (plugin_foreach_with_mask(thd, show_plugins, DRIZZLE_ANY_PLUGIN,
206
175
~PLUGIN_IS_FREED, table))
332
mysqld_show_create(Session *session, TableList *table_list)
301
mysqld_show_create(THD *thd, TABLE_LIST *table_list)
334
Protocol *protocol= session->protocol;
303
Protocol *protocol= thd->protocol;
336
305
String buffer(buff, sizeof(buff), system_charset_info);
338
307
/* Only one table for now, but VIEW can involve several tables */
339
if (open_normal_and_derived_tables(session, table_list, 0))
308
if (open_normal_and_derived_tables(thd, table_list, 0))
341
if (session->is_error())
310
if (thd->is_error() && thd->main_da.sql_errno() != ER_VIEW_INVALID)
345
314
Clear all messages with 'error' level status and
346
issue a warning with 'warning' level status in
315
issue a warning with 'warning' level status in
347
316
case of invalid view and last error is ER_VIEW_INVALID
349
drizzle_reset_errors(session, true);
350
session->clear_error();
318
drizzle_reset_errors(thd, true);
353
322
buffer.length(0);
355
if (store_create_info(session, table_list, &buffer, NULL))
324
if (store_create_info(thd, table_list, &buffer, NULL))
358
327
List<Item> field_list;
568
537
# Quote character
571
int get_quote_char_for_identifier(Session *session, const char *name, uint32_t length)
540
int get_quote_char_for_identifier(THD *thd, const char *name, uint length)
574
543
!is_keyword(name,length) &&
575
544
!require_quotes(name, length) &&
576
!(session->options & OPTION_QUOTE_SHOW_CREATE))
545
!(thd->options & OPTION_QUOTE_SHOW_CREATE))
582
551
/* Append directory name (if exists) to CREATE INFO */
584
static void append_directory(Session *,
553
static void append_directory(THD *thd __attribute__((unused)),
585
554
String *packet, const char *dir_type,
586
const char *filename)
555
const char *filename)
590
uint32_t length= dirname_length(filename);
559
uint length= dirname_length(filename);
591
560
packet->append(' ');
592
561
packet->append(dir_type);
593
562
packet->append(STRING_WITH_LEN(" DIRECTORY='"));
667
636
to tailor the format of the statement. Can be
668
637
NULL, in which case only SQL_MODE is considered
669
638
when building the statement.
672
641
Currently always return 0, but might return error code in the
679
int store_create_info(Session *session, TableList *table_list, String *packet,
648
int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
680
649
HA_CREATE_INFO *create_info_arg)
682
651
List<Item> field_list;
683
char tmp[MAX_FIELD_WIDTH], *for_str, def_value_buf[MAX_FIELD_WIDTH];
652
char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], def_value_buf[MAX_FIELD_WIDTH];
684
653
const char *alias;
686
654
String type(tmp, sizeof(tmp), system_charset_info);
687
655
String def_value(def_value_buf, sizeof(def_value_buf), system_charset_info);
688
656
Field **ptr,*field;
689
uint32_t primary_key;
691
Table *table= table_list->table;
659
TABLE *table= table_list->table;
692
660
handler *file= table->file;
693
661
TABLE_SHARE *share= table->s;
694
662
HA_CREATE_INFO create_info;
715
683
alias= share->table_name.str;
718
append_identifier(session, packet, alias, strlen(alias));
686
append_identifier(thd, packet, alias, strlen(alias));
719
687
packet->append(STRING_WITH_LEN(" (\n"));
721
689
We need this to get default values from the table
722
690
We have to restore the read_set if we are called from insert in case
723
691
of row based replication.
725
old_map= table->use_all_columns(table->read_set);
693
old_map= tmp_use_all_columns(table, table->read_set);
727
695
for (ptr=table->field ; (field= *ptr); ptr++)
729
uint32_t flags = field->flags;
697
uint flags = field->flags;
731
699
if (ptr != table->field)
732
700
packet->append(STRING_WITH_LEN(",\n"));
734
702
packet->append(STRING_WITH_LEN(" "));
735
append_identifier(session,packet,field->field_name, strlen(field->field_name));
703
append_identifier(thd,packet,field->field_name, strlen(field->field_name));
736
704
packet->append(' ');
737
705
// check for surprises from the previous call to Field::sql_type()
738
706
if (type.ptr() != tmp)
854
805
packet->append(STRING_WITH_LEN("KEY "));
856
807
if (!found_primary)
857
append_identifier(session, packet, key_info->name, strlen(key_info->name));
808
append_identifier(thd, packet, key_info->name, strlen(key_info->name));
859
810
packet->append(STRING_WITH_LEN(" ("));
861
for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
812
for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
864
815
packet->append(',');
866
817
if (key_part->field)
867
append_identifier(session,packet,key_part->field->field_name,
818
append_identifier(thd,packet,key_part->field->field_name,
868
819
strlen(key_part->field->field_name));
869
820
if (key_part->field &&
870
821
(key_part->length !=
871
822
table->field[key_part->fieldnr-1]->key_length()))
874
buff= to_string(buff, (int32_t) key_part->length /
875
key_part->field->charset()->mbmaxlen);
877
packet->append(buff.c_str(), buff.length());
826
end= int10_to_str((long) key_part->length /
827
key_part->field->charset()->mbmaxlen,
830
packet->append(buff,(uint) (end-buff));
880
833
packet->append(')');
881
store_key_options(session, packet, table, key_info);
834
store_key_options(thd, packet, table, key_info);
925
878
if (create_info.auto_increment_value > 1)
927
881
packet->append(STRING_WITH_LEN(" AUTO_INCREMENT="));
928
buff= to_string(create_info.auto_increment_value);
929
packet->append(buff.c_str(), buff.length());
882
end= int64_t10_to_str(create_info.auto_increment_value, buff,10);
883
packet->append(buff, (uint) (end - buff));
887
if (share->table_charset)
891
THEN add DEFAULT CHARSET only if it was used when creating the table
893
if (!create_info_arg ||
894
(create_info_arg->used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
896
packet->append(STRING_WITH_LEN(" DEFAULT CHARSET="));
897
packet->append(share->table_charset->csname);
898
if (!(share->table_charset->state & MY_CS_PRIMARY))
900
packet->append(STRING_WITH_LEN(" COLLATE="));
901
packet->append(table->s->table_charset->name);
932
906
if (share->min_rows)
934
909
packet->append(STRING_WITH_LEN(" MIN_ROWS="));
935
buff= to_string(share->min_rows);
936
packet->append(buff.c_str(), buff.length());
910
end= int64_t10_to_str(share->min_rows, buff, 10);
911
packet->append(buff, (uint) (end- buff));
939
914
if (share->max_rows && !table_list->schema_table)
941
917
packet->append(STRING_WITH_LEN(" MAX_ROWS="));
942
buff= to_string(share->max_rows);
943
packet->append(buff.c_str(), buff.length());
918
end= int64_t10_to_str(share->max_rows, buff, 10);
919
packet->append(buff, (uint) (end - buff));
946
922
if (share->avg_row_length)
948
925
packet->append(STRING_WITH_LEN(" AVG_ROW_LENGTH="));
949
buff= to_string(share->avg_row_length);
950
packet->append(buff.c_str(), buff.length());
926
end= int64_t10_to_str(share->avg_row_length, buff,10);
927
packet->append(buff, (uint) (end - buff));
953
930
if (share->db_create_options & HA_OPTION_PACK_KEYS)
1017
996
the resulting CREATE statement contains "IF NOT EXISTS" clause. Other flags
1018
997
in @c create_options are ignored.
1020
@param session The current thread instance.
999
@param thd The current thread instance.
1021
1000
@param dbname The name of the database.
1022
1001
@param buffer A String instance where the statement is stored.
1023
@param create_info If not NULL, the options member influences the resulting
1002
@param create_info If not NULL, the options member influences the resulting
1024
1003
CRATE statement.
1026
1005
@returns true if errors are detected, false otherwise.
1029
bool store_db_create_info(Session *session, const char *dbname, String *buffer,
1008
bool store_db_create_info(THD *thd, const char *dbname, String *buffer,
1030
1009
HA_CREATE_INFO *create_info)
1032
1011
HA_CREATE_INFO create;
1033
uint32_t create_options = create_info ? create_info->options : 0;
1012
uint create_options = create_info ? create_info->options : 0;
1035
1014
if (!my_strcasecmp(system_charset_info, dbname,
1036
INFORMATION_SCHEMA_NAME.c_str()))
1015
INFORMATION_SCHEMA_NAME.str))
1038
dbname= INFORMATION_SCHEMA_NAME.c_str();
1017
dbname= INFORMATION_SCHEMA_NAME.str;
1039
1018
create.default_table_charset= system_charset_info;
1152
1132
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1155
pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
1156
if (!session->killed)
1135
VOID(pthread_mutex_lock(&LOCK_thread_count)); // For unlink from list
1158
I_List_iterator<Session> it(threads);
1138
I_List_iterator<THD> it(threads);
1160
1140
while ((tmp=it++))
1162
Security_context *tmp_sctx= &tmp->security_ctx;
1142
Security_context *tmp_sctx= tmp->security_ctx;
1163
1143
struct st_my_thread_var *mysys_var;
1164
if ((tmp->vio_ok() || tmp->system_thread) && (!user || (tmp_sctx->user.c_str() && !strcmp(tmp_sctx->user.c_str(), user))))
1144
if ((tmp->vio_ok() || tmp->system_thread) && (!user || (tmp_sctx->user && !strcmp(tmp_sctx->user, user))))
1166
thread_info *session_info= new thread_info;
1146
thread_info *thd_info= new thread_info;
1168
session_info->thread_id=tmp->thread_id;
1169
session_info->user= session->strdup(tmp_sctx->user.c_str() ? tmp_sctx->user.c_str() :
1148
thd_info->thread_id=tmp->thread_id;
1149
thd_info->user= thd->strdup(tmp_sctx->user ? tmp_sctx->user :
1170
1150
(tmp->system_thread ?
1171
1151
"system user" : "unauthenticated user"));
1172
session_info->host= session->strdup(tmp_sctx->ip.c_str());
1173
if ((session_info->db=tmp->db)) // Safe test
1174
session_info->db=session->strdup(session_info->db);
1175
session_info->command=(int) tmp->command;
1152
thd_info->host= thd->strdup(tmp_sctx->ip);
1153
if ((thd_info->db=tmp->db)) // Safe test
1154
thd_info->db=thd->strdup(thd_info->db);
1155
thd_info->command=(int) tmp->command;
1176
1156
if ((mysys_var= tmp->mysys_var))
1177
1157
pthread_mutex_lock(&mysys_var->mutex);
1178
session_info->proc_info= (char*) (tmp->killed == Session::KILL_CONNECTION? "Killed" : 0);
1179
session_info->state_info= (char*) (tmp->net.reading_or_writing ?
1158
thd_info->proc_info= (char*) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0);
1159
thd_info->state_info= (char*) (tmp->net.reading_or_writing ?
1180
1160
(tmp->net.reading_or_writing == 2 ?
1181
1161
"Writing to net" :
1182
session_info->command == COM_SLEEP ? NULL :
1162
thd_info->command == COM_SLEEP ? NullS :
1183
1163
"Reading from net") :
1184
tmp->get_proc_info() ? tmp->get_proc_info() :
1164
tmp->proc_info ? tmp->proc_info :
1185
1165
tmp->mysys_var &&
1186
1166
tmp->mysys_var->current_cond ?
1187
"Waiting on cond" : NULL);
1167
"Waiting on cond" : NullS);
1189
1169
pthread_mutex_unlock(&mysys_var->mutex);
1191
session_info->start_time= tmp->start_time;
1192
session_info->query=0;
1171
thd_info->start_time= tmp->start_time;
1193
1173
if (tmp->query)
1196
1176
query_length is always set to 0 when we set query = NULL; see
1197
the comment in session.h why this prevents crashes in possible
1177
the comment in sql_class.h why this prevents crashes in possible
1198
1178
races with query_length
1200
uint32_t length= cmin((uint32_t)max_query_length, tmp->query_length);
1201
session_info->query=(char*) session->strmake(tmp->query,length);
1180
uint length= min((uint32_t)max_query_length, tmp->query_length);
1181
thd_info->query=(char*) thd->strmake(tmp->query,length);
1203
thread_infos.append(session_info);
1183
thread_infos.append(thd_info);
1207
pthread_mutex_unlock(&LOCK_thread_count);
1187
VOID(pthread_mutex_unlock(&LOCK_thread_count));
1209
thread_info *session_info;
1210
time_t now= time(NULL);
1211
while ((session_info=thread_infos.get()))
1189
thread_info *thd_info;
1190
time_t now= my_time(0);
1191
while ((thd_info=thread_infos.get()))
1213
1193
protocol->prepare_for_resend();
1214
protocol->store((uint64_t) session_info->thread_id);
1215
protocol->store(session_info->user, system_charset_info);
1216
protocol->store(session_info->host, system_charset_info);
1217
protocol->store(session_info->db, system_charset_info);
1218
if (session_info->proc_info)
1219
protocol->store(session_info->proc_info, system_charset_info);
1194
protocol->store((uint64_t) thd_info->thread_id);
1195
protocol->store(thd_info->user, system_charset_info);
1196
protocol->store(thd_info->host, system_charset_info);
1197
protocol->store(thd_info->db, system_charset_info);
1198
if (thd_info->proc_info)
1199
protocol->store(thd_info->proc_info, system_charset_info);
1221
protocol->store(command_name[session_info->command].str, system_charset_info);
1222
if (session_info->start_time)
1223
protocol->store((uint32_t) (now - session_info->start_time));
1201
protocol->store(command_name[thd_info->command].str, system_charset_info);
1202
if (thd_info->start_time)
1203
protocol->store((uint32_t) (now - thd_info->start_time));
1225
1205
protocol->store_null();
1226
protocol->store(session_info->state_info, system_charset_info);
1227
protocol->store(session_info->query, system_charset_info);
1206
protocol->store(thd_info->state_info, system_charset_info);
1207
protocol->store(thd_info->query, system_charset_info);
1228
1208
if (protocol->write())
1229
1209
break; /* purecov: inspected */
1235
int fill_schema_processlist(Session* session, TableList* tables, COND*)
1215
int fill_schema_processlist(THD* thd, TABLE_LIST* tables,
1216
COND* cond __attribute__((unused)))
1237
Table *table= tables->table;
1218
TABLE *table= tables->table;
1238
1219
const CHARSET_INFO * const cs= system_charset_info;
1240
time_t now= time(NULL);
1242
if (now == (time_t)-1)
1247
pthread_mutex_lock(&LOCK_thread_count);
1249
if (!session->killed)
1221
time_t now= my_time(0);
1225
VOID(pthread_mutex_lock(&LOCK_thread_count));
1251
I_List_iterator<Session> it(threads);
1229
I_List_iterator<THD> it(threads);
1254
1232
while ((tmp= it++))
1256
Security_context *tmp_sctx= &tmp->security_ctx;
1234
Security_context *tmp_sctx= tmp->security_ctx;
1257
1235
struct st_my_thread_var *mysys_var;
1258
1236
const char *val;
1735
int make_table_list(Session *session, SELECT_LEX *sel,
1702
int make_table_list(THD *thd, SELECT_LEX *sel,
1736
1703
LEX_STRING *db_name, LEX_STRING *table_name)
1738
1705
Table_ident *table_ident;
1739
table_ident= new Table_ident(session, *db_name, *table_name, 1);
1706
table_ident= new Table_ident(thd, *db_name, *table_name, 1);
1740
1707
sel->init_query();
1741
if (!sel->add_table_to_list(session, table_ident, 0, 0, TL_READ))
1708
if (!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ))
1748
@brief Get lookup value from the part of 'WHERE' condition
1715
@brief Get lookup value from the part of 'WHERE' condition
1750
@details This function gets lookup value from
1751
the part of 'WHERE' condition if it's possible and
1717
@details This function gets lookup value from
1718
the part of 'WHERE' condition if it's possible and
1752
1719
fill appropriate lookup_field_vals struct field
1753
1720
with this value.
1755
@param[in] session thread handler
1722
@param[in] thd thread handler
1756
1723
@param[in] item_func part of WHERE condition
1757
1724
@param[in] table I_S table
1758
@param[in, out] lookup_field_vals Struct which holds lookup values
1725
@param[in, out] lookup_field_vals Struct which holds lookup values
1762
1729
1 error, there can be no matching records for the condition
1765
bool get_lookup_value(Session *session, Item_func *item_func,
1732
bool get_lookup_value(THD *thd, Item_func *item_func,
1767
1734
LOOKUP_FIELD_VALUES *lookup_field_vals)
1769
1736
ST_SCHEMA_TABLE *schema_table= table->schema_table;
1809
1776
/* Lookup value is database name */
1810
if (!cs->coll->strnncollsp(cs, (unsigned char *) field_name1, strlen(field_name1),
1811
(unsigned char *) item_field->field_name,
1777
if (!cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
1778
(uchar *) item_field->field_name,
1812
1779
strlen(item_field->field_name), 0))
1814
session->make_lex_string(&lookup_field_vals->db_value, tmp_str->ptr(),
1781
thd->make_lex_string(&lookup_field_vals->db_value, tmp_str->ptr(),
1815
1782
tmp_str->length(), false);
1817
1784
/* Lookup value is table name */
1818
else if (!cs->coll->strnncollsp(cs, (unsigned char *) field_name2,
1785
else if (!cs->coll->strnncollsp(cs, (uchar *) field_name2,
1819
1786
strlen(field_name2),
1820
(unsigned char *) item_field->field_name,
1787
(uchar *) item_field->field_name,
1821
1788
strlen(item_field->field_name), 0))
1823
session->make_lex_string(&lookup_field_vals->table_value, tmp_str->ptr(),
1790
thd->make_lex_string(&lookup_field_vals->table_value, tmp_str->ptr(),
1824
1791
tmp_str->length(), false);
1832
@brief Calculates lookup values from 'WHERE' condition
1799
@brief Calculates lookup values from 'WHERE' condition
1834
1801
@details This function calculates lookup value(database name, table name)
1835
from 'WHERE' condition if it's possible and
1802
from 'WHERE' condition if it's possible and
1836
1803
fill lookup_field_vals struct fields with these values.
1838
@param[in] session thread handler
1805
@param[in] thd thread handler
1839
1806
@param[in] cond WHERE condition
1840
1807
@param[in] table I_S table
1841
@param[in, out] lookup_field_vals Struct which holds lookup values
1808
@param[in, out] lookup_field_vals Struct which holds lookup values
1845
1812
1 error, there can be no matching records for the condition
1848
bool calc_lookup_values_from_cond(Session *session, COND *cond, TableList *table,
1815
bool calc_lookup_values_from_cond(THD *thd, COND *cond, TABLE_LIST *table,
1849
1816
LOOKUP_FIELD_VALUES *lookup_field_vals)
1902
1869
const char *field_name2= schema_table->idx_field2 >= 0 ?
1903
1870
field_info[schema_table->idx_field2].field_name : "";
1904
1871
if (table->table != item_field->field->table ||
1905
(cs->coll->strnncollsp(cs, (unsigned char *) field_name1, strlen(field_name1),
1906
(unsigned char *) item_field->field_name,
1872
(cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
1873
(uchar *) item_field->field_name,
1907
1874
strlen(item_field->field_name), 0) &&
1908
cs->coll->strnncollsp(cs, (unsigned char *) field_name2, strlen(field_name2),
1909
(unsigned char *) item_field->field_name,
1875
cs->coll->strnncollsp(cs, (uchar *) field_name2, strlen(field_name2),
1876
(uchar *) item_field->field_name,
1910
1877
strlen(item_field->field_name), 0)))
1984
1951
from LEX struct and fill lookup_field_vals struct field
1985
1952
with these values.
1987
@param[in] session thread handler
1954
@param[in] thd thread handler
1988
1955
@param[in] cond WHERE condition
1989
1956
@param[in] tables I_S table
1990
@param[in, out] lookup_field_values Struct which holds lookup values
1957
@param[in, out] lookup_field_values Struct which holds lookup values
1994
1961
1 error, there can be no matching records for the condition
1997
bool get_lookup_field_values(Session *session, COND *cond, TableList *tables,
1964
bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables,
1998
1965
LOOKUP_FIELD_VALUES *lookup_field_values)
2000
LEX *lex= session->lex;
2001
const char *wild= lex->wild ? lex->wild->ptr() : NULL;
1968
const char *wild= lex->wild ? lex->wild->ptr() : NullS;
2002
1969
memset(lookup_field_values, 0, sizeof(LOOKUP_FIELD_VALUES));
2003
1970
switch (lex->sql_command) {
2004
1971
case SQLCOM_SHOW_DATABASES:
2044
session thread handler
2045
2012
files list of db names
2046
2013
wild wild string
2047
2014
idx_field_vals idx_field_vals->db_name contains db name or
2049
2016
with_i_schema returns 1 if we added 'IS' name to list
2057
int make_db_list(Session *session, List<LEX_STRING> *files,
2024
int make_db_list(THD *thd, List<LEX_STRING> *files,
2058
2025
LOOKUP_FIELD_VALUES *lookup_field_vals,
2059
2026
bool *with_i_schema)
2061
2028
LEX_STRING *i_s_name_copy= 0;
2062
i_s_name_copy= session->make_lex_string(i_s_name_copy,
2063
INFORMATION_SCHEMA_NAME.c_str(),
2064
INFORMATION_SCHEMA_NAME.length(), true);
2029
i_s_name_copy= thd->make_lex_string(i_s_name_copy,
2030
INFORMATION_SCHEMA_NAME.str,
2031
INFORMATION_SCHEMA_NAME.length, true);
2065
2032
*with_i_schema= 0;
2066
2033
if (lookup_field_vals->wild_db_value)
2287
2254
@retval 1 error
2291
fill_schema_show_cols_or_idxs(Session *session, TableList *tables,
2258
fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables,
2292
2259
ST_SCHEMA_TABLE *schema_table,
2293
2260
Open_tables_state *open_tables_state_backup)
2295
LEX *lex= session->lex;
2297
2264
LEX_STRING tmp_lex_string, tmp_lex_string1, *db_name, *table_name;
2298
2265
enum_sql_command save_sql_command= lex->sql_command;
2299
TableList *show_table_list= (TableList*) tables->schema_select_lex->
2266
TABLE_LIST *show_table_list= (TABLE_LIST*) tables->schema_select_lex->
2300
2267
table_list.first;
2301
Table *table= tables->table;
2268
TABLE *table= tables->table;
2304
2271
lex->all_selects_list= tables->schema_select_lex;
2306
Restore session->temporary_tables to be able to process
2273
Restore thd->temporary_tables to be able to process
2307
2274
temporary tables(only for 'show index' & 'show columns').
2308
2275
This should be changed when processing of temporary tables for
2309
2276
I_S tables will be done.
2311
session->temporary_tables= open_tables_state_backup->temporary_tables;
2278
thd->temporary_tables= open_tables_state_backup->temporary_tables;
2313
2280
Let us set fake sql_command so views won't try to merge
2314
2281
themselves into main statement. If we don't do this,
2315
2282
SELECT * from information_schema.xxxx will cause problems.
2316
SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()'
2283
SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()'
2318
2285
lex->sql_command= SQLCOM_SHOW_FIELDS;
2319
res= open_normal_and_derived_tables(session, show_table_list,
2286
res= open_normal_and_derived_tables(thd, show_table_list,
2320
2287
DRIZZLE_LOCK_IGNORE_FLUSH);
2321
2288
lex->sql_command= save_sql_command;
2323
2290
get_all_tables() returns 1 on failure and 0 on success thus
2324
2291
return only these and not the result code of ::process_table()
2326
We should use show_table_list->alias instead of
2293
We should use show_table_list->alias instead of
2327
2294
show_table_list->table_name because table_name
2328
2295
could be changed during opening of I_S tables. It's safe
2329
to use alias because alias contains original table name
2330
in this case(this part of code is used only for
2296
to use alias because alias contains original table name
2297
in this case(this part of code is used only for
2331
2298
'show columns' & 'show statistics' commands).
2333
table_name= session->make_lex_string(&tmp_lex_string1, show_table_list->alias,
2300
table_name= thd->make_lex_string(&tmp_lex_string1, show_table_list->alias,
2334
2301
strlen(show_table_list->alias), false);
2335
db_name= session->make_lex_string(&tmp_lex_string, show_table_list->db,
2302
db_name= thd->make_lex_string(&tmp_lex_string, show_table_list->db,
2336
2303
show_table_list->db_length, false);
2339
error= test(schema_table->process_table(session, show_table_list,
2306
error= test(schema_table->process_table(thd, show_table_list,
2340
2307
table, res, db_name,
2342
session->temporary_tables= 0;
2343
close_tables_for_reopen(session, &show_table_list);
2309
thd->temporary_tables= 0;
2310
close_tables_for_reopen(thd, &show_table_list);
2349
@brief Fill I_S table for SHOW Table NAMES commands
2316
@brief Fill I_S table for SHOW TABLE NAMES commands
2351
@param[in] session thread handler
2352
@param[in] table Table struct for I_S table
2318
@param[in] thd thread handler
2319
@param[in] table TABLE struct for I_S table
2353
2320
@param[in] db_name database name
2354
2321
@param[in] table_name table name
2355
2322
@param[in] with_i_schema I_S table if true
2340
enum legacy_db_type not_used;
2373
2341
char path[FN_REFLEN];
2374
(void) build_table_filename(path, sizeof(path), db_name->str,
2342
(void) build_table_filename(path, sizeof(path), db_name->str,
2375
2343
table_name->str, reg_ext, 0);
2377
table->field[3]->store(STRING_WITH_LEN("BASE Table"),
2378
system_charset_info);
2380
if (session->is_error() && session->main_da.sql_errno() == ER_NO_SUCH_TABLE)
2344
switch (mysql_frm_type(thd, path, ¬_used)) {
2346
table->field[3]->store(STRING_WITH_LEN("ERROR"),
2347
system_charset_info);
2350
table->field[3]->store(STRING_WITH_LEN("BASE TABLE"),
2351
system_charset_info);
2356
if (thd->is_error() && thd->main_da.sql_errno() == ER_NO_SUCH_TABLE)
2382
session->clear_error();
2386
if (schema_table_store_record(session, table))
2362
if (schema_table_store_record(thd, table))
2446
2422
open_tables function for this table
2449
static int fill_schema_table_from_frm(Session *session,TableList *tables,
2425
static int fill_schema_table_from_frm(THD *thd,TABLE_LIST *tables,
2450
2426
ST_SCHEMA_TABLE *schema_table,
2451
2427
LEX_STRING *db_name,
2452
2428
LEX_STRING *table_name,
2453
enum enum_schema_tables)
2429
enum enum_schema_tables schema_table_idx __attribute__((unused)))
2455
Table *table= tables->table;
2431
TABLE *table= tables->table;
2456
2432
TABLE_SHARE *share;
2458
TableList table_list;
2434
TABLE_LIST table_list;
2461
2437
char key[MAX_DBKEY_LENGTH];
2462
uint32_t key_length;
2464
memset(&table_list, 0, sizeof(TableList));
2465
memset(&tbl, 0, sizeof(Table));
2440
memset(&table_list, 0, sizeof(TABLE_LIST));
2441
memset(&tbl, 0, sizeof(TABLE));
2467
2443
table_list.table_name= table_name->str;
2468
2444
table_list.db= db_name->str;
2470
key_length= create_table_def_key(session, key, &table_list, 0);
2446
key_length= create_table_def_key(thd, key, &table_list, 0);
2471
2447
pthread_mutex_lock(&LOCK_open);
2472
share= get_table_share(session, &table_list, key,
2473
key_length, 0, &error);
2448
share= get_table_share(thd, &table_list, key,
2449
key_length, OPEN_VIEW, &error);
2529
2505
List<LEX_STRING> db_names;
2530
2506
List_iterator_fast<LEX_STRING> it(db_names);
2531
2507
COND *partial_cond= 0;
2532
uint32_t derived_tables= lex->derived_tables;
2508
uint derived_tables= lex->derived_tables;
2534
2510
Open_tables_state open_tables_state_backup;
2535
2511
Query_tables_list query_tables_list_backup;
2536
uint32_t table_open_method;
2537
bool old_value= session->no_warnings_for_error;
2512
uint table_open_method;
2513
bool old_value= thd->no_warnings_for_error;
2515
lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
2540
2518
We should not introduce deadlocks even if we already have some
2541
2519
tables open and locked, since we won't lock tables which we will
2542
2520
open and will ignore possible name-locks for these tables.
2544
session->reset_n_backup_open_tables_state(&open_tables_state_backup);
2522
thd->reset_n_backup_open_tables_state(&open_tables_state_backup);
2546
2524
schema_table_idx= get_schema_table_idx(schema_table);
2547
2525
tables->table_open_method= table_open_method=
2548
2526
get_table_open_method(tables, schema_table, schema_table_idx);
2550
2528
this branch processes SHOW FIELDS, SHOW INDEXES commands.
2551
2529
see sql_parse.cc, prepare_schema_table() function where
2552
2530
this values are initialized
2554
2532
if (lsel && lsel->table_list.first)
2556
error= fill_schema_show_cols_or_idxs(session, tables, schema_table,
2534
error= fill_schema_show_cols_or_idxs(thd, tables, schema_table,
2557
2535
&open_tables_state_backup);
2561
if (get_lookup_field_values(session, cond, tables, &lookup_field_vals))
2539
if (get_lookup_field_values(thd, cond, tables, &lookup_field_vals))
2662
2640
Set the parent lex of 'sel' because it is needed by
2663
2641
sel.init_query() which is called inside make_table_list.
2665
session->no_warnings_for_error= 1;
2643
thd->no_warnings_for_error= 1;
2666
2644
sel.parent_lex= lex;
2667
2645
/* db_name can be changed in make_table_list() func */
2668
if (!session->make_lex_string(&orig_db_name, db_name->str,
2646
if (!thd->make_lex_string(&orig_db_name, db_name->str,
2669
2647
db_name->length, false))
2671
if (make_table_list(session, &sel, db_name, table_name))
2649
if (make_table_list(thd, &sel, db_name, table_name))
2673
TableList *show_table_list= (TableList*) sel.table_list.first;
2651
TABLE_LIST *show_table_list= (TABLE_LIST*) sel.table_list.first;
2674
2652
lex->all_selects_list= &sel;
2675
2653
lex->derived_tables= 0;
2676
2654
lex->sql_command= SQLCOM_SHOW_FIELDS;
2677
2655
show_table_list->i_s_requested_object=
2678
2656
schema_table->i_s_requested_object;
2679
res= open_normal_and_derived_tables(session, show_table_list,
2657
res= open_normal_and_derived_tables(thd, show_table_list,
2680
2658
DRIZZLE_LOCK_IGNORE_FLUSH);
2681
2659
lex->sql_command= save_sql_command;
2683
2661
XXX: show_table_list has a flag i_is_requested,
2684
2662
and when it's set, open_normal_and_derived_tables()
2685
2663
can return an error without setting an error message
2686
in Session, which is a hack. This is why we have to
2687
check for res, then for session->is_error() only then
2688
for session->main_da.sql_errno().
2664
in THD, which is a hack. This is why we have to
2665
check for res, then for thd->is_error() only then
2666
for thd->main_da.sql_errno().
2690
if (res && session->is_error() &&
2691
session->main_da.sql_errno() == ER_NO_SUCH_TABLE)
2668
if (res && thd->is_error() &&
2669
thd->main_da.sql_errno() == ER_NO_SUCH_TABLE)
2694
2672
Hide error for not existing table.
2697
2675
table does not exist.
2700
session->clear_error();
2705
We should use show_table_list->alias instead of
2683
We should use show_table_list->alias instead of
2706
2684
show_table_list->table_name because table_name
2707
2685
could be changed during opening of I_S tables. It's safe
2708
to use alias because alias contains original table name
2686
to use alias because alias contains original table name
2711
session->make_lex_string(&tmp_lex_string, show_table_list->alias,
2689
thd->make_lex_string(&tmp_lex_string, show_table_list->alias,
2712
2690
strlen(show_table_list->alias), false);
2713
res= schema_table->process_table(session, show_table_list, table,
2691
res= schema_table->process_table(thd, show_table_list, table,
2714
2692
res, &orig_db_name,
2715
2693
&tmp_lex_string);
2716
close_tables_for_reopen(session, &show_table_list);
2694
close_tables_for_reopen(thd, &show_table_list);
2718
2696
assert(!lex->query_tables_own_last);
2734
session->restore_backup_open_tables_state(&open_tables_state_backup);
2712
thd->restore_backup_open_tables_state(&open_tables_state_backup);
2713
lex->restore_backup_query_tables_list(&query_tables_list_backup);
2735
2714
lex->derived_tables= derived_tables;
2736
2715
lex->all_selects_list= old_all_select_lex;
2737
2716
lex->sql_command= save_sql_command;
2738
session->no_warnings_for_error= old_value;
2717
thd->no_warnings_for_error= old_value;
2743
bool store_schema_shemata(Session* session, Table *table, LEX_STRING *db_name,
2722
bool store_schema_shemata(THD* thd, TABLE *table, LEX_STRING *db_name,
2744
2723
const CHARSET_INFO * const cs)
2746
2725
restore_record(table, s->default_values);
2747
2726
table->field[1]->store(db_name->str, db_name->length, system_charset_info);
2748
2727
table->field[2]->store(cs->csname, strlen(cs->csname), system_charset_info);
2749
2728
table->field[3]->store(cs->name, strlen(cs->name), system_charset_info);
2750
return schema_table_store_record(session, table);
2729
return schema_table_store_record(thd, table);
2754
int fill_schema_schemata(Session *session, TableList *tables, COND *cond)
2733
int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
2757
2736
TODO: fill_schema_shemata() is called when new client is connected.
2859
2838
tmp_buff= (char *) ha_resolve_storage_engine_name(tmp_db_type);
2860
2839
table->field[4]->store(tmp_buff, strlen(tmp_buff), cs);
2861
table->field[5]->store((int64_t) 0, true);
2840
table->field[5]->store((int64_t) share->frm_version, true);
2863
2842
ptr=option_buff;
2864
2843
if (share->min_rows)
2866
ptr= strcpy(ptr," min_rows=")+10;
2867
ptr= int64_t10_to_str(share->min_rows,ptr,10);
2845
ptr=stpcpy(ptr," min_rows=");
2846
ptr=int64_t10_to_str(share->min_rows,ptr,10);
2869
2848
if (share->max_rows)
2871
ptr= strcpy(ptr," max_rows=")+10;
2872
ptr= int64_t10_to_str(share->max_rows,ptr,10);
2850
ptr=stpcpy(ptr," max_rows=");
2851
ptr=int64_t10_to_str(share->max_rows,ptr,10);
2874
2853
if (share->avg_row_length)
2876
ptr= strcpy(ptr," avg_row_length=")+16;
2877
ptr= int64_t10_to_str(share->avg_row_length,ptr,10);
2855
ptr=stpcpy(ptr," avg_row_length=");
2856
ptr=int64_t10_to_str(share->avg_row_length,ptr,10);
2879
2858
if (share->db_create_options & HA_OPTION_PACK_KEYS)
2880
ptr= strcpy(ptr," pack_keys=1")+12;
2859
ptr=stpcpy(ptr," pack_keys=1");
2881
2860
if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
2882
ptr= strcpy(ptr," pack_keys=0")+12;
2861
ptr=stpcpy(ptr," pack_keys=0");
2883
2862
/* We use CHECKSUM, instead of TABLE_CHECKSUM, for backward compability */
2884
2863
if (share->db_create_options & HA_OPTION_CHECKSUM)
2885
ptr= strcpy(ptr," checksum=1")+11;
2864
ptr=stpcpy(ptr," checksum=1");
2886
2865
if (share->page_checksum != HA_CHOICE_UNDEF)
2887
ptr+= sprintf(ptr, " page_checksum=%s",
2888
ha_choice_values[(uint) share->page_checksum]);
2866
ptr= strxmov(ptr, " page_checksum=",
2867
ha_choice_values[(uint) share->page_checksum], NullS);
2889
2868
if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
2890
ptr= strcpy(ptr," delay_key_write=1")+18;
2869
ptr=stpcpy(ptr," delay_key_write=1");
2891
2870
if (share->row_type != ROW_TYPE_DEFAULT)
2892
ptr+= sprintf(ptr, " row_format=%s", ha_row_type[(uint)share->row_type]);
2871
ptr=strxmov(ptr, " row_format=",
2872
ha_row_type[(uint) share->row_type],
2893
2874
if (share->block_size)
2895
ptr= strcpy(ptr, " block_size=")+12;
2876
ptr= stpcpy(ptr, " block_size=");
2896
2877
ptr= int64_t10_to_str(share->block_size, ptr, 10);
2899
2880
if (share->transactional != HA_CHOICE_UNDEF)
2901
ptr+= sprintf(ptr, " TRANSACTIONAL=%s",
2902
(share->transactional == HA_CHOICE_YES ? "1" : "0"));
2882
ptr= strxmov(ptr, " TRANSACTIONAL=",
2883
(share->transactional == HA_CHOICE_YES ? "1" : "0"),
2904
2886
if (share->transactional != HA_CHOICE_UNDEF)
2905
ptr+= sprintf(ptr, " transactional=%s",
2906
ha_choice_values[(uint) share->transactional]);
2887
ptr= strxmov(ptr, " transactional=",
2888
ha_choice_values[(uint) share->transactional], NullS);
2907
2889
table->field[19]->store(option_buff+1,
2908
(ptr == option_buff ? 0 :
2890
(ptr == option_buff ? 0 :
2909
2891
(uint) (ptr-option_buff)-1), cs);
2911
2893
tmp_buff= (share->table_charset ?
2971
2953
if (file->stats.create_time)
2973
session->variables.time_zone->gmt_sec_to_TIME(&time,
2974
(time_t) file->stats.create_time);
2955
thd->variables.time_zone->gmt_sec_to_TIME(&time,
2956
(my_time_t) file->stats.create_time);
2975
2957
table->field[14]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2976
2958
table->field[14]->set_notnull();
2978
2960
if (file->stats.update_time)
2980
session->variables.time_zone->gmt_sec_to_TIME(&time,
2981
(time_t) file->stats.update_time);
2962
thd->variables.time_zone->gmt_sec_to_TIME(&time,
2963
(my_time_t) file->stats.update_time);
2982
2964
table->field[15]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2983
2965
table->field[15]->set_notnull();
2985
2967
if (file->stats.check_time)
2987
session->variables.time_zone->gmt_sec_to_TIME(&time,
2988
(time_t) file->stats.check_time);
2969
thd->variables.time_zone->gmt_sec_to_TIME(&time,
2970
(my_time_t) file->stats.check_time);
2989
2971
table->field[16]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2990
2972
table->field[16]->set_notnull();
3187
3171
table->field[4]->store((int64_t) count, true);
3189
if (get_field_default_value(session, timestamp_field, field, &type, 0))
3173
if (get_field_default_value(thd, timestamp_field, field, &type, 0))
3191
3175
table->field[5]->store(type.ptr(), type.length(), cs);
3192
3176
table->field[5]->set_notnull();
3194
pos=(unsigned char*) ((field->flags & NOT_NULL_FLAG) ? "NO" : "YES");
3178
pos=(uchar*) ((field->flags & NOT_NULL_FLAG) ? "NO" : "YES");
3195
3179
table->field[6]->store((const char*) pos,
3196
3180
strlen((const char*) pos), cs);
3197
3181
store_column_type(table, field, cs, 7);
3199
pos=(unsigned char*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
3183
pos=(uchar*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
3200
3184
(field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
3201
3185
(field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
3202
3186
table->field[15]->store((const char*) pos,
3209
3193
field->unireg_check != Field::TIMESTAMP_DN_FIELD)
3210
3194
table->field[16]->store(STRING_WITH_LEN("on update CURRENT_TIMESTAMP"),
3212
if (field->vcol_info)
3213
table->field[16]->store(STRING_WITH_LEN("VIRTUAL"), cs);
3214
3197
table->field[18]->store(field->comment.str, field->comment.length, cs);
3216
3199
enum column_format_type column_format= (enum column_format_type)
3217
3200
((field->flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
3218
pos=(unsigned char*)"Default";
3201
pos=(uchar*)"Default";
3219
3202
table->field[19]->store((const char*) pos,
3220
3203
strlen((const char*) pos), cs);
3221
pos=(unsigned char*)(column_format == COLUMN_FORMAT_TYPE_DEFAULT ? "Default" :
3204
pos=(uchar*)(column_format == COLUMN_FORMAT_TYPE_DEFAULT ? "Default" :
3222
3205
column_format == COLUMN_FORMAT_TYPE_FIXED ? "Fixed" :
3224
3207
table->field[20]->store((const char*) pos,
3225
3208
strlen((const char*) pos), cs);
3227
if (schema_table_store_record(session, table))
3210
if (schema_table_store_record(thd, table))
3308
int fill_schema_coll_charset_app(Session *session, TableList *tables, COND *)
3291
int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
3310
3293
CHARSET_INFO **cs;
3311
Table *table= tables->table;
3294
TABLE *table= tables->table;
3312
3295
const CHARSET_INFO * const scs= system_charset_info;
3313
3296
for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
3315
3298
CHARSET_INFO **cl;
3316
3299
const CHARSET_INFO *tmp_cs= cs[0];
3317
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
3300
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
3318
3301
!(tmp_cs->state & MY_CS_PRIMARY))
3320
3303
for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
3322
3305
const CHARSET_INFO *tmp_cl= cl[0];
3323
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
3306
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
3324
3307
!my_charset_same(tmp_cs,tmp_cl))
3326
3309
restore_record(table, s->default_values);
3327
3310
table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
3328
3311
table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
3329
if (schema_table_store_record(session, table))
3312
if (schema_table_store_record(thd, table))
3337
static int get_schema_stat_record(Session *session, TableList *tables,
3338
Table *table, bool res,
3320
static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
3321
TABLE *table, bool res,
3339
3322
LEX_STRING *db_name,
3340
3323
LEX_STRING *table_name)
3342
3325
const CHARSET_INFO * const cs= system_charset_info;
3345
if (session->lex->sql_command != SQLCOM_SHOW_KEYS)
3328
if (thd->lex->sql_command != SQLCOM_SHOW_KEYS)
3348
3331
I.e. we are in SELECT FROM INFORMATION_SCHEMA.STATISTICS
3349
3332
rather than in SHOW KEYS
3351
if (session->is_error())
3352
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3353
session->main_da.sql_errno(), session->main_da.message());
3354
session->clear_error();
3334
if (thd->is_error())
3335
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3336
thd->main_da.sql_errno(), thd->main_da.message());
3361
Table *show_table= tables->table;
3344
TABLE *show_table= tables->table;
3362
3345
KEY *key_info=show_table->s->key_info;
3363
3346
if (show_table->file)
3364
3347
show_table->file->info(HA_STATUS_VARIABLE |
3365
3348
HA_STATUS_NO_LOCK |
3366
3349
HA_STATUS_TIME);
3367
for (uint32_t i=0 ; i < show_table->s->keys ; i++,key_info++)
3350
for (uint i=0 ; i < show_table->s->keys ; i++,key_info++)
3369
3352
KEY_PART_INFO *key_part= key_info->key_part;
3370
3353
const char *str;
3371
for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
3354
for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
3373
3356
restore_record(table, s->default_values);
3374
3357
table->field[1]->store(db_name->str, db_name->length, cs);
3442
3425
table->field[3]->store(db_name->str, db_name->length, cs);
3443
3426
table->field[4]->store(table_name->str, table_name->length, cs);
3444
3427
table->field[5]->store(con_type, con_len, cs);
3445
return schema_table_store_record(session, table);
3428
return schema_table_store_record(thd, table);
3449
static int get_schema_constraints_record(Session *session, TableList *tables,
3450
Table *table, bool res,
3432
static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
3433
TABLE *table, bool res,
3451
3434
LEX_STRING *db_name,
3452
3435
LEX_STRING *table_name)
3456
if (session->is_error())
3457
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3458
session->main_da.sql_errno(), session->main_da.message());
3459
session->clear_error();
3439
if (thd->is_error())
3440
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3441
thd->main_da.sql_errno(), thd->main_da.message());
3464
3447
List<FOREIGN_KEY_INFO> f_key_list;
3465
Table *show_table= tables->table;
3448
TABLE *show_table= tables->table;
3466
3449
KEY *key_info=show_table->key_info;
3467
uint32_t primary_key= show_table->s->primary_key;
3468
show_table->file->info(HA_STATUS_VARIABLE |
3450
uint primary_key= show_table->s->primary_key;
3451
show_table->file->info(HA_STATUS_VARIABLE |
3469
3452
HA_STATUS_NO_LOCK |
3470
3453
HA_STATUS_TIME);
3471
for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
3454
for (uint i=0 ; i < show_table->s->keys ; i++, key_info++)
3473
3456
if (i != primary_key && !(key_info->flags & HA_NOSAME))
3476
if (i == primary_key && is_primary_key(key_info))
3459
if (i == primary_key && !strcmp(key_info->name, primary_key_name))
3478
if (store_constraints(session, table, db_name, table_name, key_info->name,
3461
if (store_constraints(thd, table, db_name, table_name, key_info->name,
3479
3462
strlen(key_info->name),
3480
3463
STRING_WITH_LEN("PRIMARY KEY")))
3483
3466
else if (key_info->flags & HA_NOSAME)
3485
if (store_constraints(session, table, db_name, table_name, key_info->name,
3468
if (store_constraints(thd, table, db_name, table_name, key_info->name,
3486
3469
strlen(key_info->name),
3487
3470
STRING_WITH_LEN("UNIQUE")))
3492
show_table->file->get_foreign_key_list(session, &f_key_list);
3475
show_table->file->get_foreign_key_list(thd, &f_key_list);
3493
3476
FOREIGN_KEY_INFO *f_key_info;
3494
3477
List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
3495
3478
while ((f_key_info=it++))
3497
if (store_constraints(session, table, db_name, table_name,
3480
if (store_constraints(thd, table, db_name, table_name,
3498
3481
f_key_info->forein_id->str,
3499
3482
strlen(f_key_info->forein_id->str),
3500
3483
"FOREIGN KEY", 11))
3523
static int get_schema_key_column_usage_record(Session *session,
3525
Table *table, bool res,
3506
static int get_schema_key_column_usage_record(THD *thd,
3508
TABLE *table, bool res,
3526
3509
LEX_STRING *db_name,
3527
3510
LEX_STRING *table_name)
3531
if (session->is_error())
3532
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3533
session->main_da.sql_errno(), session->main_da.message());
3534
session->clear_error();
3514
if (thd->is_error())
3515
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3516
thd->main_da.sql_errno(), thd->main_da.message());
3539
3522
List<FOREIGN_KEY_INFO> f_key_list;
3540
Table *show_table= tables->table;
3523
TABLE *show_table= tables->table;
3541
3524
KEY *key_info=show_table->key_info;
3542
uint32_t primary_key= show_table->s->primary_key;
3543
show_table->file->info(HA_STATUS_VARIABLE |
3525
uint primary_key= show_table->s->primary_key;
3526
show_table->file->info(HA_STATUS_VARIABLE |
3544
3527
HA_STATUS_NO_LOCK |
3545
3528
HA_STATUS_TIME);
3546
for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
3529
for (uint i=0 ; i < show_table->s->keys ; i++, key_info++)
3548
3531
if (i != primary_key && !(key_info->flags & HA_NOSAME))
3551
3534
KEY_PART_INFO *key_part= key_info->key_part;
3552
for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
3535
for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
3554
3537
if (key_part->field)
3648
3631
schema_table_idx == SCH_GLOBAL_VARIABLES)
3649
3632
option_type= OPT_GLOBAL;
3651
pthread_rwlock_rdlock(&LOCK_system_variables_hash);
3652
res= show_status_array(session, wild, enumerate_sys_vars(session, sorted_vars),
3634
rw_rdlock(&LOCK_system_variables_hash);
3635
res= show_status_array(thd, wild, enumerate_sys_vars(thd, sorted_vars),
3653
3636
option_type, NULL, "", tables->table, upper_case_names);
3654
pthread_rwlock_unlock(&LOCK_system_variables_hash);
3637
rw_unlock(&LOCK_system_variables_hash);
3659
int fill_status(Session *session, TableList *tables, COND *)
3642
int fill_status(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
3661
LEX *lex= session->lex;
3662
const char *wild= lex->wild ? lex->wild->ptr() : NULL;
3645
const char *wild= lex->wild ? lex->wild->ptr() : NullS;
3664
3647
STATUS_VAR *tmp1, tmp;
3665
3648
enum enum_schema_tables schema_table_idx=
3720
get_referential_constraints_record(Session *session, TableList *tables,
3721
Table *table, bool res,
3703
get_referential_constraints_record(THD *thd, TABLE_LIST *tables,
3704
TABLE *table, bool res,
3722
3705
LEX_STRING *db_name, LEX_STRING *table_name)
3724
3707
const CHARSET_INFO * const cs= system_charset_info;
3728
if (session->is_error())
3729
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3730
session->main_da.sql_errno(), session->main_da.message());
3731
session->clear_error();
3711
if (thd->is_error())
3712
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3713
thd->main_da.sql_errno(), thd->main_da.message());
3736
3719
List<FOREIGN_KEY_INFO> f_key_list;
3737
Table *show_table= tables->table;
3738
show_table->file->info(HA_STATUS_VARIABLE |
3720
TABLE *show_table= tables->table;
3721
show_table->file->info(HA_STATUS_VARIABLE |
3739
3722
HA_STATUS_NO_LOCK |
3740
3723
HA_STATUS_TIME);
3742
show_table->file->get_foreign_key_list(session, &f_key_list);
3725
show_table->file->get_foreign_key_list(thd, &f_key_list);
3743
3726
FOREIGN_KEY_INFO *f_key_info;
3744
3727
List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
3745
3728
while ((f_key_info= it++))
3749
3732
table->field[9]->store(table_name->str, table_name->length, cs);
3750
3733
table->field[2]->store(f_key_info->forein_id->str,
3751
3734
f_key_info->forein_id->length, cs);
3752
table->field[4]->store(f_key_info->referenced_db->str,
3735
table->field[4]->store(f_key_info->referenced_db->str,
3753
3736
f_key_info->referenced_db->length, cs);
3754
table->field[10]->store(f_key_info->referenced_table->str,
3737
table->field[10]->store(f_key_info->referenced_table->str,
3755
3738
f_key_info->referenced_table->length, cs);
3756
3739
if (f_key_info->referenced_key_name)
3758
table->field[5]->store(f_key_info->referenced_key_name->str,
3741
table->field[5]->store(f_key_info->referenced_key_name->str,
3759
3742
f_key_info->referenced_key_name->length, cs);
3760
3743
table->field[5]->set_notnull();
3763
3746
table->field[5]->set_null();
3764
3747
table->field[6]->store(STRING_WITH_LEN("NONE"), cs);
3765
table->field[7]->store(f_key_info->update_method->str,
3748
table->field[7]->store(f_key_info->update_method->str,
3766
3749
f_key_info->update_method->length, cs);
3767
table->field[8]->store(f_key_info->delete_method->str,
3750
table->field[8]->store(f_key_info->delete_method->str,
3768
3751
f_key_info->delete_method->length, cs);
3769
if (schema_table_store_record(session, table))
3752
if (schema_table_store_record(thd, table))
3945
3931
TMP_TABLE_PARAM *tmp_table_param =
3946
(TMP_TABLE_PARAM*) (session->alloc(sizeof(TMP_TABLE_PARAM)));
3932
(TMP_TABLE_PARAM*) (thd->alloc(sizeof(TMP_TABLE_PARAM)));
3947
3933
tmp_table_param->init();
3948
3934
tmp_table_param->table_charset= cs;
3949
3935
tmp_table_param->field_count= field_count;
3950
3936
tmp_table_param->schema_table= 1;
3951
SELECT_LEX *select_lex= session->lex->current_select;
3952
if (!(table= create_tmp_table(session, tmp_table_param,
3953
field_list, (order_st*) 0, 0, 0,
3954
(select_lex->options | session->options |
3937
SELECT_LEX *select_lex= thd->lex->current_select;
3938
if (!(table= create_tmp_table(thd, tmp_table_param,
3939
field_list, (ORDER*) 0, 0, 0,
3940
(select_lex->options | thd->options |
3955
3941
TMP_TABLE_ALL_COLUMNS),
3956
3942
HA_POS_ERROR, table_list->alias)))
3958
3944
my_bitmap_map* bitmaps=
3959
(my_bitmap_map*) session->alloc(bitmap_buffer_size(field_count));
3945
(my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count));
3960
3946
bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count,
3962
3948
table->read_set= &table->def_read_set;
3984
int make_old_format(Session *session, ST_SCHEMA_TABLE *schema_table)
3970
int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
3986
3972
ST_FIELD_INFO *field_info= schema_table->fields_info;
3987
Name_resolution_context *context= &session->lex->select_lex.context;
3973
Name_resolution_context *context= &thd->lex->select_lex.context;
3988
3974
for (; field_info->field_name; field_info++)
3990
3976
if (field_info->old_name)
3992
3978
Item_field *field= new Item_field(context,
3993
NULL, NULL, field_info->field_name);
3979
NullS, NullS, field_info->field_name);
3996
3982
field->set_name(field_info->old_name,
3997
3983
strlen(field_info->old_name),
3998
3984
system_charset_info);
3999
if (add_item_to_list(session, field))
3985
if (add_item_to_list(thd, field))
4052
4038
buffer.append(')');
4054
4040
Item_field *field= new Item_field(context,
4055
NULL, NULL, field_info->field_name);
4056
if (add_item_to_list(session, field))
4041
NullS, NullS, field_info->field_name);
4042
if (add_item_to_list(thd, field))
4058
4044
field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
4059
if (session->lex->verbose)
4045
if (thd->lex->verbose)
4061
4047
field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
4062
4048
field_info= &schema_table->fields_info[3];
4063
field= new Item_field(context, NULL, NULL, field_info->field_name);
4064
if (add_item_to_list(session, field))
4049
field= new Item_field(context, NullS, NullS, field_info->field_name);
4050
if (add_item_to_list(thd, field))
4066
4052
field->set_name(field_info->old_name, strlen(field_info->old_name),
4067
4053
system_charset_info);
4073
int make_columns_old_format(Session *session, ST_SCHEMA_TABLE *schema_table)
4059
int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
4075
4061
int fields_arr[]= {3, 14, 13, 6, 15, 5, 16, 17, 18, -1};
4076
4062
int *field_num= fields_arr;
4077
4063
ST_FIELD_INFO *field_info;
4078
Name_resolution_context *context= &session->lex->select_lex.context;
4064
Name_resolution_context *context= &thd->lex->select_lex.context;
4080
4066
for (; *field_num >= 0; field_num++)
4082
4068
field_info= &schema_table->fields_info[*field_num];
4083
if (!session->lex->verbose && (*field_num == 13 ||
4069
if (!thd->lex->verbose && (*field_num == 13 ||
4084
4070
*field_num == 17 ||
4085
4071
*field_num == 18))
4087
4073
Item_field *field= new Item_field(context,
4088
NULL, NULL, field_info->field_name);
4074
NullS, NullS, field_info->field_name);
4091
4077
field->set_name(field_info->old_name,
4092
4078
strlen(field_info->old_name),
4093
4079
system_charset_info);
4094
if (add_item_to_list(session, field))
4080
if (add_item_to_list(thd, field))
4102
int make_character_sets_old_format(Session *session, ST_SCHEMA_TABLE *schema_table)
4088
int make_character_sets_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
4104
4090
int fields_arr[]= {0, 2, 1, 3, -1};
4105
4091
int *field_num= fields_arr;
4106
4092
ST_FIELD_INFO *field_info;
4107
Name_resolution_context *context= &session->lex->select_lex.context;
4093
Name_resolution_context *context= &thd->lex->select_lex.context;
4109
4095
for (; *field_num >= 0; field_num++)
4111
4097
field_info= &schema_table->fields_info[*field_num];
4112
4098
Item_field *field= new Item_field(context,
4113
NULL, NULL, field_info->field_name);
4099
NullS, NullS, field_info->field_name);
4116
4102
field->set_name(field_info->old_name,
4117
4103
strlen(field_info->old_name),
4118
4104
system_charset_info);
4119
if (add_item_to_list(session, field))
4105
if (add_item_to_list(thd, field))
4158
4144
table_list->table_name= table->s->table_name.str;
4159
4145
table_list->table_name_length= table->s->table_name.length;
4160
4146
table_list->table= table;
4161
table->next= session->derived_tables;
4162
session->derived_tables= table;
4147
table->next= thd->derived_tables;
4148
thd->derived_tables= table;
4163
4149
table_list->select_lex->options |= OPTION_SCHEMA_TABLE;
4151
if (table_list->schema_table_reformed) // show command
4153
SELECT_LEX *sel= lex->current_select;
4155
Field_translator *transl, *org_transl;
4157
if (table_list->field_translation)
4159
Field_translator *end= table_list->field_translation_end;
4160
for (transl= table_list->field_translation; transl < end; transl++)
4162
if (!transl->item->fixed &&
4163
transl->item->fix_fields(thd, &transl->item))
4168
List_iterator_fast<Item> it(sel->item_list);
4170
(Field_translator*)(thd->stmt_arena->
4171
alloc(sel->item_list.elements *
4172
sizeof(Field_translator)))))
4176
for (org_transl= transl; (item= it++); transl++)
4179
transl->name= item->name;
4180
if (!item->fixed && item->fix_fields(thd, &transl->item))
4185
table_list->field_translation= org_transl;
4186
table_list->field_translation_end= transl;
4189
4213
We have to make non const db_name & table_name
4190
4214
because of lower_case_table_names
4192
session->make_lex_string(&db, INFORMATION_SCHEMA_NAME.c_str(),
4193
INFORMATION_SCHEMA_NAME.length(), 0);
4194
session->make_lex_string(&table, schema_table->table_name,
4216
thd->make_lex_string(&db, INFORMATION_SCHEMA_NAME.str,
4217
INFORMATION_SCHEMA_NAME.length, 0);
4218
thd->make_lex_string(&table, schema_table->table_name,
4195
4219
strlen(schema_table->table_name), 0);
4196
if (schema_table->old_format(session, schema_table) || /* Handle old syntax */
4197
!sel->add_table_to_list(session, new Table_ident(session, db, table, 0),
4220
if (schema_table->old_format(thd, schema_table) || /* Handle old syntax */
4221
!sel->add_table_to_list(thd, new Table_ident(thd, db, table, 0),
4198
4222
0, 0, TL_READ))
4315
4339
{"ROW_FORMAT", 10, DRIZZLE_TYPE_VARCHAR, 0, 1, "Row_format", OPEN_FULL_TABLE},
4316
4340
{"TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4317
4341
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Rows", OPEN_FULL_TABLE},
4318
{"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4342
{"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4319
4343
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Avg_row_length", OPEN_FULL_TABLE},
4320
{"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4344
{"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4321
4345
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_length", OPEN_FULL_TABLE},
4322
4346
{"MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4323
4347
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Max_data_length", OPEN_FULL_TABLE},
4324
{"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4348
{"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4325
4349
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Index_length", OPEN_FULL_TABLE},
4326
4350
{"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4327
4351
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free", OPEN_FULL_TABLE},
4328
{"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG, 0,
4352
{"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG, 0,
4329
4353
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Auto_increment", OPEN_FULL_TABLE},
4330
4354
{"CREATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Create_time", OPEN_FULL_TABLE},
4331
4355
{"UPDATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Update_time", OPEN_FULL_TABLE},
4570
4594
ST_SCHEMA_TABLE schema_tables[]=
4572
{"CHARACTER_SETS", charsets_fields_info, create_schema_table,
4596
{"CHARACTER_SETS", charsets_fields_info, create_schema_table,
4573
4597
fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0},
4574
{"COLLATIONS", collation_fields_info, create_schema_table,
4598
{"COLLATIONS", collation_fields_info, create_schema_table,
4575
4599
fill_schema_collation, make_old_format, 0, -1, -1, 0, 0},
4576
4600
{"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
4577
4601
create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, 0},
4578
{"COLUMNS", columns_fields_info, create_schema_table,
4602
{"COLUMNS", columns_fields_info, create_schema_table,
4579
4603
get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0,
4580
OPTIMIZE_I_S_TABLE},
4604
OPTIMIZE_I_S_TABLE|OPEN_VIEW_FULL},
4581
4605
{"GLOBAL_STATUS", variables_fields_info, create_schema_table,
4582
4606
fill_status, make_old_format, 0, -1, -1, 0, 0},
4583
4607
{"GLOBAL_VARIABLES", variables_fields_info, create_schema_table,
4600
4624
fill_status, make_old_format, 0, -1, -1, 0, 0},
4601
4625
{"SESSION_VARIABLES", variables_fields_info, create_schema_table,
4602
4626
fill_variables, make_old_format, 0, -1, -1, 0, 0},
4603
{"STATISTICS", stat_fields_info, create_schema_table,
4627
{"STATISTICS", stat_fields_info, create_schema_table,
4604
4628
get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0,
4605
4629
OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE},
4606
{"STATUS", variables_fields_info, create_schema_table, fill_status,
4630
{"STATUS", variables_fields_info, create_schema_table, fill_status,
4607
4631
make_old_format, 0, -1, -1, 1, 0},
4608
{"TABLES", tables_fields_info, create_schema_table,
4632
{"TABLES", tables_fields_info, create_schema_table,
4609
4633
get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0,
4610
4634
OPTIMIZE_I_S_TABLE},
4611
4635
{"TABLE_CONSTRAINTS", table_constraints_fields_info, create_schema_table,
4628
4652
ST_SCHEMA_TABLE *schema_table;
4630
if ((schema_table= new ST_SCHEMA_TABLE) == NULL)
4632
memset(schema_table, 0, sizeof(ST_SCHEMA_TABLE));
4654
if (!(schema_table= (ST_SCHEMA_TABLE *)my_malloc(sizeof(ST_SCHEMA_TABLE),
4655
MYF(MY_WME | MY_ZEROFILL))))
4634
4657
/* Historical Requirement */
4635
4658
plugin->data= schema_table; // shortcut for the future
4636
4659
if (plugin->plugin->init)
4638
4661
schema_table->create_table= create_schema_table;
4639
4662
schema_table->old_format= make_old_format;
4640
schema_table->idx_field1= -1,
4641
schema_table->idx_field2= -1;
4663
schema_table->idx_field1= -1,
4664
schema_table->idx_field2= -1;
4643
4666
/* Make the name available to the init() function. */
4644
4667
schema_table->table_name= plugin->name.str;
4646
4669
if (plugin->plugin->init(schema_table))
4648
errmsg_printf(ERRMSG_LVL_ERROR,
4649
_("Plugin '%s' init function returned error."),
4671
sql_print_error("Plugin '%s' init function returned error.",
4654
4676
/* Make sure the plugin name is not set inside the init() function. */
4655
4677
schema_table->table_name= plugin->name.str;
4660
delete schema_table;
4682
my_free(schema_table, MYF(0));
4665
4686
int finalize_schema_table(st_plugin_int *plugin)