0

我创建了一个函数,如下所示:

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

我在这里做错了什么。

4

0 回答 0