Add postgresql function for access to pickle tags array and aggregate it.

remotes/origin/enhancement/email-actions
Andrey Antukh 2013-11-08 08:36:53 +01:00
parent fe540f41d2
commit 00ccbefbc7
1 changed files with 24 additions and 0 deletions

24
sql/tags.sql Normal file
View File

@ -0,0 +1,24 @@
CREATE OR REPLACE FUNCTION unpickle (data text)
RETURNS text[]
AS $$
import base64
import pickle
return pickle.loads(base64.b64decode(data))
$$ LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION array_uniq_join (data text[], data2 text[])
RETURNS text[]
AS $$
tmp = set(data)
tmp.update(data2)
return tuple(tmp)
$$ LANGUAGE plpythonu;
DROP AGGREGATE array_uniq_concat (text[]);
CREATE AGGREGATE array_uniq_concat (text[])
(
sfunc = array_uniq_join,
stype = text[],
initcond = '{}'
);