[MDEV-25382] cannot set local variable in the RETURNING clause of INSERT ... RETURNING Created: 2021-04-10 Updated: 2021-04-14 Resolved: 2021-04-11 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Insert |
| Affects Version/s: | 10.5.9 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Ashford Nichols | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | insert, insert_into | ||
| Environment: |
Linux Mint 20.1 |
||
| Issue Links: |
|
||||||||
| Description |
|
Given the following table:
I'm trying to create a stored routine that retrieves the auto-generated value of col3 using the RETURNING clause of the INSERT ... RETURNING statement, as follows:
However, I'm getting the following syntax error:
Also, this problem seems to only occur when attempting to set local variable, as I am able to rewrite the routine as follows:
|
| Comments |
| Comment by Sergei Golubchik [ 2021-04-11 ] | ||
|
RETURNING clause accepts the same syntax as a valid SELECT clause,
either | ||
| Comment by Ashford Nichols [ 2021-04-11 ] | ||
|
Please note that the following also doesn't work, despite being valid select syntax:
| ||
| Comment by Sergei Golubchik [ 2021-04-14 ] | ||
|
I suspect that
is not allowed too. That is, it doesn't work in SELECT, so it should not work in RETURNING either. But your first query RETURNING ... INTO makes perfect sense. It's not supported now, but it's a valid feature that we should implement some day. |