Commit 0559f129 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-13209 Cross-database operation with virtual columns fails

if we don't need to print field's table name,
we surely don't need to print field's db name either
parent 186075ad
create database mysqltest1;
create table mysqltest1.t1 (i int, j int as (i) persistent);
show create table mysqltest1.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL,
`j` int(11) GENERATED ALWAYS AS (`i`) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table mysqltest1.t1 add index (i);
show create table mysqltest1.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL,
`j` int(11) GENERATED ALWAYS AS (`i`) STORED,
KEY `i` (`i`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop database mysqltest1;
#
# MDEV-13209 Cross-database operation with virtual columns fails
#
create database mysqltest1;
create table mysqltest1.t1 (i int, j int as (i) persistent);
show create table mysqltest1.t1;
alter table mysqltest1.t1 add index (i);
show create table mysqltest1.t1;
drop database mysqltest1;
...@@ -2669,22 +2669,21 @@ void Item_ident::print(String *str, enum_query_type query_type) ...@@ -2669,22 +2669,21 @@ void Item_ident::print(String *str, enum_query_type query_type)
use_db_name= !(cached_table && cached_table->belong_to_view && use_db_name= !(cached_table && cached_table->belong_to_view &&
cached_table->belong_to_view->compact_view_format); cached_table->belong_to_view->compact_view_format);
if (!use_db_name && use_table_name && if (use_table_name && (query_type & QT_ITEM_IDENT_SKIP_TABLE_NAMES))
(query_type & QT_ITEM_IDENT_SKIP_TABLE_NAMES))
{ {
/* /*
Don't print the table name if it's the only table in the context Don't print the table name if it's the only table in the context
XXX technically, that's a sufficient, but too strong condition XXX technically, that's a sufficient, but too strong condition
*/ */
if (!context) if (!context)
use_table_name= false; use_db_name= use_table_name= false;
else if (context->outer_context) else if (context->outer_context)
use_table_name= true; use_table_name= true;
else if (context->last_name_resolution_table == context->first_name_resolution_table) else if (context->last_name_resolution_table == context->first_name_resolution_table)
use_table_name= false; use_db_name= use_table_name= false;
else if (!context->last_name_resolution_table && else if (!context->last_name_resolution_table &&
!context->first_name_resolution_table->next_name_resolution_table) !context->first_name_resolution_table->next_name_resolution_table)
use_table_name= false; use_db_name= use_table_name= false;
} }
if (!field_name || !field_name[0]) if (!field_name || !field_name[0])
......
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