Skip to content
Permalink
Browse files

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
  • Loading branch information...
vuvova committed Jun 30, 2017
1 parent 186075a commit 0559f12972dba6a141de553aacd724b2bcfaf71d
Showing with 30 additions and 5 deletions.
  1. +17 −0 mysql-test/suite/vcol/r/cross_db.result
  2. +9 −0 mysql-test/suite/vcol/t/cross_db.test
  3. +4 −5 sql/item.cc
@@ -0,0 +1,17 @@
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;
@@ -0,0 +1,9 @@
#
# 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)
use_db_name= !(cached_table && cached_table->belong_to_view &&
cached_table->belong_to_view->compact_view_format);

if (!use_db_name && use_table_name &&
(query_type & QT_ITEM_IDENT_SKIP_TABLE_NAMES))
if (use_table_name && (query_type & QT_ITEM_IDENT_SKIP_TABLE_NAMES))
{
/*
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
*/
if (!context)
use_table_name= false;
use_db_name= use_table_name= false;
else if (context->outer_context)
use_table_name= true;
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 &&
!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])

0 comments on commit 0559f12

Please sign in to comment.
You can’t perform that action at this time.