Skip to content

Commit b2a7b43

Browse files
committed
Updating Parser interface documentation to include requirement to return vitess.ErrEmpty for empty queries
1 parent c5725b1 commit b2a7b43

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

sql/parser.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,21 @@ import (
2828
var GlobalParser Parser = NewMysqlParser()
2929

3030
type Parser interface {
31-
// ParseSimple takes only query string and returns the parsed statement.
31+
// ParseSimple takes a |query| and returns the parsed statement. If |query| represents a no-op statement,
32+
// such as ";" or "-- comment", then implementations must return Vitess' ErrEmpty error.
3233
ParseSimple(query string) (ast.Statement, error)
33-
// Parse parses using default parser options of the ctx and returns the parsed statement
34-
// along with the query string and remainder string if it's multiple queries.
34+
// Parse parses |query| using the default parser options of the ctx and returns the parsed statement
35+
// along with the query string and remainder string if it's multiple queries. If |query| represents a
36+
// no-op statement, such as ";" or "-- comment", then implementations must return Vitess' ErrEmpty error.
3537
Parse(ctx *Context, query string, multi bool) (ast.Statement, string, string, error)
36-
// ParseWithOptions parses using given parser options and returns the parsed statement
37-
// along with the query string and remainder string if it's multiple queries.
38+
// ParseWithOptions parses |query| using the given parser |options| and specified |delimiter|. The parsed statement
39+
// is returned, along with the query string and remainder string if |multi| has been set to true and there are
40+
// multiple statements in |query|. If |query| represents a no-op statement, such as ";" or "-- comment", then
41+
// implementations must return Vitess' ErrEmpty error.
3842
ParseWithOptions(ctx context.Context, query string, delimiter rune, multi bool, options ast.ParserOptions) (ast.Statement, string, string, error)
3943
// ParseOneWithOptions parses the first query using specified parsing returns the parsed statement along with
40-
// the index of the start of the next query.
44+
// the index of the start of the next query. If |query| represents a no-op statement, such as ";" or "-- comment",
45+
// then implementations must return Vitess' ErrEmpty error.
4146
ParseOneWithOptions(context.Context, string, ast.ParserOptions) (ast.Statement, int, error)
4247
}
4348

0 commit comments

Comments
 (0)