Yair Zaslavsky has uploaded a new change for review. Change subject: core: Adding fnSplitterMap function ......................................................................
core: Adding fnSplitterMap function This function accepts as argument a command delimited string that each of its parts is a key value pair (key=value) For example: select fnSplitterMap('123=VM,456=Storage'); Change-Id: I802ef2e0d90ff1c23646d7e1edbe3aa0bff62d2f Signed-off-by: Yair Zaslavsky <yzasl...@redhat.com> --- M backend/manager/dbscripts/create_functions.sql 1 file changed, 19 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/13/14913/1 diff --git a/backend/manager/dbscripts/create_functions.sql b/backend/manager/dbscripts/create_functions.sql index 06c74d5..3c1b13f 100644 --- a/backend/manager/dbscripts/create_functions.sql +++ b/backend/manager/dbscripts/create_functions.sql @@ -40,6 +40,25 @@ LANGUAGE plpgsql; +DROP TYPE IF EXISTS mapEntryType CASCADE; +CREATE TYPE mapEntryType AS(map_key text, map_value text); + + +CREATE OR REPLACE FUNCTION public.fnSplitterMap(mapText TEXT) +RETURNS SETOF mapEntryType + AS $function$ +BEGIN +-- Checks if mapText contains a valid map string. A valid map string is a string that is comma delimited and +-- that each of the parts is in the format of key=value + IF mapText != '' AND mapText ~ '([[:alnum:]])+(=)+([[:alnum:]])+(,([[:alnum:]])+(=)+([[:alnum:]]))*' THEN + RETURN QUERY + SELECT substr(splitted,1,position('=' in splitted)-1) as map_key,substr(splitted,position('=' in splitted)+1) as map_value FROM + (SELECT regexp_split_to_table(mapText, ',') as splitted) as subquery; + END IF; +END; $function$ +LANGUAGE plpgsql; + + CREATE OR REPLACE FUNCTION fnSplitterUuid(ids TEXT) RETURNS SETOF UUID AS $function$ BEGIN -- To view, visit http://gerrit.ovirt.org/14913 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I802ef2e0d90ff1c23646d7e1edbe3aa0bff62d2f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yair Zaslavsky <yzasl...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches