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
6fbbb085
Commit
6fbbb085
authored
Mar 26, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-18968 Both (WHERE 0.1) and (WHERE NOT 0.1) return empty set
parent
ed643f4b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
20 deletions
+55
-20
mysql-test/r/func_group.result
mysql-test/r/func_group.result
+4
-4
mysql-test/r/type_decimal.result
mysql-test/r/type_decimal.result
+20
-0
mysql-test/t/type_decimal.test
mysql-test/t/type_decimal.test
+21
-0
sql/item.h
sql/item.h
+7
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+1
-1
sql/item_func.cc
sql/item_func.cc
+0
-12
sql/item_func.h
sql/item_func.h
+0
-1
sql/sql_select.cc
sql/sql_select.cc
+2
-2
No files found.
mysql-test/r/func_group.result
View file @
6fbbb085
...
@@ -1979,8 +1979,8 @@ FROM t2);
...
@@ -1979,8 +1979,8 @@ FROM t2);
MIN(t2.pk)
MIN(t2.pk)
NULL
NULL
Warnings:
Warnings:
Warning 1292 Truncated incorrect
INTEGER
value: 'j'
Warning 1292 Truncated incorrect
DOUBLE
value: 'j'
Warning 1292 Truncated incorrect
INTEGER
value: 'j'
Warning 1292 Truncated incorrect
DOUBLE
value: 'j'
EXPLAIN
EXPLAIN
SELECT MIN(t2.pk)
SELECT MIN(t2.pk)
...
@@ -1993,8 +1993,8 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -1993,8 +1993,8 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
Warnings:
Warnings:
Warning 1292 Truncated incorrect
INTEGER
value: 'j'
Warning 1292 Truncated incorrect
DOUBLE
value: 'j'
Warning 1292 Truncated incorrect
INTEGER
value: 'j'
Warning 1292 Truncated incorrect
DOUBLE
value: 'j'
#
#
# 2) Test that subquery materialization is setup for query with
# 2) Test that subquery materialization is setup for query with
...
...
mysql-test/r/type_decimal.result
View file @
6fbbb085
...
@@ -1019,3 +1019,23 @@ cast('-0.0' as decimal(5,1)) < 0
...
@@ -1019,3 +1019,23 @@ cast('-0.0' as decimal(5,1)) < 0
#
#
# End of 5.5 tests
# End of 5.5 tests
#
#
#
# Start of 10.1 tests
#
#
# MDEV-18968 Both (WHERE 0.1) and (WHERE NOT 0.1) return empty set
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10);
SELECT CASE WHEN 0.1 THEN 'TRUE' ELSE 'FALSE' END FROM t1;
CASE WHEN 0.1 THEN 'TRUE' ELSE 'FALSE' END
TRUE
SELECT * FROM t1 WHERE 0.1;
a
10
SELECT * FROM t1 WHERE NOT 0.1;
a
DROP TABLE t1;
#
# End of 10.1 tests
#
mysql-test/t/type_decimal.test
View file @
6fbbb085
...
@@ -612,3 +612,24 @@ select cast('-0.0' as decimal(5,1)) < 0;
...
@@ -612,3 +612,24 @@ select cast('-0.0' as decimal(5,1)) < 0;
--
echo
#
--
echo
#
--
echo
# End of 5.5 tests
--
echo
# End of 5.5 tests
--
echo
#
--
echo
#
--
echo
#
--
echo
# Start of 10.1 tests
--
echo
#
--
echo
#
--
echo
# MDEV-18968 Both (WHERE 0.1) and (WHERE NOT 0.1) return empty set
--
echo
#
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
10
);
SELECT
CASE
WHEN
0.1
THEN
'TRUE'
ELSE
'FALSE'
END
FROM
t1
;
SELECT
*
FROM
t1
WHERE
0.1
;
SELECT
*
FROM
t1
WHERE
NOT
0.1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of 10.1 tests
--
echo
#
sql/item.h
View file @
6fbbb085
...
@@ -1000,6 +1000,13 @@ class Item: public Value_source,
...
@@ -1000,6 +1000,13 @@ class Item: public Value_source,
virtual
bool
val_bool
();
virtual
bool
val_bool
();
virtual
String
*
val_nodeset
(
String
*
)
{
return
0
;
}
virtual
String
*
val_nodeset
(
String
*
)
{
return
0
;
}
bool
eval_const_cond
()
{
DBUG_ASSERT
(
const_item
());
DBUG_ASSERT
(
!
is_expensive
());
return
val_bool
();
}
/*
/*
save_val() is method of val_* family which stores value in the given
save_val() is method of val_* family which stores value in the given
field.
field.
...
...
sql/item_cmpfunc.cc
View file @
6fbbb085
...
@@ -4667,7 +4667,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
...
@@ -4667,7 +4667,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
if
(
item
->
const_item
()
&&
!
item
->
with_param
&&
if
(
item
->
const_item
()
&&
!
item
->
with_param
&&
!
item
->
is_expensive
()
&&
!
cond_has_datetime_is_null
(
item
))
!
item
->
is_expensive
()
&&
!
cond_has_datetime_is_null
(
item
))
{
{
if
(
item
->
val_int
()
==
is_and_cond
&&
top_level
())
if
(
item
->
eval_const_cond
()
==
is_and_cond
&&
top_level
())
{
{
/*
/*
a. This is "... AND true_cond AND ..."
a. This is "... AND true_cond AND ..."
...
...
sql/item_func.cc
View file @
6fbbb085
...
@@ -68,18 +68,6 @@ bool check_reserved_words(LEX_STRING *name)
...
@@ -68,18 +68,6 @@ bool check_reserved_words(LEX_STRING *name)
}
}
/**
@return
TRUE if item is a constant
*/
bool
eval_const_cond
(
COND
*
cond
)
{
return
((
Item_func
*
)
cond
)
->
val_int
()
?
TRUE
:
FALSE
;
}
/**
/**
Test if the sum of arguments overflows the ulonglong range.
Test if the sum of arguments overflows the ulonglong range.
*/
*/
...
...
sql/item_func.h
View file @
6fbbb085
...
@@ -2279,7 +2279,6 @@ extern enum_field_types agg_field_type(Item **items, uint nitems,
...
@@ -2279,7 +2279,6 @@ extern enum_field_types agg_field_type(Item **items, uint nitems,
Item
*
find_date_time_item
(
Item
**
args
,
uint
nargs
,
uint
col
);
Item
*
find_date_time_item
(
Item
**
args
,
uint
nargs
,
uint
col
);
double
my_double_round
(
double
value
,
longlong
dec
,
bool
dec_unsigned
,
double
my_double_round
(
double
value
,
longlong
dec
,
bool
dec_unsigned
,
bool
truncate
);
bool
truncate
);
bool
eval_const_cond
(
COND
*
cond
);
extern
bool
volatile
mqh_used
;
extern
bool
volatile
mqh_used
;
...
...
sql/sql_select.cc
View file @
6fbbb085
...
@@ -15644,7 +15644,7 @@ Item::remove_eq_conds(THD *thd, Item::cond_result *cond_value, bool top_level_ar
...
@@ -15644,7 +15644,7 @@ Item::remove_eq_conds(THD *thd, Item::cond_result *cond_value, bool top_level_ar
{
{
if
(
const_item
()
&&
!
is_expensive
())
if
(
const_item
()
&&
!
is_expensive
())
{
{
*
cond_value
=
eval_const_cond
(
this
)
?
Item
::
COND_TRUE
:
Item
::
COND_FALSE
;
*
cond_value
=
eval_const_cond
()
?
Item
::
COND_TRUE
:
Item
::
COND_FALSE
;
return
(
COND
*
)
0
;
return
(
COND
*
)
0
;
}
}
*
cond_value
=
Item
::
COND_OK
;
*
cond_value
=
Item
::
COND_OK
;
...
@@ -15658,7 +15658,7 @@ Item_bool_func2::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
...
@@ -15658,7 +15658,7 @@ Item_bool_func2::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
{
{
if
(
const_item
()
&&
!
is_expensive
())
if
(
const_item
()
&&
!
is_expensive
())
{
{
*
cond_value
=
eval_const_cond
(
this
)
?
Item
::
COND_TRUE
:
Item
::
COND_FALSE
;
*
cond_value
=
eval_const_cond
()
?
Item
::
COND_TRUE
:
Item
::
COND_FALSE
;
return
(
COND
*
)
0
;
return
(
COND
*
)
0
;
}
}
if
((
*
cond_value
=
eq_cmp_result
())
!=
Item
::
COND_OK
)
if
((
*
cond_value
=
eq_cmp_result
())
!=
Item
::
COND_OK
)
...
...
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