List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:June 9 1999 3:31pm
Subject:Strange sorting on negative numbers of type decimal
View as plain text  
>>>>> "eric" == eric  <eric@stripped> writes:

>> Description:
eric> Sorting on a decimal field with negative numbers cause a strange sequence
eric> should be -14,-13,-12,-12,-10,-5,-4,-3,-2,-1,0,1,2,3,4,5,10,11,12,13,14
eric> but is    -10,-11,-12,-13,-14,-1,-2,-3,-4,-5,0,1,2,3,4,5,10,11,12,13,14

eric> The sorting code in isamchk seems to suffer from the same problem.

>> How-To-Repeat:
eric> CREATE TABLE test (
eric> num decimal(6,2) DEFAULT '0.00' NOT NULL,
eric> KEY num (num)
eric> );

eric> INSERT INTO test VALUES (-13);
eric> INSERT INTO test VALUES (-10);
eric> INSERT INTO test VALUES (-11);
eric> INSERT INTO test VALUES (-12);
eric> INSERT INTO test VALUES (-14);
eric> INSERT INTO test VALUES (-4);
eric> INSERT INTO test VALUES (-5);
eric> INSERT INTO test VALUES (-3);
eric> INSERT INTO test VALUES (-1);
eric> INSERT INTO test VALUES (-2);
eric> INSERT INTO test VALUES (0);
eric> INSERT INTO test VALUES (3);
eric> INSERT INTO test VALUES (2);
eric> INSERT INTO test VALUES (1);
eric> INSERT INTO test VALUES (5);
eric> INSERT INTO test VALUES (4);
eric> INSERT INTO test VALUES (13);
eric> INSERT INTO test VALUES (12);
eric> INSERT INTO test VALUES (14);
eric> INSERT INTO test VALUES (10);
eric> INSERT INTO test VALUES (11);

eric> select num from test order by num;

	
Hi!

This is probably a bug in the ISAM indexing of decimal columns.
I can't fix this easily in the old ISAM, but I will verify that the
new ISAM in MySQL 3.23 doesn't have this problem!

Regards,
Monty
Thread
Strange sorting on negative numbers of type decimaleric9 Jun
  • Re: Strange sorting on negative numbers of type decimalJim Faucette9 Jun
    • Re: Strange sorting on negative numbers of type decimalEric Thelin9 Jun
  • Strange sorting on negative numbers of type decimalMichael Widenius9 Jun
  • Re: Strange sorting on negative numbers of type decimalBlake Binkley10 Jun
    • Re: Strange sorting on negative numbers of type decimalMichael Widenius10 Jun