Fix typmod defaulting to 0 instead of -1 for all types#269
Merged
fuziontech merged 3 commits intomainfrom Feb 28, 2026
Merged
Conversation
PostgreSQL uses typmod=-1 to mean "no type modifier". Go's zero value for int32 is 0, so every TypeInfo without an explicit Typmod was sending typmod=0 on the wire. JDBC clients (pgjdbc) interpret this differently from -1: - INTERVAL typmod=0 → getScale() returns 0 (precision 0, no fractional seconds) instead of 6 (default microsecond precision) - TIME/TIMESTAMP typmod=0 → similar precision mismatch - Other types: typmod=0 can trigger unexpected metadata behavior This likely causes Metabase/JDBC NoSuchElementException errors when querying INTERVAL-returning functions like uptime(). Also adds missing rows.Err() check in handleExecute (extended query protocol). The simple query path checked for streaming errors but the extended protocol path did not, meaning gRPC stream errors from workers would be silently swallowed instead of reported to the client. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add STRING, TIME WITH TIME ZONE, TIMESTAMP WITH TIME ZONE, and unknown type (SOMECUSTOMTYPE) cases to TestMapDuckDBTypeTypmod - Add TestExtendedQueryErrorHandling integration test with two subtests: single error recovery and multi-cycle error/success on same connection Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TypeInforeturns that didn't explicitly setTypmodwere getting Go's zero value (0) instead of PostgreSQL's "no modifier" sentinel (-1). This caused JDBC clients (pgjdbc) to misinterpret column metadata — most critically for INTERVAL, where typmod=0 means "second precision 0" (no fractional seconds) vs typmod=-1 meaning "default precision" (microseconds).rows.Err()check inhandleExecute: The extended query protocol's Execute path didn't check for streaming errors after the row iteration loop. The simple query path (executeSelectQuery) already had this check. Without it, gRPC stream errors from workers could be silently swallowed, sendingCommandCompleteto the client without reporting the error.Context
Metabase (JDBC/c3p0) was reporting
java.util.NoSuchElementExceptionwhen runningselect worker_version(), uptime()with no corresponding errors in duckgres logs. Theuptime()macro returns an INTERVAL. pgjdbc'sTypeInfoCache.getScale()returnstypmod & 0xFFFFwhen typmod != -1, so typmod=0 → scale=0 (no fractional seconds), while typmod=-1 → scale=6 (default microsecond precision). This metadata mismatch between what duckgres reports and what the actual data contains is the likely root cause of the JDBC client error.Test plan
TestMapDuckDBTypeTypmodverifies all types return typmod=-1 except HUGEINT, UBIGINT, and DECIMAL(p,s) which have specific positive typmodsTestMapDuckDBTypestill passes (OID/Size unchanged)go test ./server/passesgo build ./...succeeds🤖 Generated with Claude Code