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.96) (envelope-from ) id 1wg1V8-005rh8-30 for pgsql-bugs@arkaria.postgresql.org; Sat, 04 Jul 2026 14:37:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wg1V7-00APaX-1z for pgsql-bugs@arkaria.postgresql.org; Sat, 04 Jul 2026 14:37:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wg1V7-00APaO-1D for pgsql-bugs@lists.postgresql.org; Sat, 04 Jul 2026 14:37:49 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wg1V5-00000001hKK-03uh for pgsql-bugs@lists.postgresql.org; Sat, 04 Jul 2026 14:37:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 664Ebbxf038959; Sat, 4 Jul 2026 10:37:37 -0400 From: Tom Lane To: adamkpickering@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19543: ALTER RULE ... RENAME accepts reserved name "_RETURN" for a non-view rule; breaks a restored dump In-reply-to: <19543-461228e77f3b32fc@postgresql.org> References: <19543-461228e77f3b32fc@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 03 Jul 2026 23:26:57 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <38957.1783175857.1@sss.pgh.pa.us> Date: Sat, 04 Jul 2026 10:37:37 -0400 Message-ID: <38958.1783175857@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form 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