• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

babelfish-for-postgresql / babelfish_extensions / 17260507915
76%
BABEL_5_X_DEV: 77%

Build:
Build:
LAST BUILD BRANCH: 5577-5x
DEFAULT BRANCH: BABEL_5_X_DEV
Ran 27 Aug 2025 08:16AM UTC
Jobs 1
Files 120
Run time 2min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

27 Aug 2025 07:41AM UTC coverage: 75.576% (+0.002%) from 75.574%
17260507915

push

github

web-flow
Fix datetime roundoff mechanism during storing/insertion of data (#4045)

Datetime datatype in TSQL has a precision of 3 ms and this behaviour is persisted in all operations i.e., qual conditions, operators, cast etc. However, Babelfish only follows this rule during returning rows. In all other operations, it does not apply any round off mechanism (relies on PG’s handling).

It is a day one issue in babelfish where we internally store the original value for datetime datatype and not the one rounded to increments of .000, .003, or .007 seconds.
For Example in this case:

CREATE TABLE dbo.DateTimeTest (
    id BIGINT IDENTITY(1,1) NOT NULL PRIMARY KEY,
    lastmodifieddate DATETIME NULL
);
INSERT INTO dbo.DateTimeTest (lastmodifieddate)
VALUES (CAST('2021-09-20T04:00:49.299' AS DATETIME2(3)));

The value stored in lastmodifieddate column in babelfish would actually be '2021-09-20T04:00:49.299' and not '2021-09-20T04:00:49.300'

So, when we select the datetime column:

SELECT * FROM dbo.DateTimeTest;

Then the TDS Sender function for datetime kick in and rounds off the value to '2021-09-20T04:00:49.300'

For other cases, the original value is used for any operations performed!
Example in the second case:

SELECT * FROM dbo.DateTimeTest WHERE lastmodifieddate = '2021-09-20T04:00:49.300';

The = operator would compare with original value of lastmodifieddate column i.e. '2021-09-20T04:00:49.299' and hence no rows are returned.

To solve this issue, rather than rounding off the values while sending the rows to user, we should store the values in rounded off format.

Tasks: BABEL-5265, BABEL-1081

Signed-of-by: Shameem Ahmed shmeeh@amazon.com

50 of 54 new or added lines in 7 files covered. (92.59%)

4 existing lines in 2 files now uncovered.

49496 of 65492 relevant lines covered (75.58%)

327366.0 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
2
93.42
0.08% contrib/babelfishpg_common/src/datetime.c
2
93.15
-1.49% contrib/babelfishpg_tds/src/backend/tds/tdstimestamp.c

Uncovered Existing Lines

Lines Coverage ∆ File
2
76.16
-0.62% contrib/babelfishpg_tds/src/backend/tds/tdscomm.c
2
93.15
-1.49% contrib/babelfishpg_tds/src/backend/tds/tdstimestamp.c
Jobs
ID Job ID Ran Files Coverage
1 17260507915.1 27 Aug 2025 08:16AM UTC 120
75.58
GitHub Action Run
Source Files on build 17260507915
  • Tree
  • List 120
  • Changed 8
  • Source Changed 7
  • Coverage Changed 7
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #17260507915
  • 6f86e105 on github
  • Prev Build on BABEL_4_7_STABLE (#17223129979)
  • Next Build on BABEL_4_7_STABLE (#18138166071)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc