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 1xFI33-00000001YOY-1ud0 for pgsql-docs@arkaria.postgresql.org; Fri, 09 Oct 2026 21:22:37 +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 1xFI31-00000001H8k-1lVj for pgsql-docs@arkaria.postgresql.org; Fri, 09 Oct 2026 21:22:35 +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 1xFI31-00000001H8c-0cbg for pgsql-docs@lists.postgresql.org; Fri, 09 Oct 2026 21:22:35 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xFI2y-00000001I8y-3TbD for pgsql-docs@lists.postgresql.org; Fri, 09 Oct 2026 21:22:34 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-48c4be28b82so178052f8f.2 for ; Fri, 09 Oct 2026 14:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1791580950; x=1792185750; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:to:from:subject:message-id:from:to:cc :subject:date:message-id:reply-to:content-type; bh=TL1NYRlJufo/I7iJGTfj1oMpPK+2xuGIbbf5z5yXUlo=; b=XB7r9MDUMcbdXJNgq62SF18zEpiRrD96OtTyIrW3e1M+0LCGLtj1odXh+DtaNPT36j boJWq2cphl0Y2L9MY94XDdfuhjk0v96I1s0LTKCH45/2n2K2bVMRhu+4xr8DksLacJ3I SCOfbWQ4DH7jmb5ixJ7TnjpsgJHwMZSHOgD6VPJRieWN2dOOexk22cYaZwAJn906HAA7 Mee+He7dRDbPd3e2aIhFFYNteG/zTc1udywkf1ZV+FEhEIPEeZfyAvYyICjCyX+/eLVv XI7w5IYWo734kTzCVeQfqK/5FyKxRRWMW6EeG7goqFzs8vgM7TvYLGjF35bwiMk54CEf 9Zvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791580950; x=1792185750; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=TL1NYRlJufo/I7iJGTfj1oMpPK+2xuGIbbf5z5yXUlo=; b=JsYMdkNt21plSPz1YE6c1TCwRqoMcKqLjgAbSQjfSQGxAwhD0Ylcu3MfWV7+WKT2rI y20cHFvXQ0BEAgiJebac8kts62ZWVQoxKi0YWMSPtTA73D2Cm/UlQW6yjl/nKTAADFQ3 spMdMBZcIYO4DPfy2axDjeutC4+H+kWYsczfgUMh9jT84ISbtU4goTdHZqcQMSsp4ZbR ak2ERkzyZtXHqF4sUxcHAIdVr4jEyB/w2sa2nDmAECQEsEYofD/ydEVoKTfYBH4gpzfM OYuW3HAnQQTKmeeo1majhxrLLk5z3mxfW25gDqFQGQ1qj0G7VMrVMK75k+svO6isAcrC wsjw== X-Forwarded-Encrypted: i=1; AKwUvBzMkmSR35++cjRyk+r/DWeLOKofzc+WKDKYAWDVsD4tUuf/IM8he791sWfXck8Mvo5UtWPNzI8YCprW@lists.postgresql.org X-Gm-Message-State: AFq9FYLLdgRqyBN3r95ysNCnfDssns/APkqJhZCu3GjS394S17gJ+Xa7 QjT1m7wWmx0aFoPHC1zgRaJFV05pgDE3XXf97Q3r5qT+TKJoCwBVfhrmC8Y6WQpL21o= X-Gm-Gg: AYBFou0+2ktvWtzwsT3SuRuO1kz0Y2nL2IyoJ/qC6fO029Cd1mwnuk8iq+C3dRJg5gR 2hI9tVNEaYEXDOfvlr4CfvStjVwgO3aTA6SeVl+TPLUsuY/grghfmsbgWL/usqLc1c+8evGYgk9 p4INjtbWuPFgKbClEVG9DaqlEuAELeBzTyPGUfF86SAJBJFDhZpuhr5wrHicb6RmUVAwIwpQCGL mIArEDkAvinfWUSJmVZTbcLEyf8p1/5rsTodUEY0M5AkcjITy5LfpjIM88fnq1TUh/THVnUjLNi 2sovaodR8RhviYXZGk1nhImdJbKFO48OROJtiRyKj56G/cJI8cuw4BNsZ6zAueX6nHIk4CI2JgU 55WBoch8cnFfaSiLcd7BB+QLiJv8bIewkYt4IcyG7VqxfA8RjrigebKODU/0cpNUvuxrQzF5r79 Jf9dd/wHPY3CG+052tdyqbzJ0ppwEtkUy7IeJh9tIGWCcQNmJKsa8Rro0mmG8ZRp+OqoHKBaZQ7 P96zSayUM/o1mO0exnLz/GN+KS112k= X-Received: by 2002:a05:6000:4287:b0:48b:68:592e with SMTP id ffacd0b85a97d-48dba77cf6dmr7939512f8f.4.1791580949175; Fri, 09 Oct 2026 14:22:29 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:270:b677:677f:591c:a18a:2956]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48dbae37509sm5063039f8f.7.2026.10.09.14.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2026 14:22:28 -0700 (PDT) Message-ID: <12030d192d4a881dff7363d035631c349a0d2514.camel@cybertec.at> Subject: Re: ALTER SCHEMA: renaming does not update string-literal function bodies From: Laurenz Albe To: ben@mlabs.city, pgsql-docs@lists.postgresql.org Date: Fri, 09 Oct 2026 23:22:27 +0200 In-Reply-To: <179157432663.2048046.109109804107041431@wrigleys.postgresql.org> References: <179157432663.2048046.109109804107041431@wrigleys.postgresql.org> 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 Fri, 2026-10-09 at 19:32 +0000, PG Doc comments form wrote: > Page: https://www.postgresql.org/docs/18/sql-alterschema.html >=20 > The ALTER SCHEMA page has no Notes section, and renaming a schema has one > consequence that is easy to miss. >=20 > Objects that store parsed references follow the rename: views, functions > with SQL-standard bodies (BEGIN ATOMIC), and privileges, including ALTER > DEFAULT PRIVILEGES entries. Function bodies written as string constants (= AS > $$ ... $$, and every non-SQL language) are stored as text, so a > schema-qualified reference inside them keeps the old name and fails at th= e > next call. On 14.10, after ALTER SCHEMA old RENAME TO newsch, a LANGUAGE = sql > function containing SELECT count(*) FROM old.t fails with ERROR: relation > "old.t" does not exist, while the BEGIN ATOMIC version returns the right > count. >=20 > Suggested note: >=20 > "Renaming a schema does not update references to it inside function and > procedure bodies written as string constants, since those are parsed only= at > execution time (see CREATE FUNCTION). Views and SQL-standard function bod= ies > are updated automatically." I think that would be useful information (but it would have to be worded differently: neither views nor SQL-standard function bodies are really updated). However, it feels odd to document that for schemas, but not for tables, col= umns, functions and all other kinds of objects. It would be even worse to docume= nt that over and over for all the ALTER commands. How about describing that in a generic location, so that it is clear that i= t applies to all objects? I am not sure where, but perhaps some introductory note in the "Data Definition" chapter? Yours, Laurenz Albe