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

Function SanitizeSQL

backend/plugin/db/util/statement_parser.go:195–205  ·  view source on GitHub ↗

SanitizeSQL removes comments, splits the sql by `;` and returns the trimmed sql statement array.

(sql string)

Source from the content-addressed store, hash-verified

193
194// SanitizeSQL removes comments, splits the sql by `;` and returns the trimmed sql statement array.
195func SanitizeSQL(sql string) ([]string, error) {
196 query, err := removeCommentsAndTrim(sql)
197 if err != nil {
198 return nil, err
199 }
200 stmts, err := splitStatement(query)
201 if err != nil {
202 return nil, err
203 }
204 return stmts, nil
205}
206
207// IsDDL returns true if the given sql string is a DDL statement.
208func IsDDL(query string) bool {

Callers 10

QueryConnMethod · 0.92
dryRunQueryMethod · 0.92
ExecuteMethod · 0.92
QueryConnMethod · 0.92
ExecuteMethod · 0.92
QueryConnMethod · 0.92
explainStatementMethod · 0.92
ExecuteMethod · 0.92
QueryConnMethod · 0.92
TestSanitizeQueryFunction · 0.85

Calls 2

removeCommentsAndTrimFunction · 0.85
splitStatementFunction · 0.85

Tested by 1

TestSanitizeQueryFunction · 0.68