Simone Tiraboschi has uploaded a new change for review.

Change subject: packaging: setup: creating fn_db_unlock_all before executing
......................................................................

packaging: setup: creating fn_db_unlock_all before executing

fn_db_unlock_all stored procedure was not available on 3.5
Creating it before executing to unlock every entity also
upgrading from 3.5.z to 3.6

Change-Id: I3d43e5d27654916aa440a2405c6f4474e49c9590
Bug-Url: https://bugzilla.redhat.com/1204673
Signed-off-by: Simone Tiraboschi <[email protected]>
---
M packaging/setup/dbutils/unlock_entity.sh
A packaging/setup/dbutils/unlock_entity.sql
2 files changed, 35 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/81/40081/1

diff --git a/packaging/setup/dbutils/unlock_entity.sh 
b/packaging/setup/dbutils/unlock_entity.sh
index 1af604e..483f61c 100755
--- a/packaging/setup/dbutils/unlock_entity.sh
+++ b/packaging/setup/dbutils/unlock_entity.sh
@@ -212,6 +212,10 @@
     [ -n "${IDS}" -a -n "${QUERY}" ] && die "Please specify one ids or query"
 fi
 
+# Install fn_db_unlock_all procedure
+dbfunc_psql_die --file="$(dirname "$0")/unlock_entity.sql" > /dev/null
+
+# Execute
 if [ -n "${QUERY}" ]; then
        entity_query "${TYPE}"
 else
diff --git a/packaging/setup/dbutils/unlock_entity.sql 
b/packaging/setup/dbutils/unlock_entity.sql
new file mode 100644
index 0000000..4ad1ba7
--- /dev/null
+++ b/packaging/setup/dbutils/unlock_entity.sql
@@ -0,0 +1,31 @@
+/************************************************************************************************
+ The following are helper SP for unlock_entity.sh utility and are not exposed 
to the application DAOs
+************************************************************************************************/
+-- Unlocks all locked entities
+create or replace FUNCTION fn_db_unlock_all()
+returns void
+AS $procedure$
+declare
+    DOWN integer;
+    OK integer;
+    LOCKED integer;
+    TEMPLATE_OK integer;
+    TEMPLATE_LOCKED integer;
+    IMAGE_LOCKED integer;
+    SNAPSHOT_OK varchar;
+    SNAPSHOT_LOCKED varchar;
+BEGIN
+    DOWN:=0;
+    OK:=1;
+    LOCKED:=2;
+    TEMPLATE_OK:=0;
+    TEMPLATE_LOCKED:=1;
+    IMAGE_LOCKED:=15;
+    SNAPSHOT_OK:='OK';
+    SNAPSHOT_LOCKED:='LOCKED';
+    update vm_static set template_status = TEMPLATE_OK where template_status = 
TEMPLATE_LOCKED;
+    update vm_dynamic set status = DOWN where status = IMAGE_LOCKED;
+    update images set imagestatus = OK where imagestatus = LOCKED;
+    update snapshots set status = SNAPSHOT_OK where status ilike 
SNAPSHOT_LOCKED;
+END; $procedure$
+LANGUAGE plpgsql;


-- 
To view, visit https://gerrit.ovirt.org/40081
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d43e5d27654916aa440a2405c6f4474e49c9590
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Simone Tiraboschi <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to