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

Function ReleaseAST

pkg/sql/ast/pool.go:458–480  ·  view source on GitHub ↗

ReleaseAST returns an AST container to the pool for reuse. ReleaseAST cleans up and returns the AST to the pool, allowing it to be reused in future NewAST() calls. This is critical for memory efficiency and performance. Cleanup Process: 1. Returns all statement objects to their respective pools 2.

(ast *AST)

Source from the content-addressed store, hash-verified

456//
457// See also: NewAST(), PutSelectStatement(), PutInsertStatement()
458func ReleaseAST(ast *AST) {
459 if ast == nil {
460 return
461 }
462
463 // Clean up all statements
464 for i := range ast.Statements {
465 releaseStatement(ast.Statements[i])
466 ast.Statements[i] = nil
467 }
468
469 // Reset slice but keep capacity
470 ast.Statements = ast.Statements[:0]
471
472 // Reset comments but keep capacity
473 if cap(ast.Comments) > 0 {
474 ast.Comments = ast.Comments[:0]
475 }
476
477 // Return to pool
478 metrics.RecordNamedPoolPut("ast")
479 astPool.Put(ast)
480}
481
482// ReleaseStatements returns a slice of statements back to their respective pools.
483// Use this to clean up statements returned by ParseWithRecovery, which returns

Calls 3

RecordNamedPoolPutFunction · 0.92
releaseStatementFunction · 0.85
PutMethod · 0.80