Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pHoAT-0003Wq-B4 for pgsql-admin@arkaria.postgresql.org; Tue, 17 Jan 2023 15:46:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pHoAS-0004uB-4j for pgsql-admin@arkaria.postgresql.org; Tue, 17 Jan 2023 15:46:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pHoAR-0004u2-Qv for pgsql-admin@lists.postgresql.org; Tue, 17 Jan 2023 15:46:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pHoAP-0004hj-F7 for pgsql-admin@lists.postgresql.org; Tue, 17 Jan 2023 15:46:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 30HFkRfF2965715; Tue, 17 Jan 2023 10:46:27 -0500 From: Tom Lane To: Laurenz Albe cc: Kouber Saparev , pgsql-admin@lists.postgresql.org Subject: Re: ERROR: failed to change schema dependency for type xxx.yyy In-reply-to: <4f49be99291439cfd0b04ec5c2c6f3ece6ed731a.camel@cybertec.at> References: <4f49be99291439cfd0b04ec5c2c6f3ece6ed731a.camel@cybertec.at> Comments: In-reply-to Laurenz Albe message dated "Tue, 17 Jan 2023 15:58:21 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2965713.1673970387.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 17 Jan 2023 10:46:27 -0500 Message-ID: <2965714.1673970387@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Laurenz Albe 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 =3D 1202633909=C2=A0+ deptype =3D= 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 entr= ies, > 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=3D# create type foo as enum ('a','b'); CREATE TYPE regression=3D# create schema bar; CREATE SCHEMA regression=3D# alter type public.foo set schema bar; ALTER TYPE regression=3D# create schema baz; CREATE SCHEMA regression=3D# alter type bar.foo set schema baz; ALTER TYPE regression=3D# select pg_describe_object(classid, objid, objsubid) as obj,= pg_describe_object(refclassid, refobjid, refobjsubid) as ref, deptype fro= m pg_depend where refobjid =3D 'baz.foo'::regtype; obj | ref | deptype = ----------------+--------------+--------- type baz.foo[] | type baz.foo | i (1 row) regression=3D# select pg_describe_object(classid, objid, objsubid) as obj,= pg_describe_object(refclassid, refobjid, refobjsubid) as ref, deptype fro= m pg_depend where objid =3D '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