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
ee6ac4d3
Commit
ee6ac4d3
authored
Jun 25, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-12574 MAX(old_decimal) produces a column of the old DECIMAL type
parent
01bbb912
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
9 deletions
+77
-9
mysql-test/r/type_decimal.result
mysql-test/r/type_decimal.result
+25
-0
mysql-test/t/type_decimal.test
mysql-test/t/type_decimal.test
+21
-0
sql/field.cc
sql/field.cc
+18
-9
sql/field.h
sql/field.h
+13
-0
No files found.
mysql-test/r/type_decimal.result
View file @
ee6ac4d3
...
...
@@ -1033,5 +1033,30 @@ c1 c2
0.123456 0.123456
SET sql_mode=DEFAULT;
#
# MDEV-12574 MAX(old_decimal) produces a column of the old DECIMAL type
#
SHOW CREATE TABLE t1dec102;
Table Create Table
t1dec102 CREATE TABLE `t1dec102` (
`a` decimal(10,2)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
CREATE TABLE t1 AS SELECT a, MAX(a), COALESCE(a) FROM t1dec102;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2) DEFAULT NULL,
`MAX(a)` decimal(10,2) DEFAULT NULL,
`COALESCE(a)` decimal(12,2) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 AS SELECT a FROM t1dec102 UNION SELECT a FROM t1dec102;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(12,2) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP TABLE t1dec102;
#
# End of 10.2 tests
#
mysql-test/t/type_decimal.test
View file @
ee6ac4d3
...
...
@@ -627,6 +627,27 @@ SELECT
CAST
(
TIME
'00:00:00.123456'
AS
DECIMAL
(
10
,
6
))
AS
c2
;
SET
sql_mode
=
DEFAULT
;
--
echo
#
--
echo
# MDEV-12574 MAX(old_decimal) produces a column of the old DECIMAL type
--
echo
#
let
$MYSQLD_DATADIR
=
`select @@datadir`
;
--
copy_file
std_data
/
old_decimal
/
t1dec102
.
frm
$MYSQLD_DATADIR
/
test
/
t1dec102
.
frm
--
copy_file
std_data
/
old_decimal
/
t1dec102
.
MYD
$MYSQLD_DATADIR
/
test
/
t1dec102
.
MYD
--
copy_file
std_data
/
old_decimal
/
t1dec102
.
MYI
$MYSQLD_DATADIR
/
test
/
t1dec102
.
MYI
SHOW
CREATE
TABLE
t1dec102
;
CREATE
TABLE
t1
AS
SELECT
a
,
MAX
(
a
),
COALESCE
(
a
)
FROM
t1dec102
;
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
AS
SELECT
a
FROM
t1dec102
UNION
SELECT
a
FROM
t1dec102
;
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
DROP
TABLE
t1dec102
;
--
echo
#
--
echo
# End of 10.2 tests
--
echo
#
sql/field.cc
View file @
ee6ac4d3
...
...
@@ -2973,6 +2973,23 @@ void Field_decimal::sql_type(String &res) const
}
Field
*
Field_decimal
::
make_new_field
(
MEM_ROOT
*
root
,
TABLE
*
new_table
,
bool
keep_type
)
{
if
(
keep_type
)
return
Field_real
::
make_new_field
(
root
,
new_table
,
keep_type
);
Field
*
field
=
new
(
root
)
Field_new_decimal
(
NULL
,
field_length
,
maybe_null
()
?
(
uchar
*
)
""
:
0
,
0
,
NONE
,
field_name
,
dec
,
flags
&
ZEROFILL_FLAG
,
unsigned_flag
);
if
(
field
)
field
->
init_for_make_new_field
(
new_table
,
orig_table
);
return
field
;
}
/****************************************************************************
** Field_new_decimal
****************************************************************************/
...
...
@@ -7439,15 +7456,7 @@ Field *Field_string::make_new_field(MEM_ROOT *root, TABLE *new_table,
This is done to ensure that ALTER TABLE will convert old VARCHAR fields
to now VARCHAR fields.
*/
field
->
init
(
new_table
);
/*
Normally orig_table is different from table only if field was
created via ::make_new_field. Here we alter the type of field,
so ::make_new_field is not applicable. But we still need to
preserve the original field metadata for the client-server
protocol.
*/
field
->
orig_table
=
orig_table
;
field
->
init_for_make_new_field
(
new_table
,
orig_table
);
}
return
field
;
}
...
...
sql/field.h
View file @
ee6ac4d3
...
...
@@ -1368,6 +1368,18 @@ class Field: public Value_source
orig_table
=
table
=
table_arg
;
set_table_name
(
&
table_arg
->
alias
);
}
void
init_for_make_new_field
(
TABLE
*
new_table_arg
,
TABLE
*
orig_table_arg
)
{
init
(
new_table_arg
);
/*
Normally orig_table is different from table only if field was
created via ::make_new_field. Here we alter the type of field,
so ::make_new_field is not applicable. But we still need to
preserve the original field metadata for the client-server
protocol.
*/
orig_table
=
orig_table_arg
;
}
/* maximum possible display length */
virtual
uint32
max_display_length
()
=
0
;
...
...
@@ -1828,6 +1840,7 @@ class Field_decimal :public Field_real {
unireg_check_arg
,
field_name_arg
,
dec_arg
,
zero_arg
,
unsigned_arg
)
{}
Field
*
make_new_field
(
MEM_ROOT
*
root
,
TABLE
*
new_table
,
bool
keep_type
);
enum_field_types
type
()
const
{
return
MYSQL_TYPE_DECIMAL
;}
enum
ha_base_keytype
key_type
()
const
{
return
zerofill
?
HA_KEYTYPE_BINARY
:
HA_KEYTYPE_NUM
;
}
...
...
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