Commit 9c5fd0f6 authored by Sergei Golubchik's avatar Sergei Golubchik

vcols: cannot use CONTEXT_ANALYSIS_ONLY_VCOL_EXPR on fix_fields

because CONTEXT_ANALYSIS_ONLY_VCOL_EXPR can be used only for,
exactly, context analysys. Items fixed that way cannot be evaluated.
But vcols are going to be evaluated, so they have to be fixed properly,
for evaluation.
parent a59f483c
......@@ -227,7 +227,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(20) DEFAULT NULL,
`b` bigint(20) GENERATED ALWAYS AS (`a` > '2') VIRTUAL
`b` bigint(20) GENERATED ALWAYS AS (`a` > 2) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 (a) values (1),(3);
select * from t1;
......@@ -522,5 +522,25 @@ Warning 1292 Incorrect datetime value: 'x'
Warning 1292 Incorrect datetime value: 'root@localhost'
drop table t1;
#
# CONTEXT_ANALYSIS_ONLY_VCOL_EXPR
#
create table t1 (c1 char(1) character set ucs2 collate ucs2_test_ci,
v1 char(1) character set ucs2 collate ucs2_test_ci as (c1),
v2 int as (c1 = 'b'),
v3 int as (v1 = 'b'));
insert into t1 (c1) values ('a');
select * from t1 where v1 = 'b';
c1 v1 v2 v3
a a 1 1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` char(1) CHARACTER SET ucs2 COLLATE ucs2_test_ci DEFAULT NULL,
`v1` char(1) CHARACTER SET ucs2 GENERATED ALWAYS AS (`c1`) VIRTUAL,
`v2` int(11) GENERATED ALWAYS AS (`c1` = 'b') VIRTUAL,
`v3` int(11) GENERATED ALWAYS AS (`v1` = 'b') VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
#
# End of 10.2 tests
#
--character-sets-dir=$MYSQL_TEST_DIR/std_data/ldml/
......@@ -496,6 +496,21 @@ insert into t1(b) values ('2022-03-17 14:55:37');
select 1 from t1 x natural join t1;
drop table t1;
--echo #
--echo # CONTEXT_ANALYSIS_ONLY_VCOL_EXPR
--echo #
--source include/have_ucs2.inc
create table t1 (c1 char(1) character set ucs2 collate ucs2_test_ci,
v1 char(1) character set ucs2 collate ucs2_test_ci as (c1),
v2 int as (c1 = 'b'),
v3 int as (v1 = 'b'));
insert into t1 (c1) values ('a');
select * from t1 where v1 = 'b';
show create table t1;
drop table t1;
--echo #
--echo # End of 10.2 tests
--echo #
......@@ -5807,10 +5807,18 @@ class Item_cache: public Item_basic_constant,
}
return mark_unsupported_function("cache", arg, VCOL_IMPOSSIBLE);
}
bool fix_fields(THD *thd, Item **ref)
{
fixed= 1;
if (example && !example->fixed)
return example->fix_fields(thd, ref);
return 0;
}
void cleanup()
{
clear();
Item_basic_constant::cleanup();
fixed= 0;
}
/**
Check if saved item has a non-NULL value.
......
......@@ -193,7 +193,6 @@ init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex)
return TRUE;
context->resolve_in_table_list_only(table_list);
lex->use_only_table_context= TRUE;
lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VCOL_EXPR;
select_lex->cur_pos_in_select_list= UNDEF_POS;
table->map= 1; //To ensure correct calculation of const item
table_list->table= table;
......
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