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
1a072883
Commit
1a072883
authored
Nov 06, 2009
by
Alexander Nozdrin
Browse files
Options
Browse Files
Download
Plain Diff
Auto-merge from mysql-trunk-merge.
parents
52b1bfe4
0b43c4e7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
7 deletions
+98
-7
mysql-test/r/innodb_mysql.result
mysql-test/r/innodb_mysql.result
+42
-0
mysql-test/t/innodb_mysql.test
mysql-test/t/innodb_mysql.test
+29
-0
sql/item.cc
sql/item.cc
+27
-7
No files found.
mysql-test/r/innodb_mysql.result
View file @
1a072883
...
...
@@ -2209,6 +2209,48 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 128 Using where
DROP TABLE t1;
#
# Bug #47963: Wrong results when index is used
#
CREATE TABLE t1(
a VARCHAR(5) NOT NULL,
b VARCHAR(5) NOT NULL,
c DATETIME NOT NULL,
KEY (c)
) ENGINE=InnoDB;
INSERT INTO t1 VALUES('TEST', 'TEST', '2009-10-09 00:00:00');
SELECT * FROM t1 WHERE a = 'TEST' AND
c >= '2009-10-09 00:00:00' AND c <= '2009-10-09 00:00:00';
a b c
TEST TEST 2009-10-09 00:00:00
SELECT * FROM t1 WHERE a = 'TEST' AND
c >= '2009-10-09 00:00:00.0' AND c <= '2009-10-09 00:00:00.0';
a b c
TEST TEST 2009-10-09 00:00:00
SELECT * FROM t1 WHERE a = 'TEST' AND
c >= '2009-10-09 00:00:00.0' AND c <= '2009-10-09 00:00:00';
a b c
TEST TEST 2009-10-09 00:00:00
SELECT * FROM t1 WHERE a = 'TEST' AND
c >= '2009-10-09 00:00:00' AND c <= '2009-10-09 00:00:00.0';
a b c
TEST TEST 2009-10-09 00:00:00
SELECT * FROM t1 WHERE a = 'TEST' AND
c >= '2009-10-09 00:00:00.000' AND c <= '2009-10-09 00:00:00.000';
a b c
TEST TEST 2009-10-09 00:00:00
SELECT * FROM t1 WHERE a = 'TEST' AND
c >= '2009-10-09 00:00:00.00' AND c <= '2009-10-09 00:00:00.001';
a b c
TEST TEST 2009-10-09 00:00:00
SELECT * FROM t1 WHERE a = 'TEST' AND
c >= '2009-10-09 00:00:00.001' AND c <= '2009-10-09 00:00:00.00';
a b c
EXPLAIN SELECT * FROM t1 WHERE a = 'TEST' AND
c >= '2009-10-09 00:00:00.001' AND c <= '2009-10-09 00:00:00.00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
DROP TABLE t1;
End of 5.1 tests
#
# Test for bug #39932 "create table fails if column for FK is in different
...
...
mysql-test/t/innodb_mysql.test
View file @
1a072883
...
...
@@ -461,6 +461,35 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a;
DROP
TABLE
t1
;
--
echo
#
--
echo
# Bug #47963: Wrong results when index is used
--
echo
#
CREATE
TABLE
t1
(
a
VARCHAR
(
5
)
NOT
NULL
,
b
VARCHAR
(
5
)
NOT
NULL
,
c
DATETIME
NOT
NULL
,
KEY
(
c
)
)
ENGINE
=
InnoDB
;
INSERT
INTO
t1
VALUES
(
'TEST'
,
'TEST'
,
'2009-10-09 00:00:00'
);
SELECT
*
FROM
t1
WHERE
a
=
'TEST'
AND
c
>=
'2009-10-09 00:00:00'
AND
c
<=
'2009-10-09 00:00:00'
;
SELECT
*
FROM
t1
WHERE
a
=
'TEST'
AND
c
>=
'2009-10-09 00:00:00.0'
AND
c
<=
'2009-10-09 00:00:00.0'
;
SELECT
*
FROM
t1
WHERE
a
=
'TEST'
AND
c
>=
'2009-10-09 00:00:00.0'
AND
c
<=
'2009-10-09 00:00:00'
;
SELECT
*
FROM
t1
WHERE
a
=
'TEST'
AND
c
>=
'2009-10-09 00:00:00'
AND
c
<=
'2009-10-09 00:00:00.0'
;
SELECT
*
FROM
t1
WHERE
a
=
'TEST'
AND
c
>=
'2009-10-09 00:00:00.000'
AND
c
<=
'2009-10-09 00:00:00.000'
;
SELECT
*
FROM
t1
WHERE
a
=
'TEST'
AND
c
>=
'2009-10-09 00:00:00.00'
AND
c
<=
'2009-10-09 00:00:00.001'
;
SELECT
*
FROM
t1
WHERE
a
=
'TEST'
AND
c
>=
'2009-10-09 00:00:00.001'
AND
c
<=
'2009-10-09 00:00:00.00'
;
EXPLAIN
SELECT
*
FROM
t1
WHERE
a
=
'TEST'
AND
c
>=
'2009-10-09 00:00:00.001'
AND
c
<=
'2009-10-09 00:00:00.00'
;
DROP
TABLE
t1
;
--
echo
End
of
5.1
tests
...
...
sql/item.cc
View file @
1a072883
...
...
@@ -7064,17 +7064,37 @@ int stored_field_cmp_to_item(Field *field, Item *item)
/*
If comparing DATE with DATETIME, append the time-part to the DATE.
So that the strings are equally formatted.
A DATE converted to string is 10
characters, and a DATETIME converted
to string is 19
characters.
A DATE converted to string is 10
(MAX_DATE_WIDTH) characters,
and a DATETIME converted to string is 19 (MAX_DATETIME_WIDTH)
characters.
*/
field_type
=
field
->
type
();
uint32
item_length
=
item_result
->
length
();
if
(
field_type
==
MYSQL_TYPE_DATE
&&
item_
result
->
length
()
==
19
)
item_
length
==
MAX_DATETIME_WIDTH
)
field_tmp
.
append
(
" 00:00:00"
);
else
if
(
field_type
==
MYSQL_TYPE_DATETIME
&&
item_result
->
length
()
==
10
)
item_result
->
append
(
" 00:00:00"
);
else
if
(
field_type
==
MYSQL_TYPE_DATETIME
)
{
if
(
item_length
==
MAX_DATE_WIDTH
)
item_result
->
append
(
" 00:00:00"
);
else
if
(
item_length
>
MAX_DATETIME_WIDTH
)
{
/*
We don't store microsecond part of DATETIME in field
but item_result contains it. As we compare DATETIMEs as strings
we must trim trailing 0's in item_result's microsecond part
to ensure "YYYY-MM-DD HH:MM:SS" == "YYYY-MM-DD HH:MM:SS.0000"
*/
char
*
end
=
(
char
*
)
item_result
->
ptr
()
+
item_length
-
1
;
/* Trim trailing 0's */
while
(
*
end
==
'0'
)
end
--
;
/* Trim '.' if no microseconds */
if
(
*
end
==
'.'
)
end
--
;
DBUG_ASSERT
(
end
-
item_result
->
ptr
()
+
1
>=
MAX_DATETIME_WIDTH
);
item_result
->
length
(
end
-
item_result
->
ptr
()
+
1
);
}
}
return
stringcmp
(
&
field_tmp
,
item_result
);
}
if
(
res_type
==
INT_RESULT
)
...
...
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