Additional fix for WL#1629: SHOW with WHERE(discussed with PeterG)

 - Do not allow a column list as part of SHOW WITH WHERE task.
 - The WHERE clause must accept field names which are
   valid in SHOW, not INFORMATION_SCHEMA names.
parent 0a59f6aa
show variables variable_name where variable_name like "skip_show_database"; show variables where variable_name like "skip_show_database";
variable_name Variable_name Value
skip_show_database skip_show_database OFF
grant all privileges on test.* to mysqltest_1@localhost; grant all privileges on test.* to mysqltest_1@localhost;
select * from information_schema.SCHEMATA where schema_name > 'm'; select * from information_schema.SCHEMATA where schema_name > 'm';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH
...@@ -11,11 +11,6 @@ schema_name ...@@ -11,11 +11,6 @@ schema_name
information_schema information_schema
mysql mysql
test test
show databases *;
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH
NULL information_schema utf8 NULL
NULL mysql latin1 NULL
NULL test latin1 NULL
show databases like 't%'; show databases like 't%';
Database (t%) Database (t%)
test test
...@@ -24,11 +19,8 @@ Database ...@@ -24,11 +19,8 @@ Database
information_schema information_schema
mysql mysql
test test
show databases * where schema_name like 't%'; show databases where `database` = 't%';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH Database
NULL test latin1 NULL
show databases * where schema_name = 't%';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH
create database testtets; create database testtets;
create table testtets.t1(a int, b VARCHAR(30), KEY string_data (b)); create table testtets.t1(a int, b VARCHAR(30), KEY string_data (b));
create table test.t2(a int); create table test.t2(a int);
...@@ -116,20 +108,13 @@ t4 ...@@ -116,20 +108,13 @@ t4
select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets"; select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT
NULL testtets t1 1 testtets string_data 1 b A NULL NULL NULL YES BTREE NULL testtets t1 1 testtets string_data 1 b A NULL NULL NULL YES BTREE
show keys * from t3 where TABLE_SCHEMA Like "test%"; show keys from t3 where Key_name = "a_data";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT
NULL test t3 1 test a_data 1 a A NULL NULL NULL YES BTREE
show keys from t3 where INDEX_NAME = "a_data";
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t3 1 a_data 1 a A NULL NULL NULL YES BTREE t3 1 a_data 1 a A NULL NULL NULL YES BTREE
show tables like 't%'; show tables like 't%';
Tables_in_test (t%) Tables_in_test (t%)
t2 t2
t3 t3
show tables * from test where table_name like 't%';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
NULL test t2
NULL test t3
show table status; show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t2 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL t2 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL
...@@ -148,10 +133,9 @@ select * from information_schema.COLUMNS where table_name="t1" ...@@ -148,10 +133,9 @@ select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a"; and column_name= "a";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
NULL testtets t1 a 1 NULL YES int 11 11 11 0 NULL NULL int(11) select,insert,update,references NULL testtets t1 a 1 NULL YES int 11 11 11 0 NULL NULL int(11) select,insert,update,references
show columns * from testtets.t1 where table_name = "t1"; show columns from testtets.t1 where field like "%a%";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT Field Type Null Key Default Extra
NULL testtets t1 a 1 NULL YES int 11 11 11 0 NULL NULL int(11) select,insert,update,references a int(11) YES NULL
NULL testtets t1 b 2 NULL YES varchar 30 30 NULL NULL latin1 latin1_swedish_ci varchar(30) MUL select,insert,update,references
drop view v1; drop view v1;
drop tables testtets.t4, testtets.t1, t2, t3; drop tables testtets.t4, testtets.t1, t2, t3;
drop database testtets; drop database testtets;
...@@ -162,18 +146,9 @@ latin1 latin1_swedish_ci ISO 8859-1 West European 1 ...@@ -162,18 +146,9 @@ latin1 latin1_swedish_ci ISO 8859-1 West European 1
SHOW CHARACTER SET LIKE 'latin1%'; SHOW CHARACTER SET LIKE 'latin1%';
Charset Description Default collation Maxlen Charset Description Default collation Maxlen
latin1 ISO 8859-1 West European latin1_swedish_ci 1 latin1 ISO 8859-1 West European latin1_swedish_ci 1
SHOW CHARACTER SET * LIKE 'latin1%'; SHOW CHARACTER SET WHERE charset like 'latin1%';
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
latin1 latin1_swedish_ci ISO 8859-1 West European 1
SHOW CHARACTER SET WHERE CHARACTER_SET_NAME like 'latin1%';
Charset Description Default collation Maxlen Charset Description Default collation Maxlen
latin1 ISO 8859-1 West European latin1_swedish_ci 1 latin1 ISO 8859-1 West European latin1_swedish_ci 1
SHOW CHARACTER SET CHARACTER_SET_NAME WHERE CHARACTER_SET_NAME like 'latin1%';
CHARACTER_SET_NAME
latin1
SHOW CHARACTER SET * WHERE CHARACTER_SET_NAME like 'latin1%';
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
latin1 latin1_swedish_ci ISO 8859-1 West European 1
select * from information_schema.COLLATIONS select * from information_schema.COLLATIONS
where COLLATION_NAME like 'latin1%'; where COLLATION_NAME like 'latin1%';
COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
...@@ -195,17 +170,7 @@ latin1_bin latin1 47 Yes 1 ...@@ -195,17 +170,7 @@ latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0 latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0 latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0 latin1_spanish_ci latin1 94 0
SHOW COLLATION * LIKE 'latin1%'; SHOW COLLATION WHERE collation like 'latin1%';
COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0
latin1_german2_ci latin1 31 Yes 2
latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0
SHOW COLLATION WHERE COLLATION_NAME like 'latin1%';
Collation Charset Id Default Compiled Sortlen Collation Charset Id Default Compiled Sortlen
latin1_german1_ci latin1 5 0 latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1 latin1_swedish_ci latin1 8 Yes Yes 1
...@@ -215,26 +180,6 @@ latin1_bin latin1 47 Yes 1 ...@@ -215,26 +180,6 @@ latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0 latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0 latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0 latin1_spanish_ci latin1 94 0
SHOW COLLATION COLLATION_NAME WHERE COLLATION_NAME like 'latin1%';
COLLATION_NAME
latin1_german1_ci
latin1_swedish_ci
latin1_danish_ci
latin1_german2_ci
latin1_bin
latin1_general_ci
latin1_general_cs
latin1_spanish_ci
SHOW COLLATION * WHERE COLLATION_NAME like 'latin1%';
COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0
latin1_german2_ci latin1 31 Yes 2
latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
where COLLATION_NAME like 'latin1%'; where COLLATION_NAME like 'latin1%';
COLLATION_NAME CHARACTER_SET_NAME COLLATION_NAME CHARACTER_SET_NAME
...@@ -668,14 +613,11 @@ BASE TABLE ...@@ -668,14 +613,11 @@ BASE TABLE
show open tables where `table` like "user"; show open tables where `table` like "user";
Database Table In_use Name_locked Database Table In_use Name_locked
mysql user 0 0 mysql user 0 0
show status variable_name where variable_name like "%database%"; show status where variable_name like "%database%";
variable_name Variable_name Value
Com_show_databases Com_show_databases 0
show variables variable_name where variable_name like "%database%"; show variables where variable_name like "skip_show_databas";
variable_name Variable_name Value
character_set_database
collation_database
skip_show_database
show global status like "Threads_running"; show global status like "Threads_running";
Variable_name Value Variable_name Value
Threads_running 1 Threads_running 1
...@@ -2,16 +2,14 @@ ...@@ -2,16 +2,14 @@
# Test for information_schema.schemata & # Test for information_schema.schemata &
# show databases # show databases
show variables variable_name where variable_name like "skip_show_database"; show variables where variable_name like "skip_show_database";
grant all privileges on test.* to mysqltest_1@localhost; grant all privileges on test.* to mysqltest_1@localhost;
select * from information_schema.SCHEMATA where schema_name > 'm'; select * from information_schema.SCHEMATA where schema_name > 'm';
select schema_name from information_schema.schemata; select schema_name from information_schema.schemata;
show databases *;
show databases like 't%'; show databases like 't%';
show databases; show databases;
show databases * where schema_name like 't%'; show databases where `database` = 't%';
show databases * where schema_name = 't%';
# Test for information_schema.tables & # Test for information_schema.tables &
# show tables # show tables
...@@ -35,12 +33,9 @@ select table_name from information_schema.TABLES ...@@ -35,12 +33,9 @@ select table_name from information_schema.TABLES
where table_schema = "testtets" and table_name like "t%"; where table_schema = "testtets" and table_name like "t%";
select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets"; select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets";
show keys * from t3 where TABLE_SCHEMA Like "test%"; show keys from t3 where Key_name = "a_data";
show keys from t3 where INDEX_NAME = "a_data";
show tables like 't%'; show tables like 't%';
--replace_column 15 # 16 #
show tables * from test where table_name like 't%';
--replace_column 12 # 13 # --replace_column 12 # 13 #
--replace_result "2147483647 " "21474836479 " --replace_result "2147483647 " "21474836479 "
show table status; show table status;
...@@ -49,7 +44,7 @@ show full columns from mysql.db like "Insert%"; ...@@ -49,7 +44,7 @@ show full columns from mysql.db like "Insert%";
show full columns from v1; show full columns from v1;
select * from information_schema.COLUMNS where table_name="t1" select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a"; and column_name= "a";
show columns * from testtets.t1 where table_name = "t1"; show columns from testtets.t1 where field like "%a%";
drop view v1; drop view v1;
drop tables testtets.t4, testtets.t1, t2, t3; drop tables testtets.t4, testtets.t1, t2, t3;
...@@ -61,10 +56,7 @@ drop database testtets; ...@@ -61,10 +56,7 @@ drop database testtets;
select * from information_schema.CHARACTER_SETS select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like 'latin1%'; where CHARACTER_SET_NAME like 'latin1%';
SHOW CHARACTER SET LIKE 'latin1%'; SHOW CHARACTER SET LIKE 'latin1%';
SHOW CHARACTER SET * LIKE 'latin1%'; SHOW CHARACTER SET WHERE charset like 'latin1%';
SHOW CHARACTER SET WHERE CHARACTER_SET_NAME like 'latin1%';
SHOW CHARACTER SET CHARACTER_SET_NAME WHERE CHARACTER_SET_NAME like 'latin1%';
SHOW CHARACTER SET * WHERE CHARACTER_SET_NAME like 'latin1%';
# Test for information_schema.COLLATIONS & # Test for information_schema.COLLATIONS &
# SHOW COLLATION # SHOW COLLATION
...@@ -72,10 +64,7 @@ SHOW CHARACTER SET * WHERE CHARACTER_SET_NAME like 'latin1%'; ...@@ -72,10 +64,7 @@ SHOW CHARACTER SET * WHERE CHARACTER_SET_NAME like 'latin1%';
select * from information_schema.COLLATIONS select * from information_schema.COLLATIONS
where COLLATION_NAME like 'latin1%'; where COLLATION_NAME like 'latin1%';
SHOW COLLATION LIKE 'latin1%'; SHOW COLLATION LIKE 'latin1%';
SHOW COLLATION * LIKE 'latin1%'; SHOW COLLATION WHERE collation like 'latin1%';
SHOW COLLATION WHERE COLLATION_NAME like 'latin1%';
SHOW COLLATION COLLATION_NAME WHERE COLLATION_NAME like 'latin1%';
SHOW COLLATION * WHERE COLLATION_NAME like 'latin1%';
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
where COLLATION_NAME like 'latin1%'; where COLLATION_NAME like 'latin1%';
...@@ -351,9 +340,9 @@ where table_schema="mysql" and table_name="user"; ...@@ -351,9 +340,9 @@ where table_schema="mysql" and table_name="user";
# test for 'show open tables ... where' # test for 'show open tables ... where'
show open tables where `table` like "user"; show open tables where `table` like "user";
# test for 'show status ... where' # test for 'show status ... where'
show status variable_name where variable_name like "%database%"; show status where variable_name like "%database%";
# test for 'show variables ... where' # test for 'show variables ... where'
show variables variable_name where variable_name like "%database%"; show variables where variable_name like "skip_show_databas";
# #
# Bug #7981:SHOW GLOBAL STATUS crashes server # Bug #7981:SHOW GLOBAL STATUS crashes server
......
...@@ -2114,16 +2114,24 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list, ...@@ -2114,16 +2114,24 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
DBUG_PRINT("enter", ("table: '%s' name: '%s' item name: '%s' ref 0x%lx", DBUG_PRINT("enter", ("table: '%s' name: '%s' item name: '%s' ref 0x%lx",
table_list->alias, name, item_name, (ulong) ref)); table_list->alias, name, item_name, (ulong) ref));
if (table_list->field_translation) if (table_list->field_translation)
{
uint num;
if (table_list->schema_table_reformed)
{
num= thd->lex->current_select->item_list.elements;
}
else
{ {
DBUG_ASSERT(ref != 0 && table_list->view != 0); DBUG_ASSERT(ref != 0 && table_list->view != 0);
uint num= table_list->view->select_lex.item_list.elements; num= table_list->view->select_lex.item_list.elements;
}
Field_translator *trans= table_list->field_translation; Field_translator *trans= table_list->field_translation;
for (uint i= 0; i < num; i ++) for (uint i= 0; i < num; i ++)
{ {
if (!my_strcasecmp(system_charset_info, trans[i].name, name)) if (!my_strcasecmp(system_charset_info, trans[i].name, name))
{ {
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
if (check_grants_view && if (check_grants_view && !table_list->schema_table_reformed &&
check_grant_column(thd, &table_list->grant, check_grant_column(thd, &table_list->grant,
table_list->view_db.str, table_list->view_db.str,
table_list->view_name.str, table_list->view_name.str,
......
...@@ -2014,6 +2014,7 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, ...@@ -2014,6 +2014,7 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
} }
TABLE_LIST *table_list= (TABLE_LIST*) select_lex->table_list.first; TABLE_LIST *table_list= (TABLE_LIST*) select_lex->table_list.first;
table_list->schema_select_lex= sel; table_list->schema_select_lex= sel;
table_list->schema_table_reformed= 1;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -3191,6 +3191,59 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) ...@@ -3191,6 +3191,59 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
thd->derived_tables= table; thd->derived_tables= table;
table_list->select_lex->options |= OPTION_SCHEMA_TABLE; table_list->select_lex->options |= OPTION_SCHEMA_TABLE;
lex->safe_to_cache_query= 0; lex->safe_to_cache_query= 0;
if (table_list->schema_table_reformed) // show command
{
SELECT_LEX *sel= lex->current_select;
uint i= 0;
Item *item;
Field_translator *transl;
if (table_list->field_translation)
{
Field_translator *end= table_list->field_translation +
sel->item_list.elements;
for (transl= table_list->field_translation; transl < end; transl++)
{
if (!transl->item->fixed &&
transl->item->fix_fields(thd, table_list, &transl->item))
{
DBUG_RETURN(1);
}
}
if (sel->where && !sel->where->fixed &&
sel->where->fix_fields(thd, table_list, &sel->where))
{
DBUG_RETURN(1);
}
for (transl= table_list->field_translation; transl < end; transl++)
{
transl->item->rename((char *)transl->name);
}
DBUG_RETURN(0);
}
List_iterator_fast<Item> it(sel->item_list);
if (!(transl=
(Field_translator*)(thd->current_arena->
alloc(sel->item_list.elements *
sizeof(Field_translator)))))
{
DBUG_RETURN(1);
}
while ((item= it++))
{
char *name= item->name;
transl[i].item= item;
if (!item->fixed && item->fix_fields(thd, table_list, &transl[i].item))
{
DBUG_RETURN(1);
}
transl[i++].name= name;
}
table_list->field_translation= transl;
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -3223,8 +3276,7 @@ int make_schema_select(THD *thd, SELECT_LEX *sel, ...@@ -3223,8 +3276,7 @@ int make_schema_select(THD *thd, SELECT_LEX *sel,
information_schema_name.length, 0); information_schema_name.length, 0);
make_lex_string(thd, &table, schema_table->table_name, make_lex_string(thd, &table, schema_table->table_name,
strlen(schema_table->table_name), 0); strlen(schema_table->table_name), 0);
if (!sel->item_list.elements && /* Handle old syntax */ if (schema_table->old_format(thd, schema_table) || /* Handle old syntax */
schema_table->old_format(thd, schema_table) ||
!sel->add_table_to_list(thd, new Table_ident(thd, db, table, 0), !sel->add_table_to_list(thd, new Table_ident(thd, db, table, 0),
0, 0, TL_READ, (List<String> *) 0, 0, 0, TL_READ, (List<String> *) 0,
(List<String> *) 0)) (List<String> *) 0))
......
...@@ -5876,6 +5876,9 @@ show: SHOW ...@@ -5876,6 +5876,9 @@ show: SHOW
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->wild=0; lex->wild=0;
lex->lock_option= TL_READ;
mysql_init_select(lex);
lex->current_select->parsing_place= SELECT_LIST;
bzero((char*) &lex->create_info,sizeof(lex->create_info)); bzero((char*) &lex->create_info,sizeof(lex->create_info));
} }
show_param show_param
...@@ -5883,7 +5886,7 @@ show: SHOW ...@@ -5883,7 +5886,7 @@ show: SHOW
; ;
show_param: show_param:
DATABASES ext_select_item_list wild_and_where DATABASES wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
...@@ -5891,44 +5894,44 @@ show_param: ...@@ -5891,44 +5894,44 @@ show_param:
if (prepare_schema_table(YYTHD, lex, 0, SCH_SCHEMATA)) if (prepare_schema_table(YYTHD, lex, 0, SCH_SCHEMATA))
YYABORT; YYABORT;
} }
| opt_full TABLES ext_select_item_list opt_db wild_and_where | opt_full TABLES opt_db wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_TABLES; lex->orig_sql_command= SQLCOM_SHOW_TABLES;
lex->select_lex.db= $4; lex->select_lex.db= $3;
if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_NAMES)) if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_NAMES))
YYABORT; YYABORT;
} }
| TABLE_SYM STATUS_SYM ext_select_item_list opt_db wild_and_where | TABLE_SYM STATUS_SYM opt_db wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATUS; lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATUS;
lex->select_lex.db= $4; lex->select_lex.db= $3;
if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLES)) if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLES))
YYABORT; YYABORT;
} }
| OPEN_SYM TABLES ext_select_item_list opt_db wild_and_where | OPEN_SYM TABLES opt_db wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_OPEN_TABLES; lex->orig_sql_command= SQLCOM_SHOW_OPEN_TABLES;
lex->select_lex.db= $4; lex->select_lex.db= $3;
if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES)) if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
YYABORT; YYABORT;
} }
| ENGINE_SYM storage_engines | ENGINE_SYM storage_engines
{ Lex->create_info.db_type= $2; } { Lex->create_info.db_type= $2; }
show_engine_param show_engine_param
| opt_full COLUMNS ext_select_item_list from_or_in table_ident opt_db wild_and_where | opt_full COLUMNS from_or_in table_ident opt_db wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_FIELDS; lex->orig_sql_command= SQLCOM_SHOW_FIELDS;
if ($6) if ($5)
$5->change_db($6); $4->change_db($5);
if (prepare_schema_table(YYTHD, lex, $5, SCH_COLUMNS)) if (prepare_schema_table(YYTHD, lex, $4, SCH_COLUMNS))
YYABORT; YYABORT;
} }
| NEW_SYM MASTER_SYM FOR_SYM SLAVE WITH MASTER_LOG_FILE_SYM EQ | NEW_SYM MASTER_SYM FOR_SYM SLAVE WITH MASTER_LOG_FILE_SYM EQ
...@@ -5954,14 +5957,14 @@ show_param: ...@@ -5954,14 +5957,14 @@ show_param:
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_BINLOG_EVENTS; lex->sql_command= SQLCOM_SHOW_BINLOG_EVENTS;
} opt_limit_clause_init } opt_limit_clause_init
| keys_or_index ext_select_item_list from_or_in table_ident opt_db where_clause | keys_or_index from_or_in table_ident opt_db where_clause
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_KEYS; lex->orig_sql_command= SQLCOM_SHOW_KEYS;
if ($5) if ($4)
$4->change_db($5); $3->change_db($4);
if (prepare_schema_table(YYTHD, lex, $4, SCH_STATISTICS)) if (prepare_schema_table(YYTHD, lex, $3, SCH_STATISTICS))
YYABORT; YYABORT;
} }
| COLUMN_SYM TYPES_SYM | COLUMN_SYM TYPES_SYM
...@@ -5993,7 +5996,7 @@ show_param: ...@@ -5993,7 +5996,7 @@ show_param:
{ Lex->sql_command = SQLCOM_SHOW_WARNS;} { Lex->sql_command = SQLCOM_SHOW_WARNS;}
| ERRORS opt_limit_clause_init | ERRORS opt_limit_clause_init
{ Lex->sql_command = SQLCOM_SHOW_ERRORS;} { Lex->sql_command = SQLCOM_SHOW_ERRORS;}
| opt_var_type STATUS_SYM ext_select_item_list wild_and_where | opt_var_type STATUS_SYM wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
...@@ -6008,7 +6011,7 @@ show_param: ...@@ -6008,7 +6011,7 @@ show_param:
{ Lex->sql_command = SQLCOM_SHOW_MUTEX_STATUS; } { Lex->sql_command = SQLCOM_SHOW_MUTEX_STATUS; }
| opt_full PROCESSLIST_SYM | opt_full PROCESSLIST_SYM
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;} { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
| opt_var_type VARIABLES ext_select_item_list wild_and_where | opt_var_type VARIABLES wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
...@@ -6017,7 +6020,7 @@ show_param: ...@@ -6017,7 +6020,7 @@ show_param:
if (prepare_schema_table(YYTHD, lex, 0, SCH_VARIABLES)) if (prepare_schema_table(YYTHD, lex, 0, SCH_VARIABLES))
YYABORT; YYABORT;
} }
| charset ext_select_item_list wild_and_where | charset wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
...@@ -6025,7 +6028,7 @@ show_param: ...@@ -6025,7 +6028,7 @@ show_param:
if (prepare_schema_table(YYTHD, lex, 0, SCH_CHARSETS)) if (prepare_schema_table(YYTHD, lex, 0, SCH_CHARSETS))
YYABORT; YYABORT;
} }
| COLLATION_SYM ext_select_item_list wild_and_where | COLLATION_SYM wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
...@@ -6111,7 +6114,7 @@ show_param: ...@@ -6111,7 +6114,7 @@ show_param:
lex->sql_command = SQLCOM_SHOW_CREATE_FUNC; lex->sql_command = SQLCOM_SHOW_CREATE_FUNC;
lex->spname= $3; lex->spname= $3;
} }
| PROCEDURE STATUS_SYM ext_select_item_list wild_and_where | PROCEDURE STATUS_SYM wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
...@@ -6119,7 +6122,7 @@ show_param: ...@@ -6119,7 +6122,7 @@ show_param:
if (prepare_schema_table(YYTHD, lex, 0, SCH_PROCEDURES)) if (prepare_schema_table(YYTHD, lex, 0, SCH_PROCEDURES))
YYABORT; YYABORT;
} }
| FUNCTION_SYM STATUS_SYM ext_select_item_list wild_and_where | FUNCTION_SYM STATUS_SYM wild_and_where
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT; lex->sql_command= SQLCOM_SELECT;
...@@ -6193,20 +6196,6 @@ wild_and_where: ...@@ -6193,20 +6196,6 @@ wild_and_where:
} }
; ;
ext_select_item_list:
{
LEX *lex=Lex;
SELECT_LEX *sel= lex->current_select;
lex->lock_option= TL_READ;
mysql_init_select(lex);
lex->current_select->parsing_place= SELECT_LIST;
}
ext_select_item_list2;
ext_select_item_list2:
/* empty */ {}
| select_item_list {};
/* A Oracle compatible synonym for show */ /* A Oracle compatible synonym for show */
describe: describe:
......
...@@ -356,6 +356,7 @@ typedef struct st_table_list ...@@ -356,6 +356,7 @@ typedef struct st_table_list
st_select_lex_unit *derived; /* SELECT_LEX_UNIT of derived table */ st_select_lex_unit *derived; /* SELECT_LEX_UNIT of derived table */
ST_SCHEMA_TABLE *schema_table; /* Information_schema table */ ST_SCHEMA_TABLE *schema_table; /* Information_schema table */
st_select_lex *schema_select_lex; st_select_lex *schema_select_lex;
bool schema_table_reformed;
/* link to select_lex where this table was used */ /* link to select_lex where this table was used */
st_select_lex *select_lex; st_select_lex *select_lex;
st_lex *view; /* link on VIEW lex for merging */ st_lex *view; /* link on VIEW lex for merging */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment