Open midenok opened 5 years ago
#0 Item_field::fix_outer_field (this=0x7fcf7c015cc0, thd=0x7fcf7c000ce8, from_field=0x7fcf8dc10a90, reference=0x7fcf7c015de8) at /home/midenok/src/mariadb/10.3/src/sql/item.cc:5715
#1 0x0000000000b5f6c1 in Item_field::fix_fields (this=0x7fcf7c015cc0, thd=0x7fcf7c000ce8, reference=0x7fcf7c015de8) at /home/midenok/src/mariadb/10.3/src/sql/item.cc:6156
#2 0x00000000006865e7 in Item::fix_fields_if_needed (this=0x7fcf7c015cc0, thd=0x7fcf7c000ce8, ref=0x7fcf7c015de8) at /home/midenok/src/mariadb/10.3/src/sql/item.h:823
#3 0x0000000000685a37 in Item::fix_fields_if_needed_for_scalar (this=0x7fcf7c015cc0, thd=0x7fcf7c000ce8, ref=0x7fcf7c015de8) at /home/midenok/src/mariadb/10.3/src/sql/item.h:827
#4 0x0000000000717c02 in setup_fields (thd=0x7fcf7c000ce8, ref_pointer_array=..., fields=..., column_usage=MARK_COLUMNS_READ, sum_func_list=0x7fcf7c03b9a0, pre_fix=0x7fcf7c014eb8, allow_sum_func=true) at /home/midenok/src/mariadb/10.3/src/sql/sql_base.cc:7456
#5 0x000000000080f01a in JOIN::prepare (this=0x7fcf7c03b680, tables_init=0x7fcf7c015e50, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7fcf7c014d78, unit_arg=0x7fcf7c0145f8) at /home/midenok/src/mariadb/10.3/src/sql/sql_select.cc:1134
#6 0x00000000008e9303 in st_select_lex_unit::prepare_join (this=0x7fcf7c0145f8, thd_arg=0x7fcf7c000ce8, sl=0x7fcf7c014d78, tmp_result=0x0, additional_options=0, is_union_select=false) at /home/midenok/src/mariadb/10.3/src/sql/sql_union.cc:655
#7 0x00000000008e3eee in st_select_lex_unit::prepare (this=0x7fcf7c0145f8, derived_arg=0x7fcf7c013c88, sel_result=0x0, additional_options=0) at /home/midenok/src/mariadb/10.3/src/sql/sql_union.cc:981
#8 0x00000000007622af in mysql_derived_prepare (thd=0x7fcf7c000ce8, lex=0x7fcf7c004ae0, derived=0x7fcf7c013c88) at /home/midenok/src/mariadb/10.3/src/sql/sql_derived.cc:700
#9 0x00000000007655f4 in mysql_handle_single_derived (lex=0x7fcf7c004ae0, derived=0x7fcf7c013c88, phases=2) at /home/midenok/src/mariadb/10.3/src/sql/sql_derived.cc:199
#10 0x000000000091ee8f in TABLE_LIST::handle_derived (this=0x7fcf7c013c88, lex=0x7fcf7c004ae0, phases=2) at /home/midenok/src/mariadb/10.3/src/sql/table.cc:8287
#11 0x0000000000780734 in LEX::handle_list_of_derived (this=0x7fcf7c004ae0, table_list=0x7fcf7c013c88, phases=2) at /home/midenok/src/mariadb/10.3/src/sql/sql_lex.h:4019
#12 0x0000000000d338c3 in mysql_delete (thd=0x7fcf7c000ce8, table_list=0x7fcf7c013c88, conds=0x0, order_list=0x7fcf7c0055a0, limit=18446744073709551615, options=0, result=0x0) at /home/midenok/src/mariadb/10.3/src/sql/sql_delete.cc:304
#13 0x00000000007c2854 in mysql_execute_command (thd=0x7fcf7c000ce8) at /home/midenok/src/mariadb/10.3/src/sql/sql_parse.cc:4658
#14 0x00000000007b9c60 in mysql_parse (thd=0x7fcf7c000ce8, rawbuf=0x7fcf7c013bc0 "DELETE FROM v2", length=14, parser_state=0x7fcf8dc155e8, is_com_multi=false, is_next_command=false) at /home/midenok/src/mariadb/10.3/src/sql/sql_parse.cc:7818
(rr) pitem this
$18 = 0x1e8d600 <dbug_item_print_buf> "v1.a"
#8 0x00000000007622af in mysql_derived_prepare
(rr) p dbug_print_select((st_select_lex *)derived->view.unit.slave)
$10 = 0x1e49400 <dbug_item_print_buf> "select v1.a AS a from test.v1"
Wrong field from t1. derived->view.unit
has stale SELECT.
#0 mysql_make_view (thd=0x7f25cc000ce8, share=0x7f25cc037eb0, table=0x7f25cc013c88, open_view_no_parse=false) at /home/midenok/src/mariadb/10.3/src/sql/sql_view.cc:1391
#1 0x00000000006df090 in open_table (thd=0x7f25cc000ce8, table_list=0x7f25cc013c88, ot_ctx=0x7f25e2d7cab8) at /home/midenok/src/mariadb/10.3/src/sql/sql_base.cc:1897
#2 0x00000000006e3db5 in open_and_process_table (thd=0x7f25cc000ce8, tables=0x7f25cc013c88, counter=0x7f25e2d7cbbc, flags=0, prelocking_strategy=0x7f25e2d7cc30, has_prelocking_list=false, ot_ctx=0x7f25e2d7cab8) at /home/midenok/src/mariadb/10.3/src/sql/sql_base.cc:3675
#3 0x00000000006e278d in open_tables (thd=0x7f25cc000ce8, options=..., start=0x7f25e2d7cbd0, counter=0x7f25e2d7cbbc, flags=0, prelocking_strategy=0x7f25e2d7cc30) at /home/midenok/src/mariadb/10.3/src/sql/sql_base.cc:4144
#4 0x00000000006e7205 in open_and_lock_tables (thd=0x7f25cc000ce8, options=..., tables=0x7f25cc013c88, derived=true, flags=0, prelocking_strategy=0x7f25e2d7cc30) at /home/midenok/src/mariadb/10.3/src/sql/sql_base.cc:5032
#5 0x00000000006939dc in open_and_lock_tables (thd=0x7f25cc000ce8, tables=0x7f25cc013c88, derived=true, flags=0) at /home/midenok/src/mariadb/10.3/src/sql/sql_base.h:503
#6 0x0000000000d08d41 in mysql_delete (thd=0x7f25cc000ce8, table_list=0x7f25cc013c88, conds=0x0, order_list=0x7f25cc0055a0, limit=18446744073709551615, options=0, result=0x0) at /home/midenok/src/mariadb/10.3/src/sql/sql_delete.cc:295
#7 0x0000000000797b54 in mysql_execute_command (thd=0x7f25cc000ce8) at /home/midenok/src/mariadb/10.3/src/sql/sql_parse.cc:4658
#8 0x000000000078ef60 in mysql_parse (thd=0x7f25cc000ce8, rawbuf=0x7f25cc013bc0 "delete from v2", length=14, parser_state=0x7f25e2d805e8, is_com_multi=false, is_next_command=false) at /home/midenok/src/mariadb/10.3/src/sql/sql_parse.cc:7818
p table->select_stmt.str
$19 = 0x7f25cc014450 "select `v1`.`a` AS `a` from `test`.`v1`"
v2 has wrong fields, but this is ok. The problem is that v1 is processed and then v2 is processed and both try to get versioning conditions as they both point to t2. v1 is processed correctly, but v2 should not be processed: versioning conditions already acquired.
Update versioning conditions via mysql_derived_prepare()
is needed for this case:
create or replace table t1 (x int) with system versioning;
insert into t1 values (1), (2);
create or replace view v1 as select * from t1 where x > 1;
update v1 set x= x + 1;
create or replace database test;
REPLACE works just fine without it.
Reproduce
Result
Good