Commit 92d7dd19 authored by unknown's avatar unknown

Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-5.0

into deer.(none):/home/hf/work/mysql-5.0.clean


mysql-test/r/show_check.result:
  Auto merged
mysql-test/r/sql_mode.result:
  Auto merged
parents d426b591 05d18135
......@@ -267,9 +267,9 @@ drop table t1;
create table t1 (c decimal(3,3), d double(3,3), f float(3,3));
show columns from t1;
Field Type Null Key Default Extra
c decimal(4,3) YES NULL
d double(4,3) YES NULL
f float(4,3) YES NULL
c decimal(3,3) YES NULL
d double(3,3) YES NULL
f float(3,3) YES NULL
drop table t1;
SET @old_sql_mode= @@sql_mode, sql_mode= '';
SET @old_sql_quote_show_create= @@sql_quote_show_create, sql_quote_show_create= OFF;
......
......@@ -120,7 +120,7 @@ create table t1 ( min_num dec(6,6) default .000001);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`min_num` decimal(7,6) default '0.000001'
`min_num` decimal(6,6) default '0.000001'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1 ;
set session sql_mode = 'IGNORE_SPACE';
......@@ -128,14 +128,14 @@ create table t1 ( min_num dec(6,6) default 0.000001);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`min_num` decimal(7,6) default '0.000001'
`min_num` decimal(6,6) default '0.000001'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1 ;
create table t1 ( min_num dec(6,6) default .000001);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`min_num` decimal(7,6) default '0.000001'
`min_num` decimal(6,6) default '0.000001'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1 ;
set @@SQL_MODE=NULL;
......
......@@ -476,12 +476,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1,1))' at line 1
CREATE TABLE t1 (a_dec DECIMAL(0,11));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a_dec` decimal(11,11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
ERROR 42000: Scale may not be larger than the precision (column 'a_dec').
create table t1(a decimal(7,3));
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
select * from t1;
......@@ -699,24 +694,6 @@ select * from t1;
d
1
drop table t1;
create table t1 (d decimal(64,99));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`d` decimal(64,30) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (1);
select * from t1;
d
1.000000000000000000000000000000
drop table t1;
create table t1 (d decimal(10,12));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`d` decimal(13,12) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (d decimal(5));
show create table t1;
Table Create Table
......@@ -732,7 +709,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (d decimal(66,0));
ERROR 42000: Incorrect column specifier for column 'd'
ERROR 42000: Too big precision 66 specified for column 'd'. Maximum is 65.
CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2));
INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00),
(2, 0.00, 0.00), (2, -13.20, 0.00), (2, 59.60, 46.40),
......
......@@ -103,7 +103,7 @@ select max(a),min(a),avg(a) from t1;
max(a) min(a) avg(a)
1 1 1
drop table t1;
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6));
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(7,6));
show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment
f float NULL YES NULL #
......@@ -133,17 +133,7 @@ min(a)
-0.010
drop table t1;
create table t1 (a float(200,100), b double(200,100));
insert t1 values (1.0, 2.0);
select * from t1;
a b
1.000000000000000000000000000000 2.000000000000000000000000000000
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` float(200,30) default NULL,
`b` double(200,30) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
ERROR 42000: Too big scale 100 specified for column 'a'. Maximum is 30.
create table t1 (c20 char);
insert into t1 values (5000.0);
Warnings:
......
......@@ -940,3 +940,18 @@ cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15))
select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;
c1 c2 c3
9.5468126085974 9.547 9.547
create table t1 (sl decimal(70,30));
ERROR 42000: Too big precision 70 specified for column 'sl'. Maximum is 65.
create table t1 (sl decimal(32,31));
ERROR 42000: Too big scale 31 specified for column 'sl'. Maximum is 30.
create table t1 (sl decimal(0,38));
ERROR 42000: Too big scale 38 specified for column 'sl'. Maximum is 30.
create table t1 (sl decimal(0,30));
ERROR 42000: Scale may not be larger than the precision (column 'sl').
create table t1 (sl decimal(5, 5));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`sl` decimal(5,5) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
......@@ -247,9 +247,8 @@ CREATE TABLE t1 (a_dec DECIMAL(-1,0));
CREATE TABLE t1 (a_dec DECIMAL(-2,1));
--error 1064
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
--error 1427
CREATE TABLE t1 (a_dec DECIMAL(0,11));
SHOW CREATE TABLE t1;
DROP TABLE t1;
#
# Zero prepend overflow bug
......@@ -293,21 +292,13 @@ create table t1 (d decimal(64,0));
insert into t1 values (1);
select * from t1;
drop table t1;
create table t1 (d decimal(64,99));
show create table t1;
insert into t1 values (1);
select * from t1;
drop table t1;
create table t1 (d decimal(10,12));
show create table t1;
drop table t1;
create table t1 (d decimal(5));
show create table t1;
drop table t1;
create table t1 (d decimal);
show create table t1;
drop table t1;
--error 1063
--error 1426
create table t1 (d decimal(66,0));
#
......
......@@ -67,7 +67,7 @@ drop table t1;
# FLOAT/DOUBLE/DECIMAL handling
#
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6));
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(7,6));
# We mask out Privileges column because it differs for embedded server
--replace_column 8 #
show full columns from t1;
......@@ -79,11 +79,8 @@ select a from t1 order by a;
select min(a) from t1;
drop table t1;
--error 1425
create table t1 (a float(200,100), b double(200,100));
insert t1 values (1.0, 2.0);
select * from t1;
show create table t1;
drop table t1;
#
# float in a char(1) field
......
......@@ -983,3 +983,18 @@ select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(3
# Bug #11708 (conversion to decimal fails in decimal part)
#
select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;
#
# Bug #8449 (Silent column changes)
#
--error 1426
create table t1 (sl decimal(70,30));
--error 1425
create table t1 (sl decimal(32,31));
--error 1425
create table t1 (sl decimal(0,38));
--error 1427
create table t1 (sl decimal(0,30));
create table t1 (sl decimal(5, 5));
show create table t1;
drop table t1;
......@@ -5362,3 +5362,9 @@ ER_NO_DEFAULT_FOR_VIEW_FIELD
eng "Field of view '%-.64s.%-.64s' underlying table doesn't have a default value"
ER_SP_NO_RECURSION
eng "Recursive stored routines are not allowed."
ER_TOO_BIG_SCALE 42000 S1009
eng "Too big scale %d specified for column '%-.64s'. Maximum is %d."
ER_TOO_BIG_PRECISION 42000 S1009
eng "Too big precision %d specified for column '%-.64s'. Maximum is %d."
ER_SCALE_BIGGER_THAN_PRECISION 42000 S1009
eng "Scale may not be larger than the precision (column '%-.64s')."
......@@ -5564,8 +5564,14 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
new_field->flags= type_modifier;
new_field->unireg_check= (type_modifier & AUTO_INCREMENT_FLAG ?
Field::NEXT_NUMBER : Field::NONE);
new_field->decimals= decimals ? (uint) set_zone(atoi(decimals),0,
NOT_FIXED_DEC-1) : 0;
new_field->decimals= decimals ? (uint)atoi(decimals) : 0;
if (new_field->decimals >= NOT_FIXED_DEC)
{
my_error(ER_TOO_BIG_SCALE, MYF(0), new_field->decimals, field_name,
NOT_FIXED_DEC-1);
DBUG_RETURN(NULL);
}
new_field->sql_type=type;
new_field->length=0;
new_field->change=change;
......@@ -5586,11 +5592,6 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
length=0; /* purecov: inspected */
sign_len=type_modifier & UNSIGNED_FLAG ? 0 : 1;
if (new_field->length && new_field->decimals &&
new_field->length < new_field->decimals+1 &&
new_field->decimals != NOT_FIXED_DEC)
new_field->length=new_field->decimals+1; /* purecov: inspected */
switch (type) {
case FIELD_TYPE_TINY:
if (!length) new_field->length=MAX_TINYINT_WIDTH+sign_len;
......@@ -5616,22 +5617,24 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
break;
case FIELD_TYPE_NEWDECIMAL:
if (!length)
new_field->length= 10;
if (new_field->length > DECIMAL_MAX_PRECISION)
{
if (!(new_field->length= new_field->decimals))
new_field->length= 10; // Default length for DECIMAL
my_error(ER_TOO_BIG_PRECISION, MYF(0), new_field->length, field_name,
DECIMAL_MAX_PRECISION);
DBUG_RETURN(NULL);
}
new_field->pack_length=
my_decimal_get_binary_size(new_field->length, new_field->decimals);
if (new_field->length <= DECIMAL_MAX_PRECISION &&
new_field->length >= new_field->decimals)
if (new_field->length < new_field->decimals)
{
new_field->length=
my_decimal_precision_to_length(new_field->length, new_field->decimals,
type_modifier & UNSIGNED_FLAG);
break;
my_error(ER_SCALE_BIGGER_THAN_PRECISION, MYF(0), field_name);
DBUG_RETURN(NULL);
}
my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name);
DBUG_RETURN(NULL);
new_field->length=
my_decimal_precision_to_length(new_field->length, new_field->decimals,
type_modifier & UNSIGNED_FLAG);
new_field->pack_length=
my_decimal_get_binary_size(new_field->length, new_field->decimals);
break;
case MYSQL_TYPE_VARCHAR:
/*
Long VARCHAR's are automaticly converted to blobs in mysql_prepare_table
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment