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
196f0c75
Commit
196f0c75
authored
Dec 13, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into mysql.com:/home/psergey/mysql-5.0-bug32198
parents
1cdd95f7
c6675cd1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
1 deletion
+67
-1
mysql-test/r/range.result
mysql-test/r/range.result
+18
-0
mysql-test/t/range.test
mysql-test/t/range.test
+20
-0
sql/field.cc
sql/field.cc
+3
-0
sql/opt_range.cc
sql/opt_range.cc
+26
-1
No files found.
mysql-test/r/range.result
View file @
196f0c75
...
@@ -1135,3 +1135,21 @@ item started price
...
@@ -1135,3 +1135,21 @@ item started price
A1 2005-11-01 08:00:00 1000.000
A1 2005-11-01 08:00:00 1000.000
A1 2005-11-15 00:00:00 2000.000
A1 2005-11-15 00:00:00 2000.000
DROP TABLE t1;
DROP TABLE t1;
BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly"
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
dateval date default NULL,
PRIMARY KEY (id),
KEY dateval (dateval)
) AUTO_INCREMENT=173;
INSERT INTO t1 VALUES
(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'),
(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'),
(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11');
This must use range access:
explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range dateval dateval 4 NULL 2 Using where
drop table t1;
mysql-test/t/range.test
View file @
196f0c75
...
@@ -935,4 +935,24 @@ SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
...
@@ -935,4 +935,24 @@ SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
DROP
TABLE
t1
;
DROP
TABLE
t1
;
--
echo
--
echo
BUG
#32198 "Comparison of DATE with DATETIME still not using indexes correctly"
--
echo
CREATE
TABLE
t1
(
id
int
(
11
)
NOT
NULL
auto_increment
,
dateval
date
default
NULL
,
PRIMARY
KEY
(
id
),
KEY
dateval
(
dateval
)
)
AUTO_INCREMENT
=
173
;
INSERT
INTO
t1
VALUES
(
1
,
'2007-01-01'
),(
2
,
'2007-01-02'
),(
3
,
'2007-01-03'
),(
4
,
'2007-01-04'
),
(
5
,
'2007-01-05'
),(
6
,
'2007-01-06'
),(
7
,
'2007-01-07'
),(
8
,
'2007-01-08'
),
(
9
,
'2007-01-09'
),(
10
,
'2007-01-10'
),(
11
,
'2007-01-11'
);
--
echo
This
must
use
range
access:
explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59'
;
drop
table
t1
;
# End of 5.0 tests
# End of 5.0 tests
sql/field.cc
View file @
196f0c75
...
@@ -5259,6 +5259,9 @@ void Field_date::sql_type(String &res) const
...
@@ -5259,6 +5259,9 @@ void Field_date::sql_type(String &res) const
1 Value was cut during conversion
1 Value was cut during conversion
2 Wrong date string
2 Wrong date string
3 Datetime value that was cut (warning level NOTE)
3 Datetime value that was cut (warning level NOTE)
This is used by opt_range.cc:get_mm_leaf(). Note that there is a
nearly-identical class Field_date doesn't ever return 3 from its
store function.
*/
*/
int
Field_newdate
::
store
(
const
char
*
from
,
uint
len
,
CHARSET_INFO
*
cs
)
int
Field_newdate
::
store
(
const
char
*
from
,
uint
len
,
CHARSET_INFO
*
cs
)
...
...
sql/opt_range.cc
View file @
196f0c75
...
@@ -4414,6 +4414,7 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
...
@@ -4414,6 +4414,7 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
{
{
tree
=
new
(
alloc
)
SEL_ARG
(
field
,
0
,
0
);
tree
=
new
(
alloc
)
SEL_ARG
(
field
,
0
,
0
);
tree
->
type
=
SEL_ARG
::
IMPOSSIBLE
;
tree
->
type
=
SEL_ARG
::
IMPOSSIBLE
;
goto
end
;
}
}
else
else
{
{
...
@@ -4422,8 +4423,32 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
...
@@ -4422,8 +4423,32 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
for the cases like int_field > 999999999999999999999999 as well.
for the cases like int_field > 999999999999999999999999 as well.
*/
*/
tree
=
0
;
tree
=
0
;
if
(
err
==
3
&&
field
->
type
()
==
FIELD_TYPE_DATE
&&
(
type
==
Item_func
::
GT_FUNC
||
type
==
Item_func
::
GE_FUNC
||
type
==
Item_func
::
LT_FUNC
||
type
==
Item_func
::
LE_FUNC
)
)
{
/*
We were saving DATETIME into a DATE column, the conversion went ok
but a non-zero time part was cut off.
In MySQL's SQL dialect, DATE and DATETIME are compared as datetime
values. Index over a DATE column uses DATE comparison. Changing
from one comparison to the other is possible:
datetime(date_col)< '2007-12-10 12:34:55' -> date_col<='2007-12-10'
datetime(date_col)<='2007-12-10 12:34:55' -> date_col<='2007-12-10'
datetime(date_col)> '2007-12-10 12:34:55' -> date_col>='2007-12-10'
datetime(date_col)>='2007-12-10 12:34:55' -> date_col>='2007-12-10'
but we'll need to convert '>' to '>=' and '<' to '<='. This will
be done together with other types at the end of this function
(grep for field_is_equal_to_item)
*/
}
else
goto
end
;
}
}
goto
end
;
}
}
if
(
err
<
0
)
if
(
err
<
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