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
45753263
Commit
45753263
authored
Mar 27, 2009
by
Staale Smedseng
Browse files
Options
Browse Files
Download
Plain Diff
Merge from 5.1-bugteam
parents
70fdfcb6
7b006908
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
14 deletions
+54
-14
mysql-test/r/union.result
mysql-test/r/union.result
+12
-0
mysql-test/t/union.test
mysql-test/t/union.test
+15
-0
sql/field.cc
sql/field.cc
+3
-3
sql/item.cc
sql/item.cc
+19
-11
sql/mysql_priv.h
sql/mysql_priv.h
+5
-0
No files found.
mysql-test/r/union.result
View file @
45753263
...
@@ -1562,4 +1562,16 @@ DESC t6;
...
@@ -1562,4 +1562,16 @@ DESC t6;
Field Type Null Key Default Extra
Field Type Null Key Default Extra
NULL int(11) YES NULL
NULL int(11) YES NULL
DROP TABLE t1, t2, t3, t4, t5, t6;
DROP TABLE t1, t2, t3, t4, t5, t6;
CREATE TABLE t1 (f FLOAT(9,6));
CREATE TABLE t2 AS SELECT f FROM t1 UNION SELECT f FROM t1;
SHOW FIELDS FROM t2;
Field Type Null Key Default Extra
f float(9,6) YES NULL
DROP TABLE t1, t2;
CREATE TABLE t1(d DOUBLE(9,6));
CREATE TABLE t2 AS SELECT d FROM t1 UNION SELECT d FROM t1;
SHOW FIELDS FROM t2;
Field Type Null Key Default Extra
d double(9,6) YES NULL
DROP TABLE t1, t2;
End of 5.0 tests
End of 5.0 tests
mysql-test/t/union.test
View file @
45753263
...
@@ -1074,4 +1074,19 @@ SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1;
...
@@ -1074,4 +1074,19 @@ SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1;
DESC
t6
;
DESC
t6
;
DROP
TABLE
t1
,
t2
,
t3
,
t4
,
t5
,
t6
;
DROP
TABLE
t1
,
t2
,
t3
,
t4
,
t5
,
t6
;
#
# Bug #43432: Union on floats does unnecessary rounding
#
CREATE
TABLE
t1
(
f
FLOAT
(
9
,
6
));
CREATE
TABLE
t2
AS
SELECT
f
FROM
t1
UNION
SELECT
f
FROM
t1
;
SHOW
FIELDS
FROM
t2
;
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
t1
(
d
DOUBLE
(
9
,
6
));
CREATE
TABLE
t2
AS
SELECT
d
FROM
t1
UNION
SELECT
d
FROM
t1
;
SHOW
FIELDS
FROM
t2
;
DROP
TABLE
t1
,
t2
;
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
sql/field.cc
View file @
45753263
...
@@ -9685,16 +9685,16 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
...
@@ -9685,16 +9685,16 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
else
if
(
tmp_length
>
PRECISION_FOR_FLOAT
)
else
if
(
tmp_length
>
PRECISION_FOR_FLOAT
)
{
{
sql_type
=
MYSQL_TYPE_DOUBLE
;
sql_type
=
MYSQL_TYPE_DOUBLE
;
length
=
DBL_DIG
+
7
;
/* -[digits].E+### */
length
=
MAX_DOUBLE_STR_LENGTH
;
}
}
else
else
length
=
FLT_DIG
+
6
;
/* -[digits].E+## */
length
=
MAX_FLOAT_STR_LENGTH
;
decimals
=
NOT_FIXED_DEC
;
decimals
=
NOT_FIXED_DEC
;
break
;
break
;
}
}
if
(
!
fld_length
&&
!
fld_decimals
)
if
(
!
fld_length
&&
!
fld_decimals
)
{
{
length
=
FLT_DIG
+
6
;
length
=
MAX_FLOAT_STR_LENGTH
;
decimals
=
NOT_FIXED_DEC
;
decimals
=
NOT_FIXED_DEC
;
}
}
if
(
length
<
decimals
&&
if
(
length
<
decimals
&&
...
...
sql/item.cc
View file @
45753263
...
@@ -7124,21 +7124,29 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
...
@@ -7124,21 +7124,29 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
case
REAL_RESULT
:
case
REAL_RESULT
:
{
{
if
(
decimals
!=
NOT_FIXED_DEC
)
if
(
decimals
!=
NOT_FIXED_DEC
)
{
/*
For FLOAT(M,D)/DOUBLE(M,D) do not change precision
if both fields have the same M and D
*/
if
(
item
->
max_length
!=
max_length_orig
||
item
->
decimals
!=
decimals_orig
)
{
{
int
delta1
=
max_length_orig
-
decimals_orig
;
int
delta1
=
max_length_orig
-
decimals_orig
;
int
delta2
=
item
->
max_length
-
item
->
decimals
;
int
delta2
=
item
->
max_length
-
item
->
decimals
;
max_length
=
max
(
delta1
,
delta2
)
+
decimals
;
max_length
=
max
(
delta1
,
delta2
)
+
decimals
;
if
(
fld_type
==
MYSQL_TYPE_FLOAT
&&
max_length
>
FLT_DIG
+
2
)
if
(
fld_type
==
MYSQL_TYPE_FLOAT
&&
max_length
>
FLT_DIG
+
2
)
{
{
max_length
=
FLT_DIG
+
6
;
max_length
=
MAX_FLOAT_STR_LENGTH
;
decimals
=
NOT_FIXED_DEC
;
decimals
=
NOT_FIXED_DEC
;
}
}
if
(
fld_type
==
MYSQL_TYPE_DOUBLE
&&
max_length
>
DBL_DIG
+
2
)
else
if
(
fld_type
==
MYSQL_TYPE_DOUBLE
&&
max_length
>
DBL_DIG
+
2
)
{
{
max_length
=
DBL_DIG
+
7
;
max_length
=
MAX_DOUBLE_STR_LENGTH
;
decimals
=
NOT_FIXED_DEC
;
decimals
=
NOT_FIXED_DEC
;
}
}
}
}
}
else
else
max_length
=
(
fld_type
==
MYSQL_TYPE_FLOAT
)
?
FLT_DIG
+
6
:
DBL_DIG
+
7
;
max_length
=
(
fld_type
==
MYSQL_TYPE_FLOAT
)
?
FLT_DIG
+
6
:
DBL_DIG
+
7
;
break
;
break
;
...
...
sql/mysql_priv.h
View file @
45753263
...
@@ -363,6 +363,11 @@ class Default_object_creation_ctx : public Object_creation_ctx
...
@@ -363,6 +363,11 @@ class Default_object_creation_ctx : public Object_creation_ctx
#define PRECISION_FOR_DOUBLE 53
#define PRECISION_FOR_DOUBLE 53
#define PRECISION_FOR_FLOAT 24
#define PRECISION_FOR_FLOAT 24
/* -[digits].E+## */
#define MAX_FLOAT_STR_LENGTH (FLT_DIG + 6)
/* -[digits].E+### */
#define MAX_DOUBLE_STR_LENGTH (DBL_DIG + 7)
/*
/*
Default time to wait before aborting a new client connection
Default time to wait before aborting a new client connection
that does not respond to "initial server greeting" timely
that does not respond to "initial server greeting" timely
...
...
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