From 8ded41105758327cae175660fc53051d6d374eeb Mon Sep 17 00:00:00 2001 From: Chaithra Reddy Date: Thu, 3 Jul 2014 14:12:02 +0530 Subject: Bug#18469276: MOD FOR SMALL DECIMALS FAILS Problem: If leading zeroes of fractional part of a decimal number exceeds 45, mod operation on the same fails. Analysis: Currently there is a miscalcultion of fractional part for very small decimals in do_div_mod. For ex: For 0.000(45 times).....3 length of the integer part becomes -5 (for a length of one, buffer can hold 9 digits. Since number of zeroes are 45, integer part becomes 5) and it is negative because of the leading zeroes present in the fractional part. Fractional part is the number of digits present after the point which is 46 and therefore rounded off to the nearest 9 multiple which is 54. So the length of the resulting fractional part becomes 6. Because of this, the combined length of integer part and fractional part exceeds the max length allocated which is 9 and thereby failing. Solution: In case of negative integer value, it indicates there are leading zeroes in fractional part. As a result stop1 pointer should be set not just based on frac0 but also intg0. This is because the detination buffer will be filled with 0's for the length of intg0. strings/decimal.c: Calculate stop1 pointer based on the length of intg0 and frac0. --- strings/decimal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'strings') diff --git a/strings/decimal.c b/strings/decimal.c index 39dff0723b9..4f5528fcccc 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2322,7 +2322,7 @@ static int do_div_mod(const decimal_t *from1, const decimal_t *from2, error=E_DEC_TRUNCATED; goto done; } - stop1=start1+frac0; + stop1= start1 + frac0 + intg0; frac0+=intg0; to->intg=0; while (intg0++ < 0) -- cgit v1.2.1 From f8893dc472570383d2445c026c1488a010865a84 Mon Sep 17 00:00:00 2001 From: mithun Date: Tue, 12 Aug 2014 17:16:51 +0530 Subject: Bug #11755818 : LIKE DOESN'T MATCH WHEN CP932_BIN/SJIS_BIN COLLATIONS ARE USED. ISSUE : ------- Code points of HALF WIDTH KATAKANA in SJIS/CP932 range from A1 to DF. In function my_wildcmp_mb_bin_impl while comparing such single byte code points, there is a code which compares signed character with unsigned character. Because of this, comparisons of two same code points representing a HALF WIDTH KATAKANA character always fails. Solution: --------- A code point of HALF WIDTH KATAKANA at-least need 8 bits. Promoting the variable from uchar to int will fix the issue. mysql-test/t/ctype_cp932.test: Tests which have conditions LIKE 'STRING PATTERN WITH HALF WIDTH KATAKANA'. strings/ctype-mb.c: A code point of HALF WIDTH KATAKANA at-least need 8 bits. Promoting the variable from uchar to int will fix the issue. --- strings/ctype-mb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'strings') diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 258613d3b05..02373304672 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1044,7 +1044,7 @@ static int my_wildcmp_mb_bin_impl(CHARSET_INFO *cs, } if (*wildstr == w_many) { /* Found w_many */ - uchar cmp; + int cmp; const char* mb = wildstr; int mb_len=0; -- cgit v1.2.1