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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
8f13b541
Commit
8f13b541
authored
Dec 01, 2007
by
kaa@polly.(none)
Browse files
Options
Browse Files
Download
Plain Diff
Merge polly.(none):/home/kaa/src/maint/bug26788/my51-bug26788
into polly.(none):/home/kaa/src/maint/mysql-5.1-maint
parents
b44d7923
109c0439
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
262 additions
and
24 deletions
+262
-24
mysql-test/r/insert.result
mysql-test/r/insert.result
+120
-0
mysql-test/t/cast.test
mysql-test/t/cast.test
+0
-2
mysql-test/t/insert.test
mysql-test/t/insert.test
+81
-0
mysql-test/t/type_float.test
mysql-test/t/type_float.test
+0
-5
mysql-test/t/variables.test
mysql-test/t/variables.test
+0
-2
sql/field.cc
sql/field.cc
+61
-15
No files found.
mysql-test/r/insert.result
View file @
8f13b541
...
...
@@ -499,6 +499,126 @@ i
2
2
DROP TABLE t1, t2;
CREATE TABLE t1 (
a char(20) NOT NULL,
b char(7) DEFAULT NULL,
c char(4) DEFAULT NULL
);
INSERT INTO t1(a,b,c) VALUES (9.999999e+0, 9.999999e+0, 9.999e+0);
INSERT INTO t1(a,b,c) VALUES (1.225e-05, 1.225e-05, 1.225e-05);
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t1(a,b) VALUES (1.225e-04, 1.225e-04);
INSERT INTO t1(a,b) VALUES (1.225e-01, 1.225e-01);
INSERT INTO t1(a,b) VALUES (1.225877e-01, 1.225877e-01);
INSERT INTO t1(a,b) VALUES (1.225e+01, 1.225e+01);
INSERT INTO t1(a,b,c) VALUES (1.225e+01, 1.225e+01, 1.225e+01);
INSERT INTO t1(a,b) VALUES (1.225e+05, 1.225e+05);
INSERT INTO t1(a,b) VALUES (1.225e+10, 1.225e+10);
INSERT INTO t1(a,b) VALUES (1.225e+15, 1.225e+15);
INSERT INTO t1(a,b) VALUES (5000000e+0, 5000000e+0);
INSERT INTO t1(a,b) VALUES (1.25e+78, 1.25e+78);
INSERT INTO t1(a,b) VALUES (1.25e-94, 1.25e-94);
INSERT INTO t1(a,b) VALUES (1.25e+203, 1.25e+203);
INSERT INTO t1(a,b) VALUES (1.25e-175, 1.25e-175);
INSERT INTO t1(a,c) VALUES (1.225e+0, 1.225e+0);
INSERT INTO t1(a,c) VALUES (1.37e+0, 1.37e+0);
INSERT INTO t1(a,c) VALUES (-1.37e+0, -1.37e+0);
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
SELECT * FROM t1;
a b c
9.999999000000000748 10 10
1.225e-05 1.2e-05 1e-0
0.0001225 0.00012 NULL
0.122499999999999998 0.1225 NULL
0.122587699999999994 0.12259 NULL
12.25 12.25 NULL
12.25 12.25 12.2
122500 122500 NULL
12250000000 1.2e+10 NULL
1225000000000000 1.2e+15 NULL
5000000 5000000 NULL
1.25e+78 1.2e+78 NULL
1.25e-94 1.2e-94 NULL
1.25e+203 1e+203 NULL
1.25e-175 1e-175 NULL
1.225000000000000089 NULL 1.23
1.370000000000000107 NULL 1.37
-1.37 NULL -1.3
0.00187 NULL 0.00
-0.0187 NULL -0.0
5000 NULL 5000
-5000 NULL -500
DROP TABLE t1;
CREATE TABLE t1 (
a char(20) NOT NULL,
b char(7) DEFAULT NULL,
c char(5)
);
INSERT INTO t1(a,b,c) VALUES (9.999999e+0, 9.999999e+0, 9.999e+0);
INSERT INTO t1(a,b,c) VALUES (1.225e-05, 1.225e-05, 1.225e-05);
INSERT INTO t1(a,b) VALUES (1.225e-04, 1.225e-04);
INSERT INTO t1(a,b) VALUES (1.225e-01, 1.225e-01);
INSERT INTO t1(a,b) VALUES (1.225877e-01, 1.225877e-01);
INSERT INTO t1(a,b) VALUES (1.225e+01, 1.225e+01);
INSERT INTO t1(a,b,c) VALUES (1.225e+01, 1.225e+01, 1.225e+01);
INSERT INTO t1(a,b) VALUES (1.225e+05, 1.225e+05);
INSERT INTO t1(a,b) VALUES (1.225e+10, 1.225e+10);
INSERT INTO t1(a,b) VALUES (1.225e+15, 1.225e+15);
INSERT INTO t1(a,b) VALUES (5000000e+0, 5000000e+0);
INSERT INTO t1(a,b) VALUES (1.25e+78, 1.25e+78);
INSERT INTO t1(a,b) VALUES (1.25e-94, 1.25e-94);
INSERT INTO t1(a,b) VALUES (1.25e+203, 1.25e+203);
INSERT INTO t1(a,b) VALUES (1.25e-175, 1.25e-175);
INSERT INTO t1(a,c) VALUES (1.225e+0, 1.225e+0);
INSERT INTO t1(a,c) VALUES (1.37e+0, 1.37e+0);
INSERT INTO t1(a,c) VALUES (-1.37e+0, -1.37e+0);
INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
SELECT * FROM t1;
a b c
9.999999000000000748 10 9.999
1.225e-05 1.2e-05 1e-05
0.0001225 0.00012 NULL
0.122499999999999998 0.1225 NULL
0.122587699999999994 0.12259 NULL
12.25 12.25 NULL
12.25 12.25 12.25
122500 122500 NULL
12250000000 1.2e+10 NULL
1225000000000000 1.2e+15 NULL
5000000 5000000 NULL
1.25e+78 1.2e+78 NULL
1.25e-94 1.2e-94 NULL
1.25e+203 1e+203 NULL
1.25e-175 1e-175 NULL
1.225000000000000089 NULL 1.225
1.370000000000000107 NULL 1.37
-1.37 NULL -1.37
0.00187 NULL 0.002
-0.0187 NULL -0.01
5000 NULL 5000
-5000 NULL -5000
DROP TABLE t1;
CREATE TABLE t (a CHAR(10),b INT);
INSERT INTO t VALUES (),(),();
INSERT INTO t(a) SELECT rand() FROM t;
DROP TABLE t;
CREATE TABLE t1 (c1 INT NOT NULL);
INSERT INTO t1 VALUES(4188.32999999999992724042385816574096679687500),
('4188.32999999999992724042385816574096679687500'), (4188);
...
...
mysql-test/t/cast.test
View file @
8f13b541
...
...
@@ -177,8 +177,6 @@ select cast(1.0e+300 as signed int);
CREATE
TABLE
t1
(
f1
double
);
INSERT
INTO
t1
SET
f1
=
-
1.0e+30
;
INSERT
INTO
t1
SET
f1
=
+
1.0e+30
;
# Expected result is +-1e+30, but Windows returns +-1e+030.
--
replace_result
1
e
+
030
1
e
+
30
SELECT
f1
AS
double_val
,
CAST
(
f1
AS
SIGNED
INT
)
AS
cast_val
FROM
t1
;
DROP
TABLE
t1
;
...
...
mysql-test/t/insert.test
View file @
8f13b541
...
...
@@ -387,6 +387,87 @@ SELECT * FROM t2;
DROP
TABLE
t1
,
t2
;
#
# Bug #26788: mysqld (debug) aborts when inserting specific numbers into char
# fields
#
CREATE
TABLE
t1
(
a
char
(
20
)
NOT
NULL
,
b
char
(
7
)
DEFAULT
NULL
,
c
char
(
4
)
DEFAULT
NULL
);
INSERT
INTO
t1
(
a
,
b
,
c
)
VALUES
(
9.999999e+0
,
9.999999e+0
,
9.999e+0
);
INSERT
INTO
t1
(
a
,
b
,
c
)
VALUES
(
1.225e-05
,
1.225e-05
,
1.225e-05
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e-04
,
1.225e-04
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e-01
,
1.225e-01
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225877e-01
,
1.225877e-01
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e+01
,
1.225e+01
);
INSERT
INTO
t1
(
a
,
b
,
c
)
VALUES
(
1.225e+01
,
1.225e+01
,
1.225e+01
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e+05
,
1.225e+05
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e+10
,
1.225e+10
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e+15
,
1.225e+15
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
5000000
e
+
0
,
5000000
e
+
0
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.25e+78
,
1.25e+78
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.25e-94
,
1.25e-94
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.25e+203
,
1.25e+203
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.25e-175
,
1.25e-175
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
1.225e+0
,
1.225e+0
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
1.37e+0
,
1.37e+0
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
-
1.37e+0
,
-
1.37e+0
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
1.87e-3
,
1.87e-3
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
-
1.87e-2
,
-
1.87e-2
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
5000
e
+
0
,
5000
e
+
0
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
-
5000
e
+
0
,
-
5000
e
+
0
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
char
(
20
)
NOT
NULL
,
b
char
(
7
)
DEFAULT
NULL
,
c
char
(
5
)
);
INSERT
INTO
t1
(
a
,
b
,
c
)
VALUES
(
9.999999e+0
,
9.999999e+0
,
9.999e+0
);
INSERT
INTO
t1
(
a
,
b
,
c
)
VALUES
(
1.225e-05
,
1.225e-05
,
1.225e-05
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e-04
,
1.225e-04
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e-01
,
1.225e-01
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225877e-01
,
1.225877e-01
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e+01
,
1.225e+01
);
INSERT
INTO
t1
(
a
,
b
,
c
)
VALUES
(
1.225e+01
,
1.225e+01
,
1.225e+01
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e+05
,
1.225e+05
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e+10
,
1.225e+10
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.225e+15
,
1.225e+15
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
5000000
e
+
0
,
5000000
e
+
0
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.25e+78
,
1.25e+78
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.25e-94
,
1.25e-94
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.25e+203
,
1.25e+203
);
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1.25e-175
,
1.25e-175
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
1.225e+0
,
1.225e+0
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
1.37e+0
,
1.37e+0
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
-
1.37e+0
,
-
1.37e+0
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
1.87e-3
,
1.87e-3
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
-
1.87e-2
,
-
1.87e-2
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
5000
e
+
0
,
5000
e
+
0
);
INSERT
INTO
t1
(
a
,
c
)
VALUES
(
-
5000
e
+
0
,
-
5000
e
+
0
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
#
# Bug #31152: assertion in Field_str::store(double)
#
CREATE
TABLE
t
(
a
CHAR
(
10
),
b
INT
);
INSERT
INTO
t
VALUES
(),(),();
INSERT
INTO
t
(
a
)
SELECT
rand
()
FROM
t
;
DROP
TABLE
t
;
#
# Bug #30453: String not cast to int correctly
#
...
...
mysql-test/t/type_float.test
View file @
8f13b541
...
...
@@ -116,15 +116,10 @@ drop table if exists t1;
# Check conversion of floats to character field (Bug #7774)
create
table
t1
(
c
char
(
20
));
insert
into
t1
values
(
5
e
-
28
);
# Expected result is "5e-28", but windows returns "5e-028"
--
replace_result
5
e
-
02
8
5
e
-
28
select
*
from
t1
;
drop
table
t1
;
create
table
t1
(
c
char
(
6
));
insert
into
t1
values
(
2
e5
),(
2
e6
),(
2
e
-
4
),(
2
e
-
5
);
# Expected result is "2e+06", but windows returns "2e+006"
# Expected result is "2e-05", but windows returns "2e-005"
--
replace_result
2
e
+
006
2
e
+
06
2
e
-
005
2
e
-
05
select
*
from
t1
;
drop
table
t1
;
...
...
mysql-test/t/variables.test
View file @
8f13b541
...
...
@@ -50,8 +50,6 @@ select @test, @`test`, @TEST, @`TEST`, @"teSt";
set
@
select
=
2
,
@
t5
=
1.23456
;
select
@
`select`
,
@
not_used
;
set
@
test_int
=
10
,
@
test_double
=
1
e
-
10
,
@
test_string
=
"abcdeghi"
,
@
test_string2
=
"abcdefghij"
,
@
select
=
NULL
;
# Expected result "1e-10", windows returns "1e-010"
--
replace_result
1
e
-
010
1
e
-
10
select
@
test_int
,
@
test_double
,
@
test_string
,
@
test_string2
,
@
select
;
set
@
test_int
=
"hello"
,
@
test_double
=
"hello"
,
@
test_string
=
"hello"
,
@
test_string2
=
"hello"
;
select
@
test_int
,
@
test_double
,
@
test_string
,
@
test_string2
;
...
...
sql/field.cc
View file @
8f13b541
...
...
@@ -6259,24 +6259,70 @@ int Field_str::store(double nr)
ASSERT_COLUMN_MARKED_FOR_WRITE
;
char
buff
[
DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE
];
uint
length
;
bool
use_scientific_notation
=
TRUE
;
uint
local_char_length
=
field_length
/
charset
()
->
mbmaxlen
;
/*
Check fabs(nr) against longest value that can be stored in field,
which depends on whether the value is < 1 or not, and negative or not
*/
double
anr
=
fabs
(
nr
);
int
neg
=
(
nr
<
0.0
)
?
1
:
0
;
if
(
local_char_length
>
4
&&
local_char_length
<
32
&&
(
anr
<
1.0
?
anr
>
1
/
(
log_10
[
max
(
0
,(
int
)
local_char_length
-
neg
-
2
)])
/* -2 for "0." */
:
anr
<
log_10
[
local_char_length
-
neg
]
-
1
))
use_scientific_notation
=
FALSE
;
length
=
(
uint
)
my_sprintf
(
buff
,
(
buff
,
"%-.*g"
,
(
use_scientific_notation
?
max
(
0
,
(
int
)
local_char_length
-
neg
-
5
)
:
local_char_length
),
nr
));
uint
max_length
;
int
exp
;
uint
digits
;
uint
i
;
/* Calculate the exponent from the 'e'-format conversion */
if
(
anr
<
1.0
&&
anr
>
0
)
{
for
(
exp
=
0
;
anr
<
1e-100
;
exp
-=
100
,
anr
*=
1e100
);
for
(;
anr
<
1e-10
;
exp
-=
10
,
anr
*=
1e10
);
for
(
i
=
1
;
anr
<
1
/
log_10
[
i
];
exp
--
,
i
++
);
exp
--
;
}
else
{
for
(
exp
=
0
;
anr
>
1e100
;
exp
+=
100
,
anr
/=
1e100
);
for
(;
anr
>
1e10
;
exp
+=
10
,
anr
/=
1e10
);
for
(
i
=
1
;
anr
>
log_10
[
i
];
exp
++
,
i
++
);
}
max_length
=
local_char_length
-
neg
;
/*
Since in sprintf("%g") precision means the number of significant digits,
calculate the maximum number of significant digits if the 'f'-format
would be used (+1 for decimal point if the number has a fractional part).
*/
digits
=
max
(
0
,
(
int
)
max_length
-
(
nr
!=
trunc
(
nr
)));
/*
If the exponent is negative, decrease digits by the number of leading zeros
after the decimal point that do not count as significant digits.
*/
if
(
exp
<
0
)
digits
=
max
(
0
,
(
int
)
digits
+
exp
);
/*
'e'-format is used only if the exponent is less than -4 or greater than or
equal to the precision. In this case we need to adjust the number of
significant digits to take "e+NN" + decimal point into account (hence -5).
We also have to reserve one additional character if abs(exp) >= 100.
*/
if
(
exp
>=
(
int
)
digits
||
exp
<
-
4
)
digits
=
max
(
0
,
(
int
)
(
max_length
-
5
-
(
exp
>=
100
||
exp
<=
-
100
)));
length
=
(
uint
)
my_sprintf
(
buff
,
(
buff
,
"%-.*g"
,
digits
,
nr
));
#ifdef __WIN__
/*
Windows always zero-pads the exponent to 3 digits, we want to remove the
leading 0 to match the sprintf() output on other platforms.
*/
if
((
exp
>=
(
int
)
digits
||
exp
<
-
4
)
&&
exp
>
-
100
&&
exp
<
100
)
{
DBUG_ASSERT
(
length
>=
6
);
/* 1e+NNN */
uint
tmp
=
length
-
3
;
buff
[
tmp
]
=
buff
[
tmp
+
1
];
tmp
++
;
buff
[
tmp
]
=
buff
[
tmp
+
1
];
length
--
;
}
#endif
/*
+1 below is because "precision" in %g above means the
max. number of significant digits, not the output width.
...
...
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