Re: ERROR: failed to change schema dependency for type xxx.yyy

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Kouber Saparev <kouber(at)gmail(dot)com>, pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: ERROR: failed to change schema dependency for type xxx.yyy
Date: 2023-01-17 15:46:27
Message-ID: 2965714.1673970387@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> writes:
> On Tue, 2023-01-17 at 12:46 +0200, Kouber Saparev wrote:
>> Any ideas how we could proceed any further?
>> And btw what is the entry above: objid = 1202633909 + deptype = i?

> There was probably a dependency *missing*: you get this error message if
> the database wants to delete the dependency on the old schema and add
> one on the new schema, but it cannot find the former.
> This is data corruption, but considering the way you delete catalog entries,
> I am not surprised.

Indeed. Personally, when I want to look into pg_depend, I invariably
use pg_describe_object() to make sense of the entries.

regression=# create type foo as enum ('a','b');
CREATE TYPE
regression=# create schema bar;
CREATE SCHEMA
regression=# alter type public.foo set schema bar;
ALTER TYPE
regression=# create schema baz;
CREATE SCHEMA
regression=# alter type bar.foo set schema baz;
ALTER TYPE

regression=# select pg_describe_object(classid, objid, objsubid) as obj, pg_describe_object(refclassid, refobjid, refobjsubid) as ref, deptype from pg_depend where refobjid = 'baz.foo'::regtype;
obj | ref | deptype
----------------+--------------+---------
type baz.foo[] | type baz.foo | i
(1 row)

regression=# select pg_describe_object(classid, objid, objsubid) as obj, pg_describe_object(refclassid, refobjid, refobjsubid) as ref, deptype from pg_depend where objid = 'baz.foo'::regtype;
obj | ref | deptype
--------------+------------+---------
type baz.foo | schema baz | n
(1 row)

If you'd done it like that, you would probably have figured out fairly
quickly that you were looking at the wrong end of the dependency
relationships. See also

https://www.postgresql.org/docs/current/catalog-pg-depend.html

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Vivek Gadge 2023-01-17 17:32:26 Connection Taking time to authentication of database
Previous Message Laurenz Albe 2023-01-17 14:58:21 Re: ERROR: failed to change schema dependency for type xxx.yyy