BUG #18502: Upsert on view returns 42P10 error when condition is an expression

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: michael(dot)wanghai(dot)a(at)outlook(dot)com
Subject: BUG #18502: Upsert on view returns 42P10 error when condition is an expression
Date: 2024-06-11 09:01:25
Message-ID: 18502-545b53f5b81e54e0@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18502
Logged by: Michael Wang
Email address: michael(dot)wanghai(dot)a(at)outlook(dot)com
PostgreSQL version: 12.5
Operating system: Official docker Image run in MacOS 14.3
Description:

I have a table, index and view like following:
```
CREATE TABLE my_table
(
id uuid primary key,
data jsonb not null
);
CREATE UNIQUE INDEX ON my_table ((data ->> 'key'));
CREATE VIEW my_view AS SELECT * FROM my_table;
```
The upsert on view returns 42P10 error when I execute the following SQL
```
INSERT INTO my_view (id, data)
VALUES ('990cc75c-2e60-4c0d-8bec-9ac976dc03bc'::uuid,
'{
"key": "value"
}'::jsonb)
ON CONFLICT ((data ->> 'key'))
DO NOTHING;
```
I tested cast expression and fails as well
```
CREATE UNIQUE INDEX ON my_table ((id::text));
INSERT INTO my_view (id, data)
VALUES ('990cc75c-2e60-4c0d-8bec-9ac976dc03bc'::uuid,
'{
"key": "value"
}'::jsonb)
ON CONFLICT ((id::text))
DO NOTHING;
```
I also tested `DO UPDATE...`, the same error is returned.
I also tested with the latest official docker image witch is PG 16, same
error returns.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2024-06-11 09:02:25 Re: BUG #18377: Assert false in "partdesc->nparts >= pinfo->nparts", fileName="execPartition.c", lineNumber=1943
Previous Message Alexander Lakhin 2024-06-11 08:00:01 Re: BUG #18483: Segmentation fault in tests modules