Skip to content

starts_with function are simplified incorrectly when the prefix contains an underscore #19076

Closed

Description

@willemv

Describe the bug

starts_with(expr, 'literal') functions are simplified to expr LIKE 'literal%'

The simplification process correctly escapes percent signs (%) in the pattern, but forgets to escape underscores (_). Underscores also have a special meaning in the LIKE operator: match any single character.

To Reproduce

Easy to reproduce with this query:

SELECT starts_with('foobar', 'foo_'), starts_with('foo_bar', 'foo_')
----
# current, incorrect result:
true, true

Expected behavior

The query above should result in

false, true

In other words, simplification of the starts_with function should escape underscores in patterns

Additional context

The ends_with function is not simplified, so is not affected by this bug

Activity

  1. added theissue type on Dec 3, 2025
  2. willemv commented on Dec 3, 2025

    @willemv
    ContributorAuthor

    take

  3. added a commit that references this issue on Dec 5, 2025
    340a28c
  4. added 3 commits that reference this issue on Jan 9, 2026
    dc5b7cd
    b4dac3a
    b4e6d5f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions