summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <jani@ibmlab.site>2005-05-10 09:25:25 +0300
committerunknown <jani@ibmlab.site>2005-05-10 09:25:25 +0300
commit6037cd1775552b505536110eea71c9b7f7614447 (patch)
treef87e20f2434c703ccb73126c311b26f52ef6b3bb /strings
parent848611b5ed1e565d02eea896e22753b818c458c5 (diff)
downloadmariadb-git-6037cd1775552b505536110eea71c9b7f7614447.tar.gz
Fixed Bug#10232: update with subquery, precision math,
another column gets rotten value. mysql-test/r/type_newdecimal.result: Added a test case for Bug#10232: update with subquery, precision math, another column gets rotten value. mysql-test/t/type_newdecimal.test: Added a test case for Bug#10232: update with subquery, precision math, another column gets rotten value.
Diffstat (limited to 'strings')
-rw-r--r--strings/decimal.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 3fa06132cf1..1e62333ee66 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1162,6 +1162,8 @@ int decimal2bin(decimal_t *from, char *to, int precision, int frac)
isize0=intg0*sizeof(dec1)+dig2bytes[intg0x],
fsize0=frac0*sizeof(dec1)+dig2bytes[frac0x],
fsize1=frac1*sizeof(dec1)+dig2bytes[frac1x];
+ const int orig_isize0= isize0;
+ const int orig_fsize0= fsize0;
char *orig_to= to;
buf1= remove_leading_zeroes(from, &from_intg);
@@ -1252,10 +1254,15 @@ int decimal2bin(decimal_t *from, char *to, int precision, int frac)
}
if (fsize0 > fsize1)
{
- while (fsize0-- > fsize1)
+ char *to_end= orig_to + orig_fsize0 + orig_isize0;
+
+ while (fsize0-- > fsize1 && to < to_end)
*to++=(uchar)mask;
}
orig_to[0]^= 0x80;
+
+ /* Check that we have written the whole decimal and nothing more */
+ DBUG_ASSERT(to == orig_to + orig_fsize0 + orig_isize0);
return error;
}