git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4b200a2)
Allow REASSIGNED OWNED to handle opclasses and opfamilies.
Sat, 3 Jul 2010 13:53:13 +0000 (13:53 +0000)
Sat, 3 Jul 2010 13:53:13 +0000 (13:53 +0000)
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.


diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index c7a5e86c58340f768115c0d51f8fa0478272dcde..c7cc40f78849c6fb4dfa2da70cc502173151233e 100644 (file)
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.41 2010年04月05日 01:09:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.42 2010年07月03日 13:53:13 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,6 +28,8 @@
#include "catalog/pg_largeobject.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_operator.h"
+#include "catalog/pg_opclass.h"
+#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_tablespace.h"
@@ -1367,6 +1369,14 @@ shdepReassignOwned(List *roleids, Oid newrole)
*/
break;
+ case OperatorClassRelationId:
+ AlterOpClassOwner_oid(sdepForm->objid, newrole);
+ break;
+
+ case OperatorFamilyRelationId:
+ AlterOpFamilyOwner_oid(sdepForm->objid, newrole);
+ break;
+
default:
elog(ERROR, "unexpected classid %u", sdepForm->classid);
break;
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index a043680e340dca9d7866a34d24410a77722cc886..1cd7223095a6c81402963ded29e4ca585ae6cff8 100644 (file)
--- 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.66 2010年02月14日 18:42:14 rhaas Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.67 2010年07月03日 13:53:13 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1948,6 +1948,27 @@ AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId)
heap_close(rel, NoLock);
}
+/*
+ * Change operator class owner, specified by OID
+ */
+void
+AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId)
+{
+ HeapTuple tup;
+ Relation rel;
+
+ rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
+
+ tup = SearchSysCacheCopy1(CLAOID, ObjectIdGetDatum(opclassOid));
+ 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.
@@ -2070,6 +2091,27 @@ AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId)
heap_close(rel, NoLock);
}
+/*
+ * Change operator family owner, specified by OID
+ */
+void
+AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId)
+{
+ HeapTuple tup;
+ Relation rel;
+
+ rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
+
+ tup = SearchSysCacheCopy1(OPFAMILYOID, ObjectIdGetDatum(opfamilyOid));
+ 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.
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h
index 49d9f19966df67704e89116f0d3432dc5223489b..cd5be6e4fda92c257c916c70998a98e8519a3dce 100644 (file)
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.101 2010年02月26日 02:01:24 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.102 2010年07月03日 13:53:13 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -96,7 +96,9 @@ extern void RemoveAmProcEntryById(Oid entryOid);
extern void RenameOpClass(List *name, const char *access_method, const char *newname);
extern void RenameOpFamily(List *name, const char *access_method, const char *newname);
extern void AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId);
+extern void AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId);
extern void AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId);
+extern void AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId);
/* commands/tsearchcmds.c */
extern void DefineTSParser(List *names, List *parameters);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /