Commit a8a8da39 authored by serg@serg.mylan's avatar serg@serg.mylan

different (simpler and more compatible) fix for bug#4046

parent 5d947f7b
......@@ -363,6 +363,13 @@ CREATE TABLE t1 (a_dec DECIMAL(-2,1));
Too big column length for column 'a_dec' (max = 255). Use BLOB instead
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
Too big column length for column 'a_dec' (max = 255). Use BLOB instead
CREATE TABLE t1 (a_dec DECIMAL(0,11));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a_dec` decimal(12,11) default NULL
) TYPE=MyISAM
DROP TABLE t1;
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;
......
......@@ -240,6 +240,9 @@ CREATE TABLE t1 (a_dec DECIMAL(-1,0));
CREATE TABLE t1 (a_dec DECIMAL(-2,1));
--error 1074
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
CREATE TABLE t1 (a_dec DECIMAL(0,11));
SHOW CREATE TABLE t1;
DROP TABLE t1;
#
# Zero prepend overflow bug
......
......@@ -3157,7 +3157,10 @@ bool add_field_to_list(char *field_name, enum_field_types type,
break;
case FIELD_TYPE_DECIMAL:
if (!length)
new_field->length= 10; // Default length for DECIMAL
if (new_field->length= new_field->decimals)
new_field->length++;
else
new_field->length=10; // Default length for DECIMAL
if (new_field->length < MAX_FIELD_WIDTH) // Skip wrong argument
{
new_field->length+=sign_len;
......
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