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
57bcc70f
Commit
57bcc70f
authored
Apr 25, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-12582 Wrong data type for CREATE..SELECT MAX(COALESCE(timestamp_column))
parent
6cc40856
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
38 deletions
+38
-38
mysql-test/r/type_timestamp.result
mysql-test/r/type_timestamp.result
+20
-0
mysql-test/t/type_timestamp.test
mysql-test/t/type_timestamp.test
+16
-0
sql/item_sum.cc
sql/item_sum.cc
+2
-38
No files found.
mysql-test/r/type_timestamp.result
View file @
57bcc70f
...
...
@@ -992,5 +992,25 @@ a b
DROP TABLE t1;
SET @@timestamp=DEFAULT;
#
# MDEV-12582 Wrong data type for CREATE..SELECT MAX(COALESCE(timestamp_column))
#
CREATE TABLE t1 (a TIMESTAMP);
CREATE TABLE t2 AS SELECT
MAX(a),
COALESCE(a),
COALESCE(MAX(a)),
MAX(COALESCE(a))
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`MAX(a)` timestamp NULL DEFAULT NULL,
`COALESCE(a)` timestamp NULL DEFAULT NULL,
`COALESCE(MAX(a))` timestamp NULL DEFAULT NULL,
`MAX(COALESCE(a))` timestamp NULL DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
DROP TABLE t1;
#
# End of 10.3 tests
#
mysql-test/t/type_timestamp.test
View file @
57bcc70f
...
...
@@ -587,6 +587,22 @@ SELECT * FROM t1 WHERE TIME'10:20:30' BETWEEN a and b;
DROP
TABLE
t1
;
SET
@@
timestamp
=
DEFAULT
;
--
echo
#
--
echo
# MDEV-12582 Wrong data type for CREATE..SELECT MAX(COALESCE(timestamp_column))
--
echo
#
CREATE
TABLE
t1
(
a
TIMESTAMP
);
CREATE
TABLE
t2
AS
SELECT
MAX
(
a
),
COALESCE
(
a
),
COALESCE
(
MAX
(
a
)),
MAX
(
COALESCE
(
a
))
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of 10.3 tests
--
echo
#
sql/item_sum.cc
View file @
57bcc70f
...
...
@@ -1202,51 +1202,15 @@ void Item_sum_hybrid::setup_hybrid(THD *thd, Item *item, Item *value_arg)
Field
*
Item_sum_hybrid
::
create_tmp_field
(
bool
group
,
TABLE
*
table
)
{
Field
*
field
;
MEM_ROOT
*
mem_root
;
if
(
args
[
0
]
->
type
()
==
Item
::
FIELD_ITEM
)
{
field
=
((
Item_field
*
)
args
[
0
])
->
field
;
Field
*
field
=
((
Item_field
*
)
args
[
0
])
->
field
;
if
((
field
=
create_tmp_field_from_field
(
table
->
in_use
,
field
,
&
name
,
table
,
NULL
)))
field
->
flags
&=
~
NOT_NULL_FLAG
;
return
field
;
}
/*
DATE/TIME fields have STRING_RESULT result types.
In order to preserve field type, it's needed to handle DATE/TIME
fields creations separately.
*/
mem_root
=
table
->
in_use
->
mem_root
;
switch
(
args
[
0
]
->
field_type
())
{
case
MYSQL_TYPE_DATE
:
{
field
=
new
(
mem_root
)
Field_newdate
(
0
,
maybe_null
?
(
uchar
*
)
""
:
0
,
0
,
Field
::
NONE
,
&
name
);
break
;
}
case
MYSQL_TYPE_TIME
:
{
field
=
new_Field_time
(
mem_root
,
0
,
maybe_null
?
(
uchar
*
)
""
:
0
,
0
,
Field
::
NONE
,
&
name
,
decimals
);
break
;
}
case
MYSQL_TYPE_TIMESTAMP
:
case
MYSQL_TYPE_DATETIME
:
{
field
=
new_Field_datetime
(
mem_root
,
0
,
maybe_null
?
(
uchar
*
)
""
:
0
,
0
,
Field
::
NONE
,
&
name
,
decimals
);
break
;
}
default:
return
Item_sum
::
create_tmp_field
(
group
,
table
);
}
if
(
field
)
field
->
init
(
table
);
return
field
;
return
Item_sum
::
create_tmp_field
(
group
,
table
);
}
...
...
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