From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: michael.wanghai.a@outlook.com
Subject: BUG #18502: Upsert on view returns 42P10 error when condition is an expression
Date: Tue, 11 Jun 2024 09:01:25 +0000
Message-ID: <18502-545b53f5b81e54e0@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 18502
Logged by: Michael Wang
Email address: michael.wanghai.a@outlook.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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, michael.wanghai.a@outlook.com
Subject: Re: BUG #18502: Upsert on view returns 42P10 error when condition is an expression
In-Reply-To: <18502-545b53f5b81e54e0@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox