SQLite Forum

inconsistent output: insert on conflict with returning
Login
Well, PostgreSQL does behave differently here (see last `insert` below), again. So I'd be leaning more toward the bug side:

```
D:\oss>psql -h pq
Password for user ddevienne:
psql (12.1, server 12.5)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

ddevienne=> create temp table foo (name text unique);
CREATE TABLE
ddevienne=> insert into foo values ('name1') on conflict(name) do nothing returning *;
 name
-------
 name1
(1 row)


INSERT 0 1
ddevienne=> insert into foo values ('name1') on conflict(name) do nothing returning *;
 name
------
(0 rows)


INSERT 0 0
ddevienne=> drop table foo;
DROP TABLE
ddevienne=> create temp table foo (name text unique, amount int);
CREATE TABLE
ddevienne=> insert into foo values ('name1', 0) on conflict(name) do update set amount=excluded.amount returning *;
 name  | amount
-------+--------
 name1 |      0
(1 row)


INSERT 0 1
ddevienne=> insert into foo values ('name1', 1) on conflict(name) do update set amount=excluded.amount returning *;
 name  | amount
-------+--------
 name1 |      1
(1 row)


INSERT 0 1
ddevienne=>
```