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
19fa54f0
Commit
19fa54f0
authored
Sep 09, 2005
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Bug#10716, Procedure Analyse results in wrong values for optimal field type
Added test case.
parent
6c7f692d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
mysql-test/r/analyse.result
mysql-test/r/analyse.result
+6
-0
mysql-test/t/analyse.test
mysql-test/t/analyse.test
+9
-0
sql/sql_analyse.cc
sql/sql_analyse.cc
+10
-5
No files found.
mysql-test/r/analyse.result
View file @
19fa54f0
...
@@ -102,3 +102,9 @@ select * from t1 procedure analyse();
...
@@ -102,3 +102,9 @@ select * from t1 procedure analyse();
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.v " \\ 1 19 0 0 3.7619 NULL ENUM('"','""','"c','\'\0\\"','\'','\'\'','\'b','a\0\0\0b','a\0','a""""b','a\'\'\'\'b','abc','abc\'def\\hij"klm\0opq','a\\\\\\\\b','b\'','c"','d\\','The\ZEnd','\\','\\d','\\\\') NOT NULL
test.t1.v " \\ 1 19 0 0 3.7619 NULL ENUM('"','""','"c','\'\0\\"','\'','\'\'','\'b','a\0\0\0b','a\0','a""""b','a\'\'\'\'b','abc','abc\'def\\hij"klm\0opq','a\\\\\\\\b','b\'','c"','d\\','The\ZEnd','\\','\\d','\\\\') NOT NULL
drop table t1;
drop table t1;
create table t1 (d double);
insert into t1 values (100000);
select * from t1 procedure analyse (1,1);
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.d 100000 100000 6 6 0 0 100000 0 MEDIUMINT(6) UNSIGNED NOT NULL
drop table t1;
mysql-test/t/analyse.test
View file @
19fa54f0
...
@@ -48,4 +48,13 @@ insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),(
...
@@ -48,4 +48,13 @@ insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),(
select
*
from
t1
procedure
analyse
();
select
*
from
t1
procedure
analyse
();
drop
table
t1
;
drop
table
t1
;
#
# Bug#10716 - Procedure Analyse results in wrong values for optimal field type
#
create
table
t1
(
d
double
);
insert
into
t1
values
(
100000
);
select
*
from
t1
procedure
analyse
(
1
,
1
);
drop
table
t1
;
# End of 4.1 tests
# End of 4.1 tests
sql/sql_analyse.cc
View file @
19fa54f0
...
@@ -789,18 +789,23 @@ void field_real::get_opt_type(String *answer,
...
@@ -789,18 +789,23 @@ void field_real::get_opt_type(String *answer,
if
(
!
max_notzero_dec_len
)
if
(
!
max_notzero_dec_len
)
{
{
if
(
min_arg
>=
-
128
&&
max_arg
<=
(
min_arg
>=
0
?
255
:
127
))
if
(
min_arg
>=
-
128
&&
max_arg
<=
(
min_arg
>=
0
?
255
:
127
))
sprintf
(
buff
,
"TINYINT(%d)"
,
(
int
)
max_length
-
(
item
->
decimals
+
1
));
sprintf
(
buff
,
"TINYINT(%d)"
,
(
int
)
max_length
-
((
item
->
decimals
==
NOT_FIXED_DEC
)
?
0
:
(
item
->
decimals
+
1
)));
else
if
(
min_arg
>=
INT_MIN16
&&
max_arg
<=
(
min_arg
>=
0
?
else
if
(
min_arg
>=
INT_MIN16
&&
max_arg
<=
(
min_arg
>=
0
?
UINT_MAX16
:
INT_MAX16
))
UINT_MAX16
:
INT_MAX16
))
sprintf
(
buff
,
"SMALLINT(%d)"
,
(
int
)
max_length
-
(
item
->
decimals
+
1
));
sprintf
(
buff
,
"SMALLINT(%d)"
,
(
int
)
max_length
-
((
item
->
decimals
==
NOT_FIXED_DEC
)
?
0
:
(
item
->
decimals
+
1
)));
else
if
(
min_arg
>=
INT_MIN24
&&
max_arg
<=
(
min_arg
>=
0
?
else
if
(
min_arg
>=
INT_MIN24
&&
max_arg
<=
(
min_arg
>=
0
?
UINT_MAX24
:
INT_MAX24
))
UINT_MAX24
:
INT_MAX24
))
sprintf
(
buff
,
"MEDIUMINT(%d)"
,
(
int
)
max_length
-
(
item
->
decimals
+
1
));
sprintf
(
buff
,
"MEDIUMINT(%d)"
,
(
int
)
max_length
-
((
item
->
decimals
==
NOT_FIXED_DEC
)
?
0
:
(
item
->
decimals
+
1
)));
else
if
(
min_arg
>=
INT_MIN32
&&
max_arg
<=
(
min_arg
>=
0
?
else
if
(
min_arg
>=
INT_MIN32
&&
max_arg
<=
(
min_arg
>=
0
?
UINT_MAX32
:
INT_MAX32
))
UINT_MAX32
:
INT_MAX32
))
sprintf
(
buff
,
"INT(%d)"
,
(
int
)
max_length
-
(
item
->
decimals
+
1
));
sprintf
(
buff
,
"INT(%d)"
,
(
int
)
max_length
-
((
item
->
decimals
==
NOT_FIXED_DEC
)
?
0
:
(
item
->
decimals
+
1
)));
else
else
sprintf
(
buff
,
"BIGINT(%d)"
,
(
int
)
max_length
-
(
item
->
decimals
+
1
));
sprintf
(
buff
,
"BIGINT(%d)"
,
(
int
)
max_length
-
((
item
->
decimals
==
NOT_FIXED_DEC
)
?
0
:
(
item
->
decimals
+
1
)));
answer
->
append
(
buff
,
(
uint
)
strlen
(
buff
));
answer
->
append
(
buff
,
(
uint
)
strlen
(
buff
));
if
(
min_arg
>=
0
)
if
(
min_arg
>=
0
)
answer
->
append
(
" UNSIGNED"
);
answer
->
append
(
" UNSIGNED"
);
...
...
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