Bug #4956 strange result, insert into longtext, parameter with numeric value
Submitted: 9 Aug 2004 15:38 Modified: 14 Apr 2005 22:16
Reporter: Matthias Leich Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 OS:
Assigned to: Konstantin Osipov CPU Architecture:Any

[9 Aug 2004 15:38] Matthias Leich
Description:
I get strange results, when I perform the following statements:
create table tx ( my_test varchar(100), my_col longtext) ;
insert into tx set my_test= 'non PS, 1.0 as constant',my_col=1.0;
prepare stmt1 from "insert into tx set my_test='PS,1.0 as constant',my_col=1.0";
execute stmt1 ;
set @arg00=1.0;
insert into tx set my_test= 'non PS, 1.0 in parameter',my_col = @arg00 ;
prepare stmt1 from "insert into tx set my_test='PS,1.0 in parameter',my_col=?";
execute stmt1 using @arg00 ;
select my_test, my_col from tx ;
------------------------------------------
my_test	                            my_col
non PS, 1.0 as constant	     1.00
PS,1.0 as constant	       1.00
non PS, 1.0 in parameter   1          <-- Why is there the value '1' and not '1.00' ?
PS,1.0 in parameter	     1.00     

I don't have any problems with these results, because I assume it is no good idea 
to assign numeric values/types to longtext columns. So you may treat this report 
as a pure observation of an anomaly where one result does not meet the 
expectation.

But if this result is not intended and/or caused by defects which may produce real 
bad effects, please treat is as a bug.

Further observations:
   The server seems to treat the 
   - constant as double(3,1)
   - parameter as double.

My environment: Intel PC with Linux(SuSE 9.0)
      MySQL 4.1 source distrib. (last ChangeSet@1.1943, 2004-08-09 13:04:34+05:00)

How to repeat:
Please use my test file, copy it to mysql-test/t
  ./mysql-test-run ml_err21

Suggested fix:
It would be nice to have a description within the manual, which conversions will be made
during the assignment of numerical values to longtext columns.
[9 Aug 2004 15:43] Matthias Leich
test case

Attachment: ml_err21.test (application/octet-stream, text), 751 bytes.

[31 Mar 2005 0:26] Konstantin Osipov
This is fixed in 5.0 which adds the new DECIMAL type.
I'm changing the status to 'In progress' as I intend to add the test case to the test suite.
[14 Apr 2005 22:15] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/24031
[14 Apr 2005 22:16] Konstantin Osipov
Fixed in 5.0 tree, currently tagged 5.0.5