Skip to content

Commit

Permalink
[DPE-3551] Fix large objects ownership (canonical#390)
Browse files Browse the repository at this point in the history
* Fix large objects ownership

Signed-off-by: Marcelo Henrique Neppel <[email protected]>

* Bump LIBPATCH

Signed-off-by: Marcelo Henrique Neppel <[email protected]>

---------

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
  • Loading branch information
marceloneppel authored Feb 19, 2024
1 parent 41eaa84 commit b1c6c81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/charms/postgresql_k8s/v0/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 23
LIBPATCH = 24

INVALID_EXTRA_USER_ROLE_BLOCKING_MESSAGE = "invalid role(s) for extra user roles"

Expand Down Expand Up @@ -355,6 +355,13 @@ def _generate_database_privileges_statements(
sql.Identifier(user),
)
)
statements.append(
"""UPDATE pg_catalog.pg_largeobject_metadata
SET lomowner = (SELECT oid FROM pg_roles WHERE rolname = '{}')
WHERE lomowner = (SELECT oid FROM pg_roles WHERE rolname = '{}');""".format(
user, self.user
)
)
else:
for schema in schemas:
schema = sql.Identifier(schema)
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ def test_generate_database_privileges_statements(self):
";' AS statement\nFROM pg_catalog.pg_views WHERE NOT schemaname IN ('pg_catalog', 'information_schema')) AS statements ORDER BY index) LOOP\n EXECUTE format(r.statement);\n END LOOP;\nEND; $$;"
),
]
)
),
"UPDATE pg_catalog.pg_largeobject_metadata\nSET lomowner = (SELECT oid FROM pg_roles WHERE rolname = 'test_user')\nWHERE lomowner = (SELECT oid FROM pg_roles WHERE rolname = 'operator');",
],
)
# Test with multiple established relations.
Expand Down

0 comments on commit b1c6c81

Please sign in to comment.