revision-id: 40d84f31c81496f59e48cb3fa318cb0eec580bfb (mariadb-10.2.16-102-g40d84f31c81) parent(s): c634fd0cbf36605b1ec49d1ec7f613d2834e6333 author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2018-08-27 13:01:02 +0200 message: c --- mysql-test/r/func_default.result | 2 +- mysql-test/r/func_time.result | 33 +++++++++++++++++++++++++++++++-- mysql-test/t/func_time.test | 15 +++++++++++++-- sql/field.cc | 8 ++------ sql/item.cc | 6 ++---- 5 files changed, 49 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/func_default.result b/mysql-test/r/func_default.result index 1f331af287c..3927c387680 100644 --- a/mysql-test/r/func_default.result +++ b/mysql-test/r/func_default.result @@ -8,7 +8,7 @@ explain extended select default(str), default(strnull), default(intg), default(r id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings: -Note 1003 select default(`str`) AS `default(str)`,default(`strnull`) AS `default(strnull)`,default(`intg`) AS `default(intg)`,default(`rel`) AS `default(rel)` from dual +Note 1003 select default(`test`.`t1`.`str`) AS `default(str)`,default(`test`.`t1`.`strnull`) AS `default(strnull)`,default(`test`.`t1`.`intg`) AS `default(intg)`,default(`test`.`t1`.`rel`) AS `default(rel)` from dual select * from t1 where str <> default(str); str strnull intg rel 0 0 diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 5b9286323a7..1407a04e0ce 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -3288,8 +3288,37 @@ NULL NULL Warnings: Warning 1292 Incorrect datetime value: '18446744073709551615' -DROP VIEW v1; -DROP TABLE t1; +CREATE TABLE t2 (pk int default 1, a1 date); +INSERT INTO t2 VALUES (4,NULL); +CREATE view v2 as SELECT default(t1.pk), default(t2.pk), t1.pk from t1,t2; +select * from v2; +default(t1.pk) default(t2.pk) pk +0 1 1 +0 1 2 +0 1 3 +0 1 4 +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select default(`t1`.`pk`) AS `default(t1.pk)`,default(`t2`.`pk`) AS `default(t2.pk)`,`t1`.`pk` AS `pk` from (`t1` join `t2`) latin1 latin1_swedish_ci +CREATE view v3 as SELECT default(pk) from t2; +select * from v3; +default(pk) +1 +explain extended select * from v3; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select default(`test`.`t2`.`pk`) AS `default(pk)` from dual +explain extended select default(pk) from t2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select default(`test`.`t2`.`pk`) AS `default(pk)` from dual +show create view v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select default(`t2`.`pk`) AS `default(pk)` from `t2` latin1 latin1_swedish_ci +DROP VIEW v1,v2,v3; +DROP TABLE t1,t2; # # End of 10.2 tests # diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 0253a2d548e..0805063c395 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1876,8 +1876,19 @@ SELECT t1.pk AS pk, t1.a1 AS a1 FROM t1; SELECT a1 BETWEEN (('2018-08-24')) AND (DEFAULT(pk)) FROM v1; SELECT a1 BETWEEN (('2018-08-24')) AND (~ DEFAULT(pk)) FROM v1; -DROP VIEW v1; -DROP TABLE t1; +CREATE TABLE t2 (pk int default 1, a1 date); +INSERT INTO t2 VALUES (4,NULL); +CREATE view v2 as SELECT default(t1.pk), default(t2.pk), t1.pk from t1,t2; +select * from v2; +show create view v2; +CREATE view v3 as SELECT default(pk) from t2; +select * from v3; +explain extended select * from v3; +explain extended select default(pk) from t2; +show create view v3; + +DROP VIEW v1,v2,v3; +DROP TABLE t1,t2; --echo # --echo # End of 10.2 tests diff --git a/sql/field.cc b/sql/field.cc index e12adbf47b3..80553cca015 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -76,18 +76,14 @@ const char field_separator=','; (!table->read_set || \ bitmap_is_set(table->read_set, field_index) || \ (!(ptr >= table->record[0] && \ - ptr < table->record[0] + table->s->reclength) && \ - !(ptr >= table->record[1] && \ - ptr < table->record[1] + table->s->reclength)))) + ptr < table->record[0] + table->s->reclength)))) #define ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED \ DBUG_ASSERT(is_stat_field || !table || \ (!table->write_set || \ bitmap_is_set(table->write_set, field_index) || \ (!(ptr >= table->record[0] && \ - ptr < table->record[0] + table->s->reclength) && \ - !(ptr >= table->record[1] && \ - ptr < table->record[1] + table->s->reclength))) || \ + ptr < table->record[0] + table->s->reclength))) || \ (table->vcol_set && bitmap_is_set(table->vcol_set, field_index))) #define FLAGSTR(S,F) ((S) & (F) ? #F " " : "") diff --git a/sql/item.cc b/sql/item.cc index 70fea097d36..ab26f619768 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -8961,7 +8961,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items) */ fix_session_vcol_expr_for_read(thd, def_field, def_field->default_value); if (thd->mark_used_columns != MARK_COLUMNS_NONE) - def_field->default_value->expr->walk(&Item::register_field_in_read_map, 1, 0); + def_field->default_value->expr->update_used_tables(); def_field->move_field(newptr+1, def_field->maybe_null() ? newptr : 0, 1); } else @@ -8990,9 +8990,7 @@ void Item_default_value::print(String *str, enum_query_type query_type) tables but its name so we set QT_NO_DATA_EXPANSION (as we print for table definition, also we do not need table and database name) */ - query_type= (enum_query_type) (query_type | QT_NO_DATA_EXPANSION | - QT_ITEM_IDENT_SKIP_DB_NAMES | - QT_ITEM_IDENT_SKIP_TABLE_NAMES); + query_type= (enum_query_type) (query_type | QT_NO_DATA_EXPANSION); arg->print(str, query_type); str->append(')'); }