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

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

Build:
Build:
LAST BUILD BRANCH: datetime2fromparts_bugfix
DEFAULT BRANCH: BABEL_5_X_DEV
Ran 01 Oct 2024 07:02AM UTC
Jobs 1
Files 115
Run time 1min
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

01 Oct 2024 06:26AM UTC coverage: 74.474% (+0.004%) from 74.47%
11119835728

push

github

web-flow
Fix CASE statement when branch expression is of String Datatype. (#2931)

Issue:

Return type of overall CASE expression when branch expression is of string datatype gives a different return type as
compared to TSQL expression.

eg. Return type of overall CASE expression is evaluated to become VARCHAR, if all branches are of NVARCHAR type
because Postgres tries to coerce result of every branch expression to base type (VARCHAR), whereas in TSQL, overall
return type is NVARCHAR in this example.

CREATE TABLE ALLTEXTS(
  CODE nvarchar(30) NOT NULL,
  LANG nvarchar(2) NOT NULL,
  TEXT nvarchar(2000) NULL
)

INSERT INTO ALLTEXTS (CODE, LANG, TEXT) VALUES ('53075', 'EN', N'Registration Card - Standard');

INSERT INTO ALLTEXTS (CODE, LANG, TEXT) VALUES ('53075', 'AR', N'بطاقة التسجيل - قياسية');

INSERT INTO ALLTEXTS (CODE, LANG, TEXT) VALUES ('53075', 'JP', N'登録カード–標準');

SELECT CASE WHEN 1 = 1 THEN TEXT END AS WrongValue2 FROM ALLTEXTS

Return type: varchar
expected type: nvarchar

Changes made to fix the issues:

tsql_select_common_type_hook() is set to return common_type for all branches when branch expression is of string
datatype, that calculate according to the TSQL precedence, whereas till now it was set according to the PG precedence
order (which was different from TSQL). This hook solved our problem as it returns result according to the TSQL
precedence order. 

We have also fixed the typmod of resultant expression by calculating the common typmod and setting all branches of
CASE statement to the calculated typmod.

Task: BABEL-5103, BABEL-4332
Signed-off-by: Yashneet Vinayak <yashneet@amazon.com>

36 of 36 new or added lines in 1 file covered. (100.0%)

2 existing lines in 2 files now uncovered.

45121 of 60586 relevant lines covered (74.47%)

162232.64 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
1
81.62
0.25% contrib/babelfishpg_tsql/src/pltsql_coerce.c
1
73.8
-0.21% contrib/babelfishpg_tds/src/backend/tds/tdsutils.c
Jobs
ID Job ID Ran Files Coverage
1 11119835728.1 01 Oct 2024 07:02AM UTC 115
74.47
GitHub Action Run
Source Files on build 11119835728
  • Tree
  • List 115
  • Changed 77
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #11119835728
  • 43f1a579 on github
  • Prev Build on BABEL_4_X_DEV (#11109596996)
  • Next Build on BABEL_4_X_DEV (#11122537724)
  • 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

© 2025 Coveralls, Inc