MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / parseSQL

Function parseSQL

pkg/sql/security/scanner_bench_test.go:27–41  ·  view source on GitHub ↗

parseSQL is a helper function to parse SQL and return the AST

(b *testing.B, sql string)

Source from the content-addressed store, hash-verified

25
26// parseSQL is a helper function to parse SQL and return the AST
27func parseSQL(b *testing.B, sql string) *ast.AST {
28 tkz := tokenizer.GetTokenizer()
29 defer tokenizer.PutTokenizer(tkz)
30 tokens, err := tkz.Tokenize([]byte(sql))
31 if err != nil {
32 b.Fatalf("Failed to tokenize: %v", err)
33 }
34
35 p := parser.NewParser()
36 tree, err := p.ParseFromModelTokens(tokens)
37 if err != nil {
38 b.Fatalf("Failed to parse: %v", err)
39 }
40 return tree
41}
42
43// BenchmarkScanner_CleanSQL benchmarks scanning clean SQL
44func BenchmarkScanner_CleanSQL(b *testing.B) {

Calls 6

ParseFromModelTokensMethod · 0.95
GetTokenizerFunction · 0.92
PutTokenizerFunction · 0.92
NewParserFunction · 0.92
TokenizeMethod · 0.80
FatalfMethod · 0.65

Tested by

no test coverage detected