我有一个如下创建的函数:
CREATE LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION unpickle (data text)
RETURNS text[]
AS $$
import base64
import pickle
return pickle.loads(base64.b64decode(data))
$$ LANGUAGE plpythonu IMMUTABLE;
CREATE INDEX issues_unpickle_tags_index ON issue USING btree (unpickle(tags));
创建索引时出现错误 - ERROR: function unpickle(text[]) does not exist.
表的结构如下:
CREATE TABLE "issue" (
"id" int4 DEFAULT nextval('issue_id_seq'::regclass) NOT NULL,
"tags" text[] COLLATE "default",
"description" text COLLATE "default" NOT NULL
)
我尝试将第一部分更改为
CREATE OR REPLACE FUNCTION unpickle (data text[])
RETURNS text[]
然后得到错误 - ERROR: TypeError: must be string or buffer, not list
我在这里做错了什么。