fix: handle prepare response when number of fields in the prepare header does not match the actual number in the response #2056
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.
ref: #2052
Update: main reason for the #2052 is not the medatdata_follows flag and/or missing parameters. The issue is caused by prepare header returning number of placeholders in the query ( 1 for
select * from user order by ?
) but the actual number of parameters following the header is 0 - see #2052 (comment). Changing the scope of this PR to handle "ignored" parameters / columnsContext: we currently expect that prepare response has exactly num fields + num parameters ColumnnDefinition packets in the response. However ether of them could be skipped by the server even when num fields is > 0 and/or num parameters > 0.
See https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_stmt_prepare.html
Descoping:
metadata_follows
in COM_STMT_PREPARE_OK packet deserealisationOPTIONAL_RESULTSET_METADATA
/DEPRECATE_EOF
connection flags and metadata_follows COM_STMT_PREPARE_OK packet.execute()
call if expected and actual number of parameters do not match. In that case 2 options: store them separately ( reported number of parameters and array of deserialised parameter metadata ( could be empty ) OR fill array with default / unknown metadata.