It seems that the vertica client had an issue consuming ReadyForQuery messages when prepared statements are used and several consecutive queries are rejected with permission error.
It seems that when a permission denied error is happening then the server replies with ErrorResponse and ReadyForQuery.
First attempt:
self._message in cursor.py is None
trying to read BindComplete in _execute_prepared_statement() but ErrorResponse is found -> self._message in cursor.py is sill None
ReadyForQuery after ErrorResponse is not consumed
Second attempt:
self._message in cursor.py is None
ReadyForQuery in buffer is consumed in execute() and stored to self._message
trying to read BindComplete in _execute_prepared_statement() but ErrorResponse is found -> self._message in cursor.py is now ReadyForQuery
ReadyForQuery after ErrorResponse is not consumed
Third attempt:
self._message in cursor.py is ReadyForQuery
ReadyForQuery is not consumed in execute() because self._message is ReadyForQuery
trying to read BindComplete in _execute_prepared_statement() but ReadyForQuery is found -> raising this anomaly as an exception
This fix introduces an error handler for the prepared statement execution to always set the ErrorResponse as self._message to make it possible for the flush_to_query_ready() in execute() to consume and store ReadyForQuery
Also integration test is added.
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
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.
Fixes bug (#579)
It seems that the vertica client had an issue consuming ReadyForQuery messages when prepared statements are used and several consecutive queries are rejected with permission error.
Faulty sequence of messages:
It seems that when a permission denied error is happening then the server replies with ErrorResponse and ReadyForQuery.
First attempt:
Second attempt:
Third attempt:
This fix introduces an error handler for the prepared statement execution to always set the ErrorResponse as self._message to make it possible for the flush_to_query_ready() in execute() to consume and store ReadyForQuery
Also integration test is added.