Bug #21087 Lost connection to MySQL server during query when querying negative values
Submitted: 17 Jul 2006 0:54 Modified: 17 Jul 2006 10:35
Reporter: N Bernhardt Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.22 OS:Linux (SuSe Linux 10.1)
Assigned to: CPU Architecture:Any
Tags: Lost connection

[17 Jul 2006 0:54] N Bernhardt
Description:
The table looks like:
=====================
CREATE TABLE sys_language (
  uid int(11) unsigned NOT NULL auto_increment,
  pid int(11) unsigned NOT NULL default '0',
  tstamp int(11) unsigned NOT NULL default '0',
  hidden tinyint(4) unsigned NOT NULL default '0',
  title varchar(80) collate utf8_unicode_ci NOT NULL default '',
  flag varchar(20) collate utf8_unicode_ci NOT NULL default '',
  static_lang_isocode int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (uid),
  KEY parent (pid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Typo3 table';

INSERT INTO sys_language (uid, pid, tstamp, hidden, title, flag, static_lang_isocode) VALUES (1, 0, 1113854871, 0, 'deutsch', 'de.gif', 43),
(2, 0, 1113854871, 0, 'polski', 'pl.gif', 91);

Note that the pid field is UNSIGNED.

How to repeat:
Execute the following query:
SELECT uid, pid, title
FROM sys_language
WHERE pid NOT 
IN (
-1, 0, 1, 2, 3, 41, 30, 4, 5, 45, 43, 44, 9, 48, 47, 49, 6, 7, 29, 50, 8, 53, 54, 31, 19, 20, 42, 21, 34, 35, 22, 27, 28, 23, 32, 33, 24, 39, 38, 37, 40, 46, 51, 52
)
LIMIT 0 , 30

Not that the first value is negative (-1). This results in an error message 
"Lost connection to MySQL server during query".
Altering the pid field to 
pid int(11) NOT NULL default '0'
so it can store negative values succeed with above mentioned query as expected.

Suggested fix:
Either the server should ignore negative values in comparisons when the field can only store 0 and positive values, or throw an appropriate error message.
[17 Jul 2006 10:33] Hartmut Holzgraefe
mysqltest test case

Attachment: bug21087.tgz (application/x-gtar, text), 757 bytes.

[17 Jul 2006 10:35] Hartmut Holzgraefe
Duplicate of bug #19618 which is already fixed