Updated VIEW does not work with ON CONFLICT in Postgres 9.5

PostgreSQL Version: 9.5.4

I have a table defined as:

CREATE TABLE IF NOT EXISTS TEST_1 (
ID       SERIAL PRIMARY KEY,
C1       BYTEA,
C2       TEXT NOT NULL,
C3       BOOLEAN NOT NULL DEFAULT FALSE,
CONSTRAINT TEST_1_unique_idx UNIQUE(C1, C2)
);

I have a view defined as:

create or replace view test as select * from test_1 with cascaded check
option;

This is necessary to abstract from the name of the table, while the application code is working through the name of the view (to implement a kind of simple partitioning with replacing tables if necessary)

When I ran the following query in the view :

insert into test (c1, c2, c3) values (decode('MTIzAAE=', 'base64'), 'text', true) on conflict (c1, c2) do update set c3=excluded.c3

I get the following error:

[0A000] ERROR: ON CONFLICT is not supported on table "test" used as a catalog table
  Position: 83

But the same query in the table works as expected. According to the Postgres documentation, this should work with the view as well, since ON CONFLICT is fully supported by updated views https://www.postgresql.org/docs/9.5/static/sql-createview.html

Any ideas what I am missing?

+2
1

-, , with check option

with cascaded check option, .

, .

+1

Source: https://habr.com/ru/post/1670701/


All Articles