There is support for COMMENT ON RULE without specifying a table
name, for upgrading from pre-7.3 instances. I think it might be time
for that workaround to go.
Patch attached.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From d15411c389659ac789199e46edaa2de43768e600 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut
Date: Wed, 22 Feb 2017 08:45:14 -0500
Subject: [PATCH] Remove deprecated COMMENT ON RULE syntax
This was only used for allowing upgrades from pre-7.3 instances, which
was a long time ago.
---
src/backend/catalog/objectaddress.c| 126 -
src/backend/parser/gram.y | 10 --
src/backend/rewrite/rewriteSupport.c | 55 -
src/include/rewrite/rewriteSupport.h | 2 -
.../test_ddl_deparse/expected/comment_on.out | 2 +-
.../modules/test_ddl_deparse/sql/comment_on.sql| 2 +-
src/test/regress/expected/object_address.out | 4 +-
7 files changed, 53 insertions(+), 148 deletions(-)
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 9029477d68..cc636e2e3e 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -1325,6 +1325,8 @@ get_object_address_relobject(ObjectType objtype, List *objname,
Relation relation = NULL;
int nnames;
const char *depname;
+ List *relname;
+ Oid reloid;
/* Extract name of dependent object. */
depname = strVal(llast(objname));
@@ -1332,88 +1334,58 @@ get_object_address_relobject(ObjectType objtype, List *objname,
/* Separate relation name from dependent object name. */
nnames = list_length(objname);
if (nnames < 2)
- {
- Oid reloid;
-
- /*
- * For compatibility with very old releases, we sometimes allow users
- * to attempt to specify a rule without mentioning the relation name.
- * If there's only rule by that name in the entire database, this will
- * work. But objects other than rules don't get this special
- * treatment.
- */
- if (objtype != OBJECT_RULE)
- elog(ERROR, "must specify relation and object name");
- address.classId = RewriteRelationId;
- address.objectId =
- get_rewrite_oid_without_relid(depname, &reloid, missing_ok);
- address.objectSubId = 0;
-
- /*
- * Caller is expecting to get back the relation, even though we didn't
- * end up using it to find the rule.
- */
- if (OidIsValid(address.objectId))
- relation = heap_open(reloid, AccessShareLock);
- }
- else
- {
- List *relname;
- Oid reloid;
+ ereport(ERROR,
+(errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("must specify relation and object name")));
- /* Extract relation name and open relation. */
- relname = list_truncate(list_copy(objname), nnames - 1);
- relation = heap_openrv_extended(makeRangeVarFromNameList(relname),
- AccessShareLock,
- missing_ok);
+ /* Extract relation name and open relation. */
+ relname = list_truncate(list_copy(objname), nnames - 1);
+ relation = heap_openrv_extended(makeRangeVarFromNameList(relname),
+ AccessShareLock,
+ missing_ok);
- reloid = relation ? RelationGetRelid(relation) : InvalidOid;
+ reloid = relation ? RelationGetRelid(relation) : InvalidOid;
- switch (objtype)
- {
- case OBJECT_RULE:
-address.classId = RewriteRelationId;
-address.objectId = relation ?
- get_rewrite_oid(reloid, depname, missing_ok) : InvalidOid;
-address.objectSubId = 0;
-break;
- case OBJECT_TRIGGER:
-address.classId = TriggerRelationId;
-address.objectId = relation ?
- get_trigger_oid(reloid, depname, missing_ok) : InvalidOid;
-address.objectSubId = 0;
-break;
- case OBJECT_TABCONSTRAINT:
-address.classId = ConstraintRelationId;
-address.objectId = relation ?
- get_relation_constraint_oid(reloid, depname, missing_ok) :
- InvalidOid;
-address.objectSubId = 0;
-break;
- case OBJECT_POLICY:
-address.classId = PolicyRelationId;
-address.objectId = relation ?
- get_relation_policy_oid(reloid, depname, missing_ok) :
- InvalidOid;
-address.objectSubId = 0;
-break;
- default:
-elog(ERROR, "unrecognized objtype: %d", (int) objtype);
-/* placate compiler, which doesn't know elog won't return */
-address.classId = InvalidOid;
-address.objectId = InvalidOid;
-address.objectSubId = 0;
- }
+ switch (objtype)
+ {
+ case OBJECT_RULE:
+ address.classId = RewriteRelationId;
+ address.objectId = relation ?
+get_rewrite_oid(reloid, depname, missing_ok) : InvalidOid;
+ address.objectSubId = 0;
+ break;
+ case OBJECT_TRIGGER:
+ address.classId = TriggerRelationId;
+ address.objectId = relation ?
+get_trigger_oid(reloid, depname, missing_ok) : InvalidOid;
+ address.objectSubId = 0;
+ break;
+ case OBJECT_TABCONSTRAINT:
+ address.classId = ConstraintRelationId;
+ address.objectId