summaryrefslogtreecommitdiff
path: root/sql/my_decimal.cc
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-02-19 19:00:41 +0200
committerunknown <monty@mysql.com>2005-02-19 19:00:41 +0200
commit6c8ae9d65ec0fe3ee9c8349dd7f8cc7336c958dd (patch)
tree5a44a1612b30cc4765614c35e5172d824e16bb09 /sql/my_decimal.cc
parent0bc02450a61180a5827ce4ab2a2b3538c1c1ce91 (diff)
parent64cc538bda5908e2688a1ba08a9ff156971a102b (diff)
downloadmariadb-git-6c8ae9d65ec0fe3ee9c8349dd7f8cc7336c958dd.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/my/mysql-5.0 BUILD/SETUP.sh: Auto merged mysql-test/r/ps_6bdb.result: Auto merged sql/item.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/log_event.cc: Auto merged sql/my_decimal.cc: Auto merged sql/my_decimal.h: Auto merged sql/mysql_priv.h: Auto merged sql/sp_head.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_select.cc: Auto merged
Diffstat (limited to 'sql/my_decimal.cc')
-rw-r--r--sql/my_decimal.cc35
1 files changed, 30 insertions, 5 deletions
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index 36229d1c795..3e3538a1da9 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -13,6 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
#include "mysql_priv.h"
#ifndef MYSQL_CLIENT
@@ -154,10 +155,11 @@ int my_decimal2binary(uint mask, const my_decimal *d, char *bin, int prec,
E_DEC_BAD_NUM
E_DEC_OOM
*/
+
int str2my_decimal(uint mask, const char *from, uint length,
CHARSET_INFO *charset, my_decimal *decimal_value)
{
- char *end;
+ char *end, *from_end;
int err;
char buff[STRING_BUFFER_USUAL_SIZE];
String tmp(buff, sizeof(buff), &my_charset_bin);
@@ -169,10 +171,20 @@ int str2my_decimal(uint mask, const char *from, uint length,
length= tmp.length();
charset= &my_charset_bin;
}
- my_decimal_set_zero(decimal_value);
+ from_end= end= (char*) from+length;
err= string2decimal((char *)from, (decimal *)decimal_value, &end);
- if ((uint) (end-from) != length && !err)
- err= E_DEC_TRUNCATED;
+ if (end != from_end && !err)
+ {
+ /* Give warining if there is something other than end space */
+ for ( ; end < from_end; end++)
+ {
+ if (!my_isspace(&my_charset_latin1, *end))
+ {
+ err= E_DEC_TRUNCATED;
+ break;
+ }
+ }
+ }
check_result(mask, err);
return err;
}
@@ -200,12 +212,25 @@ print_decimal_buff(const my_decimal *dec, const byte* ptr, int length)
{
print_decimal(dec);
fprintf(DBUG_FILE, "Record: ");
- for(int i= 0; i < length; i++)
+ for (int i= 0; i < length; i++)
{
fprintf(DBUG_FILE, "%02X ", (uint)((uchar *)ptr)[i]);
}
fprintf(DBUG_FILE, "\n");
}
+
+
+void dbug_print_decimal(const char *tag, const char *format, my_decimal *val)
+{
+ char buff[DECIMAL_MAX_STR_LENGTH];
+ String str(buff, sizeof(buff), &my_charset_bin);
+ if (!val)
+ str.set("NULL", 4, &my_charset_bin);
+ else
+ my_decimal2string(0, val, 0, 0, 0, &str);
+ DBUG_PRINT(tag, (format, val));
+}
+
#endif