ClickHouse / ClickHouse/clickhouse-go

wrong result for numeric and positional parameters check in query

Open
#935 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
3.3k
Forks
680
Avg merge
2d 3h
Merged PRs (30d)
14

Description

When I build a request similar to this one

`select`
`my_other_field`
`from`
`my_other_table`
`where`
`toString((joinGet('my_db.my_table', 'my_field', cityHash64(lower(my_string_value))) as m_s_v) ? 'my_string_data' : '') <> $1`

Driver returns "clickhouse [bind]: mixed named, numeric or positional parameters" and doesn't send query to Clickhouse, because of the check in bind() function

`var bindNumericRe = regexp.MustCompile(`\$[0-9]+`)`
`var bindPositionalRe = regexp.MustCompile(`[^\\][?]`)`

But if I send request with a CLI clickhouse-client, query works and returns data

Is it possible to fix this problem?

#### Environment
* Client version: 2.4.3
* Language version: English
* OS: Linux
* Interface: ClickHouse API / database/sql compatible driver

#### ClickHouse server
* ClickHouse Server version: 22.1.3.7

Contributor guide

Open the contributing guide

Research direction

Start in the bind() function at bindNumericRe and bindPositionalRe, using the supplied query as the reproduction case. Check the parameter classification against the ClickHouse client result, then verify that this query is accepted and returns data without the mixed-parameters error.

Written by the indexing model from the issue text.

Assessment

Tech stack
clickhouse, go, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.