3 ms·
Is it? Returning the conflicts that weren't inserted seems more obviously useful to me.
by OJFord 6y ago
Is it? Returning the conflicts that weren't inserted seems more obviously useful to me.
- saltcured 6y agoThe RETURNING semantics produce content of the resulting row after insertion. For the ones that have been skipped, this could be ill-defined. The content is not just the content of the row data that was supplied, but potentially server-generated content from sequences, row-level triggers, etc.
- ivoras 6y agoThere's one HUGE upside for doing it the current way: autogenerated columns. E.g. CREATE TABLE t (id SERIAL PRIMARY KEY, x INTEGER UNIQUE); INSERT INTO t (x) VALUES (42), (43) ON CONFLICT DO NOTHING RETURNING *; This does EXACTLY the most useful thing if one of '42' or '43' conflicts.