Skip to content

Conversation

@JC1738
Copy link
Owner

@JC1738 JC1738 commented Jan 20, 2026

Summary

  • Add helper functions to duckdb-go-api for error handling and vector assignment
  • Refactor DuckArrow to use these helpers, reducing boilerplate and memory leak risk

New Helper Functions (in duckdb-go-api)

Error Handling:

  • SetBindError(info BindInfo, format string, args...) - for table function bind callbacks
  • SetInitError(info InitInfo, format string, args...) - for table function init callbacks
  • SetFunctionError(info FunctionInfo, format string, args...) - for table function scan callbacks

Vector Assignment:

  • AssignStringToVector(vec Vector, idx int, str string) - for VARCHAR columns
  • AssignBytesToVector(vec Vector, idx int, data []byte) - for BLOB columns

Changes

File Changes
table_function.go Replace ~8 error handling blocks, update string/binary conversions
config_function.go Use AssignStringToVector for result message
version_function.go Use AssignStringToVector for version output
duckdb-go-api Update submodule with new helper functions
tests/*.sql Fix credentials and TLS settings

Impact

Metric Before After
Error handling lines ~60 lines ~15 lines
String assignment boilerplate Inconsistent Centralized
Memory leak risk Higher (manual CString/free) Lower (encapsulated)

Test plan

  • Unit tests pass (make test-unit)
  • Integration tests pass (make test-all)
  • Build succeeds (make build)
  • Code review completed

Use SetBindError, SetInitError, SetFunctionError helpers for error handling
with automatic memory management, reducing boilerplate from 3-4 lines to 1.

Use AssignStringToVector and AssignBytesToVector helpers for string/binary
assignment, simplifying type conversion code.

Changes:
- table_function.go: Replace ~8 error blocks, update string/binary conversions
- config_function.go: Use AssignStringToVector for result message
- version_function.go: Use AssignStringToVector for version output
- Update duckdb-go-api submodule with new helper functions
- Fix test credentials (gizmosql_user) and TLS settings
DuckDB CLI v1.4.0 only supports loading extensions built for C API v1.2.0.
Update Makefile to embed v1.2.0 (matching main.go's duckdb.Init call) so
the extension can load correctly.

The headers from v1.4.0 are still used for new features, but the declared
API version must be v1.2.0 for compatibility.
@JC1738 JC1738 merged commit a9a96bd into main Jan 20, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants