25
25
#include <drizzled/data_home.h>
26
26
#include <drizzled/sql_base.h>
27
27
#include <drizzled/show.h>
28
#include <drizzled/info_schema.h>
28
29
#include <drizzled/rename.h>
29
30
#include <drizzled/function/time/unix_timestamp.h>
30
31
#include <drizzled/function/get_system_var.h>
129
130
The following admin table operations are allowed
132
sql_command_flags[SQLCOM_REPAIR]= CF_WRITE_LOGS_COMMAND;
133
133
sql_command_flags[SQLCOM_OPTIMIZE]= CF_WRITE_LOGS_COMMAND;
134
134
sql_command_flags[SQLCOM_ANALYZE]= CF_WRITE_LOGS_COMMAND;
317
317
It prepares a Select_Lex and a TableList object to represent the
318
318
given command as a SELECT parse tree.
320
@param session thread handle
321
@param lex current lex
322
@param table_ident table alias if it's used
323
@param schema_table_idx the type of the INFORMATION_SCHEMA table to be
320
@param session thread handle
321
@param lex current lex
322
@param table_ident table alias if it's used
323
@param schema_table_name the name of the INFORMATION_SCHEMA table to be
327
327
Due to the way this function works with memory and LEX it cannot
338
338
int prepare_schema_table(Session *session, LEX *lex, Table_ident *table_ident,
339
enum enum_schema_tables schema_table_idx)
339
const string& schema_table_name)
341
341
Select_Lex *schema_select_lex= NULL;
343
switch (schema_table_idx) {
346
case SCH_TABLE_NAMES:
351
if (lex->select_lex.db == NULL &&
352
lex->copy_db_to(&lex->select_lex.db, &dummy))
356
schema_select_lex= new Select_Lex();
357
db.str= schema_select_lex->db= lex->select_lex.db;
358
schema_select_lex->table_list.first= NULL;
359
db.length= strlen(db.str);
361
if (check_db_name(&db))
363
my_error(ER_WRONG_DB_NAME, MYF(0), db.str);
344
if (schema_table_name.compare("TABLES") == 0 ||
345
schema_table_name.compare("TABLE_NAMES") == 0)
349
if (lex->select_lex.db == NULL &&
350
lex->copy_db_to(&lex->select_lex.db, &dummy))
354
schema_select_lex= new Select_Lex();
355
db.str= schema_select_lex->db= lex->select_lex.db;
356
schema_select_lex->table_list.first= NULL;
357
db.length= strlen(db.str);
359
if (check_db_name(&db))
361
my_error(ER_WRONG_DB_NAME, MYF(0), db.str);
365
else if (schema_table_name.compare("COLUMNS") == 0 ||
366
schema_table_name.compare("STATISTICS") == 0)
371
368
assert(table_ident);
372
369
TableList **query_tables_last= lex->query_tables_last;
374
371
/* 'parent_lex' is used in init_query() so it must be before it. */
375
372
schema_select_lex->parent_lex= lex;
376
373
schema_select_lex->init_query();
377
if (!schema_select_lex->add_table_to_list(session, table_ident, 0, 0, TL_READ))
374
if (! schema_select_lex->add_table_to_list(session, table_ident, 0, 0, TL_READ))
379
378
lex->query_tables_last= query_tables_last;
382
case SCH_OPEN_TABLES:
387
case SCH_COLLATION_CHARACTER_SET_APPLICABILITY:
388
case SCH_TABLE_CONSTRAINTS:
389
case SCH_KEY_COLUMN_USAGE:
394
381
Select_Lex *select_lex= lex->current_select;
395
382
assert(select_lex);
396
if (make_schema_select(session, select_lex, schema_table_idx))
383
if (make_schema_select(session, select_lex, schema_table_name))
553
540
case SQLCOM_SHOW_ENGINE_STATUS:
555
res = ha_show_status(session, lex->create_info.db_type, HA_ENGINE_STATUS);
542
res = ha_show_status(session, lex->show_engine, HA_ENGINE_STATUS);
558
545
case SQLCOM_CREATE_TABLE:
825
813
res = mysql_checksum_table(session, first_table, &lex->check_opt);
830
assert(first_table == all_tables && first_table != 0);
831
res= mysql_repair_table(session, first_table, &lex->check_opt);
832
/* ! we write after unlocking the table */
834
Presumably, REPAIR and binlog writing doesn't require synchronization
836
write_bin_log(session, true, session->query, session->query_length);
837
select_lex->table_list.first= (unsigned char*) first_table;
838
lex->query_tables=all_tables;
841
816
case SQLCOM_CHECK:
843
818
assert(first_table == all_tables && first_table != 0);
1083
1058
case SQLCOM_SHOW_PROCESSLIST:
1084
1059
mysqld_list_processes(session, NULL, lex->verbose);
1086
case SQLCOM_SHOW_ENGINE_LOGS:
1088
res= ha_show_status(session, lex->create_info.db_type, HA_ENGINE_LOGS);
1091
1061
case SQLCOM_CHANGE_DB:
1093
1063
LEX_STRING db_str= { (char *) select_lex->db, strlen(select_lex->db) };
1906
1876
InfoSchemaTable *schema_table= find_schema_table(ptr->table_name);
1907
1877
if (!schema_table ||
1908
(schema_table->hidden &&
1878
(schema_table->isHidden() &&
1909
1879
((sql_command_flags[lex->sql_command].test(CF_BIT_STATUS_COMMAND)) == 0 ||
1911
1881
this check is used for show columns|keys from I_S hidden table