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

Function SplitSQL

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

SplitSQL splits the given T-SQL script into statements. Strategy: use omni's mssql parser to obtain per-statement byte ranges, then emit one base.Statement per omni statement with strict byte-contiguity and position adjacency: 1. stmts[0].Range.Start == 0 stmts[i].Range.Start == stmts[i-1].Range.E

(statement string)

Source from the content-addressed store, hash-verified

34//
35// On parser failure, falls back to the semicolon-based tokenizer splitter.
36func SplitSQL(statement string) ([]base.Statement, error) {
37 omniStmts, err := omnimssql.Parse(statement)
38 if err != nil {
39 return splitBySemi(statement)
40 }
41 return toBaseStatements(statement, omniStmts), nil
42}
43
44func splitBySemi(statement string) ([]base.Statement, error) {
45 t := tokenizer.NewTokenizer(statement)

Callers 2

parseTSQLStatementsFunction · 0.70
skipHeadingSQLsFunction · 0.70

Calls 2

splitBySemiFunction · 0.85
toBaseStatementsFunction · 0.85

Tested by

no test coverage detected