summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/type_newdecimal.result10
-rw-r--r--mysql-test/t/type_newdecimal.test8
-rw-r--r--strings/decimal.c3
3 files changed, 20 insertions, 1 deletions
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 1dd1142aea8..d39d2e3401d 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -976,3 +976,13 @@ select * from t1;
f1 f2 f3 f4 f5 f6 f7 f8
1 18 99 100 104 200 1000 10000
drop table t1;
+create table t1 (
+f0 decimal (30,30) zerofill not null DEFAULT 0,
+f1 decimal (0,0) zerofill not null default 0);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f0` decimal(30,30) unsigned zerofill NOT NULL default '0.000000000000000000000000000000',
+ `f1` decimal(10,0) unsigned zerofill NOT NULL default '0000000000'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index e2f247edcd3..81e06c70c7d 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1007,3 +1007,11 @@ insert into t1 (f1) values (1);
select * from t1;
drop table t1;
+#
+# Bug 12173 (show create table fails)
+#
+create table t1 (
+ f0 decimal (30,30) zerofill not null DEFAULT 0,
+ f1 decimal (0,0) zerofill not null default 0);
+show create table t1;
+drop table t1;
diff --git a/strings/decimal.c b/strings/decimal.c
index ca92ace92e1..4dc5fa91e0a 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -351,7 +351,8 @@ int decimal2string(decimal_t *from, char *to, int *to_len,
buf0=&tmp;
}
- intg_len= fixed_precision ? fixed_intg : (intg ? intg : 1);
+ if (!(intg_len= fixed_precision ? fixed_intg : intg))
+ intg_len= 1;
frac_len= fixed_precision ? fixed_decimals : frac;
len= from->sign + intg_len + test(frac) + frac_len;
if (fixed_precision)