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

Function analyzeSafe

backend/plugin/parser/pg/query_span_loader_poc_test.go:2510–2520  ·  view source on GitHub ↗

analyzeSafe runs AnalyzeSelectStmt but returns (nil, err) instead of failing the test — probe tests need to record whether analyze succeeded.

(cat *catalog.Catalog, sql string)

Source from the content-addressed store, hash-verified

2508// analyzeSafe runs AnalyzeSelectStmt but returns (nil, err) instead of failing
2509// the test — probe tests need to record whether analyze succeeded.
2510func analyzeSafe(cat *catalog.Catalog, sql string) (*catalog.Query, error) {
2511 stmts, err := ParsePg(sql)
2512 if err != nil {
2513 return nil, errors.Wrap(err, "parse")
2514 }
2515 sel, ok := stmts[0].AST.(*ast.SelectStmt)
2516 if !ok {
2517 return nil, errors.Errorf("not a SelectStmt: %T", stmts[0].AST)
2518 }
2519 return cat.AnalyzeSelectStmt(sel)
2520}
2521
2522func targetsOf(q *catalog.Query) int {
2523 if q == nil {

Calls 2

ParsePgFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected