MCPcopy Create free account
hub / github.com/bytebase/bytebase / getPrependStatements

Function getPrependStatements

backend/plugin/parser/pg/restore.go:299–321  ·  view source on GitHub ↗
(statement string)

Source from the content-addressed store, hash-verified

297}
298
299func getPrependStatements(statement string) (string, error) {
300 stmts, err := ParsePg(statement)
301 if err != nil {
302 return "", errors.Wrap(err, "failed to parse statement")
303 }
304
305 for _, stmt := range stmts {
306 if stmt.Empty() {
307 continue
308 }
309 vs, ok := stmt.AST.(*ast.VariableSetStmt)
310 if !ok {
311 continue
312 }
313 name := strings.ToLower(vs.Name)
314 if name == "role" || name == "search_path" {
315 text := strings.TrimRight(strings.TrimSpace(stmt.Text), ";")
316 return text, nil
317 }
318 }
319
320 return "", nil
321}

Callers 1

GenerateRestoreSQLFunction · 0.70

Calls 1

ParsePgFunction · 0.85

Tested by

no test coverage detected