Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb3b7d60

Browse files
committed
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, whenREASSIGN OWNED was added, but for now I have not done that.Asko Tiidumaa, with minor adjustments by me.
1 parent4b200a2 commitb3b7d60

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

‎src/backend/catalog/pg_shdepend.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.41 2010/04/05 01:09:52 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.42 2010/07/03 13:53:13 rhaas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -28,6 +28,8 @@
2828
#include"catalog/pg_largeobject.h"
2929
#include"catalog/pg_namespace.h"
3030
#include"catalog/pg_operator.h"
31+
#include"catalog/pg_opclass.h"
32+
#include"catalog/pg_opfamily.h"
3133
#include"catalog/pg_proc.h"
3234
#include"catalog/pg_shdepend.h"
3335
#include"catalog/pg_tablespace.h"
@@ -1367,6 +1369,14 @@ shdepReassignOwned(List *roleids, Oid newrole)
13671369
*/
13681370
break;
13691371

1372+
caseOperatorClassRelationId:
1373+
AlterOpClassOwner_oid(sdepForm->objid,newrole);
1374+
break;
1375+
1376+
caseOperatorFamilyRelationId:
1377+
AlterOpFamilyOwner_oid(sdepForm->objid,newrole);
1378+
break;
1379+
13701380
default:
13711381
elog(ERROR,"unexpected classid %u",sdepForm->classid);
13721382
break;

‎src/backend/commands/opclasscmds.c

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.66 2010/02/14 18:42:14 rhaas Exp $
12+
* $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.67 2010/07/03 13:53:13 rhaas Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -1948,6 +1948,27 @@ AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId)
19481948
heap_close(rel,NoLock);
19491949
}
19501950

1951+
/*
1952+
* Change operator class owner, specified by OID
1953+
*/
1954+
void
1955+
AlterOpClassOwner_oid(OidopclassOid,OidnewOwnerId)
1956+
{
1957+
HeapTupletup;
1958+
Relationrel;
1959+
1960+
rel=heap_open(OperatorClassRelationId,RowExclusiveLock);
1961+
1962+
tup=SearchSysCacheCopy1(CLAOID,ObjectIdGetDatum(opclassOid));
1963+
if (!HeapTupleIsValid(tup))
1964+
elog(ERROR,"cache lookup failed for opclass %u",opclassOid);
1965+
1966+
AlterOpClassOwner_internal(rel,tup,newOwnerId);
1967+
1968+
heap_freetuple(tup);
1969+
heap_close(rel,NoLock);
1970+
}
1971+
19511972
/*
19521973
* The first parameter is pg_opclass, opened and suitably locked. The second
19531974
* 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)
20702091
heap_close(rel,NoLock);
20712092
}
20722093

2094+
/*
2095+
* Change operator family owner, specified by OID
2096+
*/
2097+
void
2098+
AlterOpFamilyOwner_oid(OidopfamilyOid,OidnewOwnerId)
2099+
{
2100+
HeapTupletup;
2101+
Relationrel;
2102+
2103+
rel=heap_open(OperatorFamilyRelationId,RowExclusiveLock);
2104+
2105+
tup=SearchSysCacheCopy1(OPFAMILYOID,ObjectIdGetDatum(opfamilyOid));
2106+
if (!HeapTupleIsValid(tup))
2107+
elog(ERROR,"cache lookup failed for opfamily %u",opfamilyOid);
2108+
2109+
AlterOpFamilyOwner_internal(rel,tup,newOwnerId);
2110+
2111+
heap_freetuple(tup);
2112+
heap_close(rel,NoLock);
2113+
}
2114+
20732115
/*
20742116
* The first parameter is pg_opfamily, opened and suitably locked.The second
20752117
* parameter is a copy of the tuple from pg_opfamily we want to modify.

‎src/include/commands/defrem.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.101 2010/02/26 02:01:24 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.102 2010/07/03 13:53:13 rhaas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -96,7 +96,9 @@ extern void RemoveAmProcEntryById(Oid entryOid);
9696
externvoidRenameOpClass(List*name,constchar*access_method,constchar*newname);
9797
externvoidRenameOpFamily(List*name,constchar*access_method,constchar*newname);
9898
externvoidAlterOpClassOwner(List*name,constchar*access_method,OidnewOwnerId);
99+
externvoidAlterOpClassOwner_oid(OidopclassOid,OidnewOwnerId);
99100
externvoidAlterOpFamilyOwner(List*name,constchar*access_method,OidnewOwnerId);
101+
externvoidAlterOpFamilyOwner_oid(OidopfamilyOid,OidnewOwnerId);
100102

101103
/* commands/tsearchcmds.c */
102104
externvoidDefineTSParser(List*names,List*parameters);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp