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

Function SplitSQL

backend/plugin/parser/pg/split.go:18–36  ·  view source on GitHub ↗

SplitSQL splits the given SQL statement into multiple SQL statements. It uses omni's lexical splitter which handles quotes, dollar-quotes, comments, and BEGIN ATOMIC blocks without requiring valid SQL.

(statement string)

Source from the content-addressed store, hash-verified

16// It uses omni's lexical splitter which handles quotes, dollar-quotes,
17// comments, and BEGIN ATOMIC blocks without requiring valid SQL.
18func SplitSQL(statement string) ([]base.Statement, error) {
19 segments := omnipg.Split(statement)
20
21 result := make([]base.Statement, 0, len(segments))
22 positionMapper := base.NewByteOffsetPositionMapper(statement)
23 for _, seg := range segments {
24 result = append(result, base.Statement{
25 Text: seg.Text,
26 Empty: seg.Empty(),
27 Start: positionMapper.Position(seg.ByteStart),
28 End: positionMapper.Position(seg.ByteEnd),
29 Range: &storepb.Range{
30 Start: int32(seg.ByteStart),
31 End: int32(seg.ByteEnd),
32 },
33 })
34 }
35 return result, nil
36}

Callers 5

TestPostgreSQLParserFunction · 0.70
skipHeadingSQLsFunction · 0.70
parsePgStatementsFunction · 0.70

Calls 2

PositionMethod · 0.95