Yair Zaslavsky has uploaded a new change for review. Change subject: engine: Adding a helper function to check if table exists ......................................................................
engine: Adding a helper function to check if table exists Bug-Url: https://bugzilla.redhat.com/1161012 Change-Id: I9421526de442640cf985cb0302f7fa3d6daa909a Signed-off-by: Yair Zaslavsky <yzasl...@redhat.com> --- M packaging/dbscripts/common_sp.sql 1 file changed, 14 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/37846/1 diff --git a/packaging/dbscripts/common_sp.sql b/packaging/dbscripts/common_sp.sql index 18951ac..8ba08d6 100644 --- a/packaging/dbscripts/common_sp.sql +++ b/packaging/dbscripts/common_sp.sql @@ -421,6 +421,20 @@ END; $procedure$ LANGUAGE plpgsql; +-- Checks if a table given by its name exists in DB +CREATE OR REPLACE FUNCTION fn_db_is_table_exists (v_table varchar(64)) returns boolean STABLE + AS $procedure$ + declare + retvalue boolean; +BEGIN + retvalue := EXISTS ( + SELECT * FROM information_schema.tables WHERE table_schema = 'public' AND table_name ILIKE v_table + ); + return retvalue; +END; $procedure$ +LANGUAGE plpgsql; + + -- Creates an index on an existing table, if there is no WHERE condition, the last argument should be empty ('') -- Example : Table T with columns a,b and c -- fn_db_create_index('T_INDEX', 'T', 'a,b', ''); ==> Creates an index named T_INDEX on table T (a,b) -- To view, visit http://gerrit.ovirt.org/37846 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9421526de442640cf985cb0302f7fa3d6daa909a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Yair Zaslavsky <yzasl...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches