Skip to content

Commit

Permalink
support stored system procedures (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
nktks authored Jul 4, 2024
1 parent c70d18b commit e1ee214
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type QueryStats struct {

var (
// SQL
selectRe = regexp.MustCompile(`(?is)^(?:WITH|@{.+|SELECT)\s.+$`)
selectRe = regexp.MustCompile(`(?is)^(?:WITH|CALL|@{.+|SELECT)\s.+$`)

// DDL
createDatabaseRe = regexp.MustCompile(`(?is)^CREATE\s+DATABASE\s.+$`)
Expand Down
15 changes: 15 additions & 0 deletions statement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,21 @@ func TestBuildStatement(t *testing.T) {
input: "DESC SELECT * FROM t1",
want: &ExplainStatement{Explain: "SELECT * FROM t1"},
},
{
desc: "Stored system procedures",
input: `CALL cancel_query("1234567890123456789")`,
want: &SelectStatement{Query: `CALL cancel_query("1234567890123456789")`},
},
{
desc: "EXPLAIN Stored system procedures",
input: `EXPLAIN CALL cancel_query("1234567890123456789")`,
want: &ExplainStatement{Explain: `CALL cancel_query("1234567890123456789")`},
},
{
desc: "EXPLAIN ANALYZE Stored system procedures",
input: `EXPLAIN ANALYZE CALL cancel_query("1234567890123456789")`,
want: &ExplainAnalyzeStatement{Query: `CALL cancel_query("1234567890123456789")`},
},
} {
t.Run(test.desc, func(t *testing.T) {
got, err := BuildStatement(test.input)
Expand Down

0 comments on commit e1ee214

Please sign in to comment.