Merge branch '2.0' into develop-2.0-merge
This commit is contained in:
@ -97,7 +97,7 @@ static parsing_info_t* parsing_info_init(void (*donefun)(void *));
|
||||
static void parsing_info_set_plain_str(void* ptr, char* str);
|
||||
/** Free THD context and close MYSQL */
|
||||
static void parsing_info_done(void* ptr);
|
||||
static void* skygw_get_affected_tables(void* lexptr);
|
||||
static TABLE_LIST* skygw_get_affected_tables(void* lexptr);
|
||||
static bool ensure_query_is_parsed(GWBUF* query);
|
||||
static bool parse_query(GWBUF* querybuf);
|
||||
static bool query_is_parsed(GWBUF* buf);
|
||||
@ -1090,7 +1090,7 @@ LEX* get_lex(GWBUF* querybuf)
|
||||
* @param thd Pointer to a valid THD
|
||||
* @return Pointer to the head of the TABLE_LIST chain or NULL in case of an error
|
||||
*/
|
||||
static void* skygw_get_affected_tables(void* lexptr)
|
||||
static TABLE_LIST* skygw_get_affected_tables(void* lexptr)
|
||||
{
|
||||
LEX* lex = (LEX*) lexptr;
|
||||
|
||||
@ -1100,7 +1100,23 @@ static void* skygw_get_affected_tables(void* lexptr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void*) lex->current_select->table_list.first;
|
||||
TABLE_LIST *tbl = lex->current_select->table_list.first;
|
||||
|
||||
if (tbl && tbl->schema_select_lex && tbl->schema_select_lex->table_list.elements &&
|
||||
lex->sql_command != SQLCOM_SHOW_KEYS)
|
||||
{
|
||||
/**
|
||||
* Some statements e.g. EXPLAIN or SHOW COLUMNS give `information_schema`
|
||||
* as the underlying table and the table in the query is stored in
|
||||
* @c schema_select_lex.
|
||||
*
|
||||
* SHOW [KEYS | INDEX] does the reverse so we need to skip the
|
||||
* @c schema_select_lex when processing a SHOW [KEYS | INDEX] statement.
|
||||
*/
|
||||
tbl = tbl->schema_select_lex->table_list.first;
|
||||
}
|
||||
|
||||
return tbl;
|
||||
}
|
||||
|
||||
char** qc_get_table_names(GWBUF* querybuf, int* tblsize, bool fullnames)
|
||||
@ -1129,7 +1145,7 @@ char** qc_get_table_names(GWBUF* querybuf, int* tblsize, bool fullnames)
|
||||
|
||||
while (lex->current_select)
|
||||
{
|
||||
tbl = (TABLE_LIST*) skygw_get_affected_tables(lex);
|
||||
tbl = skygw_get_affected_tables(lex);
|
||||
|
||||
while (tbl)
|
||||
{
|
||||
|
||||
@ -2417,7 +2417,7 @@ extern void maxscaleShow(Parse* pParse, MxsShow* pShow)
|
||||
case MXS_SHOW_COLUMNS:
|
||||
{
|
||||
info->types = QUERY_TYPE_READ;
|
||||
update_names(info, "information_schema", "COLUMNS");
|
||||
update_names(info, zDatabase, zName);
|
||||
if (pShow->data == MXS_SHOW_COLUMNS_FULL)
|
||||
{
|
||||
update_field_info(info, "information_schema", "COLUMNS", "COLLATION_NAME", u, NULL);
|
||||
|
||||
@ -3022,13 +3022,17 @@ like_or_where_opt ::= WHERE expr.
|
||||
|
||||
%type show {MxsShow}
|
||||
|
||||
show(A) ::= SHOW full_opt(X) COLUMNS from_or_in nm(Y) dbnm(Z) from_or_in_db_opt like_or_where_opt . {
|
||||
show(A) ::= SHOW full_opt(X) COLUMNS from_or_in nm(Y) dbnm(Z) from_or_in_db_opt(W) like_or_where_opt . {
|
||||
A.what = MXS_SHOW_COLUMNS;
|
||||
A.data = X;
|
||||
if (Z.z) {
|
||||
A.pName = &Z;
|
||||
A.pDatabase = &Y;
|
||||
}
|
||||
else if (W.z) {
|
||||
A.pName = &Y;
|
||||
A.pDatabase = &W;
|
||||
}
|
||||
else {
|
||||
A.pName = &Y;
|
||||
A.pDatabase = NULL;
|
||||
|
||||
Reference in New Issue
Block a user