-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
MDEV-27013: COM_STMT_PREPARE returns 0 columns for INSERT .. RETURNING #4045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 10.6
Are you sure you want to change the base?
Conversation
The problem with current correction is that the expected number of columns is returned, but no columns follows. see a few line above : |
Thanks @rusher The comm list matches the list in Ready:
|
…ETE .. RETURNING To satisfy the protocol requirements the SQL statements with RETURNING, the protocol needed to indicate the number of columns returned. Once there the columns returned is indicated, then the column definition packet is required to follow in the protocol. To achieve this the check_prepared_statement for the specific commands that support RETURNING, and have been parsed to have returning now include the column count followed by the metadata. INSERT .. SELECT ... RETURNING and REPLACE .. SELECT .. RETURNING previously didn't populate the fields required. Where a null sel_res is passed to the function mysql_insert_select_prepare it was an non-prepared statement with without RETURNING or it might be a prepared statement with returning. In that case, prepare the result returning fields. Without this MariaDB would segfault in result.send_result_set_metadata as the item.field items where null. Note the unit test would return the correct results the server correction changed as it was populated from the COM_STMT_EXECUTE rather than the COM_STMT_PREPARE packet. This test useful to run via socat interceptor[1] to examine the results at offset 9 after packet beginning 0c along with the fields that are returned afterwards. Also it tests the required server code paths. tests/mariadb-client-test -S /tmp/intercept.sock -u $USER -D test test_mdev_27013 [1] socat -x -v UNIX-LISTEN:/tmp/intercept.sock,fork UNIX-CONNECT:/tmp/mariadb.sock
Description
If this was a SELECT statement, the columns would be populated by the mysql_test_insert call to send_prep_stmt. So we need to get the column count for returning statements and populate this instead of 0.
Release Notes
TODO: What should the release notes say about this change?
Include any changed system variables, status variables or behaviour. Optionally list any https://mariadb.com/kb/ pages that need changing.
How can this PR be tested?
Basing the PR against the correct MariaDB version
main
branch.PR quality check