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

babelfish-for-postgresql / babelfish_extensions / 11293830753
74%
BABEL_5_X_DEV: 77%

Build:
Build:
LAST BUILD BRANCH: babel_5688_min
DEFAULT BRANCH: BABEL_5_X_DEV
Ran 11 Oct 2024 02:41PM UTC
Jobs 1
Files 114
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

11 Oct 2024 02:06PM UTC coverage: 73.701% (+0.02%) from 73.679%
11293830753

push

github

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

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>

69 of 70 new or added lines in 3 files covered. (98.57%)

1 existing line in 1 file now uncovered.

43014 of 58363 relevant lines covered (73.7%)

142465.73 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
81.72
0.74% contrib/babelfishpg_tsql/src/pltsql_coerce.c

Uncovered Existing Lines

Lines Coverage ∆ File
1
81.72
0.74% contrib/babelfishpg_tsql/src/pltsql_coerce.c
Jobs
ID Job ID Ran Files Coverage
1 11293830753.1 11 Oct 2024 02:41PM UTC 114
73.7
GitHub Action Run
Source Files on build 11293830753
  • Tree
  • List 114
  • Changed 76
  • Source Changed 4
  • Coverage Changed 5
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #11293830753
  • c1720e72 on github
  • Prev Build on BABEL_3_X_DEV (#11256404749)
  • Next Build on BABEL_3_X_DEV (#11342002948)
  • 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