Skip to content

Commit e1ee214

Browse files
authored
support stored system procedures (#171)
1 parent c70d18b commit e1ee214

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

statement.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ type QueryStats struct {
8282

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

8787
// DDL
8888
createDatabaseRe = regexp.MustCompile(`(?is)^CREATE\s+DATABASE\s.+$`)

statement_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,21 @@ func TestBuildStatement(t *testing.T) {
507507
input: "DESC SELECT * FROM t1",
508508
want: &ExplainStatement{Explain: "SELECT * FROM t1"},
509509
},
510+
{
511+
desc: "Stored system procedures",
512+
input: `CALL cancel_query("1234567890123456789")`,
513+
want: &SelectStatement{Query: `CALL cancel_query("1234567890123456789")`},
514+
},
515+
{
516+
desc: "EXPLAIN Stored system procedures",
517+
input: `EXPLAIN CALL cancel_query("1234567890123456789")`,
518+
want: &ExplainStatement{Explain: `CALL cancel_query("1234567890123456789")`},
519+
},
520+
{
521+
desc: "EXPLAIN ANALYZE Stored system procedures",
522+
input: `EXPLAIN ANALYZE CALL cancel_query("1234567890123456789")`,
523+
want: &ExplainAnalyzeStatement{Query: `CALL cancel_query("1234567890123456789")`},
524+
},
510525
} {
511526
t.Run(test.desc, func(t *testing.T) {
512527
got, err := BuildStatement(test.input)

0 commit comments

Comments
 (0)