Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
6728aae3
Commit
6728aae3
authored
Jan 17, 2017
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '5.5' into 10.0
parents
e4e801d4
b948b5f7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
118 additions
and
51 deletions
+118
-51
mysql-test/suite/vcol/r/wrong_arena.result
mysql-test/suite/vcol/r/wrong_arena.result
+61
-0
mysql-test/suite/vcol/t/wrong_arena.test
mysql-test/suite/vcol/t/wrong_arena.test
+35
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+12
-15
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+4
-8
sql/item_func.cc
sql/item_func.cc
+2
-5
sql/item_func.h
sql/item_func.h
+0
-1
sql/sql_class.cc
sql/sql_class.cc
+0
-1
sql/sql_class.h
sql/sql_class.h
+0
-19
sql/table.cc
sql/table.cc
+4
-2
No files found.
mysql-test/suite/vcol/r/wrong_arena.result
0 → 100644
View file @
6728aae3
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
# 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'
Warning 1292 Incorrect datetime value: '2'
Warning 1292 Incorrect datetime value: '3'
show create table t1;
Table Create Table
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,
`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'
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 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 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;
create table t1 (a datetime,
b datetime as (least(a,1)) # Item_func_min_max::get_date
);
insert t1 (a) values ('2010-10-10 10:10:10');
select * from t1;
a b
2010-10-10 10:10:10 0000-00-00 00:00:00
Warnings:
Warning 1292 Incorrect datetime value: '1'
select * from t1;
a b
2010-10-10 10:10:10 0000-00-00 00:00:00
Warnings:
Warning 1292 Incorrect datetime value: '1'
drop table t1;
mysql-test/suite/vcol/t/wrong_arena.test
0 → 100644
View file @
6728aae3
#
# This tests various issues when vcol items allocate memory (e.g. more items)
# not in the TABLE::expr_arena.
#
#
# MDEV-9690 concurrent queries with virtual columns crash in temporal code
#
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
# 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
;
insert
t1
(
a
)
values
(
'2010-10-10 10:10:10'
);
select
*
from
t1
;
disconnect
con1
;
connection
default
;
select
*
from
t1
;
drop
table
t1
;
connect
con1
,
localhost
,
root
;
create
table
t1
(
a
datetime
,
b
datetime
as
(
least
(
a
,
1
))
# Item_func_min_max::get_date
);
insert
t1
(
a
)
values
(
'2010-10-10 10:10:10'
);
select
*
from
t1
;
disconnect
con1
;
connection
default
;
select
*
from
t1
;
drop
table
t1
;
sql/item_cmpfunc.cc
View file @
6728aae3
...
...
@@ -798,7 +798,7 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg,
Item
**
a1
,
Item
**
a2
,
Item_result
type
)
{
thd
=
current_thd
;
THD
*
thd
=
current_thd
;
owner
=
owner_arg
;
set_null
=
set_null
&&
owner_arg
;
a
=
a1
;
...
...
@@ -868,7 +868,6 @@ Item** Arg_comparator::cache_converted_constant(THD *thd_arg, Item **value,
void
Arg_comparator
::
set_datetime_cmp_func
(
Item_result_field
*
owner_arg
,
Item
**
a1
,
Item
**
b1
)
{
thd
=
current_thd
;
owner
=
owner_arg
;
a
=
a1
;
b
=
b1
;
...
...
@@ -943,12 +942,10 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
if
(
cache_arg
&&
item
->
const_item
()
&&
!
(
item
->
type
()
==
Item
::
CACHE_ITEM
&&
item
->
cmp_type
()
==
TIME_RESULT
))
{
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
);
if
(
!
thd
)
thd
=
current_thd
;
Item_cache_temporal
*
cache
=
new
Item_cache_temporal
(
f_type
);
cache
->
store_packed
(
value
,
item
);
*
cache_arg
=
cache
;
*
item_arg
=
cache_arg
;
...
...
@@ -983,12 +980,12 @@ int Arg_comparator::compare_datetime()
owner
->
null_value
=
1
;
/* Get DATE/DATETIME/TIME value of the 'a' item. */
a_value
=
get_datetime_value
(
thd
,
&
a
,
&
a_cache
,
*
b
,
&
a_is_null
);
a_value
=
get_datetime_value
(
0
,
&
a
,
&
a_cache
,
*
b
,
&
a_is_null
);
if
(
a_is_null
)
return
-
1
;
/* Get DATE/DATETIME/TIME value of the 'b' item. */
b_value
=
get_datetime_value
(
thd
,
&
b
,
&
b_cache
,
*
a
,
&
b_is_null
);
b_value
=
get_datetime_value
(
0
,
&
b
,
&
b_cache
,
*
a
,
&
b_is_null
);
if
(
b_is_null
)
return
-
1
;
...
...
@@ -1006,10 +1003,10 @@ int Arg_comparator::compare_e_datetime()
longlong
a_value
,
b_value
;
/* Get DATE/DATETIME/TIME value of the 'a' item. */
a_value
=
get_datetime_value
(
thd
,
&
a
,
&
a_cache
,
*
b
,
&
a_is_null
);
a_value
=
get_datetime_value
(
0
,
&
a
,
&
a_cache
,
*
b
,
&
a_is_null
);
/* Get DATE/DATETIME/TIME value of the 'b' item. */
b_value
=
get_datetime_value
(
thd
,
&
b
,
&
b_cache
,
*
a
,
&
b_is_null
);
b_value
=
get_datetime_value
(
0
,
&
b
,
&
b_cache
,
*
a
,
&
b_is_null
);
return
a_is_null
||
b_is_null
?
a_is_null
==
b_is_null
:
a_value
==
b_value
;
}
...
...
@@ -3663,7 +3660,7 @@ void in_datetime::set(uint pos,Item *item)
bool
is_null
;
struct
packed_longlong
*
buff
=
&
((
packed_longlong
*
)
base
)[
pos
];
buff
->
val
=
get_datetime_value
(
thd
,
&
tmp_item
,
0
,
warn_item
,
&
is_null
);
buff
->
val
=
get_datetime_value
(
0
,
&
tmp_item
,
0
,
warn_item
,
&
is_null
);
buff
->
unsigned_flag
=
1L
;
}
...
...
@@ -3671,7 +3668,7 @@ uchar *in_datetime::get_value(Item *item)
{
bool
is_null
;
Item
**
tmp_item
=
lval_cache
?
&
lval_cache
:
&
item
;
tmp
.
val
=
get_datetime_value
(
thd
,
&
tmp_item
,
&
lval_cache
,
warn_item
,
&
is_null
);
tmp
.
val
=
get_datetime_value
(
0
,
&
tmp_item
,
&
lval_cache
,
warn_item
,
&
is_null
);
if
(
item
->
null_value
)
return
0
;
tmp
.
unsigned_flag
=
1L
;
...
...
@@ -3915,7 +3912,7 @@ void cmp_item_datetime::store_value(Item *item)
{
bool
is_null
;
Item
**
tmp_item
=
lval_cache
?
&
lval_cache
:
&
item
;
value
=
get_datetime_value
(
thd
,
&
tmp_item
,
&
lval_cache
,
warn_item
,
&
is_null
);
value
=
get_datetime_value
(
0
,
&
tmp_item
,
&
lval_cache
,
warn_item
,
&
is_null
);
}
...
...
@@ -3924,7 +3921,7 @@ int cmp_item_datetime::cmp(Item *arg)
bool
is_null
;
Item
**
tmp_item
=
&
arg
;
return
value
!=
get_datetime_value
(
thd
,
&
tmp_item
,
0
,
warn_item
,
&
is_null
);
get_datetime_value
(
0
,
&
tmp_item
,
0
,
warn_item
,
&
is_null
);
}
...
...
sql/item_cmpfunc.h
View file @
6728aae3
...
...
@@ -45,7 +45,6 @@ class Arg_comparator: public Sql_alloc
Arg_comparator
*
comparators
;
// used only for compare_row()
double
precision
;
/* Fields used in DATE/DATETIME comparison. */
THD
*
thd
;
Item
*
a_cache
,
*
b_cache
;
// Cached values of a and b items
// when one of arguments is NULL.
int
set_compare_func
(
Item_result_field
*
owner
,
Item_result
type
);
...
...
@@ -61,10 +60,10 @@ class Arg_comparator: public Sql_alloc
/* Allow owner function to use string buffers. */
String
value1
,
value2
;
Arg_comparator
()
:
set_null
(
TRUE
),
comparators
(
0
),
thd
(
0
),
Arg_comparator
()
:
set_null
(
TRUE
),
comparators
(
0
),
a_cache
(
0
),
b_cache
(
0
)
{};
Arg_comparator
(
Item
**
a1
,
Item
**
a2
)
:
a
(
a1
),
b
(
a2
),
set_null
(
TRUE
),
comparators
(
0
),
thd
(
0
),
a_cache
(
0
),
b_cache
(
0
)
{};
comparators
(
0
),
a_cache
(
0
),
b_cache
(
0
)
{};
int
set_cmp_func
(
Item_result_field
*
owner_arg
,
Item
**
a1
,
Item
**
a2
,
...
...
@@ -963,15 +962,13 @@ class in_longlong :public in_vector
class
in_datetime
:
public
in_longlong
{
public:
THD
*
thd
;
/* An item used to issue warnings. */
Item
*
warn_item
;
/* Cache for the left item. */
Item
*
lval_cache
;
in_datetime
(
Item
*
warn_item_arg
,
uint
elements
)
:
in_longlong
(
elements
),
thd
(
current_thd
),
warn_item
(
warn_item_arg
),
lval_cache
(
0
)
{};
:
in_longlong
(
elements
),
warn_item
(
warn_item_arg
),
lval_cache
(
0
)
{};
void
set
(
uint
pos
,
Item
*
item
);
uchar
*
get_value
(
Item
*
item
);
Item
*
create_item
()
...
...
@@ -1131,14 +1128,13 @@ class cmp_item_datetime :public cmp_item
{
longlong
value
;
public:
THD
*
thd
;
/* Item used for issuing warnings. */
Item
*
warn_item
;
/* Cache for the left item. */
Item
*
lval_cache
;
cmp_item_datetime
(
Item
*
warn_item_arg
)
:
thd
(
current_thd
),
warn_item
(
warn_item_arg
),
lval_cache
(
0
)
{}
:
warn_item
(
warn_item_arg
),
lval_cache
(
0
)
{}
void
store_value
(
Item
*
item
);
int
cmp
(
Item
*
arg
);
int
compare
(
cmp_item
*
ci
);
...
...
sql/item_func.cc
View file @
6728aae3
...
...
@@ -2853,7 +2853,6 @@ void Item_func_min_max::fix_length_and_dec()
decimals
=
0
;
max_length
=
0
;
maybe_null
=
0
;
thd
=
current_thd
;
cmp_type
=
args
[
0
]
->
result_type
();
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
...
...
@@ -2926,13 +2925,11 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
{
Item
**
arg
=
args
+
i
;
bool
is_null
;
longlong
res
=
get_datetime_value
(
thd
,
&
arg
,
0
,
compare_as_dates
,
&
is_null
);
longlong
res
=
get_datetime_value
(
0
,
&
arg
,
0
,
compare_as_dates
,
&
is_null
);
/* Check if we need to stop (because of error or KILL) and stop the loop */
if
(
thd
->
is_error
()
||
args
[
i
]
->
null_value
)
{
if
(
args
[
i
]
->
null_value
)
return
(
null_value
=
1
);
}
if
(
i
==
0
||
(
res
<
min_max
?
cmp_sign
:
-
cmp_sign
)
>
0
)
min_max
=
res
;
...
...
sql/item_func.h
View file @
6728aae3
...
...
@@ -1077,7 +1077,6 @@ class Item_func_min_max :public Item_func
int
cmp_sign
;
/* An item used for issuing warnings while string to DATETIME conversion. */
Item
*
compare_as_dates
;
THD
*
thd
;
protected:
enum_field_types
cached_field_type
;
public:
...
...
sql/sql_class.cc
View file @
6728aae3
...
...
@@ -1054,7 +1054,6 @@ THD::THD()
m_internal_handler
=
NULL
;
m_binlog_invoker
=
INVOKER_NONE
;
arena_for_cached_items
=
0
;
memset
(
&
invoker_user
,
0
,
sizeof
(
invoker_user
));
memset
(
&
invoker_host
,
0
,
sizeof
(
invoker_host
));
prepare_derived_at_open
=
FALSE
;
...
...
sql/sql_class.h
View file @
6728aae3
...
...
@@ -3676,26 +3676,7 @@ class THD :public Statement,
}
}
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().
...
...
sql/table.cc
View file @
6728aae3
...
...
@@ -6704,7 +6704,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
++
)
{
...
...
@@ -6722,7 +6724,7 @@ int update_virtual_fields(THD *thd, TABLE *table,
DBUG_PRINT
(
"info"
,
(
"field '%s' - skipped"
,
vfield
->
field_name
));
}
}
thd
->
res
et_arena_for_cached_items
(
0
);
thd
->
res
tore_active_arena
(
table
->
expr_arena
,
&
backup_arena
);
DBUG_RETURN
(
0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment