@@ -1080,13 +1080,14 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
1080
1080
ListCell * lc2 ;
1081
1081
1082
1082
/*
1083
- * Enforce superuser-ness if appropriate. We postpone these checks until
1084
- * here so that the control flags are correctly associated with the right
1083
+ * Enforce superuser-ness/membership of the pg_manage_extensions
1084
+ * predefined role if appropriate. We postpone these checks until here
1085
+ * so that the control flags are correctly associated with the right
1085
1086
* script(s) if they happen to be set in secondary control files.
1086
1087
*/
1087
1088
if (control -> superuser && !superuser ())
1088
1089
{
1089
- if (extension_is_trusted (control ))
1090
+ if (extension_is_trusted (control ) || has_privs_of_role ( GetUserId (), ROLE_PG_MANAGE_EXTENSIONS ) )
1090
1091
switch_to_superuser = true;
1091
1092
else if (from_version == NULL )
1092
1093
ereport (ERROR ,
@@ -1095,15 +1096,15 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
1095
1096
control -> name ),
1096
1097
control -> trusted
1097
1098
? errhint ("Must have CREATE privilege on current database to create this extension." )
1098
- : errhint ("Must be superuser to create this extension." )));
1099
+ : errhint ("Must be superuser or member of pg_manage_extensions to create this extension." )));
1099
1100
else
1100
1101
ereport (ERROR ,
1101
1102
(errcode (ERRCODE_INSUFFICIENT_PRIVILEGE ),
1102
1103
errmsg ("permission denied to update extension \"%s\"" ,
1103
1104
control -> name ),
1104
1105
control -> trusted
1105
1106
? errhint ("Must have CREATE privilege on current database to update this extension." )
1106
- : errhint ("Must be superuser to update this extension." )));
1107
+ : errhint ("Must be superuser or member of pg_manage_extensions to update this extension." )));
1107
1108
}
1108
1109
1109
1110
filename = get_extension_script_filename (control , from_version , version );
0 commit comments