pgsql: Disallow renaming a rule to "_RETURN".

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Disallow renaming a rule to "_RETURN".
Date: 2026-07-04 15:34:46
Message-ID: E1wg2OE-001K7W-1r@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Disallow renaming a rule to "_RETURN".

ON SELECT rules must be named "_RETURN", while other kinds of rules
must not be; this ancient restriction is depended on by various client
code. We successfully enforced this convention in most places, but
ALTER RULE allowed renaming a non-SELECT rule to "_RETURN". Notably,
that would break dump/restore, since the eventual CREATE RULE command
would reject the name.

While at it, remove DefineQueryRewrite's hack to substitute "_RETURN"
for the convention that was used before 7.3. We dropped other
server-side code that supported restoring pre-7.3 dumps some time ago
(notably in e58a59975 and nearby commits), but this bit was missed.

Bug: #19543
Reported-by: Adam Pickering <adamkpickering(at)gmail(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/19543-461228e77f3b32fc@postgresql.org
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/eada45dd846d4324c33e3ae357fb4c8fbf01bc6b

Modified Files
--------------
src/backend/rewrite/rewriteDefine.c | 36 ++++++++++++++++--------------------
src/test/regress/expected/rules.out | 2 ++
src/test/regress/sql/rules.sql | 1 +
3 files changed, 19 insertions(+), 20 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2026-07-05 11:57:11 pgsql: Fix properties orphaned by dropping a label
Previous Message Peter Eisentraut 2026-07-03 21:51:18 pgsql: Make property graph object descriptions better translatable