BUG #18000: Access method used by matview can be dropped leaving broken matview

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #18000: Access method used by matview can be dropped leaving broken matview
Date: 2023-06-26 08:00:01
Message-ID: 18000-9145c25b1af475ca@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: 18000
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)com
PostgreSQL version: 16beta1
Operating system: Ubuntu 22.04
Description:

The following script:
BEGIN;
CREATE ACCESS METHOD heap2 TYPE TABLE HANDLER heap_tableam_handler;
CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT 1::int;
ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2;
DROP ACCESS METHOD heap2;
SELECT * FROM heapmv;
COMMIT;
SELECT * FROM heapmv;
DROP MATERIALIZED VIEW heapmv;

drops the access method heap2, but leaves the materialized view heapmv,
which then can not be accessed nor dropped:
ERROR: cache lookup failed for access method 16390

You cannot dump the database, too:
pg_dump: error: query failed: ERROR: cache lookup failed for access method
16390
pg_dump: detail: Query was: SELECT
pg_catalog.pg_get_viewdef('16391'::pg_catalog.oid) AS viewdef

But if the access method was set during a matview creation, it's deletion
is
prevented as expected:
CREATE ACCESS METHOD heap2 TYPE TABLE HANDLER heap_tableam_handler;
CREATE MATERIALIZED VIEW heapmv USING heap2 AS SELECT 1::int;
DROP ACCESS METHOD heap2;
ERROR: cannot drop access method heap2 because other objects depend on it
DETAIL: materialized view heapmv depends on access method heap2
HINT: Use DROP ... CASCADE to drop the dependent objects too.

Reproduced on REL_15_STABLE .. master.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2023-06-26 08:04:26 Re: BUG #17949: Adding an index introduces serialisation anomalies.
Previous Message PG Bug reporting form 2023-06-26 07:06:07 BUG #17999: comment to BUG 17990 (PSQL Process hangs in parallel mode)