Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s0tec-0080zS-6y for pgsql-bugs@arkaria.postgresql.org; Sun, 28 Apr 2024 01:48:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s0teY-00Ba44-R5 for pgsql-bugs@arkaria.postgresql.org; Sun, 28 Apr 2024 01:48:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s0teY-00Ba3w-IZ for pgsql-bugs@lists.postgresql.org; Sun, 28 Apr 2024 01:48:31 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s0teS-000Nyp-Qg for pgsql-bugs@lists.postgresql.org; Sun, 28 Apr 2024 01:48: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 43S1mL4n403600; Sat, 27 Apr 2024 21:48:21 -0400 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org, Peter Eisentraut Subject: Re: BUG #18449: Altering column type fails when an SQL routine depends on the column In-reply-to: <18449-f8248467aaa294d5@postgresql.org> References: <18449-f8248467aaa294d5@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sat, 27 Apr 2024 04:00:01 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <403598.1714268901.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 27 Apr 2024 21:48:21 -0400 Message-ID: <403599.1714268901@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > The following script: > CREATE TABLE t(a int, b varchar); > CREATE FUNCTION f(i int) RETURNS text LANGUAGE SQL > RETURN (SELECT b FROM t WHERE a =3D $1); > ALTER TABLE t ALTER COLUMN b TYPE text; > fails with: > ERROR: unexpected object depending on column: function f(integer) > on REL_14_STABLE .. master since e717a9a18. Thanks for the report. It looks like most of the other hard cases in RememberAllDependentForRebuilding just error out with code along the lines of ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot alter type of a column used by= a view or rule"), I'm inclined to do likewise for functions. We could imagine trying to re-parse the function definition against the new column type, but there are way too many ways for that to go wrong. Just for starters, there are possibly-security-grade hazards if the current search_path isn't what it was when the function was created. There's no guarantee that we'd succeed anyway, eg the new column type might not work for some function or operator that's applied to it, and if not the resulting error message would likely be very surprising. regards, tom lane