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 1p4vVH-0005rK-TS for pgsql-bugs@arkaria.postgresql.org; Tue, 13 Dec 2022 02:58:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p4vVG-0000P1-BQ for pgsql-bugs@arkaria.postgresql.org; Tue, 13 Dec 2022 02:58:46 +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 1p4vVG-0000Os-1S for pgsql-bugs@lists.postgresql.org; Tue, 13 Dec 2022 02:58:46 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p4vVD-0005qb-VI for pgsql-bugs@lists.postgresql.org; Tue, 13 Dec 2022 02:58:45 +0000 Received: by mail-pj1-x102c.google.com with SMTP id q17-20020a17090aa01100b002194cba32e9so2072697pjp.1 for ; Mon, 12 Dec 2022 18:58:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iwPS7EEnLGcR4Ry/nMwjpRmPQb2110yCjLx2GSujon0=; b=ZVG1CgikXW/aHxJqg2h3vWMRsG4Z9BDOpGaQy7uZspIeu1n3SMqHVIKKhHJ3zvO1UC x9I4ZOyAQqdEu1rbrN2VpXJzNlCMrXBH/+xZo8cfpHKzYa+Cf+VmRkmlynd3cdyY0Cr6 ARr6KRn+ig9RT1bnjXLb8khrUU6DCPm336Ty4WlE7YKv09JOSZSoJM7I5YCn6GTVF+lg qHpxD9GGWmBDf71S2ThsLnnpAOWsmIOjJCTSwZJU8A5kHZmJbySnTU8T9jYacIs7SyjW msJ8tL5a0I/R58pOTJXspX+aZ2FFp6EAbrNtWizZ9TnDnQOKjOA99xhIk29zB3jIbneA 53cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iwPS7EEnLGcR4Ry/nMwjpRmPQb2110yCjLx2GSujon0=; b=q0ewAx9kE6rvAK1qc7V7kksv/t0teBx76Z0V4chXwvo4k6YJsLjeI9Iy1M1i9xV6YP K0inA1uZIJ5xDGZzKXZ4tLsGQvc80hybt/qz1cfz7wP+AU2fLVGlKJNWagnkvweJ15Gk B8Y9pS+kPE/kOzz4rlPKz5uSfNocVKCtT3ZTc3LPmZ0+Ci7mKwKDME/Jv7v7zXwrU4rc I0/ykpCYdi2R/ovQQqOspmfUOBNILDD/aGUK7pw7nycNZEtiPu83j5iuupWDcnqeKLfo iOGytDNQpTC4q6bz0q5HyKeQGPQzmlaASnHhJ12Wkf7wxYnd9CEezSf8VVPkKT8qFMVs iHdQ== X-Gm-Message-State: ANoB5pmtjd6DtDAk/0pnW42lNvZhJCKc47abUtXkGJtqZj8wf8Rg3pFZ Tf+iUgAphr1gLYQPXYaRSyt/GH0nWL0oM7XCx3s= X-Google-Smtp-Source: AA0mqf7SZ4gYYBxDlEndMqZqLVEUSIy6zMjg5GcYllUS0e1ikA1DXq25xVgAqYr8uWgcbWdlgezX68Y2X8weopNL2sI= X-Received: by 2002:a17:903:1303:b0:176:7852:dae3 with SMTP id iy3-20020a170903130300b001767852dae3mr722153plb.25.1670900321189; Mon, 12 Dec 2022 18:58:41 -0800 (PST) MIME-Version: 1.0 References: <17706-fa10a46c1ac9ce5a@postgresql.org> In-Reply-To: From: Richard Guo Date: Tue, 13 Dec 2022 10:58:30 +0800 Message-ID: Subject: Re: BUG #17706: ALTER TYPE leads to crash To: "David G. Johnston" Cc: s.shinderuk@postgrespro.ru, pgsql-bugs@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000019835c05efaccc9e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000019835c05efaccc9e Content-Type: text/plain; charset="UTF-8" On Thu, Dec 8, 2022 at 1:01 PM David G. Johnston wrote: > We don't need to fix this though (i.e., make the query continue to somehow > work), we need to detect the situation and return some kind of error as > opposed to crashing the server. The transaction itself is doing something > illegal and can be forced to abort. Alternatively, maybe the ALTER TYPE > command can emit the error that it is unable to alter the type as it is > already in use by the current session. But that would close off possible > non-problematic uses of ALTER TYPE in this situation > Yeah, that makes sense. If we create a table using type foo, the alter operation would error out like that. create table t (a foo); alter type foo alter attribute b type text; ERROR: cannot alter type "foo" because column "t.a" uses it Maybe we can likewise record the dependencies for the type if it's being used in other more scenarios besides as a column in some table? Thanks Richard --00000000000019835c05efaccc9e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Thu, Dec 8, 2022 at 1:01 PM David G. J= ohnston <david.g.johnston@= gmail.com> wrote:
We don't need to fix this though (i.e., mak= e the query continue to somehow work), we need to detect the situation and = return some kind of error as opposed to crashing the server.=C2=A0 The tran= saction itself is doing something illegal and can be forced to abort.=C2=A0= Alternatively, maybe the ALTER TYPE command can emit the error that it is = unable to alter the type as it is already in use by the current session.=C2= =A0 But that would close off possible non-problematic uses of ALTER TYPE in= this situation
=C2=A0
Yeah, t= hat makes sense.=C2=A0 If we create a table using type foo, the alter
op= eration would error out like that.

create table t (a foo);

al= ter type foo alter attribute b type text;
ERROR: =C2=A0cannot alter type= "foo" because column "t.a" uses it

Maybe we can= likewise record the dependencies for the type if it's being
used in= other more scenarios besides as a column in some table?

Thanks
R= ichard
--00000000000019835c05efaccc9e--