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 1xFHPs-00000001XYu-0W2i for pgsql-docs@arkaria.postgresql.org; Fri, 09 Oct 2026 20:42:08 +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 1xFHPp-00000001BJF-1io5 for pgsql-docs@arkaria.postgresql.org; Fri, 09 Oct 2026 20:42:05 +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.98.2) (envelope-from ) id 1xFGL7-000000014t7-3HfR for pgsql-docs@lists.postgresql.org; Fri, 09 Oct 2026 19:33:09 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xFGL4-00000001D6S-33zp for pgsql-docs@lists.postgresql.org; Fri, 09 Oct 2026 19:33:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=4lpQ1xYWtwSll1FXm94sl728PnapkDsB7Z3HNhtdIwo=; b=RsB0CtnmofDu1YjUyX6O4ZoRKp Nnu6xSw1OGF4NRCTJu9BxuTxtxfnSDiNHgY/f570Q3jLo7hNRTpzRGDdFIyOevFbHORgvpPVKsP/A c9Olz+rbRNiFDrUNSFYN/oeIStASgGpyvFRQSGTLvxaCEutk43Rj6GGbHrdcuXzM1AM1C77HrUxxA 35ZhMKiw34xc2+SmOGqqHQgCV9aLXoETyOCvBfYQYm1GsbdQdH3zJ6SM8beaGjj2daCeHYtImkrjR nlS4zuaqv2cooGP5nkVd5qJlLrrpge12VHIf+iYP079w4x27PTj1pe7Id4ay250PFv8E5eiDftCiU FOORXOmg==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xFGL3-00000003aiQ-2j0D for pgsql-docs@lists.postgresql.org; Fri, 09 Oct 2026 19:33:05 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xFGL2-0000000AQym-1MdT for pgsql-docs@lists.postgresql.org; Fri, 09 Oct 2026 19:33:04 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: ALTER SCHEMA: renaming does not update string-literal function bodies To: pgsql-docs@lists.postgresql.org From: PG Doc comments form Cc: ben@mlabs.city Reply-To: ben@mlabs.city, pgsql-docs@lists.postgresql.org Date: Fri, 09 Oct 2026 19:32:06 +0000 Message-ID: <179157432663.2048046.109109804107041431@wrigleys.postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following documentation comment has been logged on the website: Page: https://www.postgresql.org/docs/18/sql-alterschema.html Description: The ALTER SCHEMA page has no Notes section, and renaming a schema has one consequence that is easy to miss. 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 the 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. Suggested note: "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 bodies are updated automatically."