| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | adamkpickering(at)gmail(dot)com |
| Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19543: ALTER RULE ... RENAME accepts reserved name "_RETURN" for a non-view rule; breaks a restored dump |
| Date: | 2026-07-04 14:37:37 |
| Message-ID: | 38958.1783175857@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> CREATE RULE rejects the name _RETURN for a rule that is not an ON SELECT
> rule. ALTER RULE ... RENAME does not: an existing ON UPDATE/INSERT/DELETE
> rule on an ordinary table can be renamed to _RETURN and the server accepts
> it.
Good catch, will fix.
While we're here, I'm tempted to discard the obsolete logic in
CREATE RULE's implementation of a related check:
/*
* ... and finally the rule must be named _RETURN.
*/
if (strcmp(rulename, ViewSelectRuleName) != 0)
{
/*
* In versions before 7.3, the expected name was _RETviewname. For
* backwards compatibility with old pg_dump output, accept that
* and silently change it to _RETURN. Since this is just a quick
* backwards-compatibility hack, limit the number of characters
* checked to a few less than NAMEDATALEN; this saves having to
* worry about where a multibyte character might have gotten
* truncated.
*/
if (strncmp(rulename, "_RET", 4) != 0 ||
strncmp(rulename + 4, RelationGetRelationName(event_relation),
NAMEDATALEN - 4 - 4) != 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("view rule for \"%s\" must be named \"%s\"",
RelationGetRelationName(event_relation),
ViewSelectRuleName)));
We discarded compatibility with pre-7.3 dump files some time ago
(notably in e58a59975 and adjacent commits), but this small detail
wasn't noticed at the time.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | David Rowley | 2026-07-03 23:57:23 | Re: BUG #19533: Wrong results from WindowAgg run-condition pushdown on count() with EXCLUDE CURRENT ROW |