Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
Description
Please add a RETURNING option to INSERT.
Example from PostgreSQL
postgres=# CREATE TABLE t1 (id SERIAL, name VARCHAR(100));
|
CREATE TABLE
|
postgres=# INSERT INTO t1(name) VALUES('test') RETURNING id;
|
id
|
----
|
1
|
(1 row)
|
|
INSERT 0 1
|
Inspired by: https://evertpot.com/writing-sql-for-postgres-mysql-sqlite/
This could make it easier to write statements which work with both MariaDB and PostgreSQL. And this might improve compatibility with Oracle RDBMS.
How it'll work:
- All variants of INSERT will work — INSERT ... VALUES, INSERT ... SET, INSERT ... SELECT
- INSERT ... ON DUPLICATE KEY UPDATE will work, will return the final row values (inserted or updated)
- REPLACE will return what's inserted
- INSERT IGNORE will return what it'll try to insert, (ignoring insert errors, as expected)
- INSERT DELAYED will, obviously, not work
- rows will be returned as they're being inserted. If the insert fails in the middle and is rolled back — rows might've been sent that didn't end up in the table
Attachments
Issue Links
- is duplicated by
-
MDEV-10422 INSERT RETURNING
- Closed
-
MDEV-20033 sql_mode="oracle" does not support INSERT INTO ... RETURNING
- Closed
- links to