summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorjani@ibmlab.site <>2005-05-10 09:25:25 +0300
committerjani@ibmlab.site <>2005-05-10 09:25:25 +0300
commit0b5cedca79b476bc4e9f1c1f80745c2982210932 (patch)
treef87e20f2434c703ccb73126c311b26f52ef6b3bb /strings
parentb2fc830459eb5f03caa4cb73005ead95c0f72924 (diff)
downloadmariadb-git-0b5cedca79b476bc4e9f1c1f80745c2982210932.tar.gz
Fixed 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;
}