diff options
author | unknown <monty@narttu.mysql.fi> | 2003-05-14 22:12:55 +0300 |
---|---|---|
committer | unknown <monty@narttu.mysql.fi> | 2003-05-14 22:12:55 +0300 |
commit | ac316cfdb33bd4974a90c240c7a14ecb6a29da34 (patch) | |
tree | ce722533b213ba0daa1a73dd20f1df13b6144a60 | |
parent | 7297502a7bc6ab09d8e7c6cbd822bba4d58d4977 (diff) | |
download | mariadb-git-ac316cfdb33bd4974a90c240c7a14ecb6a29da34.tar.gz |
Fixed bug in CREATE ... DECIMAL(-1,1). Bug #432
mysql-test/mysql-test-run.sh:
Ensure that tests are sorted
mysql-test/r/type_decimal.result:
Test for bug with decimal()
mysql-test/t/type_decimal.test:
Test for bug with decimal()
sql/sql_parse.cc:
Fixed bug in CREATE ... DECIMAL(-1,1)
-rw-r--r-- | mysql-test/mysql-test-run.sh | 3 | ||||
-rw-r--r-- | mysql-test/r/type_decimal.result | 6 | ||||
-rw-r--r-- | mysql-test/t/type_decimal.test | 10 | ||||
-rw-r--r-- | sql/sql_parse.cc | 16 |
4 files changed, 27 insertions, 8 deletions
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 40726b776e8..7ce6ffe14af 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -114,6 +114,7 @@ if test $? != 0; then exit 1; fi TR=tr XARGS=`which xargs` if test $? != 0; then exit 1; fi +SORT=sort # Are we using a source or a binary distribution? @@ -1363,7 +1364,7 @@ then if [ x$RECORD = x1 ]; then $ECHO "Will not run in record mode without a specific test case." else - for tf in $TESTDIR/*.$TESTSUFFIX + for tf in `ls -1 $TESTDIR/*.$TESTSUFFIX | $SORT` do run_testcase $tf done diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 4c326957c03..b74765696a2 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -357,3 +357,9 @@ select * from t1; a 99999999999 drop table t1; +CREATE TABLE t1 (a_dec DECIMAL(-1,0)); +Too big column length for column 'a_dec' (max = 255). Use BLOB instead +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 diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 7d5d719592c..7aedc051905 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -230,3 +230,13 @@ insert into t1 values("1e4294967297"); select * from t1; drop table t1; +# +# Test of wrong decimal type +# + +--error 1074 +CREATE TABLE t1 (a_dec DECIMAL(-1,0)); +--error 1074 +CREATE TABLE t1 (a_dec DECIMAL(-2,1)); +--error 1074 +CREATE TABLE t1 (a_dec DECIMAL(-1,1)); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ad2f7f9a8bd..e69d260bf11 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2977,9 +2977,8 @@ bool add_field_to_list(char *field_name, enum_field_types type, new_field->change=change; new_field->interval=0; new_field->pack_length=0; - if (length) - if (!(new_field->length= (uint) atoi(length))) - length=0; /* purecov: inspected */ + if (length && !(new_field->length= (uint) atoi(length))) + length=0; /* purecov: inspected */ uint sign_len=type_modifier & UNSIGNED_FLAG ? 0 : 1; if (new_field->length && new_field->decimals && @@ -3015,10 +3014,13 @@ 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 - new_field->length+=sign_len; - if (new_field->decimals) - new_field->length++; + new_field->length= 10; // Default length for DECIMAL + if (new_field->length < MAX_FIELD_WIDTH) // Skip wrong argument + { + new_field->length+=sign_len; + if (new_field->decimals) + new_field->length++; + } break; case FIELD_TYPE_BLOB: case FIELD_TYPE_TINY_BLOB: |