You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
execute(format('grant %s on schema %s to postgres %s', rec.privilege_type, (obj->>'oid')::regnamespace, case when rec.is_grantable then 'with grant option' else '' end));
478
482
end loop;
@@ -481,26 +485,48 @@ begin
481
485
-- types
482
486
foreach obj in array types
483
487
loop
484
-
execute(format('alter type %s owner to postgres;', (obj->>'oid')::regtype));
485
-
-- TODO: don't modify system catalog directly
486
-
update pg_type set typacl = (obj->>'acl')::aclitem[] where oid = obj->>'oid';
488
+
if obj->>'owner' = 'postgres' then
489
+
execute(format('alter type %s owner to postgres;', (obj->>'oid')::regtype));
execute(format('grant %s on type %s to postgres %s', rec.privilege_type, (obj->>'oid')::regtype, case when rec.is_grantable then 'with grant option' else '' end));
497
+
end loop;
487
498
end loop;
488
499
489
500
-- functions
490
-
foreach obj in array routines
501
+
foreach obj in array functions
491
502
loop
492
-
execute(format('alter routine %s(%s) owner to postgres;', (obj->>'oid')::regproc, pg_get_function_identity_arguments((obj->>'oid')::regproc)));
493
-
-- TODO: don't modify system catalog directly
494
-
update pg_proc set proacl = (obj->>'acl')::aclitem[] where oid = (obj->>'oid')::regproc;
503
+
if obj->>'owner' = 'postgres' then
504
+
execute(format('alter routine %s(%s) owner to postgres;', (obj->>'oid')::regproc, pg_get_function_identity_arguments((obj->>'oid')::regproc)));
execute(format('grant %s on function %s(%s) to postgres %s', rec.privilege_type, (obj->>'oid')::regproc, pg_get_function_identity_arguments((obj->>'oid')::regproc), case when rec.is_grantable then 'with grant option' else '' end));
512
+
end loop;
495
513
end loop;
496
514
497
515
-- relations
498
516
foreach obj in array relations
499
517
loop
500
518
-- obj->>'oid' (text) needs to be casted to oid first for some reason
501
-
execute(format('alter table %s owner to postgres;', (obj->>'oid')::oid::regclass));
502
-
-- TODO: don't modify system catalog directly
503
-
update pg_class set relacl = (obj->>'acl')::aclitem[] where oid = (obj->>'oid')::oid::regclass;
519
+
520
+
if obj->>'owner' = 'postgres' then
521
+
execute(format('alter table %s owner to postgres;', (obj->>'oid')::oid::regclass));
execute(format('grant %s on table %s to postgres %s', rec.privilege_type, (obj->>'oid')::oid::regclass, case when rec.is_grantable then 'with grant option' else '' end));
0 commit comments