Hello Alon Bar-Lev,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/25923
to review the following change.
Change subject: core: preserve custom db users permissions on...
......................................................................
core: preserve custom db users permissions on...
preserve custom db users permissions on upgrade
Up to this patch if custom users were added and assign privileges on DB
objects those privileges were removed when the db was updated or
refreshed.
This patch backups the privileges assigned to custom users and apply
them after the database was upgraded or refreshed.
Change-Id: If4ac85dc943fcb6a8f656a8ebeb172023e71c1ec
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1073471
Signed-off-by: Eli Mesika <[email protected]>
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M packaging/dbscripts/dbfunc-common.sh
1 file changed, 23 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-dwh refs/changes/23/25923/1
diff --git a/packaging/dbscripts/dbfunc-common.sh
b/packaging/dbscripts/dbfunc-common.sh
index af441d5..23b6bdf 100644
--- a/packaging/dbscripts/dbfunc-common.sh
+++ b/packaging/dbscripts/dbfunc-common.sh
@@ -60,12 +60,28 @@
echo "Creating fresh schema"
_dbfunc_common_schema_create
fi
+
+ local permissions
+ echo "Saving custom users permissions on database objects..."
+ permissions="$(_dbfunc_common_get_custom_user_permissions)" || exit $?
+
_dbfunc_common_schema_upgrade
+
+ echo "Applying custom users permissions on database objects..."
+ dbfunc_psql_die --command="${permissions}"
}
dbfunc_common_schema_refresh() {
+ local permissions
+
+ echo "Saving custom users permissions on database objects..."
+ permissions="$(_dbfunc_common_get_custom_user_permissions)" || exit $?
+
_dbfunc_common_schema_refresh_drop
_dbfunc_common_schema_refresh_create
+
+ echo "Applying custom users permissions on database objects..."
+ dbfunc_psql_die --command="${permissions}"
}
# gets the configuration value of the given option name and version.
@@ -270,6 +286,13 @@
dbfunc_psql_die --file="${DBFUNC_COMMON_DBSCRIPTS_DIR}/common_sp.sql" >
/dev/null
}
+_dbfunc_common_get_custom_user_permissions() {
+ # Looking for permissions not related to postgres, public our ours
(custom user permissions)
+ dbfunc_pg_dump_die --schema-only |
+ sed -n -e '/^grant/Ip' |
+ sed -e "/to \(public\|postgres\)\|${DBFUNC_DB_USER};/Id"
+}
+
_dbfunc_common_run_pre_upgrade() {
#Dropping all views & sps
_dbfunc_common_schema_refresh_drop
--
To view, visit http://gerrit.ovirt.org/25923
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If4ac85dc943fcb6a8f656a8ebeb172023e71c1ec
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-dwh
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <[email protected]>
Gerrit-Reviewer: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches