[MDEV-23768] INSERT ... RETURNING sends metadata on error Created: 2020-09-20 Updated: 2021-08-05 Resolved: 2021-05-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Insert |
| Affects Version/s: | 10.5.5, 10.6.0 |
| Fix Version/s: | 10.5.10 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Georg Richter | Assignee: | Rucha Deodhar |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | django | ||
| Description |
|
When INSERT ... RETURNING fails, it sends metadata and afterwards error packet:
Output:
|
| Comments |
| Comment by Oleksandr Byelkin [ 2020-10-15 ] | ||||||||
|
georg, don't SELECT also sends metadata and then an error in case of error, what is wrong here? | ||||||||
| Comment by Georg Richter [ 2020-10-15 ] | ||||||||
|
sanja No, for e.g. COM_QUERY cllient expects error packet (0xFF) or metadata. Biut not 0xFF after sending metadata. See https://mariadb.com/kb/en/com_query/ | ||||||||
| Comment by Oleksandr Byelkin [ 2020-10-15 ] | ||||||||
|
georg SELECT can send not only metadata but also data (part of a result set) and then send an error packet. | ||||||||
| Comment by Oleksandr Byelkin [ 2020-10-15 ] | ||||||||
|
and INSERT ... RETURNING returns data as SELECT does. | ||||||||
| Comment by Georg Richter [ 2020-10-15 ] | ||||||||
|
sanja Can you give me an example where SELECT returns metadata followed by an error? | ||||||||
| Comment by Rucha Deodhar [ 2021-05-03 ] | ||||||||
|
georg
We first send metadata. Then when we start sending data. And when the sub query shouldn't send more than one row, we get error. | ||||||||
| Comment by Georg Richter [ 2021-05-03 ] | ||||||||
|
Both the Maria and the MySQL documentation describe the return value of the mysql_real_query function: The current implementation breaks the API but is also not consistent:
Also the documentation for mysql_field_count states, that this function should be used to determine if a previously exceuted statement produced a result set. In Connectors we use this to allocate buffers before processing the resultset. It doesn't make sense to allocate buffers for processing result set if an error instead of a result set will follow. The current implementation is not only inconsistent, it also breaks a lot of applications. PQExec (postgresql client library) for example returns an error immediately with and without index. | ||||||||
| Comment by Georg Richter [ 2021-05-03 ] | ||||||||
|
I will reopen this ticket - if it is not a server bug, it should be changed to documentation issue, since it needs to be documented when and under which circumstances mysql_send_query, mysql_real_query and mysql_stmt_execute will not return an error and how to handle errors with unbuffered result sets and server side cursors. Also the client/server protocol documentation needs to be updated. | ||||||||
| Comment by Oleksandr Byelkin [ 2021-05-04 ] | ||||||||
|
georg Yes exactly what I meant, sending error after metadata is not a server bug, it always can do so. | ||||||||
| Comment by Oleksandr Byelkin [ 2021-05-04 ] | ||||||||
|
georg you better create clear MDEV for documentation with reference to this bug, otherwise docuentation team will have hard time to understand what is needed from them. |