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.98.2) (envelope-from ) id 1x8Wtc-00000001J25-017g for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Sep 2026 05:48:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x8WtZ-00000007pWK-2Kkf for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Sep 2026 05:48:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x8WtZ-00000007pWC-1Aat for pgsql-bugs@lists.postgresql.org; Mon, 21 Sep 2026 05:48:53 +0000 Received: from mail-wr2-x17.google.com ([2a00:1450:4864:30::17]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x8WtW-00000000TLT-0jII for pgsql-bugs@lists.postgresql.org; Mon, 21 Sep 2026 05:48:52 +0000 Received: by mail-wr2-x17.google.com with SMTP id ffacd0b85a97d-482f6351832so1195449f8f.3 for ; Sun, 20 Sep 2026 22:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1789969727; x=1790574527; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to:content-type; bh=JwL7inmhZdjAKW4nRYjmyriS5s6yeruDBog6cXMI1MY=; b=AfUY8bnrvM0AmJSLQoLrhKtubN515hujcdH/ijXXVok+47YQd+QKjzUtQOl2TKDCy4 2/e1Du2B7xSWOniaw9UOC1wWCoh900aZoctgOAZsDoY7GvzlMI9GWbvQ5MeDweBPJHlt uhLlqBewbNZkRcMirFXDB1voSu/2rAgCmDfTS71ZACwy0lqHkrJOzV8MlbxtnGy3VNfe sLR7nanYsu0X/RW4Xi7AuMsekp40WwztgOuYpVcJrDAsn99IUlAT74WFPKHtPIum08/U ibMt+uE8bMydw6DLr3HP6qs3qMHiIrcigJoeOMWEKlL2jM4agGlq2V/xoRSO56SUEb73 qOow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789969727; x=1790574527; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=JwL7inmhZdjAKW4nRYjmyriS5s6yeruDBog6cXMI1MY=; b=UlGCiAdY0qwUlv3Yg+a4MZgNpHzZYqX1wmlYyA8lDTxtHt2YaV4PLz8OApKmimGQ54 jlAIHwnMiTlkr3qiqzDb00W7qtNSCD/jwuyLWZLcgYJWrlYpdu12tHh/HDXUCQ54oMwn VUgz6xQzey0MbNoNFVavQlN/ifbojBwd9E0Kge3Ti9o0BQ8AD1ViLxEjXFu57YMe9NoH Lr6ctgAa+KRygC2HLFNpnoiYyU4xXdCg+DKXn9r2KvSmNWThpshDWNLy2aH+r5UpgTVU tsrVF9kF428qnzd+kjLxDvcih4kVPsvqMhVlVI8vtF6z/sjblUWSvWRXYCML0ao8wOnE PyFQ== X-Forwarded-Encrypted: i=1; AKwUvBxZAR+qoYzS90xRJ5bQFWGSQSy57gi0MAZ+GHVU0a2YLlNPBBV7PbJMXWgB1J5zgmARnVftMx58ZE66@lists.postgresql.org X-Gm-Message-State: AFuF++krlxqj9T1YonVRdNVihSAgRx0HApS0kZDfft41u5QU64DFVmRD LIGpJmC0yU7p97gA7oDfbcAWpkeR3F9d/SOs16PGwCnUGfTEASz3Jd0JuckWC+swdUM= X-Gm-Gg: AYBFou1yT0IuFcXeGc9/tTiZq/x1UBqVg9qrvotGJJWNjggBx/E55sptcM6SDSBktC9 uuxHOhf3FoRrGCXJrCM9rywElvCAhNchw8sten0njsty3VECEWpTjpIYcb5zawAK/NGwMppJe9x T95lbfnxoJzdgXb4cRGtkGeE0mIAIi+3ot1JKw6XZ0OdTwY2msb49UeoiTptbbkQp7+AlzJ2/Bc QLFq89YIkWzbnEiMba8MgdXidZ5kqTp5oWyQS1fyUPMiGtwiqY2hWuDLZnITM32ovPChQvqKAaX qBchtUlKqwCs/taPIIUbugPCzCefgo3aWiI8eBb3uy5uFQiwQUWgPh11GJkw5a8rsIFgD0Bfofy ySC6kOzAv11DxmRK4RU2r4qunF6lLSn5TPuvx6dUzb46dKjqPSuOn3c6NWGr5W8Py4jQZkx0hTF wIq4twrcdINF9dmYZKh4fr6GB+V7uhxkqxd0QaDqIvNzsEL7xlGQstcGctiKskG7M5TUmIcFrXf zuIISV8XfoOzJoWyGxYTmkG9w== X-Received: by 2002:a05:600c:3e06:b0:49e:7a10:1b71 with SMTP id 5b1f17b1804b1-49fc56d2ea3mr136665895e9.11.1789969727138; Sun, 20 Sep 2026 22:48:47 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:70:4864:ef5d:287:ba3a:375a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fc59286b6sm213113625e9.4.2026.09.20.22.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2026 22:48:46 -0700 (PDT) Message-ID: <65d97f78f24ddcfdd3b244451ed9b72284ef8fab.camel@cybertec.at> Subject: Re: Detaching a child table makes an expression using it unrestorable From: Laurenz Albe To: Manuel Reyes Bravo , Andrey Rachitskiy Cc: Jinqing Kuang , Heikki Linnakangas , "pgsql-bugs@lists.postgresql.org" Date: Mon, 21 Sep 2026 07:48:45 +0200 In-Reply-To: References: <8E44C4A2-6184-473F-B536-F73F63AEF1D0@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-2.fc44) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2026-09-21 at 01:39 -0300, Manuel Reyes Bravo wrote: > Attached is v2 of the patch that refuses ALTER COLUMN TYPE when a > stored expression holds a constant of the row type. >=20 > It fixes the wording for stand-alone composite types. v1 reported >=20 > ALTER TYPE t ALTER ATTRIBUTE b TYPE varchar; > ERROR: cannot alter table "t" because rule _RETURN on view v > stores a constant of its row type >=20 > where the existing column checks in find_composite_type_dependencies() > correctly say "cannot alter type". Both of the new reporting sites now > go through one helper that follows those checks (type, foreign table or > table), and the index case names the object the same way as the others > ("index at_tab2_idx" instead of 'an expression of "at_tab2_idx"'). > A regression test for the composite type case is added; it fails with > v1. make check passes. >=20 > I found it while reviewing Nikhil's patch in "Dropping a composite > attribute causes data integrity violations" [1], which makes ALTER TYPE > ... DROP ATTRIBUTE and ALTER TABLE ... DROP COLUMN call > find_composite_type_dependencies() as well. The two patches compose: > with both, a drop is also refused when a stored constant of the row > type would change its meaning. The details are in that thread. >=20 > [1] https://postgr.es/m/CA+UBoq0F2ua2fQEAU3-6w0oxOgFc9BgEN4gRcchiUUZ+WouV= rQ@mail.gmail.com Thanks. I briefly looked at the patch, and I wondered if you omitted pg_partitioned_table.partexprs on purpose. But taking a step back, I wonder if all that is worth the effort. PostgreSQL expects data types to be immutable, so if you modify a composite type that is used anywhere in a persistent fashion, things will break all over the place. I doubt that we can ever plug all the holes. I think it is a bad idea to use composite types in table definitions or anything else that is persistent, but we can hardly go back on that. Perhaps we should just forbid ALTER TYPE ... ADD/DROP/ALTER? That would be an incompatibility, but it wouldn't break upgrade. Yours, Laurenz Albe