Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMILAR TO with constant pattern using ‘|’, ‘*’, ‘?’ or ‘{0,N}’ doesn't work as expected #8078

Closed
eFKaey opened this issue Apr 11, 2024 · 1 comment

Comments

@eFKaey
Copy link

eFKaey commented Apr 11, 2024

We want to migrate from Firebird 2.5 to a higher version. During my compatibility tests with Firebird 5.0, I encountered a SELECT query that produced different results compared to earlier versions (2.5 / 4.0). To pinpoint the discrepancies, I created small test databases for each Firebird version.

A SELECT query using LIKE yields consistent results across versions:

SELECT a.TESTCOLUMN1, a.ID
FROM TESTTABLE a
WHERE a.TESTCOLUMN1 LIKE '7264%'

Results:

FB 2.5 / 4.0 FB 5.0
72644 72644
72649 72649

However, when using SIMILAR TO, the results differ:

SELECT a.TESTCOLUMN1, a.ID
FROM TESTTABLE a
WHERE a.TESTCOLUMN1 SIMILAR TO '72649|72644'

Results:

FB 2.5 / 4.0 FB 5.0
72644 72649
72649

It appears that in Firebird 5.0, a SELECT query with SIMILAR TO only considers the first search parameter:

SELECT a.TESTCOLUMN1, a.ID
FROM TESTTABLE a
WHERE a.TESTCOLUMN1 SIMILAR TO '72644|72649'

Results:

FB 2.5 / 4.0 FB 5.0
72644 72644
72649
@asfernandes asfernandes self-assigned this Apr 11, 2024
@asfernandes
Copy link
Member

This was being caused by wrong optimization implemented in #6873
It's caused not only with |, but also with *, ? and {0,N}.

@asfernandes asfernandes changed the title FB 5.0: SIMILAR TO with the OR operator ‘|’ doesn't work as expected SIMILAR TO with constant pattern using ‘|’, ‘*’, ‘?’ or ‘{0,N}’ doesn't work as expected Apr 12, 2024
asfernandes added a commit that referenced this issue Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment