Skip to content

Commit 90eff75

Browse files
committed
fix: drop unused splitSQLStatements shim and unify ArrayConstructor cleanup
- Remove the unused splitSQLStatements shim from pkg/gosqlx/reader.go; golangci-lint's `unused` checker flagged it because golangci.yml runs with `tests: false`. The single test caller now uses SplitStatements directly with the explicit ANSI dialect. - Route ArrayConstructorExpression.Subquery through releaseStatement (matching In/Subquery/Exists/Any/All) instead of the type-specific PutSelectStatement helper, so non-SELECT statement subqueries dispatch through the shared cleanup path.
1 parent efee232 commit 90eff75

3 files changed

Lines changed: 9 additions & 13 deletions

File tree

pkg/gosqlx/reader.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,3 @@ func (c *ctxReader) Read(p []byte) (int, error) {
222222
return c.r.Read(p)
223223
}
224224

225-
// splitSQLStatements is retained as a thin shim over SplitStatements so
226-
// existing tests and internal callers that use the ANSI default keep working
227-
// unchanged. New code should call SplitStatements directly with an explicit
228-
// dialect.
229-
func splitSQLStatements(src string) []string {
230-
return SplitStatements(src, "")
231-
}

pkg/gosqlx/reader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ func TestSplitSQLStatements(t *testing.T) {
292292
}
293293
for _, tc := range cases {
294294
t.Run(tc.name, func(t *testing.T) {
295-
segs := splitSQLStatements(tc.in)
295+
segs := SplitStatements(tc.in, "")
296296
count := 0
297297
for _, s := range segs {
298298
if strings.TrimSpace(s) != "" {

pkg/sql/ast/pool_expression_release.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,12 @@ func putExpressionImpl(expr Expression, depth int) {
438438
e.Elements[i] = nil
439439
}
440440
e.Elements = e.Elements[:0]
441-
// Subquery is *SelectStatement — release through the
442-
// statement pool, not a bare nil-assign (leak before fix).
441+
// Subquery is a Statement (typically *SelectStatement); route
442+
// through the statement dispatcher to keep dispatch consistent
443+
// with InExpression / SubqueryExpression / Exists / Any / All
444+
// and to handle non-SELECT statement types correctly.
443445
if e.Subquery != nil {
444-
PutSelectStatement(e.Subquery)
446+
releaseStatement(e.Subquery)
445447
e.Subquery = nil
446448
}
447449
arrayConstructorPool.Put(e)
@@ -656,9 +658,10 @@ func PutArrayConstructor(ac *ArrayConstructorExpression) {
656658
ac.Elements[i] = nil
657659
}
658660
ac.Elements = ac.Elements[:0]
659-
// Subquery is *SelectStatement — release through the statement pool.
661+
// Subquery is a Statement; route through releaseStatement so non-SELECT
662+
// statement types (sequence ops etc.) dispatch correctly.
660663
if ac.Subquery != nil {
661-
PutSelectStatement(ac.Subquery)
664+
releaseStatement(ac.Subquery)
662665
ac.Subquery = nil
663666
}
664667
arrayConstructorPool.Put(ac)

0 commit comments

Comments
 (0)