Fix for panic in rows.Next() when stored procedures emit NOTICE messages#188
Merged
Merged
Conversation
sharmagot
reviewed
Mar 12, 2026
Collaborator
Author
|
Collaborator
|
The changes look good to me. Approving the MR. |
sharmagot
approved these changes
Mar 12, 2026
sharmagot
left a comment
Collaborator
There was a problem hiding this comment.
The changes look good to me. Approving the MR.
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.

Problem:
When calling a stored procedure that raises one or more RAISE NOTICE messages before returning its result set, rows.Next() panics with:
panic: runtime error: index out of range [1] with length 1Root cause:
The driver sizes the destination slice (dest []driver.Value) from the first RowDescription message it receives. When a stored procedure emits RAISE NOTICE messages, the protocol response interleaving can cause the driver to commit to a dest slice sized for fewer columns (e.g. 1) than the DataRow that arrives for the actual CALL result (e.g. 2 INOUT columns). The original loop iterated over rowCols.NumCols without any bounds check against dest, causing the out-of-bounds panic on the second column.
Fix:
Added expandColumnDefs(numCols uint16) on *rows (rows.go). When the first BEDataRowMsg is received during buffering, if the arriving DataRow has more fields than columnDefs currently describes, synthetic column definitions are appended to cover the gap. Synthetic entries use OID 0 so that rows.Next() returns raw wire bytes as a string rather than asserting a false specific type. database/sql's convertAssign correctly coerces these strings to the target Go types during Scan.
expandColumnDefs is called on the first BEDataRowMsg in both:
runSimpleStatement — simple query path
collectResults — prepared statement path (the path affected by this bug)
Additionally the BERowDescMsg handler in collectResults was updated to always prefer an execution-time RowDescription over the Describe-phase one (if no DataRows have been buffered yet), so that if Vertica ever fixes this behaviour the driver will automatically pick up complete type information without needing the synthetic fallback.
Test:
Added TestStoredProcedureWithNotice
Added TestStoredProcedureWithNoticeSimpleQuery