summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-01-14 20:55:33 +0100
committerSergei Golubchik <serg@mariadb.org>2017-01-15 00:11:50 +0100
commit798fcb541698cbf51f1ee33f44b023c11dc2b784 (patch)
tree12a47741ef63500d339a1e076cafa500a03498b0
parent67e2028161d1f653a852f1a4679ff5e523296218 (diff)
downloadmariadb-git-798fcb541698cbf51f1ee33f44b023c11dc2b784.tar.gz
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()
-rw-r--r--mysql-test/suite/vcol/r/wrong_arena.result19
-rw-r--r--mysql-test/suite/vcol/t/wrong_arena.test4
-rw-r--r--sql/item_cmpfunc.cc5
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_class.h19
-rw-r--r--sql/table.cc6
6 files changed, 20 insertions, 34 deletions
diff --git a/mysql-test/suite/vcol/r/wrong_arena.result b/mysql-test/suite/vcol/r/wrong_arena.result
index d542c82458e..af41ea89ab5 100644
--- a/mysql-test/suite/vcol/r/wrong_arena.result
+++ b/mysql-test/suite/vcol/r/wrong_arena.result
@@ -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;
diff --git a/mysql-test/suite/vcol/t/wrong_arena.test b/mysql-test/suite/vcol/t/wrong_arena.test
index 8bf06bdb9bd..4276437f446 100644
--- a/mysql-test/suite/vcol/t/wrong_arena.test
+++ b/mysql-test/suite/vcol/t/wrong_arena.test
@@ -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;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 46566206094..ebe088e5092 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -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;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 62339b2690a..93af4d3bb4d 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -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;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 27bc40e3761..5dd7cd18a5d 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -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().
diff --git a/sql/table.cc b/sql/table.cc
index 1330560b6b6..9d52d5f87a2 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -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);
}