aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/opclasscmds.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2010-07-03 13:53:26 +0000
committerRobert Haas <rhaas@postgresql.org>2010-07-03 13:53:26 +0000
commitbf53e7938d14d9cbe22d5756c76529a882420085 (patch)
treea823fa510a2182377101bee562befcca07a6cc51 /src/backend/commands/opclasscmds.c
parent007d0783c797fd244980659a9dc711713e4c74d3 (diff)
downloadpostgresql-bf53e7938d14d9cbe22d5756c76529a882420085.tar.gz
postgresql-bf53e7938d14d9cbe22d5756c76529a882420085.zip
Allow REASSIGNED OWNED to handle opclasses and opfamilies.
Backpatch to 8.3, which is as far back as we have opfamilies. The opclass portion could probably be backpatched to 8.2, when REASSIGN OWNED was added, but for now I have not done that. Asko Tiidumaa, with minor adjustments by me.
Diffstat (limited to 'src/backend/commands/opclasscmds.c')
-rw-r--r--src/backend/commands/opclasscmds.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 4f0693a9ac4..811e84ad6f9 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.64 2009/01/01 17:23:39 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.64.2.1 2010/07/03 13:53:26 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1994,6 +1994,27 @@ AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId)
}
/*
+ * Change operator class owner, specified by OID
+ */
+void
+AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId)
+{
+ HeapTuple tup;
+ Relation rel;
+
+ rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
+
+ tup = SearchSysCacheCopy(CLAOID, ObjectIdGetDatum(opclassOid), 0, 0, 0);
+ if (!HeapTupleIsValid(tup))
+ elog(ERROR, "cache lookup failed for opclass %u", opclassOid);
+
+ AlterOpClassOwner_internal(rel, tup, newOwnerId);
+
+ heap_freetuple(tup);
+ heap_close(rel, NoLock);
+}
+
+/*
* The first parameter is pg_opclass, opened and suitably locked. The second
* parameter is a copy of the tuple from pg_opclass we want to modify.
*/
@@ -2121,6 +2142,28 @@ AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId)
}
/*
+ * Change operator family owner, specified by OID
+ */
+void
+AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId)
+{
+ HeapTuple tup;
+ Relation rel;
+
+ rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
+
+ tup = SearchSysCacheCopy(OPFAMILYOID, ObjectIdGetDatum(opfamilyOid),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(tup))
+ elog(ERROR, "cache lookup failed for opfamily %u", opfamilyOid);
+
+ AlterOpFamilyOwner_internal(rel, tup, newOwnerId);
+
+ heap_freetuple(tup);
+ heap_close(rel, NoLock);
+}
+
+/*
* The first parameter is pg_opfamily, opened and suitably locked. The second
* parameter is a copy of the tuple from pg_opfamily we want to modify.
*/