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
b0a92333
Commit
b0a92333
authored
Feb 09, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-15262 Wrong results for SELECT..WHERE non_indexed_datetime_column=indexed_time_column
parent
6f0b316f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
0 deletions
+74
-0
mysql-test/r/type_time_6065.result
mysql-test/r/type_time_6065.result
+44
-0
mysql-test/t/type_time_6065.test
mysql-test/t/type_time_6065.test
+23
-0
sql/field.cc
sql/field.cc
+7
-0
No files found.
mysql-test/r/type_time_6065.result
View file @
b0a92333
...
@@ -2308,3 +2308,47 @@ col_int_nokey
...
@@ -2308,3 +2308,47 @@ col_int_nokey
1
1
DROP TABLE t1,t2,t3;
DROP TABLE t1,t2,t3;
SET TIMESTAMP=0;
SET TIMESTAMP=0;
#
# MDEV-15262 Wrong results for SELECT..WHERE non_indexed_datetime_column=indexed_time_column
#
SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35');
CREATE TABLE t1 (col_time_key TIME, KEY(col_time_key));
CREATE TABLE t2 (col_datetime_key DATETIME);
INSERT INTO t1 VALUES ('-760:00:00'),('760:00:00');
INSERT INTO t1 VALUES ('-770:00:00'),('770:00:00');
INSERT INTO t2 SELECT * FROM t1;
SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key;
col_datetime_key col_time_key
2011-12-30 08:00:00 -760:00:00
2012-03-02 16:00:00 760:00:00
2011-12-29 22:00:00 -770:00:00
2012-03-03 02:00:00 770:00:00
SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key;
col_datetime_key col_time_key
2011-12-29 22:00:00 -770:00:00
2011-12-30 08:00:00 -760:00:00
2012-03-02 16:00:00 760:00:00
2012-03-03 02:00:00 770:00:00
INSERT INTO t1 VALUES ('-838:59:59'),('838:59:59');
INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '-838:59:59' HOUR_SECOND));
INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '838:59:59' HOUR_SECOND));
INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '-839:00:00' HOUR_SECOND));
INSERT INTO t2 VALUES (DATE_ADD(CURRENT_DATE, INTERVAL '839:00:00' HOUR_SECOND));
SELECT * FROM t2 STRAIGHT_JOIN t1 IGNORE INDEX(col_time_key) WHERE col_time_key = col_datetime_key;
col_datetime_key col_time_key
2011-12-30 08:00:00 -760:00:00
2012-03-02 16:00:00 760:00:00
2011-12-29 22:00:00 -770:00:00
2012-03-03 02:00:00 770:00:00
2011-12-27 01:00:01 -838:59:59
2012-03-05 22:59:59 838:59:59
SELECT * FROM t2 STRAIGHT_JOIN t1 FORCE INDEX (col_time_key) WHERE col_time_key = col_datetime_key;
col_datetime_key col_time_key
2011-12-29 22:00:00 -770:00:00
2011-12-30 08:00:00 -760:00:00
2012-03-02 16:00:00 760:00:00
2012-03-03 02:00:00 770:00:00
2011-12-27 01:00:01 -838:59:59
2012-03-05 22:59:59 838:59:59
DROP TABLE t1, t2;
SET TIMESTAMP=DEFAULT;
mysql-test/t/type_time_6065.test
View file @
b0a92333
...
@@ -172,6 +172,29 @@ eval $query;
...
@@ -172,6 +172,29 @@ eval $query;
DROP
TABLE
t1
,
t2
,
t3
;
DROP
TABLE
t1
,
t2
,
t3
;
SET
TIMESTAMP
=
0
;
# back to current time
SET
TIMESTAMP
=
0
;
# back to current time
--
echo
#
--
echo
# MDEV-15262 Wrong results for SELECT..WHERE non_indexed_datetime_column=indexed_time_column
--
echo
#
SET
TIMESTAMP
=
UNIX_TIMESTAMP
(
'2012-01-31 10:14:35'
);
CREATE
TABLE
t1
(
col_time_key
TIME
,
KEY
(
col_time_key
));
CREATE
TABLE
t2
(
col_datetime_key
DATETIME
);
INSERT
INTO
t1
VALUES
(
'-760:00:00'
),(
'760:00:00'
);
INSERT
INTO
t1
VALUES
(
'-770:00:00'
),(
'770:00:00'
);
INSERT
INTO
t2
SELECT
*
FROM
t1
;
SELECT
*
FROM
t2
STRAIGHT_JOIN
t1
IGNORE
INDEX
(
col_time_key
)
WHERE
col_time_key
=
col_datetime_key
;
SELECT
*
FROM
t2
STRAIGHT_JOIN
t1
FORCE
INDEX
(
col_time_key
)
WHERE
col_time_key
=
col_datetime_key
;
INSERT
INTO
t1
VALUES
(
'-838:59:59'
),(
'838:59:59'
);
INSERT
INTO
t2
VALUES
(
DATE_ADD
(
CURRENT_DATE
,
INTERVAL
'-838:59:59'
HOUR_SECOND
));
INSERT
INTO
t2
VALUES
(
DATE_ADD
(
CURRENT_DATE
,
INTERVAL
'838:59:59'
HOUR_SECOND
));
INSERT
INTO
t2
VALUES
(
DATE_ADD
(
CURRENT_DATE
,
INTERVAL
'-839:00:00'
HOUR_SECOND
));
INSERT
INTO
t2
VALUES
(
DATE_ADD
(
CURRENT_DATE
,
INTERVAL
'839:00:00'
HOUR_SECOND
));
SELECT
*
FROM
t2
STRAIGHT_JOIN
t1
IGNORE
INDEX
(
col_time_key
)
WHERE
col_time_key
=
col_datetime_key
;
SELECT
*
FROM
t2
STRAIGHT_JOIN
t1
FORCE
INDEX
(
col_time_key
)
WHERE
col_time_key
=
col_datetime_key
;
DROP
TABLE
t1
,
t2
;
SET
TIMESTAMP
=
DEFAULT
;
#
#
# End of 10.0 tests
# End of 10.0 tests
#
#
sql/field.cc
View file @
b0a92333
...
@@ -5330,6 +5330,13 @@ static void calc_datetime_days_diff(MYSQL_TIME *ltime, long days)
...
@@ -5330,6 +5330,13 @@ static void calc_datetime_days_diff(MYSQL_TIME *ltime, long days)
ltime
->
second
)
*
1000000LL
+
ltime
->
second
)
*
1000000LL
+
ltime
->
second_part
);
ltime
->
second_part
);
unpack_time
(
timediff
,
ltime
);
unpack_time
(
timediff
,
ltime
);
/*
unpack_time() broke down hours into ltime members hour,day,month.
Mix them back to ltime->hour using the same factors
that pack_time()/unpack_time() use (i.e. 32 for month).
*/
ltime
->
hour
+=
(
ltime
->
month
*
32
+
ltime
->
day
)
*
24
;
ltime
->
month
=
ltime
->
day
=
0
;
}
}
ltime
->
time_type
=
MYSQL_TIMESTAMP_TIME
;
ltime
->
time_type
=
MYSQL_TIMESTAMP_TIME
;
}
}
...
...
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