Re: [HACKERS] INSERT ... ON CONFLICT () SELECT

2017-06-19 Thread Matt Pulver
On Sun, Jun 18, 2017 at 9:21 PM, Peter Geoghegan wrote: > Returning rows with duplicate values seems rather unorthodox. > Ok, then option 2 it is. In summary, this is what I am going to (attempt to) implement for the new syntax: INSERT ... ON CONFLICT (...) DO SELECT RETURNING

Re: [HACKERS] INSERT ... ON CONFLICT () SELECT

2017-06-18 Thread Peter Geoghegan
On Sun, Jun 18, 2017 at 4:33 AM, Matt Pulver wrote: > This would be nearly identical to the existing error message that is > produced when running: > > INSERT INTO example (name) VALUES ('foo'), ('foo') > ON CONFLICT (name) DO UPDATE SET value=1 > RETURNING * > > >

Re: [HACKERS] INSERT ... ON CONFLICT () SELECT

2017-06-18 Thread Matt Pulver
On Sat, Jun 17, 2017 at 9:55 PM, Peter Geoghegan wrote: > On Sat, Jun 17, 2017 at 7:49 AM, Matt Pulver > wrote: > > With the proposed "INSERT ... ON CONFLICT () SELECT" feature, the > > get_or_create_id() function is simplified to: > > Are you locking

Re: [HACKERS] INSERT ... ON CONFLICT () SELECT

2017-06-17 Thread Peter Geoghegan
On Sat, Jun 17, 2017 at 7:49 AM, Matt Pulver wrote: > With the proposed "INSERT ... ON CONFLICT () SELECT" feature, the > get_or_create_id() function is simplified to: Are you locking the existing rows? Because otherwise, the determination that they're conflicting can

[HACKERS] INSERT ... ON CONFLICT () SELECT

2017-06-17 Thread Matt Pulver
Hello, I am looking to add a new language feature that returns the rows that conflict on an INSERT, and would appreciate feedback and guidance on this. Here is an example. To implement a get_or_create_id() function, this is how it must currently be done: CREATE TABLE example ( id SERIAL