mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
Fix REASSIGN OWNED so that it works on procedural languages too.
The capability for changing language owners is new in 8.3, so that's how far back this needs to be backpatched. Per bug #4132 by Kirill Simonov.
This commit is contained in:
parent
8209e1a987
commit
6750c7a751
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.23.2.1 2008/03/24 19:12:58 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.23.2.2 2008/04/29 19:37:13 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -32,6 +32,7 @@
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/conversioncmds.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "commands/proclang.h"
|
||||
#include "commands/schemacmds.h"
|
||||
#include "commands/tablecmds.h"
|
||||
#include "commands/typecmds.h"
|
||||
@ -1342,6 +1343,10 @@ shdepReassignOwned(List *roleids, Oid newrole)
|
||||
AlterFunctionOwner_oid(sdepForm->objid, newrole);
|
||||
break;
|
||||
|
||||
case LanguageRelationId:
|
||||
AlterLanguageOwner_oid(sdepForm->objid, newrole);
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "unexpected classid %d", sdepForm->classid);
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.74 2008/01/01 19:45:49 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.74.2.1 2008/04/29 19:37:13 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -48,6 +48,8 @@ typedef struct
|
||||
static void create_proc_lang(const char *languageName,
|
||||
Oid languageOwner, Oid handlerOid, Oid valOid, bool trusted);
|
||||
static PLTemplate *find_language_template(const char *languageName);
|
||||
static void AlterLanguageOwner_internal(HeapTuple tup, Relation rel,
|
||||
Oid newOwnerId);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
@ -529,7 +531,6 @@ AlterLanguageOwner(const char *name, Oid newOwnerId)
|
||||
{
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
Form_pg_language lanForm;
|
||||
|
||||
/* Translate name for consistency with CREATE */
|
||||
name = case_translate_language_name(name);
|
||||
@ -543,6 +544,47 @@ AlterLanguageOwner(const char *name, Oid newOwnerId)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("language \"%s\" does not exist", name)));
|
||||
|
||||
AlterLanguageOwner_internal(tup, rel, newOwnerId);
|
||||
|
||||
ReleaseSysCache(tup);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Change language owner, specified by OID
|
||||
*/
|
||||
void
|
||||
AlterLanguageOwner_oid(Oid oid, Oid newOwnerId)
|
||||
{
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
|
||||
rel = heap_open(LanguageRelationId, RowExclusiveLock);
|
||||
|
||||
tup = SearchSysCache(LANGOID,
|
||||
ObjectIdGetDatum(oid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tup))
|
||||
elog(ERROR, "cache lookup failed for language %u", oid);
|
||||
|
||||
AlterLanguageOwner_internal(tup, rel, newOwnerId);
|
||||
|
||||
ReleaseSysCache(tup);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Workhorse for AlterLanguageOwner variants
|
||||
*/
|
||||
static void
|
||||
AlterLanguageOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId)
|
||||
{
|
||||
Form_pg_language lanForm;
|
||||
|
||||
lanForm = (Form_pg_language) GETSTRUCT(tup);
|
||||
|
||||
/*
|
||||
@ -600,7 +642,4 @@ AlterLanguageOwner(const char *name, Oid newOwnerId)
|
||||
changeDependencyOnOwner(LanguageRelationId, HeapTupleGetOid(tup),
|
||||
newOwnerId);
|
||||
}
|
||||
|
||||
ReleaseSysCache(tup);
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ extern void DropProceduralLanguage(DropPLangStmt *stmt);
|
||||
extern void DropProceduralLanguageById(Oid langOid);
|
||||
extern void RenameLanguage(const char *oldname, const char *newname);
|
||||
extern void AlterLanguageOwner(const char *name, Oid newOwnerId);
|
||||
extern void AlterLanguageOwner_oid(Oid oid, Oid newOwnerId);
|
||||
extern bool PLTemplateExists(const char *languageName);
|
||||
|
||||
#endif /* PROCLANG_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user