-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
268 additions
and
759 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
*.swp | ||
*~ | ||
/setup.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
CREATE OR REPLACE FUNCTION v2.translate_array(source CHAR(2), target CHAR(2), q JSON) | ||
RETURNS TEXT[] AS $BODY$ | ||
DECLARE | ||
rez TEXT[]; | ||
BEGIN | ||
SELECT | ||
CASE current_setting('translation_proxy.api.current_engine') | ||
WHEN 'google' THEN | ||
translation_proxy.google_translate_array( source, target, q ) | ||
WHEN 'promt' THEN | ||
translation_proxy.promt_translate_array( source, target, array_agg( json_array_elements_text(q) ) ) | ||
END INTO rez; | ||
RETURN rez; | ||
END; | ||
$BODY$ LANGUAGE PLPGSQL SECURITY DEFINER; | ||
create schema if not exists v1; | ||
do | ||
$$ | ||
begin | ||
if not exists ( | ||
select * | ||
from pg_catalog.pg_user | ||
where usename = 'apiuser' | ||
) then | ||
create role my_user password 'SOMEPASSWORD' login; | ||
end if; | ||
end | ||
$$; | ||
|
||
GRANT EXECUTE ON FUNCTION v2.translate_array(CHAR(2), CHAR(2), JSON) TO apiuser; | ||
grant usage on schema v1 to apiuser; | ||
|
||
create or replace function v1.google_translate_array(source char(2), target char(2), q json) returns text[] as $$ | ||
select * from google_translate.translate_array(source, target, q); | ||
$$ language sql security definer; | ||
|
||
create or replace function v1.google_translate(source char(2), target char(2), q text) returns text as $$ | ||
select * from google_translate.translate(source, target, q); | ||
$$ language sql security definer; | ||
|
||
grant execute on function v1.google_translate_array(char, char, json) to apiuser; | ||
grant execute on function v1.google_translate(char, char, text) to apiuser; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.