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

babelfish-for-postgresql / babelfish_extensions / 14970420966
77%

Build:
DEFAULT BRANCH: BABEL_5_X_DEV
Ran 12 May 2025 11:29AM UTC
Jobs 1
Files 116
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

12 May 2025 10:56AM UTC coverage: 75.175%. Remained the same
14970420966

push

github

web-flow
Use Index Scan for EXACT and PREFIX pattern matches for LIKE  (#3582)

We have supported LIKE from TSQL side for case insensitive collation by transforming LIKE to ILIKE (this is a PG operator
which sorts strings case insensitively based on active locale). We have also introduced optimisation in place for the case
when the rightop of the LIKE operator is a Const node and has prefix. Eg:

-- CASE 1
SELECT COL FROM TAB WHERE COL LIKE 'ab'

-- CASE 2
SELECT COL FROM TAB WHERE COL LIKE 'a%'

This is the optimisation that we follow:

expression LIKE pattern

will become if pattern has exact match

expression = pattern

will become if pattern has prefix match

expression ILIKE pattern COLLATE cs_as AND
expression BETWEEN patternConstPrefix AND patternConstPrefix || E'\uFFFF 

E’\uFFFF is the highest sort key. We use the BETWEEN operator as in PG we can NOT use index scan for LIKE/ILIKE
operator. Whereas introducing BETWEEN will enable us to do so. And the CS_AS collation is used to store the locale info
for ILIKE.

For supporting case insensitive accent insensitive collations like latin1_general_ci_ai , we transform the node firstly by
adding a FuncExpr (remove_accents_internal) which removes the accent and then we apply the above logic.

Currently we have observed that we do not comply with the transformation above for CS collations. Rather than
COLLATE CS_AS, we observe COLLATE “default” in query plan. Consider the following query:

-- query (column a is collated with latin1_genetal_ci_as)
select a from varchar_tst where a collate chinese_prc_cs_as LIKE 'ab%'

-- query plan
Filter: (((a)::text ~~ 'ab%'::text COLLATE "default") 
This commit handles case sensitive collation in babelfish side as well with the above mentioned optimisation for EXACT and PREFIX pattern match.

We have the optimisation for EXACT and PREFIX pattern match so that =, > and <= operators can use Index when the left
operand has an Index on it. Till now babelfish was unable to use Inde... (continued)

49 of 50 new or added lines in 3 files covered. (98.0%)

3 existing lines in 1 file now uncovered.

47998 of 63848 relevant lines covered (75.18%)

299753.47 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
92.01
-0.03% contrib/babelfishpg_tsql/src/pltsql_utils.c

Uncovered Existing Lines

Lines Coverage ∆ File
3
72.43
-0.6% contrib/babelfishpg_tds/src/backend/tds/tdsutils.c
Jobs
ID Job ID Ran Files Coverage
1 14970420966.1 12 May 2025 11:29AM UTC 116
75.18
GitHub Action Run
Source Files on build 14970420966
  • Tree
  • List 116
  • Changed 4
  • Source Changed 3
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #14970420966
  • e119968d on github
  • Prev Build on BABEL_5_X_DEV (#14932031366)
  • Next Build on BABEL_5_X_DEV (#14972467354)
  • 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