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

Function PutSelectStatement

pkg/sql/ast/pool.go:663–718  ·  view source on GitHub ↗

PutSelectStatement returns a SelectStatement to the pool Uses iterative cleanup via PutExpression to handle deeply nested expressions

(stmt *SelectStatement)

Source from the content-addressed store, hash-verified

661// PutSelectStatement returns a SelectStatement to the pool
662// Uses iterative cleanup via PutExpression to handle deeply nested expressions
663func PutSelectStatement(stmt *SelectStatement) {
664 if stmt == nil {
665 return
666 }
667
668 // Collect all expressions to clean up
669 expressions := make([]Expression, 0, len(stmt.Columns)+len(stmt.OrderBy)+3)
670
671 // Collect column expressions
672 for _, col := range stmt.Columns {
673 if col != nil {
674 expressions = append(expressions, col)
675 }
676 }
677
678 // Collect ORDER BY expressions
679 for _, orderBy := range stmt.OrderBy {
680 if orderBy.Expression != nil {
681 expressions = append(expressions, orderBy.Expression)
682 }
683 }
684
685 // Collect WHERE expression
686 if stmt.Where != nil {
687 expressions = append(expressions, stmt.Where)
688 }
689
690 // Note: Limit and Offset are *int, not Expression, so no cleanup needed
691
692 // Clean up all expressions using iterative approach
693 for _, expr := range expressions {
694 PutExpression(expr)
695 }
696
697 // Reset fields
698 for i := range stmt.Columns {
699 stmt.Columns[i] = nil
700 }
701 stmt.Columns = stmt.Columns[:0]
702
703 for i := range stmt.OrderBy {
704 stmt.OrderBy[i].Expression = nil
705 }
706 stmt.OrderBy = stmt.OrderBy[:0]
707
708 stmt.TableName = ""
709 stmt.PrewhereClause = nil
710 stmt.Where = nil
711 stmt.Limit = nil
712 stmt.Offset = nil
713 stmt.Fetch = nil
714 stmt.For = nil
715
716 // Return to pool
717 selectStmtPool.Put(stmt)
718}
719
720// GetIdentifier gets an Identifier from the pool

Callers 6

TestSelectStatementPoolFunction · 0.85
releaseStatementFunction · 0.85
BenchmarkParallelFunction · 0.85

Calls 2

PutExpressionFunction · 0.85
PutMethod · 0.80

Tested by 5

TestSelectStatementPoolFunction · 0.68
BenchmarkParallelFunction · 0.68