87
return(0); /* '*' as last char: OK */
90
return (0); /* '*' as last char: OK */
88
91
flag=(*wildstr != wild_many && *wildstr != wild_one);
94
if ((cmp= *wildstr) == wild_prefix && wildstr[1])
96
cmp=my_toupper(cs, cmp);
97
while (*str && my_toupper(cs, *str) != cmp)
97
if ((cmp= *wildstr) == wild_prefix && wildstr[1])
99
cmp= my_toupper(cs, cmp);
100
while (*str && my_toupper(cs, *str) != cmp)
105
if (wild_case_compare(cs, str, wildstr) == 0)
102
if (wild_case_compare(cs, str,wildstr) == 0)
108
111
return (*str != '\0');
111
/***************************************************************************
112
** List all table types supported
113
***************************************************************************/
115
static bool show_plugins(Session *session, plugin_ref plugin,
118
Table *table= (Table*) arg;
119
struct st_mysql_plugin *plug= plugin_decl(plugin);
120
struct st_plugin_dl *plugin_dl= plugin_dlib(plugin);
121
const CHARSET_INFO * const cs= system_charset_info;
123
restore_record(table, s->default_values);
125
table->field[0]->store(plugin_name(plugin)->str,
126
plugin_name(plugin)->length, cs);
130
table->field[1]->store(plug->version, strlen(plug->version), cs);
131
table->field[1]->set_notnull();
134
table->field[1]->set_null();
136
switch (plugin_state(plugin)) {
137
/* case PLUGIN_IS_FREED: does not happen */
138
case PLUGIN_IS_DELETED:
139
table->field[2]->store(STRING_WITH_LEN("DELETED"), cs);
141
case PLUGIN_IS_UNINITIALIZED:
142
table->field[2]->store(STRING_WITH_LEN("INACTIVE"), cs);
144
case PLUGIN_IS_READY:
145
table->field[2]->store(STRING_WITH_LEN("ACTIVE"), cs);
151
table->field[3]->store(plugin_type_names[plug->type].str,
152
plugin_type_names[plug->type].length,
157
table->field[4]->store(plugin_dl->dl.str, plugin_dl->dl.length, cs);
158
table->field[4]->set_notnull();
162
table->field[4]->set_null();
167
table->field[5]->store(plug->author, strlen(plug->author), cs);
168
table->field[5]->set_notnull();
171
table->field[5]->set_null();
175
table->field[6]->store(plug->descr, strlen(plug->descr), cs);
176
table->field[6]->set_notnull();
179
table->field[6]->set_null();
181
switch (plug->license) {
182
case PLUGIN_LICENSE_GPL:
183
table->field[7]->store(PLUGIN_LICENSE_GPL_STRING,
184
strlen(PLUGIN_LICENSE_GPL_STRING), cs);
186
case PLUGIN_LICENSE_BSD:
187
table->field[7]->store(PLUGIN_LICENSE_BSD_STRING,
188
strlen(PLUGIN_LICENSE_BSD_STRING), cs);
191
table->field[7]->store(PLUGIN_LICENSE_PROPRIETARY_STRING,
192
strlen(PLUGIN_LICENSE_PROPRIETARY_STRING), cs);
195
table->field[7]->set_notnull();
197
return schema_table_store_record(session, table);
201
int fill_plugins(Session *session, TableList *tables, COND *)
203
Table *table= tables->table;
205
if (plugin_foreach_with_mask(session, show_plugins, DRIZZLE_ANY_PLUGIN,
206
~PLUGIN_IS_FREED, table))
214
find_files() - find files in a given directory.
218
session thread handler
219
files put found files in this list
220
db database name to set in TableList structure
221
path path to database
222
wild filter for found files
223
dir read databases in path if true, read .frm files in
227
FIND_FILES_OK success
228
FIND_FILES_OOM out of memory error
229
FIND_FILES_DIR no such directory, or directory can't be read
234
find_files(Session *session, List<LEX_STRING> *files, const char *db,
235
const char *path, const char *wild, bool dir)
241
LEX_STRING *file_name= 0;
242
uint32_t file_name_len;
243
TableList table_list;
245
if (wild && !wild[0])
248
memset(&table_list, 0, sizeof(table_list));
250
if (!(dirp = my_dir(path,MYF(dir ? MY_WANT_STAT : 0))))
252
if (my_errno == ENOENT)
253
my_error(ER_BAD_DB_ERROR, MYF(ME_BELL+ME_WAITTANG), db);
255
my_error(ER_CANT_READ_DIR, MYF(ME_BELL+ME_WAITTANG), path, my_errno);
256
return(FIND_FILES_DIR);
259
for (i=0 ; i < (uint) dirp->number_off_files ; i++)
117
* Find subdirectories (schemas) in a given directory (datadir).
119
* @param[in] session Thread Cursor
120
* @param[out] files Put found entries in this list
121
* @param[in] path Path to database
122
* @param[in] wild Filter for found entries
124
* @retval false Success
127
static bool find_schemas(Session *session, vector<LEX_STRING*> &files,
128
const char *path, const char *wild)
130
if (wild && (wild[0] == '\0'))
133
CachedDirectory directory(path);
135
if (directory.fail())
137
my_errno= directory.getError();
138
my_error(ER_CANT_READ_DIR, MYF(0), path, my_errno);
142
CachedDirectory::Entries entries= directory.getEntries();
143
CachedDirectory::Entries::iterator entry_iter= entries.begin();
145
while (entry_iter != entries.end())
147
uint32_t file_name_len;
261
148
char uname[NAME_LEN + 1]; /* Unencoded name */
262
file=dirp->dir_entry+i;
264
{ /* Return databases */
265
if ((file->name[0] == '.' &&
266
((file->name[1] == '.' && file->name[2] == '\0') ||
267
file->name[1] == '\0')))
268
continue; /* . or .. */
271
char buff[FN_REFLEN];
272
if (my_use_symdir && !strcmp(ext=fn_ext(file->name), ".sym"))
274
/* Only show the sym file if it points to a directory */
276
*ext=0; /* Remove extension */
277
unpack_dirname(buff, file->name);
278
end= strchr(buff, '\0');
279
if (end != buff && end[-1] == FN_LIBCHAR)
280
end[-1]= 0; // Remove end FN_LIBCHAR
281
if (stat(buff, file->mystat))
285
if (!S_ISDIR(file->mystat->st_mode))
288
file_name_len= filename_to_tablename(file->name, uname, sizeof(uname));
289
if (wild && wild_compare(uname, wild, 0))
292
session->make_lex_string(file_name, uname, file_name_len, true)))
295
return(FIND_FILES_OOM);
300
// Return only .frm files which aren't temp files.
301
if (my_strcasecmp(system_charset_info, ext=fn_rext(file->name),reg_ext) ||
302
is_prefix(file->name, TMP_FILE_PREFIX))
305
file_name_len= filename_to_tablename(file->name, uname, sizeof(uname));
308
if (lower_case_table_names)
310
if (wild_case_compare(files_charset_info, uname, wild))
313
else if (wild_compare(uname, wild, 0))
318
session->make_lex_string(file_name, uname, file_name_len, true)) ||
319
files->push_back(file_name))
322
return(FIND_FILES_OOM);
149
struct stat entry_stat;
150
CachedDirectory::Entry *entry= *entry_iter;
152
if ((entry->filename == ".") || (entry->filename == ".."))
158
if (stat(entry->filename.c_str(), &entry_stat))
161
my_error(ER_CANT_GET_STAT, MYF(0), entry->filename.c_str(), my_errno);
165
if (! S_ISDIR(entry_stat.st_mode))
171
file_name_len= filename_to_tablename(entry->filename.c_str(), uname,
173
if (wild && wild_compare(uname, wild, 0))
179
LEX_STRING *file_name= 0;
180
file_name= session->make_lex_string(file_name, uname, file_name_len, true);
181
if (file_name == NULL)
184
files.push_back(file_name);
327
return(FIND_FILES_OK);
332
mysqld_show_create(Session *session, TableList *table_list)
192
bool drizzled_show_create(Session *session, TableList *table_list)
334
Protocol *protocol= session->protocol;
336
195
String buffer(buff, sizeof(buff), system_charset_info);
338
197
/* Only one table for now, but VIEW can involve several tables */
339
if (open_normal_and_derived_tables(session, table_list, 0))
198
if (session->openTables(table_list))
341
200
if (session->is_error())
345
204
Clear all messages with 'error' level status and
2492
if (make_db_list(session, &db_names, &lookup_field_vals, &with_i_schema))
1850
table->setWriteSet();
1851
if (make_db_list(session, db_names, &lookup_field_vals, &with_i_schema))
2494
it.rewind(); /* To get access to new elements in basis list */
2495
while ((db_name= it++))
1854
for (vector<LEX_STRING*>::iterator db_name= db_names.begin(); db_name != db_names.end(); ++db_name )
1856
session->no_warnings_for_error= 1;
1857
table_names.clear();
1858
int res= make_table_name_list(session, table_names, lex,
1860
with_i_schema, *db_name);
1862
if (res == 2) /* Not fatal error, continue */
1869
for (vector<LEX_STRING*>::iterator table_name= table_names.begin(); table_name != table_names.end(); ++table_name)
2498
session->no_warnings_for_error= 1;
2499
List<LEX_STRING> table_names;
2500
int res= make_table_name_list(session, &table_names, lex,
2502
with_i_schema, db_name);
2503
if (res == 2) /* Not fatal error, continue */
1871
table->restoreRecordAsDefault();
1872
table->field[schema_table->getFirstColumnIndex()]->
1873
store((*db_name)->str, (*db_name)->length, system_charset_info);
1874
table->field[schema_table->getSecondColumnIndex()]->
1875
store((*table_name)->str, (*table_name)->length, system_charset_info);
2508
List_iterator_fast<LEX_STRING> it_files(table_names);
2509
while ((table_name= it_files++))
1877
if (!partial_cond || partial_cond->val_int())
2511
restore_record(table, s->default_values);
2512
table->field[schema_table->idx_field1]->
2513
store(db_name->str, db_name->length, system_charset_info);
2514
table->field[schema_table->idx_field2]->
2515
store(table_name->str, table_name->length, system_charset_info);
1880
If table is I_S.tables and open_table_method is 0 (eg SKIP_OPEN)
1881
we can skip table opening and we don't have lookup value for
1882
table name or lookup value is wild string(table name list is
1883
already created by make_table_name_list() function).
1885
if (! table_open_method &&
1886
schema_table->getTableName().compare("TABLES") == 0 &&
1887
(! lookup_field_vals.table_value.length ||
1888
lookup_field_vals.wild_table_value))
1890
if (schema_table_store_record(session, table))
1891
goto err; /* Out of space in temporary table */
2517
if (!partial_cond || partial_cond->val_int())
1895
/* SHOW Table NAMES command */
1896
if (schema_table->getTableName().compare("TABLE_NAMES") == 0)
2520
If table is I_S.tables and open_table_method is 0 (eg SKIP_OPEN)
2521
we can skip table opening and we don't have lookup value for
2522
table name or lookup value is wild string(table name list is
2523
already created by make_table_name_list() function).
2525
if (!table_open_method && schema_table_idx == SCH_TABLES &&
2526
(!lookup_field_vals.table_value.length ||
2527
lookup_field_vals.wild_table_value))
2529
if (schema_table_store_record(session, table))
2530
goto err; /* Out of space in temporary table */
1898
if (fill_schema_table_names(session, tables->table, *db_name,
1899
*table_name, with_i_schema))
2534
/* SHOW Table NAMES command */
2535
if (schema_table_idx == SCH_TABLE_NAMES)
1904
if (!(table_open_method & ~OPEN_FRM_ONLY) &&
2537
if (fill_schema_table_names(session, tables->table, db_name,
2538
table_name, with_i_schema))
1907
if (!fill_schema_table_from_frm(session, tables, schema_table, *db_name,
1912
LEX_STRING tmp_lex_string, orig_db_name;
1914
Set the parent lex of 'sel' because it is needed by
1915
sel.init_query() which is called inside make_table_list.
1917
session->no_warnings_for_error= 1;
1918
sel.parent_lex= lex;
1919
/* db_name can be changed in make_table_list() func */
1920
if (!session->make_lex_string(&orig_db_name, (*db_name)->str,
1921
(*db_name)->length, false))
1924
if (make_table_list(session, &sel, *db_name, *table_name))
1927
TableList *show_table_list= (TableList*) sel.table_list.first;
1928
lex->all_selects_list= &sel;
1929
lex->derived_tables= 0;
1930
lex->sql_command= SQLCOM_SHOW_FIELDS;
1931
show_table_list->i_s_requested_object=
1932
schema_table->getRequestedObject();
1933
res= session->openTables(show_table_list, DRIZZLE_LOCK_IGNORE_FLUSH);
1934
lex->sql_command= save_sql_command;
1936
XXX-> show_table_list has a flag i_is_requested,
1937
and when it's set, openTables()
1938
can return an error without setting an error message
1939
in Session, which is a hack. This is why we have to
1940
check for res, then for session->is_error() only then
1941
for session->main_da.sql_errno().
1943
if (res && session->is_error() &&
1944
session->main_da.sql_errno() == ER_NO_SUCH_TABLE)
1947
Hide error for not existing table.
1948
This error can occur for example when we use
1949
where condition with db name and table name and this
1950
table does not exist.
1953
session->clear_error();
2543
if (!(table_open_method & ~OPEN_FRM_ONLY) &&
2546
if (!fill_schema_table_from_frm(session, tables, schema_table, db_name,
2547
table_name, schema_table_idx))
2552
LEX_STRING tmp_lex_string, orig_db_name;
2554
Set the parent lex of 'sel' because it is needed by
2555
sel.init_query() which is called inside make_table_list.
2557
session->no_warnings_for_error= 1;
2558
sel.parent_lex= lex;
2559
/* db_name can be changed in make_table_list() func */
2560
if (!session->make_lex_string(&orig_db_name, db_name->str,
2561
db_name->length, false))
2563
if (make_table_list(session, &sel, db_name, table_name))
2565
TableList *show_table_list= (TableList*) sel.table_list.first;
2566
lex->all_selects_list= &sel;
2567
lex->derived_tables= 0;
2568
lex->sql_command= SQLCOM_SHOW_FIELDS;
2569
show_table_list->i_s_requested_object=
2570
schema_table->i_s_requested_object;
2571
res= open_normal_and_derived_tables(session, show_table_list,
2572
DRIZZLE_LOCK_IGNORE_FLUSH);
2573
lex->sql_command= save_sql_command;
2575
XXX: show_table_list has a flag i_is_requested,
2576
and when it's set, open_normal_and_derived_tables()
2577
can return an error without setting an error message
2578
in Session, which is a hack. This is why we have to
2579
check for res, then for session->is_error() only then
2580
for session->main_da.sql_errno().
2582
if (res && session->is_error() &&
2583
session->main_da.sql_errno() == ER_NO_SUCH_TABLE)
2586
Hide error for not existing table.
2587
This error can occur for example when we use
2588
where condition with db name and table name and this
2589
table does not exist.
2592
session->clear_error();
2597
We should use show_table_list->alias instead of
2598
show_table_list->table_name because table_name
2599
could be changed during opening of I_S tables. It's safe
2600
to use alias because alias contains original table name
2603
session->make_lex_string(&tmp_lex_string, show_table_list->alias,
2604
strlen(show_table_list->alias), false);
2605
res= schema_table->process_table(session, show_table_list, table,
2608
close_tables_for_reopen(session, &show_table_list);
2610
assert(!lex->query_tables_own_last);
1958
We should use show_table_list->alias instead of
1959
show_table_list->table_name because table_name
1960
could be changed during opening of I_S tables. It's safe
1961
to use alias because alias contains original table name
1964
session->make_lex_string(&tmp_lex_string, show_table_list->alias,
1965
strlen(show_table_list->alias), false);
1966
res= schema_table->processTable(session, show_table_list, table,
1969
session->close_tables_for_reopen(&show_table_list);
1971
assert(!lex->query_tables_own_last);
2617
If we have information schema its always the first table and only
2618
the first table. Reset for other tables.
1978
If we have information schema its always the first table and only
1979
the first table. Reset for other tables.
2626
1987
session->restore_backup_open_tables_state(&open_tables_state_backup);
2627
1988
lex->derived_tables= derived_tables;
2635
bool store_schema_shemata(Session* session, Table *table, LEX_STRING *db_name,
2636
const CHARSET_INFO * const cs)
2638
restore_record(table, s->default_values);
2639
table->field[1]->store(db_name->str, db_name->length, system_charset_info);
2640
table->field[2]->store(cs->csname, strlen(cs->csname), system_charset_info);
2641
table->field[3]->store(cs->name, strlen(cs->name), system_charset_info);
2642
return schema_table_store_record(session, table);
2646
int fill_schema_schemata(Session *session, TableList *tables, COND *cond)
2649
TODO: fill_schema_shemata() is called when new client is connected.
2650
Returning error status in this case leads to client hangup.
2653
LOOKUP_FIELD_VALUES lookup_field_vals;
2654
List<LEX_STRING> db_names;
2655
LEX_STRING *db_name;
2657
HA_CREATE_INFO create;
2658
Table *table= tables->table;
2660
if (get_lookup_field_values(session, cond, tables, &lookup_field_vals))
2662
if (make_db_list(session, &db_names, &lookup_field_vals,
2667
If we have lookup db value we should check that the database exists
2669
if(lookup_field_vals.db_value.str && !lookup_field_vals.wild_db_value &&
2672
char path[FN_REFLEN+16];
2674
struct stat stat_info;
2675
if (!lookup_field_vals.db_value.str[0])
2677
path_len= build_table_filename(path, sizeof(path),
2678
lookup_field_vals.db_value.str, "", "", 0);
2679
path[path_len-1]= 0;
2680
if (stat(path,&stat_info))
2684
List_iterator_fast<LEX_STRING> it(db_names);
2685
while ((db_name=it++))
2687
if (with_i_schema) // information schema name is always first in list
2689
if (store_schema_shemata(session, table, db_name,
2690
system_charset_info))
2696
load_db_opt_by_name(session, db_name->str, &create);
2697
if (store_schema_shemata(session, table, db_name,
2698
create.default_table_charset))
2706
static int get_schema_tables_record(Session *session, TableList *tables,
2707
Table *table, bool res,
2708
LEX_STRING *db_name,
2709
LEX_STRING *table_name)
2711
const char *tmp_buff;
2713
const CHARSET_INFO * const cs= system_charset_info;
2715
restore_record(table, s->default_values);
2716
table->field[1]->store(db_name->str, db_name->length, cs);
2717
table->field[2]->store(table_name->str, table_name->length, cs);
2721
there was errors during opening tables
2723
const char *error= session->is_error() ? session->main_da.message() : "";
2724
if (tables->schema_table)
2725
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
2727
table->field[3]->store(STRING_WITH_LEN("BASE Table"), cs);
2728
table->field[20]->store(error, strlen(error), cs);
2729
session->clear_error();
2733
char option_buff[400],*ptr;
2734
Table *show_table= tables->table;
2735
TABLE_SHARE *share= show_table->s;
2736
handler *file= show_table->file;
2737
handlerton *tmp_db_type= share->db_type();
2738
if (share->tmp_table == SYSTEM_TMP_TABLE)
2739
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
2740
else if (share->tmp_table)
2741
table->field[3]->store(STRING_WITH_LEN("LOCAL TEMPORARY"), cs);
2743
table->field[3]->store(STRING_WITH_LEN("BASE Table"), cs);
2745
for (int i= 4; i < 20; i++)
2747
if (i == 7 || (i > 12 && i < 17) || i == 18)
2749
table->field[i]->set_notnull();
2751
tmp_buff= (char *) ha_resolve_storage_engine_name(tmp_db_type);
2752
table->field[4]->store(tmp_buff, strlen(tmp_buff), cs);
2753
table->field[5]->store((int64_t) 0, true);
2756
if (share->min_rows)
2758
ptr= strcpy(ptr," min_rows=")+10;
2759
ptr= int64_t10_to_str(share->min_rows,ptr,10);
2761
if (share->max_rows)
2763
ptr= strcpy(ptr," max_rows=")+10;
2764
ptr= int64_t10_to_str(share->max_rows,ptr,10);
2766
if (share->avg_row_length)
2768
ptr= strcpy(ptr," avg_row_length=")+16;
2769
ptr= int64_t10_to_str(share->avg_row_length,ptr,10);
2771
if (share->db_create_options & HA_OPTION_PACK_KEYS)
2772
ptr= strcpy(ptr," pack_keys=1")+12;
2773
if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
2774
ptr= strcpy(ptr," pack_keys=0")+12;
2775
/* We use CHECKSUM, instead of TABLE_CHECKSUM, for backward compability */
2776
if (share->db_create_options & HA_OPTION_CHECKSUM)
2777
ptr= strcpy(ptr," checksum=1")+11;
2778
if (share->page_checksum != HA_CHOICE_UNDEF)
2779
ptr+= sprintf(ptr, " page_checksum=%s",
2780
ha_choice_values[(uint) share->page_checksum]);
2781
if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
2782
ptr= strcpy(ptr," delay_key_write=1")+18;
2783
if (share->row_type != ROW_TYPE_DEFAULT)
2784
ptr+= sprintf(ptr, " row_format=%s", ha_row_type[(uint)share->row_type]);
2785
if (share->block_size)
2787
ptr= strcpy(ptr, " block_size=")+12;
2788
ptr= int64_t10_to_str(share->block_size, ptr, 10);
2791
if (share->transactional != HA_CHOICE_UNDEF)
2793
ptr+= sprintf(ptr, " TRANSACTIONAL=%s",
2794
(share->transactional == HA_CHOICE_YES ? "1" : "0"));
2796
if (share->transactional != HA_CHOICE_UNDEF)
2797
ptr+= sprintf(ptr, " transactional=%s",
2798
ha_choice_values[(uint) share->transactional]);
2799
table->field[19]->store(option_buff+1,
2800
(ptr == option_buff ? 0 :
2801
(uint) (ptr-option_buff)-1), cs);
2803
tmp_buff= (share->table_charset ?
2804
share->table_charset->name : "default");
2805
table->field[17]->store(tmp_buff, strlen(tmp_buff), cs);
2807
if (share->comment.str)
2808
table->field[20]->store(share->comment.str, share->comment.length, cs);
2812
file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO |
2814
enum row_type row_type = file->get_row_type();
2816
case ROW_TYPE_NOT_USED:
2817
case ROW_TYPE_DEFAULT:
2818
tmp_buff= ((share->db_options_in_use &
2819
HA_OPTION_COMPRESS_RECORD) ? "Compressed" :
2820
(share->db_options_in_use & HA_OPTION_PACK_RECORD) ?
2821
"Dynamic" : "Fixed");
2823
case ROW_TYPE_FIXED:
2826
case ROW_TYPE_DYNAMIC:
2827
tmp_buff= "Dynamic";
2829
case ROW_TYPE_COMPRESSED:
2830
tmp_buff= "Compressed";
2832
case ROW_TYPE_REDUNDANT:
2833
tmp_buff= "Redundant";
2835
case ROW_TYPE_COMPACT:
2836
tmp_buff= "Compact";
2842
table->field[6]->store(tmp_buff, strlen(tmp_buff), cs);
2843
if (!tables->schema_table)
2845
table->field[7]->store((int64_t) file->stats.records, true);
2846
table->field[7]->set_notnull();
2848
table->field[8]->store((int64_t) file->stats.mean_rec_length, true);
2849
table->field[9]->store((int64_t) file->stats.data_file_length, true);
2850
if (file->stats.max_data_file_length)
2852
table->field[10]->store((int64_t) file->stats.max_data_file_length,
2855
table->field[11]->store((int64_t) file->stats.index_file_length, true);
2856
table->field[12]->store((int64_t) file->stats.delete_length, true);
2857
if (show_table->found_next_number_field)
2859
table->field[13]->store((int64_t) file->stats.auto_increment_value,
2861
table->field[13]->set_notnull();
2863
if (file->stats.create_time)
2865
session->variables.time_zone->gmt_sec_to_TIME(&time,
2866
(time_t) file->stats.create_time);
2867
table->field[14]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2868
table->field[14]->set_notnull();
2870
if (file->stats.update_time)
2872
session->variables.time_zone->gmt_sec_to_TIME(&time,
2873
(time_t) file->stats.update_time);
2874
table->field[15]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2875
table->field[15]->set_notnull();
2877
if (file->stats.check_time)
2879
session->variables.time_zone->gmt_sec_to_TIME(&time,
2880
(time_t) file->stats.check_time);
2881
table->field[16]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2882
table->field[16]->set_notnull();
2884
if (file->ha_table_flags() & (ulong) HA_HAS_CHECKSUM)
2886
table->field[18]->store((int64_t) file->checksum(), true);
2887
table->field[18]->set_notnull();
2891
return(schema_table_store_record(session, table));
2896
1997
@brief Store field characteristics into appropriate I_S table columns
3127
int fill_schema_charsets(Session *session, TableList *tables, COND *)
3130
const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
3131
Table *table= tables->table;
3132
const CHARSET_INFO * const scs= system_charset_info;
3134
for (cs= all_charsets ; cs < all_charsets+255 ; cs++)
3136
const CHARSET_INFO * const tmp_cs= cs[0];
3137
if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) &&
3138
(tmp_cs->state & MY_CS_AVAILABLE) &&
3139
!(tmp_cs->state & MY_CS_HIDDEN) &&
3140
!(wild && wild[0] &&
3141
wild_case_compare(scs, tmp_cs->csname,wild)))
3143
const char *comment;
3144
restore_record(table, s->default_values);
3145
table->field[0]->store(tmp_cs->csname, strlen(tmp_cs->csname), scs);
3146
table->field[1]->store(tmp_cs->name, strlen(tmp_cs->name), scs);
3147
comment= tmp_cs->comment ? tmp_cs->comment : "";
3148
table->field[2]->store(comment, strlen(comment), scs);
3149
table->field[3]->store((int64_t) tmp_cs->mbmaxlen, true);
3150
if (schema_table_store_record(session, table))
3158
int fill_schema_collation(Session *session, TableList *tables, COND *)
3161
const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
3162
Table *table= tables->table;
3163
const CHARSET_INFO * const scs= system_charset_info;
3164
for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
3167
const CHARSET_INFO *tmp_cs= cs[0];
3168
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
3169
(tmp_cs->state & MY_CS_HIDDEN) ||
3170
!(tmp_cs->state & MY_CS_PRIMARY))
3172
for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
3174
const CHARSET_INFO *tmp_cl= cl[0];
3175
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
3176
!my_charset_same(tmp_cs, tmp_cl))
3178
if (!(wild && wild[0] &&
3179
wild_case_compare(scs, tmp_cl->name,wild)))
3181
const char *tmp_buff;
3182
restore_record(table, s->default_values);
3183
table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
3184
table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
3185
table->field[2]->store((int64_t) tmp_cl->number, true);
3186
tmp_buff= (tmp_cl->state & MY_CS_PRIMARY) ? "Yes" : "";
3187
table->field[3]->store(tmp_buff, strlen(tmp_buff), scs);
3188
tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : "";
3189
table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
3190
table->field[5]->store((int64_t) tmp_cl->strxfrm_multiply, true);
3191
if (schema_table_store_record(session, table))
3200
int fill_schema_coll_charset_app(Session *session, TableList *tables, COND *)
3203
Table *table= tables->table;
3204
const CHARSET_INFO * const scs= system_charset_info;
3205
for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
3208
const CHARSET_INFO *tmp_cs= cs[0];
3209
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
3210
!(tmp_cs->state & MY_CS_PRIMARY))
3212
for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
3214
const CHARSET_INFO *tmp_cl= cl[0];
3215
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
3216
!my_charset_same(tmp_cs,tmp_cl))
3218
restore_record(table, s->default_values);
3219
table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
3220
table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
3221
if (schema_table_store_record(session, table))
3229
static int get_schema_stat_record(Session *session, TableList *tables,
3230
Table *table, bool res,
3231
LEX_STRING *db_name,
3232
LEX_STRING *table_name)
3234
const CHARSET_INFO * const cs= system_charset_info;
3237
if (session->lex->sql_command != SQLCOM_SHOW_KEYS)
3240
I.e. we are in SELECT FROM INFORMATION_SCHEMA.STATISTICS
3241
rather than in SHOW KEYS
3243
if (session->is_error())
3244
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3245
session->main_da.sql_errno(), session->main_da.message());
3246
session->clear_error();
3253
Table *show_table= tables->table;
3254
KEY *key_info=show_table->s->key_info;
3255
if (show_table->file)
3256
show_table->file->info(HA_STATUS_VARIABLE |
3259
for (uint32_t i=0 ; i < show_table->s->keys ; i++,key_info++)
3261
KEY_PART_INFO *key_part= key_info->key_part;
3263
for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
3265
restore_record(table, s->default_values);
3266
table->field[1]->store(db_name->str, db_name->length, cs);
3267
table->field[2]->store(table_name->str, table_name->length, cs);
3268
table->field[3]->store((int64_t) ((key_info->flags &
3269
HA_NOSAME) ? 0 : 1), true);
3270
table->field[4]->store(db_name->str, db_name->length, cs);
3271
table->field[5]->store(key_info->name, strlen(key_info->name), cs);
3272
table->field[6]->store((int64_t) (j+1), true);
3273
str=(key_part->field ? key_part->field->field_name :
3275
table->field[7]->store(str, strlen(str), cs);
3276
if (show_table->file)
3278
if (show_table->file->index_flags(i, j, 0) & HA_READ_ORDER)
3280
table->field[8]->store(((key_part->key_part_flag &
3283
table->field[8]->set_notnull();
3285
KEY *key=show_table->key_info+i;
3286
if (key->rec_per_key[j])
3288
ha_rows records=(show_table->file->stats.records /
3289
key->rec_per_key[j]);
3290
table->field[9]->store((int64_t) records, true);
3291
table->field[9]->set_notnull();
3293
str= show_table->file->index_type(i);
3294
table->field[13]->store(str, strlen(str), cs);
3296
if ((key_part->field &&
3298
show_table->s->field[key_part->fieldnr-1]->key_length()))
3300
table->field[10]->store((int64_t) key_part->length /
3301
key_part->field->charset()->mbmaxlen, true);
3302
table->field[10]->set_notnull();
3304
uint32_t flags= key_part->field ? key_part->field->flags : 0;
3305
const char *pos=(char*) ((flags & NOT_NULL_FLAG) ? "" : "YES");
3306
table->field[12]->store(pos, strlen(pos), cs);
3307
if (!show_table->s->keys_in_use.is_set(i))
3308
table->field[14]->store(STRING_WITH_LEN("disabled"), cs);
3310
table->field[14]->store("", 0, cs);
3311
table->field[14]->set_notnull();
3312
assert(test(key_info->flags & HA_USES_COMMENT) ==
3313
(key_info->comment.length > 0));
3314
if (key_info->flags & HA_USES_COMMENT)
3315
table->field[15]->store(key_info->comment.str,
3316
key_info->comment.length, cs);
3317
if (schema_table_store_record(session, table))
3326
bool store_constraints(Session *session, Table *table, LEX_STRING *db_name,
3327
LEX_STRING *table_name, const char *key_name,
3328
uint32_t key_len, const char *con_type, uint32_t con_len)
3330
const CHARSET_INFO * const cs= system_charset_info;
3331
restore_record(table, s->default_values);
3332
table->field[1]->store(db_name->str, db_name->length, cs);
3333
table->field[2]->store(key_name, key_len, cs);
3334
table->field[3]->store(db_name->str, db_name->length, cs);
3335
table->field[4]->store(table_name->str, table_name->length, cs);
3336
table->field[5]->store(con_type, con_len, cs);
3337
return schema_table_store_record(session, table);
3341
static int get_schema_constraints_record(Session *session, TableList *tables,
3342
Table *table, bool res,
3343
LEX_STRING *db_name,
3344
LEX_STRING *table_name)
3348
if (session->is_error())
3349
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3350
session->main_da.sql_errno(), session->main_da.message());
3351
session->clear_error();
3356
List<FOREIGN_KEY_INFO> f_key_list;
3357
Table *show_table= tables->table;
3358
KEY *key_info=show_table->key_info;
3359
uint32_t primary_key= show_table->s->primary_key;
3360
show_table->file->info(HA_STATUS_VARIABLE |
3363
for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
3365
if (i != primary_key && !(key_info->flags & HA_NOSAME))
3368
if (i == primary_key && is_primary_key(key_info))
3370
if (store_constraints(session, table, db_name, table_name, key_info->name,
3371
strlen(key_info->name),
3372
STRING_WITH_LEN("PRIMARY KEY")))
3375
else if (key_info->flags & HA_NOSAME)
3377
if (store_constraints(session, table, db_name, table_name, key_info->name,
3378
strlen(key_info->name),
3379
STRING_WITH_LEN("UNIQUE")))
3384
show_table->file->get_foreign_key_list(session, &f_key_list);
3385
FOREIGN_KEY_INFO *f_key_info;
3386
List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
3387
while ((f_key_info=it++))
3389
if (store_constraints(session, table, db_name, table_name,
3390
f_key_info->forein_id->str,
3391
strlen(f_key_info->forein_id->str),
3400
void store_key_column_usage(Table *table, LEX_STRING *db_name,
3401
LEX_STRING *table_name, const char *key_name,
3402
uint32_t key_len, const char *con_type, uint32_t con_len,
3405
const CHARSET_INFO * const cs= system_charset_info;
3406
table->field[1]->store(db_name->str, db_name->length, cs);
3407
table->field[2]->store(key_name, key_len, cs);
3408
table->field[4]->store(db_name->str, db_name->length, cs);
3409
table->field[5]->store(table_name->str, table_name->length, cs);
3410
table->field[6]->store(con_type, con_len, cs);
3411
table->field[7]->store((int64_t) idx, true);
3415
static int get_schema_key_column_usage_record(Session *session,
3417
Table *table, bool res,
3418
LEX_STRING *db_name,
3419
LEX_STRING *table_name)
3423
if (session->is_error())
3424
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3425
session->main_da.sql_errno(), session->main_da.message());
3426
session->clear_error();
3431
List<FOREIGN_KEY_INFO> f_key_list;
3432
Table *show_table= tables->table;
3433
KEY *key_info=show_table->key_info;
3434
uint32_t primary_key= show_table->s->primary_key;
3435
show_table->file->info(HA_STATUS_VARIABLE |
3438
for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
3440
if (i != primary_key && !(key_info->flags & HA_NOSAME))
3443
KEY_PART_INFO *key_part= key_info->key_part;
3444
for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
3446
if (key_part->field)
3449
restore_record(table, s->default_values);
3450
store_key_column_usage(table, db_name, table_name,
3452
strlen(key_info->name),
3453
key_part->field->field_name,
3454
strlen(key_part->field->field_name),
3456
if (schema_table_store_record(session, table))
3462
show_table->file->get_foreign_key_list(session, &f_key_list);
3463
FOREIGN_KEY_INFO *f_key_info;
3464
List_iterator_fast<FOREIGN_KEY_INFO> fkey_it(f_key_list);
3465
while ((f_key_info= fkey_it++))
3469
List_iterator_fast<LEX_STRING> it(f_key_info->foreign_fields),
3470
it1(f_key_info->referenced_fields);
3472
while ((f_info= it++))
3476
restore_record(table, s->default_values);
3477
store_key_column_usage(table, db_name, table_name,
3478
f_key_info->forein_id->str,
3479
f_key_info->forein_id->length,
3480
f_info->str, f_info->length,
3482
table->field[8]->store((int64_t) f_idx, true);
3483
table->field[8]->set_notnull();
3484
table->field[9]->store(f_key_info->referenced_db->str,
3485
f_key_info->referenced_db->length,
3486
system_charset_info);
3487
table->field[9]->set_notnull();
3488
table->field[10]->store(f_key_info->referenced_table->str,
3489
f_key_info->referenced_table->length,
3490
system_charset_info);
3491
table->field[10]->set_notnull();
3492
table->field[11]->store(r_info->str, r_info->length,
3493
system_charset_info);
3494
table->field[11]->set_notnull();
3495
if (schema_table_store_record(session, table))
3504
int fill_open_tables(Session *session, TableList *tables, COND *)
3506
const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
3507
Table *table= tables->table;
3508
const CHARSET_INFO * const cs= system_charset_info;
3509
OPEN_TableList *open_list;
3510
if (!(open_list=list_open_tables(session->lex->select_lex.db, wild))
3511
&& session->is_fatal_error)
3514
for (; open_list ; open_list=open_list->next)
3516
restore_record(table, s->default_values);
3517
table->field[0]->store(open_list->db, strlen(open_list->db), cs);
3518
table->field[1]->store(open_list->table, strlen(open_list->table), cs);
3519
table->field[2]->store((int64_t) open_list->in_use, true);
3520
table->field[3]->store((int64_t) open_list->locked, true);
3521
if (schema_table_store_record(session, table))
3528
int fill_variables(Session *session, TableList *tables, COND *)
3531
LEX *lex= session->lex;
3532
const char *wild= lex->wild ? lex->wild->ptr() : NULL;
3533
enum enum_schema_tables schema_table_idx=
3534
get_schema_table_idx(tables->schema_table);
3535
enum enum_var_type option_type= OPT_SESSION;
3536
bool upper_case_names= (schema_table_idx != SCH_VARIABLES);
3537
bool sorted_vars= (schema_table_idx == SCH_VARIABLES);
3539
if (lex->option_type == OPT_GLOBAL ||
3540
schema_table_idx == SCH_GLOBAL_VARIABLES)
3541
option_type= OPT_GLOBAL;
3543
pthread_rwlock_rdlock(&LOCK_system_variables_hash);
3544
res= show_status_array(session, wild, enumerate_sys_vars(session, sorted_vars),
3545
option_type, NULL, "", tables->table, upper_case_names);
3546
pthread_rwlock_unlock(&LOCK_system_variables_hash);
3551
int fill_status(Session *session, TableList *tables, COND *)
3553
LEX *lex= session->lex;
3554
const char *wild= lex->wild ? lex->wild->ptr() : NULL;
3556
STATUS_VAR *tmp1, tmp;
3557
enum enum_schema_tables schema_table_idx=
3558
get_schema_table_idx(tables->schema_table);
3559
enum enum_var_type option_type;
3560
bool upper_case_names= (schema_table_idx != SCH_STATUS);
3562
if (schema_table_idx == SCH_STATUS)
3564
option_type= lex->option_type;
3565
if (option_type == OPT_GLOBAL)
3568
tmp1= session->initial_status_var;
3570
else if (schema_table_idx == SCH_GLOBAL_STATUS)
3572
option_type= OPT_GLOBAL;
3577
option_type= OPT_SESSION;
3578
tmp1= &session->status_var;
3581
pthread_mutex_lock(&LOCK_status);
3582
if (option_type == OPT_GLOBAL)
3583
calc_sum_of_all_status(&tmp);
3584
res= show_status_array(session, wild,
3585
(SHOW_VAR *)all_status_vars.buffer,
3586
option_type, tmp1, "", tables->table,
3588
pthread_mutex_unlock(&LOCK_status);
3594
Fill and store records into I_S.referential_constraints table
3597
get_referential_constraints_record()
3598
session thread handle
3599
tables table list struct(processed table)
3601
res 1 means the error during opening of the processed table
3602
0 means processed table is opened without error
3604
file_name table name
3612
get_referential_constraints_record(Session *session, TableList *tables,
3613
Table *table, bool res,
3614
LEX_STRING *db_name, LEX_STRING *table_name)
3616
const CHARSET_INFO * const cs= system_charset_info;
3620
if (session->is_error())
3621
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3622
session->main_da.sql_errno(), session->main_da.message());
3623
session->clear_error();
3628
List<FOREIGN_KEY_INFO> f_key_list;
3629
Table *show_table= tables->table;
3630
show_table->file->info(HA_STATUS_VARIABLE |
3634
show_table->file->get_foreign_key_list(session, &f_key_list);
3635
FOREIGN_KEY_INFO *f_key_info;
3636
List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
3637
while ((f_key_info= it++))
3639
restore_record(table, s->default_values);
3640
table->field[1]->store(db_name->str, db_name->length, cs);
3641
table->field[9]->store(table_name->str, table_name->length, cs);
3642
table->field[2]->store(f_key_info->forein_id->str,
3643
f_key_info->forein_id->length, cs);
3644
table->field[4]->store(f_key_info->referenced_db->str,
3645
f_key_info->referenced_db->length, cs);
3646
table->field[10]->store(f_key_info->referenced_table->str,
3647
f_key_info->referenced_table->length, cs);
3648
if (f_key_info->referenced_key_name)
3650
table->field[5]->store(f_key_info->referenced_key_name->str,
3651
f_key_info->referenced_key_name->length, cs);
3652
table->field[5]->set_notnull();
3655
table->field[5]->set_null();
3656
table->field[6]->store(STRING_WITH_LEN("NONE"), cs);
3657
table->field[7]->store(f_key_info->update_method->str,
3658
f_key_info->update_method->length, cs);
3659
table->field[8]->store(f_key_info->delete_method->str,
3660
f_key_info->delete_method->length, cs);
3661
if (schema_table_store_record(session, table))
3669
struct schema_table_ref
3671
const char *table_name;
3672
ST_SCHEMA_TABLE *schema_table;
3677
Find schema_tables elment by name
3680
find_schema_table_in_plugin()
3681
session thread handler
3683
table_name table name
3687
1 found the schema table
3689
static bool find_schema_table_in_plugin(Session *, plugin_ref plugin,
3692
schema_table_ref *p_schema_table= (schema_table_ref *)p_table;
3693
const char* table_name= p_schema_table->table_name;
3694
ST_SCHEMA_TABLE *schema_table= plugin_data(plugin, ST_SCHEMA_TABLE *);
3696
if (!my_strcasecmp(system_charset_info,
3697
schema_table->table_name,
3699
p_schema_table->schema_table= schema_table;
3708
Find schema_tables elment by name
3712
session thread handler
3713
table_name table name
3717
# pointer to 'schema_tables' element
3720
ST_SCHEMA_TABLE *find_schema_table(Session *session, const char* table_name)
3722
schema_table_ref schema_table_a;
3723
ST_SCHEMA_TABLE *schema_table= schema_tables;
3725
for (; schema_table->table_name; schema_table++)
3727
if (!my_strcasecmp(system_charset_info,
3728
schema_table->table_name,
3730
return(schema_table);
3733
schema_table_a.table_name= table_name;
3734
if (plugin_foreach(session, find_schema_table_in_plugin,
3735
DRIZZLE_INFORMATION_SCHEMA_PLUGIN, &schema_table_a))
3736
return(schema_table_a.schema_table);
3742
ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx)
3744
return &schema_tables[schema_table_idx];
3749
Create information_schema table using schema_table data.
3754
session thread handler
3756
@param table_list Used to pass I_S table information(fields info, tables
3757
parameters etc) and table name.
3759
@retval \# Pointer to created table
3760
@retval NULL Can't create table
3763
Table *create_schema_table(Session *session, TableList *table_list)
2216
Table *plugin::InfoSchemaMethods::createSchemaTable(Session *session, TableList *table_list)
3765
2219
int field_count= 0;
3768
2222
List<Item> field_list;
3769
ST_SCHEMA_TABLE *schema_table= table_list->schema_table;
3770
ST_FIELD_INFO *fields_info= schema_table->fields_info;
3771
2223
const CHARSET_INFO * const cs= system_charset_info;
2224
const plugin::InfoSchemaTable::Columns &columns= table_list->schema_table->getColumns();
2225
plugin::InfoSchemaTable::Columns::const_iterator iter= columns.begin();
3773
for (; fields_info->field_name; fields_info++)
2227
while (iter != columns.end())
3775
switch (fields_info->field_type) {
2229
const plugin::ColumnInfo *column= *iter;
2230
switch (column->getType()) {
3776
2231
case DRIZZLE_TYPE_LONG:
3777
2232
case DRIZZLE_TYPE_LONGLONG:
3778
if (!(item= new Item_return_int(fields_info->field_name,
3779
fields_info->field_length,
3780
fields_info->field_type,
3781
fields_info->value)))
2233
if (!(item= new Item_return_int(column->getName().c_str(),
2234
column->getLength(),
2236
column->getValue())))
3785
item->unsigned_flag= (fields_info->field_flags & MY_I_S_UNSIGNED);
2240
item->unsigned_flag= (column->getFlags() & MY_I_S_UNSIGNED);
3787
2242
case DRIZZLE_TYPE_DATE:
3788
case DRIZZLE_TYPE_TIME:
3789
2243
case DRIZZLE_TYPE_TIMESTAMP:
3790
2244
case DRIZZLE_TYPE_DATETIME:
3791
if (!(item=new Item_return_date_time(fields_info->field_name,
3792
fields_info->field_type)))
2245
if (!(item=new Item_return_date_time(column->getName().c_str(),
2246
column->getType())))
3797
2251
case DRIZZLE_TYPE_DOUBLE:
3798
if ((item= new Item_float(fields_info->field_name, 0.0, NOT_FIXED_DEC,
3799
fields_info->field_length)) == NULL)
2252
if ((item= new Item_float(column->getName().c_str(), 0.0, NOT_FIXED_DEC,
2253
column->getLength())) == NULL)
3802
2256
case DRIZZLE_TYPE_NEWDECIMAL:
3803
if (!(item= new Item_decimal((int64_t) fields_info->value, false)))
2257
if (!(item= new Item_decimal((int64_t) column->getValue(), false)))
3807
item->unsigned_flag= (fields_info->field_flags & MY_I_S_UNSIGNED);
3808
item->decimals= fields_info->field_length%10;
3809
item->max_length= (fields_info->field_length/100)%100;
2261
item->unsigned_flag= (column->getFlags() & MY_I_S_UNSIGNED);
2262
item->decimals= column->getLength() % 10;
2263
item->max_length= (column->getLength()/100)%100;
3810
2264
if (item->unsigned_flag == 0)
3811
2265
item->max_length+= 1;
3812
2266
if (item->decimals > 0)
3813
2267
item->max_length+= 1;
3814
item->set_name(fields_info->field_name,
3815
strlen(fields_info->field_name), cs);
2268
item->set_name(column->getName().c_str(),
2269
column->getName().length(), cs);
3817
2271
case DRIZZLE_TYPE_BLOB:
3818
if (!(item= new Item_blob(fields_info->field_name,
3819
fields_info->field_length)))
2272
if (!(item= new Item_blob(column->getName().c_str(),
2273
column->getLength())))
3825
if (!(item= new Item_empty_string("", fields_info->field_length, cs)))
2279
if (!(item= new Item_empty_string("", column->getLength(), cs)))
3829
item->set_name(fields_info->field_name,
3830
strlen(fields_info->field_name), cs);
2283
item->set_name(column->getName().c_str(),
2284
column->getName().length(), cs);
3833
2287
field_list.push_back(item);
3834
item->maybe_null= (fields_info->field_flags & MY_I_S_MAYBE_NULL);
2288
item->maybe_null= (column->getFlags() & MY_I_S_MAYBE_NULL);
3837
TMP_TABLE_PARAM *tmp_table_param =
3838
(TMP_TABLE_PARAM*) (session->alloc(sizeof(TMP_TABLE_PARAM)));
2292
Tmp_Table_Param *tmp_table_param =
2293
(Tmp_Table_Param*) (session->alloc(sizeof(Tmp_Table_Param)));
3839
2294
tmp_table_param->init();
3840
2295
tmp_table_param->table_charset= cs;
3841
2296
tmp_table_param->field_count= field_count;
3842
2297
tmp_table_param->schema_table= 1;
3843
SELECT_LEX *select_lex= session->lex->current_select;
2298
Select_Lex *select_lex= session->lex->current_select;
3844
2299
if (!(table= create_tmp_table(session, tmp_table_param,
3845
2300
field_list, (order_st*) 0, 0, 0,
3846
2301
(select_lex->options | session->options |
4180
2520
session->no_warnings_for_error= 0;
4181
2521
return(result);
4184
ST_FIELD_INFO schema_fields_info[]=
4186
{"CATALOG_NAME", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4187
{"SCHEMA_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Database",
4189
{"DEFAULT_CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4191
{"DEFAULT_COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4192
{"SQL_PATH", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4193
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4197
ST_FIELD_INFO tables_fields_info[]=
4199
{"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4200
{"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4201
{"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name",
4203
{"TABLE_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4204
{"ENGINE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Engine", OPEN_FRM_ONLY},
4205
{"VERSION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4206
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Version", OPEN_FRM_ONLY},
4207
{"ROW_FORMAT", 10, DRIZZLE_TYPE_VARCHAR, 0, 1, "Row_format", OPEN_FULL_TABLE},
4208
{"TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4209
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Rows", OPEN_FULL_TABLE},
4210
{"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4211
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Avg_row_length", OPEN_FULL_TABLE},
4212
{"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4213
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_length", OPEN_FULL_TABLE},
4214
{"MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4215
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Max_data_length", OPEN_FULL_TABLE},
4216
{"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4217
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Index_length", OPEN_FULL_TABLE},
4218
{"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4219
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free", OPEN_FULL_TABLE},
4220
{"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG, 0,
4221
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Auto_increment", OPEN_FULL_TABLE},
4222
{"CREATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Create_time", OPEN_FULL_TABLE},
4223
{"UPDATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Update_time", OPEN_FULL_TABLE},
4224
{"CHECK_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Check_time", OPEN_FULL_TABLE},
4225
{"TABLE_COLLATION", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY},
4226
{"CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4227
(MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum", OPEN_FULL_TABLE},
4228
{"CREATE_OPTIONS", 255, DRIZZLE_TYPE_VARCHAR, 0, 1, "Create_options",
4230
{"TABLE_COMMENT", TABLE_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Comment", OPEN_FRM_ONLY},
4231
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4235
ST_FIELD_INFO columns_fields_info[]=
4237
{"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FRM_ONLY},
4238
{"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4239
{"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4240
{"COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Field",
4242
{"ORDINAL_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
4243
MY_I_S_UNSIGNED, 0, OPEN_FRM_ONLY},
4244
{"COLUMN_DEFAULT", MAX_FIELD_VARCHARLENGTH, DRIZZLE_TYPE_VARCHAR, 0,
4245
1, "Default", OPEN_FRM_ONLY},
4246
{"IS_NULLABLE", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Null", OPEN_FRM_ONLY},
4247
{"DATA_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4248
{"CHARACTER_MAXIMUM_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG,
4249
0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4250
{"CHARACTER_OCTET_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG,
4251
0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4252
{"NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG,
4253
0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4254
{"NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG,
4255
0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4256
{"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FRM_ONLY},
4257
{"COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY},
4258
{"COLUMN_TYPE", 65535, DRIZZLE_TYPE_VARCHAR, 0, 0, "Type", OPEN_FRM_ONLY},
4259
{"COLUMN_KEY", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Key", OPEN_FRM_ONLY},
4260
{"EXTRA", 27, DRIZZLE_TYPE_VARCHAR, 0, 0, "Extra", OPEN_FRM_ONLY},
4261
{"PRIVILEGES", 80, DRIZZLE_TYPE_VARCHAR, 0, 0, "Privileges", OPEN_FRM_ONLY},
4262
{"COLUMN_COMMENT", COLUMN_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Comment", OPEN_FRM_ONLY},
4263
{"STORAGE", 8, DRIZZLE_TYPE_VARCHAR, 0, 0, "Storage", OPEN_FRM_ONLY},
4264
{"FORMAT", 8, DRIZZLE_TYPE_VARCHAR, 0, 0, "Format", OPEN_FRM_ONLY},
4265
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4269
ST_FIELD_INFO charsets_fields_info[]=
4271
{"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Charset",
4273
{"DEFAULT_COLLATE_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Default collation",
4275
{"DESCRIPTION", 60, DRIZZLE_TYPE_VARCHAR, 0, 0, "Description",
4277
{"MAXLEN", 3, DRIZZLE_TYPE_LONGLONG, 0, 0, "Maxlen", SKIP_OPEN_TABLE},
4278
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4282
ST_FIELD_INFO collation_fields_info[]=
4284
{"COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Collation", SKIP_OPEN_TABLE},
4285
{"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Charset",
4287
{"ID", MY_INT32_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 0, "Id",
4289
{"IS_DEFAULT", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Default", SKIP_OPEN_TABLE},
4290
{"IS_COMPILED", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Compiled", SKIP_OPEN_TABLE},
4291
{"SORTLEN", 3, DRIZZLE_TYPE_LONGLONG, 0, 0, "Sortlen", SKIP_OPEN_TABLE},
4292
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4297
ST_FIELD_INFO coll_charset_app_fields_info[]=
4299
{"COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4300
{"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4301
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4305
ST_FIELD_INFO stat_fields_info[]=
4307
{"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FRM_ONLY},
4308
{"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4309
{"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table", OPEN_FRM_ONLY},
4310
{"NON_UNIQUE", 1, DRIZZLE_TYPE_LONGLONG, 0, 0, "Non_unique", OPEN_FRM_ONLY},
4311
{"INDEX_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4312
{"INDEX_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Key_name",
4314
{"SEQ_IN_INDEX", 2, DRIZZLE_TYPE_LONGLONG, 0, 0, "Seq_in_index", OPEN_FRM_ONLY},
4315
{"COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Column_name",
4317
{"COLLATION", 1, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY},
4318
{"CARDINALITY", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 1,
4319
"Cardinality", OPEN_FULL_TABLE},
4320
{"SUB_PART", 3, DRIZZLE_TYPE_LONGLONG, 0, 1, "Sub_part", OPEN_FRM_ONLY},
4321
{"PACKED", 10, DRIZZLE_TYPE_VARCHAR, 0, 1, "Packed", OPEN_FRM_ONLY},
4322
{"NULLABLE", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Null", OPEN_FRM_ONLY},
4323
{"INDEX_TYPE", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "Index_type", OPEN_FULL_TABLE},
4324
{"COMMENT", 16, DRIZZLE_TYPE_VARCHAR, 0, 1, "Comment", OPEN_FRM_ONLY},
4325
{"INDEX_COMMENT", INDEX_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Index_Comment", OPEN_FRM_ONLY},
4326
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4330
ST_FIELD_INFO table_constraints_fields_info[]=
4332
{"CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4333
{"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4335
{"CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4337
{"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4338
{"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4339
{"CONSTRAINT_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4341
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4345
ST_FIELD_INFO key_column_usage_fields_info[]=
4347
{"CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4348
{"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4350
{"CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4352
{"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4353
{"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4354
{"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4355
{"COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4356
{"ORDINAL_POSITION", 10 ,DRIZZLE_TYPE_LONGLONG, 0, 0, 0, OPEN_FULL_TABLE},
4357
{"POSITION_IN_UNIQUE_CONSTRAINT", 10 ,DRIZZLE_TYPE_LONGLONG, 0, 1, 0,
4359
{"REFERENCED_TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4361
{"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4363
{"REFERENCED_COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4365
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4369
ST_FIELD_INFO table_names_fields_info[]=
4371
{"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4372
{"TABLE_SCHEMA",NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4373
{"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Tables_in_",
4375
{"TABLE_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table_type",
4377
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4381
ST_FIELD_INFO open_tables_fields_info[]=
4383
{"Database", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Database",
4385
{"Table",NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table", SKIP_OPEN_TABLE},
4386
{"In_use", 1, DRIZZLE_TYPE_LONGLONG, 0, 0, "In_use", SKIP_OPEN_TABLE},
4387
{"Name_locked", 4, DRIZZLE_TYPE_LONGLONG, 0, 0, "Name_locked", SKIP_OPEN_TABLE},
4388
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4392
ST_FIELD_INFO variables_fields_info[]=
4394
{"VARIABLE_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Variable_name",
4396
{"VARIABLE_VALUE", 16300, DRIZZLE_TYPE_VARCHAR, 0, 1, "Value", SKIP_OPEN_TABLE},
4397
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4401
ST_FIELD_INFO processlist_fields_info[]=
4403
{"ID", 4, DRIZZLE_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE},
4404
{"USER", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "User", SKIP_OPEN_TABLE},
4405
{"HOST", LIST_PROCESS_HOST_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Host",
4407
{"DB", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Db", SKIP_OPEN_TABLE},
4408
{"COMMAND", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "Command", SKIP_OPEN_TABLE},
4409
{"TIME", 7, DRIZZLE_TYPE_LONGLONG, 0, 0, "Time", SKIP_OPEN_TABLE},
4410
{"STATE", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "State", SKIP_OPEN_TABLE},
4411
{"INFO", PROCESS_LIST_INFO_WIDTH, DRIZZLE_TYPE_VARCHAR, 0, 1, "Info",
4413
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4417
ST_FIELD_INFO plugin_fields_info[]=
4419
{"PLUGIN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name",
4421
{"PLUGIN_VERSION", 20, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4422
{"PLUGIN_STATUS", 10, DRIZZLE_TYPE_VARCHAR, 0, 0, "Status", SKIP_OPEN_TABLE},
4423
{"PLUGIN_TYPE", 80, DRIZZLE_TYPE_VARCHAR, 0, 0, "Type", SKIP_OPEN_TABLE},
4424
{"PLUGIN_LIBRARY", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Library",
4426
{"PLUGIN_AUTHOR", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4427
{"PLUGIN_DESCRIPTION", 65535, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4428
{"PLUGIN_LICENSE", 80, DRIZZLE_TYPE_VARCHAR, 0, 1, "License", SKIP_OPEN_TABLE},
4429
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4432
ST_FIELD_INFO referential_constraints_fields_info[]=
4434
{"CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4435
{"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4437
{"CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4439
{"UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4441
{"UNIQUE_CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4443
{"UNIQUE_CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0,
4444
MY_I_S_MAYBE_NULL, 0, OPEN_FULL_TABLE},
4445
{"MATCH_OPTION", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4446
{"UPDATE_RULE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4447
{"DELETE_RULE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4448
{"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4449
{"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4451
{0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
4456
Description of ST_FIELD_INFO in table.h
4458
Make sure that the order of schema_tables and enum_schema_tables are the same.
4462
ST_SCHEMA_TABLE schema_tables[]=
4464
{"CHARACTER_SETS", charsets_fields_info, create_schema_table,
4465
fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0},
4466
{"COLLATIONS", collation_fields_info, create_schema_table,
4467
fill_schema_collation, make_old_format, 0, -1, -1, 0, 0},
4468
{"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
4469
create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, 0},
4470
{"COLUMNS", columns_fields_info, create_schema_table,
4471
get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0,
4472
OPTIMIZE_I_S_TABLE},
4473
{"GLOBAL_STATUS", variables_fields_info, create_schema_table,
4474
fill_status, make_old_format, 0, -1, -1, 0, 0},
4475
{"GLOBAL_VARIABLES", variables_fields_info, create_schema_table,
4476
fill_variables, make_old_format, 0, -1, -1, 0, 0},
4477
{"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
4478
get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0,
4480
{"OPEN_TABLES", open_tables_fields_info, create_schema_table,
4481
fill_open_tables, make_old_format, 0, -1, -1, 1, 0},
4482
{"PLUGINS", plugin_fields_info, create_schema_table,
4483
fill_plugins, make_old_format, 0, -1, -1, 0, 0},
4484
{"PROCESSLIST", processlist_fields_info, create_schema_table,
4485
fill_schema_processlist, make_old_format, 0, -1, -1, 0, 0},
4486
{"REFERENTIAL_CONSTRAINTS", referential_constraints_fields_info,
4487
create_schema_table, get_all_tables, 0, get_referential_constraints_record,
4488
1, 9, 0, OPEN_TABLE_ONLY},
4489
{"SCHEMATA", schema_fields_info, create_schema_table,
4490
fill_schema_schemata, make_schemata_old_format, 0, 1, -1, 0, 0},
4491
{"SESSION_STATUS", variables_fields_info, create_schema_table,
4492
fill_status, make_old_format, 0, -1, -1, 0, 0},
4493
{"SESSION_VARIABLES", variables_fields_info, create_schema_table,
4494
fill_variables, make_old_format, 0, -1, -1, 0, 0},
4495
{"STATISTICS", stat_fields_info, create_schema_table,
4496
get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0,
4497
OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE},
4498
{"STATUS", variables_fields_info, create_schema_table, fill_status,
4499
make_old_format, 0, -1, -1, 1, 0},
4500
{"TABLES", tables_fields_info, create_schema_table,
4501
get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0,
4502
OPTIMIZE_I_S_TABLE},
4503
{"TABLE_CONSTRAINTS", table_constraints_fields_info, create_schema_table,
4504
get_all_tables, 0, get_schema_constraints_record, 3, 4, 0, OPEN_TABLE_ONLY},
4505
{"TABLE_NAMES", table_names_fields_info, create_schema_table,
4506
get_all_tables, make_table_names_old_format, 0, 1, 2, 1, 0},
4507
{"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
4508
make_old_format, 0, -1, -1, 1, 0},
4509
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
4513
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
4514
template class List_iterator_fast<char>;
4515
template class List<char>;
4518
int initialize_schema_table(st_plugin_int *plugin)
4520
ST_SCHEMA_TABLE *schema_table;
4522
if ((schema_table= new ST_SCHEMA_TABLE) == NULL)
4524
memset(schema_table, 0, sizeof(ST_SCHEMA_TABLE));
4526
/* Historical Requirement */
4527
plugin->data= schema_table; // shortcut for the future
4528
if (plugin->plugin->init)
4530
schema_table->create_table= create_schema_table;
4531
schema_table->old_format= make_old_format;
4532
schema_table->idx_field1= -1,
4533
schema_table->idx_field2= -1;
4535
/* Make the name available to the init() function. */
4536
schema_table->table_name= plugin->name.str;
4538
if (plugin->plugin->init(schema_table))
4540
errmsg_printf(ERRMSG_LVL_ERROR,
4541
_("Plugin '%s' init function returned error."),
4546
/* Make sure the plugin name is not set inside the init() function. */
4547
schema_table->table_name= plugin->name.str;
4552
delete schema_table;
4557
int finalize_schema_table(st_plugin_int *plugin)
4559
ST_SCHEMA_TABLE *schema_table= (ST_SCHEMA_TABLE *)plugin->data;
4561
if (schema_table && plugin->plugin->deinit)
4562
delete schema_table;