PutSelectStatement returns a SelectStatement to the pool Uses iterative cleanup via PutExpression to handle deeply nested expressions
(stmt *SelectStatement)
| 661 | // PutSelectStatement returns a SelectStatement to the pool |
| 662 | // Uses iterative cleanup via PutExpression to handle deeply nested expressions |
| 663 | func 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 |