Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1945 05/06/15 08:27:33 igor@stripped +4 -0
cast.result, cast.test:
Added test case for bug #11283.
field.h, field.cc:
Fixed bug #11283: wrong conversion from varchar to decimal.
Added methods Field_string::val_decimal,
Field_varstring::val_decimal, Field_blob::val_decimal.
They are not inherited from the base class Field_longstr
anymore.
mysql-test/r/cast.result
1.30 05/06/15 08:27:09 igor@stripped +8 -0
Added test case for bug #11283.
mysql-test/t/cast.test
1.20 05/06/15 08:26:43 igor@stripped +13 -0
Added test case for bug #11283.
sql/field.h
1.161 05/06/15 08:25:48 igor@stripped +3 -1
Fixed bug #11283: wrong conversion from varchar to decimal.
Added methods Field_string::val_decimal,
Field_varstring::val_decimal, Field_blob::val_decimal.
They are not inherited from the base class Field_longstr
anymore.
sql/field.cc
1.263 05/06/15 08:21:44 igor@stripped +29 -8
Fixed bug #11283: wrong conversion from varchar to decimal.
Added methods Field_string::val_decimal,
Field_varstring::val_decimal, Field_blob::val_decimal.
They are not inherited from the base class Field_longstr
anymore.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: igor
# Host: rurik.mysql.com
# Root: /home/igor/dev/mysql-5.0-0
--- 1.262/sql/field.cc Thu Jun 9 19:29:51 2005
+++ 1.263/sql/field.cc Wed Jun 15 08:21:44 2005
@@ -5956,14 +5956,6 @@
}
-my_decimal *Field_longstr::val_decimal(my_decimal *decimal_value)
-{
- str2my_decimal(E_DEC_FATAL_ERROR, ptr, field_length, charset(),
- decimal_value);
- return decimal_value;
-}
-
-
String *Field_string::val_str(String *val_buffer __attribute__((unused)),
String *val_ptr)
{
@@ -5975,6 +5967,14 @@
}
+my_decimal *Field_string::val_decimal(my_decimal *decimal_value)
+{
+ str2my_decimal(E_DEC_FATAL_ERROR, ptr, field_length, charset(),
+ decimal_value);
+ return decimal_value;
+}
+
+
int Field_string::cmp(const char *a_ptr, const char *b_ptr)
{
uint a_len, b_len;
@@ -6288,6 +6288,15 @@
}
+my_decimal *Field_varstring::val_decimal(my_decimal *decimal_value)
+{
+ uint length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr);
+ str2my_decimal(E_DEC_FATAL_ERROR, ptr+length_bytes, length, charset(),
+ decimal_value);
+ return decimal_value;
+}
+
+
int Field_varstring::cmp(const char *a_ptr, const char *b_ptr)
{
uint a_length, b_length;
@@ -6903,6 +6912,18 @@
else
val_ptr->set((const char*) blob,get_length(ptr),charset());
return val_ptr;
+}
+
+
+my_decimal *Field_blob::val_decimal(my_decimal *decimal_value)
+{
+ char *blob;
+ memcpy_fixed(&blob, ptr+packlength, sizeof(char*));
+ if (!blob)
+ blob= "";
+ str2my_decimal(E_DEC_FATAL_ERROR, blob, get_length(ptr), charset(),
+ decimal_value);
+ return decimal_value;
}
--- 1.160/sql/field.h Thu Jun 9 19:29:52 2005
+++ 1.161/sql/field.h Wed Jun 15 08:25:48 2005
@@ -381,7 +381,6 @@
field_name_arg, table_arg, charset)
{}
- my_decimal *val_decimal(my_decimal *);
int store_decimal(const my_decimal *d);
};
@@ -993,6 +992,7 @@
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
+ my_decimal *val_decimal(my_decimal *);
int cmp(const char *,const char*);
void sort_string(char *buff,uint length);
void sql_type(String &str) const;
@@ -1051,6 +1051,7 @@
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
+ my_decimal *val_decimal(my_decimal *);
int cmp(const char *,const char*);
void sort_string(char *buff,uint length);
void get_key_image(char *buff,uint length, imagetype type);
@@ -1106,6 +1107,7 @@
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
+ my_decimal *val_decimal(my_decimal *);
int cmp(const char *,const char*);
int cmp(const char *a, uint32 a_length, const char *b, uint32 b_length);
int cmp_binary(const char *a,const char *b, uint32 max_length=~0L);
--- 1.29/mysql-test/r/cast.result Sat Apr 30 08:40:05 2005
+++ 1.30/mysql-test/r/cast.result Wed Jun 15 08:27:09 2005
@@ -344,3 +344,11 @@
cast(s1 as decimal(7,2))
111111.00
drop table t1;
+CREATE TABLE t1 (v varchar(10), tt tinytext, t text,
+mt mediumtext, lt longtext);
+INSERT INTO t1 VALUES ('1.01', '2.02', '3.03', '4.04', '5.05');
+SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL),
+CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1;
+CAST(v AS DECIMAL) CAST(tt AS DECIMAL) CAST(t AS DECIMAL) CAST(mt AS DECIMAL) CAST(lt AS
DECIMAL)
+1.01 2.02 3.03 4.04 5.05
+DROP TABLE t1;
--- 1.19/mysql-test/t/cast.test Fri Apr 29 23:46:04 2005
+++ 1.20/mysql-test/t/cast.test Wed Jun 15 08:26:43 2005
@@ -168,3 +168,16 @@
insert into t1 values ('11:11:11');
select cast(s1 as decimal(7,2)) from t1;
drop table t1;
+
+#
+# Test for bug #11283: field conversion from varchar, and text types to decimal
+#
+
+CREATE TABLE t1 (v varchar(10), tt tinytext, t text,
+ mt mediumtext, lt longtext);
+INSERT INTO t1 VALUES ('1.01', '2.02', '3.03', '4.04', '5.05');
+
+SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL),
+ CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1;
+
+DROP TABLE t1;
| Thread |
|---|
| • bk commit into 5.0 tree (igor:1.1945) BUG#11283 | igor | 15 Jun |