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

Commit77d3b98

Browse files
committed
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 howfar back this needs to be backpatched.Per bug #4132 by Kirill Simonov.
1 parent6fff5c3 commit77d3b98

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

‎src/backend/catalog/pg_shdepend.c

Lines changed: 6 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.26 2008/03/26 21:10:37 alvherre Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.27 2008/04/29 19:37:04 alvherre Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -32,6 +32,7 @@
3232
#include"catalog/pg_type.h"
3333
#include"commands/conversioncmds.h"
3434
#include"commands/defrem.h"
35+
#include"commands/proclang.h"
3536
#include"commands/schemacmds.h"
3637
#include"commands/tablecmds.h"
3738
#include"commands/typecmds.h"
@@ -1313,6 +1314,10 @@ shdepReassignOwned(List *roleids, Oid newrole)
13131314
AlterFunctionOwner_oid(sdepForm->objid,newrole);
13141315
break;
13151316

1317+
caseLanguageRelationId:
1318+
AlterLanguageOwner_oid(sdepForm->objid,newrole);
1319+
break;
1320+
13161321
default:
13171322
elog(ERROR,"unexpected classid %d",sdepForm->classid);
13181323
break;

‎src/backend/commands/proclang.c

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.77 2008/03/27 03:57:33 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.78 2008/04/29 19:37:04 alvherre Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -50,6 +50,8 @@ typedef struct
5050
staticvoidcreate_proc_lang(constchar*languageName,
5151
OidlanguageOwner,OidhandlerOid,OidvalOid,booltrusted);
5252
staticPLTemplate*find_language_template(constchar*languageName);
53+
staticvoidAlterLanguageOwner_internal(HeapTupletup,Relationrel,
54+
OidnewOwnerId);
5355

5456

5557
/* ---------------------------------------------------------------------
@@ -528,7 +530,6 @@ AlterLanguageOwner(const char *name, Oid newOwnerId)
528530
{
529531
HeapTupletup;
530532
Relationrel;
531-
Form_pg_languagelanForm;
532533

533534
/* Translate name for consistency with CREATE */
534535
name=case_translate_language_name(name);
@@ -542,6 +543,47 @@ AlterLanguageOwner(const char *name, Oid newOwnerId)
542543
ereport(ERROR,
543544
(errcode(ERRCODE_UNDEFINED_OBJECT),
544545
errmsg("language \"%s\" does not exist",name)));
546+
547+
AlterLanguageOwner_internal(tup,rel,newOwnerId);
548+
549+
ReleaseSysCache(tup);
550+
551+
heap_close(rel,RowExclusiveLock);
552+
553+
}
554+
555+
/*
556+
* Change language owner, specified by OID
557+
*/
558+
void
559+
AlterLanguageOwner_oid(Oidoid,OidnewOwnerId)
560+
{
561+
HeapTupletup;
562+
Relationrel;
563+
564+
rel=heap_open(LanguageRelationId,RowExclusiveLock);
565+
566+
tup=SearchSysCache(LANGOID,
567+
ObjectIdGetDatum(oid),
568+
0,0,0);
569+
if (!HeapTupleIsValid(tup))
570+
elog(ERROR,"cache lookup failed for language %u",oid);
571+
572+
AlterLanguageOwner_internal(tup,rel,newOwnerId);
573+
574+
ReleaseSysCache(tup);
575+
576+
heap_close(rel,RowExclusiveLock);
577+
}
578+
579+
/*
580+
* Workhorse for AlterLanguageOwner variants
581+
*/
582+
staticvoid
583+
AlterLanguageOwner_internal(HeapTupletup,Relationrel,OidnewOwnerId)
584+
{
585+
Form_pg_languagelanForm;
586+
545587
lanForm= (Form_pg_language)GETSTRUCT(tup);
546588

547589
/*
@@ -599,7 +641,4 @@ AlterLanguageOwner(const char *name, Oid newOwnerId)
599641
changeDependencyOnOwner(LanguageRelationId,HeapTupleGetOid(tup),
600642
newOwnerId);
601643
}
602-
603-
ReleaseSysCache(tup);
604-
heap_close(rel,RowExclusiveLock);
605644
}

‎src/include/commands/proclang.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extern void DropProceduralLanguage(DropPLangStmt *stmt);
1616
externvoidDropProceduralLanguageById(OidlangOid);
1717
externvoidRenameLanguage(constchar*oldname,constchar*newname);
1818
externvoidAlterLanguageOwner(constchar*name,OidnewOwnerId);
19+
externvoidAlterLanguageOwner_oid(Oidoid,OidnewOwnerId);
1920
externboolPLTemplateExists(constchar*languageName);
2021

2122
#endif/* PROCLANG_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp