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

The locate function fails when the optional start_pos argument is not set and ignores it when it is set #466

Closed
slabko opened this issue Feb 10, 2025 · 0 comments · Fixed by #469
Labels

Comments

@slabko
Copy link
Contributor

slabko commented Feb 10, 2025

When calling locate with the start_pos argument specified, the ODBC driver always ignores it. For example, the following query finds the substring in both cases as if start_pos were either not specified or set to 1:

SELECT {fn locate('test', '1test', 5)}, {fn locate('test', '1234test', 5)};

The query incorrectly returns 2 and 5, instead of the expected 0 and 5 -- the substring 'test' should not be found in '1test' if the search starts from the 5th character.

In reality, the ODBC driver sends the following query to ClickHouse, completely omitting the start_pos parameter:

SELECT position('2test', 'test'), position('1234test', 'test');

However, the expected query should retain the start_pos parameter from the original query:

SELECT position('2test', 'test', 5), position('1234test', 'test', 5);

Moreover, if the locate function is called without the start_pos parameter, the ODBC driver fails to replace the {fn ...} escape sequence entirely.

For example, the following query:

SELECT {fn locate('test', 'test')};

is sent as-is, without replacing the {fn ...} sequence, leading to a syntax error on the ClickHouse side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant