Skip to content

Precision of standalone routine may differ from packaged one in SQL dialect 1 #7501

@pavel-zotov

Description

@pavel-zotov

Consider script:

set list on;
set sql dialect 1;

shell del C:\FBTESTING\qa\misc\tmp4test.fdb 2>nul;
create database 'localhost:C:\FBTESTING\qa\misc\tmp4test.fdb';
select mon$sql_dialect from mon$database;
commit;

recreate table test(id int primary key, x numeric(9,2), y numeric(9,2));
insert into test(id, x, y) select row_number()over(), 1.11, 333.33 from rdb$types,rdb$types rows 1000;
commit;

set term ^;
create or alter function fn_sum returns double precision as
begin
    return ( select sum(x/y) from test );
end
^
create or alter package pg as
begin
    function pg_sum returns double precision;
end
^
recreate package body pg as
begin
    function pg_sum returns double precision as
    begin
        return ( select sum(x/y) from test );
    end
end
^
set term ;^
commit;

select fn_sum(), pg.pg_sum() from rdb$database;

Its result will be:

MON$SQL_DIALECT                 1

FN_SUM                          3.330033300333080
PG_SUM                          3.300000000000000

If we change in script set sql dialect to 3 then out put will contain same values (3.300000000000000).
No matter whether some value proper or no, but result must be the same for PSQL unit regardless is it standalone or packaged.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions