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 current parser does not support multi-statement SQL parsing. Is there any alternative method to solve this problem? #1427

Open
tchen-coder opened this issue Aug 18, 2023 · 0 comments

Comments

@tchen-coder
Copy link

Feature Request

SQL Query

-- SQL query
set @temp=0;
select cnt into @temp from tst ORDER BY cnt DESC LIMIT 1;
Update tst set cnt=@temp+100 where id in(10);

// Go code for parsing the SQL query
sql := "set @temp=0;select cnt into @temp from tst ORDER BY cnt DESC LIMIT 1;Update tst set cnt=@temp+100 where id in(10);"
p := parser.New()
stmtNodes, _, err := p.Parse(sql, "", "")

if err != nil {
    fmt.Println("Error parsing SQL:", err)
    return
}
for _, stmtNode := range stmtNodes {
    fmt.Println("Parsed statement:", stmtNode.Text())
}

Error parsing SQL: line 1 column 27 near "into @temp from tst ORDER BY cnt DESC LIMIT 1;Update tst set cnt=@temp+100 where id in(10);"

-- SQL for creating database table
CREATE TABLE `tst` (
    `id` int(10) DEFAULT NULL,
    `cnt` int(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant