Eli Mesika has uploaded a new change for review.

Change subject: Adding support for user types cleanup
......................................................................

Adding support for user types cleanup

The following patch adds support for user-types cleanup in the database.
Call had been added as well to the cleandb function.

Change-Id: I1a7d5a644895be7374febec081e4931be1902962
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1034201
Signed-off-by: Eli Mesika <[email protected]>
---
M packaging/dbscripts/common_sp.sql
M packaging/dbscripts/dbfunctions.sh
M packaging/setup/ovirt_engine_setup/database.py
3 files changed, 23 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/94/21894/1

diff --git a/packaging/dbscripts/common_sp.sql 
b/packaging/dbscripts/common_sp.sql
index 63df62d..41f99dc 100644
--- a/packaging/dbscripts/common_sp.sql
+++ b/packaging/dbscripts/common_sp.sql
@@ -282,6 +282,14 @@
 END; $procedure$
 LANGUAGE plpgsql;
 
+Create or replace FUNCTION generate_drop_all_user_types_syntax() RETURNS SETOF 
text STABLE
+   AS $procedure$
+BEGIN
+RETURN QUERY select 'DROP TYPE if exists ' || user_defined_type_name || ' 
CASCADE;' from information_schema.user_defined_types where 
user_defined_type_schema = 'public' order by user_defined_type_name;
+END; $procedure$
+LANGUAGE plpgsql;
+
+
 Create or replace FUNCTION fn_get_column_size( v_table varchar(64), v_column 
varchar(64)) returns integer STABLE
    AS $procedure$
    declare
diff --git a/packaging/dbscripts/dbfunctions.sh 
b/packaging/dbscripts/dbfunctions.sh
index 2a470e5..b4c1da9 100755
--- a/packaging/dbscripts/dbfunctions.sh
+++ b/packaging/dbscripts/dbfunctions.sh
@@ -81,6 +81,8 @@
     execute_command "$CMD" ${DATABASE} ${SERVERNAME} ${PORT} >> $file
     CMD="select * from generate_drop_all_functions_syntax();"
     execute_command "$CMD"  ${DATABASE} ${SERVERNAME} ${PORT} >> $file
+    CMD="select * from generate_drop_all_user_types_syntax();"
+    execute_command "$CMD"  ${DATABASE} ${SERVERNAME} ${PORT} >> $file
     execute_file "${file}" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null
 }
 
diff --git a/packaging/setup/ovirt_engine_setup/database.py 
b/packaging/setup/ovirt_engine_setup/database.py
index 76999b3..156980a 100644
--- a/packaging/setup/ovirt_engine_setup/database.py
+++ b/packaging/setup/ovirt_engine_setup/database.py
@@ -341,7 +341,7 @@
             statement="""
                 create or replace
                 function
-                    generate_drop_all_functions_syntax()
+                    oesetup_generate_drop_all_syntax()
                     returns setof text
                 AS $procedure$ begin
                     return query
@@ -358,9 +358,16 @@
                                 pg_proc.pronamespace=ns.oid
                             )
                         where
-                            ns.nspname = 'public' and
-                            proname not ilike 'uuid%%'
-                        order by proname;
+                            ns.nspname = 'public'
+                        union
+                        select
+                            'drop type if exists ' ||
+                            user_defined_type_name || ' ' ||
+                            'cascade;'
+                        from
+                            information_schema.user_defined_types
+                        where
+                            user_defined_type_schema = 'public';
                 end; $procedure$
                 language plpgsql;
             """,
@@ -371,8 +378,8 @@
 
         spdrops = statement.execute(
             statement="""
-                select generate_drop_all_functions_syntax as drop
-                from generate_drop_all_functions_syntax()
+                select oesetup_generate_drop_all_syntax as drop
+                from oesetup_generate_drop_all_syntax()
             """,
             ownConnection=True,
             transaction=False,


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

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

Reply via email to