PG Bug reporting form <noreply@postgresql.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