diff options
author | Sergei Golubchik <serg@mariadb.org> | 2022-04-16 11:53:44 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2022-04-19 17:10:05 +0200 |
commit | 9c5fd0f624df846686742182825d964c546fac58 (patch) | |
tree | 57070f9bf34643e66f3f90136fd8ffab1a315cb3 | |
parent | a59f483c06b12e606747da3f864ed94615f038c0 (diff) | |
download | mariadb-git-9c5fd0f624df846686742182825d964c546fac58.tar.gz |
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.
-rw-r--r-- | mysql-test/suite/vcol/r/vcol_misc.result | 22 | ||||
-rw-r--r-- | mysql-test/suite/vcol/t/vcol_misc.opt | 1 | ||||
-rw-r--r-- | mysql-test/suite/vcol/t/vcol_misc.test | 15 | ||||
-rw-r--r-- | sql/item.h | 8 | ||||
-rw-r--r-- | sql/sql_lex.cc | 1 |
5 files changed, 45 insertions, 2 deletions
diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result index f13a20bf4c9..f4790a7cbec 100644 --- a/mysql-test/suite/vcol/r/vcol_misc.result +++ b/mysql-test/suite/vcol/r/vcol_misc.result @@ -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 # diff --git a/mysql-test/suite/vcol/t/vcol_misc.opt b/mysql-test/suite/vcol/t/vcol_misc.opt new file mode 100644 index 00000000000..fd1faea4f8e --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_misc.opt @@ -0,0 +1 @@ +--character-sets-dir=$MYSQL_TEST_DIR/std_data/ldml/ diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test index 821dd418e64..b37b9e8f3d5 100644 --- a/mysql-test/suite/vcol/t/vcol_misc.test +++ b/mysql-test/suite/vcol/t/vcol_misc.test @@ -497,5 +497,20 @@ 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 # + diff --git a/sql/item.h b/sql/item.h index 6b4ca89f3c7..07c17901afd 100644 --- a/sql/item.h +++ b/sql/item.h @@ -5807,10 +5807,18 @@ public: } 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. diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 47ff2836aba..22ee8801e3a 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -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; |