Skip to content

Commit 62ee33e

Browse files
committed
Handling overflow and incorrect outputs in case of certain money and smallmoney arithmetic and math functions.
There were certain issues found both w.r.t overflow handling and certain functions and operations giving incorrect result for money and smallmoney datatype. This commit addresses those issues. Issue #1: Overflow of smallmoney arithmetic leading to TDS hang. Issue #2: Unhandled overflow cases leading to incorrect output. Issue #3: Fixeddecimal operators being resolved for smallmoney functions and operations leading to incorrect results. Task: BABEL-5745, BABEL-5757, BABEL-5756, BABEL-5747, BABEL-5754 Signed-off-by: Ayush Shah <[email protected]>
1 parent aec18e3 commit 62ee33e

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--5.2.0--5.3.0.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ DROP OPERATOR IF EXISTS sys.+ (sys.BIT, sys.SMALLMONEY);
553553
CREATE OPERATOR sys.+ (
554554
LEFTARG = sys.BIT,
555555
RIGHTARG = sys.SMALLMONEY,
556-
PROCEDURE = bitsmallmoneymi
556+
PROCEDURE = bitsmallmoneypl
557557
);
558558

559559
DROP OPERATOR IF EXISTS sys.- (sys.SMALLMONEY, sys.BIT);

test/JDBC/expected/parallel_query/babel_varbinary-vu-verify.out

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,15 @@ GO
707707
~~START~~
708708
text
709709
Query Text: Select varbinary_col from babel_varbinary_test_table2 where varbinary_col < cast(0x123 as varbinary(100)) + cast(0x123 as varbinary(100))
710-
Index Only Scan using babel_varbinary_test_indbabel_v93c04b51675320c0200287b60808b914 on babel_varbinary_test_table2
711-
Index Cond: (varbinary_col < '0x01230123'::bbf_varbinary)
710+
Gather
711+
Workers Planned: 4
712+
-> Parallel Seq Scan on babel_varbinary_test_table2
713+
Filter: ((varbinary_col)::bbf_varbinary < '0x01230123'::bbf_varbinary)
712714
~~END~~
713715

714716
~~START~~
715717
text
716-
Babelfish T-SQL Batch Parsing Time: 3.989 ms
718+
Babelfish T-SQL Batch Parsing Time: 7.781 ms
717719
~~END~~
718720

719721

@@ -722,13 +724,15 @@ GO
722724
~~START~~
723725
text
724726
Query Text: Select varbinary_col from babel_varbinary_test_table2 where varbinary_col < cast(0x123 as varbinary(max)) + cast(0x123 as varbinary(max))
725-
Index Only Scan using babel_varbinary_test_indbabel_v93c04b51675320c0200287b60808b914 on babel_varbinary_test_table2
726-
Index Cond: (varbinary_col < '0x01230123'::bbf_varbinary)
727+
Gather
728+
Workers Planned: 4
729+
-> Parallel Seq Scan on babel_varbinary_test_table2
730+
Filter: ((varbinary_col)::bbf_varbinary < '0x01230123'::bbf_varbinary)
727731
~~END~~
728732

729733
~~START~~
730734
text
731-
Babelfish T-SQL Batch Parsing Time: 0.177 ms
735+
Babelfish T-SQL Batch Parsing Time: 0.217 ms
732736
~~END~~
733737

734738

@@ -737,13 +741,15 @@ GO
737741
~~START~~
738742
text
739743
Query Text: Select varbinary_col from babel_varbinary_test_table2 where varbinary_col > cast(0x123 as varbinary(max)) + cast(0x123 as varbinary(max))
740-
Index Only Scan using babel_varbinary_test_indbabel_v93c04b51675320c0200287b60808b914 on babel_varbinary_test_table2
741-
Index Cond: (varbinary_col > '0x01230123'::bbf_varbinary)
744+
Gather
745+
Workers Planned: 4
746+
-> Parallel Seq Scan on babel_varbinary_test_table2
747+
Filter: ((varbinary_col)::bbf_varbinary > '0x01230123'::bbf_varbinary)
742748
~~END~~
743749

744750
~~START~~
745751
text
746-
Babelfish T-SQL Batch Parsing Time: 3.744 ms
752+
Babelfish T-SQL Batch Parsing Time: 7.684 ms
747753
~~END~~
748754

749755

@@ -754,15 +760,15 @@ text
754760
Query Text: select count(*) from babel_varbinary_test_table2 where varbinary_col > cast(0x123 as varbinary(max)) + cast(0x123 as varbinary(max))
755761
Finalize Aggregate
756762
-> Gather
757-
Workers Planned: 2
763+
Workers Planned: 4
758764
-> Partial Aggregate
759765
-> Parallel Seq Scan on babel_varbinary_test_table2
760766
Filter: ((varbinary_col)::bbf_varbinary > '0x01230123'::bbf_varbinary)
761767
~~END~~
762768

763769
~~START~~
764770
text
765-
Babelfish T-SQL Batch Parsing Time: 17.049 ms
771+
Babelfish T-SQL Batch Parsing Time: 33.697 ms
766772
~~END~~
767773

768774

@@ -773,15 +779,15 @@ text
773779
Query Text: select count(*) from babel_varbinary_test_table2 where varbinary_col < cast(0x123 as varbinary(max)) + cast(0x123 as varbinary(max))
774780
Finalize Aggregate
775781
-> Gather
776-
Workers Planned: 2
782+
Workers Planned: 4
777783
-> Partial Aggregate
778784
-> Parallel Seq Scan on babel_varbinary_test_table2
779785
Filter: ((varbinary_col)::bbf_varbinary < '0x01230123'::bbf_varbinary)
780786
~~END~~
781787

782788
~~START~~
783789
text
784-
Babelfish T-SQL Batch Parsing Time: 0.152 ms
790+
Babelfish T-SQL Batch Parsing Time: 0.216 ms
785791
~~END~~
786792

787793

0 commit comments

Comments
 (0)