Menu

#612 Incorrect read double AsFloat from database mariadb and postges on Linux only

8.0.0
open
nobody
Bug Report
2024-09-16
2024-09-06
Jony Rh
No

FPC 3.2.2, Lazarus 3.4 x86_64 win and linux, Zeos 8.0.0

After update to 8.0.0, mariadb and postgres incorrect read double AsFloat from database mariadb and postges ONLY on linux. If get AsCurrency - is OK! This error only on linux, on windows is OK!

Example on linux maria and postrges:
Field VALUE_FLOAT = 172471.3

ZReadOnlyQuery1.Fields.FieldByName('VALUE_FLOAT').AsFloat = 3.69576882163363E-10
ZReadOnlyQuery1.Fields.FieldByName('VALUE_FLOAT').AsCurrency = 172471.3
ZReadOnlyQuery1.Fields.FieldByName('VALUE_FLOAT').AsString = 172471.3
ZReadOnlyQuery1.Fields.FieldByName('VALUE_FLOAT').AsInteger = 172471

Discussion

  • Jony Rh

    Jony Rh - 2024-09-06

    if use AsBCD and BcdToDouble (unit FMTBcd) - is OK!
    FloatToStr(BcdToDouble(ZReadOnlyQuery1.Fields.FieldByName('VALUE_FLOAT').AsBCD) = 172471.3

    or if you use AsBCD instead of AsFloat

     

    Last edit: Jony Rh 2024-09-06
  • Jony Rh

    Jony Rh - 2024-09-06
    • status: open --> closed
     
  • marsupilami79

    marsupilami79 - 2024-09-06
    • status: closed --> open
     
  • marsupilami79

    marsupilami79 - 2024-09-06

    Hello,

    what is the field type in the database? Numeric(x,y)? float?

    Best regards,

    Jan

     
    • Jony Rh

      Jony Rh - 2024-09-06

      Hi, in mariadb DECIMAL(15,3), postgres NUMERIC(15,3)

       

      Last edit: Jony Rh 2024-09-06
  • Jony Rh

    Jony Rh - 2024-09-08

    @marsupilami79, this is a bug or not?!

     

    Last edit: Jony Rh 2024-09-09
  • Jony Rh

    Jony Rh - 2024-09-09

    project for testing and screens with results on linux ubuntu

     
  • marsupilami79

    marsupilami79 - 2024-09-13

    Hello Jony,

    I can not reproduce the issue. The output of your program for mariadb on my test computer is:

    Params:
    g - use postrges
    l - library path
    h - host
    r - port
    u - user
    p - password
    v - out as variant
    
    -172471.3
    Z8T_FLOAT               -172471
    Z8T_FLOAT_U             172471
    Z8T_DOUBLE              -172471.3
    Z8T_DOUBLE_U            172471.3
    Z8T_DECIMAL             -172471.3
    Z8T_DECIMAL_U           172471.3
    

    My system:
    Zeos 8.0-patches from SVN
    FPC 3.2.2 + Lazarus 3.4, compiles with fpcupdeluxe
    Debian Linux 12.7 with MariaDB 10.11.6

    So there are questions:
    Which Ubuntu do you use?
    How did you install FPC and Lazarus?
    How did you install PostgreSQL and MariaDB?

    Does it work for you if you install FPC and Lazarus using fpcupdeluxe?

     
    • Jony Rh

      Jony Rh - 2024-09-13

      Hello, marsupilami79

      I'm using FPC 3.2.2 + Lazarus 3.4, . with fpcupdeluxe 2.4.0e on Windows and using cross-compile for linux64 and win64. Zeos8 from OPM. Error screens from Ubuntu 22.04 Desktop, installing mariadb and postgres from apt install. If using cross-compile with last version 7 - every is ok...

       

      Last edit: Jony Rh 2024-09-13

Log in to post a comment.