Gilad Chaplik has uploaded a new change for review.

Change subject: core: storage element missing DC id for search
......................................................................

core: storage element missing DC id for search

In patch 34784, data center uuid for search was removed.
This fix returns it when there's only one.

Change-Id: I2277ab4ab3a27cf81881ac2ec922bb0c3483ea19
Bug-Url: https://bugzilla.redhat.com/1166182
Signed-off-by: Gilad Chaplik <gchap...@redhat.com>
---
M packaging/dbscripts/common_sp.sql
M packaging/dbscripts/create_views.sql
2 files changed, 13 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/52/35452/1

diff --git a/packaging/dbscripts/common_sp.sql 
b/packaging/dbscripts/common_sp.sql
index 178c57b..d7eb22f 100644
--- a/packaging/dbscripts/common_sp.sql
+++ b/packaging/dbscripts/common_sp.sql
@@ -619,3 +619,13 @@
 LANGUAGE plpgsql;
 
 
+-- First aggregate function, reutrns the first not null element.
+CREATE OR REPLACE FUNCTION public.first_agg ( anyelement, anyelement )
+RETURNS anyelement LANGUAGE sql IMMUTABLE STRICT AS $$
+        SELECT $1;
+$$;
+CREATE AGGREGATE public.first (
+        sfunc    = public.first_agg,
+        basetype = anyelement,
+        stype    = anyelement
+);
diff --git a/packaging/dbscripts/create_views.sql 
b/packaging/dbscripts/create_views.sql
index 24c9a11..5e62780 100644
--- a/packaging/dbscripts/create_views.sql
+++ b/packaging/dbscripts/create_views.sql
@@ -355,7 +355,7 @@
                           WHEN status_table.is_multi_domain THEN NULL
                           WHEN status_table.status IS NULL THEN 2 -- in case 
domain is unattached
                           ELSE status_table.status END as status,
-                null::uuid as storage_pool_id,
+                status_table.storage_pool_id as storage_pool_id,
                 status_table.pool_names AS storage_pool_name,
                 storage_domain_dynamic.available_disk_size as 
available_disk_size,
                 storage_domain_dynamic.used_disk_size as used_disk_size,
@@ -372,7 +372,8 @@
                 (SELECT storage_id,
                         count(storage_id) > 1 AS is_multi_domain,
                         max(storage_pool_iso_map.status) AS status,
-                        array_to_string(array_agg(storage_pool.name), ',') AS 
pool_names
+                        array_to_string(array_agg(storage_pool.name), ',') AS 
pool_names,
+                        CASE WHEN count(storage_pool.id) = 1 THEN 
first(storage_pool.id) ELSE NULL END as storage_pool_id
                  FROM storage_pool_iso_map
                  JOIN storage_pool ON storage_pool_iso_map.storage_pool_id = 
storage_pool.id
                  GROUP BY storage_id) AS status_table ON 
storage_domain_static.id=status_table.storage_id


-- 
To view, visit http://gerrit.ovirt.org/35452
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2277ab4ab3a27cf81881ac2ec922bb0c3483ea19
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to