From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: ben@mlabs.city
Subject: ALTER SCHEMA: renaming does not update string-literal function bodies
Date: Fri, 09 Oct 2026 19:32:06 +0000
Message-ID: <179157432663.2048046.109109804107041431@wrigleys.postgresql.org> (raw)
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."
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-docs@postgresql.org
Cc: noreply@postgresql.org, ben@mlabs.city
Subject: Re: ALTER SCHEMA: renaming does not update string-literal function bodies
In-Reply-To: <179157432663.2048046.109109804107041431@wrigleys.postgresql.org>
References: <179157432663.2048046.109109804107041431@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox