Menu

#3064 (ok 3.3.6) It fails to edit rows with positive DECIMAL(16,6)

fixed
1
2013-06-11
2010-07-19
Antares7364
No

I have a table with two DECIMAL(16,6) field.
When I browse my table and click on the "edit" icon, PHPMyAdmin fails to load this row because its criterias are wrong : it wraps the DECIMAL field name with CONCAT(). Without CONCAT() it's working perfectly. And if the field has a value of 0.000000 it works too.

Here is the SELECT request generated when I want to edit a row :

SELECT *
FROM `mydb`.`accounts`
WHERE `accounts`.`id` =0
AND `accounts`.`admin_login` = 'dd'
AND `accounts`.`admin_password` = 'dd'
AND CONCAT( `accounts`.`SYNC_LMT` ) = 0.000000
AND `accounts`.`SYNC_LMB` =0
AND CONCAT( `accounts`.`SYNC_DBMT` ) = 1279557821.443215;
=> MySQL returned an empty result set (i.e. zero rows).

Here is my table structure and content :

CREATE TABLE IF NOT EXISTS `accounts` (
`id` int(11) NOT NULL,
`admin_login` varchar(100) CHARACTER SET utf8 NOT NULL,
`admin_password` varchar(100) CHARACTER SET utf8 NOT NULL,
`SYNC_LMT` decimal(16,6) unsigned NOT NULL,
`SYNC_LMB` int(2) unsigned NOT NULL,
`SYNC_DBMT` decimal(16,6) unsigned NOT NULL,
KEY `id` (`id`),
KEY `SYNC_LMT` (`SYNC_LMT`),
KEY `SYNC_LMB` (`SYNC_LMB`),
KEY `SYNC_DBMT` (`SYNC_DBMT`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `accounts`
--

INSERT INTO `accounts` (`id`, `admin_login`, `admin_password`, `SYNC_LMT`, `SYNC_LMB`, `SYNC_DBMT`) VALUES
(0, 'dd', 'dd', 0.000000, 0, 1279557821.443215);

Discussion

  • Michal Čihař

    Michal Čihař - 2010-07-20

    What phpMyAdmin and MySQL versions do you use? I can not reproduce the failure (though the CONCAT is indeed there).

     
  • Michal Čihař

    Michal Čihař - 2010-07-20
    • assigned_to: nobody --> nijel
     
  • Michal Čihař

    Michal Čihař - 2010-07-20
    • priority: 5 --> 1
    • summary: It fails to edit rows with positive DECIMAL(16,6) values --> (ok 3.3.6) It fails to edit rows with positive DECIMAL(16,6)
    • status: open --> open-fixed
     
  • Michal Čihař

    Michal Čihař - 2010-07-20

    I just fixed using CONCAT for decimal fields.

     
  • Antares7364

    Antares7364 - 2010-07-20

    Server version: 5.1.41-3ubuntu12.3
    PMA Version information: 3.3.3

    When will the fixed release be available ?

    Thanks

     
  • Michal Čihař

    Michal Čihař - 2010-07-20

    It will take about month, currently we're just in freeze for 3.3.4, so this fix could not go into it.

     
  • Antares7364

    Antares7364 - 2010-07-25

    Your patch seems to work with one non-zero DECIMAL column, but not with two.
    Can you check ?
    Here is my updated table structure and data, the delete icon still fails with this.

    --
    -- Table structure for table `accounts`
    --

    CREATE TABLE IF NOT EXISTS `accounts` (
    `id` int(11) NOT NULL,
    `admin_login` varchar(100) CHARACTER SET utf8 NOT NULL,
    `admin_password` varchar(100) CHARACTER SET utf8 NOT NULL,
    `SYNC_LMT` decimal(16,6) unsigned NOT NULL,
    `SYNC_LMB` int(2) unsigned NOT NULL,
    `SYNC_DBMT` decimal(16,6) unsigned NOT NULL,
    KEY `id` (`id`),
    KEY `SYNC_LMT` (`SYNC_LMT`),
    KEY `SYNC_LMB` (`SYNC_LMB`),
    KEY `SYNC_DBMT` (`SYNC_DBMT`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    --
    -- Dumping data for table `accounts`
    --

    INSERT INTO `accounts` (`id`, `admin_login`, `admin_password`, `SYNC_LMT`, `SYNC_LMB`, `SYNC_DBMT`) VALUES
    (3, 'zzz', 'zzz', 1280056069.763544, 1, 1280056069.763560),
    (0, 'xxx', 'xxx', 1280056100.672505, 1, 1280056100.672521);

     
  • Marc Delisle

    Marc Delisle - 2010-07-25
    • priority: 1 --> 5
    • summary: (ok 3.3.6) It fails to edit rows with positive DECIMAL(16,6) --> It fails to edit rows with positive DECIMAL(16,6)
    • status: open-fixed --> open
     
  • Antares7364

    Antares7364 - 2010-07-25

    The problem may be at MySQL level.
    I made some tests :

    SELECT concat('1280056069.763560')=1280056069.763560
    => 0

    SELECT '1280056069.763560'=1280056069.763560
    => 0

    SELECT concat('1280056069.76356')=1280056069.76356
    => 0

    SELECT concat('1280056069.76')=1280056069.76
    => 1

    SELECT concat('1280056069')=1280056069
    => 1

    SELECT concat('1280056069.763560')='1280056069.763560'
    => 1

     
  • Antares7364

    Antares7364 - 2010-07-25

    I just read chapter 11.2.2 of MySQL manual, it explains the limits of MySQL comparisons when using data of different types.
    You should avoid using CONCAT(), and just compare column_name=column_value in the request made by your script.
    Here is what the doc said :

    "Comparisons that use floating-point numbers (or values that are converted to floating-point numbers) are approximate because such numbers are inexact. This might lead to results that appear inconsistent:

    mysql> SELECT '18015376320243458' = 18015376320243458;
    -> 1
    mysql> SELECT '18015376320243459' = 18015376320243459;
    -> 0

    Such results can occur because the values are converted to floating-point numbers, which have only 53 bits of precision and are subject to rounding."

     
  • Marc Delisle

    Marc Delisle - 2010-07-25

    In general, for float columns we had to use CONCAT() because without it, comparison failed.

    P.S. if you had defined a primary key, it would be used for edit or delete, instead of generating a big condition.

     
  • Antares7364

    Antares7364 - 2010-07-25

    If you want to use CONCAT() you must wrap the row value with quotes (see the last line of my tests), to have string on both sides of the = operator.
    Or you use directly the column name and the row value (both DECIMAL).

     
  • Michal Čihař

    Michal Čihař - 2010-07-26
    • priority: 5 --> 1
    • summary: It fails to edit rows with positive DECIMAL(16,6) --> (ok 3.3.6) It fails to edit rows with positive DECIMAL(16,6)
     
  • Antares7364

    Antares7364 - 2010-07-30

    The patch is working great !
    Thanks !

     
  • Marc Delisle

    Marc Delisle - 2010-08-28
    • status: open --> closed
     
  • Michal Čihař

    Michal Čihař - 2013-06-11
    • Status: closed --> fixed