midenok / mariadb

MariaDB server is a community developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.
GNU General Public License v2.0
0 stars 0 forks source link

MDEV-22563 Sig 11 manipulating tables #73

Closed midenok closed 4 years ago

midenok commented 4 years ago

Reproduce


create or replace table person_principal
(
    person_id bigint not null,
    insurant_id varchar(10) not null,
    principal_id bigint not null,
    principal_officer_id bigint not null,
    nursing_degree tinyint null,
    nursing_degree_valid_from date not null default cast(current_timestamp(6) as date),
    carma_user_id bigint not null,
    current_date_time timestamp(6) not null default current_timestamp(6) on update current_timestamp(6),
    constraint pk_person_principal primary key (person_id asc),
    constraint ck_person_principal_nursing_degree check (nursing_degree in (1,2,3,4,5))
);

create or replace table person_principal_hist
(
    person_id bigint not null,
    insurant_id varchar(10) not null,
    principal_id bigint not null,
    principal_officer_id bigint not null,
    nursing_degree tinyint null,
    nursing_degree_valid_from date not null default cast(now() as date),
    carma_user_id bigint not null,
    orig_date_time datetime(6) not null,
    constraint pk_person_principal_hist primary key (person_id asc, orig_date_time asc),
    constraint ck_person_principal_hist_nursing_degree check (nursing_degree in (1,2,3,4,5))
);

insert into person_principal
    (person_id, insurant_id, principal_id, principal_officer_id, nursing_degree, nursing_degree_valid_from, carma_user_id)
values
    (1, 'A123456789', 5, 1, 1, '2018-05-06', 1);

alter table person_principal add column if not exists date_mask tinyint null;

update person_principal set date_mask = 0;

alter table person_principal modify column date_mask tinyint not null;

drop tables person_principal_hist, person_principal;

Result

#0  0x0000000000da28b9 in Item_func_in::cleanup (this=0x7fb8140156d0) at /home/midenok/src/mariadb/10.4/src/sql/item_cmpfunc.h:2414
#1  0x00000000007a8bda in Item::delete_self (this=0x7fb8140156d0) at /home/midenok/src/mariadb/10.4/src/sql/item.h:2182
#2  0x0000000000794c99 in Query_arena::free_items (this=0x7fb814000d40) at /home/midenok/src/mariadb/10.4/src/sql/sql_class.cc:3779
#3  0x0000000000794a3b in THD::cleanup_after_query (this=0x7fb814000d28) at /home/midenok/src/mariadb/10.4/src/sql/sql_class.cc:2279
#4  0x00000000008169f6 in mysql_parse (thd=0x7fb814000d28, rawbuf=0x7fb814014080 "alter table person_principal add column if not exists date_mask tinyint null", length=76, parser_state=0x7fb824ddb5e0, is_com_multi=false, is_next_command=false) at /home/midenok/src/mariadb/10.4/src/sql/sql_parse.cc:7923
(rr) p array
$8 = (in_vector *) 0x7fb81402b448
(rr) p *array
$9 = {
<Sql_alloc> = {<No data fields>},
members of in_vector:
_vptr$in_vector = 0x8f8f8f8f8f8f8f8f,
base = 0x8f8f8f8f8f8f8f8f <error: Cannot access memory at address 0x8f8f8f8f8f8f8f8f>,
size = 2408550287,
compare = 0x8f8f8f8f8f8f8f8f,
collation = 0x8f8f8f8f8f8f8f8f,
count = 2408550287,
used_count = 2408550287
}

Freed before

#0  Item_func_in::cleanup (this=0x7fb81402b228) at /home/midenok/src/mariadb/10.4/src/sql/item_cmpfunc.h:2414
#1  0x00000000007a8bda in Item::delete_self (this=0x7fb81402b228) at /home/midenok/src/mariadb/10.4/src/sql/item.h:2182
#2  0x0000000000794c99 in Query_arena::free_items (this=0x7fb81401b468) at /home/midenok/src/mariadb/10.4/src/sql/sql_class.cc:3779
#3  0x0000000000979a74 in closefrm (table=0x7fb8140290f8) at /home/midenok/src/mariadb/10.4/src/sql/table.cc:4056
#4  0x0000000000abaf07 in intern_close_table (table=0x7fb8140290f8) at /home/midenok/src/mariadb/10.4/src/sql/table_cache.cc:221
#5  0x0000000000abb4d2 in tc_remove_table (table=0x7fb8140290f8) at /home/midenok/src/mariadb/10.4/src/sql/table_cache.cc:259
#6  0x0000000000abbb92 in tc_release_table (table=0x7fb8140290f8) at /home/midenok/src/mariadb/10.4/src/sql/table_cache.cc:471
#7  0x000000000075a62c in close_thread_table (thd=0x7fb814000d28, table_ptr=0x7fb814000e08) at /home/midenok/src/mariadb/10.4/src/sql/sql_base.cc:1078
#8  0x0000000000758f28 in close_all_tables_for_name (thd=0x7fb814000d28, share=0x7fb81401c810, extra=HA_EXTRA_NOT_USED, skip_table=0x0) at /home/midenok/src/mariadb/10.4/src/sql/sql_base.cc:842
#9  0x000000000092caa2 in mysql_alter_table (thd=0x7fb814000d28, new_db=0x7fb8140054d8, new_name=0x7fb8140058e0, create_info=0x7fb824dd8488, table_list=0x7fb8140141e8, alter_info=0x7fb824dd83d0, order_num=0, order=0x0, ignore=false) at /home/midenok/src/mariadb/10.4/src/sql/sql_table.cc:10326
#10 0x00000000009e1a26 in Sql_cmd_alter_table::execute (this=0x7fb8140149d8, thd=0x7fb814000d28) at /home/midenok/src/mariadb/10.4/src/sql/sql_alter.cc:502
#11 0x000000000082626b in mysql_execute_command (thd=0x7fb814000d28) at /home/midenok/src/mariadb/10.4/src/sql/sql_parse.cc:6101
#12 0x0000000000816790 in mysql_parse (thd=0x7fb814000d28, rawbuf=0x7fb814014080 "alter table person_principal add column if not exists date_mask tinyint null", length=76, parser_state=0x7fb824ddb5e0, is_com_multi=false, is_next_command=false) at /home/midenok/src/mariadb/10.4/src/sql/sql_parse.cc:7900
(rr) p array
$12 = (in_vector *) 0x7fb81402b448
midenok commented 4 years ago

0x7fb8140156d0->array assigned

#0  0x0000000000da57e3 in Item_func_in::Item_func_in (this=0x7fb8140156d0) at /home/midenok/src/mariadb/10.4/src/sql/item_cmpfunc.h:2324
#1  0x0000000000da56df in get_item_copy<Item_func_in> (thd=0x7fb814000d28, item=0x7fb81402b228) at /home/midenok/src/mariadb/10.4/src/sql/item.h:2368
#2  0x0000000000da2a1d in Item_func_in::get_copy (this=0x7fb81402b228, thd=0x7fb814000d28) at /home/midenok/src/mariadb/10.4/src/sql/item_cmpfunc.h:2455
#3  0x0000000000b961cd in Virtual_column_info::clone (this=0x7fb81402b418, thd=0x7fb814000d28) at /home/midenok/src/mariadb/10.4/src/sql/field.cc:11399
#4  0x0000000000927ba0 in mysql_prepare_alter_table (thd=0x7fb814000d28, table=0x7fb8140290f8, create_info=0x7fb824dd8488, alter_info=0x7fb824dd83d0, alter_ctx=0x7fb824dd7108) at /home/midenok/src/mariadb/10.4/src/sql/sql_table.cc:8635
#5  0x000000000092b205 in mysql_alter_table (thd=0x7fb814000d28, new_db=0x7fb8140054d8, new_name=0x7fb8140058e0, create_info=0x7fb824dd8488, table_list=0x7fb8140141e8, alter_info=0x7fb824dd83d0, order_num=0, order=0x0, ignore=false) at /home/midenok/src/mariadb/10.4/src/sql/sql_table.cc:9819
#6  0x00000000009e1a26 in Sql_cmd_alter_table::execute (this=0x7fb8140149d8, thd=0x7fb814000d28) at /home/midenok/src/mariadb/10.4/src/sql/sql_alter.cc:502
#7  0x000000000082626b in mysql_execute_command (thd=0x7fb814000d28) at /home/midenok/src/mariadb/10.4/src/sql/sql_parse.cc:6101
#8  0x0000000000816790 in mysql_parse (thd=0x7fb814000d28, rawbuf=0x7fb814014080 "alter table person_principal add column if not exists date_mask tinyint null", length=76, parser_state=0x7fb824ddb5e0, is_com_multi=false, is_next_command=false) at /home/midenok/src/mariadb/10.4/src/sql/sql_parse.cc:7900

Cause

No copy constructor for deep copy in Item_func_in. get_copy() does shallow copy while build_clone() does deep copy.