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

connect::prepareBatch parsed INSERT query incorrectly #1247

Closed
timmyb32r opened this issue Mar 24, 2024 · 2 comments · Fixed by #1252
Closed

connect::prepareBatch parsed INSERT query incorrectly #1247

timmyb32r opened this issue Mar 24, 2024 · 2 comments · Fixed by #1252
Labels

Comments

@timmyb32r
Copy link

In trunk now function prepareBatch trying to parse INSERT statement by regexp:

var splitInsertRe = regexp.MustCompile(`(?i)\sVALUES\s*\(`)
var columnMatch = regexp.MustCompile(`.*\((?P<Columns>.+)\)$`)

func (c *connect) prepareBatch(...)
    query = splitInsertRe.Split(query, -1)[0]
    colMatch := columnMatch.FindStringSubmatch(query)

so, the problem is - user can create any columnName into backticks, which also makes possible to match part of regexp.

Example (any column_name with parentheses as part of name):

INSERT INTO `my_schema`.`my_table` (`__primary_key`,`ColumnNameWithParentheses(something)`) VALUES (1,1);

I see good solution here - at least use tokenizer from Clickhouse antlr grammar instead of regexp.

I have PR with fix & test

@timmyb32r
Copy link
Author

damn, don't know how to allocate issue number, and link PR into issue.
So, the PR is into #1248
can anybody link that PR into this issue?)

@jkaflik
Copy link
Contributor

jkaflik commented Mar 25, 2024

@timmyb32r you already referenced it. GitHub does it automatically when you post a link/issue number.

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.

2 participants