Commit 3db98095 authored by unknown's avatar unknown

support of view to COM_FIELD_LIST added (BUG#5145)

sql/sql_parse.cc:
  support of view to COM_FIELD_LIST added
sql/sql_show.cc:
  support of view to COM_FIELD_LIST added
parent fcbd2485
...@@ -1327,6 +1327,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1327,6 +1327,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
this so that they will not get logged to the slow query log this so that they will not get logged to the slow query log
*/ */
thd->slow_command=FALSE; thd->slow_command=FALSE;
thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
thd->set_time(); thd->set_time();
VOID(pthread_mutex_lock(&LOCK_thread_count)); VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id=query_id; thd->query_id=query_id;
...@@ -1570,7 +1571,17 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1570,7 +1571,17 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (grant_option && if (grant_option &&
check_grant(thd, SELECT_ACL, &table_list, 2, UINT_MAX, 0)) check_grant(thd, SELECT_ACL, &table_list, 2, UINT_MAX, 0))
break; break;
/* switch on VIEW optimisation: do not fill temporary tables */
thd->lex->sql_command= SQLCOM_SHOW_FIELDS;
/* init structures for VIEW processing */
table_list.select_lex= &(thd->lex->select_lex);
mysql_init_query(thd, (uchar*)"", 0);
thd->lex->
select_lex.table_list.link_in_list((byte*) &table_list,
(byte**) &table_list.next_local);
mysqld_list_fields(thd,&table_list,fields); mysqld_list_fields(thd,&table_list,fields);
thd->lex->unit.cleanup();
free_items(thd->free_list); free_items(thd->free_list);
thd->free_list=0; /* free_list should never point to garbage */ thd->free_list=0; /* free_list should never point to garbage */
break; break;
......
...@@ -1124,14 +1124,19 @@ void ...@@ -1124,14 +1124,19 @@ void
mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild) mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
{ {
TABLE *table; TABLE *table;
int res;
DBUG_ENTER("mysqld_list_fields"); DBUG_ENTER("mysqld_list_fields");
DBUG_PRINT("enter",("table: %s",table_list->real_name)); DBUG_PRINT("enter",("table: %s",table_list->real_name));
if (!(table = open_ltable(thd, table_list, TL_UNLOCK))) table_list->lock_type= TL_UNLOCK;
if ((res= open_and_lock_tables(thd, table_list)))
{ {
send_error(thd); if (res < 0)
send_error(thd);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
table= table_list->table;
List<Item> field_list; List<Item> field_list;
Field **ptr,*field; Field **ptr,*field;
......
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