MCPcopy Index your code
hub / github.com/bytebase/bytebase / SplitSQL

Function SplitSQL

backend/plugin/parser/mysql/split.go:20–29  ·  view source on GitHub ↗

SplitSQL splits the given SQL statement into multiple SQL statements. It uses omni's lexical splitter which handles quotes, comments, compound statements (BEGIN...END, IF...END IF, etc.) and DELIMITER without requiring valid SQL.

(statement string)

Source from the content-addressed store, hash-verified

18// statements (BEGIN...END, IF...END IF, etc.) and DELIMITER without
19// requiring valid SQL.
20func SplitSQL(statement string) ([]base.Statement, error) {
21 segments := mysqlparser.Split(statement)
22
23 result := make([]base.Statement, 0, len(segments))
24 positionMapper := base.NewByteOffsetPositionMapper(statement)
25 for _, seg := range segments {
26 result = append(result, base.NewStatementFromRange(statement, positionMapper, seg.ByteStart, seg.ByteEnd, seg.Empty()))
27 }
28 return result, nil
29}

Calls 2

NewStatementFromRangeFunction · 0.92