bugfix: cmp_item_row::alloc_comparators() allocated on the wrong arena
it used current_thd->alloc() and allocated on the thd's execution arena, not on table->expr_arena. Remove THD::arena_for_cached_items that is temporarily set in update_virtual_fields(), and replaces THD arena in get_datetime_value(). Instead set THD arena to table->expr_arena for the whole duration of update_virtual_fields()
This commit is contained in:
parent
67e2028161
commit
798fcb5416
@ -2,7 +2,9 @@ create table t1 (a datetime,
|
||||
# get_datetime_value
|
||||
b int as (a > 1), # Arg_comparator
|
||||
c int as (a in (1,2,3)), # in_datetime
|
||||
d int as ((a,a) in ((1,1),(2,1),(NULL,1))) # cmp_item_datetime
|
||||
d int as ((a,a) in ((1,1),(2,1),(NULL,1))), # cmp_item_datetime
|
||||
# other issues
|
||||
e int as ((a,1) in ((1,1),(2,1),(NULL,1))) # cmp_item_row::alloc_comparators()
|
||||
);
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1'
|
||||
@ -14,7 +16,8 @@ t1 CREATE TABLE `t1` (
|
||||
`a` datetime DEFAULT NULL,
|
||||
`b` int(11) AS (a > 1) VIRTUAL,
|
||||
`c` int(11) AS (a in (1,2,3)) VIRTUAL,
|
||||
`d` int(11) AS ((a,a) in ((1,1),(2,1),(NULL,1))) VIRTUAL
|
||||
`d` int(11) AS ((a,a) in ((1,1),(2,1),(NULL,1))) VIRTUAL,
|
||||
`e` int(11) AS ((a,1) in ((1,1),(2,1),(NULL,1))) VIRTUAL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1'
|
||||
@ -22,18 +25,22 @@ Warning 1292 Incorrect datetime value: '2'
|
||||
Warning 1292 Incorrect datetime value: '3'
|
||||
insert t1 (a) values ('2010-10-10 10:10:10');
|
||||
select * from t1;
|
||||
a b c d
|
||||
2010-10-10 10:10:10 1 0 0
|
||||
a b c d e
|
||||
2010-10-10 10:10:10 1 0 0 NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1'
|
||||
Warning 1292 Incorrect datetime value: '1'
|
||||
Warning 1292 Incorrect datetime value: '2'
|
||||
Warning 1292 Incorrect datetime value: '1'
|
||||
Warning 1292 Incorrect datetime value: '1'
|
||||
Warning 1292 Incorrect datetime value: '2'
|
||||
select * from t1;
|
||||
a b c d
|
||||
2010-10-10 10:10:10 1 0 0
|
||||
a b c d e
|
||||
2010-10-10 10:10:10 1 0 0 NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1'
|
||||
Warning 1292 Incorrect datetime value: '2'
|
||||
Warning 1292 Incorrect datetime value: '1'
|
||||
Warning 1292 Incorrect datetime value: '1'
|
||||
Warning 1292 Incorrect datetime value: '2'
|
||||
drop table t1;
|
||||
|
@ -10,7 +10,9 @@ create table t1 (a datetime,
|
||||
# get_datetime_value
|
||||
b int as (a > 1), # Arg_comparator
|
||||
c int as (a in (1,2,3)), # in_datetime
|
||||
d int as ((a,a) in ((1,1),(2,1),(NULL,1))) # cmp_item_datetime
|
||||
d int as ((a,a) in ((1,1),(2,1),(NULL,1))), # cmp_item_datetime
|
||||
# other issues
|
||||
e int as ((a,1) in ((1,1),(2,1),(NULL,1))) # cmp_item_row::alloc_comparators()
|
||||
);
|
||||
show create table t1;
|
||||
connect con1, localhost, root;
|
||||
|
@ -921,12 +921,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
|
||||
if (!thd)
|
||||
thd= current_thd;
|
||||
|
||||
Query_arena backup;
|
||||
Query_arena *save_arena= thd->switch_to_arena_for_cached_items(&backup);
|
||||
Item_cache_temporal *cache= new Item_cache_temporal(f_type);
|
||||
if (save_arena)
|
||||
thd->set_query_arena(save_arena);
|
||||
|
||||
cache->store_packed(value, item);
|
||||
*cache_arg= cache;
|
||||
*item_arg= cache_arg;
|
||||
|
@ -957,7 +957,6 @@ THD::THD()
|
||||
|
||||
m_internal_handler= NULL;
|
||||
m_binlog_invoker= FALSE;
|
||||
arena_for_cached_items= 0;
|
||||
memset(&invoker_user, 0, sizeof(invoker_user));
|
||||
memset(&invoker_host, 0, sizeof(invoker_host));
|
||||
prepare_derived_at_open= FALSE;
|
||||
|
@ -3102,26 +3102,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
/*
|
||||
This reference points to the table arena when the expression
|
||||
for a virtual column is being evaluated
|
||||
*/
|
||||
Query_arena *arena_for_cached_items;
|
||||
|
||||
public:
|
||||
void reset_arena_for_cached_items(Query_arena *new_arena)
|
||||
{
|
||||
arena_for_cached_items= new_arena;
|
||||
}
|
||||
Query_arena *switch_to_arena_for_cached_items(Query_arena *backup)
|
||||
{
|
||||
if (!arena_for_cached_items)
|
||||
return 0;
|
||||
set_n_backup_active_arena(arena_for_cached_items, backup);
|
||||
return backup;
|
||||
}
|
||||
|
||||
void clear_wakeup_ready() { wakeup_ready= false; }
|
||||
/*
|
||||
Sleep waiting for others to wake us up with signal_wakeup_ready().
|
||||
|
@ -6575,7 +6575,9 @@ int update_virtual_fields(THD *thd, TABLE *table,
|
||||
int error __attribute__ ((unused))= 0;
|
||||
DBUG_ASSERT(table && table->vfield);
|
||||
|
||||
thd->reset_arena_for_cached_items(table->expr_arena);
|
||||
Query_arena backup_arena;
|
||||
thd->set_n_backup_active_arena(table->expr_arena, &backup_arena);
|
||||
|
||||
/* Iterate over virtual fields in the table */
|
||||
for (vfield_ptr= table->vfield; *vfield_ptr; vfield_ptr++)
|
||||
{
|
||||
@ -6593,7 +6595,7 @@ int update_virtual_fields(THD *thd, TABLE *table,
|
||||
DBUG_PRINT("info", ("field '%s' - skipped", vfield->field_name));
|
||||
}
|
||||
}
|
||||
thd->reset_arena_for_cached_items(0);
|
||||
thd->restore_active_arena(table->expr_arena, &backup_arena);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user