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 1pHnPz-0007NA-P6 for pgsql-admin@arkaria.postgresql.org; Tue, 17 Jan 2023 14:58:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pHnPy-0003Ji-D0 for pgsql-admin@arkaria.postgresql.org; Tue, 17 Jan 2023 14:58:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pHnPy-0003JZ-3X for pgsql-admin@lists.postgresql.org; Tue, 17 Jan 2023 14:58:30 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pHnPr-0005JK-Jd for pgsql-admin@lists.postgresql.org; Tue, 17 Jan 2023 14:58:29 +0000 Received: by mail-ej1-x635.google.com with SMTP id bk15so18465769ejb.9 for ; Tue, 17 Jan 2023 06:58:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=W43PZ6VZg83kTxCoHeQw2rUNfEjsyucK4soABDxffNA=; b=gnMeF4Ls/IFZ5xO5vPtYkMoZxOG5nd+3dzXuU4bgzg2USTuazS9/5xUOS6iQw2lwhn rlsgTEZPhJaNe5ZcMbpiQDgPLXIEU7QRTaV67vw8Q9Eq6eNl0LpGfu74hqkMQKUafCtq htQ4F8EohfZsSdYxDfID+GFhhempj29Pm7uS91Dm8ZAuiAcK+FqTtZUlZFEdAz781hgP zcR0OXYLk9NDlVT0MBOoAvpYnAlm1nZqax4Ki5gUfeJU5Mru6KtXszNL+w99eKzyIVia hWZZNHPsyhv/R66twEhJnXjtGl/tgcPN03qQg7VfHCmpiqCS8IQFLe75zj2Hm3xD9iQS B+sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=W43PZ6VZg83kTxCoHeQw2rUNfEjsyucK4soABDxffNA=; b=GDsP7T+V4YOkPHXTeYisNDHExxAxg5TQrAVhY53QujrMiTmDi89Ky6n+oDBG2Yk1I1 JW2infC0MmpFFEzSqKPlKq/3HVgJmq7ti7f85SQ0xcoMNg3qKOppEiiJKAj31Y3yn+5+ wWg/CoWc8b/ADRWBzjY4SLeIzfdm16skUdwBLytSFIkN6JR8cJ7aXkThE42M696rKMCg cFzIdGG4Hjzq16I1vQDu3ZMPCaPRknELQ3l7rVRe7BQB0Qoih4Gb0WtalSygyBIYVWh5 8OEWHU4RUuD9ktIpJvGd1TGt0h4HayWol4wQ+msvhxXegUK2e2Hx9t0ZxfPahcqdpQfn vRkg== X-Gm-Message-State: AFqh2koVzzRj8ckVpLpeigEH36Jxojq6cGDrOqduRHgq9XNnOGsuOJEH qhw2U4vh2oOEtBqsFtwRG7luFQ== X-Google-Smtp-Source: AMrXdXsq3RDYlnOnKRsaxFdNmLj+FiB/sBZbQoQ2TssMVUwDCEJYhVSrY+2H7jjTOeaRn792i5nW/A== X-Received: by 2002:a17:906:c02:b0:83f:cbc0:1b30 with SMTP id s2-20020a1709060c0200b0083fcbc01b30mr3184688ejf.10.1673967502354; Tue, 17 Jan 2023 06:58:22 -0800 (PST) Received: from dynamic-pd01.res.v6.highway.a1.net ([2001:871:5e:539:1b2c:c52a:475d:310c]) by smtp.gmail.com with ESMTPSA id gk8-20020a17090790c800b0084d35ffbc20sm12215535ejb.68.2023.01.17.06.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 06:58:21 -0800 (PST) Message-ID: <4f49be99291439cfd0b04ec5c2c6f3ece6ed731a.camel@cybertec.at> Subject: Re: ERROR: failed to change schema dependency for type xxx.yyy From: Laurenz Albe To: Kouber Saparev , pgsql-admin@lists.postgresql.org Date: Tue, 17 Jan 2023 15:58:21 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2023-01-17 at 12:46 +0200, Kouber Saparev wrote: > Trying to change the schema of an enumerated type results in the error be= low: >=20 > db=3D# ALTER TYPE xxx.yyy SET SCHEMA zzz; > ERROR: =C2=A0failed to change schema dependency for type xxx.yyy >=20 > I was able to track this down to=C2=A0changeDependencyFor() within pg_dep= end.c, > but still am not able to understand the reason for this error. >=20 > When looking into the pg_depend catalog, originally there were 700 entrie= s. > After a series of cascading drops of the tables, views and functions invo= lved, > only one was left: >=20 > db=3D# SELECT deptype, objid::regclass FROM pg_depend WHERE refobjid =3D > (SELECT oid FROM pg_type WHERE typnamespace =3D 'xxx'::regnamespace = AND typname =3D 'yyy'); > =C2=A0deptype | =C2=A0 objid > ---------+------------ > =C2=A0i =C2=A0 =C2=A0 =C2=A0 | 1202633909 > (1 row) >=20 > Then I deleted manually from pg_depend this entry, and there were 0 entri= es left, > but still the error was persisting. I am not able to change the schema, > which is quite a blocker in our migration plan. >=20 > 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 entries= , I am not surprised. The missing entry should be like this: INSERT INTO pg_depend (classid, objid, objsubid, refclassid, refobjid, refobjsubid, deptype) VALUES ('pg_type'::regclass, 'xxx.yyy'::regtype, 0, 'pg_namespace'::regclass, 'xxx'::regnamespace, 0, 'n'); That dependency prevents users from dropping the schema while the type is still in it. Yours, Laurenz Albe