Bug #38444 mysqltest/mysql don't generate the same output with unsigned/signed conversion

Submitted: 30 Jul 2008 0:04 Modified: 30 Jul 2008 23:39
Reporter: Larry Zhou Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Tests Severity:S3 (Non-critical)
Version:5.0.37, 5.1.23 OS:Linux
Assigned to: CPU Architecture:Any
Tags: MySQL, mysqltest

[30 Jul 2008 0:04] Larry Zhou
Description:

$ cat sign.test
# Test signed/unsigned conversion
# we use InnoDB to repro the bug, but other engine would generate the same bug.

-- source include/have_innodb.inc

--disable_warnings
drop table if exists t2;
--enable_warnings

# create t2, Note that Fp is signed
CREATE TABLE `t2` (
  `Fp` bigint(20) NOT NULL default '0',
  `Text` varchar(255) character set latin1 collate latin1_bin NOT NULL default '',
  PRIMARY KEY  (`Fp`),
  KEY `Text` (`Text`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

# put some values
insert into t2 values
(-1552084730623784428, 100),
(-2474873173060715355, 101),
(-7134262809993999386, 1001);

# this one works with mysqltest and mysql
select * from t2 where Fp=-2474873173060715355;

# get the unsigned value of Fp
select cast(-2474873173060715355 as unsigned);

# this line generates nothing from mysqltest
# but it generates (-2474873173060715355, 101) if run thru mysql client.
select * from t2 where Fp=15971870900648836261;

# cleanup
drop table t2;
========================================================

running the same thing thru mysql, there is a match for 
select * from t2 where Fp=15971870900648836261;

while running it as mysqltest, there is no match for that query

How to repeat:

put above script under mysql-test/t/sign.test

then run 
mysql-test$ ./mysql-test-run sign

look at sign.log file
==================================
mysql-test$ cat r/sign.log
drop table if exists t2;
CREATE TABLE `t2` (
`Fp` bigint(20) NOT NULL default '0',
`Text` varchar(255) character set latin1 collate latin1_bin NOT NULL default '',
PRIMARY KEY  (`Fp`),
KEY `Text` (`Text`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
insert into t2 values
(-1552084730623784428, 100),
(-2474873173060715355, 101),
(-7134262809993999386, 1001);
select * from t2 where Fp=-2474873173060715355;
Fp      Text
-2474873173060715355    101
select cast(-2474873173060715355 as unsigned);
cast(-2474873173060715355 as unsigned)
15971870900648836261
select * from t2 where Fp=15971870900648836261;
Fp      Text
drop table t2;
======================================

run as mysql client
======================================
mysql-test$ mysql -uroot  -E test < t/sign.test
*************************** 1. row ***************************
  Fp: -2474873173060715355
Text: 101
*************************** 1. row ***************************
cast(-2474873173060715355 as unsigned): 15971870900648836261
*************************** 1. row ***************************
  Fp: -2474873173060715355
Text: 101

=================================
[30 Jul 2008 16:38] Sveta Smirnova
Thank you for the report.

No results of query select * from t2 where Fp=15971870900648836261; is expected, because mysqld can not gues if you mean 15971870900648836261 is unsigned.

So behavior of mysql command line is wrong. But I can not repeat such behavior with current development sources. Please try current version 5.0.51b or 5.1.26 and if problem still exists provide us details of your installation: accurate OS and MySQL package name.
[30 Jul 2008 23:39] Larry Zhou
My bad.

I just checked the original version of MySQL.
And yes, "No results of query select * from t2 where Fp=15971870900648836261; is
expected".

There is an added option, that would cause the some changes in behavior.

I am sorry about this false alarm.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.