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
930f711b
Commit
930f711b
authored
Jul 08, 2007
by
gshchepa/uchum@gleb.loc
Browse files
Options
Browse Files
Download
Plain Diff
Merge gshchepa@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into gleb.loc:/home/uchum/work/bk/5.1-opt
parents
cb86f26d
4d8e0fb5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
0 deletions
+75
-0
mysql-test/r/type_newdecimal.result
mysql-test/r/type_newdecimal.result
+28
-0
mysql-test/t/type_newdecimal.test
mysql-test/t/type_newdecimal.test
+33
-0
sql/field.cc
sql/field.cc
+2
-0
sql/item_create.cc
sql/item_create.cc
+12
-0
No files found.
mysql-test/r/type_newdecimal.result
View file @
930f711b
...
@@ -1481,6 +1481,34 @@ drop table t1;
...
@@ -1481,6 +1481,34 @@ drop table t1;
SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b;
SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b;
a b
a b
0.9999999999999800000000000000 0.9999999999999800000000000000
0.9999999999999800000000000000 0.9999999999999800000000000000
SELECT CAST(1 AS decimal(65,10));
CAST(1 AS decimal(65,10))
1.0000000000
SELECT CAST(1 AS decimal(66,10));
ERROR 42000: Too big precision 66 specified for column '1'. Maximum is 65.
SELECT CAST(1 AS decimal(65,30));
CAST(1 AS decimal(65,30))
1.000000000000000000000000000000
SELECT CAST(1 AS decimal(65,31));
ERROR 42000: Too big scale 31 specified for column '1'. Maximum is 30.
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
SELECT a+CAST(1 AS decimal(65,30)) AS aa, SUM(b) FROM t1 GROUP BY aa;
aa SUM(b)
2.000000000000000000000000000000 10
3.000000000000000000000000000000 10
4.000000000000000000000000000000 30
SELECT a+CAST(1 AS decimal(65,31)) AS aa, SUM(b) FROM t1 GROUP BY aa;
ERROR 42000: Too big scale 31 specified for column '1'. Maximum is 30.
DROP TABLE t1;
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
SET @a= CAST(1 AS decimal);
SELECT 1 FROM t1 GROUP BY @b := @a, @b;
1
1
1
DROP TABLE t1;
End of 5.0 tests
End of 5.0 tests
select cast(143.481 as decimal(4,1));
select cast(143.481 as decimal(4,1));
cast(143.481 as decimal(4,1))
cast(143.481 as decimal(4,1))
...
...
mysql-test/t/type_newdecimal.test
View file @
930f711b
...
@@ -1172,6 +1172,39 @@ drop table t1;
...
@@ -1172,6 +1172,39 @@ drop table t1;
#
#
SELECT
1.000000000000
*
99.999999999998
/
100
a
,
1.000000000000
*
(
99.999999999998
/
100
)
b
;
SELECT
1.000000000000
*
99.999999999998
/
100
a
,
1.000000000000
*
(
99.999999999998
/
100
)
b
;
#
# Bug #29415: CAST AS DECIMAL(P,S) with too big precision/scale
#
SELECT
CAST
(
1
AS
decimal
(
65
,
10
));
--
error
ER_TOO_BIG_PRECISION
SELECT
CAST
(
1
AS
decimal
(
66
,
10
));
SELECT
CAST
(
1
AS
decimal
(
65
,
30
));
--
error
ER_TOO_BIG_SCALE
SELECT
CAST
(
1
AS
decimal
(
65
,
31
));
CREATE
TABLE
t1
(
a
int
DEFAULT
NULL
,
b
int
DEFAULT
NULL
);
INSERT
INTO
t1
VALUES
(
3
,
30
),
(
1
,
10
),
(
2
,
10
);
SELECT
a
+
CAST
(
1
AS
decimal
(
65
,
30
))
AS
aa
,
SUM
(
b
)
FROM
t1
GROUP
BY
aa
;
--
error
ER_TOO_BIG_SCALE
SELECT
a
+
CAST
(
1
AS
decimal
(
65
,
31
))
AS
aa
,
SUM
(
b
)
FROM
t1
GROUP
BY
aa
;
DROP
TABLE
t1
;
#
# Bug #29417: assertion abort for a grouping query with decimal user variable
#
CREATE
TABLE
t1
(
a
int
DEFAULT
NULL
,
b
int
DEFAULT
NULL
);
INSERT
INTO
t1
VALUES
(
3
,
30
),
(
1
,
10
),
(
2
,
10
);
SET
@
a
=
CAST
(
1
AS
decimal
);
SELECT
1
FROM
t1
GROUP
BY
@
b
:=
@
a
,
@
b
;
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
#
#
...
...
sql/field.cc
View file @
930f711b
...
@@ -2316,6 +2316,7 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg,
...
@@ -2316,6 +2316,7 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg,
unireg_check_arg
,
field_name_arg
,
dec_arg
,
zero_arg
,
unsigned_arg
)
unireg_check_arg
,
field_name_arg
,
dec_arg
,
zero_arg
,
unsigned_arg
)
{
{
precision
=
my_decimal_length_to_precision
(
len_arg
,
dec_arg
,
unsigned_arg
);
precision
=
my_decimal_length_to_precision
(
len_arg
,
dec_arg
,
unsigned_arg
);
set_if_smaller
(
precision
,
DECIMAL_MAX_PRECISION
);
DBUG_ASSERT
((
precision
<=
DECIMAL_MAX_PRECISION
)
&&
DBUG_ASSERT
((
precision
<=
DECIMAL_MAX_PRECISION
)
&&
(
dec
<=
DECIMAL_MAX_SCALE
));
(
dec
<=
DECIMAL_MAX_SCALE
));
bin_size
=
my_decimal_get_binary_size
(
precision
,
dec
);
bin_size
=
my_decimal_get_binary_size
(
precision
,
dec
);
...
@@ -2332,6 +2333,7 @@ Field_new_decimal::Field_new_decimal(uint32 len_arg,
...
@@ -2332,6 +2333,7 @@ Field_new_decimal::Field_new_decimal(uint32 len_arg,
NONE
,
name
,
dec_arg
,
0
,
unsigned_arg
)
NONE
,
name
,
dec_arg
,
0
,
unsigned_arg
)
{
{
precision
=
my_decimal_length_to_precision
(
len_arg
,
dec_arg
,
unsigned_arg
);
precision
=
my_decimal_length_to_precision
(
len_arg
,
dec_arg
,
unsigned_arg
);
set_if_smaller
(
precision
,
DECIMAL_MAX_PRECISION
);
DBUG_ASSERT
((
precision
<=
DECIMAL_MAX_PRECISION
)
&&
DBUG_ASSERT
((
precision
<=
DECIMAL_MAX_PRECISION
)
&&
(
dec
<=
DECIMAL_MAX_SCALE
));
(
dec
<=
DECIMAL_MAX_SCALE
));
bin_size
=
my_decimal_get_binary_size
(
precision
,
dec
);
bin_size
=
my_decimal_get_binary_size
(
precision
,
dec
);
...
...
sql/item_create.cc
View file @
930f711b
...
@@ -5039,6 +5039,18 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
...
@@ -5039,6 +5039,18 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
my_error
(
ER_M_BIGGER_THAN_D
,
MYF
(
0
),
""
);
my_error
(
ER_M_BIGGER_THAN_D
,
MYF
(
0
),
""
);
return
0
;
return
0
;
}
}
if
(
len
>
DECIMAL_MAX_PRECISION
)
{
my_error
(
ER_TOO_BIG_PRECISION
,
MYF
(
0
),
len
,
a
->
name
,
DECIMAL_MAX_PRECISION
);
return
0
;
}
if
(
dec
>
DECIMAL_MAX_SCALE
)
{
my_error
(
ER_TOO_BIG_SCALE
,
MYF
(
0
),
dec
,
a
->
name
,
DECIMAL_MAX_SCALE
);
return
0
;
}
res
=
new
(
thd
->
mem_root
)
Item_decimal_typecast
(
a
,
len
,
dec
);
res
=
new
(
thd
->
mem_root
)
Item_decimal_typecast
(
a
,
len
,
dec
);
break
;
break
;
}
}
...
...
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