diff --git a/scripts-available/CDB_UserDomain.sql b/scripts-available/CDB_UserDomain.sql new file mode 100644 index 0000000..6bc154d --- /dev/null +++ b/scripts-available/CDB_UserDomain.sql @@ -0,0 +1,18 @@ +-- Function that setups user's domain, port and http/https inside his own DB. +-- Used for HTTP table sync functions. +CREATE OR REPLACE FUNCTION CDB_SetUserDomain(domain text, port int8, secure boolean) +RETURNS VOID AS +$$ +DECLARE + sql TEXT; +BEGIN + sql := 'CREATE OR REPLACE FUNCTION public._CDB_UserDomain() ' + || ' RETURNS TABLE (domain text, port int8, secure boolean) ' + || ' AS $X$ ' + || ' SELECT ''' || domain || '''::text, ' || port || '::int8, ' || secure || '::boolean ' + || ' $X$ LANGUAGE sql IMMUTABLE'; + EXECUTE sql; + RETURN; +END +$$ +LANGUAGE 'plpgsql' VOLATILE STRICT; \ No newline at end of file diff --git a/scripts-enabled/210-CDB_UserDomain.sql b/scripts-enabled/210-CDB_UserDomain.sql new file mode 120000 index 0000000..4027cd5 --- /dev/null +++ b/scripts-enabled/210-CDB_UserDomain.sql @@ -0,0 +1 @@ +../scripts-available/CDB_UserDomain.sql \ No newline at end of file