Skip to content

Commit be4fd8a

Browse files
committed
Eliminate allocation in *Stmt.ColumnName
Fixes #118
1 parent eecedde commit be4fd8a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
[Unreleased]: https://github.com/zombiezen/go-sqlite/compare/v1.4.0...main
99

10+
## [Unreleased][]
11+
12+
### Changed
13+
14+
- The minimum `modernc.org/sqlite` version updated to 1.36.1.
15+
16+
### Fixed
17+
18+
- `*Stmt.ColumnName` no longer performs an allocation
19+
([#101](https://github.com/zombiezen/go-sqlite/issues/118)).
20+
- The doc comment for `OpenFlags` has been rewritten for clarity
21+
([#114](https://github.com/zombiezen/go-sqlite/pull/114)).
22+
1023
## [1.4.0][] - 2024-09-23
1124

1225
Version 1.4 adds the `sqlitex.ResultBytes` function

sqlite.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,12 @@ func (stmt *Stmt) ColumnCount() int {
869869
//
870870
// https://sqlite.org/c3ref/column_name.html
871871
func (stmt *Stmt) ColumnName(col int) string {
872-
return libc.GoString(lib.Xsqlite3_column_name(stmt.conn.tls, stmt.stmt, int32(col)))
872+
for name, namedCol := range stmt.colNames {
873+
if namedCol == col {
874+
return name
875+
}
876+
}
877+
return ""
873878
}
874879

875880
// BindParamCount reports the number of parameters in stmt.

0 commit comments

Comments
 (0)