[MDEV-10422] INSERT RETURNING Created: 2016-07-24  Updated: 2023-10-18  Resolved: 2017-05-29

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: VAROQUI Stephane Assignee: Unassigned
Resolution: Duplicate Votes: 3
Labels: None

Issue Links:
Duplicate
duplicates MDEV-10014 Add RETURNING to INSERT Closed
Relates
relates to MDEV-3814 Implement DELETE with result set (mwl... Closed
relates to MDEV-5092 Implement UPDATE with result set In Review
relates to MDEV-8307 Allow DELETE FROM RETURNING to be use... Open

 Description   

Dear Developers,

Would make sense after getting any default possible value in columns to have INSERT RETURNING syntax , that send back resultset off every columns that do set a default value in a ROW.

In useful in such cases :

  • to get back an array of auto increment PK values for connectors batch mode
  • to enable ORM to have a real object view of some default values inserted inside records
  • in multi master and Galera to stop using auto-increment for PK in profit of uuid_short
  • to pack protocol roundtrip like last_insert_id

Oracle allow sequence for this:
https://oracle-base.com/articles/misc/dml-returning-into-clause
postgresql
https://www.postgresql.org/docs/9.2/static/sql-insert.html

MsSQL works for every default like UID
INSERT INTO table (name)
OUTPUT Inserted.ID
VALUES('bob');

SqlLite
https://github.com/jazzyb/sqlite_ecto/wiki/Sqlite.Ecto's-Pseudo-Returning-Clause

Thanks in advance



 Comments   
Comment by Michaël de groot [ 2016-07-24 ]

This is a great idea! Would save 1 query with its rtt and in case of multi inserts a lot of effort and complexity.

Generated at Thu Feb 08 07:42:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.