Index: database.sql ================================================================== --- database.sql +++ database.sql @@ -36,18 +36,18 @@ as $$ select get_site(tripdomain($1)) as result; $$; -- this function adds tag to domain -CREATE or replace FUNCTION mark(domain text, new_tag text) RETURNS void +CREATE or replace FUNCTION mark(domain text, new_tag text) RETURNS integer LANGUAGE sql immutable STRICT AS $$ select mark(get_site($1), $2) as result; $$; -- this function adds tag to site by site id -CREATE or replace FUNCTION mark(my_id_site integer, new_tag text) RETURNS void +CREATE or replace FUNCTION mark(my_id_site integer, new_tag text) RETURNS integer LANGUAGE plpgsql STRICT AS $$ declare -- maybe check should be added to make sure supplied site id really exists my_tag text[]; @@ -63,10 +63,11 @@ -- joining tags select usort(my_tag || array[new_tag]) into my_tag; -- updating existing record update urls set id_tag = get_tag(my_tag || array[new_tag]) where id_site = my_id_site; end if; + return my_id_site; end; $$; -- this function returns id of tag array create or replace function get_tag(my_tag text[]) returns integer